UNPKG

@konstructio/ui

Version:

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

47 lines (46 loc) 1.03 kB
import { jsx as m, Fragment as l } from "react/jsx-runtime"; import { useState as n, useCallback as x } from "react"; import { cn as c } from "../../utils/index.js"; import { RadioCard as G } from "../RadioCard/RadioCard.js"; import { radioCardGroupVariants as R } from "./RadioCardGroup.variants.js"; const w = ({ className: d, defaultChecked: o, direction: s, name: e, options: i, theme: a, wrapperClassName: p, onValueChange: t }) => { const [f, N] = n(o), S = x( (r) => { N(r), t == null || t(r); }, [t] ); return /* @__PURE__ */ m( "div", { className: c( R({ className: p, direction: s }) ), "data-theme": a, children: /* @__PURE__ */ m(l, { children: i.map(({ value: r, ...k }) => /* @__PURE__ */ m( G, { value: r, name: e, className: c(d), checked: f === r, onChange: () => S(r), ...k }, r )) }) } ); }; export { w as RadioCardGroup };