@vaadin/combo-box 23.2.0-alpha2 → 23.2.0-alpha3
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 -13
- package/src/lit/renderer-directives.d.ts +3 -3
- package/src/vaadin-combo-box-data-provider-mixin.d.ts +2 -2
- package/src/vaadin-combo-box-data-provider-mixin.js +28 -30
- package/src/vaadin-combo-box-light.d.ts +17 -8
- package/src/vaadin-combo-box-light.js +4 -1
- package/src/vaadin-combo-box-mixin.d.ts +5 -10
- package/src/vaadin-combo-box-mixin.js +42 -45
- package/src/vaadin-combo-box.d.ts +27 -18
- 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": "23.2.0-
|
|
3
|
+
"version": "23.2.0-alpha3",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -36,23 +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.2.0-
|
|
40
|
-
"@vaadin/field-base": "23.2.0-
|
|
41
|
-
"@vaadin/input-container": "23.2.0-
|
|
42
|
-
"@vaadin/item": "23.2.0-
|
|
43
|
-
"@vaadin/lit-renderer": "23.2.0-
|
|
44
|
-
"@vaadin/vaadin-lumo-styles": "23.2.0-
|
|
45
|
-
"@vaadin/vaadin-material-styles": "23.2.0-
|
|
46
|
-
"@vaadin/vaadin-overlay": "23.2.0-
|
|
47
|
-
"@vaadin/vaadin-themable-mixin": "23.2.0-
|
|
39
|
+
"@vaadin/component-base": "23.2.0-alpha3",
|
|
40
|
+
"@vaadin/field-base": "23.2.0-alpha3",
|
|
41
|
+
"@vaadin/input-container": "23.2.0-alpha3",
|
|
42
|
+
"@vaadin/item": "23.2.0-alpha3",
|
|
43
|
+
"@vaadin/lit-renderer": "23.2.0-alpha3",
|
|
44
|
+
"@vaadin/vaadin-lumo-styles": "23.2.0-alpha3",
|
|
45
|
+
"@vaadin/vaadin-material-styles": "23.2.0-alpha3",
|
|
46
|
+
"@vaadin/vaadin-overlay": "23.2.0-alpha3",
|
|
47
|
+
"@vaadin/vaadin-themable-mixin": "23.2.0-alpha3"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@esm-bundle/chai": "^4.3.4",
|
|
51
|
-
"@vaadin/polymer-legacy-adapter": "23.2.0-
|
|
51
|
+
"@vaadin/polymer-legacy-adapter": "23.2.0-alpha3",
|
|
52
52
|
"@vaadin/testing-helpers": "^0.3.2",
|
|
53
|
-
"@vaadin/text-field": "23.2.0-
|
|
53
|
+
"@vaadin/text-field": "23.2.0-alpha3",
|
|
54
54
|
"lit": "^2.0.0",
|
|
55
55
|
"sinon": "^13.0.2"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "06e5875be93ca50da2846dafc65a8531010c0576"
|
|
58
58
|
}
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
* Copyright (c) 2017 - 2022 Vaadin Ltd.
|
|
4
4
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
5
|
*/
|
|
6
|
-
import { TemplateResult } from 'lit';
|
|
7
|
-
import { DirectiveResult } from 'lit/directive.js';
|
|
6
|
+
import type { TemplateResult } from 'lit';
|
|
7
|
+
import type { DirectiveResult } from 'lit/directive.js';
|
|
8
8
|
import { LitRendererDirective } from '@vaadin/lit-renderer';
|
|
9
|
-
import { ComboBox, ComboBoxItemModel } from '../vaadin-combo-box.js';
|
|
9
|
+
import type { ComboBox, ComboBoxItemModel } from '../vaadin-combo-box.js';
|
|
10
10
|
|
|
11
11
|
export type ComboBoxLitRenderer<TItem> = (
|
|
12
12
|
item: TItem,
|
|
@@ -3,9 +3,9 @@
|
|
|
3
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
|
-
import { Constructor } from '@open-wc/dedupe-mixin';
|
|
6
|
+
import type { Constructor } from '@open-wc/dedupe-mixin';
|
|
7
7
|
|
|
8
|
-
export type ComboBoxDataProviderCallback<TItem> = (items: TItem[], size
|
|
8
|
+
export type ComboBoxDataProviderCallback<TItem> = (items: TItem[], size?: number) => void;
|
|
9
9
|
|
|
10
10
|
export interface ComboBoxDataProviderParams {
|
|
11
11
|
page: number;
|
|
@@ -62,13 +62,17 @@ export const ComboBoxDataProviderMixin = (superClass) =>
|
|
|
62
62
|
__placeHolder: {
|
|
63
63
|
value: new ComboBoxPlaceholder(),
|
|
64
64
|
},
|
|
65
|
+
|
|
66
|
+
/** @private */
|
|
67
|
+
__previousDataProviderFilter: {
|
|
68
|
+
type: String,
|
|
69
|
+
},
|
|
65
70
|
};
|
|
66
71
|
}
|
|
67
72
|
|
|
68
73
|
static get observers() {
|
|
69
74
|
return [
|
|
70
|
-
'_dataProviderFilterChanged(filter
|
|
71
|
-
'_dataProviderClearFilter(dataProvider, opened, value)',
|
|
75
|
+
'_dataProviderFilterChanged(filter)',
|
|
72
76
|
'_warnDataProviderValue(dataProvider, value)',
|
|
73
77
|
'_ensureFirstPage(opened)',
|
|
74
78
|
];
|
|
@@ -77,7 +81,6 @@ export const ComboBoxDataProviderMixin = (superClass) =>
|
|
|
77
81
|
/** @protected */
|
|
78
82
|
ready() {
|
|
79
83
|
super.ready();
|
|
80
|
-
this.clearCache();
|
|
81
84
|
this._scroller.addEventListener('index-requested', (e) => {
|
|
82
85
|
const index = e.detail.index;
|
|
83
86
|
const currentScrollerPos = e.detail.currentScrollerPos;
|
|
@@ -101,38 +104,25 @@ export const ComboBoxDataProviderMixin = (superClass) =>
|
|
|
101
104
|
}
|
|
102
105
|
|
|
103
106
|
/** @private */
|
|
104
|
-
_dataProviderFilterChanged() {
|
|
105
|
-
if (
|
|
107
|
+
_dataProviderFilterChanged(filter) {
|
|
108
|
+
if (this.__previousDataProviderFilter === undefined && filter === '') {
|
|
109
|
+
this.__previousDataProviderFilter = filter;
|
|
106
110
|
return;
|
|
107
111
|
}
|
|
108
112
|
|
|
109
|
-
this.
|
|
110
|
-
|
|
113
|
+
if (this.__previousDataProviderFilter !== filter) {
|
|
114
|
+
this.__previousDataProviderFilter = filter;
|
|
111
115
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
116
|
+
this._pendingRequests = {};
|
|
117
|
+
// Immediately mark as loading if this refresh leads to re-fetching pages
|
|
118
|
+
// This prevents some issues with the properties below triggering
|
|
119
|
+
// observers that also rely on the loading state
|
|
120
|
+
this.loading = this._shouldFetchData();
|
|
121
|
+
// Reset size and internal loading state
|
|
122
|
+
this.size = undefined;
|
|
120
123
|
|
|
121
|
-
|
|
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
|
|
128
|
-
this.size = undefined;
|
|
129
|
-
this._pendingRequests = {};
|
|
130
|
-
// Clear filter if requested
|
|
131
|
-
if (clearFilter) {
|
|
132
|
-
this.filter = '';
|
|
124
|
+
this.clearCache();
|
|
133
125
|
}
|
|
134
|
-
// Clear cached pages, and reload current page if we need the data
|
|
135
|
-
this.clearCache();
|
|
136
126
|
}
|
|
137
127
|
|
|
138
128
|
/** @private */
|
|
@@ -199,7 +189,10 @@ export const ComboBoxDataProviderMixin = (superClass) =>
|
|
|
199
189
|
if (!this.opened && !this.hasAttribute('focused')) {
|
|
200
190
|
this._commitValue();
|
|
201
191
|
}
|
|
202
|
-
|
|
192
|
+
|
|
193
|
+
if (size !== undefined) {
|
|
194
|
+
this.size = size;
|
|
195
|
+
}
|
|
203
196
|
|
|
204
197
|
delete this._pendingRequests[page];
|
|
205
198
|
|
|
@@ -229,13 +222,16 @@ export const ComboBoxDataProviderMixin = (superClass) =>
|
|
|
229
222
|
if (!this.dataProvider) {
|
|
230
223
|
return;
|
|
231
224
|
}
|
|
225
|
+
|
|
232
226
|
this._pendingRequests = {};
|
|
233
227
|
const filteredItems = [];
|
|
234
228
|
for (let i = 0; i < (this.size || 0); i++) {
|
|
235
229
|
filteredItems.push(this.__placeHolder);
|
|
236
230
|
}
|
|
237
231
|
this.filteredItems = filteredItems;
|
|
232
|
+
|
|
238
233
|
if (this._shouldFetchData()) {
|
|
234
|
+
this._forceNextRequest = false;
|
|
239
235
|
this._loadPage(0);
|
|
240
236
|
} else {
|
|
241
237
|
this._forceNextRequest = true;
|
|
@@ -269,6 +265,8 @@ export const ComboBoxDataProviderMixin = (superClass) =>
|
|
|
269
265
|
this._ensureItemsOrDataProvider(() => {
|
|
270
266
|
this.dataProvider = oldDataProvider;
|
|
271
267
|
});
|
|
268
|
+
|
|
269
|
+
this.clearCache();
|
|
272
270
|
}
|
|
273
271
|
|
|
274
272
|
/** @private */
|
|
@@ -3,13 +3,13 @@
|
|
|
3
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
|
-
import { DisabledMixinClass } from '@vaadin/component-base/src/disabled-mixin.js';
|
|
7
|
-
import { KeyboardMixinClass } from '@vaadin/component-base/src/keyboard-mixin.js';
|
|
8
|
-
import { InputMixinClass } from '@vaadin/field-base/src/input-mixin.js';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { ComboBoxDefaultItem } from './vaadin-combo-box-mixin.js';
|
|
6
|
+
import type { DisabledMixinClass } from '@vaadin/component-base/src/disabled-mixin.js';
|
|
7
|
+
import type { KeyboardMixinClass } from '@vaadin/component-base/src/keyboard-mixin.js';
|
|
8
|
+
import type { InputMixinClass } from '@vaadin/field-base/src/input-mixin.js';
|
|
9
|
+
import type { ValidateMixinClass } from '@vaadin/field-base/src/validate-mixin.js';
|
|
10
|
+
import type { ThemableMixinClass } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
11
|
+
import type { ComboBoxDataProviderMixinClass } from './vaadin-combo-box-data-provider-mixin.js';
|
|
12
|
+
import type { ComboBoxDefaultItem, ComboBoxMixinClass } from './vaadin-combo-box-mixin.js';
|
|
13
13
|
export {
|
|
14
14
|
ComboBoxDataProvider,
|
|
15
15
|
ComboBoxDataProviderCallback,
|
|
@@ -54,6 +54,11 @@ export type ComboBoxLightFilterChangedEvent = CustomEvent<{ value: string }>;
|
|
|
54
54
|
*/
|
|
55
55
|
export type ComboBoxLightSelectedItemChangedEvent<TItem> = CustomEvent<{ value: TItem | null | undefined }>;
|
|
56
56
|
|
|
57
|
+
/**
|
|
58
|
+
* Fired whenever the field is validated.
|
|
59
|
+
*/
|
|
60
|
+
export type ComboBoxLightValidatedEvent = CustomEvent<{ valid: boolean }>;
|
|
61
|
+
|
|
57
62
|
export interface ComboBoxLightEventMap<TItem> extends HTMLElementEventMap {
|
|
58
63
|
change: ComboBoxLightChangeEvent<TItem>;
|
|
59
64
|
|
|
@@ -68,6 +73,8 @@ export interface ComboBoxLightEventMap<TItem> extends HTMLElementEventMap {
|
|
|
68
73
|
'value-changed': ComboBoxLightValueChangedEvent;
|
|
69
74
|
|
|
70
75
|
'selected-item-changed': ComboBoxLightSelectedItemChangedEvent<TItem>;
|
|
76
|
+
|
|
77
|
+
validated: ComboBoxLightValidatedEvent;
|
|
71
78
|
}
|
|
72
79
|
|
|
73
80
|
/**
|
|
@@ -114,6 +121,7 @@ export interface ComboBoxLightEventMap<TItem> extends HTMLElementEventMap {
|
|
|
114
121
|
* @fires {CustomEvent} opened-changed - Fired when the `opened` property changes.
|
|
115
122
|
* @fires {CustomEvent} selected-item-changed - Fired when the `selectedItem` property changes.
|
|
116
123
|
* @fires {CustomEvent} value-changed - Fired when the `value` property changes.
|
|
124
|
+
* @fires {CustomEvent} validated - Fired whenever the field is validated.
|
|
117
125
|
*/
|
|
118
126
|
declare class ComboBoxLight<TItem = ComboBoxDefaultItem> extends HTMLElement {
|
|
119
127
|
/**
|
|
@@ -142,7 +150,8 @@ interface ComboBoxLight<TItem = ComboBoxDefaultItem>
|
|
|
142
150
|
KeyboardMixinClass,
|
|
143
151
|
InputMixinClass,
|
|
144
152
|
DisabledMixinClass,
|
|
145
|
-
ThemableMixinClass
|
|
153
|
+
ThemableMixinClass,
|
|
154
|
+
ValidateMixinClass {}
|
|
146
155
|
|
|
147
156
|
declare global {
|
|
148
157
|
interface HTMLElementTagNameMap {
|
|
@@ -8,6 +8,7 @@ import './vaadin-combo-box-overlay.js';
|
|
|
8
8
|
import './vaadin-combo-box-scroller.js';
|
|
9
9
|
import { dashToCamelCase } from '@polymer/polymer/lib/utils/case-map.js';
|
|
10
10
|
import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
11
|
+
import { ValidateMixin } from '@vaadin/field-base/src/validate-mixin.js';
|
|
11
12
|
import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
12
13
|
import { ComboBoxDataProviderMixin } from './vaadin-combo-box-data-provider-mixin.js';
|
|
13
14
|
import { ComboBoxMixin } from './vaadin-combo-box-mixin.js';
|
|
@@ -56,13 +57,15 @@ import { ComboBoxMixin } from './vaadin-combo-box-mixin.js';
|
|
|
56
57
|
* @fires {CustomEvent} opened-changed - Fired when the `opened` property changes.
|
|
57
58
|
* @fires {CustomEvent} selected-item-changed - Fired when the `selectedItem` property changes.
|
|
58
59
|
* @fires {CustomEvent} value-changed - Fired when the `value` property changes.
|
|
60
|
+
* @fires {CustomEvent} validated - Fired whenever the field is validated.
|
|
59
61
|
*
|
|
60
62
|
* @extends HTMLElement
|
|
61
63
|
* @mixes ComboBoxDataProviderMixin
|
|
62
64
|
* @mixes ComboBoxMixin
|
|
63
65
|
* @mixes ThemableMixin
|
|
66
|
+
* @mixes ValidateMixin
|
|
64
67
|
*/
|
|
65
|
-
class ComboBoxLight extends ComboBoxDataProviderMixin(ComboBoxMixin(ThemableMixin(PolymerElement))) {
|
|
68
|
+
class ComboBoxLight extends ComboBoxDataProviderMixin(ComboBoxMixin(ValidateMixin(ThemableMixin(PolymerElement)))) {
|
|
66
69
|
static get is() {
|
|
67
70
|
return 'vaadin-combo-box-light';
|
|
68
71
|
}
|
|
@@ -3,11 +3,11 @@
|
|
|
3
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
|
-
import { Constructor } from '@open-wc/dedupe-mixin';
|
|
7
|
-
import { DisabledMixinClass } from '@vaadin/component-base/src/disabled-mixin.js';
|
|
8
|
-
import { KeyboardMixinClass } from '@vaadin/component-base/src/keyboard-mixin.js';
|
|
9
|
-
import { InputMixinClass } from '@vaadin/field-base/src/input-mixin.js';
|
|
10
|
-
import { ComboBox } from './vaadin-combo-box.js';
|
|
6
|
+
import type { Constructor } from '@open-wc/dedupe-mixin';
|
|
7
|
+
import type { DisabledMixinClass } from '@vaadin/component-base/src/disabled-mixin.js';
|
|
8
|
+
import type { KeyboardMixinClass } from '@vaadin/component-base/src/keyboard-mixin.js';
|
|
9
|
+
import type { InputMixinClass } from '@vaadin/field-base/src/input-mixin.js';
|
|
10
|
+
import type { ComboBox } from './vaadin-combo-box.js';
|
|
11
11
|
|
|
12
12
|
export type ComboBoxDefaultItem = any;
|
|
13
13
|
|
|
@@ -138,11 +138,6 @@ export declare class ComboBoxMixinClass<TItem> {
|
|
|
138
138
|
*/
|
|
139
139
|
itemIdPath: string | null | undefined;
|
|
140
140
|
|
|
141
|
-
/**
|
|
142
|
-
* Set to true if the value is invalid.
|
|
143
|
-
*/
|
|
144
|
-
invalid: boolean;
|
|
145
|
-
|
|
146
141
|
protected readonly _propertyForValue: string;
|
|
147
142
|
|
|
148
143
|
protected _inputElementValue: string | undefined;
|
|
@@ -236,7 +236,6 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
236
236
|
|
|
237
237
|
static get observers() {
|
|
238
238
|
return [
|
|
239
|
-
'_filterChanged(filter, itemValuePath, itemLabelPath)',
|
|
240
239
|
'_selectedItemChanged(selectedItem, itemValuePath, itemLabelPath)',
|
|
241
240
|
'_openedOrItemsChanged(opened, filteredItems, loading)',
|
|
242
241
|
'_updateScroller(_scroller, filteredItems, opened, loading, selectedItem, itemIdPath, _focusedIndex, renderer, theme)',
|
|
@@ -382,6 +381,25 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
382
381
|
this.opened = false;
|
|
383
382
|
}
|
|
384
383
|
|
|
384
|
+
/**
|
|
385
|
+
* Override Polymer lifecycle callback to handle `filter` property change after
|
|
386
|
+
* the observer for `opened` property is triggered. This is needed when opening
|
|
387
|
+
* combo-box on user input to ensure the focused index is set correctly.
|
|
388
|
+
*
|
|
389
|
+
* @param {!Object} currentProps Current accessor values
|
|
390
|
+
* @param {?Object} changedProps Properties changed since the last call
|
|
391
|
+
* @param {?Object} oldProps Previous values for each changed property
|
|
392
|
+
* @protected
|
|
393
|
+
* @override
|
|
394
|
+
*/
|
|
395
|
+
_propertiesChanged(currentProps, changedProps, oldProps) {
|
|
396
|
+
super._propertiesChanged(currentProps, changedProps, oldProps);
|
|
397
|
+
|
|
398
|
+
if (changedProps.filter !== undefined) {
|
|
399
|
+
this._filterChanged(changedProps.filter);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
|
|
385
403
|
/** @private */
|
|
386
404
|
_initOverlay() {
|
|
387
405
|
const overlay = this.$.overlay;
|
|
@@ -926,9 +944,7 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
926
944
|
|
|
927
945
|
this._clearSelectionRange();
|
|
928
946
|
|
|
929
|
-
|
|
930
|
-
this.filter = '';
|
|
931
|
-
}
|
|
947
|
+
this.filter = '';
|
|
932
948
|
}
|
|
933
949
|
|
|
934
950
|
/**
|
|
@@ -946,19 +962,27 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
946
962
|
* @override
|
|
947
963
|
*/
|
|
948
964
|
_onInput(event) {
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
965
|
+
const filter = this._inputElementValue;
|
|
966
|
+
|
|
967
|
+
// When opening dropdown on user input, both `opened` and `filter` properties are set.
|
|
968
|
+
// Perform a batched property update instead of relying on sync property observers.
|
|
969
|
+
// This is necessary to avoid an extra data-provider request for loading first page.
|
|
970
|
+
const props = {};
|
|
952
971
|
|
|
953
|
-
|
|
954
|
-
if (this.filter === value) {
|
|
972
|
+
if (this.filter === filter) {
|
|
955
973
|
// Filter and input value might get out of sync, while keyboard navigating for example.
|
|
956
974
|
// Afterwards, input value might be changed to the same value as used in filtering.
|
|
957
975
|
// In situation like these, we need to make sure all the filter changes handlers are run.
|
|
958
|
-
this._filterChanged(this.filter
|
|
976
|
+
this._filterChanged(this.filter);
|
|
959
977
|
} else {
|
|
960
|
-
|
|
978
|
+
props.filter = filter;
|
|
961
979
|
}
|
|
980
|
+
|
|
981
|
+
if (!this.opened && !this._isClearButton(event) && !this.autoOpenDisabled) {
|
|
982
|
+
props.opened = true;
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
this.setProperties(props);
|
|
962
986
|
}
|
|
963
987
|
|
|
964
988
|
/**
|
|
@@ -981,11 +1005,7 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
981
1005
|
}
|
|
982
1006
|
|
|
983
1007
|
/** @private */
|
|
984
|
-
_filterChanged(filter
|
|
985
|
-
if (filter === undefined) {
|
|
986
|
-
return;
|
|
987
|
-
}
|
|
988
|
-
|
|
1008
|
+
_filterChanged(filter) {
|
|
989
1009
|
// Scroll to the top of the list whenever the filter changes.
|
|
990
1010
|
this._scrollIntoView(0);
|
|
991
1011
|
|
|
@@ -1064,14 +1084,11 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
1064
1084
|
}
|
|
1065
1085
|
|
|
1066
1086
|
if (isValidValue(value)) {
|
|
1067
|
-
let item;
|
|
1068
1087
|
if (this._getItemValue(this.selectedItem) !== value) {
|
|
1069
1088
|
this._selectItemForValue(value);
|
|
1070
|
-
} else {
|
|
1071
|
-
item = this.selectedItem;
|
|
1072
1089
|
}
|
|
1073
1090
|
|
|
1074
|
-
if (!
|
|
1091
|
+
if (!this.selectedItem && this.allowCustomValue) {
|
|
1075
1092
|
this._inputElementValue = value;
|
|
1076
1093
|
}
|
|
1077
1094
|
|
|
@@ -1079,6 +1096,9 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
1079
1096
|
} else {
|
|
1080
1097
|
this.selectedItem = null;
|
|
1081
1098
|
}
|
|
1099
|
+
|
|
1100
|
+
this.filter = '';
|
|
1101
|
+
|
|
1082
1102
|
// In the next _detectAndDispatchChange() call, the change detection should pass
|
|
1083
1103
|
this._lastCommittedValue = undefined;
|
|
1084
1104
|
}
|
|
@@ -1277,35 +1297,12 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
1277
1297
|
this._clear();
|
|
1278
1298
|
}
|
|
1279
1299
|
|
|
1280
|
-
/**
|
|
1281
|
-
* Returns true if `value` is valid, and sets the `invalid` flag appropriately.
|
|
1282
|
-
*
|
|
1283
|
-
* @return {boolean} True if the value is valid and sets the `invalid` flag appropriately
|
|
1284
|
-
*/
|
|
1285
|
-
validate() {
|
|
1286
|
-
return !(this.invalid = !this.checkValidity());
|
|
1287
|
-
}
|
|
1288
|
-
|
|
1289
|
-
/**
|
|
1290
|
-
* Returns true if the current input value satisfies all constraints (if any).
|
|
1291
|
-
* You can override this method for custom validations.
|
|
1292
|
-
*
|
|
1293
|
-
* @return {boolean}
|
|
1294
|
-
*/
|
|
1295
|
-
checkValidity() {
|
|
1296
|
-
if (super.checkValidity) {
|
|
1297
|
-
return super.checkValidity();
|
|
1298
|
-
}
|
|
1299
|
-
|
|
1300
|
-
return !this.required || !!this.value;
|
|
1301
|
-
}
|
|
1302
|
-
|
|
1303
1300
|
/**
|
|
1304
1301
|
* Fired when the value changes.
|
|
1305
1302
|
*
|
|
1306
1303
|
* @event value-changed
|
|
1307
1304
|
* @param {Object} detail
|
|
1308
|
-
*
|
|
1305
|
+
* @param {String} detail.value the combobox value
|
|
1309
1306
|
*/
|
|
1310
1307
|
|
|
1311
1308
|
/**
|
|
@@ -1313,7 +1310,7 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
1313
1310
|
*
|
|
1314
1311
|
* @event selected-item-changed
|
|
1315
1312
|
* @param {Object} detail
|
|
1316
|
-
*
|
|
1313
|
+
* @param {Object|String} detail.value the selected item. Type is the same as the type of `items`.
|
|
1317
1314
|
*/
|
|
1318
1315
|
|
|
1319
1316
|
/**
|
|
@@ -3,24 +3,24 @@
|
|
|
3
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
|
-
import { ControllerMixinClass } from '@vaadin/component-base/src/controller-mixin.js';
|
|
7
|
-
import { DisabledMixinClass } from '@vaadin/component-base/src/disabled-mixin.js';
|
|
8
|
-
import { ElementMixinClass } from '@vaadin/component-base/src/element-mixin.js';
|
|
9
|
-
import { FocusMixinClass } from '@vaadin/component-base/src/focus-mixin.js';
|
|
10
|
-
import { KeyboardMixinClass } from '@vaadin/component-base/src/keyboard-mixin.js';
|
|
11
|
-
import { DelegateFocusMixinClass } from '@vaadin/field-base/src/delegate-focus-mixin.js';
|
|
12
|
-
import { DelegateStateMixinClass } from '@vaadin/field-base/src/delegate-state-mixin.js';
|
|
13
|
-
import { FieldMixinClass } from '@vaadin/field-base/src/field-mixin.js';
|
|
14
|
-
import { InputConstraintsMixinClass } from '@vaadin/field-base/src/input-constraints-mixin.js';
|
|
15
|
-
import { InputControlMixinClass } from '@vaadin/field-base/src/input-control-mixin.js';
|
|
16
|
-
import { InputMixinClass } from '@vaadin/field-base/src/input-mixin.js';
|
|
17
|
-
import { LabelMixinClass } from '@vaadin/field-base/src/label-mixin.js';
|
|
18
|
-
import { PatternMixinClass } from '@vaadin/field-base/src/pattern-mixin.js';
|
|
19
|
-
import { ValidateMixinClass } from '@vaadin/field-base/src/validate-mixin.js';
|
|
20
|
-
import { ThemableMixinClass } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
21
|
-
import { ComboBoxDataProviderMixinClass } from './vaadin-combo-box-data-provider-mixin.js';
|
|
22
|
-
import { ComboBoxMixinClass } from './vaadin-combo-box-mixin.js';
|
|
23
|
-
import { ComboBoxDefaultItem } from './vaadin-combo-box-mixin.js';
|
|
6
|
+
import type { ControllerMixinClass } from '@vaadin/component-base/src/controller-mixin.js';
|
|
7
|
+
import type { DisabledMixinClass } from '@vaadin/component-base/src/disabled-mixin.js';
|
|
8
|
+
import type { ElementMixinClass } from '@vaadin/component-base/src/element-mixin.js';
|
|
9
|
+
import type { FocusMixinClass } from '@vaadin/component-base/src/focus-mixin.js';
|
|
10
|
+
import type { KeyboardMixinClass } from '@vaadin/component-base/src/keyboard-mixin.js';
|
|
11
|
+
import type { DelegateFocusMixinClass } from '@vaadin/field-base/src/delegate-focus-mixin.js';
|
|
12
|
+
import type { DelegateStateMixinClass } from '@vaadin/field-base/src/delegate-state-mixin.js';
|
|
13
|
+
import type { FieldMixinClass } from '@vaadin/field-base/src/field-mixin.js';
|
|
14
|
+
import type { InputConstraintsMixinClass } from '@vaadin/field-base/src/input-constraints-mixin.js';
|
|
15
|
+
import type { InputControlMixinClass } from '@vaadin/field-base/src/input-control-mixin.js';
|
|
16
|
+
import type { InputMixinClass } from '@vaadin/field-base/src/input-mixin.js';
|
|
17
|
+
import type { LabelMixinClass } from '@vaadin/field-base/src/label-mixin.js';
|
|
18
|
+
import type { PatternMixinClass } from '@vaadin/field-base/src/pattern-mixin.js';
|
|
19
|
+
import type { ValidateMixinClass } from '@vaadin/field-base/src/validate-mixin.js';
|
|
20
|
+
import type { ThemableMixinClass } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
21
|
+
import type { ComboBoxDataProviderMixinClass } from './vaadin-combo-box-data-provider-mixin.js';
|
|
22
|
+
import type { ComboBoxMixinClass } from './vaadin-combo-box-mixin.js';
|
|
23
|
+
import type { ComboBoxDefaultItem } from './vaadin-combo-box-mixin.js';
|
|
24
24
|
export {
|
|
25
25
|
ComboBoxDataProvider,
|
|
26
26
|
ComboBoxDataProviderCallback,
|
|
@@ -65,6 +65,11 @@ export type ComboBoxFilterChangedEvent = CustomEvent<{ value: string }>;
|
|
|
65
65
|
*/
|
|
66
66
|
export type ComboBoxSelectedItemChangedEvent<TItem> = CustomEvent<{ value: TItem | null | undefined }>;
|
|
67
67
|
|
|
68
|
+
/**
|
|
69
|
+
* Fired whenever the field is validated.
|
|
70
|
+
*/
|
|
71
|
+
export type ComboBoxValidatedEvent = CustomEvent<{ valid: boolean }>;
|
|
72
|
+
|
|
68
73
|
export interface ComboBoxEventMap<TItem> extends HTMLElementEventMap {
|
|
69
74
|
change: ComboBoxChangeEvent<TItem>;
|
|
70
75
|
|
|
@@ -79,6 +84,8 @@ export interface ComboBoxEventMap<TItem> extends HTMLElementEventMap {
|
|
|
79
84
|
'value-changed': ComboBoxValueChangedEvent;
|
|
80
85
|
|
|
81
86
|
'selected-item-changed': ComboBoxSelectedItemChangedEvent<TItem>;
|
|
87
|
+
|
|
88
|
+
validated: ComboBoxValidatedEvent;
|
|
82
89
|
}
|
|
83
90
|
|
|
84
91
|
/**
|
|
@@ -165,6 +172,7 @@ export interface ComboBoxEventMap<TItem> extends HTMLElementEventMap {
|
|
|
165
172
|
* Custom property | Description | Default
|
|
166
173
|
* ----------------------------------------|----------------------------|---------
|
|
167
174
|
* `--vaadin-field-default-width` | Default width of the field | `12em`
|
|
175
|
+
* `--vaadin-combo-box-overlay-width` | Width of the overlay | `auto`
|
|
168
176
|
* `--vaadin-combo-box-overlay-max-height` | Max height of the overlay | `65vh`
|
|
169
177
|
*
|
|
170
178
|
* `<vaadin-combo-box>` provides the same set of shadow DOM parts and state attributes as `<vaadin-text-field>`.
|
|
@@ -207,6 +215,7 @@ export interface ComboBoxEventMap<TItem> extends HTMLElementEventMap {
|
|
|
207
215
|
* @fires {CustomEvent} opened-changed - Fired when the `opened` property changes.
|
|
208
216
|
* @fires {CustomEvent} selected-item-changed - Fired when the `selectedItem` property changes.
|
|
209
217
|
* @fires {CustomEvent} value-changed - Fired when the `value` property changes.
|
|
218
|
+
* @fires {CustomEvent} validated - Fired whenever the field is validated.
|
|
210
219
|
*/
|
|
211
220
|
declare class ComboBox<TItem = ComboBoxDefaultItem> extends HTMLElement {
|
|
212
221
|
addEventListener<K extends keyof ComboBoxEventMap<TItem>>(
|
package/src/vaadin-combo-box.js
CHANGED
|
@@ -104,6 +104,7 @@ registerStyles('vaadin-combo-box', inputFieldShared, { moduleId: 'vaadin-combo-b
|
|
|
104
104
|
* Custom property | Description | Default
|
|
105
105
|
* ----------------------------------------|----------------------------|---------
|
|
106
106
|
* `--vaadin-field-default-width` | Default width of the field | `12em`
|
|
107
|
+
* `--vaadin-combo-box-overlay-width` | Width of the overlay | `auto`
|
|
107
108
|
* `--vaadin-combo-box-overlay-max-height` | Max height of the overlay | `65vh`
|
|
108
109
|
*
|
|
109
110
|
* `<vaadin-combo-box>` provides the same set of shadow DOM parts and state attributes as `<vaadin-text-field>`.
|
|
@@ -146,6 +147,7 @@ registerStyles('vaadin-combo-box', inputFieldShared, { moduleId: 'vaadin-combo-b
|
|
|
146
147
|
* @fires {CustomEvent} opened-changed - Fired when the `opened` property changes.
|
|
147
148
|
* @fires {CustomEvent} selected-item-changed - Fired when the `selectedItem` property changes.
|
|
148
149
|
* @fires {CustomEvent} value-changed - Fired when the `value` property changes.
|
|
150
|
+
* @fires {CustomEvent} validated - Fired whenever the field is validated.
|
|
149
151
|
*
|
|
150
152
|
* @extends HTMLElement
|
|
151
153
|
* @mixes ElementMixin
|