{"version":3,"names":["createContext","useContext","RadioRootContext","useRadioRootContext","context","Error"],"sources":["radio-root-context.ts"],"sourcesContent":["import { type Accessor, createContext, useContext } from \"solid-js\";\nimport type { FieldRootState } from \"../internals/field-constants\";\n\n/**\n * The full state shape exposed by `<Radio.Root>` to its children. Mirrors\n * React's `RadioRootState` (see\n * `packages/react/src/radio/root/RadioRoot.tsx` — the inline `RadioRootState`\n * interface extends `FieldRootState`).\n *\n * `checked`, `disabled`, `readOnly` and `required` are the radio-specific\n * slots. The remainder (`valid`, `touched`, `dirty`, `filled`, `focused`) are\n * inherited from the surrounding `<Field.Root>` when one exists — they flow\n * through `data-*` projection and the `render` / `class` / `style` callbacks.\n */\nexport interface RadioRootState extends FieldRootState {\n\t/** Whether the radio button is currently selected. */\n\tchecked: boolean;\n\t/** Whether the component should ignore user interaction. */\n\tdisabled: boolean;\n\t/** Whether the user should be unable to select the radio button. */\n\treadOnly: boolean;\n\t/** Whether the user must choose a value before submitting a form. */\n\trequired: boolean;\n}\n\n/**\n * The context value consumed by `<Radio.Indicator>`. Every reactive slot is\n * exposed as an `Accessor<T>` so descendants pull the latest value on demand\n * and don't trip the top-level reactive read rule (RFC 01).\n *\n * Shape diverges from the React port: React stores a plain object + dispatches\n * via re-render. Solid's no-top-level-reactive-reads rule means we need a\n * live accessor for each field so `<Radio.Indicator>`'s render body (which\n * reads `checked` inside JSX to decide whether to emit the span) stays\n * reactive without a memo ping-pong.\n */\nexport interface RadioRootContextValue {\n\t/** Accessor for the full state object (used for `data-*` projection). */\n\tstate: Accessor<RadioRootState>;\n\t/** Direct accessor for `checked` — convenience for the indicator's gate. */\n\tchecked: Accessor<boolean>;\n}\n\n/**\n * Radio root context. `createContext<T | null>(null)` + `== null` sentinel\n * — Solid 2's `useContext` throws `ContextNotFoundError` when\n * the default is `undefined`, which would shadow the intended Base UI error\n * message below.\n */\nexport const RadioRootContext = createContext<RadioRootContextValue | null>(\n\tnull,\n);\n\n/**\n * Read the `<Radio.Root>` context. Throws a descriptive error if the caller\n * forgot to wrap their subtree in `<Radio.Root>` — matches Base UI React's\n * `useRadioRootContext`.\n */\nexport function useRadioRootContext(): RadioRootContextValue {\n\tconst context = useContext(RadioRootContext);\n\tif (context == null) {\n\t\tthrow new Error(\n\t\t\t\"Base UI: RadioRootContext is missing. Radio parts must be placed within <Radio.Root>.\",\n\t\t);\n\t}\n\treturn context;\n}\n"],"mappings":"AAAA,SAAwBA,aAAa,EAAEC,UAAU,QAAQ,UAAU;;AAGnE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,GAAGF,aAAa,CAC5C,IACD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,OAAO,SAASG,mBAAmBA,CAAA,EAA0B;EAC5D,MAAMC,OAAO,GAAGH,UAAU,CAACC,gBAAgB,CAAC;EAC5C,IAAIE,OAAO,IAAI,IAAI,EAAE;IACpB,MAAM,IAAIC,KAAK,CACd,uFACD,CAAC;EACF;EACA,OAAOD,OAAO;AACf","ignoreList":[]}