{"version":3,"names":["createContext","createMemo","untrack","useContext","makeSlotRefDirective","readOption","mergeRootProps","SNAPSHOT_KEYS","snapshotKeys","RadioContext","useRadio","ctx","Error","createRadio","options","checked","Boolean","name","disabled","readOnly","required","select","event","reason","ev","Event","cancelable","onCheckedChange","triggerInternal","type","role","aria-checked","aria-readonly","undefined","aria-required","data-checked","data-unchecked","data-disabled","data-readonly","data-required","onClick","trigger","userProps","triggerRef","api","Provider","props","children","RADIO_SNAPSHOT_KEYS"],"sources":["create-radio.tsx"],"sourcesContent":["import type { JSX } from \"@solidjs/web\";\nimport {\n\ttype Accessor,\n\tcreateContext,\n\tcreateMemo,\n\tuntrack,\n\tuseContext,\n} from \"solid-js\";\nimport { makeSlotRefDirective } from \"../internals/make-slot-ref-directive\";\nimport { type MaybeAccessor, readOption } from \"../internals/maybe-accessor\";\nimport { mergeRootProps } from \"../internals/merge-root-props\";\nimport {\n\tSNAPSHOT_KEYS,\n\ttype Snapshottable,\n\tsnapshotKeys,\n} from \"../internals/observability/snapshot\";\n\n/**\n * Why the checked state changed. Emitted on the third arg of\n * `onCheckedChange(next, event, reason)` and accepted by\n * `c.select(event?, reason?)`.\n *\n * - `\"trigger-press\"` — click (or keyboard activation that bubbles to click)\n *   on the trigger slot.\n * - `\"imperative\"` — programmatic `select()` with no originating DOM event.\n *\n * Outer compounds that embed Radio (RadioGroup) translate this to their own\n * reason taxonomy.\n */\nexport type RadioChangeReason = \"trigger-press\" | \"imperative\";\n\n/**\n * Options for {@link createRadio}.\n *\n * Every reactive input is `MaybeAccessor<T>` — pass an accessor to make the\n * value reactive, or a bare value for one-shot config.\n *\n * **Solid-native shape (2026-04-30).** No internal state. `checked` is\n * required and the consumer always owns the signal. The primitive is a pure\n * function from `(checked, onCheckedChange) → api`. See `solidify.md` §6.\n */\nexport interface CreateRadioOptions {\n\t/**\n\t * Checked state. Consumer-owned signal — the primitive reads through the\n\t * accessor and does NOT keep an internal copy. Writes happen via\n\t * `onCheckedChange` (the consumer's responsibility to update their signal).\n\t * When embedded in a `<RadioGroup>`, this is wired to\n\t * `() => group.value() === props.value` by the wrapper.\n\t */\n\tchecked: MaybeAccessor<boolean>;\n\t/**\n\t * Whether interaction is suppressed.\n\t * @default false\n\t */\n\tdisabled?: MaybeAccessor<boolean>;\n\t/**\n\t * Whether the radio is read-only — focusable but not selectable.\n\t * @default false\n\t */\n\treadOnly?: MaybeAccessor<boolean>;\n\t/**\n\t * Whether the radio must be selected before form submission.\n\t * @default false\n\t */\n\trequired?: MaybeAccessor<boolean>;\n\t/**\n\t * Change callback. Called synchronously with `(next, event, reason)`.\n\t * `event.preventDefault()` is now a no-op for the primitive (the\n\t * consumer's signal write is the only writer).\n\t *\n\t * Radios are one-way: `select()` always sends `next === true`. There is\n\t * no path that sends `false` — clicking an already-checked radio is a\n\t * no-op (matches Base UI React).\n\t */\n\tonCheckedChange?: (\n\t\tchecked: boolean,\n\t\tevent: Event,\n\t\treason: RadioChangeReason,\n\t) => void;\n}\n\n/**\n * Public API returned by {@link createRadio}. Flat accessors and setters at\n * the root; no `state` snapshot blob.\n */\nexport interface RadioApi {\n\tchecked: Accessor<boolean>;\n\tdisabled: Accessor<boolean>;\n\treadOnly: Accessor<boolean>;\n\trequired: Accessor<boolean>;\n\n\t/**\n\t * Select this radio (set `checked = true`). No-op while `disabled` /\n\t * `readOnly`, and no-op if already checked. Fires\n\t * `onCheckedChange(true, event, reason)`; if the consumer calls\n\t * `event.preventDefault()` the internal write is skipped.\n\t */\n\tselect: (event?: Event, reason?: RadioChangeReason) => void;\n\n\t/**\n\t * Trigger slot — getter-bag of attributes ready for spreading onto a\n\t * `<button role=\"radio\">`.\n\t */\n\ttrigger: <U extends object | undefined = undefined>(\n\t\tuserProps?: U,\n\t) => RadioTriggerSlotProps & (U extends object ? U : object);\n\n\t/**\n\t * Directive form of {@link trigger} — returns a `ref` callback that\n\t * spreads the trigger slot bag onto the element at apply time.\n\t */\n\ttriggerRef: () => (el: HTMLButtonElement | null) => void;\n\n\t/**\n\t * Context provider. Wrap a subtree to make the api discoverable via\n\t * `useRadio()` without prop-drilling.\n\t */\n\tProvider: (props: { children: JSX.Element }) => JSX.Element;\n}\n\n/** Shape of attributes emitted by `c.trigger()`. */\nexport interface RadioTriggerSlotProps {\n\ttype: \"button\";\n\trole: \"radio\";\n\t\"aria-checked\": \"true\" | \"false\";\n\t\"aria-readonly\": \"true\" | undefined;\n\t\"aria-required\": \"true\" | undefined;\n\t\"data-checked\": \"\" | undefined;\n\t\"data-unchecked\": \"\" | undefined;\n\t\"data-disabled\": \"\" | undefined;\n\t\"data-readonly\": \"\" | undefined;\n\t\"data-required\": \"\" | undefined;\n\tonClick: (event: MouseEvent) => void;\n}\n\nconst RadioContext = createContext<RadioApi | null>(null);\n\n/**\n * Read the nearest {@link RadioApi} provided by `c.Provider`. Throws if used\n * outside a Provider.\n */\nexport function useRadio(): RadioApi {\n\tconst ctx = useContext(RadioContext);\n\tif (ctx == null) {\n\t\tthrow new Error(\n\t\t\t\"Base UI: useRadio() must be called inside a <c.Provider>.\",\n\t\t);\n\t}\n\treturn ctx;\n}\n\n/**\n * Solid 2.0-native compound primitive for a single radio input. One call owns\n * logical state (checked/disabled/readOnly/required, onCheckedChange). Group\n * coordination, hidden-input form wiring, and field-control validation are\n * the `<Radio.Root>` / `<RadioGroup>` wrappers' job.\n *\n * Radios are one-way: `select()` always sends `next === true`. Clicking an\n * already-checked radio is a no-op (matches Base UI React).\n */\nexport function createRadio(options: CreateRadioOptions): RadioApi {\n\t// `checked` reads through the consumer's accessor — no internal signal,\n\t// no controlled-or-internal branching. Memoized so dependents see the\n\t// same identity within a tracking scope.\n\tconst checked = createMemo<boolean>(\n\t\t() => Boolean(readOption(options.checked)),\n\t\t{ name: \"radio.checked\" },\n\t);\n\n\tconst disabled = createMemo<boolean>(\n\t\t() => Boolean(readOption(options.disabled)),\n\t\t{ name: \"radio.disabled\" },\n\t);\n\tconst readOnly = createMemo<boolean>(\n\t\t() => Boolean(readOption(options.readOnly)),\n\t\t{ name: \"radio.readOnly\" },\n\t);\n\tconst required = createMemo<boolean>(\n\t\t() => Boolean(readOption(options.required)),\n\t\t{ name: \"radio.required\" },\n\t);\n\n\t// `select` is a pure event-emitter. It fires `onCheckedChange(true, event, reason)`;\n\t// the consumer is responsible for updating their checked-signal in response.\n\t// There is no internal state to write — `event.preventDefault()` is now a\n\t// no-op for the primitive (the consumer's handler is the only writer).\n\tconst select = (\n\t\tevent?: Event,\n\t\treason: RadioChangeReason = \"imperative\",\n\t): void => {\n\t\tif (untrack(disabled) || untrack(readOnly)) return;\n\t\tif (untrack(checked)) return;\n\t\tconst ev = event ?? new Event(\"checkedchange\", { cancelable: true });\n\t\toptions.onCheckedChange?.(true, ev, reason);\n\t};\n\n\tconst triggerInternal = {\n\t\ttype: \"button\" as const,\n\t\trole: \"radio\" as const,\n\t\tget \"aria-checked\"() {\n\t\t\treturn checked() ? (\"true\" as const) : (\"false\" as const);\n\t\t},\n\t\tget \"aria-readonly\"() {\n\t\t\treturn readOnly() ? (\"true\" as const) : undefined;\n\t\t},\n\t\tget \"aria-required\"() {\n\t\t\treturn required() ? (\"true\" as const) : undefined;\n\t\t},\n\t\tget \"data-checked\"() {\n\t\t\treturn checked() ? \"\" : undefined;\n\t\t},\n\t\tget \"data-unchecked\"() {\n\t\t\treturn checked() ? undefined : \"\";\n\t\t},\n\t\tget \"data-disabled\"() {\n\t\t\treturn disabled() ? \"\" : undefined;\n\t\t},\n\t\tget \"data-readonly\"() {\n\t\t\treturn readOnly() ? \"\" : undefined;\n\t\t},\n\t\tget \"data-required\"() {\n\t\t\treturn required() ? \"\" : undefined;\n\t\t},\n\t\tonClick(event: MouseEvent) {\n\t\t\tif (disabled() || readOnly()) return;\n\t\t\tif (untrack(checked)) return;\n\t\t\tselect(event, \"trigger-press\");\n\t\t},\n\t};\n\n\tconst trigger = <U extends object | undefined>(userProps?: U) =>\n\t\tmergeRootProps(triggerInternal, userProps) as RadioTriggerSlotProps &\n\t\t\t(U extends object ? U : object);\n\n\tconst triggerRef = (): ((el: HTMLButtonElement | null) => void) =>\n\t\tmakeSlotRefDirective(() => trigger());\n\n\tconst api: RadioApi = {\n\t\tchecked,\n\t\tdisabled,\n\t\treadOnly,\n\t\trequired,\n\t\tselect,\n\t\ttrigger,\n\t\ttriggerRef,\n\t\tProvider: (props) => (\n\t\t\t<RadioContext value={api}>{props.children}</RadioContext>\n\t\t),\n\t};\n\t(api as RadioApi & Snapshottable)[SNAPSHOT_KEYS] = RADIO_SNAPSHOT_KEYS;\n\treturn api;\n}\n\nconst RADIO_SNAPSHOT_KEYS = snapshotKeys<RadioApi>(\n\t\"checked\",\n\t\"disabled\",\n\t\"readOnly\",\n\t\"required\",\n);\n"],"mappings":"AACA,SAECA,aAAa,EACbC,UAAU,EACVC,OAAO,EACPC,UAAU,QACJ,UAAU;AACjB,SAASC,oBAAoB,QAAQ,sCAAsC;AAC3E,SAA6BC,UAAU,QAAQ,6BAA6B;AAC5E,SAASC,cAAc,QAAQ,+BAA+B;AAC9D,SACCC,aAAa,EAEbC,YAAY,QACN,qCAAqC;;AAE5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAyCA;AACA;AACA;AACA;;AAoCA;;AAeA,MAAMC,YAAY,GAAGT,aAAa,CAAkB,IAAI,CAAC;;AAEzD;AACA;AACA;AACA;AACA,OAAO,SAASU,QAAQA,CAAA,EAAa;EACpC,MAAMC,GAAG,GAAGR,UAAU,CAACM,YAAY,CAAC;EACpC,IAAIE,GAAG,IAAI,IAAI,EAAE;IAChB,MAAM,IAAIC,KAAK,CACd,2DACD,CAAC;EACF;EACA,OAAOD,GAAG;AACX;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,WAAWA,CAACC,OAA2B,EAAY;EAClE;EACA;EACA;EACA,MAAMC,OAAO,GAAGd,UAAU,CACzB,MAA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