import { type Accessor, createContext, useContext } from "solid-js"; import type { MutableRef } from "../internals/floating-ui/types"; export type PreviewCardSide = | "top" | "bottom" | "left" | "right" | "inline-end" | "inline-start"; export type PreviewCardAlign = "start" | "center" | "end"; /** * Context shape published by `` so descendants * (`Popup`, `Arrow`) can read the resolved placement / arrow ref / arrow * styles. Mirrors `PreviewCardPositionerContext` from the React source * with the Solid convention that reactive fields are `Accessor`. */ export interface PreviewCardPositionerContextValue { /** 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 PreviewCardPositionerContext = createContext(null); export function usePreviewCardPositionerContext(): PreviewCardPositionerContextValue { const context = useContext(PreviewCardPositionerContext); if (context === null) { throw new Error( "Base UI: PreviewCardPositionerContext is missing. and must be placed within .", ); } return context; }