@redocly/theme
Version:
Shared UI components lib
33 lines (32 loc) • 1.39 kB
TypeScript
import type { TooltipPlacement, TooltipProps } from '../../core/types';
export declare function getDefaultFallbackPlacements(placement: TooltipPlacement): TooltipPlacement[];
export declare function calcAnchorPoint(triggerRect: DOMRect, placement: TooltipPlacement, arrowPosition: TooltipProps['arrowPosition']): {
top: number;
left: number;
};
type FitsInViewportParams = {
anchor: {
top: number;
left: number;
};
tooltipWidth: number;
tooltipHeight: number;
placement: TooltipPlacement;
arrowPosition: TooltipProps['arrowPosition'];
};
export declare function fitsInViewport({ anchor, tooltipWidth, tooltipHeight, placement, arrowPosition, }: FitsInViewportParams): boolean;
type ResolvePlacementParams = {
triggerRect: DOMRect;
tooltipWidth: number;
tooltipHeight: number;
placement: TooltipPlacement;
arrowPosition: TooltipProps['arrowPosition'];
fallbackPlacements: TooltipPlacement[] | undefined;
};
/**
* Given the trigger rect, tooltip dimensions, primary placement/arrow, and
* fallback list, returns the first placement that keeps the tooltip fully
* inside the viewport. Falls back to the primary when nothing fits.
*/
export declare function resolvePlacement({ triggerRect, tooltipWidth, tooltipHeight, placement, arrowPosition, fallbackPlacements, }: ResolvePlacementParams): TooltipPlacement;
export {};