@vaadin/multi-select-combo-box 25.1.0-beta2 → 25.1.0-beta4

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.
@@ -246,10 +246,12 @@
246
246
  {
247
247
  "kind": "field",
248
248
  "name": "i18n",
249
- "description": "The object used to localize this component. To change the default\nlocalization, replace this with an object that provides all properties, or\njust the individual properties you want to change.\n\nThe object has the following JSON structure and default values:\n```js\n{\n // Screen reader announcement on clear button click.\n cleared: 'Selection cleared',\n // Screen reader announcement when a chip is focused.\n focused: ' focused. Press Backspace to remove',\n // Screen reader announcement when item is selected.\n selected: 'added to selection',\n // Screen reader announcement when item is deselected.\n deselected: 'removed from selection',\n // Screen reader announcement of the selected items count.\n // {count} is replaced with the actual count of items.\n total: '{count} items selected',\n}\n```",
249
+ "privacy": "public",
250
250
  "type": {
251
251
  "text": "Object"
252
252
  },
253
+ "description": "The object used to localize this component. To change the default\nlocalization, replace this with an object that provides all properties, or\njust the individual properties you want to change.\n\nThe object has the following JSON structure and default values:\n```js\n{\n // Screen reader announcement on clear button click.\n cleared: 'Selection cleared',\n // Screen reader announcement when a chip is focused.\n focused: ' focused. Press Backspace to remove',\n // Screen reader announcement when item is selected.\n selected: 'added to selection',\n // Screen reader announcement when item is deselected.\n deselected: 'removed from selection',\n // Screen reader announcement of the selected items count.\n // {count} is replaced with the actual count of items.\n total: '{count} items selected',\n}\n```",
254
+ "attribute": "i18n",
253
255
  "inheritedFrom": {
254
256
  "name": "I18nMixin",
255
257
  "package": "@vaadin/component-base/src/i18n-mixin.js"
@@ -669,6 +671,11 @@
669
671
  },
670
672
  {
671
673
  "name": "i18n",
674
+ "type": {
675
+ "text": "Object"
676
+ },
677
+ "description": "The object used to localize this component. To change the default\nlocalization, replace this with an object that provides all properties, or\njust the individual properties you want to change.\n\nShould be overridden by subclasses to provide a custom JSDoc with the\ndefault I18N properties.",
678
+ "fieldName": "i18n",
672
679
  "inheritedFrom": {
673
680
  "name": "I18nMixin",
674
681
  "package": "@vaadin/component-base/src/i18n-mixin.js"
@@ -1039,10 +1046,12 @@
1039
1046
  {
1040
1047
  "kind": "field",
1041
1048
  "name": "i18n",
1042
- "description": "The object used to localize this component. To change the default\nlocalization, replace this with an object that provides all properties, or\njust the individual properties you want to change.\n\nThe object has the following JSON structure and default values:\n```js\n{\n // Screen reader announcement on clear button click.\n cleared: 'Selection cleared',\n // Screen reader announcement when a chip is focused.\n focused: ' focused. Press Backspace to remove',\n // Screen reader announcement when item is selected.\n selected: 'added to selection',\n // Screen reader announcement when item is deselected.\n deselected: 'removed from selection',\n // Screen reader announcement of the selected items count.\n // {count} is replaced with the actual count of items.\n total: '{count} items selected',\n}\n```",
1049
+ "privacy": "public",
1043
1050
  "type": {
1044
1051
  "text": "Object"
1045
1052
  },
1053
+ "description": "The object used to localize this component. To change the default\nlocalization, replace this with an object that provides all properties, or\njust the individual properties you want to change.\n\nThe object has the following JSON structure and default values:\n```js\n{\n // Screen reader announcement on clear button click.\n cleared: 'Selection cleared',\n // Screen reader announcement when a chip is focused.\n focused: ' focused. Press Backspace to remove',\n // Screen reader announcement when item is selected.\n selected: 'added to selection',\n // Screen reader announcement when item is deselected.\n deselected: 'removed from selection',\n // Screen reader announcement of the selected items count.\n // {count} is replaced with the actual count of items.\n total: '{count} items selected',\n}\n```",
1054
+ "attribute": "i18n",
1046
1055
  "inheritedFrom": {
1047
1056
  "name": "I18nMixin",
1048
1057
  "package": "@vaadin/component-base/src/i18n-mixin.js"
@@ -1479,6 +1488,11 @@
1479
1488
  },
1480
1489
  {
1481
1490
  "name": "i18n",
1491
+ "type": {
1492
+ "text": "Object"
1493
+ },
1494
+ "description": "The object used to localize this component. To change the default\nlocalization, replace this with an object that provides all properties, or\njust the individual properties you want to change.\n\nShould be overridden by subclasses to provide a custom JSDoc with the\ndefault I18N properties.",
1495
+ "fieldName": "i18n",
1482
1496
  "inheritedFrom": {
1483
1497
  "name": "I18nMixin",
1484
1498
  "package": "@vaadin/component-base/src/i18n-mixin.js"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/multi-select-combo-box",
3
- "version": "25.1.0-beta2",
3
+ "version": "25.1.0-beta4",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -37,29 +37,29 @@
37
37
  ],
38
38
  "dependencies": {
39
39
  "@open-wc/dedupe-mixin": "^1.3.0",
40
- "@vaadin/a11y-base": "25.1.0-beta2",
41
- "@vaadin/combo-box": "25.1.0-beta2",
42
- "@vaadin/component-base": "25.1.0-beta2",
43
- "@vaadin/field-base": "25.1.0-beta2",
44
- "@vaadin/input-container": "25.1.0-beta2",
45
- "@vaadin/item": "25.1.0-beta2",
46
- "@vaadin/lit-renderer": "25.1.0-beta2",
47
- "@vaadin/overlay": "25.1.0-beta2",
48
- "@vaadin/vaadin-themable-mixin": "25.1.0-beta2",
40
+ "@vaadin/a11y-base": "25.1.0-beta4",
41
+ "@vaadin/combo-box": "25.1.0-beta4",
42
+ "@vaadin/component-base": "25.1.0-beta4",
43
+ "@vaadin/field-base": "25.1.0-beta4",
44
+ "@vaadin/input-container": "25.1.0-beta4",
45
+ "@vaadin/item": "25.1.0-beta4",
46
+ "@vaadin/lit-renderer": "25.1.0-beta4",
47
+ "@vaadin/overlay": "25.1.0-beta4",
48
+ "@vaadin/vaadin-themable-mixin": "25.1.0-beta4",
49
49
  "lit": "^3.0.0"
50
50
  },
51
51
  "devDependencies": {
52
- "@vaadin/aura": "25.1.0-beta2",
53
- "@vaadin/chai-plugins": "25.1.0-beta2",
54
- "@vaadin/test-runner-commands": "25.1.0-beta2",
52
+ "@vaadin/aura": "25.1.0-beta4",
53
+ "@vaadin/chai-plugins": "25.1.0-beta4",
54
+ "@vaadin/test-runner-commands": "25.1.0-beta4",
55
55
  "@vaadin/testing-helpers": "^2.0.0",
56
- "@vaadin/vaadin-lumo-styles": "25.1.0-beta2",
57
- "sinon": "^21.0.0"
56
+ "@vaadin/vaadin-lumo-styles": "25.1.0-beta4",
57
+ "sinon": "^21.0.2"
58
58
  },
59
59
  "customElements": "custom-elements.json",
60
60
  "web-types": [
61
61
  "web-types.json",
62
62
  "web-types.lit.json"
63
63
  ],
64
- "gitHead": "ffbedbae08a5160d13bcd1c6fcaa328df5103a05"
64
+ "gitHead": "b27f6706a2b5c07cedec353fccbdecee95d53024"
65
65
  }
@@ -872,6 +872,11 @@ export const MultiSelectComboBoxMixin = (superClass) =>
872
872
  return chip;
873
873
  }
874
874
 
875
+ /** @private */
876
+ __getWrapperWidth() {
877
+ return this._inputField.$.wrapper.clientWidth;
878
+ }
879
+
875
880
  /** @private */
876
881
  __getOverflowWidth() {
877
882
  const chip = this._overflow;
@@ -905,82 +910,94 @@ export const MultiSelectComboBoxMixin = (superClass) =>
905
910
  chip.remove();
906
911
  });
907
912
 
908
- const items = [...this.selectedItems];
913
+ if (this.selectedItems.length === 0) {
914
+ this._overflowItems = [];
915
+ return;
916
+ }
917
+
918
+ // When auto expanding vertically, create all chips without overflow
919
+ if (this.autoExpandVertically) {
920
+ this.selectedItems.forEach((item) => {
921
+ this.appendChild(this.__createChip(item));
922
+ });
923
+ this._overflowItems = [];
924
+ return;
925
+ }
909
926
 
910
- // Detect available remaining width for chips
911
- const totalWidth = this._inputField.$.wrapper.clientWidth;
912
927
  const inputWidth = parseInt(getComputedStyle(this.inputElement).flexBasis);
913
928
 
914
- let remainingWidth = totalWidth - inputWidth;
929
+ if (this.autoExpandHorizontally) {
930
+ this._overflowItems = this.__updateChipsHorizontalExpand(this.selectedItems, inputWidth);
931
+ } else {
932
+ this._overflowItems = this.__updateChipsDefault(this.selectedItems, inputWidth);
933
+ }
934
+ }
915
935
 
916
- if (items.length > 1) {
917
- remainingWidth -= this.__getOverflowWidth();
936
+ /** @private */
937
+ __updateChipsHorizontalExpand(items, inputWidth) {
938
+ // Add all chips to make the field fully expand
939
+ const chips = items.map((item) => {
940
+ const chip = this.__createChip(item);
941
+ this.appendChild(chip);
942
+ return chip;
943
+ });
944
+
945
+ if (this.__getWrapperWidth() - this.$.chips.clientWidth >= inputWidth) {
946
+ return [];
918
947
  }
919
948
 
920
- const chipMinWidth = parseInt(getComputedStyle(this).getPropertyValue('--_chip-min-width'));
949
+ // Remove chips from the end until there is enough width for the input element to fit,
950
+ // keeping at least one chip visible
951
+ const overflowWidth = this.__getOverflowWidth();
952
+ let visibleCount = chips.length;
921
953
 
922
- if (this.autoExpandHorizontally) {
923
- const chips = [];
924
-
925
- // First, add all chips to make the field fully expand
926
- for (let i = items.length - 1, refNode = null; i >= 0; i--) {
927
- const chip = this.__createChip(items[i]);
928
- this.insertBefore(chip, refNode);
929
- refNode = chip;
930
- chips.unshift(chip);
954
+ while (visibleCount > 1) {
955
+ visibleCount -= 1;
956
+ chips[visibleCount].remove();
957
+
958
+ if (this.__getWrapperWidth() - this.$.chips.clientWidth >= inputWidth + overflowWidth) {
959
+ break;
931
960
  }
961
+ }
932
962
 
933
- const overflowItems = [];
934
- const availableWidth = this._inputField.$.wrapper.clientWidth - this.$.chips.clientWidth;
935
-
936
- // When auto expanding vertically, no need to measure width
937
- if (!this.autoExpandVertically && availableWidth < inputWidth) {
938
- // Always show at least last item as a chip
939
- while (chips.length > 1) {
940
- const lastChip = chips.pop();
941
- lastChip.remove();
942
- overflowItems.unshift(items.pop());
943
-
944
- // Remove chips until there is enough width for the input element to fit
945
- const neededWidth = overflowItems.length > 0 ? inputWidth + this.__getOverflowWidth() : inputWidth;
946
- if (this._inputField.$.wrapper.clientWidth - this.$.chips.clientWidth >= neededWidth) {
947
- break;
948
- }
949
- }
963
+ if (visibleCount === 1) {
964
+ const chipMinWidth = parseInt(getComputedStyle(this).getPropertyValue('--_chip-min-width'));
965
+ const remainingWidth = this.__getWrapperWidth() - inputWidth - overflowWidth;
966
+ chips[0].style.maxWidth = `${Math.max(chipMinWidth, remainingWidth)}px`;
967
+ }
950
968
 
951
- if (chips.length === 1) {
952
- chips[0].style.maxWidth = `${Math.max(chipMinWidth, remainingWidth)}px`;
953
- }
954
- }
969
+ return items.slice(visibleCount);
970
+ }
955
971
 
956
- this._overflowItems = overflowItems;
957
- return;
972
+ /** @private */
973
+ __updateChipsDefault(items, inputWidth) {
974
+ let remainingWidth = this.__getWrapperWidth() - inputWidth;
975
+
976
+ if (items.length > 1) {
977
+ remainingWidth -= this.__getOverflowWidth();
958
978
  }
959
979
 
960
- // Add chips until remaining width is exceeded
980
+ const chipMinWidth = parseInt(getComputedStyle(this).getPropertyValue('--_chip-min-width'));
981
+
982
+ // Add chips from the end until remaining width is exceeded
961
983
  for (let i = items.length - 1, refNode = null; i >= 0; i--) {
962
984
  const chip = this.__createChip(items[i]);
963
985
  this.insertBefore(chip, refNode);
964
986
 
965
- // When auto expanding vertically, no need to measure remaining width
966
- if (!this.autoExpandVertically) {
967
- if (this.$.chips.clientWidth > remainingWidth) {
968
- // If there is no more space for chips, or if there is at least one
969
- // chip already shown, collapse all remaining chips to the overflow
970
- if (remainingWidth < chipMinWidth || refNode !== null) {
971
- chip.remove();
972
- break;
973
- }
987
+ if (this.$.chips.clientWidth > remainingWidth) {
988
+ // If there is no more space for chips, or if there is at least one
989
+ // chip already shown, collapse all remaining chips to the overflow
990
+ if (remainingWidth < chipMinWidth || refNode !== null) {
991
+ chip.remove();
992
+ return items.slice(0, i + 1);
974
993
  }
975
-
976
- chip.style.maxWidth = `${remainingWidth}px`;
977
994
  }
978
995
 
979
- items.pop();
996
+ chip.style.maxWidth = `${remainingWidth}px`;
980
997
  refNode = chip;
981
998
  }
982
999
 
983
- this._overflowItems = items;
1000
+ return [];
984
1001
  }
985
1002
 
986
1003
  /** @private */
package/web-types.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/multi-select-combo-box",
4
- "version": "25.1.0-beta2",
4
+ "version": "25.1.0-beta4",
5
5
  "description-markup": "markdown",
6
6
  "contributions": {
7
7
  "html": {
@@ -164,6 +164,17 @@
164
164
  ]
165
165
  }
166
166
  },
167
+ {
168
+ "name": "i18n",
169
+ "description": "The object used to localize this component. To change the default\nlocalization, replace this with an object that provides all properties, or\njust the individual properties you want to change.\n\nShould be overridden by subclasses to provide a custom JSDoc with the\ndefault I18N properties.",
170
+ "value": {
171
+ "type": [
172
+ "Object",
173
+ "null",
174
+ "undefined"
175
+ ]
176
+ }
177
+ },
167
178
  {
168
179
  "name": "invalid",
169
180
  "description": "Set to true when the field is invalid.",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/web-types",
3
3
  "name": "@vaadin/multi-select-combo-box",
4
- "version": "25.1.0-beta2",
4
+ "version": "25.1.0-beta4",
5
5
  "description-markup": "markdown",
6
6
  "framework": "lit",
7
7
  "framework-config": {