import { RefObject } from 'react'; import { ElementPlacement } from './utils'; /** * Floating behavior presets used by `calculateFloatingPosition()`. * * @remarks * Each mode defines its own fallback placement list: * - **tooltip** – top/bottom center. * - **dropdown** – bottom/top aligned to the anchor edge, never centered nor sideways. * - **menu** – bottomLeft/Right → top. * - **submenu** – right/left of parent item. * * @category Utils */ export type ElementFloatingMode = 'tooltip' | 'dropdown' | 'menu' | 'submenu'; /** * Options for floating element positioning. * * @property placement - Initial placement or `"auto"` for fallbacks. * @property offset - Gap (in px) between elements. * @property mode - Floating behavior preset. * * @category Utils */ export interface CalculateFloatingPositionOptions { placement?: ElementPlacement; offset?: number; mode?: ElementFloatingMode; } /** * Computed final placement of the floating element. * * @property x - Clamped X coordinate. * @property y - Clamped Y coordinate. * @property placement - Placement actually applied after fallback logic. * * @category Utils */ export interface ElementFloatingPosition { x: number; y: number; placement: ElementPlacement; } /** * Computes the optimal on-screen position for tooltips, dropdowns, menus and submenus. * * @param referenceRef - Ref to anchor element. * @param floatingRef - Ref to floating panel element. * @param options - Placement configuration. * * @returns Final `{ x, y, placement }`, or `null` when refs are missing. * * @remarks * - Supports `"auto"` with preset-specific fallbacks (`mode`). * - Prevents overflow — returned values are fully **viewport clamped**. * - Works with all UUI floating components. * - Side placements (`centerLeft`, `centerRight`) ignore vertical overflow by design. * * @example * const pos = calculateFloatingPosition(refTrigger, refPanel, { * placement: "auto", * offset: 8, * mode: "menu" * }); * * @category Utils */ export declare function calculateFloatingPosition(referenceRef: RefObject, floatingRef: RefObject, options?: CalculateFloatingPositionOptions): ElementFloatingPosition | null;