import type { ARIAButtonType } from '@fluentui/react-aria'; import type { ComponentProps } from '@fluentui/react-utilities'; import type { ComponentState } from '@fluentui/react-utilities'; import type { ContextSelector } from '@fluentui/react-context-selector'; import type { EventData } from '@fluentui/react-utilities'; import type { EventHandler } from '@fluentui/react-utilities'; import type { ForwardRefComponent } from '@fluentui/react-utilities'; import type { JSXElement } from '@fluentui/react-utilities'; import type { PopoverTriggerChildProps as PopoverTriggerChildProps_2 } from '@fluentui/react-popover'; import { PositioningShorthand } from '@fluentui/react-positioning'; import * as React_2 from 'react'; import type { Slot } from '@fluentui/react-utilities'; import type { TriggerProps } from '@fluentui/react-utilities'; declare type HeadlessPopoverTriggerChildExtras = { 'aria-haspopup'?: 'true'; 'aria-details'?: string; 'data-open'?: string; }; /** * Data attached to open/close events. Uses the canonical `EventData` shape so * consumers can discriminate on `type` or use the handler directly via * `EventHandler`. */ export declare type OnOpenChangeData = EventData & { open: boolean; }; /** * Events that can trigger Popover open/close changes. */ export declare type OpenPopoverEvents = MouseEvent | TouchEvent | React_2.FocusEvent | React_2.KeyboardEvent | React_2.MouseEvent; /** * Headless Popover component. * * Renders the surface in the browser's top layer with `popover="auto"`, * letting the platform handle light dismiss (Escape, click-outside, * popover-stack peer dismissal). Open paths (click, hover, context menu, * controlled `open` prop) flow through React; close paths defer to the * browser, with `toggle` events mirrored back into state. */ export declare const Popover: { (props: PopoverProps): JSXElement; displayName: string; }; /** * Context shared between Popover and its children. */ export declare type PopoverContextValue = Pick & { positioning: { targetRef: React_2.RefCallback; containerRef: React_2.RefCallback; }; }; /** * Popover Props */ export declare type PopoverProps = { /** * Can contain two children including `PopoverTrigger` and `PopoverSurface`. * Alternatively can only contain `PopoverSurface` if using a custom `target`. */ children: [JSXElement, JSXElement] | JSXElement; /** Controlled open state. */ open?: boolean; /** * Default open state for uncontrolled mode. * @default false */ defaultOpen?: boolean; /** Callback when the open state changes. */ onOpenChange?: EventHandler; /** * Open on hover. * @default false */ openOnHover?: boolean; /** * Open on context menu (right-click). * @default false */ openOnContext?: boolean; /** * Delay in ms before closing on mouse leave. * @default 500 */ mouseLeaveDelay?: number; /** * Positioning configuration. Accepts either a full `PositioningProps` * object or a shorthand string such as `'below'` / `'above-end'`. * * See the {@link https://react.fluentui.dev/?path=/docs/headless-concepts-positioning--docs Positioning concept} * for the full list of options and live examples. */ positioning?: PositioningShorthand; /** * Display an arrow pointing to the target. * @default false */ withArrow?: boolean; /** * Optional id for the popover surface. When provided, this id is applied to * the `PopoverSurface` element and referenced by `PopoverTrigger` * (`aria-details`). If omitted, a generated id is used. */ id?: string; /** * When true, opens the popover as a modal via `HTMLDialogElement.showModal()`. * Focus is trapped inside the surface, the rest of the page is inert, and * focus is restored to the trigger when the popover closes — all spec-mandated * by the native dialog element. * * When false (default), the popover is non-modal: opens via `showPopover()`, * the browser handles light dismiss (Escape, click-outside, popover-stack * peer dismissal), and no focus trap or autofocus is applied unless a child * has the HTML `autofocus` attribute. * * @default false */ trapFocus?: boolean; }; /** * Popover State */ export declare type PopoverState = Required> & Pick & { setOpen: (e: OpenPopoverEvents, open: boolean) => void; toggleOpen: (e: OpenPopoverEvents) => void; triggerRef: React_2.RefObject; contentRef: React_2.RefObject; arrowRef: React_2.RefObject; popoverTrigger: React_2.ReactElement | undefined; popoverSurface: React_2.ReactElement | undefined; contextTarget: { x: number; y: number; } | undefined; setContextTarget: (target: { x: number; y: number; } | undefined) => void; positioning: PositioningReturn; surfaceId: string; }; /** * Headless PopoverSurface component. * * Renders the popover content area as a native `` so * a single element supports both non-modal (`showPopover()`) and modal * (`showModal()`) show modes; the choice is driven by the parent * `Popover`'s `trapFocus` prop. */ export declare const PopoverSurface: ForwardRefComponent; export declare type PopoverSurfaceProps = ComponentProps; /** * PopoverSurface Slots. * * The root renders as a native `` so a single element * supports both show modes: `showPopover()` for non-modal (default) and * `showModal()` for the modal/focus-trap path. */ export declare type PopoverSurfaceSlots = { root: Slot<'dialog'>; }; export declare type PopoverSurfaceState = ComponentState & { withArrow: boolean | undefined; arrowRef: React_2.RefObject; 'data-open': string; }; /** * Headless PopoverTrigger component. * * Wraps a trigger element, applying event handlers and ARIA attributes * for popover interaction. */ export declare const PopoverTrigger: React_2.FC; /** * Props that are merged onto the child of the PopoverTrigger when cloned. * Composes canonical {@link CanonicalPopoverTriggerChildProps} with the headless-specific extras. */ declare type PopoverTriggerChildProps = PopoverTriggerChildProps_2; /** * PopoverTrigger Props */ export declare type PopoverTriggerProps = Omit, 'children'> & { children: React_2.ReactElement; /** * Disable ARIA button enhancement on the trigger. * @default false */ disableButtonEnhancement?: boolean; }; /** * PopoverTrigger State */ export declare type PopoverTriggerState = { children: React_2.ReactElement | null; }; declare type PositioningReturn = { targetRef: React_2.RefCallback; containerRef: React_2.RefCallback; }; /** * Renders the Popover component by wrapping children with the PopoverContext.Provider. */ export declare const renderPopover: (state: PopoverState, contextValues: { popover: PopoverContextValue; }) => React_2.ReactElement; export declare const renderPopoverSurface: (state: PopoverSurfaceState) => JSXElement; /** * Renders the PopoverTrigger (returns the cloned child element). */ export declare const renderPopoverTrigger: (state: PopoverTriggerState) => JSXElement | null; /** * Returns the state for a Popover component. */ export declare const usePopover: (props: PopoverProps) => PopoverState; /** * Hook to consume PopoverContext with a selector for optimized re-renders. */ export declare const usePopoverContext: (selector: ContextSelector) => T; export declare const usePopoverContextValues: (state: PopoverState) => { popover: PopoverContextValue; }; /** * Returns the state for a PopoverSurface component. */ export declare const usePopoverSurface: (props: PopoverSurfaceProps, ref: React_2.Ref) => PopoverSurfaceState; /** * Returns the state for a PopoverTrigger component. * Applies event handlers and ARIA attributes to the child element. */ export declare const usePopoverTrigger: (props: PopoverTriggerProps) => PopoverTriggerState; export { }