@vaadin/date-picker 23.0.10 → 23.0.13

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": "23.0.10",
3
+ "version": "23.0.13",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -34,21 +34,20 @@
34
34
  "dependencies": {
35
35
  "@open-wc/dedupe-mixin": "^1.3.0",
36
36
  "@polymer/polymer": "^3.2.0",
37
- "@vaadin/button": "^23.0.10",
38
- "@vaadin/component-base": "^23.0.10",
39
- "@vaadin/field-base": "^23.0.10",
40
- "@vaadin/input-container": "^23.0.10",
41
- "@vaadin/vaadin-lumo-styles": "^23.0.10",
42
- "@vaadin/vaadin-material-styles": "^23.0.10",
43
- "@vaadin/vaadin-overlay": "^23.0.10",
44
- "@vaadin/vaadin-themable-mixin": "^23.0.10"
37
+ "@vaadin/button": "^23.0.13",
38
+ "@vaadin/component-base": "^23.0.13",
39
+ "@vaadin/field-base": "^23.0.13",
40
+ "@vaadin/input-container": "^23.0.13",
41
+ "@vaadin/vaadin-lumo-styles": "^23.0.13",
42
+ "@vaadin/vaadin-material-styles": "^23.0.13",
43
+ "@vaadin/vaadin-overlay": "^23.0.13",
44
+ "@vaadin/vaadin-themable-mixin": "^23.0.13"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@esm-bundle/chai": "^4.3.4",
48
- "@vaadin/dialog": "^23.0.10",
49
- "@vaadin/polymer-legacy-adapter": "^23.0.10",
48
+ "@vaadin/dialog": "^23.0.13",
50
49
  "@vaadin/testing-helpers": "^0.3.2",
51
50
  "sinon": "^9.2.0"
52
51
  },
53
- "gitHead": "e8402a55ce0e823ae6da5c97486998cfd931b1d3"
52
+ "gitHead": "e915550ec6400b5eae6c779fe0afeb1931399312"
54
53
  }
@@ -84,13 +84,10 @@ class DatePickerLight extends ThemableMixin(DatePickerMixin(PolymerElement)) {
84
84
  fullscreen$="[[_fullscreen]]"
85
85
  label="[[label]]"
86
86
  selected-date="[[_selectedDate]]"
87
- slot="dropdown-content"
88
87
  focused-date="{{_focusedDate}}"
89
88
  show-week-numbers="[[showWeekNumbers]]"
90
89
  min-date="[[_minDate]]"
91
90
  max-date="[[_maxDate]]"
92
- on-date-tap="_close"
93
- role="dialog"
94
91
  part="overlay-content"
95
92
  theme$="[[__getOverlayTheme(theme, _overlayInitialized)]]"
96
93
  >
@@ -128,6 +125,13 @@ class DatePickerLight extends ThemableMixin(DatePickerMixin(PolymerElement)) {
128
125
  };
129
126
  }
130
127
 
128
+ /** @protected */
129
+ ready() {
130
+ super.ready();
131
+
132
+ this._initOverlay();
133
+ }
134
+
131
135
  /** @protected */
132
136
  connectedCallback() {
133
137
  super.connectedCallback();
@@ -471,13 +471,18 @@ export const DatePickerMixin = (subclass) =>
471
471
  }
472
472
  }
473
473
 
474
- /** @private */
474
+ /** @protected */
475
475
  _initOverlay() {
476
476
  this.$.overlay.removeAttribute('disable-upgrade');
477
477
  this._overlayInitialized = true;
478
478
 
479
479
  this.$.overlay.addEventListener('opened-changed', (e) => (this.opened = e.detail.value));
480
480
 
481
+ this.$.overlay.addEventListener('vaadin-overlay-escape-press', () => {
482
+ this._focusedDate = this._selectedDate;
483
+ this._close();
484
+ });
485
+
481
486
  this._overlayContent.addEventListener('close', this._close.bind(this));
482
487
  this._overlayContent.addEventListener('focus-input', this._focusAndSelect.bind(this));
483
488
 
@@ -486,6 +491,8 @@ export const DatePickerMixin = (subclass) =>
486
491
  this.__userConfirmedDate = true;
487
492
 
488
493
  this._selectDate(e.detail.date);
494
+
495
+ this._close(e);
489
496
  });
490
497
 
491
498
  // User confirmed selected date by pressing Enter or Today.
@@ -496,12 +503,10 @@ export const DatePickerMixin = (subclass) =>
496
503
  });
497
504
 
498
505
  // Keep focus attribute in focusElement for styling
499
- this._overlayContent.addEventListener('focus', () => {
506
+ this._overlayContent.addEventListener('focusin', () => {
500
507
  this._setFocused(true);
501
508
  });
502
509
 
503
- this.$.overlay.addEventListener('vaadin-overlay-close', this._onVaadinOverlayClose.bind(this));
504
-
505
510
  this.addEventListener('mousedown', () => this.__bringToFront());
506
511
  this.addEventListener('touchstart', () => this.__bringToFront());
507
512
  }
@@ -761,6 +766,7 @@ export const DatePickerMixin = (subclass) =>
761
766
 
762
767
  if (this._noInput && this.focusElement) {
763
768
  this.focusElement.blur();
769
+ this._overlayContent.focusDateElement();
764
770
  }
765
771
  }
766
772
 
@@ -847,9 +853,7 @@ export const DatePickerMixin = (subclass) =>
847
853
 
848
854
  /** @protected */
849
855
  _focus() {
850
- if (this._noInput) {
851
- this._overlayInitialized && this._overlayContent.focus();
852
- } else {
856
+ if (!this._noInput) {
853
857
  this.inputElement.focus();
854
858
  }
855
859
  }
@@ -965,21 +969,7 @@ export const DatePickerMixin = (subclass) =>
965
969
  break;
966
970
  }
967
971
  case 'Escape':
968
- if (this.opened) {
969
- this._focusedDate = this._selectedDate;
970
- this._close();
971
- } else if (this.clearButtonVisible) {
972
- this._onClearButtonClick();
973
- } else if (this.autoOpenDisabled) {
974
- // Do not restore selected date if Esc was pressed after clearing input field
975
- if (this.inputElement.value === '') {
976
- this._selectDate(null);
977
- }
978
- this._applyInputValue(this._selectedDate);
979
- } else {
980
- this._focusedDate = this._selectedDate;
981
- this._selectParsedOrFocusedDate();
982
- }
972
+ this._onEscape();
983
973
  break;
984
974
  case 'Tab':
985
975
  if (this.opened) {
@@ -998,6 +988,27 @@ export const DatePickerMixin = (subclass) =>
998
988
  }
999
989
  }
1000
990
 
991
+ /** @private */
992
+ _onEscape() {
993
+ // Closing overlay is handled in vaadin-overlay-escape-press event listener.
994
+ if (this.opened) {
995
+ return;
996
+ }
997
+
998
+ if (this.clearButtonVisible) {
999
+ this._onClearButtonClick();
1000
+ } else if (this.autoOpenDisabled) {
1001
+ // Do not restore selected date if Esc was pressed after clearing input field
1002
+ if (this.inputElement.value === '') {
1003
+ this._selectDate(null);
1004
+ }
1005
+ this._applyInputValue(this._selectedDate);
1006
+ } else {
1007
+ this._focusedDate = this._selectedDate;
1008
+ this._selectParsedOrFocusedDate();
1009
+ }
1010
+ }
1011
+
1001
1012
  /** @private */
1002
1013
  _getParsedDate(inputValue = this._inputValue) {
1003
1014
  const dateObject = this.i18n.parseDate && this.i18n.parseDate(inputValue);
@@ -326,6 +326,9 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
326
326
 
327
327
  ready() {
328
328
  super.ready();
329
+
330
+ this.setAttribute('role', 'dialog');
331
+
329
332
  addListener(this, 'tap', this._stopPropagation);
330
333
  addListener(this.$.scrollers, 'track', this._track.bind(this));
331
334
  addListener(this.shadowRoot.querySelector('[part="clear-button"]'), 'tap', this._clear.bind(this));
@@ -682,12 +685,6 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
682
685
  }
683
686
 
684
687
  _close() {
685
- const overlayContent = this.getRootNode().host;
686
- const overlay = overlayContent ? overlayContent.getRootNode().host : null;
687
- if (overlay) {
688
- overlay.opened = false;
689
- }
690
-
691
688
  this.dispatchEvent(new CustomEvent('close', { bubbles: true, composed: true }));
692
689
  }
693
690
 
@@ -754,10 +751,6 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
754
751
  this._moveFocusByMonths(event.shiftKey ? -12 : -1);
755
752
  handled = true;
756
753
  break;
757
- case 'Escape':
758
- this._cancel();
759
- handled = true;
760
- break;
761
754
  default:
762
755
  break;
763
756
  }
@@ -770,7 +763,10 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
770
763
 
771
764
  __onTodayButtonKeyDown(event) {
772
765
  if (this.hasAttribute('fullscreen')) {
773
- event.stopPropagation();
766
+ // Do not prevent closing on Esc
767
+ if (event.key !== 'Escape') {
768
+ event.stopPropagation();
769
+ }
774
770
  return;
775
771
  }
776
772
 
@@ -781,17 +777,14 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
781
777
  // We need to move the scroll to focused date.
782
778
  setTimeout(() => this.revealDate(this.focusedDate), 1);
783
779
  }
784
-
785
- if (event.key === 'Escape') {
786
- this._cancel();
787
- event.preventDefault();
788
- event.stopPropagation();
789
- }
790
780
  }
791
781
 
792
782
  __onCancelButtonKeyDown(event) {
793
783
  if (this.hasAttribute('fullscreen')) {
794
- event.stopPropagation();
784
+ // Do not prevent closing on Esc
785
+ if (event.key !== 'Escape') {
786
+ event.stopPropagation();
787
+ }
795
788
  return;
796
789
  }
797
790
 
@@ -801,12 +794,6 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
801
794
  event.stopPropagation();
802
795
  this.dispatchEvent(new CustomEvent('focus-input', { bubbles: true, composed: true }));
803
796
  }
804
-
805
- if (event.key === 'Escape') {
806
- this._cancel();
807
- event.preventDefault();
808
- event.stopPropagation();
809
- }
810
797
  }
811
798
 
812
799
  __tryFocusDate() {
@@ -173,13 +173,10 @@ class DatePicker extends DatePickerMixin(InputControlMixin(ThemableMixin(Element
173
173
  fullscreen$="[[_fullscreen]]"
174
174
  label="[[label]]"
175
175
  selected-date="[[_selectedDate]]"
176
- slot="dropdown-content"
177
176
  focused-date="{{_focusedDate}}"
178
177
  show-week-numbers="[[showWeekNumbers]]"
179
178
  min-date="[[_minDate]]"
180
179
  max-date="[[_maxDate]]"
181
- role="dialog"
182
- on-date-tap="_close"
183
180
  part="overlay-content"
184
181
  theme$="[[__getOverlayTheme(theme, _overlayInitialized)]]"
185
182
  ></vaadin-date-picker-overlay-content>
@@ -215,6 +212,13 @@ class DatePicker extends DatePickerMixin(InputControlMixin(ThemableMixin(Element
215
212
  toggleButton.addEventListener('mousedown', (e) => e.preventDefault());
216
213
  }
217
214
 
215
+ /** @protected */
216
+ _initOverlay() {
217
+ super._initOverlay();
218
+
219
+ this.$.overlay.addEventListener('vaadin-overlay-close', this._onVaadinOverlayClose.bind(this));
220
+ }
221
+
218
222
  /** @private */
219
223
  _onVaadinOverlayClose(e) {
220
224
  if (this._openedWithFocusRing && this.hasAttribute('focused')) {
@@ -1,5 +1,6 @@
1
1
  import '@vaadin/vaadin-lumo-styles/sizing.js';
2
2
  import '@vaadin/vaadin-lumo-styles/spacing.js';
3
+ import '@vaadin/vaadin-overlay/theme/lumo/vaadin-overlay.js';
3
4
  import { menuOverlay } from '@vaadin/vaadin-lumo-styles/mixins/menu-overlay.js';
4
5
  import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
5
6
 
@@ -1,3 +1,4 @@
1
+ import '@vaadin/vaadin-overlay/theme/material/vaadin-overlay.js';
1
2
  import { overlay } from '@vaadin/vaadin-material-styles/mixins/overlay.js';
2
3
  import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
3
4