UNPKG

@lanaco/lnc-react-ui

Version:

React component library

105 lines (104 loc) 2.06 kB
import { jsx as l } from "react/jsx-runtime"; import { forwardRef as P, useState as j, useEffect as z } from "react"; import { n as R } from "./emotion-styled.browser.esm-CjCaF13H.js"; import { P as e } from "./index-S5Cd7WrG.js"; import T from "./RadioInput.js"; import { u as k } from "./emotion-element-f0de968e.browser.esm-CkCiQliQ.js"; const N = R.div` display: inline-flex; flex-direction: ${(r) => r.inline === !0 ? "row" : "column"}; gap: 1.5rem; width: fit-content; box-sizing: border-box; `, S = P((r, s) => { const { id: t = "", name: m, value: o = null, disabled: d = !1, readOnly: p = !1, items: u = [], mapId: V = "id", mapValue: E = "value", radioProps: c, inline: f = !0, //---------------- onChange: n = () => { }, //---------------- className: g = "", style: y = {}, size: b = "small", color: h = "primary", ...v } = r; var x = k(); const [C, w] = j(null); z(() => { o !== C && w(o); }, [o]); var I = { color: h, theme: x, size: b, disabled: d, readOnly: p }; const O = (a, i) => { n && n(a); }; return /* @__PURE__ */ l( N, { ref: s, id: t, inline: f, style: y, className: g, ...v, children: u.map((a, i) => /* @__PURE__ */ l( T, { ...I, label: a.label, value: a.value, ...c, onChange: O, name: m }, i )) } ); }); S.propTypes = { id: e.string, name: e.string, value: e.any, disabled: e.bool, readOnly: e.bool, items: e.arrayOf(e.object), mapId: e.string, mapValue: e.string, inline: e.bool, //---------------- onChange: e.func, //---------------- className: e.string, style: e.object, size: e.oneOf(["small", "medium", "large"]), color: e.oneOf([ "primary", "secondary", "success", "danger", "warning", "information", "neutral", "gray" ]), radioProps: e.any }; export { S as default };