@vaadin/combo-box 23.2.0-alpha3 → 23.2.0-alpha4

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/combo-box",
3
- "version": "23.2.0-alpha3",
3
+ "version": "23.2.0-alpha4",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -24,7 +24,9 @@
24
24
  "src",
25
25
  "theme",
26
26
  "vaadin-*.d.ts",
27
- "vaadin-*.js"
27
+ "vaadin-*.js",
28
+ "web-types.json",
29
+ "web-types.lit.json"
28
30
  ],
29
31
  "keywords": [
30
32
  "Vaadin",
@@ -36,23 +38,27 @@
36
38
  "dependencies": {
37
39
  "@open-wc/dedupe-mixin": "^1.3.0",
38
40
  "@polymer/polymer": "^3.0.0",
39
- "@vaadin/component-base": "23.2.0-alpha3",
40
- "@vaadin/field-base": "23.2.0-alpha3",
41
- "@vaadin/input-container": "23.2.0-alpha3",
42
- "@vaadin/item": "23.2.0-alpha3",
43
- "@vaadin/lit-renderer": "23.2.0-alpha3",
44
- "@vaadin/vaadin-lumo-styles": "23.2.0-alpha3",
45
- "@vaadin/vaadin-material-styles": "23.2.0-alpha3",
46
- "@vaadin/vaadin-overlay": "23.2.0-alpha3",
47
- "@vaadin/vaadin-themable-mixin": "23.2.0-alpha3"
41
+ "@vaadin/component-base": "23.2.0-alpha4",
42
+ "@vaadin/field-base": "23.2.0-alpha4",
43
+ "@vaadin/input-container": "23.2.0-alpha4",
44
+ "@vaadin/item": "23.2.0-alpha4",
45
+ "@vaadin/lit-renderer": "23.2.0-alpha4",
46
+ "@vaadin/vaadin-lumo-styles": "23.2.0-alpha4",
47
+ "@vaadin/vaadin-material-styles": "23.2.0-alpha4",
48
+ "@vaadin/vaadin-overlay": "23.2.0-alpha4",
49
+ "@vaadin/vaadin-themable-mixin": "23.2.0-alpha4"
48
50
  },
49
51
  "devDependencies": {
50
52
  "@esm-bundle/chai": "^4.3.4",
51
- "@vaadin/polymer-legacy-adapter": "23.2.0-alpha3",
53
+ "@vaadin/polymer-legacy-adapter": "23.2.0-alpha4",
52
54
  "@vaadin/testing-helpers": "^0.3.2",
53
- "@vaadin/text-field": "23.2.0-alpha3",
55
+ "@vaadin/text-field": "23.2.0-alpha4",
54
56
  "lit": "^2.0.0",
55
57
  "sinon": "^13.0.2"
56
58
  },
57
- "gitHead": "06e5875be93ca50da2846dafc65a8531010c0576"
59
+ "web-types": [
60
+ "web-types.json",
61
+ "web-types.lit.json"
62
+ ],
63
+ "gitHead": "cbf5f1d0f38ac9b81c65cf9ef5660182e176e598"
58
64
  }
@@ -20,7 +20,7 @@ export type ComboBoxDataProvider<TItem> = (
20
20
 
21
21
  export declare function ComboBoxDataProviderMixin<TItem, T extends Constructor<HTMLElement>>(
22
22
  base: T,
23
- ): T & Constructor<ComboBoxDataProviderMixinClass<TItem>>;
23
+ ): Constructor<ComboBoxDataProviderMixinClass<TItem>> & T;
24
24
 
25
25
  export declare class ComboBoxDataProviderMixinClass<TItem> {
26
26
  /**
@@ -186,7 +186,7 @@ export const ComboBoxDataProviderMixin = (superClass) =>
186
186
  filteredItems.splice(params.page * params.pageSize, items.length, ...items);
187
187
  this.filteredItems = filteredItems;
188
188
 
189
- if (!this.opened && !this.hasAttribute('focused')) {
189
+ if (!this.opened && !this._isInputFocused()) {
190
190
  this._commitValue();
191
191
  }
192
192
 
@@ -134,13 +134,13 @@ declare class ComboBoxLight<TItem = ComboBoxDefaultItem> extends HTMLElement {
134
134
  addEventListener<K extends keyof ComboBoxLightEventMap<TItem>>(
135
135
  type: K,
136
136
  listener: (this: ComboBoxLight<TItem>, ev: ComboBoxLightEventMap<TItem>[K]) => void,
137
- options?: boolean | AddEventListenerOptions,
137
+ options?: AddEventListenerOptions | boolean,
138
138
  ): void;
139
139
 
140
140
  removeEventListener<K extends keyof ComboBoxLightEventMap<TItem>>(
141
141
  type: K,
142
142
  listener: (this: ComboBoxLight<TItem>, ev: ComboBoxLightEventMap<TItem>[K]) => void,
143
- options?: boolean | EventListenerOptions,
143
+ options?: EventListenerOptions | boolean,
144
144
  ): void;
145
145
  }
146
146
 
@@ -24,11 +24,11 @@ export type ComboBoxRenderer<TItem> = (
24
24
 
25
25
  export declare function ComboBoxMixin<TItem, T extends Constructor<HTMLElement>>(
26
26
  base: T,
27
- ): T &
28
- Constructor<ComboBoxMixinClass<TItem>> &
27
+ ): Constructor<ComboBoxMixinClass<TItem>> &
29
28
  Constructor<DisabledMixinClass> &
30
29
  Constructor<InputMixinClass> &
31
- Constructor<KeyboardMixinClass>;
30
+ Constructor<KeyboardMixinClass> &
31
+ T;
32
32
 
33
33
  export declare class ComboBoxMixinClass<TItem> {
34
34
  /**
@@ -165,16 +165,5 @@ export declare class ComboBoxMixinClass<TItem> {
165
165
  */
166
166
  close(): void;
167
167
 
168
- /**
169
- * Returns true if `value` is valid, and sets the `invalid` flag appropriately.
170
- */
171
- validate(): boolean;
172
-
173
- /**
174
- * Returns true if the current input value satisfies all constraints (if any).
175
- * You can override this method for custom validations.
176
- */
177
- checkValidity(): boolean;
178
-
179
168
  protected _revertInputValue(): void;
180
169
  }
@@ -6,6 +6,7 @@
6
6
  import { isTouch } from '@vaadin/component-base/src/browser-utils.js';
7
7
  import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
8
8
  import { DisabledMixin } from '@vaadin/component-base/src/disabled-mixin.js';
9
+ import { isElementFocused } from '@vaadin/component-base/src/focus-utils.js';
9
10
  import { KeyboardMixin } from '@vaadin/component-base/src/keyboard-mixin.js';
10
11
  import { processTemplates } from '@vaadin/component-base/src/templates.js';
11
12
  import { InputMixin } from '@vaadin/field-base/src/input-mixin.js';
@@ -413,11 +414,6 @@ export const ComboBoxMixin = (subclass) =>
413
414
  // Prevent blurring the input when clicking inside the overlay
414
415
  overlay.addEventListener('mousedown', (e) => e.preventDefault());
415
416
 
416
- // Preventing the default modal behavior of the overlay on input click
417
- overlay.addEventListener('vaadin-overlay-outside-click', (e) => {
418
- e.preventDefault();
419
- });
420
-
421
417
  // Manual two-way binding for the overlay "opened" property
422
418
  overlay.addEventListener('opened-changed', (e) => {
423
419
  this._overlayOpened = e.detail.value;
@@ -511,6 +507,11 @@ export const ComboBoxMixin = (subclass) =>
511
507
  this._updateActiveDescendant(index);
512
508
  }
513
509
 
510
+ /** @protected */
511
+ _isInputFocused() {
512
+ return this.inputElement && isElementFocused(this.inputElement);
513
+ }
514
+
514
515
  /** @private */
515
516
  _updateActiveDescendant(index) {
516
517
  const input = this.inputElement;
@@ -537,14 +538,14 @@ export const ComboBoxMixin = (subclass) =>
537
538
  this._openedWithFocusRing = this.hasAttribute('focus-ring');
538
539
  // For touch devices, we don't want to popup virtual keyboard
539
540
  // unless input element is explicitly focused by the user.
540
- if (!this.hasAttribute('focused') && !isTouch) {
541
+ if (!this._isInputFocused() && !isTouch) {
541
542
  this.focus();
542
543
  }
543
544
 
544
545
  this.$.overlay.restoreFocusOnClose = true;
545
546
  } else {
546
547
  this._onClosed();
547
- if (this._openedWithFocusRing && this.hasAttribute('focused')) {
548
+ if (this._openedWithFocusRing && this._isInputFocused()) {
548
549
  this.setAttribute('focus-ring', '');
549
550
  }
550
551
  }
@@ -618,8 +619,6 @@ export const ComboBoxMixin = (subclass) =>
618
619
 
619
620
  /** @private */
620
621
  _onClick(e) {
621
- this._closeOnBlurIsPrevented = true;
622
-
623
622
  const path = e.composedPath();
624
623
 
625
624
  if (this._isClearButton(e)) {
@@ -629,8 +628,6 @@ export const ComboBoxMixin = (subclass) =>
629
628
  } else {
630
629
  this._onHostClick(e);
631
630
  }
632
-
633
- this._closeOnBlurIsPrevented = false;
634
631
  }
635
632
 
636
633
  /**
@@ -646,16 +643,12 @@ export const ComboBoxMixin = (subclass) =>
646
643
  if (e.key === 'Tab') {
647
644
  this.$.overlay.restoreFocusOnClose = false;
648
645
  } else if (e.key === 'ArrowDown') {
649
- this._closeOnBlurIsPrevented = true;
650
646
  this._onArrowDown();
651
- this._closeOnBlurIsPrevented = false;
652
647
 
653
648
  // Prevent caret from moving
654
649
  e.preventDefault();
655
650
  } else if (e.key === 'ArrowUp') {
656
- this._closeOnBlurIsPrevented = true;
657
651
  this._onArrowUp();
658
- this._closeOnBlurIsPrevented = false;
659
652
 
660
653
  // Prevent caret from moving
661
654
  e.preventDefault();
@@ -726,8 +719,7 @@ export const ComboBoxMixin = (subclass) =>
726
719
  // and there's no need to modify the selection range if the input isn't focused anyway.
727
720
  // This affects Safari. When the overlay is open, and then hitting tab, browser should focus
728
721
  // the next focusable element instead of the combo-box itself.
729
- // Checking the focused property here is enough instead of checking the activeElement.
730
- if (this.hasAttribute('focused')) {
722
+ if (this._isInputFocused() && this.inputElement.setSelectionRange) {
731
723
  this.inputElement.setSelectionRange(start, end);
732
724
  }
733
725
  }
@@ -837,7 +829,7 @@ export const ComboBoxMixin = (subclass) =>
837
829
  toggleElement.addEventListener('mousedown', (e) => e.preventDefault());
838
830
  // Unfocus previously focused element if focus is not inside combo box (on touch devices)
839
831
  toggleElement.addEventListener('click', () => {
840
- if (isTouch && !this.hasAttribute('focused')) {
832
+ if (isTouch && !this._isInputFocused()) {
841
833
  document.activeElement.blur();
842
834
  }
843
835
  });
@@ -221,13 +221,13 @@ declare class ComboBox<TItem = ComboBoxDefaultItem> extends HTMLElement {
221
221
  addEventListener<K extends keyof ComboBoxEventMap<TItem>>(
222
222
  type: K,
223
223
  listener: (this: ComboBox<TItem>, ev: ComboBoxEventMap<TItem>[K]) => void,
224
- options?: boolean | AddEventListenerOptions,
224
+ options?: AddEventListenerOptions | boolean,
225
225
  ): void;
226
226
 
227
227
  removeEventListener<K extends keyof ComboBoxEventMap<TItem>>(
228
228
  type: K,
229
229
  listener: (this: ComboBox<TItem>, ev: ComboBoxEventMap<TItem>[K]) => void,
230
- options?: boolean | EventListenerOptions,
230
+ options?: EventListenerOptions | boolean,
231
231
  ): void;
232
232
  }
233
233