@vaadin/date-picker 24.2.0-dev.f254716fe → 24.3.0-alpha2

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/date-picker",
3
- "version": "24.2.0-dev.f254716fe",
3
+ "version": "24.3.0-alpha2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -21,6 +21,10 @@
21
21
  "type": "module",
22
22
  "files": [
23
23
  "src",
24
+ "!src/vaadin-lit-date-picker-overlay-content.js",
25
+ "!src/vaadin-lit-date-picker-overlay.js",
26
+ "!src/vaadin-lit-month-calendar.js",
27
+ "!src/vaadin-lit-date-picker.js",
24
28
  "theme",
25
29
  "vaadin-*.d.ts",
26
30
  "vaadin-*.js",
@@ -36,24 +40,24 @@
36
40
  "dependencies": {
37
41
  "@open-wc/dedupe-mixin": "^1.3.0",
38
42
  "@polymer/polymer": "^3.2.0",
39
- "@vaadin/a11y-base": "24.2.0-dev.f254716fe",
40
- "@vaadin/button": "24.2.0-dev.f254716fe",
41
- "@vaadin/component-base": "24.2.0-dev.f254716fe",
42
- "@vaadin/field-base": "24.2.0-dev.f254716fe",
43
- "@vaadin/input-container": "24.2.0-dev.f254716fe",
44
- "@vaadin/overlay": "24.2.0-dev.f254716fe",
45
- "@vaadin/vaadin-lumo-styles": "24.2.0-dev.f254716fe",
46
- "@vaadin/vaadin-material-styles": "24.2.0-dev.f254716fe",
47
- "@vaadin/vaadin-themable-mixin": "24.2.0-dev.f254716fe"
43
+ "@vaadin/a11y-base": "24.3.0-alpha2",
44
+ "@vaadin/button": "24.3.0-alpha2",
45
+ "@vaadin/component-base": "24.3.0-alpha2",
46
+ "@vaadin/field-base": "24.3.0-alpha2",
47
+ "@vaadin/input-container": "24.3.0-alpha2",
48
+ "@vaadin/overlay": "24.3.0-alpha2",
49
+ "@vaadin/vaadin-lumo-styles": "24.3.0-alpha2",
50
+ "@vaadin/vaadin-material-styles": "24.3.0-alpha2",
51
+ "@vaadin/vaadin-themable-mixin": "24.3.0-alpha2"
48
52
  },
49
53
  "devDependencies": {
50
54
  "@esm-bundle/chai": "^4.3.4",
51
- "@vaadin/testing-helpers": "^0.4.3",
55
+ "@vaadin/testing-helpers": "^0.5.0",
52
56
  "sinon": "^13.0.2"
53
57
  },
54
58
  "web-types": [
55
59
  "web-types.json",
56
60
  "web-types.lit.json"
57
61
  ],
58
- "gitHead": "da54950b9f8c14c6451ede0d426e16a489c7fb9b"
62
+ "gitHead": "0fd437292fa2a2f65e29b424d2456909ad2d684b"
59
63
  }
@@ -3,10 +3,11 @@
3
3
  * Copyright (c) 2016 - 2023 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- import './vaadin-date-picker-overlay.js';
7
6
  import './vaadin-date-picker-overlay-content.js';
7
+ import './vaadin-date-picker-overlay.js';
8
8
  import { dashToCamelCase } from '@polymer/polymer/lib/utils/case-map.js';
9
9
  import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
10
+ import { defineCustomElement } from '@vaadin/component-base/src/define.js';
10
11
  import { ValidateMixin } from '@vaadin/field-base/src/validate-mixin.js';
11
12
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
12
13
  import { DatePickerMixin } from './vaadin-date-picker-mixin.js';
@@ -45,6 +46,7 @@ import { DatePickerMixin } from './vaadin-date-picker-mixin.js';
45
46
  * @fires {CustomEvent} value-changed - Fired when the `value` property changes.
46
47
  * @fires {CustomEvent} validated - Fired whenever the field is validated.
47
48
  *
49
+ * @customElement
48
50
  * @extends HTMLElement
49
51
  * @mixes ThemableMixin
50
52
  * @mixes DatePickerMixin
@@ -126,6 +128,6 @@ class DatePickerLight extends ThemableMixin(DatePickerMixin(ValidateMixin(Polyme
126
128
  }
127
129
  }
128
130
 
129
- customElements.define(DatePickerLight.is, DatePickerLight);
131
+ defineCustomElement(DatePickerLight);
130
132
 
131
133
  export { DatePickerLight };
@@ -42,14 +42,18 @@ export const DatePickerMixin = (subclass) =>
42
42
  * @protected
43
43
  */
44
44
  _selectedDate: {
45
- type: Date,
45
+ type: Object,
46
+ sync: true,
46
47
  },
47
48
 
48
49
  /**
49
50
  * @type {Date | undefined}
50
51
  * @protected
51
52
  */
52
- _focusedDate: Date,
53
+ _focusedDate: {
54
+ type: Object,
55
+ sync: true,
56
+ },
53
57
 
54
58
  /**
55
59
  * Selected date.
@@ -64,6 +68,7 @@ export const DatePickerMixin = (subclass) =>
64
68
  type: String,
65
69
  notify: true,
66
70
  value: '',
71
+ sync: true,
67
72
  },
68
73
 
69
74
  /**
@@ -82,6 +87,7 @@ export const DatePickerMixin = (subclass) =>
82
87
  reflectToAttribute: true,
83
88
  notify: true,
84
89
  observer: '_openedChanged',
90
+ sync: true,
85
91
  },
86
92
 
87
93
  /**
@@ -99,6 +105,7 @@ export const DatePickerMixin = (subclass) =>
99
105
  showWeekNumbers: {
100
106
  type: Boolean,
101
107
  value: false,
108
+ sync: true,
102
109
  },
103
110
 
104
111
  /**
@@ -108,6 +115,7 @@ export const DatePickerMixin = (subclass) =>
108
115
  _fullscreen: {
109
116
  type: Boolean,
110
117
  value: false,
118
+ sync: true,
111
119
  },
112
120
 
113
121
  /**
@@ -206,6 +214,7 @@ export const DatePickerMixin = (subclass) =>
206
214
  */
207
215
  i18n: {
208
216
  type: Object,
217
+ sync: true,
209
218
  value: () => {
210
219
  return {
211
220
  monthNames: [
@@ -276,6 +285,7 @@ export const DatePickerMixin = (subclass) =>
276
285
  */
277
286
  min: {
278
287
  type: String,
288
+ sync: true,
279
289
  },
280
290
 
281
291
  /**
@@ -289,6 +299,7 @@ export const DatePickerMixin = (subclass) =>
289
299
  */
290
300
  max: {
291
301
  type: String,
302
+ sync: true,
292
303
  },
293
304
 
294
305
  /**
@@ -299,6 +310,7 @@ export const DatePickerMixin = (subclass) =>
299
310
  _minDate: {
300
311
  type: Date,
301
312
  computed: '__computeMinOrMaxDate(min)',
313
+ sync: true,
302
314
  },
303
315
 
304
316
  /**
@@ -309,6 +321,7 @@ export const DatePickerMixin = (subclass) =>
309
321
  _maxDate: {
310
322
  type: Date,
311
323
  computed: '__computeMinOrMaxDate(max)',
324
+ sync: true,
312
325
  },
313
326
 
314
327
  /** @private */
@@ -327,7 +340,10 @@ export const DatePickerMixin = (subclass) =>
327
340
  _focusOverlayOnOpen: Boolean,
328
341
 
329
342
  /** @private */
330
- _overlayContent: Object,
343
+ _overlayContent: {
344
+ type: Object,
345
+ sync: true,
346
+ },
331
347
 
332
348
  /**
333
349
  * In date-picker, unlike other components extending `InputMixin`,
@@ -347,8 +363,8 @@ export const DatePickerMixin = (subclass) =>
347
363
 
348
364
  static get observers() {
349
365
  return [
350
- '_selectedDateChanged(_selectedDate, i18n.formatDate)',
351
- '_focusedDateChanged(_focusedDate, i18n.formatDate)',
366
+ '_selectedDateChanged(_selectedDate, i18n)',
367
+ '_focusedDateChanged(_focusedDate, i18n)',
352
368
  '__updateOverlayContent(_overlayContent, i18n, label, _minDate, _maxDate, _focusedDate, _selectedDate, showWeekNumbers)',
353
369
  '__updateOverlayContentTheme(_overlayContent, _theme)',
354
370
  '__updateOverlayContentFullScreen(_overlayContent, _fullscreen)',
@@ -431,19 +447,13 @@ export const DatePickerMixin = (subclass) =>
431
447
  super._onBlur(event);
432
448
 
433
449
  if (!this.opened) {
434
- if (this.autoOpenDisabled) {
435
- this._selectParsedOrFocusedDate();
436
- }
450
+ this.__commitParsedOrFocusedDate();
437
451
 
438
452
  // Do not validate when focusout is caused by document
439
453
  // losing focus, which happens on browser tab switch.
440
454
  if (document.hasFocus()) {
441
455
  this.validate();
442
456
  }
443
-
444
- if (this._inputElementValue === '' && this.value !== '') {
445
- this.value = '';
446
- }
447
457
  }
448
458
  }
449
459
 
@@ -477,25 +487,6 @@ export const DatePickerMixin = (subclass) =>
477
487
  this.opened = false;
478
488
  }
479
489
 
480
- /**
481
- * Override Polymer lifecycle callback to dispatch `change` event if needed.
482
- * This is necessary to ensure `change` is fired after `value-changed`.
483
- *
484
- * @param {!Object} currentProps Current accessor values
485
- * @param {?Object} changedProps Properties changed since the last call
486
- * @param {?Object} oldProps Previous values for each changed property
487
- * @protected
488
- * @override
489
- */
490
- _propertiesChanged(currentProps, changedProps, oldProps) {
491
- super._propertiesChanged(currentProps, changedProps, oldProps);
492
-
493
- if ('value' in changedProps && this.__dispatchChange) {
494
- this.dispatchEvent(new CustomEvent('change', { bubbles: true }));
495
- this.__dispatchChange = false;
496
- }
497
- }
498
-
499
490
  /**
500
491
  * Opens the dropdown.
501
492
  */
@@ -532,19 +523,14 @@ export const DatePickerMixin = (subclass) =>
532
523
 
533
524
  // User confirmed selected date by clicking the calendar.
534
525
  content.addEventListener('date-tap', (e) => {
535
- this.__userConfirmedDate = true;
536
-
537
- this._selectDate(e.detail.date);
526
+ this.__commitDate(e.detail.date);
538
527
 
539
528
  this._close();
540
529
  });
541
530
 
542
531
  // User confirmed selected date by pressing Enter, Space, or Today.
543
532
  content.addEventListener('date-selected', (e) => {
544
- // Reset if a date is deselected.
545
- this.__userConfirmedDate = !!e.detail.date;
546
-
547
- this._selectDate(e.detail.date);
533
+ this.__commitDate(e.detail.date);
548
534
  });
549
535
 
550
536
  // Set focus-ring attribute when moving focus to the overlay
@@ -561,6 +547,34 @@ export const DatePickerMixin = (subclass) =>
561
547
  });
562
548
  }
563
549
 
550
+ /**
551
+ * @param {string} dateString
552
+ * @private
553
+ */
554
+ __parseDate(dateString) {
555
+ if (!this.i18n.parseDate) {
556
+ return;
557
+ }
558
+
559
+ let dateObject = this.i18n.parseDate(dateString);
560
+ if (dateObject) {
561
+ dateObject = parseDate(`${dateObject.year}-${dateObject.month + 1}-${dateObject.day}`);
562
+ }
563
+ if (dateObject && !isNaN(dateObject.getTime())) {
564
+ return dateObject;
565
+ }
566
+ }
567
+
568
+ /**
569
+ * @param {Date} dateObject
570
+ * @private
571
+ */
572
+ __formatDate(dateObject) {
573
+ if (this.i18n.formatDate) {
574
+ return this.i18n.formatDate(extractDateParts(dateObject));
575
+ }
576
+ }
577
+
564
578
  /**
565
579
  * Returns true if the current input value satisfies all constraints (if any)
566
580
  *
@@ -570,9 +584,7 @@ export const DatePickerMixin = (subclass) =>
570
584
  */
571
585
  checkValidity() {
572
586
  const inputValue = this._inputElementValue;
573
- const inputValid =
574
- !inputValue ||
575
- (!!this._selectedDate && inputValue === this._getFormattedDate(this.i18n.formatDate, this._selectedDate));
587
+ const inputValid = !inputValue || (!!this._selectedDate && inputValue === this.__formatDate(this._selectedDate));
576
588
  const minMaxValid = !this._selectedDate || dateAllowed(this._selectedDate, this._minDate, this._maxDate);
577
589
 
578
590
  let inputValidity = true;
@@ -633,22 +645,27 @@ export const DatePickerMixin = (subclass) =>
633
645
  this._shouldKeepFocusRing = focused && this._keyboardActive;
634
646
  }
635
647
 
648
+ /** @private */
649
+ __dispatchChange() {
650
+ this.validate();
651
+ this.dispatchEvent(new CustomEvent('change', { bubbles: true }));
652
+ }
653
+
636
654
  /**
637
- * Select date on user interaction and set the flag
638
- * to fire change event if necessary.
655
+ * Sets the given date as the value and fires a change event
656
+ * if the value has changed.
639
657
  *
640
- * @param {Date} dateToSelect
641
- * @protected
658
+ * @param {Date} date
659
+ * @private
642
660
  */
643
- _selectDate(dateToSelect) {
644
- const value = this._formatISO(dateToSelect);
661
+ __commitDate(date) {
662
+ const prevValue = this.value;
645
663
 
646
- // Only set flag if the value will change.
647
- if (this.value !== value) {
648
- this.__dispatchChange = true;
649
- }
664
+ this._selectedDate = date;
650
665
 
651
- this._selectedDate = dateToSelect;
666
+ if (prevValue !== this.value) {
667
+ this.__dispatchChange();
668
+ }
652
669
  }
653
670
 
654
671
  /** @private */
@@ -724,28 +741,24 @@ export const DatePickerMixin = (subclass) =>
724
741
  }
725
742
 
726
743
  /** @private */
727
- _selectedDateChanged(selectedDate, formatDate) {
728
- if (selectedDate === undefined || formatDate === undefined) {
744
+ _selectedDateChanged(selectedDate, i18n) {
745
+ if (selectedDate === undefined || i18n === undefined) {
729
746
  return;
730
747
  }
731
- const value = this._formatISO(selectedDate);
732
748
 
733
749
  if (!this.__keepInputValue) {
734
750
  this._applyInputValue(selectedDate);
735
751
  }
736
752
 
737
- if (value !== this.value) {
738
- this.validate();
739
- this.value = value;
740
- }
753
+ this.value = this._formatISO(selectedDate);
741
754
  this._ignoreFocusedDateChange = true;
742
755
  this._focusedDate = selectedDate;
743
756
  this._ignoreFocusedDateChange = false;
744
757
  }
745
758
 
746
759
  /** @private */
747
- _focusedDateChanged(focusedDate, formatDate) {
748
- if (focusedDate === undefined || formatDate === undefined) {
760
+ _focusedDateChanged(focusedDate, i18n) {
761
+ if (focusedDate === undefined || i18n === undefined) {
749
762
  return;
750
763
  }
751
764
  if (!this._ignoreFocusedDateChange && !this._noInput) {
@@ -795,15 +808,13 @@ export const DatePickerMixin = (subclass) =>
795
808
  // eslint-disable-next-line max-params
796
809
  __updateOverlayContent(overlayContent, i18n, label, minDate, maxDate, focusedDate, selectedDate, showWeekNumbers) {
797
810
  if (overlayContent) {
798
- overlayContent.setProperties({
799
- i18n,
800
- label,
801
- minDate,
802
- maxDate,
803
- focusedDate,
804
- selectedDate,
805
- showWeekNumbers,
806
- });
811
+ overlayContent.i18n = i18n;
812
+ overlayContent.label = label;
813
+ overlayContent.minDate = minDate;
814
+ overlayContent.maxDate = maxDate;
815
+ overlayContent.focusedDate = focusedDate;
816
+ overlayContent.selectedDate = selectedDate;
817
+ overlayContent.showWeekNumbers = showWeekNumbers;
807
818
  }
808
819
  }
809
820
 
@@ -834,6 +845,7 @@ export const DatePickerMixin = (subclass) =>
834
845
  /** @protected */
835
846
  _onOverlayOpened() {
836
847
  const content = this._overlayContent;
848
+ content.reset();
837
849
 
838
850
  // Detect which date to show
839
851
  const initialPosition = this._getInitialPosition();
@@ -879,24 +891,31 @@ export const DatePickerMixin = (subclass) =>
879
891
  : getClosestDate(initialPosition, [this._minDate, this._maxDate]);
880
892
  }
881
893
 
882
- /** @private */
883
- _selectParsedOrFocusedDate() {
894
+ /**
895
+ * Tries to parse the input element's value as a date. When succeeds,
896
+ * sets the resulting date as the value and fires a change event
897
+ * (if the value has changed). If no i18n parser is provided, sets
898
+ * the focused date as the value.
899
+ *
900
+ * @private
901
+ */
902
+ __commitParsedOrFocusedDate() {
884
903
  // Select the parsed input or focused date
885
904
  this._ignoreFocusedDateChange = true;
886
905
  if (this.i18n.parseDate) {
887
906
  const inputValue = this._inputElementValue || '';
888
- const parsedDate = this._getParsedDate(inputValue);
907
+ const parsedDate = this.__parseDate(inputValue);
889
908
 
890
- if (this._isValidDate(parsedDate)) {
891
- this._selectDate(parsedDate);
909
+ if (parsedDate) {
910
+ this.__commitDate(parsedDate);
892
911
  } else {
893
912
  this.__keepInputValue = true;
894
- this._selectDate(null);
913
+ this.__commitDate(null);
895
914
  this._selectedDate = null;
896
915
  this.__keepInputValue = false;
897
916
  }
898
917
  } else if (this._focusedDate) {
899
- this._selectDate(this._focusedDate);
918
+ this.__commitDate(this._focusedDate);
900
919
  }
901
920
  this._ignoreFocusedDateChange = false;
902
921
  }
@@ -911,19 +930,15 @@ export const DatePickerMixin = (subclass) =>
911
930
 
912
931
  window.removeEventListener('scroll', this._boundOnScroll, true);
913
932
 
914
- // No need to select date on close if it was confirmed by the user.
915
- if (this.__userConfirmedDate) {
916
- this.__userConfirmedDate = false;
917
- } else {
918
- this._selectParsedOrFocusedDate();
919
- }
933
+ this.__commitParsedOrFocusedDate();
920
934
 
921
935
  if (this._nativeInput && this._nativeInput.selectionStart) {
922
936
  this._nativeInput.selectionStart = this._nativeInput.selectionEnd;
923
937
  }
924
938
  // No need to revalidate the value after `_selectedDateChanged`
925
- // Needed in case the value was not changed: open and close dropdown.
926
- if (!this.value) {
939
+ // Needed in case the value was not changed: open and close dropdown,
940
+ // especially on outside click. On Esc key press, do not validate.
941
+ if (!this.value && !this._keyboardActive) {
927
942
  this.validate();
928
943
  }
929
944
  }
@@ -950,12 +965,7 @@ export const DatePickerMixin = (subclass) =>
950
965
 
951
966
  /** @private */
952
967
  _applyInputValue(date) {
953
- this._inputElementValue = date ? this._getFormattedDate(this.i18n.formatDate, date) : '';
954
- }
955
-
956
- /** @private */
957
- _getFormattedDate(formatDate, date) {
958
- return formatDate(extractDateParts(date));
968
+ this._inputElementValue = date ? this.__formatDate(date) : '';
959
969
  }
960
970
 
961
971
  /** @private */
@@ -965,23 +975,14 @@ export const DatePickerMixin = (subclass) =>
965
975
  }
966
976
  }
967
977
 
968
- /** @private */
969
- _isValidDate(d) {
970
- return d && !isNaN(d.getTime());
971
- }
972
-
973
978
  /**
974
979
  * Override an event listener from `InputConstraintsMixin`
975
- * to have date-picker fully control when to fire a change event.
980
+ * to have date-picker fully control when to fire a change event
981
+ * and trigger validation.
982
+ *
976
983
  * @protected
977
984
  */
978
985
  _onChange(event) {
979
- // For change event on the native <input> blur, after the input is cleared,
980
- // we schedule change event to be dispatched on date-picker blur.
981
- if (this._inputElementValue === '') {
982
- this.__dispatchChange = true;
983
- }
984
-
985
986
  event.stopPropagation();
986
987
  }
987
988
 
@@ -1015,10 +1016,7 @@ export const DatePickerMixin = (subclass) =>
1015
1016
  */
1016
1017
  _onClearButtonClick(event) {
1017
1018
  event.preventDefault();
1018
- this._inputElementValue = '';
1019
- this.value = '';
1020
- this.validate();
1021
- this.dispatchEvent(new CustomEvent('change', { bubbles: true }));
1019
+ this.__commitDate(null);
1022
1020
  }
1023
1021
 
1024
1022
  /**
@@ -1087,7 +1085,7 @@ export const DatePickerMixin = (subclass) =>
1087
1085
  // Closing will implicitly select parsed or focused date
1088
1086
  this.close();
1089
1087
  } else {
1090
- this._selectParsedOrFocusedDate();
1088
+ this.__commitParsedOrFocusedDate();
1091
1089
  }
1092
1090
  if (oldValue === this.value) {
1093
1091
  this.validate();
@@ -1117,25 +1115,14 @@ export const DatePickerMixin = (subclass) =>
1117
1115
  return;
1118
1116
  }
1119
1117
 
1120
- if (this.autoOpenDisabled) {
1118
+ if (this.inputElement.value === '') {
1121
1119
  // Do not restore selected date if Esc was pressed after clearing input field
1122
- if (this.inputElement.value === '') {
1123
- this._selectDate(null);
1124
- }
1125
- this._applyInputValue(this._selectedDate);
1120
+ this.__commitDate(null);
1126
1121
  } else {
1127
- this._focusedDate = this._selectedDate;
1128
- this._selectParsedOrFocusedDate();
1122
+ this._applyInputValue(this._selectedDate);
1129
1123
  }
1130
1124
  }
1131
1125
 
1132
- /** @private */
1133
- _getParsedDate(inputValue = this._inputElementValue) {
1134
- const dateObject = this.i18n.parseDate && this.i18n.parseDate(inputValue);
1135
- const parsedDate = dateObject && parseDate(`${dateObject.year}-${dateObject.month + 1}-${dateObject.day}`);
1136
- return parsedDate;
1137
- }
1138
-
1139
1126
  /** @protected */
1140
1127
  _isClearButton(event) {
1141
1128
  return event.composedPath()[0] === this.clearElement;
@@ -1146,18 +1133,13 @@ export const DatePickerMixin = (subclass) =>
1146
1133
  * @protected
1147
1134
  */
1148
1135
  _onInput() {
1149
- if (!this.opened && this.inputElement.value && !this.autoOpenDisabled) {
1136
+ if (!this.opened && this._inputElementValue && !this.autoOpenDisabled) {
1150
1137
  this.open();
1151
1138
  }
1152
- this._userInputValueChanged();
1153
- }
1154
1139
 
1155
- /** @private */
1156
- _userInputValueChanged() {
1157
1140
  if (this._inputElementValue) {
1158
- const parsedDate = this._getParsedDate();
1159
-
1160
- if (this._isValidDate(parsedDate)) {
1141
+ const parsedDate = this.__parseDate(this._inputElementValue);
1142
+ if (parsedDate) {
1161
1143
  this._ignoreFocusedDateChange = true;
1162
1144
  if (!dateEquals(parsedDate, this._focusedDate)) {
1163
1145
  this._focusedDate = parsedDate;
@@ -3,11 +3,12 @@
3
3
  * Copyright (c) 2016 - 2023 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- import { html } from '@polymer/polymer/lib/utils/html-tag.js';
6
+ import { defineCustomElement } from '@vaadin/component-base/src/define.js';
7
7
  import { dateAfterXMonths } from './vaadin-date-picker-helper.js';
8
8
  import { InfiniteScroller } from './vaadin-infinite-scroller.js';
9
9
 
10
- const stylesTemplate = html`
10
+ const stylesTemplate = document.createElement('template');
11
+ stylesTemplate.innerHTML = `
11
12
  <style>
12
13
  :host {
13
14
  --vaadin-infinite-scroller-item-height: 270px;
@@ -21,11 +22,10 @@ const stylesTemplate = html`
21
22
  </style>
22
23
  `;
23
24
 
24
- let memoizedTemplate;
25
-
26
25
  /**
27
26
  * An element used internally by `<vaadin-date-picker>`. Not intended to be used separately.
28
27
  *
28
+ * @customElement
29
29
  * @extends InfiniteScroller
30
30
  * @private
31
31
  */
@@ -34,22 +34,11 @@ class DatePickerMonthScroller extends InfiniteScroller {
34
34
  return 'vaadin-date-picker-month-scroller';
35
35
  }
36
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
- }
37
+ constructor() {
38
+ super();
45
39
 
46
- static get properties() {
47
- return {
48
- bufferSize: {
49
- type: Number,
50
- value: 3,
51
- },
52
- };
40
+ this.bufferSize = 3;
41
+ this.shadowRoot.appendChild(stylesTemplate.content.cloneNode(true));
53
42
  }
54
43
 
55
44
  /**
@@ -71,4 +60,4 @@ class DatePickerMonthScroller extends InfiniteScroller {
71
60
  }
72
61
  }
73
62
 
74
- customElements.define(DatePickerMonthScroller.is, DatePickerMonthScroller);
63
+ defineCustomElement(DatePickerMonthScroller);