@vaadin/combo-box 23.1.0-alpha3 → 23.1.0-beta2
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/lit.d.ts +1 -0
- package/lit.js +1 -0
- package/package.json +16 -13
- package/src/lit/renderer-directives.d.ts +63 -0
- package/src/lit/renderer-directives.js +60 -0
- package/src/vaadin-combo-box-data-provider-mixin.d.ts +2 -2
- package/src/vaadin-combo-box-data-provider-mixin.js +10 -10
- package/src/vaadin-combo-box-dropdown.js +16 -16
- package/src/vaadin-combo-box-item.js +4 -4
- package/src/vaadin-combo-box-light.d.ts +3 -3
- package/src/vaadin-combo-box-light.js +3 -3
- package/src/vaadin-combo-box-mixin.d.ts +2 -2
- package/src/vaadin-combo-box-mixin.js +26 -25
- package/src/vaadin-combo-box-overlay.js +1 -1
- package/src/vaadin-combo-box-scroller.js +16 -16
- package/src/vaadin-combo-box.d.ts +3 -3
- package/src/vaadin-combo-box.js +4 -4
- package/theme/lumo/vaadin-combo-box-dropdown-styles.js +1 -1
- package/theme/lumo/vaadin-combo-box-item-styles.js +1 -1
- package/theme/material/vaadin-combo-box-dropdown-styles.js +1 -1
- package/theme/material/vaadin-combo-box-item-styles.js +1 -1
package/lit.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './src/lit/renderer-directives.js';
|
package/lit.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './src/lit/renderer-directives.js';
|
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-beta2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -21,6 +21,8 @@
|
|
|
21
21
|
"files": [
|
|
22
22
|
"src",
|
|
23
23
|
"theme",
|
|
24
|
+
"lit.js",
|
|
25
|
+
"lit.d.ts",
|
|
24
26
|
"vaadin-*.d.ts",
|
|
25
27
|
"vaadin-*.js"
|
|
26
28
|
],
|
|
@@ -34,23 +36,24 @@
|
|
|
34
36
|
"dependencies": {
|
|
35
37
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
36
38
|
"@polymer/polymer": "^3.0.0",
|
|
37
|
-
"@vaadin/component-base": "23.1.0-
|
|
38
|
-
"@vaadin/field-base": "23.1.0-
|
|
39
|
-
"@vaadin/input-container": "23.1.0-
|
|
40
|
-
"@vaadin/item": "23.1.0-
|
|
41
|
-
"@vaadin/
|
|
42
|
-
"@vaadin/vaadin-
|
|
43
|
-
"@vaadin/vaadin-
|
|
44
|
-
"@vaadin/vaadin-
|
|
39
|
+
"@vaadin/component-base": "23.1.0-beta2",
|
|
40
|
+
"@vaadin/field-base": "23.1.0-beta2",
|
|
41
|
+
"@vaadin/input-container": "23.1.0-beta2",
|
|
42
|
+
"@vaadin/item": "23.1.0-beta2",
|
|
43
|
+
"@vaadin/lit-renderer": "23.1.0-beta2",
|
|
44
|
+
"@vaadin/vaadin-lumo-styles": "23.1.0-beta2",
|
|
45
|
+
"@vaadin/vaadin-material-styles": "23.1.0-beta2",
|
|
46
|
+
"@vaadin/vaadin-overlay": "23.1.0-beta2",
|
|
47
|
+
"@vaadin/vaadin-themable-mixin": "23.1.0-beta2"
|
|
45
48
|
},
|
|
46
49
|
"devDependencies": {
|
|
47
50
|
"@esm-bundle/chai": "^4.3.4",
|
|
48
|
-
"@vaadin/dialog": "23.1.0-
|
|
49
|
-
"@vaadin/polymer-legacy-adapter": "23.1.0-
|
|
51
|
+
"@vaadin/dialog": "23.1.0-beta2",
|
|
52
|
+
"@vaadin/polymer-legacy-adapter": "23.1.0-beta2",
|
|
50
53
|
"@vaadin/testing-helpers": "^0.3.2",
|
|
51
|
-
"@vaadin/text-field": "23.1.0-
|
|
54
|
+
"@vaadin/text-field": "23.1.0-beta2",
|
|
52
55
|
"lit": "^2.0.0",
|
|
53
56
|
"sinon": "^13.0.2"
|
|
54
57
|
},
|
|
55
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "f11f9245a0b5e6bf912725a501c27c24b74e7c8d"
|
|
56
59
|
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2017 - 2022 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import { TemplateResult } from 'lit';
|
|
7
|
+
import { DirectiveResult } from 'lit/directive.js';
|
|
8
|
+
import { LitRendererDirective } from '@vaadin/lit-renderer';
|
|
9
|
+
import { ComboBox, ComboBoxItemModel } from '../vaadin-combo-box.js';
|
|
10
|
+
|
|
11
|
+
export type ComboBoxLitRenderer<TItem> = (
|
|
12
|
+
item: TItem,
|
|
13
|
+
model: ComboBoxItemModel<TItem>,
|
|
14
|
+
comboBox: ComboBox<TItem>,
|
|
15
|
+
) => TemplateResult;
|
|
16
|
+
|
|
17
|
+
export class ComboBoxRendererDirective<TItem> extends LitRendererDirective<ComboBox, ComboBoxLitRenderer<TItem>> {
|
|
18
|
+
/**
|
|
19
|
+
* Adds the renderer callback to the combo-box.
|
|
20
|
+
*/
|
|
21
|
+
addRenderer(): void;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Runs the renderer callback on the combo-box.
|
|
25
|
+
*/
|
|
26
|
+
runRenderer(): void;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Removes the renderer callback from the combo-box.
|
|
30
|
+
*/
|
|
31
|
+
removeRenderer(): void;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* A Lit directive for rendering the content of the `<vaadin-combo-box-item>` elements.
|
|
36
|
+
*
|
|
37
|
+
* The directive accepts a renderer callback returning a Lit template and assigns it to the combo-box
|
|
38
|
+
* via the `renderer` property. The renderer is called for each combo-box item when assigned
|
|
39
|
+
* and whenever a single dependency or an array of dependencies changes.
|
|
40
|
+
* It is not guaranteed that the renderer will be called immediately (synchronously) in both cases.
|
|
41
|
+
*
|
|
42
|
+
* Dependencies can be a single value or an array of values.
|
|
43
|
+
* Values are checked against previous values with strict equality (`===`),
|
|
44
|
+
* so the check won't detect nested property changes inside objects or arrays.
|
|
45
|
+
* When dependencies are provided as an array, each item is checked against the previous value
|
|
46
|
+
* at the same index with strict equality. Nested arrays are also checked only by strict
|
|
47
|
+
* equality.
|
|
48
|
+
*
|
|
49
|
+
* Example of usage:
|
|
50
|
+
* ```js
|
|
51
|
+
* `<vaadin-combo-box
|
|
52
|
+
* ${comboBoxRenderer((item, model, comboBox) => html`...`)}
|
|
53
|
+
* ></vaadin-combo-box>`
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* @param renderer the renderer callback that returns a Lit template.
|
|
57
|
+
* @param dependencies a single dependency or an array of dependencies
|
|
58
|
+
* which trigger a re-render when changed.
|
|
59
|
+
*/
|
|
60
|
+
export declare function comboBoxRenderer<TItem>(
|
|
61
|
+
renderer: ComboBoxLitRenderer<TItem>,
|
|
62
|
+
dependencies?: unknown,
|
|
63
|
+
): DirectiveResult<typeof ComboBoxRendererDirective>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) 2017 - 2022 Vaadin Ltd.
|
|
4
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
5
|
+
*/
|
|
6
|
+
import { directive } from 'lit/directive.js';
|
|
7
|
+
import { LitRendererDirective } from '@vaadin/lit-renderer';
|
|
8
|
+
|
|
9
|
+
export class ComboBoxRendererDirective extends LitRendererDirective {
|
|
10
|
+
/**
|
|
11
|
+
* Adds the renderer callback to the combo-box.
|
|
12
|
+
*/
|
|
13
|
+
addRenderer() {
|
|
14
|
+
this.element.renderer = (root, comboBox, model) => {
|
|
15
|
+
this.renderRenderer(root, model.item, model, comboBox);
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Runs the renderer callback on the combo-box.
|
|
21
|
+
*/
|
|
22
|
+
runRenderer() {
|
|
23
|
+
this.element.requestContentUpdate();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Removes the renderer callback from the combo-box.
|
|
28
|
+
*/
|
|
29
|
+
removeRenderer() {
|
|
30
|
+
this.element.renderer = null;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* A Lit directive for rendering the content of the `<vaadin-combo-box-item>` elements.
|
|
36
|
+
*
|
|
37
|
+
* The directive accepts a renderer callback returning a Lit template and assigns it to the combo-box
|
|
38
|
+
* via the `renderer` property. The renderer is called for each combo-box item when assigned
|
|
39
|
+
* and whenever a single dependency or an array of dependencies changes.
|
|
40
|
+
* It is not guaranteed that the renderer will be called immediately (synchronously) in both cases.
|
|
41
|
+
*
|
|
42
|
+
* Dependencies can be a single value or an array of values.
|
|
43
|
+
* Values are checked against previous values with strict equality (`===`),
|
|
44
|
+
* so the check won't detect nested property changes inside objects or arrays.
|
|
45
|
+
* When dependencies are provided as an array, each item is checked against the previous value
|
|
46
|
+
* at the same index with strict equality. Nested arrays are also checked only by strict
|
|
47
|
+
* equality.
|
|
48
|
+
*
|
|
49
|
+
* Example of usage:
|
|
50
|
+
* ```js
|
|
51
|
+
* `<vaadin-combo-box
|
|
52
|
+
* ${comboBoxRenderer((item, model, comboBox) => html`...`)}
|
|
53
|
+
* ></vaadin-combo-box>`
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* @param renderer the renderer callback that returns a Lit template.
|
|
57
|
+
* @param dependencies a single dependency or an array of dependencies
|
|
58
|
+
* which trigger a re-render when changed.
|
|
59
|
+
*/
|
|
60
|
+
export const comboBoxRenderer = directive(ComboBoxRendererDirective);
|
|
@@ -15,11 +15,11 @@ export interface ComboBoxDataProviderParams {
|
|
|
15
15
|
|
|
16
16
|
export type ComboBoxDataProvider<TItem> = (
|
|
17
17
|
params: ComboBoxDataProviderParams,
|
|
18
|
-
callback: ComboBoxDataProviderCallback<TItem
|
|
18
|
+
callback: ComboBoxDataProviderCallback<TItem>,
|
|
19
19
|
) => void;
|
|
20
20
|
|
|
21
21
|
export declare function ComboBoxDataProviderMixin<TItem, T extends Constructor<HTMLElement>>(
|
|
22
|
-
base: T
|
|
22
|
+
base: T,
|
|
23
23
|
): T & Constructor<ComboBoxDataProviderMixinClass<TItem>>;
|
|
24
24
|
|
|
25
25
|
export declare class ComboBoxDataProviderMixinClass<TItem> {
|
|
@@ -20,7 +20,7 @@ export const ComboBoxDataProviderMixin = (superClass) =>
|
|
|
20
20
|
pageSize: {
|
|
21
21
|
type: Number,
|
|
22
22
|
value: 50,
|
|
23
|
-
observer: '_pageSizeChanged'
|
|
23
|
+
observer: '_pageSizeChanged',
|
|
24
24
|
},
|
|
25
25
|
|
|
26
26
|
/**
|
|
@@ -29,7 +29,7 @@ export const ComboBoxDataProviderMixin = (superClass) =>
|
|
|
29
29
|
*/
|
|
30
30
|
size: {
|
|
31
31
|
type: Number,
|
|
32
|
-
observer: '_sizeChanged'
|
|
32
|
+
observer: '_sizeChanged',
|
|
33
33
|
},
|
|
34
34
|
|
|
35
35
|
/**
|
|
@@ -48,20 +48,20 @@ export const ComboBoxDataProviderMixin = (superClass) =>
|
|
|
48
48
|
*/
|
|
49
49
|
dataProvider: {
|
|
50
50
|
type: Object,
|
|
51
|
-
observer: '_dataProviderChanged'
|
|
51
|
+
observer: '_dataProviderChanged',
|
|
52
52
|
},
|
|
53
53
|
|
|
54
54
|
/** @private */
|
|
55
55
|
_pendingRequests: {
|
|
56
56
|
value: () => {
|
|
57
57
|
return {};
|
|
58
|
-
}
|
|
58
|
+
},
|
|
59
59
|
},
|
|
60
60
|
|
|
61
61
|
/** @private */
|
|
62
62
|
__placeHolder: {
|
|
63
|
-
value: new ComboBoxPlaceholder()
|
|
64
|
-
}
|
|
63
|
+
value: new ComboBoxPlaceholder(),
|
|
64
|
+
},
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
67
|
|
|
@@ -70,7 +70,7 @@ export const ComboBoxDataProviderMixin = (superClass) =>
|
|
|
70
70
|
'_dataProviderFilterChanged(filter, dataProvider)',
|
|
71
71
|
'_dataProviderClearFilter(dataProvider, opened, value)',
|
|
72
72
|
'_warnDataProviderValue(dataProvider, value)',
|
|
73
|
-
'_ensureFirstPage(opened)'
|
|
73
|
+
'_ensureFirstPage(opened)',
|
|
74
74
|
];
|
|
75
75
|
}
|
|
76
76
|
|
|
@@ -164,14 +164,14 @@ export const ComboBoxDataProviderMixin = (superClass) =>
|
|
|
164
164
|
|
|
165
165
|
/** @private */
|
|
166
166
|
_loadPage(page) {
|
|
167
|
-
//
|
|
167
|
+
// Make sure same page isn't requested multiple times.
|
|
168
168
|
if (!this._pendingRequests[page] && this.dataProvider) {
|
|
169
169
|
this.loading = true;
|
|
170
170
|
|
|
171
171
|
const params = {
|
|
172
172
|
page,
|
|
173
173
|
pageSize: this.pageSize,
|
|
174
|
-
filter: this.filter
|
|
174
|
+
filter: this.filter,
|
|
175
175
|
};
|
|
176
176
|
|
|
177
177
|
const callback = (items, size) => {
|
|
@@ -282,7 +282,7 @@ export const ComboBoxDataProviderMixin = (superClass) =>
|
|
|
282
282
|
'Nothing to display in the text field. This usually happens when ' +
|
|
283
283
|
'setting an initial `value` before any items are returned from ' +
|
|
284
284
|
'the `dataProvider` callback. Consider setting `selectedItem` ' +
|
|
285
|
-
'instead of `value`'
|
|
285
|
+
'instead of `value`',
|
|
286
286
|
);
|
|
287
287
|
}
|
|
288
288
|
}
|
|
@@ -48,7 +48,7 @@ export class ComboBoxDropdown extends PolymerElement {
|
|
|
48
48
|
*/
|
|
49
49
|
positionTarget: {
|
|
50
50
|
type: Object,
|
|
51
|
-
observer: '_positionTargetChanged'
|
|
51
|
+
observer: '_positionTargetChanged',
|
|
52
52
|
},
|
|
53
53
|
|
|
54
54
|
/**
|
|
@@ -62,7 +62,7 @@ export class ComboBoxDropdown extends PolymerElement {
|
|
|
62
62
|
loading: {
|
|
63
63
|
type: Boolean,
|
|
64
64
|
value: false,
|
|
65
|
-
reflectToAttribute: true
|
|
65
|
+
reflectToAttribute: true,
|
|
66
66
|
},
|
|
67
67
|
|
|
68
68
|
/**
|
|
@@ -71,31 +71,31 @@ export class ComboBoxDropdown extends PolymerElement {
|
|
|
71
71
|
theme: String,
|
|
72
72
|
|
|
73
73
|
_selectedItem: {
|
|
74
|
-
type: Object
|
|
74
|
+
type: Object,
|
|
75
75
|
},
|
|
76
76
|
|
|
77
77
|
_items: {
|
|
78
|
-
type: Array
|
|
78
|
+
type: Array,
|
|
79
79
|
},
|
|
80
80
|
|
|
81
81
|
_focusedIndex: {
|
|
82
82
|
type: Number,
|
|
83
|
-
value: -1
|
|
83
|
+
value: -1,
|
|
84
84
|
},
|
|
85
85
|
|
|
86
86
|
focusedItem: {
|
|
87
87
|
type: String,
|
|
88
|
-
computed: '_getFocusedItem(_focusedIndex)'
|
|
88
|
+
computed: '_getFocusedItem(_focusedIndex)',
|
|
89
89
|
},
|
|
90
90
|
|
|
91
91
|
_itemLabelPath: {
|
|
92
92
|
type: String,
|
|
93
|
-
value: 'label'
|
|
93
|
+
value: 'label',
|
|
94
94
|
},
|
|
95
95
|
|
|
96
96
|
_itemValuePath: {
|
|
97
97
|
type: String,
|
|
98
|
-
value: 'value'
|
|
98
|
+
value: 'value',
|
|
99
99
|
},
|
|
100
100
|
|
|
101
101
|
_scroller: Object,
|
|
@@ -104,15 +104,15 @@ export class ComboBoxDropdown extends PolymerElement {
|
|
|
104
104
|
|
|
105
105
|
_overlayOpened: {
|
|
106
106
|
type: Boolean,
|
|
107
|
-
observer: '_openedChanged'
|
|
108
|
-
}
|
|
107
|
+
observer: '_openedChanged',
|
|
108
|
+
},
|
|
109
109
|
};
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
static get observers() {
|
|
113
113
|
return [
|
|
114
114
|
'_openedOrItemsChanged(opened, _items, loading)',
|
|
115
|
-
'__updateScroller(_scroller, _items, opened, loading, _selectedItem, _itemIdPath, _focusedIndex, renderer, theme)'
|
|
115
|
+
'__updateScroller(_scroller, _items, opened, loading, _selectedItem, _itemIdPath, _focusedIndex, renderer, theme)',
|
|
116
116
|
];
|
|
117
117
|
}
|
|
118
118
|
|
|
@@ -174,8 +174,8 @@ export class ComboBoxDropdown extends PolymerElement {
|
|
|
174
174
|
_fireTouchAction(sourceEvent) {
|
|
175
175
|
this.dispatchEvent(
|
|
176
176
|
new CustomEvent('vaadin-overlay-touch-action', {
|
|
177
|
-
detail: { sourceEvent
|
|
178
|
-
})
|
|
177
|
+
detail: { sourceEvent },
|
|
178
|
+
}),
|
|
179
179
|
);
|
|
180
180
|
}
|
|
181
181
|
|
|
@@ -265,7 +265,7 @@ export class ComboBoxDropdown extends PolymerElement {
|
|
|
265
265
|
itemIdPath,
|
|
266
266
|
focusedIndex,
|
|
267
267
|
renderer,
|
|
268
|
-
theme
|
|
268
|
+
theme,
|
|
269
269
|
});
|
|
270
270
|
}
|
|
271
271
|
}
|
|
@@ -275,7 +275,7 @@ export class ComboBoxDropdown extends PolymerElement {
|
|
|
275
275
|
}
|
|
276
276
|
|
|
277
277
|
_positionTargetChanged(target) {
|
|
278
|
-
//
|
|
278
|
+
// We must update the overlay width when the positionTarget is set (or changes)
|
|
279
279
|
if (target) {
|
|
280
280
|
this._setOverlayWidth();
|
|
281
281
|
}
|
|
@@ -285,7 +285,7 @@ export class ComboBoxDropdown extends PolymerElement {
|
|
|
285
285
|
if (!this.positionTarget) {
|
|
286
286
|
return;
|
|
287
287
|
}
|
|
288
|
-
const inputWidth = this.positionTarget.clientWidth
|
|
288
|
+
const inputWidth = `${this.positionTarget.clientWidth}px`;
|
|
289
289
|
const propPrefix = `${this.__hostTagName}-overlay`;
|
|
290
290
|
const customWidth = getComputedStyle(this).getPropertyValue(`--${propPrefix}-width`);
|
|
291
291
|
|
|
@@ -79,7 +79,7 @@ export class ComboBoxItem extends ThemableMixin(DirMixin(PolymerElement)) {
|
|
|
79
79
|
selected: {
|
|
80
80
|
type: Boolean,
|
|
81
81
|
value: false,
|
|
82
|
-
reflectToAttribute: true
|
|
82
|
+
reflectToAttribute: true,
|
|
83
83
|
},
|
|
84
84
|
|
|
85
85
|
/**
|
|
@@ -88,7 +88,7 @@ export class ComboBoxItem extends ThemableMixin(DirMixin(PolymerElement)) {
|
|
|
88
88
|
focused: {
|
|
89
89
|
type: Boolean,
|
|
90
90
|
value: false,
|
|
91
|
-
reflectToAttribute: true
|
|
91
|
+
reflectToAttribute: true,
|
|
92
92
|
},
|
|
93
93
|
|
|
94
94
|
/**
|
|
@@ -99,7 +99,7 @@ export class ComboBoxItem extends ThemableMixin(DirMixin(PolymerElement)) {
|
|
|
99
99
|
/**
|
|
100
100
|
* Saved instance of a custom renderer function.
|
|
101
101
|
*/
|
|
102
|
-
_oldRenderer: Function
|
|
102
|
+
_oldRenderer: Function,
|
|
103
103
|
};
|
|
104
104
|
}
|
|
105
105
|
|
|
@@ -133,7 +133,7 @@ export class ComboBoxItem extends ThemableMixin(DirMixin(PolymerElement)) {
|
|
|
133
133
|
index: this.index,
|
|
134
134
|
item: this.item,
|
|
135
135
|
focused: this.focused,
|
|
136
|
-
selected: this.selected
|
|
136
|
+
selected: this.selected,
|
|
137
137
|
};
|
|
138
138
|
|
|
139
139
|
this.renderer(this, this._comboBox, model);
|
|
@@ -13,7 +13,7 @@ import { ComboBoxDefaultItem } from './vaadin-combo-box-mixin.js';
|
|
|
13
13
|
export {
|
|
14
14
|
ComboBoxDataProvider,
|
|
15
15
|
ComboBoxDataProviderCallback,
|
|
16
|
-
ComboBoxDataProviderParams
|
|
16
|
+
ComboBoxDataProviderParams,
|
|
17
17
|
} from './vaadin-combo-box-data-provider-mixin.js';
|
|
18
18
|
export { ComboBoxDefaultItem, ComboBoxItemModel, ComboBoxRenderer } from './vaadin-combo-box-mixin.js';
|
|
19
19
|
|
|
@@ -126,13 +126,13 @@ declare class ComboBoxLight<TItem = ComboBoxDefaultItem> extends HTMLElement {
|
|
|
126
126
|
addEventListener<K extends keyof ComboBoxLightEventMap<TItem>>(
|
|
127
127
|
type: K,
|
|
128
128
|
listener: (this: ComboBoxLight<TItem>, ev: ComboBoxLightEventMap<TItem>[K]) => void,
|
|
129
|
-
options?: boolean | AddEventListenerOptions
|
|
129
|
+
options?: boolean | AddEventListenerOptions,
|
|
130
130
|
): void;
|
|
131
131
|
|
|
132
132
|
removeEventListener<K extends keyof ComboBoxLightEventMap<TItem>>(
|
|
133
133
|
type: K,
|
|
134
134
|
listener: (this: ComboBoxLight<TItem>, ev: ComboBoxLightEventMap<TItem>[K]) => void,
|
|
135
|
-
options?: boolean | EventListenerOptions
|
|
135
|
+
options?: boolean | EventListenerOptions,
|
|
136
136
|
): void;
|
|
137
137
|
}
|
|
138
138
|
|
|
@@ -101,8 +101,8 @@ class ComboBoxLight extends ComboBoxDataProviderMixin(ComboBoxMixin(ThemableMixi
|
|
|
101
101
|
*/
|
|
102
102
|
attrForValue: {
|
|
103
103
|
type: String,
|
|
104
|
-
value: 'value'
|
|
105
|
-
}
|
|
104
|
+
value: 'value',
|
|
105
|
+
},
|
|
106
106
|
};
|
|
107
107
|
}
|
|
108
108
|
|
|
@@ -151,7 +151,7 @@ class ComboBoxLight extends ComboBoxDataProviderMixin(ComboBoxMixin(ThemableMixi
|
|
|
151
151
|
_isClearButton(event) {
|
|
152
152
|
return (
|
|
153
153
|
super._isClearButton(event) ||
|
|
154
|
-
(event.type === 'input' && !event.isTrusted) || //
|
|
154
|
+
(event.type === 'input' && !event.isTrusted) || // Fake input event dispatched by clear button
|
|
155
155
|
event.composedPath()[0].getAttribute('part') === 'clear-button'
|
|
156
156
|
);
|
|
157
157
|
}
|
|
@@ -19,11 +19,11 @@ export interface ComboBoxItemModel<TItem> {
|
|
|
19
19
|
export type ComboBoxRenderer<TItem> = (
|
|
20
20
|
root: HTMLElement,
|
|
21
21
|
comboBox: ComboBox<TItem>,
|
|
22
|
-
model: ComboBoxItemModel<TItem
|
|
22
|
+
model: ComboBoxItemModel<TItem>,
|
|
23
23
|
) => void;
|
|
24
24
|
|
|
25
25
|
export declare function ComboBoxMixin<TItem, T extends Constructor<HTMLElement>>(
|
|
26
|
-
base: T
|
|
26
|
+
base: T,
|
|
27
27
|
): T &
|
|
28
28
|
Constructor<ComboBoxMixinClass<TItem>> &
|
|
29
29
|
Constructor<DisabledMixinClass> &
|
|
@@ -29,7 +29,7 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
29
29
|
notify: true,
|
|
30
30
|
value: false,
|
|
31
31
|
reflectToAttribute: true,
|
|
32
|
-
observer: '_openedChanged'
|
|
32
|
+
observer: '_openedChanged',
|
|
33
33
|
},
|
|
34
34
|
|
|
35
35
|
/**
|
|
@@ -37,7 +37,7 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
37
37
|
* @attr {boolean} auto-open-disabled
|
|
38
38
|
*/
|
|
39
39
|
autoOpenDisabled: {
|
|
40
|
-
type: Boolean
|
|
40
|
+
type: Boolean,
|
|
41
41
|
},
|
|
42
42
|
|
|
43
43
|
/**
|
|
@@ -47,7 +47,7 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
47
47
|
readonly: {
|
|
48
48
|
type: Boolean,
|
|
49
49
|
value: false,
|
|
50
|
-
reflectToAttribute: true
|
|
50
|
+
reflectToAttribute: true,
|
|
51
51
|
},
|
|
52
52
|
|
|
53
53
|
/**
|
|
@@ -71,7 +71,7 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
71
71
|
*/
|
|
72
72
|
items: {
|
|
73
73
|
type: Array,
|
|
74
|
-
observer: '_itemsChanged'
|
|
74
|
+
observer: '_itemsChanged',
|
|
75
75
|
},
|
|
76
76
|
|
|
77
77
|
/**
|
|
@@ -84,7 +84,7 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
84
84
|
*/
|
|
85
85
|
allowCustomValue: {
|
|
86
86
|
type: Boolean,
|
|
87
|
-
value: false
|
|
87
|
+
value: false,
|
|
88
88
|
},
|
|
89
89
|
|
|
90
90
|
/**
|
|
@@ -94,7 +94,7 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
94
94
|
* @type {!Array<!ComboBoxItem | string> | undefined}
|
|
95
95
|
*/
|
|
96
96
|
filteredItems: {
|
|
97
|
-
type: Array
|
|
97
|
+
type: Array,
|
|
98
98
|
},
|
|
99
99
|
|
|
100
100
|
/**
|
|
@@ -111,7 +111,7 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
111
111
|
type: Boolean,
|
|
112
112
|
value: false,
|
|
113
113
|
reflectToAttribute: true,
|
|
114
|
-
observer: '_loadingChanged'
|
|
114
|
+
observer: '_loadingChanged',
|
|
115
115
|
},
|
|
116
116
|
|
|
117
117
|
/**
|
|
@@ -121,7 +121,7 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
121
121
|
_focusedIndex: {
|
|
122
122
|
type: Number,
|
|
123
123
|
observer: '_focusedIndexChanged',
|
|
124
|
-
value: -1
|
|
124
|
+
value: -1,
|
|
125
125
|
},
|
|
126
126
|
|
|
127
127
|
/**
|
|
@@ -131,7 +131,7 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
131
131
|
filter: {
|
|
132
132
|
type: String,
|
|
133
133
|
value: '',
|
|
134
|
-
notify: true
|
|
134
|
+
notify: true,
|
|
135
135
|
},
|
|
136
136
|
|
|
137
137
|
/**
|
|
@@ -140,7 +140,7 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
140
140
|
*/
|
|
141
141
|
selectedItem: {
|
|
142
142
|
type: Object,
|
|
143
|
-
notify: true
|
|
143
|
+
notify: true,
|
|
144
144
|
},
|
|
145
145
|
|
|
146
146
|
/**
|
|
@@ -156,7 +156,7 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
156
156
|
itemLabelPath: {
|
|
157
157
|
type: String,
|
|
158
158
|
value: 'label',
|
|
159
|
-
observer: '_itemLabelPathChanged'
|
|
159
|
+
observer: '_itemLabelPathChanged',
|
|
160
160
|
},
|
|
161
161
|
|
|
162
162
|
/**
|
|
@@ -171,7 +171,7 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
171
171
|
*/
|
|
172
172
|
itemValuePath: {
|
|
173
173
|
type: String,
|
|
174
|
-
value: 'value'
|
|
174
|
+
value: 'value',
|
|
175
175
|
},
|
|
176
176
|
|
|
177
177
|
/**
|
|
@@ -189,14 +189,14 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
189
189
|
*/
|
|
190
190
|
_toggleElement: {
|
|
191
191
|
type: Object,
|
|
192
|
-
observer: '_toggleElementChanged'
|
|
192
|
+
observer: '_toggleElementChanged',
|
|
193
193
|
},
|
|
194
194
|
|
|
195
195
|
/** @private */
|
|
196
196
|
_closeOnBlurIsPrevented: Boolean,
|
|
197
197
|
|
|
198
198
|
/** @private */
|
|
199
|
-
__restoreFocusOnClose: Boolean
|
|
199
|
+
__restoreFocusOnClose: Boolean,
|
|
200
200
|
};
|
|
201
201
|
}
|
|
202
202
|
|
|
@@ -205,7 +205,7 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
205
205
|
'_filterChanged(filter, itemValuePath, itemLabelPath)',
|
|
206
206
|
'_itemsOrPathsChanged(items.*, itemValuePath, itemLabelPath)',
|
|
207
207
|
'_filteredItemsChanged(filteredItems.*, itemValuePath, itemLabelPath)',
|
|
208
|
-
'_selectedItemChanged(selectedItem, itemValuePath, itemLabelPath)'
|
|
208
|
+
'_selectedItemChanged(selectedItem, itemValuePath, itemLabelPath)',
|
|
209
209
|
];
|
|
210
210
|
}
|
|
211
211
|
|
|
@@ -469,14 +469,14 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
469
469
|
this._onArrowDown();
|
|
470
470
|
this._closeOnBlurIsPrevented = false;
|
|
471
471
|
|
|
472
|
-
//
|
|
472
|
+
// Prevent caret from moving
|
|
473
473
|
e.preventDefault();
|
|
474
474
|
} else if (e.key === 'ArrowUp') {
|
|
475
475
|
this._closeOnBlurIsPrevented = true;
|
|
476
476
|
this._onArrowUp();
|
|
477
477
|
this._closeOnBlurIsPrevented = false;
|
|
478
478
|
|
|
479
|
-
//
|
|
479
|
+
// Prevent caret from moving
|
|
480
480
|
e.preventDefault();
|
|
481
481
|
} else if (e.key === 'Enter') {
|
|
482
482
|
this._onEnter(e);
|
|
@@ -576,7 +576,7 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
576
576
|
|
|
577
577
|
/** @private */
|
|
578
578
|
_onEnter(e) {
|
|
579
|
-
//
|
|
579
|
+
// Do not commit value when custom values are disallowed and input value is not a valid option
|
|
580
580
|
// also stop propagation of the event, otherwise the user could submit a form while the input
|
|
581
581
|
// still contains an invalid value
|
|
582
582
|
if (!this.allowCustomValue && this._inputElementValue !== '' && this._focusedIndex < 0) {
|
|
@@ -587,7 +587,7 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
587
587
|
return;
|
|
588
588
|
}
|
|
589
589
|
|
|
590
|
-
//
|
|
590
|
+
// Stop propagation of the enter event only if the dropdown is opened, this
|
|
591
591
|
// "consumes" the enter event for the action of closing the dropdown
|
|
592
592
|
if (this.opened) {
|
|
593
593
|
// Do not submit the surrounding form.
|
|
@@ -704,7 +704,7 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
704
704
|
if (this.selectedItem !== focusedItem) {
|
|
705
705
|
this.selectedItem = focusedItem;
|
|
706
706
|
}
|
|
707
|
-
//
|
|
707
|
+
// Make sure input field is updated in case value doesn't change (i.e. FOO -> foo)
|
|
708
708
|
this._inputElementValue = this._getItemLabel(this.selectedItem);
|
|
709
709
|
} else if (this._inputElementValue === '' || this._inputElementValue === undefined) {
|
|
710
710
|
this.selectedItem = null;
|
|
@@ -723,7 +723,7 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
723
723
|
|
|
724
724
|
if (
|
|
725
725
|
this.allowCustomValue &&
|
|
726
|
-
//
|
|
726
|
+
// To prevent a repetitive input value being saved after pressing ESC and Tab.
|
|
727
727
|
!itemMatchingByLabel
|
|
728
728
|
) {
|
|
729
729
|
const customValue = this._inputElementValue;
|
|
@@ -737,7 +737,7 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
737
737
|
detail: customValue,
|
|
738
738
|
composed: true,
|
|
739
739
|
cancelable: true,
|
|
740
|
-
bubbles: true
|
|
740
|
+
bubbles: true,
|
|
741
741
|
});
|
|
742
742
|
this.dispatchEvent(e);
|
|
743
743
|
if (!e.defaultPrevented) {
|
|
@@ -971,10 +971,11 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
971
971
|
this._selectItemForValue(this.value);
|
|
972
972
|
}
|
|
973
973
|
|
|
974
|
-
|
|
974
|
+
const inputValue = this._inputElementValue;
|
|
975
|
+
if (inputValue === undefined || inputValue === this._getItemLabel(this.selectedItem)) {
|
|
975
976
|
// When the input element value is the same as the current value or not defined,
|
|
976
977
|
// set the focused index to the item that matches the value.
|
|
977
|
-
this._focusedIndex = this.
|
|
978
|
+
this._focusedIndex = this.$.dropdown.indexOfLabel(this._getItemLabel(this.selectedItem));
|
|
978
979
|
} else {
|
|
979
980
|
// When the user filled in something that is different from the current value = filtering is enabled,
|
|
980
981
|
// set the focused index to the item that matches the filter query.
|
|
@@ -1056,7 +1057,7 @@ export const ComboBoxMixin = (subclass) =>
|
|
|
1056
1057
|
|
|
1057
1058
|
/** @private */
|
|
1058
1059
|
_overlaySelectedItemChanged(e) {
|
|
1059
|
-
//
|
|
1060
|
+
// Stop this private event from leaking outside.
|
|
1060
1061
|
e.stopPropagation();
|
|
1061
1062
|
|
|
1062
1063
|
if (e.detail.item instanceof ComboBoxPlaceholder) {
|
|
@@ -56,7 +56,7 @@ export class ComboBoxScroller extends PolymerElement {
|
|
|
56
56
|
*/
|
|
57
57
|
items: {
|
|
58
58
|
type: Array,
|
|
59
|
-
observer: '__itemsChanged'
|
|
59
|
+
observer: '__itemsChanged',
|
|
60
60
|
},
|
|
61
61
|
|
|
62
62
|
/**
|
|
@@ -65,7 +65,7 @@ export class ComboBoxScroller extends PolymerElement {
|
|
|
65
65
|
*/
|
|
66
66
|
focusedIndex: {
|
|
67
67
|
type: Number,
|
|
68
|
-
observer: '__focusedIndexChanged'
|
|
68
|
+
observer: '__focusedIndexChanged',
|
|
69
69
|
},
|
|
70
70
|
|
|
71
71
|
/**
|
|
@@ -73,7 +73,7 @@ export class ComboBoxScroller extends PolymerElement {
|
|
|
73
73
|
*/
|
|
74
74
|
loading: {
|
|
75
75
|
type: Boolean,
|
|
76
|
-
observer: '__loadingChanged'
|
|
76
|
+
observer: '__loadingChanged',
|
|
77
77
|
},
|
|
78
78
|
|
|
79
79
|
/**
|
|
@@ -82,35 +82,35 @@ export class ComboBoxScroller extends PolymerElement {
|
|
|
82
82
|
*/
|
|
83
83
|
opened: {
|
|
84
84
|
type: Boolean,
|
|
85
|
-
observer: '__openedChanged'
|
|
85
|
+
observer: '__openedChanged',
|
|
86
86
|
},
|
|
87
87
|
|
|
88
88
|
/**
|
|
89
89
|
* The selected item from the `items` array.
|
|
90
90
|
*/
|
|
91
91
|
selectedItem: {
|
|
92
|
-
type: Object
|
|
92
|
+
type: Object,
|
|
93
93
|
},
|
|
94
94
|
|
|
95
95
|
/**
|
|
96
96
|
* Path for the id of the item, used to detect whether the item is selected.
|
|
97
97
|
*/
|
|
98
98
|
itemIdPath: {
|
|
99
|
-
type: String
|
|
99
|
+
type: String,
|
|
100
100
|
},
|
|
101
101
|
|
|
102
102
|
/**
|
|
103
103
|
* Reference to the combo-box, used by the item elements.
|
|
104
104
|
*/
|
|
105
105
|
comboBox: {
|
|
106
|
-
type: Object
|
|
106
|
+
type: Object,
|
|
107
107
|
},
|
|
108
108
|
|
|
109
109
|
/**
|
|
110
110
|
* Function used to set a label for every combo-box item.
|
|
111
111
|
*/
|
|
112
112
|
getItemLabel: {
|
|
113
|
-
type: Object
|
|
113
|
+
type: Object,
|
|
114
114
|
},
|
|
115
115
|
|
|
116
116
|
/**
|
|
@@ -118,15 +118,15 @@ export class ComboBoxScroller extends PolymerElement {
|
|
|
118
118
|
*/
|
|
119
119
|
renderer: {
|
|
120
120
|
type: Object,
|
|
121
|
-
observer: '__rendererChanged'
|
|
121
|
+
observer: '__rendererChanged',
|
|
122
122
|
},
|
|
123
123
|
|
|
124
124
|
/**
|
|
125
125
|
* Used to propagate the `theme` attribute from the host element.
|
|
126
126
|
*/
|
|
127
127
|
theme: {
|
|
128
|
-
type: String
|
|
129
|
-
}
|
|
128
|
+
type: String,
|
|
129
|
+
},
|
|
130
130
|
};
|
|
131
131
|
}
|
|
132
132
|
|
|
@@ -159,7 +159,7 @@ export class ComboBoxScroller extends PolymerElement {
|
|
|
159
159
|
updateElement: this.__updateElement.bind(this),
|
|
160
160
|
elementsContainer: this,
|
|
161
161
|
scrollTarget: this,
|
|
162
|
-
scrollContainer: this.$.selector
|
|
162
|
+
scrollContainer: this.$.selector,
|
|
163
163
|
});
|
|
164
164
|
}
|
|
165
165
|
|
|
@@ -193,7 +193,7 @@ export class ComboBoxScroller extends PolymerElement {
|
|
|
193
193
|
|
|
194
194
|
// Sometimes the item is partly below the bottom edge, detect and adjust.
|
|
195
195
|
const lastPhysicalItem = [...this.children].find(
|
|
196
|
-
(el) => !el.hidden && el.index === this.__virtualizer.lastVisibleIndex
|
|
196
|
+
(el) => !el.hidden && el.index === this.__virtualizer.lastVisibleIndex,
|
|
197
197
|
);
|
|
198
198
|
if (!lastPhysicalItem || index !== lastPhysicalItem.index) {
|
|
199
199
|
return;
|
|
@@ -218,7 +218,7 @@ export class ComboBoxScroller extends PolymerElement {
|
|
|
218
218
|
|
|
219
219
|
/** @private */
|
|
220
220
|
__isItemFocused(focusedIndex, itemIndex) {
|
|
221
|
-
return focusedIndex
|
|
221
|
+
return focusedIndex === itemIndex;
|
|
222
222
|
}
|
|
223
223
|
|
|
224
224
|
/** @private */
|
|
@@ -294,7 +294,7 @@ export class ComboBoxScroller extends PolymerElement {
|
|
|
294
294
|
label: this.getItemLabel(item),
|
|
295
295
|
selected: this.__isItemSelected(item, this.selectedItem, this.itemIdPath),
|
|
296
296
|
renderer: this.renderer,
|
|
297
|
-
focused: this.__isItemFocused(focusedIndex, index)
|
|
297
|
+
focused: this.__isItemFocused(focusedIndex, index),
|
|
298
298
|
});
|
|
299
299
|
|
|
300
300
|
el.id = `${this.__hostTagName}-item-${index}`;
|
|
@@ -355,7 +355,7 @@ export class ComboBoxScroller extends PolymerElement {
|
|
|
355
355
|
__requestItemByIndex(item, index) {
|
|
356
356
|
if (item instanceof ComboBoxPlaceholder && index !== undefined) {
|
|
357
357
|
this.dispatchEvent(
|
|
358
|
-
new CustomEvent('index-requested', { detail: { index, currentScrollerPos: this._oldScrollerPosition } })
|
|
358
|
+
new CustomEvent('index-requested', { detail: { index, currentScrollerPos: this._oldScrollerPosition } }),
|
|
359
359
|
);
|
|
360
360
|
}
|
|
361
361
|
|
|
@@ -24,7 +24,7 @@ import { ComboBoxDefaultItem } from './vaadin-combo-box-mixin.js';
|
|
|
24
24
|
export {
|
|
25
25
|
ComboBoxDataProvider,
|
|
26
26
|
ComboBoxDataProviderCallback,
|
|
27
|
-
ComboBoxDataProviderParams
|
|
27
|
+
ComboBoxDataProviderParams,
|
|
28
28
|
} from './vaadin-combo-box-data-provider-mixin.js';
|
|
29
29
|
export { ComboBoxDefaultItem, ComboBoxItemModel, ComboBoxRenderer } from './vaadin-combo-box-mixin.js';
|
|
30
30
|
|
|
@@ -212,13 +212,13 @@ declare class ComboBox<TItem = ComboBoxDefaultItem> extends HTMLElement {
|
|
|
212
212
|
addEventListener<K extends keyof ComboBoxEventMap<TItem>>(
|
|
213
213
|
type: K,
|
|
214
214
|
listener: (this: ComboBox<TItem>, ev: ComboBoxEventMap<TItem>[K]) => void,
|
|
215
|
-
options?: boolean | AddEventListenerOptions
|
|
215
|
+
options?: boolean | AddEventListenerOptions,
|
|
216
216
|
): void;
|
|
217
217
|
|
|
218
218
|
removeEventListener<K extends keyof ComboBoxEventMap<TItem>>(
|
|
219
219
|
type: K,
|
|
220
220
|
listener: (this: ComboBox<TItem>, ev: ComboBoxEventMap<TItem>[K]) => void,
|
|
221
|
-
options?: boolean | EventListenerOptions
|
|
221
|
+
options?: boolean | EventListenerOptions,
|
|
222
222
|
): void;
|
|
223
223
|
}
|
|
224
224
|
|
package/src/vaadin-combo-box.js
CHANGED
|
@@ -154,7 +154,7 @@ registerStyles('vaadin-combo-box', inputFieldShared, { moduleId: 'vaadin-combo-b
|
|
|
154
154
|
* @mixes ComboBoxMixin
|
|
155
155
|
*/
|
|
156
156
|
class ComboBox extends ComboBoxDataProviderMixin(
|
|
157
|
-
ComboBoxMixin(PatternMixin(InputControlMixin(ThemableMixin(ElementMixin(PolymerElement)))))
|
|
157
|
+
ComboBoxMixin(PatternMixin(InputControlMixin(ThemableMixin(ElementMixin(PolymerElement))))),
|
|
158
158
|
) {
|
|
159
159
|
static get is() {
|
|
160
160
|
return 'vaadin-combo-box';
|
|
@@ -218,8 +218,8 @@ class ComboBox extends ComboBoxDataProviderMixin(
|
|
|
218
218
|
* @protected
|
|
219
219
|
*/
|
|
220
220
|
_positionTarget: {
|
|
221
|
-
type: Object
|
|
222
|
-
}
|
|
221
|
+
type: Object,
|
|
222
|
+
},
|
|
223
223
|
};
|
|
224
224
|
}
|
|
225
225
|
|
|
@@ -242,7 +242,7 @@ class ComboBox extends ComboBoxDataProviderMixin(
|
|
|
242
242
|
this._setFocusElement(input);
|
|
243
243
|
this.stateTarget = input;
|
|
244
244
|
this.ariaTarget = input;
|
|
245
|
-
})
|
|
245
|
+
}),
|
|
246
246
|
);
|
|
247
247
|
this.addController(new LabelledInputController(this.inputElement, this._labelController));
|
|
248
248
|
this._positionTarget = this.shadowRoot.querySelector('[part="input-field"]');
|