/** * 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[]; }; /** * Get element dimensions relative to viewport with calculated center points */ export declare function getElementRect(el: HTMLElement): ElementRect; /** * Get viewport dimensions and scroll position */ export declare function getViewportRect(): ViewportRect; /** * Calculate position for a specific placement * Returns x, y coordinates and overflow information */ export declare function calculatePlacement(options: CalculatePlacementOptions): PositionResult; /** * 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; /** * Create auto-update system for position tracking * Continuously monitors and updates position when target or floating element changes * * @param targetEl - The anchor element to position relative to * @param floatingEl - The floating element to position * @param updateFn - Callback function that receives new position data * @param config - Position options (same as findBestPosition) * @returns Cleanup function to stop auto-updating */ export declare function autoUpdate(targetEl: HTMLElement, floatingEl: HTMLElement, updateFn: (position: PositionResult) => void, config: Omit): CleanupFn; //# sourceMappingURL=positioning.d.ts.map