@vaadin/date-picker 23.3.0-alpha2 → 24.0.0-alpha1
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 +10 -10
- package/src/vaadin-date-picker-helper.d.ts +7 -0
- package/src/vaadin-date-picker-helper.js +14 -0
- package/src/vaadin-date-picker-light.d.ts +0 -6
- package/src/vaadin-date-picker-light.js +4 -42
- package/src/vaadin-date-picker-mixin.d.ts +0 -9
- package/src/vaadin-date-picker-mixin.js +73 -52
- package/src/vaadin-date-picker-month-scroller.js +74 -0
- package/src/vaadin-date-picker-overlay-content.js +297 -175
- package/src/vaadin-date-picker-overlay.js +21 -10
- package/src/vaadin-date-picker-year-scroller.js +104 -0
- package/src/vaadin-date-picker-year.js +57 -0
- package/src/vaadin-date-picker.d.ts +19 -9
- package/src/vaadin-date-picker.js +38 -36
- package/src/vaadin-infinite-scroller.js +69 -41
- package/src/vaadin-month-calendar.js +3 -7
- package/theme/lumo/vaadin-date-picker-overlay-content-styles.js +15 -52
- package/theme/lumo/vaadin-date-picker-overlay-styles.js +1 -1
- package/theme/lumo/vaadin-date-picker-year-styles.js +32 -0
- package/theme/material/vaadin-date-picker-overlay-content-styles.js +11 -36
- package/theme/material/vaadin-date-picker-overlay-styles.js +1 -1
- package/theme/material/vaadin-date-picker-year-styles.js +28 -0
- package/web-types.json +5 -5
- package/web-types.lit.json +5 -5
- package/src/vaadin-date-picker-styles.js +0 -33
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/date-picker",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "24.0.0-alpha1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -36,14 +36,14 @@
|
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
38
38
|
"@polymer/polymer": "^3.2.0",
|
|
39
|
-
"@vaadin/button": "
|
|
40
|
-
"@vaadin/component-base": "
|
|
41
|
-
"@vaadin/field-base": "
|
|
42
|
-
"@vaadin/input-container": "
|
|
43
|
-
"@vaadin/
|
|
44
|
-
"@vaadin/vaadin-
|
|
45
|
-
"@vaadin/vaadin-
|
|
46
|
-
"@vaadin/vaadin-themable-mixin": "
|
|
39
|
+
"@vaadin/button": "24.0.0-alpha1",
|
|
40
|
+
"@vaadin/component-base": "24.0.0-alpha1",
|
|
41
|
+
"@vaadin/field-base": "24.0.0-alpha1",
|
|
42
|
+
"@vaadin/input-container": "24.0.0-alpha1",
|
|
43
|
+
"@vaadin/overlay": "24.0.0-alpha1",
|
|
44
|
+
"@vaadin/vaadin-lumo-styles": "24.0.0-alpha1",
|
|
45
|
+
"@vaadin/vaadin-material-styles": "24.0.0-alpha1",
|
|
46
|
+
"@vaadin/vaadin-themable-mixin": "24.0.0-alpha1"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@esm-bundle/chai": "^4.3.4",
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"web-types.json",
|
|
55
55
|
"web-types.lit.json"
|
|
56
56
|
],
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "427527c27c4b27822d61fd41d38d7b170134770b"
|
|
58
58
|
}
|
|
@@ -41,3 +41,10 @@ export { extractDateParts };
|
|
|
41
41
|
* to the expected format.
|
|
42
42
|
*/
|
|
43
43
|
declare function extractDateParts(date: Date): { day: number; month: number; year: number };
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Get difference in months between today and given months value.
|
|
47
|
+
*/
|
|
48
|
+
declare function dateAfterXMonths(months: number): number;
|
|
49
|
+
|
|
50
|
+
export { dateAfterXMonths };
|
|
@@ -103,3 +103,17 @@ export function extractDateParts(date) {
|
|
|
103
103
|
year: date.getFullYear(),
|
|
104
104
|
};
|
|
105
105
|
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Get difference in months between today and given months value.
|
|
109
|
+
*
|
|
110
|
+
* @param {number} months
|
|
111
|
+
* @return {number}
|
|
112
|
+
*/
|
|
113
|
+
export function dateAfterXMonths(months) {
|
|
114
|
+
const today = new Date();
|
|
115
|
+
const result = new Date(today);
|
|
116
|
+
result.setDate(1);
|
|
117
|
+
result.setMonth(parseInt(months) + today.getMonth());
|
|
118
|
+
return result;
|
|
119
|
+
}
|
|
@@ -66,12 +66,6 @@ export interface DatePickerLightEventMap extends HTMLElementEventMap, DatePicker
|
|
|
66
66
|
*
|
|
67
67
|
* ### Styling
|
|
68
68
|
*
|
|
69
|
-
* The following shadow DOM parts are available for styling:
|
|
70
|
-
*
|
|
71
|
-
* Part name | Description | Theme for Element
|
|
72
|
-
* ----------------|----------------|----------------
|
|
73
|
-
* `overlay-content` | The overlay element | vaadin-date-picker-light
|
|
74
|
-
*
|
|
75
69
|
* See [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.
|
|
76
70
|
*
|
|
77
71
|
* In addition to `<vaadin-date-picker-light>` itself, the following
|
|
@@ -28,12 +28,6 @@ import { DatePickerMixin } from './vaadin-date-picker-mixin.js';
|
|
|
28
28
|
*
|
|
29
29
|
* ### Styling
|
|
30
30
|
*
|
|
31
|
-
* The following shadow DOM parts are available for styling:
|
|
32
|
-
*
|
|
33
|
-
* Part name | Description | Theme for Element
|
|
34
|
-
* ----------------|----------------|----------------
|
|
35
|
-
* `overlay-content` | The overlay element | vaadin-date-picker-light
|
|
36
|
-
*
|
|
37
31
|
* See [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.
|
|
38
32
|
*
|
|
39
33
|
* In addition to `<vaadin-date-picker-light>` itself, the following
|
|
@@ -73,29 +67,13 @@ class DatePickerLight extends ThemableMixin(DatePickerMixin(ValidateMixin(Polyme
|
|
|
73
67
|
id="overlay"
|
|
74
68
|
fullscreen$="[[_fullscreen]]"
|
|
75
69
|
opened="{{opened}}"
|
|
70
|
+
on-vaadin-overlay-escape-press="_onOverlayEscapePress"
|
|
76
71
|
on-vaadin-overlay-open="_onOverlayOpened"
|
|
77
72
|
on-vaadin-overlay-closing="_onOverlayClosed"
|
|
78
73
|
restore-focus-on-close
|
|
79
74
|
restore-focus-node="[[inputElement]]"
|
|
80
|
-
theme$="[[
|
|
81
|
-
>
|
|
82
|
-
<template>
|
|
83
|
-
<vaadin-date-picker-overlay-content
|
|
84
|
-
id="overlay-content"
|
|
85
|
-
i18n="[[i18n]]"
|
|
86
|
-
fullscreen$="[[_fullscreen]]"
|
|
87
|
-
label="[[label]]"
|
|
88
|
-
selected-date="[[_selectedDate]]"
|
|
89
|
-
focused-date="{{_focusedDate}}"
|
|
90
|
-
show-week-numbers="[[showWeekNumbers]]"
|
|
91
|
-
min-date="[[_minDate]]"
|
|
92
|
-
max-date="[[_maxDate]]"
|
|
93
|
-
part="overlay-content"
|
|
94
|
-
theme$="[[__getOverlayTheme(_theme, _overlayInitialized)]]"
|
|
95
|
-
>
|
|
96
|
-
</vaadin-date-picker-overlay-content>
|
|
97
|
-
</template>
|
|
98
|
-
</vaadin-date-picker-overlay>
|
|
75
|
+
theme$="[[_theme]]"
|
|
76
|
+
></vaadin-date-picker-overlay>
|
|
99
77
|
`;
|
|
100
78
|
}
|
|
101
79
|
|
|
@@ -115,29 +93,13 @@ class DatePickerLight extends ThemableMixin(DatePickerMixin(ValidateMixin(Polyme
|
|
|
115
93
|
type: String,
|
|
116
94
|
value: 'value',
|
|
117
95
|
},
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* @type {boolean}
|
|
121
|
-
* @protected
|
|
122
|
-
*/
|
|
123
|
-
_overlayInitialized: {
|
|
124
|
-
type: Boolean,
|
|
125
|
-
value: true,
|
|
126
|
-
},
|
|
127
96
|
};
|
|
128
97
|
}
|
|
129
98
|
|
|
130
|
-
/** @protected */
|
|
131
|
-
ready() {
|
|
132
|
-
super.ready();
|
|
133
|
-
|
|
134
|
-
this._initOverlay();
|
|
135
|
-
}
|
|
136
|
-
|
|
137
99
|
/** @protected */
|
|
138
100
|
connectedCallback() {
|
|
139
101
|
super.connectedCallback();
|
|
140
|
-
const cssSelector = 'vaadin-text-field
|
|
102
|
+
const cssSelector = 'vaadin-text-field,.input';
|
|
141
103
|
this._setInputElement(this.querySelector(cssSelector));
|
|
142
104
|
this._setFocusElement(this.inputElement);
|
|
143
105
|
}
|
|
@@ -22,8 +22,6 @@ export interface DatePickerI18n {
|
|
|
22
22
|
weekdays: string[];
|
|
23
23
|
weekdaysShort: string[];
|
|
24
24
|
firstDayOfWeek: number;
|
|
25
|
-
week: string;
|
|
26
|
-
calendar: string;
|
|
27
25
|
today: string;
|
|
28
26
|
cancel: string;
|
|
29
27
|
parseDate(date: string): DatePickerDate | undefined;
|
|
@@ -121,13 +119,6 @@ export declare class DatePickerMixinClass {
|
|
|
121
119
|
* // (0 = Sunday, 1 = Monday, etc.).
|
|
122
120
|
* firstDayOfWeek: 0,
|
|
123
121
|
*
|
|
124
|
-
* // Used in screen reader announcements along with week
|
|
125
|
-
* // numbers, if they are displayed.
|
|
126
|
-
* week: 'Week',
|
|
127
|
-
*
|
|
128
|
-
* // Translation of the Calendar icon button title.
|
|
129
|
-
* calendar: 'Calendar',
|
|
130
|
-
*
|
|
131
122
|
* // Translation of the Today shortcut button text.
|
|
132
123
|
* today: 'Today',
|
|
133
124
|
*
|
|
@@ -84,6 +84,7 @@ export const DatePickerMixin = (subclass) =>
|
|
|
84
84
|
*/
|
|
85
85
|
showWeekNumbers: {
|
|
86
86
|
type: Boolean,
|
|
87
|
+
value: false,
|
|
87
88
|
},
|
|
88
89
|
|
|
89
90
|
/**
|
|
@@ -145,13 +146,6 @@ export const DatePickerMixin = (subclass) =>
|
|
|
145
146
|
* // (0 = Sunday, 1 = Monday, etc.).
|
|
146
147
|
* firstDayOfWeek: 0,
|
|
147
148
|
*
|
|
148
|
-
* // Used in screen reader announcements along with week
|
|
149
|
-
* // numbers, if they are displayed.
|
|
150
|
-
* week: 'Week',
|
|
151
|
-
*
|
|
152
|
-
* // Translation of the Calendar icon button title.
|
|
153
|
-
* calendar: 'Calendar',
|
|
154
|
-
*
|
|
155
149
|
* // Translation of the Today shortcut button text.
|
|
156
150
|
* today: 'Today',
|
|
157
151
|
*
|
|
@@ -207,8 +201,6 @@ export const DatePickerMixin = (subclass) =>
|
|
|
207
201
|
weekdays: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
|
|
208
202
|
weekdaysShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
|
|
209
203
|
firstDayOfWeek: 0,
|
|
210
|
-
week: 'Week',
|
|
211
|
-
calendar: 'Calendar',
|
|
212
204
|
today: 'Today',
|
|
213
205
|
cancel: 'Cancel',
|
|
214
206
|
formatDate: (d) => {
|
|
@@ -308,8 +300,8 @@ export const DatePickerMixin = (subclass) =>
|
|
|
308
300
|
/** @private */
|
|
309
301
|
_focusOverlayOnOpen: Boolean,
|
|
310
302
|
|
|
311
|
-
/** @
|
|
312
|
-
|
|
303
|
+
/** @private */
|
|
304
|
+
_overlayContent: Object,
|
|
313
305
|
};
|
|
314
306
|
}
|
|
315
307
|
|
|
@@ -317,6 +309,9 @@ export const DatePickerMixin = (subclass) =>
|
|
|
317
309
|
return [
|
|
318
310
|
'_selectedDateChanged(_selectedDate, i18n.formatDate)',
|
|
319
311
|
'_focusedDateChanged(_focusedDate, i18n.formatDate)',
|
|
312
|
+
'__updateOverlayContent(_overlayContent, i18n, label, _minDate, _maxDate, _focusedDate, _selectedDate, showWeekNumbers)',
|
|
313
|
+
'__updateOverlayContentTheme(_overlayContent, _theme)',
|
|
314
|
+
'__updateOverlayContentFullScreen(_overlayContent, _fullscreen)',
|
|
320
315
|
];
|
|
321
316
|
}
|
|
322
317
|
|
|
@@ -361,6 +356,7 @@ export const DatePickerMixin = (subclass) =>
|
|
|
361
356
|
|
|
362
357
|
this._boundOnClick = this._onClick.bind(this);
|
|
363
358
|
this._boundOnScroll = this._onScroll.bind(this);
|
|
359
|
+
this._boundOverlayRenderer = this._overlayRenderer.bind(this);
|
|
364
360
|
}
|
|
365
361
|
|
|
366
362
|
/**
|
|
@@ -411,6 +407,11 @@ export const DatePickerMixin = (subclass) =>
|
|
|
411
407
|
);
|
|
412
408
|
|
|
413
409
|
this.addController(new VirtualKeyboardController(this));
|
|
410
|
+
|
|
411
|
+
this.$.overlay.renderer = this._boundOverlayRenderer;
|
|
412
|
+
|
|
413
|
+
this.addEventListener('mousedown', () => this.__bringToFront());
|
|
414
|
+
this.addEventListener('touchstart', () => this.__bringToFront());
|
|
414
415
|
}
|
|
415
416
|
|
|
416
417
|
/** @protected */
|
|
@@ -452,33 +453,29 @@ export const DatePickerMixin = (subclass) =>
|
|
|
452
453
|
* Closes the dropdown.
|
|
453
454
|
*/
|
|
454
455
|
close() {
|
|
455
|
-
|
|
456
|
-
this.$.overlay.close();
|
|
457
|
-
}
|
|
456
|
+
this.$.overlay.close();
|
|
458
457
|
}
|
|
459
458
|
|
|
460
|
-
/** @
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
459
|
+
/** @private */
|
|
460
|
+
_overlayRenderer(root) {
|
|
461
|
+
if (root.firstChild) {
|
|
462
|
+
return;
|
|
463
|
+
}
|
|
464
464
|
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
465
|
+
// Create and store document content element
|
|
466
|
+
const content = document.createElement('vaadin-date-picker-overlay-content');
|
|
467
|
+
root.appendChild(content);
|
|
468
468
|
|
|
469
|
-
this
|
|
470
|
-
this._focusedDate = this._selectedDate;
|
|
471
|
-
this._close();
|
|
472
|
-
});
|
|
469
|
+
this._overlayContent = content;
|
|
473
470
|
|
|
474
|
-
|
|
471
|
+
content.addEventListener('close', () => {
|
|
475
472
|
this._close();
|
|
476
473
|
});
|
|
477
474
|
|
|
478
|
-
|
|
475
|
+
content.addEventListener('focus-input', this._focusAndSelect.bind(this));
|
|
479
476
|
|
|
480
477
|
// User confirmed selected date by clicking the calendar.
|
|
481
|
-
|
|
478
|
+
content.addEventListener('date-tap', (e) => {
|
|
482
479
|
this.__userConfirmedDate = true;
|
|
483
480
|
|
|
484
481
|
this._selectDate(e.detail.date);
|
|
@@ -487,7 +484,7 @@ export const DatePickerMixin = (subclass) =>
|
|
|
487
484
|
});
|
|
488
485
|
|
|
489
486
|
// User confirmed selected date by pressing Enter or Today.
|
|
490
|
-
|
|
487
|
+
content.addEventListener('date-selected', (e) => {
|
|
491
488
|
this.__userConfirmedDate = true;
|
|
492
489
|
|
|
493
490
|
this._selectDate(e.detail.date);
|
|
@@ -495,14 +492,16 @@ export const DatePickerMixin = (subclass) =>
|
|
|
495
492
|
|
|
496
493
|
// Set focus-ring attribute when moving focus to the overlay
|
|
497
494
|
// by pressing Tab or arrow key, after opening it on click.
|
|
498
|
-
|
|
495
|
+
content.addEventListener('focusin', () => {
|
|
499
496
|
if (this._keyboardActive) {
|
|
500
497
|
this._setFocused(true);
|
|
501
498
|
}
|
|
502
499
|
});
|
|
503
500
|
|
|
504
|
-
|
|
505
|
-
|
|
501
|
+
// Two-way data binding for `focusedDate` property
|
|
502
|
+
content.addEventListener('focused-date-changed', (e) => {
|
|
503
|
+
this._focusedDate = e.detail.value;
|
|
504
|
+
});
|
|
506
505
|
}
|
|
507
506
|
|
|
508
507
|
/**
|
|
@@ -676,12 +675,6 @@ export const DatePickerMixin = (subclass) =>
|
|
|
676
675
|
|
|
677
676
|
/** @protected */
|
|
678
677
|
_openedChanged(opened) {
|
|
679
|
-
if (opened && !this._overlayInitialized) {
|
|
680
|
-
this._initOverlay();
|
|
681
|
-
}
|
|
682
|
-
if (this._overlayInitialized) {
|
|
683
|
-
this.$.overlay.opened = opened;
|
|
684
|
-
}
|
|
685
678
|
if (this.inputElement) {
|
|
686
679
|
this.inputElement.setAttribute('aria-expanded', opened);
|
|
687
680
|
}
|
|
@@ -717,13 +710,6 @@ export const DatePickerMixin = (subclass) =>
|
|
|
717
710
|
}
|
|
718
711
|
}
|
|
719
712
|
|
|
720
|
-
/** @private */
|
|
721
|
-
__getOverlayTheme(theme, overlayInitialized) {
|
|
722
|
-
if (overlayInitialized) {
|
|
723
|
-
return theme;
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
|
-
|
|
727
713
|
/**
|
|
728
714
|
* Override the value observer from `InputMixin` to implement custom
|
|
729
715
|
* handling of the `value` property. The date-picker doesn't forward
|
|
@@ -762,6 +748,46 @@ export const DatePickerMixin = (subclass) =>
|
|
|
762
748
|
this._toggleHasValue(this._hasValue);
|
|
763
749
|
}
|
|
764
750
|
|
|
751
|
+
/** @private */
|
|
752
|
+
// eslint-disable-next-line max-params
|
|
753
|
+
__updateOverlayContent(overlayContent, i18n, label, minDate, maxDate, focusedDate, selectedDate, showWeekNumbers) {
|
|
754
|
+
if (overlayContent) {
|
|
755
|
+
overlayContent.setProperties({
|
|
756
|
+
i18n,
|
|
757
|
+
label,
|
|
758
|
+
minDate,
|
|
759
|
+
maxDate,
|
|
760
|
+
focusedDate,
|
|
761
|
+
selectedDate,
|
|
762
|
+
showWeekNumbers,
|
|
763
|
+
});
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
/** @private */
|
|
768
|
+
__updateOverlayContentTheme(overlayContent, theme) {
|
|
769
|
+
if (overlayContent) {
|
|
770
|
+
if (theme) {
|
|
771
|
+
overlayContent.setAttribute('theme', theme);
|
|
772
|
+
} else {
|
|
773
|
+
overlayContent.removeAttribute('theme');
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
/** @private */
|
|
779
|
+
__updateOverlayContentFullScreen(overlayContent, fullscreen) {
|
|
780
|
+
if (overlayContent) {
|
|
781
|
+
overlayContent.toggleAttribute('fullscreen', fullscreen);
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
/** @protected */
|
|
786
|
+
_onOverlayEscapePress() {
|
|
787
|
+
this._focusedDate = this._selectedDate;
|
|
788
|
+
this._close();
|
|
789
|
+
}
|
|
790
|
+
|
|
765
791
|
/** @protected */
|
|
766
792
|
_onOverlayOpened() {
|
|
767
793
|
const parsedInitialPosition = this._parseDate(this.initialPosition);
|
|
@@ -996,7 +1022,7 @@ export const DatePickerMixin = (subclass) =>
|
|
|
996
1022
|
const parsedDate = this._getParsedDate();
|
|
997
1023
|
const isValidDate = this._isValidDate(parsedDate);
|
|
998
1024
|
if (this.opened) {
|
|
999
|
-
if (this.
|
|
1025
|
+
if (this._overlayContent && this._overlayContent.focusedDate && isValidDate) {
|
|
1000
1026
|
this._selectDate(this._overlayContent.focusedDate);
|
|
1001
1027
|
}
|
|
1002
1028
|
this.close();
|
|
@@ -1071,7 +1097,7 @@ export const DatePickerMixin = (subclass) =>
|
|
|
1071
1097
|
|
|
1072
1098
|
/** @private */
|
|
1073
1099
|
_userInputValueChanged() {
|
|
1074
|
-
if (this.
|
|
1100
|
+
if (this._inputValue) {
|
|
1075
1101
|
const parsedDate = this._getParsedDate();
|
|
1076
1102
|
|
|
1077
1103
|
if (this._isValidDate(parsedDate)) {
|
|
@@ -1084,11 +1110,6 @@ export const DatePickerMixin = (subclass) =>
|
|
|
1084
1110
|
}
|
|
1085
1111
|
}
|
|
1086
1112
|
|
|
1087
|
-
/** @private */
|
|
1088
|
-
get _overlayContent() {
|
|
1089
|
-
return this.$.overlay.content.querySelector('#overlay-content');
|
|
1090
|
-
}
|
|
1091
|
-
|
|
1092
1113
|
/** @private */
|
|
1093
1114
|
__computeMinOrMaxDate(dateString) {
|
|
1094
1115
|
return this._parseDate(dateString);
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2016 - 2022 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import { html } from '@polymer/polymer/lib/utils/html-tag.js';
|
|
7
|
+
import { dateAfterXMonths } from './vaadin-date-picker-helper.js';
|
|
8
|
+
import { InfiniteScroller } from './vaadin-infinite-scroller.js';
|
|
9
|
+
|
|
10
|
+
const stylesTemplate = html`
|
|
11
|
+
<style>
|
|
12
|
+
:host {
|
|
13
|
+
--vaadin-infinite-scroller-item-height: 270px;
|
|
14
|
+
position: absolute;
|
|
15
|
+
top: 0;
|
|
16
|
+
left: 0;
|
|
17
|
+
right: 0;
|
|
18
|
+
bottom: 0;
|
|
19
|
+
height: 100%;
|
|
20
|
+
}
|
|
21
|
+
</style>
|
|
22
|
+
`;
|
|
23
|
+
|
|
24
|
+
let memoizedTemplate;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* An element used internally by `<vaadin-date-picker>`. Not intended to be used separately.
|
|
28
|
+
*
|
|
29
|
+
* @extends InfiniteScroller
|
|
30
|
+
* @private
|
|
31
|
+
*/
|
|
32
|
+
class DatePickerMonthScroller extends InfiniteScroller {
|
|
33
|
+
static get is() {
|
|
34
|
+
return 'vaadin-date-picker-month-scroller';
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
static get template() {
|
|
38
|
+
if (!memoizedTemplate) {
|
|
39
|
+
memoizedTemplate = super.template.cloneNode(true);
|
|
40
|
+
memoizedTemplate.content.appendChild(stylesTemplate.content.cloneNode(true));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return memoizedTemplate;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
static get properties() {
|
|
47
|
+
return {
|
|
48
|
+
bufferSize: {
|
|
49
|
+
type: Number,
|
|
50
|
+
value: 3,
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* @protected
|
|
57
|
+
* @override
|
|
58
|
+
*/
|
|
59
|
+
_createElement() {
|
|
60
|
+
return document.createElement('vaadin-month-calendar');
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @param {HTMLElement} element
|
|
65
|
+
* @param {number} index
|
|
66
|
+
* @protected
|
|
67
|
+
* @override
|
|
68
|
+
*/
|
|
69
|
+
_updateElement(element, index) {
|
|
70
|
+
element.month = dateAfterXMonths(index);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
customElements.define(DatePickerMonthScroller.is, DatePickerMonthScroller);
|