UNPKG

fui-fancyui

Version:
71 lines (70 loc) 1.64 kB
"use client"; import { jsx as l } from "react/jsx-runtime"; import v, { useId as w, useState as M, useRef as N, useEffect as W } from "react"; import j from "../../molecules/FancySelectWrapper/FancySelectWrapper.js"; import D from "../../atoms/RawRadio/RawRadio.js"; import H from "../../../design/designFunctions/getOpositMainThemeType/getOpositMainThemeType.js"; const L = v.forwardRef((s, t) => { const { align: d = "left", alignInput: p, label: f, description: u, externalStyle: m, checked: r, id: y, name: h, value: k, themeType: i = "primary", layer: R = 2, layerTitle: g = 0, layerDescription: T = 2, className: S, onChange: c, ...x } = s, C = w(), n = y || C, [E, o] = M(r || !1), a = N(null), F = (e) => { typeof t == "function" ? t(e) : t && (t.current = e), a.current = e; }; W(() => { r !== void 0 && o(r); }, [r]); const I = () => { a.current && !a.current.disabled && a.current.click(); }, b = (e) => { o(e.target.checked), c == null || c(e); }; return /* @__PURE__ */ l( j, { externalStyle: m, id: n, label: f, description: u, align: d, alignInput: p, themeType: H(i), layer: g, layerDescription: T, className: S, onClick: I, inputElement: /* @__PURE__ */ l( D, { ref: F, themeType: i, layer: R, name: h, checked: E, value: k, id: n, onChange: b, ...x } ) } ); }); L.displayName = "FancyRadio"; export { L as default };