@vaadin/combo-box 25.0.0-alpha4 → 25.0.0-alpha6
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 +13 -13
- package/src/styles/vaadin-combo-box-overlay-base-styles.js +32 -49
- package/src/styles/vaadin-combo-box-scroller-core-styles.js +0 -3
- package/src/vaadin-combo-box-base-mixin.js +0 -3
- package/src/vaadin-combo-box-item.js +2 -2
- package/src/vaadin-combo-box-overlay-mixin.js +2 -2
- package/src/vaadin-combo-box-overlay.js +2 -2
- package/src/vaadin-combo-box-scroller.js +2 -2
- package/src/vaadin-combo-box.js +3 -2
- package/web-types.json +2 -2
- package/web-types.lit.json +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/combo-box",
|
|
3
|
-
"version": "25.0.0-
|
|
3
|
+
"version": "25.0.0-alpha6",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -38,20 +38,20 @@
|
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
41
|
-
"@vaadin/a11y-base": "25.0.0-
|
|
42
|
-
"@vaadin/component-base": "25.0.0-
|
|
43
|
-
"@vaadin/field-base": "25.0.0-
|
|
44
|
-
"@vaadin/input-container": "25.0.0-
|
|
45
|
-
"@vaadin/item": "25.0.0-
|
|
46
|
-
"@vaadin/lit-renderer": "25.0.0-
|
|
47
|
-
"@vaadin/overlay": "25.0.0-
|
|
48
|
-
"@vaadin/vaadin-lumo-styles": "25.0.0-
|
|
49
|
-
"@vaadin/vaadin-themable-mixin": "25.0.0-
|
|
41
|
+
"@vaadin/a11y-base": "25.0.0-alpha6",
|
|
42
|
+
"@vaadin/component-base": "25.0.0-alpha6",
|
|
43
|
+
"@vaadin/field-base": "25.0.0-alpha6",
|
|
44
|
+
"@vaadin/input-container": "25.0.0-alpha6",
|
|
45
|
+
"@vaadin/item": "25.0.0-alpha6",
|
|
46
|
+
"@vaadin/lit-renderer": "25.0.0-alpha6",
|
|
47
|
+
"@vaadin/overlay": "25.0.0-alpha6",
|
|
48
|
+
"@vaadin/vaadin-lumo-styles": "25.0.0-alpha6",
|
|
49
|
+
"@vaadin/vaadin-themable-mixin": "25.0.0-alpha6",
|
|
50
50
|
"lit": "^3.0.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@vaadin/chai-plugins": "25.0.0-
|
|
54
|
-
"@vaadin/test-runner-commands": "25.0.0-
|
|
53
|
+
"@vaadin/chai-plugins": "25.0.0-alpha6",
|
|
54
|
+
"@vaadin/test-runner-commands": "25.0.0-alpha6",
|
|
55
55
|
"@vaadin/testing-helpers": "^2.0.0",
|
|
56
56
|
"sinon": "^18.0.0"
|
|
57
57
|
},
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"web-types.json",
|
|
60
60
|
"web-types.lit.json"
|
|
61
61
|
],
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "cd1d084198d2b326c58d44bb39fa4845b71ce551"
|
|
63
63
|
}
|
|
@@ -5,61 +5,44 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import '@vaadin/component-base/src/style-props.js';
|
|
7
7
|
import { css } from 'lit';
|
|
8
|
+
import { loaderStyles } from '@vaadin/component-base/src/loader-styles.js';
|
|
9
|
+
|
|
10
|
+
export const comboBoxOverlayStyles = [
|
|
11
|
+
loaderStyles,
|
|
12
|
+
css`
|
|
13
|
+
@layer base {
|
|
14
|
+
:host {
|
|
15
|
+
--vaadin-item-checkmark-display: block;
|
|
16
|
+
}
|
|
8
17
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
[part='overlay'] {
|
|
16
|
-
position: relative;
|
|
17
|
-
width: var(--vaadin-combo-box-overlay-width, var(--_vaadin-combo-box-overlay-default-width, auto));
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
[part='loader'] {
|
|
21
|
-
animation: spin 1s linear infinite;
|
|
22
|
-
border: 2px solid;
|
|
23
|
-
--_spinner-color: var(--vaadin-combo-box-spinner-color, var(--_vaadin-color-strong));
|
|
24
|
-
border-color: var(--_spinner-color) var(--_spinner-color) hsl(from var(--_spinner-color) h s l / 0.2)
|
|
25
|
-
hsl(from var(--_spinner-color) h s l / 0.2);
|
|
26
|
-
border-radius: var(--_vaadin-radius-full);
|
|
27
|
-
box-sizing: border-box;
|
|
28
|
-
display: none;
|
|
29
|
-
height: var(--vaadin-icon-size, 1lh);
|
|
30
|
-
inset: calc(var(--vaadin-item-overlay-padding, 4px) + 2px);
|
|
31
|
-
inset-block-end: auto;
|
|
32
|
-
inset-inline-start: auto;
|
|
33
|
-
pointer-events: none;
|
|
34
|
-
position: absolute;
|
|
35
|
-
width: var(--vaadin-icon-size, 1lh);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
[part='content'] {
|
|
39
|
-
display: flex;
|
|
40
|
-
flex-direction: column;
|
|
41
|
-
height: 100%;
|
|
42
|
-
}
|
|
18
|
+
[part='overlay'] {
|
|
19
|
+
position: relative;
|
|
20
|
+
width: var(--vaadin-combo-box-overlay-width, var(--_vaadin-combo-box-overlay-default-width, auto));
|
|
21
|
+
}
|
|
43
22
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
23
|
+
[part='content'] {
|
|
24
|
+
display: flex;
|
|
25
|
+
flex-direction: column;
|
|
26
|
+
height: 100%;
|
|
27
|
+
}
|
|
47
28
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
29
|
+
:host([loading]) [part='content'] {
|
|
30
|
+
--_items-min-height: calc(var(--vaadin-icon-size, 1lh) + 4px);
|
|
31
|
+
}
|
|
51
32
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
33
|
+
@media (forced-colors: active) {
|
|
34
|
+
[part='loader'] {
|
|
35
|
+
forced-color-adjust: none;
|
|
36
|
+
--vaadin-combo-box-spinner-color: CanvasText;
|
|
37
|
+
}
|
|
55
38
|
}
|
|
56
|
-
}
|
|
57
39
|
|
|
58
|
-
@media (forced-colors: active) {
|
|
59
40
|
[part='loader'] {
|
|
60
|
-
|
|
61
|
-
--vaadin-
|
|
41
|
+
position: absolute;
|
|
42
|
+
inset: calc(var(--vaadin-item-overlay-padding, 4px) + 2px);
|
|
43
|
+
inset-block-end: auto;
|
|
44
|
+
inset-inline-start: auto;
|
|
62
45
|
}
|
|
63
46
|
}
|
|
64
|
-
|
|
65
|
-
|
|
47
|
+
`,
|
|
48
|
+
];
|
|
@@ -14,9 +14,6 @@ export const comboBoxScrollerStyles = css`
|
|
|
14
14
|
/* Fixes item background from getting on top of scrollbars on Safari */
|
|
15
15
|
transform: translate3d(0, 0, 0);
|
|
16
16
|
|
|
17
|
-
/* Enable momentum scrolling on iOS */
|
|
18
|
-
-webkit-overflow-scrolling: touch;
|
|
19
|
-
|
|
20
17
|
/* Fixes scrollbar disappearing when 'Show scroll bars: Always' enabled in Safari */
|
|
21
18
|
box-shadow: 0 0 0 white;
|
|
22
19
|
}
|
|
@@ -225,9 +225,6 @@ export const ComboBoxBaseMixin = (superClass) =>
|
|
|
225
225
|
_initOverlay() {
|
|
226
226
|
const overlay = this.$.overlay;
|
|
227
227
|
|
|
228
|
-
// Store instance for detecting "dir" attribute on opening
|
|
229
|
-
overlay._comboBox = this;
|
|
230
|
-
|
|
231
228
|
overlay.addEventListener('touchend', this._boundOnOverlayTouchAction);
|
|
232
229
|
overlay.addEventListener('touchmove', this._boundOnOverlayTouchAction);
|
|
233
230
|
|
|
@@ -8,7 +8,7 @@ import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
|
8
8
|
import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
|
|
9
9
|
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
10
10
|
import { itemStyles } from '@vaadin/item/src/styles/vaadin-item-core-styles.js';
|
|
11
|
-
import {
|
|
11
|
+
import { LumoInjectionMixin } from '@vaadin/vaadin-themable-mixin/lumo-injection-mixin.js';
|
|
12
12
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
13
13
|
import { ComboBoxItemMixin } from './vaadin-combo-box-item-mixin.js';
|
|
14
14
|
|
|
@@ -40,7 +40,7 @@ import { ComboBoxItemMixin } from './vaadin-combo-box-item-mixin.js';
|
|
|
40
40
|
* @private
|
|
41
41
|
*/
|
|
42
42
|
export class ComboBoxItem extends ComboBoxItemMixin(
|
|
43
|
-
|
|
43
|
+
LumoInjectionMixin(ThemableMixin(DirMixin(PolylitMixin(LitElement)))),
|
|
44
44
|
) {
|
|
45
45
|
static get is() {
|
|
46
46
|
return 'vaadin-combo-box-item';
|
|
@@ -34,7 +34,7 @@ export const ComboBoxOverlayMixin = (superClass) =>
|
|
|
34
34
|
|
|
35
35
|
/** @protected */
|
|
36
36
|
_getHostDir() {
|
|
37
|
-
return this.
|
|
37
|
+
return this.owner && this.owner.getAttribute('dir');
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
/**
|
|
@@ -69,7 +69,7 @@ export const ComboBoxOverlayMixin = (superClass) =>
|
|
|
69
69
|
const propPrefix = this.localName;
|
|
70
70
|
this.style.setProperty(`--_${propPrefix}-default-width`, `${this.positionTarget.offsetWidth}px`);
|
|
71
71
|
|
|
72
|
-
const customWidth = getComputedStyle(this.
|
|
72
|
+
const customWidth = getComputedStyle(this.owner).getPropertyValue(`--${propPrefix}-width`);
|
|
73
73
|
|
|
74
74
|
if (customWidth === '') {
|
|
75
75
|
this.style.removeProperty(`--${propPrefix}-width`);
|
|
@@ -9,7 +9,7 @@ import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
|
|
|
9
9
|
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
10
10
|
import { overlayStyles } from '@vaadin/overlay/src/styles/vaadin-overlay-core-styles.js';
|
|
11
11
|
import { OverlayMixin } from '@vaadin/overlay/src/vaadin-overlay-mixin.js';
|
|
12
|
-
import {
|
|
12
|
+
import { LumoInjectionMixin } from '@vaadin/vaadin-themable-mixin/lumo-injection-mixin.js';
|
|
13
13
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
14
14
|
import { comboBoxOverlayStyles } from './styles/vaadin-combo-box-overlay-core-styles.js';
|
|
15
15
|
import { ComboBoxOverlayMixin } from './vaadin-combo-box-overlay-mixin.js';
|
|
@@ -26,7 +26,7 @@ import { ComboBoxOverlayMixin } from './vaadin-combo-box-overlay-mixin.js';
|
|
|
26
26
|
* @private
|
|
27
27
|
*/
|
|
28
28
|
export class ComboBoxOverlay extends ComboBoxOverlayMixin(
|
|
29
|
-
OverlayMixin(DirMixin(
|
|
29
|
+
OverlayMixin(DirMixin(LumoInjectionMixin(ThemableMixin(PolylitMixin(LitElement))))),
|
|
30
30
|
) {
|
|
31
31
|
static get is() {
|
|
32
32
|
return 'vaadin-combo-box-overlay';
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { html, LitElement } from 'lit';
|
|
7
7
|
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
8
8
|
import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
|
|
9
|
-
import {
|
|
9
|
+
import { LumoInjectionMixin } from '@vaadin/vaadin-themable-mixin/lumo-injection-mixin.js';
|
|
10
10
|
import { comboBoxScrollerStyles } from './styles/vaadin-combo-box-scroller-core-styles.js';
|
|
11
11
|
import { ComboBoxScrollerMixin } from './vaadin-combo-box-scroller-mixin.js';
|
|
12
12
|
|
|
@@ -18,7 +18,7 @@ import { ComboBoxScrollerMixin } from './vaadin-combo-box-scroller-mixin.js';
|
|
|
18
18
|
* @mixes ComboBoxScrollerMixin
|
|
19
19
|
* @private
|
|
20
20
|
*/
|
|
21
|
-
export class ComboBoxScroller extends ComboBoxScrollerMixin(
|
|
21
|
+
export class ComboBoxScroller extends ComboBoxScrollerMixin(LumoInjectionMixin(PolylitMixin(LitElement))) {
|
|
22
22
|
static get is() {
|
|
23
23
|
return 'vaadin-combo-box-scroller';
|
|
24
24
|
}
|
package/src/vaadin-combo-box.js
CHANGED
|
@@ -18,7 +18,7 @@ import { InputController } from '@vaadin/field-base/src/input-controller.js';
|
|
|
18
18
|
import { LabelledInputController } from '@vaadin/field-base/src/labelled-input-controller.js';
|
|
19
19
|
import { PatternMixin } from '@vaadin/field-base/src/pattern-mixin.js';
|
|
20
20
|
import { inputFieldShared } from '@vaadin/field-base/src/styles/input-field-shared-styles.js';
|
|
21
|
-
import {
|
|
21
|
+
import { LumoInjectionMixin } from '@vaadin/vaadin-themable-mixin/lumo-injection-mixin.js';
|
|
22
22
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
23
23
|
import { comboBoxStyles } from './styles/vaadin-combo-box-core-styles.js';
|
|
24
24
|
import { ComboBoxDataProviderMixin } from './vaadin-combo-box-data-provider-mixin.js';
|
|
@@ -157,7 +157,7 @@ import { ComboBoxMixin } from './vaadin-combo-box-mixin.js';
|
|
|
157
157
|
*/
|
|
158
158
|
class ComboBox extends ComboBoxDataProviderMixin(
|
|
159
159
|
ComboBoxMixin(
|
|
160
|
-
PatternMixin(InputControlMixin(
|
|
160
|
+
PatternMixin(InputControlMixin(LumoInjectionMixin(ThemableMixin(ElementMixin(PolylitMixin(LitElement)))))),
|
|
161
161
|
),
|
|
162
162
|
) {
|
|
163
163
|
static get is() {
|
|
@@ -221,6 +221,7 @@ class ComboBox extends ComboBoxDataProviderMixin(
|
|
|
221
221
|
|
|
222
222
|
<vaadin-combo-box-overlay
|
|
223
223
|
id="overlay"
|
|
224
|
+
.owner="${this}"
|
|
224
225
|
.opened="${this._overlayOpened}"
|
|
225
226
|
?loading="${this.loading}"
|
|
226
227
|
theme="${ifDefined(this._theme)}"
|
package/web-types.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/web-types",
|
|
3
3
|
"name": "@vaadin/combo-box",
|
|
4
|
-
"version": "25.0.0-
|
|
4
|
+
"version": "25.0.0-alpha6",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"contributions": {
|
|
7
7
|
"html": {
|
|
8
8
|
"elements": [
|
|
9
9
|
{
|
|
10
10
|
"name": "vaadin-combo-box",
|
|
11
|
-
"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/25.0.0-
|
|
11
|
+
"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/25.0.0-alpha6/#/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/25.0.0-alpha6/#/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/25.0.0-alpha6/#/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/25.0.0-alpha6/#/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\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/25.0.0-alpha6/#/elements/vaadin-overlay).\n- `<vaadin-combo-box-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha6/#/elements/vaadin-item).\n- [`<vaadin-input-container>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha6/#/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/styling-components) documentation.",
|
|
12
12
|
"attributes": [
|
|
13
13
|
{
|
|
14
14
|
"name": "disabled",
|
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": "25.0.0-
|
|
4
|
+
"version": "25.0.0-alpha6",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"framework": "lit",
|
|
7
7
|
"framework-config": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"elements": [
|
|
17
17
|
{
|
|
18
18
|
"name": "vaadin-combo-box",
|
|
19
|
-
"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/25.0.0-
|
|
19
|
+
"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/25.0.0-alpha6/#/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/25.0.0-alpha6/#/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/25.0.0-alpha6/#/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/25.0.0-alpha6/#/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\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/25.0.0-alpha6/#/elements/vaadin-overlay).\n- `<vaadin-combo-box-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha6/#/elements/vaadin-item).\n- [`<vaadin-input-container>`](https://cdn.vaadin.com/vaadin-web-components/25.0.0-alpha6/#/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/styling-components) documentation.",
|
|
20
20
|
"extension": true,
|
|
21
21
|
"attributes": [
|
|
22
22
|
{
|