/** * ContextMenu - a menu opened by right-click (the native `contextmenu` event) at * the pointer position, rather than by clicking a trigger button. It shares the * exact item / surface look of {@link ./dropdown-menu.tsx DropdownMenu} (classes * ported 1:1 from Studio, token names remapped to veryfront's `[var(--token)]` * vocabulary) and reuses the shared {@link ./floating.tsx Floating} portal + * fixed-positioning helper for dismissal (outside-click / `Escape`), scroll * following, viewport clamping, and portalling into the `[data-vf-ui]` token * scope. The only behavioural difference from DropdownMenu is the trigger: it * captures `onContextMenu`, calls `preventDefault()`, and opens the surface at * the pointer's `clientX` / `clientY` via a zero-size virtual anchor. * * A11y work (roving focus, typeahead, focus trap) is tracked in * anchored-surface.tsx and shared with the other menu surfaces. * * @example * ```tsx * * * Right-click here * * * Actions * * console.log("cut")}>Cut * console.log("copy")}>Copy * * * console.log("delete")}>Delete * * * ``` * * @module react/components/ui/context-menu */ import * as React from "react"; import { type PolymorphicButtonAttributes } from "./slot.js"; import { type DisclosureOptions } from "./disclosure.js"; /** Props accepted by ``. */ export interface ContextMenuProps extends DisclosureOptions { /** The trigger and content parts to compose. */ children: React.ReactNode; } /** * ContextMenu root - owns open state and the pointer position. Renders a * zero-size, `position: fixed` virtual anchor (kept inside the token scope so * the portalled surface resolves `var(--…)`), which `Floating` measures to place * the surface at the last right-click. */ export declare function ContextMenu({ children, open, defaultOpen, onOpenChange }: ContextMenuProps): React.ReactElement; /** Props accepted by ``. */ export interface ContextMenuTriggerProps extends React.HTMLAttributes { /** Merge the trigger behaviour onto your own element instead of a wrapper `div`. */ asChild?: boolean; /** React 19: ref is a regular prop, forwarded to the trigger node. */ ref?: React.Ref; } /** Literal slotted trigger contract with an element-specific ref and events. */ export type ContextMenuSlottedTriggerProps = Omit, "children" | "ref"> & { asChild: true; children: React.ReactElement; ref?: React.Ref; }; /** * Trigger - the region a right-click opens the menu over. Captures * `onContextMenu`, calls `preventDefault()` (suppressing the browser's native * menu), and opens the surface at the pointer coordinates. `asChild` merges onto * the child element, which must forward `ref` to its DOM node. */ export declare function ContextMenuTrigger(props: ContextMenuSlottedTriggerProps): React.ReactElement; export declare function ContextMenuTrigger(props: ContextMenuTriggerProps): React.ReactElement; /** Props accepted by ``. */ export interface ContextMenuContentProps extends React.HTMLAttributes { /** Horizontal edge of the surface aligned to the pointer. @default "start" */ align?: "start" | "end"; /** Consumer ref for the surface node (forwarded through `Floating`). */ ref?: React.Ref; } /** Menu surface - portalled to the pointer position while open. No border (Studio). */ export declare function ContextMenuContent({ children, className, align, onKeyDown, ref, ...props }: ContextMenuContentProps): React.ReactElement | null; /** Groups related items with a tight inner gap (Studio: `gap-px p-0.5`). */ export declare function ContextMenuGroup({ children, className }: { children: React.ReactNode; className?: string; }): React.ReactElement; /** Props accepted by ``. */ export interface ContextMenuItemProps extends React.ButtonHTMLAttributes { /** Called when the item is chosen (also closes the menu). */ onSelect?: () => void; /** `asChild` merges item styling onto your own element. */ asChild?: boolean; /** Consumer ref for the item node. */ ref?: React.Ref; } /** Literal slotted item contract with element-specific refs and events. */ export type ContextMenuSlottedItemProps = Omit, "children" | "ref" | "onSelect"> & { /** Called when the item is chosen (also closes the menu). */ onSelect?: () => void; asChild: true; children: React.ReactElement; disabled?: boolean; ref?: React.Ref; }; /** A selectable menu item. Icons render at `size-3.5` (14px). Closes on select. */ export declare function ContextMenuItem(props: ContextMenuSlottedItemProps): React.ReactElement; export declare function ContextMenuItem(props: ContextMenuItemProps): React.ReactElement; /** Full-width divider between groups (Studio: `-mx-2.5 my-2`). */ export declare function ContextMenuSeparator({ className }: { className?: string; }): React.ReactElement; /** Non-interactive section label - full-strength foreground (Studio). */ export declare function ContextMenuLabel({ children, className, }: { children: React.ReactNode; className?: string; }): React.ReactElement; //# sourceMappingURL=context-menu.d.ts.map