-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathrange-datepicker-behavior.js
61 lines (53 loc) · 1.38 KB
/
range-datepicker-behavior.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import format from 'date-fns/esm/format';
// import en from 'date-fns/esm/locale/en';
//
// const locales = { en, fr };
/**
* `range-datepicker-behavior`
*
*/
/* eslint no-unused-vars: off */
/* @polymerMixin */
export default subclass => class extends subclass {
_localeChanged(locale) {
if (!this.month) {
this.month = format(new Date(), 'MM', { awareOfUnicodeTokens: true });
}
if (!this.year) {
this.year = format(new Date(), 'yyyy');
}
}
_handlePrevMonth() {
if (!this.enableYearChange) {
this.shadowRoot.querySelector('range-datepicker-calendar[next]')._handlePrevMonth();
}
}
_handleNextMonth() {
if (!this.enableYearChange) {
this.shadowRoot.querySelector('range-datepicker-calendar[prev]')._handleNextMonth();
}
}
_monthChanged(month, year) {
if (year && month) {
const monthPlus = `0${((month % 12) + 1)}`;
this._monthPlus = monthPlus.substring(monthPlus.length - 2);
if (this._monthPlus === '01') {
this._yearPlus = parseInt(year, 10) + 1;
} else {
this._yearPlus = parseInt(year, 10);
}
}
}
_isNarrow(forceNarrow, narrow) {
if (forceNarrow || narrow) {
return true;
}
return false;
}
_noRangeChanged(isNoRange, wasNoRange) {
if (!wasNoRange && isNoRange) {
this.dateTo = undefined;
this._hoveredDate = undefined;
}
}
};