UNPKG

@transkripid/flowbite-react

Version:

Official React components built for Flowbite and Tailwind CSS - Transkrip.id fork

63 lines (62 loc) 3.92 kB
import { jsx as A, jsxs as B, Fragment as L } from "react/jsx-runtime"; import { c as P } from "react/compiler-runtime"; import { forwardRef as Q, useId as U } from "react"; import { twMerge as G } from "tailwind-merge"; import { mergeDeep as V } from "../../helpers/merge-deep.mjs"; import { getTheme as W } from "../../theme-store/index.mjs"; const X = Q((r, S) => { const e = P(72); let t, d, n, o, i, s, m, j, I, a; e[0] !== r ? ({ checked: t, className: d, color: j, sizing: I, disabled: n, label: o, name: i, onChange: s, theme: a, ...m } = r, e[0] = r, e[1] = t, e[2] = d, e[3] = n, e[4] = o, e[5] = i, e[6] = s, e[7] = m, e[8] = j, e[9] = I, e[10] = a) : (t = e[1], d = e[2], n = e[3], o = e[4], i = e[5], s = e[6], m = e[7], j = e[8], I = e[9], a = e[10]); const M = j === void 0 ? "blue" : j, R = I === void 0 ? "md" : I; let K; e[11] !== a ? (K = a === void 0 ? {} : a, e[11] = a, e[12] = K) : K = e[12]; const _ = K, g = U(); let f, h, b, w, p, u, y, k, c, N, v, x, D, T, l; if (e[13] !== t || e[14] !== d || e[15] !== M || e[16] !== _ || e[17] !== n || e[18] !== g || e[19] !== i || e[20] !== s || e[21] !== m || e[22] !== S || e[23] !== R) { l = V(W().toggleSwitch, _); let E; e[39] !== t || e[40] !== s ? (E = () => s(!t), e[39] = t, e[40] = s, e[41] = E) : E = e[41]; const q = E; let F; e[42] !== q ? (F = () => { q(); }, e[42] = q, e[43] = F) : F = e[43]; const H = F, J = Y; e[44] !== t || e[45] !== i || e[46] !== S ? (c = i && t ? /* @__PURE__ */ A("input", { ref: S, checked: t, hidden: !0, name: i, readOnly: !0, type: "checkbox", className: "sr-only" }) : null, e[44] = t, e[45] = i, e[46] = S, e[47] = c) : c = e[47], x = t, D = `${g}-flowbite-toggleswitch-label`, T = n, f = `${g}-flowbite-toggleswitch`, h = H, b = J, w = "switch", p = 0, u = "button", y = G(l.root.base, l.root.active[n ? "off" : "on"], d), k = m, N = "flowbite-toggleswitch-toggle", v = G(l.toggle.base, l.toggle.checked[t ? "on" : "off"], t && l.toggle.checked.color[M], l.toggle.sizes[R]), e[13] = t, e[14] = d, e[15] = M, e[16] = _, e[17] = n, e[18] = g, e[19] = i, e[20] = s, e[21] = m, e[22] = S, e[23] = R, e[24] = f, e[25] = h, e[26] = b, e[27] = w, e[28] = p, e[29] = u, e[30] = y, e[31] = k, e[32] = c, e[33] = N, e[34] = v, e[35] = x, e[36] = D, e[37] = T, e[38] = l; } else f = e[24], h = e[25], b = e[26], w = e[27], p = e[28], u = e[29], y = e[30], k = e[31], c = e[32], N = e[33], v = e[34], x = e[35], D = e[36], T = e[37], l = e[38]; let $; e[48] !== N || e[49] !== v ? ($ = /* @__PURE__ */ A("div", { "data-testid": N, className: v }), e[48] = N, e[49] = v, e[50] = $) : $ = e[50]; let z; e[51] !== g || e[52] !== o || e[53] !== l ? (z = o != null && o.length ? /* @__PURE__ */ A("span", { "data-testid": "flowbite-toggleswitch-label", id: `${g}-flowbite-toggleswitch-label`, className: l.root.label, children: o }) : null, e[51] = g, e[52] = o, e[53] = l, e[54] = z) : z = e[54]; let C; e[55] !== f || e[56] !== h || e[57] !== b || e[58] !== w || e[59] !== p || e[60] !== u || e[61] !== y || e[62] !== k || e[63] !== $ || e[64] !== z || e[65] !== x || e[66] !== D || e[67] !== T ? (C = /* @__PURE__ */ B("button", { "aria-checked": x, "aria-labelledby": D, disabled: T, id: f, onClick: h, onKeyDown: b, role: w, tabIndex: p, type: u, className: y, ...k, children: [ $, z ] }), e[55] = f, e[56] = h, e[57] = b, e[58] = w, e[59] = p, e[60] = u, e[61] = y, e[62] = k, e[63] = $, e[64] = z, e[65] = x, e[66] = D, e[67] = T, e[68] = C) : C = e[68]; let O; return e[69] !== c || e[70] !== C ? (O = /* @__PURE__ */ B(L, { children: [ c, C ] }), e[69] = c, e[70] = C, e[71] = O) : O = e[71], O; }); X.displayName = "ToggleSwitch"; function Y(r) { r.code == "Enter" && r.preventDefault(); } export { X as ToggleSwitch }; //# sourceMappingURL=ToggleSwitch.mjs.map