UNPKG

@konstructio/ui

Version:

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

80 lines (79 loc) 1.83 kB
import { jsxs as T, jsx as e } from "react/jsx-runtime"; import { forwardRef as V, useId as j, useCallback as w } from "react"; import { cn as r } from "../../utils/index.js"; import { radioVariants as F, labelRadioVariants as $, wrapperRadioVariants as y } from "./Radio.variants.js"; import { useTheme as I } from "../../contexts/theme.hook.js"; const D = V( ({ checked: t = !1, className: c, defaultChecked: o, disabled: a, label: d, labelTextClassName: p, name: i, theme: n, value: m, wrapperClassName: f, onChange: s }, h) => { const N = j(), { theme: u } = I(), l = `${N}-${i}`, x = n ?? u, R = w( (b) => { s == null || s(b); }, [s] ); return /* @__PURE__ */ T( "label", { htmlFor: l, className: r( y({ className: f, disabled: a || !1 }) ), children: [ /* @__PURE__ */ e( "input", { ref: h, id: l, type: "radio", name: i, value: m, checked: t, defaultChecked: o, className: "hidden peer", onChange: () => R(m), disabled: a } ), /* @__PURE__ */ e( "span", { className: r( F({ className: c, theme: x, disabled: a || !1, checked: t || o || !1 }) ) } ), /* @__PURE__ */ e( "span", { className: r($({ className: p })), children: d } ) ] } ); } ); export { D as Radio };