@vaadin/date-picker 23.1.0-beta2 → 23.1.0-rc1

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.1.0-beta2",
3
+ "version": "23.1.0-rc1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -34,21 +34,19 @@
34
34
  "dependencies": {
35
35
  "@open-wc/dedupe-mixin": "^1.3.0",
36
36
  "@polymer/polymer": "^3.2.0",
37
- "@vaadin/button": "23.1.0-beta2",
38
- "@vaadin/component-base": "23.1.0-beta2",
39
- "@vaadin/field-base": "23.1.0-beta2",
40
- "@vaadin/input-container": "23.1.0-beta2",
41
- "@vaadin/vaadin-lumo-styles": "23.1.0-beta2",
42
- "@vaadin/vaadin-material-styles": "23.1.0-beta2",
43
- "@vaadin/vaadin-overlay": "23.1.0-beta2",
44
- "@vaadin/vaadin-themable-mixin": "23.1.0-beta2"
37
+ "@vaadin/button": "23.1.0-rc1",
38
+ "@vaadin/component-base": "23.1.0-rc1",
39
+ "@vaadin/field-base": "23.1.0-rc1",
40
+ "@vaadin/input-container": "23.1.0-rc1",
41
+ "@vaadin/vaadin-lumo-styles": "23.1.0-rc1",
42
+ "@vaadin/vaadin-material-styles": "23.1.0-rc1",
43
+ "@vaadin/vaadin-overlay": "23.1.0-rc1",
44
+ "@vaadin/vaadin-themable-mixin": "23.1.0-rc1"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@esm-bundle/chai": "^4.3.4",
48
- "@vaadin/dialog": "23.1.0-beta2",
49
- "@vaadin/polymer-legacy-adapter": "23.1.0-beta2",
50
48
  "@vaadin/testing-helpers": "^0.3.2",
51
49
  "sinon": "^13.0.2"
52
50
  },
53
- "gitHead": "f11f9245a0b5e6bf912725a501c27c24b74e7c8d"
51
+ "gitHead": "5ecb85e16e938df827fefca4bd2a665a1e29913e"
54
52
  }
@@ -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
  >
@@ -480,6 +480,11 @@ export const DatePickerMixin = (subclass) =>
480
480
 
481
481
  this.$.overlay.addEventListener('opened-changed', (e) => (this.opened = e.detail.value));
482
482
 
483
+ this.$.overlay.addEventListener('vaadin-overlay-escape-press', () => {
484
+ this._focusedDate = this._selectedDate;
485
+ this._close();
486
+ });
487
+
483
488
  this._overlayContent.addEventListener('close', this._close.bind(this));
484
489
  this._overlayContent.addEventListener('focus-input', this._focusAndSelect.bind(this));
485
490
 
@@ -488,6 +493,8 @@ export const DatePickerMixin = (subclass) =>
488
493
  this.__userConfirmedDate = true;
489
494
 
490
495
  this._selectDate(e.detail.date);
496
+
497
+ this._close(e);
491
498
  });
492
499
 
493
500
  // User confirmed selected date by pressing Enter or Today.
@@ -498,7 +505,7 @@ export const DatePickerMixin = (subclass) =>
498
505
  });
499
506
 
500
507
  // Keep focus attribute in focusElement for styling
501
- this._overlayContent.addEventListener('focus', () => {
508
+ this._overlayContent.addEventListener('focusin', () => {
502
509
  this._setFocused(true);
503
510
  });
504
511
 
@@ -767,6 +774,7 @@ export const DatePickerMixin = (subclass) =>
767
774
 
768
775
  if (this._noInput && this.focusElement) {
769
776
  this.focusElement.blur();
777
+ this._overlayContent.focusDateElement();
770
778
  }
771
779
  }
772
780
 
@@ -853,11 +861,7 @@ export const DatePickerMixin = (subclass) =>
853
861
 
854
862
  /** @protected */
855
863
  _focus() {
856
- if (this._noInput) {
857
- if (this._overlayInitialized) {
858
- this._overlayContent.focus();
859
- }
860
- } else {
864
+ if (!this._noInput) {
861
865
  this.inputElement.focus();
862
866
  }
863
867
  }
@@ -973,21 +977,7 @@ export const DatePickerMixin = (subclass) =>
973
977
  break;
974
978
  }
975
979
  case 'Escape':
976
- if (this.opened) {
977
- this._focusedDate = this._selectedDate;
978
- this._close();
979
- } else if (this.clearButtonVisible) {
980
- this._onClearButtonClick();
981
- } else if (this.autoOpenDisabled) {
982
- // Do not restore selected date if Esc was pressed after clearing input field
983
- if (this.inputElement.value === '') {
984
- this._selectDate(null);
985
- }
986
- this._applyInputValue(this._selectedDate);
987
- } else {
988
- this._focusedDate = this._selectedDate;
989
- this._selectParsedOrFocusedDate();
990
- }
980
+ this._onEscape();
991
981
  break;
992
982
  case 'Tab':
993
983
  if (this.opened) {
@@ -1006,6 +996,27 @@ export const DatePickerMixin = (subclass) =>
1006
996
  }
1007
997
  }
1008
998
 
999
+ /** @private */
1000
+ _onEscape() {
1001
+ // Closing overlay is handled in vaadin-overlay-escape-press event listener.
1002
+ if (this.opened) {
1003
+ return;
1004
+ }
1005
+
1006
+ if (this.clearButtonVisible) {
1007
+ this._onClearButtonClick();
1008
+ } else if (this.autoOpenDisabled) {
1009
+ // Do not restore selected date if Esc was pressed after clearing input field
1010
+ if (this.inputElement.value === '') {
1011
+ this._selectDate(null);
1012
+ }
1013
+ this._applyInputValue(this._selectedDate);
1014
+ } else {
1015
+ this._focusedDate = this._selectedDate;
1016
+ this._selectParsedOrFocusedDate();
1017
+ }
1018
+ }
1019
+
1009
1020
  /** @private */
1010
1021
  _getParsedDate(inputValue = this._inputValue) {
1011
1022
  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));
@@ -686,12 +689,6 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
686
689
  }
687
690
 
688
691
  _close() {
689
- const overlayContent = this.getRootNode().host;
690
- const overlay = overlayContent ? overlayContent.getRootNode().host : null;
691
- if (overlay) {
692
- overlay.opened = false;
693
- }
694
-
695
692
  this.dispatchEvent(new CustomEvent('close', { bubbles: true, composed: true }));
696
693
  }
697
694
 
@@ -758,10 +755,6 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
758
755
  this._moveFocusByMonths(event.shiftKey ? -12 : -1);
759
756
  handled = true;
760
757
  break;
761
- case 'Escape':
762
- this._cancel();
763
- handled = true;
764
- break;
765
758
  default:
766
759
  break;
767
760
  }
@@ -785,12 +778,6 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
785
778
  // We need to move the scroll to focused date.
786
779
  setTimeout(() => this.revealDate(this.focusedDate), 1);
787
780
  }
788
-
789
- if (event.key === 'Escape') {
790
- this._cancel();
791
- event.preventDefault();
792
- event.stopPropagation();
793
- }
794
781
  }
795
782
 
796
783
  __onCancelButtonKeyDown(event) {
@@ -805,12 +792,6 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
805
792
  event.stopPropagation();
806
793
  this.dispatchEvent(new CustomEvent('focus-input', { bubbles: true, composed: true }));
807
794
  }
808
-
809
- if (event.key === 'Escape') {
810
- this._cancel();
811
- event.preventDefault();
812
- event.stopPropagation();
813
- }
814
795
  }
815
796
 
816
797
  __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>
@@ -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