import { type CSSProperties } from 'react'; import { useFloating as useFloatingUI, type Placement, type Strategy } from '@floating-ui/react-dom'; import type { Side, Align } from '../types'; export interface UseFloatingOptions { /** * The preferred side of the floating element. * @default 'bottom' */ side?: Side; /** * The preferred alignment of the floating element. * @default 'center' */ align?: Align; /** * Arrow element for positioning. */ arrowRef?: Element | null; } export interface UseFloatingReturn { /** * The x-coordinate for positioning. */ x: number | null; /** * The y-coordinate for positioning. */ y: number | null; /** * Ready-to-use CSS styles for the floating element. * Includes position, transform and top/left coordinates. * Before the first measurement completes the element is kept off-screen * via `translate(0, -200%)` to prevent a flash of incorrect position. */ floatingStyles: CSSProperties; /** * Ready-to-use CSS styles for the arrow element. * Includes absolute positioning, left/top offset, edge anchoring and * the translate that moves the arrow outside the content boundary. * Only meaningful when an arrowRef is provided. */ arrowStyles: CSSProperties; /** * Computed placement string combining side and align. */ placement: Placement; /** * The positioning strategy. */ strategy: Strategy; /** * Refs for reference and floating elements. */ refs: ReturnType['refs']; /** * Middleware data from positioning calculations. */ middlewareData: ReturnType['middlewareData']; } /** * Hook for positioning floating elements using Floating UI. * * @example * ```tsx * const { x, y, placement, strategy, refs } = useFloating({ * side: 'bottom', * align: 'center', * }); * ``` */ export declare const useFloating: (options?: UseFloatingOptions) => UseFloatingReturn;