import { type ReactNode } from 'react'; import { type FloatingAnchor } from './floating.js'; import { type MenuSize } from './Menu.js'; import { type MenuEntry, type MenuSearch } from './MenuEntries.js'; export interface OpenMenuOptions { search?: MenuSearch | undefined; /** Called once the menu closes, or another menu replaces it. */ onClose?: (() => void) | undefined; /** As `MenuPopup`'s: `sm` rows for a compact surface. */ size?: MenuSize | undefined; /** As `MenuPopup`'s: classes on the menu and its submenus, such as a terminal's colors. */ themeClassName?: string | undefined; /** What else closes it, for a menu over something that moves under it, such as a * terminal's: a wheel outside the menu, the window losing focus, or the window resizing. */ closeOn?: readonly MenuCloseTrigger[] | undefined; } export type MenuCloseTrigger = 'wheel' | 'blur' | 'resize'; /** Where a menu opens: an element, such as the button that opened it, or a pointer event, * such as a right-click. An event with Shift held is left to the browser, whose own menu * then shows; any other has its default prevented. */ export type MenuOpener = FloatingAnchor & { shiftKey?: boolean; preventDefault?: () => void; }; /** Opens a menu of `items` at `at`. Returns false when it opened none: no items, Shift held, * or `at` is the element whose menu is open, which it closes instead. */ export type OpenMenu = (at: MenuOpener, items: MenuEntry[], options?: OpenMenuOptions) => boolean | void; /** * One menu that any number of rows, buttons or a canvas open with their own * items, so a long list holds a single menu rather than one per row. Render * `contextMenu` once. Most hosts want the one `UIProvider` mounts, through * `useOpenMenu`; this is for a menu scoped to one region. */ export declare function useContextMenu(): { openMenu: OpenMenu; closeMenu: () => void; contextMenu: import("react").JSX.Element | null; openedBy: Element | null; }; /** The one menu every row, button and canvas below it opens through `useOpenMenu`, so none * renders a menu of its own. `UIProvider` mounts it; nothing else needs to. */ export declare function ContextMenuProvider({ children }: { children: ReactNode; }): import("react").JSX.Element; /** Opens the app's one shared menu: `openMenu(e, items)` from a right-click, or * `openMenu(button, items)` under a button, which a second press closes. */ export declare function useOpenMenu(): OpenMenu; /** Closes the app's shared menu, if it is open, for a host whose surface moves out from under * it in a way `closeOn` doesn't cover, such as a pane that switches. */ export declare function useCloseMenu(): () => void; /** The element the shared menu is open under, so its button can say it's expanded. */ export declare function useMenuOpenedBy(): Element | null;