@konstructio/ui
Version:
A set of reusable and customizable React components built for konstruct.io
79 lines (78 loc) • 1.73 kB
JavaScript
import { jsxs as u, jsx as r } from "react/jsx-runtime";
import { forwardRef as x, useId as V, useCallback as h } from "react";
import { cn as e } from "../../utils/index.js";
import { radioVariants as j, labelRadioVariants as w, wrapperRadioVariants as F } from "./Radio.variants.js";
const z = x(
({
checked: i = !1,
className: m,
defaultChecked: l,
disabled: s,
label: c,
labelTextClassName: p,
name: t,
theme: f,
value: o,
wrapperClassName: n,
onChange: a
}, N) => {
const d = `${V()}-${t}`, R = h(
(b) => {
a == null || a(b);
},
[a]
);
return /* @__PURE__ */ u(
"label",
{
htmlFor: d,
className: e(
F({
className: n,
disabled: s || !1
})
),
"data-theme": f,
children: [
/* @__PURE__ */ r(
"input",
{
ref: N,
id: d,
type: "radio",
name: t,
value: o,
checked: i,
defaultChecked: l,
className: "hidden peer",
onChange: () => R(o),
disabled: s
}
),
/* @__PURE__ */ r(
"span",
{
className: e(
j({
className: m,
disabled: s || !1,
checked: i || l || !1
})
)
}
),
/* @__PURE__ */ r(
"span",
{
className: e(w({ className: p })),
children: c
}
)
]
}
);
}
);
export {
z as Radio
};