@sproutsocial/seeds-react-menu 0.2.1 → 0.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/.eslintrc.js +2 -6
- package/.turbo/turbo-build.log +10 -10
- package/CHANGELOG.md +7 -0
- package/dist/esm/index.js +11 -11
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +7 -6
- package/dist/index.d.ts +7 -6
- package/dist/index.js +6 -10
- package/dist/index.js.map +1 -1
- package/package.json +3 -5
- package/src/ActionMenu/ActionMenu.tsx +2 -3
- package/src/MenuContent/MenuContentTypes.ts +2 -1
- package/src/MenuContext.tsx +6 -1
- package/src/MenuGroup/MenuGroupTypes.ts +0 -1
- package/src/MenuGroup/__tests__/MenuGroup.test.tsx +0 -1
- package/src/MenuHeader/__tests__/MenuHeader.typetest.tsx +0 -1
- package/src/MenuItem/MenuItem.tsx +0 -4
- package/src/MenuItem/styles.tsx +1 -1
- package/src/MenuItem/useOptionProps.tsx +0 -1
- package/src/MenuRoot/MenuRoot.tsx +2 -2
- package/src/MenuRoot/__tests__/MenuRoot.test.tsx +1 -2
- package/src/MultiSelectMenu/MultiSelectMenu.tsx +0 -1
- package/src/MultiSelectMenu/__tests__/MultiSelectMenu.test.tsx +7 -2
- package/src/SingleSelectMenu/SingleSelectMenu.tsx +0 -1
- package/src/hooks/useItemsFromChildren.tsx +7 -5
- package/src/index.ts +1 -0
- package/src/types.ts +2 -5
- package/tsconfig.json +1 -1
- package/.eslintignore +0 -6
package/dist/index.d.mts
CHANGED
|
@@ -22,14 +22,11 @@ declare const MENU_ITEM_ROLES: {
|
|
|
22
22
|
};
|
|
23
23
|
type TypeMenuItemRoles = (typeof MENU_ITEM_ROLES)[keyof typeof MENU_ITEM_ROLES];
|
|
24
24
|
|
|
25
|
-
interface
|
|
26
|
-
element: React.ReactElement<TypeMenuItemProps>;
|
|
27
|
-
parents: readonly React.ReactNode[];
|
|
28
|
-
}
|
|
29
|
-
interface TypeDefaultItemProps extends Partial<TypeItemElements> {
|
|
25
|
+
interface TypeDefaultItemProps {
|
|
30
26
|
id: string;
|
|
31
27
|
index: number;
|
|
32
28
|
disabled?: boolean;
|
|
29
|
+
menuItemProps?: TypeMenuItemProps;
|
|
33
30
|
}
|
|
34
31
|
type TypeNotEmptyChildren = React.ReactChild | React.ReactFragment | React.ReactPortal;
|
|
35
32
|
|
|
@@ -247,6 +244,10 @@ declare const MultiSelectMenu: ({ children, stateReducer: externalStateReducer,
|
|
|
247
244
|
interface TypeUseItemsFromChildrenProps {
|
|
248
245
|
children: ReactNode;
|
|
249
246
|
}
|
|
247
|
+
interface TypeItemElements {
|
|
248
|
+
element: React__default.ReactElement<TypeMenuItemProps>;
|
|
249
|
+
parents: readonly React__default.ReactNode[];
|
|
250
|
+
}
|
|
250
251
|
declare const useItemsFromChildren: ({ children, }: TypeUseItemsFromChildrenProps) => {
|
|
251
252
|
allMenuItems: TypeDefaultItemProps[];
|
|
252
253
|
menuItemsMap: {
|
|
@@ -260,4 +261,4 @@ declare const defaultUseSelectProps: {
|
|
|
260
261
|
isItemDisabled: (item: any) => boolean;
|
|
261
262
|
};
|
|
262
263
|
|
|
263
|
-
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 TypeDownshiftMultiSelectProps, type TypeMenuContentProps, type TypeMenuContext, type TypeMenuContextProps, type TypeMenuGroupProps, type TypeMenuGroupStyledProps, type TypeMenuHeaderProps, type TypeMenuItemProps, type TypeMenuItemStyledProps, type TypeMenuProviderProps, type TypeMenuRootOwnProps, type TypeMenuRootProps, type TypeMenuToggleButtonProps, type TypeSingleSelectMenuProps, type TypeUseItemsFromChildrenProps, defaultUseSelectProps, useItemsFromChildren, useMenu, useMenuContext, useSelectStateReducer };
|
|
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 TypeItemElements, type TypeMenuContentProps, type TypeMenuContext, type TypeMenuContextProps, type TypeMenuGroupProps, type TypeMenuGroupStyledProps, type TypeMenuHeaderProps, type TypeMenuItemProps, type TypeMenuItemStyledProps, type TypeMenuProviderProps, type TypeMenuRootOwnProps, type TypeMenuRootProps, type TypeMenuToggleButtonProps, type TypeNotEmptyChildren, type TypeSingleSelectMenuProps, type TypeUseItemsFromChildrenProps, defaultUseSelectProps, useItemsFromChildren, useMenu, useMenuContext, useSelectStateReducer };
|
package/dist/index.d.ts
CHANGED
|
@@ -22,14 +22,11 @@ declare const MENU_ITEM_ROLES: {
|
|
|
22
22
|
};
|
|
23
23
|
type TypeMenuItemRoles = (typeof MENU_ITEM_ROLES)[keyof typeof MENU_ITEM_ROLES];
|
|
24
24
|
|
|
25
|
-
interface
|
|
26
|
-
element: React.ReactElement<TypeMenuItemProps>;
|
|
27
|
-
parents: readonly React.ReactNode[];
|
|
28
|
-
}
|
|
29
|
-
interface TypeDefaultItemProps extends Partial<TypeItemElements> {
|
|
25
|
+
interface TypeDefaultItemProps {
|
|
30
26
|
id: string;
|
|
31
27
|
index: number;
|
|
32
28
|
disabled?: boolean;
|
|
29
|
+
menuItemProps?: TypeMenuItemProps;
|
|
33
30
|
}
|
|
34
31
|
type TypeNotEmptyChildren = React.ReactChild | React.ReactFragment | React.ReactPortal;
|
|
35
32
|
|
|
@@ -247,6 +244,10 @@ declare const MultiSelectMenu: ({ children, stateReducer: externalStateReducer,
|
|
|
247
244
|
interface TypeUseItemsFromChildrenProps {
|
|
248
245
|
children: ReactNode;
|
|
249
246
|
}
|
|
247
|
+
interface TypeItemElements {
|
|
248
|
+
element: React__default.ReactElement<TypeMenuItemProps>;
|
|
249
|
+
parents: readonly React__default.ReactNode[];
|
|
250
|
+
}
|
|
250
251
|
declare const useItemsFromChildren: ({ children, }: TypeUseItemsFromChildrenProps) => {
|
|
251
252
|
allMenuItems: TypeDefaultItemProps[];
|
|
252
253
|
menuItemsMap: {
|
|
@@ -260,4 +261,4 @@ declare const defaultUseSelectProps: {
|
|
|
260
261
|
isItemDisabled: (item: any) => boolean;
|
|
261
262
|
};
|
|
262
263
|
|
|
263
|
-
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 TypeDownshiftMultiSelectProps, type TypeMenuContentProps, type TypeMenuContext, type TypeMenuContextProps, type TypeMenuGroupProps, type TypeMenuGroupStyledProps, type TypeMenuHeaderProps, type TypeMenuItemProps, type TypeMenuItemStyledProps, type TypeMenuProviderProps, type TypeMenuRootOwnProps, type TypeMenuRootProps, type TypeMenuToggleButtonProps, type TypeSingleSelectMenuProps, type TypeUseItemsFromChildrenProps, defaultUseSelectProps, useItemsFromChildren, useMenu, useMenuContext, useSelectStateReducer };
|
|
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 TypeItemElements, type TypeMenuContentProps, type TypeMenuContext, type TypeMenuContextProps, type TypeMenuGroupProps, type TypeMenuGroupStyledProps, type TypeMenuHeaderProps, type TypeMenuItemProps, type TypeMenuItemStyledProps, type TypeMenuProviderProps, type TypeMenuRootOwnProps, type TypeMenuRootProps, type TypeMenuToggleButtonProps, type TypeNotEmptyChildren, type TypeSingleSelectMenuProps, type TypeUseItemsFromChildrenProps, defaultUseSelectProps, useItemsFromChildren, useMenu, useMenuContext, useSelectStateReducer };
|
package/dist/index.js
CHANGED
|
@@ -1737,7 +1737,6 @@ var MenuItemContainer = import_styled_components2.default.li`
|
|
|
1737
1737
|
list-style-type: none;
|
|
1738
1738
|
margin-left: ${({ theme: theme2 }) => theme2.space[300]};
|
|
1739
1739
|
margin-right: ${({ theme: theme2 }) => theme2.space[300]};
|
|
1740
|
-
transition: all ${({ theme: theme2 }) => theme2.duration["fast"]};
|
|
1741
1740
|
|
|
1742
1741
|
&:first-child {
|
|
1743
1742
|
margin-top: ${({ theme: theme2 }) => theme2.space[300]};
|
|
@@ -1762,6 +1761,7 @@ var StyledMenuItem = import_styled_components2.default.div`
|
|
|
1762
1761
|
padding: ${({ theme: theme2 }) => theme2.space[300]};
|
|
1763
1762
|
outline: 0;
|
|
1764
1763
|
${({ theme: theme2 }) => theme2.typography[200]};
|
|
1764
|
+
transition: all ${({ theme: theme2 }) => theme2.duration["fast"]};
|
|
1765
1765
|
|
|
1766
1766
|
/* Highlighted */
|
|
1767
1767
|
${({ $highlighted }) => $highlighted && highlightedStyles}
|
|
@@ -1892,7 +1892,6 @@ var useOptionProps = ({
|
|
|
1892
1892
|
const { selectedItem, selectedItems, isListbox } = (0, import_react2.useContext)(MenuContext);
|
|
1893
1893
|
const selected = (0, import_react2.useMemo)(
|
|
1894
1894
|
() => selectedItem?.id === id || !!selectedItems?.find((item) => item?.id === id),
|
|
1895
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1896
1895
|
[selectedItem, selectedItems]
|
|
1897
1896
|
);
|
|
1898
1897
|
const label = inputLabelId || `menu-item-child-${id}`;
|
|
@@ -1922,12 +1921,9 @@ var MenuItem = ({
|
|
|
1922
1921
|
children,
|
|
1923
1922
|
onClick,
|
|
1924
1923
|
onKeyDown,
|
|
1925
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1926
1924
|
disabled: disabled2 = false,
|
|
1927
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1928
1925
|
ref,
|
|
1929
1926
|
href,
|
|
1930
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1931
1927
|
color: color2,
|
|
1932
1928
|
...props
|
|
1933
1929
|
}) => {
|
|
@@ -2296,6 +2292,7 @@ var MenuRoot = ({
|
|
|
2296
2292
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(MenuProvider, { ...contextProps, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2297
2293
|
import_seeds_react_popout.Popout,
|
|
2298
2294
|
{
|
|
2295
|
+
menuPopout: true,
|
|
2299
2296
|
isOpen: !!isOpen,
|
|
2300
2297
|
setIsOpen,
|
|
2301
2298
|
content: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(CustomPopoutContent, { width: width2, children }),
|
|
@@ -2388,13 +2385,12 @@ var useItemsFromChildren = ({
|
|
|
2388
2385
|
const allMenuItemElements = getAllMenuItems(children);
|
|
2389
2386
|
const menuItemsMap2 = {};
|
|
2390
2387
|
const allMenuItems2 = allMenuItemElements.map(
|
|
2391
|
-
({ element
|
|
2388
|
+
({ element }, index) => {
|
|
2392
2389
|
const item = {
|
|
2393
2390
|
id: element.props.id,
|
|
2394
2391
|
disabled: element.props.disabled,
|
|
2395
2392
|
index,
|
|
2396
|
-
element
|
|
2397
|
-
parents
|
|
2393
|
+
menuItemProps: element.props
|
|
2398
2394
|
};
|
|
2399
2395
|
menuItemsMap2[`${item.id}`] = item;
|
|
2400
2396
|
return item;
|
|
@@ -2439,11 +2435,11 @@ var handleStateChange = (changes, currentSelectedItem) => {
|
|
|
2439
2435
|
const selectedItem = changes.selectedItem || currentSelectedItem;
|
|
2440
2436
|
if (!selectedItem)
|
|
2441
2437
|
return;
|
|
2442
|
-
if (selectedItem.
|
|
2438
|
+
if (selectedItem.disabled) {
|
|
2443
2439
|
return;
|
|
2444
2440
|
}
|
|
2445
2441
|
const isEnterKeyDown = changes.type === import_downshift2.useSelect.stateChangeTypes.ToggleButtonKeyDownEnter;
|
|
2446
|
-
const selectedItemProps = selectedItem.
|
|
2442
|
+
const selectedItemProps = selectedItem.menuItemProps;
|
|
2447
2443
|
if (selectedItemProps?.onClick) {
|
|
2448
2444
|
const syntheticKeyboardEvent = new KeyboardEvent("keydown", {
|
|
2449
2445
|
key: isEnterKeyDown ? "Enter" : " ",
|