UNPKG

@konstructio/ui

Version:

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

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