{"version":3,"names":["createContext","useContext","ScrollAreaRootContext","useScrollAreaRootContext","context","Error"],"sources":["scroll-area-root-context.ts"],"sourcesContent":["import { type Accessor, createContext, useContext } from \"solid-js\";\n\n/**\n * x/y pixel pair — used for scroll positions and corner measurements.\n */\nexport interface Coords {\n\tx: number;\n\ty: number;\n}\n\n/**\n * width/height pixel pair — used for thumb and corner measurements.\n */\nexport interface Size {\n\twidth: number;\n\theight: number;\n}\n\n/**\n * Overflow-edge flags. Each flag indicates whether the scroll offset on the\n * corresponding side exceeds the configured threshold.\n */\nexport interface OverflowEdges {\n\txStart: boolean;\n\txEnd: boolean;\n\tyStart: boolean;\n\tyEnd: boolean;\n}\n\n/**\n * Scrollbar visibility. A scrollbar is hidden when the content doesn't\n * overflow along its axis; the corner is hidden when either scrollbar is\n * hidden.\n */\nexport interface HiddenState {\n\tx: boolean;\n\ty: boolean;\n\tcorner: boolean;\n}\n\n/**\n * Normalized overflow-edge threshold (all four sides, pixels). Consumers\n * pass either a number or a partial object to `<ScrollArea.Root>`; the root\n * component normalizes it into this shape before publishing to context.\n */\nexport interface OverflowEdgeThreshold {\n\txStart: number;\n\txEnd: number;\n\tyStart: number;\n\tyEnd: number;\n}\n\n/**\n * Shared root state projected onto the root, viewport, content and\n * scrollbar parts. Mirrors Base UI React's `ScrollAreaRootState`.\n */\nexport interface ScrollAreaRootState {\n\t/** Whether the user is currently scrolling. */\n\tscrolling: boolean;\n\t/** Whether horizontal overflow is present. */\n\thasOverflowX: boolean;\n\t/** Whether vertical overflow is present. */\n\thasOverflowY: boolean;\n\t/** Whether there is overflow past the inline-start edge. */\n\toverflowXStart: boolean;\n\t/** Whether there is overflow past the inline-end edge. */\n\toverflowXEnd: boolean;\n\t/** Whether there is overflow past the block-start edge. */\n\toverflowYStart: boolean;\n\t/** Whether there is overflow past the block-end edge. */\n\toverflowYEnd: boolean;\n\t/** Whether the scrollbar corner is currently hidden. */\n\tcornerHidden: boolean;\n}\n\n/**\n * Mutable ref container — mirrors React's `RefObject<T | null>` so the\n * scroll-area port reads 1:1 against the React source.\n */\nexport interface MutableRef<T> {\n\tcurrent: T | null;\n}\n\n/**\n * Value published by `<ScrollArea.Root>` to its descendants.\n *\n * Every reactive field is an `Accessor<T>` so subscribers stay narrow. Setters\n * are plain functions that write into the root's signals. Element refs are\n * mutable containers rather than accessors — the ref targets don't need to\n * trigger re-renders (their imperative reads happen inside event handlers\n * and layout effects).\n */\nexport interface ScrollAreaRootContextValue {\n\t// Measurements published by the viewport.\n\tcornerSize: Accessor<Size>;\n\tsetCornerSize: (next: Size | ((prev: Size) => Size)) => void;\n\tthumbSize: Accessor<Size>;\n\tsetThumbSize: (next: Size | ((prev: Size) => Size)) => void;\n\thasMeasuredScrollbar: Accessor<boolean>;\n\tsetHasMeasuredScrollbar: (next: boolean) => void;\n\n\t// Interaction state.\n\thovering: Accessor<boolean>;\n\tsetHovering: (next: boolean) => void;\n\tscrollingX: Accessor<boolean>;\n\tsetScrollingX: (next: boolean) => void;\n\tscrollingY: Accessor<boolean>;\n\tsetScrollingY: (next: boolean) => void;\n\n\t// Element refs. Mutated imperatively; not reactive.\n\tviewportRef: MutableRef<HTMLDivElement>;\n\trootRef: MutableRef<HTMLDivElement>;\n\tscrollbarYRef: MutableRef<HTMLDivElement>;\n\tscrollbarXRef: MutableRef<HTMLDivElement>;\n\tthumbYRef: MutableRef<HTMLDivElement>;\n\tthumbXRef: MutableRef<HTMLDivElement>;\n\tcornerRef: MutableRef<HTMLDivElement>;\n\n\t// Pointer-interaction handlers (shared between root / scrollbar / thumb).\n\thandlePointerDown: (event: PointerEvent) => void;\n\thandlePointerMove: (event: PointerEvent) => void;\n\thandlePointerUp: (event: PointerEvent) => void;\n\thandleScroll: (scrollPosition: Coords) => void;\n\n\t// Identity and per-axis visibility.\n\trootId: string;\n\thiddenState: Accessor<HiddenState>;\n\tsetHiddenState: (\n\t\tnext: HiddenState | ((prev: HiddenState) => HiddenState),\n\t) => void;\n\toverflowEdges: Accessor<OverflowEdges>;\n\tsetOverflowEdges: (\n\t\tnext: OverflowEdges | ((prev: OverflowEdges) => OverflowEdges),\n\t) => void;\n\n\t// Shared state accessor (used by Content's `data-*` projection).\n\tviewportState: Accessor<ScrollAreaRootState>;\n\toverflowEdgeThreshold: OverflowEdgeThreshold;\n}\n\n/**\n * Root context. `createContext<T | null>(null)` + `== null` sentinel —\n * Solid 2's `useContext` throws `ContextNotFoundError` when the\n * default is `undefined`, which would shadow the intended Base UI error\n * message below.\n */\nexport const ScrollAreaRootContext =\n\tcreateContext<ScrollAreaRootContextValue | null>(null);\n\n/**\n * Read the `<ScrollArea.Root>` context. Throws when used outside a root.\n */\nexport function useScrollAreaRootContext(): ScrollAreaRootContextValue {\n\tconst context = useContext(ScrollAreaRootContext);\n\tif (context == null) {\n\t\tthrow new Error(\n\t\t\t\"Base UI: ScrollAreaRootContext is missing. ScrollArea parts must be placed within <ScrollArea.Root>.\",\n\t\t);\n\t}\n\treturn context;\n}\n"],"mappings":"AAAA,SAAwBA,aAAa,EAAEC,UAAU,QAAQ,UAAU;;AAEnE;AACA;AACA;;AAMA;AACA;AACA;;AAMA;AACA;AACA;AACA;;AAQA;AACA;AACA;AACA;AACA;;AAOA;AACA;AACA;AACA;AACA;;AAQA;AACA;AACA;AACA;;AAoBA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAiDA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,qBAAqB,GACjCF,aAAa,CAAoC,IAAI,CAAC;;AAEvD;AACA;AACA;AACA,OAAO,SAASG,wBAAwBA,CAAA,EAA+B;EACtE,MAAMC,OAAO,GAAGH,UAAU,CAACC,qBAAqB,CAAC;EACjD,IAAIE,OAAO,IAAI,IAAI,EAAE;IACpB,MAAM,IAAIC,KAAK,CACd,sGACD,CAAC;EACF;EACA,OAAOD,OAAO;AACf","ignoreList":[]}