import { createContext, useContext } from "solid-js"; /** * Context handed to descendants of ``. Currently only * `` uses this — it calls `computeThumbPosition()` when * its ResizeObserver fires. */ export interface ScrollAreaViewportContextValue { computeThumbPosition: () => void; } /** * `createContext(null)` + `== null` sentinel — * Solid 2's `useContext` throws `ContextNotFoundError` when the default is * `undefined`, which would shadow the intended Base UI error message below. */ export const ScrollAreaViewportContext = createContext(null); export function useScrollAreaViewportContext(): ScrollAreaViewportContextValue { const context = useContext(ScrollAreaViewportContext); if (context == null) { throw new Error( "Base UI: ScrollAreaViewportContext missing. ScrollAreaViewport parts must be placed within .", ); } return context; }