@purpurds/toggle 5.25.0 → 5.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/LICENSE.txt +4 -4
- package/dist/toggle.cjs.js +5 -5
- package/dist/toggle.cjs.js.map +1 -1
- package/dist/toggle.es.js +104 -113
- package/dist/toggle.es.js.map +1 -1
- package/package.json +5 -5
package/dist/toggle.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsx as x, jsxs as
|
|
2
|
-
import { forwardRef as w, Children as y, isValidElement as
|
|
1
|
+
import { jsx as x, jsxs as Z } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as w, Children as y, isValidElement as P, createElement as _, Fragment as K, cloneElement as R, useEffect as D, useCallback as B, useMemo as H, createContext as G, useContext as fe, useRef as O, useState as $, useLayoutEffect as Q } from "react";
|
|
3
3
|
import "react-dom";
|
|
4
4
|
function ge(e) {
|
|
5
5
|
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
@@ -98,35 +98,35 @@ function E() {
|
|
|
98
98
|
function Se(e, n) {
|
|
99
99
|
typeof e == "function" ? e(n) : e != null && (e.current = n);
|
|
100
100
|
}
|
|
101
|
-
function
|
|
101
|
+
function ke(...e) {
|
|
102
102
|
return (n) => e.forEach(
|
|
103
103
|
(t) => Se(t, n)
|
|
104
104
|
);
|
|
105
105
|
}
|
|
106
106
|
const te = /* @__PURE__ */ w((e, n) => {
|
|
107
|
-
const { children: t, ...a } = e, c = y.toArray(t), r = c.find(
|
|
107
|
+
const { children: t, ...a } = e, c = y.toArray(t), r = c.find(Ce);
|
|
108
108
|
if (r) {
|
|
109
|
-
const o = r.props.children, u = c.map((i) => i === r ? y.count(o) > 1 ? y.only(null) : /* @__PURE__ */
|
|
110
|
-
return /* @__PURE__ */ _(
|
|
109
|
+
const o = r.props.children, u = c.map((i) => i === r ? y.count(o) > 1 ? y.only(null) : /* @__PURE__ */ P(o) ? o.props.children : null : i);
|
|
110
|
+
return /* @__PURE__ */ _(W, E({}, a, {
|
|
111
111
|
ref: n
|
|
112
|
-
}), /* @__PURE__ */
|
|
112
|
+
}), /* @__PURE__ */ P(o) ? /* @__PURE__ */ R(o, void 0, u) : null);
|
|
113
113
|
}
|
|
114
|
-
return /* @__PURE__ */ _(
|
|
114
|
+
return /* @__PURE__ */ _(W, E({}, a, {
|
|
115
115
|
ref: n
|
|
116
116
|
}), t);
|
|
117
117
|
});
|
|
118
118
|
te.displayName = "Slot";
|
|
119
|
-
const
|
|
119
|
+
const W = /* @__PURE__ */ w((e, n) => {
|
|
120
120
|
const { children: t, ...a } = e;
|
|
121
|
-
return /* @__PURE__ */
|
|
121
|
+
return /* @__PURE__ */ P(t) ? /* @__PURE__ */ R(t, {
|
|
122
122
|
...Ne(a, t.props),
|
|
123
|
-
ref: n ?
|
|
123
|
+
ref: n ? ke(n, t.ref) : t.ref
|
|
124
124
|
}) : y.count(t) > 1 ? y.only(null) : null;
|
|
125
125
|
});
|
|
126
|
-
|
|
127
|
-
const
|
|
128
|
-
function
|
|
129
|
-
return /* @__PURE__ */
|
|
126
|
+
W.displayName = "SlotClone";
|
|
127
|
+
const Pe = ({ children: e }) => /* @__PURE__ */ _(K, null, e);
|
|
128
|
+
function Ce(e) {
|
|
129
|
+
return /* @__PURE__ */ P(e) && e.type === Pe;
|
|
130
130
|
}
|
|
131
131
|
function Ne(e, n) {
|
|
132
132
|
const t = {
|
|
@@ -166,7 +166,7 @@ const De = [
|
|
|
166
166
|
"span",
|
|
167
167
|
"svg",
|
|
168
168
|
"ul"
|
|
169
|
-
],
|
|
169
|
+
], Oe = De.reduce((e, n) => {
|
|
170
170
|
const t = /* @__PURE__ */ w((a, c) => {
|
|
171
171
|
const { asChild: r, ...o } = a, u = r ? te : n;
|
|
172
172
|
return D(() => {
|
|
@@ -179,14 +179,14 @@ const De = [
|
|
|
179
179
|
...e,
|
|
180
180
|
[n]: t
|
|
181
181
|
};
|
|
182
|
-
}, {}), Ee = /* @__PURE__ */ w((e, n) => /* @__PURE__ */ _(
|
|
182
|
+
}, {}), Ee = /* @__PURE__ */ w((e, n) => /* @__PURE__ */ _(Oe.label, E({}, e, {
|
|
183
183
|
ref: n,
|
|
184
184
|
onMouseDown: (t) => {
|
|
185
185
|
var a;
|
|
186
186
|
(a = e.onMouseDown) === null || a === void 0 || a.call(e, t), !t.defaultPrevented && t.detail > 1 && t.preventDefault();
|
|
187
187
|
}
|
|
188
|
-
}))),
|
|
189
|
-
function
|
|
188
|
+
}))), Ae = Ee;
|
|
189
|
+
function je(e) {
|
|
190
190
|
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
191
191
|
}
|
|
192
192
|
var ne = { exports: {} };
|
|
@@ -226,11 +226,11 @@ var ne = { exports: {} };
|
|
|
226
226
|
})();
|
|
227
227
|
})(ne);
|
|
228
228
|
var Me = ne.exports;
|
|
229
|
-
const
|
|
229
|
+
const Xe = /* @__PURE__ */ je(Me), T = {
|
|
230
230
|
"purpur-label": "_purpur-label_12cfi_1",
|
|
231
231
|
"purpur-label--negative": "_purpur-label--negative_12cfi_9",
|
|
232
232
|
"purpur-label--disabled": "_purpur-label--disabled_12cfi_12"
|
|
233
|
-
},
|
|
233
|
+
}, q = "purpur-label", He = ({
|
|
234
234
|
children: e,
|
|
235
235
|
className: n,
|
|
236
236
|
htmlFor: t,
|
|
@@ -239,17 +239,17 @@ const je = /* @__PURE__ */ Re(Me), z = {
|
|
|
239
239
|
negative: r = !1,
|
|
240
240
|
...o
|
|
241
241
|
}) => {
|
|
242
|
-
const u =
|
|
242
|
+
const u = Xe([
|
|
243
243
|
n,
|
|
244
|
-
|
|
244
|
+
T[q],
|
|
245
245
|
{
|
|
246
|
-
[
|
|
247
|
-
[
|
|
246
|
+
[T[`${q}--disabled`]]: c,
|
|
247
|
+
[T[`${q}--negative`]]: r
|
|
248
248
|
}
|
|
249
249
|
]);
|
|
250
|
-
return /* @__PURE__ */ x(
|
|
250
|
+
return /* @__PURE__ */ x(Ae, { className: u, "data-testid": a, htmlFor: t, ...o, children: e });
|
|
251
251
|
};
|
|
252
|
-
function
|
|
252
|
+
function Re(e) {
|
|
253
253
|
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
254
254
|
}
|
|
255
255
|
var oe = { exports: {} };
|
|
@@ -288,8 +288,8 @@ var oe = { exports: {} };
|
|
|
288
288
|
e.exports ? (t.default = t, e.exports = t) : window.classNames = t;
|
|
289
289
|
})();
|
|
290
290
|
})(oe);
|
|
291
|
-
var
|
|
292
|
-
const
|
|
291
|
+
var Be = oe.exports;
|
|
292
|
+
const Le = /* @__PURE__ */ Re(Be), M = {
|
|
293
293
|
"purpur-paragraph": "_purpur-paragraph_1rh57_1",
|
|
294
294
|
"purpur-paragraph--disabled": "_purpur-paragraph--disabled_1rh57_7",
|
|
295
295
|
"purpur-paragraph--hyphens": "_purpur-paragraph--hyphens_1rh57_10",
|
|
@@ -304,35 +304,26 @@ const Be = /* @__PURE__ */ Le(Xe), M = {
|
|
|
304
304
|
"purpur-paragraph--additional-100-medium": "_purpur-paragraph--additional-100-medium_1rh57_60",
|
|
305
305
|
"purpur-paragraph--overline-100": "_purpur-paragraph--overline-100_1rh57_67",
|
|
306
306
|
"purpur-paragraph--overline-200": "_purpur-paragraph--overline-200_1rh57_75"
|
|
307
|
-
},
|
|
308
|
-
PARAGRAPH100: "paragraph-100"
|
|
309
|
-
|
|
310
|
-
PARAGRAPH100BOLD: "paragraph-100-bold",
|
|
311
|
-
PARAGRAPH200: "paragraph-200",
|
|
312
|
-
PREAMBLE100: "preamble-100",
|
|
313
|
-
PREAMBLE200: "preamble-200",
|
|
314
|
-
ADDITIONAL100: "additional-100",
|
|
315
|
-
ADDITIONAL100MEDIUM: "additional-100-medium",
|
|
316
|
-
OVERLINE100: "overline-100",
|
|
317
|
-
OVERLINE200: "overline-200"
|
|
318
|
-
}, j = "purpur-paragraph", ae = ({
|
|
307
|
+
}, ze = {
|
|
308
|
+
PARAGRAPH100: "paragraph-100"
|
|
309
|
+
}, X = "purpur-paragraph", ae = ({
|
|
319
310
|
["data-testid"]: e,
|
|
320
311
|
children: n,
|
|
321
312
|
className: t,
|
|
322
313
|
disabled: a,
|
|
323
314
|
enableHyphenation: c = !1,
|
|
324
315
|
negative: r = !1,
|
|
325
|
-
variant: o =
|
|
316
|
+
variant: o = ze.PARAGRAPH100,
|
|
326
317
|
...u
|
|
327
318
|
}) => {
|
|
328
|
-
const i =
|
|
319
|
+
const i = Le([
|
|
329
320
|
t,
|
|
330
|
-
M[
|
|
331
|
-
M[`${
|
|
321
|
+
M[X],
|
|
322
|
+
M[`${X}--${o}`],
|
|
332
323
|
{
|
|
333
|
-
[M[`${
|
|
334
|
-
[M[`${
|
|
335
|
-
[M[`${
|
|
324
|
+
[M[`${X}--hyphens`]]: c,
|
|
325
|
+
[M[`${X}--disabled`]]: a,
|
|
326
|
+
[M[`${X}--negative`]]: r
|
|
336
327
|
}
|
|
337
328
|
]);
|
|
338
329
|
return /* @__PURE__ */ x("p", { ...u, className: i, "data-testid": e, children: n });
|
|
@@ -347,26 +338,26 @@ function N() {
|
|
|
347
338
|
return e;
|
|
348
339
|
}, N.apply(null, arguments);
|
|
349
340
|
}
|
|
350
|
-
function
|
|
341
|
+
function Te(e, n, { checkForDefaultPrevented: t = !0 } = {}) {
|
|
351
342
|
return function(c) {
|
|
352
343
|
if (e == null || e(c), t === !1 || !c.defaultPrevented) return n == null ? void 0 : n(c);
|
|
353
344
|
};
|
|
354
345
|
}
|
|
355
|
-
function
|
|
346
|
+
function qe(e, n) {
|
|
356
347
|
typeof e == "function" ? e(n) : e != null && (e.current = n);
|
|
357
348
|
}
|
|
358
349
|
function ce(...e) {
|
|
359
350
|
return (n) => e.forEach(
|
|
360
|
-
(t) =>
|
|
351
|
+
(t) => qe(t, n)
|
|
361
352
|
);
|
|
362
353
|
}
|
|
363
|
-
function
|
|
364
|
-
return
|
|
354
|
+
function Fe(...e) {
|
|
355
|
+
return B(ce(...e), e);
|
|
365
356
|
}
|
|
366
|
-
function
|
|
357
|
+
function We(e, n = []) {
|
|
367
358
|
let t = [];
|
|
368
359
|
function a(r, o) {
|
|
369
|
-
const u = /* @__PURE__ */
|
|
360
|
+
const u = /* @__PURE__ */ G(o), i = t.length;
|
|
370
361
|
t = [
|
|
371
362
|
...t,
|
|
372
363
|
o
|
|
@@ -392,7 +383,7 @@ function Fe(e, n = []) {
|
|
|
392
383
|
];
|
|
393
384
|
}
|
|
394
385
|
const c = () => {
|
|
395
|
-
const r = t.map((o) => /* @__PURE__ */
|
|
386
|
+
const r = t.map((o) => /* @__PURE__ */ G(o));
|
|
396
387
|
return function(u) {
|
|
397
388
|
const i = (u == null ? void 0 : u[e]) || r;
|
|
398
389
|
return H(
|
|
@@ -411,10 +402,10 @@ function Fe(e, n = []) {
|
|
|
411
402
|
};
|
|
412
403
|
return c.scopeName = e, [
|
|
413
404
|
a,
|
|
414
|
-
|
|
405
|
+
Ie(c, ...n)
|
|
415
406
|
];
|
|
416
407
|
}
|
|
417
|
-
function
|
|
408
|
+
function Ie(...e) {
|
|
418
409
|
const n = e[0];
|
|
419
410
|
if (e.length === 1) return n;
|
|
420
411
|
const t = () => {
|
|
@@ -445,7 +436,7 @@ function Ue(...e) {
|
|
|
445
436
|
return t.scopeName = n.scopeName, t;
|
|
446
437
|
}
|
|
447
438
|
function ue(e) {
|
|
448
|
-
const n =
|
|
439
|
+
const n = O(e);
|
|
449
440
|
return D(() => {
|
|
450
441
|
n.current = e;
|
|
451
442
|
}), H(
|
|
@@ -456,12 +447,12 @@ function ue(e) {
|
|
|
456
447
|
[]
|
|
457
448
|
);
|
|
458
449
|
}
|
|
459
|
-
function
|
|
450
|
+
function Ue({ prop: e, defaultProp: n, onChange: t = () => {
|
|
460
451
|
} }) {
|
|
461
|
-
const [a, c] =
|
|
452
|
+
const [a, c] = Ve({
|
|
462
453
|
defaultProp: n,
|
|
463
454
|
onChange: t
|
|
464
|
-
}), r = e !== void 0, o = r ? e : a, u = ue(t), i =
|
|
455
|
+
}), r = e !== void 0, o = r ? e : a, u = ue(t), i = B((s) => {
|
|
465
456
|
if (r) {
|
|
466
457
|
const l = typeof s == "function" ? s(e) : s;
|
|
467
458
|
l !== e && u(l);
|
|
@@ -477,8 +468,8 @@ function Ve({ prop: e, defaultProp: n, onChange: t = () => {
|
|
|
477
468
|
i
|
|
478
469
|
];
|
|
479
470
|
}
|
|
480
|
-
function
|
|
481
|
-
const t = $(e), [a] = t, c =
|
|
471
|
+
function Ve({ defaultProp: e, onChange: n }) {
|
|
472
|
+
const t = $(e), [a] = t, c = O(a), r = ue(n);
|
|
482
473
|
return D(() => {
|
|
483
474
|
c.current !== a && (r(a), c.current = a);
|
|
484
475
|
}, [
|
|
@@ -487,8 +478,8 @@ function We({ defaultProp: e, onChange: n }) {
|
|
|
487
478
|
r
|
|
488
479
|
]), t;
|
|
489
480
|
}
|
|
490
|
-
function
|
|
491
|
-
const n =
|
|
481
|
+
function Ze(e) {
|
|
482
|
+
const n = O({
|
|
492
483
|
value: e,
|
|
493
484
|
previous: e
|
|
494
485
|
});
|
|
@@ -496,11 +487,11 @@ function Ge(e) {
|
|
|
496
487
|
e
|
|
497
488
|
]);
|
|
498
489
|
}
|
|
499
|
-
const
|
|
490
|
+
const Ge = globalThis != null && globalThis.document ? Q : () => {
|
|
500
491
|
};
|
|
501
492
|
function Je(e) {
|
|
502
493
|
const [n, t] = $(void 0);
|
|
503
|
-
return
|
|
494
|
+
return Ge(() => {
|
|
504
495
|
if (e) {
|
|
505
496
|
t({
|
|
506
497
|
width: e.offsetWidth,
|
|
@@ -532,27 +523,27 @@ function Je(e) {
|
|
|
532
523
|
const ie = /* @__PURE__ */ w((e, n) => {
|
|
533
524
|
const { children: t, ...a } = e, c = y.toArray(t), r = c.find(Ke);
|
|
534
525
|
if (r) {
|
|
535
|
-
const o = r.props.children, u = c.map((i) => i === r ? y.count(o) > 1 ? y.only(null) : /* @__PURE__ */
|
|
536
|
-
return /* @__PURE__ */ _(
|
|
526
|
+
const o = r.props.children, u = c.map((i) => i === r ? y.count(o) > 1 ? y.only(null) : /* @__PURE__ */ P(o) ? o.props.children : null : i);
|
|
527
|
+
return /* @__PURE__ */ _(I, N({}, a, {
|
|
537
528
|
ref: n
|
|
538
|
-
}), /* @__PURE__ */
|
|
529
|
+
}), /* @__PURE__ */ P(o) ? /* @__PURE__ */ R(o, void 0, u) : null);
|
|
539
530
|
}
|
|
540
|
-
return /* @__PURE__ */ _(
|
|
531
|
+
return /* @__PURE__ */ _(I, N({}, a, {
|
|
541
532
|
ref: n
|
|
542
533
|
}), t);
|
|
543
534
|
});
|
|
544
535
|
ie.displayName = "Slot";
|
|
545
|
-
const
|
|
536
|
+
const I = /* @__PURE__ */ w((e, n) => {
|
|
546
537
|
const { children: t, ...a } = e;
|
|
547
|
-
return /* @__PURE__ */
|
|
538
|
+
return /* @__PURE__ */ P(t) ? /* @__PURE__ */ R(t, {
|
|
548
539
|
...Qe(a, t.props),
|
|
549
540
|
ref: n ? ce(n, t.ref) : t.ref
|
|
550
541
|
}) : y.count(t) > 1 ? y.only(null) : null;
|
|
551
542
|
});
|
|
552
|
-
|
|
543
|
+
I.displayName = "SlotClone";
|
|
553
544
|
const Ye = ({ children: e }) => /* @__PURE__ */ _(K, null, e);
|
|
554
545
|
function Ke(e) {
|
|
555
|
-
return /* @__PURE__ */
|
|
546
|
+
return /* @__PURE__ */ P(e) && e.type === Ye;
|
|
556
547
|
}
|
|
557
548
|
function Qe(e, n) {
|
|
558
549
|
const t = {
|
|
@@ -605,11 +596,11 @@ const er = [
|
|
|
605
596
|
...e,
|
|
606
597
|
[n]: t
|
|
607
598
|
};
|
|
608
|
-
}, {}), le = "Switch", [rr, mr] =
|
|
609
|
-
const { __scopeSwitch: t, name: a, checked: c, defaultChecked: r, required: o, disabled: u, value: i = "on", onCheckedChange: s, ...h } = e, [l, p] = $(null), v =
|
|
599
|
+
}, {}), le = "Switch", [rr, mr] = We(le), [tr, nr] = rr(le), or = /* @__PURE__ */ w((e, n) => {
|
|
600
|
+
const { __scopeSwitch: t, name: a, checked: c, defaultChecked: r, required: o, disabled: u, value: i = "on", onCheckedChange: s, ...h } = e, [l, p] = $(null), v = Fe(
|
|
610
601
|
n,
|
|
611
602
|
(m) => p(m)
|
|
612
|
-
), f =
|
|
603
|
+
), f = O(!1), g = l ? !!l.closest("form") : !0, [d = !1, b] = Ue({
|
|
613
604
|
prop: c,
|
|
614
605
|
defaultProp: r,
|
|
615
606
|
onChange: s
|
|
@@ -629,9 +620,9 @@ const er = [
|
|
|
629
620
|
value: i
|
|
630
621
|
}, h, {
|
|
631
622
|
ref: v,
|
|
632
|
-
onClick:
|
|
623
|
+
onClick: Te(e.onClick, (m) => {
|
|
633
624
|
b(
|
|
634
|
-
(
|
|
625
|
+
(C) => !C
|
|
635
626
|
), g && (f.current = m.isPropagationStopped(), f.current || m.stopPropagation());
|
|
636
627
|
})
|
|
637
628
|
})), g && /* @__PURE__ */ _(ur, {
|
|
@@ -655,7 +646,7 @@ const er = [
|
|
|
655
646
|
ref: n
|
|
656
647
|
}));
|
|
657
648
|
}), ur = (e) => {
|
|
658
|
-
const { control: n, checked: t, bubbles: a = !0, ...c } = e, r =
|
|
649
|
+
const { control: n, checked: t, bubbles: a = !0, ...c } = e, r = O(null), o = Ze(t), u = Je(n);
|
|
659
650
|
return D(() => {
|
|
660
651
|
const i = r.current, s = window.HTMLInputElement.prototype, l = Object.getOwnPropertyDescriptor(s, "checked").set;
|
|
661
652
|
if (o !== t && l) {
|
|
@@ -729,7 +720,7 @@ var de = { exports: {} };
|
|
|
729
720
|
})();
|
|
730
721
|
})(de);
|
|
731
722
|
var pr = de.exports;
|
|
732
|
-
const
|
|
723
|
+
const F = /* @__PURE__ */ lr(pr), S = {
|
|
733
724
|
"purpur-toggle": "_purpur-toggle_1xng6_1",
|
|
734
725
|
"purpur-toggle__track": "_purpur-toggle__track_1xng6_7",
|
|
735
726
|
"purpur-toggle__checkmark-container": "_purpur-toggle__checkmark-container_1xng6_45",
|
|
@@ -755,38 +746,38 @@ const q = /* @__PURE__ */ lr(pr), S = {
|
|
|
755
746
|
const m = Y(b.nativeEvent) ? b.nativeEvent.touches[0].clientX : b.nativeEvent.clientX;
|
|
756
747
|
l(m), t == null || t();
|
|
757
748
|
}
|
|
758
|
-
}, g =
|
|
749
|
+
}, g = B(
|
|
759
750
|
(b) => {
|
|
760
751
|
if (typeof h != "number")
|
|
761
752
|
return;
|
|
762
|
-
const
|
|
763
|
-
if (!
|
|
753
|
+
const C = (Y(b) ? b.touches[0].clientX : b.clientX) - h;
|
|
754
|
+
if (!C)
|
|
764
755
|
return;
|
|
765
|
-
const
|
|
766
|
-
!p && Math.abs(
|
|
767
|
-
const
|
|
768
|
-
s(
|
|
756
|
+
const A = o + C;
|
|
757
|
+
!p && Math.abs(A) && v(!0);
|
|
758
|
+
const L = A > r.right ? r.right : A < r.left ? r.left : A;
|
|
759
|
+
s(L), a == null || a({ x: L });
|
|
769
760
|
},
|
|
770
761
|
[a, s, p, h]
|
|
771
|
-
), d =
|
|
762
|
+
), d = B(() => {
|
|
772
763
|
l(void 0), s(void 0), v(!1), c == null || c();
|
|
773
764
|
}, [c, l]);
|
|
774
765
|
return D(() => (window.addEventListener("mousemove", g), window.addEventListener("touchmove", g), () => {
|
|
775
766
|
window.removeEventListener("mousemove", g), window.removeEventListener("touchmove", g);
|
|
776
767
|
}), [g]), D(() => (window.addEventListener("mouseup", d), window.addEventListener("touchend", d), () => {
|
|
777
768
|
window.removeEventListener("mouseup", d), window.removeEventListener("touchend", d);
|
|
778
|
-
}), [d]),
|
|
769
|
+
}), [d]), P(e) ? R(y.only(e), {
|
|
779
770
|
onMouseDown: f,
|
|
780
771
|
onTouchStart: f,
|
|
781
772
|
style: { ...u, transform: `translateX(${p ? i : o}px)` }
|
|
782
773
|
}) : null;
|
|
783
774
|
}, fr = ({ checked: e, onChange: n }) => {
|
|
784
|
-
var
|
|
785
|
-
const t =
|
|
775
|
+
var U, V;
|
|
776
|
+
const t = O(null), a = O(null), [c, r] = $(void 0), [o, u] = $(!1), [i, s] = $(0), [h, l] = $(0), [p, v] = $(0);
|
|
786
777
|
Q(() => {
|
|
787
|
-
var
|
|
788
|
-
l(((
|
|
789
|
-
}, [(
|
|
778
|
+
var j, z;
|
|
779
|
+
l(((j = a.current) == null ? void 0 : j.clientHeight) || 0), v(((z = t.current) == null ? void 0 : z.clientHeight) || 0);
|
|
780
|
+
}, [(U = a.current) == null ? void 0 : U.clientHeight, (V = t.current) == null ? void 0 : V.clientHeight]);
|
|
790
781
|
const f = (p || 0) - h, g = h + f, d = f / 2, b = g / 2, m = typeof c == "number" && (e ? c < b : c > b);
|
|
791
782
|
return {
|
|
792
783
|
trackRef: t,
|
|
@@ -794,8 +785,8 @@ const q = /* @__PURE__ */ lr(pr), S = {
|
|
|
794
785
|
isDragging: o,
|
|
795
786
|
bounds: { left: d, right: g },
|
|
796
787
|
position: e ? g : d,
|
|
797
|
-
onDrag: ({ x:
|
|
798
|
-
r(
|
|
788
|
+
onDrag: ({ x: j }) => {
|
|
789
|
+
r(j), Math.abs((e ? g : d) - j) > 2 && u(!0);
|
|
799
790
|
},
|
|
800
791
|
onStop: () => {
|
|
801
792
|
u(!1), o && s(Date.now()), m && (n == null || n(!e));
|
|
@@ -804,7 +795,7 @@ const q = /* @__PURE__ */ lr(pr), S = {
|
|
|
804
795
|
Date.now() - i > 50 && (n == null || n(!e)), r(void 0);
|
|
805
796
|
}
|
|
806
797
|
};
|
|
807
|
-
},
|
|
798
|
+
}, k = "purpur-toggle", gr = ({
|
|
808
799
|
["data-testid"]: e,
|
|
809
800
|
className: n,
|
|
810
801
|
label: t,
|
|
@@ -819,8 +810,8 @@ const q = /* @__PURE__ */ lr(pr), S = {
|
|
|
819
810
|
typeof r == "boolean" ? r : !!u
|
|
820
811
|
), p = !!(typeof r == "boolean" ? r : h), { thumbRef: v, trackRef: f, isDragging: g, onChangeWithDrag: d, ...b } = fr({
|
|
821
812
|
checked: p,
|
|
822
|
-
onChange: (
|
|
823
|
-
i.disabled || (a == null || a(
|
|
813
|
+
onChange: (C) => {
|
|
814
|
+
i.disabled || (a == null || a(C), l(C));
|
|
824
815
|
}
|
|
825
816
|
}), m = () => /* @__PURE__ */ x(
|
|
826
817
|
He,
|
|
@@ -828,14 +819,14 @@ const q = /* @__PURE__ */ lr(pr), S = {
|
|
|
828
819
|
htmlFor: i.id,
|
|
829
820
|
"data-testid": e && `${e}-label`,
|
|
830
821
|
disabled: i.disabled,
|
|
831
|
-
className:
|
|
832
|
-
S[`${
|
|
833
|
-
S[`${
|
|
822
|
+
className: F(
|
|
823
|
+
S[`${k}__label`],
|
|
824
|
+
S[`${k}__label--${c}`]
|
|
834
825
|
),
|
|
835
826
|
children: /* @__PURE__ */ x(ae, { variant: "paragraph-100", disabled: i.disabled, children: t })
|
|
836
827
|
}
|
|
837
828
|
);
|
|
838
|
-
return /* @__PURE__ */
|
|
829
|
+
return /* @__PURE__ */ Z("div", { className: F([n, S[`${k}__container`]]), children: [
|
|
839
830
|
t && c === "left" && m(),
|
|
840
831
|
/* @__PURE__ */ x(
|
|
841
832
|
ir,
|
|
@@ -844,14 +835,14 @@ const q = /* @__PURE__ */ lr(pr), S = {
|
|
|
844
835
|
ref: s,
|
|
845
836
|
id: i.id,
|
|
846
837
|
"data-testid": e,
|
|
847
|
-
className: S[
|
|
838
|
+
className: S[k],
|
|
848
839
|
onCheckedChange: d,
|
|
849
840
|
checked: p,
|
|
850
|
-
children: /* @__PURE__ */
|
|
851
|
-
/* @__PURE__ */ x("span", { className: S[`${
|
|
841
|
+
children: /* @__PURE__ */ Z("span", { ref: f, className: S[`${k}__track`], children: [
|
|
842
|
+
/* @__PURE__ */ x("span", { className: S[`${k}__checkmark-container`], children: /* @__PURE__ */ x(
|
|
852
843
|
re,
|
|
853
844
|
{
|
|
854
|
-
className: S[`${
|
|
845
|
+
className: S[`${k}__checkmark`],
|
|
855
846
|
svg: ve,
|
|
856
847
|
size: "xxs"
|
|
857
848
|
}
|
|
@@ -861,10 +852,10 @@ const q = /* @__PURE__ */ lr(pr), S = {
|
|
|
861
852
|
{
|
|
862
853
|
ref: v,
|
|
863
854
|
"data-testid": e && `${e}-thumb`,
|
|
864
|
-
className:
|
|
865
|
-
S[`${
|
|
855
|
+
className: F([
|
|
856
|
+
S[`${k}__thumb`],
|
|
866
857
|
{
|
|
867
|
-
[S[`${
|
|
858
|
+
[S[`${k}__thumb--dragging`]]: g
|
|
868
859
|
}
|
|
869
860
|
])
|
|
870
861
|
}
|