@vaadin/combo-box 22.0.0-rc1 → 23.0.0-alpha2
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.js +1 -2
- package/src/vaadin-combo-box-dropdown.js +4 -11
- package/src/vaadin-combo-box-item.js +4 -2
- package/src/vaadin-combo-box-light.d.ts +9 -0
- package/src/vaadin-combo-box-light.js +3 -2
- package/src/vaadin-combo-box-mixin.js +26 -28
- package/src/vaadin-combo-box-scroller.js +1 -2
- package/src/vaadin-combo-box.d.ts +9 -0
- package/src/vaadin-combo-box.js +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/combo-box",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "23.0.0-alpha2",
|
|
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": "
|
|
38
|
-
"@vaadin/field-base": "
|
|
39
|
-
"@vaadin/input-container": "
|
|
40
|
-
"@vaadin/item": "
|
|
41
|
-
"@vaadin/vaadin-lumo-styles": "
|
|
42
|
-
"@vaadin/vaadin-material-styles": "
|
|
43
|
-
"@vaadin/vaadin-overlay": "
|
|
44
|
-
"@vaadin/vaadin-themable-mixin": "
|
|
36
|
+
"@vaadin/component-base": "23.0.0-alpha2",
|
|
37
|
+
"@vaadin/field-base": "23.0.0-alpha2",
|
|
38
|
+
"@vaadin/input-container": "23.0.0-alpha2",
|
|
39
|
+
"@vaadin/item": "23.0.0-alpha2",
|
|
40
|
+
"@vaadin/vaadin-lumo-styles": "23.0.0-alpha2",
|
|
41
|
+
"@vaadin/vaadin-material-styles": "23.0.0-alpha2",
|
|
42
|
+
"@vaadin/vaadin-overlay": "23.0.0-alpha2",
|
|
43
|
+
"@vaadin/vaadin-themable-mixin": "23.0.0-alpha2"
|
|
45
44
|
},
|
|
46
45
|
"devDependencies": {
|
|
47
46
|
"@esm-bundle/chai": "^4.3.4",
|
|
48
|
-
"@vaadin/dialog": "
|
|
49
|
-
"@vaadin/polymer-legacy-adapter": "
|
|
47
|
+
"@vaadin/dialog": "23.0.0-alpha2",
|
|
48
|
+
"@vaadin/polymer-legacy-adapter": "23.0.0-alpha2",
|
|
50
49
|
"@vaadin/testing-helpers": "^0.3.2",
|
|
51
|
-
"@vaadin/text-field": "
|
|
50
|
+
"@vaadin/text-field": "23.0.0-alpha2",
|
|
52
51
|
"lit": "^2.0.0",
|
|
53
52
|
"sinon": "^9.2.0"
|
|
54
53
|
},
|
|
55
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "070f586dead02ca41b66717820c647f48bf1665f"
|
|
56
55
|
}
|
|
@@ -158,9 +158,8 @@ export const ComboBoxDataProviderMixin = (superClass) =>
|
|
|
158
158
|
const loadedItem = this.filteredItems[page * this.pageSize];
|
|
159
159
|
if (loadedItem !== undefined) {
|
|
160
160
|
return loadedItem instanceof ComboBoxPlaceholder;
|
|
161
|
-
} else {
|
|
162
|
-
return this.size === undefined;
|
|
163
161
|
}
|
|
162
|
+
return this.size === undefined;
|
|
164
163
|
}
|
|
165
164
|
|
|
166
165
|
/** @private */
|
|
@@ -6,8 +6,6 @@
|
|
|
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
|
}
|
|
@@ -31,6 +29,8 @@ export class ComboBoxDropdown extends mixinBehaviors(IronResizableBehavior, Poly
|
|
|
31
29
|
theme$="[[theme]]"
|
|
32
30
|
position-target="[[positionTarget]]"
|
|
33
31
|
no-vertical-overlap
|
|
32
|
+
restore-focus-on-close="[[restoreFocusOnClose]]"
|
|
33
|
+
restore-focus-node="[[restoreFocusNode]]"
|
|
34
34
|
></vaadin-combo-box-overlay>
|
|
35
35
|
`;
|
|
36
36
|
}
|
|
@@ -171,14 +171,6 @@ export class ComboBoxDropdown extends mixinBehaviors(IronResizableBehavior, Poly
|
|
|
171
171
|
this._overlayOpened = false;
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
-
notifyResize() {
|
|
175
|
-
super.notifyResize();
|
|
176
|
-
|
|
177
|
-
if (this.positionTarget && this.opened) {
|
|
178
|
-
this._setOverlayWidth();
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
174
|
_fireTouchAction(sourceEvent) {
|
|
183
175
|
this.dispatchEvent(
|
|
184
176
|
new CustomEvent('vaadin-overlay-touch-action', {
|
|
@@ -262,6 +254,7 @@ export class ComboBoxDropdown extends mixinBehaviors(IronResizableBehavior, Poly
|
|
|
262
254
|
}
|
|
263
255
|
}
|
|
264
256
|
|
|
257
|
+
// eslint-disable-next-line max-params
|
|
265
258
|
__updateScroller(scroller, items, opened, loading, selectedItem, itemIdPath, focusedIndex, renderer, theme) {
|
|
266
259
|
if (scroller) {
|
|
267
260
|
scroller.setProperties({
|
|
@@ -140,7 +140,7 @@ export class ComboBoxItem extends ThemableMixin(DirMixin(PolymerElement)) {
|
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
/** @private */
|
|
143
|
-
__rendererOrItemChanged(renderer, index, item
|
|
143
|
+
__rendererOrItemChanged(renderer, index, item) {
|
|
144
144
|
if (item === undefined || index === undefined) {
|
|
145
145
|
return;
|
|
146
146
|
}
|
|
@@ -161,7 +161,9 @@ export class ComboBoxItem extends ThemableMixin(DirMixin(PolymerElement)) {
|
|
|
161
161
|
|
|
162
162
|
/** @private */
|
|
163
163
|
__updateLabel(label, renderer) {
|
|
164
|
-
if (renderer)
|
|
164
|
+
if (renderer) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
165
167
|
|
|
166
168
|
this.textContent = label;
|
|
167
169
|
}
|
|
@@ -17,6 +17,13 @@ export {
|
|
|
17
17
|
} from './vaadin-combo-box-data-provider-mixin.js';
|
|
18
18
|
export { ComboBoxDefaultItem, ComboBoxItemModel, ComboBoxRenderer } from './vaadin-combo-box-mixin.js';
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Fired when the user commits a value change.
|
|
22
|
+
*/
|
|
23
|
+
export type ComboBoxLightChangeEvent<TItem> = Event & {
|
|
24
|
+
target: ComboBoxLight<TItem>;
|
|
25
|
+
};
|
|
26
|
+
|
|
20
27
|
/**
|
|
21
28
|
* Fired when the user sets a custom value.
|
|
22
29
|
*/
|
|
@@ -48,6 +55,8 @@ export type ComboBoxLightFilterChangedEvent = CustomEvent<{ value: string }>;
|
|
|
48
55
|
export type ComboBoxLightSelectedItemChangedEvent<TItem> = CustomEvent<{ value: TItem | null | undefined }>;
|
|
49
56
|
|
|
50
57
|
export interface ComboBoxLightEventMap<TItem> extends HTMLElementEventMap {
|
|
58
|
+
change: ComboBoxLightChangeEvent<TItem>;
|
|
59
|
+
|
|
51
60
|
'custom-value-set': ComboBoxLightCustomValueSetEvent;
|
|
52
61
|
|
|
53
62
|
'opened-changed': ComboBoxLightOpenedChangedEvent;
|
|
@@ -79,6 +79,8 @@ class ComboBoxLight extends ComboBoxDataProviderMixin(ComboBoxMixin(ThemableMixi
|
|
|
79
79
|
id="dropdown"
|
|
80
80
|
opened="[[opened]]"
|
|
81
81
|
position-target="[[inputElement]]"
|
|
82
|
+
restore-focus-on-close="[[__restoreFocusOnClose]]"
|
|
83
|
+
restore-focus-node="[[inputElement]]"
|
|
82
84
|
renderer="[[renderer]]"
|
|
83
85
|
_focused-index="[[_focusedIndex]]"
|
|
84
86
|
_item-id-path="[[itemIdPath]]"
|
|
@@ -133,9 +135,8 @@ class ComboBoxLight extends ComboBoxDataProviderMixin(ComboBoxMixin(ThemableMixi
|
|
|
133
135
|
checkValidity() {
|
|
134
136
|
if (this.inputElement.validate) {
|
|
135
137
|
return this.inputElement.validate();
|
|
136
|
-
} else {
|
|
137
|
-
return super.checkValidity();
|
|
138
138
|
}
|
|
139
|
+
return super.checkValidity();
|
|
139
140
|
}
|
|
140
141
|
|
|
141
142
|
/**
|
|
@@ -190,7 +190,10 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
190
190
|
},
|
|
191
191
|
|
|
192
192
|
/** @private */
|
|
193
|
-
_closeOnBlurIsPrevented: Boolean
|
|
193
|
+
_closeOnBlurIsPrevented: Boolean,
|
|
194
|
+
|
|
195
|
+
/** @private */
|
|
196
|
+
__restoreFocusOnClose: Boolean
|
|
194
197
|
};
|
|
195
198
|
}
|
|
196
199
|
|
|
@@ -364,6 +367,8 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
364
367
|
if (!this.hasAttribute('focused') && !isTouch) {
|
|
365
368
|
this.focus();
|
|
366
369
|
}
|
|
370
|
+
|
|
371
|
+
this.__restoreFocusOnClose = true;
|
|
367
372
|
} else {
|
|
368
373
|
this._onClosed();
|
|
369
374
|
if (this._openedWithFocusRing && this.hasAttribute('focused')) {
|
|
@@ -435,23 +440,25 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
435
440
|
* @override
|
|
436
441
|
*/
|
|
437
442
|
_onKeyDown(e) {
|
|
438
|
-
if (e.
|
|
443
|
+
if (e.key === 'Tab') {
|
|
444
|
+
this.__restoreFocusOnClose = false;
|
|
445
|
+
} else if (e.key === 'ArrowDown') {
|
|
439
446
|
this._closeOnBlurIsPrevented = true;
|
|
440
447
|
this._onArrowDown();
|
|
441
448
|
this._closeOnBlurIsPrevented = false;
|
|
442
449
|
|
|
443
450
|
// prevent caret from moving
|
|
444
451
|
e.preventDefault();
|
|
445
|
-
} else if (e.
|
|
452
|
+
} else if (e.key === 'ArrowUp') {
|
|
446
453
|
this._closeOnBlurIsPrevented = true;
|
|
447
454
|
this._onArrowUp();
|
|
448
455
|
this._closeOnBlurIsPrevented = false;
|
|
449
456
|
|
|
450
457
|
// prevent caret from moving
|
|
451
458
|
e.preventDefault();
|
|
452
|
-
} else if (e.
|
|
459
|
+
} else if (e.key === 'Enter') {
|
|
453
460
|
this._onEnter(e);
|
|
454
|
-
} else if (e.
|
|
461
|
+
} else if (e.key === 'Escape') {
|
|
455
462
|
this._onEscape(e);
|
|
456
463
|
}
|
|
457
464
|
}
|
|
@@ -581,25 +588,23 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
581
588
|
// The clear button is visible and the overlay is closed, so clear the value.
|
|
582
589
|
this._clear();
|
|
583
590
|
}
|
|
584
|
-
} else {
|
|
591
|
+
} else if (this.opened) {
|
|
585
592
|
// Auto-open is enabled
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
e.stopPropagation();
|
|
593
|
+
// The overlay is open
|
|
594
|
+
e.stopPropagation();
|
|
589
595
|
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
}
|
|
598
|
-
} else if (this.clearButtonVisible && !!this.value) {
|
|
599
|
-
e.stopPropagation();
|
|
600
|
-
// The clear button is visible and the overlay is closed, so clear the value.
|
|
601
|
-
this._clear();
|
|
596
|
+
if (this._focusedIndex > -1) {
|
|
597
|
+
// An item is focused, revert the input to the filtered value
|
|
598
|
+
this._focusedIndex = -1;
|
|
599
|
+
this._revertInputValue();
|
|
600
|
+
} else {
|
|
601
|
+
// No item is focused, cancel the change and close the overlay
|
|
602
|
+
this.cancel();
|
|
602
603
|
}
|
|
604
|
+
} else if (this.clearButtonVisible && !!this.value) {
|
|
605
|
+
e.stopPropagation();
|
|
606
|
+
// The clear button is visible and the overlay is closed, so clear the value.
|
|
607
|
+
this._clear();
|
|
603
608
|
}
|
|
604
609
|
}
|
|
605
610
|
|
|
@@ -643,8 +648,6 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
643
648
|
|
|
644
649
|
/** @private */
|
|
645
650
|
_onOpened() {
|
|
646
|
-
setTimeout(() => this._resizeDropdown(), 1);
|
|
647
|
-
|
|
648
651
|
// Defer scroll position adjustment to improve performance.
|
|
649
652
|
requestAnimationFrame(() => {
|
|
650
653
|
this.$.dropdown.adjustScrollPosition();
|
|
@@ -820,11 +823,6 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
820
823
|
}
|
|
821
824
|
}
|
|
822
825
|
|
|
823
|
-
/** @private */
|
|
824
|
-
_resizeDropdown() {
|
|
825
|
-
this.$.dropdown.notifyResize();
|
|
826
|
-
}
|
|
827
|
-
|
|
828
826
|
/** @private */
|
|
829
827
|
_selectedItemChanged(selectedItem) {
|
|
830
828
|
if (selectedItem === null || selectedItem === undefined) {
|
|
@@ -221,9 +221,8 @@ export class ComboBoxScroller extends PolymerElement {
|
|
|
221
221
|
return false;
|
|
222
222
|
} else if (itemIdPath && item !== undefined && selectedItem !== undefined) {
|
|
223
223
|
return this.get(itemIdPath, item) === this.get(itemIdPath, selectedItem);
|
|
224
|
-
} else {
|
|
225
|
-
return item === selectedItem;
|
|
226
224
|
}
|
|
225
|
+
return item === selectedItem;
|
|
227
226
|
}
|
|
228
227
|
|
|
229
228
|
/** @private */
|
|
@@ -28,6 +28,13 @@ export {
|
|
|
28
28
|
} from './vaadin-combo-box-data-provider-mixin.js';
|
|
29
29
|
export { ComboBoxDefaultItem, ComboBoxItemModel, ComboBoxRenderer } from './vaadin-combo-box-mixin.js';
|
|
30
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Fired when the user commits a value change.
|
|
33
|
+
*/
|
|
34
|
+
export type ComboBoxChangeEvent<TItem> = Event & {
|
|
35
|
+
target: ComboBox<TItem>;
|
|
36
|
+
};
|
|
37
|
+
|
|
31
38
|
/**
|
|
32
39
|
* Fired when the user sets a custom value.
|
|
33
40
|
*/
|
|
@@ -59,6 +66,8 @@ export type ComboBoxFilterChangedEvent = CustomEvent<{ value: string }>;
|
|
|
59
66
|
export type ComboBoxSelectedItemChangedEvent<TItem> = CustomEvent<{ value: TItem | null | undefined }>;
|
|
60
67
|
|
|
61
68
|
export interface ComboBoxEventMap<TItem> extends HTMLElementEventMap {
|
|
69
|
+
change: ComboBoxChangeEvent<TItem>;
|
|
70
|
+
|
|
62
71
|
'custom-value-set': ComboBoxCustomValueSetEvent;
|
|
63
72
|
|
|
64
73
|
'opened-changed': ComboBoxOpenedChangedEvent;
|
package/src/vaadin-combo-box.js
CHANGED
|
@@ -201,6 +201,8 @@ class ComboBox extends ComboBoxDataProviderMixin(
|
|
|
201
201
|
opened="[[opened]]"
|
|
202
202
|
renderer="[[renderer]]"
|
|
203
203
|
position-target="[[_positionTarget]]"
|
|
204
|
+
restore-focus-on-close="[[__restoreFocusOnClose]]"
|
|
205
|
+
restore-focus-node="[[inputElement]]"
|
|
204
206
|
_focused-index="[[_focusedIndex]]"
|
|
205
207
|
_item-id-path="[[itemIdPath]]"
|
|
206
208
|
_item-label-path="[[itemLabelPath]]"
|