UNPKG

@stihl-design-system/components

Version:

Welcome to the STIHL Design System react component library.

127 lines (126 loc) 6.54 kB
"use client"; import { jsx as D, jsxs as ne } from "react/jsx-runtime"; import { d as ve } from "./chunks/index.CgTHIF3K.js"; import { c as E } from "./chunks/index.CEyLAtio.js"; import { forwardRef as Ae, useRef as ce, useState as pe, useEffect as Ce } from "react"; import './assets/radio.CgpGvYc-.css';const he = (H) => H.replace(/\s+/g, ""), ye = "ds-radio_root_2idos_1", ke = "ds-radio_root--disabled_2idos_24", ge = "ds-radio_root--with-custom-area_2idos_27", Ne = "ds-radio_root--with-custom-area--above_2idos_30", We = "ds-radio_radio_2idos_36", xe = "ds-radio_dot_2idos_54", De = "ds-radio_radio--invalid_2idos_78", He = "ds-radio_label_2idos_83", Be = "ds-radio_label--bold_2idos_100", Se = "ds-radio_label--with-custom-area_2idos_111", Ue = "ds-radio_custom-area_2idos_115", Ie = "ds-radio_custom-area--above_2idos_123", $e = "ds-radio_hint_2idos_129", we = "ds-radio_hint--visible_2idos_153", je = "ds-radio_hint--unchecked-hidden_2idos_157", Ee = "ds-radio_input_2idos_163", t = { root: ye, rootDisabled: ke, rootWithCustomArea: ge, rootWithCustomAreaAbove: Ne, radio: We, dot: xe, radioInvalid: De, label: He, labelBold: Be, labelWithCustomArea: Se, customArea: Ue, customAreaAbove: Ie, hint: $e, hintVisible: we, hintUncheckedHidden: je, input: Ee }, Ve = Ae((H, _) => { const e = ve.c(83); let B, b, o, n, i, d, c, h, v, S, U, I, $, w, j, u; e[0] !== H ? ({ label: d, name: c, value: u, checked: B, className: b, customArea: o, isCustomAreaAbove: S, defaultChecked: U, disabled: I, fieldsetId: n, hint: i, invalid: $, isBold: w, hideUncheckedHint: j, onChange: h, ...v } = H, e[0] = H, e[1] = B, e[2] = b, e[3] = o, e[4] = n, e[5] = i, e[6] = d, e[7] = c, e[8] = h, e[9] = v, e[10] = S, e[11] = U, e[12] = I, e[13] = $, e[14] = w, e[15] = j, e[16] = u) : (B = e[1], b = e[2], o = e[3], n = e[4], i = e[5], d = e[6], c = e[7], h = e[8], v = e[9], S = e[10], U = e[11], I = e[12], $ = e[13], w = e[14], j = e[15], u = e[16]); const f = S === void 0 ? !1 : S, ue = U === void 0 ? !1 : U, a = I === void 0 ? !1 : I, A = $ === void 0 ? !1 : $, X = w === void 0 ? !1 : w, r = j === void 0 ? !1 : j, fe = ce(null), s = ce(null), [me, _e] = pe(ue), V = B !== void 0, l = V ? B : me; let O, R; e[17] !== l || e[18] !== r ? (O = () => { s.current && (r ? (s.current.style.height === "0px" || s.current.style.height === "") && l ? (s.current.style.height = `${s.current.scrollHeight}px`, s.current.style.opacity = "1") : l || (s.current.style.opacity = "0", s.current.style.height = "0px", s.current.style.pointerEvents = "none") : (s.current.style.height === "0px" || s.current.style.height === "") && (s.current.style.height = "auto", s.current.style.opacity = "1")); }, R = [s, l, r], e[17] = l, e[18] = r, e[19] = O, e[20] = R) : (O = e[19], R = e[20]), Ce(O, R); const Y = !!o, Z = !!o && f; let q; e[21] !== b || e[22] !== a || e[23] !== Z || e[24] !== Y ? (q = E(t.root, { [t.rootDisabled]: a, [t.rootWithCustomArea]: Y, [t.rootWithCustomAreaAbove]: Z }, b), e[21] = b, e[22] = a, e[23] = Z, e[24] = Y, e[25] = q) : q = e[25]; const ee = q, te = !!o; let z; e[26] !== X || e[27] !== te ? (z = E(t.label, { [t.labelBold]: X, [t.labelWithCustomArea]: te }), e[26] = X, e[27] = te, e[28] = z) : z = e[28]; const se = z; let F; e[29] !== l || e[30] !== r || e[31] !== i ? (F = () => !r && i ? !0 : !!(r && i && l), e[29] = l, e[30] = r, e[31] = i, e[32] = F) : F = e[32]; const G = F, oe = r && !G(); let J; e[33] !== G || e[34] !== oe ? (J = E(t.hint, { [t.hintUncheckedHidden]: oe, [t.hintVisible]: G() }), e[33] = G, e[34] = oe, e[35] = J) : J = e[35]; const ie = J; let K; e[36] !== A ? (K = E(t.radio, { [t.radioInvalid]: A }), e[36] = A, e[37] = K) : K = e[37]; const le = K; let L; e[38] === Symbol.for("react.memo_cache_sentinel") ? (L = E(t.customArea, t.customAreaAbove), e[38] = L) : L = e[38]; const be = L; let M; e[39] !== a || e[40] !== V || e[41] !== h ? (M = (m) => { if (a) { m.preventDefault(); return; } V || _e(m.target.checked), h && h(m); }, e[39] = a, e[40] = V, e[41] = h, e[42] = M) : M = e[42]; const ae = M, p = i ? `${he(c)}-${he(u)}-description` : void 0; let P; e[43] !== p || e[44] !== n || e[45] !== A ? (P = [A && n && `${n}-feedback`, p].filter(Boolean).join(" ") || void 0, e[43] = p, e[44] = n, e[45] = A, e[46] = P) : P = e[46]; const re = P; let C; e[47] !== _ ? (C = (m) => { typeof _ == "function" ? _(m) : _ !== null && (_.current = m), fe.current = m; }, e[47] = _, e[48] = C) : C = e[48]; const de = typeof d == "string" ? d : void 0; let y; e[49] !== re || e[50] !== l || e[51] !== a || e[52] !== ae || e[53] !== c || e[54] !== v || e[55] !== C || e[56] !== de || e[57] !== u ? (y = /* @__PURE__ */ D("input", { type: "radio", value: u, name: c, className: t.input, ref: C, onChange: ae, ...v, disabled: a, checked: l, "aria-label": de, "aria-describedby": re }), e[49] = re, e[50] = l, e[51] = a, e[52] = ae, e[53] = c, e[54] = v, e[55] = C, e[56] = de, e[57] = u, e[58] = y) : y = e[58]; let Q; e[59] === Symbol.for("react.memo_cache_sentinel") ? (Q = /* @__PURE__ */ D("div", { className: t.dot }), e[59] = Q) : Q = e[59]; let k; e[60] !== le ? (k = /* @__PURE__ */ D("span", { className: le, children: Q }), e[60] = le, e[61] = k) : k = e[61]; let g; e[62] !== o || e[63] !== f ? (g = o && f && /* @__PURE__ */ D("div", { className: be, children: o }), e[62] = o, e[63] = f, e[64] = g) : g = e[64]; let N; e[65] !== o || e[66] !== f ? (N = o && !f && /* @__PURE__ */ D("div", { className: t.customArea, children: o }), e[65] = o, e[66] = f, e[67] = N) : N = e[67]; let W; e[68] !== p || e[69] !== i || e[70] !== ie ? (W = /* @__PURE__ */ D("span", { id: p, className: ie, ref: s, children: i }), e[68] = p, e[69] = i, e[70] = ie, e[71] = W) : W = e[71]; let x; e[72] !== d || e[73] !== se || e[74] !== N || e[75] !== W ? (x = /* @__PURE__ */ ne("span", { className: se, children: [ d, N, W ] }), e[72] = d, e[73] = se, e[74] = N, e[75] = W, e[76] = x) : x = e[76]; let T; return e[77] !== ee || e[78] !== y || e[79] !== k || e[80] !== g || e[81] !== x ? (T = /* @__PURE__ */ ne("label", { className: ee, children: [ y, k, g, x ] }), e[77] = ee, e[78] = y, e[79] = k, e[80] = g, e[81] = x, e[82] = T) : T = e[82], T; }); Ve.displayName = "DSRadio"; export { Ve as DSRadio };