import { ReactNode } from 'react'; import { Color } from '../types.js'; import { SurfaceProps, SurfaceVariant } from './Surface.js'; export interface PopoverRootProps { /** Trigger + popover (+ optional close) elements. */ children: ReactNode; /** Initial open state (uncontrolled). Default `false`. Ignored when `open` is provided. */ defaultOpen?: boolean; /** Controlled open state. When provided, internal state is bypassed. */ open?: boolean; /** Fires whenever the open state should change (clicks on trigger, outside-clicks, escape). */ onOpenChange?: (open: boolean) => void; } /** * State container for the `Popover` + `PopoverTrigger` + `Popover` compound. Holds the open * state and the anchor ref so a `PopoverTrigger` can register the anchor element and a sibling * `Popover` can read both via context. * * Use this when you want the trigger and the popover to be siblings in JSX (Radix-style): * * ```tsx * * * ... * * ``` * * Skip this and pass `open`/`onOpenChange`/`anchorRef` directly to `` if you'd rather * control state yourself. */ export declare const PopoverRoot: ({ children, defaultOpen, open: openProp, onOpenChange, }: PopoverRootProps) => import("react/jsx-runtime").JSX.Element; export interface PopoverTriggerProps { /** Single React element to use as the trigger. Must accept `ref` and `onClick`. */ children: ReactNode; } /** * Wraps a single child element to act as the popover trigger. **Clones** the child to attach: * - a `ref` callback that registers the element as the popover's anchor (composed with any * existing ref on the child), * - an `onClick` handler that toggles the surrounding `PopoverRoot`'s open state (composed * with any existing `onClick`). * * No-ops (renders the child as-is) when used outside a `PopoverRoot`. Expects exactly one * React element child that accepts `ref` and `onClick`. */ export declare const PopoverTrigger: ({ children }: PopoverTriggerProps) => import("react/jsx-runtime").JSX.Element; export interface PopoverCloseProps { /** Single React element to use as the close affordance. Must accept `onClick`. */ children: ReactNode; } /** * Wraps a single child element to close the surrounding popover when clicked. **Clones** the * child to attach an `onClick` handler that flips the surrounding `PopoverRoot`'s open state * to `false` (composed with any existing `onClick` on the child). * * ```tsx * * * * ... * * * * ``` * * No-ops (renders the child as-is) when used outside a `PopoverRoot`. */ export declare const PopoverClose: ({ children }: PopoverCloseProps) => import("react/jsx-runtime").JSX.Element; export type PopoverPosition = 'top-start' | 'top' | 'top-end' | 'bottom-start' | 'bottom' | 'bottom-end' | 'left-start' | 'left' | 'left-end' | 'right-start' | 'right' | 'right-end' | 'center'; export type PopoverOffset = OffsetValue | [OffsetValue, OffsetValue]; type OffsetValue = number | string; type PopoverOwnProps = { /** Controlled open state. When omitted, falls back to the surrounding `PopoverRoot` state, then `false`. */ open?: boolean; /** Fires whenever the open state should change. When omitted, falls back to the `PopoverRoot` setter. */ onOpenChange?: (open: boolean) => void; /** Extra classes applied to the popover root `Surface`. */ className?: string; /** Extra classes applied to the inner scrollable content area. Default includes `max-h-[70vh] overflow-auto`. */ contentClassName?: string; /** * Ref to the element the popover should anchor against. Defaults to the anchor registered by `PopoverRoot` + `PopoverTrigger`. * * CSS anchor positioning is used - an `anchor-name` is auto-applied to the element if it doesn't already have one. */ anchorRef?: React.RefObject; /** * Static rect (or ref to one) to anchor against when there's no DOM anchor element (e.g. for a context menu opened at a pointer position). Ignored if `anchorRef.current` exists. */ anchorRect?: DOMRect | React.RefObject; /** * Portal target. CSS selector string (default `'#app, #__next, #root'` - first match wins), or `false` to render inline without portalling. */ root?: string | boolean; /** Anchor side + alignment, or `'center'` to open centered over the anchor. See `PopoverPosition`. Default `'bottom'`. */ position?: PopoverPosition; /** * Spacing from anchor. Either a single value (main axis only) or `[main, cross]`. * * Numbers are pixels; strings pass through (e.g. `'8px'`, `'50%'` - `%` resolves against `anchor-size(width|height)` depending on the position). */ offset?: OffsetValue | [OffsetValue, OffsetValue]; /** * Minimum gap (px) the popover should keep from the viewport edge when it would otherwise be clamped there. Default `4`. Set to `0` to disable. */ viewportMargin?: number; /** Render a backdrop behind the popover. Default `false`. */ backdrop?: boolean; /** Make the backdrop transparent (still captures clicks for outside-close). */ backdropTransparent?: boolean; /** Accent color token (`Color` enum). Sets the popover's `cladd-color-{name}` class - used by border/ring/text helpers. */ color?: Color; /** Popover content. */ children?: ReactNode; /** * Forwarded to the underlying `Surface` as `level`. Default depends on theme: `1` for light theme, `undefined` (parent + 1) for dark theme. */ surfaceLevel?: number | string; /** Surface variant. Default depends on theme: `'gradient'` for dark, `'solid'` for light. */ variant?: SurfaceVariant; /** Outline ring on the popover surface. Default `true` for non-light themes. */ outline?: boolean; /** Set to `true` when the popover is rendered inside a React `lazy()` + `Suspense` boundary so it opens on the next tick (after the lazy chunk has resolved and mounted). */ lazy?: boolean; /** Default `true`. */ closeOnBackdropClick?: boolean; /** Default `true`. Suppressed automatically when this popover has a child popover/dialog open. */ closeOnEscape?: boolean; /** Fires when the open transition begins (after `open` flips to `true`, before the animation). */ onOpen?: () => void; /** Fires after the open transition completes (`transitionend` on the surface). */ onOpened?: () => void; /** Fires when the close transition begins (after `open` flips to `false`, before the animation). */ onClose?: () => void; /** Fires after the close transition completes - use for unmount/cleanup work tied to dismissal. */ onClosed?: () => void; /** Forwarded to the popover surface root element. */ ref?: React.Ref; }; export type PopoverProps = PopoverOwnProps & Omit; /** Shape of `Popover` defaults that can be supplied via `CladdProvider`'s `defaults` prop. */ export type PopoverDefaultProps = Partial>; export declare const Popover: (props: PopoverProps) => import("react/jsx-runtime").JSX.Element; export {}; //# sourceMappingURL=Popover.d.ts.map