import * as React from "react"; /** * A single entry in a {@link PopupMenu}. Provide `label` (with optional `icon`) for the common * case, or `content` for a fully custom item body (overrides `label`/`icon`). * @category Components * @group Popup Menu */ export interface IPopupMenuItem { /** entry discriminant; defaults to a selectable item */ type?: "item"; /** stable unique key for this item */ key: string; /** text shown for the item when `content` is not given */ label?: string; /** optional leading icon, shown before the label */ icon?: React.ReactNode; /** custom item body; when present it overrides `label` and `icon` */ content?: React.ReactNode; /** when true the item cannot be selected */ disabled?: boolean; /** called when this item is selected instead of the menu-level onSelect */ onSelect?: (item: IPopupMenuItem) => void; } /** * A non-selectable divider (horizontal rule) between menu items. * @category Components * @group Popup Menu */ export interface IPopupMenuDivider { /** entry discriminant */ type: "divider"; /** stable unique key for this divider */ key: string; } /** * An entry in a {@link PopupMenu}: a selectable {@link IPopupMenuItem} or an * {@link IPopupMenuDivider}. * @category Components * @group Popup Menu */ export type PopupMenuEntry = IPopupMenuItem | IPopupMenuDivider; /** * Helpers passed to a custom {@link IPopupMenuProps.renderItem} so it can drive the menu's * canonical selection/close behaviour (focus return, onSelect, onClose). * @category Components * @group Popup Menu */ export interface IPopupMenuItemApi { /** select this item (fires onSelect then closes the menu) */ select: () => void; /** close the menu without selecting */ close: () => void; } /** * Props for the reusable {@link PopupMenu} control and the {@link showPopupMenu} helper. The * control has no dependency on the layout model - it can be used as a standalone menu/context menu. * @category Components * @group Popup Menu */ export interface IPopupMenuProps { /** where to position the menu: a screen point (e.g. a right-click location), a DOMRect, or an * element to anchor to. An element is measured when the menu opens. */ anchor: { x: number; y: number; } | DOMRect | HTMLElement; /** the menu entries (selectable items and/or dividers) */ items: PopupMenuEntry[]; /** called with the chosen item when one is selected */ onSelect?: (item: IPopupMenuItem) => void; /** called when the menu closes (selection, Escape/Tab, outside click, or programmatic hide) */ onClose: () => void; /** element the menu is positioned within and portalled into; defaults to the anchor's document body. * Should be a positioned element (e.g. the FlexLayout root) for precise placement. For context menus * on nodes (tab, tabset...) use node.getLayoutRef()! */ container?: HTMLElement; /** maps default class names to custom ones (e.g. for css modules); defaults to identity */ classNameMapper?: (defaultClassName: string) => string; /** custom renderer for an item; must render an element with role="menuitem" and tabIndex=-1 */ renderItem?: (item: IPopupMenuItem, index: number, api: IPopupMenuItemApi) => React.ReactNode; /** element to return focus to when the menu closes; defaults to the anchor when it is an element */ returnFocusTo?: HTMLElement; /** accessible label for the menu */ title?: string; } /** * A reusable, accessible popup menu. Positions itself relative to an anchor point or element, * handles keyboard navigation (arrows, Enter/Space, Escape/Tab), focus management, and * outside-click dismissal. Portals itself into `container` (default: the document body). * * For fire-on-event usage (e.g. a right-click context menu) see {@link showPopupMenu}, which * mounts this component imperatively and returns a hide handle. * @category Components * @group Popup Menu */ export declare const PopupMenu: { (props: IPopupMenuProps): React.ReactPortal; displayName: string; }; /** * Imperatively show a {@link PopupMenu} (e.g. from a context-menu / right-click handler). Mounts * the menu in its own React root and returns an idempotent hide handle; the menu also closes on * selection, Escape/Tab and outside click. * @category Components * @group Popup Menu */ export declare function showPopupMenu(props: IPopupMenuProps): () => void;