@vaadin/combo-box 23.1.2 → 23.2.0-dev.48e5e3967

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.1.2",
3
+ "version": "23.2.0-dev.48e5e3967",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -19,10 +19,10 @@
19
19
  "main": "vaadin-combo-box.js",
20
20
  "type": "module",
21
21
  "files": [
22
+ "lit.d.ts",
23
+ "lit.js",
22
24
  "src",
23
25
  "theme",
24
- "lit.js",
25
- "lit.d.ts",
26
26
  "vaadin-*.d.ts",
27
27
  "vaadin-*.js"
28
28
  ],
@@ -36,23 +36,23 @@
36
36
  "dependencies": {
37
37
  "@open-wc/dedupe-mixin": "^1.3.0",
38
38
  "@polymer/polymer": "^3.0.0",
39
- "@vaadin/component-base": "^23.1.2",
40
- "@vaadin/field-base": "^23.1.2",
41
- "@vaadin/input-container": "^23.1.2",
42
- "@vaadin/item": "^23.1.2",
43
- "@vaadin/lit-renderer": "^23.1.2",
44
- "@vaadin/vaadin-lumo-styles": "^23.1.2",
45
- "@vaadin/vaadin-material-styles": "^23.1.2",
46
- "@vaadin/vaadin-overlay": "^23.1.2",
47
- "@vaadin/vaadin-themable-mixin": "^23.1.2"
39
+ "@vaadin/component-base": "23.2.0-dev.48e5e3967",
40
+ "@vaadin/field-base": "23.2.0-dev.48e5e3967",
41
+ "@vaadin/input-container": "23.2.0-dev.48e5e3967",
42
+ "@vaadin/item": "23.2.0-dev.48e5e3967",
43
+ "@vaadin/lit-renderer": "23.2.0-dev.48e5e3967",
44
+ "@vaadin/vaadin-lumo-styles": "23.2.0-dev.48e5e3967",
45
+ "@vaadin/vaadin-material-styles": "23.2.0-dev.48e5e3967",
46
+ "@vaadin/vaadin-overlay": "23.2.0-dev.48e5e3967",
47
+ "@vaadin/vaadin-themable-mixin": "23.2.0-dev.48e5e3967"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@esm-bundle/chai": "^4.3.4",
51
- "@vaadin/polymer-legacy-adapter": "^23.1.2",
51
+ "@vaadin/polymer-legacy-adapter": "23.2.0-dev.48e5e3967",
52
52
  "@vaadin/testing-helpers": "^0.3.2",
53
- "@vaadin/text-field": "^23.1.2",
53
+ "@vaadin/text-field": "23.2.0-dev.48e5e3967",
54
54
  "lit": "^2.0.0",
55
55
  "sinon": "^13.0.2"
56
56
  },
57
- "gitHead": "6fb205c6e9a761feadfb779dd5d7af96d3102e56"
57
+ "gitHead": "961bc4ae5b707c3c02f12b99819b3c12c9b478aa"
58
58
  }
@@ -81,7 +81,7 @@ export const ComboBoxDataProviderMixin = (superClass) =>
81
81
  /** @protected */
82
82
  ready() {
83
83
  super.ready();
84
- this.$.dropdown.addEventListener('index-requested', (e) => {
84
+ this._scroller.addEventListener('index-requested', (e) => {
85
85
  const index = e.detail.index;
86
86
  const currentScrollerPos = e.detail.currentScrollerPos;
87
87
  const allowedIndexRange = Math.floor(this.pageSize * 1.5);
@@ -167,44 +167,44 @@ export const ComboBoxDataProviderMixin = (superClass) =>
167
167
  /** @private */
168
168
  _loadPage(page) {
169
169
  // Make sure same page isn't requested multiple times.
170
- if (!this._pendingRequests[page] && this.dataProvider) {
171
- this.loading = true;
172
-
173
- const params = {
174
- page,
175
- pageSize: this.pageSize,
176
- filter: this.filter,
177
- };
178
-
179
- const callback = (items, size) => {
180
- if (this._pendingRequests[page] === callback) {
181
- const filteredItems = this.filteredItems ? [...this.filteredItems] : [];
182
- filteredItems.splice(params.page * params.pageSize, items.length, ...items);
183
- this.filteredItems = filteredItems;
184
-
185
- // Update selectedItem from filteredItems if value is set
186
- if (this._isValidValue(this.value) && this._getItemValue(this.selectedItem) !== this.value) {
187
- this._selectItemForValue(this.value);
188
- }
189
- if (!this.opened && !this.hasAttribute('focused')) {
190
- this._commitValue();
191
- }
192
- this.size = size;
193
-
194
- delete this._pendingRequests[page];
195
-
196
- if (Object.keys(this._pendingRequests).length === 0) {
197
- this.loading = false;
198
- }
199
- }
200
- };
170
+ if (this._pendingRequests[page] || !this.dataProvider) {
171
+ return;
172
+ }
173
+
174
+ const params = {
175
+ page,
176
+ pageSize: this.pageSize,
177
+ filter: this.filter,
178
+ };
201
179
 
202
- if (!this._pendingRequests[page]) {
203
- // Don't request page if it's already being requested
204
- this._pendingRequests[page] = callback;
205
- this.dataProvider(params, callback);
180
+ const callback = (items, size) => {
181
+ if (this._pendingRequests[page] !== callback) {
182
+ return;
206
183
  }
207
- }
184
+
185
+ const filteredItems = this.filteredItems ? [...this.filteredItems] : [];
186
+ filteredItems.splice(params.page * params.pageSize, items.length, ...items);
187
+ this.filteredItems = filteredItems;
188
+
189
+ if (!this.opened && !this.hasAttribute('focused')) {
190
+ this._commitValue();
191
+ }
192
+ this.size = size;
193
+
194
+ delete this._pendingRequests[page];
195
+
196
+ if (Object.keys(this._pendingRequests).length === 0) {
197
+ this.loading = false;
198
+ }
199
+ };
200
+
201
+ this._pendingRequests[page] = callback;
202
+ // Set the `loading` flag only after marking the request as pending
203
+ // to prevent the same page from getting requested multiple times
204
+ // as a result of `__loadingChanged` in the scroller which requests
205
+ // a virtualizer update which in turn may trigger a data provider page request.
206
+ this.loading = true;
207
+ this.dataProvider(params, callback);
208
208
  }
209
209
 
210
210
  /** @private */
@@ -279,7 +279,7 @@ export const ComboBoxDataProviderMixin = (superClass) =>
279
279
  /** @private */
280
280
  _warnDataProviderValue(dataProvider, value) {
281
281
  if (dataProvider && value !== '' && (this.selectedItem === undefined || this.selectedItem === null)) {
282
- const valueIndex = this._indexOfValue(value, this.filteredItems);
282
+ const valueIndex = this.__getItemIndexByValue(this.filteredItems, value);
283
283
  if (valueIndex < 0 || !this._getItemLabel(this.filteredItems[valueIndex])) {
284
284
  console.warn(
285
285
  'Warning: unable to determine the label for the provided `value`. ' +
@@ -6,6 +6,7 @@
6
6
  import { DisabledMixinClass } from '@vaadin/component-base/src/disabled-mixin.js';
7
7
  import { KeyboardMixinClass } from '@vaadin/component-base/src/keyboard-mixin.js';
8
8
  import { InputMixinClass } from '@vaadin/field-base/src/input-mixin.js';
9
+ import { ValidateMixinClass } from '@vaadin/field-base/src/validate-mixin.js';
9
10
  import { ThemableMixinClass } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
10
11
  import { ComboBoxDataProviderMixinClass } from './vaadin-combo-box-data-provider-mixin.js';
11
12
  import { ComboBoxMixinClass } from './vaadin-combo-box-mixin.js';
@@ -142,7 +143,8 @@ interface ComboBoxLight<TItem = ComboBoxDefaultItem>
142
143
  KeyboardMixinClass,
143
144
  InputMixinClass,
144
145
  DisabledMixinClass,
145
- ThemableMixinClass {}
146
+ ThemableMixinClass,
147
+ ValidateMixinClass {}
146
148
 
147
149
  declare global {
148
150
  interface HTMLElementTagNameMap {
@@ -3,9 +3,12 @@
3
3
  * Copyright (c) 2015 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- import './vaadin-combo-box-dropdown.js';
6
+ import './vaadin-combo-box-item.js';
7
+ import './vaadin-combo-box-overlay.js';
8
+ import './vaadin-combo-box-scroller.js';
7
9
  import { dashToCamelCase } from '@polymer/polymer/lib/utils/case-map.js';
8
10
  import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
11
+ import { ValidateMixin } from '@vaadin/field-base/src/validate-mixin.js';
9
12
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
10
13
  import { ComboBoxDataProviderMixin } from './vaadin-combo-box-data-provider-mixin.js';
11
14
  import { ComboBoxMixin } from './vaadin-combo-box-mixin.js';
@@ -59,8 +62,9 @@ import { ComboBoxMixin } from './vaadin-combo-box-mixin.js';
59
62
  * @mixes ComboBoxDataProviderMixin
60
63
  * @mixes ComboBoxMixin
61
64
  * @mixes ThemableMixin
65
+ * @mixes ValidateMixin
62
66
  */
63
- class ComboBoxLight extends ComboBoxDataProviderMixin(ComboBoxMixin(ThemableMixin(PolymerElement))) {
67
+ class ComboBoxLight extends ComboBoxDataProviderMixin(ComboBoxMixin(ValidateMixin(ThemableMixin(PolymerElement)))) {
64
68
  static get is() {
65
69
  return 'vaadin-combo-box-light';
66
70
  }
@@ -75,19 +79,16 @@ class ComboBoxLight extends ComboBoxDataProviderMixin(ComboBoxMixin(ThemableMixi
75
79
 
76
80
  <slot></slot>
77
81
 
78
- <vaadin-combo-box-dropdown
79
- id="dropdown"
80
- opened="[[opened]]"
82
+ <vaadin-combo-box-overlay
83
+ id="overlay"
84
+ hidden$="[[_isOverlayHidden(filteredItems, loading)]]"
85
+ opened="[[_overlayOpened]]"
86
+ loading$="[[loading]]"
87
+ theme$="[[_theme]]"
81
88
  position-target="[[inputElement]]"
82
- restore-focus-on-close="[[__restoreFocusOnClose]]"
89
+ no-vertical-overlap
83
90
  restore-focus-node="[[inputElement]]"
84
- renderer="[[renderer]]"
85
- _focused-index="[[_focusedIndex]]"
86
- _item-id-path="[[itemIdPath]]"
87
- _item-label-path="[[itemLabelPath]]"
88
- loading="[[loading]]"
89
- theme="[[_theme]]"
90
- ></vaadin-combo-box-dropdown>
91
+ ></vaadin-combo-box-overlay>
91
92
  `;
92
93
  }
93
94
 
@@ -138,15 +138,15 @@ export declare class ComboBoxMixinClass<TItem> {
138
138
  */
139
139
  itemIdPath: string | null | undefined;
140
140
 
141
- /**
142
- * Set to true if the value is invalid.
143
- */
144
- invalid: boolean;
145
-
146
141
  protected readonly _propertyForValue: string;
147
142
 
148
143
  protected _inputElementValue: string | undefined;
149
144
 
145
+ /**
146
+ * Tag name prefix used by scroller and items.
147
+ */
148
+ protected readonly _tagNamePrefix: string;
149
+
150
150
  /**
151
151
  * Requests an update for the content of items.
152
152
  * While performing the update, it invokes the renderer (passed in the `renderer` property) once an item.
@@ -177,6 +177,4 @@ export declare class ComboBoxMixinClass<TItem> {
177
177
  checkValidity(): boolean;
178
178
 
179
179
  protected _revertInputValue(): void;
180
-
181
- protected _getItemElements(): HTMLElement[];
182
180
  }