import * as React from 'react'; import { ListAction, ListState, UseListRootSlotProps } from '../useList'; import { MenuItemMetadata } from '../useMenuItem'; import { EventHandlers } from '../utils/types'; import { MenuProviderValue } from './MenuProvider'; export interface UseMenuParameters { /** * If `true`, the menu will be initially open. * @default false */ defaultOpen?: boolean; /** * If `true`, the menu will be open. * This is the controlled equivalent of the `defaultOpen` parameter. */ open?: boolean; /** * Callback fired when the menu is opened or closed. */ onOpenChange?: (open: boolean) => void; /** * Id of the menu listbox. */ listboxId?: string; /** * Ref of the menu listbox. */ listboxRef?: React.Ref; } export interface UseMenuReturnValue { /** * The value to be passed into the MenuProvider. */ contextValue: MenuProviderValue; /** * Action dispatcher for the menu component. * Allows to programmatically control the menu. */ dispatch: (action: ListAction) => void; /** * Resolver for the listbox component's props. * @param otherHandlers event handlers for the listbox component * @returns props that should be spread on the listbox component */ getListboxProps: (otherHandlers?: TOther) => UseMenuListboxSlotProps; /** * The highlighted option in the menu listbox. */ highlightedValue: string | null; /** * The ref to the listbox DOM node. */ listboxRef: React.RefCallback | null; /** * Items in the menu listbox. */ menuItems: Map; /** * If `true`, the menu is open. */ open: boolean; } interface UseMenuListboxSlotEventHandlers { onBlur: React.FocusEventHandler; onKeyDown: React.KeyboardEventHandler; } export type UseMenuListboxSlotProps = UseListRootSlotProps & UseMenuListboxSlotEventHandlers> & { ref: React.RefCallback | null; role: React.AriaRole; }; export interface MenuInternalState extends ListState { /** * If `true`, the menu is open. */ open: boolean; } export {};