@sproutsocial/seeds-react-menu 1.11.3 → 1.11.5
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 +10 -10
- package/CHANGELOG.md +18 -0
- package/dist/esm/v3/index.js +44 -9
- package/dist/esm/v3/index.js.map +1 -1
- package/dist/v3/index.js +44 -9
- package/dist/v3/index.js.map +1 -1
- package/package.json +9 -9
- 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/SingleSearchableSelect.stories.tsx +21 -0
- package/src/v3/SingleSearchableSelect.tsx +32 -9
package/dist/v3/index.js
CHANGED
|
@@ -213,6 +213,7 @@ var Field = import_styled_components2.default.div`
|
|
|
213
213
|
display: flex;
|
|
214
214
|
flex-direction: column;
|
|
215
215
|
gap: ${({ theme }) => theme.space[200]};
|
|
216
|
+
width: 100%;
|
|
216
217
|
`;
|
|
217
218
|
var SelectLabel = (0, import_styled_components2.default)(import_select2.Select.Label)`
|
|
218
219
|
font-size: ${({ theme }) => theme.typography[200].fontSize};
|
|
@@ -1151,6 +1152,16 @@ var ComboboxItem_default = ComboboxItem2;
|
|
|
1151
1152
|
var React7 = __toESM(require("react"));
|
|
1152
1153
|
var import_combobox2 = require("@base-ui/react/combobox");
|
|
1153
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
|
|
1154
1165
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1155
1166
|
var ITEM_HEIGHT = 32;
|
|
1156
1167
|
function isGroupHeaderSentinel(v) {
|
|
@@ -1212,7 +1223,7 @@ function VirtualizedComboboxList({
|
|
|
1212
1223
|
style: { position: "relative", width: "100%", height: totalSize },
|
|
1213
1224
|
children: virtualizer.getVirtualItems().map((virtualItem) => {
|
|
1214
1225
|
const row = filteredItems[virtualItem.index];
|
|
1215
|
-
if (
|
|
1226
|
+
if (row == null) return null;
|
|
1216
1227
|
const baseStyle = {
|
|
1217
1228
|
position: "absolute",
|
|
1218
1229
|
top: 0,
|
|
@@ -1221,6 +1232,22 @@ function VirtualizedComboboxList({
|
|
|
1221
1232
|
transform: `translateY(${virtualItem.start}px)`,
|
|
1222
1233
|
boxSizing: "border-box"
|
|
1223
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
|
+
}
|
|
1224
1251
|
if (isSelectAllSentinel(row)) {
|
|
1225
1252
|
const selectedCount = selectedArray.length;
|
|
1226
1253
|
const totalCount = data.length;
|
|
@@ -1279,6 +1306,7 @@ function VirtualizedComboboxList({
|
|
|
1279
1306
|
value: item,
|
|
1280
1307
|
itemId: String(item.id),
|
|
1281
1308
|
label: itemToString(item),
|
|
1309
|
+
disabled: item.disabled,
|
|
1282
1310
|
inputType,
|
|
1283
1311
|
renderItem: renderItem ? () => renderItem(item) : () => itemToString(item),
|
|
1284
1312
|
style: baseStyle,
|
|
@@ -1806,9 +1834,10 @@ function SingleSearchableSelect(props) {
|
|
|
1806
1834
|
);
|
|
1807
1835
|
const value = isControlled ? idToItem(selectedItemId) : internalValue;
|
|
1808
1836
|
function handleValueChange(newItem) {
|
|
1809
|
-
|
|
1837
|
+
const realItem = newItem == null || isPlaceholderSentinel(newItem) ? null : newItem;
|
|
1838
|
+
if (!isControlled) setInternalValue(realItem);
|
|
1810
1839
|
if (onSelectedItemIdChange) {
|
|
1811
|
-
onSelectedItemIdChange(
|
|
1840
|
+
onSelectedItemIdChange(realItem ? realItem.id : null);
|
|
1812
1841
|
}
|
|
1813
1842
|
}
|
|
1814
1843
|
const groups = React10.useMemo(
|
|
@@ -1824,9 +1853,14 @@ function SingleSearchableSelect(props) {
|
|
|
1824
1853
|
value,
|
|
1825
1854
|
disabled: props.disabled,
|
|
1826
1855
|
onValueChange: handleValueChange,
|
|
1827
|
-
itemToStringLabel: itemToString,
|
|
1828
|
-
isItemEqualToValue: (a, b) =>
|
|
1829
|
-
|
|
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),
|
|
1830
1864
|
virtualized: isVirtualized,
|
|
1831
1865
|
open,
|
|
1832
1866
|
onOpenChange: setOpen,
|
|
@@ -1845,7 +1879,7 @@ function SingleSearchableSelect(props) {
|
|
|
1845
1879
|
} : void 0,
|
|
1846
1880
|
children: [
|
|
1847
1881
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(SearchableSelectTrigger, { id, children: [
|
|
1848
|
-
/* @__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 }) }),
|
|
1849
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, {}) }) })
|
|
1850
1884
|
] }),
|
|
1851
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)(
|
|
@@ -1906,9 +1940,10 @@ function SingleSearchableSelect(props) {
|
|
|
1906
1940
|
includePlaceholderItem && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1907
1941
|
ComboboxItem_default,
|
|
1908
1942
|
{
|
|
1909
|
-
value:
|
|
1943
|
+
value: makePlaceholderSentinel(placeholder),
|
|
1910
1944
|
itemId: "placeholder",
|
|
1911
|
-
label: placeholder
|
|
1945
|
+
label: placeholder,
|
|
1946
|
+
inputType
|
|
1912
1947
|
},
|
|
1913
1948
|
"placeholder"
|
|
1914
1949
|
),
|