import type { ReactElement, ReactNode } from 'react'; export type ContextMenuRole = 'copy' | 'paste' | 'cut' | 'selectAll' | 'undo' | 'redo' | 'quit'; /** What an item does: a built-in `` element, or your own function. */ export type ContextMenuAction = ReactElement | (() => void | Promise); export interface ContextMenuEntry { label: string; shortcut?: string; disabled?: boolean; /** A built-in `` / `` / … element, or a custom function. */ action?: ContextMenuAction; /** A nested submenu (in place of an action). */ items?: ContextMenuItemSpec[]; } export type ContextMenuItemSpec = ContextMenuEntry | { separator: true; }; export declare function useContextMenu(items: ContextMenuItemSpec[]): void; export declare function useContextMenu(id: string, items: ContextMenuItemSpec[]): void; export interface ContextMenuTriggerProps { /** Links this region to the `useContextMenu(id, …)` of the same name. */ id: string; /** * Also pull in the enclosing scope's items (a separator, then its items) — * and, if that scope inherits too, recurse outward from there, up to the * app-wide default menu (the outermost root scope). Defaults to `false`: * this scope's items only, same as today. */ inherit?: boolean; /** * Attach the handler to the child element directly (no wrapper node). Defaults * to `true` when there's a single element child, `false` otherwise (then a * `display: contents` `` carries the handler). Set it explicitly to * override. */ asChild?: boolean; children?: ReactNode; } export declare function ContextMenuTrigger({ id, inherit, asChild, children }: ContextMenuTriggerProps): import("react").JSX.Element; declare function Reload(): null; declare namespace Reload { var displayName: string; } export interface ActionNavigateProps { to: string; } declare function Navigate(_props: ActionNavigateProps): null; declare namespace Navigate { var displayName: string; } export interface ActionRunProps { action: () => void | Promise; } /** A custom action in component form — the same as passing a bare function. */ declare function Run(_props: ActionRunProps): null; declare namespace Run { var displayName: string; } export declare const Action: { Copy: { (): null; displayName: string; }; Paste: { (): null; displayName: string; }; Cut: { (): null; displayName: string; }; SelectAll: { (): null; displayName: string; }; Undo: { (): null; displayName: string; }; Redo: { (): null; displayName: string; }; Quit: { (): null; displayName: string; }; Reload: typeof Reload; Navigate: typeof Navigate; Run: typeof Run; }; /** * Turn a map of named functions into `` components you can drop * straight into a menu item's `action`, alongside the built-ins. Define your * app's actions once (typically in `src/lib/action.ts`, backed by a store so * they're callable from anywhere) and reuse them across menus without a * per-call-site wrapper. For example, define an `increment` entry with * `createActions`, then use the resulting `Action.increment` component as the * menu item's action. * * The returned object also includes the built-in `Action.Copy` / `Action.Reload` * / … so a file can import a single `Action`. */ export declare function createActions void | Promise>>(defs: T): typeof Action & { [K in keyof T]: () => null; }; export {}; //# sourceMappingURL=context-menu.d.ts.map