import { type PopoverRootProps } from '@ark-ui/react/popover'; import { type RefObject } from 'react'; import { type CollisionPadding } from './useSafeCollisionPadding.ts'; export type PositionSide = 'top' | 'right' | 'bottom' | 'left'; export type PositionAlign = 'start' | 'center' | 'end'; /** How floating content wants to be placed; the machine, which the root owns, does the placing. */ export type PlacementOptions = { side?: PositionSide; align?: PositionAlign; sideOffset?: number; alignOffset?: number; collisionPadding?: CollisionPadding; collisionBoundary?: Element | null | Array; avoidCollisions?: boolean; hideWhenDetached?: boolean; }; /** The `positioning` every Zag floating machine takes; the popover's is the shared shape. */ export type Positioning = NonNullable; /** What a Zag machine accepts as the element its floating content is positioned against. */ export type AnchorElement = HTMLElement | { getBoundingClientRect: () => DOMRect; contextElement?: Element; }; /** * Hands a virtual anchor to the machine as its anchor element rather than as a bare rect: the * element is what the machine's scroll and resize observers attach to, so the content follows the * anchor when an ancestor scrolls. */ export declare const toAnchorElement: (element: Element | null) => AnchorElement | null; export declare const toPlacement: (side?: PositionSide, align?: PositionAlign) => "bottom-end" | "bottom-start" | "left-end" | "left-start" | "right-end" | "right-start" | "top-end" | "top-start" | PositionSide; /** Consumers hand the machine a per-side padding; it takes one number, so the widest side wins. */ export declare const toOverflowPadding: (padding: { top: number; right: number; bottom: number; left: number; }) => number; export type UsePositioningOptions = { open: boolean; /** The element the content is placed at and bounded by, unless a virtual anchor stands in. */ triggerRef: RefObject; placement: PlacementOptions; defaultSide?: PositionSide; defaultAlign?: PositionAlign; }; /** * Radix-shaped placement props as one Zag `positioning` object, plus a virtual anchor the machine * positions at, and observes, in place of its trigger. Shared by every floating root so the * collision, offset and anchor semantics are one implementation. */ export type UsePositioningResult = { positioning: Positioning; /** Registers the element the content is positioned at instead of the trigger; returns the unregister. */ setVirtualAnchor: (ref: RefObject) => () => void; }; export declare const usePositioning: ({ open, triggerRef, placement: options, defaultSide, defaultAlign, }: UsePositioningOptions) => UsePositioningResult; //# sourceMappingURL=usePositioning.d.ts.map