@vaadin/date-picker 23.1.0-alpha3 → 23.1.0-beta2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +12 -12
- package/src/vaadin-date-picker-helper.js +3 -3
- package/src/vaadin-date-picker-light.d.ts +2 -2
- package/src/vaadin-date-picker-light.js +3 -3
- package/src/vaadin-date-picker-mixin.d.ts +7 -4
- package/src/vaadin-date-picker-mixin.js +41 -34
- package/src/vaadin-date-picker-overlay-content.js +62 -49
- package/src/vaadin-date-picker-overlay.js +1 -1
- package/src/vaadin-date-picker.d.ts +2 -2
- package/src/vaadin-date-picker.js +3 -2
- package/src/vaadin-infinite-scroller.js +16 -16
- package/src/vaadin-month-calendar.js +31 -42
- package/theme/lumo/vaadin-date-picker-overlay-content-styles.js +1 -1
- package/theme/lumo/vaadin-date-picker-overlay-styles.js +1 -1
- package/theme/lumo/vaadin-month-calendar-styles.js +6 -1
- package/theme/material/vaadin-date-picker-overlay-content-styles.js +1 -1
- package/theme/material/vaadin-date-picker-overlay-styles.js +1 -1
- package/theme/material/vaadin-month-calendar-styles.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/date-picker",
|
|
3
|
-
"version": "23.1.0-
|
|
3
|
+
"version": "23.1.0-beta2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -34,21 +34,21 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
36
36
|
"@polymer/polymer": "^3.2.0",
|
|
37
|
-
"@vaadin/button": "23.1.0-
|
|
38
|
-
"@vaadin/component-base": "23.1.0-
|
|
39
|
-
"@vaadin/field-base": "23.1.0-
|
|
40
|
-
"@vaadin/input-container": "23.1.0-
|
|
41
|
-
"@vaadin/vaadin-lumo-styles": "23.1.0-
|
|
42
|
-
"@vaadin/vaadin-material-styles": "23.1.0-
|
|
43
|
-
"@vaadin/vaadin-overlay": "23.1.0-
|
|
44
|
-
"@vaadin/vaadin-themable-mixin": "23.1.0-
|
|
37
|
+
"@vaadin/button": "23.1.0-beta2",
|
|
38
|
+
"@vaadin/component-base": "23.1.0-beta2",
|
|
39
|
+
"@vaadin/field-base": "23.1.0-beta2",
|
|
40
|
+
"@vaadin/input-container": "23.1.0-beta2",
|
|
41
|
+
"@vaadin/vaadin-lumo-styles": "23.1.0-beta2",
|
|
42
|
+
"@vaadin/vaadin-material-styles": "23.1.0-beta2",
|
|
43
|
+
"@vaadin/vaadin-overlay": "23.1.0-beta2",
|
|
44
|
+
"@vaadin/vaadin-themable-mixin": "23.1.0-beta2"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@esm-bundle/chai": "^4.3.4",
|
|
48
|
-
"@vaadin/dialog": "23.1.0-
|
|
49
|
-
"@vaadin/polymer-legacy-adapter": "23.1.0-
|
|
48
|
+
"@vaadin/dialog": "23.1.0-beta2",
|
|
49
|
+
"@vaadin/polymer-legacy-adapter": "23.1.0-beta2",
|
|
50
50
|
"@vaadin/testing-helpers": "^0.3.2",
|
|
51
51
|
"sinon": "^13.0.2"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "f11f9245a0b5e6bf912725a501c27c24b74e7c8d"
|
|
54
54
|
}
|
|
@@ -84,8 +84,8 @@ export function getClosestDate(date, dates) {
|
|
|
84
84
|
return candidate;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
const candidateDiff = Math.abs(date.getTime() - candidate.getTime());
|
|
88
|
+
const closestDateDiff = Math.abs(closestDate.getTime() - date.getTime());
|
|
89
89
|
return candidateDiff < closestDateDiff ? candidate : closestDate;
|
|
90
90
|
});
|
|
91
91
|
}
|
|
@@ -100,6 +100,6 @@ export function extractDateParts(date) {
|
|
|
100
100
|
return {
|
|
101
101
|
day: date.getDate(),
|
|
102
102
|
month: date.getMonth(),
|
|
103
|
-
year: date.getFullYear()
|
|
103
|
+
year: date.getFullYear(),
|
|
104
104
|
};
|
|
105
105
|
}
|
|
@@ -90,13 +90,13 @@ declare class DatePickerLight extends ThemableMixin(DatePickerMixin(HTMLElement)
|
|
|
90
90
|
addEventListener<K extends keyof DatePickerLightEventMap>(
|
|
91
91
|
type: K,
|
|
92
92
|
listener: (this: DatePickerLight, ev: DatePickerLightEventMap[K]) => void,
|
|
93
|
-
options?: boolean | AddEventListenerOptions
|
|
93
|
+
options?: boolean | AddEventListenerOptions,
|
|
94
94
|
): void;
|
|
95
95
|
|
|
96
96
|
removeEventListener<K extends keyof DatePickerLightEventMap>(
|
|
97
97
|
type: K,
|
|
98
98
|
listener: (this: DatePickerLight, ev: DatePickerLightEventMap[K]) => void,
|
|
99
|
-
options?: boolean | EventListenerOptions
|
|
99
|
+
options?: boolean | EventListenerOptions,
|
|
100
100
|
): void;
|
|
101
101
|
}
|
|
102
102
|
|
|
@@ -114,7 +114,7 @@ class DatePickerLight extends ThemableMixin(DatePickerMixin(PolymerElement)) {
|
|
|
114
114
|
*/
|
|
115
115
|
attrForValue: {
|
|
116
116
|
type: String,
|
|
117
|
-
value: 'value'
|
|
117
|
+
value: 'value',
|
|
118
118
|
},
|
|
119
119
|
|
|
120
120
|
/**
|
|
@@ -123,8 +123,8 @@ class DatePickerLight extends ThemableMixin(DatePickerMixin(PolymerElement)) {
|
|
|
123
123
|
*/
|
|
124
124
|
_overlayInitialized: {
|
|
125
125
|
type: Boolean,
|
|
126
|
-
value: true
|
|
127
|
-
}
|
|
126
|
+
value: true,
|
|
127
|
+
},
|
|
128
128
|
};
|
|
129
129
|
}
|
|
130
130
|
|
|
@@ -26,13 +26,13 @@ export interface DatePickerI18n {
|
|
|
26
26
|
clear: string;
|
|
27
27
|
today: string;
|
|
28
28
|
cancel: string;
|
|
29
|
-
parseDate
|
|
30
|
-
formatDate
|
|
31
|
-
formatTitle
|
|
29
|
+
parseDate(date: string): DatePickerDate | undefined;
|
|
30
|
+
formatDate(date: DatePickerDate): string;
|
|
31
|
+
formatTitle(monthName: string, fullYear: number): string;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
export declare function DatePickerMixin<T extends Constructor<HTMLElement>>(
|
|
35
|
-
base: T
|
|
35
|
+
base: T,
|
|
36
36
|
): T &
|
|
37
37
|
Constructor<DatePickerMixinClass> &
|
|
38
38
|
Constructor<DelegateFocusMixinClass> &
|
|
@@ -55,6 +55,7 @@ export declare class DatePickerMixinClass {
|
|
|
55
55
|
* Date which should be visible when there is no value selected.
|
|
56
56
|
*
|
|
57
57
|
* The same date formats as for the `value` property are supported.
|
|
58
|
+
* @attr {string} initial-position
|
|
58
59
|
*/
|
|
59
60
|
initialPosition: string | null | undefined;
|
|
60
61
|
|
|
@@ -65,6 +66,7 @@ export declare class DatePickerMixinClass {
|
|
|
65
66
|
|
|
66
67
|
/**
|
|
67
68
|
* Set true to prevent the overlay from opening automatically.
|
|
69
|
+
* @attr {boolean} auto-open-disabled
|
|
68
70
|
*/
|
|
69
71
|
autoOpenDisabled: boolean | null | undefined;
|
|
70
72
|
|
|
@@ -72,6 +74,7 @@ export declare class DatePickerMixinClass {
|
|
|
72
74
|
* Set true to display ISO-8601 week numbers in the calendar. Notice that
|
|
73
75
|
* displaying week numbers is only supported when `i18n.firstDayOfWeek`
|
|
74
76
|
* is 1 (Monday).
|
|
77
|
+
* @attr {boolean} show-week-numbers
|
|
75
78
|
*/
|
|
76
79
|
showWeekNumbers: boolean | null | undefined;
|
|
77
80
|
|
|
@@ -26,7 +26,7 @@ export const DatePickerMixin = (subclass) =>
|
|
|
26
26
|
* @protected
|
|
27
27
|
*/
|
|
28
28
|
_selectedDate: {
|
|
29
|
-
type: Date
|
|
29
|
+
type: Date,
|
|
30
30
|
},
|
|
31
31
|
|
|
32
32
|
/**
|
|
@@ -48,7 +48,7 @@ export const DatePickerMixin = (subclass) =>
|
|
|
48
48
|
type: String,
|
|
49
49
|
observer: '_valueChanged',
|
|
50
50
|
notify: true,
|
|
51
|
-
value: ''
|
|
51
|
+
value: '',
|
|
52
52
|
},
|
|
53
53
|
|
|
54
54
|
/**
|
|
@@ -66,7 +66,7 @@ export const DatePickerMixin = (subclass) =>
|
|
|
66
66
|
type: Boolean,
|
|
67
67
|
reflectToAttribute: true,
|
|
68
68
|
notify: true,
|
|
69
|
-
observer: '_openedChanged'
|
|
69
|
+
observer: '_openedChanged',
|
|
70
70
|
},
|
|
71
71
|
|
|
72
72
|
/**
|
|
@@ -82,7 +82,7 @@ export const DatePickerMixin = (subclass) =>
|
|
|
82
82
|
* @attr {boolean} show-week-numbers
|
|
83
83
|
*/
|
|
84
84
|
showWeekNumbers: {
|
|
85
|
-
type: Boolean
|
|
85
|
+
type: Boolean,
|
|
86
86
|
},
|
|
87
87
|
|
|
88
88
|
/**
|
|
@@ -91,7 +91,7 @@ export const DatePickerMixin = (subclass) =>
|
|
|
91
91
|
*/
|
|
92
92
|
_fullscreen: {
|
|
93
93
|
type: Boolean,
|
|
94
|
-
value: false
|
|
94
|
+
value: false,
|
|
95
95
|
},
|
|
96
96
|
|
|
97
97
|
/**
|
|
@@ -99,7 +99,7 @@ export const DatePickerMixin = (subclass) =>
|
|
|
99
99
|
* @protected
|
|
100
100
|
*/
|
|
101
101
|
_fullscreenMediaQuery: {
|
|
102
|
-
value: '(max-width: 420px), (max-height: 420px)'
|
|
102
|
+
value: '(max-width: 420px), (max-height: 420px)',
|
|
103
103
|
},
|
|
104
104
|
|
|
105
105
|
/**
|
|
@@ -208,7 +208,7 @@ export const DatePickerMixin = (subclass) =>
|
|
|
208
208
|
'September',
|
|
209
209
|
'October',
|
|
210
210
|
'November',
|
|
211
|
-
'December'
|
|
211
|
+
'December',
|
|
212
212
|
],
|
|
213
213
|
weekdays: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
|
|
214
214
|
weekdaysShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
|
|
@@ -247,10 +247,10 @@ export const DatePickerMixin = (subclass) =>
|
|
|
247
247
|
}
|
|
248
248
|
},
|
|
249
249
|
formatTitle: (monthName, fullYear) => {
|
|
250
|
-
return monthName
|
|
251
|
-
}
|
|
250
|
+
return `${monthName} ${fullYear}`;
|
|
251
|
+
},
|
|
252
252
|
};
|
|
253
|
-
}
|
|
253
|
+
},
|
|
254
254
|
},
|
|
255
255
|
|
|
256
256
|
/**
|
|
@@ -264,7 +264,7 @@ export const DatePickerMixin = (subclass) =>
|
|
|
264
264
|
*/
|
|
265
265
|
min: {
|
|
266
266
|
type: String,
|
|
267
|
-
observer: '_minChanged'
|
|
267
|
+
observer: '_minChanged',
|
|
268
268
|
},
|
|
269
269
|
|
|
270
270
|
/**
|
|
@@ -278,7 +278,7 @@ export const DatePickerMixin = (subclass) =>
|
|
|
278
278
|
*/
|
|
279
279
|
max: {
|
|
280
280
|
type: String,
|
|
281
|
-
observer: '_maxChanged'
|
|
281
|
+
observer: '_maxChanged',
|
|
282
282
|
},
|
|
283
283
|
|
|
284
284
|
/**
|
|
@@ -288,8 +288,8 @@ export const DatePickerMixin = (subclass) =>
|
|
|
288
288
|
*/
|
|
289
289
|
_minDate: {
|
|
290
290
|
type: Date,
|
|
291
|
-
//
|
|
292
|
-
value: ''
|
|
291
|
+
// Null does not work here because minimizer passes undefined to overlay (#351)
|
|
292
|
+
value: '',
|
|
293
293
|
},
|
|
294
294
|
|
|
295
295
|
/**
|
|
@@ -299,39 +299,39 @@ export const DatePickerMixin = (subclass) =>
|
|
|
299
299
|
*/
|
|
300
300
|
_maxDate: {
|
|
301
301
|
type: Date,
|
|
302
|
-
value: ''
|
|
302
|
+
value: '',
|
|
303
303
|
},
|
|
304
304
|
|
|
305
305
|
/** @private */
|
|
306
306
|
_noInput: {
|
|
307
307
|
type: Boolean,
|
|
308
|
-
computed: '_isNoInput(inputElement, _fullscreen, _ios, i18n, opened, autoOpenDisabled)'
|
|
308
|
+
computed: '_isNoInput(inputElement, _fullscreen, _ios, i18n, opened, autoOpenDisabled)',
|
|
309
309
|
},
|
|
310
310
|
|
|
311
311
|
/** @private */
|
|
312
312
|
_ios: {
|
|
313
313
|
type: Boolean,
|
|
314
|
-
value: isIOS
|
|
314
|
+
value: isIOS,
|
|
315
315
|
},
|
|
316
316
|
|
|
317
317
|
/** @private */
|
|
318
318
|
_webkitOverflowScroll: {
|
|
319
319
|
type: Boolean,
|
|
320
|
-
value: document.createElement('div').style.webkitOverflowScrolling === ''
|
|
320
|
+
value: document.createElement('div').style.webkitOverflowScrolling === '',
|
|
321
321
|
},
|
|
322
322
|
|
|
323
323
|
/** @private */
|
|
324
324
|
_focusOverlayOnOpen: Boolean,
|
|
325
325
|
|
|
326
326
|
/** @protected */
|
|
327
|
-
_overlayInitialized: Boolean
|
|
327
|
+
_overlayInitialized: Boolean,
|
|
328
328
|
};
|
|
329
329
|
}
|
|
330
330
|
|
|
331
331
|
static get observers() {
|
|
332
332
|
return [
|
|
333
333
|
'_selectedDateChanged(_selectedDate, i18n.formatDate)',
|
|
334
|
-
'_focusedDateChanged(_focusedDate, i18n.formatDate)'
|
|
334
|
+
'_focusedDateChanged(_focusedDate, i18n.formatDate)',
|
|
335
335
|
];
|
|
336
336
|
}
|
|
337
337
|
|
|
@@ -380,7 +380,9 @@ export const DatePickerMixin = (subclass) =>
|
|
|
380
380
|
_onFocus(event) {
|
|
381
381
|
super._onFocus(event);
|
|
382
382
|
|
|
383
|
-
this._noInput
|
|
383
|
+
if (this._noInput) {
|
|
384
|
+
event.target.blur();
|
|
385
|
+
}
|
|
384
386
|
}
|
|
385
387
|
|
|
386
388
|
/**
|
|
@@ -421,7 +423,7 @@ export const DatePickerMixin = (subclass) =>
|
|
|
421
423
|
this.addController(
|
|
422
424
|
new MediaQueryController(this._fullscreenMediaQuery, (matches) => {
|
|
423
425
|
this._fullscreen = matches;
|
|
424
|
-
})
|
|
426
|
+
}),
|
|
425
427
|
);
|
|
426
428
|
|
|
427
429
|
this.addController(new VirtualKeyboardController(this));
|
|
@@ -533,7 +535,7 @@ export const DatePickerMixin = (subclass) =>
|
|
|
533
535
|
if (this.inputElement.checkValidity) {
|
|
534
536
|
inputValidity = this.inputElement.checkValidity();
|
|
535
537
|
} else if (this.inputElement.validate) {
|
|
536
|
-
//
|
|
538
|
+
// Iron-form-elements have the validate API
|
|
537
539
|
inputValidity = this.inputElement.validate();
|
|
538
540
|
}
|
|
539
541
|
}
|
|
@@ -662,7 +664,9 @@ export const DatePickerMixin = (subclass) =>
|
|
|
662
664
|
}
|
|
663
665
|
const value = this._formatISO(selectedDate);
|
|
664
666
|
|
|
665
|
-
this.__keepInputValue
|
|
667
|
+
if (!this.__keepInputValue) {
|
|
668
|
+
this._applyInputValue(selectedDate);
|
|
669
|
+
}
|
|
666
670
|
|
|
667
671
|
if (value !== this.value) {
|
|
668
672
|
this.validate();
|
|
@@ -704,7 +708,9 @@ export const DatePickerMixin = (subclass) =>
|
|
|
704
708
|
}
|
|
705
709
|
if (!dateEquals(this[property], date)) {
|
|
706
710
|
this[property] = date;
|
|
707
|
-
this.value
|
|
711
|
+
if (this.value) {
|
|
712
|
+
this.validate();
|
|
713
|
+
}
|
|
708
714
|
}
|
|
709
715
|
}
|
|
710
716
|
|
|
@@ -774,8 +780,8 @@ export const DatePickerMixin = (subclass) =>
|
|
|
774
780
|
const oldInlineValue = element.style.webkitOverflowScrolling;
|
|
775
781
|
element.style.webkitOverflowScrolling = 'auto';
|
|
776
782
|
result.push({
|
|
777
|
-
element
|
|
778
|
-
oldInlineValue
|
|
783
|
+
element,
|
|
784
|
+
oldInlineValue,
|
|
779
785
|
});
|
|
780
786
|
}
|
|
781
787
|
element = element.parentElement;
|
|
@@ -811,7 +817,7 @@ export const DatePickerMixin = (subclass) =>
|
|
|
811
817
|
|
|
812
818
|
if (this._touchPrevented) {
|
|
813
819
|
this._touchPrevented.forEach(
|
|
814
|
-
(prevented) => (prevented.element.style.webkitOverflowScrolling = prevented.oldInlineValue)
|
|
820
|
+
(prevented) => (prevented.element.style.webkitOverflowScrolling = prevented.oldInlineValue),
|
|
815
821
|
);
|
|
816
822
|
this._touchPrevented = [];
|
|
817
823
|
}
|
|
@@ -848,7 +854,9 @@ export const DatePickerMixin = (subclass) =>
|
|
|
848
854
|
/** @protected */
|
|
849
855
|
_focus() {
|
|
850
856
|
if (this._noInput) {
|
|
851
|
-
this._overlayInitialized
|
|
857
|
+
if (this._overlayInitialized) {
|
|
858
|
+
this._overlayContent.focus();
|
|
859
|
+
}
|
|
852
860
|
} else {
|
|
853
861
|
this.inputElement.focus();
|
|
854
862
|
}
|
|
@@ -923,8 +931,8 @@ export const DatePickerMixin = (subclass) =>
|
|
|
923
931
|
// The input element cannot be readonly as it would conflict with
|
|
924
932
|
// the required attribute. Both are not allowed on an input element.
|
|
925
933
|
// Therefore we prevent default on most keydown events.
|
|
926
|
-
|
|
927
|
-
9 //
|
|
934
|
+
const allowedKeys = [
|
|
935
|
+
9, // Tab
|
|
928
936
|
];
|
|
929
937
|
if (allowedKeys.indexOf(e.keyCode) === -1) {
|
|
930
938
|
e.preventDefault();
|
|
@@ -934,7 +942,7 @@ export const DatePickerMixin = (subclass) =>
|
|
|
934
942
|
switch (e.key) {
|
|
935
943
|
case 'ArrowDown':
|
|
936
944
|
case 'ArrowUp':
|
|
937
|
-
//
|
|
945
|
+
// Prevent scrolling the page with arrows
|
|
938
946
|
e.preventDefault();
|
|
939
947
|
if (this.opened) {
|
|
940
948
|
// The overlay can be opened with ctrl + option + shift in VoiceOver
|
|
@@ -1001,8 +1009,7 @@ export const DatePickerMixin = (subclass) =>
|
|
|
1001
1009
|
/** @private */
|
|
1002
1010
|
_getParsedDate(inputValue = this._inputValue) {
|
|
1003
1011
|
const dateObject = this.i18n.parseDate && this.i18n.parseDate(inputValue);
|
|
1004
|
-
const parsedDate =
|
|
1005
|
-
dateObject && this._parseDate(dateObject.year + '-' + (dateObject.month + 1) + '-' + dateObject.day);
|
|
1012
|
+
const parsedDate = dateObject && this._parseDate(`${dateObject.year}-${dateObject.month + 1}-${dateObject.day}`);
|
|
1006
1013
|
return parsedDate;
|
|
1007
1014
|
}
|
|
1008
1015
|
|
|
@@ -233,11 +233,16 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
|
|
|
233
233
|
|
|
234
234
|
static get properties() {
|
|
235
235
|
return {
|
|
236
|
+
scrollDuration: {
|
|
237
|
+
type: Number,
|
|
238
|
+
default: 300,
|
|
239
|
+
},
|
|
240
|
+
|
|
236
241
|
/**
|
|
237
242
|
* The value for this element.
|
|
238
243
|
*/
|
|
239
244
|
selectedDate: {
|
|
240
|
-
type: Date
|
|
245
|
+
type: Date,
|
|
241
246
|
},
|
|
242
247
|
|
|
243
248
|
/**
|
|
@@ -246,7 +251,7 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
|
|
|
246
251
|
focusedDate: {
|
|
247
252
|
type: Date,
|
|
248
253
|
notify: true,
|
|
249
|
-
observer: '_focusedDateChanged'
|
|
254
|
+
observer: '_focusedDateChanged',
|
|
250
255
|
},
|
|
251
256
|
|
|
252
257
|
_focusedMonthDate: Number,
|
|
@@ -256,11 +261,11 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
|
|
|
256
261
|
*/
|
|
257
262
|
initialPosition: {
|
|
258
263
|
type: Date,
|
|
259
|
-
observer: '_initialPositionChanged'
|
|
264
|
+
observer: '_initialPositionChanged',
|
|
260
265
|
},
|
|
261
266
|
|
|
262
267
|
_originDate: {
|
|
263
|
-
value: new Date()
|
|
268
|
+
value: new Date(),
|
|
264
269
|
},
|
|
265
270
|
|
|
266
271
|
_visibleMonthIndex: Number,
|
|
@@ -269,23 +274,23 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
|
|
|
269
274
|
|
|
270
275
|
_desktopMediaQuery: {
|
|
271
276
|
type: String,
|
|
272
|
-
value: '(min-width: 375px)'
|
|
277
|
+
value: '(min-width: 375px)',
|
|
273
278
|
},
|
|
274
279
|
|
|
275
280
|
_translateX: {
|
|
276
|
-
observer: '_translateXChanged'
|
|
281
|
+
observer: '_translateXChanged',
|
|
277
282
|
},
|
|
278
283
|
|
|
279
284
|
_yearScrollerWidth: {
|
|
280
|
-
value: 50
|
|
285
|
+
value: 50,
|
|
281
286
|
},
|
|
282
287
|
|
|
283
288
|
i18n: {
|
|
284
|
-
type: Object
|
|
289
|
+
type: Object,
|
|
285
290
|
},
|
|
286
291
|
|
|
287
292
|
showWeekNumbers: {
|
|
288
|
-
type: Boolean
|
|
293
|
+
type: Boolean,
|
|
289
294
|
},
|
|
290
295
|
|
|
291
296
|
_ignoreTaps: Boolean,
|
|
@@ -305,7 +310,7 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
|
|
|
305
310
|
/**
|
|
306
311
|
* Input label
|
|
307
312
|
*/
|
|
308
|
-
label: String
|
|
313
|
+
label: String,
|
|
309
314
|
};
|
|
310
315
|
}
|
|
311
316
|
|
|
@@ -331,13 +336,13 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
|
|
|
331
336
|
addListener(
|
|
332
337
|
this.shadowRoot.querySelector('[part="years-toggle-button"]'),
|
|
333
338
|
'tap',
|
|
334
|
-
this._toggleYearScroller.bind(this)
|
|
339
|
+
this._toggleYearScroller.bind(this),
|
|
335
340
|
);
|
|
336
341
|
|
|
337
342
|
this.addController(
|
|
338
343
|
new MediaQueryController(this._desktopMediaQuery, (matches) => {
|
|
339
344
|
this._desktopMode = matches;
|
|
340
|
-
})
|
|
345
|
+
}),
|
|
341
346
|
);
|
|
342
347
|
}
|
|
343
348
|
|
|
@@ -376,7 +381,7 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
|
|
|
376
381
|
_selectDate(dateToSelect) {
|
|
377
382
|
this.selectedDate = dateToSelect;
|
|
378
383
|
this.dispatchEvent(
|
|
379
|
-
new CustomEvent('date-selected', { detail: { date: dateToSelect }, bubbles: true, composed: true })
|
|
384
|
+
new CustomEvent('date-selected', { detail: { date: dateToSelect }, bubbles: true, composed: true }),
|
|
380
385
|
);
|
|
381
386
|
}
|
|
382
387
|
|
|
@@ -404,7 +409,7 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
|
|
|
404
409
|
|
|
405
410
|
const visibleArea = Math.max(
|
|
406
411
|
this.$.monthScroller.itemHeight,
|
|
407
|
-
this.$.monthScroller.clientHeight - this.$.monthScroller.bufferOffset * 2
|
|
412
|
+
this.$.monthScroller.clientHeight - this.$.monthScroller.bufferOffset * 2,
|
|
408
413
|
);
|
|
409
414
|
const visibleItems = visibleArea / this.$.monthScroller.itemHeight;
|
|
410
415
|
const scrolledBelowViewport = this.$.monthScroller.position + visibleItems - 1 < diff;
|
|
@@ -465,7 +470,7 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
|
|
|
465
470
|
}
|
|
466
471
|
|
|
467
472
|
_onTodayTap() {
|
|
468
|
-
|
|
473
|
+
const today = new Date();
|
|
469
474
|
|
|
470
475
|
if (Math.abs(this.$.monthScroller.position - this._differenceInMonths(today, this._originDate)) < 0.001) {
|
|
471
476
|
// Select today only if the month scroller is positioned approximately
|
|
@@ -491,9 +496,9 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
|
|
|
491
496
|
|
|
492
497
|
_onYearTap(e) {
|
|
493
498
|
if (!this._ignoreTaps && !this._notTapping) {
|
|
494
|
-
|
|
499
|
+
const scrollDelta =
|
|
495
500
|
e.detail.y - (this.$.yearScroller.getBoundingClientRect().top + this.$.yearScroller.clientHeight / 2);
|
|
496
|
-
|
|
501
|
+
const yearDelta = scrollDelta / this.$.yearScroller.itemHeight;
|
|
497
502
|
this._scrollToPosition(this.$.monthScroller.position + yearDelta * 12, true);
|
|
498
503
|
}
|
|
499
504
|
}
|
|
@@ -515,7 +520,7 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
|
|
|
515
520
|
this._targetPosition = targetPosition;
|
|
516
521
|
|
|
517
522
|
// http://gizma.com/easing/
|
|
518
|
-
|
|
523
|
+
const easingFunction = (t, b, c, d) => {
|
|
519
524
|
t /= d / 2;
|
|
520
525
|
if (t < 1) {
|
|
521
526
|
return (c / 2) * t * t + b;
|
|
@@ -524,16 +529,20 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
|
|
|
524
529
|
return (-c / 2) * (t * (t - 2) - 1) + b;
|
|
525
530
|
};
|
|
526
531
|
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
var initialPosition = this.$.monthScroller.position;
|
|
532
|
+
let start = 0;
|
|
533
|
+
const initialPosition = this.$.monthScroller.position;
|
|
530
534
|
|
|
531
|
-
|
|
535
|
+
const smoothScroll = (timestamp) => {
|
|
532
536
|
start = start || timestamp;
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
if (currentTime <
|
|
536
|
-
|
|
537
|
+
const currentTime = timestamp - start;
|
|
538
|
+
|
|
539
|
+
if (currentTime < this.scrollDuration) {
|
|
540
|
+
const currentPos = easingFunction(
|
|
541
|
+
currentTime,
|
|
542
|
+
initialPosition,
|
|
543
|
+
this._targetPosition - initialPosition,
|
|
544
|
+
this.scrollDuration,
|
|
545
|
+
);
|
|
537
546
|
this.$.monthScroller.position = currentPos;
|
|
538
547
|
window.requestAnimationFrame(smoothScroll);
|
|
539
548
|
} else {
|
|
@@ -543,9 +552,9 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
|
|
|
543
552
|
composed: true,
|
|
544
553
|
detail: {
|
|
545
554
|
position: this._targetPosition,
|
|
546
|
-
oldPosition: initialPosition
|
|
547
|
-
}
|
|
548
|
-
})
|
|
555
|
+
oldPosition: initialPosition,
|
|
556
|
+
},
|
|
557
|
+
}),
|
|
549
558
|
);
|
|
550
559
|
|
|
551
560
|
this.$.monthScroller.position = this._targetPosition;
|
|
@@ -576,10 +585,10 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
|
|
|
576
585
|
this._toggleAnimateClass(true);
|
|
577
586
|
}
|
|
578
587
|
|
|
579
|
-
|
|
588
|
+
const newTranslateX = this._translateX + e.detail.ddx;
|
|
580
589
|
this._translateX = this._limit(newTranslateX, {
|
|
581
590
|
min: 0,
|
|
582
|
-
max: this._yearScrollerWidth
|
|
591
|
+
max: this._yearScrollerWidth,
|
|
583
592
|
});
|
|
584
593
|
}
|
|
585
594
|
|
|
@@ -618,7 +627,11 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
|
|
|
618
627
|
}
|
|
619
628
|
|
|
620
629
|
_toggleYearScroller() {
|
|
621
|
-
this._isYearScrollerVisible()
|
|
630
|
+
if (this._isYearScrollerVisible()) {
|
|
631
|
+
this._closeYearScroller();
|
|
632
|
+
} else {
|
|
633
|
+
this._openYearScroller();
|
|
634
|
+
}
|
|
622
635
|
}
|
|
623
636
|
|
|
624
637
|
_openYearScroller() {
|
|
@@ -637,13 +650,13 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
|
|
|
637
650
|
|
|
638
651
|
_translateXChanged(x) {
|
|
639
652
|
if (!this._desktopMode) {
|
|
640
|
-
this.$.monthScroller.style.transform =
|
|
641
|
-
this.$.yearScroller.style.transform =
|
|
653
|
+
this.$.monthScroller.style.transform = `translateX(${x - this._yearScrollerWidth}px)`;
|
|
654
|
+
this.$.yearScroller.style.transform = `translateX(${x}px)`;
|
|
642
655
|
}
|
|
643
656
|
}
|
|
644
657
|
|
|
645
658
|
_yearAfterXYears(index) {
|
|
646
|
-
|
|
659
|
+
const result = new Date(this._originDate);
|
|
647
660
|
result.setFullYear(parseInt(index) + this._originDate.getFullYear());
|
|
648
661
|
return result.getFullYear();
|
|
649
662
|
}
|
|
@@ -653,14 +666,14 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
|
|
|
653
666
|
}
|
|
654
667
|
|
|
655
668
|
_dateAfterXMonths(months) {
|
|
656
|
-
|
|
669
|
+
const result = new Date(this._originDate);
|
|
657
670
|
result.setDate(1);
|
|
658
671
|
result.setMonth(parseInt(months) + this._originDate.getMonth());
|
|
659
672
|
return result;
|
|
660
673
|
}
|
|
661
674
|
|
|
662
675
|
_differenceInMonths(date1, date2) {
|
|
663
|
-
|
|
676
|
+
const months = (date1.getFullYear() - date2.getFullYear()) * 12;
|
|
664
677
|
return months - date2.getMonth() + date1.getMonth();
|
|
665
678
|
}
|
|
666
679
|
|
|
@@ -837,8 +850,8 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
|
|
|
837
850
|
}
|
|
838
851
|
|
|
839
852
|
_moveFocusByDays(days) {
|
|
840
|
-
|
|
841
|
-
|
|
853
|
+
const focus = this.focusedDate;
|
|
854
|
+
const dateToFocus = new Date(0, 0);
|
|
842
855
|
dateToFocus.setFullYear(focus.getFullYear());
|
|
843
856
|
dateToFocus.setMonth(focus.getMonth());
|
|
844
857
|
dateToFocus.setDate(focus.getDate() + days);
|
|
@@ -848,10 +861,10 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
|
|
|
848
861
|
} else if (this._dateAllowed(focus, this.minDate, this.maxDate)) {
|
|
849
862
|
// Move to min or max date
|
|
850
863
|
if (days > 0) {
|
|
851
|
-
//
|
|
864
|
+
// Down or right
|
|
852
865
|
this.focusDate(this.maxDate);
|
|
853
866
|
} else {
|
|
854
|
-
//
|
|
867
|
+
// Up or left
|
|
855
868
|
this.focusDate(this.minDate);
|
|
856
869
|
}
|
|
857
870
|
} else {
|
|
@@ -861,12 +874,12 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
|
|
|
861
874
|
}
|
|
862
875
|
|
|
863
876
|
_moveFocusByMonths(months) {
|
|
864
|
-
|
|
865
|
-
|
|
877
|
+
const focus = this.focusedDate;
|
|
878
|
+
const dateToFocus = new Date(0, 0);
|
|
866
879
|
dateToFocus.setFullYear(focus.getFullYear());
|
|
867
880
|
dateToFocus.setMonth(focus.getMonth() + months);
|
|
868
881
|
|
|
869
|
-
|
|
882
|
+
const targetMonth = dateToFocus.getMonth();
|
|
870
883
|
|
|
871
884
|
dateToFocus.setDate(this._focusedMonthDate || (this._focusedMonthDate = focus.getDate()));
|
|
872
885
|
if (dateToFocus.getMonth() !== targetMonth) {
|
|
@@ -878,10 +891,10 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
|
|
|
878
891
|
} else if (this._dateAllowed(focus, this.minDate, this.maxDate)) {
|
|
879
892
|
// Move to min or max date
|
|
880
893
|
if (months > 0) {
|
|
881
|
-
//
|
|
894
|
+
// Pagedown
|
|
882
895
|
this.focusDate(this.maxDate);
|
|
883
896
|
} else {
|
|
884
|
-
//
|
|
897
|
+
// Pageup
|
|
885
898
|
this.focusDate(this.minDate);
|
|
886
899
|
}
|
|
887
900
|
} else {
|
|
@@ -891,7 +904,7 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
|
|
|
891
904
|
}
|
|
892
905
|
|
|
893
906
|
_moveFocusInsideMonth(focusedDate, property) {
|
|
894
|
-
|
|
907
|
+
const dateToFocus = new Date(0, 0);
|
|
895
908
|
dateToFocus.setFullYear(focusedDate.getFullYear());
|
|
896
909
|
|
|
897
910
|
if (property === 'minDate') {
|
|
@@ -918,8 +931,8 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
|
|
|
918
931
|
}
|
|
919
932
|
|
|
920
933
|
_isTodayAllowed(min, max) {
|
|
921
|
-
|
|
922
|
-
|
|
934
|
+
const today = new Date();
|
|
935
|
+
const todayMidnight = new Date(0, 0);
|
|
923
936
|
todayMidnight.setFullYear(today.getFullYear());
|
|
924
937
|
todayMidnight.setMonth(today.getMonth());
|
|
925
938
|
todayMidnight.setDate(today.getDate());
|
|
@@ -10,7 +10,7 @@ import { registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mi
|
|
|
10
10
|
import { datePickerOverlayStyles } from './vaadin-date-picker-styles.js';
|
|
11
11
|
|
|
12
12
|
registerStyles('vaadin-date-picker-overlay', datePickerOverlayStyles, {
|
|
13
|
-
moduleId: 'vaadin-date-picker-overlay-styles'
|
|
13
|
+
moduleId: 'vaadin-date-picker-overlay-styles',
|
|
14
14
|
});
|
|
15
15
|
|
|
16
16
|
let memoizedTemplate;
|
|
@@ -138,13 +138,13 @@ declare class DatePicker extends DatePickerMixin(InputControlMixin(ThemableMixin
|
|
|
138
138
|
addEventListener<K extends keyof DatePickerEventMap>(
|
|
139
139
|
type: K,
|
|
140
140
|
listener: (this: DatePicker, ev: DatePickerEventMap[K]) => void,
|
|
141
|
-
options?: boolean | AddEventListenerOptions
|
|
141
|
+
options?: boolean | AddEventListenerOptions,
|
|
142
142
|
): void;
|
|
143
143
|
|
|
144
144
|
removeEventListener<K extends keyof DatePickerEventMap>(
|
|
145
145
|
type: K,
|
|
146
146
|
listener: (this: DatePicker, ev: DatePickerEventMap[K]) => void,
|
|
147
|
-
options?: boolean | EventListenerOptions
|
|
147
|
+
options?: boolean | EventListenerOptions,
|
|
148
148
|
): void;
|
|
149
149
|
}
|
|
150
150
|
|
|
@@ -113,6 +113,7 @@ registerStyles('vaadin-date-picker', [inputFieldShared, datePickerStyles], { mod
|
|
|
113
113
|
* @mixes ElementMixin
|
|
114
114
|
* @mixes ThemableMixin
|
|
115
115
|
* @mixes InputControlMixin
|
|
116
|
+
* @mixes DatePickerMixin
|
|
116
117
|
*/
|
|
117
118
|
class DatePicker extends DatePickerMixin(InputControlMixin(ThemableMixin(ElementMixin(PolymerElement)))) {
|
|
118
119
|
static get is() {
|
|
@@ -206,7 +207,7 @@ class DatePicker extends DatePickerMixin(InputControlMixin(ThemableMixin(Element
|
|
|
206
207
|
this._setFocusElement(input);
|
|
207
208
|
this.stateTarget = input;
|
|
208
209
|
this.ariaTarget = input;
|
|
209
|
-
})
|
|
210
|
+
}),
|
|
210
211
|
);
|
|
211
212
|
this.addController(new LabelledInputController(this.inputElement, this._labelController));
|
|
212
213
|
|
|
@@ -221,7 +222,7 @@ class DatePicker extends DatePickerMixin(InputControlMixin(ThemableMixin(Element
|
|
|
221
222
|
} else if (!this.hasAttribute('focused')) {
|
|
222
223
|
this.blur();
|
|
223
224
|
}
|
|
224
|
-
if (e.detail.sourceEvent && e.detail.sourceEvent.composedPath().
|
|
225
|
+
if (e.detail.sourceEvent && e.detail.sourceEvent.composedPath().includes(this)) {
|
|
225
226
|
e.preventDefault();
|
|
226
227
|
}
|
|
227
228
|
}
|
|
@@ -83,7 +83,7 @@ class InfiniteScroller extends PolymerElement {
|
|
|
83
83
|
*/
|
|
84
84
|
bufferSize: {
|
|
85
85
|
type: Number,
|
|
86
|
-
value: 20
|
|
86
|
+
value: 20,
|
|
87
87
|
},
|
|
88
88
|
|
|
89
89
|
/**
|
|
@@ -91,14 +91,14 @@ class InfiniteScroller extends PolymerElement {
|
|
|
91
91
|
* user to be able to scroll backwards.
|
|
92
92
|
*/
|
|
93
93
|
_initialScroll: {
|
|
94
|
-
value: 500000
|
|
94
|
+
value: 500000,
|
|
95
95
|
},
|
|
96
96
|
|
|
97
97
|
/**
|
|
98
98
|
* The index/position mapped at _initialScroll point.
|
|
99
99
|
*/
|
|
100
100
|
_initialIndex: {
|
|
101
|
-
value: 0
|
|
101
|
+
value: 0,
|
|
102
102
|
},
|
|
103
103
|
|
|
104
104
|
_buffers: Array,
|
|
@@ -111,8 +111,8 @@ class InfiniteScroller extends PolymerElement {
|
|
|
111
111
|
|
|
112
112
|
active: {
|
|
113
113
|
type: Boolean,
|
|
114
|
-
observer: '_activated'
|
|
115
|
-
}
|
|
114
|
+
observer: '_activated',
|
|
115
|
+
},
|
|
116
116
|
};
|
|
117
117
|
}
|
|
118
118
|
|
|
@@ -121,11 +121,11 @@ class InfiniteScroller extends PolymerElement {
|
|
|
121
121
|
|
|
122
122
|
this._buffers = Array.prototype.slice.call(this.root.querySelectorAll('.buffer'));
|
|
123
123
|
|
|
124
|
-
this.$.fullHeight.style.height = this._initialScroll * 2
|
|
124
|
+
this.$.fullHeight.style.height = `${this._initialScroll * 2}px`;
|
|
125
125
|
|
|
126
126
|
const tpl = this.querySelector('template');
|
|
127
127
|
this._TemplateClass = templatize(tpl, this, {
|
|
128
|
-
forwardHostProp
|
|
128
|
+
forwardHostProp(prop, value) {
|
|
129
129
|
if (prop !== 'index') {
|
|
130
130
|
this._buffers.forEach((buffer) => {
|
|
131
131
|
[].forEach.call(buffer.children, (insertionPoint) => {
|
|
@@ -133,7 +133,7 @@ class InfiniteScroller extends PolymerElement {
|
|
|
133
133
|
});
|
|
134
134
|
});
|
|
135
135
|
}
|
|
136
|
-
}
|
|
136
|
+
},
|
|
137
137
|
});
|
|
138
138
|
|
|
139
139
|
// Firefox interprets elements with overflow:auto as focusable
|
|
@@ -168,7 +168,7 @@ class InfiniteScroller extends PolymerElement {
|
|
|
168
168
|
_translateBuffer(up) {
|
|
169
169
|
const index = up ? 1 : 0;
|
|
170
170
|
this._buffers[index].translateY = this._buffers[index ? 0 : 1].translateY + this._bufferHeight * (index ? -1 : 1);
|
|
171
|
-
this._buffers[index].style.transform =
|
|
171
|
+
this._buffers[index].style.transform = `translate3d(0, ${this._buffers[index].translateY}px, 0)`;
|
|
172
172
|
this._buffers[index].updated = false;
|
|
173
173
|
this._buffers.reverse();
|
|
174
174
|
}
|
|
@@ -279,7 +279,7 @@ class InfiniteScroller extends PolymerElement {
|
|
|
279
279
|
this._buffers[0].translateY = this._initialScroll - this._bufferHeight;
|
|
280
280
|
this._buffers[1].translateY = this._initialScroll;
|
|
281
281
|
this._buffers.forEach((buffer) => {
|
|
282
|
-
buffer.style.transform =
|
|
282
|
+
buffer.style.transform = `translate3d(0, ${buffer.translateY}px, 0)`;
|
|
283
283
|
});
|
|
284
284
|
this._buffers[0].updated = this._buffers[1].updated = false;
|
|
285
285
|
this._updateClones(true);
|
|
@@ -297,11 +297,11 @@ class InfiniteScroller extends PolymerElement {
|
|
|
297
297
|
this._buffers.forEach((buffer) => {
|
|
298
298
|
for (let i = 0; i < this.bufferSize; i++) {
|
|
299
299
|
const itemWrapper = document.createElement('div');
|
|
300
|
-
itemWrapper.style.height = this.itemHeight
|
|
300
|
+
itemWrapper.style.height = `${this.itemHeight}px`;
|
|
301
301
|
itemWrapper.instance = {};
|
|
302
302
|
|
|
303
303
|
const contentId = (InfiniteScroller._contentIndex = InfiniteScroller._contentIndex + 1 || 0);
|
|
304
|
-
const slotName =
|
|
304
|
+
const slotName = `vaadin-infinite-scroller-item-content-${contentId}`;
|
|
305
305
|
|
|
306
306
|
const insertionPoint = document.createElement('slot');
|
|
307
307
|
insertionPoint.setAttribute('name', slotName);
|
|
@@ -330,7 +330,7 @@ class InfiniteScroller extends PolymerElement {
|
|
|
330
330
|
return;
|
|
331
331
|
}
|
|
332
332
|
|
|
333
|
-
|
|
333
|
+
const tmpInstance = itemWrapper.instance;
|
|
334
334
|
|
|
335
335
|
itemWrapper.instance = new this._TemplateClass({});
|
|
336
336
|
itemWrapper.appendChild(itemWrapper.instance.root);
|
|
@@ -343,10 +343,10 @@ class InfiniteScroller extends PolymerElement {
|
|
|
343
343
|
_updateClones(viewPortOnly) {
|
|
344
344
|
this._firstIndex = ~~((this._buffers[0].translateY - this._initialScroll) / this.itemHeight) + this._initialIndex;
|
|
345
345
|
|
|
346
|
-
|
|
346
|
+
const scrollerRect = viewPortOnly ? this.$.scroller.getBoundingClientRect() : undefined;
|
|
347
347
|
this._buffers.forEach((buffer, bufferIndex) => {
|
|
348
348
|
if (!buffer.updated) {
|
|
349
|
-
|
|
349
|
+
const firstIndex = this._firstIndex + this.bufferSize * bufferIndex;
|
|
350
350
|
|
|
351
351
|
[].forEach.call(buffer.children, (insertionPoint, index) => {
|
|
352
352
|
const itemWrapper = insertionPoint._itemWrapper;
|
|
@@ -360,7 +360,7 @@ class InfiniteScroller extends PolymerElement {
|
|
|
360
360
|
}
|
|
361
361
|
|
|
362
362
|
_isVisible(element, container) {
|
|
363
|
-
|
|
363
|
+
const rect = element.getBoundingClientRect();
|
|
364
364
|
return rect.bottom > container.top && rect.top < container.bottom;
|
|
365
365
|
}
|
|
366
366
|
}
|
|
@@ -23,18 +23,8 @@ class MonthCalendar extends FocusMixin(ThemableMixin(PolymerElement)) {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
#monthGrid {
|
|
26
|
-
display: block;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
#monthGrid thead,
|
|
30
|
-
#monthGrid tbody {
|
|
31
|
-
display: block;
|
|
32
26
|
width: 100%;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
[part='weekdays'] {
|
|
36
|
-
display: flex;
|
|
37
|
-
flex-grow: 1;
|
|
27
|
+
border-collapse: collapse;
|
|
38
28
|
}
|
|
39
29
|
|
|
40
30
|
#days-container tr,
|
|
@@ -53,9 +43,7 @@ class MonthCalendar extends FocusMixin(ThemableMixin(PolymerElement)) {
|
|
|
53
43
|
|
|
54
44
|
[part='weekday'],
|
|
55
45
|
[part='date'] {
|
|
56
|
-
|
|
57
|
-
/* Would use calc(100% / 7) but it doesn't work nice on IE */
|
|
58
|
-
width: 14.285714286%;
|
|
46
|
+
width: calc(100% / 7);
|
|
59
47
|
padding: 0;
|
|
60
48
|
font-weight: normal;
|
|
61
49
|
}
|
|
@@ -64,6 +52,12 @@ class MonthCalendar extends FocusMixin(ThemableMixin(PolymerElement)) {
|
|
|
64
52
|
[part='week-number'] {
|
|
65
53
|
width: 12.5%;
|
|
66
54
|
flex-shrink: 0;
|
|
55
|
+
padding: 0;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
:host([week-numbers]) [part='weekday']:not(:empty),
|
|
59
|
+
:host([week-numbers]) [part='date'] {
|
|
60
|
+
width: 12.5%;
|
|
67
61
|
}
|
|
68
62
|
</style>
|
|
69
63
|
|
|
@@ -135,7 +129,7 @@ class MonthCalendar extends FocusMixin(ThemableMixin(PolymerElement)) {
|
|
|
135
129
|
*/
|
|
136
130
|
month: {
|
|
137
131
|
type: Date,
|
|
138
|
-
value: new Date()
|
|
132
|
+
value: new Date(),
|
|
139
133
|
},
|
|
140
134
|
|
|
141
135
|
/**
|
|
@@ -143,7 +137,7 @@ class MonthCalendar extends FocusMixin(ThemableMixin(PolymerElement)) {
|
|
|
143
137
|
*/
|
|
144
138
|
selectedDate: {
|
|
145
139
|
type: Date,
|
|
146
|
-
notify: true
|
|
140
|
+
notify: true,
|
|
147
141
|
},
|
|
148
142
|
|
|
149
143
|
/**
|
|
@@ -153,11 +147,11 @@ class MonthCalendar extends FocusMixin(ThemableMixin(PolymerElement)) {
|
|
|
153
147
|
|
|
154
148
|
showWeekNumbers: {
|
|
155
149
|
type: Boolean,
|
|
156
|
-
value: false
|
|
150
|
+
value: false,
|
|
157
151
|
},
|
|
158
152
|
|
|
159
153
|
i18n: {
|
|
160
|
-
type: Object
|
|
154
|
+
type: Object,
|
|
161
155
|
},
|
|
162
156
|
|
|
163
157
|
/**
|
|
@@ -172,7 +166,7 @@ class MonthCalendar extends FocusMixin(ThemableMixin(PolymerElement)) {
|
|
|
172
166
|
*/
|
|
173
167
|
minDate: {
|
|
174
168
|
type: Date,
|
|
175
|
-
value: null
|
|
169
|
+
value: null,
|
|
176
170
|
},
|
|
177
171
|
|
|
178
172
|
/**
|
|
@@ -180,31 +174,31 @@ class MonthCalendar extends FocusMixin(ThemableMixin(PolymerElement)) {
|
|
|
180
174
|
*/
|
|
181
175
|
maxDate: {
|
|
182
176
|
type: Date,
|
|
183
|
-
value: null
|
|
177
|
+
value: null,
|
|
184
178
|
},
|
|
185
179
|
|
|
186
180
|
_days: {
|
|
187
181
|
type: Array,
|
|
188
|
-
computed: '_getDays(month, i18n.firstDayOfWeek, minDate, maxDate)'
|
|
182
|
+
computed: '_getDays(month, i18n.firstDayOfWeek, minDate, maxDate)',
|
|
189
183
|
},
|
|
190
184
|
|
|
191
185
|
_weeks: {
|
|
192
186
|
type: Array,
|
|
193
|
-
computed: '_getWeeks(_days)'
|
|
187
|
+
computed: '_getWeeks(_days)',
|
|
194
188
|
},
|
|
195
189
|
|
|
196
190
|
disabled: {
|
|
197
191
|
type: Boolean,
|
|
198
192
|
reflectToAttribute: true,
|
|
199
|
-
computed: '_isDisabled(month, minDate, maxDate)'
|
|
200
|
-
}
|
|
193
|
+
computed: '_isDisabled(month, minDate, maxDate)',
|
|
194
|
+
},
|
|
201
195
|
};
|
|
202
196
|
}
|
|
203
197
|
|
|
204
198
|
static get observers() {
|
|
205
199
|
return [
|
|
206
200
|
'_showWeekNumbersChanged(showWeekNumbers, i18n.firstDayOfWeek)',
|
|
207
|
-
'__focusedDateChanged(focusedDate, _days)'
|
|
201
|
+
'__focusedDateChanged(focusedDate, _days)',
|
|
208
202
|
];
|
|
209
203
|
}
|
|
210
204
|
|
|
@@ -223,13 +217,13 @@ class MonthCalendar extends FocusMixin(ThemableMixin(PolymerElement)) {
|
|
|
223
217
|
/* Returns true if all the dates in the month are out of the allowed range */
|
|
224
218
|
_isDisabled(month, minDate, maxDate) {
|
|
225
219
|
// First day of the month
|
|
226
|
-
|
|
220
|
+
const firstDate = new Date(0, 0);
|
|
227
221
|
firstDate.setFullYear(month.getFullYear());
|
|
228
222
|
firstDate.setMonth(month.getMonth());
|
|
229
223
|
firstDate.setDate(1);
|
|
230
224
|
|
|
231
225
|
// Last day of the month
|
|
232
|
-
|
|
226
|
+
const lastDate = new Date(0, 0);
|
|
233
227
|
lastDate.setFullYear(month.getFullYear());
|
|
234
228
|
lastDate.setMonth(month.getMonth() + 1);
|
|
235
229
|
lastDate.setDate(0);
|
|
@@ -285,7 +279,7 @@ class MonthCalendar extends FocusMixin(ThemableMixin(PolymerElement)) {
|
|
|
285
279
|
weekDayNames = weekDayNames.map((day, index) => {
|
|
286
280
|
return {
|
|
287
281
|
weekDay: day,
|
|
288
|
-
weekDayShort: weekDayNamesShort[index]
|
|
282
|
+
weekDayShort: weekDayNamesShort[index],
|
|
289
283
|
};
|
|
290
284
|
});
|
|
291
285
|
|
|
@@ -326,7 +320,7 @@ class MonthCalendar extends FocusMixin(ThemableMixin(PolymerElement)) {
|
|
|
326
320
|
return;
|
|
327
321
|
}
|
|
328
322
|
// First day of the month (at midnight).
|
|
329
|
-
|
|
323
|
+
const date = new Date(0, 0);
|
|
330
324
|
date.setFullYear(month.getFullYear());
|
|
331
325
|
date.setMonth(month.getMonth());
|
|
332
326
|
date.setDate(1);
|
|
@@ -336,9 +330,9 @@ class MonthCalendar extends FocusMixin(ThemableMixin(PolymerElement)) {
|
|
|
336
330
|
this._dateAdd(date, -1);
|
|
337
331
|
}
|
|
338
332
|
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
333
|
+
const days = [];
|
|
334
|
+
const startMonth = date.getMonth();
|
|
335
|
+
const targetMonth = month.getMonth();
|
|
342
336
|
while (date.getMonth() === targetMonth || date.getMonth() === startMonth) {
|
|
343
337
|
days.push(date.getMonth() === targetMonth ? new Date(date.getTime()) : null);
|
|
344
338
|
|
|
@@ -362,7 +356,7 @@ class MonthCalendar extends FocusMixin(ThemableMixin(PolymerElement)) {
|
|
|
362
356
|
if (!this.ignoreTaps && !this._notTapping && e.target.date && !e.target.hasAttribute('disabled')) {
|
|
363
357
|
this.selectedDate = e.target.date;
|
|
364
358
|
this.dispatchEvent(
|
|
365
|
-
new CustomEvent('date-tap', { detail: { date: e.target.date }, bubbles: true, composed: true })
|
|
359
|
+
new CustomEvent('date-tap', { detail: { date: e.target.date }, bubbles: true, composed: true }),
|
|
366
360
|
);
|
|
367
361
|
}
|
|
368
362
|
}
|
|
@@ -412,17 +406,12 @@ class MonthCalendar extends FocusMixin(ThemableMixin(PolymerElement)) {
|
|
|
412
406
|
return '';
|
|
413
407
|
}
|
|
414
408
|
|
|
415
|
-
|
|
416
|
-
this.
|
|
417
|
-
|
|
418
|
-
this.i18n.monthNames[date.getMonth()] +
|
|
419
|
-
' ' +
|
|
420
|
-
date.getFullYear() +
|
|
421
|
-
', ' +
|
|
422
|
-
this.i18n.weekdays[date.getDay()];
|
|
409
|
+
let ariaLabel = `${this._getDate(date)} ${this.i18n.monthNames[date.getMonth()]} ${date.getFullYear()}, ${
|
|
410
|
+
this.i18n.weekdays[date.getDay()]
|
|
411
|
+
}`;
|
|
423
412
|
|
|
424
413
|
if (this._isToday(date)) {
|
|
425
|
-
ariaLabel +=
|
|
414
|
+
ariaLabel += `, ${this.i18n.today}`;
|
|
426
415
|
}
|
|
427
416
|
|
|
428
417
|
return ariaLabel;
|
|
@@ -68,6 +68,11 @@ registerStyles(
|
|
|
68
68
|
cursor: var(--lumo-clickable-cursor);
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
:host([week-numbers]) [part='weekday']:not(:empty),
|
|
72
|
+
:host([week-numbers]) [part='date'] {
|
|
73
|
+
width: calc((100% - var(--lumo-size-xs)) / 7);
|
|
74
|
+
}
|
|
75
|
+
|
|
71
76
|
/* Today date */
|
|
72
77
|
|
|
73
78
|
[part='date'][today] {
|
|
@@ -143,7 +148,7 @@ registerStyles(
|
|
|
143
148
|
color: var(--lumo-disabled-text-color) !important;
|
|
144
149
|
}
|
|
145
150
|
`,
|
|
146
|
-
{ moduleId: 'lumo-month-calendar' }
|
|
151
|
+
{ moduleId: 'lumo-month-calendar' },
|
|
147
152
|
);
|
|
148
153
|
|
|
149
154
|
const $_documentContainer = document.createElement('template');
|