@vaadin/date-picker 24.2.0-alpha6 → 24.2.0-alpha8

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-alpha6",
3
+ "version": "24.2.0-alpha8",
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-alpha6",
40
- "@vaadin/button": "24.2.0-alpha6",
41
- "@vaadin/component-base": "24.2.0-alpha6",
42
- "@vaadin/field-base": "24.2.0-alpha6",
43
- "@vaadin/input-container": "24.2.0-alpha6",
44
- "@vaadin/overlay": "24.2.0-alpha6",
45
- "@vaadin/vaadin-lumo-styles": "24.2.0-alpha6",
46
- "@vaadin/vaadin-material-styles": "24.2.0-alpha6",
47
- "@vaadin/vaadin-themable-mixin": "24.2.0-alpha6"
43
+ "@vaadin/a11y-base": "24.2.0-alpha8",
44
+ "@vaadin/button": "24.2.0-alpha8",
45
+ "@vaadin/component-base": "24.2.0-alpha8",
46
+ "@vaadin/field-base": "24.2.0-alpha8",
47
+ "@vaadin/input-container": "24.2.0-alpha8",
48
+ "@vaadin/overlay": "24.2.0-alpha8",
49
+ "@vaadin/vaadin-lumo-styles": "24.2.0-alpha8",
50
+ "@vaadin/vaadin-material-styles": "24.2.0-alpha8",
51
+ "@vaadin/vaadin-themable-mixin": "24.2.0-alpha8"
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": "3ef6e6cd66919b3ef7637e42916e4c54656beb51"
62
+ "gitHead": "2c024e8fd462d178430418f76a61f498fb549998"
59
63
  }
@@ -25,6 +25,11 @@ export type DatePickerLightOpenedChangedEvent = CustomEvent<{ value: boolean }>;
25
25
  */
26
26
  export type DatePickerLightInvalidChangedEvent = CustomEvent<{ value: boolean }>;
27
27
 
28
+ /**
29
+ * Fired when the `dirty` property changes.
30
+ */
31
+ export type DatePickerLightDirtyChangedEvent = CustomEvent<{ value: boolean }>;
32
+
28
33
  /**
29
34
  * Fired when the `value` property changes.
30
35
  */
@@ -40,6 +45,8 @@ export interface DatePickerLightCustomEventMap {
40
45
 
41
46
  'invalid-changed': DatePickerLightInvalidChangedEvent;
42
47
 
48
+ 'dirty-changed': DatePickerLightDirtyChangedEvent;
49
+
43
50
  'value-changed': DatePickerLightValueChangedEvent;
44
51
 
45
52
  validated: DatePickerLightValidatedEvent;
@@ -80,6 +87,7 @@ export interface DatePickerLightEventMap extends HTMLElementEventMap, DatePicker
80
87
  *
81
88
  * @fires {Event} change - Fired when the user commits a value change.
82
89
  * @fires {CustomEvent} opened-changed - Fired when the `opened` property changes.
90
+ * @fires {CustomEvent} dirty-changed - Fired when the `dirty` property changes.
83
91
  * @fires {CustomEvent} value-changed - Fired when the `value` property changes.
84
92
  * @fires {CustomEvent} validated - Fired whenever the field is validated.
85
93
  */
@@ -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)',
@@ -490,6 +506,22 @@ export const DatePickerMixin = (subclass) =>
490
506
  }
491
507
  }
492
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
+
493
525
  /**
494
526
  * Opens the dropdown.
495
527
  */
@@ -639,6 +671,7 @@ export const DatePickerMixin = (subclass) =>
639
671
 
640
672
  // Only set flag if the value will change.
641
673
  if (this.value !== value) {
674
+ this.dirty = true;
642
675
  this.__dispatchChange = true;
643
676
  }
644
677
 
@@ -718,8 +751,8 @@ export const DatePickerMixin = (subclass) =>
718
751
  }
719
752
 
720
753
  /** @private */
721
- _selectedDateChanged(selectedDate, formatDate) {
722
- if (selectedDate === undefined || formatDate === undefined) {
754
+ _selectedDateChanged(selectedDate, i18n) {
755
+ if (selectedDate === undefined || i18n === undefined) {
723
756
  return;
724
757
  }
725
758
  const value = this._formatISO(selectedDate);
@@ -738,8 +771,8 @@ export const DatePickerMixin = (subclass) =>
738
771
  }
739
772
 
740
773
  /** @private */
741
- _focusedDateChanged(focusedDate, formatDate) {
742
- if (focusedDate === undefined || formatDate === undefined) {
774
+ _focusedDateChanged(focusedDate, i18n) {
775
+ if (focusedDate === undefined || i18n === undefined) {
743
776
  return;
744
777
  }
745
778
  if (!this._ignoreFocusedDateChange && !this._noInput) {
@@ -789,15 +822,13 @@ export const DatePickerMixin = (subclass) =>
789
822
  // eslint-disable-next-line max-params
790
823
  __updateOverlayContent(overlayContent, i18n, label, minDate, maxDate, focusedDate, selectedDate, showWeekNumbers) {
791
824
  if (overlayContent) {
792
- overlayContent.setProperties({
793
- i18n,
794
- label,
795
- minDate,
796
- maxDate,
797
- focusedDate,
798
- selectedDate,
799
- showWeekNumbers,
800
- });
825
+ overlayContent.i18n = i18n;
826
+ overlayContent.label = label;
827
+ overlayContent.minDate = minDate;
828
+ overlayContent.maxDate = maxDate;
829
+ overlayContent.focusedDate = focusedDate;
830
+ overlayContent.selectedDate = selectedDate;
831
+ overlayContent.showWeekNumbers = showWeekNumbers;
801
832
  }
802
833
  }
803
834
 
@@ -828,6 +859,7 @@ export const DatePickerMixin = (subclass) =>
828
859
  /** @protected */
829
860
  _onOverlayOpened() {
830
861
  const content = this._overlayContent;
862
+ content.reset();
831
863
 
832
864
  // Detect which date to show
833
865
  const initialPosition = this._getInitialPosition();
@@ -1009,6 +1041,7 @@ export const DatePickerMixin = (subclass) =>
1009
1041
  */
1010
1042
  _onClearButtonClick(event) {
1011
1043
  event.preventDefault();
1044
+ this.dirty = true;
1012
1045
  this._inputElementValue = '';
1013
1046
  this.value = '';
1014
1047
  this.validate();
@@ -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
  /**