import { type AriaAttributes, type ComponentType, type Dispatch, type KeyboardEvent, type MouseEvent, type ReactNode, type RefObject, type SetStateAction } from "react"; import { type IDropdownBodyRenderProps } from "../../Dropdown/Dropdown.js"; import { type SizeMedium, type SizeSmall } from "../@types/size.js"; /** * @internal */ export type IUiMenuItemData = { [type in IUiMenuItem["type"]]?: unknown; }; /** * @internal */ export type IUiMenuStaticItem = { type: "static"; id?: string; data: T["static"]; }; /** * Renders as the design-system menu divider. Dangling separators (leading, trailing, or adjacent * after conditional items drop out) are collapsed automatically. * * @internal */ export type IUiMenuSeparatorItem = { type: "separator"; id?: string; }; /** * @internal */ export type IUiMenuInteractiveItem = { type: "interactive"; id: string; stringTitle: string; isDisabled?: boolean; isSelected?: boolean; selectionRole?: "radio" | "checkbox"; isDestructive?: boolean; tooltip?: ReactNode; tooltipWidth?: number; data: T["interactive"]; subItems?: IUiMenuItem[]; iconRight?: ReactNode; iconLeft?: ReactNode; ariaAttributes?: AriaAttributes; }; /** * @internal */ export type IUiMenuGroupItem = { type: "group"; id: string; stringTitle: string; data: T["group"]; subItems: IUiMenuItem[]; }; /** * @internal */ export type IUiMenuContentItem = { type: "content"; id: string; stringTitle: string; isDisabled?: boolean; showComponentOnly?: boolean; iconLeft?: ReactNode; ariaAttributes?: AriaAttributes; data: T["content"]; Component: ComponentType<{ onBack: () => void; onClose: () => void; }>; }; /** * @internal */ export type IUiMenuItem = IUiMenuStaticItem | IUiMenuSeparatorItem | IUiMenuInteractiveItem | IUiMenuGroupItem | IUiMenuContentItem; /** * @internal */ export type IUiMenuFocusableItem = IUiMenuInteractiveItem | IUiMenuContentItem; /** * @internal */ export interface IUiMenuItemProps { item: IUiMenuItem; } /** * @internal */ export interface IUiMenuInteractiveItemWrapperProps { item: IUiMenuInteractiveItem; Component?: ComponentType>; } /** * @internal */ export interface IUiMenuContentItemWrapperProps { item: IUiMenuContentItem; } /** * @internal */ export interface IUiMenuInteractiveItemProps { item: IUiMenuInteractiveItem; isFocused: boolean; /** Whether the item's tooltip should be visually open right now (keyboard-focused, not dismissed). */ isTooltipOpen?: boolean; } /** * @internal */ export interface IUiMenuGroupItemProps { item: IUiMenuGroupItem; } /** * @internal */ export interface IUiMenuStaticItemProps { item: IUiMenuStaticItem; } /** * @internal */ export interface IUiMenuContentItemProps { item: IUiMenuContentItem; isFocused: boolean; } /** * @internal */ export interface IUiMenuContentProps { item: IUiMenuContentItem; } /** * @internal */ export interface IUiMenuSubview { title: string; path: string; tooltipText?: string; payload?: Record; } /** * @internal */ export type IUiMenuControlType = "keyboard" | "mouse" | "unknown"; /** * @internal */ export interface IUiMenuPluggableComponents { InteractiveItem: ComponentType>; InteractiveItemWrapper: ComponentType>; GroupItem: ComponentType>; StaticItem: ComponentType>; ContentItemWrapper: ComponentType>; ContentItem: ComponentType>; Content: ComponentType>; MenuHeader: ComponentType; } /** * @internal */ export interface IUiMenuContext extends IUiMenuPluggableComponents { items: IUiMenuItem[]; size: SizeSmall | SizeMedium; focusedItem: IUiMenuFocusableItem | undefined; shownCustomContentItemId?: string; shownSubview: IUiMenuSubview[]; setShownCustomContentItemId: Dispatch>; pushShownSubview: (subview: IUiMenuSubview) => void; popShownSubview: () => void; onSelect: (item: IUiMenuFocusableItem | undefined, event: MouseEvent | KeyboardEvent) => void; onEnterLevel?: (item: IUiMenuFocusableItem | undefined, event: MouseEvent | KeyboardEvent) => boolean; onLeaveLevel?: (item: IUiMenuFocusableItem | undefined, event: MouseEvent | KeyboardEvent) => boolean; onClose?: () => void; setFocusedId: Dispatch>; isItemFocusable: (item: IUiMenuItem) => boolean; controlType: IUiMenuControlType; setControlType: Dispatch>; /** Whether the container is real-DOM-focused with the browser's :focus-visible heuristic. */ isMenuFocusVisible: boolean; setIsMenuFocusVisible: Dispatch>; scrollToView: (element: HTMLElement | null) => void; makeItemId: (item: IUiMenuItem) => string | undefined; /** * @deprecated use `itemDataTestId` instead. Prop will be removed. */ itemClassName?: ((item: IUiMenuItem) => string | undefined) | string; itemDataTestId?: ((item: IUiMenuItem) => string | undefined) | string; ItemComponent: ComponentType>; menuComponentRef: RefObject; itemsContainerRef: RefObject; menuCtxData?: M; } /** * @internal */ export interface IUiMenuProps extends Partial> { items: IUiMenuItem[]; size?: SizeSmall | SizeMedium; dataTestId?: ((context: IUiMenuContext) => string | undefined) | string; itemDataTestId?: ((item: IUiMenuItem) => string | undefined) | string; minWidth?: number; maxWidth?: number; maxHeight?: ((context: IUiMenuContext) => number | undefined) | number; containerBottomPadding?: "none" | "small" | "medium"; containerTopPadding?: "none" | "small" | "medium"; onSelect?: (item: IUiMenuInteractiveItem, event: MouseEvent | KeyboardEvent) => void; onEnterLevel?: (item: IUiMenuFocusableItem | undefined, event: MouseEvent | KeyboardEvent) => boolean; onLeaveLevel?: (item: IUiMenuFocusableItem | undefined, event: MouseEvent | KeyboardEvent) => boolean; onLevelChange?: (level: number, item?: IUiMenuContentItem | IUiMenuInteractiveItem) => void; onClose?: () => void; onUnhandledKeyDown?: (event: KeyboardEvent, context: IUiMenuContext) => void; shouldKeyboardActionPreventDefault?: boolean; shouldKeyboardActionStopPropagation?: boolean; shouldCloseOnSelect?: boolean; isDisabledFocusable?: boolean; ariaAttributes: Omit; menuCtxData?: M; } //# sourceMappingURL=types.d.ts.map