@stihl-design-system/components
Version:
Welcome to the STIHL Design System react component library.
149 lines (148 loc) • 7.47 kB
JavaScript
"use client";
import { jsx as B, jsxs as ge } from "react/jsx-runtime";
import { d as Ne } from "./chunks/index.cKLI89Eg.js";
import { c as f } from "./chunks/index.DQOqod3i.js";
import { forwardRef as We, useRef as ve, useState as xe, useEffect as He } from "react";
import './assets/radio.9hUUyg8R.css';const Ae = (U) => U.replace(/\s+/g, ""), Be = "ds-radio_root_1c2bg_1", Ue = "ds-radio_root--dark_1c2bg_24", Ie = "ds-radio_root--disabled_1c2bg_27", Se = "ds-radio_root--with-custom-area_1c2bg_30", $e = "ds-radio_root--with-custom-area--above_1c2bg_33", we = "ds-radio_radio_1c2bg_41", je = "ds-radio_dot_1c2bg_64", Ee = "ds-radio_radio--invalid_1c2bg_88", Ve = "ds-radio_radio--dark_1c2bg_92", Oe = "ds-radio_label_1c2bg_108", Re = "ds-radio_label--bold_1c2bg_125", Te = "ds-radio_label--with-custom-area_1c2bg_137", qe = "ds-radio_custom-area_1c2bg_141", ze = "ds-radio_custom-area--disabled_1c2bg_149", Fe = "ds-radio_custom-area--above_1c2bg_152", Ge = "ds-radio_hint_1c2bg_159", Je = "ds-radio_hint--visible_1c2bg_183", Ke = "ds-radio_hint--unchecked-hidden_1c2bg_187", Le = "ds-radio_input_1c2bg_193", Me = "ds-radio_input--dark_1c2bg_294", t = {
root: Be,
rootDark: Ue,
rootDisabled: Ie,
rootWithCustomArea: Se,
rootWithCustomAreaAbove: $e,
radio: we,
dot: je,
radioInvalid: Ee,
radioDark: Ve,
label: Oe,
labelBold: Re,
labelWithCustomArea: Te,
customArea: qe,
customAreaDisabled: ze,
customAreaAbove: Fe,
hint: Ge,
hintVisible: Je,
hintUncheckedHidden: Ke,
input: Le,
inputDark: Me
}, Pe = We((U, g) => {
const e = Ne.c(98);
let I, v, i, h, l, u, r, b, A, S, $, w, j, E, V, O, c;
e[0] !== U ? ({
label: u,
name: r,
value: c,
checked: I,
className: v,
customArea: i,
isCustomAreaAbove: S,
defaultChecked: $,
disabled: w,
fieldsetId: h,
hint: l,
invalid: j,
isBold: E,
hideUncheckedHint: V,
theme: O,
onChange: b,
...A
} = U, e[0] = U, e[1] = I, e[2] = v, e[3] = i, e[4] = h, e[5] = l, e[6] = u, e[7] = r, e[8] = b, e[9] = A, e[10] = S, e[11] = $, e[12] = w, e[13] = j, e[14] = E, e[15] = V, e[16] = O, e[17] = c) : (I = e[1], v = e[2], i = e[3], h = e[4], l = e[5], u = e[6], r = e[7], b = e[8], A = e[9], S = e[10], $ = e[11], w = e[12], j = e[13], E = e[14], V = e[15], O = e[16], c = e[17]);
const _ = S === void 0 ? !1 : S, pe = $ === void 0 ? !1 : $, s = w === void 0 ? !1 : w, p = j === void 0 ? !1 : j, se = E === void 0 ? !1 : E, d = V === void 0 ? !1 : V, ke = O === void 0 ? "light" : O, Ce = ve(null), o = ve(null), [ye, De] = xe(pe), R = I !== void 0, a = R ? I : ye;
let T, q;
e[18] !== a || e[19] !== d ? (T = () => {
o.current && (d ? (o.current.style.height === "0px" || o.current.style.height === "") && a ? (o.current.style.height = `${o.current.scrollHeight}px`, o.current.style.opacity = "1") : a || (o.current.style.opacity = "0", o.current.style.height = "0px", o.current.style.pointerEvents = "none") : (o.current.style.height === "0px" || o.current.style.height === "") && (o.current.style.height = "auto", o.current.style.opacity = "1"));
}, q = [o, a, d], e[18] = a, e[19] = d, e[20] = T, e[21] = q) : (T = e[20], q = e[21]), He(T, q);
const n = ke === "dark", oe = !!i, ie = !!i && _;
let z;
e[22] !== v || e[23] !== s || e[24] !== n || e[25] !== oe || e[26] !== ie ? (z = f(t.root, {
[t.rootDark]: n,
[t.rootDisabled]: s,
[t.rootWithCustomArea]: oe,
[t.rootWithCustomAreaAbove]: ie
}, v), e[22] = v, e[23] = s, e[24] = n, e[25] = oe, e[26] = ie, e[27] = z) : z = e[27];
const le = z, ae = !!i;
let F;
e[28] !== se || e[29] !== ae ? (F = f(t.label, {
[t.labelBold]: se,
[t.labelWithCustomArea]: ae
}), e[28] = se, e[29] = ae, e[30] = F) : F = e[30];
const re = F;
let G;
e[31] !== a || e[32] !== d || e[33] !== l ? (G = () => !d && l ? !0 : !!(d && l && a), e[31] = a, e[32] = d, e[33] = l, e[34] = G) : G = e[34];
const J = G, ce = d && !J();
let K;
e[35] !== J || e[36] !== ce ? (K = f(t.hint, {
[t.hintUncheckedHidden]: ce,
[t.hintVisible]: J()
}), e[35] = J, e[36] = ce, e[37] = K) : K = e[37];
const de = K;
let L;
e[38] !== n ? (L = f(t.input, {
[t.inputDark]: n
}), e[38] = n, e[39] = L) : L = e[39];
const ne = L;
let M;
e[40] !== p || e[41] !== n ? (M = f(t.radio, {
[t.radioDark]: n,
[t.radioInvalid]: p
}), e[40] = p, e[41] = n, e[42] = M) : M = e[42];
const ue = M;
let P;
e[43] !== s ? (P = f(t.customArea, {
[t.customAreaDisabled]: s
}), e[43] = s, e[44] = P) : P = e[44];
const he = P;
let Q;
e[45] !== s ? (Q = f(t.customArea, t.customAreaAbove, {
[t.customAreaDisabled]: s
}), e[45] = s, e[46] = Q) : Q = e[46];
const be = Q;
let X;
e[47] !== s || e[48] !== R || e[49] !== b ? (X = (m) => {
if (s) {
m.preventDefault();
return;
}
R || De(m.target.checked), b && b(m);
}, e[47] = s, e[48] = R, e[49] = b, e[50] = X) : X = e[50];
const _e = X;
let Y;
e[51] !== l || e[52] !== r || e[53] !== c ? (Y = l ? `${Ae(r)}-${Ae(c)}-description` : void 0, e[51] = l, e[52] = r, e[53] = c, e[54] = Y) : Y = e[54];
const k = Y;
let Z;
e[55] !== k || e[56] !== h || e[57] !== p ? (Z = [p && h && `${h}-feedback`, k].filter(Boolean).join(" ") || void 0, e[55] = k, e[56] = h, e[57] = p, e[58] = Z) : Z = e[58];
const me = Z;
let C;
e[59] !== g ? (C = (m) => {
typeof g == "function" ? g(m) : g !== null && (g.current = m), Ce.current = m;
}, e[59] = g, e[60] = C) : C = e[60];
const fe = typeof u == "string" ? u : void 0;
let y;
e[61] !== me || e[62] !== a || e[63] !== s || e[64] !== _e || e[65] !== ne || e[66] !== r || e[67] !== A || e[68] !== C || e[69] !== fe || e[70] !== c ? (y = /* @__PURE__ */ B("input", { type: "radio", value: c, name: r, className: ne, ref: C, onChange: _e, ...A, disabled: s, checked: a, "aria-label": fe, "aria-describedby": me }), e[61] = me, e[62] = a, e[63] = s, e[64] = _e, e[65] = ne, e[66] = r, e[67] = A, e[68] = C, e[69] = fe, e[70] = c, e[71] = y) : y = e[71];
let ee;
e[72] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (ee = /* @__PURE__ */ B("div", { className: t.dot }), e[72] = ee) : ee = e[72];
let D;
e[73] !== ue ? (D = /* @__PURE__ */ B("span", { className: ue, children: ee }), e[73] = ue, e[74] = D) : D = e[74];
let N;
e[75] !== i || e[76] !== be || e[77] !== _ ? (N = i && _ && /* @__PURE__ */ B("div", { className: be, children: i }), e[75] = i, e[76] = be, e[77] = _, e[78] = N) : N = e[78];
let W;
e[79] !== i || e[80] !== he || e[81] !== _ ? (W = i && !_ && /* @__PURE__ */ B("div", { className: he, children: i }), e[79] = i, e[80] = he, e[81] = _, e[82] = W) : W = e[82];
let x;
e[83] !== k || e[84] !== l || e[85] !== de ? (x = /* @__PURE__ */ B("span", { id: k, className: de, ref: o, children: l }), e[83] = k, e[84] = l, e[85] = de, e[86] = x) : x = e[86];
let H;
e[87] !== u || e[88] !== re || e[89] !== W || e[90] !== x ? (H = /* @__PURE__ */ ge("span", { className: re, children: [
u,
W,
x
] }), e[87] = u, e[88] = re, e[89] = W, e[90] = x, e[91] = H) : H = e[91];
let te;
return e[92] !== le || e[93] !== y || e[94] !== D || e[95] !== N || e[96] !== H ? (te = /* @__PURE__ */ ge("label", { className: le, children: [
y,
D,
N,
H
] }), e[92] = le, e[93] = y, e[94] = D, e[95] = N, e[96] = H, e[97] = te) : te = e[97], te;
});
Pe.displayName = "DSRadio";
export {
Pe as DSRadio
};