@purpurds/toggle 4.1.1 → 4.2.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 +3 -3
- package/dist/toggle.cjs.js +5 -5
- package/dist/toggle.cjs.js.map +1 -1
- package/dist/toggle.es.js +109 -106
- 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
|
|
2
|
-
import { forwardRef as
|
|
1
|
+
import { jsx as x, jsxs as G } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as w, Children as y, isValidElement as k, createElement as _, cloneElement as L, useEffect as A, Fragment as ee, useCallback as X, createContext as Z, useMemo as R, useContext as fe, useRef as D, useState as $, useLayoutEffect as te } 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;
|
|
@@ -54,7 +54,7 @@ const be = /* @__PURE__ */ ge(he), _e = {
|
|
|
54
54
|
svg: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path fill-rule="evenodd" d="M21.243 4.176a2 2 0 0 1 .324 2.81l-10.45 13.176a2.092 2.092 0 0 1-3.118.18l-5.413-5.413A2 2 0 1 1 5.414 12.1l3.9 3.9 9.118-11.5a2 2 0 0 1 2.81-.324Z" clip-rule="evenodd"/></svg>',
|
|
55
55
|
keywords: ["checkmark-bold"],
|
|
56
56
|
category: "utility"
|
|
57
|
-
}, me = be.bind(_e), J = "purpur-icon", $e = "md", ye = (e) => e.filter((n) => Object.keys(n).length >= 1).map((n) => `${n.name}="${n.value}"`).join(" "),
|
|
57
|
+
}, me = be.bind(_e), J = "purpur-icon", $e = "md", ye = (e) => e.filter((n) => Object.keys(n).length >= 1).map((n) => `${n.name}="${n.value}"`).join(" "), xe = ({ content: e = "", title: n } = {}) => {
|
|
58
58
|
const r = [
|
|
59
59
|
{ name: "xmlns", value: "http://www.w3.org/2000/svg" },
|
|
60
60
|
{ name: "fill", value: "currentColor" },
|
|
@@ -62,7 +62,7 @@ const be = /* @__PURE__ */ ge(he), _e = {
|
|
|
62
62
|
n ? { name: "role", value: "img" } : { name: "aria-hidden", value: "true" }
|
|
63
63
|
], o = n ? `<title>${n}</title>` : "";
|
|
64
64
|
return `<svg ${ye(r)}>${o}${e}</svg>`;
|
|
65
|
-
},
|
|
65
|
+
}, we = (e) => e.replace(/<(\/?)svg([^>]*)>/g, "").trim(), Se = ({
|
|
66
66
|
["data-testid"]: e,
|
|
67
67
|
svg: n,
|
|
68
68
|
allyTitle: r,
|
|
@@ -70,11 +70,11 @@ const be = /* @__PURE__ */ ge(he), _e = {
|
|
|
70
70
|
size: c = $e,
|
|
71
71
|
...t
|
|
72
72
|
}) => {
|
|
73
|
-
const a =
|
|
74
|
-
content:
|
|
73
|
+
const a = xe({
|
|
74
|
+
content: we(n.svg),
|
|
75
75
|
title: r
|
|
76
76
|
}), u = me(o, J, `${J}--${c}`);
|
|
77
|
-
return /* @__PURE__ */
|
|
77
|
+
return /* @__PURE__ */ x(
|
|
78
78
|
"span",
|
|
79
79
|
{
|
|
80
80
|
"aria-label": r,
|
|
@@ -95,48 +95,48 @@ function q() {
|
|
|
95
95
|
return e;
|
|
96
96
|
}, q.apply(this, arguments);
|
|
97
97
|
}
|
|
98
|
-
function
|
|
99
|
-
return
|
|
98
|
+
function M() {
|
|
99
|
+
return M = Object.assign ? Object.assign.bind() : function(e) {
|
|
100
100
|
for (var n = 1; n < arguments.length; n++) {
|
|
101
101
|
var r = arguments[n];
|
|
102
102
|
for (var o in r)
|
|
103
103
|
Object.prototype.hasOwnProperty.call(r, o) && (e[o] = r[o]);
|
|
104
104
|
}
|
|
105
105
|
return e;
|
|
106
|
-
},
|
|
106
|
+
}, M.apply(this, arguments);
|
|
107
107
|
}
|
|
108
|
-
function
|
|
108
|
+
function Pe(e, n) {
|
|
109
109
|
typeof e == "function" ? e(n) : e != null && (e.current = n);
|
|
110
110
|
}
|
|
111
|
-
function
|
|
111
|
+
function ke(...e) {
|
|
112
112
|
return (n) => e.forEach(
|
|
113
|
-
(r) =>
|
|
113
|
+
(r) => Pe(r, n)
|
|
114
114
|
);
|
|
115
115
|
}
|
|
116
|
-
const ne = /* @__PURE__ */
|
|
116
|
+
const ne = /* @__PURE__ */ w((e, n) => {
|
|
117
117
|
const { children: r, ...o } = e, c = y.toArray(r), t = c.find(Ae);
|
|
118
118
|
if (t) {
|
|
119
|
-
const a = t.props.children, u = c.map((i) => i === t ? y.count(a) > 1 ? y.only(null) : /* @__PURE__ */
|
|
120
|
-
return /* @__PURE__ */ _(F,
|
|
119
|
+
const a = t.props.children, u = c.map((i) => i === t ? y.count(a) > 1 ? y.only(null) : /* @__PURE__ */ k(a) ? a.props.children : null : i);
|
|
120
|
+
return /* @__PURE__ */ _(F, M({}, o, {
|
|
121
121
|
ref: n
|
|
122
|
-
}), /* @__PURE__ */
|
|
122
|
+
}), /* @__PURE__ */ k(a) ? /* @__PURE__ */ L(a, void 0, u) : null);
|
|
123
123
|
}
|
|
124
|
-
return /* @__PURE__ */ _(F,
|
|
124
|
+
return /* @__PURE__ */ _(F, M({}, o, {
|
|
125
125
|
ref: n
|
|
126
126
|
}), r);
|
|
127
127
|
});
|
|
128
128
|
ne.displayName = "Slot";
|
|
129
|
-
const F = /* @__PURE__ */
|
|
129
|
+
const F = /* @__PURE__ */ w((e, n) => {
|
|
130
130
|
const { children: r, ...o } = e;
|
|
131
|
-
return /* @__PURE__ */
|
|
131
|
+
return /* @__PURE__ */ k(r) ? /* @__PURE__ */ L(r, {
|
|
132
132
|
...De(o, r.props),
|
|
133
|
-
ref: n ?
|
|
133
|
+
ref: n ? ke(n, r.ref) : r.ref
|
|
134
134
|
}) : y.count(r) > 1 ? y.only(null) : null;
|
|
135
135
|
});
|
|
136
136
|
F.displayName = "SlotClone";
|
|
137
137
|
const Oe = ({ children: e }) => /* @__PURE__ */ _(ee, null, e);
|
|
138
138
|
function Ae(e) {
|
|
139
|
-
return /* @__PURE__ */
|
|
139
|
+
return /* @__PURE__ */ k(e) && e.type === Oe;
|
|
140
140
|
}
|
|
141
141
|
function De(e, n) {
|
|
142
142
|
const r = {
|
|
@@ -177,11 +177,11 @@ const Ce = [
|
|
|
177
177
|
"svg",
|
|
178
178
|
"ul"
|
|
179
179
|
], Ne = Ce.reduce((e, n) => {
|
|
180
|
-
const r = /* @__PURE__ */
|
|
180
|
+
const r = /* @__PURE__ */ w((o, c) => {
|
|
181
181
|
const { asChild: t, ...a } = o, u = t ? ne : n;
|
|
182
182
|
return A(() => {
|
|
183
183
|
window[Symbol.for("radix-ui")] = !0;
|
|
184
|
-
}, []), /* @__PURE__ */ _(u,
|
|
184
|
+
}, []), /* @__PURE__ */ _(u, M({}, a, {
|
|
185
185
|
ref: c
|
|
186
186
|
}));
|
|
187
187
|
});
|
|
@@ -189,7 +189,7 @@ const Ce = [
|
|
|
189
189
|
...e,
|
|
190
190
|
[n]: r
|
|
191
191
|
};
|
|
192
|
-
}, {}), Ee = /* @__PURE__ */
|
|
192
|
+
}, {}), Ee = /* @__PURE__ */ w((e, n) => /* @__PURE__ */ _(Ne.label, q({}, e, {
|
|
193
193
|
ref: n,
|
|
194
194
|
onMouseDown: (r) => {
|
|
195
195
|
var o;
|
|
@@ -236,10 +236,10 @@ var oe = { exports: {} };
|
|
|
236
236
|
})();
|
|
237
237
|
})(oe);
|
|
238
238
|
var Me = oe.exports;
|
|
239
|
-
const
|
|
239
|
+
const ze = /* @__PURE__ */ Re(Me), K = {
|
|
240
240
|
"purpur-label": "_purpur-label_1jub8_1",
|
|
241
241
|
"purpur-label--disabled": "_purpur-label--disabled_1jub8_9"
|
|
242
|
-
}, Q = "purpur-label",
|
|
242
|
+
}, Q = "purpur-label", He = ({
|
|
243
243
|
children: e,
|
|
244
244
|
className: n,
|
|
245
245
|
htmlFor: r,
|
|
@@ -247,14 +247,14 @@ const He = /* @__PURE__ */ Re(Me), K = {
|
|
|
247
247
|
disabled: c,
|
|
248
248
|
...t
|
|
249
249
|
}) => {
|
|
250
|
-
const a =
|
|
250
|
+
const a = ze([
|
|
251
251
|
n,
|
|
252
252
|
K[Q],
|
|
253
253
|
{ [K[`${Q}--disabled`]]: c }
|
|
254
254
|
]);
|
|
255
|
-
return /* @__PURE__ */
|
|
255
|
+
return /* @__PURE__ */ x(je, { className: a, "data-testid": o, htmlFor: r, ...t, children: e });
|
|
256
256
|
};
|
|
257
|
-
function
|
|
257
|
+
function Le(e) {
|
|
258
258
|
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
259
259
|
}
|
|
260
260
|
var ae = { exports: {} };
|
|
@@ -293,22 +293,23 @@ var ae = { exports: {} };
|
|
|
293
293
|
e.exports ? (r.default = r, e.exports = r) : window.classNames = r;
|
|
294
294
|
})();
|
|
295
295
|
})(ae);
|
|
296
|
-
var
|
|
297
|
-
const
|
|
298
|
-
"purpur-paragraph": "_purpur-
|
|
299
|
-
"purpur-paragraph--disabled": "_purpur-paragraph--
|
|
300
|
-
"purpur-paragraph--hyphens": "_purpur-paragraph--
|
|
301
|
-
"purpur-paragraph--
|
|
302
|
-
"purpur-paragraph--paragraph-100
|
|
303
|
-
"purpur-paragraph--paragraph-100-
|
|
304
|
-
"purpur-paragraph--paragraph-
|
|
305
|
-
"purpur-paragraph--
|
|
306
|
-
"purpur-paragraph--preamble-
|
|
307
|
-
"purpur-paragraph--
|
|
308
|
-
"purpur-paragraph--additional-100
|
|
309
|
-
"purpur-paragraph--
|
|
310
|
-
"purpur-paragraph--overline-
|
|
311
|
-
|
|
296
|
+
var Xe = ae.exports;
|
|
297
|
+
const Be = /* @__PURE__ */ Le(Xe), E = {
|
|
298
|
+
"purpur-paragraph": "_purpur-paragraph_15yuz_1",
|
|
299
|
+
"purpur-paragraph--disabled": "_purpur-paragraph--disabled_15yuz_7",
|
|
300
|
+
"purpur-paragraph--hyphens": "_purpur-paragraph--hyphens_15yuz_10",
|
|
301
|
+
"purpur-paragraph--negative": "_purpur-paragraph--negative_15yuz_13",
|
|
302
|
+
"purpur-paragraph--paragraph-100": "_purpur-paragraph--paragraph-100_15yuz_16",
|
|
303
|
+
"purpur-paragraph--paragraph-100-medium": "_purpur-paragraph--paragraph-100-medium_15yuz_22",
|
|
304
|
+
"purpur-paragraph--paragraph-100-bold": "_purpur-paragraph--paragraph-100-bold_15yuz_29",
|
|
305
|
+
"purpur-paragraph--paragraph-200": "_purpur-paragraph--paragraph-200_15yuz_36",
|
|
306
|
+
"purpur-paragraph--preamble-100": "_purpur-paragraph--preamble-100_15yuz_42",
|
|
307
|
+
"purpur-paragraph--preamble-200": "_purpur-paragraph--preamble-200_15yuz_48",
|
|
308
|
+
"purpur-paragraph--additional-100": "_purpur-paragraph--additional-100_15yuz_54",
|
|
309
|
+
"purpur-paragraph--additional-100-medium": "_purpur-paragraph--additional-100-medium_15yuz_60",
|
|
310
|
+
"purpur-paragraph--overline-100": "_purpur-paragraph--overline-100_15yuz_67",
|
|
311
|
+
"purpur-paragraph--overline-200": "_purpur-paragraph--overline-200_15yuz_75"
|
|
312
|
+
}, Te = {
|
|
312
313
|
PARAGRAPH100: "paragraph-100",
|
|
313
314
|
PARAGRAPH100MEDIUM: "paragraph-100-medium",
|
|
314
315
|
PARAGRAPH100BOLD: "paragraph-100-bold",
|
|
@@ -319,35 +320,37 @@ const Te = /* @__PURE__ */ Xe(Be), L = {
|
|
|
319
320
|
ADDITIONAL100MEDIUM: "additional-100-medium",
|
|
320
321
|
OVERLINE100: "overline-100",
|
|
321
322
|
OVERLINE200: "overline-200"
|
|
322
|
-
},
|
|
323
|
+
}, j = "purpur-paragraph", Ie = ({
|
|
323
324
|
["data-testid"]: e,
|
|
324
325
|
children: n,
|
|
325
326
|
className: r = "",
|
|
326
327
|
disabled: o,
|
|
327
328
|
enableHyphenation: c = !1,
|
|
328
|
-
|
|
329
|
-
|
|
329
|
+
negative: t = !1,
|
|
330
|
+
variant: a = Te.PARAGRAPH100,
|
|
331
|
+
...u
|
|
330
332
|
}) => {
|
|
331
|
-
const
|
|
333
|
+
const i = Be([
|
|
332
334
|
r,
|
|
333
|
-
|
|
334
|
-
|
|
335
|
+
E[j],
|
|
336
|
+
E[`${j}--${a}`],
|
|
335
337
|
{
|
|
336
|
-
[
|
|
337
|
-
[
|
|
338
|
+
[E[`${j}--hyphens`]]: c,
|
|
339
|
+
[E[`${j}--disabled`]]: o,
|
|
340
|
+
[E[`${j}--negative`]]: t
|
|
338
341
|
}
|
|
339
342
|
]);
|
|
340
|
-
return /* @__PURE__ */
|
|
343
|
+
return /* @__PURE__ */ x("p", { ...u, className: i, "data-testid": e, children: n });
|
|
341
344
|
};
|
|
342
|
-
function
|
|
343
|
-
return
|
|
345
|
+
function z() {
|
|
346
|
+
return z = Object.assign ? Object.assign.bind() : function(e) {
|
|
344
347
|
for (var n = 1; n < arguments.length; n++) {
|
|
345
348
|
var r = arguments[n];
|
|
346
349
|
for (var o in r)
|
|
347
350
|
Object.prototype.hasOwnProperty.call(r, o) && (e[o] = r[o]);
|
|
348
351
|
}
|
|
349
352
|
return e;
|
|
350
|
-
},
|
|
353
|
+
}, z.apply(this, arguments);
|
|
351
354
|
}
|
|
352
355
|
function qe(e, n, { checkForDefaultPrevented: r = !0 } = {}) {
|
|
353
356
|
return function(c) {
|
|
@@ -364,7 +367,7 @@ function ce(...e) {
|
|
|
364
367
|
);
|
|
365
368
|
}
|
|
366
369
|
function Ve(...e) {
|
|
367
|
-
return
|
|
370
|
+
return X(ce(...e), e);
|
|
368
371
|
}
|
|
369
372
|
function Ue(e, n = []) {
|
|
370
373
|
let r = [];
|
|
@@ -375,7 +378,7 @@ function Ue(e, n = []) {
|
|
|
375
378
|
a
|
|
376
379
|
];
|
|
377
380
|
function s(l) {
|
|
378
|
-
const { scope: p, children: v, ...f } = l, g = (p == null ? void 0 : p[e][i]) || u, d =
|
|
381
|
+
const { scope: p, children: v, ...f } = l, g = (p == null ? void 0 : p[e][i]) || u, d = R(
|
|
379
382
|
() => f,
|
|
380
383
|
Object.values(f)
|
|
381
384
|
);
|
|
@@ -400,7 +403,7 @@ function Ue(e, n = []) {
|
|
|
400
403
|
const t = r.map((a) => /* @__PURE__ */ Z(a));
|
|
401
404
|
return function(u) {
|
|
402
405
|
const i = (u == null ? void 0 : u[e]) || t;
|
|
403
|
-
return
|
|
406
|
+
return R(
|
|
404
407
|
() => ({
|
|
405
408
|
[`__scope${e}`]: {
|
|
406
409
|
...u,
|
|
@@ -438,7 +441,7 @@ function We(...e) {
|
|
|
438
441
|
...l
|
|
439
442
|
};
|
|
440
443
|
}, {});
|
|
441
|
-
return
|
|
444
|
+
return R(
|
|
442
445
|
() => ({
|
|
443
446
|
[`__scope${n.scopeName}`]: a
|
|
444
447
|
}),
|
|
@@ -454,7 +457,7 @@ function ue(e) {
|
|
|
454
457
|
const n = D(e);
|
|
455
458
|
return A(() => {
|
|
456
459
|
n.current = e;
|
|
457
|
-
}),
|
|
460
|
+
}), R(
|
|
458
461
|
() => (...r) => {
|
|
459
462
|
var o;
|
|
460
463
|
return (o = n.current) === null || o === void 0 ? void 0 : o.call(n, ...r);
|
|
@@ -467,7 +470,7 @@ function Ge({ prop: e, defaultProp: n, onChange: r = () => {
|
|
|
467
470
|
const [o, c] = Ze({
|
|
468
471
|
defaultProp: n,
|
|
469
472
|
onChange: r
|
|
470
|
-
}), t = e !== void 0, a = t ? e : o, u = ue(r), i =
|
|
473
|
+
}), t = e !== void 0, a = t ? e : o, u = ue(r), i = X((s) => {
|
|
471
474
|
if (t) {
|
|
472
475
|
const l = typeof s == "function" ? s(e) : s;
|
|
473
476
|
l !== e && u(l);
|
|
@@ -499,7 +502,7 @@ function Je(e) {
|
|
|
499
502
|
value: e,
|
|
500
503
|
previous: e
|
|
501
504
|
});
|
|
502
|
-
return
|
|
505
|
+
return R(() => (n.current.value !== e && (n.current.previous = n.current.value, n.current.value = e), n.current.previous), [
|
|
503
506
|
e
|
|
504
507
|
]);
|
|
505
508
|
}
|
|
@@ -537,32 +540,32 @@ function Qe(e) {
|
|
|
537
540
|
e
|
|
538
541
|
]), n;
|
|
539
542
|
}
|
|
540
|
-
function
|
|
541
|
-
return
|
|
543
|
+
function H() {
|
|
544
|
+
return H = Object.assign ? Object.assign.bind() : function(e) {
|
|
542
545
|
for (var n = 1; n < arguments.length; n++) {
|
|
543
546
|
var r = arguments[n];
|
|
544
547
|
for (var o in r)
|
|
545
548
|
Object.prototype.hasOwnProperty.call(r, o) && (e[o] = r[o]);
|
|
546
549
|
}
|
|
547
550
|
return e;
|
|
548
|
-
},
|
|
551
|
+
}, H.apply(this, arguments);
|
|
549
552
|
}
|
|
550
|
-
const ie = /* @__PURE__ */
|
|
553
|
+
const ie = /* @__PURE__ */ w((e, n) => {
|
|
551
554
|
const { children: r, ...o } = e, c = y.toArray(r), t = c.find(et);
|
|
552
555
|
if (t) {
|
|
553
|
-
const a = t.props.children, u = c.map((i) => i === t ? y.count(a) > 1 ? y.only(null) : /* @__PURE__ */
|
|
554
|
-
return /* @__PURE__ */ _(V,
|
|
556
|
+
const a = t.props.children, u = c.map((i) => i === t ? y.count(a) > 1 ? y.only(null) : /* @__PURE__ */ k(a) ? a.props.children : null : i);
|
|
557
|
+
return /* @__PURE__ */ _(V, H({}, o, {
|
|
555
558
|
ref: n
|
|
556
|
-
}), /* @__PURE__ */
|
|
559
|
+
}), /* @__PURE__ */ k(a) ? /* @__PURE__ */ L(a, void 0, u) : null);
|
|
557
560
|
}
|
|
558
|
-
return /* @__PURE__ */ _(V,
|
|
561
|
+
return /* @__PURE__ */ _(V, H({}, o, {
|
|
559
562
|
ref: n
|
|
560
563
|
}), r);
|
|
561
564
|
});
|
|
562
565
|
ie.displayName = "Slot";
|
|
563
|
-
const V = /* @__PURE__ */
|
|
566
|
+
const V = /* @__PURE__ */ w((e, n) => {
|
|
564
567
|
const { children: r, ...o } = e;
|
|
565
|
-
return /* @__PURE__ */
|
|
568
|
+
return /* @__PURE__ */ k(r) ? /* @__PURE__ */ L(r, {
|
|
566
569
|
...tt(o, r.props),
|
|
567
570
|
ref: n ? ce(n, r.ref) : r.ref
|
|
568
571
|
}) : y.count(r) > 1 ? y.only(null) : null;
|
|
@@ -570,7 +573,7 @@ const V = /* @__PURE__ */ x((e, n) => {
|
|
|
570
573
|
V.displayName = "SlotClone";
|
|
571
574
|
const Ye = ({ children: e }) => /* @__PURE__ */ _(ee, null, e);
|
|
572
575
|
function et(e) {
|
|
573
|
-
return /* @__PURE__ */
|
|
576
|
+
return /* @__PURE__ */ k(e) && e.type === Ye;
|
|
574
577
|
}
|
|
575
578
|
function tt(e, n) {
|
|
576
579
|
const r = {
|
|
@@ -611,11 +614,11 @@ const rt = [
|
|
|
611
614
|
"svg",
|
|
612
615
|
"ul"
|
|
613
616
|
], se = rt.reduce((e, n) => {
|
|
614
|
-
const r = /* @__PURE__ */
|
|
617
|
+
const r = /* @__PURE__ */ w((o, c) => {
|
|
615
618
|
const { asChild: t, ...a } = o, u = t ? ie : n;
|
|
616
619
|
return A(() => {
|
|
617
620
|
window[Symbol.for("radix-ui")] = !0;
|
|
618
|
-
}, []), /* @__PURE__ */ _(u,
|
|
621
|
+
}, []), /* @__PURE__ */ _(u, H({}, a, {
|
|
619
622
|
ref: c
|
|
620
623
|
}));
|
|
621
624
|
});
|
|
@@ -623,7 +626,7 @@ const rt = [
|
|
|
623
626
|
...e,
|
|
624
627
|
[n]: r
|
|
625
628
|
};
|
|
626
|
-
}, {}), le = "Switch", [nt, yt] = Ue(le), [ot, at] = nt(le), ct = /* @__PURE__ */
|
|
629
|
+
}, {}), le = "Switch", [nt, yt] = Ue(le), [ot, at] = nt(le), ct = /* @__PURE__ */ w((e, n) => {
|
|
627
630
|
const { __scopeSwitch: r, name: o, checked: c, defaultChecked: t, required: a, disabled: u, value: i = "on", onCheckedChange: s, ...h } = e, [l, p] = $(null), v = Ve(
|
|
628
631
|
n,
|
|
629
632
|
(m) => p(m)
|
|
@@ -636,7 +639,7 @@ const rt = [
|
|
|
636
639
|
scope: r,
|
|
637
640
|
checked: d,
|
|
638
641
|
disabled: u
|
|
639
|
-
}, /* @__PURE__ */ _(se.button,
|
|
642
|
+
}, /* @__PURE__ */ _(se.button, z({
|
|
640
643
|
type: "button",
|
|
641
644
|
role: "switch",
|
|
642
645
|
"aria-checked": d,
|
|
@@ -664,9 +667,9 @@ const rt = [
|
|
|
664
667
|
transform: "translateX(-100%)"
|
|
665
668
|
}
|
|
666
669
|
}));
|
|
667
|
-
}), ut = "SwitchThumb", it = /* @__PURE__ */
|
|
670
|
+
}), ut = "SwitchThumb", it = /* @__PURE__ */ w((e, n) => {
|
|
668
671
|
const { __scopeSwitch: r, ...o } = e, c = at(ut, r);
|
|
669
|
-
return /* @__PURE__ */ _(se.span,
|
|
672
|
+
return /* @__PURE__ */ _(se.span, z({
|
|
670
673
|
"data-state": pe(c.checked),
|
|
671
674
|
"data-disabled": c.disabled ? "" : void 0
|
|
672
675
|
}, o, {
|
|
@@ -686,7 +689,7 @@ const rt = [
|
|
|
686
689
|
a,
|
|
687
690
|
r,
|
|
688
691
|
o
|
|
689
|
-
]), /* @__PURE__ */ _("input",
|
|
692
|
+
]), /* @__PURE__ */ _("input", z({
|
|
690
693
|
type: "checkbox",
|
|
691
694
|
"aria-hidden": !0,
|
|
692
695
|
defaultChecked: r
|
|
@@ -773,7 +776,7 @@ const I = /* @__PURE__ */ dt(ft), S = {
|
|
|
773
776
|
const m = Y(b.nativeEvent) ? b.nativeEvent.touches[0].clientX : b.nativeEvent.clientX;
|
|
774
777
|
l(m), r == null || r();
|
|
775
778
|
}
|
|
776
|
-
}, g =
|
|
779
|
+
}, g = X(
|
|
777
780
|
(b) => {
|
|
778
781
|
if (typeof h != "number")
|
|
779
782
|
return;
|
|
@@ -782,18 +785,18 @@ const I = /* @__PURE__ */ dt(ft), S = {
|
|
|
782
785
|
return;
|
|
783
786
|
const C = a + O;
|
|
784
787
|
!p && Math.abs(C) && v(!0);
|
|
785
|
-
const
|
|
786
|
-
s(
|
|
788
|
+
const B = C > t.right ? t.right : C < t.left ? t.left : C;
|
|
789
|
+
s(B), o == null || o({ x: B });
|
|
787
790
|
},
|
|
788
791
|
[o, s, p, h]
|
|
789
|
-
), d =
|
|
792
|
+
), d = X(() => {
|
|
790
793
|
l(void 0), s(void 0), v(!1), c == null || c();
|
|
791
794
|
}, [c, l]);
|
|
792
795
|
return A(() => (window.addEventListener("mousemove", g), window.addEventListener("touchmove", g), () => {
|
|
793
796
|
window.removeEventListener("mousemove", g), window.removeEventListener("touchmove", g);
|
|
794
797
|
}), [g]), A(() => (window.addEventListener("mouseup", d), window.addEventListener("touchend", d), () => {
|
|
795
798
|
window.removeEventListener("mouseup", d), window.removeEventListener("touchend", d);
|
|
796
|
-
}), [d]),
|
|
799
|
+
}), [d]), k(e) ? L(y.only(e), {
|
|
797
800
|
onMouseDown: f,
|
|
798
801
|
onTouchStart: f,
|
|
799
802
|
style: { ...u, transform: `translateX(${p ? i : a}px)` }
|
|
@@ -802,8 +805,8 @@ const I = /* @__PURE__ */ dt(ft), S = {
|
|
|
802
805
|
var U, W;
|
|
803
806
|
const r = D(null), o = D(null), [c, t] = $(void 0), [a, u] = $(!1), [i, s] = $(0), [h, l] = $(0), [p, v] = $(0);
|
|
804
807
|
te(() => {
|
|
805
|
-
var N,
|
|
806
|
-
l(((N = o.current) == null ? void 0 : N.clientHeight) || 0), v(((
|
|
808
|
+
var N, T;
|
|
809
|
+
l(((N = o.current) == null ? void 0 : N.clientHeight) || 0), v(((T = r.current) == null ? void 0 : T.clientHeight) || 0);
|
|
807
810
|
}, [(U = o.current) == null ? void 0 : U.clientHeight, (W = r.current) == null ? void 0 : W.clientHeight]);
|
|
808
811
|
const f = (p || 0) - h, g = h + f, d = f / 2, b = g / 2, m = typeof c == "number" && (e ? c < b : c > b);
|
|
809
812
|
return {
|
|
@@ -822,7 +825,7 @@ const I = /* @__PURE__ */ dt(ft), S = {
|
|
|
822
825
|
Date.now() - i > 50 && (n == null || n(!e)), t(void 0);
|
|
823
826
|
}
|
|
824
827
|
};
|
|
825
|
-
},
|
|
828
|
+
}, P = "purpur-toggle", bt = ({
|
|
826
829
|
["data-testid"]: e,
|
|
827
830
|
className: n,
|
|
828
831
|
label: r,
|
|
@@ -840,49 +843,49 @@ const I = /* @__PURE__ */ dt(ft), S = {
|
|
|
840
843
|
onChange: (O) => {
|
|
841
844
|
i.disabled || (o == null || o(O), l(O));
|
|
842
845
|
}
|
|
843
|
-
}), m = () => /* @__PURE__ */
|
|
844
|
-
|
|
846
|
+
}), m = () => /* @__PURE__ */ x(
|
|
847
|
+
He,
|
|
845
848
|
{
|
|
846
849
|
htmlFor: i.id,
|
|
847
850
|
"data-testid": e && `${e}-label`,
|
|
848
851
|
disabled: i.disabled,
|
|
849
852
|
className: I(
|
|
850
|
-
S[`${
|
|
851
|
-
S[`${
|
|
853
|
+
S[`${P}__label`],
|
|
854
|
+
S[`${P}__label--${c}`]
|
|
852
855
|
),
|
|
853
|
-
children: /* @__PURE__ */
|
|
856
|
+
children: /* @__PURE__ */ x(Ie, { variant: "paragraph-100", disabled: i.disabled, children: r })
|
|
854
857
|
}
|
|
855
858
|
);
|
|
856
|
-
return /* @__PURE__ */ G("div", { className: I([n, S[`${
|
|
859
|
+
return /* @__PURE__ */ G("div", { className: I([n, S[`${P}__container`]]), children: [
|
|
857
860
|
r && c === "left" && m(),
|
|
858
|
-
/* @__PURE__ */
|
|
861
|
+
/* @__PURE__ */ x(
|
|
859
862
|
lt,
|
|
860
863
|
{
|
|
861
864
|
...i,
|
|
862
865
|
ref: s,
|
|
863
866
|
id: i.id,
|
|
864
867
|
"data-testid": e,
|
|
865
|
-
className: S[
|
|
868
|
+
className: S[P],
|
|
866
869
|
onCheckedChange: d,
|
|
867
870
|
checked: p,
|
|
868
|
-
children: /* @__PURE__ */ G("span", { ref: f, className: S[`${
|
|
869
|
-
/* @__PURE__ */
|
|
871
|
+
children: /* @__PURE__ */ G("span", { ref: f, className: S[`${P}__track`], children: [
|
|
872
|
+
/* @__PURE__ */ x("span", { className: S[`${P}__checkmark-container`], children: /* @__PURE__ */ x(
|
|
870
873
|
Se,
|
|
871
874
|
{
|
|
872
|
-
className: S[`${
|
|
875
|
+
className: S[`${P}__checkmark`],
|
|
873
876
|
svg: ve,
|
|
874
877
|
size: "xxs"
|
|
875
878
|
}
|
|
876
879
|
) }),
|
|
877
|
-
/* @__PURE__ */
|
|
880
|
+
/* @__PURE__ */ x(gt, { disabled: a, ...b, children: /* @__PURE__ */ x(
|
|
878
881
|
pt,
|
|
879
882
|
{
|
|
880
883
|
ref: v,
|
|
881
884
|
"data-testid": e && `${e}-thumb`,
|
|
882
885
|
className: I([
|
|
883
|
-
S[`${
|
|
886
|
+
S[`${P}__thumb`],
|
|
884
887
|
{
|
|
885
|
-
[S[`${
|
|
888
|
+
[S[`${P}__thumb--dragging`]]: g
|
|
886
889
|
}
|
|
887
890
|
])
|
|
888
891
|
}
|
|
@@ -892,7 +895,7 @@ const I = /* @__PURE__ */ dt(ft), S = {
|
|
|
892
895
|
),
|
|
893
896
|
r && c === "right" && m()
|
|
894
897
|
] });
|
|
895
|
-
}, _t =
|
|
898
|
+
}, _t = w(bt);
|
|
896
899
|
_t.displayName = "Toggle";
|
|
897
900
|
export {
|
|
898
901
|
_t as Toggle
|