@purpurds/toggle 6.1.3 → 6.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/DraggableX.d.ts +4 -3
- package/dist/DraggableX.d.ts.map +1 -1
- package/dist/LICENSE.txt +3 -3
- package/dist/hooks/useResizeObserver.d.ts +1 -1
- package/dist/hooks/useResizeObserver.d.ts.map +1 -1
- package/dist/hooks/useToggleDrag.d.ts +3 -3
- package/dist/hooks/useToggleDrag.d.ts.map +1 -1
- package/dist/toggle.cjs.js +3 -3
- package/dist/toggle.cjs.js.map +1 -1
- package/dist/toggle.es.js +93 -93
- package/dist/toggle.es.js.map +1 -1
- package/package.json +25 -11
- package/src/DraggableX.tsx +3 -4
- package/src/hooks/useResizeObserver.ts +1 -1
- package/src/hooks/useToggleDrag.ts +2 -2
package/dist/toggle.es.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as f, Fragment as F, jsxs as M } from "react/jsx-runtime";
|
|
2
2
|
import * as s from "react";
|
|
3
|
-
import { useState as
|
|
3
|
+
import { useState as P, useCallback as z, useEffect as k, isValidElement as ce, cloneElement as le, useRef as $, forwardRef as pe } from "react";
|
|
4
4
|
import "react-dom";
|
|
5
|
-
function
|
|
5
|
+
function de(e) {
|
|
6
6
|
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
7
7
|
}
|
|
8
8
|
var U = { exports: {} };
|
|
@@ -41,8 +41,8 @@ var U = { exports: {} };
|
|
|
41
41
|
e.exports ? (t.default = t, e.exports = t) : window.classNames = t;
|
|
42
42
|
})();
|
|
43
43
|
})(U);
|
|
44
|
-
var
|
|
45
|
-
const
|
|
44
|
+
var fe = U.exports;
|
|
45
|
+
const he = /* @__PURE__ */ de(fe), ge = {
|
|
46
46
|
"purpur-icon": "_purpur-icon_8u1lq_1",
|
|
47
47
|
"purpur-icon--xxs": "_purpur-icon--xxs_8u1lq_4",
|
|
48
48
|
"purpur-icon--xs": "_purpur-icon--xs_8u1lq_8",
|
|
@@ -50,26 +50,26 @@ const ge = /* @__PURE__ */ fe(he), me = {
|
|
|
50
50
|
"purpur-icon--md": "_purpur-icon--md_8u1lq_16",
|
|
51
51
|
"purpur-icon--lg": "_purpur-icon--lg_8u1lq_20",
|
|
52
52
|
"purpur-icon--xl": "_purpur-icon--xl_8u1lq_24"
|
|
53
|
-
},
|
|
53
|
+
}, me = he.bind(ge), X = "purpur-icon", _e = "md", ve = (e) => e.filter((n) => Object.keys(n).length >= 1).map((n) => `${n.name}="${n.value}"`).join(" "), be = ({ content: e = "", title: n } = {}) => {
|
|
54
54
|
const t = [
|
|
55
55
|
{ name: "xmlns", value: "http://www.w3.org/2000/svg" },
|
|
56
56
|
{ name: "fill", value: "currentColor" },
|
|
57
57
|
{ name: "viewBox", value: "0 0 24 24" },
|
|
58
58
|
n ? { name: "role", value: "img" } : { name: "aria-hidden", value: "true" }
|
|
59
59
|
], a = n ? `<title>${n}</title>` : "";
|
|
60
|
-
return `<svg ${
|
|
61
|
-
},
|
|
60
|
+
return `<svg ${ve(t)}>${a}${e}</svg>`;
|
|
61
|
+
}, ye = (e) => e.replace(/<(\/?)svg([^>]*)>/g, "").trim(), G = ({
|
|
62
62
|
["data-testid"]: e,
|
|
63
63
|
svg: n,
|
|
64
64
|
allyTitle: t,
|
|
65
65
|
className: a,
|
|
66
|
-
size: o =
|
|
66
|
+
size: o = _e,
|
|
67
67
|
...r
|
|
68
68
|
}) => {
|
|
69
|
-
const i =
|
|
70
|
-
content:
|
|
69
|
+
const i = be({
|
|
70
|
+
content: ye(n.svg),
|
|
71
71
|
title: t
|
|
72
|
-
}), u =
|
|
72
|
+
}), u = me(a, X, `${X}--${o}`);
|
|
73
73
|
return /* @__PURE__ */ f(
|
|
74
74
|
"span",
|
|
75
75
|
{
|
|
@@ -82,7 +82,7 @@ const ge = /* @__PURE__ */ fe(he), me = {
|
|
|
82
82
|
);
|
|
83
83
|
};
|
|
84
84
|
G.displayName = "Icon";
|
|
85
|
-
const
|
|
85
|
+
const we = {
|
|
86
86
|
name: "checkmark-bold",
|
|
87
87
|
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>',
|
|
88
88
|
keywords: ["checkmark-bold"],
|
|
@@ -93,7 +93,7 @@ function W(e, n) {
|
|
|
93
93
|
return e(n);
|
|
94
94
|
e != null && (e.current = n);
|
|
95
95
|
}
|
|
96
|
-
function
|
|
96
|
+
function Se(...e) {
|
|
97
97
|
return (n) => {
|
|
98
98
|
let t = !1;
|
|
99
99
|
const a = e.map((o) => {
|
|
@@ -110,7 +110,7 @@ function xe(...e) {
|
|
|
110
110
|
};
|
|
111
111
|
}
|
|
112
112
|
var Z = s.forwardRef((e, n) => {
|
|
113
|
-
const { children: t, ...a } = e, o = s.Children.toArray(t), r = o.find(
|
|
113
|
+
const { children: t, ...a } = e, o = s.Children.toArray(t), r = o.find(Re);
|
|
114
114
|
if (r) {
|
|
115
115
|
const i = r.props.children, u = o.map((c) => c === r ? s.Children.count(i) > 1 ? s.Children.only(null) : s.isValidElement(i) ? i.props.children : null : c);
|
|
116
116
|
return /* @__PURE__ */ f(j, { ...a, ref: n, children: s.isValidElement(i) ? s.cloneElement(i, void 0, u) : null });
|
|
@@ -121,15 +121,15 @@ Z.displayName = "Slot";
|
|
|
121
121
|
var j = s.forwardRef((e, n) => {
|
|
122
122
|
const { children: t, ...a } = e;
|
|
123
123
|
if (s.isValidElement(t)) {
|
|
124
|
-
const o =
|
|
125
|
-
return t.type !== s.Fragment && (r.ref = n ?
|
|
124
|
+
const o = Ce(t), r = Pe(a, t.props);
|
|
125
|
+
return t.type !== s.Fragment && (r.ref = n ? Se(n, o) : o), s.cloneElement(t, r);
|
|
126
126
|
}
|
|
127
127
|
return s.Children.count(t) > 1 ? s.Children.only(null) : null;
|
|
128
128
|
});
|
|
129
129
|
j.displayName = "SlotClone";
|
|
130
|
-
var
|
|
131
|
-
function
|
|
132
|
-
return s.isValidElement(e) && e.type ===
|
|
130
|
+
var xe = ({ children: e }) => /* @__PURE__ */ f(F, { children: e });
|
|
131
|
+
function Re(e) {
|
|
132
|
+
return s.isValidElement(e) && e.type === xe;
|
|
133
133
|
}
|
|
134
134
|
function Pe(e, n) {
|
|
135
135
|
const t = { ...n };
|
|
@@ -141,12 +141,12 @@ function Pe(e, n) {
|
|
|
141
141
|
}
|
|
142
142
|
return { ...e, ...t };
|
|
143
143
|
}
|
|
144
|
-
function
|
|
144
|
+
function Ce(e) {
|
|
145
145
|
var n, t;
|
|
146
146
|
let a = (n = Object.getOwnPropertyDescriptor(e.props, "ref")) == null ? void 0 : n.get, o = a && "isReactWarning" in a && a.isReactWarning;
|
|
147
147
|
return o ? e.ref : (a = (t = Object.getOwnPropertyDescriptor(e, "ref")) == null ? void 0 : t.get, o = a && "isReactWarning" in a && a.isReactWarning, o ? e.props.ref : e.props.ref || e.ref);
|
|
148
148
|
}
|
|
149
|
-
var
|
|
149
|
+
var Ee = [
|
|
150
150
|
"a",
|
|
151
151
|
"button",
|
|
152
152
|
"div",
|
|
@@ -163,14 +163,14 @@ var $e = [
|
|
|
163
163
|
"span",
|
|
164
164
|
"svg",
|
|
165
165
|
"ul"
|
|
166
|
-
],
|
|
166
|
+
], $e = Ee.reduce((e, n) => {
|
|
167
167
|
const t = s.forwardRef((a, o) => {
|
|
168
168
|
const { asChild: r, ...i } = a, u = r ? Z : n;
|
|
169
169
|
return typeof window < "u" && (window[Symbol.for("radix-ui")] = !0), /* @__PURE__ */ f(u, { ...i, ref: o });
|
|
170
170
|
});
|
|
171
171
|
return t.displayName = `Primitive.${n}`, { ...e, [n]: t };
|
|
172
|
-
}, {}),
|
|
173
|
-
|
|
172
|
+
}, {}), ke = "Label", J = s.forwardRef((e, n) => /* @__PURE__ */ f(
|
|
173
|
+
$e.label,
|
|
174
174
|
{
|
|
175
175
|
...e,
|
|
176
176
|
ref: n,
|
|
@@ -180,9 +180,9 @@ var $e = [
|
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
182
|
));
|
|
183
|
-
J.displayName =
|
|
184
|
-
var
|
|
185
|
-
function
|
|
183
|
+
J.displayName = ke;
|
|
184
|
+
var Ae = J;
|
|
185
|
+
function De(e) {
|
|
186
186
|
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
187
187
|
}
|
|
188
188
|
var K = { exports: {} };
|
|
@@ -221,12 +221,12 @@ var K = { exports: {} };
|
|
|
221
221
|
e.exports ? (t.default = t, e.exports = t) : window.classNames = t;
|
|
222
222
|
})();
|
|
223
223
|
})(K);
|
|
224
|
-
var
|
|
225
|
-
const
|
|
224
|
+
var Ne = K.exports;
|
|
225
|
+
const Oe = /* @__PURE__ */ De(Ne), D = {
|
|
226
226
|
"purpur-label": "_purpur-label_12cfi_1",
|
|
227
227
|
"purpur-label--negative": "_purpur-label--negative_12cfi_9",
|
|
228
228
|
"purpur-label--disabled": "_purpur-label--disabled_12cfi_12"
|
|
229
|
-
}, N = "purpur-label",
|
|
229
|
+
}, N = "purpur-label", Me = ({
|
|
230
230
|
children: e,
|
|
231
231
|
className: n,
|
|
232
232
|
htmlFor: t,
|
|
@@ -235,7 +235,7 @@ const Me = /* @__PURE__ */ Ne(Oe), D = {
|
|
|
235
235
|
negative: r = !1,
|
|
236
236
|
...i
|
|
237
237
|
}) => {
|
|
238
|
-
const u =
|
|
238
|
+
const u = Oe([
|
|
239
239
|
n,
|
|
240
240
|
D[N],
|
|
241
241
|
{
|
|
@@ -243,9 +243,9 @@ const Me = /* @__PURE__ */ Ne(Oe), D = {
|
|
|
243
243
|
[D[`${N}--negative`]]: r
|
|
244
244
|
}
|
|
245
245
|
]);
|
|
246
|
-
return /* @__PURE__ */ f(
|
|
246
|
+
return /* @__PURE__ */ f(Ae, { className: u, "data-testid": a, htmlFor: t, ...i, children: e });
|
|
247
247
|
};
|
|
248
|
-
function
|
|
248
|
+
function ze(e) {
|
|
249
249
|
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
250
250
|
}
|
|
251
251
|
var Q = { exports: {} };
|
|
@@ -284,8 +284,8 @@ var Q = { exports: {} };
|
|
|
284
284
|
e.exports ? (t.default = t, e.exports = t) : window.classNames = t;
|
|
285
285
|
})();
|
|
286
286
|
})(Q);
|
|
287
|
-
var
|
|
288
|
-
const
|
|
287
|
+
var je = Q.exports;
|
|
288
|
+
const Le = /* @__PURE__ */ ze(je), C = {
|
|
289
289
|
"purpur-paragraph": "_purpur-paragraph_1rh57_1",
|
|
290
290
|
"purpur-paragraph--disabled": "_purpur-paragraph--disabled_1rh57_7",
|
|
291
291
|
"purpur-paragraph--hyphens": "_purpur-paragraph--hyphens_1rh57_10",
|
|
@@ -300,7 +300,7 @@ const Be = /* @__PURE__ */ je(Le), P = {
|
|
|
300
300
|
"purpur-paragraph--additional-100-medium": "_purpur-paragraph--additional-100-medium_1rh57_60",
|
|
301
301
|
"purpur-paragraph--overline-100": "_purpur-paragraph--overline-100_1rh57_67",
|
|
302
302
|
"purpur-paragraph--overline-200": "_purpur-paragraph--overline-200_1rh57_75"
|
|
303
|
-
},
|
|
303
|
+
}, Be = {
|
|
304
304
|
PARAGRAPH100: "paragraph-100",
|
|
305
305
|
PARAGRAPH100MEDIUM: "paragraph-100-medium",
|
|
306
306
|
PARAGRAPH100BOLD: "paragraph-100-bold",
|
|
@@ -318,23 +318,23 @@ const Be = /* @__PURE__ */ je(Le), P = {
|
|
|
318
318
|
disabled: a,
|
|
319
319
|
enableHyphenation: o = !1,
|
|
320
320
|
negative: r = !1,
|
|
321
|
-
variant: i =
|
|
321
|
+
variant: i = Be.PARAGRAPH100,
|
|
322
322
|
...u
|
|
323
323
|
}) => {
|
|
324
|
-
const c =
|
|
324
|
+
const c = Le([
|
|
325
325
|
t,
|
|
326
|
-
|
|
327
|
-
|
|
326
|
+
C[E],
|
|
327
|
+
C[`${E}--${i}`],
|
|
328
328
|
{
|
|
329
|
-
[
|
|
330
|
-
[
|
|
331
|
-
[
|
|
329
|
+
[C[`${E}--hyphens`]]: o,
|
|
330
|
+
[C[`${E}--disabled`]]: a,
|
|
331
|
+
[C[`${E}--negative`]]: r
|
|
332
332
|
}
|
|
333
333
|
]);
|
|
334
334
|
return /* @__PURE__ */ f("p", { ...u, className: c, "data-testid": e, children: n });
|
|
335
335
|
};
|
|
336
336
|
Y.displayName = "Paragraph";
|
|
337
|
-
function
|
|
337
|
+
function Xe(e, n, { checkForDefaultPrevented: t = !0 } = {}) {
|
|
338
338
|
return function(o) {
|
|
339
339
|
if (e == null || e(o), t === !1 || !o.defaultPrevented)
|
|
340
340
|
return n == null ? void 0 : n(o);
|
|
@@ -361,10 +361,10 @@ function ee(...e) {
|
|
|
361
361
|
};
|
|
362
362
|
};
|
|
363
363
|
}
|
|
364
|
-
function
|
|
364
|
+
function We(...e) {
|
|
365
365
|
return s.useCallback(ee(...e), e);
|
|
366
366
|
}
|
|
367
|
-
function
|
|
367
|
+
function Ie(e, n = []) {
|
|
368
368
|
let t = [];
|
|
369
369
|
function a(r, i) {
|
|
370
370
|
const u = s.createContext(i), c = t.length;
|
|
@@ -394,9 +394,9 @@ function He(e, n = []) {
|
|
|
394
394
|
);
|
|
395
395
|
};
|
|
396
396
|
};
|
|
397
|
-
return o.scopeName = e, [a,
|
|
397
|
+
return o.scopeName = e, [a, He(o, ...n)];
|
|
398
398
|
}
|
|
399
|
-
function
|
|
399
|
+
function He(...e) {
|
|
400
400
|
const n = e[0];
|
|
401
401
|
if (e.length === 1) return n;
|
|
402
402
|
const t = () => {
|
|
@@ -423,13 +423,13 @@ function re(e) {
|
|
|
423
423
|
return (a = n.current) == null ? void 0 : a.call(n, ...t);
|
|
424
424
|
}, []);
|
|
425
425
|
}
|
|
426
|
-
function
|
|
426
|
+
function Ve({
|
|
427
427
|
prop: e,
|
|
428
428
|
defaultProp: n,
|
|
429
429
|
onChange: t = () => {
|
|
430
430
|
}
|
|
431
431
|
}) {
|
|
432
|
-
const [a, o] =
|
|
432
|
+
const [a, o] = Te({ defaultProp: n, onChange: t }), r = e !== void 0, i = r ? e : a, u = re(t), c = s.useCallback(
|
|
433
433
|
(l) => {
|
|
434
434
|
if (r) {
|
|
435
435
|
const d = typeof l == "function" ? l(e) : l;
|
|
@@ -441,7 +441,7 @@ function Te({
|
|
|
441
441
|
);
|
|
442
442
|
return [i, c];
|
|
443
443
|
}
|
|
444
|
-
function
|
|
444
|
+
function Te({
|
|
445
445
|
defaultProp: e,
|
|
446
446
|
onChange: n
|
|
447
447
|
}) {
|
|
@@ -450,15 +450,15 @@ function qe({
|
|
|
450
450
|
o.current !== a && (r(a), o.current = a);
|
|
451
451
|
}, [a, o, r]), t;
|
|
452
452
|
}
|
|
453
|
-
function
|
|
453
|
+
function qe(e) {
|
|
454
454
|
const n = s.useRef({ value: e, previous: e });
|
|
455
455
|
return s.useMemo(() => (n.current.value !== e && (n.current.previous = n.current.value, n.current.value = e), n.current.previous), [e]);
|
|
456
456
|
}
|
|
457
|
-
var
|
|
457
|
+
var Fe = globalThis != null && globalThis.document ? s.useLayoutEffect : () => {
|
|
458
458
|
};
|
|
459
|
-
function
|
|
459
|
+
function Ue(e) {
|
|
460
460
|
const [n, t] = s.useState(void 0);
|
|
461
|
-
return
|
|
461
|
+
return Fe(() => {
|
|
462
462
|
if (e) {
|
|
463
463
|
t({ width: e.offsetWidth, height: e.offsetHeight });
|
|
464
464
|
const a = new ResizeObserver((o) => {
|
|
@@ -479,7 +479,7 @@ function Ge(e) {
|
|
|
479
479
|
}, [e]), n;
|
|
480
480
|
}
|
|
481
481
|
var te = s.forwardRef((e, n) => {
|
|
482
|
-
const { children: t, ...a } = e, o = s.Children.toArray(t), r = o.find(
|
|
482
|
+
const { children: t, ...a } = e, o = s.Children.toArray(t), r = o.find(Ze);
|
|
483
483
|
if (r) {
|
|
484
484
|
const i = r.props.children, u = o.map((c) => c === r ? s.Children.count(i) > 1 ? s.Children.only(null) : s.isValidElement(i) ? i.props.children : null : c);
|
|
485
485
|
return /* @__PURE__ */ f(L, { ...a, ref: n, children: s.isValidElement(i) ? s.cloneElement(i, void 0, u) : null });
|
|
@@ -490,17 +490,17 @@ te.displayName = "Slot";
|
|
|
490
490
|
var L = s.forwardRef((e, n) => {
|
|
491
491
|
const { children: t, ...a } = e;
|
|
492
492
|
if (s.isValidElement(t)) {
|
|
493
|
-
const o =
|
|
493
|
+
const o = Ke(t), r = Je(a, t.props);
|
|
494
494
|
return t.type !== s.Fragment && (r.ref = n ? ee(n, o) : o), s.cloneElement(t, r);
|
|
495
495
|
}
|
|
496
496
|
return s.Children.count(t) > 1 ? s.Children.only(null) : null;
|
|
497
497
|
});
|
|
498
498
|
L.displayName = "SlotClone";
|
|
499
|
-
var
|
|
500
|
-
function
|
|
501
|
-
return s.isValidElement(e) && e.type ===
|
|
499
|
+
var Ge = ({ children: e }) => /* @__PURE__ */ f(F, { children: e });
|
|
500
|
+
function Ze(e) {
|
|
501
|
+
return s.isValidElement(e) && e.type === Ge;
|
|
502
502
|
}
|
|
503
|
-
function
|
|
503
|
+
function Je(e, n) {
|
|
504
504
|
const t = { ...n };
|
|
505
505
|
for (const a in n) {
|
|
506
506
|
const o = e[a], r = n[a];
|
|
@@ -510,12 +510,12 @@ function Ke(e, n) {
|
|
|
510
510
|
}
|
|
511
511
|
return { ...e, ...t };
|
|
512
512
|
}
|
|
513
|
-
function
|
|
513
|
+
function Ke(e) {
|
|
514
514
|
var a, o;
|
|
515
515
|
let n = (a = Object.getOwnPropertyDescriptor(e.props, "ref")) == null ? void 0 : a.get, t = n && "isReactWarning" in n && n.isReactWarning;
|
|
516
516
|
return t ? e.ref : (n = (o = Object.getOwnPropertyDescriptor(e, "ref")) == null ? void 0 : o.get, t = n && "isReactWarning" in n && n.isReactWarning, t ? e.props.ref : e.props.ref || e.ref);
|
|
517
517
|
}
|
|
518
|
-
var
|
|
518
|
+
var Qe = [
|
|
519
519
|
"a",
|
|
520
520
|
"button",
|
|
521
521
|
"div",
|
|
@@ -532,13 +532,13 @@ var Ye = [
|
|
|
532
532
|
"span",
|
|
533
533
|
"svg",
|
|
534
534
|
"ul"
|
|
535
|
-
], ne =
|
|
535
|
+
], ne = Qe.reduce((e, n) => {
|
|
536
536
|
const t = s.forwardRef((a, o) => {
|
|
537
537
|
const { asChild: r, ...i } = a, u = r ? te : n;
|
|
538
538
|
return typeof window < "u" && (window[Symbol.for("radix-ui")] = !0), /* @__PURE__ */ f(u, { ...i, ref: o });
|
|
539
539
|
});
|
|
540
540
|
return t.displayName = `Primitive.${n}`, { ...e, [n]: t };
|
|
541
|
-
}, {}), B = "Switch", [
|
|
541
|
+
}, {}), B = "Switch", [Ye, gr] = Ie(B), [er, rr] = Ye(B), oe = s.forwardRef(
|
|
542
542
|
(e, n) => {
|
|
543
543
|
const {
|
|
544
544
|
__scopeSwitch: t,
|
|
@@ -551,12 +551,12 @@ var Ye = [
|
|
|
551
551
|
onCheckedChange: l,
|
|
552
552
|
form: _,
|
|
553
553
|
...d
|
|
554
|
-
} = e, [p, g] = s.useState(null), h =
|
|
554
|
+
} = e, [p, g] = s.useState(null), h = We(n, (y) => g(y)), m = s.useRef(!1), b = p ? _ || !!p.closest("form") : !0, [v = !1, R] = Ve({
|
|
555
555
|
prop: o,
|
|
556
556
|
defaultProp: r,
|
|
557
557
|
onChange: l
|
|
558
558
|
});
|
|
559
|
-
return /* @__PURE__ */ M(
|
|
559
|
+
return /* @__PURE__ */ M(er, { scope: t, checked: v, disabled: u, children: [
|
|
560
560
|
/* @__PURE__ */ f(
|
|
561
561
|
ne.button,
|
|
562
562
|
{
|
|
@@ -570,13 +570,13 @@ var Ye = [
|
|
|
570
570
|
value: c,
|
|
571
571
|
...d,
|
|
572
572
|
ref: h,
|
|
573
|
-
onClick:
|
|
573
|
+
onClick: Xe(e.onClick, (y) => {
|
|
574
574
|
R((w) => !w), b && (m.current = y.isPropagationStopped(), m.current || y.stopPropagation());
|
|
575
575
|
})
|
|
576
576
|
}
|
|
577
577
|
),
|
|
578
578
|
b && /* @__PURE__ */ f(
|
|
579
|
-
|
|
579
|
+
tr,
|
|
580
580
|
{
|
|
581
581
|
control: p,
|
|
582
582
|
bubbles: !m.current,
|
|
@@ -595,7 +595,7 @@ var Ye = [
|
|
|
595
595
|
oe.displayName = B;
|
|
596
596
|
var ae = "SwitchThumb", ie = s.forwardRef(
|
|
597
597
|
(e, n) => {
|
|
598
|
-
const { __scopeSwitch: t, ...a } = e, o =
|
|
598
|
+
const { __scopeSwitch: t, ...a } = e, o = rr(ae, t);
|
|
599
599
|
return /* @__PURE__ */ f(
|
|
600
600
|
ne.span,
|
|
601
601
|
{
|
|
@@ -608,8 +608,8 @@ var ae = "SwitchThumb", ie = s.forwardRef(
|
|
|
608
608
|
}
|
|
609
609
|
);
|
|
610
610
|
ie.displayName = ae;
|
|
611
|
-
var
|
|
612
|
-
const { control: n, checked: t, bubbles: a = !0, ...o } = e, r = s.useRef(null), i =
|
|
611
|
+
var tr = (e) => {
|
|
612
|
+
const { control: n, checked: t, bubbles: a = !0, ...o } = e, r = s.useRef(null), i = qe(t), u = Ue(n);
|
|
613
613
|
return s.useEffect(() => {
|
|
614
614
|
const c = r.current, l = window.HTMLInputElement.prototype, d = Object.getOwnPropertyDescriptor(l, "checked").set;
|
|
615
615
|
if (i !== t && d) {
|
|
@@ -639,8 +639,8 @@ var nr = (e) => {
|
|
|
639
639
|
function ue(e) {
|
|
640
640
|
return e ? "checked" : "unchecked";
|
|
641
641
|
}
|
|
642
|
-
var
|
|
643
|
-
function
|
|
642
|
+
var nr = oe, or = ie;
|
|
643
|
+
function ar(e) {
|
|
644
644
|
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
645
645
|
}
|
|
646
646
|
var se = { exports: {} };
|
|
@@ -679,8 +679,8 @@ var se = { exports: {} };
|
|
|
679
679
|
e.exports ? (t.default = t, e.exports = t) : window.classNames = t;
|
|
680
680
|
})();
|
|
681
681
|
})(se);
|
|
682
|
-
var
|
|
683
|
-
const O = /* @__PURE__ */ ir
|
|
682
|
+
var ir = se.exports;
|
|
683
|
+
const O = /* @__PURE__ */ ar(ir), H = (e) => e && "touches" in e, ur = ({
|
|
684
684
|
children: e,
|
|
685
685
|
disabled: n,
|
|
686
686
|
onStart: t,
|
|
@@ -690,7 +690,7 @@ const O = /* @__PURE__ */ ir(ur), H = (e) => e && "touches" in e, sr = ({
|
|
|
690
690
|
position: i,
|
|
691
691
|
style: u
|
|
692
692
|
}) => {
|
|
693
|
-
const [c, l] =
|
|
693
|
+
const [c, l] = P(void 0), [_, d] = P(void 0), [p, g] = P(!1), h = (v) => {
|
|
694
694
|
if (!n) {
|
|
695
695
|
v.preventDefault();
|
|
696
696
|
const R = H(v.nativeEvent) ? v.nativeEvent.touches[0].clientX : v.nativeEvent.clientX;
|
|
@@ -716,7 +716,7 @@ const O = /* @__PURE__ */ ir(ur), H = (e) => e && "touches" in e, sr = ({
|
|
|
716
716
|
window.removeEventListener("mousemove", m), window.removeEventListener("touchmove", m);
|
|
717
717
|
}), [m]), k(() => (window.addEventListener("mouseup", b), window.addEventListener("touchend", b), () => {
|
|
718
718
|
window.removeEventListener("mouseup", b), window.removeEventListener("touchend", b);
|
|
719
|
-
}), [b]), ce(e) ? le(
|
|
719
|
+
}), [b]), ce(e) ? le(e, {
|
|
720
720
|
onMouseDown: h,
|
|
721
721
|
onTouchStart: h,
|
|
722
722
|
style: { ...u, transform: `translateX(${p ? c : i}px)` }
|
|
@@ -726,7 +726,7 @@ const O = /* @__PURE__ */ ir(ur), H = (e) => e && "touches" in e, sr = ({
|
|
|
726
726
|
height: void 0
|
|
727
727
|
};
|
|
728
728
|
function T(e) {
|
|
729
|
-
const { ref: n, box: t = "content-box", round: a } = e, [{ width: o, height: r }, i] =
|
|
729
|
+
const { ref: n, box: t = "content-box", round: a } = e, [{ width: o, height: r }, i] = P(V), u = sr(), c = $({ ...V }), l = $(void 0);
|
|
730
730
|
return l.current = e.onResize, k(() => {
|
|
731
731
|
if (!n.current || typeof window > "u" || !("ResizeObserver" in window))
|
|
732
732
|
return;
|
|
@@ -755,14 +755,14 @@ function q(e, n, t) {
|
|
|
755
755
|
e[n][t]
|
|
756
756
|
) : n === "contentBoxSize" ? e.contentRect[t === "inlineSize" ? "width" : "height"] : void 0;
|
|
757
757
|
}
|
|
758
|
-
function
|
|
758
|
+
function sr() {
|
|
759
759
|
const e = $(!1);
|
|
760
760
|
return k(() => (e.current = !0, () => {
|
|
761
761
|
e.current = !1;
|
|
762
762
|
}), []), z(() => e.current, []);
|
|
763
763
|
}
|
|
764
|
-
const
|
|
765
|
-
const t = $(null), a = $(null), [o, r] =
|
|
764
|
+
const cr = ({ checked: e, onChange: n }) => {
|
|
765
|
+
const t = $(null), a = $(null), [o, r] = P(void 0), [i, u] = P(!1), [c, l] = P(0), { height: _ = 0 } = T({ ref: a, round: !0 }), { height: d = 0 } = T({ ref: t, round: !0 }), p = (d || 0) - _, g = _ + p, h = p / 2, m = g / 2, b = typeof o == "number" && (e ? o < m : o > m);
|
|
766
766
|
return {
|
|
767
767
|
trackRef: t,
|
|
768
768
|
thumbRef: a,
|
|
@@ -789,7 +789,7 @@ const lr = ({ checked: e, onChange: n }) => {
|
|
|
789
789
|
"purpur-toggle__label--right": "_purpur-toggle__label--right_1xng6_100",
|
|
790
790
|
"purpur-toggle__label--left": "_purpur-toggle__label--left_1xng6_103",
|
|
791
791
|
"purpur-toggle__container": "_purpur-toggle__container_1xng6_106"
|
|
792
|
-
}, x = "purpur-toggle",
|
|
792
|
+
}, x = "purpur-toggle", lr = ({
|
|
793
793
|
["data-testid"]: e,
|
|
794
794
|
className: n,
|
|
795
795
|
label: t,
|
|
@@ -800,15 +800,15 @@ const lr = ({ checked: e, onChange: n }) => {
|
|
|
800
800
|
defaultChecked: u,
|
|
801
801
|
...c
|
|
802
802
|
}, l) => {
|
|
803
|
-
const [_, d] =
|
|
803
|
+
const [_, d] = P(
|
|
804
804
|
typeof r == "boolean" ? r : !!u
|
|
805
|
-
), p = !!(typeof r == "boolean" ? r : _), { thumbRef: g, trackRef: h, isDragging: m, onChangeWithDrag: b, ...v } =
|
|
805
|
+
), p = !!(typeof r == "boolean" ? r : _), { thumbRef: g, trackRef: h, isDragging: m, onChangeWithDrag: b, ...v } = cr({
|
|
806
806
|
checked: p,
|
|
807
807
|
onChange: (y) => {
|
|
808
808
|
c.disabled || (a == null || a(y), d(y));
|
|
809
809
|
}
|
|
810
810
|
}), R = () => /* @__PURE__ */ f(
|
|
811
|
-
|
|
811
|
+
Me,
|
|
812
812
|
{
|
|
813
813
|
htmlFor: c.id,
|
|
814
814
|
"data-testid": e && `${e}-label`,
|
|
@@ -823,7 +823,7 @@ const lr = ({ checked: e, onChange: n }) => {
|
|
|
823
823
|
return /* @__PURE__ */ M("div", { className: O([n, S[`${x}__container`]]), children: [
|
|
824
824
|
t && o === "left" && R(),
|
|
825
825
|
/* @__PURE__ */ f(
|
|
826
|
-
|
|
826
|
+
nr,
|
|
827
827
|
{
|
|
828
828
|
...c,
|
|
829
829
|
ref: l,
|
|
@@ -837,12 +837,12 @@ const lr = ({ checked: e, onChange: n }) => {
|
|
|
837
837
|
G,
|
|
838
838
|
{
|
|
839
839
|
className: S[`${x}__checkmark`],
|
|
840
|
-
svg:
|
|
840
|
+
svg: we,
|
|
841
841
|
size: "xxs"
|
|
842
842
|
}
|
|
843
843
|
) }),
|
|
844
|
-
/* @__PURE__ */ f(
|
|
845
|
-
|
|
844
|
+
/* @__PURE__ */ f(ur, { disabled: i, ...v, children: /* @__PURE__ */ f(
|
|
845
|
+
or,
|
|
846
846
|
{
|
|
847
847
|
ref: g,
|
|
848
848
|
"data-testid": e && `${e}-thumb`,
|
|
@@ -859,9 +859,9 @@ const lr = ({ checked: e, onChange: n }) => {
|
|
|
859
859
|
),
|
|
860
860
|
t && o === "right" && R()
|
|
861
861
|
] });
|
|
862
|
-
},
|
|
863
|
-
|
|
862
|
+
}, pr = pe(lr);
|
|
863
|
+
pr.displayName = "Toggle";
|
|
864
864
|
export {
|
|
865
|
-
|
|
865
|
+
pr as Toggle
|
|
866
866
|
};
|
|
867
867
|
//# sourceMappingURL=toggle.es.js.map
|