@sproutsocial/seeds-react-menu 0.2.3 → 0.3.0

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.
@@ -8,14 +8,14 @@ CLI Target: es2022
8
8
  CLI Cleaning output folder
9
9
  CJS Build start
10
10
  ESM Build start
11
- ESM dist/esm/index.js 80.44 KB
12
- ESM dist/esm/index.js.map 253.72 KB
13
- ESM ⚡️ Build success in 647ms
14
- CJS dist/index.js 85.04 KB
15
- CJS dist/index.js.map 254.58 KB
16
- CJS ⚡️ Build success in 676ms
11
+ ESM dist/esm/index.js 80.99 KB
12
+ ESM dist/esm/index.js.map 254.93 KB
13
+ ESM ⚡️ Build success in 542ms
14
+ CJS dist/index.js 85.59 KB
15
+ CJS dist/index.js.map 255.79 KB
16
+ CJS ⚡️ Build success in 566ms
17
17
  DTS Build start
18
- DTS ⚡️ Build success in 16400ms
19
- DTS dist/index.d.ts 15.61 KB
20
- DTS dist/index.d.mts 15.61 KB
21
- Done in 20.31s.
18
+ DTS ⚡️ Build success in 15441ms
19
+ DTS dist/index.d.ts 15.86 KB
20
+ DTS dist/index.d.mts 15.86 KB
21
+ Done in 19.62s.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @sproutsocial/seeds-react-menu
2
2
 
3
+ ## 0.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 1178353: Implements isSingleSelect prop on MenuGroup
8
+ - This prop allows you to specify that only one item in the MenuGroup can be selected at a time.
9
+ - This prop is necessary if you need to combine multiple single-select MenuGroups or a mix of single-select and multi-select MenuGroups within a single Menu.
10
+ - In this case, you should use MultiSelectMenu and set isSingleSelect to true on the MenuGroup(s) that should only allow one selection.
11
+ - By contrast, the SingleSelectMenu component only allows one item to be selected across all MenuGroups.
12
+ - If you only have one MenuGroup, or if you only want to allow a single selection across all MenuGroups, you should use SingleSelectMenu instead.
13
+ - SingleSelectMenu ignores the `isSingleSelect` prop on MenuGroup.
14
+
3
15
  ## 0.2.3
4
16
 
5
17
  ### Patch Changes
package/dist/esm/index.js CHANGED
@@ -1900,12 +1900,12 @@ var MenuItem = ({
1900
1900
  ...props
1901
1901
  }) => {
1902
1902
  const { getItemProps, itemsMap, highlightedIndex, isListbox } = useContext3(MenuContext);
1903
+ const item = itemsMap[id] || { index: 0, id };
1903
1904
  const { ...optionProps } = useOptionProps({
1904
1905
  id,
1905
1906
  children,
1906
1907
  ...props
1907
1908
  });
1908
- const item = itemsMap[id] || { index: 0, id };
1909
1909
  const highlighted = highlightedIndex === item?.index;
1910
1910
  return /* @__PURE__ */ jsx3(MenuItemContainer, { role: "none", children: /* @__PURE__ */ jsx3(
1911
1911
  StyledMenuItem,
@@ -2225,6 +2225,8 @@ var MenuGroup = ({
2225
2225
  children,
2226
2226
  title,
2227
2227
  color: color2,
2228
+ isSingleSelect,
2229
+ id,
2228
2230
  ...rest
2229
2231
  }) => {
2230
2232
  const titleId = `menu-group-title-${Math.random().toString(36).slice(2, 11)}`;
@@ -2232,6 +2234,8 @@ var MenuGroup = ({
2232
2234
  StyledMenuGroup,
2233
2235
  {
2234
2236
  role: "group",
2237
+ id,
2238
+ isSingleSelect,
2235
2239
  "aria-labelledby": title ? titleId : void 0,
2236
2240
  color: color2,
2237
2241
  ...rest,
@@ -2365,12 +2369,16 @@ var useItemsFromChildren = ({
2365
2369
  const allMenuItemElements = getAllMenuItems(children);
2366
2370
  const menuItemsMap2 = {};
2367
2371
  const allMenuItems2 = allMenuItemElements.map(
2368
- ({ element }, index) => {
2372
+ ({ element, parents }, index) => {
2373
+ const parentMenuGroup = parents.find(
2374
+ (parent) => checkIfIsElement(parent, "MenuGroup")
2375
+ );
2369
2376
  const item = {
2370
2377
  id: element.props.id,
2371
2378
  disabled: element.props.disabled,
2372
2379
  index,
2373
- menuItemProps: element.props
2380
+ menuItemProps: element.props,
2381
+ menuGroupProps: parentMenuGroup ? parentMenuGroup.props : void 0
2374
2382
  };
2375
2383
  menuItemsMap2[`${item.id}`] = item;
2376
2384
  return item;
@@ -2604,6 +2612,12 @@ var MultiSelectMenu = ({
2604
2612
  } else {
2605
2613
  addSelectedItem(newSelectedItem);
2606
2614
  }
2615
+ if (newSelectedItem.menuGroupProps?.isSingleSelect) {
2616
+ const groupItems = selectedItems.filter(
2617
+ (item) => item.menuGroupProps?.id === newSelectedItem.menuGroupProps?.id
2618
+ );
2619
+ groupItems.forEach((item) => removeSelectedItem(item));
2620
+ }
2607
2621
  break;
2608
2622
  default:
2609
2623
  break;