UNPKG

@clubmed/trident-ui

Version:

Shared ClubMed React UI components

40 lines (39 loc) 980 B
import { jsx as v } from "react/jsx-runtime"; import { useId as x, Children as I, isValidElement as b, cloneElement as C } from "react"; import { useValue as h } from "../../../hooks/useValue.js"; import { c as E } from "../../../chunks/index.js"; function G(l) { const s = x(), { id: a = s, name: r = a, children: t, value: i, defaultValue: m, onChange: u, disabled: d, readOnly: p, tabIndex: c = 0, ...n } = l, { value: f, setValue: V } = h({ name: r, initialValue: i, defaultValue: m, onChange: u }); return /* @__PURE__ */ v("div", { ...n, className: E("flex gap-12", n.className), role: "radiogroup", children: I.map(t, (e, o) => b(e) ? C(e, { ...e.props, name: r, id: `${a}-${o}`, disabled: d, readOnly: p, tabIndex: c + o + 1, checked: f === e.props.value, onChange(N, g) { V(g); } }) : e) }); } export { G as RadioGroup }; //# sourceMappingURL=RadioGroup.js.map