@vaadin/combo-box 24.4.0-alpha18 → 24.4.0-alpha19

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": "24.4.0-alpha18",
3
+ "version": "24.4.0-alpha19",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -26,7 +26,9 @@
26
26
  "vaadin-*.d.ts",
27
27
  "vaadin-*.js",
28
28
  "web-types.json",
29
- "web-types.lit.json"
29
+ "web-types.lit.json",
30
+ "!vaadin-lit-*.d.ts",
31
+ "!vaadin-lit-*.js"
30
32
  ],
31
33
  "keywords": [
32
34
  "Vaadin",
@@ -38,21 +40,21 @@
38
40
  "dependencies": {
39
41
  "@open-wc/dedupe-mixin": "^1.3.0",
40
42
  "@polymer/polymer": "^3.0.0",
41
- "@vaadin/a11y-base": "24.4.0-alpha18",
42
- "@vaadin/component-base": "24.4.0-alpha18",
43
- "@vaadin/field-base": "24.4.0-alpha18",
44
- "@vaadin/input-container": "24.4.0-alpha18",
45
- "@vaadin/item": "24.4.0-alpha18",
46
- "@vaadin/lit-renderer": "24.4.0-alpha18",
47
- "@vaadin/overlay": "24.4.0-alpha18",
48
- "@vaadin/vaadin-lumo-styles": "24.4.0-alpha18",
49
- "@vaadin/vaadin-material-styles": "24.4.0-alpha18",
50
- "@vaadin/vaadin-themable-mixin": "24.4.0-alpha18"
43
+ "@vaadin/a11y-base": "24.4.0-alpha19",
44
+ "@vaadin/component-base": "24.4.0-alpha19",
45
+ "@vaadin/field-base": "24.4.0-alpha19",
46
+ "@vaadin/input-container": "24.4.0-alpha19",
47
+ "@vaadin/item": "24.4.0-alpha19",
48
+ "@vaadin/lit-renderer": "24.4.0-alpha19",
49
+ "@vaadin/overlay": "24.4.0-alpha19",
50
+ "@vaadin/vaadin-lumo-styles": "24.4.0-alpha19",
51
+ "@vaadin/vaadin-material-styles": "24.4.0-alpha19",
52
+ "@vaadin/vaadin-themable-mixin": "24.4.0-alpha19"
51
53
  },
52
54
  "devDependencies": {
53
55
  "@esm-bundle/chai": "^4.3.4",
54
56
  "@vaadin/testing-helpers": "^0.6.0",
55
- "@vaadin/text-field": "24.4.0-alpha18",
57
+ "@vaadin/text-field": "24.4.0-alpha19",
56
58
  "lit": "^3.0.0",
57
59
  "sinon": "^13.0.2"
58
60
  },
@@ -60,5 +62,5 @@
60
62
  "web-types.json",
61
63
  "web-types.lit.json"
62
64
  ],
63
- "gitHead": "7d675c61eaa32ef50c07de7b2fea19ff437b6b90"
65
+ "gitHead": "5fad5eb53de7da69c1a19776a11ba74ceba27ea0"
64
66
  }
@@ -21,6 +21,7 @@ export const ComboBoxDataProviderMixin = (superClass) =>
21
21
  type: Number,
22
22
  value: 50,
23
23
  observer: '_pageSizeChanged',
24
+ sync: true,
24
25
  },
25
26
 
26
27
  /**
@@ -30,6 +31,7 @@ export const ComboBoxDataProviderMixin = (superClass) =>
30
31
  size: {
31
32
  type: Number,
32
33
  observer: '_sizeChanged',
34
+ sync: true,
33
35
  },
34
36
 
35
37
  /**
@@ -49,6 +51,7 @@ export const ComboBoxDataProviderMixin = (superClass) =>
49
51
  dataProvider: {
50
52
  type: Object,
51
53
  observer: '_dataProviderChanged',
54
+ sync: true,
52
55
  },
53
56
 
54
57
  /** @private */
@@ -82,18 +85,11 @@ export const ComboBoxDataProviderMixin = (superClass) =>
82
85
  ready() {
83
86
  super.ready();
84
87
  this._scroller.addEventListener('index-requested', (e) => {
85
- const index = e.detail.index;
86
- const currentScrollerPos = e.detail.currentScrollerPos;
87
- const allowedIndexRange = Math.floor(this.pageSize * 1.5);
88
-
89
- // Ignores the indexes, which are being re-sent during scrolling reset,
90
- // if the corresponding page is around the current scroller position.
91
- // Otherwise, there might be a last pages duplicates, which cause the
92
- // loading indicator hanging and blank items
93
- if (this._shouldSkipIndex(index, allowedIndexRange, currentScrollerPos)) {
88
+ if (!this._shouldFetchData()) {
94
89
  return;
95
90
  }
96
91
 
92
+ const index = e.detail.index;
97
93
  if (index !== undefined) {
98
94
  const page = this._getPageForIndex(index);
99
95
  if (this._shouldLoadPage(page)) {
@@ -125,7 +121,7 @@ export const ComboBoxDataProviderMixin = (superClass) =>
125
121
  }
126
122
  }
127
123
 
128
- /** @private */
124
+ /** @protected */
129
125
  _shouldFetchData() {
130
126
  if (!this.dataProvider) {
131
127
  return false;
@@ -136,23 +132,18 @@ export const ComboBoxDataProviderMixin = (superClass) =>
136
132
 
137
133
  /** @private */
138
134
  _ensureFirstPage(opened) {
135
+ if (!this._shouldFetchData()) {
136
+ return;
137
+ }
138
+
139
139
  if (opened && this._shouldLoadPage(0)) {
140
140
  this._loadPage(0);
141
141
  }
142
142
  }
143
143
 
144
- /** @private */
145
- _shouldSkipIndex(index, allowedIndexRange, currentScrollerPos) {
146
- return (
147
- currentScrollerPos !== 0 &&
148
- index >= currentScrollerPos - allowedIndexRange &&
149
- index <= currentScrollerPos + allowedIndexRange
150
- );
151
- }
152
-
153
144
  /** @private */
154
145
  _shouldLoadPage(page) {
155
- if (!this.filteredItems || this._forceNextRequest) {
146
+ if (this._forceNextRequest) {
156
147
  this._forceNextRequest = false;
157
148
  return true;
158
149
  }
@@ -60,7 +60,7 @@ export const ComboBoxItemMixin = (superClass) =>
60
60
  }
61
61
 
62
62
  static get observers() {
63
- return ['__rendererOrItemChanged(renderer, index, item.*, selected, focused)', '__updateLabel(label, renderer)'];
63
+ return ['__rendererOrItemChanged(renderer, index, item, selected, focused)', '__updateLabel(label, renderer)'];
64
64
  }
65
65
 
66
66
  static get observedAttributes() {
@@ -71,6 +71,7 @@ export const ComboBoxMixin = (subclass) =>
71
71
  notify: true,
72
72
  value: false,
73
73
  reflectToAttribute: true,
74
+ sync: true,
74
75
  observer: '_openedChanged',
75
76
  },
76
77
 
@@ -80,6 +81,7 @@ export const ComboBoxMixin = (subclass) =>
80
81
  */
81
82
  autoOpenDisabled: {
82
83
  type: Boolean,
84
+ sync: true,
83
85
  },
84
86
 
85
87
  /**
@@ -104,7 +106,10 @@ export const ComboBoxMixin = (subclass) =>
104
106
  * - `model.item` The item.
105
107
  * @type {ComboBoxRenderer | undefined}
106
108
  */
107
- renderer: Function,
109
+ renderer: {
110
+ type: Object,
111
+ sync: true,
112
+ },
108
113
 
109
114
  /**
110
115
  * A full set of items to filter the visible options from.
@@ -113,6 +118,7 @@ export const ComboBoxMixin = (subclass) =>
113
118
  */
114
119
  items: {
115
120
  type: Array,
121
+ sync: true,
116
122
  observer: '_itemsChanged',
117
123
  },
118
124
 
@@ -138,6 +144,7 @@ export const ComboBoxMixin = (subclass) =>
138
144
  filteredItems: {
139
145
  type: Array,
140
146
  observer: '_filteredItemsChanged',
147
+ sync: true,
141
148
  },
142
149
 
143
150
  /**
@@ -154,6 +161,7 @@ export const ComboBoxMixin = (subclass) =>
154
161
  type: Boolean,
155
162
  value: false,
156
163
  reflectToAttribute: true,
164
+ sync: true,
157
165
  },
158
166
 
159
167
  /**
@@ -164,6 +172,7 @@ export const ComboBoxMixin = (subclass) =>
164
172
  type: Number,
165
173
  observer: '_focusedIndexChanged',
166
174
  value: -1,
175
+ sync: true,
167
176
  },
168
177
 
169
178
  /**
@@ -174,6 +183,7 @@ export const ComboBoxMixin = (subclass) =>
174
183
  type: String,
175
184
  value: '',
176
185
  notify: true,
186
+ sync: true,
177
187
  },
178
188
 
179
189
  /**
@@ -183,6 +193,7 @@ export const ComboBoxMixin = (subclass) =>
183
193
  selectedItem: {
184
194
  type: Object,
185
195
  notify: true,
196
+ sync: true,
186
197
  },
187
198
 
188
199
  /**
@@ -199,6 +210,7 @@ export const ComboBoxMixin = (subclass) =>
199
210
  type: String,
200
211
  value: 'label',
201
212
  observer: '_itemLabelPathChanged',
213
+ sync: true,
202
214
  },
203
215
 
204
216
  /**
@@ -214,6 +226,7 @@ export const ComboBoxMixin = (subclass) =>
214
226
  itemValuePath: {
215
227
  type: String,
216
228
  value: 'value',
229
+ sync: true,
217
230
  },
218
231
 
219
232
  /**
@@ -223,7 +236,10 @@ export const ComboBoxMixin = (subclass) =>
223
236
  * `dataProvider` callback).
224
237
  * @attr {string} item-id-path
225
238
  */
226
- itemIdPath: String,
239
+ itemIdPath: {
240
+ type: String,
241
+ sync: true,
242
+ },
227
243
 
228
244
  /**
229
245
  * @type {!HTMLElement | undefined}
@@ -240,17 +256,22 @@ export const ComboBoxMixin = (subclass) =>
240
256
  */
241
257
  _dropdownItems: {
242
258
  type: Array,
259
+ sync: true,
243
260
  },
244
261
 
245
262
  /** @private */
246
263
  _closeOnBlurIsPrevented: Boolean,
247
264
 
248
265
  /** @private */
249
- _scroller: Object,
266
+ _scroller: {
267
+ type: Object,
268
+ sync: true,
269
+ },
250
270
 
251
271
  /** @private */
252
272
  _overlayOpened: {
253
273
  type: Boolean,
274
+ sync: true,
254
275
  observer: '_overlayOpenedChanged',
255
276
  },
256
277
  };
@@ -260,7 +281,7 @@ export const ComboBoxMixin = (subclass) =>
260
281
  return [
261
282
  '_selectedItemChanged(selectedItem, itemValuePath, itemLabelPath)',
262
283
  '_openedOrItemsChanged(opened, _dropdownItems, loading)',
263
- '_updateScroller(_scroller, _dropdownItems, opened, loading, selectedItem, itemIdPath, _focusedIndex, renderer, theme)',
284
+ '_updateScroller(_scroller, _dropdownItems, opened, loading, selectedItem, itemIdPath, _focusedIndex, renderer, _theme)',
264
285
  ];
265
286
  }
266
287
 
@@ -413,6 +434,18 @@ export const ComboBoxMixin = (subclass) =>
413
434
  }
414
435
  }
415
436
 
437
+ /**
438
+ * Override LitElement lifecycle callback to handle filter property change.
439
+ * @param {Object} props
440
+ */
441
+ updated(props) {
442
+ super.updated(props);
443
+
444
+ if (props.has('filter')) {
445
+ this._filterChanged(this.filter);
446
+ }
447
+ }
448
+
416
449
  /** @private */
417
450
  _initOverlay() {
418
451
  const overlay = this.$.overlay;
@@ -441,25 +474,23 @@ export const ComboBoxMixin = (subclass) =>
441
474
  * @protected
442
475
  */
443
476
  _initScroller(host) {
444
- const scrollerTag = `${this._tagNamePrefix}-scroller`;
477
+ const scroller = document.createElement(`${this._tagNamePrefix}-scroller`);
478
+
479
+ scroller.owner = host || this;
480
+ scroller.getItemLabel = this._getItemLabel.bind(this);
481
+ scroller.addEventListener('selection-changed', this._boundOverlaySelectedItemChanged);
445
482
 
446
483
  const overlay = this._overlayElement;
447
484
 
448
485
  overlay.renderer = (root) => {
449
- if (!root.firstChild) {
450
- root.appendChild(document.createElement(scrollerTag));
486
+ if (!root.innerHTML) {
487
+ root.appendChild(scroller);
451
488
  }
452
489
  };
453
490
 
454
491
  // Ensure the scroller is rendered
455
492
  overlay.requestContentUpdate();
456
493
 
457
- const scroller = overlay.querySelector(scrollerTag);
458
-
459
- scroller.owner = host || this;
460
- scroller.getItemLabel = this._getItemLabel.bind(this);
461
- scroller.addEventListener('selection-changed', this._boundOverlaySelectedItemChanged);
462
-
463
494
  // Trigger the observer to set properties
464
495
  this._scroller = scroller;
465
496
  }
@@ -483,6 +514,17 @@ export const ComboBoxMixin = (subclass) =>
483
514
  renderer,
484
515
  theme,
485
516
  });
517
+
518
+ // NOTE: in PolylitMixin, setProperties() waits for `hasUpdated` to be set.
519
+ // This means for the first opening, properties won't be set synchronously.
520
+ // Call `performUpdate()` in this case to mimic the Polymer version logic.
521
+ if (scroller.performUpdate && !scroller.hasUpdated) {
522
+ try {
523
+ scroller.performUpdate();
524
+ } catch (_) {
525
+ // Suppress errors in synchronous tests for pre-opened combo-box.
526
+ }
527
+ }
486
528
  }
487
529
  }
488
530
 
@@ -21,6 +21,7 @@ export const ComboBoxScrollerMixin = (superClass) =>
21
21
  */
22
22
  items: {
23
23
  type: Array,
24
+ sync: true,
24
25
  observer: '__itemsChanged',
25
26
  },
26
27
 
@@ -30,6 +31,7 @@ export const ComboBoxScrollerMixin = (superClass) =>
30
31
  */
31
32
  focusedIndex: {
32
33
  type: Number,
34
+ sync: true,
33
35
  observer: '__focusedIndexChanged',
34
36
  },
35
37
 
@@ -38,6 +40,7 @@ export const ComboBoxScrollerMixin = (superClass) =>
38
40
  */
39
41
  loading: {
40
42
  type: Boolean,
43
+ sync: true,
41
44
  observer: '__loadingChanged',
42
45
  },
43
46
 
@@ -47,6 +50,7 @@ export const ComboBoxScrollerMixin = (superClass) =>
47
50
  */
48
51
  opened: {
49
52
  type: Boolean,
53
+ sync: true,
50
54
  observer: '__openedChanged',
51
55
  },
52
56
 
@@ -55,6 +59,7 @@ export const ComboBoxScrollerMixin = (superClass) =>
55
59
  */
56
60
  selectedItem: {
57
61
  type: Object,
62
+ sync: true,
58
63
  observer: '__selectedItemChanged',
59
64
  },
60
65
 
@@ -84,6 +89,7 @@ export const ComboBoxScrollerMixin = (superClass) =>
84
89
  */
85
90
  renderer: {
86
91
  type: Object,
92
+ sync: true,
87
93
  observer: '__rendererChanged',
88
94
  },
89
95
 
@@ -158,7 +164,7 @@ export const ComboBoxScrollerMixin = (superClass) =>
158
164
  * @param {number} index
159
165
  */
160
166
  scrollIntoView(index) {
161
- if (!(this.opened && index >= 0)) {
167
+ if (!this.__virtualizer || !(this.opened && index >= 0)) {
162
168
  return;
163
169
  }
164
170
 
@@ -286,6 +292,12 @@ export const ComboBoxScrollerMixin = (superClass) =>
286
292
  focused: !this.loading && focusedIndex === index,
287
293
  });
288
294
 
295
+ // NOTE: in PolylitMixin, setProperties() waits for `hasUpdated` to be set.
296
+ // However, this causes issues with virtualizer. So we enforce sync update.
297
+ if (el.performUpdate && !el.hasUpdated) {
298
+ el.performUpdate();
299
+ }
300
+
289
301
  el.id = `${this.__hostTagName}-item-${index}`;
290
302
  el.setAttribute('role', index !== undefined ? 'option' : false);
291
303
  el.setAttribute('aria-selected', selected.toString());
@@ -346,7 +358,6 @@ export const ComboBoxScrollerMixin = (superClass) =>
346
358
  new CustomEvent('index-requested', {
347
359
  detail: {
348
360
  index,
349
- currentScrollerPos: this._oldScrollerPosition,
350
361
  },
351
362
  }),
352
363
  );
@@ -0,0 +1,50 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2015 - 2024 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import { css, html, LitElement } from 'lit';
7
+ import { defineCustomElement } from '@vaadin/component-base/src/define.js';
8
+ import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
9
+ import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
10
+ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
11
+ import { ComboBoxItemMixin } from './vaadin-combo-box-item-mixin.js';
12
+
13
+ /**
14
+ * LitElement based version of `<vaadin-combo-box-item>` web component.
15
+ *
16
+ * ## Disclaimer
17
+ *
18
+ * This component is an experiment not intended for publishing to npm.
19
+ * There is no ETA regarding specific Vaadin version where it'll land.
20
+ * Feel free to try this code in your apps as per Apache 2.0 license.
21
+ */
22
+ export class ComboBoxItem extends ComboBoxItemMixin(ThemableMixin(DirMixin(PolylitMixin(LitElement)))) {
23
+ static get is() {
24
+ return 'vaadin-combo-box-item';
25
+ }
26
+
27
+ static get styles() {
28
+ return css`
29
+ :host {
30
+ display: block;
31
+ }
32
+
33
+ :host([hidden]) {
34
+ display: none;
35
+ }
36
+ `;
37
+ }
38
+
39
+ /** @protected */
40
+ render() {
41
+ return html`
42
+ <span part="checkmark" aria-hidden="true"></span>
43
+ <div part="content">
44
+ <slot></slot>
45
+ </div>
46
+ `;
47
+ }
48
+ }
49
+
50
+ defineCustomElement(ComboBoxItem);
@@ -0,0 +1,58 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2015 - 2024 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import './vaadin-lit-combo-box-item.js';
7
+ import './vaadin-lit-combo-box-overlay.js';
8
+ import './vaadin-lit-combo-box-scroller.js';
9
+ import { css, html, LitElement } from 'lit';
10
+ import { ifDefined } from 'lit/directives/if-defined.js';
11
+ import { defineCustomElement } from '@vaadin/component-base/src/define.js';
12
+ import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
13
+ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
14
+ import { ComboBoxLightMixin } from './vaadin-combo-box-light-mixin.js';
15
+
16
+ /**
17
+ * LitElement based version of `<vaadin-combo-box-light>` web component.
18
+ *
19
+ * ## Disclaimer
20
+ *
21
+ * This component is an experiment not intended for publishing to npm.
22
+ * There is no ETA regarding specific Vaadin version where it'll land.
23
+ * Feel free to try this code in your apps as per Apache 2.0 license.
24
+ */
25
+ class ComboBoxLight extends ComboBoxLightMixin(ThemableMixin(PolylitMixin(LitElement))) {
26
+ static get is() {
27
+ return 'vaadin-combo-box-light';
28
+ }
29
+
30
+ static get styles() {
31
+ return css`
32
+ :host([opened]) {
33
+ pointer-events: auto;
34
+ }
35
+ `;
36
+ }
37
+
38
+ /** @protected */
39
+ render() {
40
+ return html`
41
+ <slot></slot>
42
+
43
+ <vaadin-combo-box-overlay
44
+ id="overlay"
45
+ .opened="${this._overlayOpened}"
46
+ ?loading="${this.loading}"
47
+ theme="${ifDefined(this._theme)}"
48
+ .positionTarget="${this.inputElement}"
49
+ .restoreFocusNode="${this.inputElement}"
50
+ no-vertical-overlap
51
+ ></vaadin-combo-box-overlay>
52
+ `;
53
+ }
54
+ }
55
+
56
+ defineCustomElement(ComboBoxLight);
57
+
58
+ export { ComboBoxLight };
@@ -0,0 +1,76 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2015 - 2024 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import { css, html, LitElement } from 'lit';
7
+ import { defineCustomElement } from '@vaadin/component-base/src/define.js';
8
+ import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
9
+ import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
10
+ import { OverlayMixin } from '@vaadin/overlay/src/vaadin-overlay-mixin.js';
11
+ import { overlayStyles } from '@vaadin/overlay/src/vaadin-overlay-styles.js';
12
+ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
13
+ import { ComboBoxOverlayMixin } from './vaadin-combo-box-overlay-mixin.js';
14
+
15
+ const comboBoxOverlayStyles = css`
16
+ #overlay {
17
+ width: var(--vaadin-combo-box-overlay-width, var(--_vaadin-combo-box-overlay-default-width, auto));
18
+ }
19
+
20
+ [part='content'] {
21
+ display: flex;
22
+ flex-direction: column;
23
+ height: 100%;
24
+ }
25
+ `;
26
+
27
+ /**
28
+ * An element used internally by `<vaadin-combo-box>`. Not intended to be used separately.
29
+ *
30
+ * @extends HTMLElement
31
+ * @mixes ComboBoxOverlayMixin
32
+ * @mixes DirMixin
33
+ * @mixes OverlayMixin
34
+ * @mixes ThemableMixin
35
+ * @private
36
+ */
37
+ export class ComboBoxOverlay extends ComboBoxOverlayMixin(
38
+ OverlayMixin(DirMixin(ThemableMixin(PolylitMixin(LitElement)))),
39
+ ) {
40
+ static get is() {
41
+ return 'vaadin-combo-box-overlay';
42
+ }
43
+
44
+ static get styles() {
45
+ return [overlayStyles, comboBoxOverlayStyles, comboBoxOverlayStyles];
46
+ }
47
+
48
+ static get properties() {
49
+ return {
50
+ /**
51
+ * When true, the overlay is visible and attached to body.
52
+ * This property config is overridden to set `sync: true`.
53
+ */
54
+ opened: {
55
+ type: Boolean,
56
+ notify: true,
57
+ observer: '_openedChanged',
58
+ reflectToAttribute: true,
59
+ sync: true,
60
+ },
61
+ };
62
+ }
63
+
64
+ /** @protected */
65
+ render() {
66
+ return html`
67
+ <div id="backdrop" part="backdrop" hidden></div>
68
+ <div part="overlay" id="overlay">
69
+ <div part="loader"></div>
70
+ <div part="content" id="content"><slot></slot></div>
71
+ </div>
72
+ `;
73
+ }
74
+ }
75
+
76
+ defineCustomElement(ComboBoxOverlay);
@@ -0,0 +1,59 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2015 - 2024 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import { css, html, LitElement } from 'lit';
7
+ import { defineCustomElement } from '@vaadin/component-base/src/define.js';
8
+ import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
9
+ import { ComboBoxScrollerMixin } from './vaadin-combo-box-scroller-mixin.js';
10
+
11
+ /**
12
+ * An element used internally by `<vaadin-combo-box>`. Not intended to be used separately.
13
+ *
14
+ * @extends HTMLElement
15
+ * @mixes ComboBoxScrollerMixin
16
+ * @private
17
+ */
18
+ export class ComboBoxScroller extends ComboBoxScrollerMixin(PolylitMixin(LitElement)) {
19
+ static get is() {
20
+ return 'vaadin-combo-box-scroller';
21
+ }
22
+
23
+ static get styles() {
24
+ return css`
25
+ :host {
26
+ display: block;
27
+ min-height: 1px;
28
+ overflow: auto;
29
+
30
+ /* Fixes item background from getting on top of scrollbars on Safari */
31
+ transform: translate3d(0, 0, 0);
32
+
33
+ /* Enable momentum scrolling on iOS */
34
+ -webkit-overflow-scrolling: touch;
35
+
36
+ /* Fixes scrollbar disappearing when 'Show scroll bars: Always' enabled in Safari */
37
+ box-shadow: 0 0 0 white;
38
+ }
39
+
40
+ #selector {
41
+ border-width: var(--_vaadin-combo-box-items-container-border-width);
42
+ border-style: var(--_vaadin-combo-box-items-container-border-style);
43
+ border-color: var(--_vaadin-combo-box-items-container-border-color, transparent);
44
+ position: relative;
45
+ }
46
+ `;
47
+ }
48
+
49
+ /** @protected */
50
+ render() {
51
+ return html`
52
+ <div id="selector">
53
+ <slot></slot>
54
+ </div>
55
+ `;
56
+ }
57
+ }
58
+
59
+ defineCustomElement(ComboBoxScroller);
@@ -0,0 +1,170 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2015 - 2024 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import '@vaadin/input-container/src/vaadin-lit-input-container.js';
7
+ import './vaadin-lit-combo-box-item.js';
8
+ import './vaadin-lit-combo-box-overlay.js';
9
+ import './vaadin-lit-combo-box-scroller.js';
10
+ import { css, html, LitElement } from 'lit';
11
+ import { ifDefined } from 'lit/directives/if-defined.js';
12
+ import { defineCustomElement } from '@vaadin/component-base/src/define.js';
13
+ import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
14
+ import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
15
+ import { TooltipController } from '@vaadin/component-base/src/tooltip-controller.js';
16
+ import { InputControlMixin } from '@vaadin/field-base/src/input-control-mixin.js';
17
+ import { InputController } from '@vaadin/field-base/src/input-controller.js';
18
+ import { LabelledInputController } from '@vaadin/field-base/src/labelled-input-controller.js';
19
+ import { PatternMixin } from '@vaadin/field-base/src/pattern-mixin.js';
20
+ import { inputFieldShared } from '@vaadin/field-base/src/styles/input-field-shared-styles.js';
21
+ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
22
+ import { ComboBoxDataProviderMixin } from './vaadin-combo-box-data-provider-mixin.js';
23
+ import { ComboBoxMixin } from './vaadin-combo-box-mixin.js';
24
+
25
+ /**
26
+ * LitElement based version of `<vaadin-combo-box>` web component.
27
+ *
28
+ * ## Disclaimer
29
+ *
30
+ * This component is an experiment not intended for publishing to npm.
31
+ * There is no ETA regarding specific Vaadin version where it'll land.
32
+ * Feel free to try this code in your apps as per Apache 2.0 license.
33
+ */
34
+ class ComboBox extends ComboBoxDataProviderMixin(
35
+ ComboBoxMixin(PatternMixin(InputControlMixin(ThemableMixin(ElementMixin(PolylitMixin(LitElement)))))),
36
+ ) {
37
+ static get is() {
38
+ return 'vaadin-combo-box';
39
+ }
40
+
41
+ static get styles() {
42
+ return [
43
+ inputFieldShared,
44
+ css`
45
+ :host([opened]) {
46
+ pointer-events: auto;
47
+ }
48
+ `,
49
+ ];
50
+ }
51
+
52
+ static get properties() {
53
+ return {
54
+ /**
55
+ * @protected
56
+ */
57
+ _positionTarget: {
58
+ type: Object,
59
+ },
60
+ };
61
+ }
62
+
63
+ /**
64
+ * Used by `InputControlMixin` as a reference to the clear button element.
65
+ * @protected
66
+ * @return {!HTMLElement}
67
+ */
68
+ get clearElement() {
69
+ return this.$.clearButton;
70
+ }
71
+
72
+ /** @protected */
73
+ render() {
74
+ return html`
75
+ <div class="vaadin-combo-box-container">
76
+ <div part="label">
77
+ <slot name="label"></slot>
78
+ <span part="required-indicator" aria-hidden="true" @click="${this.focus}"></span>
79
+ </div>
80
+
81
+ <vaadin-input-container
82
+ part="input-field"
83
+ .readonly="${this.readonly}"
84
+ .disabled="${this.disabled}"
85
+ .invalid="${this.invalid}"
86
+ theme="${ifDefined(this._theme)}"
87
+ >
88
+ <slot name="prefix" slot="prefix"></slot>
89
+ <slot name="input"></slot>
90
+ <div id="clearButton" part="clear-button" slot="suffix" aria-hidden="true"></div>
91
+ <div id="toggleButton" part="toggle-button" slot="suffix" aria-hidden="true"></div>
92
+ </vaadin-input-container>
93
+
94
+ <div part="helper-text">
95
+ <slot name="helper"></slot>
96
+ </div>
97
+
98
+ <div part="error-message">
99
+ <slot name="error-message"></slot>
100
+ </div>
101
+ </div>
102
+
103
+ <vaadin-combo-box-overlay
104
+ id="overlay"
105
+ .opened="${this._overlayOpened}"
106
+ ?loading="${this.loading}"
107
+ theme="${ifDefined(this._theme)}"
108
+ .positionTarget="${this._positionTarget}"
109
+ .restoreFocusNode="${this.inputElement}"
110
+ no-vertical-overlap
111
+ ></vaadin-combo-box-overlay>
112
+
113
+ <slot name="tooltip"></slot>
114
+ `;
115
+ }
116
+
117
+ /** @protected */
118
+ ready() {
119
+ super.ready();
120
+
121
+ this.addController(
122
+ new InputController(this, (input) => {
123
+ this._setInputElement(input);
124
+ this._setFocusElement(input);
125
+ this.stateTarget = input;
126
+ this.ariaTarget = input;
127
+ }),
128
+ );
129
+ this.addController(new LabelledInputController(this.inputElement, this._labelController));
130
+
131
+ this._tooltipController = new TooltipController(this);
132
+ this.addController(this._tooltipController);
133
+ this._tooltipController.setPosition('top');
134
+ this._tooltipController.setShouldShow((target) => !target.opened);
135
+
136
+ this._positionTarget = this.shadowRoot.querySelector('[part="input-field"]');
137
+ this._toggleElement = this.$.toggleButton;
138
+ }
139
+
140
+ /**
141
+ * Override the method from `InputControlMixin`
142
+ * to stop event propagation to prevent `ComboBoxMixin`
143
+ * from handling this click event also on its own.
144
+ *
145
+ * @param {Event} event
146
+ * @protected
147
+ * @override
148
+ */
149
+ _onClearButtonClick(event) {
150
+ event.stopPropagation();
151
+ super._onClearButtonClick(event);
152
+ }
153
+
154
+ /**
155
+ * @param {Event} event
156
+ * @protected
157
+ */
158
+ _onHostClick(event) {
159
+ const path = event.composedPath();
160
+
161
+ // Open dropdown only when clicking on the label or input field
162
+ if (path.includes(this._labelNode) || path.includes(this._positionTarget)) {
163
+ super._onHostClick(event);
164
+ }
165
+ }
166
+ }
167
+
168
+ defineCustomElement(ComboBox);
169
+
170
+ export { ComboBox };
@@ -1,3 +1,3 @@
1
1
  import './vaadin-combo-box-item-styles.js';
2
2
  import './vaadin-combo-box-overlay-styles.js';
3
- import '../../src/vaadin-combo-box-light.js';
3
+ import '../../src/vaadin-lit-combo-box-light.js';
@@ -1,4 +1,4 @@
1
1
  import './vaadin-combo-box-item-styles.js';
2
2
  import './vaadin-combo-box-overlay-styles.js';
3
3
  import './vaadin-combo-box-styles.js';
4
- import '../../src/vaadin-combo-box.js';
4
+ import '../../src/vaadin-lit-combo-box.js';
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.4.0-alpha18",
4
+ "version": "24.4.0-alpha17",
5
5
  "description-markup": "markdown",
6
6
  "contributions": {
7
7
  "html": {
@@ -460,7 +460,7 @@
460
460
  },
461
461
  {
462
462
  "name": "vaadin-combo-box",
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.4.0-alpha18/#/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.4.0-alpha18/#/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.4.0-alpha18/#/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.4.0-alpha18/#/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.4.0-alpha18/#/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.4.0-alpha18/#/elements/vaadin-overlay).\n- `<vaadin-combo-box-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/24.4.0-alpha18/#/elements/vaadin-item).\n- [`<vaadin-input-container>`](https://cdn.vaadin.com/vaadin-web-components/24.4.0-alpha18/#/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.",
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.4.0-alpha17/#/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.4.0-alpha17/#/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.4.0-alpha17/#/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.4.0-alpha17/#/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.4.0-alpha17/#/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.4.0-alpha17/#/elements/vaadin-overlay).\n- `<vaadin-combo-box-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/24.4.0-alpha17/#/elements/vaadin-item).\n- [`<vaadin-input-container>`](https://cdn.vaadin.com/vaadin-web-components/24.4.0-alpha17/#/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.",
464
464
  "attributes": [
465
465
  {
466
466
  "name": "disabled",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/combo-box",
4
- "version": "24.4.0-alpha18",
4
+ "version": "24.4.0-alpha17",
5
5
  "description-markup": "markdown",
6
6
  "framework": "lit",
7
7
  "framework-config": {
@@ -247,7 +247,7 @@
247
247
  },
248
248
  {
249
249
  "name": "vaadin-combo-box",
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.4.0-alpha18/#/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.4.0-alpha18/#/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.4.0-alpha18/#/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.4.0-alpha18/#/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.4.0-alpha18/#/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.4.0-alpha18/#/elements/vaadin-overlay).\n- `<vaadin-combo-box-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/24.4.0-alpha18/#/elements/vaadin-item).\n- [`<vaadin-input-container>`](https://cdn.vaadin.com/vaadin-web-components/24.4.0-alpha18/#/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.",
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.4.0-alpha17/#/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.4.0-alpha17/#/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.4.0-alpha17/#/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.4.0-alpha17/#/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.4.0-alpha17/#/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.4.0-alpha17/#/elements/vaadin-overlay).\n- `<vaadin-combo-box-item>` - has the same API as [`<vaadin-item>`](https://cdn.vaadin.com/vaadin-web-components/24.4.0-alpha17/#/elements/vaadin-item).\n- [`<vaadin-input-container>`](https://cdn.vaadin.com/vaadin-web-components/24.4.0-alpha17/#/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.",
251
251
  "extension": true,
252
252
  "attributes": [
253
253
  {
@@ -1,5 +0,0 @@
1
- import '@vaadin/vaadin-lumo-styles/color.js';
2
- import '@vaadin/vaadin-lumo-styles/spacing.js';
3
- import '@vaadin/vaadin-lumo-styles/style.js';
4
- declare const comboBoxItem: import("lit").CSSResult;
5
- export { comboBoxItem };
@@ -1,6 +0,0 @@
1
- import '@vaadin/vaadin-lumo-styles/color.js';
2
- import '@vaadin/vaadin-lumo-styles/spacing.js';
3
- import '@vaadin/vaadin-lumo-styles/style.js';
4
- declare const comboBoxOverlay: import("lit").CSSResult;
5
- declare const comboBoxLoader: import("lit").CSSResult;
6
- export { comboBoxLoader, comboBoxOverlay };
@@ -1,2 +0,0 @@
1
- import '@vaadin/input-container/theme/lumo/vaadin-input-container-styles.js';
2
- import '@vaadin/vaadin-lumo-styles/font-icons.js';
@@ -1,5 +0,0 @@
1
- import '@vaadin/vaadin-material-styles/color.js';
2
- import '@vaadin/vaadin-material-styles/font-icons.js';
3
- import '@vaadin/vaadin-material-styles/typography.js';
4
- declare const comboBoxItem: import("lit").CSSResult;
5
- export { comboBoxItem };
@@ -1,3 +0,0 @@
1
- import './vaadin-combo-box-item-styles.js';
2
- import './vaadin-combo-box-overlay-styles.js';
3
- import '../../src/vaadin-combo-box-light.js';
@@ -1,4 +0,0 @@
1
- import '@vaadin/vaadin-material-styles/color.js';
2
- declare const comboBoxOverlay: import("lit").CSSResult;
3
- declare const comboBoxLoader: import("lit").CSSResult;
4
- export { comboBoxLoader, comboBoxOverlay };
@@ -1,3 +0,0 @@
1
- import '@vaadin/input-container/theme/material/vaadin-input-container-styles.js';
2
- import '@vaadin/vaadin-material-styles/color.js';
3
- import '@vaadin/vaadin-material-styles/font-icons.js';
@@ -1,4 +0,0 @@
1
- import './vaadin-combo-box-item-styles.js';
2
- import './vaadin-combo-box-overlay-styles.js';
3
- import './vaadin-combo-box-styles.js';
4
- import '../../src/vaadin-combo-box.js';