/** * Core positioning engine for floating elements * Adapted from ty.positioning ClojureScript implementation * * Handles smart positioning of tooltips, dropdowns, popups, and other * floating elements relative to anchor elements with automatic overflow * detection and placement fallback. */ /** * Placement orientation - how the floating element is positioned */ export type PlacementOrientation = 'horizontal' | 'vertical'; /** * Vertical alignment options */ export type VerticalAlign = 'top' | 'center' | 'bottom' | 'end'; /** * Horizontal alignment options */ export type HorizontalAlign = 'start' | 'center' | 'end'; /** * All available placement options */ export type Placement = 'top-start' | 'top' | 'top-end' | 'right-start' | 'right' | 'right-end' | 'bottom-start' | 'bottom' | 'bottom-end' | 'left-start' | 'left' | 'left-end'; /** * Placement configuration */ export interface PlacementConfig { vertical: VerticalAlign; horizontal: HorizontalAlign; orientation?: PlacementOrientation; } /** * Element rectangle with calculated center points */ export interface ElementRect { top: number; left: number; right: number; bottom: number; width: number; height: number; centerX: number; centerY: number; } /** * Viewport dimensions and scroll position */ export interface ViewportRect { width: number; height: number; scrollX: number; scrollY: number; } /** * Overflow data for all edges */ export interface OverflowData { top: number; left: number; bottom: number; right: number; } /** * Calculated position result */ export interface PositionResult { x: number; y: number; placement: Placement; overflow: OverflowData; overflowAmount: number; fits: boolean; } /** * Options for findBestPosition */ export interface PositionOptions { targetEl: HTMLElement; floatingEl: HTMLElement; preferences?: Placement[]; offset?: number; padding?: number; containerPadding?: number; } /** * Options for calculatePlacement */ export interface CalculatePlacementOptions { targetRect: ElementRect; floatingRect: ElementRect; placement: Placement; offset: number; padding: number; scrollbarWidth: number; containerPadding: number; } /** * Cleanup function type */ export type CleanupFn = () => void; /** * Map of all placement configurations */ export declare const placements: Record; /** * Default placement preference lists for different use cases */ export declare const placementPreferences: { default: Placement[]; tooltip: Placement[]; dropdown: Placement[]; }; /** * Find the best position for the floating element * Tries all preference placements and returns the one that fits best */ export declare function findBestPosition(options: PositionOptions): PositionResult; /** * Below/above placement for trigger-anchored `` popups. * * Unlike findBestPosition (12-placement engine for non-modal floats), these * popups only ever open below or above their trigger, and their CSS anchors * with `top:` when below but `bottom:` when above — so both conventions are * returned and the caller picks by `below`. */ export interface AnchoredPopupOptions { anchorRect: DOMRect | ElementRect; popupWidth: number; popupHeight: number; /** Gap between trigger and popup edge (px, default 4) */ gap?: number; /** Minimum distance from viewport edges (px, default 8) */ padding?: number; /** Horizontal anchor edge: trigger's left edge ("start", default) or * right edge ("end"). Either way the result is clamped into the * viewport, same as before. */ align?: "start" | "end"; } export interface AnchoredPopupPosition { /** Popup left edge, viewport coords, clamped into view */ x: number; /** CSS `top` value when below */ topY: number; /** CSS `bottom` value when above */ bottomY: number; below: boolean; } export declare function computeAnchoredPosition(o: AnchoredPopupOptions): AnchoredPopupPosition; //# sourceMappingURL=positioning.d.ts.map