{"version":3,"names":["createContext","useContext","DrawerRootContext","useDrawerRootContext","optional","context","Error"],"sources":["drawer-root-context.ts"],"sourcesContent":["/**\n * Context set by `<Drawer.Root>` that carries drawer-specific state on top\n * of the `<Dialog.Root>` context the drawer composes over.\n *\n * Mirrors Base UI React's `DrawerRootContext`\n * (`packages/react/src/drawer/root/DrawerRootContext.ts`). The Solid port\n * switches every field to an `Accessor<T>` so consumers can subscribe\n * without wrapping, and follows the null-sentinel convention for\n * the optional \"is this a drawer subtree?\" detection path.\n */\n\nimport { type Accessor, createContext, useContext } from \"solid-js\";\nimport type {\n\tBaseUIChangeEventDetails,\n\tREASONS,\n} from \"../../internals/change-event-details\";\n\n/** Swipe-direction union. `'down'` by default. */\nexport type DrawerSwipeDirection = \"up\" | \"down\" | \"left\" | \"right\";\n\n/** A single snap point — fraction (0..1), px count, or a CSS length string. */\nexport type DrawerSnapPoint = number | string;\n\n/**\n * Nested-drawer swipe-progress store. Implemented without Solid's reactive\n * graph so parent drawers can observe progress without re-running effects.\n * Mirrors React's same-named shape.\n */\nexport interface DrawerNestedSwipeProgressStore {\n\tgetSnapshot: () => number;\n\tsubscribe: (listener: () => void) => () => void;\n}\n\nexport interface DrawerRootContextValue {\n\t/** Dismissal direction. */\n\tswipeDirection: Accessor<DrawerSwipeDirection>;\n\t/** Whether snap points can be skipped based on swipe velocity. */\n\tsnapToSequentialPoints: Accessor<boolean>;\n\t/** Configured snap-point list. */\n\tsnapPoints: Accessor<DrawerSnapPoint[] | undefined>;\n\t/** Active snap point. */\n\tactiveSnapPoint: Accessor<DrawerSnapPoint | null | undefined>;\n\t/** Request an open-state change from a drawer-owned interaction. */\n\tsetOpen: (\n\t\tnext: boolean,\n\t\tdetails: BaseUIChangeEventDetails<\n\t\t\tDrawerRootChangeEventReason,\n\t\t\t{ preventUnmountOnClose: () => void }\n\t\t>,\n\t) => void;\n\t/** Write a new active snap point. */\n\tsetActiveSnapPoint: (\n\t\tsnapPoint: DrawerSnapPoint | null,\n\t\tdetails?: DrawerRootSnapPointChangeEventDetails,\n\t) => void;\n\t/** Measured frontmost popup height in the current nested stack. */\n\tfrontmostHeight: Accessor<number>;\n\t/** Measured height of this drawer's popup. */\n\tpopupHeight: Accessor<number>;\n\t/** Whether a nested drawer is mounted (open or transitioning out). */\n\thasNestedDrawer: Accessor<boolean>;\n\t/** Whether a nested drawer is currently being swiped. */\n\tnestedSwiping: Accessor<boolean>;\n\t/** Nested swipe progress store (non-reactive). */\n\tnestedSwipeProgressStore: DrawerNestedSwipeProgressStore;\n\t/** Popup → root: popup height changed. */\n\tonPopupHeightChange: (height: number) => void;\n\t/** Nested → root: frontmost-height changed. */\n\tonNestedFrontmostHeightChange: (height: number) => void;\n\t/** Nested → root: nested drawer presence changed. */\n\tonNestedDrawerPresenceChange: (present: boolean) => void;\n\t/** Nested → root: nested swiping changed. */\n\tonNestedSwipingChange: (swiping: boolean) => void;\n\t/** Nested → root: nested swipe progress changed. */\n\tonNestedSwipeProgressChange: (progress: number) => void;\n\t/** Proxy of this root's `onNestedFrontmostHeightChange` for children. */\n\tnotifyParentFrontmostHeight?: ((height: number) => void) | undefined;\n\t/** Proxy of this root's `onNestedSwipingChange`. */\n\tnotifyParentSwipingChange?: ((swiping: boolean) => void) | undefined;\n\t/** Proxy of this root's `onNestedSwipeProgressChange`. */\n\tnotifyParentSwipeProgressChange?: ((progress: number) => void) | undefined;\n\t/** Proxy of this root's `onNestedDrawerPresenceChange`. */\n\tnotifyParentHasNestedDrawer?: ((present: boolean) => void) | undefined;\n}\n\nexport type DrawerRootChangeEventReason =\n\t| typeof REASONS.triggerPress\n\t| typeof REASONS.outsidePress\n\t| typeof REASONS.escapeKey\n\t| typeof REASONS.closeWatcher\n\t| typeof REASONS.closePress\n\t| typeof REASONS.focusOut\n\t| typeof REASONS.imperativeAction\n\t| typeof REASONS.swipe\n\t| typeof REASONS.none;\n\nexport type DrawerRootSnapPointChangeEventReason = DrawerRootChangeEventReason;\n\n/** Change-event details for `onSnapPointChange`. Matches React. */\nexport type DrawerRootSnapPointChangeEventDetails =\n\tBaseUIChangeEventDetails<DrawerRootChangeEventReason>;\n\n/**\n * Null-sentinel context. `<Drawer.Root>` is optional around\n * a `<Drawer.Trigger>` when a detached handle is supplied.\n */\nexport const DrawerRootContext = createContext<DrawerRootContextValue | null>(\n\tnull,\n);\n\nexport function useDrawerRootContext(): DrawerRootContextValue;\nexport function useDrawerRootContext(\n\toptional: true,\n): DrawerRootContextValue | null;\nexport function useDrawerRootContext(\n\toptional?: boolean,\n): DrawerRootContextValue | null {\n\tconst context = useContext(DrawerRootContext);\n\tif (context == null && !optional) {\n\t\tthrow new Error(\n\t\t\t\"Base UI: DrawerRootContext is missing. Drawer parts must be placed within <Drawer.Root>.\",\n\t\t);\n\t}\n\treturn context;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAAwBA,aAAa,EAAEC,UAAU,QAAQ,UAAU;;AAMnE;;AAGA;;AAGA;AACA;AACA;AACA;AACA;;AAuEA;;AAIA;AACA;AACA;AACA;AACA,OAAO,MAAMC,iBAAiB,GAAGF,aAAa,CAC7C,IACD,CAAC;AAMD,OAAO,SAASG,oBAAoBA,CACnCC,QAAkB,EACc;EAChC,MAAMC,OAAO,GAAGJ,UAAU,CAACC,iBAAiB,CAAC;EAC7C,IAAIG,OAAO,IAAI,IAAI,IAAI,CAACD,QAAQ,EAAE;IACjC,MAAM,IAAIE,KAAK,CACd,0FACD,CAAC;EACF;EACA,OAAOD,OAAO;AACf","ignoreList":[]}