UNPKG

@konstructio/ui

Version:

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

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