welcome-ui
Version:
Customizable design system with react, typescript, tailwindcss and ariakit.
73 lines (72 loc) • 1.91 kB
JavaScript
"use client";
import { jsx as n } from "react/jsx-runtime";
import { c as G, u as P } from "./B7UTNDHN-C-gORHYH.js";
import { c as $, b, d as x, u as L } from "./RTNCFSKZ-P4icqVD0.js";
import { F as j, G as d, H as m, I as c } from "./OE2EFRVA-C3721cM3.js";
import { FieldGroup as y } from "./FieldGroup.js";
import { Radio as F } from "./Radio.js";
import { c as N } from "./index-PAaZGbyz.js";
import "react";
function k(t = {}) {
var e = j(t, []), a;
const r = (a = e.store) == null ? void 0 : a.getState(), s = G(d(c({}, e), {
focusLoop: m(e.focusLoop, r == null ? void 0 : r.focusLoop, !0)
})), i = d(c({}, s.getState()), {
value: m(
e.value,
r == null ? void 0 : r.value,
e.defaultValue,
null
)
}), u = $(i, s, e.store);
return d(c(c({}, s), u), {
setValue: (l) => u.setState("value", l)
});
}
function H(t, e, a) {
return t = P(t, e, a), x(t, a, "value", "setValue"), t;
}
function O(t = {}) {
const [e, a] = b(k, t);
return H(e, a, t);
}
const g = "_root_v6e2n_2", q = {
root: g
}, w = N(q), K = ({
className: t,
dataTestId: e,
disabled: a,
hideLabel: r,
id: s,
label: i,
name: u,
onChange: l,
options: p = [],
renderOption: f = F,
required: S,
value: _,
...V
}) => {
const v = O({ defaultValue: _ }), R = L(v, "value"), h = (o) => {
a || (v.setValue(o), l == null || l(o));
};
return /* @__PURE__ */ n(y, { "data-testid": e, hideLabel: r, label: i, required: S, children: /* @__PURE__ */ n("div", { className: w("root", t), children: p.map((o) => /* @__PURE__ */ n(
f,
{
checked: o.value === R,
dataTestId: e ? `${e}-${o.value}` : void 0,
disabled: a,
hint: o.hint,
id: `${s || u}.${o.value}`,
label: o.label,
name: u,
onChange: () => h(o.value),
value: o.value,
...V
},
o.value
)) }) });
};
export {
K as RadioGroup
};