@sproutsocial/seeds-react-menu 1.11.2 → 1.11.4
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/.turbo/turbo-build.log +16 -16
- package/CHANGELOG.md +12 -0
- package/dist/esm/v3/index.js +104 -42
- package/dist/esm/v3/index.js.map +1 -1
- package/dist/v3/index.d.mts +2 -0
- package/dist/v3/index.d.ts +2 -0
- package/dist/v3/index.js +103 -41
- package/dist/v3/index.js.map +1 -1
- package/package.json +1 -1
- package/src/v3/Common/ComboboxItem.tsx +3 -0
- package/src/v3/Common/SelectItem.tsx +3 -0
- package/src/v3/Common/SelectStyles.tsx +1 -0
- package/src/v3/Common/VirtualizedComboboxList.tsx +23 -1
- package/src/v3/Common/sentinels.ts +17 -0
- package/src/v3/Common/types.ts +1 -0
- package/src/v3/MultiCombobox.stories.tsx +25 -1
- package/src/v3/MultiCombobox.tsx +3 -0
- package/src/v3/MultiSearchableSelect.stories.tsx +26 -1
- package/src/v3/MultiSearchableSelect.tsx +3 -0
- package/src/v3/MultiSelect.stories.tsx +24 -1
- package/src/v3/MultiSelect.tsx +2 -0
- package/src/v3/SingleCombobox.stories.tsx +25 -1
- package/src/v3/SingleCombobox.tsx +2 -0
- package/src/v3/SingleSearchableSelect.stories.tsx +67 -1
- package/src/v3/SingleSearchableSelect.tsx +59 -20
- package/src/v3/SingleSelect.stories.tsx +24 -1
- package/src/v3/SingleSelect.tsx +2 -1
- package/src/v3/storyData.tsx +5 -0
package/dist/v3/index.d.mts
CHANGED
|
@@ -5,6 +5,7 @@ import * as styled_components from 'styled-components';
|
|
|
5
5
|
|
|
6
6
|
interface DataWithId {
|
|
7
7
|
id: string | number;
|
|
8
|
+
disabled?: boolean;
|
|
8
9
|
}
|
|
9
10
|
|
|
10
11
|
interface SingleSelectBaseProps {
|
|
@@ -174,6 +175,7 @@ declare function MultiCombobox<T extends DataWithId>(props: MultiComboboxProps<T
|
|
|
174
175
|
interface SingleSearchableSelectBaseProps {
|
|
175
176
|
id?: string;
|
|
176
177
|
placeholder?: string;
|
|
178
|
+
includePlaceholderItem?: boolean;
|
|
177
179
|
searchPlaceholder?: string;
|
|
178
180
|
emptyText?: string;
|
|
179
181
|
isLoading?: boolean;
|
package/dist/v3/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import * as styled_components from 'styled-components';
|
|
|
5
5
|
|
|
6
6
|
interface DataWithId {
|
|
7
7
|
id: string | number;
|
|
8
|
+
disabled?: boolean;
|
|
8
9
|
}
|
|
9
10
|
|
|
10
11
|
interface SingleSelectBaseProps {
|
|
@@ -174,6 +175,7 @@ declare function MultiCombobox<T extends DataWithId>(props: MultiComboboxProps<T
|
|
|
174
175
|
interface SingleSearchableSelectBaseProps {
|
|
175
176
|
id?: string;
|
|
176
177
|
placeholder?: string;
|
|
178
|
+
includePlaceholderItem?: boolean;
|
|
177
179
|
searchPlaceholder?: string;
|
|
178
180
|
emptyText?: string;
|
|
179
181
|
isLoading?: boolean;
|
package/dist/v3/index.js
CHANGED
|
@@ -142,6 +142,7 @@ function CheckIcon() {
|
|
|
142
142
|
function SelectItem({
|
|
143
143
|
value,
|
|
144
144
|
label,
|
|
145
|
+
disabled,
|
|
145
146
|
inputType = "icon",
|
|
146
147
|
renderItem,
|
|
147
148
|
hidden
|
|
@@ -150,6 +151,7 @@ function SelectItem({
|
|
|
150
151
|
StyledItem,
|
|
151
152
|
{
|
|
152
153
|
value,
|
|
154
|
+
disabled,
|
|
153
155
|
style: hidden ? { display: "none" } : void 0,
|
|
154
156
|
"data-qa-menu-item": label,
|
|
155
157
|
children: [
|
|
@@ -211,6 +213,7 @@ var Field = import_styled_components2.default.div`
|
|
|
211
213
|
display: flex;
|
|
212
214
|
flex-direction: column;
|
|
213
215
|
gap: ${({ theme }) => theme.space[200]};
|
|
216
|
+
width: 100%;
|
|
214
217
|
`;
|
|
215
218
|
var SelectLabel = (0, import_styled_components2.default)(import_select2.Select.Label)`
|
|
216
219
|
font-size: ${({ theme }) => theme.typography[200].fontSize};
|
|
@@ -432,6 +435,7 @@ function SingleSelect(props) {
|
|
|
432
435
|
{
|
|
433
436
|
value: String(item.id),
|
|
434
437
|
label: itemToString(item),
|
|
438
|
+
disabled: item.disabled,
|
|
435
439
|
inputType,
|
|
436
440
|
renderItem: renderItem ? () => renderItem(item) : () => itemToString(item)
|
|
437
441
|
},
|
|
@@ -439,29 +443,27 @@ function SingleSelect(props) {
|
|
|
439
443
|
))
|
|
440
444
|
] }),
|
|
441
445
|
index < arr.length - 1 && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(SelectSeparator, {})
|
|
442
|
-
] }, group.value)) : (
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
] })
|
|
464
|
-
) }),
|
|
446
|
+
] }, group.value)) : /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
447
|
+
includePlaceholderItem && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
448
|
+
SelectItem,
|
|
449
|
+
{
|
|
450
|
+
value: null,
|
|
451
|
+
label: placeholder ?? ""
|
|
452
|
+
},
|
|
453
|
+
"placeholder"
|
|
454
|
+
),
|
|
455
|
+
data.map((item) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
456
|
+
SelectItem,
|
|
457
|
+
{
|
|
458
|
+
value: String(item.id),
|
|
459
|
+
label: itemToString(item),
|
|
460
|
+
disabled: item.disabled,
|
|
461
|
+
inputType,
|
|
462
|
+
renderItem: renderItem ? () => renderItem(item) : () => itemToString(item)
|
|
463
|
+
},
|
|
464
|
+
item.id
|
|
465
|
+
))
|
|
466
|
+
] }) }),
|
|
465
467
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_select3.Select.ScrollDownArrow, {})
|
|
466
468
|
] }) }) })
|
|
467
469
|
]
|
|
@@ -574,6 +576,7 @@ function MultiSelect(props) {
|
|
|
574
576
|
{
|
|
575
577
|
value: String(item.id),
|
|
576
578
|
label: itemToString(item),
|
|
579
|
+
disabled: item.disabled,
|
|
577
580
|
inputType,
|
|
578
581
|
hidden: removeSelectedItems && value.includes(String(item.id)),
|
|
579
582
|
renderItem: renderItem ? () => renderItem(item) : void 0
|
|
@@ -587,6 +590,7 @@ function MultiSelect(props) {
|
|
|
587
590
|
{
|
|
588
591
|
value: String(item.id),
|
|
589
592
|
label: itemToString(item),
|
|
593
|
+
disabled: item.disabled,
|
|
590
594
|
inputType,
|
|
591
595
|
hidden: removeSelectedItems && value.includes(String(item.id)),
|
|
592
596
|
renderItem: renderItem ? () => renderItem(item) : () => itemToString(item)
|
|
@@ -1085,6 +1089,7 @@ function ComboboxItemInner({
|
|
|
1085
1089
|
value,
|
|
1086
1090
|
itemId,
|
|
1087
1091
|
label,
|
|
1092
|
+
disabled,
|
|
1088
1093
|
inputType = "icon",
|
|
1089
1094
|
renderItem,
|
|
1090
1095
|
index,
|
|
@@ -1099,6 +1104,7 @@ function ComboboxItemInner({
|
|
|
1099
1104
|
"data-index": dataIndex,
|
|
1100
1105
|
style,
|
|
1101
1106
|
ref,
|
|
1107
|
+
disabled,
|
|
1102
1108
|
"data-qa-menu-item": label,
|
|
1103
1109
|
children: [
|
|
1104
1110
|
inputType === "radio" ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
@@ -1146,6 +1152,16 @@ var ComboboxItem_default = ComboboxItem2;
|
|
|
1146
1152
|
var React7 = __toESM(require("react"));
|
|
1147
1153
|
var import_combobox2 = require("@base-ui/react/combobox");
|
|
1148
1154
|
var import_react_virtual = require("@tanstack/react-virtual");
|
|
1155
|
+
|
|
1156
|
+
// src/v3/Common/sentinels.ts
|
|
1157
|
+
function makePlaceholderSentinel(label) {
|
|
1158
|
+
return { __placeholder: true, label };
|
|
1159
|
+
}
|
|
1160
|
+
function isPlaceholderSentinel(v) {
|
|
1161
|
+
return typeof v === "object" && v !== null && "__placeholder" in v;
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
// src/v3/Common/VirtualizedComboboxList.tsx
|
|
1149
1165
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1150
1166
|
var ITEM_HEIGHT = 32;
|
|
1151
1167
|
function isGroupHeaderSentinel(v) {
|
|
@@ -1207,7 +1223,7 @@ function VirtualizedComboboxList({
|
|
|
1207
1223
|
style: { position: "relative", width: "100%", height: totalSize },
|
|
1208
1224
|
children: virtualizer.getVirtualItems().map((virtualItem) => {
|
|
1209
1225
|
const row = filteredItems[virtualItem.index];
|
|
1210
|
-
if (
|
|
1226
|
+
if (row == null) return null;
|
|
1211
1227
|
const baseStyle = {
|
|
1212
1228
|
position: "absolute",
|
|
1213
1229
|
top: 0,
|
|
@@ -1216,6 +1232,22 @@ function VirtualizedComboboxList({
|
|
|
1216
1232
|
transform: `translateY(${virtualItem.start}px)`,
|
|
1217
1233
|
boxSizing: "border-box"
|
|
1218
1234
|
};
|
|
1235
|
+
if (isPlaceholderSentinel(row)) {
|
|
1236
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1237
|
+
ComboboxItem_default,
|
|
1238
|
+
{
|
|
1239
|
+
index: virtualItem.index,
|
|
1240
|
+
"data-index": virtualItem.index,
|
|
1241
|
+
value: row,
|
|
1242
|
+
itemId: "placeholder",
|
|
1243
|
+
label: row.label,
|
|
1244
|
+
inputType,
|
|
1245
|
+
style: baseStyle,
|
|
1246
|
+
ref: virtualizer.measureElement
|
|
1247
|
+
},
|
|
1248
|
+
"placeholder"
|
|
1249
|
+
);
|
|
1250
|
+
}
|
|
1219
1251
|
if (isSelectAllSentinel(row)) {
|
|
1220
1252
|
const selectedCount = selectedArray.length;
|
|
1221
1253
|
const totalCount = data.length;
|
|
@@ -1274,6 +1306,7 @@ function VirtualizedComboboxList({
|
|
|
1274
1306
|
value: item,
|
|
1275
1307
|
itemId: String(item.id),
|
|
1276
1308
|
label: itemToString(item),
|
|
1309
|
+
disabled: item.disabled,
|
|
1277
1310
|
inputType,
|
|
1278
1311
|
renderItem: renderItem ? () => renderItem(item) : () => itemToString(item),
|
|
1279
1312
|
style: baseStyle,
|
|
@@ -1409,6 +1442,7 @@ function SingleCombobox(props) {
|
|
|
1409
1442
|
value: item,
|
|
1410
1443
|
itemId: String(item.id),
|
|
1411
1444
|
label: itemToString(item),
|
|
1445
|
+
disabled: item.disabled,
|
|
1412
1446
|
inputType,
|
|
1413
1447
|
renderItem: renderItem ? () => renderItem(item) : () => itemToString(item)
|
|
1414
1448
|
},
|
|
@@ -1422,6 +1456,7 @@ function SingleCombobox(props) {
|
|
|
1422
1456
|
value: item,
|
|
1423
1457
|
itemId: String(item.id),
|
|
1424
1458
|
label: itemToString(item),
|
|
1459
|
+
disabled: item.disabled,
|
|
1425
1460
|
inputType,
|
|
1426
1461
|
renderItem: renderItem ? () => renderItem(item) : () => itemToString(item)
|
|
1427
1462
|
},
|
|
@@ -1595,6 +1630,7 @@ function MultiCombobox(props) {
|
|
|
1595
1630
|
value: item,
|
|
1596
1631
|
itemId: String(item.id),
|
|
1597
1632
|
label: itemToString(item),
|
|
1633
|
+
disabled: item.disabled,
|
|
1598
1634
|
inputType,
|
|
1599
1635
|
renderItem: renderItem ? () => renderItem(item) : () => itemToString(item)
|
|
1600
1636
|
},
|
|
@@ -1723,6 +1759,7 @@ function MultiCombobox(props) {
|
|
|
1723
1759
|
value: item,
|
|
1724
1760
|
itemId: String(item.id),
|
|
1725
1761
|
label: itemToString(item),
|
|
1762
|
+
disabled: item.disabled,
|
|
1726
1763
|
inputType,
|
|
1727
1764
|
renderItem: renderItem ? () => renderItem(item) : () => itemToString(item)
|
|
1728
1765
|
},
|
|
@@ -1736,6 +1773,7 @@ function MultiCombobox(props) {
|
|
|
1736
1773
|
value: item,
|
|
1737
1774
|
itemId: String(item.id),
|
|
1738
1775
|
label: itemToString(item),
|
|
1776
|
+
disabled: item.disabled,
|
|
1739
1777
|
inputType,
|
|
1740
1778
|
renderItem: renderItem ? () => renderItem(item) : () => itemToString(item)
|
|
1741
1779
|
},
|
|
@@ -1761,6 +1799,7 @@ function SingleSearchableSelect(props) {
|
|
|
1761
1799
|
const {
|
|
1762
1800
|
id,
|
|
1763
1801
|
placeholder = "Select...",
|
|
1802
|
+
includePlaceholderItem,
|
|
1764
1803
|
searchPlaceholder = "Search...",
|
|
1765
1804
|
emptyText = "No results found.",
|
|
1766
1805
|
isLoading = false,
|
|
@@ -1795,9 +1834,10 @@ function SingleSearchableSelect(props) {
|
|
|
1795
1834
|
);
|
|
1796
1835
|
const value = isControlled ? idToItem(selectedItemId) : internalValue;
|
|
1797
1836
|
function handleValueChange(newItem) {
|
|
1798
|
-
|
|
1837
|
+
const realItem = newItem == null || isPlaceholderSentinel(newItem) ? null : newItem;
|
|
1838
|
+
if (!isControlled) setInternalValue(realItem);
|
|
1799
1839
|
if (onSelectedItemIdChange) {
|
|
1800
|
-
onSelectedItemIdChange(
|
|
1840
|
+
onSelectedItemIdChange(realItem ? realItem.id : null);
|
|
1801
1841
|
}
|
|
1802
1842
|
}
|
|
1803
1843
|
const groups = React10.useMemo(
|
|
@@ -1813,9 +1853,14 @@ function SingleSearchableSelect(props) {
|
|
|
1813
1853
|
value,
|
|
1814
1854
|
disabled: props.disabled,
|
|
1815
1855
|
onValueChange: handleValueChange,
|
|
1816
|
-
itemToStringLabel: itemToString,
|
|
1817
|
-
isItemEqualToValue: (a, b) =>
|
|
1818
|
-
|
|
1856
|
+
itemToStringLabel: (item) => isPlaceholderSentinel(item) ? item.label : itemToString(item),
|
|
1857
|
+
isItemEqualToValue: (a, b) => {
|
|
1858
|
+
if (isPlaceholderSentinel(a) && isPlaceholderSentinel(b)) return true;
|
|
1859
|
+
if (isPlaceholderSentinel(a)) return b == null;
|
|
1860
|
+
if (isPlaceholderSentinel(b)) return a == null;
|
|
1861
|
+
return a != null && b != null && a.id === b.id;
|
|
1862
|
+
},
|
|
1863
|
+
items: isVirtualized ? includePlaceholderItem ? [makePlaceholderSentinel(placeholder), ...data] : data : groups ?? (isChildrenMode ? void 0 : data),
|
|
1819
1864
|
virtualized: isVirtualized,
|
|
1820
1865
|
open,
|
|
1821
1866
|
onOpenChange: setOpen,
|
|
@@ -1834,7 +1879,7 @@ function SingleSearchableSelect(props) {
|
|
|
1834
1879
|
} : void 0,
|
|
1835
1880
|
children: [
|
|
1836
1881
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(SearchableSelectTrigger, { id, children: [
|
|
1837
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(SearchableSelectPlaceholder, { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_combobox5.Combobox.Value, { placeholder, children: value ? renderSelection ? renderSelection(value) : itemToString(value) :
|
|
1882
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(SearchableSelectPlaceholder, { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_combobox5.Combobox.Value, { placeholder, children: value ? renderSelection ? renderSelection(value) : itemToString(value) : placeholder }) }),
|
|
1838
1883
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(SearchableSelectTriggerIcon, { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(StyledChevron, { "data-chevron": true, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ChevronIcon, {}) }) })
|
|
1839
1884
|
] }),
|
|
1840
1885
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_combobox5.Combobox.Portal, { container: portalContainer, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ComboboxPositioner, { sideOffset: 4, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
@@ -1883,6 +1928,7 @@ function SingleSearchableSelect(props) {
|
|
|
1883
1928
|
value: item,
|
|
1884
1929
|
itemId: String(item.id),
|
|
1885
1930
|
label: itemToString(item),
|
|
1931
|
+
disabled: item.disabled,
|
|
1886
1932
|
inputType,
|
|
1887
1933
|
renderItem: renderItem ? () => renderItem(item) : () => itemToString(item)
|
|
1888
1934
|
},
|
|
@@ -1890,17 +1936,30 @@ function SingleSearchableSelect(props) {
|
|
|
1890
1936
|
) })
|
|
1891
1937
|
] }),
|
|
1892
1938
|
index < groups.length - 1 && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ComboboxSeparator, {})
|
|
1893
|
-
] }, group.value) :
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1939
|
+
] }, group.value) : /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
|
|
1940
|
+
includePlaceholderItem && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1941
|
+
ComboboxItem_default,
|
|
1942
|
+
{
|
|
1943
|
+
value: makePlaceholderSentinel(placeholder),
|
|
1944
|
+
itemId: "placeholder",
|
|
1945
|
+
label: placeholder,
|
|
1946
|
+
inputType
|
|
1947
|
+
},
|
|
1948
|
+
"placeholder"
|
|
1949
|
+
),
|
|
1950
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_combobox5.Combobox.Collection, { children: (item) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1951
|
+
ComboboxItem_default,
|
|
1952
|
+
{
|
|
1953
|
+
value: item,
|
|
1954
|
+
itemId: String(item.id),
|
|
1955
|
+
label: itemToString(item),
|
|
1956
|
+
disabled: item.disabled,
|
|
1957
|
+
inputType,
|
|
1958
|
+
renderItem: renderItem ? () => renderItem(item) : void 0
|
|
1959
|
+
},
|
|
1960
|
+
item.id
|
|
1961
|
+
) })
|
|
1962
|
+
] })
|
|
1904
1963
|
}
|
|
1905
1964
|
)
|
|
1906
1965
|
]
|
|
@@ -2071,6 +2130,7 @@ function MultiSearchableSelect(props) {
|
|
|
2071
2130
|
value: item,
|
|
2072
2131
|
itemId: String(item.id),
|
|
2073
2132
|
label: itemToString(item),
|
|
2133
|
+
disabled: item.disabled,
|
|
2074
2134
|
inputType,
|
|
2075
2135
|
renderItem: renderItem ? () => renderItem(item) : () => itemToString(item)
|
|
2076
2136
|
},
|
|
@@ -2185,6 +2245,7 @@ function MultiSearchableSelect(props) {
|
|
|
2185
2245
|
value: item,
|
|
2186
2246
|
itemId: String(item.id),
|
|
2187
2247
|
label: itemToString(item),
|
|
2248
|
+
disabled: item.disabled,
|
|
2188
2249
|
inputType,
|
|
2189
2250
|
renderItem: renderItem ? () => renderItem(item) : () => itemToString(item)
|
|
2190
2251
|
},
|
|
@@ -2198,6 +2259,7 @@ function MultiSearchableSelect(props) {
|
|
|
2198
2259
|
value: item,
|
|
2199
2260
|
itemId: String(item.id),
|
|
2200
2261
|
label: itemToString(item),
|
|
2262
|
+
disabled: item.disabled,
|
|
2201
2263
|
inputType,
|
|
2202
2264
|
renderItem: renderItem ? () => renderItem(item) : () => itemToString(item)
|
|
2203
2265
|
},
|