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