UNPKG

@base-ui-components/react

Version:

Base UI is a library of headless ('unstyled') React components and low-level hooks. You gain complete control over your app's CSS and accessibility features.

85 lines 3.86 kB
import * as React from 'react'; import { PopoverHandle } from "../store/PopoverHandle.js"; import { type BaseUIChangeEventDetails } from "../../utils/createBaseUIEventDetails.js"; import { REASONS } from "../../utils/reasons.js"; import { type PayloadChildRenderFunction } from "../../utils/popups/index.js"; /** * Groups all parts of the popover. * Doesn’t render its own HTML element. * * Documentation: [Base UI Popover](https://base-ui.com/react/components/popover) */ export declare function PopoverRoot<Payload = unknown>(props: PopoverRoot.Props<Payload>): import("react/jsx-runtime").JSX.Element; export interface PopoverRootState {} export interface PopoverRootProps<Payload = unknown> { /** * Whether the popover is initially open. * * To render a controlled popover, use the `open` prop instead. * @default false */ defaultOpen?: boolean; /** * Whether the popover is currently open. */ open?: boolean; /** * Event handler called when the popover is opened or closed. */ onOpenChange?: (open: boolean, eventDetails: PopoverRoot.ChangeEventDetails) => void; /** * Event handler called after any animations complete when the popover is opened or closed. */ onOpenChangeComplete?: (open: boolean) => void; /** * A ref to imperative actions. * - `unmount`: When specified, the popover will not be unmounted when closed. * Instead, the `unmount` function must be called to unmount the popover manually. * Useful when the popover's animation is controlled by an external library. */ actionsRef?: React.RefObject<PopoverRoot.Actions | null>; /** * Determines if the popover enters a modal state when open. * - `true`: user interaction is limited to the popover: document page scroll is locked, and pointer interactions on outside elements are disabled. * - `false`: user interaction with the rest of the document is allowed. * - `'trap-focus'`: focus is trapped inside the popover, but document page scroll is not locked and pointer interactions outside of it remain enabled. * @default false */ modal?: boolean | 'trap-focus'; /** * ID of the trigger that the popover is associated with. * This is useful in conjuntion with the `open` prop to create a controlled popover. * There's no need to specify this prop when the popover is uncontrolled (i.e. when the `open` prop is not set). */ triggerId?: string | null; /** * ID of the trigger that the popover is associated with. * This is useful in conjuntion with the `defaultOpen` prop to create an initially open popover. */ defaultTriggerId?: string | null; /** * A handle to associate the popover with a trigger. * If specified, allows external triggers to control the popover's open state. */ handle?: PopoverHandle<Payload>; /** * The content of the popover. * This can be a regular React node or a render function that receives the `payload` of the active trigger. */ children?: React.ReactNode | PayloadChildRenderFunction<Payload>; } export interface PopoverRootActions { unmount: () => void; close: () => void; } export type PopoverRootChangeEventReason = typeof REASONS.triggerHover | typeof REASONS.triggerFocus | typeof REASONS.triggerPress | typeof REASONS.outsidePress | typeof REASONS.escapeKey | typeof REASONS.closePress | typeof REASONS.focusOut | typeof REASONS.imperativeAction | typeof REASONS.none; export type PopoverRootChangeEventDetails = BaseUIChangeEventDetails<PopoverRoot.ChangeEventReason> & { preventUnmountOnClose(): void; }; export declare namespace PopoverRoot { type State = PopoverRootState; type Props<Payload = unknown> = PopoverRootProps<Payload>; type Actions = PopoverRootActions; type ChangeEventReason = PopoverRootChangeEventReason; type ChangeEventDetails = PopoverRootChangeEventDetails; }