@vaadin/date-picker 23.1.0-rc2 → 23.1.1

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-rc2",
3
+ "version": "23.1.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -34,19 +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-rc2",
38
- "@vaadin/component-base": "23.1.0-rc2",
39
- "@vaadin/field-base": "23.1.0-rc2",
40
- "@vaadin/input-container": "23.1.0-rc2",
41
- "@vaadin/vaadin-lumo-styles": "23.1.0-rc2",
42
- "@vaadin/vaadin-material-styles": "23.1.0-rc2",
43
- "@vaadin/vaadin-overlay": "23.1.0-rc2",
44
- "@vaadin/vaadin-themable-mixin": "23.1.0-rc2"
37
+ "@vaadin/button": "^23.1.1",
38
+ "@vaadin/component-base": "^23.1.1",
39
+ "@vaadin/field-base": "^23.1.1",
40
+ "@vaadin/input-container": "^23.1.1",
41
+ "@vaadin/vaadin-lumo-styles": "^23.1.1",
42
+ "@vaadin/vaadin-material-styles": "^23.1.1",
43
+ "@vaadin/vaadin-overlay": "^23.1.1",
44
+ "@vaadin/vaadin-themable-mixin": "^23.1.1"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@esm-bundle/chai": "^4.3.4",
48
48
  "@vaadin/testing-helpers": "^0.3.2",
49
49
  "sinon": "^13.0.2"
50
50
  },
51
- "gitHead": "154c6782c42145fed21e443559fbe2d781ad3ec7"
51
+ "gitHead": "390458d6519433a2dd502cef90da48e84573a275"
52
52
  }
@@ -336,7 +336,7 @@ export const DatePickerMixin = (subclass) =>
336
336
  }
337
337
 
338
338
  /**
339
- * Override a getter from `ClearButtonMixin` to make it optional
339
+ * Override a getter from `InputControlMixin` to make it optional
340
340
  * and to prevent warning when a clear button is missing,
341
341
  * for example when using <vaadin-date-picker-light>.
342
342
  * @protected
@@ -370,6 +370,7 @@ export const DatePickerMixin = (subclass) =>
370
370
  constructor() {
371
371
  super();
372
372
 
373
+ this._boundOnClick = this._onClick.bind(this);
373
374
  this._boundOnScroll = this._onScroll.bind(this);
374
375
  }
375
376
 
@@ -414,11 +415,7 @@ export const DatePickerMixin = (subclass) =>
414
415
  ready() {
415
416
  super.ready();
416
417
 
417
- this.addEventListener('click', (e) => {
418
- if (!this._isClearButton(e) && (!this.autoOpenDisabled || this._noInput)) {
419
- this.open();
420
- }
421
- });
418
+ this.addEventListener('click', this._boundOnClick);
422
419
 
423
420
  this.addController(
424
421
  new MediaQueryController(this._fullscreenMediaQuery, (matches) => {
@@ -911,11 +908,35 @@ export const DatePickerMixin = (subclass) =>
911
908
  }
912
909
 
913
910
  /**
914
- * Override an event listener from `ClearButtonMixin`
911
+ * @param {Event} event
912
+ * @private
913
+ */
914
+ _onClick(event) {
915
+ // Clear button click is handled in separate listener
916
+ // but bubbles to the host, so we need to ignore it.
917
+ if (!this._isClearButton(event)) {
918
+ this._onHostClick(event);
919
+ }
920
+ }
921
+
922
+ /**
923
+ * @param {Event} event
924
+ * @private
925
+ */
926
+ _onHostClick(event) {
927
+ if (!this.autoOpenDisabled || this._noInput) {
928
+ event.preventDefault();
929
+ this.open();
930
+ }
931
+ }
932
+
933
+ /**
934
+ * Override an event listener from `InputControlMixin`
915
935
  * to validate and dispatch change on clear.
916
936
  * @protected
917
937
  */
918
- _onClearButtonClick() {
938
+ _onClearButtonClick(event) {
939
+ event.preventDefault();
919
940
  this.value = '';
920
941
  this._inputValue = '';
921
942
  this.validate();
@@ -924,11 +945,13 @@ export const DatePickerMixin = (subclass) =>
924
945
 
925
946
  /**
926
947
  * Override an event listener from `KeyboardMixin`.
927
- * Do not call `super` to also override `ClearButtonMixin`.
948
+ * @param {KeyboardEvent} e
928
949
  * @protected
929
950
  * @override
930
951
  */
931
952
  _onKeyDown(e) {
953
+ super._onKeyDown(e);
954
+
932
955
  if (this._noInput) {
933
956
  // The input element cannot be readonly as it would conflict with
934
957
  // the required attribute. Both are not allowed on an input element.
@@ -955,28 +978,6 @@ export const DatePickerMixin = (subclass) =>
955
978
  this.open();
956
979
  }
957
980
  break;
958
- case 'Enter': {
959
- const parsedDate = this._getParsedDate();
960
- const isValidDate = this._isValidDate(parsedDate);
961
- if (this.opened) {
962
- if (this._overlayInitialized && this._overlayContent.focusedDate && isValidDate) {
963
- this._selectDate(this._overlayContent.focusedDate);
964
- }
965
- this.close();
966
- } else if (!isValidDate && this.inputElement.value !== '') {
967
- this.validate();
968
- } else {
969
- const oldValue = this.value;
970
- this._selectParsedOrFocusedDate();
971
- if (oldValue === this.value) {
972
- this.validate();
973
- }
974
- }
975
- break;
976
- }
977
- case 'Escape':
978
- this._onEscape();
979
- break;
980
981
  case 'Tab':
981
982
  if (this.opened) {
982
983
  e.preventDefault();
@@ -995,16 +996,56 @@ export const DatePickerMixin = (subclass) =>
995
996
  }
996
997
  }
997
998
 
998
- /** @private */
999
- _onEscape() {
999
+ /**
1000
+ * Override an event listener from `KeyboardMixin`.
1001
+ *
1002
+ * @param {!KeyboardEvent} _event
1003
+ * @protected
1004
+ * @override
1005
+ */
1006
+ _onEnter(_event) {
1007
+ const parsedDate = this._getParsedDate();
1008
+ const isValidDate = this._isValidDate(parsedDate);
1009
+ if (this.opened) {
1010
+ if (this._overlayInitialized && this._overlayContent.focusedDate && isValidDate) {
1011
+ this._selectDate(this._overlayContent.focusedDate);
1012
+ }
1013
+ this.close();
1014
+ } else if (!isValidDate && this.inputElement.value !== '') {
1015
+ this.validate();
1016
+ } else {
1017
+ const oldValue = this.value;
1018
+ this._selectParsedOrFocusedDate();
1019
+ if (oldValue === this.value) {
1020
+ this.validate();
1021
+ }
1022
+ }
1023
+ }
1024
+
1025
+ /**
1026
+ * Override an event listener from `KeyboardMixin`.
1027
+ * Do not call `super` in order to override clear
1028
+ * button logic defined in `InputControlMixin`.
1029
+ *
1030
+ * @param {!KeyboardEvent} event
1031
+ * @protected
1032
+ * @override
1033
+ */
1034
+ _onEscape(event) {
1000
1035
  // Closing overlay is handled in vaadin-overlay-escape-press event listener.
1001
1036
  if (this.opened) {
1002
1037
  return;
1003
1038
  }
1004
1039
 
1005
- if (this.clearButtonVisible) {
1006
- this._onClearButtonClick();
1007
- } else if (this.autoOpenDisabled) {
1040
+ if (this.clearButtonVisible && !!this.value) {
1041
+ // Stop event from propagating to the host element
1042
+ // to avoid closing dialog when clearing on Esc
1043
+ event.stopPropagation();
1044
+ this._onClearButtonClick(event);
1045
+ return;
1046
+ }
1047
+
1048
+ if (this.autoOpenDisabled) {
1008
1049
  // Do not restore selected date if Esc was pressed after clearing input field
1009
1050
  if (this.inputElement.value === '') {
1010
1051
  this._selectDate(null);
@@ -235,7 +235,7 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
235
235
  return {
236
236
  scrollDuration: {
237
237
  type: Number,
238
- default: 300,
238
+ value: 300,
239
239
  },
240
240
 
241
241
  /**
@@ -186,7 +186,7 @@ class DatePicker extends DatePickerMixin(InputControlMixin(ThemableMixin(Element
186
186
  }
187
187
 
188
188
  /**
189
- * Used by `ClearButtonMixin` as a reference to the clear button element.
189
+ * Used by `InputControlMixin` as a reference to the clear button element.
190
190
  * @protected
191
191
  * @return {!HTMLElement}
192
192
  */