@konstructio/ui
Version:
A set of reusable and customizable React components built for konstruct.io
51 lines (50 loc) • 1.04 kB
JavaScript
import { jsx as e } from "react/jsx-runtime";
import { S as k } from "../../index-BvoZGpli.js";
import { useState as x, useCallback as C } from "react";
import { cn as r } from "../../utils/index.js";
import { Radio as G } from "../Radio/Radio.js";
import { radioGroupVariants as R } from "./RadioGroup.variants.js";
const y = ({
asChild: m,
className: s,
defaultChecked: c,
name: a,
options: i,
theme: d,
wrapperClassName: n,
direction: p,
onValueChange: t
}) => {
const f = m ? k : "div", [l, S] = x(
() => c
), h = C(
(o) => {
S(o), t?.(o);
},
[t]
);
return /* @__PURE__ */ e(
f,
{
className: r(
R({ className: n, direction: p })
),
"data-theme": d,
children: i.map(({ value: o, ...N }) => /* @__PURE__ */ e(
G,
{
value: o,
name: a,
className: r(s),
checked: l === o,
onChange: () => h(o),
...N
},
o
))
}
);
};
export {
y as RadioGroup
};