@vaadin/multi-select-combo-box 25.2.0-alpha1 → 25.2.0-alpha11

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/multi-select-combo-box",
3
- "version": "25.2.0-alpha1",
3
+ "version": "25.2.0-alpha11",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -37,23 +37,23 @@
37
37
  ],
38
38
  "dependencies": {
39
39
  "@open-wc/dedupe-mixin": "^1.3.0",
40
- "@vaadin/a11y-base": "25.2.0-alpha1",
41
- "@vaadin/combo-box": "25.2.0-alpha1",
42
- "@vaadin/component-base": "25.2.0-alpha1",
43
- "@vaadin/field-base": "25.2.0-alpha1",
44
- "@vaadin/input-container": "25.2.0-alpha1",
45
- "@vaadin/item": "25.2.0-alpha1",
46
- "@vaadin/lit-renderer": "25.2.0-alpha1",
47
- "@vaadin/overlay": "25.2.0-alpha1",
48
- "@vaadin/vaadin-themable-mixin": "25.2.0-alpha1",
40
+ "@vaadin/a11y-base": "25.2.0-alpha11",
41
+ "@vaadin/combo-box": "25.2.0-alpha11",
42
+ "@vaadin/component-base": "25.2.0-alpha11",
43
+ "@vaadin/field-base": "25.2.0-alpha11",
44
+ "@vaadin/input-container": "25.2.0-alpha11",
45
+ "@vaadin/item": "25.2.0-alpha11",
46
+ "@vaadin/lit-renderer": "25.2.0-alpha11",
47
+ "@vaadin/overlay": "25.2.0-alpha11",
48
+ "@vaadin/vaadin-themable-mixin": "25.2.0-alpha11",
49
49
  "lit": "^3.0.0"
50
50
  },
51
51
  "devDependencies": {
52
- "@vaadin/aura": "25.2.0-alpha1",
53
- "@vaadin/chai-plugins": "25.2.0-alpha1",
54
- "@vaadin/test-runner-commands": "25.2.0-alpha1",
52
+ "@vaadin/aura": "25.2.0-alpha11",
53
+ "@vaadin/chai-plugins": "25.2.0-alpha11",
54
+ "@vaadin/test-runner-commands": "25.2.0-alpha11",
55
55
  "@vaadin/testing-helpers": "^2.0.0",
56
- "@vaadin/vaadin-lumo-styles": "25.2.0-alpha1",
56
+ "@vaadin/vaadin-lumo-styles": "25.2.0-alpha11",
57
57
  "sinon": "^21.0.2"
58
58
  },
59
59
  "customElements": "custom-elements.json",
@@ -61,5 +61,5 @@
61
61
  "web-types.json",
62
62
  "web-types.lit.json"
63
63
  ],
64
- "gitHead": "866f813f89655a351cbd25328eba1fcb317e267d"
64
+ "gitHead": "fdc37e932709f95491a027aeb2090911cb7528c6"
65
65
  }
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2018 - 2026 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2026 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import type { ComboBoxDefaultItem, ComboBoxItemMixinClass } from '@vaadin/combo-box/src/vaadin-combo-box-item-mixin.js';
@@ -35,9 +35,6 @@ import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mix
35
35
  * See [Styling Components](https://vaadin.com/docs/latest/styling/styling-components) documentation.
36
36
  *
37
37
  * @customElement vaadin-multi-select-combo-box-item
38
- * @mixes ComboBoxItemMixin
39
- * @mixes ThemableMixin
40
- * @mixes DirMixin
41
38
  * @private
42
39
  */
43
40
  export class MultiSelectComboBoxItem extends ComboBoxItemMixin(
@@ -12,6 +12,7 @@ import type { ComboBoxItemModel } from '@vaadin/combo-box/src/vaadin-combo-box.j
12
12
  import type { ComboBoxBaseMixinClass } from '@vaadin/combo-box/src/vaadin-combo-box-base-mixin.js';
13
13
  import type { ComboBoxDataProviderMixinClass } from '@vaadin/combo-box/src/vaadin-combo-box-data-provider-mixin.js';
14
14
  import type { ComboBoxItemsMixinClass } from '@vaadin/combo-box/src/vaadin-combo-box-items-mixin.js';
15
+ import type { ComboBoxScrollToIndexMixinClass } from '@vaadin/combo-box/src/vaadin-combo-box-scroll-to-index-mixin.js';
15
16
  import type { DelegateStateMixinClass } from '@vaadin/component-base/src/delegate-state-mixin.js';
16
17
  import type { I18nMixinClass } from '@vaadin/component-base/src/i18n-mixin.js';
17
18
  import type { ResizeMixinClass } from '@vaadin/component-base/src/resize-mixin.js';
@@ -45,6 +46,7 @@ export declare function MultiSelectComboBoxMixin<TItem, T extends Constructor<HT
45
46
  Constructor<ComboBoxBaseMixinClass> &
46
47
  Constructor<ComboBoxDataProviderMixinClass<TItem>> &
47
48
  Constructor<ComboBoxItemsMixinClass<TItem>> &
49
+ Constructor<ComboBoxScrollToIndexMixinClass> &
48
50
  Constructor<DelegateFocusMixinClass> &
49
51
  Constructor<DelegateStateMixinClass> &
50
52
  Constructor<DisabledMixinClass> &
@@ -78,6 +80,14 @@ export declare class MultiSelectComboBoxMixinClass<TItem> {
78
80
  */
79
81
  autoExpandVertically: boolean;
80
82
 
83
+ /**
84
+ * Set to true to collapse all selected items chips into the overflow
85
+ * chip when they don't all fit, instead of showing as many as possible.
86
+ * Has no effect when `autoExpandVertically` is true.
87
+ * @attr {boolean} collapse-chips
88
+ */
89
+ collapseChips: boolean;
90
+
81
91
  /**
82
92
  * When true, the user can input a value that is not present in the items list.
83
93
  * @attr {boolean} allow-custom-value
@@ -7,6 +7,7 @@ import { announce } from '@vaadin/a11y-base/src/announce.js';
7
7
  import { ComboBoxDataProviderMixin } from '@vaadin/combo-box/src/vaadin-combo-box-data-provider-mixin.js';
8
8
  import { ComboBoxItemsMixin } from '@vaadin/combo-box/src/vaadin-combo-box-items-mixin.js';
9
9
  import { ComboBoxPlaceholder } from '@vaadin/combo-box/src/vaadin-combo-box-placeholder.js';
10
+ import { ComboBoxScrollToIndexMixin } from '@vaadin/combo-box/src/vaadin-combo-box-scroll-to-index-mixin.js';
10
11
  import { I18nMixin } from '@vaadin/component-base/src/i18n-mixin.js';
11
12
  import { ResizeMixin } from '@vaadin/component-base/src/resize-mixin.js';
12
13
  import { SlotController } from '@vaadin/component-base/src/slot-controller.js';
@@ -23,18 +24,11 @@ const DEFAULT_I18N = {
23
24
  total: '{count} items selected',
24
25
  };
25
26
 
26
- /**
27
- * @polymerMixin
28
- * @mixes ComboBoxDataProviderMixin
29
- * @mixes ComboBoxItemsMixin
30
- * @mixes I18nMixin
31
- * @mixes InputControlMixin
32
- * @mixes ResizeMixin
33
- */
34
27
  export const MultiSelectComboBoxMixin = (superClass) =>
35
28
  class MultiSelectComboBoxMixinClass extends I18nMixin(
36
- DEFAULT_I18N,
37
- ComboBoxDataProviderMixin(ComboBoxItemsMixin(InputControlMixin(ResizeMixin(superClass)))),
29
+ ComboBoxScrollToIndexMixin(
30
+ ComboBoxDataProviderMixin(ComboBoxItemsMixin(InputControlMixin(ResizeMixin(superClass)))),
31
+ ),
38
32
  ) {
39
33
  static get properties() {
40
34
  return {
@@ -63,6 +57,19 @@ export const MultiSelectComboBoxMixin = (superClass) =>
63
57
  sync: true,
64
58
  },
65
59
 
60
+ /**
61
+ * Set to true to collapse all selected items chips into the overflow
62
+ * chip when they don't all fit, instead of showing as many as possible.
63
+ * Has no effect when `autoExpandVertically` is true.
64
+ * @attr {boolean} collapse-chips
65
+ */
66
+ collapseChips: {
67
+ type: Boolean,
68
+ value: false,
69
+ reflectToAttribute: true,
70
+ sync: true,
71
+ },
72
+
66
73
  /**
67
74
  * A function used to generate CSS class names for dropdown
68
75
  * items and selected chips based on the item. The return
@@ -218,6 +225,10 @@ export const MultiSelectComboBoxMixin = (superClass) =>
218
225
  ];
219
226
  }
220
227
 
228
+ static get defaultI18n() {
229
+ return DEFAULT_I18N;
230
+ }
231
+
221
232
  /**
222
233
  * The object used to localize this component. To change the default
223
234
  * localization, replace this with an object that provides all properties, or
@@ -346,6 +357,7 @@ export const MultiSelectComboBoxMixin = (superClass) =>
346
357
  const chipProps = [
347
358
  'autoExpandHorizontally',
348
359
  'autoExpandVertically',
360
+ 'collapseChips',
349
361
  'disabled',
350
362
  'readonly',
351
363
  'clearButtonVisible',
@@ -483,7 +495,7 @@ export const MultiSelectComboBoxMixin = (superClass) =>
483
495
  __openedOrItemsChanged(opened, items, loading, keepOverlayOpened) {
484
496
  // Close the overlay if there are no items to display.
485
497
  // See https://github.com/vaadin/vaadin-combo-box/pull/964
486
- this._overlayOpened = opened && (keepOverlayOpened || loading || !!(items && items.length));
498
+ this._overlayOpened = opened && (keepOverlayOpened || loading || !!items?.length);
487
499
  }
488
500
 
489
501
  /**
@@ -696,7 +708,7 @@ export const MultiSelectComboBoxMixin = (superClass) =>
696
708
  return;
697
709
  }
698
710
 
699
- if (items && items.length && this._topGroup && this._topGroup.length) {
711
+ if (items?.length && this._topGroup?.length) {
700
712
  // Filter out items included to the top group.
701
713
  const filteredItems = items.filter((item) => this._findIndex(item, this._topGroup, this.itemIdPath) === -1);
702
714
 
@@ -797,7 +809,7 @@ export const MultiSelectComboBoxMixin = (superClass) =>
797
809
  if (index !== -1) {
798
810
  const lastFilter = this._lastFilter;
799
811
  // Do not unselect when manually typing and committing an already selected item.
800
- if (lastFilter && lastFilter.toLowerCase() === itemLabel.toLowerCase()) {
812
+ if (lastFilter?.toLowerCase() === itemLabel.toLowerCase()) {
801
813
  this.__clearInternalValue();
802
814
  return;
803
815
  }
@@ -926,7 +938,9 @@ export const MultiSelectComboBoxMixin = (superClass) =>
926
938
 
927
939
  const inputWidth = parseInt(getComputedStyle(this.inputElement).flexBasis);
928
940
 
929
- if (this.autoExpandHorizontally) {
941
+ if (this.collapseChips) {
942
+ this._overflowItems = this.__updateChipsCollapsed(this.selectedItems, inputWidth);
943
+ } else if (this.autoExpandHorizontally) {
930
944
  this._overflowItems = this.__updateChipsHorizontalExpand(this.selectedItems, inputWidth);
931
945
  } else {
932
946
  this._overflowItems = this.__updateChipsDefault(this.selectedItems, inputWidth);
@@ -934,15 +948,35 @@ export const MultiSelectComboBoxMixin = (superClass) =>
934
948
  }
935
949
 
936
950
  /** @private */
937
- __updateChipsHorizontalExpand(items, inputWidth) {
938
- // Add all chips to make the field fully expand
951
+ __renderAllChips(items, inputWidth) {
939
952
  const chips = items.map((item) => {
940
953
  const chip = this.__createChip(item);
941
954
  this.appendChild(chip);
942
955
  return chip;
943
956
  });
944
957
 
945
- if (this.__getWrapperWidth() - this.$.chips.clientWidth >= inputWidth) {
958
+ const allChipsFit = this.__getWrapperWidth() - this.$.chips.clientWidth >= inputWidth;
959
+ return { chips, allChipsFit };
960
+ }
961
+
962
+ /** @private */
963
+ __updateChipsCollapsed(items, inputWidth) {
964
+ const { chips, allChipsFit } = this.__renderAllChips(items, inputWidth);
965
+
966
+ if (allChipsFit) {
967
+ return [];
968
+ }
969
+
970
+ // Not enough space: remove all chips, collapse everything to overflow
971
+ chips.forEach((chip) => chip.remove());
972
+ return items.slice();
973
+ }
974
+
975
+ /** @private */
976
+ __updateChipsHorizontalExpand(items, inputWidth) {
977
+ const { chips, allChipsFit } = this.__renderAllChips(items, inputWidth);
978
+
979
+ if (allChipsFit) {
946
980
  return [];
947
981
  }
948
982
 
@@ -1298,10 +1332,4 @@ export const MultiSelectComboBoxMixin = (superClass) =>
1298
1332
  // and keep the overlay opened when clicking a chip.
1299
1333
  event.preventDefault();
1300
1334
  }
1301
-
1302
- /**
1303
- * Fired when the user sets a custom value.
1304
- * @event custom-value-set
1305
- * @param {string} detail the custom value
1306
- */
1307
1335
  };
@@ -19,10 +19,6 @@ import { multiSelectComboBoxOverlayStyles } from './styles/vaadin-multi-select-c
19
19
  *
20
20
  * @customElement vaadin-multi-select-combo-box-overlay
21
21
  * @extends HTMLElement
22
- * @mixes ComboBoxOverlayMixin
23
- * @mixes DirMixin
24
- * @mixes OverlayMixin
25
- * @mixes ThemableMixin
26
22
  * @private
27
23
  */
28
24
  class MultiSelectComboBoxOverlay extends ComboBoxOverlayMixin(
@@ -15,7 +15,6 @@ import { multiSelectComboBoxScrollerStyles } from './styles/vaadin-multi-select-
15
15
  *
16
16
  * @customElement vaadin-multi-select-combo-box-scroller
17
17
  * @extends HTMLElement
18
- * @mixes ComboBoxScrollerMixin
19
18
  * @private
20
19
  */
21
20
  export class MultiSelectComboBoxScroller extends ComboBoxScrollerMixin(PolylitMixin(LitElement)) {
@@ -98,9 +98,6 @@ import { MultiSelectComboBoxMixin } from './vaadin-multi-select-combo-box-mixin.
98
98
  *
99
99
  * @customElement vaadin-multi-select-combo-box
100
100
  * @extends HTMLElement
101
- * @mixes ElementMixin
102
- * @mixes ThemableMixin
103
- * @mixes MultiSelectComboBoxMixin
104
101
  */
105
102
  class MultiSelectComboBox extends MultiSelectComboBoxMixin(
106
103
  ThemableMixin(ElementMixin(PolylitMixin(LumoInjectionMixin(LitElement)))),