{"version":3,"names":["createContext","useContext","NOOP","NOOP_RADIO_GROUP_CONTEXT","checkedValue","undefined","setCheckedValue","disabled","readOnly","required","name","form","touched","setTouched","present","RadioGroupContext","useRadioGroupContext"],"sources":["radio-group-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 { FieldRootState } from \"../internals/field-constants\";\n\n/**\n * Reason string attached to every `onValueChange` event details object.\n * Matches Base UI React's `RadioGroup.ChangeEventReason`.\n */\nexport type RadioGroupChangeEventReason = typeof REASONS.none;\n\n/**\n * Shape of the details bag handed to `onValueChange`. The consumer may call\n * `details.cancel()` on the uncontrolled branch to veto the internal write.\n */\nexport type RadioGroupChangeEventDetails =\n\tBaseUIChangeEventDetails<RadioGroupChangeEventReason>;\n\n/**\n * State exposed by `<RadioGroup>`. Inherits the surrounding `<Field.Root>`\n * state so the shared `data-valid` / `data-touched` / `data-dirty` /\n * `data-filled` / `data-focused` / `data-invalid` projection flows through.\n */\nexport interface RadioGroupState extends FieldRootState {\n\t/** Whether the user should be unable to change the selected radio. */\n\treadOnly: boolean;\n\t/** Whether the user must choose a radio before submitting a form. */\n\trequired: boolean;\n}\n\n/**\n * Context value consumed by child `<Radio.Root>` elements. Every reactive\n * slot is exposed as an `Accessor<T>` so descendants pull the latest value\n * on demand — keeps Solid 2's no-top-level-reactive-reads rule (RFC 01)\n * satisfied.\n *\n * Shape diverges from the React port: React stores a plain object + triggers\n * re-renders; Solid needs live accessors per slot so child radios stay\n * reactive without a memo ping-pong.\n */\nexport interface RadioGroupContextValue {\n\t/** Currently selected value — `undefined` when nothing is selected. */\n\tcheckedValue: Accessor<unknown>;\n\t/**\n\t * Request a change to the selected value. Fires the consumer's\n\t * `onValueChange` (with a cancel-capable details bag) then — if not\n\t * canceled — writes the internal signal in the uncontrolled branch.\n\t */\n\tsetCheckedValue: (\n\t\tvalue: unknown,\n\t\teventDetails: RadioGroupChangeEventDetails,\n\t) => void;\n\t/** Whether user interaction with the group is disabled. */\n\tdisabled: Accessor<boolean>;\n\t/** Whether the group rejects user-driven selection changes. */\n\treadOnly: Accessor<boolean>;\n\t/** Whether the user must select a radio before submitting. */\n\trequired: Accessor<boolean>;\n\t/** `name` applied to every child radio's hidden input. */\n\tname: Accessor<string | undefined>;\n\t/** Shared `form` attribute applied to every child radio's hidden input. */\n\tform: Accessor<string | undefined>;\n\t/**\n\t * Latched by the group's capturing `onKeyDown` whenever the user presses\n\t * an arrow key, and read by a focused radio's `onFocus` handler so the\n\t * radio can auto-select on arrow-key navigation (mirrors React's\n\t * `touched` / `setTouched` dance in `RadioGroup.tsx:176`).\n\t */\n\ttouched: Accessor<boolean>;\n\t/** Flip the `touched` latch. Consumers call `setTouched(false)` after\n\t * acting on a touched-focus to disarm it. */\n\tsetTouched: (next: boolean) => void;\n\t/** Marker — `true` when this context was provided by a real `<RadioGroup>`. */\n\treadonly present: boolean;\n}\n\nconst NOOP = () => {};\n\n/**\n * Sentinel returned when a `<Radio.Root>` renders outside a `<RadioGroup>`.\n * Every setter is a no-op and every accessor returns \"nothing\". Callers\n * branch on `.present` to decide whether to fall back to their standalone\n * path (e.g. the radio's own consumer-owned signal for checked state).\n */\nexport const NOOP_RADIO_GROUP_CONTEXT: RadioGroupContextValue = {\n\tcheckedValue: () => undefined,\n\tsetCheckedValue: NOOP,\n\tdisabled: () => false,\n\treadOnly: () => false,\n\trequired: () => false,\n\tname: () => undefined,\n\tform: () => undefined,\n\ttouched: () => false,\n\tsetTouched: NOOP,\n\tpresent: false,\n};\n\n/**\n * Context carrying the current `<RadioGroup>` state. Provided via Solid 2's\n * context-as-provider pattern (`<RadioGroupContext value={...}>`).\n */\nexport const RadioGroupContext = createContext<RadioGroupContextValue>(\n\tNOOP_RADIO_GROUP_CONTEXT,\n);\n\n/**\n * Read the nearest `<RadioGroup>` context. Returns {@link NOOP_RADIO_GROUP_CONTEXT}\n * when there is no group ancestor — callers can branch on `.present` to\n * decide between \"group owns the state\" and standalone fallback paths.\n */\nexport function useRadioGroupContext(): RadioGroupContextValue {\n\treturn useContext(RadioGroupContext);\n}\n"],"mappings":"AAAA,SAAwBA,aAAa,EAAEC,UAAU,QAAQ,UAAU;;AAOnE;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAqCA,MAAMC,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;;AAErB;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,wBAAgD,GAAG;EAC/DC,YAAY,EAAEA,CAAA,KAAMC,SAAS;EAC7BC,eAAe,EAAEJ,IAAI;EACrBK,QAAQ,EAAEA,CAAA,KAAM,KAAK;EACrBC,QAAQ,EAAEA,CAAA,KAAM,KAAK;EACrBC,QAAQ,EAAEA,CAAA,KAAM,KAAK;EACrBC,IAAI,EAAEA,CAAA,KAAML,SAAS;EACrBM,IAAI,EAAEA,CAAA,KAAMN,SAAS;EACrBO,OAAO,EAAEA,CAAA,KAAM,KAAK;EACpBC,UAAU,EAAEX,IAAI;EAChBY,OAAO,EAAE;AACV,CAAC;;AAED;AACA;AACA;AACA;AACA,OAAO,MAAMC,iBAAiB,GAAGf,aAAa,CAC7CG,wBACD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,OAAO,SAASa,oBAAoBA,CAAA,EAA2B;EAC9D,OAAOf,UAAU,CAACc,iBAAiB,CAAC;AACrC","ignoreList":[]}