@purpurds/toggle 5.10.1 → 5.11.1
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 +121 -126
- package/dist/toggle.es.js.map +1 -1
- package/dist/useToggleDrag.d.ts.map +1 -1
- package/package.json +15 -15
- package/src/toggle.stories.tsx +50 -17
- package/readme.mdx +0 -124
package/dist/toggle.es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { jsx as x, jsxs as
|
|
2
|
-
import { forwardRef as w, Children as y, isValidElement as
|
|
1
|
+
import { jsx as x, jsxs as K } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as w, Children as y, isValidElement as k, createElement as _, cloneElement as X, useEffect as A, Fragment as ee, useCallback as B, createContext as J, useMemo as R, useContext as ge, useRef as D, useState as $, useLayoutEffect as re } from "react";
|
|
3
3
|
import "react-dom";
|
|
4
|
-
function
|
|
4
|
+
function he(e) {
|
|
5
5
|
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
6
6
|
}
|
|
7
7
|
var te = { exports: {} };
|
|
@@ -40,8 +40,8 @@ var te = { exports: {} };
|
|
|
40
40
|
e.exports ? (t.default = t, e.exports = t) : window.classNames = t;
|
|
41
41
|
})();
|
|
42
42
|
})(te);
|
|
43
|
-
var
|
|
44
|
-
const
|
|
43
|
+
var be = te.exports;
|
|
44
|
+
const _e = /* @__PURE__ */ he(be), ve = {
|
|
45
45
|
"purpur-icon": "_purpur-icon_8u1lq_1",
|
|
46
46
|
"purpur-icon--xxs": "_purpur-icon--xxs_8u1lq_4",
|
|
47
47
|
"purpur-icon--xs": "_purpur-icon--xs_8u1lq_8",
|
|
@@ -49,31 +49,31 @@ const be = /* @__PURE__ */ ge(he), _e = {
|
|
|
49
49
|
"purpur-icon--md": "_purpur-icon--md_8u1lq_16",
|
|
50
50
|
"purpur-icon--lg": "_purpur-icon--lg_8u1lq_20",
|
|
51
51
|
"purpur-icon--xl": "_purpur-icon--xl_8u1lq_24"
|
|
52
|
-
},
|
|
52
|
+
}, me = {
|
|
53
53
|
name: "checkmark-bold",
|
|
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
|
-
},
|
|
57
|
+
}, $e = _e.bind(ve), Q = "purpur-icon", ye = "md", xe = (e) => e.filter((n) => Object.keys(n).length >= 1).map((n) => `${n.name}="${n.value}"`).join(" "), we = ({ content: e = "", title: n } = {}) => {
|
|
58
58
|
const t = [
|
|
59
59
|
{ name: "xmlns", value: "http://www.w3.org/2000/svg" },
|
|
60
60
|
{ name: "fill", value: "currentColor" },
|
|
61
61
|
{ name: "viewBox", value: "0 0 24 24" },
|
|
62
62
|
n ? { name: "role", value: "img" } : { name: "aria-hidden", value: "true" }
|
|
63
63
|
], o = n ? `<title>${n}</title>` : "";
|
|
64
|
-
return `<svg ${
|
|
65
|
-
},
|
|
64
|
+
return `<svg ${xe(t)}>${o}${e}</svg>`;
|
|
65
|
+
}, Se = (e) => e.replace(/<(\/?)svg([^>]*)>/g, "").trim(), Pe = ({
|
|
66
66
|
["data-testid"]: e,
|
|
67
67
|
svg: n,
|
|
68
68
|
allyTitle: t,
|
|
69
|
-
className: o
|
|
70
|
-
size: c =
|
|
69
|
+
className: o,
|
|
70
|
+
size: c = ye,
|
|
71
71
|
...r
|
|
72
72
|
}) => {
|
|
73
|
-
const a =
|
|
74
|
-
content:
|
|
73
|
+
const a = we({
|
|
74
|
+
content: Se(n.svg),
|
|
75
75
|
title: t
|
|
76
|
-
}), u =
|
|
76
|
+
}), u = $e(o, Q, `${Q}--${c}`);
|
|
77
77
|
return /* @__PURE__ */ x(
|
|
78
78
|
"span",
|
|
79
79
|
{
|
|
@@ -85,15 +85,15 @@ const be = /* @__PURE__ */ ge(he), _e = {
|
|
|
85
85
|
}
|
|
86
86
|
);
|
|
87
87
|
};
|
|
88
|
-
function
|
|
89
|
-
return
|
|
88
|
+
function W() {
|
|
89
|
+
return W = Object.assign ? Object.assign.bind() : function(e) {
|
|
90
90
|
for (var n = 1; n < arguments.length; n++) {
|
|
91
91
|
var t = arguments[n];
|
|
92
92
|
for (var o in t)
|
|
93
93
|
Object.prototype.hasOwnProperty.call(t, o) && (e[o] = t[o]);
|
|
94
94
|
}
|
|
95
95
|
return e;
|
|
96
|
-
},
|
|
96
|
+
}, W.apply(this, arguments);
|
|
97
97
|
}
|
|
98
98
|
function M() {
|
|
99
99
|
return M = Object.assign ? Object.assign.bind() : function(e) {
|
|
@@ -105,40 +105,40 @@ function M() {
|
|
|
105
105
|
return e;
|
|
106
106
|
}, M.apply(this, arguments);
|
|
107
107
|
}
|
|
108
|
-
function
|
|
108
|
+
function ke(e, n) {
|
|
109
109
|
typeof e == "function" ? e(n) : e != null && (e.current = n);
|
|
110
110
|
}
|
|
111
111
|
function Oe(...e) {
|
|
112
112
|
return (n) => e.forEach(
|
|
113
|
-
(t) =>
|
|
113
|
+
(t) => ke(t, n)
|
|
114
114
|
);
|
|
115
115
|
}
|
|
116
116
|
const ne = /* @__PURE__ */ w((e, n) => {
|
|
117
|
-
const { children: t, ...o } = e, c = y.toArray(t), r = c.find(
|
|
117
|
+
const { children: t, ...o } = e, c = y.toArray(t), r = c.find(De);
|
|
118
118
|
if (r) {
|
|
119
|
-
const a = r.props.children, u = c.map((i) => i === r ? y.count(a) > 1 ? y.only(null) : /* @__PURE__ */
|
|
120
|
-
return /* @__PURE__ */ _(
|
|
119
|
+
const a = r.props.children, u = c.map((i) => i === r ? y.count(a) > 1 ? y.only(null) : /* @__PURE__ */ k(a) ? a.props.children : null : i);
|
|
120
|
+
return /* @__PURE__ */ _(G, M({}, o, {
|
|
121
121
|
ref: n
|
|
122
|
-
}), /* @__PURE__ */
|
|
122
|
+
}), /* @__PURE__ */ k(a) ? /* @__PURE__ */ X(a, void 0, u) : null);
|
|
123
123
|
}
|
|
124
|
-
return /* @__PURE__ */ _(
|
|
124
|
+
return /* @__PURE__ */ _(G, M({}, o, {
|
|
125
125
|
ref: n
|
|
126
126
|
}), t);
|
|
127
127
|
});
|
|
128
128
|
ne.displayName = "Slot";
|
|
129
|
-
const
|
|
129
|
+
const G = /* @__PURE__ */ w((e, n) => {
|
|
130
130
|
const { children: t, ...o } = e;
|
|
131
|
-
return /* @__PURE__ */
|
|
132
|
-
...
|
|
131
|
+
return /* @__PURE__ */ k(t) ? /* @__PURE__ */ X(t, {
|
|
132
|
+
...Ne(o, t.props),
|
|
133
133
|
ref: n ? Oe(n, t.ref) : t.ref
|
|
134
134
|
}) : y.count(t) > 1 ? y.only(null) : null;
|
|
135
135
|
});
|
|
136
|
-
|
|
137
|
-
const
|
|
138
|
-
function
|
|
139
|
-
return /* @__PURE__ */
|
|
136
|
+
G.displayName = "SlotClone";
|
|
137
|
+
const Ae = ({ children: e }) => /* @__PURE__ */ _(ee, null, e);
|
|
138
|
+
function De(e) {
|
|
139
|
+
return /* @__PURE__ */ k(e) && e.type === Ae;
|
|
140
140
|
}
|
|
141
|
-
function
|
|
141
|
+
function Ne(e, n) {
|
|
142
142
|
const t = {
|
|
143
143
|
...n
|
|
144
144
|
};
|
|
@@ -159,7 +159,7 @@ function Ce(e, n) {
|
|
|
159
159
|
...t
|
|
160
160
|
};
|
|
161
161
|
}
|
|
162
|
-
const
|
|
162
|
+
const Ce = [
|
|
163
163
|
"a",
|
|
164
164
|
"button",
|
|
165
165
|
"div",
|
|
@@ -176,7 +176,7 @@ const De = [
|
|
|
176
176
|
"span",
|
|
177
177
|
"svg",
|
|
178
178
|
"ul"
|
|
179
|
-
], Ee =
|
|
179
|
+
], Ee = Ce.reduce((e, n) => {
|
|
180
180
|
const t = /* @__PURE__ */ w((o, c) => {
|
|
181
181
|
const { asChild: r, ...a } = o, u = r ? ne : n;
|
|
182
182
|
return A(() => {
|
|
@@ -189,14 +189,14 @@ const De = [
|
|
|
189
189
|
...e,
|
|
190
190
|
[n]: t
|
|
191
191
|
};
|
|
192
|
-
}, {}),
|
|
192
|
+
}, {}), je = /* @__PURE__ */ w((e, n) => /* @__PURE__ */ _(Ee.label, W({}, e, {
|
|
193
193
|
ref: n,
|
|
194
194
|
onMouseDown: (t) => {
|
|
195
195
|
var o;
|
|
196
196
|
(o = e.onMouseDown) === null || o === void 0 || o.call(e, t), !t.defaultPrevented && t.detail > 1 && t.preventDefault();
|
|
197
197
|
}
|
|
198
|
-
}))),
|
|
199
|
-
function
|
|
198
|
+
}))), Re = je;
|
|
199
|
+
function Me(e) {
|
|
200
200
|
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
201
201
|
}
|
|
202
202
|
var oe = { exports: {} };
|
|
@@ -235,12 +235,12 @@ var oe = { exports: {} };
|
|
|
235
235
|
e.exports ? (t.default = t, e.exports = t) : window.classNames = t;
|
|
236
236
|
})();
|
|
237
237
|
})(oe);
|
|
238
|
-
var
|
|
239
|
-
const
|
|
238
|
+
var He = oe.exports;
|
|
239
|
+
const Le = /* @__PURE__ */ Me(He), I = {
|
|
240
240
|
"purpur-label": "_purpur-label_12cfi_1",
|
|
241
241
|
"purpur-label--negative": "_purpur-label--negative_12cfi_9",
|
|
242
242
|
"purpur-label--disabled": "_purpur-label--disabled_12cfi_12"
|
|
243
|
-
}, q = "purpur-label",
|
|
243
|
+
}, q = "purpur-label", Xe = ({
|
|
244
244
|
children: e,
|
|
245
245
|
className: n,
|
|
246
246
|
htmlFor: t,
|
|
@@ -249,7 +249,7 @@ const He = /* @__PURE__ */ Re(Me), I = {
|
|
|
249
249
|
negative: r = !1,
|
|
250
250
|
...a
|
|
251
251
|
}) => {
|
|
252
|
-
const u =
|
|
252
|
+
const u = Le([
|
|
253
253
|
n,
|
|
254
254
|
I[q],
|
|
255
255
|
{
|
|
@@ -257,9 +257,9 @@ const He = /* @__PURE__ */ Re(Me), I = {
|
|
|
257
257
|
[I[`${q}--negative`]]: r
|
|
258
258
|
}
|
|
259
259
|
]);
|
|
260
|
-
return /* @__PURE__ */ x(
|
|
260
|
+
return /* @__PURE__ */ x(Re, { className: u, "data-testid": o, htmlFor: t, ...a, children: e });
|
|
261
261
|
};
|
|
262
|
-
function
|
|
262
|
+
function Be(e) {
|
|
263
263
|
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
264
264
|
}
|
|
265
265
|
var ae = { exports: {} };
|
|
@@ -298,8 +298,8 @@ var ae = { exports: {} };
|
|
|
298
298
|
e.exports ? (t.default = t, e.exports = t) : window.classNames = t;
|
|
299
299
|
})();
|
|
300
300
|
})(ae);
|
|
301
|
-
var
|
|
302
|
-
const
|
|
301
|
+
var Te = ae.exports;
|
|
302
|
+
const ze = /* @__PURE__ */ Be(Te), E = {
|
|
303
303
|
"purpur-paragraph": "_purpur-paragraph_1rh57_1",
|
|
304
304
|
"purpur-paragraph--disabled": "_purpur-paragraph--disabled_1rh57_7",
|
|
305
305
|
"purpur-paragraph--hyphens": "_purpur-paragraph--hyphens_1rh57_10",
|
|
@@ -314,7 +314,7 @@ const Te = /* @__PURE__ */ Xe(Be), N = {
|
|
|
314
314
|
"purpur-paragraph--additional-100-medium": "_purpur-paragraph--additional-100-medium_1rh57_60",
|
|
315
315
|
"purpur-paragraph--overline-100": "_purpur-paragraph--overline-100_1rh57_67",
|
|
316
316
|
"purpur-paragraph--overline-200": "_purpur-paragraph--overline-200_1rh57_75"
|
|
317
|
-
},
|
|
317
|
+
}, Ie = {
|
|
318
318
|
PARAGRAPH100: "paragraph-100",
|
|
319
319
|
PARAGRAPH100MEDIUM: "paragraph-100-medium",
|
|
320
320
|
PARAGRAPH100BOLD: "paragraph-100-bold",
|
|
@@ -325,28 +325,29 @@ const Te = /* @__PURE__ */ Xe(Be), N = {
|
|
|
325
325
|
ADDITIONAL100MEDIUM: "additional-100-medium",
|
|
326
326
|
OVERLINE100: "overline-100",
|
|
327
327
|
OVERLINE200: "overline-200"
|
|
328
|
-
}, j = "purpur-paragraph",
|
|
328
|
+
}, j = "purpur-paragraph", ce = ({
|
|
329
329
|
["data-testid"]: e,
|
|
330
330
|
children: n,
|
|
331
|
-
className: t
|
|
331
|
+
className: t,
|
|
332
332
|
disabled: o,
|
|
333
333
|
enableHyphenation: c = !1,
|
|
334
334
|
negative: r = !1,
|
|
335
|
-
variant: a =
|
|
335
|
+
variant: a = Ie.PARAGRAPH100,
|
|
336
336
|
...u
|
|
337
337
|
}) => {
|
|
338
|
-
const i =
|
|
338
|
+
const i = ze([
|
|
339
339
|
t,
|
|
340
|
-
|
|
341
|
-
|
|
340
|
+
E[j],
|
|
341
|
+
E[`${j}--${a}`],
|
|
342
342
|
{
|
|
343
|
-
[
|
|
344
|
-
[
|
|
345
|
-
[
|
|
343
|
+
[E[`${j}--hyphens`]]: c,
|
|
344
|
+
[E[`${j}--disabled`]]: o,
|
|
345
|
+
[E[`${j}--negative`]]: r
|
|
346
346
|
}
|
|
347
347
|
]);
|
|
348
348
|
return /* @__PURE__ */ x("p", { ...u, className: i, "data-testid": e, children: n });
|
|
349
349
|
};
|
|
350
|
+
ce.displayName = "Paragraph";
|
|
350
351
|
function H() {
|
|
351
352
|
return H = Object.assign ? Object.assign.bind() : function(e) {
|
|
352
353
|
for (var n = 1; n < arguments.length; n++) {
|
|
@@ -359,25 +360,24 @@ function H() {
|
|
|
359
360
|
}
|
|
360
361
|
function qe(e, n, { checkForDefaultPrevented: t = !0 } = {}) {
|
|
361
362
|
return function(c) {
|
|
362
|
-
if (e == null || e(c), t === !1 || !c.defaultPrevented)
|
|
363
|
-
return n == null ? void 0 : n(c);
|
|
363
|
+
if (e == null || e(c), t === !1 || !c.defaultPrevented) return n == null ? void 0 : n(c);
|
|
364
364
|
};
|
|
365
365
|
}
|
|
366
366
|
function Fe(e, n) {
|
|
367
367
|
typeof e == "function" ? e(n) : e != null && (e.current = n);
|
|
368
368
|
}
|
|
369
|
-
function
|
|
369
|
+
function ue(...e) {
|
|
370
370
|
return (n) => e.forEach(
|
|
371
371
|
(t) => Fe(t, n)
|
|
372
372
|
);
|
|
373
373
|
}
|
|
374
|
-
function
|
|
375
|
-
return B(
|
|
374
|
+
function We(...e) {
|
|
375
|
+
return B(ue(...e), e);
|
|
376
376
|
}
|
|
377
|
-
function
|
|
377
|
+
function Ge(e, n = []) {
|
|
378
378
|
let t = [];
|
|
379
379
|
function o(r, a) {
|
|
380
|
-
const u = /* @__PURE__ */
|
|
380
|
+
const u = /* @__PURE__ */ J(a), i = t.length;
|
|
381
381
|
t = [
|
|
382
382
|
...t,
|
|
383
383
|
a
|
|
@@ -392,11 +392,9 @@ function We(e, n = []) {
|
|
|
392
392
|
}, v);
|
|
393
393
|
}
|
|
394
394
|
function h(l, p) {
|
|
395
|
-
const v = (p == null ? void 0 : p[e][i]) || u, f =
|
|
396
|
-
if (f)
|
|
397
|
-
|
|
398
|
-
if (a !== void 0)
|
|
399
|
-
return a;
|
|
395
|
+
const v = (p == null ? void 0 : p[e][i]) || u, f = ge(v);
|
|
396
|
+
if (f) return f;
|
|
397
|
+
if (a !== void 0) return a;
|
|
400
398
|
throw new Error(`\`${l}\` must be used within \`${r}\``);
|
|
401
399
|
}
|
|
402
400
|
return s.displayName = r + "Provider", [
|
|
@@ -405,7 +403,7 @@ function We(e, n = []) {
|
|
|
405
403
|
];
|
|
406
404
|
}
|
|
407
405
|
const c = () => {
|
|
408
|
-
const r = t.map((a) => /* @__PURE__ */
|
|
406
|
+
const r = t.map((a) => /* @__PURE__ */ J(a));
|
|
409
407
|
return function(u) {
|
|
410
408
|
const i = (u == null ? void 0 : u[e]) || r;
|
|
411
409
|
return R(
|
|
@@ -429,8 +427,7 @@ function We(e, n = []) {
|
|
|
429
427
|
}
|
|
430
428
|
function Ue(...e) {
|
|
431
429
|
const n = e[0];
|
|
432
|
-
if (e.length === 1)
|
|
433
|
-
return n;
|
|
430
|
+
if (e.length === 1) return n;
|
|
434
431
|
const t = () => {
|
|
435
432
|
const o = e.map(
|
|
436
433
|
(c) => ({
|
|
@@ -458,8 +455,8 @@ function Ue(...e) {
|
|
|
458
455
|
};
|
|
459
456
|
return t.scopeName = n.scopeName, t;
|
|
460
457
|
}
|
|
461
|
-
function
|
|
462
|
-
const n =
|
|
458
|
+
function ie(e) {
|
|
459
|
+
const n = D(e);
|
|
463
460
|
return A(() => {
|
|
464
461
|
n.current = e;
|
|
465
462
|
}), R(
|
|
@@ -470,17 +467,16 @@ function ue(e) {
|
|
|
470
467
|
[]
|
|
471
468
|
);
|
|
472
469
|
}
|
|
473
|
-
function
|
|
470
|
+
function Ve({ prop: e, defaultProp: n, onChange: t = () => {
|
|
474
471
|
} }) {
|
|
475
472
|
const [o, c] = Ze({
|
|
476
473
|
defaultProp: n,
|
|
477
474
|
onChange: t
|
|
478
|
-
}), r = e !== void 0, a = r ? e : o, u =
|
|
475
|
+
}), r = e !== void 0, a = r ? e : o, u = ie(t), i = B((s) => {
|
|
479
476
|
if (r) {
|
|
480
477
|
const l = typeof s == "function" ? s(e) : s;
|
|
481
478
|
l !== e && u(l);
|
|
482
|
-
} else
|
|
483
|
-
c(s);
|
|
479
|
+
} else c(s);
|
|
484
480
|
}, [
|
|
485
481
|
r,
|
|
486
482
|
e,
|
|
@@ -493,7 +489,7 @@ function Ge({ prop: e, defaultProp: n, onChange: t = () => {
|
|
|
493
489
|
];
|
|
494
490
|
}
|
|
495
491
|
function Ze({ defaultProp: e, onChange: n }) {
|
|
496
|
-
const t = $(e), [o] = t, c =
|
|
492
|
+
const t = $(e), [o] = t, c = D(o), r = ie(n);
|
|
497
493
|
return A(() => {
|
|
498
494
|
c.current !== o && (r(o), c.current = o);
|
|
499
495
|
}, [
|
|
@@ -502,8 +498,8 @@ function Ze({ defaultProp: e, onChange: n }) {
|
|
|
502
498
|
r
|
|
503
499
|
]), t;
|
|
504
500
|
}
|
|
505
|
-
function
|
|
506
|
-
const n =
|
|
501
|
+
function Ke(e) {
|
|
502
|
+
const n = D({
|
|
507
503
|
value: e,
|
|
508
504
|
previous: e
|
|
509
505
|
});
|
|
@@ -511,19 +507,18 @@ function Je(e) {
|
|
|
511
507
|
e
|
|
512
508
|
]);
|
|
513
509
|
}
|
|
514
|
-
const
|
|
510
|
+
const Je = globalThis != null && globalThis.document ? re : () => {
|
|
515
511
|
};
|
|
516
512
|
function Qe(e) {
|
|
517
513
|
const [n, t] = $(void 0);
|
|
518
|
-
return
|
|
514
|
+
return Je(() => {
|
|
519
515
|
if (e) {
|
|
520
516
|
t({
|
|
521
517
|
width: e.offsetWidth,
|
|
522
518
|
height: e.offsetHeight
|
|
523
519
|
});
|
|
524
520
|
const o = new ResizeObserver((c) => {
|
|
525
|
-
if (!Array.isArray(c) || !c.length)
|
|
526
|
-
return;
|
|
521
|
+
if (!Array.isArray(c) || !c.length) return;
|
|
527
522
|
const r = c[0];
|
|
528
523
|
let a, u;
|
|
529
524
|
if ("borderBoxSize" in r) {
|
|
@@ -555,30 +550,30 @@ function L() {
|
|
|
555
550
|
return e;
|
|
556
551
|
}, L.apply(this, arguments);
|
|
557
552
|
}
|
|
558
|
-
const
|
|
553
|
+
const se = /* @__PURE__ */ w((e, n) => {
|
|
559
554
|
const { children: t, ...o } = e, c = y.toArray(t), r = c.find(er);
|
|
560
555
|
if (r) {
|
|
561
|
-
const a = r.props.children, u = c.map((i) => i === r ? y.count(a) > 1 ? y.only(null) : /* @__PURE__ */
|
|
556
|
+
const a = r.props.children, u = c.map((i) => i === r ? y.count(a) > 1 ? y.only(null) : /* @__PURE__ */ k(a) ? a.props.children : null : i);
|
|
562
557
|
return /* @__PURE__ */ _(U, L({}, o, {
|
|
563
558
|
ref: n
|
|
564
|
-
}), /* @__PURE__ */
|
|
559
|
+
}), /* @__PURE__ */ k(a) ? /* @__PURE__ */ X(a, void 0, u) : null);
|
|
565
560
|
}
|
|
566
561
|
return /* @__PURE__ */ _(U, L({}, o, {
|
|
567
562
|
ref: n
|
|
568
563
|
}), t);
|
|
569
564
|
});
|
|
570
|
-
|
|
565
|
+
se.displayName = "Slot";
|
|
571
566
|
const U = /* @__PURE__ */ w((e, n) => {
|
|
572
567
|
const { children: t, ...o } = e;
|
|
573
|
-
return /* @__PURE__ */
|
|
568
|
+
return /* @__PURE__ */ k(t) ? /* @__PURE__ */ X(t, {
|
|
574
569
|
...rr(o, t.props),
|
|
575
|
-
ref: n ?
|
|
570
|
+
ref: n ? ue(n, t.ref) : t.ref
|
|
576
571
|
}) : y.count(t) > 1 ? y.only(null) : null;
|
|
577
572
|
});
|
|
578
573
|
U.displayName = "SlotClone";
|
|
579
574
|
const Ye = ({ children: e }) => /* @__PURE__ */ _(ee, null, e);
|
|
580
575
|
function er(e) {
|
|
581
|
-
return /* @__PURE__ */
|
|
576
|
+
return /* @__PURE__ */ k(e) && e.type === Ye;
|
|
582
577
|
}
|
|
583
578
|
function rr(e, n) {
|
|
584
579
|
const t = {
|
|
@@ -618,9 +613,9 @@ const tr = [
|
|
|
618
613
|
"span",
|
|
619
614
|
"svg",
|
|
620
615
|
"ul"
|
|
621
|
-
],
|
|
616
|
+
], le = tr.reduce((e, n) => {
|
|
622
617
|
const t = /* @__PURE__ */ w((o, c) => {
|
|
623
|
-
const { asChild: r, ...a } = o, u = r ?
|
|
618
|
+
const { asChild: r, ...a } = o, u = r ? se : n;
|
|
624
619
|
return A(() => {
|
|
625
620
|
window[Symbol.for("radix-ui")] = !0;
|
|
626
621
|
}, []), /* @__PURE__ */ _(u, L({}, a, {
|
|
@@ -631,11 +626,11 @@ const tr = [
|
|
|
631
626
|
...e,
|
|
632
627
|
[n]: t
|
|
633
628
|
};
|
|
634
|
-
}, {}),
|
|
635
|
-
const { __scopeSwitch: t, name: o, checked: c, defaultChecked: r, required: a, disabled: u, value: i = "on", onCheckedChange: s, ...h } = e, [l, p] = $(null), v =
|
|
629
|
+
}, {}), pe = "Switch", [nr, yr] = Ge(pe), [or, ar] = nr(pe), cr = /* @__PURE__ */ w((e, n) => {
|
|
630
|
+
const { __scopeSwitch: t, name: o, checked: c, defaultChecked: r, required: a, disabled: u, value: i = "on", onCheckedChange: s, ...h } = e, [l, p] = $(null), v = We(
|
|
636
631
|
n,
|
|
637
632
|
(m) => p(m)
|
|
638
|
-
), f =
|
|
633
|
+
), f = D(!1), g = l ? !!l.closest("form") : !0, [d = !1, b] = Ve({
|
|
639
634
|
prop: c,
|
|
640
635
|
defaultProp: r,
|
|
641
636
|
onChange: s
|
|
@@ -644,12 +639,12 @@ const tr = [
|
|
|
644
639
|
scope: t,
|
|
645
640
|
checked: d,
|
|
646
641
|
disabled: u
|
|
647
|
-
}, /* @__PURE__ */ _(
|
|
642
|
+
}, /* @__PURE__ */ _(le.button, H({
|
|
648
643
|
type: "button",
|
|
649
644
|
role: "switch",
|
|
650
645
|
"aria-checked": d,
|
|
651
646
|
"aria-required": a,
|
|
652
|
-
"data-state":
|
|
647
|
+
"data-state": de(d),
|
|
653
648
|
"data-disabled": u ? "" : void 0,
|
|
654
649
|
disabled: u,
|
|
655
650
|
value: i
|
|
@@ -657,7 +652,7 @@ const tr = [
|
|
|
657
652
|
ref: v,
|
|
658
653
|
onClick: qe(e.onClick, (m) => {
|
|
659
654
|
b(
|
|
660
|
-
(
|
|
655
|
+
(O) => !O
|
|
661
656
|
), g && (f.current = m.isPropagationStopped(), f.current || m.stopPropagation());
|
|
662
657
|
})
|
|
663
658
|
})), g && /* @__PURE__ */ _(sr, {
|
|
@@ -674,14 +669,14 @@ const tr = [
|
|
|
674
669
|
}));
|
|
675
670
|
}), ur = "SwitchThumb", ir = /* @__PURE__ */ w((e, n) => {
|
|
676
671
|
const { __scopeSwitch: t, ...o } = e, c = ar(ur, t);
|
|
677
|
-
return /* @__PURE__ */ _(
|
|
678
|
-
"data-state":
|
|
672
|
+
return /* @__PURE__ */ _(le.span, H({
|
|
673
|
+
"data-state": de(c.checked),
|
|
679
674
|
"data-disabled": c.disabled ? "" : void 0
|
|
680
675
|
}, o, {
|
|
681
676
|
ref: n
|
|
682
677
|
}));
|
|
683
678
|
}), sr = (e) => {
|
|
684
|
-
const { control: n, checked: t, bubbles: o = !0, ...c } = e, r =
|
|
679
|
+
const { control: n, checked: t, bubbles: o = !0, ...c } = e, r = D(null), a = Ke(t), u = Qe(n);
|
|
685
680
|
return A(() => {
|
|
686
681
|
const i = r.current, s = window.HTMLInputElement.prototype, l = Object.getOwnPropertyDescriptor(s, "checked").set;
|
|
687
682
|
if (a !== t && l) {
|
|
@@ -711,14 +706,14 @@ const tr = [
|
|
|
711
706
|
}
|
|
712
707
|
}));
|
|
713
708
|
};
|
|
714
|
-
function
|
|
709
|
+
function de(e) {
|
|
715
710
|
return e ? "checked" : "unchecked";
|
|
716
711
|
}
|
|
717
712
|
const lr = cr, pr = ir;
|
|
718
713
|
function dr(e) {
|
|
719
714
|
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
720
715
|
}
|
|
721
|
-
var
|
|
716
|
+
var fe = { exports: {} };
|
|
722
717
|
/*!
|
|
723
718
|
Copyright (c) 2018 Jed Watson.
|
|
724
719
|
Licensed under the MIT License (MIT), see
|
|
@@ -753,8 +748,8 @@ var de = { exports: {} };
|
|
|
753
748
|
}
|
|
754
749
|
e.exports ? (t.default = t, e.exports = t) : window.classNames = t;
|
|
755
750
|
})();
|
|
756
|
-
})(
|
|
757
|
-
var fr =
|
|
751
|
+
})(fe);
|
|
752
|
+
var fr = fe.exports;
|
|
758
753
|
const F = /* @__PURE__ */ dr(fr), S = {
|
|
759
754
|
"purpur-toggle": "_purpur-toggle_1xng6_1",
|
|
760
755
|
"purpur-toggle__track": "_purpur-toggle__track_1xng6_7",
|
|
@@ -785,12 +780,12 @@ const F = /* @__PURE__ */ dr(fr), S = {
|
|
|
785
780
|
(b) => {
|
|
786
781
|
if (typeof h != "number")
|
|
787
782
|
return;
|
|
788
|
-
const
|
|
789
|
-
if (!
|
|
783
|
+
const O = (Y(b) ? b.touches[0].clientX : b.clientX) - h;
|
|
784
|
+
if (!O)
|
|
790
785
|
return;
|
|
791
|
-
const
|
|
792
|
-
!p && Math.abs(
|
|
793
|
-
const T =
|
|
786
|
+
const N = a + O;
|
|
787
|
+
!p && Math.abs(N) && v(!0);
|
|
788
|
+
const T = N > r.right ? r.right : N < r.left ? r.left : N;
|
|
794
789
|
s(T), o == null || o({ x: T });
|
|
795
790
|
},
|
|
796
791
|
[o, s, p, h]
|
|
@@ -801,18 +796,18 @@ const F = /* @__PURE__ */ dr(fr), S = {
|
|
|
801
796
|
window.removeEventListener("mousemove", g), window.removeEventListener("touchmove", g);
|
|
802
797
|
}), [g]), A(() => (window.addEventListener("mouseup", d), window.addEventListener("touchend", d), () => {
|
|
803
798
|
window.removeEventListener("mouseup", d), window.removeEventListener("touchend", d);
|
|
804
|
-
}), [d]),
|
|
799
|
+
}), [d]), k(e) ? X(y.only(e), {
|
|
805
800
|
onMouseDown: f,
|
|
806
801
|
onTouchStart: f,
|
|
807
802
|
style: { ...u, transform: `translateX(${p ? i : a}px)` }
|
|
808
803
|
}) : null;
|
|
809
804
|
}, hr = ({ checked: e, onChange: n }) => {
|
|
810
|
-
var
|
|
811
|
-
const t =
|
|
805
|
+
var V, Z;
|
|
806
|
+
const t = D(null), o = D(null), [c, r] = $(void 0), [a, u] = $(!1), [i, s] = $(0), [h, l] = $(0), [p, v] = $(0);
|
|
812
807
|
re(() => {
|
|
813
|
-
var
|
|
814
|
-
l(((
|
|
815
|
-
}, [(
|
|
808
|
+
var C, z;
|
|
809
|
+
l(((C = o.current) == null ? void 0 : C.clientHeight) || 0), v(((z = t.current) == null ? void 0 : z.clientHeight) || 0);
|
|
810
|
+
}, [(V = o.current) == null ? void 0 : V.clientHeight, (Z = t.current) == null ? void 0 : Z.clientHeight]);
|
|
816
811
|
const f = (p || 0) - h, g = h + f, d = f / 2, b = g / 2, m = typeof c == "number" && (e ? c < b : c > b);
|
|
817
812
|
return {
|
|
818
813
|
trackRef: t,
|
|
@@ -820,8 +815,8 @@ const F = /* @__PURE__ */ dr(fr), S = {
|
|
|
820
815
|
isDragging: a,
|
|
821
816
|
bounds: { left: d, right: g },
|
|
822
817
|
position: e ? g : d,
|
|
823
|
-
onDrag: ({ x:
|
|
824
|
-
r(
|
|
818
|
+
onDrag: ({ x: C }) => {
|
|
819
|
+
r(C), Math.abs((e ? g : d) - C) > 2 && u(!0);
|
|
825
820
|
},
|
|
826
821
|
onStop: () => {
|
|
827
822
|
u(!1), a && s(Date.now()), m && (n == null || n(!e));
|
|
@@ -845,11 +840,11 @@ const F = /* @__PURE__ */ dr(fr), S = {
|
|
|
845
840
|
typeof r == "boolean" ? r : !!u
|
|
846
841
|
), p = !!(typeof r == "boolean" ? r : h), { thumbRef: v, trackRef: f, isDragging: g, onChangeWithDrag: d, ...b } = hr({
|
|
847
842
|
checked: p,
|
|
848
|
-
onChange: (
|
|
849
|
-
i.disabled || (o == null || o(
|
|
843
|
+
onChange: (O) => {
|
|
844
|
+
i.disabled || (o == null || o(O), l(O));
|
|
850
845
|
}
|
|
851
846
|
}), m = () => /* @__PURE__ */ x(
|
|
852
|
-
|
|
847
|
+
Xe,
|
|
853
848
|
{
|
|
854
849
|
htmlFor: i.id,
|
|
855
850
|
"data-testid": e && `${e}-label`,
|
|
@@ -858,10 +853,10 @@ const F = /* @__PURE__ */ dr(fr), S = {
|
|
|
858
853
|
S[`${P}__label`],
|
|
859
854
|
S[`${P}__label--${c}`]
|
|
860
855
|
),
|
|
861
|
-
children: /* @__PURE__ */ x(
|
|
856
|
+
children: /* @__PURE__ */ x(ce, { variant: "paragraph-100", disabled: i.disabled, children: t })
|
|
862
857
|
}
|
|
863
858
|
);
|
|
864
|
-
return /* @__PURE__ */
|
|
859
|
+
return /* @__PURE__ */ K("div", { className: F([n, S[`${P}__container`]]), children: [
|
|
865
860
|
t && c === "left" && m(),
|
|
866
861
|
/* @__PURE__ */ x(
|
|
867
862
|
lr,
|
|
@@ -873,12 +868,12 @@ const F = /* @__PURE__ */ dr(fr), S = {
|
|
|
873
868
|
className: S[P],
|
|
874
869
|
onCheckedChange: d,
|
|
875
870
|
checked: p,
|
|
876
|
-
children: /* @__PURE__ */
|
|
871
|
+
children: /* @__PURE__ */ K("span", { ref: f, className: S[`${P}__track`], children: [
|
|
877
872
|
/* @__PURE__ */ x("span", { className: S[`${P}__checkmark-container`], children: /* @__PURE__ */ x(
|
|
878
|
-
|
|
873
|
+
Pe,
|
|
879
874
|
{
|
|
880
875
|
className: S[`${P}__checkmark`],
|
|
881
|
-
svg:
|
|
876
|
+
svg: me,
|
|
882
877
|
size: "xxs"
|
|
883
878
|
}
|
|
884
879
|
) }),
|