@sproutsocial/seeds-react-menu 1.15.10 → 1.16.1
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 +12 -12
- package/CHANGELOG.md +23 -0
- package/dist/esm/v3/index.js +29 -10
- 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 +29 -10
- package/dist/v3/index.js.map +1 -1
- package/package.json +13 -13
- package/src/v3/Common/ComboboxStyles.tsx +6 -0
- package/src/v3/Common/VirtualizedComboboxList.tsx +3 -0
- package/src/v3/MultiCombobox.stories.tsx +22 -0
- package/src/v3/MultiCombobox.tsx +12 -1
- package/src/v3/__tests__/MultiCombobox.test.tsx +91 -0
package/dist/v3/index.d.mts
CHANGED
|
@@ -167,6 +167,7 @@ interface MultiComboboxDataProps<T extends DataWithId> extends MultiComboboxBase
|
|
|
167
167
|
onSelectedItemIdsChange?: (ids: Array<T["id"]>) => void;
|
|
168
168
|
groupBy?: (item: T) => string;
|
|
169
169
|
renderGroupHeading?: (label: string) => React.ReactNode;
|
|
170
|
+
isGroupHeaderDisabled?: (groupName: string) => boolean;
|
|
170
171
|
selectHeadings?: boolean;
|
|
171
172
|
selectAll?: boolean | string;
|
|
172
173
|
isVirtualized?: boolean;
|
|
@@ -189,6 +190,7 @@ interface MultiComboboxChildrenProps extends MultiComboboxBaseProps {
|
|
|
189
190
|
inputType?: never;
|
|
190
191
|
groupBy?: never;
|
|
191
192
|
renderGroupHeading?: never;
|
|
193
|
+
isGroupHeaderDisabled?: never;
|
|
192
194
|
selectHeadings?: never;
|
|
193
195
|
selectAll?: never;
|
|
194
196
|
removeSelectedItems?: never;
|
package/dist/v3/index.d.ts
CHANGED
|
@@ -167,6 +167,7 @@ interface MultiComboboxDataProps<T extends DataWithId> extends MultiComboboxBase
|
|
|
167
167
|
onSelectedItemIdsChange?: (ids: Array<T["id"]>) => void;
|
|
168
168
|
groupBy?: (item: T) => string;
|
|
169
169
|
renderGroupHeading?: (label: string) => React.ReactNode;
|
|
170
|
+
isGroupHeaderDisabled?: (groupName: string) => boolean;
|
|
170
171
|
selectHeadings?: boolean;
|
|
171
172
|
selectAll?: boolean | string;
|
|
172
173
|
isVirtualized?: boolean;
|
|
@@ -189,6 +190,7 @@ interface MultiComboboxChildrenProps extends MultiComboboxBaseProps {
|
|
|
189
190
|
inputType?: never;
|
|
190
191
|
groupBy?: never;
|
|
191
192
|
renderGroupHeading?: never;
|
|
193
|
+
isGroupHeaderDisabled?: never;
|
|
192
194
|
selectHeadings?: never;
|
|
193
195
|
selectAll?: never;
|
|
194
196
|
removeSelectedItems?: never;
|
package/dist/v3/index.js
CHANGED
|
@@ -937,6 +937,12 @@ var ComboboxGroupHeaderItem = (0, import_styled_components6.default)(import_comb
|
|
|
937
937
|
background: ${({ theme }) => theme.colors.listItem.background.hover};
|
|
938
938
|
color: ${({ theme }) => theme.colors.text.body};
|
|
939
939
|
}
|
|
940
|
+
|
|
941
|
+
&[data-disabled] {
|
|
942
|
+
opacity: 0.4;
|
|
943
|
+
cursor: not-allowed;
|
|
944
|
+
pointer-events: none;
|
|
945
|
+
}
|
|
940
946
|
`;
|
|
941
947
|
var ComboboxSelectAllItem = (0, import_styled_components6.default)(import_combobox.Combobox.Item)`
|
|
942
948
|
display: flex;
|
|
@@ -1263,6 +1269,7 @@ function VirtualizedComboboxList({
|
|
|
1263
1269
|
inputType,
|
|
1264
1270
|
renderItem,
|
|
1265
1271
|
renderGroupHeading,
|
|
1272
|
+
isGroupHeaderDisabled,
|
|
1266
1273
|
renderCreatableItem
|
|
1267
1274
|
}) {
|
|
1268
1275
|
const filteredItems = import_combobox2.Combobox.useFilteredItems();
|
|
@@ -1365,6 +1372,7 @@ function VirtualizedComboboxList({
|
|
|
1365
1372
|
index: virtualItem.index,
|
|
1366
1373
|
"data-index": virtualItem.index,
|
|
1367
1374
|
value: row,
|
|
1375
|
+
disabled: isGroupHeaderDisabled?.(row.groupName),
|
|
1368
1376
|
style: baseStyle,
|
|
1369
1377
|
ref: virtualizer.measureElement,
|
|
1370
1378
|
children: [
|
|
@@ -1631,6 +1639,7 @@ function MultiCombobox(props) {
|
|
|
1631
1639
|
const inputType = isChildrenMode ? "checkbox" : removeSelectedItems ? "none" : props.inputType ?? "checkbox";
|
|
1632
1640
|
const groupBy = isChildrenMode ? void 0 : props.groupBy;
|
|
1633
1641
|
const renderGroupHeading = isChildrenMode ? void 0 : props.renderGroupHeading;
|
|
1642
|
+
const isGroupHeaderDisabled = isChildrenMode ? void 0 : props.isGroupHeaderDisabled;
|
|
1634
1643
|
const selectHeadings = isChildrenMode ? false : props.selectHeadings ?? false;
|
|
1635
1644
|
const selectAllProp = isChildrenMode ? false : props.selectAll ?? false;
|
|
1636
1645
|
const selectAll = Boolean(selectAllProp);
|
|
@@ -1729,6 +1738,7 @@ function MultiCombobox(props) {
|
|
|
1729
1738
|
}
|
|
1730
1739
|
let updated = [...realItems];
|
|
1731
1740
|
for (const sentinel of groupSentinels) {
|
|
1741
|
+
if (isGroupHeaderDisabled?.(sentinel.groupName)) continue;
|
|
1732
1742
|
const group = groups?.find((g) => g.value === sentinel.groupName);
|
|
1733
1743
|
if (!group) continue;
|
|
1734
1744
|
const allSelected = group.items.every(
|
|
@@ -1783,16 +1793,24 @@ function MultiCombobox(props) {
|
|
|
1783
1793
|
(item2) => value.some((s) => s.id === item2.id)
|
|
1784
1794
|
).length;
|
|
1785
1795
|
const state = selectedCount === 0 ? "none" : selectedCount === groupItemsList.length ? "all" : "partial";
|
|
1786
|
-
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1797
|
+
ComboboxGroupHeaderItem,
|
|
1798
|
+
{
|
|
1799
|
+
value: row,
|
|
1800
|
+
disabled: isGroupHeaderDisabled?.(row.groupName),
|
|
1801
|
+
children: [
|
|
1802
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1803
|
+
ComboboxGroupHeaderCheckbox,
|
|
1804
|
+
{
|
|
1805
|
+
$state: state,
|
|
1806
|
+
id: `__header-${row.groupName}`
|
|
1807
|
+
}
|
|
1808
|
+
),
|
|
1809
|
+
renderGroupHeading ? renderGroupHeading(row.groupName) : row.groupName
|
|
1810
|
+
]
|
|
1811
|
+
},
|
|
1812
|
+
`__header-${row.groupName}`
|
|
1813
|
+
);
|
|
1796
1814
|
}
|
|
1797
1815
|
if (isCreatableSentinel(row)) {
|
|
1798
1816
|
return renderCreatableItem(row);
|
|
@@ -1988,6 +2006,7 @@ function MultiCombobox(props) {
|
|
|
1988
2006
|
inputType,
|
|
1989
2007
|
renderItem,
|
|
1990
2008
|
renderGroupHeading,
|
|
2009
|
+
isGroupHeaderDisabled,
|
|
1991
2010
|
renderCreatableItem: creatableProp ? (sentinel, style, index, measureRef) => renderCreatableItem(
|
|
1992
2011
|
sentinel,
|
|
1993
2012
|
style,
|