@vaadin/combo-box 23.1.0-beta4 → 23.1.0-rc3
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 +24 -12
- package/src/vaadin-combo-box-dropdown.js +0 -29
- package/src/vaadin-combo-box-light.js +1 -1
- package/src/vaadin-combo-box-mixin.d.ts +10 -10
- package/src/vaadin-combo-box-mixin.js +35 -13
- package/src/vaadin-combo-box-overlay.js +23 -0
- package/src/vaadin-combo-box.js +2 -2
- package/theme/material/vaadin-combo-box-dropdown-styles.js +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/combo-box",
|
|
3
|
-
"version": "23.1.0-
|
|
3
|
+
"version": "23.1.0-rc3",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -36,24 +36,23 @@
|
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
38
38
|
"@polymer/polymer": "^3.0.0",
|
|
39
|
-
"@vaadin/component-base": "23.1.0-
|
|
40
|
-
"@vaadin/field-base": "23.1.0-
|
|
41
|
-
"@vaadin/input-container": "23.1.0-
|
|
42
|
-
"@vaadin/item": "23.1.0-
|
|
43
|
-
"@vaadin/lit-renderer": "23.1.0-
|
|
44
|
-
"@vaadin/vaadin-lumo-styles": "23.1.0-
|
|
45
|
-
"@vaadin/vaadin-material-styles": "23.1.0-
|
|
46
|
-
"@vaadin/vaadin-overlay": "23.1.0-
|
|
47
|
-
"@vaadin/vaadin-themable-mixin": "23.1.0-
|
|
39
|
+
"@vaadin/component-base": "23.1.0-rc3",
|
|
40
|
+
"@vaadin/field-base": "23.1.0-rc3",
|
|
41
|
+
"@vaadin/input-container": "23.1.0-rc3",
|
|
42
|
+
"@vaadin/item": "23.1.0-rc3",
|
|
43
|
+
"@vaadin/lit-renderer": "23.1.0-rc3",
|
|
44
|
+
"@vaadin/vaadin-lumo-styles": "23.1.0-rc3",
|
|
45
|
+
"@vaadin/vaadin-material-styles": "23.1.0-rc3",
|
|
46
|
+
"@vaadin/vaadin-overlay": "23.1.0-rc3",
|
|
47
|
+
"@vaadin/vaadin-themable-mixin": "23.1.0-rc3"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@esm-bundle/chai": "^4.3.4",
|
|
51
|
-
"@vaadin/
|
|
52
|
-
"@vaadin/polymer-legacy-adapter": "23.1.0-beta4",
|
|
51
|
+
"@vaadin/polymer-legacy-adapter": "23.1.0-rc3",
|
|
53
52
|
"@vaadin/testing-helpers": "^0.3.2",
|
|
54
|
-
"@vaadin/text-field": "23.1.0-
|
|
53
|
+
"@vaadin/text-field": "23.1.0-rc3",
|
|
55
54
|
"lit": "^2.0.0",
|
|
56
55
|
"sinon": "^13.0.2"
|
|
57
56
|
},
|
|
58
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "49c312fbe0228adb559296d45655bbfd4eac6235"
|
|
59
58
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { Constructor } from '@open-wc/dedupe-mixin';
|
|
7
7
|
|
|
8
|
-
export type ComboBoxDataProviderCallback<TItem> = (items:
|
|
8
|
+
export type ComboBoxDataProviderCallback<TItem> = (items: TItem[], size: number) => void;
|
|
9
9
|
|
|
10
10
|
export interface ComboBoxDataProviderParams {
|
|
11
11
|
page: number;
|
|
@@ -74,18 +74,6 @@ export const ComboBoxDataProviderMixin = (superClass) =>
|
|
|
74
74
|
];
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
/** @private */
|
|
78
|
-
_dataProviderClearFilter(dataProvider, opened, value) {
|
|
79
|
-
// Can't depend on filter in this observer as we don't want
|
|
80
|
-
// to clear the filter whenever it's set
|
|
81
|
-
if (dataProvider && !this.loading && this.filter && !(opened && this.autoOpenDisabled && value === this.filter)) {
|
|
82
|
-
this.size = undefined;
|
|
83
|
-
this._pendingRequests = {};
|
|
84
|
-
this.filter = '';
|
|
85
|
-
this.clearCache();
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
77
|
/** @protected */
|
|
90
78
|
ready() {
|
|
91
79
|
super.ready();
|
|
@@ -118,8 +106,32 @@ export const ComboBoxDataProviderMixin = (superClass) =>
|
|
|
118
106
|
return;
|
|
119
107
|
}
|
|
120
108
|
|
|
109
|
+
this._refreshData();
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** @private */
|
|
113
|
+
_dataProviderClearFilter(dataProvider, opened, value) {
|
|
114
|
+
// Can't depend on filter in this observer as we don't want
|
|
115
|
+
// to clear the filter whenever it's set
|
|
116
|
+
if (dataProvider && !this.loading && this.filter && !(opened && this.autoOpenDisabled && value === this.filter)) {
|
|
117
|
+
this._refreshData(true);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** @private */
|
|
122
|
+
_refreshData(clearFilter) {
|
|
123
|
+
// Immediately mark as loading if this refresh leads to re-fetching pages
|
|
124
|
+
// This prevents some issues with the properties below triggering
|
|
125
|
+
// observers that also rely on the loading state
|
|
126
|
+
this.loading = this._shouldFetchData();
|
|
127
|
+
// Reset size and internal loading state
|
|
121
128
|
this.size = undefined;
|
|
122
129
|
this._pendingRequests = {};
|
|
130
|
+
// Clear filter if requested
|
|
131
|
+
if (clearFilter) {
|
|
132
|
+
this.filter = '';
|
|
133
|
+
}
|
|
134
|
+
// Clear cached pages, and reload current page if we need the data
|
|
123
135
|
this.clearCache();
|
|
124
136
|
}
|
|
125
137
|
|
|
@@ -48,7 +48,6 @@ export class ComboBoxDropdown extends PolymerElement {
|
|
|
48
48
|
*/
|
|
49
49
|
positionTarget: {
|
|
50
50
|
type: Object,
|
|
51
|
-
observer: '_positionTargetChanged',
|
|
52
51
|
},
|
|
53
52
|
|
|
54
53
|
/**
|
|
@@ -185,8 +184,6 @@ export class ComboBoxDropdown extends PolymerElement {
|
|
|
185
184
|
|
|
186
185
|
_openedChanged(opened, wasOpened) {
|
|
187
186
|
if (opened) {
|
|
188
|
-
this._setOverlayWidth();
|
|
189
|
-
|
|
190
187
|
this._scroller.style.maxHeight =
|
|
191
188
|
getComputedStyle(this).getPropertyValue(`--${this.__hostTagName}-overlay-max-height`) || '65vh';
|
|
192
189
|
|
|
@@ -274,32 +271,6 @@ export class ComboBoxDropdown extends PolymerElement {
|
|
|
274
271
|
return !this.loading && !(this._items && this._items.length);
|
|
275
272
|
}
|
|
276
273
|
|
|
277
|
-
_positionTargetChanged(target) {
|
|
278
|
-
// We must update the overlay width when the positionTarget is set (or changes)
|
|
279
|
-
if (target) {
|
|
280
|
-
this._setOverlayWidth();
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
_setOverlayWidth() {
|
|
285
|
-
if (!this.positionTarget) {
|
|
286
|
-
return;
|
|
287
|
-
}
|
|
288
|
-
const inputWidth = `${this.positionTarget.clientWidth}px`;
|
|
289
|
-
const propPrefix = `${this.__hostTagName}-overlay`;
|
|
290
|
-
const customWidth = getComputedStyle(this).getPropertyValue(`--${propPrefix}-width`);
|
|
291
|
-
|
|
292
|
-
this.$.overlay.style.setProperty(`--_${propPrefix}-default-width`, inputWidth);
|
|
293
|
-
|
|
294
|
-
if (customWidth === '') {
|
|
295
|
-
this.$.overlay.style.removeProperty(`--${propPrefix}-width`);
|
|
296
|
-
} else {
|
|
297
|
-
this.$.overlay.style.setProperty(`--${propPrefix}-width`, customWidth);
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
this.$.overlay._updatePosition();
|
|
301
|
-
}
|
|
302
|
-
|
|
303
274
|
/**
|
|
304
275
|
* Fired after the `vaadin-combo-box-dropdown` opens.
|
|
305
276
|
*
|
|
@@ -107,7 +107,7 @@ class ComboBoxLight extends ComboBoxDataProviderMixin(ComboBoxMixin(ThemableMixi
|
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
/**
|
|
110
|
-
* Used by `
|
|
110
|
+
* Used by `InputControlMixin` as a reference to the clear button element.
|
|
111
111
|
* @protected
|
|
112
112
|
* @return {!HTMLElement}
|
|
113
113
|
*/
|
|
@@ -31,14 +31,6 @@ export declare function ComboBoxMixin<TItem, T extends Constructor<HTMLElement>>
|
|
|
31
31
|
Constructor<KeyboardMixinClass>;
|
|
32
32
|
|
|
33
33
|
export declare class ComboBoxMixinClass<TItem> {
|
|
34
|
-
protected readonly _propertyForValue: string;
|
|
35
|
-
|
|
36
|
-
protected _inputElementValue: string | undefined;
|
|
37
|
-
|
|
38
|
-
protected _revertInputValue(): void;
|
|
39
|
-
|
|
40
|
-
protected _getItemElements(): HTMLElement[];
|
|
41
|
-
|
|
42
34
|
/**
|
|
43
35
|
* True if the dropdown is open, false otherwise.
|
|
44
36
|
*/
|
|
@@ -72,7 +64,7 @@ export declare class ComboBoxMixinClass<TItem> {
|
|
|
72
64
|
* A full set of items to filter the visible options from.
|
|
73
65
|
* The items can be of either `String` or `Object` type.
|
|
74
66
|
*/
|
|
75
|
-
items:
|
|
67
|
+
items: TItem[] | undefined;
|
|
76
68
|
|
|
77
69
|
/**
|
|
78
70
|
* If `true`, the user can input a value that is not present in the items list.
|
|
@@ -88,7 +80,7 @@ export declare class ComboBoxMixinClass<TItem> {
|
|
|
88
80
|
* can be assigned directly to omit the internal filtering functionality.
|
|
89
81
|
* The items can be of either `String` or `Object` type.
|
|
90
82
|
*/
|
|
91
|
-
filteredItems:
|
|
83
|
+
filteredItems: TItem[] | undefined;
|
|
92
84
|
|
|
93
85
|
/**
|
|
94
86
|
* The `String` value for the selected item of the combo box.
|
|
@@ -151,6 +143,10 @@ export declare class ComboBoxMixinClass<TItem> {
|
|
|
151
143
|
*/
|
|
152
144
|
invalid: boolean;
|
|
153
145
|
|
|
146
|
+
protected readonly _propertyForValue: string;
|
|
147
|
+
|
|
148
|
+
protected _inputElementValue: string | undefined;
|
|
149
|
+
|
|
154
150
|
/**
|
|
155
151
|
* Requests an update for the content of items.
|
|
156
152
|
* While performing the update, it invokes the renderer (passed in the `renderer` property) once an item.
|
|
@@ -179,4 +175,8 @@ export declare class ComboBoxMixinClass<TItem> {
|
|
|
179
175
|
* You can override this method for custom validations.
|
|
180
176
|
*/
|
|
181
177
|
checkValidity(): boolean;
|
|
178
|
+
|
|
179
|
+
protected _revertInputValue(): void;
|
|
180
|
+
|
|
181
|
+
protected _getItemElements(): HTMLElement[];
|
|
182
182
|
}
|
|
@@ -423,12 +423,29 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
423
423
|
}
|
|
424
424
|
}
|
|
425
425
|
|
|
426
|
+
/**
|
|
427
|
+
* @param {Event} event
|
|
428
|
+
* @private
|
|
429
|
+
*/
|
|
430
|
+
_onToggleButtonClick(event) {
|
|
431
|
+
// Prevent parent components such as `vaadin-grid`
|
|
432
|
+
// from handling the click event after it bubbles.
|
|
433
|
+
event.preventDefault();
|
|
434
|
+
|
|
435
|
+
if (this.opened) {
|
|
436
|
+
this.close();
|
|
437
|
+
} else {
|
|
438
|
+
this.open();
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
|
|
426
442
|
/**
|
|
427
443
|
* @param {Event} event
|
|
428
444
|
* @protected
|
|
429
445
|
*/
|
|
430
|
-
_onHostClick(
|
|
446
|
+
_onHostClick(event) {
|
|
431
447
|
if (!this.autoOpenDisabled) {
|
|
448
|
+
event.preventDefault();
|
|
432
449
|
this.open();
|
|
433
450
|
}
|
|
434
451
|
}
|
|
@@ -442,11 +459,7 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
442
459
|
if (this._isClearButton(e)) {
|
|
443
460
|
this._handleClearButtonClick(e);
|
|
444
461
|
} else if (path.indexOf(this._toggleElement) > -1) {
|
|
445
|
-
|
|
446
|
-
this.close();
|
|
447
|
-
} else {
|
|
448
|
-
this.open();
|
|
449
|
-
}
|
|
462
|
+
this._onToggleButtonClick(e);
|
|
450
463
|
} else {
|
|
451
464
|
this._onHostClick(e);
|
|
452
465
|
}
|
|
@@ -456,12 +469,14 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
456
469
|
|
|
457
470
|
/**
|
|
458
471
|
* Override an event listener from `KeyboardMixin`.
|
|
459
|
-
*
|
|
460
|
-
*
|
|
472
|
+
*
|
|
473
|
+
* @param {KeyboardEvent} e
|
|
461
474
|
* @protected
|
|
462
475
|
* @override
|
|
463
476
|
*/
|
|
464
477
|
_onKeyDown(e) {
|
|
478
|
+
super._onKeyDown(e);
|
|
479
|
+
|
|
465
480
|
if (e.key === 'Tab') {
|
|
466
481
|
this.__restoreFocusOnClose = false;
|
|
467
482
|
} else if (e.key === 'ArrowDown') {
|
|
@@ -478,10 +493,6 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
478
493
|
|
|
479
494
|
// Prevent caret from moving
|
|
480
495
|
e.preventDefault();
|
|
481
|
-
} else if (e.key === 'Enter') {
|
|
482
|
-
this._onEnter(e);
|
|
483
|
-
} else if (e.key === 'Escape') {
|
|
484
|
-
this._onEscape(e);
|
|
485
496
|
}
|
|
486
497
|
}
|
|
487
498
|
|
|
@@ -574,7 +585,13 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
574
585
|
}
|
|
575
586
|
}
|
|
576
587
|
|
|
577
|
-
/**
|
|
588
|
+
/**
|
|
589
|
+
* Override an event listener from `KeyboardMixin`.
|
|
590
|
+
*
|
|
591
|
+
* @param {KeyboardEvent} e
|
|
592
|
+
* @protected
|
|
593
|
+
* @override
|
|
594
|
+
*/
|
|
578
595
|
_onEnter(e) {
|
|
579
596
|
// Do not commit value when custom values are disallowed and input value is not a valid option
|
|
580
597
|
// also stop propagation of the event, otherwise the user could submit a form while the input
|
|
@@ -600,8 +617,13 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
600
617
|
}
|
|
601
618
|
|
|
602
619
|
/**
|
|
620
|
+
* Override an event listener from `KeyboardMixin`.
|
|
621
|
+
* Do not call `super` in order to override clear
|
|
622
|
+
* button logic defined in `InputControlMixin`.
|
|
623
|
+
*
|
|
603
624
|
* @param {!KeyboardEvent} e
|
|
604
625
|
* @protected
|
|
626
|
+
* @override
|
|
605
627
|
*/
|
|
606
628
|
_onEscape(e) {
|
|
607
629
|
if (this.autoOpenDisabled) {
|
|
@@ -45,11 +45,17 @@ export class ComboBoxOverlay extends PositionMixin(OverlayElement) {
|
|
|
45
45
|
return memoizedTemplate;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
static get observers() {
|
|
49
|
+
return ['_setOverlayWidth(positionTarget, opened)'];
|
|
50
|
+
}
|
|
51
|
+
|
|
48
52
|
connectedCallback() {
|
|
49
53
|
super.connectedCallback();
|
|
50
54
|
|
|
51
55
|
const dropdown = this.__dataHost;
|
|
52
56
|
const comboBox = dropdown && dropdown.getRootNode().host;
|
|
57
|
+
this._comboBox = comboBox;
|
|
58
|
+
|
|
53
59
|
const hostDir = comboBox && comboBox.getAttribute('dir');
|
|
54
60
|
if (hostDir) {
|
|
55
61
|
this.setAttribute('dir', hostDir);
|
|
@@ -70,6 +76,23 @@ export class ComboBoxOverlay extends PositionMixin(OverlayElement) {
|
|
|
70
76
|
this.close();
|
|
71
77
|
}
|
|
72
78
|
}
|
|
79
|
+
|
|
80
|
+
_setOverlayWidth(positionTarget, opened) {
|
|
81
|
+
if (positionTarget && opened) {
|
|
82
|
+
const propPrefix = this.localName;
|
|
83
|
+
this.style.setProperty(`--_${propPrefix}-default-width`, `${positionTarget.clientWidth}px`);
|
|
84
|
+
|
|
85
|
+
const customWidth = getComputedStyle(this._comboBox).getPropertyValue(`--${propPrefix}-width`);
|
|
86
|
+
|
|
87
|
+
if (customWidth === '') {
|
|
88
|
+
this.style.removeProperty(`--${propPrefix}-width`);
|
|
89
|
+
} else {
|
|
90
|
+
this.style.setProperty(`--${propPrefix}-width`, customWidth);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
this._updatePosition();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
73
96
|
}
|
|
74
97
|
|
|
75
98
|
customElements.define(ComboBoxOverlay.is, ComboBoxOverlay);
|
package/src/vaadin-combo-box.js
CHANGED
|
@@ -224,7 +224,7 @@ class ComboBox extends ComboBoxDataProviderMixin(
|
|
|
224
224
|
}
|
|
225
225
|
|
|
226
226
|
/**
|
|
227
|
-
* Used by `
|
|
227
|
+
* Used by `InputControlMixin` as a reference to the clear button element.
|
|
228
228
|
* @protected
|
|
229
229
|
* @return {!HTMLElement}
|
|
230
230
|
*/
|
|
@@ -282,7 +282,7 @@ class ComboBox extends ComboBoxDataProviderMixin(
|
|
|
282
282
|
}
|
|
283
283
|
|
|
284
284
|
/**
|
|
285
|
-
* Override method inherited from `
|
|
285
|
+
* Override method inherited from `InputControlMixin` to handle clear
|
|
286
286
|
* button click and stop event from propagating to the host element.
|
|
287
287
|
* @param {Event} event
|
|
288
288
|
* @protected
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import '@vaadin/vaadin-material-styles/color.js';
|
|
2
|
+
import '@vaadin/vaadin-overlay/theme/material/vaadin-overlay.js';
|
|
2
3
|
import { menuOverlay } from '@vaadin/vaadin-material-styles/mixins/menu-overlay.js';
|
|
3
4
|
import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
4
5
|
|