@sproutsocial/seeds-react-menu 0.2.0 → 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/.turbo/turbo-build.log +10 -10
- package/CHANGELOG.md +13 -0
- package/dist/esm/index.js +35 -20
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +8 -7
- package/dist/index.d.ts +8 -7
- package/dist/index.js +35 -20
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/ActionMenu/ActionMenu.tsx +2 -2
- package/src/MenuItem/styles.tsx +3 -1
- package/src/MenuRoot/MenuRoot.feature +20 -10
- package/src/MenuRoot/MenuRoot.tsx +1 -0
- package/src/MenuRoot/__tests__/MenuRoot.test.tsx +163 -30
- package/src/MultiSelectMenu/MultiSelectMenu.feature +2 -13
- package/src/MultiSelectMenu/__tests__/MultiSelectMenu.test.tsx +139 -133
- package/src/hooks/useItemsFromChildren.tsx +7 -4
- package/src/index.ts +1 -0
- package/src/types.ts +2 -5
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
|
|
|
@@ -144,7 +141,7 @@ interface TypeMenuGroupProps extends TypeMenuGroupStyledProps, Omit<React.Compon
|
|
|
144
141
|
declare const MenuGroup: ({ titleAs, children, title, color, ...rest }: TypeMenuGroupProps) => react_jsx_runtime.JSX.Element;
|
|
145
142
|
|
|
146
143
|
declare const StyledMenuGroup: styled_components.StyledComponent<"li", styled_components.DefaultTheme, TypeMenuGroupProps, never>;
|
|
147
|
-
declare const StyledTitle: styled_components.StyledComponent<
|
|
144
|
+
declare const StyledTitle: styled_components.StyledComponent<React$1.FC<_sproutsocial_seeds_react_text.TypeTextProps>, styled_components.DefaultTheme, {}, never>;
|
|
148
145
|
declare const StyledMenuGroupUl: styled_components.StyledComponent<"ul", styled_components.DefaultTheme, {}, never>;
|
|
149
146
|
|
|
150
147
|
interface TypeDownshiftMultiSelectProps extends Partial<UseSelectProps<TypeDefaultItemProps>>, Partial<Omit<UseMultipleSelectionProps<TypeDefaultItemProps>, "stateReducer" | "onStateChange" | "getA11yStatusMessage">> {
|
|
@@ -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
|
|
|
@@ -144,7 +141,7 @@ interface TypeMenuGroupProps extends TypeMenuGroupStyledProps, Omit<React.Compon
|
|
|
144
141
|
declare const MenuGroup: ({ titleAs, children, title, color, ...rest }: TypeMenuGroupProps) => react_jsx_runtime.JSX.Element;
|
|
145
142
|
|
|
146
143
|
declare const StyledMenuGroup: styled_components.StyledComponent<"li", styled_components.DefaultTheme, TypeMenuGroupProps, never>;
|
|
147
|
-
declare const StyledTitle: styled_components.StyledComponent<
|
|
144
|
+
declare const StyledTitle: styled_components.StyledComponent<React$1.FC<_sproutsocial_seeds_react_text.TypeTextProps>, styled_components.DefaultTheme, {}, never>;
|
|
148
145
|
declare const StyledMenuGroupUl: styled_components.StyledComponent<"ul", styled_components.DefaultTheme, {}, never>;
|
|
149
146
|
|
|
150
147
|
interface TypeDownshiftMultiSelectProps extends Partial<UseSelectProps<TypeDefaultItemProps>>, Partial<Omit<UseMultipleSelectionProps<TypeDefaultItemProps>, "stateReducer" | "onStateChange" | "getA11yStatusMessage">> {
|
|
@@ -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
|
@@ -1729,13 +1729,14 @@ var highlightedStyles = import_styled_components2.css`
|
|
|
1729
1729
|
cursor: pointer;
|
|
1730
1730
|
border: 1px solid ${({ theme: theme2 }) => theme2.colors.listItem.border.base};
|
|
1731
1731
|
background-color: ${({ theme: theme2 }) => theme2.colors.listItem.background.hover};
|
|
1732
|
+
color: ${({ theme: theme2 }) => theme2.colors.text.body};
|
|
1733
|
+
text-decoration: none;
|
|
1732
1734
|
`;
|
|
1733
1735
|
var MenuItemContainer = import_styled_components2.default.li`
|
|
1734
1736
|
box-sizing: border-box;
|
|
1735
1737
|
list-style-type: none;
|
|
1736
1738
|
margin-left: ${({ theme: theme2 }) => theme2.space[300]};
|
|
1737
1739
|
margin-right: ${({ theme: theme2 }) => theme2.space[300]};
|
|
1738
|
-
transition: all ${({ theme: theme2 }) => theme2.duration["fast"]};
|
|
1739
1740
|
|
|
1740
1741
|
&:first-child {
|
|
1741
1742
|
margin-top: ${({ theme: theme2 }) => theme2.space[300]};
|
|
@@ -1760,6 +1761,7 @@ var StyledMenuItem = import_styled_components2.default.div`
|
|
|
1760
1761
|
padding: ${({ theme: theme2 }) => theme2.space[300]};
|
|
1761
1762
|
outline: 0;
|
|
1762
1763
|
${({ theme: theme2 }) => theme2.typography[200]};
|
|
1764
|
+
transition: all ${({ theme: theme2 }) => theme2.duration["fast"]};
|
|
1763
1765
|
|
|
1764
1766
|
/* Highlighted */
|
|
1765
1767
|
${({ $highlighted }) => $highlighted && highlightedStyles}
|
|
@@ -2182,20 +2184,33 @@ var Text = ({ fontSize: fontSize2, children, qa, color: color2, ...rest }) => {
|
|
|
2182
2184
|
}
|
|
2183
2185
|
);
|
|
2184
2186
|
};
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
Text.
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
Text.
|
|
2197
|
-
|
|
2198
|
-
|
|
2187
|
+
var withTextLogic = (Component) => {
|
|
2188
|
+
return ({ children, ...props }) => {
|
|
2189
|
+
const qaText = typeof children === "string" ? children : void 0;
|
|
2190
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Component, { "data-qa-text": qaText, ...props, children });
|
|
2191
|
+
};
|
|
2192
|
+
};
|
|
2193
|
+
var HeadlineWithLogic = withTextLogic(Headline);
|
|
2194
|
+
HeadlineWithLogic.displayName = "Text.Headline";
|
|
2195
|
+
Text.Headline = HeadlineWithLogic;
|
|
2196
|
+
var SubHeadlineWithLogic = withTextLogic(SubHeadline);
|
|
2197
|
+
SubHeadlineWithLogic.displayName = "Text.SubHeadline";
|
|
2198
|
+
Text.SubHeadline = SubHeadlineWithLogic;
|
|
2199
|
+
var SmallSubHeadlineWithLogic = withTextLogic(SmallSubHeadline);
|
|
2200
|
+
SmallSubHeadlineWithLogic.displayName = "Text.SmallSubHeadline";
|
|
2201
|
+
Text.SmallSubHeadline = SmallSubHeadlineWithLogic;
|
|
2202
|
+
var BylineWithLogic = withTextLogic(Byline);
|
|
2203
|
+
BylineWithLogic.displayName = "Text.Byline";
|
|
2204
|
+
Text.Byline = BylineWithLogic;
|
|
2205
|
+
var SmallBylineWithLogic = withTextLogic(SmallByline);
|
|
2206
|
+
SmallBylineWithLogic.displayName = "Text.SmallByline";
|
|
2207
|
+
Text.SmallByline = SmallBylineWithLogic;
|
|
2208
|
+
var BodyCopyWithLogic = withTextLogic(BodyCopy);
|
|
2209
|
+
BodyCopyWithLogic.displayName = "Text.BodyCopy";
|
|
2210
|
+
Text.BodyCopy = BodyCopyWithLogic;
|
|
2211
|
+
var SmallBodyCopyWithLogic = withTextLogic(SmallBodyCopy);
|
|
2212
|
+
SmallBodyCopyWithLogic.displayName = "Text.SmallBodyCopy";
|
|
2213
|
+
Text.SmallBodyCopy = SmallBodyCopyWithLogic;
|
|
2199
2214
|
var Text_default = Text;
|
|
2200
2215
|
var src_default = Text_default;
|
|
2201
2216
|
|
|
@@ -2277,6 +2292,7 @@ var MenuRoot = ({
|
|
|
2277
2292
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(MenuProvider, { ...contextProps, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2278
2293
|
import_seeds_react_popout.Popout,
|
|
2279
2294
|
{
|
|
2295
|
+
menuPopout: true,
|
|
2280
2296
|
isOpen: !!isOpen,
|
|
2281
2297
|
setIsOpen,
|
|
2282
2298
|
content: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(CustomPopoutContent, { width: width2, children }),
|
|
@@ -2369,13 +2385,12 @@ var useItemsFromChildren = ({
|
|
|
2369
2385
|
const allMenuItemElements = getAllMenuItems(children);
|
|
2370
2386
|
const menuItemsMap2 = {};
|
|
2371
2387
|
const allMenuItems2 = allMenuItemElements.map(
|
|
2372
|
-
({ element
|
|
2388
|
+
({ element }, index) => {
|
|
2373
2389
|
const item = {
|
|
2374
2390
|
id: element.props.id,
|
|
2375
2391
|
disabled: element.props.disabled,
|
|
2376
2392
|
index,
|
|
2377
|
-
element
|
|
2378
|
-
parents
|
|
2393
|
+
menuItemProps: element.props
|
|
2379
2394
|
};
|
|
2380
2395
|
menuItemsMap2[`${item.id}`] = item;
|
|
2381
2396
|
return item;
|
|
@@ -2420,11 +2435,11 @@ var handleStateChange = (changes, currentSelectedItem) => {
|
|
|
2420
2435
|
const selectedItem = changes.selectedItem || currentSelectedItem;
|
|
2421
2436
|
if (!selectedItem)
|
|
2422
2437
|
return;
|
|
2423
|
-
if (selectedItem.
|
|
2438
|
+
if (selectedItem.disabled) {
|
|
2424
2439
|
return;
|
|
2425
2440
|
}
|
|
2426
2441
|
const isEnterKeyDown = changes.type === import_downshift2.useSelect.stateChangeTypes.ToggleButtonKeyDownEnter;
|
|
2427
|
-
const selectedItemProps = selectedItem.
|
|
2442
|
+
const selectedItemProps = selectedItem.menuItemProps;
|
|
2428
2443
|
if (selectedItemProps?.onClick) {
|
|
2429
2444
|
const syntheticKeyboardEvent = new KeyboardEvent("keydown", {
|
|
2430
2445
|
key: isEnterKeyDown ? "Enter" : " ",
|