UNPKG

welcome-ui

Version:

Customizable design system with react, typescript, tailwindcss and ariakit.

82 lines (81 loc) 1.96 kB
"use client"; import './RadioGroup.css'; import { jsx as c } from "react/jsx-runtime"; import { c as G, u as h } from "./IQYAUKXT-Cltvp3KN.js"; import { c as x, u as _, a as $, b as y } from "./Q5W46E73-5xQblshY.js"; import { x as d } from "./U6HHPQDW-CzxyP5H7.js"; import { FieldGroup as L } from "./FieldGroup.js"; import { Radio as N } from "./Radio.js"; import { c as P } from "./index-B6iGEm-i.js"; import "react"; function b({ ...e } = {}) { var o; const t = (o = e.store) == null ? void 0 : o.getState(), r = G({ ...e, focusLoop: d(e.focusLoop, t == null ? void 0 : t.focusLoop, !0) }), l = { ...r.getState(), value: d( e.value, t == null ? void 0 : t.value, e.defaultValue, null ) }, u = x(l, r, e.store); return { ...r, ...u, setValue: (s) => u.setState("value", s) }; } function j(e, o, t) { return e = h(e, o, t), $(e, t, "value", "setValue"), e; } function k(e = {}) { const [o, t] = _(b, e); return j(o, t, e); } const C = "_root_17iu3_2", F = { root: C }, O = P(F), g = ({ className: e, dataTestId: o, disabled: t, hideLabel: r, id: l, label: u, name: s, onChange: i, options: m = [], renderOption: v = N, required: f, value: S, ...V }) => { const n = k({ defaultValue: S }), p = y(n, "value"), R = (a) => { t || (n.setValue(a), i == null || i(a)); }; return /* @__PURE__ */ c(L, { "data-testid": o, hideLabel: r, label: u, required: f, children: /* @__PURE__ */ c("div", { className: O("root", e), children: m.map((a) => /* @__PURE__ */ c( v, { checked: a.value === p, dataTestId: o ? `${o}-${a.value}` : void 0, disabled: t, hint: a.hint, id: `${l || s}.${a.value}`, label: a.label, name: s, onChange: () => R(a.value), value: a.value, ...V }, a.value )) }) }); }; g.displayName = "RadioGroup"; export { g as RadioGroup, F as radioGroupClasses };