import { CSSProperties, ReactNode } from 'react'; import { SlotClassNames, SlotStyles, HtmlProps } from '../types/slots.types.js'; import { Presentation } from '../configProvider/presentation.types.js'; /** Preferred side of the trigger the panel opens on. Flips to the opposite side when there's no room. */ export declare enum PopoverPlacement { Top = "top", Bottom = "bottom", Left = "left", Right = "right" } /** Alignment along the trigger's cross axis (horizontal for top/bottom, vertical for left/right). */ export declare enum PopoverAlign { Start = "start", Center = "center", End = "end" } /** What opens the popover. */ export declare enum PopoverTrigger { Click = "click", Hover = "hover", Focus = "focus" } export type PopoverSlots = 'root' | 'trigger' | 'floating' | 'panel' | 'arrow' | 'backdrop'; export interface PopoverProps extends Omit { /** The trigger element. */ children?: ReactNode; /** * Place the panel against this element instead of `children`, for one Popover does not wrap. * Open it with `isOpen`; `null` falls back to `children`. */ anchor?: HTMLElement | null; /** The popover body. */ content?: ReactNode; /** Preferred side (default `Bottom`). */ placement?: PopoverPlacement; /** Cross-axis alignment (default `Center`). */ align?: PopoverAlign; /** What opens the popover (default `Click`). */ trigger?: PopoverTrigger; /** Controlled open state. Omit for uncontrolled. */ isOpen?: boolean; /** Initial open state when uncontrolled (default `false`). */ defaultOpen?: boolean; /** * Fires whenever the popover wants to open or close. `fromKeyboard` says * whether a key caused it, which is what a menu needs in order to put the * focus on an entry only when the pointer was not what opened it. */ onOpenChange?: (isOpen: boolean, meta: { fromKeyboard: boolean; }) => void; /** Gap in px between trigger and panel (default `10`). */ offset?: number; /** Render the arrow pointing at the trigger (default `true`). */ withArrow?: boolean; /** Close on a click outside, or when focus leaves the trigger and panel (default `true`). */ closeOnOutsideClick?: boolean; /** Close when pressing Escape (default `true`). */ closeOnEscape?: boolean; /** Delay in ms before a hover-triggered popover opens (default `100`). */ openDelay?: number; /** Delay in ms before a hover-triggered popover closes (default `120`). */ closeDelay?: number; /** Prevent the popover from opening. */ disabled?: boolean; /** * Move focus into the panel when it opens, and claim `role="dialog"` with it. * `'keyboard'` (the default) does it only when the open came from the * keyboard: the panel is portaled to the end of the document, so Tab never * reaches it on its own, while a click leaves the focus where the pointer * already put it. `true` always, `false` never. */ focusOnOpen?: boolean | 'keyboard'; /** * Whether clicking the trigger while the panel is open closes it (default * `true`). A menu button should toggle; a text field that opens a picker * should not, or clicking into it to place the caret would close the panel. */ closeOnTriggerClick?: boolean; /** * `'trigger'` gives the panel at least the trigger's width, for a list that * should line up with the field it belongs to. `'auto'` (the default) lets it * size to its own content. */ width?: 'auto' | 'trigger'; /** * Cap the panel at a readable measure (default `true`). Off for a panel with * its own width, a calendar or a media grid. */ constrainWidth?: boolean; /** Where the panel opens: anchored to the trigger (`Default`), pinned to the bottom of the * screen, or the latter only on a small touch screen. Only a `Click` trigger presents as a * sheet. */ presentation?: Presentation; className?: string; style?: CSSProperties; classNames?: SlotClassNames; styles?: SlotStyles; }