@sproutsocial/seeds-react-menu 0.2.3 → 0.4.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 +27 -0
- package/dist/esm/index.js +243 -75
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +81 -49
- package/dist/index.d.ts +81 -49
- package/dist/index.js +237 -67
- package/dist/index.js.map +1 -1
- package/package.json +3 -1
- package/src/Autocomplete/Autocomplete.feature +14 -43
- package/src/Autocomplete/Autocomplete.stories.tsx +128 -0
- package/src/Autocomplete/Autocomplete.tsx +29 -11
- package/src/Autocomplete/AutocompleteInput.tsx +51 -0
- package/src/Autocomplete/AutocompleteTypes.ts +8 -1
- package/src/Autocomplete/__tests__/Autocomplete.test.tsx +142 -89
- package/src/Autocomplete/__tests__/Autocomplete.typetest.tsx +25 -43
- package/src/Autocomplete/index.ts +1 -0
- package/src/MenuContent/MenuContent.tsx +2 -2
- package/src/MenuContext.tsx +11 -5
- package/src/MenuGroup/MenuGroup.feature +19 -37
- package/src/MenuGroup/MenuGroup.tsx +18 -3
- package/src/MenuGroup/MenuGroupTypes.ts +6 -1
- package/src/MenuGroup/__tests__/MenuGroup.test.tsx +167 -9
- package/src/MenuGroup/__tests__/MenuGroup.typetest.tsx +27 -13
- package/src/MenuItem/MenuItem.tsx +7 -4
- package/src/MenuLabel.tsx +4 -4
- package/src/MenuRoot/MenuRoot.tsx +5 -3
- 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/SingleSelectMenu.tsx +2 -2
- package/src/SingleSelectMenu/__tests__/SingleSelectMenu.test.tsx +3 -3
- package/src/__fixtures__/menu-test-data.ts +36 -0
- package/src/__tests__/Menu.test.tsx +29 -96
- package/src/hooks/useItemsFromChildren.tsx +71 -21
- package/src/index.ts +1 -0
- package/src/reducers/useComboboxStateReducer.tsx +11 -8
- package/src/storybookUtilities/menu-storybook-components.tsx +39 -0
- package/src/types.ts +3 -0
package/dist/index.d.mts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as downshift from 'downshift';
|
|
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';
|
|
3
|
+
import { GetItemPropsOptions, UseComboboxProps, UseSelectProps, UseMultipleSelectionProps, UseComboboxReturnValue, UseSelectReturnValue, UseMultipleSelectionReturnValue, UseComboboxGetInputPropsOptions } 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';
|
|
11
11
|
import * as _sproutsocial_seeds_react_text from '@sproutsocial/seeds-react-text';
|
|
12
|
-
import { TypeTextProps } from '@sproutsocial/seeds-react-text';
|
|
13
12
|
import { TypePopoutProps } from '@sproutsocial/seeds-react-popout';
|
|
13
|
+
import { TypeLabelProps } from '@sproutsocial/seeds-react-label';
|
|
14
14
|
import { TypeButtonProps } from '@sproutsocial/seeds-react-button';
|
|
15
|
+
import { TypeInputProps } from '@sproutsocial/seeds-react-input';
|
|
15
16
|
|
|
16
17
|
declare const MENU_ITEM_ROLES: {
|
|
17
18
|
readonly MENUITEM: "menuitem";
|
|
@@ -22,11 +23,50 @@ declare const MENU_ITEM_ROLES: {
|
|
|
22
23
|
};
|
|
23
24
|
type TypeMenuItemRoles = (typeof MENU_ITEM_ROLES)[keyof typeof MENU_ITEM_ROLES];
|
|
24
25
|
|
|
26
|
+
interface TypeMenuGroupStyledProps extends TypeBorderSystemProps, TypeColorSystemProps, TypeFlexboxSystemProps, TypeGridSystemProps, TypeLayoutSystemProps, TypePositionSystemProps, TypeSpaceSystemProps, TypeTypographySystemProps {
|
|
27
|
+
}
|
|
28
|
+
interface TypeMenuGroupProps extends TypeMenuGroupStyledProps, Omit<React.ComponentPropsWithoutRef<"ul">, "color"> {
|
|
29
|
+
id: string;
|
|
30
|
+
isSingleSelect?: boolean;
|
|
31
|
+
title?: string;
|
|
32
|
+
children?: ReactNode;
|
|
33
|
+
items?: TypeMenuItemProps[];
|
|
34
|
+
MenuItemComponent?: typeof MenuItem;
|
|
35
|
+
titleAs?: string | React.ComponentType<any>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @link https://seeds.sproutsocial.com/components/menu-group/
|
|
40
|
+
*
|
|
41
|
+
* @description MenuGroup is used to group lists of {@link https://github.com/sproutsocial/seeds/tree/dev/seeds-react/seeds-react-menu/src/MenuItem | MenuItems}.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* <ActionMenu>
|
|
45
|
+
* <MenuContent>
|
|
46
|
+
* <MenuGroup title="Group 1" id="1">
|
|
47
|
+
* <MenuItem>Item 1</MenuItem>
|
|
48
|
+
* </MenuGroup>
|
|
49
|
+
* <MenuGroup title="Group 2" id="2">
|
|
50
|
+
* <MenuItem>Item 2</MenuItem>
|
|
51
|
+
* </MenuGroup>
|
|
52
|
+
* </MenuContent>
|
|
53
|
+
* </ActionMenu>
|
|
54
|
+
*
|
|
55
|
+
* @see {@link https://seeds.sproutsocial.com/components/menu-item/ | MenuItem}
|
|
56
|
+
*/
|
|
57
|
+
declare const MenuGroup: ({ titleAs, children: childrenProp, title, color, isSingleSelect, id, items, MenuItemComponent, ...rest }: TypeMenuGroupProps) => react_jsx_runtime.JSX.Element | null;
|
|
58
|
+
|
|
59
|
+
declare const StyledMenuGroup: styled_components.StyledComponent<"li", styled_components.DefaultTheme, TypeMenuGroupProps, never>;
|
|
60
|
+
declare const StyledTitle: styled_components.StyledComponent<React$1.FC<_sproutsocial_seeds_react_text.TypeTextProps>, styled_components.DefaultTheme, {}, never>;
|
|
61
|
+
declare const StyledMenuGroupUl: styled_components.StyledComponent<"ul", styled_components.DefaultTheme, {}, never>;
|
|
62
|
+
|
|
25
63
|
interface TypeDefaultItemProps {
|
|
26
64
|
id: string;
|
|
27
65
|
index: number;
|
|
28
66
|
disabled?: boolean;
|
|
67
|
+
hidden?: boolean;
|
|
29
68
|
menuItemProps?: TypeMenuItemProps;
|
|
69
|
+
menuGroupProps?: TypeMenuGroupProps;
|
|
30
70
|
}
|
|
31
71
|
type TypeNotEmptyChildren = React.ReactChild | React.ReactFragment | React.ReactPortal;
|
|
32
72
|
|
|
@@ -87,10 +127,10 @@ interface TypeMenuContentProps extends HTMLMotionProps<"ul"> {
|
|
|
87
127
|
* <ActionMenu>
|
|
88
128
|
* <MenuHeader>Header</MenuHeader>
|
|
89
129
|
* <MenuContent>
|
|
90
|
-
* <MenuGroup>
|
|
130
|
+
* <MenuGroup id="1">
|
|
91
131
|
* <MenuItem>Item 1</MenuItem>
|
|
92
132
|
* </MenuGroup>
|
|
93
|
-
* <MenuGroup>
|
|
133
|
+
* <MenuGroup id="2">
|
|
94
134
|
* <MenuItem>Item 2</MenuItem>
|
|
95
135
|
* </MenuGroup>
|
|
96
136
|
* </MenuContent>
|
|
@@ -111,39 +151,6 @@ declare const MenuContent: ({ id, children, ...rest }: TypeMenuContentProps) =>
|
|
|
111
151
|
*/
|
|
112
152
|
declare const MenuFooter: ({ children, ...rest }: TypeBoxProps) => react_jsx_runtime.JSX.Element;
|
|
113
153
|
|
|
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
154
|
interface TypeDownshiftComboboxProps extends Partial<UseComboboxProps<TypeDefaultItemProps>> {
|
|
148
155
|
}
|
|
149
156
|
interface TypeDownshiftSelectProps extends Partial<UseSelectProps<TypeDefaultItemProps>> {
|
|
@@ -163,6 +170,9 @@ type TypeDonwshiftSharedReturnValue = "getLabelProps" | "getToggleButtonProps" |
|
|
|
163
170
|
type TypeDonwshiftSharedProps = "onHighlightedIndexChange" | "onIsOpenChange" | "onSelectedItemChange" | "onStateChange" | "stateReducer";
|
|
164
171
|
interface TypeMenuContextProps extends Omit<TypeDownshiftComboboxReturnValue, TypeDonwshiftSharedReturnValue>, Omit<TypeDownshiftComboboxProps, TypeDonwshiftSharedProps>, Omit<TypeDownshiftSelectReturnValue, TypeDonwshiftSharedReturnValue>, Omit<TypeDownshiftSelectProps, TypeDonwshiftSharedProps>, TypeDownshiftMultiSelectReturnValue, TypeDownshiftMultiSelectProps {
|
|
165
172
|
items: TypeDefaultItemProps[];
|
|
173
|
+
itemsMap?: {
|
|
174
|
+
[key: string]: TypeDefaultItemProps;
|
|
175
|
+
};
|
|
166
176
|
isListbox?: boolean;
|
|
167
177
|
onHighlightedIndexChange?: TypeDownshiftComboboxProps["onHighlightedIndexChange"] | TypeDownshiftSelectProps["onHighlightedIndexChange"];
|
|
168
178
|
onIsOpenChange?: TypeDownshiftComboboxProps["onIsOpenChange"] | TypeDownshiftSelectProps["onIsOpenChange"];
|
|
@@ -178,13 +188,14 @@ interface TypeMenuContext extends TypeMenuContextProps {
|
|
|
178
188
|
[key: string]: TypeDefaultItemProps;
|
|
179
189
|
};
|
|
180
190
|
}
|
|
181
|
-
interface TypeMenuProviderProps
|
|
191
|
+
interface TypeMenuProviderProps {
|
|
182
192
|
children: TypeNotEmptyChildren;
|
|
193
|
+
menuProps: Partial<TypeMenuContextProps>;
|
|
183
194
|
}
|
|
184
195
|
/**
|
|
185
196
|
* Hook for initializing Menu context
|
|
186
197
|
*/
|
|
187
|
-
declare const useMenu: ({ items, isListbox, isOpen, ...rest }?: Partial<TypeMenuContextProps>) => TypeMenuContext;
|
|
198
|
+
declare const useMenu: ({ items, isListbox, isOpen, itemsMap: itemsMapFromProps, ...rest }?: Partial<TypeMenuContextProps>) => TypeMenuContext;
|
|
188
199
|
/**
|
|
189
200
|
* MenuContext factory, sets the type and the initial object
|
|
190
201
|
*/
|
|
@@ -192,7 +203,7 @@ declare const MenuContext: React__default.Context<TypeMenuContext>;
|
|
|
192
203
|
/**
|
|
193
204
|
* Provider Component sets the context values into the provider
|
|
194
205
|
*/
|
|
195
|
-
declare const MenuProvider: ({ children,
|
|
206
|
+
declare const MenuProvider: ({ children, menuProps, }: TypeMenuProviderProps) => react_jsx_runtime.JSX.Element;
|
|
196
207
|
/**
|
|
197
208
|
* Utility hook for consuming MenuContext
|
|
198
209
|
*/
|
|
@@ -203,16 +214,16 @@ interface TypeMenuRootOwnProps {
|
|
|
203
214
|
popoutProps?: Partial<Omit<TypePopoutProps, "isOpen" | "setIsOpen" | "content" | "children">>;
|
|
204
215
|
width?: TypePopoutProps["width"];
|
|
205
216
|
}
|
|
206
|
-
interface TypeMenuRootProps extends Partial<TypeMenuProviderProps>, TypeMenuRootOwnProps {
|
|
217
|
+
interface TypeMenuRootProps extends Partial<TypeMenuProviderProps["menuProps"]>, Pick<TypeMenuProviderProps, "children">, TypeMenuRootOwnProps {
|
|
207
218
|
}
|
|
208
219
|
/**
|
|
209
220
|
* @link https://seeds.sproutsocial.com/components/menu-root/
|
|
210
221
|
*
|
|
211
222
|
* @description MenuRoot is a utility component used to handle {@link https://github.com/sproutsocial/seeds/blob/dev/seeds-react/seeds-react-menu/src/MenuContext.tsx | MenuContext}. This component should rarely, if ever, be used directly unless building a custom menu type.
|
|
212
223
|
*/
|
|
213
|
-
declare const MenuRoot: ({ children, menuToggleElement, popoutProps, width, ...contextProps }: TypeMenuRootProps) => react_jsx_runtime.JSX.Element;
|
|
224
|
+
declare const MenuRoot: ({ children, menuToggleElement, popoutProps: { focusLockProps, ...popoutProps }, width, ...contextProps }: TypeMenuRootProps) => react_jsx_runtime.JSX.Element;
|
|
214
225
|
|
|
215
|
-
declare const MenuLabel: ({ children, ...rest }:
|
|
226
|
+
declare const MenuLabel: ({ children, ...rest }: Partial<TypeLabelProps>) => react_jsx_runtime.JSX.Element;
|
|
216
227
|
|
|
217
228
|
interface TypeMenuToggleButtonProps extends Partial<TypeButtonProps> {
|
|
218
229
|
children: ReactNode;
|
|
@@ -262,12 +273,33 @@ interface TypeMultiSelectMenuProps extends TypeMenuRootOwnProps, TypeDownshiftSe
|
|
|
262
273
|
*/
|
|
263
274
|
declare const MultiSelectMenu: ({ children, stateReducer: externalStateReducer, getA11yMultiStatusMessage, onMultiSelectStateChange, multiSelectStateReducer, ...useSelectProps }: TypeMultiSelectMenuProps) => react_jsx_runtime.JSX.Element;
|
|
264
275
|
|
|
276
|
+
interface TypeAutocompleteProps extends TypeMenuRootOwnProps, TypeDownshiftComboboxProps {
|
|
277
|
+
children: TypeMenuRootProps["children"];
|
|
278
|
+
getIsItemVisible?: (item: TypeMenuContext["items"][number], inputValue: string) => boolean;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* @link https://seeds.sproutsocial.com/components/multiselect-menu/
|
|
283
|
+
*
|
|
284
|
+
* @description A Autocomplete allows multiple {@link https://github.com/sproutsocial/seeds/tree/dev/seeds-react/seeds-react-menu/src/MenuItem | MenuItems} to be selected from a list or groups of lists.
|
|
285
|
+
*
|
|
286
|
+
* @see {@link https://seeds.sproutsocial.com/components/menu-group/ | MenuGroup}
|
|
287
|
+
*/
|
|
288
|
+
declare const Autocomplete: ({ children, stateReducer: externalStateReducer, itemToString, getIsItemVisible, ...useComboboxProps }: TypeAutocompleteProps) => react_jsx_runtime.JSX.Element;
|
|
289
|
+
|
|
290
|
+
type TypeInputEventListeners = "onKeyDown" | "onChange" | "onInput" | "onBlur" | "onClick" | "refKey";
|
|
291
|
+
interface TypeAutocompleteInputProps extends Pick<UseComboboxGetInputPropsOptions, TypeInputEventListeners>, Omit<Partial<TypeInputProps>, TypeInputEventListeners> {
|
|
292
|
+
}
|
|
293
|
+
declare const AutocompleteInput: ({ onKeyDown, onChange, onInput, onBlur, onClick, inputProps, ...rest }: TypeAutocompleteInputProps) => react_jsx_runtime.JSX.Element;
|
|
294
|
+
|
|
265
295
|
interface TypeUseItemsFromChildrenProps {
|
|
266
296
|
children: ReactNode;
|
|
267
297
|
}
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
298
|
+
type TypeItemElement = React__default.ReactElement<TypeMenuItemProps>;
|
|
299
|
+
type TypeMenuGroupElement = React__default.ReactElement<TypeMenuGroupProps>;
|
|
300
|
+
interface TypeMenuChildren {
|
|
301
|
+
type: "item" | "group";
|
|
302
|
+
element: React__default.ReactElement<TypeMenuGroupProps> | React__default.ReactElement<TypeMenuItemProps>;
|
|
271
303
|
}
|
|
272
304
|
declare const useItemsFromChildren: ({ children, }: TypeUseItemsFromChildrenProps) => {
|
|
273
305
|
allMenuItems: TypeDefaultItemProps[];
|
|
@@ -282,4 +314,4 @@ declare const defaultUseSelectProps: {
|
|
|
282
314
|
isItemDisabled: (item: any) => boolean;
|
|
283
315
|
};
|
|
284
316
|
|
|
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
|
|
317
|
+
export { ActionMenu, Autocomplete, AutocompleteInput, 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 TypeAutocompleteInputProps, type TypeAutocompleteProps, type TypeDefaultItemProps, type TypeDownshiftComboboxProps, type TypeDownshiftComboboxReturnValue, type TypeDownshiftMultiSelectProps, type TypeDownshiftMultiSelectReturnValue, type TypeDownshiftSelectProps, type TypeDownshiftSelectReturnValue, type TypeItemElement, type TypeMenuChildren, 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,17 +1,18 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as downshift from 'downshift';
|
|
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';
|
|
3
|
+
import { GetItemPropsOptions, UseComboboxProps, UseSelectProps, UseMultipleSelectionProps, UseComboboxReturnValue, UseSelectReturnValue, UseMultipleSelectionReturnValue, UseComboboxGetInputPropsOptions } 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';
|
|
11
11
|
import * as _sproutsocial_seeds_react_text from '@sproutsocial/seeds-react-text';
|
|
12
|
-
import { TypeTextProps } from '@sproutsocial/seeds-react-text';
|
|
13
12
|
import { TypePopoutProps } from '@sproutsocial/seeds-react-popout';
|
|
13
|
+
import { TypeLabelProps } from '@sproutsocial/seeds-react-label';
|
|
14
14
|
import { TypeButtonProps } from '@sproutsocial/seeds-react-button';
|
|
15
|
+
import { TypeInputProps } from '@sproutsocial/seeds-react-input';
|
|
15
16
|
|
|
16
17
|
declare const MENU_ITEM_ROLES: {
|
|
17
18
|
readonly MENUITEM: "menuitem";
|
|
@@ -22,11 +23,50 @@ declare const MENU_ITEM_ROLES: {
|
|
|
22
23
|
};
|
|
23
24
|
type TypeMenuItemRoles = (typeof MENU_ITEM_ROLES)[keyof typeof MENU_ITEM_ROLES];
|
|
24
25
|
|
|
26
|
+
interface TypeMenuGroupStyledProps extends TypeBorderSystemProps, TypeColorSystemProps, TypeFlexboxSystemProps, TypeGridSystemProps, TypeLayoutSystemProps, TypePositionSystemProps, TypeSpaceSystemProps, TypeTypographySystemProps {
|
|
27
|
+
}
|
|
28
|
+
interface TypeMenuGroupProps extends TypeMenuGroupStyledProps, Omit<React.ComponentPropsWithoutRef<"ul">, "color"> {
|
|
29
|
+
id: string;
|
|
30
|
+
isSingleSelect?: boolean;
|
|
31
|
+
title?: string;
|
|
32
|
+
children?: ReactNode;
|
|
33
|
+
items?: TypeMenuItemProps[];
|
|
34
|
+
MenuItemComponent?: typeof MenuItem;
|
|
35
|
+
titleAs?: string | React.ComponentType<any>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @link https://seeds.sproutsocial.com/components/menu-group/
|
|
40
|
+
*
|
|
41
|
+
* @description MenuGroup is used to group lists of {@link https://github.com/sproutsocial/seeds/tree/dev/seeds-react/seeds-react-menu/src/MenuItem | MenuItems}.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* <ActionMenu>
|
|
45
|
+
* <MenuContent>
|
|
46
|
+
* <MenuGroup title="Group 1" id="1">
|
|
47
|
+
* <MenuItem>Item 1</MenuItem>
|
|
48
|
+
* </MenuGroup>
|
|
49
|
+
* <MenuGroup title="Group 2" id="2">
|
|
50
|
+
* <MenuItem>Item 2</MenuItem>
|
|
51
|
+
* </MenuGroup>
|
|
52
|
+
* </MenuContent>
|
|
53
|
+
* </ActionMenu>
|
|
54
|
+
*
|
|
55
|
+
* @see {@link https://seeds.sproutsocial.com/components/menu-item/ | MenuItem}
|
|
56
|
+
*/
|
|
57
|
+
declare const MenuGroup: ({ titleAs, children: childrenProp, title, color, isSingleSelect, id, items, MenuItemComponent, ...rest }: TypeMenuGroupProps) => react_jsx_runtime.JSX.Element | null;
|
|
58
|
+
|
|
59
|
+
declare const StyledMenuGroup: styled_components.StyledComponent<"li", styled_components.DefaultTheme, TypeMenuGroupProps, never>;
|
|
60
|
+
declare const StyledTitle: styled_components.StyledComponent<React$1.FC<_sproutsocial_seeds_react_text.TypeTextProps>, styled_components.DefaultTheme, {}, never>;
|
|
61
|
+
declare const StyledMenuGroupUl: styled_components.StyledComponent<"ul", styled_components.DefaultTheme, {}, never>;
|
|
62
|
+
|
|
25
63
|
interface TypeDefaultItemProps {
|
|
26
64
|
id: string;
|
|
27
65
|
index: number;
|
|
28
66
|
disabled?: boolean;
|
|
67
|
+
hidden?: boolean;
|
|
29
68
|
menuItemProps?: TypeMenuItemProps;
|
|
69
|
+
menuGroupProps?: TypeMenuGroupProps;
|
|
30
70
|
}
|
|
31
71
|
type TypeNotEmptyChildren = React.ReactChild | React.ReactFragment | React.ReactPortal;
|
|
32
72
|
|
|
@@ -87,10 +127,10 @@ interface TypeMenuContentProps extends HTMLMotionProps<"ul"> {
|
|
|
87
127
|
* <ActionMenu>
|
|
88
128
|
* <MenuHeader>Header</MenuHeader>
|
|
89
129
|
* <MenuContent>
|
|
90
|
-
* <MenuGroup>
|
|
130
|
+
* <MenuGroup id="1">
|
|
91
131
|
* <MenuItem>Item 1</MenuItem>
|
|
92
132
|
* </MenuGroup>
|
|
93
|
-
* <MenuGroup>
|
|
133
|
+
* <MenuGroup id="2">
|
|
94
134
|
* <MenuItem>Item 2</MenuItem>
|
|
95
135
|
* </MenuGroup>
|
|
96
136
|
* </MenuContent>
|
|
@@ -111,39 +151,6 @@ declare const MenuContent: ({ id, children, ...rest }: TypeMenuContentProps) =>
|
|
|
111
151
|
*/
|
|
112
152
|
declare const MenuFooter: ({ children, ...rest }: TypeBoxProps) => react_jsx_runtime.JSX.Element;
|
|
113
153
|
|
|
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
154
|
interface TypeDownshiftComboboxProps extends Partial<UseComboboxProps<TypeDefaultItemProps>> {
|
|
148
155
|
}
|
|
149
156
|
interface TypeDownshiftSelectProps extends Partial<UseSelectProps<TypeDefaultItemProps>> {
|
|
@@ -163,6 +170,9 @@ type TypeDonwshiftSharedReturnValue = "getLabelProps" | "getToggleButtonProps" |
|
|
|
163
170
|
type TypeDonwshiftSharedProps = "onHighlightedIndexChange" | "onIsOpenChange" | "onSelectedItemChange" | "onStateChange" | "stateReducer";
|
|
164
171
|
interface TypeMenuContextProps extends Omit<TypeDownshiftComboboxReturnValue, TypeDonwshiftSharedReturnValue>, Omit<TypeDownshiftComboboxProps, TypeDonwshiftSharedProps>, Omit<TypeDownshiftSelectReturnValue, TypeDonwshiftSharedReturnValue>, Omit<TypeDownshiftSelectProps, TypeDonwshiftSharedProps>, TypeDownshiftMultiSelectReturnValue, TypeDownshiftMultiSelectProps {
|
|
165
172
|
items: TypeDefaultItemProps[];
|
|
173
|
+
itemsMap?: {
|
|
174
|
+
[key: string]: TypeDefaultItemProps;
|
|
175
|
+
};
|
|
166
176
|
isListbox?: boolean;
|
|
167
177
|
onHighlightedIndexChange?: TypeDownshiftComboboxProps["onHighlightedIndexChange"] | TypeDownshiftSelectProps["onHighlightedIndexChange"];
|
|
168
178
|
onIsOpenChange?: TypeDownshiftComboboxProps["onIsOpenChange"] | TypeDownshiftSelectProps["onIsOpenChange"];
|
|
@@ -178,13 +188,14 @@ interface TypeMenuContext extends TypeMenuContextProps {
|
|
|
178
188
|
[key: string]: TypeDefaultItemProps;
|
|
179
189
|
};
|
|
180
190
|
}
|
|
181
|
-
interface TypeMenuProviderProps
|
|
191
|
+
interface TypeMenuProviderProps {
|
|
182
192
|
children: TypeNotEmptyChildren;
|
|
193
|
+
menuProps: Partial<TypeMenuContextProps>;
|
|
183
194
|
}
|
|
184
195
|
/**
|
|
185
196
|
* Hook for initializing Menu context
|
|
186
197
|
*/
|
|
187
|
-
declare const useMenu: ({ items, isListbox, isOpen, ...rest }?: Partial<TypeMenuContextProps>) => TypeMenuContext;
|
|
198
|
+
declare const useMenu: ({ items, isListbox, isOpen, itemsMap: itemsMapFromProps, ...rest }?: Partial<TypeMenuContextProps>) => TypeMenuContext;
|
|
188
199
|
/**
|
|
189
200
|
* MenuContext factory, sets the type and the initial object
|
|
190
201
|
*/
|
|
@@ -192,7 +203,7 @@ declare const MenuContext: React__default.Context<TypeMenuContext>;
|
|
|
192
203
|
/**
|
|
193
204
|
* Provider Component sets the context values into the provider
|
|
194
205
|
*/
|
|
195
|
-
declare const MenuProvider: ({ children,
|
|
206
|
+
declare const MenuProvider: ({ children, menuProps, }: TypeMenuProviderProps) => react_jsx_runtime.JSX.Element;
|
|
196
207
|
/**
|
|
197
208
|
* Utility hook for consuming MenuContext
|
|
198
209
|
*/
|
|
@@ -203,16 +214,16 @@ interface TypeMenuRootOwnProps {
|
|
|
203
214
|
popoutProps?: Partial<Omit<TypePopoutProps, "isOpen" | "setIsOpen" | "content" | "children">>;
|
|
204
215
|
width?: TypePopoutProps["width"];
|
|
205
216
|
}
|
|
206
|
-
interface TypeMenuRootProps extends Partial<TypeMenuProviderProps>, TypeMenuRootOwnProps {
|
|
217
|
+
interface TypeMenuRootProps extends Partial<TypeMenuProviderProps["menuProps"]>, Pick<TypeMenuProviderProps, "children">, TypeMenuRootOwnProps {
|
|
207
218
|
}
|
|
208
219
|
/**
|
|
209
220
|
* @link https://seeds.sproutsocial.com/components/menu-root/
|
|
210
221
|
*
|
|
211
222
|
* @description MenuRoot is a utility component used to handle {@link https://github.com/sproutsocial/seeds/blob/dev/seeds-react/seeds-react-menu/src/MenuContext.tsx | MenuContext}. This component should rarely, if ever, be used directly unless building a custom menu type.
|
|
212
223
|
*/
|
|
213
|
-
declare const MenuRoot: ({ children, menuToggleElement, popoutProps, width, ...contextProps }: TypeMenuRootProps) => react_jsx_runtime.JSX.Element;
|
|
224
|
+
declare const MenuRoot: ({ children, menuToggleElement, popoutProps: { focusLockProps, ...popoutProps }, width, ...contextProps }: TypeMenuRootProps) => react_jsx_runtime.JSX.Element;
|
|
214
225
|
|
|
215
|
-
declare const MenuLabel: ({ children, ...rest }:
|
|
226
|
+
declare const MenuLabel: ({ children, ...rest }: Partial<TypeLabelProps>) => react_jsx_runtime.JSX.Element;
|
|
216
227
|
|
|
217
228
|
interface TypeMenuToggleButtonProps extends Partial<TypeButtonProps> {
|
|
218
229
|
children: ReactNode;
|
|
@@ -262,12 +273,33 @@ interface TypeMultiSelectMenuProps extends TypeMenuRootOwnProps, TypeDownshiftSe
|
|
|
262
273
|
*/
|
|
263
274
|
declare const MultiSelectMenu: ({ children, stateReducer: externalStateReducer, getA11yMultiStatusMessage, onMultiSelectStateChange, multiSelectStateReducer, ...useSelectProps }: TypeMultiSelectMenuProps) => react_jsx_runtime.JSX.Element;
|
|
264
275
|
|
|
276
|
+
interface TypeAutocompleteProps extends TypeMenuRootOwnProps, TypeDownshiftComboboxProps {
|
|
277
|
+
children: TypeMenuRootProps["children"];
|
|
278
|
+
getIsItemVisible?: (item: TypeMenuContext["items"][number], inputValue: string) => boolean;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* @link https://seeds.sproutsocial.com/components/multiselect-menu/
|
|
283
|
+
*
|
|
284
|
+
* @description A Autocomplete allows multiple {@link https://github.com/sproutsocial/seeds/tree/dev/seeds-react/seeds-react-menu/src/MenuItem | MenuItems} to be selected from a list or groups of lists.
|
|
285
|
+
*
|
|
286
|
+
* @see {@link https://seeds.sproutsocial.com/components/menu-group/ | MenuGroup}
|
|
287
|
+
*/
|
|
288
|
+
declare const Autocomplete: ({ children, stateReducer: externalStateReducer, itemToString, getIsItemVisible, ...useComboboxProps }: TypeAutocompleteProps) => react_jsx_runtime.JSX.Element;
|
|
289
|
+
|
|
290
|
+
type TypeInputEventListeners = "onKeyDown" | "onChange" | "onInput" | "onBlur" | "onClick" | "refKey";
|
|
291
|
+
interface TypeAutocompleteInputProps extends Pick<UseComboboxGetInputPropsOptions, TypeInputEventListeners>, Omit<Partial<TypeInputProps>, TypeInputEventListeners> {
|
|
292
|
+
}
|
|
293
|
+
declare const AutocompleteInput: ({ onKeyDown, onChange, onInput, onBlur, onClick, inputProps, ...rest }: TypeAutocompleteInputProps) => react_jsx_runtime.JSX.Element;
|
|
294
|
+
|
|
265
295
|
interface TypeUseItemsFromChildrenProps {
|
|
266
296
|
children: ReactNode;
|
|
267
297
|
}
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
298
|
+
type TypeItemElement = React__default.ReactElement<TypeMenuItemProps>;
|
|
299
|
+
type TypeMenuGroupElement = React__default.ReactElement<TypeMenuGroupProps>;
|
|
300
|
+
interface TypeMenuChildren {
|
|
301
|
+
type: "item" | "group";
|
|
302
|
+
element: React__default.ReactElement<TypeMenuGroupProps> | React__default.ReactElement<TypeMenuItemProps>;
|
|
271
303
|
}
|
|
272
304
|
declare const useItemsFromChildren: ({ children, }: TypeUseItemsFromChildrenProps) => {
|
|
273
305
|
allMenuItems: TypeDefaultItemProps[];
|
|
@@ -282,4 +314,4 @@ declare const defaultUseSelectProps: {
|
|
|
282
314
|
isItemDisabled: (item: any) => boolean;
|
|
283
315
|
};
|
|
284
316
|
|
|
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
|
|
317
|
+
export { ActionMenu, Autocomplete, AutocompleteInput, 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 TypeAutocompleteInputProps, type TypeAutocompleteProps, type TypeDefaultItemProps, type TypeDownshiftComboboxProps, type TypeDownshiftComboboxReturnValue, type TypeDownshiftMultiSelectProps, type TypeDownshiftMultiSelectReturnValue, type TypeDownshiftSelectProps, type TypeDownshiftSelectReturnValue, type TypeItemElement, type TypeMenuChildren, 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 };
|