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