{"version":3,"names":["createContext","useContext","DialogRootContext","useDialogRootContext","optional","context","Error","IsDrawerContext"],"sources":["dialog-root-context.ts"],"sourcesContent":["/**\n * Context shape for `<Dialog.Root>` — consumed by every dialog sub-part.\n *\n * Mirrors Base UI React's `DialogRootContext` (`packages/react/src/dialog/\n * root/DialogRootContext.ts`). The Solid port exposes every reactive field\n * as an `Accessor<T>` so consumers can subscribe without wrapping.\n *\n * Context uses the `createContext<T | null>(null)` + `== null` sentinel\n * pattern — `<Dialog.Root>` wraps the subtree and every part\n * reads through `useDialogRootContext()`, which throws if no provider is\n * present (unless `optional: true` is passed).\n */\n\nimport { type Accessor, createContext, useContext } from \"solid-js\";\nimport type {\n\tBaseUIChangeEventDetails,\n\tREASONS,\n} from \"../internals/change-event-details\";\nimport type { InteractionType } from \"../internals/floating-ui/components/floating-focus-manager\";\nimport type { FloatingRootStore } from \"../internals/floating-ui/components/floating-root-store\";\nimport type { UseInteractionsReturn } from \"../internals/floating-ui/hooks/use-interactions\";\nimport type { MutableRef } from \"../internals/floating-ui/types\";\nimport type { TransitionStatus } from \"../internals/use-transition-status/use-transition-status\";\nimport type { DialogStore } from \"./store/dialog-store\";\n\n/**\n * Modal kind for `<Dialog.Root>`:\n *\n * - `true` (default): focus-trap + scroll-lock + outside pointer block.\n * - `false`: none of the above (dialog is dismissable via the backdrop\n *   click path but keyboard focus isn't trapped).\n * - `\"trap-focus\"`: focus is trapped but scroll isn't locked and outside\n *   pointer interactions remain enabled.\n */\nexport type DialogModalKind = boolean | \"trap-focus\";\n\n/** Change-event reason union for `<Dialog.Root>`. */\nexport type DialogRootChangeEventReason =\n\t| typeof REASONS.triggerPress\n\t| typeof REASONS.outsidePress\n\t| typeof REASONS.escapeKey\n\t| typeof REASONS.closePress\n\t| typeof REASONS.focusOut\n\t| typeof REASONS.imperativeAction\n\t| typeof REASONS.none;\n\n/**\n * `BaseUIChangeEventDetails` extended with the React Dialog-specific\n * `preventUnmountOnClose()` hook. When called from inside `onOpenChange`,\n * the dialog stays mounted after `open=false` — useful for consumers\n * controlling unmount timing through an external animation library.\n */\nexport type DialogRootChangeEventDetails = BaseUIChangeEventDetails<\n\tDialogRootChangeEventReason,\n\t{ preventUnmountOnClose: () => void }\n>;\n\n/**\n * Shared state surfaced on the dialog root context. Every field is a\n * signal/accessor except imperative writers.\n */\nexport interface DialogRootContextValue<Payload = unknown> {\n\t/** Reactive open flag. */\n\topen: Accessor<boolean>;\n\t/** Whether the dialog's DOM is mounted (open OR animating out). */\n\tmounted: Accessor<boolean>;\n\t/** Enter/exit transition status, or `undefined` when settled. */\n\ttransitionStatus: Accessor<TransitionStatus>;\n\t/** Modal kind. */\n\tmodal: Accessor<DialogModalKind>;\n\t/**\n\t * When true, outside-press dismissal is disabled (the dialog only\n\t * closes via Escape / Close / imperative).\n\t */\n\tdisablePointerDismissal: Accessor<boolean>;\n\t/**\n\t * The ARIA role applied to the popup. `\"dialog\"` for `<Dialog.Root>`,\n\t * `\"alertdialog\"` for `<AlertDialog.Root>`. Currently fixed to\n\t * `\"dialog\"` for the dialog compound; `alert-dialog` will override.\n\t */\n\trole: Accessor<\"dialog\" | \"alertdialog\">;\n\t/** Whether the dialog has a parent dialog ancestor. */\n\tnested: Accessor<boolean>;\n\t/** Number of nested dialogs currently open underneath this root. */\n\tnestedOpenDialogCount: Accessor<number>;\n\t/** Number of nested drawers currently open underneath this root. */\n\tnestedOpenDrawerCount: Accessor<number>;\n\t/**\n\t * How the dialog was opened — reflects the interaction type captured\n\t * by `useOpenInteractionType`. Used by the popup to decide default\n\t * initial-focus behavior (touch → focus the popup element to avoid a\n\t * virtual keyboard flash).\n\t */\n\topenMethod: Accessor<InteractionType | null>;\n\t/** Title element id → consumed by popup's `aria-labelledby`. */\n\ttitleId: Accessor<string | undefined>;\n\tsetTitleId: (id: string | undefined) => void;\n\t/** Description element id → consumed by popup's `aria-describedby`. */\n\tdescriptionId: Accessor<string | undefined>;\n\tsetDescriptionId: (id: string | undefined) => void;\n\t/**\n\t * The shared `FloatingRootStore`. `useDismiss` / `useRole` write and\n\t * the popup / trigger read reactive signals off of it.\n\t */\n\tfloatingRootContext: FloatingRootStore;\n\t/** Prop-getter bundle from `useInteractions([dismiss, role])`. */\n\tinteractions: UseInteractionsReturn;\n\t/**\n\t * Imperative setOpen — used by trigger, close button, and the handle.\n\t */\n\tsetOpen: (next: boolean, details: DialogRootChangeEventDetails) => void;\n\t/**\n\t * Popup ref slot written by `<Dialog.Popup>`. The root reads it for\n\t * `useOpenChangeComplete`'s unmount timing and outside-press checks.\n\t */\n\tpopupRef: MutableRef<HTMLElement | null>;\n\t/** Backdrop ref slot, written by `<Dialog.Backdrop>`. */\n\tbackdropRef: MutableRef<HTMLElement | null>;\n\t/** Internal backdrop ref slot, written by `<Dialog.Portal>`. */\n\tinternalBackdropRef: MutableRef<HTMLElement | null>;\n\t/**\n\t * When `current` is `false`, `useDismiss`'s outside-press path is\n\t * suppressed. `<Drawer.SwipeArea>` flips it off during an active\n\t * swipe-open gesture so the release doesn't dismiss the drawer it\n\t * just opened.\n\t */\n\toutsidePressEnabledRef: MutableRef<boolean>;\n\t/** Popup element accessor (reactive). */\n\tpopupElement: Accessor<HTMLElement | null>;\n\tsetPopupElement: (el: HTMLElement | null) => void;\n\t/** Viewport element accessor (reactive). */\n\tviewportElement: Accessor<HTMLElement | null>;\n\tsetViewportElement: (el: HTMLElement | null) => void;\n\t/** Active trigger element. */\n\ttriggerElement: Accessor<HTMLElement | null>;\n\tsetTriggerElement: (el: HTMLElement | null) => void;\n\t/** Active trigger id. */\n\tactiveTriggerId: Accessor<string | null>;\n\tsetActiveTriggerId: (id: string | null) => void;\n\t/** The dialog's store (handle registry + imperative wire). */\n\tstore: DialogStore<Payload>;\n\t/** Payload written by the active trigger. */\n\tpayload: Accessor<Payload | undefined>;\n\tsetPayload: (payload: Payload | undefined) => void;\n\t/**\n\t * Parent-context callback invoked by a nested dialog/drawer when it\n\t * opens. The child passes its own nested counts (+1 for itself,\n\t * +(isDrawer ? 1 : 0) drawer delta). The receiving parent mirrors the\n\t * counts into its own `nestedOpenDialogCount` / `nestedOpenDrawerCount`\n\t * selectors so the parent's popup can flip `data-nested-dialog-open`\n\t * and `data-nested-drawer-open`. Mirrors React's `onNestedDialogOpen`\n\t * context callback.\n\t */\n\tonNestedDialogOpen: (dialogCount: number, drawerCount: number) => void;\n\t/**\n\t * Parent-context callback invoked when a nested dialog/drawer closes.\n\t * Resets the parent's `nestedOpenDialogCount` / `nestedOpenDrawerCount`\n\t * to zero. Mirrors React's `onNestedDialogClose`.\n\t */\n\tonNestedDialogClose: () => void;\n}\n\n/**\n * Context — `null` is the sentinel for \"no provider\". We don't use\n * `undefined` here.\n */\nexport const DialogRootContext =\n\tcreateContext<DialogRootContextValue<unknown> | null>(null);\n\n/**\n * Read the current `<Dialog.Root>` context. Throws unless `optional` is\n * `true`. Mirrors Base UI React's `useDialogRootContext` overloads.\n */\nexport function useDialogRootContext(): DialogRootContextValue<unknown>;\nexport function useDialogRootContext(\n\toptional: true,\n): DialogRootContextValue<unknown> | null;\nexport function useDialogRootContext(\n\toptional?: boolean,\n): DialogRootContextValue<unknown> | null {\n\tconst context = useContext(DialogRootContext);\n\tif (context == null && !optional) {\n\t\tthrow new Error(\n\t\t\t\"Base UI: DialogRootContext is missing. Dialog parts must be placed within <Dialog.Root>.\",\n\t\t);\n\t}\n\treturn context;\n}\n\n/**\n * Drawer detection context. Set to `true` by `<Drawer.Root>` (not yet\n * ported), read here by `<Dialog.Root>` to decide whether to count this\n * dialog as a drawer for the nested-open bookkeeping. Ships now so the\n * counting paths compose cleanly when drawer lands later.\n */\nexport const IsDrawerContext = createContext<boolean>(false);\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAAwBA,aAAa,EAAEC,UAAU,QAAQ,UAAU;;AAYnE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;;AAUA;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;;AAsGA;AACA;AACA;AACA;AACA,OAAO,MAAMC,iBAAiB,GAC7BF,aAAa,CAAyC,IAAI,CAAC;;AAE5D;AACA;AACA;AACA;;AAKA,OAAO,SAASG,oBAAoBA,CACnCC,QAAkB,EACuB;EACzC,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;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAME,eAAe,GAAGP,aAAa,CAAU,KAAK,CAAC","ignoreList":[]}