@vaadin/combo-box 23.0.0-alpha2 → 23.0.0-beta1
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 +14 -13
- package/src/vaadin-combo-box-data-provider-mixin.d.ts +1 -1
- package/src/vaadin-combo-box-data-provider-mixin.js +1 -1
- package/src/vaadin-combo-box-dropdown.js +1 -1
- package/src/vaadin-combo-box-item.js +1 -1
- package/src/vaadin-combo-box-light.d.ts +1 -1
- package/src/vaadin-combo-box-light.js +1 -1
- package/src/vaadin-combo-box-mixin.d.ts +1 -1
- package/src/vaadin-combo-box-mixin.js +36 -15
- package/src/vaadin-combo-box-overlay.js +1 -1
- package/src/vaadin-combo-box-placeholder.js +1 -1
- package/src/vaadin-combo-box-scroller.js +15 -9
- package/src/vaadin-combo-box.d.ts +1 -1
- package/src/vaadin-combo-box.js +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/combo-box",
|
|
3
|
-
"version": "23.0.0-
|
|
3
|
+
"version": "23.0.0-beta1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"url": "https://github.com/vaadin/web-components/issues"
|
|
18
18
|
},
|
|
19
19
|
"main": "vaadin-combo-box.js",
|
|
20
|
+
"type": "module",
|
|
20
21
|
"files": [
|
|
21
22
|
"src",
|
|
22
23
|
"theme",
|
|
@@ -33,23 +34,23 @@
|
|
|
33
34
|
"dependencies": {
|
|
34
35
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
35
36
|
"@polymer/polymer": "^3.0.0",
|
|
36
|
-
"@vaadin/component-base": "23.0.0-
|
|
37
|
-
"@vaadin/field-base": "23.0.0-
|
|
38
|
-
"@vaadin/input-container": "23.0.0-
|
|
39
|
-
"@vaadin/item": "23.0.0-
|
|
40
|
-
"@vaadin/vaadin-lumo-styles": "23.0.0-
|
|
41
|
-
"@vaadin/vaadin-material-styles": "23.0.0-
|
|
42
|
-
"@vaadin/vaadin-overlay": "23.0.0-
|
|
43
|
-
"@vaadin/vaadin-themable-mixin": "23.0.0-
|
|
37
|
+
"@vaadin/component-base": "23.0.0-beta1",
|
|
38
|
+
"@vaadin/field-base": "23.0.0-beta1",
|
|
39
|
+
"@vaadin/input-container": "23.0.0-beta1",
|
|
40
|
+
"@vaadin/item": "23.0.0-beta1",
|
|
41
|
+
"@vaadin/vaadin-lumo-styles": "23.0.0-beta1",
|
|
42
|
+
"@vaadin/vaadin-material-styles": "23.0.0-beta1",
|
|
43
|
+
"@vaadin/vaadin-overlay": "23.0.0-beta1",
|
|
44
|
+
"@vaadin/vaadin-themable-mixin": "23.0.0-beta1"
|
|
44
45
|
},
|
|
45
46
|
"devDependencies": {
|
|
46
47
|
"@esm-bundle/chai": "^4.3.4",
|
|
47
|
-
"@vaadin/dialog": "23.0.0-
|
|
48
|
-
"@vaadin/polymer-legacy-adapter": "23.0.0-
|
|
48
|
+
"@vaadin/dialog": "23.0.0-beta1",
|
|
49
|
+
"@vaadin/polymer-legacy-adapter": "23.0.0-beta1",
|
|
49
50
|
"@vaadin/testing-helpers": "^0.3.2",
|
|
50
|
-
"@vaadin/text-field": "23.0.0-
|
|
51
|
+
"@vaadin/text-field": "23.0.0-beta1",
|
|
51
52
|
"lit": "^2.0.0",
|
|
52
53
|
"sinon": "^9.2.0"
|
|
53
54
|
},
|
|
54
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "467244b76021176c109df675799b07029b293e58"
|
|
55
56
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c)
|
|
3
|
+
* Copyright (c) 2015 - 2022 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { ComboBoxPlaceholder } from './vaadin-combo-box-placeholder.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c)
|
|
3
|
+
* Copyright (c) 2015 - 2022 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)
|
|
3
|
+
* Copyright (c) 2015 - 2022 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 { DisabledMixinClass } from '@vaadin/component-base/src/disabled-mixin.js';
|
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c)
|
|
3
|
+
* Copyright (c) 2015 - 2022 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import { isTouch } from '@vaadin/component-base/src/browser-utils.js';
|
|
7
|
+
import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
|
|
7
8
|
import { DisabledMixin } from '@vaadin/component-base/src/disabled-mixin.js';
|
|
8
9
|
import { KeyboardMixin } from '@vaadin/component-base/src/keyboard-mixin.js';
|
|
9
10
|
import { processTemplates } from '@vaadin/component-base/src/templates.js';
|
|
10
11
|
import { InputMixin } from '@vaadin/field-base/src/input-mixin.js';
|
|
12
|
+
import { VirtualKeyboardController } from '@vaadin/field-base/src/virtual-keyboard-controller.js';
|
|
11
13
|
import { ComboBoxPlaceholder } from './vaadin-combo-box-placeholder.js';
|
|
12
14
|
|
|
13
15
|
/**
|
|
14
16
|
* @polymerMixin
|
|
17
|
+
* @param {function(new:HTMLElement)} subclass
|
|
15
18
|
*/
|
|
16
19
|
export const ComboBoxMixin = (subclass) =>
|
|
17
|
-
class VaadinComboBoxMixinElement extends KeyboardMixin(InputMixin(DisabledMixin(subclass))) {
|
|
20
|
+
class VaadinComboBoxMixinElement extends ControllerMixin(KeyboardMixin(InputMixin(DisabledMixin(subclass)))) {
|
|
18
21
|
static get properties() {
|
|
19
22
|
return {
|
|
20
23
|
/**
|
|
@@ -295,6 +298,8 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
295
298
|
this.addEventListener('touchstart', bringToFrontListener);
|
|
296
299
|
|
|
297
300
|
processTemplates(this);
|
|
301
|
+
|
|
302
|
+
this.addController(new VirtualKeyboardController(this));
|
|
298
303
|
}
|
|
299
304
|
|
|
300
305
|
/**
|
|
@@ -308,6 +313,8 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
308
313
|
return;
|
|
309
314
|
}
|
|
310
315
|
|
|
316
|
+
this.$.dropdown._scroller.requestContentUpdate();
|
|
317
|
+
|
|
311
318
|
this._getItemElements().forEach((item) => {
|
|
312
319
|
item.requestContentUpdate();
|
|
313
320
|
});
|
|
@@ -409,6 +416,11 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
409
416
|
_handleClearButtonClick(event) {
|
|
410
417
|
event.preventDefault();
|
|
411
418
|
this._clear();
|
|
419
|
+
|
|
420
|
+
// De-select dropdown item
|
|
421
|
+
if (this.opened) {
|
|
422
|
+
this.requestContentUpdate();
|
|
423
|
+
}
|
|
412
424
|
}
|
|
413
425
|
|
|
414
426
|
/** @private */
|
|
@@ -690,17 +702,20 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
690
702
|
}
|
|
691
703
|
} else {
|
|
692
704
|
const toLowerCase = (item) => item && item.toLowerCase && item.toLowerCase();
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
705
|
+
|
|
706
|
+
// Try to find an item whose label matches the input value. A matching item is searched from
|
|
707
|
+
// the filteredItems array (if available) and the selectedItem (if available).
|
|
708
|
+
const itemMatchingByLabel = [...(this.filteredItems || []), this.selectedItem].find((item) => {
|
|
709
|
+
return toLowerCase(this._getItemLabel(item)) === toLowerCase(this._inputElementValue);
|
|
710
|
+
});
|
|
711
|
+
|
|
699
712
|
if (
|
|
700
713
|
this.allowCustomValue &&
|
|
701
714
|
// to prevent a repetitive input value being saved after pressing ESC and Tab.
|
|
702
|
-
!
|
|
715
|
+
!itemMatchingByLabel
|
|
703
716
|
) {
|
|
717
|
+
// An item matching by label was not found, but custom values are allowed.
|
|
718
|
+
// Dispatch a custom-value-set event with the input value.
|
|
704
719
|
const e = new CustomEvent('custom-value-set', {
|
|
705
720
|
detail: this._inputElementValue,
|
|
706
721
|
composed: true,
|
|
@@ -713,9 +728,11 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
713
728
|
this._selectItemForValue(customValue);
|
|
714
729
|
this.value = customValue;
|
|
715
730
|
}
|
|
716
|
-
} else if (!this.allowCustomValue && !this.opened &&
|
|
717
|
-
|
|
731
|
+
} else if (!this.allowCustomValue && !this.opened && itemMatchingByLabel) {
|
|
732
|
+
// An item matching by label was found, select it.
|
|
733
|
+
this.value = this._getItemValue(itemMatchingByLabel);
|
|
718
734
|
} else {
|
|
735
|
+
// Revert the input value
|
|
719
736
|
this._inputElementValue = this.selectedItem ? this._getItemLabel(this.selectedItem) : this.value || '';
|
|
720
737
|
}
|
|
721
738
|
}
|
|
@@ -929,10 +946,14 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
929
946
|
if (e.path === 'filteredItems' || e.path === 'filteredItems.splices') {
|
|
930
947
|
this._setOverlayItems(this.filteredItems);
|
|
931
948
|
|
|
932
|
-
this.
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
949
|
+
const filterIndex = this.$.dropdown.indexOfLabel(this.filter);
|
|
950
|
+
if (this.opened) {
|
|
951
|
+
this._focusedIndex = filterIndex;
|
|
952
|
+
} else {
|
|
953
|
+
// Pre-select item matching the filter to focus it later when overlay opens
|
|
954
|
+
const valueIndex = this._indexOfValue(this.value, this.filteredItems);
|
|
955
|
+
this._focusedIndex = filterIndex === -1 ? valueIndex : filterIndex;
|
|
956
|
+
}
|
|
936
957
|
|
|
937
958
|
// see https://github.com/vaadin/web-components/issues/2615
|
|
938
959
|
if (this.selectedItem === null && this._focusedIndex >= 0) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c)
|
|
3
|
+
* Copyright (c) 2015 - 2022 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 { OverlayElement } from '@vaadin/vaadin-overlay/src/vaadin-overlay.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c)
|
|
3
|
+
* Copyright (c) 2015 - 2022 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';
|
|
@@ -136,8 +136,8 @@ export class ComboBoxScroller extends PolymerElement {
|
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
__openedChanged(opened) {
|
|
139
|
-
if (
|
|
140
|
-
this.
|
|
139
|
+
if (opened) {
|
|
140
|
+
this.requestContentUpdate();
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
|
|
@@ -163,6 +163,12 @@ export class ComboBoxScroller extends PolymerElement {
|
|
|
163
163
|
});
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
+
requestContentUpdate() {
|
|
167
|
+
if (this.__virtualizer) {
|
|
168
|
+
this.__virtualizer.update();
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
166
172
|
scrollIntoView(index) {
|
|
167
173
|
if (!(this.opened && index >= 0)) {
|
|
168
174
|
return;
|
|
@@ -232,29 +238,29 @@ export class ComboBoxScroller extends PolymerElement {
|
|
|
232
238
|
this.__virtualizer.flush();
|
|
233
239
|
// Ensure the total count of items is properly announced.
|
|
234
240
|
this.setAttribute('aria-setsize', items.length);
|
|
235
|
-
this.
|
|
241
|
+
this.requestContentUpdate();
|
|
236
242
|
}
|
|
237
243
|
}
|
|
238
244
|
|
|
239
245
|
/** @private */
|
|
240
246
|
__loadingChanged(loading) {
|
|
241
247
|
if (this.__virtualizer && !loading) {
|
|
242
|
-
setTimeout(() => this.
|
|
248
|
+
setTimeout(() => this.requestContentUpdate());
|
|
243
249
|
}
|
|
244
250
|
}
|
|
245
251
|
|
|
246
252
|
/** @private */
|
|
247
253
|
__focusedIndexChanged(index) {
|
|
248
254
|
if (this.__virtualizer && index >= 0) {
|
|
249
|
-
this.
|
|
255
|
+
this.requestContentUpdate();
|
|
250
256
|
this.scrollIntoView(index);
|
|
251
257
|
}
|
|
252
258
|
}
|
|
253
259
|
|
|
254
260
|
/** @private */
|
|
255
261
|
__rendererChanged(renderer, oldRenderer) {
|
|
256
|
-
if (
|
|
257
|
-
this.
|
|
262
|
+
if (renderer || oldRenderer) {
|
|
263
|
+
this.requestContentUpdate();
|
|
258
264
|
}
|
|
259
265
|
}
|
|
260
266
|
|
|
@@ -287,7 +293,7 @@ export class ComboBoxScroller extends PolymerElement {
|
|
|
287
293
|
el.id = `${this.__hostTagName}-item-${index}`;
|
|
288
294
|
el.setAttribute('role', this.__getAriaRole(index));
|
|
289
295
|
el.setAttribute('aria-selected', this.__getAriaSelected(focusedIndex, index));
|
|
290
|
-
el.setAttribute('aria-posinset', index);
|
|
296
|
+
el.setAttribute('aria-posinset', index + 1);
|
|
291
297
|
|
|
292
298
|
if (this.theme) {
|
|
293
299
|
el.setAttribute('theme', this.theme);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c)
|
|
3
|
+
* Copyright (c) 2015 - 2022 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 { ControllerMixinClass } from '@vaadin/component-base/src/controller-mixin.js';
|
package/src/vaadin-combo-box.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright (c)
|
|
3
|
+
* Copyright (c) 2015 - 2022 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
6
|
import '@vaadin/input-container/src/vaadin-input-container.js';
|
|
@@ -244,7 +244,7 @@ class ComboBox extends ComboBoxDataProviderMixin(
|
|
|
244
244
|
this.ariaTarget = input;
|
|
245
245
|
})
|
|
246
246
|
);
|
|
247
|
-
this.addController(new LabelledInputController(this.inputElement, this.
|
|
247
|
+
this.addController(new LabelledInputController(this.inputElement, this._labelController));
|
|
248
248
|
this._positionTarget = this.shadowRoot.querySelector('[part="input-field"]');
|
|
249
249
|
this._toggleElement = this.$.toggleButton;
|
|
250
250
|
}
|