@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.
- package/.turbo/turbo-build.log +10 -10
- package/CHANGELOG.md +12 -0
- package/dist/esm/index.js +17 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +45 -39
- package/dist/index.d.ts +45 -39
- package/dist/index.js +17 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/MenuContent/MenuContent.tsx +2 -2
- package/src/MenuGroup/MenuGroup.feature +15 -15
- package/src/MenuGroup/MenuGroup.tsx +6 -2
- package/src/MenuGroup/MenuGroupTypes.ts +2 -0
- package/src/MenuGroup/__tests__/MenuGroup.test.tsx +144 -9
- package/src/MenuGroup/__tests__/MenuGroup.typetest.tsx +24 -12
- package/src/MenuItem/MenuItem.tsx +1 -1
- package/src/MenuRoot/__tests__/MenuRoot.test.tsx +1 -1
- package/src/MultiSelectMenu/MultiSelectMenu.tsx +8 -0
- package/src/MultiSelectMenu/__tests__/MultiSelectMenu.test.tsx +6 -6
- package/src/SingleSelectMenu/__tests__/SingleSelectMenu.test.tsx +3 -3
- package/src/hooks/useItemsFromChildren.tsx +12 -5
- package/src/types.ts +2 -0
package/dist/index.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as downshift from 'downshift';
|
|
3
3
|
import { GetItemPropsOptions, UseComboboxProps, UseSelectProps, UseMultipleSelectionProps, UseComboboxReturnValue, UseSelectReturnValue, UseMultipleSelectionReturnValue } from 'downshift';
|
|
4
|
-
import { TypeBorderSystemProps, TypeColorSystemProps, TypeFlexboxSystemProps, TypeGridSystemProps, TypeLayoutSystemProps, TypePositionSystemProps, TypeSpaceSystemProps, TypeTypographySystemProps, TypeStyledComponentsCommonProps } from '@sproutsocial/seeds-react-system-props';
|
|
5
|
-
import * as styled_components from 'styled-components';
|
|
6
4
|
import * as React$1 from 'react';
|
|
7
5
|
import React__default, { ReactNode } from 'react';
|
|
6
|
+
import { TypeBorderSystemProps, TypeColorSystemProps, TypeFlexboxSystemProps, TypeGridSystemProps, TypeLayoutSystemProps, TypePositionSystemProps, TypeSpaceSystemProps, TypeTypographySystemProps, TypeStyledComponentsCommonProps } from '@sproutsocial/seeds-react-system-props';
|
|
7
|
+
import * as styled_components from 'styled-components';
|
|
8
8
|
import { HTMLMotionProps } from 'motion/react';
|
|
9
9
|
import { TypeBoxProps } from '@sproutsocial/seeds-react-box';
|
|
10
10
|
export { TypeBoxProps as TypeMenuFooterProps } from '@sproutsocial/seeds-react-box';
|
|
@@ -22,11 +22,47 @@ declare const MENU_ITEM_ROLES: {
|
|
|
22
22
|
};
|
|
23
23
|
type TypeMenuItemRoles = (typeof MENU_ITEM_ROLES)[keyof typeof MENU_ITEM_ROLES];
|
|
24
24
|
|
|
25
|
+
interface TypeMenuGroupStyledProps extends TypeBorderSystemProps, TypeColorSystemProps, TypeFlexboxSystemProps, TypeGridSystemProps, TypeLayoutSystemProps, TypePositionSystemProps, TypeSpaceSystemProps, TypeTypographySystemProps {
|
|
26
|
+
}
|
|
27
|
+
interface TypeMenuGroupProps extends TypeMenuGroupStyledProps, Omit<React.ComponentPropsWithoutRef<"ul">, "color"> {
|
|
28
|
+
id: string;
|
|
29
|
+
isSingleSelect?: boolean;
|
|
30
|
+
title?: string;
|
|
31
|
+
children: ReactNode;
|
|
32
|
+
titleAs?: string | React.ComponentType<any>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @link https://seeds.sproutsocial.com/components/menu-group/
|
|
37
|
+
*
|
|
38
|
+
* @description MenuGroup is used to group lists of {@link https://github.com/sproutsocial/seeds/tree/dev/seeds-react/seeds-react-menu/src/MenuItem | MenuItems}.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* <ActionMenu>
|
|
42
|
+
* <MenuContent>
|
|
43
|
+
* <MenuGroup title="Group 1" id="1">
|
|
44
|
+
* <MenuItem>Item 1</MenuItem>
|
|
45
|
+
* </MenuGroup>
|
|
46
|
+
* <MenuGroup title="Group 2" id="2">
|
|
47
|
+
* <MenuItem>Item 2</MenuItem>
|
|
48
|
+
* </MenuGroup>
|
|
49
|
+
* </MenuContent>
|
|
50
|
+
* </ActionMenu>
|
|
51
|
+
*
|
|
52
|
+
* @see {@link https://seeds.sproutsocial.com/components/menu-item/ | MenuItem}
|
|
53
|
+
*/
|
|
54
|
+
declare const MenuGroup: ({ titleAs, children, title, color, isSingleSelect, id, ...rest }: TypeMenuGroupProps) => react_jsx_runtime.JSX.Element;
|
|
55
|
+
|
|
56
|
+
declare const StyledMenuGroup: styled_components.StyledComponent<"li", styled_components.DefaultTheme, TypeMenuGroupProps, never>;
|
|
57
|
+
declare const StyledTitle: styled_components.StyledComponent<React$1.FC<_sproutsocial_seeds_react_text.TypeTextProps>, styled_components.DefaultTheme, {}, never>;
|
|
58
|
+
declare const StyledMenuGroupUl: styled_components.StyledComponent<"ul", styled_components.DefaultTheme, {}, never>;
|
|
59
|
+
|
|
25
60
|
interface TypeDefaultItemProps {
|
|
26
61
|
id: string;
|
|
27
62
|
index: number;
|
|
28
63
|
disabled?: boolean;
|
|
29
64
|
menuItemProps?: TypeMenuItemProps;
|
|
65
|
+
menuGroupProps?: TypeMenuGroupProps;
|
|
30
66
|
}
|
|
31
67
|
type TypeNotEmptyChildren = React.ReactChild | React.ReactFragment | React.ReactPortal;
|
|
32
68
|
|
|
@@ -87,10 +123,10 @@ interface TypeMenuContentProps extends HTMLMotionProps<"ul"> {
|
|
|
87
123
|
* <ActionMenu>
|
|
88
124
|
* <MenuHeader>Header</MenuHeader>
|
|
89
125
|
* <MenuContent>
|
|
90
|
-
* <MenuGroup>
|
|
126
|
+
* <MenuGroup id="1">
|
|
91
127
|
* <MenuItem>Item 1</MenuItem>
|
|
92
128
|
* </MenuGroup>
|
|
93
|
-
* <MenuGroup>
|
|
129
|
+
* <MenuGroup id="2">
|
|
94
130
|
* <MenuItem>Item 2</MenuItem>
|
|
95
131
|
* </MenuGroup>
|
|
96
132
|
* </MenuContent>
|
|
@@ -111,39 +147,6 @@ declare const MenuContent: ({ id, children, ...rest }: TypeMenuContentProps) =>
|
|
|
111
147
|
*/
|
|
112
148
|
declare const MenuFooter: ({ children, ...rest }: TypeBoxProps) => react_jsx_runtime.JSX.Element;
|
|
113
149
|
|
|
114
|
-
interface TypeMenuGroupStyledProps extends TypeBorderSystemProps, TypeColorSystemProps, TypeFlexboxSystemProps, TypeGridSystemProps, TypeLayoutSystemProps, TypePositionSystemProps, TypeSpaceSystemProps, TypeTypographySystemProps {
|
|
115
|
-
}
|
|
116
|
-
interface TypeMenuGroupProps extends TypeMenuGroupStyledProps, Omit<React.ComponentPropsWithoutRef<"ul">, "color"> {
|
|
117
|
-
title?: string;
|
|
118
|
-
children: ReactNode;
|
|
119
|
-
titleAs?: string | React.ComponentType<any>;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* @link https://seeds.sproutsocial.com/components/menu-group/
|
|
124
|
-
*
|
|
125
|
-
* @description MenuGroup is used to group lists of {@link https://github.com/sproutsocial/seeds/tree/dev/seeds-react/seeds-react-menu/src/MenuItem | MenuItems}.
|
|
126
|
-
*
|
|
127
|
-
* @example
|
|
128
|
-
* <ActionMenu>
|
|
129
|
-
* <MenuContent>
|
|
130
|
-
* <MenuGroup title="Group 1">
|
|
131
|
-
* <MenuItem>Item 1</MenuItem>
|
|
132
|
-
* </MenuGroup>
|
|
133
|
-
* <MenuGroup title="Group 1">
|
|
134
|
-
* <MenuItem>Item 2</MenuItem>
|
|
135
|
-
* </MenuGroup>
|
|
136
|
-
* </MenuContent>
|
|
137
|
-
* </ActionMenu>
|
|
138
|
-
*
|
|
139
|
-
* @see {@link https://seeds.sproutsocial.com/components/menu-item/ | MenuItem}
|
|
140
|
-
*/
|
|
141
|
-
declare const MenuGroup: ({ titleAs, children, title, color, ...rest }: TypeMenuGroupProps) => react_jsx_runtime.JSX.Element;
|
|
142
|
-
|
|
143
|
-
declare const StyledMenuGroup: styled_components.StyledComponent<"li", styled_components.DefaultTheme, TypeMenuGroupProps, never>;
|
|
144
|
-
declare const StyledTitle: styled_components.StyledComponent<React$1.FC<_sproutsocial_seeds_react_text.TypeTextProps>, styled_components.DefaultTheme, {}, never>;
|
|
145
|
-
declare const StyledMenuGroupUl: styled_components.StyledComponent<"ul", styled_components.DefaultTheme, {}, never>;
|
|
146
|
-
|
|
147
150
|
interface TypeDownshiftComboboxProps extends Partial<UseComboboxProps<TypeDefaultItemProps>> {
|
|
148
151
|
}
|
|
149
152
|
interface TypeDownshiftSelectProps extends Partial<UseSelectProps<TypeDefaultItemProps>> {
|
|
@@ -265,10 +268,13 @@ declare const MultiSelectMenu: ({ children, stateReducer: externalStateReducer,
|
|
|
265
268
|
interface TypeUseItemsFromChildrenProps {
|
|
266
269
|
children: ReactNode;
|
|
267
270
|
}
|
|
268
|
-
interface
|
|
271
|
+
interface TypeItemElement {
|
|
269
272
|
element: React__default.ReactElement<TypeMenuItemProps>;
|
|
270
273
|
parents: readonly React__default.ReactNode[];
|
|
271
274
|
}
|
|
275
|
+
interface TypeMenuGroupElement {
|
|
276
|
+
element: React__default.ReactElement<TypeMenuGroupProps>;
|
|
277
|
+
}
|
|
272
278
|
declare const useItemsFromChildren: ({ children, }: TypeUseItemsFromChildrenProps) => {
|
|
273
279
|
allMenuItems: TypeDefaultItemProps[];
|
|
274
280
|
menuItemsMap: {
|
|
@@ -282,4 +288,4 @@ declare const defaultUseSelectProps: {
|
|
|
282
288
|
isItemDisabled: (item: any) => boolean;
|
|
283
289
|
};
|
|
284
290
|
|
|
285
|
-
export { ActionMenu, INPUT_TYPES, type InputType, MenuContent, MenuContext, MenuFooter, MenuGroup, MenuHeader, MenuItem, MenuItemAction, MenuItemContainer, MenuItemRow, MenuItemText, MenuLabel, MenuProvider, MenuRoot, MenuToggleButton, MultiSelectMenu, SingleSelectMenu, StyledMenuGroup, StyledMenuGroupUl, StyledMenuItem, StyledTitle, type TypeActionMenuProps, type TypeDefaultItemProps, type TypeDownshiftComboboxProps, type TypeDownshiftComboboxReturnValue, type TypeDownshiftMultiSelectProps, type TypeDownshiftMultiSelectReturnValue, type TypeDownshiftSelectProps, type TypeDownshiftSelectReturnValue, type
|
|
291
|
+
export { ActionMenu, INPUT_TYPES, type InputType, MenuContent, MenuContext, MenuFooter, MenuGroup, MenuHeader, MenuItem, MenuItemAction, MenuItemContainer, MenuItemRow, MenuItemText, MenuLabel, MenuProvider, MenuRoot, MenuToggleButton, MultiSelectMenu, SingleSelectMenu, StyledMenuGroup, StyledMenuGroupUl, StyledMenuItem, StyledTitle, type TypeActionMenuProps, type TypeDefaultItemProps, type TypeDownshiftComboboxProps, type TypeDownshiftComboboxReturnValue, type TypeDownshiftMultiSelectProps, type TypeDownshiftMultiSelectReturnValue, type TypeDownshiftSelectProps, type TypeDownshiftSelectReturnValue, type TypeItemElement, type TypeMenuContentProps, type TypeMenuContext, type TypeMenuContextProps, type TypeMenuGroupElement, type TypeMenuGroupProps, type TypeMenuGroupStyledProps, type TypeMenuHeaderProps, type TypeMenuItemProps, type TypeMenuItemStyledProps, type TypeMenuProviderProps, type TypeMenuRootOwnProps, type TypeMenuRootProps, type TypeMenuToggleButtonProps, type TypeMultiSelectMenuProps, type TypeNotEmptyChildren, type TypeSingleSelectMenuProps, type TypeUseItemsFromChildrenProps, defaultUseSelectProps, useItemsFromChildren, useMenu, useMenuContext, useSelectStateReducer };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as downshift from 'downshift';
|
|
3
3
|
import { GetItemPropsOptions, UseComboboxProps, UseSelectProps, UseMultipleSelectionProps, UseComboboxReturnValue, UseSelectReturnValue, UseMultipleSelectionReturnValue } from 'downshift';
|
|
4
|
-
import { TypeBorderSystemProps, TypeColorSystemProps, TypeFlexboxSystemProps, TypeGridSystemProps, TypeLayoutSystemProps, TypePositionSystemProps, TypeSpaceSystemProps, TypeTypographySystemProps, TypeStyledComponentsCommonProps } from '@sproutsocial/seeds-react-system-props';
|
|
5
|
-
import * as styled_components from 'styled-components';
|
|
6
4
|
import * as React$1 from 'react';
|
|
7
5
|
import React__default, { ReactNode } from 'react';
|
|
6
|
+
import { TypeBorderSystemProps, TypeColorSystemProps, TypeFlexboxSystemProps, TypeGridSystemProps, TypeLayoutSystemProps, TypePositionSystemProps, TypeSpaceSystemProps, TypeTypographySystemProps, TypeStyledComponentsCommonProps } from '@sproutsocial/seeds-react-system-props';
|
|
7
|
+
import * as styled_components from 'styled-components';
|
|
8
8
|
import { HTMLMotionProps } from 'motion/react';
|
|
9
9
|
import { TypeBoxProps } from '@sproutsocial/seeds-react-box';
|
|
10
10
|
export { TypeBoxProps as TypeMenuFooterProps } from '@sproutsocial/seeds-react-box';
|
|
@@ -22,11 +22,47 @@ declare const MENU_ITEM_ROLES: {
|
|
|
22
22
|
};
|
|
23
23
|
type TypeMenuItemRoles = (typeof MENU_ITEM_ROLES)[keyof typeof MENU_ITEM_ROLES];
|
|
24
24
|
|
|
25
|
+
interface TypeMenuGroupStyledProps extends TypeBorderSystemProps, TypeColorSystemProps, TypeFlexboxSystemProps, TypeGridSystemProps, TypeLayoutSystemProps, TypePositionSystemProps, TypeSpaceSystemProps, TypeTypographySystemProps {
|
|
26
|
+
}
|
|
27
|
+
interface TypeMenuGroupProps extends TypeMenuGroupStyledProps, Omit<React.ComponentPropsWithoutRef<"ul">, "color"> {
|
|
28
|
+
id: string;
|
|
29
|
+
isSingleSelect?: boolean;
|
|
30
|
+
title?: string;
|
|
31
|
+
children: ReactNode;
|
|
32
|
+
titleAs?: string | React.ComponentType<any>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @link https://seeds.sproutsocial.com/components/menu-group/
|
|
37
|
+
*
|
|
38
|
+
* @description MenuGroup is used to group lists of {@link https://github.com/sproutsocial/seeds/tree/dev/seeds-react/seeds-react-menu/src/MenuItem | MenuItems}.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* <ActionMenu>
|
|
42
|
+
* <MenuContent>
|
|
43
|
+
* <MenuGroup title="Group 1" id="1">
|
|
44
|
+
* <MenuItem>Item 1</MenuItem>
|
|
45
|
+
* </MenuGroup>
|
|
46
|
+
* <MenuGroup title="Group 2" id="2">
|
|
47
|
+
* <MenuItem>Item 2</MenuItem>
|
|
48
|
+
* </MenuGroup>
|
|
49
|
+
* </MenuContent>
|
|
50
|
+
* </ActionMenu>
|
|
51
|
+
*
|
|
52
|
+
* @see {@link https://seeds.sproutsocial.com/components/menu-item/ | MenuItem}
|
|
53
|
+
*/
|
|
54
|
+
declare const MenuGroup: ({ titleAs, children, title, color, isSingleSelect, id, ...rest }: TypeMenuGroupProps) => react_jsx_runtime.JSX.Element;
|
|
55
|
+
|
|
56
|
+
declare const StyledMenuGroup: styled_components.StyledComponent<"li", styled_components.DefaultTheme, TypeMenuGroupProps, never>;
|
|
57
|
+
declare const StyledTitle: styled_components.StyledComponent<React$1.FC<_sproutsocial_seeds_react_text.TypeTextProps>, styled_components.DefaultTheme, {}, never>;
|
|
58
|
+
declare const StyledMenuGroupUl: styled_components.StyledComponent<"ul", styled_components.DefaultTheme, {}, never>;
|
|
59
|
+
|
|
25
60
|
interface TypeDefaultItemProps {
|
|
26
61
|
id: string;
|
|
27
62
|
index: number;
|
|
28
63
|
disabled?: boolean;
|
|
29
64
|
menuItemProps?: TypeMenuItemProps;
|
|
65
|
+
menuGroupProps?: TypeMenuGroupProps;
|
|
30
66
|
}
|
|
31
67
|
type TypeNotEmptyChildren = React.ReactChild | React.ReactFragment | React.ReactPortal;
|
|
32
68
|
|
|
@@ -87,10 +123,10 @@ interface TypeMenuContentProps extends HTMLMotionProps<"ul"> {
|
|
|
87
123
|
* <ActionMenu>
|
|
88
124
|
* <MenuHeader>Header</MenuHeader>
|
|
89
125
|
* <MenuContent>
|
|
90
|
-
* <MenuGroup>
|
|
126
|
+
* <MenuGroup id="1">
|
|
91
127
|
* <MenuItem>Item 1</MenuItem>
|
|
92
128
|
* </MenuGroup>
|
|
93
|
-
* <MenuGroup>
|
|
129
|
+
* <MenuGroup id="2">
|
|
94
130
|
* <MenuItem>Item 2</MenuItem>
|
|
95
131
|
* </MenuGroup>
|
|
96
132
|
* </MenuContent>
|
|
@@ -111,39 +147,6 @@ declare const MenuContent: ({ id, children, ...rest }: TypeMenuContentProps) =>
|
|
|
111
147
|
*/
|
|
112
148
|
declare const MenuFooter: ({ children, ...rest }: TypeBoxProps) => react_jsx_runtime.JSX.Element;
|
|
113
149
|
|
|
114
|
-
interface TypeMenuGroupStyledProps extends TypeBorderSystemProps, TypeColorSystemProps, TypeFlexboxSystemProps, TypeGridSystemProps, TypeLayoutSystemProps, TypePositionSystemProps, TypeSpaceSystemProps, TypeTypographySystemProps {
|
|
115
|
-
}
|
|
116
|
-
interface TypeMenuGroupProps extends TypeMenuGroupStyledProps, Omit<React.ComponentPropsWithoutRef<"ul">, "color"> {
|
|
117
|
-
title?: string;
|
|
118
|
-
children: ReactNode;
|
|
119
|
-
titleAs?: string | React.ComponentType<any>;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* @link https://seeds.sproutsocial.com/components/menu-group/
|
|
124
|
-
*
|
|
125
|
-
* @description MenuGroup is used to group lists of {@link https://github.com/sproutsocial/seeds/tree/dev/seeds-react/seeds-react-menu/src/MenuItem | MenuItems}.
|
|
126
|
-
*
|
|
127
|
-
* @example
|
|
128
|
-
* <ActionMenu>
|
|
129
|
-
* <MenuContent>
|
|
130
|
-
* <MenuGroup title="Group 1">
|
|
131
|
-
* <MenuItem>Item 1</MenuItem>
|
|
132
|
-
* </MenuGroup>
|
|
133
|
-
* <MenuGroup title="Group 1">
|
|
134
|
-
* <MenuItem>Item 2</MenuItem>
|
|
135
|
-
* </MenuGroup>
|
|
136
|
-
* </MenuContent>
|
|
137
|
-
* </ActionMenu>
|
|
138
|
-
*
|
|
139
|
-
* @see {@link https://seeds.sproutsocial.com/components/menu-item/ | MenuItem}
|
|
140
|
-
*/
|
|
141
|
-
declare const MenuGroup: ({ titleAs, children, title, color, ...rest }: TypeMenuGroupProps) => react_jsx_runtime.JSX.Element;
|
|
142
|
-
|
|
143
|
-
declare const StyledMenuGroup: styled_components.StyledComponent<"li", styled_components.DefaultTheme, TypeMenuGroupProps, never>;
|
|
144
|
-
declare const StyledTitle: styled_components.StyledComponent<React$1.FC<_sproutsocial_seeds_react_text.TypeTextProps>, styled_components.DefaultTheme, {}, never>;
|
|
145
|
-
declare const StyledMenuGroupUl: styled_components.StyledComponent<"ul", styled_components.DefaultTheme, {}, never>;
|
|
146
|
-
|
|
147
150
|
interface TypeDownshiftComboboxProps extends Partial<UseComboboxProps<TypeDefaultItemProps>> {
|
|
148
151
|
}
|
|
149
152
|
interface TypeDownshiftSelectProps extends Partial<UseSelectProps<TypeDefaultItemProps>> {
|
|
@@ -265,10 +268,13 @@ declare const MultiSelectMenu: ({ children, stateReducer: externalStateReducer,
|
|
|
265
268
|
interface TypeUseItemsFromChildrenProps {
|
|
266
269
|
children: ReactNode;
|
|
267
270
|
}
|
|
268
|
-
interface
|
|
271
|
+
interface TypeItemElement {
|
|
269
272
|
element: React__default.ReactElement<TypeMenuItemProps>;
|
|
270
273
|
parents: readonly React__default.ReactNode[];
|
|
271
274
|
}
|
|
275
|
+
interface TypeMenuGroupElement {
|
|
276
|
+
element: React__default.ReactElement<TypeMenuGroupProps>;
|
|
277
|
+
}
|
|
272
278
|
declare const useItemsFromChildren: ({ children, }: TypeUseItemsFromChildrenProps) => {
|
|
273
279
|
allMenuItems: TypeDefaultItemProps[];
|
|
274
280
|
menuItemsMap: {
|
|
@@ -282,4 +288,4 @@ declare const defaultUseSelectProps: {
|
|
|
282
288
|
isItemDisabled: (item: any) => boolean;
|
|
283
289
|
};
|
|
284
290
|
|
|
285
|
-
export { ActionMenu, INPUT_TYPES, type InputType, MenuContent, MenuContext, MenuFooter, MenuGroup, MenuHeader, MenuItem, MenuItemAction, MenuItemContainer, MenuItemRow, MenuItemText, MenuLabel, MenuProvider, MenuRoot, MenuToggleButton, MultiSelectMenu, SingleSelectMenu, StyledMenuGroup, StyledMenuGroupUl, StyledMenuItem, StyledTitle, type TypeActionMenuProps, type TypeDefaultItemProps, type TypeDownshiftComboboxProps, type TypeDownshiftComboboxReturnValue, type TypeDownshiftMultiSelectProps, type TypeDownshiftMultiSelectReturnValue, type TypeDownshiftSelectProps, type TypeDownshiftSelectReturnValue, type
|
|
291
|
+
export { ActionMenu, INPUT_TYPES, type InputType, MenuContent, MenuContext, MenuFooter, MenuGroup, MenuHeader, MenuItem, MenuItemAction, MenuItemContainer, MenuItemRow, MenuItemText, MenuLabel, MenuProvider, MenuRoot, MenuToggleButton, MultiSelectMenu, SingleSelectMenu, StyledMenuGroup, StyledMenuGroupUl, StyledMenuItem, StyledTitle, type TypeActionMenuProps, type TypeDefaultItemProps, type TypeDownshiftComboboxProps, type TypeDownshiftComboboxReturnValue, type TypeDownshiftMultiSelectProps, type TypeDownshiftMultiSelectReturnValue, type TypeDownshiftSelectProps, type TypeDownshiftSelectReturnValue, type TypeItemElement, type TypeMenuContentProps, type TypeMenuContext, type TypeMenuContextProps, type TypeMenuGroupElement, type TypeMenuGroupProps, type TypeMenuGroupStyledProps, type TypeMenuHeaderProps, type TypeMenuItemProps, type TypeMenuItemStyledProps, type TypeMenuProviderProps, type TypeMenuRootOwnProps, type TypeMenuRootProps, type TypeMenuToggleButtonProps, type TypeMultiSelectMenuProps, type TypeNotEmptyChildren, type TypeSingleSelectMenuProps, type TypeUseItemsFromChildrenProps, defaultUseSelectProps, useItemsFromChildren, useMenu, useMenuContext, useSelectStateReducer };
|
package/dist/index.js
CHANGED
|
@@ -1928,12 +1928,12 @@ var MenuItem = ({
|
|
|
1928
1928
|
...props
|
|
1929
1929
|
}) => {
|
|
1930
1930
|
const { getItemProps, itemsMap, highlightedIndex, isListbox } = (0, import_react3.useContext)(MenuContext);
|
|
1931
|
+
const item = itemsMap[id] || { index: 0, id };
|
|
1931
1932
|
const { ...optionProps } = useOptionProps({
|
|
1932
1933
|
id,
|
|
1933
1934
|
children,
|
|
1934
1935
|
...props
|
|
1935
1936
|
});
|
|
1936
|
-
const item = itemsMap[id] || { index: 0, id };
|
|
1937
1937
|
const highlighted = highlightedIndex === item?.index;
|
|
1938
1938
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(MenuItemContainer, { role: "none", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1939
1939
|
StyledMenuItem,
|
|
@@ -2247,6 +2247,8 @@ var MenuGroup = ({
|
|
|
2247
2247
|
children,
|
|
2248
2248
|
title,
|
|
2249
2249
|
color: color2,
|
|
2250
|
+
isSingleSelect,
|
|
2251
|
+
id,
|
|
2250
2252
|
...rest
|
|
2251
2253
|
}) => {
|
|
2252
2254
|
const titleId = `menu-group-title-${Math.random().toString(36).slice(2, 11)}`;
|
|
@@ -2254,6 +2256,8 @@ var MenuGroup = ({
|
|
|
2254
2256
|
StyledMenuGroup,
|
|
2255
2257
|
{
|
|
2256
2258
|
role: "group",
|
|
2259
|
+
id,
|
|
2260
|
+
isSingleSelect,
|
|
2257
2261
|
"aria-labelledby": title ? titleId : void 0,
|
|
2258
2262
|
color: color2,
|
|
2259
2263
|
...rest,
|
|
@@ -2385,12 +2389,16 @@ var useItemsFromChildren = ({
|
|
|
2385
2389
|
const allMenuItemElements = getAllMenuItems(children);
|
|
2386
2390
|
const menuItemsMap2 = {};
|
|
2387
2391
|
const allMenuItems2 = allMenuItemElements.map(
|
|
2388
|
-
({ element }, index) => {
|
|
2392
|
+
({ element, parents }, index) => {
|
|
2393
|
+
const parentMenuGroup = parents.find(
|
|
2394
|
+
(parent) => checkIfIsElement(parent, "MenuGroup")
|
|
2395
|
+
);
|
|
2389
2396
|
const item = {
|
|
2390
2397
|
id: element.props.id,
|
|
2391
2398
|
disabled: element.props.disabled,
|
|
2392
2399
|
index,
|
|
2393
|
-
menuItemProps: element.props
|
|
2400
|
+
menuItemProps: element.props,
|
|
2401
|
+
menuGroupProps: parentMenuGroup ? parentMenuGroup.props : void 0
|
|
2394
2402
|
};
|
|
2395
2403
|
menuItemsMap2[`${item.id}`] = item;
|
|
2396
2404
|
return item;
|
|
@@ -2621,6 +2629,12 @@ var MultiSelectMenu = ({
|
|
|
2621
2629
|
} else {
|
|
2622
2630
|
addSelectedItem(newSelectedItem);
|
|
2623
2631
|
}
|
|
2632
|
+
if (newSelectedItem.menuGroupProps?.isSingleSelect) {
|
|
2633
|
+
const groupItems = selectedItems.filter(
|
|
2634
|
+
(item) => item.menuGroupProps?.id === newSelectedItem.menuGroupProps?.id
|
|
2635
|
+
);
|
|
2636
|
+
groupItems.forEach((item) => removeSelectedItem(item));
|
|
2637
|
+
}
|
|
2624
2638
|
break;
|
|
2625
2639
|
default:
|
|
2626
2640
|
break;
|