UNPKG

@konstructio/ui

Version:

A set of reusable and customizable React components built for konstruct.io

51 lines (50 loc) 1.05 kB
import { jsx as r } from "react/jsx-runtime"; import { S as x } from "../../index-B5MIi2tR.js"; import { useState as G, useCallback as R } from "react"; import { cn as m } from "../../utils/index.js"; import { Radio as b } from "../Radio/Radio.js"; import { radioGroupVariants as j } from "./RadioGroup.variants.js"; const B = ({ asChild: s, className: c, defaultChecked: e, name: i, options: d, theme: p, wrapperClassName: a, direction: f, onValueChange: o }) => { const S = s ? x : "div", [n, N] = G( () => e ), k = R( (t) => { N(t), o == null || o(t); }, [o] ); return /* @__PURE__ */ r( S, { className: m( j({ className: a, direction: f }) ), "data-theme": p, children: d.map(({ value: t, ...l }) => /* @__PURE__ */ r( b, { value: t, name: i, className: m(c), checked: n === t, onChange: () => k(t), ...l }, t )) } ); }; export { B as RadioGroup };