import { type RefObject } from 'react'; import { type TPlacementOptions } from './resolve-placement'; /** * A point in viewport coordinates (CSS pixels) at which the synthetic * anchor should be placed. * * Axis-named (`x`/`y`) rather than edge-named (`left`/`top`) so the * shape is unambiguous in RTL writing modes - there is no ambiguity * about whether a coordinate is logical (`inline-start`/`block-start`) * or physical (`left`/`top`). Viewport coordinates are always * physical, so we name them with the physical axis labels. */ export type TAnchorPoint = { x: number; y: number; }; /** * Positions a popover at a consumer-supplied viewport coordinate using a * hidden synthetic anchor. * * @example * ```tsx * function PointPositionedPopover({ popoverRef, placement, mousePos }) { * useAnchorPositionAtPoint({ * popoverRef, * placement, * isEnabled: Boolean(mousePos), * getPoint: () => { * if (!mousePos) return null; * return { x: mousePos.clientX, y: mousePos.clientY }; * }, * }); * return ...; * } * ``` */ export declare function useAnchorPositionAtPoint({ popoverRef, placement, getPoint, isEnabled, isOpen, }: { /** * Element being positioned. Passed to `useAnchorPosition`. */ popoverRef: RefObject; /** * Where the popover sits relative to the anchor. */ placement: TPlacementOptions; /** * Lazy callback returning the viewport coordinate to anchor at. * Called once per activation (every `isEnabled: false → true` * transition); the result is latched and not re-read. * * Return `null` to signal "no point yet" - the hook stays in a * no-DOM state so another positioning strategy can own the popover. * * Read from a ref, so it does not need to be memoized. */ getPoint: () => TAnchorPoint | null; /** * When `false`, the hook is a no-op: no synthetic anchor is created * and no positioning is applied. Defaults to `true`. */ isEnabled?: boolean; /** * Whether the popover is currently open. Forwarded to the inner * `useAnchorPosition` so it re-runs across host remount cycles. */ isOpen: boolean; }): void;