/** * popupPlacement.ts * * Shared placement types and coordinate utilities used by `popup()` and any * other portal-style floating surface that needs anchor-aware, flip-capable * positioning (e.g. cascading menus, date-pickers, combobox panels). * * Centralising here means every floating surface gets: * • Scroll-parent awareness (room measured against the scrollable ancestor, * not just the viewport). * • Automatic flip when the preferred side has insufficient space. * • Viewport-edge clamping so the panel never overflows by more than 4 px. */ export type PopupPlacement = "auto" | "top" | "top-start" | "top-end" | "bottom" | "bottom-start" | "bottom-end" | "left" | "left-start" | "left-end" | "right" | "right-start" | "right-end"; /** Every placement value except the virtual `"auto"` sentinel. */ export type ResolvedPlacement = Exclude; /** * Returns `true` when placement `p` fits within the available room on each * side of the anchor. */ export declare function fits(p: PopupPlacement, fW: number, fH: number, roomTop: number, roomBottom: number, roomLeft: number, roomRight: number): boolean; /** * Return the opposite placement axis (top ↔ bottom, left ↔ right). * Sub-positions (`-start` / `-end`) are preserved. */ export declare function flip(p: PopupPlacement): ResolvedPlacement; /** * Walk up the DOM from `el` and return the first ancestor that scrolls * vertically, or `null` if none is found (i.e. the document scrolls). */ export declare function getScrollParent(el: HTMLElement): HTMLElement | null; /** * Resolve the best concrete placement for a floating element given the * anchor's bounding rect, the floating element's dimensions, and the * preferred placement. * * - For `"auto"` the function tries a fixed priority list and falls back to * `"bottom-start"`. * - For any other placement it tries the preferred side, then its opposite * (flip), and finally falls back to the original preference when neither * side has enough room. * - Scroll-parent aware: available space is measured against the nearest * scrollable ancestor when one exists. */ export declare function resolvePlacement(anchor: HTMLElement, anchorRect: DOMRect, fW: number, fH: number, gap: number, preferred: PopupPlacement): ResolvedPlacement; /** * Apply `top` / `left` CSS coordinates to a fixed-position floating element * so it is anchored to the given placement. Clamps to 4 px inside the * viewport edges. */ export declare function applyCoords(el: HTMLElement, anchorRect: DOMRect, placement: ResolvedPlacement, fW: number, fH: number, gap: number): void; //# sourceMappingURL=popupPlacement.d.ts.map