{"version":3,"names":["createContext","useContext","PopoverRootContext","usePopoverRootContext","optional","context","Error"],"sources":["popover-root-context.ts"],"sourcesContent":["import { type Accessor, createContext, useContext } from \"solid-js\";\nimport type {\n\tBaseUIChangeEventDetails,\n\tREASONS,\n} from \"../internals/change-event-details\";\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 { PopoverStore } from \"./store/popover-store\";\n\n/**\n * Change-reason union for `Popover.Root`. Mirrors Base UI React's\n * `PopoverRootChangeEventReason`. The Solid port omits reasons that depend on\n * behaviors not yet ported (hover, focus-based open, imperative-action via\n * `actionsRef`); those are listed as a comment on `<Popover.Root>`.\n */\nexport type PopoverRootChangeEventReason =\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\nexport type PopoverRootChangeEventDetails =\n\tBaseUIChangeEventDetails<PopoverRootChangeEventReason>;\n\n/**\n * Modal surface kind. Mirrors Base UI React's `modal` prop union. `true`\n * traps focus AND locks scroll / blocks outside pointer input via the\n * internal backdrop; `'trap-focus'` traps focus only; `false` does neither.\n */\nexport type PopoverModalKind = boolean | \"trap-focus\";\n\n/**\n * Shared state / handles surfaced through the Popover root context. Every\n * reactive field is exposed as an `Accessor<T>` so consumers don't need to\n * guard reactive reads.\n */\nexport interface PopoverRootContextValue {\n\t/** Reactive open state (true once the popover is requested open). */\n\topen: Accessor<boolean>;\n\t/** Whether the popover DOM is currently mounted (open OR animating out). */\n\tmounted: Accessor<boolean>;\n\t/** Enter/exit transition phase, or undefined when settled. */\n\ttransitionStatus: Accessor<TransitionStatus>;\n\t/**\n\t * Modal surface kind. See {@link PopoverModalKind}.\n\t */\n\tmodal: Accessor<PopoverModalKind>;\n\t/**\n\t * The title element id, if any `<Popover.Title>` is mounted. Flows into\n\t * the popup's `aria-labelledby`. Seeded with `\"\"` at mount so Solid's\n\t * JSX spread can subscribe to the key.\n\t */\n\ttitleId: Accessor<string | undefined>;\n\tsetTitleId: (id: string | undefined) => void;\n\t/**\n\t * The description element id, if any `<Popover.Description>` is mounted.\n\t * Flows into the popup's `aria-describedby`. Same `\"\"`-seed rule as\n\t * `titleId`.\n\t */\n\tdescriptionId: Accessor<string | undefined>;\n\tsetDescriptionId: (id: string | undefined) => void;\n\t/**\n\t * The shared `FloatingRootStore`. Positioner + popup read reactive\n\t * signals off of it (open, reference/floating elements, etc).\n\t */\n\tfloatingRootContext: FloatingRootStore;\n\t/**\n\t * Prop-getter bundle produced by `useInteractions` on the root. Trigger,\n\t * Popup, and other parts feed these into their prop-merge pipelines.\n\t */\n\tinteractions: UseInteractionsReturn;\n\t/**\n\t * Imperative setOpen, invoked by the Close button and by interaction\n\t * hooks (dismiss, role) via `floatingRootContext.setOpen`. Respects\n\t * `details.cancel()` for the uncontrolled branch.\n\t */\n\tsetOpen: (next: boolean, details: PopoverRootChangeEventDetails) => void;\n\t/**\n\t * Ref slot for the popup element. The popup's ref callback writes\n\t * `.current` and the positioner uses it for the close-animation\n\t * synchronization (mirrors React's `store.context.popupRef`).\n\t */\n\tpopupRef: MutableRef<HTMLElement | null>;\n\t/**\n\t * Ref slot for the active trigger element. Matches React's\n\t * `activeTriggerElement` — positioner reads it to anchor the floating\n\t * element; popup reads it to restore focus on close.\n\t */\n\ttriggerElement: Accessor<HTMLElement | null>;\n\tsetTriggerElement: (element: HTMLElement | null) => void;\n\t/**\n\t * The `PopoverStore` instance owned by this root. Triggers register\n\t * into its `context.triggerElements` map; the handle (if any) also\n\t * points to this store.\n\t */\n\tstore: PopoverStore<unknown>;\n\t/**\n\t * Accessor for the currently-selected trigger id. Set by the\n\t * implicit-active-trigger hook, by an explicit `triggerId` prop on\n\t * the root, or by `<Popover.Trigger id=...>` when it becomes active.\n\t */\n\tactiveTriggerId: Accessor<string | null>;\n\tsetActiveTriggerId: (id: string | null) => void;\n\t/**\n\t * Accessor for the current payload (if any). Set by the active\n\t * trigger via its `payload` prop; read by\n\t * `<Popover.Root>` children render-function.\n\t */\n\tpayload: Accessor<unknown>;\n\tsetPayload: (payload: unknown) => void;\n}\n\n/**\n * Context for the Popover compound components. `null` is the default so\n * `usePopoverRootContext(true)` can be called from above a provider (e.g.\n * the `<Popover.Root>` wrapper's `FloatingTree` gate) without triggering\n * Solid 2's `ContextNotFoundError`.\n */\nexport const PopoverRootContext = createContext<PopoverRootContextValue | null>(\n\tnull,\n);\n\n/**\n * Read the current `<Popover.Root>` context. Throws unless `optional` is\n * `true`. Matches Base UI React's `usePopoverRootContext` overload shape.\n */\nexport function usePopoverRootContext(): PopoverRootContextValue;\nexport function usePopoverRootContext(\n\toptional: true,\n): PopoverRootContextValue | null;\nexport function usePopoverRootContext(\n\toptional?: boolean,\n): PopoverRootContextValue | null {\n\tconst context = useContext(PopoverRootContext);\n\tif (context == null && !optional) {\n\t\tthrow new Error(\n\t\t\t\"Base UI: PopoverRootContext is missing. Popover parts must be placed within <Popover.Root>.\",\n\t\t);\n\t}\n\treturn context;\n}\n"],"mappings":"AAAA,SAAwBA,aAAa,EAAEC,UAAU,QAAQ,UAAU;;AAWnE;AACA;AACA;AACA;AACA;AACA;;AAaA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;;AA6EA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,kBAAkB,GAAGF,aAAa,CAC9C,IACD,CAAC;;AAED;AACA;AACA;AACA;;AAKA,OAAO,SAASG,qBAAqBA,CACpCC,QAAkB,EACe;EACjC,MAAMC,OAAO,GAAGJ,UAAU,CAACC,kBAAkB,CAAC;EAC9C,IAAIG,OAAO,IAAI,IAAI,IAAI,CAACD,QAAQ,EAAE;IACjC,MAAM,IAAIE,KAAK,CACd,6FACD,CAAC;EACF;EACA,OAAOD,OAAO;AACf","ignoreList":[]}