@vaadin/combo-box 24.8.4 → 25.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.
Files changed (61) hide show
  1. package/README.md +0 -23
  2. package/package.json +17 -19
  3. package/src/styles/vaadin-combo-box-base-styles.d.ts +8 -0
  4. package/src/styles/vaadin-combo-box-base-styles.js +17 -0
  5. package/src/styles/vaadin-combo-box-core-styles.d.ts +8 -0
  6. package/src/styles/vaadin-combo-box-core-styles.js +12 -0
  7. package/src/styles/vaadin-combo-box-overlay-base-styles.js +46 -0
  8. package/src/styles/vaadin-combo-box-overlay-core-styles.js +18 -0
  9. package/src/styles/vaadin-combo-box-scroller-base-styles.js +29 -0
  10. package/src/styles/vaadin-combo-box-scroller-core-styles.js +27 -0
  11. package/src/vaadin-combo-box-base-mixin.d.ts +56 -0
  12. package/src/vaadin-combo-box-base-mixin.js +776 -0
  13. package/src/vaadin-combo-box-data-provider-mixin.js +17 -32
  14. package/src/vaadin-combo-box-item-mixin.js +6 -1
  15. package/src/vaadin-combo-box-item.js +17 -16
  16. package/src/vaadin-combo-box-items-mixin.d.ts +53 -0
  17. package/src/vaadin-combo-box-items-mixin.js +275 -0
  18. package/src/vaadin-combo-box-mixin.d.ts +3 -72
  19. package/src/vaadin-combo-box-mixin.js +84 -922
  20. package/src/vaadin-combo-box-overlay-mixin.js +1 -22
  21. package/src/vaadin-combo-box-overlay.js +15 -22
  22. package/src/vaadin-combo-box-scroller.js +10 -26
  23. package/src/vaadin-combo-box.d.ts +12 -14
  24. package/src/vaadin-combo-box.js +81 -53
  25. package/web-types.json +51 -536
  26. package/web-types.lit.json +17 -262
  27. package/src/vaadin-combo-box-light-mixin.d.ts +0 -26
  28. package/src/vaadin-combo-box-light-mixin.js +0 -131
  29. package/src/vaadin-combo-box-light.d.ts +0 -161
  30. package/src/vaadin-combo-box-light.js +0 -94
  31. package/src/vaadin-lit-combo-box-item.js +0 -68
  32. package/src/vaadin-lit-combo-box-light.js +0 -57
  33. package/src/vaadin-lit-combo-box-overlay.js +0 -60
  34. package/src/vaadin-lit-combo-box-scroller.js +0 -59
  35. package/src/vaadin-lit-combo-box.js +0 -169
  36. package/theme/lumo/vaadin-combo-box-light.d.ts +0 -3
  37. package/theme/lumo/vaadin-combo-box-light.js +0 -3
  38. package/theme/lumo/vaadin-lit-combo-box-light.d.ts +0 -3
  39. package/theme/lumo/vaadin-lit-combo-box-light.js +0 -3
  40. package/theme/lumo/vaadin-lit-combo-box.d.ts +0 -4
  41. package/theme/lumo/vaadin-lit-combo-box.js +0 -4
  42. package/theme/material/vaadin-combo-box-item-styles.d.ts +0 -5
  43. package/theme/material/vaadin-combo-box-item-styles.js +0 -20
  44. package/theme/material/vaadin-combo-box-light.d.ts +0 -3
  45. package/theme/material/vaadin-combo-box-light.js +0 -3
  46. package/theme/material/vaadin-combo-box-overlay-styles.d.ts +0 -4
  47. package/theme/material/vaadin-combo-box-overlay-styles.js +0 -51
  48. package/theme/material/vaadin-combo-box-styles.d.ts +0 -3
  49. package/theme/material/vaadin-combo-box-styles.js +0 -21
  50. package/theme/material/vaadin-combo-box.d.ts +0 -4
  51. package/theme/material/vaadin-combo-box.js +0 -4
  52. package/theme/material/vaadin-lit-combo-box-light.d.ts +0 -3
  53. package/theme/material/vaadin-lit-combo-box-light.js +0 -3
  54. package/theme/material/vaadin-lit-combo-box.d.ts +0 -4
  55. package/theme/material/vaadin-lit-combo-box.js +0 -4
  56. package/vaadin-combo-box-light.d.ts +0 -1
  57. package/vaadin-combo-box-light.js +0 -2
  58. package/vaadin-lit-combo-box-light.d.ts +0 -1
  59. package/vaadin-lit-combo-box-light.js +0 -2
  60. package/vaadin-lit-combo-box.d.ts +0 -1
  61. package/vaadin-lit-combo-box.js +0 -2
@@ -22,18 +22,6 @@ export const ComboBoxOverlayMixin = (superClass) =>
22
22
  this.requiredVerticalSpace = 200;
23
23
  }
24
24
 
25
- /** @protected */
26
- connectedCallback() {
27
- super.connectedCallback();
28
-
29
- const comboBox = this._comboBox;
30
-
31
- const hostDir = comboBox && comboBox.getAttribute('dir');
32
- if (hostDir) {
33
- this.setAttribute('dir', hostDir);
34
- }
35
- }
36
-
37
25
  /**
38
26
  * Override method inherited from `Overlay`
39
27
  * to not close on position target click.
@@ -63,16 +51,7 @@ export const ComboBoxOverlayMixin = (superClass) =>
63
51
 
64
52
  /** @protected */
65
53
  _updateOverlayWidth() {
66
- const propPrefix = this.localName;
67
- this.style.setProperty(`--_${propPrefix}-default-width`, `${this.positionTarget.offsetWidth}px`);
68
-
69
- const customWidth = getComputedStyle(this._comboBox).getPropertyValue(`--${propPrefix}-width`);
70
-
71
- if (customWidth === '') {
72
- this.style.removeProperty(`--${propPrefix}-width`);
73
- } else {
74
- this.style.setProperty(`--${propPrefix}-width`, customWidth);
75
- }
54
+ this.style.setProperty(`--_${this.localName}-default-width`, `${this.positionTarget.offsetWidth}px`);
76
55
  }
77
56
 
78
57
  /** @private */
@@ -3,30 +3,17 @@
3
3
  * Copyright (c) 2015 - 2025 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
6
+ import { html, LitElement } from 'lit';
7
7
  import { defineCustomElement } from '@vaadin/component-base/src/define.js';
8
8
  import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
9
+ import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
10
+ import { overlayStyles } from '@vaadin/overlay/src/styles/vaadin-overlay-core-styles.js';
9
11
  import { OverlayMixin } from '@vaadin/overlay/src/vaadin-overlay-mixin.js';
10
- import { overlayStyles } from '@vaadin/overlay/src/vaadin-overlay-styles.js';
11
- import { css, registerStyles, ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
12
+ import { LumoInjectionMixin } from '@vaadin/vaadin-themable-mixin/lumo-injection-mixin.js';
13
+ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
14
+ import { comboBoxOverlayStyles } from './styles/vaadin-combo-box-overlay-core-styles.js';
12
15
  import { ComboBoxOverlayMixin } from './vaadin-combo-box-overlay-mixin.js';
13
16
 
14
- const comboBoxOverlayStyles = css`
15
- #overlay {
16
- width: var(--vaadin-combo-box-overlay-width, var(--_vaadin-combo-box-overlay-default-width, auto));
17
- }
18
-
19
- [part='content'] {
20
- display: flex;
21
- flex-direction: column;
22
- height: 100%;
23
- }
24
- `;
25
-
26
- registerStyles('vaadin-combo-box-overlay', [overlayStyles, comboBoxOverlayStyles], {
27
- moduleId: 'vaadin-combo-box-overlay-styles',
28
- });
29
-
30
17
  /**
31
18
  * An element used internally by `<vaadin-combo-box>`. Not intended to be used separately.
32
19
  *
@@ -38,14 +25,20 @@ registerStyles('vaadin-combo-box-overlay', [overlayStyles, comboBoxOverlayStyles
38
25
  * @mixes ThemableMixin
39
26
  * @private
40
27
  */
41
- export class ComboBoxOverlay extends ComboBoxOverlayMixin(OverlayMixin(DirMixin(ThemableMixin(PolymerElement)))) {
28
+ export class ComboBoxOverlay extends ComboBoxOverlayMixin(
29
+ OverlayMixin(DirMixin(ThemableMixin(PolylitMixin(LumoInjectionMixin(LitElement))))),
30
+ ) {
42
31
  static get is() {
43
32
  return 'vaadin-combo-box-overlay';
44
33
  }
45
34
 
46
- static get template() {
35
+ static get styles() {
36
+ return [overlayStyles, comboBoxOverlayStyles];
37
+ }
38
+
39
+ /** @protected */
40
+ render() {
47
41
  return html`
48
- <div id="backdrop" part="backdrop" hidden></div>
49
42
  <div part="overlay" id="overlay">
50
43
  <div part="loader"></div>
51
44
  <div part="content" id="content"><slot></slot></div>
@@ -3,8 +3,10 @@
3
3
  * Copyright (c) 2015 - 2025 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
6
+ import { html, LitElement } from 'lit';
7
7
  import { defineCustomElement } from '@vaadin/component-base/src/define.js';
8
+ import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
9
+ import { comboBoxScrollerStyles } from './styles/vaadin-combo-box-scroller-core-styles.js';
8
10
  import { ComboBoxScrollerMixin } from './vaadin-combo-box-scroller-mixin.js';
9
11
 
10
12
  /**
@@ -15,36 +17,18 @@ import { ComboBoxScrollerMixin } from './vaadin-combo-box-scroller-mixin.js';
15
17
  * @mixes ComboBoxScrollerMixin
16
18
  * @private
17
19
  */
18
- export class ComboBoxScroller extends ComboBoxScrollerMixin(PolymerElement) {
20
+ export class ComboBoxScroller extends ComboBoxScrollerMixin(PolylitMixin(LitElement)) {
19
21
  static get is() {
20
22
  return 'vaadin-combo-box-scroller';
21
23
  }
22
24
 
23
- static get template() {
24
- return html`
25
- <style>
26
- :host {
27
- display: block;
28
- min-height: 1px;
29
- overflow: auto;
30
-
31
- /* Fixes item background from getting on top of scrollbars on Safari */
32
- transform: translate3d(0, 0, 0);
33
-
34
- /* Enable momentum scrolling on iOS */
35
- -webkit-overflow-scrolling: touch;
36
-
37
- /* Fixes scrollbar disappearing when 'Show scroll bars: Always' enabled in Safari */
38
- box-shadow: 0 0 0 white;
39
- }
25
+ static get styles() {
26
+ return comboBoxScrollerStyles;
27
+ }
40
28
 
41
- #selector {
42
- border-width: var(--_vaadin-combo-box-items-container-border-width);
43
- border-style: var(--_vaadin-combo-box-items-container-border-style);
44
- border-color: var(--_vaadin-combo-box-items-container-border-color, transparent);
45
- position: relative;
46
- }
47
- </style>
29
+ /** @protected */
30
+ render() {
31
+ return html`
48
32
  <div id="selector">
49
33
  <slot></slot>
50
34
  </div>
@@ -7,7 +7,6 @@ import type { DelegateFocusMixinClass } from '@vaadin/a11y-base/src/delegate-foc
7
7
  import type { DisabledMixinClass } from '@vaadin/a11y-base/src/disabled-mixin.js';
8
8
  import type { FocusMixinClass } from '@vaadin/a11y-base/src/focus-mixin.js';
9
9
  import type { KeyboardMixinClass } from '@vaadin/a11y-base/src/keyboard-mixin.js';
10
- import type { ControllerMixinClass } from '@vaadin/component-base/src/controller-mixin.js';
11
10
  import type { DelegateStateMixinClass } from '@vaadin/component-base/src/delegate-state-mixin.js';
12
11
  import type { ElementMixinClass } from '@vaadin/component-base/src/element-mixin.js';
13
12
  import type { OverlayClassMixinClass } from '@vaadin/component-base/src/overlay-class-mixin.js';
@@ -21,9 +20,12 @@ import type { PatternMixinClass } from '@vaadin/field-base/src/pattern-mixin.js'
21
20
  import type { ValidateMixinClass } from '@vaadin/field-base/src/validate-mixin.js';
22
21
  import type { ThemableMixinClass } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
23
22
  import type { ThemePropertyMixinClass } from '@vaadin/vaadin-themable-mixin/vaadin-theme-property-mixin.js';
23
+ import type { ComboBoxBaseMixinClass } from './vaadin-combo-box-base-mixin.js';
24
24
  import type { ComboBoxDataProviderMixinClass } from './vaadin-combo-box-data-provider-mixin.js';
25
+ import type { ComboBoxItemsMixinClass } from './vaadin-combo-box-items-mixin.js';
25
26
  import type { ComboBoxMixinClass } from './vaadin-combo-box-mixin.js';
26
27
  import type { ComboBoxDefaultItem } from './vaadin-combo-box-mixin.js';
28
+
27
29
  export {
28
30
  ComboBoxDataProvider,
29
31
  ComboBoxDataProviderCallback,
@@ -179,9 +181,12 @@ export interface ComboBoxEventMap<TItem> extends HTMLElementEventMap {
179
181
  *
180
182
  * In addition to `<vaadin-text-field>` parts, the following parts are available for theming:
181
183
  *
182
- * Part name | Description
183
- * ----------------|----------------
184
- * `toggle-button` | The toggle button
184
+ * Part name | Description
185
+ * -----------------|------------------
186
+ * `toggle-button` | The toggle button
187
+ * `overlay` | The overlay container
188
+ * `content` | The overlay content
189
+ * `loader` | The loading indicator shown while loading items
185
190
  *
186
191
  * In addition to `<vaadin-text-field>` state attributes, the following state attributes are available for theming:
187
192
  *
@@ -190,20 +195,12 @@ export interface ComboBoxEventMap<TItem> extends HTMLElementEventMap {
190
195
  * `opened` | Set when the combo box dropdown is open | :host
191
196
  * `loading` | Set when new items are expected | :host
192
197
  *
193
- * If you want to replace the default `<input>` and its container with a custom implementation to get full control
194
- * over the input field, consider using the [`<vaadin-combo-box-light>`](#/elements/vaadin-combo-box-light) element.
195
- *
196
198
  * ### Internal components
197
199
  *
198
200
  * In addition to `<vaadin-combo-box>` itself, the following internal
199
201
  * components are themable:
200
202
  *
201
- * - `<vaadin-combo-box-overlay>` - has the same API as [`<vaadin-overlay>`](#/elements/vaadin-overlay).
202
203
  * - `<vaadin-combo-box-item>` - has the same API as [`<vaadin-item>`](#/elements/vaadin-item).
203
- * - [`<vaadin-input-container>`](#/elements/vaadin-input-container) - an internal element wrapping the input.
204
- *
205
- * Note: the `theme` attribute value set on `<vaadin-combo-box>` is
206
- * propagated to the internal components listed above.
207
204
  *
208
205
  * See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
209
206
  *
@@ -232,7 +229,9 @@ declare class ComboBox<TItem = ComboBoxDefaultItem> extends HTMLElement {
232
229
 
233
230
  interface ComboBox<TItem = ComboBoxDefaultItem>
234
231
  extends ComboBoxDataProviderMixinClass<TItem>,
232
+ ComboBoxItemsMixinClass<TItem>,
235
233
  ComboBoxMixinClass<TItem>,
234
+ ComboBoxBaseMixinClass,
236
235
  ValidateMixinClass,
237
236
  PatternMixinClass,
238
237
  LabelMixinClass,
@@ -249,8 +248,7 @@ interface ComboBox<TItem = ComboBoxDefaultItem>
249
248
  DelegateFocusMixinClass,
250
249
  ThemableMixinClass,
251
250
  ThemePropertyMixinClass,
252
- ElementMixinClass,
253
- ControllerMixinClass {}
251
+ ElementMixinClass {}
254
252
 
255
253
  declare global {
256
254
  interface HTMLElementTagNameMap {
@@ -7,21 +7,23 @@ import '@vaadin/input-container/src/vaadin-input-container.js';
7
7
  import './vaadin-combo-box-item.js';
8
8
  import './vaadin-combo-box-overlay.js';
9
9
  import './vaadin-combo-box-scroller.js';
10
- import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
10
+ import { html, LitElement } from 'lit';
11
+ import { ifDefined } from 'lit/directives/if-defined.js';
11
12
  import { defineCustomElement } from '@vaadin/component-base/src/define.js';
12
13
  import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
14
+ import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
13
15
  import { TooltipController } from '@vaadin/component-base/src/tooltip-controller.js';
14
16
  import { InputControlMixin } from '@vaadin/field-base/src/input-control-mixin.js';
15
17
  import { InputController } from '@vaadin/field-base/src/input-controller.js';
16
18
  import { LabelledInputController } from '@vaadin/field-base/src/labelled-input-controller.js';
17
19
  import { PatternMixin } from '@vaadin/field-base/src/pattern-mixin.js';
18
20
  import { inputFieldShared } from '@vaadin/field-base/src/styles/input-field-shared-styles.js';
19
- import { registerStyles, ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
21
+ import { LumoInjectionMixin } from '@vaadin/vaadin-themable-mixin/lumo-injection-mixin.js';
22
+ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
23
+ import { comboBoxStyles } from './styles/vaadin-combo-box-core-styles.js';
20
24
  import { ComboBoxDataProviderMixin } from './vaadin-combo-box-data-provider-mixin.js';
21
25
  import { ComboBoxMixin } from './vaadin-combo-box-mixin.js';
22
26
 
23
- registerStyles('vaadin-combo-box', inputFieldShared, { moduleId: 'vaadin-combo-box-styles' });
24
-
25
27
  /**
26
28
  * `<vaadin-combo-box>` is a web component for choosing a value from a filterable list of options
27
29
  * presented in a dropdown overlay. The options can be provided as a list of strings or objects
@@ -110,9 +112,12 @@ registerStyles('vaadin-combo-box', inputFieldShared, { moduleId: 'vaadin-combo-b
110
112
  *
111
113
  * In addition to `<vaadin-text-field>` parts, the following parts are available for theming:
112
114
  *
113
- * Part name | Description
114
- * ----------------|----------------
115
- * `toggle-button` | The toggle button
115
+ * Part name | Description
116
+ * -----------------|------------------
117
+ * `toggle-button` | The toggle button
118
+ * `overlay` | The overlay container
119
+ * `content` | The overlay content
120
+ * `loader` | The loading indicator shown while loading items
116
121
  *
117
122
  * In addition to `<vaadin-text-field>` state attributes, the following state attributes are available for theming:
118
123
  *
@@ -121,20 +126,12 @@ registerStyles('vaadin-combo-box', inputFieldShared, { moduleId: 'vaadin-combo-b
121
126
  * `opened` | Set when the combo box dropdown is open | :host
122
127
  * `loading` | Set when new items are expected | :host
123
128
  *
124
- * If you want to replace the default `<input>` and its container with a custom implementation to get full control
125
- * over the input field, consider using the [`<vaadin-combo-box-light>`](#/elements/vaadin-combo-box-light) element.
126
- *
127
129
  * ### Internal components
128
130
  *
129
131
  * In addition to `<vaadin-combo-box>` itself, the following internal
130
132
  * components are themable:
131
133
  *
132
- * - `<vaadin-combo-box-overlay>` - has the same API as [`<vaadin-overlay>`](#/elements/vaadin-overlay).
133
134
  * - `<vaadin-combo-box-item>` - has the same API as [`<vaadin-item>`](#/elements/vaadin-item).
134
- * - [`<vaadin-input-container>`](#/elements/vaadin-input-container) - an internal element wrapping the input.
135
- *
136
- * Note: the `theme` attribute value set on `<vaadin-combo-box>` is
137
- * propagated to the internal components listed above.
138
135
  *
139
136
  * See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
140
137
  *
@@ -157,32 +154,53 @@ registerStyles('vaadin-combo-box', inputFieldShared, { moduleId: 'vaadin-combo-b
157
154
  * @mixes ComboBoxMixin
158
155
  */
159
156
  class ComboBox extends ComboBoxDataProviderMixin(
160
- ComboBoxMixin(PatternMixin(InputControlMixin(ThemableMixin(ElementMixin(PolymerElement))))),
157
+ ComboBoxMixin(
158
+ PatternMixin(InputControlMixin(ThemableMixin(ElementMixin(PolylitMixin(LumoInjectionMixin(LitElement)))))),
159
+ ),
161
160
  ) {
162
161
  static get is() {
163
162
  return 'vaadin-combo-box';
164
163
  }
165
164
 
166
- static get template() {
167
- return html`
168
- <style>
169
- :host([opened]) {
170
- pointer-events: auto;
171
- }
172
- </style>
165
+ static get styles() {
166
+ return [inputFieldShared, comboBoxStyles];
167
+ }
168
+
169
+ static get properties() {
170
+ return {
171
+ /**
172
+ * @protected
173
+ */
174
+ _positionTarget: {
175
+ type: Object,
176
+ },
177
+ };
178
+ }
179
+
180
+ /**
181
+ * Used by `InputControlMixin` as a reference to the clear button element.
182
+ * @protected
183
+ * @return {!HTMLElement}
184
+ */
185
+ get clearElement() {
186
+ return this.$.clearButton;
187
+ }
173
188
 
189
+ /** @protected */
190
+ render() {
191
+ return html`
174
192
  <div class="vaadin-combo-box-container">
175
193
  <div part="label">
176
194
  <slot name="label"></slot>
177
- <span part="required-indicator" aria-hidden="true" on-click="focus"></span>
195
+ <span part="required-indicator" aria-hidden="true" @click="${this.focus}"></span>
178
196
  </div>
179
197
 
180
198
  <vaadin-input-container
181
199
  part="input-field"
182
- readonly="[[readonly]]"
183
- disabled="[[disabled]]"
184
- invalid="[[invalid]]"
185
- theme$="[[_theme]]"
200
+ .readonly="${this.readonly}"
201
+ .disabled="${this.disabled}"
202
+ .invalid="${this.invalid}"
203
+ theme="${ifDefined(this._theme)}"
186
204
  >
187
205
  <slot name="prefix" slot="prefix"></slot>
188
206
  <slot name="input"></slot>
@@ -201,37 +219,22 @@ class ComboBox extends ComboBoxDataProviderMixin(
201
219
 
202
220
  <vaadin-combo-box-overlay
203
221
  id="overlay"
204
- opened="[[_overlayOpened]]"
205
- loading$="[[loading]]"
206
- theme$="[[_theme]]"
207
- position-target="[[_positionTarget]]"
222
+ exportparts="overlay, content, loader"
223
+ .owner="${this}"
224
+ .dir="${this.dir}"
225
+ .opened="${this._overlayOpened}"
226
+ ?loading="${this.loading}"
227
+ theme="${ifDefined(this._theme)}"
228
+ .positionTarget="${this._positionTarget}"
208
229
  no-vertical-overlap
209
- ></vaadin-combo-box-overlay>
230
+ >
231
+ <slot name="overlay"></slot>
232
+ </vaadin-combo-box-overlay>
210
233
 
211
234
  <slot name="tooltip"></slot>
212
235
  `;
213
236
  }
214
237
 
215
- static get properties() {
216
- return {
217
- /**
218
- * @protected
219
- */
220
- _positionTarget: {
221
- type: Object,
222
- },
223
- };
224
- }
225
-
226
- /**
227
- * Used by `InputControlMixin` as a reference to the clear button element.
228
- * @protected
229
- * @return {!HTMLElement}
230
- */
231
- get clearElement() {
232
- return this.$.clearButton;
233
- }
234
-
235
238
  /** @protected */
236
239
  ready() {
237
240
  super.ready();
@@ -256,6 +259,15 @@ class ComboBox extends ComboBoxDataProviderMixin(
256
259
  this._toggleElement = this.$.toggleButton;
257
260
  }
258
261
 
262
+ /** @protected */
263
+ updated(props) {
264
+ super.updated(props);
265
+
266
+ if (props.has('dataProvider') || props.has('value')) {
267
+ this._warnDataProviderValue(this.dataProvider, this.value);
268
+ }
269
+ }
270
+
259
271
  /**
260
272
  * Override the method from `InputControlMixin`
261
273
  * to stop event propagation to prevent `ComboBoxMixin`
@@ -282,6 +294,22 @@ class ComboBox extends ComboBoxDataProviderMixin(
282
294
  super._onHostClick(event);
283
295
  }
284
296
  }
297
+
298
+ /** @private */
299
+ _warnDataProviderValue(dataProvider, value) {
300
+ if (dataProvider && value !== '' && (this.selectedItem === undefined || this.selectedItem === null)) {
301
+ const valueIndex = this.__getItemIndexByValue(this.filteredItems, value);
302
+ if (valueIndex < 0 || !this._getItemLabel(this.filteredItems[valueIndex])) {
303
+ console.warn(
304
+ 'Warning: unable to determine the label for the provided `value`. ' +
305
+ 'Nothing to display in the text field. This usually happens when ' +
306
+ 'setting an initial `value` before any items are returned from ' +
307
+ 'the `dataProvider` callback. Consider setting `selectedItem` ' +
308
+ 'instead of `value`',
309
+ );
310
+ }
311
+ }
312
+ }
285
313
  }
286
314
 
287
315
  defineCustomElement(ComboBox);