UNPKG

@payfit/unity-components

Version:

52 lines (51 loc) • 2.33 kB
import { PropsWithChildren, ReactNode } from 'react'; import { MenuProps as ReactAriaMenuProps } from 'react-aria-components/Menu'; export interface MenuContentProps { /** Sets a fixed width for the menu panel. */ width?: number; /** Adds custom classes to the menu panel. */ className?: string; /** Controls whether items can be selected and which selection model to use. */ selectionMode?: ReactAriaMenuProps<object>['selectionMode']; /** Controls the selected item keys for selection-enabled menus. */ selectedKeys?: ReactAriaMenuProps<object>['selectedKeys']; /** Renders custom content when the menu has no items. */ renderEmptyState?: ReactNode | (() => ReactNode); } /** * Provides the keyboard-navigable list inside a `Menu` or `MenuSubmenu`. * * Use `MenuContent` for actions, links, sections, and custom empty states. * The panel uses Unity's menu sizing by default and keeps item focus and * selection semantics provided by React Aria. * @param props - Menu items, sizing, selection, and empty-state content. * @param props.children - `RawMenuItem`, `MenuSection`, `MenuSeparator`, or * `MenuSubmenu` elements. * @param props.width - Sets a fixed panel width in pixels. * @param props.className - Adds custom classes to the menu panel. * @param props.selectionMode - Enables single or multiple item selection. * @param props.selectedKeys - Controls the selected item keys. * @param props.renderEmptyState - Renders when the menu contains no items. * @see {@link MenuContentProps} for all available props. * @see {@link RawMenuItem} for the standard item composition. * @example * ```tsx * import { * MenuContent, * RawMenuItem, * } from '@payfit/unity-components' * * <MenuContent> * <RawMenuItem>Cut</RawMenuItem> * <RawMenuItem>Copy</RawMenuItem> * </MenuContent> * ``` * @remarks * The default panel width is at least 192px and at most 384px, including when * the menu renders an empty state. Pass `renderEmptyState` when the menu can * legitimately have no actions. */ export declare function MenuContent({ children, width, className, selectionMode, selectedKeys, renderEmptyState, }: PropsWithChildren<MenuContentProps>): import('react/jsx-runtime').JSX.Element; export declare namespace MenuContent { var displayName: string; }