@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.
- package/.turbo/turbo-build.log +10 -10
- package/CHANGELOG.md +12 -0
- package/dist/esm/index.js +90 -83
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +119 -59
- package/dist/index.d.ts +119 -59
- package/dist/index.js +118 -111
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/ActionMenu/ActionMenu.tsx +2 -2
- package/src/Autocomplete/Autocomplete.stories.tsx +6 -18
- package/src/Autocomplete/Autocomplete.tsx +2 -3
- package/src/Autocomplete/AutocompleteTypes.ts +16 -12
- package/src/Autocomplete/MultiAutocomplete.tsx +26 -18
- package/src/Autocomplete/SingleAutocomplete.tsx +20 -9
- package/src/MenuContent/MenuContent.tsx +4 -4
- package/src/MenuContext.tsx +3 -0
- package/src/MenuFooter/MenuFooter.tsx +2 -2
- package/src/MenuGroup/MenuGroup.tsx +4 -4
- package/src/MenuHeader/MenuHeader.tsx +4 -2
- package/src/MenuLabel.tsx +32 -2
- package/src/MenuRoot/MenuRoot.tsx +7 -24
- package/src/MenuSearchInput/MenuSearchInput.tsx +5 -11
- package/src/MenuSearchTokenInput/MenuSearchTokenInput.tsx +6 -3
- package/src/MenuToggleButton/MenuToggleButton.tsx +11 -12
- package/src/MenuTokenInput.tsx +10 -4
- package/src/MultiSelectMenu/MultiSelectMenu.tsx +4 -3
- package/src/NestedMenu/NestedMenu.feature +2 -2
- package/src/NestedMenu/NestedMenuTypes.ts +3 -0
- package/src/SingleSelectMenu/SingleSelectMenu.tsx +5 -4
- package/src/hooks/useItemFiltering.tsx +2 -1
- package/src/hooks/useMenuChildren.tsx +1 -1
- package/src/types.ts +28 -15
|
@@ -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
|
|
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
|
|
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/
|
|
12
|
+
* @link https://seeds.sproutsocial.com/components/single-select-menu/
|
|
13
13
|
*
|
|
14
|
-
* @description A SingleSelectMenu allows a single selection of a {@link https://
|
|
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
|
-
*
|
|
17
|
-
* @see {@link https://
|
|
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:
|
|
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
|
|
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
|
|
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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|