@sproutsocial/seeds-react-menu 1.2.0 → 1.2.2
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 +14 -0
- package/dist/esm/index.js +106 -76
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +120 -60
- package/dist/index.d.ts +120 -60
- package/dist/index.js +130 -105
- 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 +7 -19
- package/src/Autocomplete/Autocomplete.tsx +2 -3
- package/src/Autocomplete/AutocompleteTypes.ts +16 -12
- package/src/Autocomplete/SingleAutocomplete.tsx +2 -3
- package/src/MenuContent/MenuContent.tsx +4 -4
- package/src/MenuContext.tsx +6 -1
- 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 +46 -27
- 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/NestedMenu.tsx +3 -0
- 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
|
@@ -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
|