UNPKG

@stihl-design-system/components

Version:

Welcome to the STIHL Design System react component library.

67 lines (66 loc) 3.07 kB
"use client"; import { jsxs as O, jsx as n } from "react/jsx-runtime"; import { d as $ } from "./chunks/index.cKLI89Eg.js"; import { c as q } from "./chunks/index.DQOqod3i.js"; import { forwardRef as z } from "react"; import { D as A } from "./chunks/Icon.DYtaQgbw.js"; import { DSSpinner as B } from "./spinner.DtLnsqVV.js"; import './assets/switch.8v7Wp1Fj.css';const F = "ds-switch_root_1c6he_1", G = "ds-switch_root--label-right_1c6he_40", H = "ds-switch_root--stretched_1c6he_43", J = "ds-switch_loader_1c6he_53", K = "ds-switch_thumb_1c6he_111", M = "ds-switch_root--checked_1c6he_126", o = { root: F, rootLabelRight: G, rootStretched: H, switch: "ds-switch_switch_1c6he_48", loader: J, thumb: K, rootChecked: M }, P = z((C, N) => { const t = $.c(38); let c, l, i, s, r, m, f, _, b, p; t[0] !== C ? ({ children: l, aria: c, alignLabel: m, checked: f, className: i, disabled: _, loading: b, stretched: p, onClick: s, ...r } = C, t[0] = C, t[1] = c, t[2] = l, t[3] = i, t[4] = s, t[5] = r, t[6] = m, t[7] = f, t[8] = _, t[9] = b, t[10] = p) : (c = t[1], l = t[2], i = t[3], s = t[4], r = t[5], m = t[6], f = t[7], _ = t[8], b = t[9], p = t[10]); const E = m === void 0 ? "left" : m, u = f === void 0 ? !1 : f, w = _ === void 0 ? !1 : _, e = b === void 0 ? !1 : b, I = p === void 0 ? !1 : p, D = u === !0, L = I === !0, v = E === "right"; let k; t[11] !== i || t[12] !== D || t[13] !== L || t[14] !== v ? (k = q(o.root, i, { [o.rootChecked]: D, [o.rootStretched]: L, [o.rootLabelRight]: v }), t[11] = i, t[12] = D, t[13] = L, t[14] = v, t[15] = k) : k = t[15]; const x = k; let g; t[16] !== w || t[17] !== e || t[18] !== s ? (g = (j) => { if (w || e) { j.preventDefault(); return; } s && s(j); }, t[16] = w, t[17] = e, t[18] = s, t[19] = g) : g = t[19]; const y = g, R = w || e; let a; t[20] !== l ? (a = /* @__PURE__ */ n("span", { children: l }), t[20] = l, t[21] = a) : a = t[21]; let d; t[22] !== e ? (d = !e && /* @__PURE__ */ n("span", { className: o.switch, children: /* @__PURE__ */ n("span", { className: o.thumb, children: /* @__PURE__ */ n(A, { name: "check", "aria-hidden": "true" }) }) }), t[22] = e, t[23] = d) : d = t[23]; let h; t[24] !== e ? (h = e && /* @__PURE__ */ n("span", { className: o.loader, children: /* @__PURE__ */ n(B, { aria: { "aria-label": "Loading state" } }) }), t[24] = e, t[25] = h) : h = t[25]; let S; return t[26] !== c || t[27] !== u || t[28] !== y || t[29] !== e || t[30] !== N || t[31] !== r || t[32] !== x || t[33] !== R || t[34] !== a || t[35] !== d || t[36] !== h ? (S = /* @__PURE__ */ O("button", { className: x, onClick: y, ...c, ...r, type: "button", role: "switch", "aria-checked": u, "aria-disabled": R, "aria-busy": e, ref: N, children: [ a, d, h ] }), t[26] = c, t[27] = u, t[28] = y, t[29] = e, t[30] = N, t[31] = r, t[32] = x, t[33] = R, t[34] = a, t[35] = d, t[36] = h, t[37] = S) : S = t[37], S; }); P.displayName = "DSSwitch"; export { P as DSSwitch };