{"version":3,"names":["createContext","createMemo","useContext","createPopupCore","readOption","SNAPSHOT_KEYS","snapshotKeys","DrawerContext","useDrawer","optional","ctx","Error","createDrawer","options","core","open","disabled","onOpenChange","modal","name","disablePointerDismissal","Boolean","swipeDirection","snapPoint","snapPoints","setSnapPoint","next","onSnapPointChange","api","setOpen","toggle","Provider","props","children","DRAWER_SNAPSHOT_KEYS"],"sources":["create-drawer.tsx"],"sourcesContent":["import type { JSX } from \"@solidjs/web\";\nimport { type Accessor, createContext, createMemo, useContext } from \"solid-js\";\nimport { createPopupCore } from \"../internals/create-popup-core\";\nimport { type MaybeAccessor, readOption } from \"../internals/maybe-accessor\";\nimport {\n\tSNAPSHOT_KEYS,\n\ttype Snapshottable,\n\tsnapshotKeys,\n} from \"../internals/observability/snapshot\";\n\n/**\n * Why the drawer's open state changed.\n *\n * - `\"trigger-press\"` — trigger was clicked or keyboard-activated.\n * - `\"swipe\"` — user swipe-dismissed the drawer.\n * - `\"escape-key\"` — Escape dismissed the drawer.\n * - `\"outside-press\"` — pointer pressed outside.\n * - `\"close-button\"` — `<Drawer.Close>` was pressed.\n * - `\"close-watcher\"` — Android CloseWatcher back-gesture.\n * - `\"imperative\"` — `dr.setOpen()` called programmatically.\n */\nexport type DrawerChangeReason =\n\t| \"trigger-press\"\n\t| \"swipe\"\n\t| \"escape-key\"\n\t| \"outside-press\"\n\t| \"close-button\"\n\t| \"close-watcher\"\n\t| \"imperative\";\n\nimport type {\n\tDrawerSnapPoint,\n\tDrawerSwipeDirection,\n} from \"./root/drawer-root-context\";\n\nexport type { DrawerSnapPoint, DrawerSwipeDirection };\n\n/**\n * Options for {@link createDrawer}.\n */\nexport interface CreateDrawerOptions {\n\t/**\n\t * Open state. Consumer-owned signal.\n\t */\n\topen: MaybeAccessor<boolean>;\n\t/**\n\t * Whether interaction is suppressed.\n\t * @default false\n\t */\n\tdisabled?: MaybeAccessor<boolean>;\n\t/**\n\t * Modal surface kind (drawer is modal by default).\n\t * @default true\n\t */\n\tmodal?: MaybeAccessor<boolean | \"trap-focus\">;\n\t/**\n\t * When true, outside-press dismissal is disabled.\n\t * @default false\n\t */\n\tdisablePointerDismissal?: MaybeAccessor<boolean>;\n\t/**\n\t * Direction the drawer slides from.\n\t * @default \"down\"\n\t */\n\tswipeDirection?: MaybeAccessor<DrawerSwipeDirection>;\n\t/**\n\t * Snap points list. When provided the drawer can be dragged to each point.\n\t */\n\tsnapPoints?: MaybeAccessor<DrawerSnapPoint[] | undefined>;\n\t/**\n\t * Active snap point. Consumer-owned — pair with `onSnapPointChange`.\n\t */\n\tsnapPoint?: MaybeAccessor<DrawerSnapPoint | null | undefined>;\n\t/**\n\t * Pre-change callback fired via `runWithOwner(null, ...)`.\n\t */\n\tonOpenChange?: (\n\t\topen: boolean,\n\t\tevent: Event,\n\t\treason: DrawerChangeReason,\n\t) => void;\n\t/**\n\t * Fires on every snap-point change request.\n\t */\n\tonSnapPointChange?: (snapPoint: DrawerSnapPoint | null) => void;\n}\n\n/**\n * Public API returned by {@link createDrawer}.\n */\nexport interface DrawerApi {\n\t/** Reactive accessor for the current open state. */\n\topen: Accessor<boolean>;\n\t/** Whether interaction is suppressed. */\n\tdisabled: Accessor<boolean>;\n\t/** Modal surface kind. */\n\tmodal: Accessor<boolean | \"trap-focus\">;\n\t/** Whether outside-press dismissal is disabled. */\n\tdisablePointerDismissal: Accessor<boolean>;\n\t/** Direction the drawer slides from. */\n\tswipeDirection: Accessor<DrawerSwipeDirection>;\n\t/** Active snap point accessor. */\n\tsnapPoint: Accessor<DrawerSnapPoint | null | undefined>;\n\t/** Snap points list. */\n\tsnapPoints: Accessor<DrawerSnapPoint[] | undefined>;\n\n\t/** Imperative open setter. */\n\tsetOpen: (next: boolean, event?: Event, reason?: DrawerChangeReason) => void;\n\t/** Flip open (no-op when disabled). */\n\ttoggle: (event?: Event, reason?: DrawerChangeReason) => void;\n\t/** Imperative snap-point setter. Fires `onSnapPointChange`. */\n\tsetSnapPoint: (snapPoint: DrawerSnapPoint | null) => void;\n\n\t/** Context provider. */\n\tProvider: (props: { children: JSX.Element }) => JSX.Element;\n}\n\nconst DrawerContext = createContext<DrawerApi | null>(null);\n\n/**\n * Read the nearest {@link DrawerApi}. Throws unless `optional` is true.\n */\nexport function useDrawer(): DrawerApi;\nexport function useDrawer(optional: true): DrawerApi | null;\nexport function useDrawer(optional?: boolean): DrawerApi | null {\n\tconst ctx = useContext(DrawerContext);\n\tif (ctx == null && !optional) {\n\t\tthrow new Error(\n\t\t\t\"Base UI: useDrawer() must be called inside a <dr.Provider>.\",\n\t\t);\n\t}\n\treturn ctx;\n}\n\n/**\n * Headless primitive for a drawer compound. Modal slide-in panel with swipe\n * dismissal and snap-point control. DOM machinery lives in `<Drawer.Root>`.\n */\nexport function createDrawer(options: CreateDrawerOptions): DrawerApi {\n\tconst core = createPopupCore<DrawerChangeReason>({\n\t\topen: options.open,\n\t\tdisabled: options.disabled,\n\t\tonOpenChange: options.onOpenChange,\n\t});\n\n\tconst modal = createMemo<boolean | \"trap-focus\">(\n\t\t() => readOption(options.modal) ?? true,\n\t\t{ name: \"drawer.modal\" },\n\t);\n\n\tconst disablePointerDismissal = createMemo<boolean>(\n\t\t() => Boolean(readOption(options.disablePointerDismissal)),\n\t\t{ name: \"drawer.disablePointerDismissal\" },\n\t);\n\n\tconst swipeDirection = createMemo<DrawerSwipeDirection>(\n\t\t() =>\n\t\t\t(readOption(options.swipeDirection) ?? \"down\") as DrawerSwipeDirection,\n\t\t{ name: \"drawer.swipeDirection\" },\n\t);\n\n\tconst snapPoint = createMemo<DrawerSnapPoint | null | undefined>(\n\t\t() => readOption(options.snapPoint),\n\t\t{ name: \"drawer.snapPoint\" },\n\t);\n\n\tconst snapPoints = createMemo<DrawerSnapPoint[] | undefined>(\n\t\t() => readOption(options.snapPoints),\n\t\t{ name: \"drawer.snapPoints\" },\n\t);\n\n\tconst setSnapPoint = (next: DrawerSnapPoint | null): void => {\n\t\toptions.onSnapPointChange?.(next);\n\t};\n\n\tconst api: DrawerApi = {\n\t\topen: core.open,\n\t\tdisabled: core.disabled,\n\t\tmodal,\n\t\tdisablePointerDismissal,\n\t\tswipeDirection,\n\t\tsnapPoint,\n\t\tsnapPoints,\n\t\tsetOpen: core.setOpen,\n\t\ttoggle: core.toggle,\n\t\tsetSnapPoint,\n\t\tProvider: (props) => (\n\t\t\t<DrawerContext value={api}>{props.children}</DrawerContext>\n\t\t),\n\t};\n\n\t(api as DrawerApi & Snapshottable)[SNAPSHOT_KEYS] = DRAWER_SNAPSHOT_KEYS;\n\n\treturn api;\n}\n\nconst DRAWER_SNAPSHOT_KEYS = snapshotKeys<DrawerApi>(\n\t\"open\",\n\t\"disabled\",\n\t\"modal\",\n\t\"disablePointerDismissal\",\n\t\"swipeDirection\",\n\t\"snapPoint\",\n);\n"],"mappings":"AACA,SAAwBA,aAAa,EAAEC,UAAU,EAAEC,UAAU,QAAQ,UAAU;AAC/E,SAASC,eAAe,QAAQ,gCAAgC;AAChE,SAA6BC,UAAU,QAAQ,6BAA6B;AAC5E,SACCC,aAAa,EAEbC,YAAY,QACN,qCAAqC;;AAE5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAiBA;AACA;AACA;;AAgDA;AACA;AACA;;AA4BA,MAAMC,aAAa,GAAGP,aAAa,CAAmB,IAAI,CAAC;;AAE3D;AACA;AACA;;AAGA,OAAO,SAASQ,SAASA,CAACC,QAAkB,EAAoB;EAC/D,MAAMC,GAAG,GAAGR,UAAU,CAACK,aAAa,CAAC;EACrC,IAAIG,GAAG,IAAI,IAAI,IAAI,CAACD,QAAQ,EAAE;IAC7B,MAAM,IAAIE,KAAK,CACd,6DACD,CAAC;EACF;EACA,OAAOD,GAAG;AACX;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASE,YAAYA,CAACC,OAA4B,EAAa;EACrE,MAAMC,IAAI,GAAGX,eAAe,CAAqB;IAChDY,IAAI,EAAEF,OAAO,CAACE,IAAI;IAClBC,QAAQ,EAAEH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