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.

68 lines (67 loc) 2.85 kB
import * as React from 'react'; import { type FloatingRootContext } from '@floating-ui/react'; import type { GenericHTMLProps } from '../../utils/types.js'; import type { TransitionStatus } from '../../utils/useTransitionStatus.js'; import { type InteractionType } from '../../utils/useEnhancedClickHandler.js'; import { type OpenChangeReason } from '../../utils/translateOpenChangeReason.js'; export declare function usePopoverRoot(params: usePopoverRoot.Parameters): usePopoverRoot.ReturnValue; export declare namespace usePopoverRoot { interface Parameters { /** * 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, event?: Event, reason?: OpenChangeReason) => void; /** * Whether the popover should also open when the trigger is hovered. * @default false */ openOnHover?: boolean; /** * How long to wait before the popover may be opened on hover. Specified in milliseconds. * * Requires the `openOnHover` prop. * @default 300 */ delay?: number; /** * How long to wait before closing the popover that was opened on hover. * Specified in milliseconds. * * Requires the `openOnHover` prop. * @default 0 */ closeDelay?: number; } interface ReturnValue { open: boolean; setOpen: (open: boolean, event?: Event, reason?: OpenChangeReason) => void; mounted: boolean; setMounted: React.Dispatch<React.SetStateAction<boolean>>; transitionStatus: TransitionStatus; titleId: string | undefined; setTitleId: React.Dispatch<React.SetStateAction<string | undefined>>; descriptionId: string | undefined; setDescriptionId: React.Dispatch<React.SetStateAction<string | undefined>>; floatingRootContext: FloatingRootContext; getRootTriggerProps: (externalProps?: GenericHTMLProps) => GenericHTMLProps; getRootPopupProps: (externalProps?: GenericHTMLProps) => GenericHTMLProps; instantType: 'dismiss' | 'click' | undefined; setTriggerElement: React.Dispatch<React.SetStateAction<Element | null>>; positionerElement: HTMLElement | null; setPositionerElement: React.Dispatch<React.SetStateAction<HTMLElement | null>>; popupRef: React.RefObject<HTMLElement | null>; openMethod: InteractionType | null; openReason: OpenChangeReason | null; } }