@vaadin/combo-box 24.0.0-alpha1 → 24.0.0-alpha10
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 +12 -13
- package/src/lit/renderer-directives.d.ts +1 -1
- package/src/lit/renderer-directives.js +1 -1
- package/src/vaadin-combo-box-data-provider-mixin.d.ts +1 -1
- package/src/vaadin-combo-box-data-provider-mixin.js +1 -1
- package/src/vaadin-combo-box-item.js +1 -1
- package/src/vaadin-combo-box-light.d.ts +1 -1
- package/src/vaadin-combo-box-light.js +25 -25
- package/src/vaadin-combo-box-mixin.d.ts +3 -1
- package/src/vaadin-combo-box-mixin.js +35 -25
- package/src/vaadin-combo-box-overlay.js +1 -1
- package/src/vaadin-combo-box-placeholder.js +1 -1
- package/src/vaadin-combo-box-scroller.js +17 -18
- package/src/vaadin-combo-box.d.ts +16 -18
- package/src/vaadin-combo-box.js +13 -17
- package/web-types.json +90 -24
- package/web-types.lit.json +30 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/combo-box",
|
|
3
|
-
"version": "24.0.0-
|
|
3
|
+
"version": "24.0.0-alpha10",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -38,21 +38,20 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
40
40
|
"@polymer/polymer": "^3.0.0",
|
|
41
|
-
"@vaadin/component-base": "24.0.0-
|
|
42
|
-
"@vaadin/field-base": "24.0.0-
|
|
43
|
-
"@vaadin/input-container": "24.0.0-
|
|
44
|
-
"@vaadin/item": "24.0.0-
|
|
45
|
-
"@vaadin/lit-renderer": "24.0.0-
|
|
46
|
-
"@vaadin/overlay": "24.0.0-
|
|
47
|
-
"@vaadin/vaadin-lumo-styles": "24.0.0-
|
|
48
|
-
"@vaadin/vaadin-material-styles": "24.0.0-
|
|
49
|
-
"@vaadin/vaadin-themable-mixin": "24.0.0-
|
|
41
|
+
"@vaadin/component-base": "24.0.0-alpha10",
|
|
42
|
+
"@vaadin/field-base": "24.0.0-alpha10",
|
|
43
|
+
"@vaadin/input-container": "24.0.0-alpha10",
|
|
44
|
+
"@vaadin/item": "24.0.0-alpha10",
|
|
45
|
+
"@vaadin/lit-renderer": "24.0.0-alpha10",
|
|
46
|
+
"@vaadin/overlay": "24.0.0-alpha10",
|
|
47
|
+
"@vaadin/vaadin-lumo-styles": "24.0.0-alpha10",
|
|
48
|
+
"@vaadin/vaadin-material-styles": "24.0.0-alpha10",
|
|
49
|
+
"@vaadin/vaadin-themable-mixin": "24.0.0-alpha10"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@esm-bundle/chai": "^4.3.4",
|
|
53
|
-
"@vaadin/polymer-legacy-adapter": "24.0.0-alpha1",
|
|
54
53
|
"@vaadin/testing-helpers": "^0.3.2",
|
|
55
|
-
"@vaadin/text-field": "24.0.0-
|
|
54
|
+
"@vaadin/text-field": "24.0.0-alpha10",
|
|
56
55
|
"lit": "^2.0.0",
|
|
57
56
|
"sinon": "^13.0.2"
|
|
58
57
|
},
|
|
@@ -60,5 +59,5 @@
|
|
|
60
59
|
"web-types.json",
|
|
61
60
|
"web-types.lit.json"
|
|
62
61
|
],
|
|
63
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "2e04534d8b47bcd216f89b5f849bafef1a73b174"
|
|
64
63
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2015 -
|
|
3
|
+
* Copyright (c) 2015 - 2023 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import type { Constructor } from '@open-wc/dedupe-mixin';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2015 -
|
|
3
|
+
* Copyright (c) 2015 - 2023 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { ComboBoxPlaceholder } from './vaadin-combo-box-placeholder.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2015 -
|
|
3
|
+
* Copyright (c) 2015 - 2023 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2015 -
|
|
3
|
+
* Copyright (c) 2015 - 2023 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import type { DisabledMixinClass } from '@vaadin/component-base/src/disabled-mixin.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2015 -
|
|
3
|
+
* Copyright (c) 2015 - 2023 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import './vaadin-combo-box-item.js';
|
|
@@ -117,30 +117,6 @@ class ComboBoxLight extends ComboBoxDataProviderMixin(ComboBoxMixin(ValidateMixi
|
|
|
117
117
|
return this.querySelector('.clear-button');
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
/** @protected */
|
|
121
|
-
ready() {
|
|
122
|
-
super.ready();
|
|
123
|
-
|
|
124
|
-
this._toggleElement = this.querySelector('.toggle-button');
|
|
125
|
-
|
|
126
|
-
// Wait until the slotted input DOM is ready
|
|
127
|
-
afterNextRender(this, () => {
|
|
128
|
-
this._setInputElement(this.querySelector('vaadin-text-field,.input'));
|
|
129
|
-
this._revertInputValue();
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Returns true if the current input value satisfies all constraints (if any).
|
|
135
|
-
* @return {boolean}
|
|
136
|
-
*/
|
|
137
|
-
checkValidity() {
|
|
138
|
-
if (this.inputElement.validate) {
|
|
139
|
-
return this.inputElement.validate();
|
|
140
|
-
}
|
|
141
|
-
return super.checkValidity();
|
|
142
|
-
}
|
|
143
|
-
|
|
144
120
|
/**
|
|
145
121
|
* @return {string}
|
|
146
122
|
* @protected
|
|
@@ -181,6 +157,30 @@ class ComboBoxLight extends ComboBoxDataProviderMixin(ComboBoxMixin(ValidateMixi
|
|
|
181
157
|
return undefined;
|
|
182
158
|
}
|
|
183
159
|
|
|
160
|
+
/** @protected */
|
|
161
|
+
ready() {
|
|
162
|
+
super.ready();
|
|
163
|
+
|
|
164
|
+
this._toggleElement = this.querySelector('.toggle-button');
|
|
165
|
+
|
|
166
|
+
// Wait until the slotted input DOM is ready
|
|
167
|
+
afterNextRender(this, () => {
|
|
168
|
+
this._setInputElement(this.querySelector('vaadin-text-field,.input'));
|
|
169
|
+
this._revertInputValue();
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Returns true if the current input value satisfies all constraints (if any).
|
|
175
|
+
* @return {boolean}
|
|
176
|
+
*/
|
|
177
|
+
checkValidity() {
|
|
178
|
+
if (this.inputElement.validate) {
|
|
179
|
+
return this.inputElement.validate();
|
|
180
|
+
}
|
|
181
|
+
return super.checkValidity();
|
|
182
|
+
}
|
|
183
|
+
|
|
184
184
|
/** @protected */
|
|
185
185
|
_isClearButton(event) {
|
|
186
186
|
return (
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2015 -
|
|
3
|
+
* Copyright (c) 2015 - 2023 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import type { Constructor } from '@open-wc/dedupe-mixin';
|
|
7
7
|
import type { DisabledMixinClass } from '@vaadin/component-base/src/disabled-mixin.js';
|
|
8
8
|
import type { KeyboardMixinClass } from '@vaadin/component-base/src/keyboard-mixin.js';
|
|
9
|
+
import type { OverlayClassMixinClass } from '@vaadin/component-base/src/overlay-class-mixin.js';
|
|
9
10
|
import type { InputMixinClass } from '@vaadin/field-base/src/input-mixin.js';
|
|
10
11
|
import type { ComboBox } from './vaadin-combo-box.js';
|
|
11
12
|
|
|
@@ -28,6 +29,7 @@ export declare function ComboBoxMixin<TItem, T extends Constructor<HTMLElement>>
|
|
|
28
29
|
Constructor<DisabledMixinClass> &
|
|
29
30
|
Constructor<InputMixinClass> &
|
|
30
31
|
Constructor<KeyboardMixinClass> &
|
|
32
|
+
Constructor<OverlayClassMixinClass> &
|
|
31
33
|
T;
|
|
32
34
|
|
|
33
35
|
export declare class ComboBoxMixinClass<TItem> {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2015 -
|
|
3
|
+
* Copyright (c) 2015 - 2023 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { isTouch } from '@vaadin/component-base/src/browser-utils.js';
|
|
@@ -8,6 +8,7 @@ import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js'
|
|
|
8
8
|
import { DisabledMixin } from '@vaadin/component-base/src/disabled-mixin.js';
|
|
9
9
|
import { isElementFocused } from '@vaadin/component-base/src/focus-utils.js';
|
|
10
10
|
import { KeyboardMixin } from '@vaadin/component-base/src/keyboard-mixin.js';
|
|
11
|
+
import { OverlayClassMixin } from '@vaadin/component-base/src/overlay-class-mixin.js';
|
|
11
12
|
import { processTemplates } from '@vaadin/component-base/src/templates.js';
|
|
12
13
|
import { InputMixin } from '@vaadin/field-base/src/input-mixin.js';
|
|
13
14
|
import { VirtualKeyboardController } from '@vaadin/field-base/src/virtual-keyboard-controller.js';
|
|
@@ -43,10 +44,17 @@ function findItemIndex(items, callback) {
|
|
|
43
44
|
|
|
44
45
|
/**
|
|
45
46
|
* @polymerMixin
|
|
47
|
+
* @mixes ControllerMixin
|
|
48
|
+
* @mixes DisabledMixin
|
|
49
|
+
* @mixes InputMixin
|
|
50
|
+
* @mixes KeyboardMixin
|
|
51
|
+
* @mixes OverlayClassMixin
|
|
46
52
|
* @param {function(new:HTMLElement)} subclass
|
|
47
53
|
*/
|
|
48
54
|
export const ComboBoxMixin = (subclass) =>
|
|
49
|
-
class
|
|
55
|
+
class ComboBoxMixinClass extends OverlayClassMixin(
|
|
56
|
+
ControllerMixin(KeyboardMixin(InputMixin(DisabledMixin(subclass)))),
|
|
57
|
+
) {
|
|
50
58
|
static get properties() {
|
|
51
59
|
return {
|
|
52
60
|
/**
|
|
@@ -262,6 +270,24 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
262
270
|
return 'vaadin-combo-box';
|
|
263
271
|
}
|
|
264
272
|
|
|
273
|
+
/**
|
|
274
|
+
* Get a reference to the native `<input>` element.
|
|
275
|
+
* Override to provide a custom input.
|
|
276
|
+
* @protected
|
|
277
|
+
* @return {HTMLInputElement | undefined}
|
|
278
|
+
*/
|
|
279
|
+
get _nativeInput() {
|
|
280
|
+
return this.inputElement;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* @return {string}
|
|
285
|
+
* @protected
|
|
286
|
+
*/
|
|
287
|
+
get _propertyForValue() {
|
|
288
|
+
return 'value';
|
|
289
|
+
}
|
|
290
|
+
|
|
265
291
|
/**
|
|
266
292
|
* @return {string | undefined}
|
|
267
293
|
* @protected
|
|
@@ -280,16 +306,6 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
280
306
|
}
|
|
281
307
|
}
|
|
282
308
|
|
|
283
|
-
/**
|
|
284
|
-
* Get a reference to the native `<input>` element.
|
|
285
|
-
* Override to provide a custom input.
|
|
286
|
-
* @protected
|
|
287
|
-
* @return {HTMLInputElement | undefined}
|
|
288
|
-
*/
|
|
289
|
-
get _nativeInput() {
|
|
290
|
-
return this.inputElement;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
309
|
/**
|
|
294
310
|
* Override method inherited from `InputMixin`
|
|
295
311
|
* to customize the input element.
|
|
@@ -339,7 +355,7 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
339
355
|
|
|
340
356
|
const bringToFrontListener = () => {
|
|
341
357
|
requestAnimationFrame(() => {
|
|
342
|
-
this
|
|
358
|
+
this._overlayElement.bringToFront();
|
|
343
359
|
});
|
|
344
360
|
};
|
|
345
361
|
|
|
@@ -430,6 +446,8 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
430
446
|
overlay.addEventListener('opened-changed', (e) => {
|
|
431
447
|
this._overlayOpened = e.detail.value;
|
|
432
448
|
});
|
|
449
|
+
|
|
450
|
+
this._overlayElement = overlay;
|
|
433
451
|
}
|
|
434
452
|
|
|
435
453
|
/**
|
|
@@ -441,7 +459,7 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
441
459
|
_initScroller(host) {
|
|
442
460
|
const scrollerTag = `${this._tagNamePrefix}-scroller`;
|
|
443
461
|
|
|
444
|
-
const overlay = this
|
|
462
|
+
const overlay = this._overlayElement;
|
|
445
463
|
|
|
446
464
|
overlay.renderer = (root) => {
|
|
447
465
|
if (!root.firstChild) {
|
|
@@ -547,7 +565,7 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
547
565
|
this.focus();
|
|
548
566
|
}
|
|
549
567
|
|
|
550
|
-
this
|
|
568
|
+
this._overlayElement.restoreFocusOnClose = true;
|
|
551
569
|
} else {
|
|
552
570
|
this._onClosed();
|
|
553
571
|
if (this._openedWithFocusRing && this._isInputFocused()) {
|
|
@@ -646,7 +664,7 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
646
664
|
super._onKeyDown(e);
|
|
647
665
|
|
|
648
666
|
if (e.key === 'Tab') {
|
|
649
|
-
this
|
|
667
|
+
this._overlayElement.restoreFocusOnClose = false;
|
|
650
668
|
} else if (e.key === 'ArrowDown') {
|
|
651
669
|
this._onArrowDown();
|
|
652
670
|
|
|
@@ -944,14 +962,6 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
944
962
|
this.filter = '';
|
|
945
963
|
}
|
|
946
964
|
|
|
947
|
-
/**
|
|
948
|
-
* @return {string}
|
|
949
|
-
* @protected
|
|
950
|
-
*/
|
|
951
|
-
get _propertyForValue() {
|
|
952
|
-
return 'value';
|
|
953
|
-
}
|
|
954
|
-
|
|
955
965
|
/**
|
|
956
966
|
* Override an event listener from `InputMixin`.
|
|
957
967
|
* @param {!Event} event
|
|
@@ -1271,7 +1281,7 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
1271
1281
|
}
|
|
1272
1282
|
|
|
1273
1283
|
// Fixes the problem with `focusout` happening when clicking on the scroll bar on Edge
|
|
1274
|
-
if (event.relatedTarget === this
|
|
1284
|
+
if (event.relatedTarget === this._overlayElement) {
|
|
1275
1285
|
event.composedPath()[0].focus();
|
|
1276
1286
|
return;
|
|
1277
1287
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2015 -
|
|
3
|
+
* Copyright (c) 2015 - 2023 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { Overlay } from '@vaadin/overlay/src/vaadin-overlay.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2015 -
|
|
3
|
+
* Copyright (c) 2015 - 2023 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
@@ -137,6 +137,21 @@ export class ComboBoxScroller extends PolymerElement {
|
|
|
137
137
|
this.__boundOnItemClick = this.__onItemClick.bind(this);
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
+
get _viewportTotalPaddingBottom() {
|
|
141
|
+
if (this._cachedViewportTotalPaddingBottom === undefined) {
|
|
142
|
+
const itemsStyle = window.getComputedStyle(this.$.selector);
|
|
143
|
+
this._cachedViewportTotalPaddingBottom = [itemsStyle.paddingBottom, itemsStyle.borderBottomWidth]
|
|
144
|
+
.map((v) => {
|
|
145
|
+
return parseInt(v, 10);
|
|
146
|
+
})
|
|
147
|
+
.reduce((sum, v) => {
|
|
148
|
+
return sum + v;
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return this._cachedViewportTotalPaddingBottom;
|
|
153
|
+
}
|
|
154
|
+
|
|
140
155
|
__openedChanged(opened) {
|
|
141
156
|
if (opened) {
|
|
142
157
|
this.requestContentUpdate();
|
|
@@ -239,8 +254,6 @@ export class ComboBoxScroller extends PolymerElement {
|
|
|
239
254
|
if (this.__virtualizer && items) {
|
|
240
255
|
this.__virtualizer.size = items.length;
|
|
241
256
|
this.__virtualizer.flush();
|
|
242
|
-
// Ensure the total count of items is properly announced.
|
|
243
|
-
this.setAttribute('aria-setsize', items.length);
|
|
244
257
|
this.requestContentUpdate();
|
|
245
258
|
}
|
|
246
259
|
}
|
|
@@ -305,6 +318,7 @@ export class ComboBoxScroller extends PolymerElement {
|
|
|
305
318
|
el.setAttribute('role', this.__getAriaRole(index));
|
|
306
319
|
el.setAttribute('aria-selected', this.__getAriaSelected(focusedIndex, index));
|
|
307
320
|
el.setAttribute('aria-posinset', index + 1);
|
|
321
|
+
el.setAttribute('aria-setsize', this.items.length);
|
|
308
322
|
|
|
309
323
|
if (this.theme) {
|
|
310
324
|
el.setAttribute('theme', this.theme);
|
|
@@ -339,21 +353,6 @@ export class ComboBoxScroller extends PolymerElement {
|
|
|
339
353
|
});
|
|
340
354
|
}
|
|
341
355
|
|
|
342
|
-
get _viewportTotalPaddingBottom() {
|
|
343
|
-
if (this._cachedViewportTotalPaddingBottom === undefined) {
|
|
344
|
-
const itemsStyle = window.getComputedStyle(this.$.selector);
|
|
345
|
-
this._cachedViewportTotalPaddingBottom = [itemsStyle.paddingBottom, itemsStyle.borderBottomWidth]
|
|
346
|
-
.map((v) => {
|
|
347
|
-
return parseInt(v, 10);
|
|
348
|
-
})
|
|
349
|
-
.reduce((sum, v) => {
|
|
350
|
-
return sum + v;
|
|
351
|
-
});
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
return this._cachedViewportTotalPaddingBottom;
|
|
355
|
-
}
|
|
356
|
-
|
|
357
356
|
/**
|
|
358
357
|
* Dispatches an `index-requested` event for the given index to notify
|
|
359
358
|
* the data provider that it should start loading the page containing the requested index.
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2015 -
|
|
3
|
+
* Copyright (c) 2015 - 2023 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import type { ControllerMixinClass } from '@vaadin/component-base/src/controller-mixin.js';
|
|
7
|
+
import type { DelegateFocusMixinClass } from '@vaadin/component-base/src/delegate-focus-mixin.js';
|
|
8
|
+
import type { DelegateStateMixinClass } from '@vaadin/component-base/src/delegate-state-mixin.js';
|
|
7
9
|
import type { DisabledMixinClass } from '@vaadin/component-base/src/disabled-mixin.js';
|
|
8
10
|
import type { ElementMixinClass } from '@vaadin/component-base/src/element-mixin.js';
|
|
9
11
|
import type { FocusMixinClass } from '@vaadin/component-base/src/focus-mixin.js';
|
|
10
12
|
import type { KeyboardMixinClass } from '@vaadin/component-base/src/keyboard-mixin.js';
|
|
11
|
-
import type {
|
|
12
|
-
import type { DelegateStateMixinClass } from '@vaadin/field-base/src/delegate-state-mixin.js';
|
|
13
|
+
import type { OverlayClassMixinClass } from '@vaadin/component-base/src/overlay-class-mixin.js';
|
|
13
14
|
import type { FieldMixinClass } from '@vaadin/field-base/src/field-mixin.js';
|
|
14
15
|
import type { InputConstraintsMixinClass } from '@vaadin/field-base/src/input-constraints-mixin.js';
|
|
15
16
|
import type { InputControlMixinClass } from '@vaadin/field-base/src/input-control-mixin.js';
|
|
@@ -148,21 +149,17 @@ export interface ComboBoxEventMap<TItem> extends HTMLElementEventMap {
|
|
|
148
149
|
* needs to be set manually. The total number of items can be returned
|
|
149
150
|
* in the second argument of the data provider callback:__
|
|
150
151
|
*
|
|
151
|
-
* ```
|
|
152
|
-
* comboBox.dataProvider =
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
* );
|
|
163
|
-
* };
|
|
164
|
-
* xhr.open('GET', url, true);
|
|
165
|
-
* xhr.send();
|
|
152
|
+
* ```js
|
|
153
|
+
* comboBox.dataProvider = async (params, callback) => {
|
|
154
|
+
* const API = 'https://demo.vaadin.com/demo-data/1.0/filtered-countries';
|
|
155
|
+
* const { filter, page, pageSize } = params;
|
|
156
|
+
* const index = page * pageSize;
|
|
157
|
+
*
|
|
158
|
+
* const res = await fetch(`${API}?index=${index}&count=${pageSize}&filter=${filter}`);
|
|
159
|
+
* if (res.ok) {
|
|
160
|
+
* const { result, size } = await res.json();
|
|
161
|
+
* callback(result, size);
|
|
162
|
+
* }
|
|
166
163
|
* };
|
|
167
164
|
* ```
|
|
168
165
|
*
|
|
@@ -239,6 +236,7 @@ interface ComboBox<TItem = ComboBoxDefaultItem>
|
|
|
239
236
|
PatternMixinClass,
|
|
240
237
|
LabelMixinClass,
|
|
241
238
|
KeyboardMixinClass,
|
|
239
|
+
OverlayClassMixinClass,
|
|
242
240
|
InputMixinClass,
|
|
243
241
|
InputControlMixinClass,
|
|
244
242
|
InputConstraintsMixinClass,
|
package/src/vaadin-combo-box.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2015 -
|
|
3
|
+
* Copyright (c) 2015 - 2023 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import '@vaadin/input-container/src/vaadin-input-container.js';
|
|
@@ -80,21 +80,17 @@ registerStyles('vaadin-combo-box', inputFieldShared, { moduleId: 'vaadin-combo-b
|
|
|
80
80
|
* needs to be set manually. The total number of items can be returned
|
|
81
81
|
* in the second argument of the data provider callback:__
|
|
82
82
|
*
|
|
83
|
-
* ```
|
|
84
|
-
* comboBox.dataProvider =
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
* );
|
|
95
|
-
* };
|
|
96
|
-
* xhr.open('GET', url, true);
|
|
97
|
-
* xhr.send();
|
|
83
|
+
* ```js
|
|
84
|
+
* comboBox.dataProvider = async (params, callback) => {
|
|
85
|
+
* const API = 'https://demo.vaadin.com/demo-data/1.0/filtered-countries';
|
|
86
|
+
* const { filter, page, pageSize } = params;
|
|
87
|
+
* const index = page * pageSize;
|
|
88
|
+
*
|
|
89
|
+
* const res = await fetch(`${API}?index=${index}&count=${pageSize}&filter=${filter}`);
|
|
90
|
+
* if (res.ok) {
|
|
91
|
+
* const { result, size } = await res.json();
|
|
92
|
+
* callback(result, size);
|
|
93
|
+
* }
|
|
98
94
|
* };
|
|
99
95
|
* ```
|
|
100
96
|
*
|
|
@@ -282,7 +278,7 @@ class ComboBox extends ComboBoxDataProviderMixin(
|
|
|
282
278
|
*/
|
|
283
279
|
_shouldRemoveFocus(event) {
|
|
284
280
|
// Do not blur when focus moves to the overlay
|
|
285
|
-
if (event.relatedTarget === this
|
|
281
|
+
if (event.relatedTarget === this._overlayElement) {
|
|
286
282
|
event.composedPath()[0].focus();
|
|
287
283
|
return false;
|
|
288
284
|
}
|
package/web-types.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/web-types",
|
|
3
3
|
"name": "@vaadin/combo-box",
|
|
4
|
-
"version": "24.0.0-
|
|
4
|
+
"version": "24.0.0-alpha10",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"contributions": {
|
|
7
7
|
"html": {
|
|
@@ -29,6 +29,39 @@
|
|
|
29
29
|
]
|
|
30
30
|
}
|
|
31
31
|
},
|
|
32
|
+
{
|
|
33
|
+
"name": "disabled",
|
|
34
|
+
"description": "If true, the user cannot interact with this element.",
|
|
35
|
+
"value": {
|
|
36
|
+
"type": [
|
|
37
|
+
"boolean",
|
|
38
|
+
"null",
|
|
39
|
+
"undefined"
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"name": "value",
|
|
45
|
+
"description": "The value of the field.",
|
|
46
|
+
"value": {
|
|
47
|
+
"type": [
|
|
48
|
+
"string",
|
|
49
|
+
"null",
|
|
50
|
+
"undefined"
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"name": "overlay-class",
|
|
56
|
+
"description": "A space-delimited list of CSS class names to set on the overlay element.\nThis property does not affect other CSS class names set manually via JS.\n\nNote, if the CSS class name was set with this property, clearing it will\nremove it from the overlay, even if the same class name was also added\nmanually, e.g. by using `classList.add()` in the `renderer` function.",
|
|
57
|
+
"value": {
|
|
58
|
+
"type": [
|
|
59
|
+
"string",
|
|
60
|
+
"null",
|
|
61
|
+
"undefined"
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
},
|
|
32
65
|
{
|
|
33
66
|
"name": "opened",
|
|
34
67
|
"description": "True if the dropdown is open, false otherwise.",
|
|
@@ -188,6 +221,39 @@
|
|
|
188
221
|
]
|
|
189
222
|
}
|
|
190
223
|
},
|
|
224
|
+
{
|
|
225
|
+
"name": "disabled",
|
|
226
|
+
"description": "If true, the user cannot interact with this element.",
|
|
227
|
+
"value": {
|
|
228
|
+
"type": [
|
|
229
|
+
"boolean",
|
|
230
|
+
"null",
|
|
231
|
+
"undefined"
|
|
232
|
+
]
|
|
233
|
+
}
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
"name": "value",
|
|
237
|
+
"description": "The value of the field.",
|
|
238
|
+
"value": {
|
|
239
|
+
"type": [
|
|
240
|
+
"string",
|
|
241
|
+
"null",
|
|
242
|
+
"undefined"
|
|
243
|
+
]
|
|
244
|
+
}
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
"name": "overlayClass",
|
|
248
|
+
"description": "A space-delimited list of CSS class names to set on the overlay element.\nThis property does not affect other CSS class names set manually via JS.\n\nNote, if the CSS class name was set with this property, clearing it will\nremove it from the overlay, even if the same class name was also added\nmanually, e.g. by using `classList.add()` in the `renderer` function.",
|
|
249
|
+
"value": {
|
|
250
|
+
"type": [
|
|
251
|
+
"string",
|
|
252
|
+
"null",
|
|
253
|
+
"undefined"
|
|
254
|
+
]
|
|
255
|
+
}
|
|
256
|
+
},
|
|
191
257
|
{
|
|
192
258
|
"name": "opened",
|
|
193
259
|
"description": "True if the dropdown is open, false otherwise.",
|
|
@@ -394,7 +460,7 @@
|
|
|
394
460
|
},
|
|
395
461
|
{
|
|
396
462
|
"name": "vaadin-combo-box",
|
|
397
|
-
"description": "`<vaadin-combo-box>` is a web component for choosing a value from a filterable list of options\npresented in a dropdown overlay. The options can be provided as a list of strings or objects\nby setting [`items`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-
|
|
463
|
+
"description": "`<vaadin-combo-box>` is a web component for choosing a value from a filterable list of options\npresented in a dropdown overlay. The options can be provided as a list of strings or objects\nby setting [`items`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha10/#/elements/vaadin-combo-box#property-items) property on the element.\n\n```html\n<vaadin-combo-box id=\"combo-box\"></vaadin-combo-box>\n```\n```js\ndocument.querySelector('#combo-box').items = ['apple', 'orange', 'banana'];\n```\n\nWhen the selected `value` is changed, a `value-changed` event is triggered.\n\n### Item rendering\n\nTo customize the content of the `<vaadin-combo-box-item>` elements placed in the dropdown, use\n[`renderer`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha10/#/elements/vaadin-combo-box#property-renderer) property which accepts a function.\nThe renderer function is called with `root`, `comboBox`, and `model` as arguments.\n\nGenerate DOM content by using `model` object properties if needed, and append it to the `root`\nelement. The `comboBox` reference is provided to access the combo-box element state. Do not\nset combo-box properties in a `renderer` function.\n\n```js\nconst comboBox = document.querySelector('#combo-box');\ncomboBox.items = [{'label': 'Hydrogen', 'value': 'H'}];\ncomboBox.renderer = (root, comboBox, model) => {\n const item = model.item;\n root.innerHTML = `${model.index}: ${item.label} <b>${item.value}</b>`;\n};\n```\n\nRenderer is called on the opening of the combo-box and each time the related model is updated.\nBefore creating new content, it is recommended to check if there is already an existing DOM\nelement in `root` from a previous renderer call for reusing it. Even though combo-box uses\ninfinite scrolling, reducing DOM operations might improve performance.\n\nThe following properties are available in the `model` argument:\n\nProperty | Type | Description\n-----------|------------------|-------------\n`index` | Number | Index of the item in the `items` array\n`item` | String or Object | The item reference\n`selected` | Boolean | True when item is selected\n`focused` | Boolean | True when item is focused\n\n### Lazy Loading with Function Data Provider\n\nIn addition to assigning an array to the items property, you can alternatively use the\n[`dataProvider`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha10/#/elements/vaadin-combo-box#property-dataProvider) function property.\nThe `<vaadin-combo-box>` calls this function lazily, only when it needs more data\nto be displayed.\n\n__Note that when using function data providers, the total number of items\nneeds to be set manually. The total number of items can be returned\nin the second argument of the data provider callback:__\n\n```js\ncomboBox.dataProvider = async (params, callback) => {\n const API = 'https://demo.vaadin.com/demo-data/1.0/filtered-countries';\n const { filter, page, pageSize } = params;\n const index = page * pageSize;\n\n const res = await fetch(`${API}?index=${index}&count=${pageSize}&filter=${filter}`);\n if (res.ok) {\n const { result, size } = await res.json();\n callback(result, size);\n }\n};\n```\n\n### Styling\n\nThe following custom properties are available for styling:\n\nCustom property | Description | Default\n----------------------------------------|----------------------------|---------\n`--vaadin-field-default-width` | Default width of the field | `12em`\n`--vaadin-combo-box-overlay-width` | Width of the overlay | `auto`\n`--vaadin-combo-box-overlay-max-height` | Max height of the overlay | `65vh`\n\n`<vaadin-combo-box>` provides the same set of shadow DOM parts and state attributes as `<vaadin-text-field>`.\nSee [`<vaadin-text-field>`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha10/#/elements/vaadin-text-field) for the styling documentation.\n\nIn addition to `<vaadin-text-field>` parts, the following parts are available for theming:\n\nPart name | Description\n----------------|----------------\n`toggle-button` | The toggle button\n\nIn addition to `<vaadin-text-field>` state attributes, the following state attributes are available for theming:\n\nAttribute | Description | Part name\n----------|-------------|------------\n`opened` | Set when the combo box dropdown is open | :host\n`loading` | Set when new items are expected | :host\n\nIf you want to replace the default `<input>` and its container with a custom implementation to get full control\nover the input field, consider using the [`<vaadin-combo-box-light>`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha10/#/elements/vaadin-combo-box-light) element.\n\n### Internal components\n\nIn addition to `<vaadin-combo-box>` itself, the following internal\ncomponents are themable:\n\n- `<vaadin-combo-box-overlay>` - has the same API as [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha10/#/elements/vaadin-overlay).\n- `<vaadin-combo-box-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha10/#/elements/vaadin-item).\n- [`<vaadin-input-container>`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha10/#/elements/vaadin-input-container) - an internal element wrapping the input.\n\nNote: the `theme` attribute value set on `<vaadin-combo-box>` is\npropagated to the internal components listed above.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.",
|
|
398
464
|
"attributes": [
|
|
399
465
|
{
|
|
400
466
|
"name": "disabled",
|
|
@@ -570,17 +636,6 @@
|
|
|
570
636
|
]
|
|
571
637
|
}
|
|
572
638
|
},
|
|
573
|
-
{
|
|
574
|
-
"name": "prevent-invalid-input",
|
|
575
|
-
"description": "When set to true, user is prevented from typing a value that\nconflicts with the given `pattern`.",
|
|
576
|
-
"value": {
|
|
577
|
-
"type": [
|
|
578
|
-
"boolean",
|
|
579
|
-
"null",
|
|
580
|
-
"undefined"
|
|
581
|
-
]
|
|
582
|
-
}
|
|
583
|
-
},
|
|
584
639
|
{
|
|
585
640
|
"name": "page-size",
|
|
586
641
|
"description": "Number of items fetched at a time from the dataprovider.",
|
|
@@ -600,6 +655,17 @@
|
|
|
600
655
|
]
|
|
601
656
|
}
|
|
602
657
|
},
|
|
658
|
+
{
|
|
659
|
+
"name": "overlay-class",
|
|
660
|
+
"description": "A space-delimited list of CSS class names to set on the overlay element.\nThis property does not affect other CSS class names set manually via JS.\n\nNote, if the CSS class name was set with this property, clearing it will\nremove it from the overlay, even if the same class name was also added\nmanually, e.g. by using `classList.add()` in the `renderer` function.",
|
|
661
|
+
"value": {
|
|
662
|
+
"type": [
|
|
663
|
+
"string",
|
|
664
|
+
"null",
|
|
665
|
+
"undefined"
|
|
666
|
+
]
|
|
667
|
+
}
|
|
668
|
+
},
|
|
603
669
|
{
|
|
604
670
|
"name": "opened",
|
|
605
671
|
"description": "True if the dropdown is open, false otherwise.",
|
|
@@ -864,17 +930,6 @@
|
|
|
864
930
|
]
|
|
865
931
|
}
|
|
866
932
|
},
|
|
867
|
-
{
|
|
868
|
-
"name": "preventInvalidInput",
|
|
869
|
-
"description": "When set to true, user is prevented from typing a value that\nconflicts with the given `pattern`.",
|
|
870
|
-
"value": {
|
|
871
|
-
"type": [
|
|
872
|
-
"boolean",
|
|
873
|
-
"null",
|
|
874
|
-
"undefined"
|
|
875
|
-
]
|
|
876
|
-
}
|
|
877
|
-
},
|
|
878
933
|
{
|
|
879
934
|
"name": "pageSize",
|
|
880
935
|
"description": "Number of items fetched at a time from the dataprovider.",
|
|
@@ -904,6 +959,17 @@
|
|
|
904
959
|
]
|
|
905
960
|
}
|
|
906
961
|
},
|
|
962
|
+
{
|
|
963
|
+
"name": "overlayClass",
|
|
964
|
+
"description": "A space-delimited list of CSS class names to set on the overlay element.\nThis property does not affect other CSS class names set manually via JS.\n\nNote, if the CSS class name was set with this property, clearing it will\nremove it from the overlay, even if the same class name was also added\nmanually, e.g. by using `classList.add()` in the `renderer` function.",
|
|
965
|
+
"value": {
|
|
966
|
+
"type": [
|
|
967
|
+
"string",
|
|
968
|
+
"null",
|
|
969
|
+
"undefined"
|
|
970
|
+
]
|
|
971
|
+
}
|
|
972
|
+
},
|
|
907
973
|
{
|
|
908
974
|
"name": "opened",
|
|
909
975
|
"description": "True if the dropdown is open, false otherwise.",
|
package/web-types.lit.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/web-types",
|
|
3
3
|
"name": "@vaadin/combo-box",
|
|
4
|
-
"version": "24.0.0-
|
|
4
|
+
"version": "24.0.0-alpha10",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"framework": "lit",
|
|
7
7
|
"framework-config": {
|
|
@@ -19,6 +19,13 @@
|
|
|
19
19
|
"description": "`<vaadin-combo-box-light>` is a customizable version of the `<vaadin-combo-box>` providing\nonly the dropdown functionality and leaving the input field definition to the user.\n\nThe element has the same API as `<vaadin-combo-box>`.\n\nTo create a custom input field, you need to add a child element which has a two-way\ndata-bindable property representing the input value. The property name is expected\nto be `value` by default. For example, you can use `<vaadin-text-field>` element:\n\n```html\n<vaadin-combo-box-light>\n <vaadin-text-field></vaadin-text-field>\n</vaadin-combo-box-light>\n```\n\nIf you are using custom input field that has other property for value,\nset `class=\"input\"` to enable corresponding logic, and use `attr-for-value`\nattribute to specify which property to use:\n\n```html\n<vaadin-combo-box-light attr-for-value=\"input-value\">\n <custom-input class=\"input\"></custom-input>\n</vaadin-combo-box-light>\n```\n\nYou can also pass custom toggle and clear buttons with corresponding classes:\n\n```html\n<vaadin-combo-box-light>\n <custom-input class=\"input\" attr-for-value=\"input-value\">\n <button slot=\"suffix\" class=\"clear-button\">Clear</button>\n <button slot=\"suffix\" class=\"toggle-button\">Toggle</button>\n </custom-input>\n</vaadin-combo-box-light>\n```",
|
|
20
20
|
"extension": true,
|
|
21
21
|
"attributes": [
|
|
22
|
+
{
|
|
23
|
+
"name": "?disabled",
|
|
24
|
+
"description": "If true, the user cannot interact with this element.",
|
|
25
|
+
"value": {
|
|
26
|
+
"kind": "expression"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
22
29
|
{
|
|
23
30
|
"name": "?opened",
|
|
24
31
|
"description": "True if the dropdown is open, false otherwise.",
|
|
@@ -89,6 +96,20 @@
|
|
|
89
96
|
"kind": "expression"
|
|
90
97
|
}
|
|
91
98
|
},
|
|
99
|
+
{
|
|
100
|
+
"name": ".value",
|
|
101
|
+
"description": "The value of the field.",
|
|
102
|
+
"value": {
|
|
103
|
+
"kind": "expression"
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"name": ".overlayClass",
|
|
108
|
+
"description": "A space-delimited list of CSS class names to set on the overlay element.\nThis property does not affect other CSS class names set manually via JS.\n\nNote, if the CSS class name was set with this property, clearing it will\nremove it from the overlay, even if the same class name was also added\nmanually, e.g. by using `classList.add()` in the `renderer` function.",
|
|
109
|
+
"value": {
|
|
110
|
+
"kind": "expression"
|
|
111
|
+
}
|
|
112
|
+
},
|
|
92
113
|
{
|
|
93
114
|
"name": ".renderer",
|
|
94
115
|
"description": "Custom function for rendering the content of every item.\nReceives three arguments:\n\n- `root` The `<vaadin-combo-box-item>` internal container DOM element.\n- `comboBox` The reference to the `<vaadin-combo-box>` element.\n- `model` The object with the properties related with the rendered\n item, contains:\n - `model.index` The index of the rendered item.\n - `model.item` The item.",
|
|
@@ -226,7 +247,7 @@
|
|
|
226
247
|
},
|
|
227
248
|
{
|
|
228
249
|
"name": "vaadin-combo-box",
|
|
229
|
-
"description": "`<vaadin-combo-box>` is a web component for choosing a value from a filterable list of options\npresented in a dropdown overlay. The options can be provided as a list of strings or objects\nby setting [`items`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-
|
|
250
|
+
"description": "`<vaadin-combo-box>` is a web component for choosing a value from a filterable list of options\npresented in a dropdown overlay. The options can be provided as a list of strings or objects\nby setting [`items`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha10/#/elements/vaadin-combo-box#property-items) property on the element.\n\n```html\n<vaadin-combo-box id=\"combo-box\"></vaadin-combo-box>\n```\n```js\ndocument.querySelector('#combo-box').items = ['apple', 'orange', 'banana'];\n```\n\nWhen the selected `value` is changed, a `value-changed` event is triggered.\n\n### Item rendering\n\nTo customize the content of the `<vaadin-combo-box-item>` elements placed in the dropdown, use\n[`renderer`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha10/#/elements/vaadin-combo-box#property-renderer) property which accepts a function.\nThe renderer function is called with `root`, `comboBox`, and `model` as arguments.\n\nGenerate DOM content by using `model` object properties if needed, and append it to the `root`\nelement. The `comboBox` reference is provided to access the combo-box element state. Do not\nset combo-box properties in a `renderer` function.\n\n```js\nconst comboBox = document.querySelector('#combo-box');\ncomboBox.items = [{'label': 'Hydrogen', 'value': 'H'}];\ncomboBox.renderer = (root, comboBox, model) => {\n const item = model.item;\n root.innerHTML = `${model.index}: ${item.label} <b>${item.value}</b>`;\n};\n```\n\nRenderer is called on the opening of the combo-box and each time the related model is updated.\nBefore creating new content, it is recommended to check if there is already an existing DOM\nelement in `root` from a previous renderer call for reusing it. Even though combo-box uses\ninfinite scrolling, reducing DOM operations might improve performance.\n\nThe following properties are available in the `model` argument:\n\nProperty | Type | Description\n-----------|------------------|-------------\n`index` | Number | Index of the item in the `items` array\n`item` | String or Object | The item reference\n`selected` | Boolean | True when item is selected\n`focused` | Boolean | True when item is focused\n\n### Lazy Loading with Function Data Provider\n\nIn addition to assigning an array to the items property, you can alternatively use the\n[`dataProvider`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha10/#/elements/vaadin-combo-box#property-dataProvider) function property.\nThe `<vaadin-combo-box>` calls this function lazily, only when it needs more data\nto be displayed.\n\n__Note that when using function data providers, the total number of items\nneeds to be set manually. The total number of items can be returned\nin the second argument of the data provider callback:__\n\n```js\ncomboBox.dataProvider = async (params, callback) => {\n const API = 'https://demo.vaadin.com/demo-data/1.0/filtered-countries';\n const { filter, page, pageSize } = params;\n const index = page * pageSize;\n\n const res = await fetch(`${API}?index=${index}&count=${pageSize}&filter=${filter}`);\n if (res.ok) {\n const { result, size } = await res.json();\n callback(result, size);\n }\n};\n```\n\n### Styling\n\nThe following custom properties are available for styling:\n\nCustom property | Description | Default\n----------------------------------------|----------------------------|---------\n`--vaadin-field-default-width` | Default width of the field | `12em`\n`--vaadin-combo-box-overlay-width` | Width of the overlay | `auto`\n`--vaadin-combo-box-overlay-max-height` | Max height of the overlay | `65vh`\n\n`<vaadin-combo-box>` provides the same set of shadow DOM parts and state attributes as `<vaadin-text-field>`.\nSee [`<vaadin-text-field>`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha10/#/elements/vaadin-text-field) for the styling documentation.\n\nIn addition to `<vaadin-text-field>` parts, the following parts are available for theming:\n\nPart name | Description\n----------------|----------------\n`toggle-button` | The toggle button\n\nIn addition to `<vaadin-text-field>` state attributes, the following state attributes are available for theming:\n\nAttribute | Description | Part name\n----------|-------------|------------\n`opened` | Set when the combo box dropdown is open | :host\n`loading` | Set when new items are expected | :host\n\nIf you want to replace the default `<input>` and its container with a custom implementation to get full control\nover the input field, consider using the [`<vaadin-combo-box-light>`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha10/#/elements/vaadin-combo-box-light) element.\n\n### Internal components\n\nIn addition to `<vaadin-combo-box>` itself, the following internal\ncomponents are themable:\n\n- `<vaadin-combo-box-overlay>` - has the same API as [`<vaadin-overlay>`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha10/#/elements/vaadin-overlay).\n- `<vaadin-combo-box-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha10/#/elements/vaadin-item).\n- [`<vaadin-input-container>`](https://cdn.vaadin.com/vaadin-web-components/24.0.0-alpha10/#/elements/vaadin-input-container) - an internal element wrapping the input.\n\nNote: the `theme` attribute value set on `<vaadin-combo-box>` is\npropagated to the internal components listed above.\n\nSee [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.",
|
|
230
251
|
"extension": true,
|
|
231
252
|
"attributes": [
|
|
232
253
|
{
|
|
@@ -278,13 +299,6 @@
|
|
|
278
299
|
"kind": "expression"
|
|
279
300
|
}
|
|
280
301
|
},
|
|
281
|
-
{
|
|
282
|
-
"name": "?preventInvalidInput",
|
|
283
|
-
"description": "When set to true, user is prevented from typing a value that\nconflicts with the given `pattern`.",
|
|
284
|
-
"value": {
|
|
285
|
-
"kind": "expression"
|
|
286
|
-
}
|
|
287
|
-
},
|
|
288
302
|
{
|
|
289
303
|
"name": "?opened",
|
|
290
304
|
"description": "True if the dropdown is open, false otherwise.",
|
|
@@ -397,6 +411,13 @@
|
|
|
397
411
|
"kind": "expression"
|
|
398
412
|
}
|
|
399
413
|
},
|
|
414
|
+
{
|
|
415
|
+
"name": ".overlayClass",
|
|
416
|
+
"description": "A space-delimited list of CSS class names to set on the overlay element.\nThis property does not affect other CSS class names set manually via JS.\n\nNote, if the CSS class name was set with this property, clearing it will\nremove it from the overlay, even if the same class name was also added\nmanually, e.g. by using `classList.add()` in the `renderer` function.",
|
|
417
|
+
"value": {
|
|
418
|
+
"kind": "expression"
|
|
419
|
+
}
|
|
420
|
+
},
|
|
400
421
|
{
|
|
401
422
|
"name": ".renderer",
|
|
402
423
|
"description": "Custom function for rendering the content of every item.\nReceives three arguments:\n\n- `root` The `<vaadin-combo-box-item>` internal container DOM element.\n- `comboBox` The reference to the `<vaadin-combo-box>` element.\n- `model` The object with the properties related with the rendered\n item, contains:\n - `model.index` The index of the rendered item.\n - `model.item` The item.",
|