@purpurds/toggle 8.8.1 → 8.9.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/styles.css +1 -1
- package/dist/toggle.cjs.js +1 -17
- package/dist/toggle.cjs.js.map +1 -1
- package/dist/toggle.es.js +256 -287
- package/dist/toggle.es.js.map +1 -1
- package/package.json +22 -22
package/dist/toggle.es.js
CHANGED
|
@@ -1,29 +1,23 @@
|
|
|
1
1
|
import { jsx as g, jsxs as O } from "react/jsx-runtime";
|
|
2
2
|
import * as s from "react";
|
|
3
|
-
import { useState as
|
|
3
|
+
import { useState as C, useCallback as A, useEffect as P, cloneElement as ue, isValidElement as se, useRef as E, forwardRef as ce } from "react";
|
|
4
4
|
import "react-dom";
|
|
5
5
|
function le(e) {
|
|
6
6
|
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
7
7
|
}
|
|
8
|
-
var j = { exports: {} };
|
|
9
|
-
/*!
|
|
10
|
-
Copyright (c) 2018 Jed Watson.
|
|
11
|
-
Licensed under the MIT License (MIT), see
|
|
12
|
-
http://jedwatson.github.io/classnames
|
|
13
|
-
*/
|
|
14
|
-
var q;
|
|
8
|
+
var j = { exports: {} }, q;
|
|
15
9
|
function pe() {
|
|
16
10
|
return q || (q = 1, (function(e) {
|
|
17
11
|
(function() {
|
|
18
12
|
var n = {}.hasOwnProperty;
|
|
19
13
|
function t() {
|
|
20
|
-
for (var r = "",
|
|
21
|
-
var
|
|
22
|
-
|
|
14
|
+
for (var r = "", i = 0; i < arguments.length; i++) {
|
|
15
|
+
var u = arguments[i];
|
|
16
|
+
u && (r = o(r, a.call(this, u)));
|
|
23
17
|
}
|
|
24
18
|
return r;
|
|
25
19
|
}
|
|
26
|
-
function
|
|
20
|
+
function a(r) {
|
|
27
21
|
if (typeof r == "string" || typeof r == "number")
|
|
28
22
|
return this && this[r] || r;
|
|
29
23
|
if (typeof r != "object")
|
|
@@ -32,20 +26,20 @@ function pe() {
|
|
|
32
26
|
return t.apply(this, r);
|
|
33
27
|
if (r.toString !== Object.prototype.toString && !r.toString.toString().includes("[native code]"))
|
|
34
28
|
return r.toString();
|
|
35
|
-
var
|
|
36
|
-
for (var
|
|
37
|
-
n.call(r,
|
|
38
|
-
return
|
|
29
|
+
var i = "";
|
|
30
|
+
for (var u in r)
|
|
31
|
+
n.call(r, u) && r[u] && (i = o(i, this && this[u] || u));
|
|
32
|
+
return i;
|
|
39
33
|
}
|
|
40
|
-
function o(r,
|
|
41
|
-
return
|
|
34
|
+
function o(r, i) {
|
|
35
|
+
return i ? r ? r + " " + i : r + i : r;
|
|
42
36
|
}
|
|
43
37
|
e.exports ? (t.default = t, e.exports = t) : window.classNames = t;
|
|
44
38
|
})();
|
|
45
39
|
})(j)), j.exports;
|
|
46
40
|
}
|
|
47
|
-
var
|
|
48
|
-
const
|
|
41
|
+
var de = pe();
|
|
42
|
+
const fe = /* @__PURE__ */ le(de), he = {
|
|
49
43
|
"purpur-icon": "_purpur-icon_8u1lq_1",
|
|
50
44
|
"purpur-icon--xxs": "_purpur-icon--xxs_8u1lq_4",
|
|
51
45
|
"purpur-icon--xs": "_purpur-icon--xs_8u1lq_8",
|
|
@@ -53,20 +47,20 @@ const de = /* @__PURE__ */ le(fe), he = {
|
|
|
53
47
|
"purpur-icon--md": "_purpur-icon--md_8u1lq_16",
|
|
54
48
|
"purpur-icon--lg": "_purpur-icon--lg_8u1lq_20",
|
|
55
49
|
"purpur-icon--xl": "_purpur-icon--xl_8u1lq_24"
|
|
56
|
-
}, ge =
|
|
50
|
+
}, ge = fe.bind(he), B = "purpur-icon", _e = "md", me = (e) => e.filter((n) => Object.keys(n).length >= 1).map((n) => `${n.name}="${n.value}"`).join(" "), ve = ({ content: e = "", title: n } = {}) => {
|
|
57
51
|
const t = [
|
|
58
52
|
{ name: "xmlns", value: "http://www.w3.org/2000/svg" },
|
|
59
53
|
{ name: "fill", value: "currentColor" },
|
|
60
54
|
{ name: "viewBox", value: "0 0 24 24" },
|
|
61
55
|
n ? { name: "role", value: "img" } : { name: "aria-hidden", value: "true" }
|
|
62
|
-
],
|
|
63
|
-
return `<svg ${me(t)}>${
|
|
64
|
-
}, be = (e) => e.replace(/<(\/?)svg([^>]*)>/g, "").trim(), J = ({ svg: e, allyTitle: n, className: t, size:
|
|
56
|
+
], a = n ? `<title>${n}</title>` : "";
|
|
57
|
+
return `<svg ${me(t)}>${a}${e}</svg>`;
|
|
58
|
+
}, be = (e) => e.replace(/<(\/?)svg([^>]*)>/g, "").trim(), J = ({ svg: e, allyTitle: n, className: t, size: a = _e, ...o }) => {
|
|
65
59
|
const r = ve({
|
|
66
60
|
content: be(e.svg),
|
|
67
61
|
title: n
|
|
68
|
-
}),
|
|
69
|
-
return /* @__PURE__ */ g("span", { className:
|
|
62
|
+
}), i = ge(B, `${B}--${a}`, t);
|
|
63
|
+
return /* @__PURE__ */ g("span", { className: i, dangerouslySetInnerHTML: { __html: r }, ...o });
|
|
70
64
|
};
|
|
71
65
|
J.displayName = "Icon";
|
|
72
66
|
const ye = {
|
|
@@ -83,20 +77,20 @@ function X(e, n) {
|
|
|
83
77
|
function we(...e) {
|
|
84
78
|
return (n) => {
|
|
85
79
|
let t = !1;
|
|
86
|
-
const
|
|
80
|
+
const a = e.map((o) => {
|
|
87
81
|
const r = X(o, n);
|
|
88
82
|
return !t && typeof r == "function" && (t = !0), r;
|
|
89
83
|
});
|
|
90
84
|
if (t)
|
|
91
85
|
return () => {
|
|
92
|
-
for (let o = 0; o <
|
|
93
|
-
const r =
|
|
86
|
+
for (let o = 0; o < a.length; o++) {
|
|
87
|
+
const r = a[o];
|
|
94
88
|
typeof r == "function" ? r() : X(e[o], null);
|
|
95
89
|
}
|
|
96
90
|
};
|
|
97
91
|
};
|
|
98
92
|
}
|
|
99
|
-
var Se = Symbol.for("react.lazy"),
|
|
93
|
+
var Se = Symbol.for("react.lazy"), k = s[" use ".trim().toString()];
|
|
100
94
|
function xe(e) {
|
|
101
95
|
return typeof e == "object" && e !== null && "then" in e;
|
|
102
96
|
}
|
|
@@ -104,52 +98,51 @@ function K(e) {
|
|
|
104
98
|
return e != null && typeof e == "object" && "$$typeof" in e && e.$$typeof === Se && "_payload" in e && xe(e._payload);
|
|
105
99
|
}
|
|
106
100
|
// @__NO_SIDE_EFFECTS__
|
|
107
|
-
function
|
|
108
|
-
const n = /* @__PURE__ */
|
|
109
|
-
let { children: r, ...
|
|
110
|
-
K(r) && typeof
|
|
111
|
-
const
|
|
101
|
+
function Ce(e) {
|
|
102
|
+
const n = /* @__PURE__ */ $e(e), t = s.forwardRef((a, o) => {
|
|
103
|
+
let { children: r, ...i } = a;
|
|
104
|
+
K(r) && typeof k == "function" && (r = k(r._payload));
|
|
105
|
+
const u = s.Children.toArray(r), c = u.find(Ee);
|
|
112
106
|
if (c) {
|
|
113
|
-
const l = c.props.children, d =
|
|
114
|
-
return /* @__PURE__ */ g(n, { ...
|
|
107
|
+
const l = c.props.children, d = u.map((p) => p === c ? s.Children.count(l) > 1 ? s.Children.only(null) : s.isValidElement(l) ? l.props.children : null : p);
|
|
108
|
+
return /* @__PURE__ */ g(n, { ...i, ref: o, children: s.isValidElement(l) ? s.cloneElement(l, void 0, d) : null });
|
|
115
109
|
}
|
|
116
|
-
return /* @__PURE__ */ g(n, { ...
|
|
110
|
+
return /* @__PURE__ */ g(n, { ...i, ref: o, children: r });
|
|
117
111
|
});
|
|
118
112
|
return t.displayName = `${e}.Slot`, t;
|
|
119
113
|
}
|
|
120
114
|
// @__NO_SIDE_EFFECTS__
|
|
121
|
-
function
|
|
122
|
-
const n = s.forwardRef((t,
|
|
115
|
+
function $e(e) {
|
|
116
|
+
const n = s.forwardRef((t, a) => {
|
|
123
117
|
let { children: o, ...r } = t;
|
|
124
|
-
if (K(o) && typeof
|
|
125
|
-
const
|
|
126
|
-
return o.type !== s.Fragment && (
|
|
118
|
+
if (K(o) && typeof k == "function" && (o = k(o._payload)), s.isValidElement(o)) {
|
|
119
|
+
const i = ke(o), u = Pe(r, o.props);
|
|
120
|
+
return o.type !== s.Fragment && (u.ref = a ? we(a, i) : i), s.cloneElement(o, u);
|
|
127
121
|
}
|
|
128
122
|
return s.Children.count(o) > 1 ? s.Children.only(null) : null;
|
|
129
123
|
});
|
|
130
124
|
return n.displayName = `${e}.SlotClone`, n;
|
|
131
125
|
}
|
|
132
126
|
var Re = Symbol("radix.slottable");
|
|
133
|
-
function
|
|
127
|
+
function Ee(e) {
|
|
134
128
|
return s.isValidElement(e) && typeof e.type == "function" && "__radixId" in e.type && e.type.__radixId === Re;
|
|
135
129
|
}
|
|
136
|
-
function
|
|
130
|
+
function Pe(e, n) {
|
|
137
131
|
const t = { ...n };
|
|
138
|
-
for (const
|
|
139
|
-
const o = e[
|
|
140
|
-
/^on[A-Z]/.test(
|
|
141
|
-
const
|
|
142
|
-
return o(...
|
|
143
|
-
} : o && (t[
|
|
132
|
+
for (const a in n) {
|
|
133
|
+
const o = e[a], r = n[a];
|
|
134
|
+
/^on[A-Z]/.test(a) ? o && r ? t[a] = (...i) => {
|
|
135
|
+
const u = r(...i);
|
|
136
|
+
return o(...i), u;
|
|
137
|
+
} : o && (t[a] = o) : a === "style" ? t[a] = { ...o, ...r } : a === "className" && (t[a] = [o, r].filter(Boolean).join(" "));
|
|
144
138
|
}
|
|
145
139
|
return { ...e, ...t };
|
|
146
140
|
}
|
|
147
|
-
function
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
return o ? e.ref : (i = (t = Object.getOwnPropertyDescriptor(e, "ref")) == null ? void 0 : t.get, o = i && "isReactWarning" in i && i.isReactWarning, o ? e.props.ref : e.props.ref || e.ref);
|
|
141
|
+
function ke(e) {
|
|
142
|
+
let n = Object.getOwnPropertyDescriptor(e.props, "ref")?.get, t = n && "isReactWarning" in n && n.isReactWarning;
|
|
143
|
+
return t ? e.ref : (n = Object.getOwnPropertyDescriptor(e, "ref")?.get, t = n && "isReactWarning" in n && n.isReactWarning, t ? e.props.ref : e.props.ref || e.ref);
|
|
151
144
|
}
|
|
152
|
-
var
|
|
145
|
+
var De = [
|
|
153
146
|
"a",
|
|
154
147
|
"button",
|
|
155
148
|
"div",
|
|
@@ -167,47 +160,40 @@ var Ne = [
|
|
|
167
160
|
"span",
|
|
168
161
|
"svg",
|
|
169
162
|
"ul"
|
|
170
|
-
],
|
|
171
|
-
const t = /* @__PURE__ */
|
|
172
|
-
const { asChild:
|
|
173
|
-
return typeof window < "u" && (window[Symbol.for("radix-ui")] = !0), /* @__PURE__ */ g(c, { ...
|
|
163
|
+
], Ne = De.reduce((e, n) => {
|
|
164
|
+
const t = /* @__PURE__ */ Ce(`Primitive.${n}`), a = s.forwardRef((o, r) => {
|
|
165
|
+
const { asChild: i, ...u } = o, c = i ? t : n;
|
|
166
|
+
return typeof window < "u" && (window[Symbol.for("radix-ui")] = !0), /* @__PURE__ */ g(c, { ...u, ref: r });
|
|
174
167
|
});
|
|
175
|
-
return
|
|
176
|
-
}, {}),
|
|
177
|
-
|
|
168
|
+
return a.displayName = `Primitive.${n}`, { ...e, [n]: a };
|
|
169
|
+
}, {}), ze = "Label", Q = s.forwardRef((e, n) => /* @__PURE__ */ g(
|
|
170
|
+
Ne.label,
|
|
178
171
|
{
|
|
179
172
|
...e,
|
|
180
173
|
ref: n,
|
|
181
174
|
onMouseDown: (t) => {
|
|
182
|
-
|
|
183
|
-
t.target.closest("button, input, select, textarea") || ((i = e.onMouseDown) == null || i.call(e, t), !t.defaultPrevented && t.detail > 1 && t.preventDefault());
|
|
175
|
+
t.target.closest("button, input, select, textarea") || (e.onMouseDown?.(t), !t.defaultPrevented && t.detail > 1 && t.preventDefault());
|
|
184
176
|
}
|
|
185
177
|
}
|
|
186
178
|
));
|
|
187
|
-
Q.displayName =
|
|
179
|
+
Q.displayName = ze;
|
|
188
180
|
var Oe = Q;
|
|
189
181
|
function Ae(e) {
|
|
190
182
|
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
191
183
|
}
|
|
192
|
-
var
|
|
193
|
-
/*!
|
|
194
|
-
Copyright (c) 2018 Jed Watson.
|
|
195
|
-
Licensed under the MIT License (MIT), see
|
|
196
|
-
http://jedwatson.github.io/classnames
|
|
197
|
-
*/
|
|
198
|
-
var W;
|
|
184
|
+
var H = { exports: {} }, L;
|
|
199
185
|
function Me() {
|
|
200
|
-
return
|
|
186
|
+
return L || (L = 1, (function(e) {
|
|
201
187
|
(function() {
|
|
202
188
|
var n = {}.hasOwnProperty;
|
|
203
189
|
function t() {
|
|
204
|
-
for (var r = "",
|
|
205
|
-
var
|
|
206
|
-
|
|
190
|
+
for (var r = "", i = 0; i < arguments.length; i++) {
|
|
191
|
+
var u = arguments[i];
|
|
192
|
+
u && (r = o(r, a.call(this, u)));
|
|
207
193
|
}
|
|
208
194
|
return r;
|
|
209
195
|
}
|
|
210
|
-
function
|
|
196
|
+
function a(r) {
|
|
211
197
|
if (typeof r == "string" || typeof r == "number")
|
|
212
198
|
return this && this[r] || r;
|
|
213
199
|
if (typeof r != "object")
|
|
@@ -216,58 +202,52 @@ function Me() {
|
|
|
216
202
|
return t.apply(this, r);
|
|
217
203
|
if (r.toString !== Object.prototype.toString && !r.toString.toString().includes("[native code]"))
|
|
218
204
|
return r.toString();
|
|
219
|
-
var
|
|
220
|
-
for (var
|
|
221
|
-
n.call(r,
|
|
222
|
-
return
|
|
205
|
+
var i = "";
|
|
206
|
+
for (var u in r)
|
|
207
|
+
n.call(r, u) && r[u] && (i = o(i, this && this[u] || u));
|
|
208
|
+
return i;
|
|
223
209
|
}
|
|
224
|
-
function o(r,
|
|
225
|
-
return
|
|
210
|
+
function o(r, i) {
|
|
211
|
+
return i ? r ? r + " " + i : r + i : r;
|
|
226
212
|
}
|
|
227
213
|
e.exports ? (t.default = t, e.exports = t) : window.classNames = t;
|
|
228
214
|
})();
|
|
229
|
-
})(
|
|
215
|
+
})(H)), H.exports;
|
|
230
216
|
}
|
|
231
217
|
var je = Me();
|
|
232
218
|
const qe = /* @__PURE__ */ Ae(je), Be = {
|
|
233
219
|
"purpur-label": "_purpur-label_1x80u_1",
|
|
234
220
|
"purpur-label--negative": "_purpur-label--negative_1x80u_8",
|
|
235
221
|
"purpur-label--disabled": "_purpur-label--disabled_1x80u_11"
|
|
236
|
-
}, Xe = qe.bind(Be),
|
|
222
|
+
}, Xe = qe.bind(Be), N = "purpur-label", He = ({
|
|
237
223
|
children: e,
|
|
238
224
|
className: n,
|
|
239
225
|
disabled: t,
|
|
240
|
-
negative:
|
|
226
|
+
negative: a = !1,
|
|
241
227
|
...o
|
|
242
228
|
}) => {
|
|
243
|
-
const r = Xe(n,
|
|
244
|
-
[`${
|
|
245
|
-
[`${
|
|
229
|
+
const r = Xe(n, N, {
|
|
230
|
+
[`${N}--disabled`]: t,
|
|
231
|
+
[`${N}--negative`]: a
|
|
246
232
|
});
|
|
247
233
|
return /* @__PURE__ */ g(Oe, { className: r, ...o, children: e });
|
|
248
234
|
};
|
|
249
|
-
function
|
|
235
|
+
function Le(e) {
|
|
250
236
|
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
251
237
|
}
|
|
252
|
-
var
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
Licensed under the MIT License (MIT), see
|
|
256
|
-
http://jedwatson.github.io/classnames
|
|
257
|
-
*/
|
|
258
|
-
var T;
|
|
259
|
-
function Ie() {
|
|
260
|
-
return T || (T = 1, (function(e) {
|
|
238
|
+
var W = { exports: {} }, I;
|
|
239
|
+
function We() {
|
|
240
|
+
return I || (I = 1, (function(e) {
|
|
261
241
|
(function() {
|
|
262
242
|
var n = {}.hasOwnProperty;
|
|
263
243
|
function t() {
|
|
264
|
-
for (var r = "",
|
|
265
|
-
var
|
|
266
|
-
|
|
244
|
+
for (var r = "", i = 0; i < arguments.length; i++) {
|
|
245
|
+
var u = arguments[i];
|
|
246
|
+
u && (r = o(r, a.call(this, u)));
|
|
267
247
|
}
|
|
268
248
|
return r;
|
|
269
249
|
}
|
|
270
|
-
function
|
|
250
|
+
function a(r) {
|
|
271
251
|
if (typeof r == "string" || typeof r == "number")
|
|
272
252
|
return this && this[r] || r;
|
|
273
253
|
if (typeof r != "object")
|
|
@@ -276,20 +256,20 @@ function Ie() {
|
|
|
276
256
|
return t.apply(this, r);
|
|
277
257
|
if (r.toString !== Object.prototype.toString && !r.toString.toString().includes("[native code]"))
|
|
278
258
|
return r.toString();
|
|
279
|
-
var
|
|
280
|
-
for (var
|
|
281
|
-
n.call(r,
|
|
282
|
-
return
|
|
259
|
+
var i = "";
|
|
260
|
+
for (var u in r)
|
|
261
|
+
n.call(r, u) && r[u] && (i = o(i, this && this[u] || u));
|
|
262
|
+
return i;
|
|
283
263
|
}
|
|
284
|
-
function o(r,
|
|
285
|
-
return
|
|
264
|
+
function o(r, i) {
|
|
265
|
+
return i ? r ? r + " " + i : r + i : r;
|
|
286
266
|
}
|
|
287
267
|
e.exports ? (t.default = t, e.exports = t) : window.classNames = t;
|
|
288
268
|
})();
|
|
289
|
-
})(
|
|
269
|
+
})(W)), W.exports;
|
|
290
270
|
}
|
|
291
|
-
var
|
|
292
|
-
const
|
|
271
|
+
var Ie = We();
|
|
272
|
+
const Te = /* @__PURE__ */ Le(Ie), Ve = {
|
|
293
273
|
"purpur-paragraph": "_purpur-paragraph_1rh57_1",
|
|
294
274
|
"purpur-paragraph--disabled": "_purpur-paragraph--disabled_1rh57_7",
|
|
295
275
|
"purpur-paragraph--hyphens": "_purpur-paragraph--hyphens_1rh57_10",
|
|
@@ -304,32 +284,32 @@ const Ve = /* @__PURE__ */ We(Te), He = {
|
|
|
304
284
|
"purpur-paragraph--additional-100-medium": "_purpur-paragraph--additional-100-medium_1rh57_60",
|
|
305
285
|
"purpur-paragraph--overline-100": "_purpur-paragraph--overline-100_1rh57_67",
|
|
306
286
|
"purpur-paragraph--overline-200": "_purpur-paragraph--overline-200_1rh57_75"
|
|
307
|
-
}, Fe =
|
|
287
|
+
}, Fe = Te.bind(Ve), Ue = {
|
|
308
288
|
PARAGRAPH100: "paragraph-100"
|
|
309
289
|
}, R = "purpur-paragraph", Y = ({
|
|
310
290
|
children: e,
|
|
311
291
|
className: n,
|
|
312
292
|
disabled: t,
|
|
313
|
-
enableHyphenation:
|
|
293
|
+
enableHyphenation: a = !1,
|
|
314
294
|
negative: o = !1,
|
|
315
295
|
variant: r = Ue.PARAGRAPH100,
|
|
316
|
-
...
|
|
296
|
+
...i
|
|
317
297
|
}) => {
|
|
318
|
-
const
|
|
319
|
-
[`${R}--hyphens`]:
|
|
298
|
+
const u = Fe(n, R, `${R}--${r}`, {
|
|
299
|
+
[`${R}--hyphens`]: a,
|
|
320
300
|
[`${R}--disabled`]: t,
|
|
321
301
|
[`${R}--negative`]: o
|
|
322
302
|
});
|
|
323
|
-
return /* @__PURE__ */ g("p", { ...
|
|
303
|
+
return /* @__PURE__ */ g("p", { ...i, className: u, children: e });
|
|
324
304
|
};
|
|
325
305
|
Y.displayName = "Paragraph";
|
|
326
306
|
function Ze(e, n, { checkForDefaultPrevented: t = !0 } = {}) {
|
|
327
307
|
return function(o) {
|
|
328
|
-
if (e
|
|
329
|
-
return n
|
|
308
|
+
if (e?.(o), t === !1 || !o.defaultPrevented)
|
|
309
|
+
return n?.(o);
|
|
330
310
|
};
|
|
331
311
|
}
|
|
332
|
-
function
|
|
312
|
+
function T(e, n) {
|
|
333
313
|
if (typeof e == "function")
|
|
334
314
|
return e(n);
|
|
335
315
|
e != null && (e.current = n);
|
|
@@ -337,15 +317,15 @@ function V(e, n) {
|
|
|
337
317
|
function ee(...e) {
|
|
338
318
|
return (n) => {
|
|
339
319
|
let t = !1;
|
|
340
|
-
const
|
|
341
|
-
const r =
|
|
320
|
+
const a = e.map((o) => {
|
|
321
|
+
const r = T(o, n);
|
|
342
322
|
return !t && typeof r == "function" && (t = !0), r;
|
|
343
323
|
});
|
|
344
324
|
if (t)
|
|
345
325
|
return () => {
|
|
346
|
-
for (let o = 0; o <
|
|
347
|
-
const r =
|
|
348
|
-
typeof r == "function" ? r() :
|
|
326
|
+
for (let o = 0; o < a.length; o++) {
|
|
327
|
+
const r = a[o];
|
|
328
|
+
typeof r == "function" ? r() : T(e[o], null);
|
|
349
329
|
}
|
|
350
330
|
};
|
|
351
331
|
};
|
|
@@ -355,50 +335,48 @@ function Ge(...e) {
|
|
|
355
335
|
}
|
|
356
336
|
function Je(e, n = []) {
|
|
357
337
|
let t = [];
|
|
358
|
-
function
|
|
359
|
-
const
|
|
360
|
-
t = [...t,
|
|
338
|
+
function a(r, i) {
|
|
339
|
+
const u = s.createContext(i), c = t.length;
|
|
340
|
+
t = [...t, i];
|
|
361
341
|
const l = (p) => {
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
return /* @__PURE__ */ g(m.Provider, { value: b, children: _ });
|
|
342
|
+
const { scope: f, children: _, ...h } = p, m = f?.[e]?.[c] || u, v = s.useMemo(() => h, Object.values(h));
|
|
343
|
+
return /* @__PURE__ */ g(m.Provider, { value: v, children: _ });
|
|
365
344
|
};
|
|
366
345
|
l.displayName = r + "Provider";
|
|
367
346
|
function d(p, f) {
|
|
368
|
-
|
|
369
|
-
const _ = ((m = f == null ? void 0 : f[e]) == null ? void 0 : m[c]) || a, h = s.useContext(_);
|
|
347
|
+
const _ = f?.[e]?.[c] || u, h = s.useContext(_);
|
|
370
348
|
if (h) return h;
|
|
371
|
-
if (
|
|
349
|
+
if (i !== void 0) return i;
|
|
372
350
|
throw new Error(`\`${p}\` must be used within \`${r}\``);
|
|
373
351
|
}
|
|
374
352
|
return [l, d];
|
|
375
353
|
}
|
|
376
354
|
const o = () => {
|
|
377
|
-
const r = t.map((
|
|
378
|
-
return function(
|
|
379
|
-
const c =
|
|
355
|
+
const r = t.map((i) => s.createContext(i));
|
|
356
|
+
return function(u) {
|
|
357
|
+
const c = u?.[e] || r;
|
|
380
358
|
return s.useMemo(
|
|
381
|
-
() => ({ [`__scope${e}`]: { ...
|
|
382
|
-
[
|
|
359
|
+
() => ({ [`__scope${e}`]: { ...u, [e]: c } }),
|
|
360
|
+
[u, c]
|
|
383
361
|
);
|
|
384
362
|
};
|
|
385
363
|
};
|
|
386
|
-
return o.scopeName = e, [
|
|
364
|
+
return o.scopeName = e, [a, Ke(o, ...n)];
|
|
387
365
|
}
|
|
388
366
|
function Ke(...e) {
|
|
389
367
|
const n = e[0];
|
|
390
368
|
if (e.length === 1) return n;
|
|
391
369
|
const t = () => {
|
|
392
|
-
const
|
|
370
|
+
const a = e.map((o) => ({
|
|
393
371
|
useScope: o(),
|
|
394
372
|
scopeName: o.scopeName
|
|
395
373
|
}));
|
|
396
374
|
return function(r) {
|
|
397
|
-
const
|
|
375
|
+
const i = a.reduce((u, { useScope: c, scopeName: l }) => {
|
|
398
376
|
const p = c(r)[`__scope${l}`];
|
|
399
|
-
return { ...
|
|
377
|
+
return { ...u, ...p };
|
|
400
378
|
}, {});
|
|
401
|
-
return s.useMemo(() => ({ [`__scope${n.scopeName}`]:
|
|
379
|
+
return s.useMemo(() => ({ [`__scope${n.scopeName}`]: i }), [i]);
|
|
402
380
|
};
|
|
403
381
|
};
|
|
404
382
|
return t.scopeName = n.scopeName, t;
|
|
@@ -407,10 +385,7 @@ function re(e) {
|
|
|
407
385
|
const n = s.useRef(e);
|
|
408
386
|
return s.useEffect(() => {
|
|
409
387
|
n.current = e;
|
|
410
|
-
}), s.useMemo(() => (...t) =>
|
|
411
|
-
var i;
|
|
412
|
-
return (i = n.current) == null ? void 0 : i.call(n, ...t);
|
|
413
|
-
}, []);
|
|
388
|
+
}), s.useMemo(() => (...t) => n.current?.(...t), []);
|
|
414
389
|
}
|
|
415
390
|
function Qe({
|
|
416
391
|
prop: e,
|
|
@@ -418,97 +393,96 @@ function Qe({
|
|
|
418
393
|
onChange: t = () => {
|
|
419
394
|
}
|
|
420
395
|
}) {
|
|
421
|
-
const [
|
|
396
|
+
const [a, o] = Ye({ defaultProp: n, onChange: t }), r = e !== void 0, i = r ? e : a, u = re(t), c = s.useCallback(
|
|
422
397
|
(l) => {
|
|
423
398
|
if (r) {
|
|
424
399
|
const p = typeof l == "function" ? l(e) : l;
|
|
425
|
-
p !== e &&
|
|
400
|
+
p !== e && u(p);
|
|
426
401
|
} else
|
|
427
402
|
o(l);
|
|
428
403
|
},
|
|
429
|
-
[r, e, o,
|
|
404
|
+
[r, e, o, u]
|
|
430
405
|
);
|
|
431
|
-
return [
|
|
406
|
+
return [i, c];
|
|
432
407
|
}
|
|
433
408
|
function Ye({
|
|
434
409
|
defaultProp: e,
|
|
435
410
|
onChange: n
|
|
436
411
|
}) {
|
|
437
|
-
const t = s.useState(e), [
|
|
412
|
+
const t = s.useState(e), [a] = t, o = s.useRef(a), r = re(n);
|
|
438
413
|
return s.useEffect(() => {
|
|
439
|
-
o.current !==
|
|
440
|
-
}, [
|
|
414
|
+
o.current !== a && (r(a), o.current = a);
|
|
415
|
+
}, [a, o, r]), t;
|
|
441
416
|
}
|
|
442
417
|
function er(e) {
|
|
443
418
|
const n = s.useRef({ value: e, previous: e });
|
|
444
419
|
return s.useMemo(() => (n.current.value !== e && (n.current.previous = n.current.value, n.current.value = e), n.current.previous), [e]);
|
|
445
420
|
}
|
|
446
|
-
var rr = globalThis
|
|
421
|
+
var rr = globalThis?.document ? s.useLayoutEffect : () => {
|
|
447
422
|
};
|
|
448
423
|
function tr(e) {
|
|
449
424
|
const [n, t] = s.useState(void 0);
|
|
450
425
|
return rr(() => {
|
|
451
426
|
if (e) {
|
|
452
427
|
t({ width: e.offsetWidth, height: e.offsetHeight });
|
|
453
|
-
const
|
|
428
|
+
const a = new ResizeObserver((o) => {
|
|
454
429
|
if (!Array.isArray(o) || !o.length)
|
|
455
430
|
return;
|
|
456
431
|
const r = o[0];
|
|
457
|
-
let
|
|
432
|
+
let i, u;
|
|
458
433
|
if ("borderBoxSize" in r) {
|
|
459
434
|
const c = r.borderBoxSize, l = Array.isArray(c) ? c[0] : c;
|
|
460
|
-
|
|
435
|
+
i = l.inlineSize, u = l.blockSize;
|
|
461
436
|
} else
|
|
462
|
-
|
|
463
|
-
t({ width:
|
|
437
|
+
i = e.offsetWidth, u = e.offsetHeight;
|
|
438
|
+
t({ width: i, height: u });
|
|
464
439
|
});
|
|
465
|
-
return
|
|
440
|
+
return a.observe(e, { box: "border-box" }), () => a.unobserve(e);
|
|
466
441
|
} else
|
|
467
442
|
t(void 0);
|
|
468
443
|
}, [e]), n;
|
|
469
444
|
}
|
|
470
445
|
// @__NO_SIDE_EFFECTS__
|
|
471
446
|
function nr(e) {
|
|
472
|
-
const n = /* @__PURE__ */ or(e), t = s.forwardRef((
|
|
473
|
-
const { children: r, ...
|
|
447
|
+
const n = /* @__PURE__ */ or(e), t = s.forwardRef((a, o) => {
|
|
448
|
+
const { children: r, ...i } = a, u = s.Children.toArray(r), c = u.find(ar);
|
|
474
449
|
if (c) {
|
|
475
|
-
const l = c.props.children, d =
|
|
476
|
-
return /* @__PURE__ */ g(n, { ...
|
|
450
|
+
const l = c.props.children, d = u.map((p) => p === c ? s.Children.count(l) > 1 ? s.Children.only(null) : s.isValidElement(l) ? l.props.children : null : p);
|
|
451
|
+
return /* @__PURE__ */ g(n, { ...i, ref: o, children: s.isValidElement(l) ? s.cloneElement(l, void 0, d) : null });
|
|
477
452
|
}
|
|
478
|
-
return /* @__PURE__ */ g(n, { ...
|
|
453
|
+
return /* @__PURE__ */ g(n, { ...i, ref: o, children: r });
|
|
479
454
|
});
|
|
480
455
|
return t.displayName = `${e}.Slot`, t;
|
|
481
456
|
}
|
|
482
457
|
// @__NO_SIDE_EFFECTS__
|
|
483
458
|
function or(e) {
|
|
484
|
-
const n = s.forwardRef((t,
|
|
459
|
+
const n = s.forwardRef((t, a) => {
|
|
485
460
|
const { children: o, ...r } = t;
|
|
486
461
|
if (s.isValidElement(o)) {
|
|
487
|
-
const
|
|
488
|
-
return o.type !== s.Fragment && (
|
|
462
|
+
const i = sr(o), u = ur(r, o.props);
|
|
463
|
+
return o.type !== s.Fragment && (u.ref = a ? ee(a, i) : i), s.cloneElement(o, u);
|
|
489
464
|
}
|
|
490
465
|
return s.Children.count(o) > 1 ? s.Children.only(null) : null;
|
|
491
466
|
});
|
|
492
467
|
return n.displayName = `${e}.SlotClone`, n;
|
|
493
468
|
}
|
|
494
469
|
var ir = Symbol("radix.slottable");
|
|
495
|
-
function
|
|
470
|
+
function ar(e) {
|
|
496
471
|
return s.isValidElement(e) && typeof e.type == "function" && "__radixId" in e.type && e.type.__radixId === ir;
|
|
497
472
|
}
|
|
498
|
-
function
|
|
473
|
+
function ur(e, n) {
|
|
499
474
|
const t = { ...n };
|
|
500
|
-
for (const
|
|
501
|
-
const o = e[
|
|
502
|
-
/^on[A-Z]/.test(
|
|
503
|
-
r(...
|
|
504
|
-
} : o && (t[
|
|
475
|
+
for (const a in n) {
|
|
476
|
+
const o = e[a], r = n[a];
|
|
477
|
+
/^on[A-Z]/.test(a) ? o && r ? t[a] = (...u) => {
|
|
478
|
+
r(...u), o(...u);
|
|
479
|
+
} : o && (t[a] = o) : a === "style" ? t[a] = { ...o, ...r } : a === "className" && (t[a] = [o, r].filter(Boolean).join(" "));
|
|
505
480
|
}
|
|
506
481
|
return { ...e, ...t };
|
|
507
482
|
}
|
|
508
483
|
function sr(e) {
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
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);
|
|
484
|
+
let n = Object.getOwnPropertyDescriptor(e.props, "ref")?.get, t = n && "isReactWarning" in n && n.isReactWarning;
|
|
485
|
+
return t ? e.ref : (n = Object.getOwnPropertyDescriptor(e, "ref")?.get, t = n && "isReactWarning" in n && n.isReactWarning, t ? e.props.ref : e.props.ref || e.ref);
|
|
512
486
|
}
|
|
513
487
|
var cr = [
|
|
514
488
|
"a",
|
|
@@ -528,58 +502,58 @@ var cr = [
|
|
|
528
502
|
"svg",
|
|
529
503
|
"ul"
|
|
530
504
|
], te = cr.reduce((e, n) => {
|
|
531
|
-
const t = /* @__PURE__ */ nr(`Primitive.${n}`),
|
|
532
|
-
const { asChild:
|
|
533
|
-
return typeof window < "u" && (window[Symbol.for("radix-ui")] = !0), /* @__PURE__ */ g(c, { ...
|
|
505
|
+
const t = /* @__PURE__ */ nr(`Primitive.${n}`), a = s.forwardRef((o, r) => {
|
|
506
|
+
const { asChild: i, ...u } = o, c = i ? t : n;
|
|
507
|
+
return typeof window < "u" && (window[Symbol.for("radix-ui")] = !0), /* @__PURE__ */ g(c, { ...u, ref: r });
|
|
534
508
|
});
|
|
535
|
-
return
|
|
536
|
-
}, {}), M = "Switch", [lr] = Je(M), [pr,
|
|
509
|
+
return a.displayName = `Primitive.${n}`, { ...e, [n]: a };
|
|
510
|
+
}, {}), M = "Switch", [lr] = Je(M), [pr, dr] = lr(M), ne = s.forwardRef(
|
|
537
511
|
(e, n) => {
|
|
538
512
|
const {
|
|
539
513
|
__scopeSwitch: t,
|
|
540
|
-
name:
|
|
514
|
+
name: a,
|
|
541
515
|
checked: o,
|
|
542
516
|
defaultChecked: r,
|
|
543
|
-
required:
|
|
544
|
-
disabled:
|
|
517
|
+
required: i,
|
|
518
|
+
disabled: u,
|
|
545
519
|
value: c = "on",
|
|
546
520
|
onCheckedChange: l,
|
|
547
521
|
form: d,
|
|
548
522
|
...p
|
|
549
|
-
} = e, [f, _] = s.useState(null), h = Ge(n, (y) => _(y)), m = s.useRef(!1),
|
|
523
|
+
} = e, [f, _] = s.useState(null), h = Ge(n, (y) => _(y)), m = s.useRef(!1), v = f ? d || !!f.closest("form") : !0, [b = !1, x] = Qe({
|
|
550
524
|
prop: o,
|
|
551
525
|
defaultProp: r,
|
|
552
526
|
onChange: l
|
|
553
527
|
});
|
|
554
|
-
return /* @__PURE__ */ O(pr, { scope: t, checked:
|
|
528
|
+
return /* @__PURE__ */ O(pr, { scope: t, checked: b, disabled: u, children: [
|
|
555
529
|
/* @__PURE__ */ g(
|
|
556
530
|
te.button,
|
|
557
531
|
{
|
|
558
532
|
type: "button",
|
|
559
533
|
role: "switch",
|
|
560
|
-
"aria-checked":
|
|
561
|
-
"aria-required":
|
|
562
|
-
"data-state":
|
|
563
|
-
"data-disabled":
|
|
564
|
-
disabled:
|
|
534
|
+
"aria-checked": b,
|
|
535
|
+
"aria-required": i,
|
|
536
|
+
"data-state": ae(b),
|
|
537
|
+
"data-disabled": u ? "" : void 0,
|
|
538
|
+
disabled: u,
|
|
565
539
|
value: c,
|
|
566
540
|
...p,
|
|
567
541
|
ref: h,
|
|
568
542
|
onClick: Ze(e.onClick, (y) => {
|
|
569
|
-
x((w) => !w),
|
|
543
|
+
x((w) => !w), v && (m.current = y.isPropagationStopped(), m.current || y.stopPropagation());
|
|
570
544
|
})
|
|
571
545
|
}
|
|
572
546
|
),
|
|
573
|
-
|
|
574
|
-
|
|
547
|
+
v && /* @__PURE__ */ g(
|
|
548
|
+
fr,
|
|
575
549
|
{
|
|
576
550
|
control: f,
|
|
577
551
|
bubbles: !m.current,
|
|
578
|
-
name:
|
|
552
|
+
name: a,
|
|
579
553
|
value: c,
|
|
580
|
-
checked:
|
|
581
|
-
required:
|
|
582
|
-
disabled:
|
|
554
|
+
checked: b,
|
|
555
|
+
required: i,
|
|
556
|
+
disabled: u,
|
|
583
557
|
form: d,
|
|
584
558
|
style: { transform: "translateX(-100%)" }
|
|
585
559
|
}
|
|
@@ -590,28 +564,28 @@ var cr = [
|
|
|
590
564
|
ne.displayName = M;
|
|
591
565
|
var oe = "SwitchThumb", ie = s.forwardRef(
|
|
592
566
|
(e, n) => {
|
|
593
|
-
const { __scopeSwitch: t, ...
|
|
567
|
+
const { __scopeSwitch: t, ...a } = e, o = dr(oe, t);
|
|
594
568
|
return /* @__PURE__ */ g(
|
|
595
569
|
te.span,
|
|
596
570
|
{
|
|
597
|
-
"data-state":
|
|
571
|
+
"data-state": ae(o.checked),
|
|
598
572
|
"data-disabled": o.disabled ? "" : void 0,
|
|
599
|
-
...
|
|
573
|
+
...a,
|
|
600
574
|
ref: n
|
|
601
575
|
}
|
|
602
576
|
);
|
|
603
577
|
}
|
|
604
578
|
);
|
|
605
579
|
ie.displayName = oe;
|
|
606
|
-
var
|
|
607
|
-
const { control: n, checked: t, bubbles:
|
|
580
|
+
var fr = (e) => {
|
|
581
|
+
const { control: n, checked: t, bubbles: a = !0, ...o } = e, r = s.useRef(null), i = er(t), u = tr(n);
|
|
608
582
|
return s.useEffect(() => {
|
|
609
583
|
const c = r.current, l = window.HTMLInputElement.prototype, p = Object.getOwnPropertyDescriptor(l, "checked").set;
|
|
610
|
-
if (
|
|
611
|
-
const f = new Event("click", { bubbles:
|
|
584
|
+
if (i !== t && p) {
|
|
585
|
+
const f = new Event("click", { bubbles: a });
|
|
612
586
|
p.call(c, t), c.dispatchEvent(f);
|
|
613
587
|
}
|
|
614
|
-
}, [
|
|
588
|
+
}, [i, t, a]), /* @__PURE__ */ g(
|
|
615
589
|
"input",
|
|
616
590
|
{
|
|
617
591
|
type: "checkbox",
|
|
@@ -622,7 +596,7 @@ var dr = (e) => {
|
|
|
622
596
|
ref: r,
|
|
623
597
|
style: {
|
|
624
598
|
...e.style,
|
|
625
|
-
...
|
|
599
|
+
...u,
|
|
626
600
|
position: "absolute",
|
|
627
601
|
pointerEvents: "none",
|
|
628
602
|
opacity: 0,
|
|
@@ -631,32 +605,27 @@ var dr = (e) => {
|
|
|
631
605
|
}
|
|
632
606
|
);
|
|
633
607
|
};
|
|
634
|
-
function
|
|
608
|
+
function ae(e) {
|
|
635
609
|
return e ? "checked" : "unchecked";
|
|
636
610
|
}
|
|
637
611
|
var hr = ne, gr = ie;
|
|
638
612
|
function _r(e) {
|
|
639
613
|
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
640
614
|
}
|
|
641
|
-
var
|
|
642
|
-
|
|
643
|
-
Copyright (c) 2018 Jed Watson.
|
|
644
|
-
Licensed under the MIT License (MIT), see
|
|
645
|
-
http://jedwatson.github.io/classnames
|
|
646
|
-
*/
|
|
647
|
-
var H;
|
|
615
|
+
var z = { exports: {} };
|
|
616
|
+
var V;
|
|
648
617
|
function mr() {
|
|
649
|
-
return
|
|
618
|
+
return V || (V = 1, (function(e) {
|
|
650
619
|
(function() {
|
|
651
620
|
var n = {}.hasOwnProperty;
|
|
652
621
|
function t() {
|
|
653
|
-
for (var r = "",
|
|
654
|
-
var
|
|
655
|
-
|
|
622
|
+
for (var r = "", i = 0; i < arguments.length; i++) {
|
|
623
|
+
var u = arguments[i];
|
|
624
|
+
u && (r = o(r, a.call(this, u)));
|
|
656
625
|
}
|
|
657
626
|
return r;
|
|
658
627
|
}
|
|
659
|
-
function
|
|
628
|
+
function a(r) {
|
|
660
629
|
if (typeof r == "string" || typeof r == "number")
|
|
661
630
|
return this && this[r] || r;
|
|
662
631
|
if (typeof r != "object")
|
|
@@ -665,84 +634,84 @@ function mr() {
|
|
|
665
634
|
return t.apply(this, r);
|
|
666
635
|
if (r.toString !== Object.prototype.toString && !r.toString.toString().includes("[native code]"))
|
|
667
636
|
return r.toString();
|
|
668
|
-
var
|
|
669
|
-
for (var
|
|
670
|
-
n.call(r,
|
|
671
|
-
return
|
|
637
|
+
var i = "";
|
|
638
|
+
for (var u in r)
|
|
639
|
+
n.call(r, u) && r[u] && (i = o(i, this && this[u] || u));
|
|
640
|
+
return i;
|
|
672
641
|
}
|
|
673
|
-
function o(r,
|
|
674
|
-
return
|
|
642
|
+
function o(r, i) {
|
|
643
|
+
return i ? r ? r + " " + i : r + i : r;
|
|
675
644
|
}
|
|
676
645
|
e.exports ? (t.default = t, e.exports = t) : window.classNames = t;
|
|
677
646
|
})();
|
|
678
|
-
})(
|
|
647
|
+
})(z)), z.exports;
|
|
679
648
|
}
|
|
680
649
|
var vr = mr();
|
|
681
650
|
const br = /* @__PURE__ */ _r(vr), F = (e) => e && "touches" in e, yr = ({
|
|
682
651
|
children: e,
|
|
683
652
|
disabled: n,
|
|
684
653
|
onStart: t,
|
|
685
|
-
onDrag:
|
|
654
|
+
onDrag: a,
|
|
686
655
|
onStop: o,
|
|
687
656
|
bounds: r,
|
|
688
|
-
position:
|
|
689
|
-
style:
|
|
657
|
+
position: i,
|
|
658
|
+
style: u
|
|
690
659
|
}) => {
|
|
691
|
-
const [c, l] =
|
|
660
|
+
const [c, l] = C(void 0), [d, p] = C(void 0), [f, _] = C(!1), h = (b) => {
|
|
692
661
|
if (!n) {
|
|
693
|
-
|
|
694
|
-
const x = F(
|
|
695
|
-
p(x), t
|
|
662
|
+
b.preventDefault();
|
|
663
|
+
const x = F(b.nativeEvent) ? b.nativeEvent.touches[0].clientX : b.nativeEvent.clientX;
|
|
664
|
+
p(x), t?.();
|
|
696
665
|
}
|
|
697
666
|
}, m = A(
|
|
698
|
-
(
|
|
667
|
+
(b) => {
|
|
699
668
|
if (typeof d != "number")
|
|
700
669
|
return;
|
|
701
|
-
const y = (F(
|
|
670
|
+
const y = (F(b) ? b.touches[0].clientX : b.clientX) - d;
|
|
702
671
|
if (!y)
|
|
703
672
|
return;
|
|
704
|
-
const w =
|
|
673
|
+
const w = i + y;
|
|
705
674
|
!f && Math.abs(w) && _(!0);
|
|
706
|
-
const
|
|
707
|
-
l(
|
|
675
|
+
const D = w > r.right ? r.right : w < r.left ? r.left : w;
|
|
676
|
+
l(D), a?.({ x: D });
|
|
708
677
|
},
|
|
709
678
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
710
|
-
[
|
|
711
|
-
),
|
|
712
|
-
p(void 0), l(void 0), _(!1), o
|
|
679
|
+
[a, l, f, d]
|
|
680
|
+
), v = A(() => {
|
|
681
|
+
p(void 0), l(void 0), _(!1), o?.();
|
|
713
682
|
}, [o, p]);
|
|
714
|
-
return
|
|
683
|
+
return P(() => (window.addEventListener("mousemove", m), window.addEventListener("touchmove", m), () => {
|
|
715
684
|
window.removeEventListener("mousemove", m), window.removeEventListener("touchmove", m);
|
|
716
|
-
}), [m]),
|
|
717
|
-
window.removeEventListener("mouseup",
|
|
718
|
-
}), [
|
|
685
|
+
}), [m]), P(() => (window.addEventListener("mouseup", v), window.addEventListener("touchend", v), () => {
|
|
686
|
+
window.removeEventListener("mouseup", v), window.removeEventListener("touchend", v);
|
|
687
|
+
}), [v]), se(e) ? ue(e, {
|
|
719
688
|
onMouseDown: h,
|
|
720
689
|
onTouchStart: h,
|
|
721
|
-
style: { ...
|
|
690
|
+
style: { ...u, transform: `translateX(${f ? c : i}px)` }
|
|
722
691
|
}) : null;
|
|
723
692
|
}, U = {
|
|
724
693
|
width: void 0,
|
|
725
694
|
height: void 0
|
|
726
695
|
};
|
|
727
696
|
function Z(e) {
|
|
728
|
-
const { ref: n, box: t = "content-box", round:
|
|
729
|
-
return l.current = e.onResize,
|
|
697
|
+
const { ref: n, box: t = "content-box", round: a } = e, [{ width: o, height: r }, i] = C(U), u = wr(), c = E({ ...U }), l = E(void 0);
|
|
698
|
+
return l.current = e.onResize, P(() => {
|
|
730
699
|
if (!n.current || typeof window > "u" || !("ResizeObserver" in window))
|
|
731
700
|
return;
|
|
732
701
|
const d = new ResizeObserver(([p]) => {
|
|
733
702
|
const f = t === "border-box" ? "borderBoxSize" : t === "device-pixel-content-box" ? "devicePixelContentBoxSize" : "contentBoxSize", _ = G(p, f, "inlineSize"), h = G(p, f, "blockSize");
|
|
734
703
|
if (c.current.width !== _ || c.current.height !== h) {
|
|
735
|
-
const
|
|
736
|
-
width: _ &&
|
|
737
|
-
height: h &&
|
|
704
|
+
const v = {
|
|
705
|
+
width: _ && a ? Math.round(_) : _,
|
|
706
|
+
height: h && a ? Math.round(h) : h
|
|
738
707
|
};
|
|
739
|
-
c.current.width = _, c.current.height = h, l.current ? l.current(
|
|
708
|
+
c.current.width = _, c.current.height = h, l.current ? l.current(v) : u() && i(v);
|
|
740
709
|
}
|
|
741
710
|
});
|
|
742
711
|
return d.observe(n.current, { box: t }), () => {
|
|
743
712
|
d.disconnect();
|
|
744
713
|
};
|
|
745
|
-
}, [t, n,
|
|
714
|
+
}, [t, n, u, a]), { width: o, height: r };
|
|
746
715
|
}
|
|
747
716
|
function G(e, n, t) {
|
|
748
717
|
return e[n] ? Array.isArray(e[n]) ? e[n][0][t] : (
|
|
@@ -752,27 +721,27 @@ function G(e, n, t) {
|
|
|
752
721
|
) : n === "contentBoxSize" ? e.contentRect[t === "inlineSize" ? "width" : "height"] : void 0;
|
|
753
722
|
}
|
|
754
723
|
function wr() {
|
|
755
|
-
const e =
|
|
756
|
-
return
|
|
724
|
+
const e = E(!1);
|
|
725
|
+
return P(() => (e.current = !0, () => {
|
|
757
726
|
e.current = !1;
|
|
758
727
|
}), []), A(() => e.current, []);
|
|
759
728
|
}
|
|
760
729
|
const Sr = ({ checked: e, onChange: n }) => {
|
|
761
|
-
const t =
|
|
730
|
+
const t = E(null), a = E(null), [o, r] = C(void 0), [i, u] = C(!1), [c, l] = C(0), { height: d = 0 } = Z({ ref: a, round: !0 }), { height: p = 0 } = Z({ ref: t, round: !0 }), f = (p || 0) - d, _ = d + f, h = f / 2, m = _ / 2, v = typeof o == "number" && (e ? o < m : o > m);
|
|
762
731
|
return {
|
|
763
732
|
trackRef: t,
|
|
764
|
-
thumbRef:
|
|
765
|
-
isDragging:
|
|
733
|
+
thumbRef: a,
|
|
734
|
+
isDragging: i,
|
|
766
735
|
bounds: { left: h, right: _ },
|
|
767
736
|
position: e ? _ : h,
|
|
768
737
|
onDrag: ({ x: w }) => {
|
|
769
|
-
r(w), Math.abs((e ? _ : h) - w) > 2 &&
|
|
738
|
+
r(w), Math.abs((e ? _ : h) - w) > 2 && u(!0);
|
|
770
739
|
},
|
|
771
740
|
onStop: () => {
|
|
772
|
-
|
|
741
|
+
u(!1), i && l(Date.now()), v && n?.(!e);
|
|
773
742
|
},
|
|
774
743
|
onChangeWithDrag: () => {
|
|
775
|
-
Date.now() - c > 50 &&
|
|
744
|
+
Date.now() - c > 50 && n?.(!e), r(void 0);
|
|
776
745
|
}
|
|
777
746
|
};
|
|
778
747
|
}, xr = {
|
|
@@ -785,36 +754,36 @@ const Sr = ({ checked: e, onChange: n }) => {
|
|
|
785
754
|
"purpur-toggle__label--right": "_purpur-toggle__label--right_zqs8u_110",
|
|
786
755
|
"purpur-toggle__label--left": "_purpur-toggle__label--left_zqs8u_113",
|
|
787
756
|
"purpur-toggle__container": "_purpur-toggle__container_zqs8u_116"
|
|
788
|
-
},
|
|
757
|
+
}, $ = br.bind(xr), S = "purpur-toggle", Cr = ce(
|
|
789
758
|
({
|
|
790
759
|
["data-testid"]: e,
|
|
791
760
|
className: n,
|
|
792
761
|
label: t,
|
|
793
|
-
onChange:
|
|
762
|
+
onChange: a,
|
|
794
763
|
labelPosition: o = "right",
|
|
795
764
|
checked: r,
|
|
796
|
-
disableDrag:
|
|
797
|
-
defaultChecked:
|
|
765
|
+
disableDrag: i,
|
|
766
|
+
defaultChecked: u,
|
|
798
767
|
...c
|
|
799
768
|
}, l) => {
|
|
800
|
-
const [d, p] =
|
|
801
|
-
typeof r == "boolean" ? r : !!
|
|
802
|
-
), f = !!(typeof r == "boolean" ? r : d), { thumbRef: _, trackRef: h, isDragging: m, onChangeWithDrag:
|
|
769
|
+
const [d, p] = C(
|
|
770
|
+
typeof r == "boolean" ? r : !!u
|
|
771
|
+
), f = !!(typeof r == "boolean" ? r : d), { thumbRef: _, trackRef: h, isDragging: m, onChangeWithDrag: v, ...b } = Sr({
|
|
803
772
|
checked: f,
|
|
804
773
|
onChange: (y) => {
|
|
805
|
-
c.disabled || (
|
|
774
|
+
c.disabled || (a?.(y), p(y));
|
|
806
775
|
}
|
|
807
776
|
}), x = () => /* @__PURE__ */ g(
|
|
808
|
-
|
|
777
|
+
He,
|
|
809
778
|
{
|
|
810
779
|
htmlFor: c.id,
|
|
811
780
|
"data-testid": e && `${e}-label`,
|
|
812
781
|
disabled: c.disabled,
|
|
813
|
-
className:
|
|
782
|
+
className: $(`${S}__label`, `${S}__label--${o}`),
|
|
814
783
|
children: /* @__PURE__ */ g(Y, { disabled: c.disabled, children: t })
|
|
815
784
|
}
|
|
816
785
|
);
|
|
817
|
-
return /* @__PURE__ */ O("div", { className:
|
|
786
|
+
return /* @__PURE__ */ O("div", { className: $(n, `${S}__container`), children: [
|
|
818
787
|
t && o === "left" && x(),
|
|
819
788
|
/* @__PURE__ */ g(
|
|
820
789
|
hr,
|
|
@@ -823,17 +792,17 @@ const Sr = ({ checked: e, onChange: n }) => {
|
|
|
823
792
|
ref: l,
|
|
824
793
|
id: c.id,
|
|
825
794
|
"data-testid": e,
|
|
826
|
-
className:
|
|
827
|
-
onCheckedChange:
|
|
795
|
+
className: $(S),
|
|
796
|
+
onCheckedChange: v,
|
|
828
797
|
checked: f,
|
|
829
|
-
children: /* @__PURE__ */ O("span", { ref: h, className:
|
|
830
|
-
/* @__PURE__ */ g("span", { className:
|
|
831
|
-
/* @__PURE__ */ g(yr, { disabled:
|
|
798
|
+
children: /* @__PURE__ */ O("span", { ref: h, className: $(`${S}__track`), children: [
|
|
799
|
+
/* @__PURE__ */ g("span", { className: $(`${S}__checkmark-container`), children: /* @__PURE__ */ g(J, { className: $(`${S}__checkmark`), svg: ye, size: "xxs" }) }),
|
|
800
|
+
/* @__PURE__ */ g(yr, { disabled: i, ...b, children: /* @__PURE__ */ g(
|
|
832
801
|
gr,
|
|
833
802
|
{
|
|
834
803
|
ref: _,
|
|
835
804
|
"data-testid": e && `${e}-thumb`,
|
|
836
|
-
className:
|
|
805
|
+
className: $(`${S}__thumb`, {
|
|
837
806
|
[`${S}__thumb--dragging`]: m
|
|
838
807
|
})
|
|
839
808
|
}
|
|
@@ -845,8 +814,8 @@ const Sr = ({ checked: e, onChange: n }) => {
|
|
|
845
814
|
] });
|
|
846
815
|
}
|
|
847
816
|
);
|
|
848
|
-
|
|
817
|
+
Cr.displayName = "Toggle";
|
|
849
818
|
export {
|
|
850
|
-
|
|
819
|
+
Cr as Toggle
|
|
851
820
|
};
|
|
852
821
|
//# sourceMappingURL=toggle.es.js.map
|