@vaadin/date-picker 24.2.0-alpha5 → 24.2.0-alpha7

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-alpha5",
3
+ "version": "24.2.0-alpha7",
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,15 +40,15 @@
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-alpha5",
40
- "@vaadin/button": "24.2.0-alpha5",
41
- "@vaadin/component-base": "24.2.0-alpha5",
42
- "@vaadin/field-base": "24.2.0-alpha5",
43
- "@vaadin/input-container": "24.2.0-alpha5",
44
- "@vaadin/overlay": "24.2.0-alpha5",
45
- "@vaadin/vaadin-lumo-styles": "24.2.0-alpha5",
46
- "@vaadin/vaadin-material-styles": "24.2.0-alpha5",
47
- "@vaadin/vaadin-themable-mixin": "24.2.0-alpha5"
43
+ "@vaadin/a11y-base": "24.2.0-alpha7",
44
+ "@vaadin/button": "24.2.0-alpha7",
45
+ "@vaadin/component-base": "24.2.0-alpha7",
46
+ "@vaadin/field-base": "24.2.0-alpha7",
47
+ "@vaadin/input-container": "24.2.0-alpha7",
48
+ "@vaadin/overlay": "24.2.0-alpha7",
49
+ "@vaadin/vaadin-lumo-styles": "24.2.0-alpha7",
50
+ "@vaadin/vaadin-material-styles": "24.2.0-alpha7",
51
+ "@vaadin/vaadin-themable-mixin": "24.2.0-alpha7"
48
52
  },
49
53
  "devDependencies": {
50
54
  "@esm-bundle/chai": "^4.3.4",
@@ -55,5 +59,5 @@
55
59
  "web-types.json",
56
60
  "web-types.lit.json"
57
61
  ],
58
- "gitHead": "73db22a5e8993e3ce48d1e6540d30eff9cb5c257"
62
+ "gitHead": "81ecf12d2d59a3e5b467273c37a391e31932dc9c"
59
63
  }
@@ -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._selectParsedOrFocusedDate();
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
 
@@ -496,6 +506,22 @@ export const DatePickerMixin = (subclass) =>
496
506
  }
497
507
  }
498
508
 
509
+ /**
510
+ * Override LitElement lifecycle callback to dispatch `change` event if needed.
511
+ * This is necessary to ensure `change` is fired after `value-changed`.
512
+ *
513
+ * @protected
514
+ * @override
515
+ */
516
+ updated(props) {
517
+ super.updated(props);
518
+
519
+ if (props.has('value') && this.__dispatchChange) {
520
+ this.dispatchEvent(new CustomEvent('change', { bubbles: true }));
521
+ this.__dispatchChange = false;
522
+ }
523
+ }
524
+
499
525
  /**
500
526
  * Opens the dropdown.
501
527
  */
@@ -724,8 +750,8 @@ export const DatePickerMixin = (subclass) =>
724
750
  }
725
751
 
726
752
  /** @private */
727
- _selectedDateChanged(selectedDate, formatDate) {
728
- if (selectedDate === undefined || formatDate === undefined) {
753
+ _selectedDateChanged(selectedDate, i18n) {
754
+ if (selectedDate === undefined || i18n === undefined) {
729
755
  return;
730
756
  }
731
757
  const value = this._formatISO(selectedDate);
@@ -744,8 +770,8 @@ export const DatePickerMixin = (subclass) =>
744
770
  }
745
771
 
746
772
  /** @private */
747
- _focusedDateChanged(focusedDate, formatDate) {
748
- if (focusedDate === undefined || formatDate === undefined) {
773
+ _focusedDateChanged(focusedDate, i18n) {
774
+ if (focusedDate === undefined || i18n === undefined) {
749
775
  return;
750
776
  }
751
777
  if (!this._ignoreFocusedDateChange && !this._noInput) {
@@ -795,15 +821,13 @@ export const DatePickerMixin = (subclass) =>
795
821
  // eslint-disable-next-line max-params
796
822
  __updateOverlayContent(overlayContent, i18n, label, minDate, maxDate, focusedDate, selectedDate, showWeekNumbers) {
797
823
  if (overlayContent) {
798
- overlayContent.setProperties({
799
- i18n,
800
- label,
801
- minDate,
802
- maxDate,
803
- focusedDate,
804
- selectedDate,
805
- showWeekNumbers,
806
- });
824
+ overlayContent.i18n = i18n;
825
+ overlayContent.label = label;
826
+ overlayContent.minDate = minDate;
827
+ overlayContent.maxDate = maxDate;
828
+ overlayContent.focusedDate = focusedDate;
829
+ overlayContent.selectedDate = selectedDate;
830
+ overlayContent.showWeekNumbers = showWeekNumbers;
807
831
  }
808
832
  }
809
833
 
@@ -834,6 +858,7 @@ export const DatePickerMixin = (subclass) =>
834
858
  /** @protected */
835
859
  _onOverlayOpened() {
836
860
  const content = this._overlayContent;
861
+ content.reset();
837
862
 
838
863
  // Detect which date to show
839
864
  const initialPosition = this._getInitialPosition();
@@ -3,11 +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 { html } from '@polymer/polymer/lib/utils/html-tag.js';
7
6
  import { dateAfterXMonths } from './vaadin-date-picker-helper.js';
8
7
  import { InfiniteScroller } from './vaadin-infinite-scroller.js';
9
8
 
10
- const stylesTemplate = html`
9
+ const stylesTemplate = document.createElement('template');
10
+ stylesTemplate.innerHTML = `
11
11
  <style>
12
12
  :host {
13
13
  --vaadin-infinite-scroller-item-height: 270px;
@@ -21,8 +21,6 @@ const stylesTemplate = html`
21
21
  </style>
22
22
  `;
23
23
 
24
- let memoizedTemplate;
25
-
26
24
  /**
27
25
  * An element used internally by `<vaadin-date-picker>`. Not intended to be used separately.
28
26
  *
@@ -34,22 +32,11 @@ class DatePickerMonthScroller extends InfiniteScroller {
34
32
  return 'vaadin-date-picker-month-scroller';
35
33
  }
36
34
 
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
- }
35
+ constructor() {
36
+ super();
45
37
 
46
- static get properties() {
47
- return {
48
- bufferSize: {
49
- type: Number,
50
- value: 3,
51
- },
52
- };
38
+ this.bufferSize = 3;
39
+ this.shadowRoot.appendChild(stylesTemplate.content.cloneNode(true));
53
40
  }
54
41
 
55
42
  /**