@vaadin/multi-select-combo-box 23.2.0-dev.53560527d → 23.2.0
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/README.md +2 -4
- package/package.json +17 -11
- package/src/lit/renderer-directives.d.ts +4 -4
- package/src/vaadin-multi-select-combo-box-chip.js +1 -1
- package/src/vaadin-multi-select-combo-box-internal.js +21 -1
- package/src/vaadin-multi-select-combo-box-item.js +1 -1
- package/src/vaadin-multi-select-combo-box.d.ts +36 -20
- package/src/vaadin-multi-select-combo-box.js +55 -31
- package/web-types.json +662 -0
- package/web-types.lit.json +279 -0
package/README.md
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
# @vaadin/multi-select-combo-box
|
|
2
2
|
|
|
3
|
-
> ⚠️ Work in progress, please do not use this component yet.
|
|
4
|
-
|
|
5
3
|
A web component that wraps `<vaadin-combo-box>` and allows selecting multiple items.
|
|
6
4
|
|
|
7
5
|
```html
|
|
@@ -29,7 +27,7 @@ import '@vaadin/multi-select-combo-box';
|
|
|
29
27
|
|
|
30
28
|
## Themes
|
|
31
29
|
|
|
32
|
-
Vaadin components come with two built-in [themes](https://vaadin.com/docs/latest/
|
|
30
|
+
Vaadin components come with two built-in [themes](https://vaadin.com/docs/latest/styling), Lumo and Material.
|
|
33
31
|
The [main entrypoint](https://github.com/vaadin/web-components/blob/master/packages/multi-select-combo-box/vaadin-multi-select-combo-box.js) of the package uses the Lumo theme.
|
|
34
32
|
|
|
35
33
|
To use the Material theme, import the component from the `theme/material` folder:
|
|
@@ -52,7 +50,7 @@ import '@vaadin/multi-select-combo-box/src/vaadin-multi-select-combo-box.js';
|
|
|
52
50
|
|
|
53
51
|
## Contributing
|
|
54
52
|
|
|
55
|
-
Read the [contributing guide](https://vaadin.com/docs/latest/
|
|
53
|
+
Read the [contributing guide](https://vaadin.com/docs/latest/contributing/overview) to learn about our development process, how to propose bugfixes and improvements, and how to test your changes to Vaadin components.
|
|
56
54
|
|
|
57
55
|
## License
|
|
58
56
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vaadin/multi-select-combo-box",
|
|
3
|
-
"version": "23.2.0
|
|
3
|
+
"version": "23.2.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -24,7 +24,9 @@
|
|
|
24
24
|
"src",
|
|
25
25
|
"theme",
|
|
26
26
|
"vaadin-*.d.ts",
|
|
27
|
-
"vaadin-*.js"
|
|
27
|
+
"vaadin-*.js",
|
|
28
|
+
"web-types.json",
|
|
29
|
+
"web-types.lit.json"
|
|
28
30
|
],
|
|
29
31
|
"keywords": [
|
|
30
32
|
"Vaadin",
|
|
@@ -35,19 +37,23 @@
|
|
|
35
37
|
],
|
|
36
38
|
"dependencies": {
|
|
37
39
|
"@polymer/polymer": "^3.0.0",
|
|
38
|
-
"@vaadin/combo-box": "23.2.0
|
|
39
|
-
"@vaadin/component-base": "23.2.0
|
|
40
|
-
"@vaadin/field-base": "23.2.0
|
|
41
|
-
"@vaadin/input-container": "23.2.0
|
|
42
|
-
"@vaadin/lit-renderer": "23.2.0
|
|
43
|
-
"@vaadin/vaadin-lumo-styles": "23.2.0
|
|
44
|
-
"@vaadin/vaadin-material-styles": "23.2.0
|
|
45
|
-
"@vaadin/vaadin-themable-mixin": "23.2.0
|
|
40
|
+
"@vaadin/combo-box": "^23.2.0",
|
|
41
|
+
"@vaadin/component-base": "^23.2.0",
|
|
42
|
+
"@vaadin/field-base": "^23.2.0",
|
|
43
|
+
"@vaadin/input-container": "^23.2.0",
|
|
44
|
+
"@vaadin/lit-renderer": "^23.2.0",
|
|
45
|
+
"@vaadin/vaadin-lumo-styles": "^23.2.0",
|
|
46
|
+
"@vaadin/vaadin-material-styles": "^23.2.0",
|
|
47
|
+
"@vaadin/vaadin-themable-mixin": "^23.2.0"
|
|
46
48
|
},
|
|
47
49
|
"devDependencies": {
|
|
48
50
|
"@esm-bundle/chai": "^4.3.4",
|
|
49
51
|
"@vaadin/testing-helpers": "^0.3.2",
|
|
50
52
|
"sinon": "^13.0.2"
|
|
51
53
|
},
|
|
52
|
-
"
|
|
54
|
+
"web-types": [
|
|
55
|
+
"web-types.json",
|
|
56
|
+
"web-types.lit.json"
|
|
57
|
+
],
|
|
58
|
+
"gitHead": "8b1f5941f26ac41ca038e75e24c8584e331bc7a8"
|
|
53
59
|
}
|
|
@@ -3,11 +3,11 @@
|
|
|
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';
|
|
8
|
-
import { ComboBoxItemModel } from '@vaadin/combo-box/src/vaadin-combo-box.js';
|
|
6
|
+
import type { TemplateResult } from 'lit';
|
|
7
|
+
import type { DirectiveResult } from 'lit/directive.js';
|
|
8
|
+
import type { ComboBoxItemModel } from '@vaadin/combo-box/src/vaadin-combo-box.js';
|
|
9
9
|
import { LitRendererDirective } from '@vaadin/lit-renderer';
|
|
10
|
-
import { MultiSelectComboBox } from '../vaadin-multi-select-combo-box.js';
|
|
10
|
+
import type { MultiSelectComboBox } from '../vaadin-multi-select-combo-box.js';
|
|
11
11
|
|
|
12
12
|
export type MultiSelectComboBoxLitRenderer<TItem> = (
|
|
13
13
|
item: TItem,
|
|
@@ -18,7 +18,7 @@ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mix
|
|
|
18
18
|
* `label` | Element containing the label
|
|
19
19
|
* `remove-button` | Remove button
|
|
20
20
|
*
|
|
21
|
-
* See [Styling Components](https://vaadin.com/docs/latest/
|
|
21
|
+
* See [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.
|
|
22
22
|
*
|
|
23
23
|
* @extends HTMLElement
|
|
24
24
|
* @private
|
|
@@ -38,7 +38,6 @@ class MultiSelectComboBoxInternal extends ComboBoxDataProviderMixin(ComboBoxMixi
|
|
|
38
38
|
|
|
39
39
|
<vaadin-multi-select-combo-box-overlay
|
|
40
40
|
id="overlay"
|
|
41
|
-
hidden$="[[_isOverlayHidden(filteredItems, loading)]]"
|
|
42
41
|
opened="[[_overlayOpened]]"
|
|
43
42
|
loading$="[[loading]]"
|
|
44
43
|
theme$="[[_theme]]"
|
|
@@ -87,6 +86,15 @@ class MultiSelectComboBoxInternal extends ComboBoxDataProviderMixin(ComboBoxMixi
|
|
|
87
86
|
value: () => [],
|
|
88
87
|
},
|
|
89
88
|
|
|
89
|
+
/**
|
|
90
|
+
* Last input value entered by the user before value is updated.
|
|
91
|
+
* Used to store `filter` property value before clearing it.
|
|
92
|
+
*/
|
|
93
|
+
lastFilter: {
|
|
94
|
+
type: String,
|
|
95
|
+
notify: true,
|
|
96
|
+
},
|
|
97
|
+
|
|
90
98
|
_target: {
|
|
91
99
|
type: Object,
|
|
92
100
|
},
|
|
@@ -195,6 +203,18 @@ class MultiSelectComboBoxInternal extends ComboBoxDataProviderMixin(ComboBoxMixi
|
|
|
195
203
|
super._closeOrCommit();
|
|
196
204
|
}
|
|
197
205
|
|
|
206
|
+
/**
|
|
207
|
+
* @protected
|
|
208
|
+
* @override
|
|
209
|
+
*/
|
|
210
|
+
_commitValue() {
|
|
211
|
+
// Store filter value for checking if user input is matching
|
|
212
|
+
// an item which is already selected, to not un-select it.
|
|
213
|
+
this.lastFilter = this.filter;
|
|
214
|
+
|
|
215
|
+
super._commitValue();
|
|
216
|
+
}
|
|
217
|
+
|
|
198
218
|
/**
|
|
199
219
|
* Override method inherited from the combo-box
|
|
200
220
|
* to not update focused item when readonly.
|
|
@@ -23,7 +23,7 @@ import { ComboBoxItem } from '@vaadin/combo-box/src/vaadin-combo-box-item.js';
|
|
|
23
23
|
* `selected` | Set when the item is selected | :host
|
|
24
24
|
* `focused` | Set when the item is focused | :host
|
|
25
25
|
*
|
|
26
|
-
* See [Styling Components](https://vaadin.com/docs/latest/
|
|
26
|
+
* See [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.
|
|
27
27
|
*
|
|
28
28
|
* @extends ComboBoxItem
|
|
29
29
|
* @private
|
|
@@ -3,26 +3,27 @@
|
|
|
3
3
|
* Copyright (c) 2021 - 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 {
|
|
6
|
+
import type {
|
|
7
7
|
ComboBoxDataProvider,
|
|
8
8
|
ComboBoxDefaultItem,
|
|
9
9
|
ComboBoxItemModel,
|
|
10
10
|
} from '@vaadin/combo-box/src/vaadin-combo-box.js';
|
|
11
|
-
import { ControllerMixinClass } from '@vaadin/component-base/src/controller-mixin.js';
|
|
12
|
-
import { DisabledMixinClass } from '@vaadin/component-base/src/disabled-mixin.js';
|
|
13
|
-
import { ElementMixinClass } from '@vaadin/component-base/src/element-mixin.js';
|
|
14
|
-
import { FocusMixinClass } from '@vaadin/component-base/src/focus-mixin.js';
|
|
15
|
-
import { KeyboardMixinClass } from '@vaadin/component-base/src/keyboard-mixin.js';
|
|
16
|
-
import { ResizeMixinClass } from '@vaadin/component-base/src/resize-mixin.js';
|
|
17
|
-
import { DelegateFocusMixinClass } from '@vaadin/field-base/src/delegate-focus-mixin.js';
|
|
18
|
-
import { DelegateStateMixinClass } from '@vaadin/field-base/src/delegate-state-mixin.js';
|
|
19
|
-
import { FieldMixinClass } from '@vaadin/field-base/src/field-mixin.js';
|
|
20
|
-
import { InputConstraintsMixinClass } from '@vaadin/field-base/src/input-constraints-mixin.js';
|
|
21
|
-
import { InputControlMixinClass } from '@vaadin/field-base/src/input-control-mixin.js';
|
|
22
|
-
import { InputMixinClass } from '@vaadin/field-base/src/input-mixin.js';
|
|
23
|
-
import { LabelMixinClass } from '@vaadin/field-base/src/label-mixin.js';
|
|
24
|
-
import { ValidateMixinClass } from '@vaadin/field-base/src/validate-mixin.js';
|
|
25
|
-
import { ThemableMixinClass } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
11
|
+
import type { ControllerMixinClass } from '@vaadin/component-base/src/controller-mixin.js';
|
|
12
|
+
import type { DisabledMixinClass } from '@vaadin/component-base/src/disabled-mixin.js';
|
|
13
|
+
import type { ElementMixinClass } from '@vaadin/component-base/src/element-mixin.js';
|
|
14
|
+
import type { FocusMixinClass } from '@vaadin/component-base/src/focus-mixin.js';
|
|
15
|
+
import type { KeyboardMixinClass } from '@vaadin/component-base/src/keyboard-mixin.js';
|
|
16
|
+
import type { ResizeMixinClass } from '@vaadin/component-base/src/resize-mixin.js';
|
|
17
|
+
import type { DelegateFocusMixinClass } from '@vaadin/field-base/src/delegate-focus-mixin.js';
|
|
18
|
+
import type { DelegateStateMixinClass } from '@vaadin/field-base/src/delegate-state-mixin.js';
|
|
19
|
+
import type { FieldMixinClass } from '@vaadin/field-base/src/field-mixin.js';
|
|
20
|
+
import type { InputConstraintsMixinClass } from '@vaadin/field-base/src/input-constraints-mixin.js';
|
|
21
|
+
import type { InputControlMixinClass } from '@vaadin/field-base/src/input-control-mixin.js';
|
|
22
|
+
import type { InputMixinClass } from '@vaadin/field-base/src/input-mixin.js';
|
|
23
|
+
import type { LabelMixinClass } from '@vaadin/field-base/src/label-mixin.js';
|
|
24
|
+
import type { ValidateMixinClass } from '@vaadin/field-base/src/validate-mixin.js';
|
|
25
|
+
import type { ThemableMixinClass } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
|
|
26
|
+
import type { ThemePropertyMixinClass } from '@vaadin/vaadin-themable-mixin/vaadin-theme-property-mixin.js';
|
|
26
27
|
|
|
27
28
|
export type MultiSelectComboBoxRenderer<TItem> = (
|
|
28
29
|
root: HTMLElement,
|
|
@@ -65,6 +66,11 @@ export type MultiSelectComboBoxInvalidChangedEvent = CustomEvent<{ value: boolea
|
|
|
65
66
|
*/
|
|
66
67
|
export type MultiSelectComboBoxSelectedItemsChangedEvent<TItem> = CustomEvent<{ value: TItem[] }>;
|
|
67
68
|
|
|
69
|
+
/**
|
|
70
|
+
* Fired whenever the field is validated.
|
|
71
|
+
*/
|
|
72
|
+
export type MultiSelectComboBoxValidatedEvent = CustomEvent<{ valid: boolean }>;
|
|
73
|
+
|
|
68
74
|
export interface MultiSelectComboBoxEventMap<TItem> extends HTMLElementEventMap {
|
|
69
75
|
change: MultiSelectComboBoxChangeEvent<TItem>;
|
|
70
76
|
|
|
@@ -75,6 +81,8 @@ export interface MultiSelectComboBoxEventMap<TItem> extends HTMLElementEventMap
|
|
|
75
81
|
'invalid-changed': MultiSelectComboBoxInvalidChangedEvent;
|
|
76
82
|
|
|
77
83
|
'selected-items-changed': MultiSelectComboBoxSelectedItemsChangedEvent<TItem>;
|
|
84
|
+
|
|
85
|
+
validated: MultiSelectComboBoxValidatedEvent;
|
|
78
86
|
}
|
|
79
87
|
|
|
80
88
|
/**
|
|
@@ -131,6 +139,7 @@ export interface MultiSelectComboBoxEventMap<TItem> extends HTMLElementEventMap
|
|
|
131
139
|
* Custom property | Description | Default
|
|
132
140
|
* -----------------------------------------------------|----------------------------|--------
|
|
133
141
|
* `--vaadin-field-default-width` | Default width of the field | `12em`
|
|
142
|
+
* `--vaadin-multi-select-combo-box-overlay-width` | Width of the overlay | `auto`
|
|
134
143
|
* `--vaadin-multi-select-combo-box-overlay-max-height` | Max height of the overlay | `65vh`
|
|
135
144
|
* `--vaadin-multi-select-combo-box-input-min-width` | Min width of the input | `4em`
|
|
136
145
|
*
|
|
@@ -146,13 +155,14 @@ export interface MultiSelectComboBoxEventMap<TItem> extends HTMLElementEventMap
|
|
|
146
155
|
* Note: the `theme` attribute value set on `<vaadin-multi-select-combo-box>` is
|
|
147
156
|
* propagated to these components.
|
|
148
157
|
*
|
|
149
|
-
* See [Styling Components](https://vaadin.com/docs/latest/
|
|
158
|
+
* See [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.
|
|
150
159
|
*
|
|
151
160
|
* @fires {Event} change - Fired when the user commits a value change.
|
|
152
161
|
* @fires {CustomEvent} custom-value-set - Fired when the user sets a custom value.
|
|
153
162
|
* @fires {CustomEvent} filter-changed - Fired when the `filter` property changes.
|
|
154
163
|
* @fires {CustomEvent} invalid-changed - Fired when the `invalid` property changes.
|
|
155
164
|
* @fires {CustomEvent} selected-items-changed - Fired when the `selectedItems` property changes.
|
|
165
|
+
* @fires {CustomEvent} validated - Fired whenever the field is validated.
|
|
156
166
|
*/
|
|
157
167
|
declare class MultiSelectComboBox<TItem = ComboBoxDefaultItem> extends HTMLElement {
|
|
158
168
|
/**
|
|
@@ -294,6 +304,11 @@ declare class MultiSelectComboBox<TItem = ComboBoxDefaultItem> extends HTMLEleme
|
|
|
294
304
|
*/
|
|
295
305
|
clearCache(): void;
|
|
296
306
|
|
|
307
|
+
/**
|
|
308
|
+
* Clears the selected items.
|
|
309
|
+
*/
|
|
310
|
+
clear(): void;
|
|
311
|
+
|
|
297
312
|
/**
|
|
298
313
|
* Requests an update for the content of items.
|
|
299
314
|
* While performing the update, it invokes the renderer (passed in the `renderer` property) once an item.
|
|
@@ -305,13 +320,13 @@ declare class MultiSelectComboBox<TItem = ComboBoxDefaultItem> extends HTMLEleme
|
|
|
305
320
|
addEventListener<K extends keyof MultiSelectComboBoxEventMap<TItem>>(
|
|
306
321
|
type: K,
|
|
307
322
|
listener: (this: MultiSelectComboBox<TItem>, ev: MultiSelectComboBoxEventMap<TItem>[K]) => void,
|
|
308
|
-
options?:
|
|
323
|
+
options?: AddEventListenerOptions | boolean,
|
|
309
324
|
): void;
|
|
310
325
|
|
|
311
326
|
removeEventListener<K extends keyof MultiSelectComboBoxEventMap<TItem>>(
|
|
312
327
|
type: K,
|
|
313
328
|
listener: (this: MultiSelectComboBox<TItem>, ev: MultiSelectComboBoxEventMap<TItem>[K]) => void,
|
|
314
|
-
options?:
|
|
329
|
+
options?: EventListenerOptions | boolean,
|
|
315
330
|
): void;
|
|
316
331
|
}
|
|
317
332
|
|
|
@@ -319,7 +334,7 @@ interface MultiSelectComboBox
|
|
|
319
334
|
extends ValidateMixinClass,
|
|
320
335
|
LabelMixinClass,
|
|
321
336
|
KeyboardMixinClass,
|
|
322
|
-
InputMixinClass,
|
|
337
|
+
Omit<InputMixinClass, 'value'>,
|
|
323
338
|
InputControlMixinClass,
|
|
324
339
|
InputConstraintsMixinClass,
|
|
325
340
|
FocusMixinClass,
|
|
@@ -329,6 +344,7 @@ interface MultiSelectComboBox
|
|
|
329
344
|
DelegateFocusMixinClass,
|
|
330
345
|
ResizeMixinClass,
|
|
331
346
|
ThemableMixinClass,
|
|
347
|
+
ThemePropertyMixinClass,
|
|
332
348
|
ElementMixinClass,
|
|
333
349
|
ControllerMixinClass {}
|
|
334
350
|
|
|
@@ -109,6 +109,7 @@ registerStyles('vaadin-multi-select-combo-box', [inputFieldShared, multiSelectCo
|
|
|
109
109
|
* Custom property | Description | Default
|
|
110
110
|
* -----------------------------------------------------|----------------------------|--------
|
|
111
111
|
* `--vaadin-field-default-width` | Default width of the field | `12em`
|
|
112
|
+
* `--vaadin-multi-select-combo-box-overlay-width` | Width of the overlay | `auto`
|
|
112
113
|
* `--vaadin-multi-select-combo-box-overlay-max-height` | Max height of the overlay | `65vh`
|
|
113
114
|
* `--vaadin-multi-select-combo-box-input-min-width` | Min width of the input | `4em`
|
|
114
115
|
*
|
|
@@ -124,13 +125,14 @@ registerStyles('vaadin-multi-select-combo-box', [inputFieldShared, multiSelectCo
|
|
|
124
125
|
* Note: the `theme` attribute value set on `<vaadin-multi-select-combo-box>` is
|
|
125
126
|
* propagated to these components.
|
|
126
127
|
*
|
|
127
|
-
* See [Styling Components](https://vaadin.com/docs/latest/
|
|
128
|
+
* See [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.
|
|
128
129
|
*
|
|
129
130
|
* @fires {Event} change - Fired when the user commits a value change.
|
|
130
131
|
* @fires {CustomEvent} custom-value-set - Fired when the user sets a custom value.
|
|
131
132
|
* @fires {CustomEvent} filter-changed - Fired when the `filter` property changes.
|
|
132
133
|
* @fires {CustomEvent} invalid-changed - Fired when the `invalid` property changes.
|
|
133
134
|
* @fires {CustomEvent} selected-items-changed - Fired when the `selectedItems` property changes.
|
|
135
|
+
* @fires {CustomEvent} validated - Fired whenever the field is validated.
|
|
134
136
|
*
|
|
135
137
|
* @extends HTMLElement
|
|
136
138
|
* @mixes ElementMixin
|
|
@@ -163,6 +165,7 @@ class MultiSelectComboBox extends ResizeMixin(InputControlMixin(ThemableMixin(El
|
|
|
163
165
|
allow-custom-value="[[allowCustomValue]]"
|
|
164
166
|
data-provider="[[dataProvider]]"
|
|
165
167
|
filter="{{filter}}"
|
|
168
|
+
last-filter="{{_lastFilter}}"
|
|
166
169
|
loading="{{loading}}"
|
|
167
170
|
size="{{size}}"
|
|
168
171
|
filtered-items="[[__effectiveFilteredItems]]"
|
|
@@ -195,7 +198,13 @@ class MultiSelectComboBox extends ResizeMixin(InputControlMixin(ThemableMixin(El
|
|
|
195
198
|
></vaadin-multi-select-combo-box-chip>
|
|
196
199
|
<div id="chips" part="chips" slot="prefix"></div>
|
|
197
200
|
<slot name="input"></slot>
|
|
198
|
-
<div
|
|
201
|
+
<div
|
|
202
|
+
id="clearButton"
|
|
203
|
+
part="clear-button"
|
|
204
|
+
slot="suffix"
|
|
205
|
+
on-touchend="_onClearButtonTouchend"
|
|
206
|
+
aria-hidden="true"
|
|
207
|
+
></div>
|
|
199
208
|
<div id="toggleButton" class="toggle-button" part="toggle-button" slot="suffix" aria-hidden="true"></div>
|
|
200
209
|
</vaadin-multi-select-combo-box-container>
|
|
201
210
|
</vaadin-multi-select-combo-box-internal>
|
|
@@ -423,6 +432,11 @@ class MultiSelectComboBox extends ResizeMixin(InputControlMixin(ThemableMixin(El
|
|
|
423
432
|
*/
|
|
424
433
|
filteredItems: Array,
|
|
425
434
|
|
|
435
|
+
/** @private */
|
|
436
|
+
value: {
|
|
437
|
+
type: String,
|
|
438
|
+
},
|
|
439
|
+
|
|
426
440
|
/** @private */
|
|
427
441
|
__effectiveItems: {
|
|
428
442
|
type: Array,
|
|
@@ -435,12 +449,6 @@ class MultiSelectComboBox extends ResizeMixin(InputControlMixin(ThemableMixin(El
|
|
|
435
449
|
computed: '__computeEffectiveFilteredItems(items, filteredItems, selectedItems, readonly)',
|
|
436
450
|
},
|
|
437
451
|
|
|
438
|
-
/** @protected */
|
|
439
|
-
_hasValue: {
|
|
440
|
-
type: Boolean,
|
|
441
|
-
value: false,
|
|
442
|
-
},
|
|
443
|
-
|
|
444
452
|
/** @private */
|
|
445
453
|
_overflowItems: {
|
|
446
454
|
type: Array,
|
|
@@ -453,6 +461,11 @@ class MultiSelectComboBox extends ResizeMixin(InputControlMixin(ThemableMixin(El
|
|
|
453
461
|
value: -1,
|
|
454
462
|
observer: '_focusedChipIndexChanged',
|
|
455
463
|
},
|
|
464
|
+
|
|
465
|
+
/** @private */
|
|
466
|
+
_lastFilter: {
|
|
467
|
+
type: String,
|
|
468
|
+
},
|
|
456
469
|
};
|
|
457
470
|
}
|
|
458
471
|
|
|
@@ -502,6 +515,15 @@ class MultiSelectComboBox extends ResizeMixin(InputControlMixin(ThemableMixin(El
|
|
|
502
515
|
return this.required && !this.readonly ? this._hasValue : true;
|
|
503
516
|
}
|
|
504
517
|
|
|
518
|
+
/**
|
|
519
|
+
* Clears the selected items.
|
|
520
|
+
*/
|
|
521
|
+
clear() {
|
|
522
|
+
this.__updateSelection([]);
|
|
523
|
+
|
|
524
|
+
announce(this.i18n.cleared);
|
|
525
|
+
}
|
|
526
|
+
|
|
505
527
|
/**
|
|
506
528
|
* Clears the cached pages and reloads data from data provider when needed.
|
|
507
529
|
*/
|
|
@@ -561,21 +583,6 @@ class MultiSelectComboBox extends ResizeMixin(InputControlMixin(ThemableMixin(El
|
|
|
561
583
|
this._focusedChipIndex = -1;
|
|
562
584
|
this.validate();
|
|
563
585
|
}
|
|
564
|
-
|
|
565
|
-
// Propagate focused attribute to internal combo box
|
|
566
|
-
if (this.$ && this.$.comboBox) {
|
|
567
|
-
this.$.comboBox.toggleAttribute('focused', focused);
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
/**
|
|
572
|
-
* Override method inherited from `InputMixin`
|
|
573
|
-
* to keep attribute after clearing the input.
|
|
574
|
-
* @protected
|
|
575
|
-
* @override
|
|
576
|
-
*/
|
|
577
|
-
_toggleHasValue() {
|
|
578
|
-
super._toggleHasValue(this._hasValue);
|
|
579
586
|
}
|
|
580
587
|
|
|
581
588
|
/**
|
|
@@ -664,9 +671,7 @@ class MultiSelectComboBox extends ResizeMixin(InputControlMixin(ThemableMixin(El
|
|
|
664
671
|
|
|
665
672
|
/** @private */
|
|
666
673
|
_selectedItemsChanged(selectedItems) {
|
|
667
|
-
this.
|
|
668
|
-
|
|
669
|
-
this._toggleHasValue();
|
|
674
|
+
this._toggleHasValue(this._hasValue);
|
|
670
675
|
|
|
671
676
|
// Use placeholder for announcing items
|
|
672
677
|
if (this._hasValue) {
|
|
@@ -755,7 +760,8 @@ class MultiSelectComboBox extends ResizeMixin(InputControlMixin(ThemableMixin(El
|
|
|
755
760
|
const itemsCopy = [...this.selectedItems];
|
|
756
761
|
itemsCopy.splice(itemsCopy.indexOf(item), 1);
|
|
757
762
|
this.__updateSelection(itemsCopy);
|
|
758
|
-
this.
|
|
763
|
+
const itemLabel = this._getItemLabel(item);
|
|
764
|
+
this.__announceItem(itemLabel, false, itemsCopy.length);
|
|
759
765
|
}
|
|
760
766
|
|
|
761
767
|
/** @private */
|
|
@@ -768,8 +774,9 @@ class MultiSelectComboBox extends ResizeMixin(InputControlMixin(ThemableMixin(El
|
|
|
768
774
|
let isSelected = false;
|
|
769
775
|
|
|
770
776
|
if (index !== -1) {
|
|
777
|
+
const lastFilter = this._lastFilter;
|
|
771
778
|
// Do not unselect when manually typing and committing an already selected item.
|
|
772
|
-
if (
|
|
779
|
+
if (lastFilter && lastFilter.toLowerCase() === itemLabel.toLowerCase()) {
|
|
773
780
|
this.__clearFilter();
|
|
774
781
|
return;
|
|
775
782
|
}
|
|
@@ -877,6 +884,14 @@ class MultiSelectComboBox extends ResizeMixin(InputControlMixin(ThemableMixin(El
|
|
|
877
884
|
this._overflowItems = items;
|
|
878
885
|
}
|
|
879
886
|
|
|
887
|
+
/** @private */
|
|
888
|
+
_onClearButtonTouchend(event) {
|
|
889
|
+
// Cancel the following click and focus events
|
|
890
|
+
event.preventDefault();
|
|
891
|
+
|
|
892
|
+
this.clear();
|
|
893
|
+
}
|
|
894
|
+
|
|
880
895
|
/**
|
|
881
896
|
* Override method inherited from `InputControlMixin` and clear items.
|
|
882
897
|
* @protected
|
|
@@ -885,9 +900,7 @@ class MultiSelectComboBox extends ResizeMixin(InputControlMixin(ThemableMixin(El
|
|
|
885
900
|
_onClearButtonClick(event) {
|
|
886
901
|
event.stopPropagation();
|
|
887
902
|
|
|
888
|
-
this.
|
|
889
|
-
|
|
890
|
-
announce(this.i18n.cleared);
|
|
903
|
+
this.clear();
|
|
891
904
|
}
|
|
892
905
|
|
|
893
906
|
/**
|
|
@@ -1092,6 +1105,17 @@ class MultiSelectComboBox extends ResizeMixin(InputControlMixin(ThemableMixin(El
|
|
|
1092
1105
|
__computeEffectiveFilteredItems(items, filteredItems, selectedItems, readonly) {
|
|
1093
1106
|
return !items && readonly ? selectedItems : filteredItems;
|
|
1094
1107
|
}
|
|
1108
|
+
|
|
1109
|
+
/**
|
|
1110
|
+
* Override a method from `InputMixin` to
|
|
1111
|
+
* compute the presence of value based on `selectedItems`.
|
|
1112
|
+
*
|
|
1113
|
+
* @protected
|
|
1114
|
+
* @override
|
|
1115
|
+
*/
|
|
1116
|
+
get _hasValue() {
|
|
1117
|
+
return this.selectedItems && this.selectedItems.length > 0;
|
|
1118
|
+
}
|
|
1095
1119
|
}
|
|
1096
1120
|
|
|
1097
1121
|
customElements.define(MultiSelectComboBox.is, MultiSelectComboBox);
|