import { type Accessor, createContext, useContext } from "solid-js"; import type { MutableRef } from "../internals/floating-ui/types"; export type TooltipSide = | "top" | "bottom" | "left" | "right" | "inline-end" | "inline-start"; export type TooltipAlign = "start" | "center" | "end"; /** * Context shape published by `` so descendants (`Popup`, * `Arrow`) can read the resolved placement / arrow ref / arrow styles. */ export interface TooltipPositionerContextValue { /** The resolved side (post-flip / post-shift). */ side: Accessor; /** The resolved alignment (post-flip / post-shift). */ align: Accessor; /** Whether the arrow has been pushed outside the centered axis. */ arrowUncentered: Accessor; /** Inline styles to apply to the arrow element (`left`/`top`/etc.). */ arrowStyles: Accessor>; /** Mutable ref for the arrow element — consumed by the `arrow` middleware. */ arrowRef: MutableRef; /** Whether the anchor element is outside the viewport (after `hide`). */ anchorHidden: Accessor; } export const TooltipPositionerContext = createContext(null); export function useTooltipPositionerContext(): TooltipPositionerContextValue { const context = useContext(TooltipPositionerContext); if (context === null) { throw new Error( "Base UI: TooltipPositionerContext is missing. Tooltip.Popup and Tooltip.Arrow must be placed within .", ); } return context; }