/** * @oxpulse/chat-widget — Shared floating-element positioning utility. * * Deduplicated from EmojiPicker.#position() and ReactionQuickBar.#position() * — both implemented the same isMountedOutside → fixed-vs-absolute + * viewport-clamp logic. This single function serves both. * * Coordinate frames: * - mountedOutside=true → position:fixed, viewport-relative coords * (getBoundingClientRect returns viewport coords; fixed maps 1:1) * - mountedOutside=false → position:absolute, container-relative coords * (subtract containerRect to convert viewport → container-local) * * Viewport clamping keeps the floating element fully on-screen. */ export interface FloatingPositionArgs { /** Anchor element rect in viewport coords (getBoundingClientRect). */ anchorRect: { top: number; bottom: number; left: number; right: number; }; /** Floating element dimensions (offsetWidth/offsetHeight). */ elemWidth: number; elemHeight: number; /** True when the element is appended outside its constructor container * (e.g. to a shadow root host) — selects fixed vs absolute. */ mountedOutside: boolean; /** Container rect in viewport coords (only used when mountedOutside=false). */ containerRect?: { top: number; left: number; width: number; height: number; }; /** Viewport dimensions. */ viewportWidth: number; viewportHeight: number; /** Margin from viewport edges (px). Default 8. */ margin?: number; /** Vertical placement preference. Default false (below anchor if room, above otherwise). * Pass true to prefer above (ReactionQuickBar pattern). */ preferAbove?: boolean; /** Gap between anchor and floating element (px). Default 4. */ gap?: number; /** Anchor by right edge instead of left (own-message pattern). Default false. */ anchorRight?: boolean; } export interface FloatingPositionResult { /** CSS position value: fixed or absolute. */ position: 'fixed' | 'absolute'; /** CSS top in px (coordinate-frame appropriate — viewport for fixed, container for absolute). */ top: number; /** CSS left in px (set when anchoring by left edge). */ left?: number; /** CSS right in px (set when anchoring by right edge — measured from * containing block right edge, NOT viewport right). */ right?: number; /** Vertical placement relative to anchor. */ placement: 'above' | 'below'; } /** * Compute the CSS position/top/left/right for a floating element anchored * to another element. Handles fixed-vs-absolute coordinate frames and * viewport clamping. * * For anchorRight=true (own-message pattern), returns `right` (distance * from containing block right edge) instead of `left`. The caller sets * `el.style.right = result.right + px` and must NOT set `left`. */ export declare function computeFloatingPosition(args: FloatingPositionArgs): FloatingPositionResult; //# sourceMappingURL=floating-position.d.ts.map