@sproutsocial/seeds-react-menu 1.12.0 → 1.12.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.
@@ -134,6 +134,8 @@ interface MultiComboboxBaseProps {
134
134
  loadingText?: string;
135
135
  disabled?: boolean;
136
136
  filter?: ((item: unknown, query: string) => boolean) | null;
137
+ inputValue?: string;
138
+ onInputValueChange?: (value: string) => void;
137
139
  }
138
140
  interface MultiComboboxDataProps<T extends DataWithId> extends MultiComboboxBaseProps {
139
141
  data: T[];
@@ -148,7 +150,7 @@ interface MultiComboboxDataProps<T extends DataWithId> extends MultiComboboxBase
148
150
  groupBy?: (item: T) => string;
149
151
  renderGroupHeading?: (label: string) => react.ReactNode;
150
152
  selectHeadings?: boolean;
151
- selectAll?: boolean;
153
+ selectAll?: boolean | string;
152
154
  isVirtualized?: boolean;
153
155
  removeSelectedItems?: boolean;
154
156
  maxTokens?: number;
@@ -134,6 +134,8 @@ interface MultiComboboxBaseProps {
134
134
  loadingText?: string;
135
135
  disabled?: boolean;
136
136
  filter?: ((item: unknown, query: string) => boolean) | null;
137
+ inputValue?: string;
138
+ onInputValueChange?: (value: string) => void;
137
139
  }
138
140
  interface MultiComboboxDataProps<T extends DataWithId> extends MultiComboboxBaseProps {
139
141
  data: T[];
@@ -148,7 +150,7 @@ interface MultiComboboxDataProps<T extends DataWithId> extends MultiComboboxBase
148
150
  groupBy?: (item: T) => string;
149
151
  renderGroupHeading?: (label: string) => react.ReactNode;
150
152
  selectHeadings?: boolean;
151
- selectAll?: boolean;
153
+ selectAll?: boolean | string;
152
154
  isVirtualized?: boolean;
153
155
  removeSelectedItems?: boolean;
154
156
  maxTokens?: number;
package/dist/v3/index.js CHANGED
@@ -1498,7 +1498,9 @@ function MultiCombobox(props) {
1498
1498
  emptyText = "No results found.",
1499
1499
  isLoading = false,
1500
1500
  loadingText = "Loading...",
1501
- filter
1501
+ filter,
1502
+ inputValue,
1503
+ onInputValueChange
1502
1504
  } = props;
1503
1505
  const isChildrenMode = "children" in props && props.children != null;
1504
1506
  const data = isChildrenMode ? [] : props.data;
@@ -1512,7 +1514,9 @@ function MultiCombobox(props) {
1512
1514
  const groupBy = isChildrenMode ? void 0 : props.groupBy;
1513
1515
  const renderGroupHeading = isChildrenMode ? void 0 : props.renderGroupHeading;
1514
1516
  const selectHeadings = isChildrenMode ? false : props.selectHeadings ?? false;
1515
- const selectAll = isChildrenMode ? false : props.selectAll ?? false;
1517
+ const selectAllProp = isChildrenMode ? false : props.selectAll ?? false;
1518
+ const selectAll = Boolean(selectAllProp);
1519
+ const selectAllLabel = typeof selectAllProp === "string" ? selectAllProp : "Select all";
1516
1520
  const isVirtualized = isChildrenMode ? false : props.isVirtualized ?? false;
1517
1521
  const children = isChildrenMode ? props.children : void 0;
1518
1522
  const selectedItemIds = props.selectedItemIds;
@@ -1539,15 +1543,20 @@ function MultiCombobox(props) {
1539
1543
  [visibleData, groupBy]
1540
1544
  );
1541
1545
  const flatItems = React9.useMemo(() => {
1542
- if (!groups || !selectHeadings && !selectAll) return null;
1546
+ if (!selectHeadings && !selectAll) return null;
1547
+ if (!groups && !selectAll) return null;
1543
1548
  const rows = [];
1544
1549
  if (selectAll) rows.push(SELECT_ALL_SENTINEL);
1545
- for (const group of groups) {
1546
- rows.push(makeGroupHeaderSentinel(group.value));
1547
- rows.push(...group.items);
1550
+ if (groups) {
1551
+ for (const group of groups) {
1552
+ rows.push(makeGroupHeaderSentinel(group.value));
1553
+ rows.push(...group.items);
1554
+ }
1555
+ } else {
1556
+ rows.push(...visibleData);
1548
1557
  }
1549
1558
  return rows;
1550
- }, [groups, selectHeadings, selectAll]);
1559
+ }, [groups, visibleData, selectHeadings, selectAll]);
1551
1560
  function setSelectedItems(items) {
1552
1561
  if (!isControlled) setInternalValue(items);
1553
1562
  if (onSelectedItemIdsChange)
@@ -1605,7 +1614,7 @@ function MultiCombobox(props) {
1605
1614
  const state = selectedCount === 0 ? "none" : selectedCount === totalCount ? "all" : "partial";
1606
1615
  return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(ComboboxSelectAllItem, { value: row, children: [
1607
1616
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ComboboxGroupHeaderCheckbox, { $state: state, id: "__selectAll" }),
1608
- "Select all"
1617
+ selectAllLabel
1609
1618
  ] }, "__selectAll");
1610
1619
  }
1611
1620
  if (isGroupHeaderSentinel2(row)) {
@@ -1653,8 +1662,13 @@ function MultiCombobox(props) {
1653
1662
  virtualized: isVirtualized,
1654
1663
  open,
1655
1664
  disabled: props.disabled,
1656
- onOpenChange: setOpen,
1665
+ onOpenChange: (nextOpen, eventDetails) => {
1666
+ if (!nextOpen && eventDetails.reason === "item-press") return;
1667
+ setOpen(nextOpen);
1668
+ },
1657
1669
  filter,
1670
+ inputValue,
1671
+ onInputValueChange,
1658
1672
  onItemHighlighted: isVirtualized ? (item, { reason, index }) => {
1659
1673
  const virt = virtualizerRef.current;
1660
1674
  if (!item || !virt) return;