@vaadin/multi-select-combo-box 25.0.0-alpha8 → 25.0.0-beta1

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.
Files changed (28) hide show
  1. package/package.json +15 -18
  2. package/src/styles/vaadin-multi-select-combo-box-base-styles.js +1 -1
  3. package/src/styles/vaadin-multi-select-combo-box-chip-base-styles.js +23 -9
  4. package/src/vaadin-multi-select-combo-box-chip.js +1 -1
  5. package/src/vaadin-multi-select-combo-box-container.js +1 -0
  6. package/src/vaadin-multi-select-combo-box-item.js +1 -1
  7. package/src/vaadin-multi-select-combo-box-mixin.d.ts +18 -89
  8. package/src/vaadin-multi-select-combo-box-mixin.js +426 -307
  9. package/src/vaadin-multi-select-combo-box-overlay.js +2 -2
  10. package/src/vaadin-multi-select-combo-box-scroller.js +1 -1
  11. package/src/vaadin-multi-select-combo-box.d.ts +13 -6
  12. package/src/vaadin-multi-select-combo-box.js +37 -88
  13. package/vaadin-multi-select-combo-box.js +1 -1
  14. package/web-types.json +205 -230
  15. package/web-types.lit.json +78 -78
  16. package/src/styles/vaadin-multi-select-combo-box-chip-core-styles.js +0 -33
  17. package/src/styles/vaadin-multi-select-combo-box-core-styles.d.ts +0 -8
  18. package/src/styles/vaadin-multi-select-combo-box-core-styles.js +0 -47
  19. package/src/styles/vaadin-multi-select-combo-box-overlay-core-styles.js +0 -21
  20. package/src/styles/vaadin-multi-select-combo-box-scroller-core-styles.js +0 -27
  21. package/src/vaadin-multi-select-combo-box-internal-mixin.js +0 -446
  22. package/src/vaadin-multi-select-combo-box-internal.js +0 -57
  23. package/theme/lumo/vaadin-multi-select-combo-box-chip-styles.d.ts +0 -10
  24. package/theme/lumo/vaadin-multi-select-combo-box-chip-styles.js +0 -107
  25. package/theme/lumo/vaadin-multi-select-combo-box-styles.d.ts +0 -10
  26. package/theme/lumo/vaadin-multi-select-combo-box-styles.js +0 -121
  27. package/theme/lumo/vaadin-multi-select-combo-box.d.ts +0 -8
  28. package/theme/lumo/vaadin-multi-select-combo-box.js +0 -8
@@ -1,446 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright (c) 2021 - 2025 Vaadin Ltd.
4
- * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
- */
6
- import { ComboBoxDataProviderMixin } from '@vaadin/combo-box/src/vaadin-combo-box-data-provider-mixin.js';
7
- import { ComboBoxMixin } from '@vaadin/combo-box/src/vaadin-combo-box-mixin.js';
8
- import { ComboBoxPlaceholder } from '@vaadin/combo-box/src/vaadin-combo-box-placeholder.js';
9
-
10
- /**
11
- * @polymerMixin
12
- * @mixes ComboBoxDataProviderMixin
13
- * @mixes ComboBoxMixin
14
- */
15
- export const MultiSelectComboBoxInternalMixin = (superClass) =>
16
- class MultiSelectComboBoxInternalMixinClass extends ComboBoxDataProviderMixin(ComboBoxMixin(superClass)) {
17
- static get properties() {
18
- return {
19
- /**
20
- * A subset of items, filtered based on the user input.
21
- */
22
- filteredItems: {
23
- type: Array,
24
- notify: true,
25
- sync: true,
26
- },
27
-
28
- /**
29
- * When true, filter string isn't cleared after selecting an item.
30
- */
31
- keepFilter: {
32
- type: Boolean,
33
- value: false,
34
- },
35
-
36
- /**
37
- * When set to `true`, "loading" attribute is set
38
- * on the host and the overlay element.
39
- * @type {boolean}
40
- */
41
- loading: {
42
- type: Boolean,
43
- notify: true,
44
- sync: true,
45
- },
46
-
47
- /**
48
- * Total number of items.
49
- * @type {number | undefined}
50
- */
51
- size: {
52
- type: Number,
53
- notify: true,
54
- observer: '_sizeChanged',
55
- sync: true,
56
- },
57
-
58
- /**
59
- * Selected items to render in the dropdown
60
- * when the component is read-only.
61
- */
62
- selectedItems: {
63
- type: Array,
64
- value: () => [],
65
- },
66
-
67
- /**
68
- * Set to true to group selected items at the top of the overlay.
69
- * @attr {boolean} selected-items-on-top
70
- */
71
- selectedItemsOnTop: {
72
- type: Boolean,
73
- value: false,
74
- sync: true,
75
- },
76
-
77
- /**
78
- * Last input value entered by the user before value is updated.
79
- * Used to store `filter` property value before clearing it.
80
- */
81
- lastFilter: {
82
- type: String,
83
- notify: true,
84
- sync: true,
85
- },
86
-
87
- /**
88
- * A subset of items to be shown at the top of the overlay.
89
- */
90
- topGroup: {
91
- type: Array,
92
- observer: '_topGroupChanged',
93
- sync: true,
94
- },
95
-
96
- owner: {
97
- type: Object,
98
- },
99
-
100
- _target: {
101
- type: Object,
102
- },
103
- };
104
- }
105
-
106
- static get observers() {
107
- return ['_readonlyChanged(readonly)'];
108
- }
109
-
110
- /**
111
- * Reference to the clear button element.
112
- * @protected
113
- * @return {!HTMLElement}
114
- */
115
- get clearElement() {
116
- return this.querySelector('[part="clear-button"]');
117
- }
118
-
119
- /**
120
- * Tag name prefix used by scroller and items.
121
- * @protected
122
- * @return {string}
123
- */
124
- get _tagNamePrefix() {
125
- return 'vaadin-multi-select-combo-box';
126
- }
127
-
128
- constructor() {
129
- super();
130
-
131
- this.addEventListener('custom-value-set', this.__onCustomValueSet.bind(this));
132
- }
133
-
134
- /**
135
- * Override method inherited from the combo-box
136
- * to allow opening dropdown when readonly.
137
- * @override
138
- */
139
- open() {
140
- if (!this.disabled && !(this.readonly && this.selectedItems.length === 0)) {
141
- this.opened = true;
142
- }
143
- }
144
-
145
- /** @protected */
146
- ready() {
147
- super.ready();
148
-
149
- this._target = this;
150
- this._toggleElement = this.querySelector('.toggle-button');
151
- }
152
-
153
- /** @protected */
154
- _updateOverlayWidth() {
155
- this.$.overlay._updateOverlayWidth();
156
- }
157
-
158
- /** @private */
159
- _readonlyChanged() {
160
- this._setDropdownItems(this.filteredItems);
161
- }
162
-
163
- /**
164
- * Override combo-box method to group selected
165
- * items at the top of the overlay.
166
- *
167
- * @protected
168
- * @override
169
- */
170
- _setDropdownItems(items) {
171
- if (this.readonly) {
172
- super._setDropdownItems(this.selectedItems);
173
- return;
174
- }
175
-
176
- if (this.filter || !this.selectedItemsOnTop) {
177
- super._setDropdownItems(items);
178
- return;
179
- }
180
-
181
- if (items && items.length && this.topGroup && this.topGroup.length) {
182
- // Filter out items included to the top group.
183
- const filteredItems = items.filter(
184
- (item) => this.owner._findIndex(item, this.topGroup, this.itemIdPath) === -1,
185
- );
186
-
187
- super._setDropdownItems(this.topGroup.concat(filteredItems));
188
- return;
189
- }
190
-
191
- super._setDropdownItems(items);
192
- }
193
-
194
- /** @private */
195
- _topGroupChanged(topGroup) {
196
- if (topGroup) {
197
- this._setDropdownItems(this.filteredItems);
198
- }
199
- }
200
-
201
- /**
202
- * Override combo-box method to set correct owner for using by item renderers.
203
- * @protected
204
- * @override
205
- */
206
- _initScroller() {
207
- super._initScroller(this.owner);
208
- }
209
-
210
- /**
211
- * Override Enter handler to keep overlay open
212
- * when item is selected or unselected.
213
- * @param {!Event} event
214
- * @protected
215
- * @override
216
- */
217
- _onEnter(event) {
218
- if (this.opened) {
219
- // Do not submit the surrounding form.
220
- event.preventDefault();
221
- // Do not trigger global listeners.
222
- event.stopPropagation();
223
-
224
- if (this.readonly) {
225
- this.close();
226
- } else if (this._hasValidInputValue()) {
227
- // Keep selected item focused after committing on Enter.
228
- const focusedItem = this._dropdownItems[this._focusedIndex];
229
- this._commitValue();
230
- this._focusedIndex = this._dropdownItems.indexOf(focusedItem);
231
- }
232
-
233
- return;
234
- }
235
-
236
- super._onEnter(event);
237
- }
238
-
239
- /**
240
- * Override Escape handler to not clear
241
- * selected items when readonly.
242
- * @param {!Event} event
243
- * @protected
244
- * @override
245
- */
246
- _onEscape(event) {
247
- if (this.readonly) {
248
- event.stopPropagation();
249
- if (this.opened) {
250
- this.close();
251
- }
252
- return;
253
- }
254
-
255
- super._onEscape(event);
256
- }
257
-
258
- /**
259
- * Override from combo-box to ignore requests to clear the filter if the
260
- * keepFilter option is enabled. Exceptions are when the dropdown is closed,
261
- * so the filter is still cleared on cancel and focus out.
262
- * @protected
263
- * @override
264
- */
265
- _clearFilter() {
266
- if (!this.keepFilter || !this.opened) {
267
- super._clearFilter();
268
- }
269
- }
270
-
271
- /**
272
- * Override method from combo-box to always clear the filter when reverting
273
- * the input value, regardless of the keepFilter option.
274
- * @override
275
- * @protected
276
- */
277
- _revertInputValueToValue() {
278
- super._revertInputValueToValue();
279
- this.filter = '';
280
- }
281
-
282
- /**
283
- * @protected
284
- * @override
285
- */
286
- _commitValue() {
287
- // Store filter value for checking if user input is matching
288
- // an item which is already selected, to not un-select it.
289
- this.lastFilter = this.filter;
290
-
291
- super._commitValue();
292
- }
293
-
294
- /**
295
- * Override method inherited from the combo-box
296
- * to not update focused item when readonly.
297
- * @protected
298
- * @override
299
- */
300
- _onArrowDown() {
301
- if (!this.readonly) {
302
- super._onArrowDown();
303
- } else if (!this.opened) {
304
- this.open();
305
- }
306
- }
307
-
308
- /**
309
- * Override method inherited from the combo-box
310
- * to not update focused item when readonly.
311
- * @protected
312
- * @override
313
- */
314
- _onArrowUp() {
315
- if (!this.readonly) {
316
- super._onArrowUp();
317
- } else if (!this.opened) {
318
- this.open();
319
- }
320
- }
321
-
322
- /**
323
- * Override method inherited from the combo-box
324
- * to close dropdown on blur when readonly.
325
- * @param {boolean} focused
326
- * @protected
327
- * @override
328
- */
329
- _setFocused(focused) {
330
- // Disable combo-box logic that updates selectedItem
331
- // based on the overlay focused index on input blur
332
- if (!focused) {
333
- this._ignoreCommitValue = true;
334
- }
335
-
336
- super._setFocused(focused);
337
-
338
- if (!focused && this.readonly && !this._closeOnBlurIsPrevented) {
339
- this.close();
340
- }
341
- }
342
-
343
- /**
344
- * Override method inherited from the combo-box
345
- * to not commit an already selected item again
346
- * after closing overlay on outside click.
347
- * @protected
348
- * @override
349
- */
350
- _onClosed() {
351
- this._ignoreCommitValue = true;
352
-
353
- super._onClosed();
354
- }
355
-
356
- /**
357
- * Override method inherited from the combo-box
358
- * to not commit an already selected item again
359
- * on blur, which would result in un-selecting.
360
- * @protected
361
- * @override
362
- */
363
- _detectAndDispatchChange() {
364
- if (this._ignoreCommitValue) {
365
- this._ignoreCommitValue = false;
366
-
367
- // Reset internal combo-box state
368
- this.clear();
369
- this._inputElementValue = '';
370
- return;
371
- }
372
-
373
- super._detectAndDispatchChange();
374
- }
375
-
376
- /**
377
- * @param {CustomEvent} event
378
- * @protected
379
- * @override
380
- */
381
- _overlaySelectedItemChanged(event) {
382
- event.stopPropagation();
383
-
384
- // Do not un-select on click when readonly
385
- if (this.readonly) {
386
- return;
387
- }
388
-
389
- if (event.detail.item instanceof ComboBoxPlaceholder) {
390
- return;
391
- }
392
-
393
- if (this.opened) {
394
- // Store filter value for checking if user input is matching
395
- // an item which is already selected, to not un-select it.
396
- this.lastFilter = this.filter;
397
-
398
- this.dispatchEvent(
399
- new CustomEvent('combo-box-item-selected', {
400
- detail: {
401
- item: event.detail.item,
402
- },
403
- }),
404
- );
405
- }
406
- }
407
-
408
- /**
409
- * Override method inherited from the combo-box
410
- * to not request data provider when read-only.
411
- *
412
- * @protected
413
- * @override
414
- */
415
- _shouldFetchData() {
416
- if (this.readonly) {
417
- return false;
418
- }
419
-
420
- return super._shouldFetchData();
421
- }
422
-
423
- /**
424
- * Override method inherited from the combo-box
425
- * to not clear the data provider cache when read-only.
426
- *
427
- * @protected
428
- * @override
429
- */
430
- clearCache() {
431
- if (this.readonly) {
432
- return;
433
- }
434
-
435
- super.clearCache();
436
- }
437
-
438
- /** @private */
439
- __onCustomValueSet(event) {
440
- // Prevent setting custom value on input blur or outside click,
441
- // so it can be only committed explicitly by pressing Enter.
442
- if (this._ignoreCommitValue) {
443
- event.stopImmediatePropagation();
444
- }
445
- }
446
- };
@@ -1,57 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright (c) 2021 - 2025 Vaadin Ltd.
4
- * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
- */
6
- import './vaadin-multi-select-combo-box-item.js';
7
- import './vaadin-multi-select-combo-box-overlay.js';
8
- import './vaadin-multi-select-combo-box-scroller.js';
9
- import { css, html, LitElement } from 'lit';
10
- import { ifDefined } from 'lit/directives/if-defined.js';
11
- import { defineCustomElement } from '@vaadin/component-base/src/define.js';
12
- import { PolylitMixin } from '@vaadin/component-base/src/polylit-mixin.js';
13
- import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
14
- import { MultiSelectComboBoxInternalMixin } from './vaadin-multi-select-combo-box-internal-mixin.js';
15
-
16
- /**
17
- * An element used internally by `<vaadin-multi-select-combo-box>`. Not intended to be used separately.
18
- *
19
- * @customElement
20
- * @extends HTMLElement
21
- * @mixes MultiSelectComboBoxInternalMixin
22
- * @mixes ThemableMixin
23
- * @private
24
- */
25
- class MultiSelectComboBoxInternal extends MultiSelectComboBoxInternalMixin(ThemableMixin(PolylitMixin(LitElement))) {
26
- static get is() {
27
- return 'vaadin-multi-select-combo-box-internal';
28
- }
29
-
30
- static get styles() {
31
- return css`
32
- :host([opened]) {
33
- pointer-events: auto;
34
- }
35
- `;
36
- }
37
-
38
- /** @protected */
39
- render() {
40
- return html`
41
- <slot></slot>
42
-
43
- <vaadin-multi-select-combo-box-overlay
44
- id="overlay"
45
- .owner="${this.owner}"
46
- .opened="${this._overlayOpened}"
47
- ?loading="${this.loading}"
48
- theme="${ifDefined(this._theme)}"
49
- .positionTarget="${this._target}"
50
- no-vertical-overlap
51
- .restoreFocusNode="${this.inputElement}"
52
- ></vaadin-multi-select-combo-box-overlay>
53
- `;
54
- }
55
- }
56
-
57
- defineCustomElement(MultiSelectComboBoxInternal);
@@ -1,10 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright (c) 2021 - 2025 Vaadin Ltd.
4
- * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
- */
6
- import '@vaadin/vaadin-lumo-styles/color.js';
7
- import '@vaadin/vaadin-lumo-styles/font-icons.js';
8
- import '@vaadin/vaadin-lumo-styles/spacing.js';
9
- import '@vaadin/vaadin-lumo-styles/style.js';
10
- import '@vaadin/vaadin-lumo-styles/typography.js';
@@ -1,107 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright (c) 2021 - 2025 Vaadin Ltd.
4
- * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
- */
6
- import '@vaadin/vaadin-lumo-styles/color.js';
7
- import '@vaadin/vaadin-lumo-styles/font-icons.js';
8
- import '@vaadin/vaadin-lumo-styles/spacing.js';
9
- import '@vaadin/vaadin-lumo-styles/style.js';
10
- import '@vaadin/vaadin-lumo-styles/typography.js';
11
- import { fieldButton } from '@vaadin/vaadin-lumo-styles/mixins/field-button.js';
12
- import { css, registerStyles } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
13
-
14
- const chip = css`
15
- :host {
16
- font-size: var(--lumo-font-size-xxs);
17
- line-height: 1;
18
- color: var(--lumo-body-text-color);
19
- border-radius: var(--lumo-border-radius-s);
20
- background-color: var(--lumo-contrast-20pct);
21
- cursor: var(--lumo-clickable-cursor);
22
- -webkit-font-smoothing: antialiased;
23
- -moz-osx-font-smoothing: grayscale;
24
- }
25
-
26
- :host([disabled]) {
27
- background-color: var(--lumo-contrast-10pct);
28
- }
29
-
30
- :host([focused]) [part='remove-button'] {
31
- color: inherit;
32
- }
33
-
34
- :host([slot='overflow']) {
35
- position: relative;
36
- min-width: var(--lumo-size-xxs);
37
- margin-inline-start: var(--lumo-space-s);
38
- }
39
-
40
- :host([slot='overflow'])::before,
41
- :host([slot='overflow'])::after {
42
- position: absolute;
43
- content: '';
44
- width: 100%;
45
- height: 100%;
46
- border-left: calc(var(--lumo-space-s) / 4) solid;
47
- border-radius: var(--lumo-border-radius-s);
48
- border-color: var(--lumo-contrast-30pct);
49
- }
50
-
51
- :host([slot='overflow'])::before {
52
- left: calc(-1 * var(--lumo-space-s) / 2);
53
- }
54
-
55
- :host([slot='overflow'])::after {
56
- left: calc(-1 * var(--lumo-space-s));
57
- }
58
-
59
- :host([count='2']) {
60
- margin-inline-start: calc(var(--lumo-space-s) / 2);
61
- }
62
-
63
- :host([count='2'])::after {
64
- display: none;
65
- }
66
-
67
- :host([count='1']) {
68
- margin-inline-start: 0;
69
- }
70
-
71
- :host([count='1'])::before,
72
- :host([count='1'])::after {
73
- display: none;
74
- }
75
-
76
- [part='label'] {
77
- font-weight: 500;
78
- line-height: 1.25;
79
- }
80
-
81
- [part='remove-button'] {
82
- display: flex;
83
- align-items: center;
84
- justify-content: center;
85
- margin-top: -0.3125em;
86
- margin-bottom: -0.3125em;
87
- margin-inline-start: auto;
88
- width: 1.25em;
89
- height: 1.25em;
90
- font-size: 1.5em;
91
- transition: none;
92
- }
93
-
94
- [part='remove-button']::before {
95
- content: var(--lumo-icons-cross);
96
- }
97
-
98
- :host([disabled]) [part='label'] {
99
- color: var(--lumo-disabled-text-color);
100
- -webkit-text-fill-color: var(--lumo-disabled-text-color);
101
- pointer-events: none;
102
- }
103
- `;
104
-
105
- registerStyles('vaadin-multi-select-combo-box-chip', [fieldButton, chip], {
106
- moduleId: 'lumo-multi-select-combo-box-chip',
107
- });
@@ -1,10 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright (c) 2021 - 2025 Vaadin Ltd.
4
- * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
- */
6
- import '@vaadin/input-container/theme/lumo/vaadin-input-container-styles.js';
7
- import '@vaadin/vaadin-lumo-styles/color.js';
8
- import '@vaadin/vaadin-lumo-styles/font-icons.js';
9
- import '@vaadin/vaadin-lumo-styles/style.js';
10
- import '@vaadin/vaadin-lumo-styles/typography.js';