@sproutsocial/seeds-react-menu 1.2.1 → 1.2.3

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.
@@ -30,7 +30,7 @@ Feature: NestedMenu
30
30
 
31
31
  Scenario: User can select a child menu without closing the menu
32
32
  Given the NestedMenu is open
33
- When an menu item that triggers a child menu is clicked
33
+ When a menu item that triggers a child menu is clicked
34
34
  Then the menu will stay open
35
35
  And the menu will not use its default open/close behavior
36
36
 
@@ -75,7 +75,7 @@ Feature: NestedMenu
75
75
 
76
76
  Scenario: A Menu stays open when a menu item with a childMenuId is clicked
77
77
  Given the NestedMenu is open
78
- When an menu item that triggers a child menu is clicked
78
+ When a menu item that triggers a child menu is clicked
79
79
  Then the menu will stay open
80
80
  And the menu will not use its default open/close behavior
81
81
 
@@ -27,13 +27,16 @@ export interface TypeNestedMenuHeaderProps extends TypeMenuHeaderProps {
27
27
  }
28
28
 
29
29
  export interface TypeNestedMenuItemProps extends TypeMenuItemProps {
30
+ /** The id of the menu to be displayed when this item is selected. */
30
31
  childMenuId?: string;
31
32
  }
32
33
 
33
34
  export interface TypeNestedMenuProps<
34
35
  I extends TypeMenuItemProps = TypeNestedMenuItemProps
35
36
  > extends Omit<TypeActionMenuBaseProps, "MenuRootComponent"> {
37
+ /** The id of the menu to display when the NestedMenu is opened. */
36
38
  initialMenuId: string;
39
+ /** An optional callback to fire when the back button is clicked.*/
37
40
  onBackButtonClick?: (menuId: string) => void;
38
41
  /** Sets the default localized label for the back arrow in all child menus.
39
42
  * This label can be overridden by including backArrowLabel in a menu's menuHeaderProps. */
@@ -9,12 +9,13 @@ import { MenuRoot, type TypeMenuRootProps } from "../MenuRoot";
9
9
  import type { TypeSingleSelectMenuProps } from "./SingleSelectMenuTypes";
10
10
 
11
11
  /**
12
- * @link https://seeds.sproutsocial.com/components/singleselect-menu/
12
+ * @link https://seeds.sproutsocial.com/components/single-select-menu/
13
13
  *
14
- * @description A SingleSelectMenu allows a single selection of a {@link https://github.com/sproutsocial/seeds/tree/dev/seeds-react/seeds-react-menu/src/MenuItem | MenuItem} from a list or groups or lists.
14
+ * @description A SingleSelectMenu allows a single selection of a {@link https://seeds.sproutsocial.com/components/seeds-react-menu/#menuitem MenuItem} from a list or groups or lists.
15
15
  *
16
- * **To trigger actions from a menu:**
17
- * @see {@link https://github.com/sproutsocial/seeds/tree/dev/seeds-react/seeds-react-menu/src/ActionMenu | ActionMenu}
16
+ * @see {@link https://seeds.sproutsocial.com/components/action-menu/ ActionMenu} for triggering actions from a menu
17
+ * @see {@link https://seeds.sproutsocial.com/components/multi-select-menu/ MultiSelectMenu} for selecting multiple items
18
+ * @see {@link https://seeds.sproutsocial.com/components/seeds-react-menu/#menugroup MenuGroup}'s isSingleSelect prop to create a single select group within a MultiSelectMenu
18
19
  */
19
20
 
20
21
  export const SingleSelectMenu = <
@@ -3,8 +3,9 @@ import type { TypeMenuContext } from "../MenuContext";
3
3
  import type { TypeInternalItemProps } from "../types";
4
4
  import { itemToString as defaultItemToString } from "../utils/downshiftDefaults";
5
5
 
6
+ /* Receives the internal Downshift version of the item, which is different from TypeMenuItemProps*/
6
7
  export type TypeGetIsItemVisibleFn = (
7
- item: TypeMenuContext["items"][number],
8
+ item: TypeInternalItemProps,
8
9
  inputValue: string
9
10
  ) => boolean;
10
11
 
@@ -262,7 +262,7 @@ export const useMenuChildren = <
262
262
  const menuItemsMap: TypeMenuContext["itemsMap"] = {};
263
263
  const allMenuItems: TypeMenuContext["items"] = [];
264
264
 
265
- // If an menuItems prop was passed to the Menu, we can bypass the children traversal.
265
+ // If a menuItems prop was passed to the Menu, we can bypass the children traversal.
266
266
  if (menuItems && menuItems.length) {
267
267
  menuItems.forEach((menuItem) => {
268
268
  addMenuItem({ itemProps: menuItem, allMenuItems, menuItemsMap });
package/src/types.ts CHANGED
@@ -3,7 +3,7 @@ import type { TypeMenuItemProps } from "./MenuItem";
3
3
  import type { TypeMenuGroupBaseProps } from "./MenuGroup";
4
4
  import type { TypeMenuRootOwnProps, TypeMenuRootProps } from "./MenuRoot";
5
5
 
6
- // The items object used internally for Menu functionality
6
+ // The item object used internally for Menu functionality
7
7
  export interface TypeInternalItemProps<Item = TypeMenuItemProps> {
8
8
  id: string;
9
9
  index: number;
@@ -13,25 +13,38 @@ export interface TypeInternalItemProps<Item = TypeMenuItemProps> {
13
13
  }
14
14
 
15
15
  export interface TypeHigherOrderComponentProps extends TypeMenuRootOwnProps {
16
+ /** Overrides the default MenuRoot component. Only necessary for specialized use cases.*/
16
17
  MenuRootComponent?: React.ComponentType<TypeMenuRootProps>;
17
18
  }
18
19
 
20
+ // Partial type, for react-docgen. Refined to the two valid configurations below.
21
+ type TypeBaseChildrenOrItems<I extends TypeMenuItemProps = TypeMenuItemProps> =
22
+ {
23
+ /** Allows menu items to be passed in as children. Cannot be used with the menuItems prop.*/
24
+ children?: TypeNotEmptyChildren;
25
+ /** Allows menu items to be passed in as objects. Cannot be used with the children prop.
26
+ * The type of each menu item, I, must be or extend TypeMenuItemProps. */
27
+ menuItems?: I[];
28
+ /** Allows a custom MenuItem component to be used when rendering using the menuItems prop.
29
+ * MenuItemComponent's prop type must match the type of the menuItems, I. */
30
+ MenuItemComponent?: React.ComponentType<I>;
31
+ };
32
+
19
33
  export type TypeChildrenOrItems<
20
34
  I extends TypeMenuItemProps = TypeMenuItemProps
21
- > =
22
- | {
23
- /** Allows menu items to be passed in as children. Cannot be used with the items prop.*/
24
- children: TypeMenuRootProps["children"];
25
- menuItems?: never;
26
- MenuItemComponent?: never;
27
- }
28
- | {
29
- children?: never;
30
- /** Allows menu items to be passed in as objects. Cannot be used with the children prop.*/
31
- menuItems: I[];
32
- /** Allows a custom MenuItem component to be used when rendering using the items prop.*/
33
- MenuItemComponent?: React.ComponentType<I>;
34
- };
35
+ > = TypeBaseChildrenOrItems<I> &
36
+ (
37
+ | {
38
+ children: TypeNotEmptyChildren;
39
+ menuItems?: never;
40
+ MenuItemComponent?: never;
41
+ }
42
+ | {
43
+ children?: never;
44
+ menuItems: I[];
45
+ MenuItemComponent?: React.ComponentType<I>;
46
+ }
47
+ );
35
48
 
36
49
  export type TypeNotEmptyChildren =
37
50
  | React.ReactChild