@vaadin/multi-select-combo-box 25.3.0 → 25.3.2
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.3.
|
|
3
|
+
"version": "25.3.2",
|
|
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.3.
|
|
41
|
-
"@vaadin/combo-box": "~25.3.
|
|
42
|
-
"@vaadin/component-base": "~25.3.
|
|
43
|
-
"@vaadin/field-base": "~25.3.
|
|
44
|
-
"@vaadin/input-container": "~25.3.
|
|
45
|
-
"@vaadin/item": "~25.3.
|
|
46
|
-
"@vaadin/lit-renderer": "~25.3.
|
|
47
|
-
"@vaadin/overlay": "~25.3.
|
|
48
|
-
"@vaadin/vaadin-themable-mixin": "~25.3.
|
|
40
|
+
"@vaadin/a11y-base": "~25.3.2",
|
|
41
|
+
"@vaadin/combo-box": "~25.3.2",
|
|
42
|
+
"@vaadin/component-base": "~25.3.2",
|
|
43
|
+
"@vaadin/field-base": "~25.3.2",
|
|
44
|
+
"@vaadin/input-container": "~25.3.2",
|
|
45
|
+
"@vaadin/item": "~25.3.2",
|
|
46
|
+
"@vaadin/lit-renderer": "~25.3.2",
|
|
47
|
+
"@vaadin/overlay": "~25.3.2",
|
|
48
|
+
"@vaadin/vaadin-themable-mixin": "~25.3.2",
|
|
49
49
|
"lit": "^3.0.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@vaadin/aura": "~25.3.
|
|
53
|
-
"@vaadin/chai-plugins": "~25.3.
|
|
54
|
-
"@vaadin/test-runner-commands": "~25.3.
|
|
52
|
+
"@vaadin/aura": "~25.3.2",
|
|
53
|
+
"@vaadin/chai-plugins": "~25.3.2",
|
|
54
|
+
"@vaadin/test-runner-commands": "~25.3.2",
|
|
55
55
|
"@vaadin/testing-helpers": "^2.0.0",
|
|
56
|
-
"@vaadin/vaadin-lumo-styles": "~25.3.
|
|
56
|
+
"@vaadin/vaadin-lumo-styles": "~25.3.2",
|
|
57
57
|
"sinon": "^22.0.0"
|
|
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": "
|
|
64
|
+
"gitHead": "3f75254a3f77da3977cb79a77f549f37b8a5d54e"
|
|
65
65
|
}
|
|
@@ -28,13 +28,13 @@ export const multiSelectComboBoxStyles = [
|
|
|
28
28
|
flex: 1 0 var(--_input-min-width);
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
::slotted([slot='chip'])
|
|
32
|
-
::slotted([slot='overflow']) {
|
|
31
|
+
::slotted([slot='chip']) {
|
|
33
32
|
flex: 0 1 auto;
|
|
33
|
+
overflow: hidden;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
::slotted([slot='
|
|
37
|
-
|
|
36
|
+
::slotted([slot='overflow']) {
|
|
37
|
+
flex: none;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
:host(:is([readonly], [disabled])) ::slotted(input) {
|
|
@@ -52,6 +52,10 @@ export const multiSelectComboBoxChipStyles = css`
|
|
|
52
52
|
translate: 25%;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
:host(:dir(rtl)) [part='remove-button'] {
|
|
56
|
+
translate: -25%;
|
|
57
|
+
}
|
|
58
|
+
|
|
55
59
|
[part='remove-button']::before {
|
|
56
60
|
content: '';
|
|
57
61
|
display: block;
|
|
@@ -62,11 +66,8 @@ export const multiSelectComboBoxChipStyles = css`
|
|
|
62
66
|
}
|
|
63
67
|
|
|
64
68
|
:host([disabled]) {
|
|
65
|
-
cursor: var(--vaadin-disabled-cursor);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
:host([disabled]) [part='label'] {
|
|
69
69
|
--vaadin-chip-text-color: var(--vaadin-text-color-disabled);
|
|
70
|
+
cursor: var(--vaadin-disabled-cursor);
|
|
70
71
|
}
|
|
71
72
|
|
|
72
73
|
:host([hidden]),
|
|
@@ -90,11 +91,11 @@ export const multiSelectComboBoxChipStyles = css`
|
|
|
90
91
|
}
|
|
91
92
|
|
|
92
93
|
:host([slot='overflow'])::before {
|
|
93
|
-
|
|
94
|
+
inset-inline-start: calc(-4px - var(--vaadin-chip-border-width, 1px));
|
|
94
95
|
}
|
|
95
96
|
|
|
96
97
|
:host([slot='overflow'])::after {
|
|
97
|
-
|
|
98
|
+
inset-inline-start: calc(-8px - var(--vaadin-chip-border-width, 1px));
|
|
98
99
|
}
|
|
99
100
|
|
|
100
101
|
:host([count='2']) {
|
|
@@ -830,27 +830,49 @@ export const MultiSelectComboBoxMixin = (superClass) =>
|
|
|
830
830
|
return chip;
|
|
831
831
|
}
|
|
832
832
|
|
|
833
|
+
/**
|
|
834
|
+
* Returns the width of the element with its fraction, unlike `clientWidth`.
|
|
835
|
+
* The chips do not shrink below their `max-width`, so a rounding error moves the input out.
|
|
836
|
+
* @private
|
|
837
|
+
*/
|
|
838
|
+
__getUsedWidth(element) {
|
|
839
|
+
return parseFloat(getComputedStyle(element).width);
|
|
840
|
+
}
|
|
841
|
+
|
|
833
842
|
/** @private */
|
|
834
|
-
|
|
835
|
-
|
|
843
|
+
__getWrapperGap() {
|
|
844
|
+
// The gap computes to `normal` when not set, which is 0 in a flex container
|
|
845
|
+
return parseFloat(getComputedStyle(this._inputField.$.wrapper).columnGap) || 0;
|
|
836
846
|
}
|
|
837
847
|
|
|
838
848
|
/** @private */
|
|
839
|
-
|
|
849
|
+
__getWrapperWidth() {
|
|
850
|
+
// Exclude the gap between the chips and the input
|
|
851
|
+
return this.__getUsedWidth(this._inputField.$.wrapper) - this.__getWrapperGap();
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
/**
|
|
855
|
+
* Returns the width that the overflow chip with the given count takes,
|
|
856
|
+
* including its margins and the gap between it and the chips.
|
|
857
|
+
* @private
|
|
858
|
+
*/
|
|
859
|
+
__getOverflowWidth(count) {
|
|
840
860
|
const chip = this._overflow;
|
|
841
861
|
|
|
862
|
+
// The `_overflowItems` observer sets the final label and count afterwards
|
|
842
863
|
chip.style.visibility = 'hidden';
|
|
843
864
|
chip.removeAttribute('hidden');
|
|
865
|
+
chip.label = `${count}`;
|
|
866
|
+
chip.setAttribute('count', `${count}`);
|
|
844
867
|
|
|
845
|
-
|
|
868
|
+
// The chip uses `box-sizing: border-box`, so its width includes padding and border
|
|
869
|
+
const { marginInlineStart, marginInlineEnd } = getComputedStyle(chip);
|
|
870
|
+
const overflowWidth =
|
|
871
|
+
this.__getUsedWidth(chip) +
|
|
872
|
+
parseFloat(marginInlineStart) +
|
|
873
|
+
parseFloat(marginInlineEnd) +
|
|
874
|
+
this.__getWrapperGap();
|
|
846
875
|
|
|
847
|
-
// Detect max possible width of the overflow chip
|
|
848
|
-
// by measuring it with widest number (2 digits)
|
|
849
|
-
chip.setAttribute('count', '99');
|
|
850
|
-
const overflowStyle = getComputedStyle(chip);
|
|
851
|
-
const overflowWidth = chip.clientWidth + parseInt(overflowStyle.marginInlineStart);
|
|
852
|
-
|
|
853
|
-
chip.setAttribute('count', count);
|
|
854
876
|
chip.setAttribute('hidden', '');
|
|
855
877
|
chip.style.visibility = '';
|
|
856
878
|
|
|
@@ -882,7 +904,7 @@ export const MultiSelectComboBoxMixin = (superClass) =>
|
|
|
882
904
|
return;
|
|
883
905
|
}
|
|
884
906
|
|
|
885
|
-
const inputWidth =
|
|
907
|
+
const inputWidth = parseFloat(getComputedStyle(this.inputElement).flexBasis);
|
|
886
908
|
|
|
887
909
|
if (this.collapseChips) {
|
|
888
910
|
this._overflowItems = this.__updateChipsCollapsed(this.selectedItems, inputWidth);
|
|
@@ -901,7 +923,7 @@ export const MultiSelectComboBoxMixin = (superClass) =>
|
|
|
901
923
|
return chip;
|
|
902
924
|
});
|
|
903
925
|
|
|
904
|
-
const allChipsFit = this.__getWrapperWidth() - this.$.chips
|
|
926
|
+
const allChipsFit = this.__getWrapperWidth() - this.__getUsedWidth(this.$.chips) >= inputWidth;
|
|
905
927
|
return { chips, allChipsFit };
|
|
906
928
|
}
|
|
907
929
|
|
|
@@ -928,21 +950,28 @@ export const MultiSelectComboBoxMixin = (superClass) =>
|
|
|
928
950
|
|
|
929
951
|
// Remove chips from the end until there is enough width for the input element to fit,
|
|
930
952
|
// keeping at least one chip visible
|
|
931
|
-
const
|
|
953
|
+
const wrapperWidth = this.__getWrapperWidth();
|
|
954
|
+
// Start from the width for the largest count, and measure the exact count only
|
|
955
|
+
// when the chips would fit with the estimate, as the label width varies per count
|
|
956
|
+
let overflowWidth = this.__getOverflowWidth(items.length - 1);
|
|
932
957
|
let visibleCount = chips.length;
|
|
933
958
|
|
|
934
959
|
while (visibleCount > 1) {
|
|
935
960
|
visibleCount -= 1;
|
|
936
961
|
chips[visibleCount].remove();
|
|
937
962
|
|
|
938
|
-
|
|
939
|
-
|
|
963
|
+
const chipsWidth = this.__getUsedWidth(this.$.chips);
|
|
964
|
+
if (wrapperWidth - chipsWidth >= inputWidth + overflowWidth) {
|
|
965
|
+
overflowWidth = this.__getOverflowWidth(items.length - visibleCount);
|
|
966
|
+
if (wrapperWidth - chipsWidth >= inputWidth + overflowWidth) {
|
|
967
|
+
break;
|
|
968
|
+
}
|
|
940
969
|
}
|
|
941
970
|
}
|
|
942
971
|
|
|
943
972
|
if (visibleCount === 1) {
|
|
944
973
|
const chipMinWidth = parseInt(getComputedStyle(this).getPropertyValue('--_chip-min-width'));
|
|
945
|
-
const remainingWidth =
|
|
974
|
+
const remainingWidth = wrapperWidth - inputWidth - overflowWidth;
|
|
946
975
|
chips[0].style.maxWidth = `${Math.max(chipMinWidth, remainingWidth)}px`;
|
|
947
976
|
}
|
|
948
977
|
|
|
@@ -951,11 +980,7 @@ export const MultiSelectComboBoxMixin = (superClass) =>
|
|
|
951
980
|
|
|
952
981
|
/** @private */
|
|
953
982
|
__updateChipsDefault(items, inputWidth) {
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
if (items.length > 1) {
|
|
957
|
-
remainingWidth -= this.__getOverflowWidth();
|
|
958
|
-
}
|
|
983
|
+
const availableWidth = this.__getWrapperWidth() - inputWidth;
|
|
959
984
|
|
|
960
985
|
const chipMinWidth = parseInt(getComputedStyle(this).getPropertyValue('--_chip-min-width'));
|
|
961
986
|
|
|
@@ -964,7 +989,12 @@ export const MultiSelectComboBoxMixin = (superClass) =>
|
|
|
964
989
|
const chip = this.__createChip(items[i]);
|
|
965
990
|
this.insertBefore(chip, refNode);
|
|
966
991
|
|
|
967
|
-
|
|
992
|
+
// Reserve space for the overflow chip with the count of the items that are not
|
|
993
|
+
// added yet, measured with a chip rendered so that the spacing between them counts
|
|
994
|
+
const remainingWidth =
|
|
995
|
+
items.length > 1 ? availableWidth - this.__getOverflowWidth(Math.max(i, 1)) : availableWidth;
|
|
996
|
+
|
|
997
|
+
if (this.__getUsedWidth(this.$.chips) > remainingWidth) {
|
|
968
998
|
// If there is no more space for chips, or if there is at least one
|
|
969
999
|
// chip already shown, collapse all remaining chips to the overflow
|
|
970
1000
|
if (remainingWidth < chipMinWidth || refNode !== null) {
|
package/web-types.json
CHANGED