@vaadin/combo-box 24.4.0-dev.b3e1d14600 → 24.4.0-rc1
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/README.md +0 -1
- package/package.json +16 -14
- package/src/lit/renderer-directives.d.ts +1 -1
- package/src/lit/renderer-directives.js +1 -1
- package/src/vaadin-combo-box-data-provider-mixin.d.ts +1 -1
- package/src/vaadin-combo-box-data-provider-mixin.js +118 -120
- package/src/vaadin-combo-box-item-mixin.d.ts +1 -1
- package/src/vaadin-combo-box-item-mixin.js +2 -2
- package/src/vaadin-combo-box-item.d.ts +1 -1
- package/src/vaadin-combo-box-item.js +1 -1
- package/src/vaadin-combo-box-light-mixin.d.ts +26 -0
- package/src/vaadin-combo-box-light-mixin.js +140 -0
- package/src/vaadin-combo-box-light.d.ts +3 -8
- package/src/vaadin-combo-box-light.js +4 -128
- package/src/vaadin-combo-box-mixin.d.ts +1 -1
- package/src/vaadin-combo-box-mixin.js +89 -32
- package/src/vaadin-combo-box-overlay-mixin.d.ts +1 -1
- package/src/vaadin-combo-box-overlay-mixin.js +1 -1
- package/src/vaadin-combo-box-overlay.d.ts +1 -1
- package/src/vaadin-combo-box-overlay.js +1 -1
- package/src/vaadin-combo-box-placeholder.js +1 -1
- package/src/vaadin-combo-box-scroller-mixin.d.ts +1 -1
- package/src/vaadin-combo-box-scroller-mixin.js +41 -16
- package/src/vaadin-combo-box-scroller.d.ts +1 -1
- package/src/vaadin-combo-box-scroller.js +1 -1
- package/src/vaadin-combo-box.d.ts +1 -1
- package/src/vaadin-combo-box.js +1 -1
- package/src/vaadin-lit-combo-box-item.js +50 -0
- package/src/vaadin-lit-combo-box-light.js +58 -0
- package/src/vaadin-lit-combo-box-overlay.js +76 -0
- package/src/vaadin-lit-combo-box-scroller.js +59 -0
- package/src/vaadin-lit-combo-box.js +170 -0
- package/theme/lumo/vaadin-combo-box-item-styles.d.ts +5 -0
- package/theme/lumo/vaadin-combo-box-item-styles.js +2 -4
- package/theme/lumo/vaadin-combo-box-light.d.ts +3 -0
- package/theme/lumo/vaadin-combo-box-overlay-styles.d.ts +6 -0
- package/theme/lumo/vaadin-combo-box-styles.d.ts +2 -0
- package/theme/lumo/vaadin-combo-box.d.ts +4 -0
- package/theme/lumo/vaadin-lit-combo-box-light.d.ts +3 -0
- package/theme/lumo/vaadin-lit-combo-box-light.js +3 -0
- package/theme/lumo/vaadin-lit-combo-box.d.ts +4 -0
- package/theme/lumo/vaadin-lit-combo-box.js +4 -0
- package/theme/material/vaadin-combo-box-item-styles.d.ts +5 -0
- package/theme/material/vaadin-combo-box-light.d.ts +3 -0
- package/theme/material/vaadin-combo-box-overlay-styles.d.ts +4 -0
- package/theme/material/vaadin-combo-box-styles.d.ts +3 -0
- package/theme/material/vaadin-combo-box.d.ts +4 -0
- package/web-types.json +1188 -0
- package/web-types.lit.json +573 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2015 -
|
|
3
|
+
* Copyright (c) 2015 - 2024 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import type { DisabledMixinClass } from '@vaadin/a11y-base/src/disabled-mixin.js';
|
|
@@ -11,6 +11,7 @@ import type { ValidateMixinClass } from '@vaadin/field-base/src/validate-mixin.j
|
|
|
11
11
|
import type { ThemableMixinClass } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
12
12
|
import type { ThemePropertyMixinClass } from '@vaadin/vaadin-themable-mixin/vaadin-theme-property-mixin.js';
|
|
13
13
|
import type { ComboBoxDataProviderMixinClass } from './vaadin-combo-box-data-provider-mixin.js';
|
|
14
|
+
import type { ComboBoxLightMixinClass } from './vaadin-combo-box-light-mixin.js';
|
|
14
15
|
import type { ComboBoxDefaultItem, ComboBoxMixinClass } from './vaadin-combo-box-mixin.js';
|
|
15
16
|
export {
|
|
16
17
|
ComboBoxDataProvider,
|
|
@@ -126,13 +127,6 @@ export interface ComboBoxLightEventMap<TItem> extends HTMLElementEventMap {
|
|
|
126
127
|
* @fires {CustomEvent} validated - Fired whenever the field is validated.
|
|
127
128
|
*/
|
|
128
129
|
declare class ComboBoxLight<TItem = ComboBoxDefaultItem> extends HTMLElement {
|
|
129
|
-
/**
|
|
130
|
-
* Name of the two-way data-bindable property representing the
|
|
131
|
-
* value of the custom input field.
|
|
132
|
-
* @attr {string} attr-for-value
|
|
133
|
-
*/
|
|
134
|
-
attrForValue: string;
|
|
135
|
-
|
|
136
130
|
addEventListener<K extends keyof ComboBoxLightEventMap<TItem>>(
|
|
137
131
|
type: K,
|
|
138
132
|
listener: (this: ComboBoxLight<TItem>, ev: ComboBoxLightEventMap<TItem>[K]) => void,
|
|
@@ -148,6 +142,7 @@ declare class ComboBoxLight<TItem = ComboBoxDefaultItem> extends HTMLElement {
|
|
|
148
142
|
|
|
149
143
|
interface ComboBoxLight<TItem = ComboBoxDefaultItem>
|
|
150
144
|
extends ComboBoxDataProviderMixinClass<TItem>,
|
|
145
|
+
ComboBoxLightMixinClass,
|
|
151
146
|
ComboBoxMixinClass<TItem>,
|
|
152
147
|
KeyboardMixinClass,
|
|
153
148
|
InputMixinClass,
|
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2015 -
|
|
3
|
+
* Copyright (c) 2015 - 2024 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import './vaadin-combo-box-item.js';
|
|
7
7
|
import './vaadin-combo-box-overlay.js';
|
|
8
8
|
import './vaadin-combo-box-scroller.js';
|
|
9
|
-
import { dashToCamelCase } from '@polymer/polymer/lib/utils/case-map.js';
|
|
10
|
-
import { afterNextRender } from '@polymer/polymer/lib/utils/render-status.js';
|
|
11
9
|
import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
12
10
|
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
13
|
-
import { ValidateMixin } from '@vaadin/field-base/src/validate-mixin.js';
|
|
14
11
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
15
|
-
import {
|
|
16
|
-
import { ComboBoxMixin } from './vaadin-combo-box-mixin.js';
|
|
12
|
+
import { ComboBoxLightMixin } from './vaadin-combo-box-light-mixin.js';
|
|
17
13
|
|
|
18
14
|
/**
|
|
19
15
|
* `<vaadin-combo-box-light>` is a customizable version of the `<vaadin-combo-box>` providing
|
|
@@ -63,12 +59,10 @@ import { ComboBoxMixin } from './vaadin-combo-box-mixin.js';
|
|
|
63
59
|
*
|
|
64
60
|
* @customElement
|
|
65
61
|
* @extends HTMLElement
|
|
66
|
-
* @mixes
|
|
67
|
-
* @mixes ComboBoxMixin
|
|
62
|
+
* @mixes ComboBoxLightMixin
|
|
68
63
|
* @mixes ThemableMixin
|
|
69
|
-
* @mixes ValidateMixin
|
|
70
64
|
*/
|
|
71
|
-
class ComboBoxLight extends
|
|
65
|
+
class ComboBoxLight extends ComboBoxLightMixin(ThemableMixin(PolymerElement)) {
|
|
72
66
|
static get is() {
|
|
73
67
|
return 'vaadin-combo-box-light';
|
|
74
68
|
}
|
|
@@ -94,124 +88,6 @@ class ComboBoxLight extends ComboBoxDataProviderMixin(ComboBoxMixin(ValidateMixi
|
|
|
94
88
|
></vaadin-combo-box-overlay>
|
|
95
89
|
`;
|
|
96
90
|
}
|
|
97
|
-
|
|
98
|
-
static get properties() {
|
|
99
|
-
return {
|
|
100
|
-
/**
|
|
101
|
-
* Name of the two-way data-bindable property representing the
|
|
102
|
-
* value of the custom input field.
|
|
103
|
-
* @attr {string} attr-for-value
|
|
104
|
-
* @type {string}
|
|
105
|
-
*/
|
|
106
|
-
attrForValue: {
|
|
107
|
-
type: String,
|
|
108
|
-
value: 'value',
|
|
109
|
-
},
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Used by `InputControlMixin` as a reference to the clear button element.
|
|
115
|
-
* @protected
|
|
116
|
-
* @return {!HTMLElement}
|
|
117
|
-
*/
|
|
118
|
-
get clearElement() {
|
|
119
|
-
return this.querySelector('.clear-button');
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Override this getter from `InputMixin` to allow using
|
|
124
|
-
* an arbitrary property name instead of `value`
|
|
125
|
-
* for accessing the input element's value.
|
|
126
|
-
*
|
|
127
|
-
* @protected
|
|
128
|
-
* @override
|
|
129
|
-
* @return {string}
|
|
130
|
-
*/
|
|
131
|
-
get _inputElementValueProperty() {
|
|
132
|
-
return dashToCamelCase(this.attrForValue);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* @protected
|
|
137
|
-
* @override
|
|
138
|
-
* @return {HTMLInputElement | undefined}
|
|
139
|
-
*/
|
|
140
|
-
get _nativeInput() {
|
|
141
|
-
const input = this.inputElement;
|
|
142
|
-
|
|
143
|
-
if (input) {
|
|
144
|
-
// Support `<input class="input">`
|
|
145
|
-
if (input instanceof HTMLInputElement) {
|
|
146
|
-
return input;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
// Support `<input>` in light DOM (e.g. `vaadin-text-field`)
|
|
150
|
-
const slottedInput = input.querySelector('input');
|
|
151
|
-
if (slottedInput) {
|
|
152
|
-
return slottedInput;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
if (input.shadowRoot) {
|
|
156
|
-
// Support `<input>` in Shadow DOM (e.g. `mwc-textfield`)
|
|
157
|
-
const shadowInput = input.shadowRoot.querySelector('input');
|
|
158
|
-
if (shadowInput) {
|
|
159
|
-
return shadowInput;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
return undefined;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
/** @protected */
|
|
168
|
-
ready() {
|
|
169
|
-
super.ready();
|
|
170
|
-
|
|
171
|
-
this._toggleElement = this.querySelector('.toggle-button');
|
|
172
|
-
|
|
173
|
-
// Wait until the slotted input DOM is ready
|
|
174
|
-
afterNextRender(this, () => {
|
|
175
|
-
this._setInputElement(this.querySelector('vaadin-text-field,.input'));
|
|
176
|
-
this._revertInputValue();
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* Returns true if the current input value satisfies all constraints (if any).
|
|
182
|
-
* @return {boolean}
|
|
183
|
-
*/
|
|
184
|
-
checkValidity() {
|
|
185
|
-
if (this.inputElement && this.inputElement.validate) {
|
|
186
|
-
return this.inputElement.validate();
|
|
187
|
-
}
|
|
188
|
-
return super.checkValidity();
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
/** @protected */
|
|
192
|
-
_isClearButton(event) {
|
|
193
|
-
return (
|
|
194
|
-
super._isClearButton(event) ||
|
|
195
|
-
(event.type === 'input' && !event.isTrusted) || // Fake input event dispatched by clear button
|
|
196
|
-
event.composedPath()[0].getAttribute('part') === 'clear-button'
|
|
197
|
-
);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* @protected
|
|
202
|
-
* @override
|
|
203
|
-
*/
|
|
204
|
-
_shouldRemoveFocus(event) {
|
|
205
|
-
const isBlurringControlButtons = event.target === this._toggleElement || event.target === this.clearElement;
|
|
206
|
-
const isFocusingInputElement = event.relatedTarget && event.relatedTarget === this._nativeInput;
|
|
207
|
-
|
|
208
|
-
// prevent closing the overlay when moving focus from clear or toggle buttons to the internal input
|
|
209
|
-
if (isBlurringControlButtons && isFocusingInputElement) {
|
|
210
|
-
return false;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
return super._shouldRemoveFocus(event);
|
|
214
|
-
}
|
|
215
91
|
}
|
|
216
92
|
|
|
217
93
|
defineCustomElement(ComboBoxLight);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2015 -
|
|
3
|
+
* Copyright (c) 2015 - 2024 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import type { Constructor } from '@open-wc/dedupe-mixin';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2015 -
|
|
3
|
+
* Copyright (c) 2015 - 2024 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { DisabledMixin } from '@vaadin/a11y-base/src/disabled-mixin.js';
|
|
@@ -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:
|
|
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:
|
|
239
|
+
itemIdPath: {
|
|
240
|
+
type: String,
|
|
241
|
+
sync: true,
|
|
242
|
+
},
|
|
227
243
|
|
|
228
244
|
/**
|
|
229
245
|
* @type {!HTMLElement | undefined}
|
|
@@ -240,27 +256,38 @@ 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:
|
|
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
|
},
|
|
277
|
+
|
|
278
|
+
/** @private */
|
|
279
|
+
__keepOverlayOpened: {
|
|
280
|
+
type: Boolean,
|
|
281
|
+
sync: true,
|
|
282
|
+
},
|
|
256
283
|
};
|
|
257
284
|
}
|
|
258
285
|
|
|
259
286
|
static get observers() {
|
|
260
287
|
return [
|
|
261
288
|
'_selectedItemChanged(selectedItem, itemValuePath, itemLabelPath)',
|
|
262
|
-
'_openedOrItemsChanged(opened, _dropdownItems, loading,
|
|
263
|
-
'_updateScroller(_scroller, _dropdownItems, opened, loading, selectedItem, itemIdPath, _focusedIndex, renderer,
|
|
289
|
+
'_openedOrItemsChanged(opened, _dropdownItems, loading, __keepOverlayOpened)',
|
|
290
|
+
'_updateScroller(_scroller, _dropdownItems, opened, loading, selectedItem, itemIdPath, _focusedIndex, renderer, _theme)',
|
|
264
291
|
];
|
|
265
292
|
}
|
|
266
293
|
|
|
@@ -413,6 +440,18 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
413
440
|
}
|
|
414
441
|
}
|
|
415
442
|
|
|
443
|
+
/**
|
|
444
|
+
* Override LitElement lifecycle callback to handle filter property change.
|
|
445
|
+
* @param {Object} props
|
|
446
|
+
*/
|
|
447
|
+
updated(props) {
|
|
448
|
+
super.updated(props);
|
|
449
|
+
|
|
450
|
+
if (props.has('filter')) {
|
|
451
|
+
this._filterChanged(this.filter);
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
|
|
416
455
|
/** @private */
|
|
417
456
|
_initOverlay() {
|
|
418
457
|
const overlay = this.$.overlay;
|
|
@@ -441,25 +480,23 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
441
480
|
* @protected
|
|
442
481
|
*/
|
|
443
482
|
_initScroller(host) {
|
|
444
|
-
const
|
|
483
|
+
const scroller = document.createElement(`${this._tagNamePrefix}-scroller`);
|
|
484
|
+
|
|
485
|
+
scroller.owner = host || this;
|
|
486
|
+
scroller.getItemLabel = this._getItemLabel.bind(this);
|
|
487
|
+
scroller.addEventListener('selection-changed', this._boundOverlaySelectedItemChanged);
|
|
445
488
|
|
|
446
489
|
const overlay = this._overlayElement;
|
|
447
490
|
|
|
448
491
|
overlay.renderer = (root) => {
|
|
449
|
-
if (!root.
|
|
450
|
-
root.appendChild(
|
|
492
|
+
if (!root.innerHTML) {
|
|
493
|
+
root.appendChild(scroller);
|
|
451
494
|
}
|
|
452
495
|
};
|
|
453
496
|
|
|
454
497
|
// Ensure the scroller is rendered
|
|
455
498
|
overlay.requestContentUpdate();
|
|
456
499
|
|
|
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
500
|
// Trigger the observer to set properties
|
|
464
501
|
this._scroller = scroller;
|
|
465
502
|
}
|
|
@@ -483,6 +520,17 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
483
520
|
renderer,
|
|
484
521
|
theme,
|
|
485
522
|
});
|
|
523
|
+
|
|
524
|
+
// NOTE: in PolylitMixin, setProperties() waits for `hasUpdated` to be set.
|
|
525
|
+
// This means for the first opening, properties won't be set synchronously.
|
|
526
|
+
// Call `performUpdate()` in this case to mimic the Polymer version logic.
|
|
527
|
+
if (scroller.performUpdate && !scroller.hasUpdated) {
|
|
528
|
+
try {
|
|
529
|
+
scroller.performUpdate();
|
|
530
|
+
} catch (_) {
|
|
531
|
+
// Suppress errors in synchronous tests for pre-opened combo-box.
|
|
532
|
+
}
|
|
533
|
+
}
|
|
486
534
|
}
|
|
487
535
|
}
|
|
488
536
|
|
|
@@ -490,7 +538,7 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
490
538
|
_openedOrItemsChanged(opened, items, loading, keepOverlayOpened) {
|
|
491
539
|
// Close the overlay if there are no items to display.
|
|
492
540
|
// See https://github.com/vaadin/vaadin-combo-box/pull/964
|
|
493
|
-
this._overlayOpened =
|
|
541
|
+
this._overlayOpened = opened && (keepOverlayOpened || loading || !!(items && items.length));
|
|
494
542
|
}
|
|
495
543
|
|
|
496
544
|
/** @private */
|
|
@@ -542,7 +590,6 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
542
590
|
}
|
|
543
591
|
|
|
544
592
|
if (opened) {
|
|
545
|
-
this._openedWithFocusRing = this.hasAttribute('focus-ring');
|
|
546
593
|
// For touch devices, we don't want to popup virtual keyboard
|
|
547
594
|
// unless input element is explicitly focused by the user.
|
|
548
595
|
if (!this._isInputFocused() && !isTouch) {
|
|
@@ -554,9 +601,6 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
554
601
|
this._overlayElement.restoreFocusOnClose = true;
|
|
555
602
|
} else {
|
|
556
603
|
this._onClosed();
|
|
557
|
-
if (this._openedWithFocusRing && this._isInputFocused()) {
|
|
558
|
-
this.setAttribute('focus-ring', '');
|
|
559
|
-
}
|
|
560
604
|
}
|
|
561
605
|
|
|
562
606
|
const input = this._nativeInput;
|
|
@@ -772,11 +816,7 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
772
816
|
// Do not commit value when custom values are disallowed and input value is not a valid option
|
|
773
817
|
// also stop propagation of the event, otherwise the user could submit a form while the input
|
|
774
818
|
// still contains an invalid value
|
|
775
|
-
|
|
776
|
-
this._focusedIndex < 0 &&
|
|
777
|
-
this._inputElementValue !== '' &&
|
|
778
|
-
this._getItemLabel(this.selectedItem) !== this._inputElementValue;
|
|
779
|
-
if (!this.allowCustomValue && hasInvalidOption) {
|
|
819
|
+
if (!this._hasValidInputValue()) {
|
|
780
820
|
// Do not submit the surrounding form.
|
|
781
821
|
e.preventDefault();
|
|
782
822
|
// Do not trigger global listeners
|
|
@@ -796,6 +836,18 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
796
836
|
this._closeOrCommit();
|
|
797
837
|
}
|
|
798
838
|
|
|
839
|
+
/**
|
|
840
|
+
* @protected
|
|
841
|
+
*/
|
|
842
|
+
_hasValidInputValue() {
|
|
843
|
+
const hasInvalidOption =
|
|
844
|
+
this._focusedIndex < 0 &&
|
|
845
|
+
this._inputElementValue !== '' &&
|
|
846
|
+
this._getItemLabel(this.selectedItem) !== this._inputElementValue;
|
|
847
|
+
|
|
848
|
+
return this.allowCustomValue || !hasInvalidOption;
|
|
849
|
+
}
|
|
850
|
+
|
|
799
851
|
/**
|
|
800
852
|
* Override an event listener from `KeyboardMixin`.
|
|
801
853
|
* Do not call `super` in order to override clear
|
|
@@ -867,6 +919,15 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
867
919
|
this._detectAndDispatchChange();
|
|
868
920
|
}
|
|
869
921
|
|
|
922
|
+
/**
|
|
923
|
+
* Clears the current filter. Should be used instead of setting the property
|
|
924
|
+
* directly in order to allow overriding this in multi-select combo box.
|
|
925
|
+
* @protected
|
|
926
|
+
*/
|
|
927
|
+
_clearFilter() {
|
|
928
|
+
this.filter = '';
|
|
929
|
+
}
|
|
930
|
+
|
|
870
931
|
/**
|
|
871
932
|
* Reverts back to original value.
|
|
872
933
|
*/
|
|
@@ -938,7 +999,7 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
938
999
|
this.value = this._getItemValue(itemMatchingInputValue);
|
|
939
1000
|
} else {
|
|
940
1001
|
// Revert the input value
|
|
941
|
-
this.
|
|
1002
|
+
this._revertInputValueToValue();
|
|
942
1003
|
}
|
|
943
1004
|
}
|
|
944
1005
|
|
|
@@ -946,7 +1007,7 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
946
1007
|
|
|
947
1008
|
this._clearSelectionRange();
|
|
948
1009
|
|
|
949
|
-
this.
|
|
1010
|
+
this._clearFilter();
|
|
950
1011
|
}
|
|
951
1012
|
|
|
952
1013
|
/**
|
|
@@ -1087,7 +1148,7 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
1087
1148
|
this.selectedItem = null;
|
|
1088
1149
|
}
|
|
1089
1150
|
|
|
1090
|
-
this.
|
|
1151
|
+
this._clearFilter();
|
|
1091
1152
|
|
|
1092
1153
|
// In the next _detectAndDispatchChange() call, the change detection should pass
|
|
1093
1154
|
this._lastCommittedValue = undefined;
|
|
@@ -1113,10 +1174,6 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
1113
1174
|
this.items = oldItems;
|
|
1114
1175
|
});
|
|
1115
1176
|
|
|
1116
|
-
if (this.dataProvider) {
|
|
1117
|
-
return;
|
|
1118
|
-
}
|
|
1119
|
-
|
|
1120
1177
|
if (items) {
|
|
1121
1178
|
this.filteredItems = items.slice(0);
|
|
1122
1179
|
} else if (oldItems) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2015 -
|
|
3
|
+
* Copyright (c) 2015 - 2024 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import type { Constructor } from '@open-wc/dedupe-mixin';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2015 -
|
|
3
|
+
* Copyright (c) 2015 - 2024 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { PositionMixin } from '@vaadin/overlay/src/vaadin-overlay-position-mixin.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2015 -
|
|
3
|
+
* Copyright (c) 2015 - 2024 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { DirMixin } from '@vaadin/component-base/src/dir-mixin.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2015 -
|
|
3
|
+
* Copyright (c) 2015 - 2024 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c) 2015 -
|
|
3
|
+
* Copyright (c) 2015 - 2024 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import type { Constructor } from '@open-wc/dedupe-mixin';
|