@sproutsocial/seeds-react-menu 0.2.2 → 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 +18 -0
- package/dist/esm/index.js +18 -4
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +70 -43
- package/dist/index.d.ts +70 -43
- package/dist/index.js +18 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/ActionMenu/ActionMenu.tsx +2 -16
- package/src/ActionMenu/ActionMenuTypes.ts +12 -0
- package/src/ActionMenu/index.ts +1 -0
- package/src/{ComboBox/ComboBox.feature → Autocomplete/Autocomplete.feature} +16 -16
- package/src/Autocomplete/Autocomplete.tsx +65 -0
- package/src/Autocomplete/AutocompleteTypes.ts +8 -0
- package/src/Autocomplete/__tests__/Autocomplete.test.tsx +113 -0
- package/src/Autocomplete/__tests__/Autocomplete.typetest.tsx +78 -0
- package/src/Autocomplete/index.ts +2 -0
- package/src/MenuContent/MenuContent.tsx +3 -3
- package/src/MenuContext.tsx +65 -9
- 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/MenuItem/__tests__/MenuItem.test.tsx +4 -1
- package/src/MenuRoot/__tests__/MenuRoot.test.tsx +1 -1
- package/src/MultiSelectMenu/MultiSelectMenu.tsx +8 -0
- package/src/MultiSelectMenu/MultiSelectMenuTypes.ts +5 -1
- package/src/MultiSelectMenu/__tests__/MultiSelectMenu.test.tsx +6 -8
- package/src/MultiSelectMenu/index.ts +1 -0
- package/src/SingleSelectMenu/SingleSelectMenuTypes.ts +2 -3
- package/src/SingleSelectMenu/__tests__/SingleSelectMenu.test.tsx +3 -3
- package/src/hooks/useItemsFromChildren.tsx +12 -5
- package/src/reducers/useComboboxStateReducer.tsx +26 -0
- package/src/types.ts +2 -0
- package/src/ComboBox/TokenInput.feature +0 -84
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
|
-
import { GetItemPropsOptions, UseSelectProps, UseMultipleSelectionProps, 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';
|
|
3
|
+
import { GetItemPropsOptions, UseComboboxProps, UseSelectProps, UseMultipleSelectionProps, UseComboboxReturnValue, UseSelectReturnValue, UseMultipleSelectionReturnValue } from 'downshift';
|
|
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,47 +147,34 @@ 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
|
|
150
|
+
interface TypeDownshiftComboboxProps extends Partial<UseComboboxProps<TypeDefaultItemProps>> {
|
|
115
151
|
}
|
|
116
|
-
interface
|
|
117
|
-
title?: string;
|
|
118
|
-
children: ReactNode;
|
|
119
|
-
titleAs?: string | React.ComponentType<any>;
|
|
152
|
+
interface TypeDownshiftSelectProps extends Partial<UseSelectProps<TypeDefaultItemProps>> {
|
|
120
153
|
}
|
|
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
|
-
interface TypeDownshiftMultiSelectProps extends Partial<UseSelectProps<TypeDefaultItemProps>>, Partial<Omit<UseMultipleSelectionProps<TypeDefaultItemProps>, "stateReducer" | "onStateChange" | "getA11yStatusMessage">> {
|
|
154
|
+
interface TypeDownshiftMultiSelectProps extends Partial<Omit<UseMultipleSelectionProps<TypeDefaultItemProps>, "stateReducer" | "onStateChange" | "getA11yStatusMessage">> {
|
|
148
155
|
getA11yMultiStatusMessage?: UseMultipleSelectionProps<TypeDefaultItemProps>["getA11yStatusMessage"];
|
|
149
156
|
onMultiSelectStateChange?: UseMultipleSelectionProps<TypeDefaultItemProps>["onStateChange"];
|
|
150
157
|
multiSelectStateReducer?: UseMultipleSelectionProps<TypeDefaultItemProps>["stateReducer"];
|
|
151
158
|
}
|
|
152
|
-
interface
|
|
159
|
+
interface TypeDownshiftComboboxReturnValue extends Partial<UseComboboxReturnValue<TypeDefaultItemProps>> {
|
|
160
|
+
}
|
|
161
|
+
interface TypeDownshiftSelectReturnValue extends Partial<UseSelectReturnValue<TypeDefaultItemProps>> {
|
|
162
|
+
}
|
|
163
|
+
interface TypeDownshiftMultiSelectReturnValue extends Partial<UseMultipleSelectionReturnValue<TypeDefaultItemProps>> {
|
|
164
|
+
}
|
|
165
|
+
type TypeDonwshiftSharedReturnValue = "getLabelProps" | "getToggleButtonProps" | "getMenuProps";
|
|
166
|
+
type TypeDonwshiftSharedProps = "onHighlightedIndexChange" | "onIsOpenChange" | "onSelectedItemChange" | "onStateChange" | "stateReducer";
|
|
167
|
+
interface TypeMenuContextProps extends Omit<TypeDownshiftComboboxReturnValue, TypeDonwshiftSharedReturnValue>, Omit<TypeDownshiftComboboxProps, TypeDonwshiftSharedProps>, Omit<TypeDownshiftSelectReturnValue, TypeDonwshiftSharedReturnValue>, Omit<TypeDownshiftSelectProps, TypeDonwshiftSharedProps>, TypeDownshiftMultiSelectReturnValue, TypeDownshiftMultiSelectProps {
|
|
153
168
|
items: TypeDefaultItemProps[];
|
|
154
169
|
isListbox?: boolean;
|
|
170
|
+
onHighlightedIndexChange?: TypeDownshiftComboboxProps["onHighlightedIndexChange"] | TypeDownshiftSelectProps["onHighlightedIndexChange"];
|
|
171
|
+
onIsOpenChange?: TypeDownshiftComboboxProps["onIsOpenChange"] | TypeDownshiftSelectProps["onIsOpenChange"];
|
|
172
|
+
onSelectedItemChange?: TypeDownshiftComboboxProps["onSelectedItemChange"] | TypeDownshiftSelectProps["onSelectedItemChange"];
|
|
173
|
+
onStateChange?: TypeDownshiftComboboxProps["onStateChange"] | TypeDownshiftSelectProps["onStateChange"];
|
|
174
|
+
stateReducer?: TypeDownshiftComboboxProps["stateReducer"] | TypeDownshiftSelectProps["stateReducer"];
|
|
175
|
+
getLabelProps?: TypeDownshiftComboboxReturnValue["getLabelProps"] | TypeDownshiftSelectReturnValue["getLabelProps"];
|
|
176
|
+
getToggleButtonProps?: TypeDownshiftComboboxReturnValue["getToggleButtonProps"] | TypeDownshiftSelectReturnValue["getToggleButtonProps"];
|
|
177
|
+
getMenuProps?: TypeDownshiftComboboxReturnValue["getMenuProps"] | TypeDownshiftSelectReturnValue["getMenuProps"];
|
|
155
178
|
}
|
|
156
179
|
interface TypeMenuContext extends TypeMenuContextProps {
|
|
157
180
|
itemsMap: {
|
|
@@ -200,9 +223,10 @@ interface TypeMenuToggleButtonProps extends Partial<TypeButtonProps> {
|
|
|
200
223
|
declare const MenuToggleButton: ({ children, ...rest }: TypeMenuToggleButtonProps) => react_jsx_runtime.JSX.Element;
|
|
201
224
|
|
|
202
225
|
type TypeInvalidMenuProps = "initialSelectedItem" | "defaultSelectedItem" | "selectedItem";
|
|
203
|
-
interface TypeActionMenuProps extends TypeMenuRootOwnProps,
|
|
226
|
+
interface TypeActionMenuProps extends TypeMenuRootOwnProps, Omit<TypeDownshiftSelectProps, TypeInvalidMenuProps> {
|
|
204
227
|
children: TypeMenuRootProps["children"];
|
|
205
228
|
}
|
|
229
|
+
|
|
206
230
|
/**
|
|
207
231
|
* @link https://seeds.sproutsocial.com/components/action-menu/
|
|
208
232
|
*
|
|
@@ -214,7 +238,7 @@ interface TypeActionMenuProps extends TypeMenuRootOwnProps, Partial<Omit<UseSele
|
|
|
214
238
|
*/
|
|
215
239
|
declare const ActionMenu: ({ children, stateReducer: externalStateReducer, ...useSelectProps }: TypeActionMenuProps) => react_jsx_runtime.JSX.Element;
|
|
216
240
|
|
|
217
|
-
interface TypeSingleSelectMenuProps extends TypeMenuRootOwnProps,
|
|
241
|
+
interface TypeSingleSelectMenuProps extends TypeMenuRootOwnProps, TypeDownshiftSelectProps {
|
|
218
242
|
children: TypeMenuRootProps["children"];
|
|
219
243
|
}
|
|
220
244
|
|
|
@@ -228,7 +252,7 @@ interface TypeSingleSelectMenuProps extends TypeMenuRootOwnProps, Partial<UseSel
|
|
|
228
252
|
*/
|
|
229
253
|
declare const SingleSelectMenu: ({ children, stateReducer: externalStateReducer, ...useSelectProps }: TypeSingleSelectMenuProps) => react_jsx_runtime.JSX.Element;
|
|
230
254
|
|
|
231
|
-
interface TypeMultiSelectMenuProps extends TypeMenuRootOwnProps, TypeDownshiftMultiSelectProps {
|
|
255
|
+
interface TypeMultiSelectMenuProps extends TypeMenuRootOwnProps, TypeDownshiftSelectProps, TypeDownshiftMultiSelectProps {
|
|
232
256
|
children: TypeMenuRootProps["children"];
|
|
233
257
|
}
|
|
234
258
|
|
|
@@ -244,10 +268,13 @@ declare const MultiSelectMenu: ({ children, stateReducer: externalStateReducer,
|
|
|
244
268
|
interface TypeUseItemsFromChildrenProps {
|
|
245
269
|
children: ReactNode;
|
|
246
270
|
}
|
|
247
|
-
interface
|
|
271
|
+
interface TypeItemElement {
|
|
248
272
|
element: React__default.ReactElement<TypeMenuItemProps>;
|
|
249
273
|
parents: readonly React__default.ReactNode[];
|
|
250
274
|
}
|
|
275
|
+
interface TypeMenuGroupElement {
|
|
276
|
+
element: React__default.ReactElement<TypeMenuGroupProps>;
|
|
277
|
+
}
|
|
251
278
|
declare const useItemsFromChildren: ({ children, }: TypeUseItemsFromChildrenProps) => {
|
|
252
279
|
allMenuItems: TypeDefaultItemProps[];
|
|
253
280
|
menuItemsMap: {
|
|
@@ -261,4 +288,4 @@ declare const defaultUseSelectProps: {
|
|
|
261
288
|
isItemDisabled: (item: any) => boolean;
|
|
262
289
|
};
|
|
263
290
|
|
|
264
|
-
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 TypeDownshiftMultiSelectProps, 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
|
-
import { GetItemPropsOptions, UseSelectProps, UseMultipleSelectionProps, 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';
|
|
3
|
+
import { GetItemPropsOptions, UseComboboxProps, UseSelectProps, UseMultipleSelectionProps, UseComboboxReturnValue, UseSelectReturnValue, UseMultipleSelectionReturnValue } from 'downshift';
|
|
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,47 +147,34 @@ 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
|
|
150
|
+
interface TypeDownshiftComboboxProps extends Partial<UseComboboxProps<TypeDefaultItemProps>> {
|
|
115
151
|
}
|
|
116
|
-
interface
|
|
117
|
-
title?: string;
|
|
118
|
-
children: ReactNode;
|
|
119
|
-
titleAs?: string | React.ComponentType<any>;
|
|
152
|
+
interface TypeDownshiftSelectProps extends Partial<UseSelectProps<TypeDefaultItemProps>> {
|
|
120
153
|
}
|
|
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
|
-
interface TypeDownshiftMultiSelectProps extends Partial<UseSelectProps<TypeDefaultItemProps>>, Partial<Omit<UseMultipleSelectionProps<TypeDefaultItemProps>, "stateReducer" | "onStateChange" | "getA11yStatusMessage">> {
|
|
154
|
+
interface TypeDownshiftMultiSelectProps extends Partial<Omit<UseMultipleSelectionProps<TypeDefaultItemProps>, "stateReducer" | "onStateChange" | "getA11yStatusMessage">> {
|
|
148
155
|
getA11yMultiStatusMessage?: UseMultipleSelectionProps<TypeDefaultItemProps>["getA11yStatusMessage"];
|
|
149
156
|
onMultiSelectStateChange?: UseMultipleSelectionProps<TypeDefaultItemProps>["onStateChange"];
|
|
150
157
|
multiSelectStateReducer?: UseMultipleSelectionProps<TypeDefaultItemProps>["stateReducer"];
|
|
151
158
|
}
|
|
152
|
-
interface
|
|
159
|
+
interface TypeDownshiftComboboxReturnValue extends Partial<UseComboboxReturnValue<TypeDefaultItemProps>> {
|
|
160
|
+
}
|
|
161
|
+
interface TypeDownshiftSelectReturnValue extends Partial<UseSelectReturnValue<TypeDefaultItemProps>> {
|
|
162
|
+
}
|
|
163
|
+
interface TypeDownshiftMultiSelectReturnValue extends Partial<UseMultipleSelectionReturnValue<TypeDefaultItemProps>> {
|
|
164
|
+
}
|
|
165
|
+
type TypeDonwshiftSharedReturnValue = "getLabelProps" | "getToggleButtonProps" | "getMenuProps";
|
|
166
|
+
type TypeDonwshiftSharedProps = "onHighlightedIndexChange" | "onIsOpenChange" | "onSelectedItemChange" | "onStateChange" | "stateReducer";
|
|
167
|
+
interface TypeMenuContextProps extends Omit<TypeDownshiftComboboxReturnValue, TypeDonwshiftSharedReturnValue>, Omit<TypeDownshiftComboboxProps, TypeDonwshiftSharedProps>, Omit<TypeDownshiftSelectReturnValue, TypeDonwshiftSharedReturnValue>, Omit<TypeDownshiftSelectProps, TypeDonwshiftSharedProps>, TypeDownshiftMultiSelectReturnValue, TypeDownshiftMultiSelectProps {
|
|
153
168
|
items: TypeDefaultItemProps[];
|
|
154
169
|
isListbox?: boolean;
|
|
170
|
+
onHighlightedIndexChange?: TypeDownshiftComboboxProps["onHighlightedIndexChange"] | TypeDownshiftSelectProps["onHighlightedIndexChange"];
|
|
171
|
+
onIsOpenChange?: TypeDownshiftComboboxProps["onIsOpenChange"] | TypeDownshiftSelectProps["onIsOpenChange"];
|
|
172
|
+
onSelectedItemChange?: TypeDownshiftComboboxProps["onSelectedItemChange"] | TypeDownshiftSelectProps["onSelectedItemChange"];
|
|
173
|
+
onStateChange?: TypeDownshiftComboboxProps["onStateChange"] | TypeDownshiftSelectProps["onStateChange"];
|
|
174
|
+
stateReducer?: TypeDownshiftComboboxProps["stateReducer"] | TypeDownshiftSelectProps["stateReducer"];
|
|
175
|
+
getLabelProps?: TypeDownshiftComboboxReturnValue["getLabelProps"] | TypeDownshiftSelectReturnValue["getLabelProps"];
|
|
176
|
+
getToggleButtonProps?: TypeDownshiftComboboxReturnValue["getToggleButtonProps"] | TypeDownshiftSelectReturnValue["getToggleButtonProps"];
|
|
177
|
+
getMenuProps?: TypeDownshiftComboboxReturnValue["getMenuProps"] | TypeDownshiftSelectReturnValue["getMenuProps"];
|
|
155
178
|
}
|
|
156
179
|
interface TypeMenuContext extends TypeMenuContextProps {
|
|
157
180
|
itemsMap: {
|
|
@@ -200,9 +223,10 @@ interface TypeMenuToggleButtonProps extends Partial<TypeButtonProps> {
|
|
|
200
223
|
declare const MenuToggleButton: ({ children, ...rest }: TypeMenuToggleButtonProps) => react_jsx_runtime.JSX.Element;
|
|
201
224
|
|
|
202
225
|
type TypeInvalidMenuProps = "initialSelectedItem" | "defaultSelectedItem" | "selectedItem";
|
|
203
|
-
interface TypeActionMenuProps extends TypeMenuRootOwnProps,
|
|
226
|
+
interface TypeActionMenuProps extends TypeMenuRootOwnProps, Omit<TypeDownshiftSelectProps, TypeInvalidMenuProps> {
|
|
204
227
|
children: TypeMenuRootProps["children"];
|
|
205
228
|
}
|
|
229
|
+
|
|
206
230
|
/**
|
|
207
231
|
* @link https://seeds.sproutsocial.com/components/action-menu/
|
|
208
232
|
*
|
|
@@ -214,7 +238,7 @@ interface TypeActionMenuProps extends TypeMenuRootOwnProps, Partial<Omit<UseSele
|
|
|
214
238
|
*/
|
|
215
239
|
declare const ActionMenu: ({ children, stateReducer: externalStateReducer, ...useSelectProps }: TypeActionMenuProps) => react_jsx_runtime.JSX.Element;
|
|
216
240
|
|
|
217
|
-
interface TypeSingleSelectMenuProps extends TypeMenuRootOwnProps,
|
|
241
|
+
interface TypeSingleSelectMenuProps extends TypeMenuRootOwnProps, TypeDownshiftSelectProps {
|
|
218
242
|
children: TypeMenuRootProps["children"];
|
|
219
243
|
}
|
|
220
244
|
|
|
@@ -228,7 +252,7 @@ interface TypeSingleSelectMenuProps extends TypeMenuRootOwnProps, Partial<UseSel
|
|
|
228
252
|
*/
|
|
229
253
|
declare const SingleSelectMenu: ({ children, stateReducer: externalStateReducer, ...useSelectProps }: TypeSingleSelectMenuProps) => react_jsx_runtime.JSX.Element;
|
|
230
254
|
|
|
231
|
-
interface TypeMultiSelectMenuProps extends TypeMenuRootOwnProps, TypeDownshiftMultiSelectProps {
|
|
255
|
+
interface TypeMultiSelectMenuProps extends TypeMenuRootOwnProps, TypeDownshiftSelectProps, TypeDownshiftMultiSelectProps {
|
|
232
256
|
children: TypeMenuRootProps["children"];
|
|
233
257
|
}
|
|
234
258
|
|
|
@@ -244,10 +268,13 @@ declare const MultiSelectMenu: ({ children, stateReducer: externalStateReducer,
|
|
|
244
268
|
interface TypeUseItemsFromChildrenProps {
|
|
245
269
|
children: ReactNode;
|
|
246
270
|
}
|
|
247
|
-
interface
|
|
271
|
+
interface TypeItemElement {
|
|
248
272
|
element: React__default.ReactElement<TypeMenuItemProps>;
|
|
249
273
|
parents: readonly React__default.ReactNode[];
|
|
250
274
|
}
|
|
275
|
+
interface TypeMenuGroupElement {
|
|
276
|
+
element: React__default.ReactElement<TypeMenuGroupProps>;
|
|
277
|
+
}
|
|
251
278
|
declare const useItemsFromChildren: ({ children, }: TypeUseItemsFromChildrenProps) => {
|
|
252
279
|
allMenuItems: TypeDefaultItemProps[];
|
|
253
280
|
menuItemsMap: {
|
|
@@ -261,4 +288,4 @@ declare const defaultUseSelectProps: {
|
|
|
261
288
|
isItemDisabled: (item: any) => boolean;
|
|
262
289
|
};
|
|
263
290
|
|
|
264
|
-
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 TypeDownshiftMultiSelectProps, 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,
|
|
@@ -2066,7 +2066,7 @@ var MenuContent = ({
|
|
|
2066
2066
|
autoFocus: true,
|
|
2067
2067
|
id,
|
|
2068
2068
|
tabIndex: 0,
|
|
2069
|
-
onKeyDown: getToggleButtonProps?.()
|
|
2069
|
+
onKeyDown: getToggleButtonProps?.()["onKeyDown"] || void 0,
|
|
2070
2070
|
"aria-activedescendant": getToggleButtonProps?.()["aria-activedescendant"],
|
|
2071
2071
|
...getMenuProps?.(
|
|
2072
2072
|
{
|
|
@@ -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;
|