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 h } from "react/jsx-runtime"; import { d as $ } from "./chunks/index.CgTHIF3K.js"; import { c as q } from "./chunks/index.CEyLAtio.js"; import { forwardRef as z } from "react"; import { D as A } from "./chunks/Icon.NSsVrYeq.js"; import { DSSpinner as B } from "./spinner.BUjhjAvw.js"; import './assets/switch.Bc9KIyw9.css';const F = "ds-switch_root_gdcld_1", G = "ds-switch_root--label-right_gdcld_40", H = "ds-switch_root--stretched_gdcld_43", J = "ds-switch_loader_gdcld_53", K = "ds-switch_thumb_gdcld_111", M = "ds-switch_root--checked_gdcld_126", o = { root: F, rootLabelRight: G, rootStretched: H, switch: "ds-switch_switch_gdcld_48", loader: J, thumb: K, rootChecked: M }, P = z((C, N) => { const t = $.c(38); let c, l, i, s, r, m, f, _, b, g; t[0] !== C ? ({ children: l, aria: c, alignLabel: m, checked: f, className: i, disabled: _, loading: b, stretched: g, 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] = g) : (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], g = t[10]); const E = m === void 0 ? "left" : m, p = f === void 0 ? !1 : f, u = _ === void 0 ? !1 : _, e = b === void 0 ? !1 : b, I = g === void 0 ? !1 : g, D = p === !0, L = I === !0, v = E === "right"; let w; t[11] !== i || t[12] !== D || t[13] !== L || t[14] !== v ? (w = 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] = w) : w = t[15]; const x = w; let k; t[16] !== u || t[17] !== e || t[18] !== s ? (k = (j) => { if (u || e) { j.preventDefault(); return; } s && s(j); }, t[16] = u, t[17] = e, t[18] = s, t[19] = k) : k = t[19]; const y = k, R = u || e; let a; t[20] !== l ? (a = /* @__PURE__ */ h("span", { children: l }), t[20] = l, t[21] = a) : a = t[21]; let d; t[22] !== e ? (d = !e && /* @__PURE__ */ h("span", { className: o.switch, children: /* @__PURE__ */ h("span", { className: o.thumb, children: /* @__PURE__ */ h(A, { name: "check", "aria-hidden": "true" }) }) }), t[22] = e, t[23] = d) : d = t[23]; let n; t[24] !== e ? (n = e && /* @__PURE__ */ h("span", { className: o.loader, children: /* @__PURE__ */ h(B, { aria: { "aria-label": "Loading state" } }) }), t[24] = e, t[25] = n) : n = t[25]; let S; return t[26] !== c || t[27] !== p || 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] !== n ? (S = /* @__PURE__ */ O("button", { className: x, onClick: y, ...c, ...r, type: "button", role: "switch", "aria-checked": p, "aria-disabled": R, "aria-busy": e, ref: N, children: [ a, d, n ] }), t[26] = c, t[27] = p, 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] = n, t[37] = S) : S = t[37], S; }); P.displayName = "DSSwitch"; export { P as DSSwitch };