import { TOOLTIP_PLACEMENT } from "../types/cssClassEnums"; import { Overflow, OverflowClassification, ViewportBox } from "../types/enchanted-tooltip"; /** * Returns a list of fallback placements for the tooltip based on the initial placement. * @param {TOOLTIP_PLACEMENT} placement - The initial tooltip placement. * @returns {TOOLTIP_PLACEMENT[]} An array of fallback placements in priority order. */ export declare const getFallbackPlacements: (placement: TOOLTIP_PLACEMENT) => TOOLTIP_PLACEMENT[]; /** * Resolves the horizontal position (left) for the tooltip based on the placement. * @param {TOOLTIP_PLACEMENT} placement - The tooltip placement. * @param {DOMRect} targetRect - The bounding rectangle of the target element. * @param {number} tooltipWidth - The width of the tooltip. * @param {boolean} isRTL - Whether the layout is right-to-left. * @returns {number} The computed left position for the tooltip. */ export declare const resolveStartEndLeft: (placement: TOOLTIP_PLACEMENT, targetRect: DOMRect, tooltipWidth: number, isRTL: boolean) => number; /** * Resolves the vertical position (top) for the tooltip based on the placement. * @param {TOOLTIP_PLACEMENT} placement - The tooltip placement. * @param {DOMRect} targetRect - The bounding rectangle of the target element. * @param {number} tooltipHeight - The height of the tooltip. * @returns {number} The computed top position for the tooltip. */ export declare const resolveStartEndTop: (placement: TOOLTIP_PLACEMENT, targetRect: DOMRect, tooltipHeight: number) => number; /** * Computes the base position (left and top) of the tooltip based on the placement. * @param {TOOLTIP_PLACEMENT} placement - The tooltip placement. * @param {DOMRect} targetRect - The bounding rectangle of the target element. * @param {DOMRect} tooltipRect - The bounding rectangle of the tooltip element. * @param {number} gap - The gap between the tooltip and the target. * @param {boolean} isRTL - Whether the layout is right-to-left. * @returns {{ left: number, top: number }} The computed base position for the tooltip. */ export declare const computeBasePosition: (placement: TOOLTIP_PLACEMENT, targetRect: DOMRect, tooltipRect: DOMRect, gap: number, isRTL: boolean) => { left: number; top: number; }; export declare const overflowCache: Map; /** * Computes the overflow values for the tooltip relative to the viewport. * @param {number} left - The left position of the tooltip. * @param {number} top - The top position of the tooltip. * @param {DOMRect} tooltipRect - The bounding rectangle of the tooltip element. * @param {ViewportBox} viewportBox - The visible viewport dimensions. * @param {number} padding - The padding to apply around the viewport. * @returns {Overflow} The computed overflow values for all sides of the tooltip. */ export declare const computeOverflows: (left: number, top: number, tooltipRect: DOMRect, viewportBox: ViewportBox, padding: number, softMargin: number) => Overflow; /** * Determines whether the placement is primarily vertical (top or bottom). * @param {TOOLTIP_PLACEMENT} placement - The tooltip placement. * @returns {boolean} `true` if the placement is vertical, otherwise `false`. */ export declare const isPrimaryVertical: (placement: TOOLTIP_PLACEMENT) => boolean; /** * Classifies the overflow of the tooltip based on the placement and soft margin. * @param {TOOLTIP_PLACEMENT} placement - The tooltip placement. * @param {Overflow} overflow - The overflow values for the tooltip. * @param {number} softMargin - The soft margin to allow for overflow. * @returns {OverflowClassification} The classification of the overflow. */ export declare const classifyOverflow: (placement: TOOLTIP_PLACEMENT, overflow: Overflow, softMargin: number) => OverflowClassification; /** * Clamps the tooltip position to ensure it stays within the viewport. * @param {number} left - The left position of the tooltip. * @param {number} top - The top position of the tooltip. * @param {DOMRect} tooltipRect - The bounding rectangle of the tooltip element. * @param {ViewportBox} viewportBox - The visible viewport dimensions. * @param {number} padding - The padding to apply around the viewport. * @returns {{ left: number, top: number }} The clamped position for the tooltip. */ export declare const clampToViewport: (left: number, top: number, tooltipRect: DOMRect, viewportBox: ViewportBox, padding: number) => { left: number; top: number; }; /** * Adjusts the tooltip position along the cross-axis to fit within the viewport. * @param {TOOLTIP_PLACEMENT} placement - The tooltip placement. * @param {{ left: number, top: number }} candidatePosition - The candidate position for the tooltip. * @param {DOMRect} tooltipRect - The bounding rectangle of the tooltip element. * @param {ViewportBox} viewportBox - The visible viewport dimensions. * @param {number} padding - The padding to apply around the viewport. * @returns {{ left: number, top: number }} The adjusted position for the tooltip. */ export declare const shiftCrossAxis: (placement: TOOLTIP_PLACEMENT, candidatePosition: { left: number; top: number; }, tooltipRect: DOMRect, viewportBox: ViewportBox, padding: number) => { left: number; top: number; }; /** * Scores a candidate placement based on its overflow values. * @param {TOOLTIP_PLACEMENT} placement - The tooltip placement. * @param {Overflow} overflow - The overflow values for the tooltip. * @returns {number} The score for the candidate placement (lower is better). */ export declare const scoreCandidate: (placement: TOOLTIP_PLACEMENT, overflow: Overflow) => number; /** * Attempts to find a valid placement for the tooltip by evaluating overflow and adjusting position. * @param {TOOLTIP_PLACEMENT} placement - The tooltip placement. * @param {DOMRect} targetRect - The bounding rectangle of the target element. * @param {DOMRect} tooltipRect - The bounding rectangle of the tooltip element. * @param {number} padding - The padding to apply around the viewport. * @param {number} gap - The gap between the tooltip and the target. * @param {number} softMargin - The soft margin to allow for overflow. * @param {ViewportBox} viewportBox - The visible viewport dimensions. * @param {boolean} isRTL - Whether the layout is right-to-left. * @returns {{ accept: boolean, left: number, top: number, placement: TOOLTIP_PLACEMENT, overflows: Overflow }} The result of the placement attempt. */ export declare const tryCandidatePlacement: (placement: TOOLTIP_PLACEMENT, targetRect: DOMRect, tooltipRect: DOMRect, padding: number, gap: number, softMargin: number, viewportBox: ViewportBox, isRTL: boolean) => { accept: boolean; left: number; top: number; placement: TOOLTIP_PLACEMENT; overflows: Overflow; }; /** * Rounds the left and top positions to the nearest integer. * @param {number} left - The left position of the tooltip. * @param {number} top - The top position of the tooltip. * @returns {{ left: number, top: number }} The rounded position. */ export declare const roundLeftTop: (left: number, top: number) => { left: number; top: number; }; /** * Determines the best placement for the tooltip by evaluating all fallback placements. * @param {TOOLTIP_PLACEMENT} placement - The initial tooltip placement. * @param {DOMRect} targetRect - The bounding rectangle of the target element. * @param {DOMRect} tooltipRect - The bounding rectangle of the tooltip element. * @param {number} padding - The padding to apply around the viewport. * @param {number} gap - The gap between the tooltip and the target. * @param {number} softMargin - The soft margin to allow for overflow. * @param {ViewportBox} viewportBox - The visible viewport dimensions. * @param {boolean} isRTL - Whether the layout is right-to-left. * @returns {{ left: number, top: number, placement: TOOLTIP_PLACEMENT }} The best placement and position for the tooltip. */ export declare const runPlacement: (placement: TOOLTIP_PLACEMENT, targetRect: DOMRect, tooltipRect: DOMRect, padding: number, gap: number, softMargin: number, viewportBox: ViewportBox, isRTL: boolean) => { left: number; top: number; placement: TOOLTIP_PLACEMENT; }; /** * Finds the nearest ancestor of a given element that has a CSS `transform` applied. * * This function traverses up the DOM tree from the element's parent, checking each * ancestor's computed style for the `transform` property. It stops and returns * the first ancestor it finds with a `transform` that is not 'none'. * * @param {HTMLElement} element The starting element to check from. * @returns {HTMLElement | null} The nearest ancestor with a `transform` or `null` if none is found. */ export declare const getAncestorWithTransform: (element: HTMLElement) => HTMLElement | null; /** * Gets the scale and translate values from an element's computed transform matrix. * @param {HTMLElement} element The element to inspect. * @returns {{scale: number, translateX: number, translateY: number}} The transform details. */ export declare const getTransformDetails: (element: HTMLElement) => { scale: number; translateX: number; translateY: number; };