/* 0.112.0 */ import type { KeyboardModifiers } from './ui-events-types'; /** * The type of a menu item: * - `command`: a command that can be selected and executed * - `divider`: a visual separator * - `heading`: a heading, not selectable. If following items * (until next divider or heading) are not visible, the heading is not * visible either. * - `submenu`: a submenu */ export type MenuItemType = 'command' | 'divider' | 'heading' | 'submenu'; /** * These props are passed to the `menu-select` event and `onMenuSelect` hook * - `id`: the `id` associated with the menu item. * - `data`: the `data` payload associated with the menu item * - `modifiers`: the keyboard modifiers that were pressed when the menu item was selected */ export type MenuItemProps = { id?: string; data?: T; modifiers?: KeyboardModifiers; }; export type DynamicValue = T | ((modifiers: KeyboardModifiers) => T); declare global { /** * Map the custom event names to types * @internal */ export interface DocumentEventMap { ['menu-select']: CustomEvent; } } export type MenuItemCommand = { type?: 'command'; /** A string of HTML markup used to describe the item */ label?: DynamicValue; /** An accessible text string that describes the item. * Usually not necessary, as the `label` is used for this, * however if the menu item is for example a color swatch, * the `ariaLabel` can be used to describe the color. */ ariaLabel?: DynamicValue; tooltip?: DynamicValue; /** A CSS class applied to the item */ class?: DynamicValue; keyboardShortcut?: string; visible?: DynamicValue; enabled?: DynamicValue; checked?: DynamicValue; /** This id string is passed to the `onMenuSelect()` hook and with the `menu-select` event */ id?: string; /** This data payload is passed to the `onMenuSelect()` hook and with the `menu-select` event */ data?: T; /** When this menu item is selected, a `menu-select` event is dispatched * and this hook is called. */ onMenuSelect?: (_: { target: EventTarget | undefined; modifiers: KeyboardModifiers; id?: string; data?: T; }) => void; }; /** A divider is a visual separator between menu items. * It is not selectable. */ export type MenuItemDivider = { type: 'divider'; }; /** A heading is a menu item that is not selectable * and used to group menu items. * * If followiung items (until next divider or heading) are not visible, the heading is not * visible either. */ export type MenuItemHeading = { type: 'heading'; label?: DynamicValue; ariaLabel?: DynamicValue; tooltip?: DynamicValue; class?: DynamicValue; }; export type MenuItemSubmenu = { type?: 'submenu'; label?: DynamicValue; ariaLabel?: DynamicValue; tooltip?: DynamicValue; class?: DynamicValue; submenu: Readonly; visible?: DynamicValue; enabled?: DynamicValue; /** * * If the menu is arranged in a custom grid, this is the number of columns. * * This property is used for keyboard navigation with the arrow keys. * * **Default**: 1. * */ columnCount?: number; /** The class applied to the submenu container. */ submenuClass?: string; }; export declare function isSubmenu(item: MenuItem): item is MenuItemSubmenu; export declare function isCommand(item: MenuItem): item is MenuItemCommand; export declare function isDivider(item: MenuItem): item is MenuItemDivider; export declare function isHeading(item: MenuItem): item is MenuItemHeading; /** Declaration of a menu item */ export type MenuItem = MenuItemDivider | MenuItemHeading | MenuItemSubmenu | MenuItemCommand;