import { type ReactNode } from 'react'; interface MenuActionBase { label: string; /** Before the label: an icon, or a mark such as a label's color dot. It stays when the * row is checked, since the check sits at the row's end. */ icon?: ReactNode; /** A second, muted line under the label, such as what a product holds. A search matches it. */ description?: string | undefined; /** The key that does the same from the page, such as `S` or `⌘K`, in plain text at the * row's end. The menu doesn't bind it; the host does. */ shortcut?: string | undefined; /** Muted text at the row's end that tells rows apart, such as a team's key `CORE`. It is * read with the label, and a menu's search matches it. For a key to press, use `shortcut`. */ hint?: string | undefined; /** A small mark at the row's end, such as a dot for something unseen. It is hidden from * screen readers, so say what it means in `label`. */ badge?: ReactNode; disabled?: boolean | undefined; /** Why the action is disabled, shown on hover and read with its name. */ disabledReason?: string | undefined; destructive?: boolean | undefined; /** More text a menu's search matches, beside the label. */ keywords?: string | undefined; } /** Runs `onClick`. */ interface MenuClickAction extends MenuActionBase { onClick: () => void; /** Makes the row an on/off choice, checked while true. */ checked?: boolean | undefined; href?: never; reloadDocument?: never; target?: never; current?: never; copy?: never; } /** Navigates to `href`. */ interface MenuLinkAction extends MenuActionBase { href: string; /** Loads the page instead of routing, for paths the host's router doesn't serve. */ reloadDocument?: boolean | undefined; /** `_blank` opens it in a new tab, such as a page outside the app: a small arrow at the * row's end shows it, and screen readers hear it. */ target?: '_blank' | undefined; /** The page the reader is on, such as the current organization in a switcher: checked at * the row's end and announced as the current page. */ current?: boolean | undefined; onClick?: never; checked?: never; copy?: never; } /** Copies `copy.text` to the clipboard, confirmed with a toast naming `copy.label`, or * saying only that it copied without one. A failure says so too. */ interface MenuCopyAction extends MenuActionBase { copy: { text: string; label?: string | undefined; }; onClick?: never; checked?: never; href?: never; reloadDocument?: never; target?: never; current?: never; } /** Something a menu row does: runs `onClick`, navigates to `href`, or copies * `copy`. Exactly one, so a row that does nothing when chosen doesn't compile. * A disabled action keeps its behavior; one that has none belongs out of the menu. */ export type MenuAction = MenuClickAction | MenuLinkAction | MenuCopyAction; /** A row that opens a menu of its own. */ export interface MenuSubmenu { label: string; icon?: ReactNode; items: MenuEntry[]; search?: MenuSearch | undefined; /** The key that opens it from the page, in plain text by the chevron. */ shortcut?: string | undefined; /** Can't be opened, such as Labels where there are none. */ disabled?: boolean | undefined; /** Why it can't be opened, shown on hover and read with its name. */ disabledReason?: string | undefined; /** More text a menu's search matches, beside the label; a match shows all its rows. */ keywords?: string | undefined; } /** Rows under a heading, which names them for screen readers too. */ export interface MenuGroup { group: string; items: MenuEntry[]; } export interface MenuDivider { divider: true; } export type MenuEntry = MenuAction | MenuSubmenu | MenuGroup | MenuDivider; export declare const menuDivider: MenuDivider; /** A field atop a menu that narrows it, submenus included, to the actions it matches. */ export interface MenuSearch { placeholder: string; /** Shown when nothing matches. */ empty: string; } export declare const isMenuDivider: (entry: MenuEntry) => entry is MenuDivider; export declare const isMenuGroup: (entry: MenuEntry) => entry is MenuGroup; export declare const isMenuSubmenu: (entry: MenuEntry) => entry is MenuSubmenu; /** Gives a menu root its search's filter; `children` renders the root with the query. */ export declare function MenuFilter({ search, children, }: { search: MenuSearch | undefined; children: (query: string) => ReactNode; }): string | number | bigint | boolean | import("react").JSX.Element | Iterable | Promise | import("react").ReactElement> | import("react").ReactPortal | null | undefined> | null | undefined; /** A menu's rows, with its search field when it has one. */ export declare function MenuEntries({ entries, search, query, }: { entries: MenuEntry[]; search?: MenuSearch | undefined; /** The search's text, from the MenuFilter around the menu's root. */ query?: string; }): import("react").JSX.Element; /** A key as `aria-keyshortcuts` spells it: `⌘K` reads Meta+K, `⇧P` Shift+P. */ export declare function ariaKeyShortcut(shortcut: string | undefined): string | undefined; /** Warns in development when an action has no behavior. The types rule that * out, but a JavaScript caller or a cast still can, and its row renders fine * and silently does nothing. */ export declare function warnIfInert(action: MenuAction, where: string): void; /** Runs an action that isn't a link: copies its text or calls its onClick. */ export declare function useRunAction(): (action: MenuAction) => void; /** One action as a menu row: a link, an on/off choice, or a plain item. */ export declare function ActionRow({ action }: { action: MenuAction; }): import("react").JSX.Element; export {};