@konstructio/ui
Version:
A set of reusable and customizable React components built for konstruct.io
30 lines (29 loc) • 964 B
JavaScript
import { t as G } from "../../dist-CMPkuWNy.js";
import { t as s } from "../../utils-COaoD3PI.js";
import { Radio as R } from "../Radio/Radio.js";
import { radioGroupVariants as b } from "./RadioGroup.variants.js";
import { useCallback as j, useState as I } from "react";
import { jsx as m } from "react/jsx-runtime";
var D = ({ asChild: a, className: c, defaultChecked: i, direction: n, name: d, options: p, theme: l, value: e, wrapperClassName: f, onValueChange: r }) => {
const S = a ? G : "div", o = e !== void 0, [h, C] = I(() => i), N = o ? e : h, k = j((t) => {
o || C(t), r?.(t);
}, [o, r]);
return /* @__PURE__ */ m(S, {
className: s(b({
className: f,
direction: n
})),
"data-theme": l,
children: p.map(({ value: t, ...x }) => /* @__PURE__ */ m(R, {
value: t,
name: d,
className: s(c),
checked: N === t,
onChange: () => k(t),
...x
}, t))
});
};
export {
D as RadioGroup
};