@vaadin/combo-box 22.0.1 → 22.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +13 -14
- 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 +2 -12
- 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 +34 -19
- 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 +17 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/combo-box",
|
|
3
|
-
"version": "22.0.
|
|
3
|
+
"version": "22.0.5",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -32,25 +32,24 @@
|
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
35
|
-
"@polymer/iron-resizable-behavior": "^3.0.0",
|
|
36
35
|
"@polymer/polymer": "^3.0.0",
|
|
37
|
-
"@vaadin/component-base": "^22.0.
|
|
38
|
-
"@vaadin/field-base": "^22.0.
|
|
39
|
-
"@vaadin/input-container": "^22.0.
|
|
40
|
-
"@vaadin/item": "^22.0.
|
|
41
|
-
"@vaadin/vaadin-lumo-styles": "^22.0.
|
|
42
|
-
"@vaadin/vaadin-material-styles": "^22.0.
|
|
43
|
-
"@vaadin/vaadin-overlay": "^22.0.
|
|
44
|
-
"@vaadin/vaadin-themable-mixin": "^22.0.
|
|
36
|
+
"@vaadin/component-base": "^22.0.5",
|
|
37
|
+
"@vaadin/field-base": "^22.0.5",
|
|
38
|
+
"@vaadin/input-container": "^22.0.5",
|
|
39
|
+
"@vaadin/item": "^22.0.5",
|
|
40
|
+
"@vaadin/vaadin-lumo-styles": "^22.0.5",
|
|
41
|
+
"@vaadin/vaadin-material-styles": "^22.0.5",
|
|
42
|
+
"@vaadin/vaadin-overlay": "^22.0.5",
|
|
43
|
+
"@vaadin/vaadin-themable-mixin": "^22.0.5"
|
|
45
44
|
},
|
|
46
45
|
"devDependencies": {
|
|
47
46
|
"@esm-bundle/chai": "^4.3.4",
|
|
48
|
-
"@vaadin/dialog": "^22.0.
|
|
49
|
-
"@vaadin/polymer-legacy-adapter": "^22.0.
|
|
47
|
+
"@vaadin/dialog": "^22.0.5",
|
|
48
|
+
"@vaadin/polymer-legacy-adapter": "^22.0.5",
|
|
50
49
|
"@vaadin/testing-helpers": "^0.3.2",
|
|
51
|
-
"@vaadin/text-field": "^22.0.
|
|
50
|
+
"@vaadin/text-field": "^22.0.5",
|
|
52
51
|
"lit": "^2.0.0",
|
|
53
52
|
"sinon": "^9.2.0"
|
|
54
53
|
},
|
|
55
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "3e1990867670f3de2dec6fa1200d945623b2710c"
|
|
56
55
|
}
|
|
@@ -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,13 +1,11 @@
|
|
|
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-combo-box-item.js';
|
|
7
7
|
import './vaadin-combo-box-overlay.js';
|
|
8
8
|
import './vaadin-combo-box-scroller.js';
|
|
9
|
-
import { IronResizableBehavior } from '@polymer/iron-resizable-behavior/iron-resizable-behavior.js';
|
|
10
|
-
import { mixinBehaviors } from '@polymer/polymer/lib/legacy/class.js';
|
|
11
9
|
import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
12
10
|
|
|
13
11
|
/**
|
|
@@ -16,7 +14,7 @@ import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
|
16
14
|
* @extends HTMLElement
|
|
17
15
|
* @private
|
|
18
16
|
*/
|
|
19
|
-
export class ComboBoxDropdown extends
|
|
17
|
+
export class ComboBoxDropdown extends PolymerElement {
|
|
20
18
|
static get is() {
|
|
21
19
|
return 'vaadin-combo-box-dropdown';
|
|
22
20
|
}
|
|
@@ -171,14 +169,6 @@ export class ComboBoxDropdown extends mixinBehaviors(IronResizableBehavior, Poly
|
|
|
171
169
|
this._overlayOpened = false;
|
|
172
170
|
}
|
|
173
171
|
|
|
174
|
-
notifyResize() {
|
|
175
|
-
super.notifyResize();
|
|
176
|
-
|
|
177
|
-
if (this.positionTarget && this.opened) {
|
|
178
|
-
this._setOverlayWidth();
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
172
|
_fireTouchAction(sourceEvent) {
|
|
183
173
|
this.dispatchEvent(
|
|
184
174
|
new CustomEvent('vaadin-overlay-touch-action', {
|
|
@@ -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,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 { isTouch } from '@vaadin/component-base/src/browser-utils.js';
|
|
@@ -305,6 +305,8 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
305
305
|
return;
|
|
306
306
|
}
|
|
307
307
|
|
|
308
|
+
this.$.dropdown._scroller.requestContentUpdate();
|
|
309
|
+
|
|
308
310
|
this._getItemElements().forEach((item) => {
|
|
309
311
|
item.requestContentUpdate();
|
|
310
312
|
});
|
|
@@ -404,6 +406,21 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
404
406
|
_handleClearButtonClick(event) {
|
|
405
407
|
event.preventDefault();
|
|
406
408
|
this._clear();
|
|
409
|
+
|
|
410
|
+
// De-select dropdown item
|
|
411
|
+
if (this.opened) {
|
|
412
|
+
this.requestContentUpdate();
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* @param {Event} event
|
|
418
|
+
* @protected
|
|
419
|
+
*/
|
|
420
|
+
_onHostClick(_event) {
|
|
421
|
+
if (!this.autoOpenDisabled) {
|
|
422
|
+
this.open();
|
|
423
|
+
}
|
|
407
424
|
}
|
|
408
425
|
|
|
409
426
|
/** @private */
|
|
@@ -420,8 +437,8 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
420
437
|
} else {
|
|
421
438
|
this.open();
|
|
422
439
|
}
|
|
423
|
-
} else
|
|
424
|
-
this.
|
|
440
|
+
} else {
|
|
441
|
+
this._onHostClick(e);
|
|
425
442
|
}
|
|
426
443
|
|
|
427
444
|
this._closeOnBlurIsPrevented = false;
|
|
@@ -643,8 +660,6 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
643
660
|
|
|
644
661
|
/** @private */
|
|
645
662
|
_onOpened() {
|
|
646
|
-
setTimeout(() => this._resizeDropdown(), 1);
|
|
647
|
-
|
|
648
663
|
// Defer scroll position adjustment to improve performance.
|
|
649
664
|
requestAnimationFrame(() => {
|
|
650
665
|
this.$.dropdown.adjustScrollPosition();
|
|
@@ -687,17 +702,20 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
687
702
|
}
|
|
688
703
|
} else {
|
|
689
704
|
const toLowerCase = (item) => item && item.toLowerCase && item.toLowerCase();
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
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
|
+
|
|
696
712
|
if (
|
|
697
713
|
this.allowCustomValue &&
|
|
698
714
|
// to prevent a repetitive input value being saved after pressing ESC and Tab.
|
|
699
|
-
!
|
|
715
|
+
!itemMatchingByLabel
|
|
700
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.
|
|
701
719
|
const e = new CustomEvent('custom-value-set', {
|
|
702
720
|
detail: this._inputElementValue,
|
|
703
721
|
composed: true,
|
|
@@ -710,9 +728,11 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
710
728
|
this._selectItemForValue(customValue);
|
|
711
729
|
this.value = customValue;
|
|
712
730
|
}
|
|
713
|
-
} else if (!this.allowCustomValue && !this.opened &&
|
|
714
|
-
|
|
731
|
+
} else if (!this.allowCustomValue && !this.opened && itemMatchingByLabel) {
|
|
732
|
+
// An item matching by label was found, select it.
|
|
733
|
+
this.value = this._getItemValue(itemMatchingByLabel);
|
|
715
734
|
} else {
|
|
735
|
+
// Revert the input value
|
|
716
736
|
this._inputElementValue = this.selectedItem ? this._getItemLabel(this.selectedItem) : this.value || '';
|
|
717
737
|
}
|
|
718
738
|
}
|
|
@@ -820,11 +840,6 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
820
840
|
}
|
|
821
841
|
}
|
|
822
842
|
|
|
823
|
-
/** @private */
|
|
824
|
-
_resizeDropdown() {
|
|
825
|
-
this.$.dropdown.notifyResize();
|
|
826
|
-
}
|
|
827
|
-
|
|
828
843
|
/** @private */
|
|
829
844
|
_selectedItemChanged(selectedItem) {
|
|
830
845
|
if (selectedItem === null || selectedItem === undefined) {
|
|
@@ -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;
|
|
@@ -233,29 +239,29 @@ export class ComboBoxScroller extends PolymerElement {
|
|
|
233
239
|
this.__virtualizer.flush();
|
|
234
240
|
// Ensure the total count of items is properly announced.
|
|
235
241
|
this.setAttribute('aria-setsize', items.length);
|
|
236
|
-
this.
|
|
242
|
+
this.requestContentUpdate();
|
|
237
243
|
}
|
|
238
244
|
}
|
|
239
245
|
|
|
240
246
|
/** @private */
|
|
241
247
|
__loadingChanged(loading) {
|
|
242
248
|
if (this.__virtualizer && !loading) {
|
|
243
|
-
setTimeout(() => this.
|
|
249
|
+
setTimeout(() => this.requestContentUpdate());
|
|
244
250
|
}
|
|
245
251
|
}
|
|
246
252
|
|
|
247
253
|
/** @private */
|
|
248
254
|
__focusedIndexChanged(index) {
|
|
249
255
|
if (this.__virtualizer && index >= 0) {
|
|
250
|
-
this.
|
|
256
|
+
this.requestContentUpdate();
|
|
251
257
|
this.scrollIntoView(index);
|
|
252
258
|
}
|
|
253
259
|
}
|
|
254
260
|
|
|
255
261
|
/** @private */
|
|
256
262
|
__rendererChanged(renderer, oldRenderer) {
|
|
257
|
-
if (
|
|
258
|
-
this.
|
|
263
|
+
if (renderer || oldRenderer) {
|
|
264
|
+
this.requestContentUpdate();
|
|
259
265
|
}
|
|
260
266
|
}
|
|
261
267
|
|
|
@@ -288,7 +294,7 @@ export class ComboBoxScroller extends PolymerElement {
|
|
|
288
294
|
el.id = `${this.__hostTagName}-item-${index}`;
|
|
289
295
|
el.setAttribute('role', this.__getAriaRole(index));
|
|
290
296
|
el.setAttribute('aria-selected', this.__getAriaSelected(focusedIndex, index));
|
|
291
|
-
el.setAttribute('aria-posinset', index);
|
|
297
|
+
el.setAttribute('aria-posinset', index + 1);
|
|
292
298
|
|
|
293
299
|
if (this.theme) {
|
|
294
300
|
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';
|
|
@@ -183,8 +183,8 @@ class ComboBox extends ComboBoxDataProviderMixin(
|
|
|
183
183
|
>
|
|
184
184
|
<slot name="prefix" slot="prefix"></slot>
|
|
185
185
|
<slot name="input"></slot>
|
|
186
|
-
<div id="clearButton" part="clear-button" slot="suffix"></div>
|
|
187
|
-
<div id="toggleButton" part="toggle-button" slot="suffix"></div>
|
|
186
|
+
<div id="clearButton" part="clear-button" slot="suffix" aria-hidden="true"></div>
|
|
187
|
+
<div id="toggleButton" part="toggle-button" slot="suffix" aria-hidden="true"></div>
|
|
188
188
|
</vaadin-input-container>
|
|
189
189
|
|
|
190
190
|
<div part="helper-text">
|
|
@@ -242,7 +242,7 @@ class ComboBox extends ComboBoxDataProviderMixin(
|
|
|
242
242
|
this.ariaTarget = input;
|
|
243
243
|
})
|
|
244
244
|
);
|
|
245
|
-
this.addController(new LabelledInputController(this.inputElement, this.
|
|
245
|
+
this.addController(new LabelledInputController(this.inputElement, this._labelController));
|
|
246
246
|
this._positionTarget = this.shadowRoot.querySelector('[part="input-field"]');
|
|
247
247
|
this._toggleElement = this.$.toggleButton;
|
|
248
248
|
}
|
|
@@ -291,6 +291,19 @@ class ComboBox extends ComboBoxDataProviderMixin(
|
|
|
291
291
|
|
|
292
292
|
this._handleClearButtonClick(event);
|
|
293
293
|
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* @param {Event} event
|
|
297
|
+
* @protected
|
|
298
|
+
*/
|
|
299
|
+
_onHostClick(event) {
|
|
300
|
+
const path = event.composedPath();
|
|
301
|
+
|
|
302
|
+
// Open dropdown only when clicking on the label or input field
|
|
303
|
+
if (path.includes(this._labelNode) || path.includes(this._positionTarget)) {
|
|
304
|
+
super._onHostClick(event);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
294
307
|
}
|
|
295
308
|
|
|
296
309
|
customElements.define(ComboBox.is, ComboBox);
|