/** * Shared anchored-positioning math for popover-like overlays (popover, * dropdown-menu, menubar content). Computes a fixed-position {top,left} for a * floating element relative to a trigger, given a side + alignment + offsets, * then clamps the result into the viewport. * * This is the simple "place + clamp" strategy (no side flipping). Components * that flip based on available space (e.g. hover-card, tooltip 'auto') keep * their own collision logic. */ export type Side = 'top' | 'bottom' | 'left' | 'right'; export type Align = 'start' | 'center' | 'end'; export interface Size { width: number; height: number; } export interface AnchoredPositionOptions { side: Side; align: Align; /** Gap between trigger and content along the side axis. */ sideOffset?: number; /** Shift along the alignment axis. */ alignOffset?: number; /** Viewport size; defaults to the window. */ viewport?: Size; /** Minimum gap to keep from the viewport edges. */ margin?: number; } export interface AnchoredPosition { top: number; left: number; side: Side; } export declare function computeAnchoredPosition(triggerRect: DOMRect, contentRect: Size, options: AnchoredPositionOptions): AnchoredPosition; /** * Measure an anchor element that may be a `display: contents` custom-element host. * * Several trigger components (seki-menubar-trigger, seki-menubar-sub-trigger, …) * set `:host { display: contents }`, which means the host generates no box of its * own and `getBoundingClientRect()` returns an all-zero rect. Anchoring a popup to * that rect pins it to the viewport origin instead of to the trigger — the menubar * dropdown rendered in the top-left corner of the page because of exactly this. * * Falls through to the first laid-out element inside the host's shadow root. */ export declare function getAnchorRect(anchor: Element | null | undefined): DOMRect | null;