@sproutsocial/seeds-react-menu 1.7.12 → 1.7.14

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/dist/v2/index.js CHANGED
@@ -247,7 +247,7 @@ function Popout({
247
247
  const radixRef = React2.useRef(null);
248
248
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Popover.Root, { open: popoverOpen, onOpenChange: popoverOnOpenChange, children: [
249
249
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Popover.Trigger, { ref: radixRef, asChild: true, children }),
250
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Popover.Anchor, {}),
250
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Popover.Anchor, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { height: "1px" }, children: "\xA0" }) }),
251
251
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Popover.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
252
252
  StyledContent,
253
253
  {
@@ -1245,7 +1245,12 @@ function SingleSelect({
1245
1245
  };
1246
1246
  }
1247
1247
  const dataItem = item;
1248
- const itemIndex = itemsForSelect.indexOf(dataItem);
1248
+ const itemIndex = itemsForSelect.findIndex((selectItem) => {
1249
+ if (isToggleItem(selectItem)) {
1250
+ return false;
1251
+ }
1252
+ return itemToKey(selectItem) === itemToKey(dataItem);
1253
+ });
1249
1254
  if (itemIndex === -1) {
1250
1255
  return {};
1251
1256
  }
@@ -1530,7 +1535,12 @@ function MultiSelect({
1530
1535
  };
1531
1536
  }
1532
1537
  const dataItem = item;
1533
- const itemIndex = itemsForSelect.indexOf(dataItem);
1538
+ const itemIndex = itemsForSelect.findIndex((selectItem) => {
1539
+ if (isGroupHeading(selectItem) || isToggleItem(selectItem)) {
1540
+ return false;
1541
+ }
1542
+ return itemToKey(selectItem) === itemToKey(dataItem);
1543
+ });
1534
1544
  if (itemIndex === -1) {
1535
1545
  return {};
1536
1546
  }
@@ -1629,10 +1639,14 @@ function SingleAutocomplete({
1629
1639
  (0, import_react10.useEffect)(() => {
1630
1640
  if (selectedItem && !isOpen) {
1631
1641
  const selectedItemString = itemToString(selectedItem);
1632
- if (!isInputValueControlled && uncontrolledInputValue !== selectedItemString) {
1633
- setUncontrolledInputValue(selectedItemString);
1634
- } else if (isInputValueControlled && inputValue !== selectedItemString) {
1635
- updateInputValue(selectedItemString);
1642
+ if (!isInputValueControlled) {
1643
+ if (uncontrolledInputValue !== selectedItemString) {
1644
+ setUncontrolledInputValue(selectedItemString);
1645
+ }
1646
+ } else {
1647
+ if (inputValue !== selectedItemString) {
1648
+ onInputValueChange?.(selectedItemString);
1649
+ }
1636
1650
  }
1637
1651
  }
1638
1652
  }, [
@@ -1640,7 +1654,9 @@ function SingleAutocomplete({
1640
1654
  isOpen,
1641
1655
  isInputValueControlled,
1642
1656
  itemToString,
1643
- uncontrolledInputValue
1657
+ uncontrolledInputValue,
1658
+ inputValue,
1659
+ onInputValueChange
1644
1660
  ]);
1645
1661
  const updateSelectedItem = (newSelectedItem) => {
1646
1662
  const newSelectedItemId = newSelectedItem ? itemToKey(newSelectedItem) : null;
@@ -1718,7 +1734,7 @@ function SingleAutocomplete({
1718
1734
  selectedItem: newSelectedItem,
1719
1735
  isOpen: newIsOpen
1720
1736
  }) {
1721
- if (newIsOpen !== void 0 && type !== import_downshift3.useCombobox.stateChangeTypes.InputBlur) {
1737
+ if (newIsOpen !== void 0) {
1722
1738
  updateIsOpen(newIsOpen);
1723
1739
  }
1724
1740
  switch (type) {
@@ -1768,12 +1784,6 @@ function SingleAutocomplete({
1768
1784
  inputProps["aria-controls"] = void 0;
1769
1785
  }
1770
1786
  const { ref, id: inputId, ...restProps } = inputProps;
1771
- const handleBlur = (e) => {
1772
- if (inputProps.onBlur) {
1773
- inputProps.onBlur(e);
1774
- }
1775
- updateIsOpen(false);
1776
- };
1777
1787
  return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1778
1788
  Popout,
1779
1789
  {
@@ -1794,7 +1804,12 @@ function SingleAutocomplete({
1794
1804
  getItemProps: (props) => {
1795
1805
  const item = items[props.index];
1796
1806
  const dataItem = item;
1797
- const itemIndex = itemsForCombobox.indexOf(dataItem);
1807
+ const itemIndex = itemsForCombobox.findIndex((comboboxItem) => {
1808
+ if (isToggleItem(comboboxItem)) {
1809
+ return false;
1810
+ }
1811
+ return itemToKey(comboboxItem) === itemToKey(dataItem);
1812
+ });
1798
1813
  if (itemIndex === -1) {
1799
1814
  return {};
1800
1815
  }
@@ -1820,9 +1835,7 @@ function SingleAutocomplete({
1820
1835
  {
1821
1836
  id,
1822
1837
  inputProps: {
1823
- ...restProps,
1824
- autoComplete: "off",
1825
- onBlur: handleBlur
1838
+ autoComplete: "off"
1826
1839
  },
1827
1840
  innerRef: ref,
1828
1841
  placeholder,
@@ -1832,8 +1845,7 @@ function SingleAutocomplete({
1832
1845
  updateSelectedItem(null);
1833
1846
  updateInputValue("");
1834
1847
  },
1835
- ...restProps,
1836
- onBlur: handleBlur
1848
+ ...restProps
1837
1849
  }
1838
1850
  )
1839
1851
  }
@@ -1843,12 +1855,16 @@ function SingleAutocomplete({
1843
1855
  // src/v2/Autocomplete/MultiAutocomplete.tsx
1844
1856
  var import_react11 = require("react");
1845
1857
  var import_downshift4 = require("downshift");
1846
- var import_seeds_react_label4 = require("@sproutsocial/seeds-react-label");
1847
1858
  var import_seeds_react_token_input = require("@sproutsocial/seeds-react-token-input");
1848
1859
  var import_jsx_runtime12 = require("react/jsx-runtime");
1849
1860
  function defaultReducer4(state, actionAndChanges) {
1850
1861
  const { changes, type } = actionAndChanges;
1851
1862
  switch (type) {
1863
+ case import_downshift4.useCombobox.stateChangeTypes.InputBlur:
1864
+ return {
1865
+ ...changes,
1866
+ isOpen: true
1867
+ };
1852
1868
  case import_downshift4.useCombobox.stateChangeTypes.InputKeyDownEnter:
1853
1869
  case import_downshift4.useCombobox.stateChangeTypes.ItemClick:
1854
1870
  return {
@@ -2025,7 +2041,6 @@ function MultiAutocomplete({
2025
2041
  } else {
2026
2042
  updateSelectedItems([...data]);
2027
2043
  }
2028
- updateInputValue("");
2029
2044
  } else if (selectHeadings && groupBy && isGroupHeading(newSelectedItem)) {
2030
2045
  const groupLabel = newSelectedItem.label;
2031
2046
  const groupItems2 = data.filter(
@@ -2043,7 +2058,6 @@ function MultiAutocomplete({
2043
2058
  ];
2044
2059
  updateSelectedItems(newItems);
2045
2060
  }
2046
- updateInputValue("");
2047
2061
  } else if (!isGroupHeading(newSelectedItem) && !isToggleItem(newSelectedItem)) {
2048
2062
  const itemIndex = selectedItems.findIndex(
2049
2063
  (item) => itemToKey(item) === itemToKey(newSelectedItem)
@@ -2055,7 +2069,6 @@ function MultiAutocomplete({
2055
2069
  } else {
2056
2070
  updateSelectedItems([...selectedItems, newSelectedItem]);
2057
2071
  }
2058
- updateInputValue("");
2059
2072
  }
2060
2073
  }
2061
2074
  break;
@@ -2093,6 +2106,7 @@ function MultiAutocomplete({
2093
2106
  if (inputProps.onBlur) {
2094
2107
  inputProps.onBlur(e);
2095
2108
  }
2109
+ updateIsOpen(false);
2096
2110
  };
2097
2111
  const inputPropsToSpread = { ...inputProps };
2098
2112
  delete inputPropsToSpread.onBlur;
@@ -2175,7 +2189,11 @@ function MultiAutocomplete({
2175
2189
  onClickToken: (e) => {
2176
2190
  e.stopPropagation();
2177
2191
  },
2178
- onBlur: handleBlur
2192
+ onBlur: handleBlur,
2193
+ "aria-controls": void 0,
2194
+ "aria-expanded": void 0,
2195
+ "aria-haspopup": void 0,
2196
+ type: void 0
2179
2197
  }
2180
2198
  )
2181
2199
  }