@krosoft/react 0.0.73 → 0.0.75

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.
@@ -1,856 +0,0 @@
1
- import { jsx as d, jsxs as re, Fragment as fe } from "react/jsx-runtime";
2
- import * as o from "react";
3
- import F from "react";
4
- import { c as pe, q as me, u as k, a as Q, d as $e, e as A, f as W, p as z, v as je } from "./index-BQOmHRsD.js";
5
- import { c as R } from "./index-gWiv5-6R.js";
6
- import * as ve from "react-dom";
7
- import Xe from "react-dom";
8
- import { c as Ye } from "./createLucideIcon-CRdjzt2A.js";
9
- const ze = pe(
10
- "relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",
11
- {
12
- variants: {
13
- variant: {
14
- default: "bg-background text-foreground",
15
- destructive: "border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"
16
- }
17
- },
18
- defaultVariants: {
19
- variant: "default"
20
- }
21
- }
22
- ), qe = o.forwardRef(
23
- ({ className: e, variant: t, ...n }, r) => /* @__PURE__ */ d("div", { ref: r, role: "alert", className: R(ze({ variant: t }), e), ...n })
24
- );
25
- qe.displayName = "Alert";
26
- const Ge = o.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ d("h5", { ref: n, className: R("mb-1 font-medium leading-none tracking-tight", e), ...t }));
27
- Ge.displayName = "AlertTitle";
28
- const Je = o.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ d("div", { ref: n, className: R("text-sm [&_p]:leading-relaxed", e), ...t }));
29
- Je.displayName = "AlertDescription";
30
- const Qe = o.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ d("div", { ref: n, className: R("rounded-lg border bg-card text-card-foreground shadow-sm", e), ...t }));
31
- Qe.displayName = "Card";
32
- const Ze = o.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ d("div", { ref: n, className: R("flex flex-col space-y-1.5 p-6", e), ...t }));
33
- Ze.displayName = "CardHeader";
34
- const et = o.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ d("h3", { ref: n, className: R("text-2xl font-semibold leading-none tracking-tight", e), ...t }));
35
- et.displayName = "CardTitle";
36
- const tt = o.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ d("p", { ref: n, className: R("text-sm text-muted-foreground", e), ...t }));
37
- tt.displayName = "CardDescription";
38
- const nt = o.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ d("div", { ref: n, className: R("p-6 pt-0", e), ...t }));
39
- nt.displayName = "CardContent";
40
- const rt = o.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ d("div", { ref: n, className: R("flex items-center p-6 pt-0", e), ...t }));
41
- rt.displayName = "CardFooter";
42
- const ot = o.forwardRef(({ className: e, type: t, ...n }, r) => /* @__PURE__ */ d(
43
- "input",
44
- {
45
- type: t,
46
- className: R(
47
- "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
48
- e
49
- ),
50
- ref: r,
51
- ...n
52
- }
53
- ));
54
- ot.displayName = "Input";
55
- function st(e) {
56
- const t = e + "CollectionProvider", [n, r] = me(t), [a, i] = n(
57
- t,
58
- { collectionRef: { current: null }, itemMap: /* @__PURE__ */ new Map() }
59
- ), u = (f) => {
60
- const { scope: c, children: h } = f, w = F.useRef(null), y = F.useRef(/* @__PURE__ */ new Map()).current;
61
- return /* @__PURE__ */ d(a, { scope: c, itemMap: y, collectionRef: w, children: h });
62
- };
63
- u.displayName = t;
64
- const l = e + "CollectionSlot", v = Q(l), s = F.forwardRef(
65
- (f, c) => {
66
- const { scope: h, children: w } = f, y = i(l, h), T = k(c, y.collectionRef);
67
- return /* @__PURE__ */ d(v, { ref: T, children: w });
68
- }
69
- );
70
- s.displayName = l;
71
- const p = e + "CollectionItemSlot", g = "data-radix-collection-item", b = Q(p), x = F.forwardRef(
72
- (f, c) => {
73
- const { scope: h, children: w, ...y } = f, T = F.useRef(null), N = k(c, T), C = i(p, h);
74
- return F.useEffect(() => (C.itemMap.set(T, { ref: T, ...y }), () => void C.itemMap.delete(T))), /* @__PURE__ */ d(b, { [g]: "", ref: N, children: w });
75
- }
76
- );
77
- x.displayName = p;
78
- function P(f) {
79
- const c = i(e + "CollectionConsumer", f);
80
- return F.useCallback(() => {
81
- const w = c.collectionRef.current;
82
- if (!w) return [];
83
- const y = Array.from(w.querySelectorAll(`[${g}]`));
84
- return Array.from(c.itemMap.values()).sort(
85
- (C, E) => y.indexOf(C.ref.current) - y.indexOf(E.ref.current)
86
- );
87
- }, [c.collectionRef, c.itemMap]);
88
- }
89
- return [
90
- { Provider: u, Slot: s, ItemSlot: x },
91
- P,
92
- r
93
- ];
94
- }
95
- var at = [
96
- "a",
97
- "button",
98
- "div",
99
- "form",
100
- "h2",
101
- "h3",
102
- "img",
103
- "input",
104
- "label",
105
- "li",
106
- "nav",
107
- "ol",
108
- "p",
109
- "select",
110
- "span",
111
- "svg",
112
- "ul"
113
- ], D = at.reduce((e, t) => {
114
- const n = Q(`Primitive.${t}`), r = o.forwardRef((a, i) => {
115
- const { asChild: u, ...l } = a, v = u ? n : t;
116
- return typeof window < "u" && (window[Symbol.for("radix-ui")] = !0), /* @__PURE__ */ d(v, { ...l, ref: i });
117
- });
118
- return r.displayName = `Primitive.${t}`, { ...e, [t]: r };
119
- }, {});
120
- function we(e, t) {
121
- e && ve.flushSync(() => e.dispatchEvent(t));
122
- }
123
- var it = "DismissableLayer", Z = "dismissableLayer.update", ct = "dismissableLayer.pointerDownOutside", dt = "dismissableLayer.focusOutside", de, ye = o.createContext({
124
- layers: /* @__PURE__ */ new Set(),
125
- layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(),
126
- branches: /* @__PURE__ */ new Set()
127
- }), Ee = o.forwardRef(
128
- (e, t) => {
129
- const {
130
- disableOutsidePointerEvents: n = !1,
131
- onEscapeKeyDown: r,
132
- onPointerDownOutside: a,
133
- onFocusOutside: i,
134
- onInteractOutside: u,
135
- onDismiss: l,
136
- ...v
137
- } = e, s = o.useContext(ye), [p, g] = o.useState(null), b = (p == null ? void 0 : p.ownerDocument) ?? (globalThis == null ? void 0 : globalThis.document), [, x] = o.useState({}), P = k(t, (E) => g(E)), f = Array.from(s.layers), [c] = [...s.layersWithOutsidePointerEventsDisabled].slice(-1), h = f.indexOf(c), w = p ? f.indexOf(p) : -1, y = s.layersWithOutsidePointerEventsDisabled.size > 0, T = w >= h, N = ut((E) => {
138
- const I = E.target, O = [...s.branches].some((_) => _.contains(I));
139
- !T || O || (a == null || a(E), u == null || u(E), E.defaultPrevented || l == null || l());
140
- }, b), C = ft((E) => {
141
- const I = E.target;
142
- [...s.branches].some((_) => _.contains(I)) || (i == null || i(E), u == null || u(E), E.defaultPrevented || l == null || l());
143
- }, b);
144
- return $e((E) => {
145
- w === s.layers.size - 1 && (r == null || r(E), !E.defaultPrevented && l && (E.preventDefault(), l()));
146
- }, b), o.useEffect(() => {
147
- if (p)
148
- return n && (s.layersWithOutsidePointerEventsDisabled.size === 0 && (de = b.body.style.pointerEvents, b.body.style.pointerEvents = "none"), s.layersWithOutsidePointerEventsDisabled.add(p)), s.layers.add(p), le(), () => {
149
- n && s.layersWithOutsidePointerEventsDisabled.size === 1 && (b.body.style.pointerEvents = de);
150
- };
151
- }, [p, b, n, s]), o.useEffect(() => () => {
152
- p && (s.layers.delete(p), s.layersWithOutsidePointerEventsDisabled.delete(p), le());
153
- }, [p, s]), o.useEffect(() => {
154
- const E = () => x({});
155
- return document.addEventListener(Z, E), () => document.removeEventListener(Z, E);
156
- }, []), /* @__PURE__ */ d(
157
- D.div,
158
- {
159
- ...v,
160
- ref: P,
161
- style: {
162
- pointerEvents: y ? T ? "auto" : "none" : void 0,
163
- ...e.style
164
- },
165
- onFocusCapture: A(e.onFocusCapture, C.onFocusCapture),
166
- onBlurCapture: A(e.onBlurCapture, C.onBlurCapture),
167
- onPointerDownCapture: A(
168
- e.onPointerDownCapture,
169
- N.onPointerDownCapture
170
- )
171
- }
172
- );
173
- }
174
- );
175
- Ee.displayName = it;
176
- var lt = "DismissableLayerBranch", Te = o.forwardRef((e, t) => {
177
- const n = o.useContext(ye), r = o.useRef(null), a = k(t, r);
178
- return o.useEffect(() => {
179
- const i = r.current;
180
- if (i)
181
- return n.branches.add(i), () => {
182
- n.branches.delete(i);
183
- };
184
- }, [n.branches]), /* @__PURE__ */ d(D.div, { ...e, ref: a });
185
- });
186
- Te.displayName = lt;
187
- function ut(e, t = globalThis == null ? void 0 : globalThis.document) {
188
- const n = W(e), r = o.useRef(!1), a = o.useRef(() => {
189
- });
190
- return o.useEffect(() => {
191
- const i = (l) => {
192
- if (l.target && !r.current) {
193
- let v = function() {
194
- ge(
195
- ct,
196
- n,
197
- s,
198
- { discrete: !0 }
199
- );
200
- };
201
- const s = { originalEvent: l };
202
- l.pointerType === "touch" ? (t.removeEventListener("click", a.current), a.current = v, t.addEventListener("click", a.current, { once: !0 })) : v();
203
- } else
204
- t.removeEventListener("click", a.current);
205
- r.current = !1;
206
- }, u = window.setTimeout(() => {
207
- t.addEventListener("pointerdown", i);
208
- }, 0);
209
- return () => {
210
- window.clearTimeout(u), t.removeEventListener("pointerdown", i), t.removeEventListener("click", a.current);
211
- };
212
- }, [t, n]), {
213
- // ensures we check React component tree (not just DOM tree)
214
- onPointerDownCapture: () => r.current = !0
215
- };
216
- }
217
- function ft(e, t = globalThis == null ? void 0 : globalThis.document) {
218
- const n = W(e), r = o.useRef(!1);
219
- return o.useEffect(() => {
220
- const a = (i) => {
221
- i.target && !r.current && ge(dt, n, { originalEvent: i }, {
222
- discrete: !1
223
- });
224
- };
225
- return t.addEventListener("focusin", a), () => t.removeEventListener("focusin", a);
226
- }, [t, n]), {
227
- onFocusCapture: () => r.current = !0,
228
- onBlurCapture: () => r.current = !1
229
- };
230
- }
231
- function le() {
232
- const e = new CustomEvent(Z);
233
- document.dispatchEvent(e);
234
- }
235
- function ge(e, t, n, { discrete: r }) {
236
- const a = n.originalEvent.target, i = new CustomEvent(e, { bubbles: !1, cancelable: !0, detail: n });
237
- t && a.addEventListener(e, t, { once: !0 }), r ? we(a, i) : a.dispatchEvent(i);
238
- }
239
- var pt = Ee, mt = Te, vt = "Portal", he = o.forwardRef((e, t) => {
240
- var l;
241
- const { container: n, ...r } = e, [a, i] = o.useState(!1);
242
- z(() => i(!0), []);
243
- const u = n || a && ((l = globalThis == null ? void 0 : globalThis.document) == null ? void 0 : l.body);
244
- return u ? Xe.createPortal(/* @__PURE__ */ d(D.div, { ...r, ref: t }), u) : null;
245
- });
246
- he.displayName = vt;
247
- function wt(e, t) {
248
- return o.useReducer((n, r) => t[n][r] ?? n, e);
249
- }
250
- var be = (e) => {
251
- const { present: t, children: n } = e, r = yt(t), a = typeof n == "function" ? n({ present: r.isPresent }) : o.Children.only(n), i = k(r.ref, Et(a));
252
- return typeof n == "function" || r.isPresent ? o.cloneElement(a, { ref: i }) : null;
253
- };
254
- be.displayName = "Presence";
255
- function yt(e) {
256
- const [t, n] = o.useState(), r = o.useRef(null), a = o.useRef(e), i = o.useRef("none"), u = e ? "mounted" : "unmounted", [l, v] = wt(u, {
257
- mounted: {
258
- UNMOUNT: "unmounted",
259
- ANIMATION_OUT: "unmountSuspended"
260
- },
261
- unmountSuspended: {
262
- MOUNT: "mounted",
263
- ANIMATION_END: "unmounted"
264
- },
265
- unmounted: {
266
- MOUNT: "mounted"
267
- }
268
- });
269
- return o.useEffect(() => {
270
- const s = X(r.current);
271
- i.current = l === "mounted" ? s : "none";
272
- }, [l]), z(() => {
273
- const s = r.current, p = a.current;
274
- if (p !== e) {
275
- const b = i.current, x = X(s);
276
- e ? v("MOUNT") : x === "none" || (s == null ? void 0 : s.display) === "none" ? v("UNMOUNT") : v(p && b !== x ? "ANIMATION_OUT" : "UNMOUNT"), a.current = e;
277
- }
278
- }, [e, v]), z(() => {
279
- if (t) {
280
- let s;
281
- const p = t.ownerDocument.defaultView ?? window, g = (x) => {
282
- const f = X(r.current).includes(CSS.escape(x.animationName));
283
- if (x.target === t && f && (v("ANIMATION_END"), !a.current)) {
284
- const c = t.style.animationFillMode;
285
- t.style.animationFillMode = "forwards", s = p.setTimeout(() => {
286
- t.style.animationFillMode === "forwards" && (t.style.animationFillMode = c);
287
- });
288
- }
289
- }, b = (x) => {
290
- x.target === t && (i.current = X(r.current));
291
- };
292
- return t.addEventListener("animationstart", b), t.addEventListener("animationcancel", g), t.addEventListener("animationend", g), () => {
293
- p.clearTimeout(s), t.removeEventListener("animationstart", b), t.removeEventListener("animationcancel", g), t.removeEventListener("animationend", g);
294
- };
295
- } else
296
- v("ANIMATION_END");
297
- }, [t, v]), {
298
- isPresent: ["mounted", "unmountSuspended"].includes(l),
299
- ref: o.useCallback((s) => {
300
- r.current = s ? getComputedStyle(s) : null, n(s);
301
- }, [])
302
- };
303
- }
304
- function X(e) {
305
- return (e == null ? void 0 : e.animationName) || "none";
306
- }
307
- function Et(e) {
308
- var r, a;
309
- let t = (r = Object.getOwnPropertyDescriptor(e.props, "ref")) == null ? void 0 : r.get, n = t && "isReactWarning" in t && t.isReactWarning;
310
- return n ? e.ref : (t = (a = Object.getOwnPropertyDescriptor(e, "ref")) == null ? void 0 : a.get, n = t && "isReactWarning" in t && t.isReactWarning, n ? e.props.ref : e.props.ref || e.ref);
311
- }
312
- var Tt = Object.freeze({
313
- // See: https://github.com/twbs/bootstrap/blob/main/scss/mixins/_visually-hidden.scss
314
- position: "absolute",
315
- border: 0,
316
- width: 1,
317
- height: 1,
318
- padding: 0,
319
- margin: -1,
320
- overflow: "hidden",
321
- clip: "rect(0, 0, 0, 0)",
322
- whiteSpace: "nowrap",
323
- wordWrap: "normal"
324
- }), gt = "VisuallyHidden", oe = o.forwardRef(
325
- (e, t) => /* @__PURE__ */ d(
326
- D.span,
327
- {
328
- ...e,
329
- ref: t,
330
- style: { ...Tt, ...e.style }
331
- }
332
- )
333
- );
334
- oe.displayName = gt;
335
- var se = "ToastProvider", [ae, ht, bt] = st("Toast"), [xe] = me("Toast", [bt]), [xt, q] = xe(se), Ce = (e) => {
336
- const {
337
- __scopeToast: t,
338
- label: n = "Notification",
339
- duration: r = 5e3,
340
- swipeDirection: a = "right",
341
- swipeThreshold: i = 50,
342
- children: u
343
- } = e, [l, v] = o.useState(null), [s, p] = o.useState(0), g = o.useRef(!1), b = o.useRef(!1);
344
- return n.trim() || console.error(
345
- `Invalid prop \`label\` supplied to \`${se}\`. Expected non-empty \`string\`.`
346
- ), /* @__PURE__ */ d(ae.Provider, { scope: t, children: /* @__PURE__ */ d(
347
- xt,
348
- {
349
- scope: t,
350
- label: n,
351
- duration: r,
352
- swipeDirection: a,
353
- swipeThreshold: i,
354
- toastCount: s,
355
- viewport: l,
356
- onViewportChange: v,
357
- onToastAdd: o.useCallback(() => p((x) => x + 1), []),
358
- onToastRemove: o.useCallback(() => p((x) => x - 1), []),
359
- isFocusedToastEscapeKeyDownRef: g,
360
- isClosePausedRef: b,
361
- children: u
362
- }
363
- ) });
364
- };
365
- Ce.displayName = se;
366
- var Ne = "ToastViewport", Ct = ["F8"], ee = "toast.viewportPause", te = "toast.viewportResume", Re = o.forwardRef(
367
- (e, t) => {
368
- const {
369
- __scopeToast: n,
370
- hotkey: r = Ct,
371
- label: a = "Notifications ({hotkey})",
372
- ...i
373
- } = e, u = q(Ne, n), l = ht(n), v = o.useRef(null), s = o.useRef(null), p = o.useRef(null), g = o.useRef(null), b = k(t, g, u.onViewportChange), x = r.join("+").replace(/Key/g, "").replace(/Digit/g, ""), P = u.toastCount > 0;
374
- o.useEffect(() => {
375
- const c = (h) => {
376
- var y;
377
- r.length !== 0 && r.every((T) => h[T] || h.code === T) && ((y = g.current) == null || y.focus());
378
- };
379
- return document.addEventListener("keydown", c), () => document.removeEventListener("keydown", c);
380
- }, [r]), o.useEffect(() => {
381
- const c = v.current, h = g.current;
382
- if (P && c && h) {
383
- const w = () => {
384
- if (!u.isClosePausedRef.current) {
385
- const C = new CustomEvent(ee);
386
- h.dispatchEvent(C), u.isClosePausedRef.current = !0;
387
- }
388
- }, y = () => {
389
- if (u.isClosePausedRef.current) {
390
- const C = new CustomEvent(te);
391
- h.dispatchEvent(C), u.isClosePausedRef.current = !1;
392
- }
393
- }, T = (C) => {
394
- !c.contains(C.relatedTarget) && y();
395
- }, N = () => {
396
- c.contains(document.activeElement) || y();
397
- };
398
- return c.addEventListener("focusin", w), c.addEventListener("focusout", T), c.addEventListener("pointermove", w), c.addEventListener("pointerleave", N), window.addEventListener("blur", w), window.addEventListener("focus", y), () => {
399
- c.removeEventListener("focusin", w), c.removeEventListener("focusout", T), c.removeEventListener("pointermove", w), c.removeEventListener("pointerleave", N), window.removeEventListener("blur", w), window.removeEventListener("focus", y);
400
- };
401
- }
402
- }, [P, u.isClosePausedRef]);
403
- const f = o.useCallback(
404
- ({ tabbingDirection: c }) => {
405
- const w = l().map((y) => {
406
- const T = y.ref.current, N = [T, ...kt(T)];
407
- return c === "forwards" ? N : N.reverse();
408
- });
409
- return (c === "forwards" ? w.reverse() : w).flat();
410
- },
411
- [l]
412
- );
413
- return o.useEffect(() => {
414
- const c = g.current;
415
- if (c) {
416
- const h = (w) => {
417
- var N, C, E;
418
- const y = w.altKey || w.ctrlKey || w.metaKey;
419
- if (w.key === "Tab" && !y) {
420
- const I = document.activeElement, O = w.shiftKey;
421
- if (w.target === c && O) {
422
- (N = s.current) == null || N.focus();
423
- return;
424
- }
425
- const M = f({ tabbingDirection: O ? "backwards" : "forwards" }), B = M.findIndex((m) => m === I);
426
- J(M.slice(B + 1)) ? w.preventDefault() : O ? (C = s.current) == null || C.focus() : (E = p.current) == null || E.focus();
427
- }
428
- };
429
- return c.addEventListener("keydown", h), () => c.removeEventListener("keydown", h);
430
- }
431
- }, [l, f]), /* @__PURE__ */ re(
432
- mt,
433
- {
434
- ref: v,
435
- role: "region",
436
- "aria-label": a.replace("{hotkey}", x),
437
- tabIndex: -1,
438
- style: { pointerEvents: P ? void 0 : "none" },
439
- children: [
440
- P && /* @__PURE__ */ d(
441
- ne,
442
- {
443
- ref: s,
444
- onFocusFromOutsideViewport: () => {
445
- const c = f({
446
- tabbingDirection: "forwards"
447
- });
448
- J(c);
449
- }
450
- }
451
- ),
452
- /* @__PURE__ */ d(ae.Slot, { scope: n, children: /* @__PURE__ */ d(D.ol, { tabIndex: -1, ...i, ref: b }) }),
453
- P && /* @__PURE__ */ d(
454
- ne,
455
- {
456
- ref: p,
457
- onFocusFromOutsideViewport: () => {
458
- const c = f({
459
- tabbingDirection: "backwards"
460
- });
461
- J(c);
462
- }
463
- }
464
- )
465
- ]
466
- }
467
- );
468
- }
469
- );
470
- Re.displayName = Ne;
471
- var Pe = "ToastFocusProxy", ne = o.forwardRef(
472
- (e, t) => {
473
- const { __scopeToast: n, onFocusFromOutsideViewport: r, ...a } = e, i = q(Pe, n);
474
- return /* @__PURE__ */ d(
475
- oe,
476
- {
477
- tabIndex: 0,
478
- ...a,
479
- ref: t,
480
- style: { position: "fixed" },
481
- onFocus: (u) => {
482
- var s;
483
- const l = u.relatedTarget;
484
- !((s = i.viewport) != null && s.contains(l)) && r();
485
- }
486
- }
487
- );
488
- }
489
- );
490
- ne.displayName = Pe;
491
- var H = "Toast", Nt = "toast.swipeStart", Rt = "toast.swipeMove", Pt = "toast.swipeCancel", At = "toast.swipeEnd", Ae = o.forwardRef(
492
- (e, t) => {
493
- const { forceMount: n, open: r, defaultOpen: a, onOpenChange: i, ...u } = e, [l, v] = je({
494
- prop: r,
495
- defaultProp: a ?? !0,
496
- onChange: i,
497
- caller: H
498
- });
499
- return /* @__PURE__ */ d(be, { present: n || l, children: /* @__PURE__ */ d(
500
- Dt,
501
- {
502
- open: l,
503
- ...u,
504
- ref: t,
505
- onClose: () => v(!1),
506
- onPause: W(e.onPause),
507
- onResume: W(e.onResume),
508
- onSwipeStart: A(e.onSwipeStart, (s) => {
509
- s.currentTarget.setAttribute("data-swipe", "start");
510
- }),
511
- onSwipeMove: A(e.onSwipeMove, (s) => {
512
- const { x: p, y: g } = s.detail.delta;
513
- s.currentTarget.setAttribute("data-swipe", "move"), s.currentTarget.style.setProperty("--radix-toast-swipe-move-x", `${p}px`), s.currentTarget.style.setProperty("--radix-toast-swipe-move-y", `${g}px`);
514
- }),
515
- onSwipeCancel: A(e.onSwipeCancel, (s) => {
516
- s.currentTarget.setAttribute("data-swipe", "cancel"), s.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"), s.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"), s.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"), s.currentTarget.style.removeProperty("--radix-toast-swipe-end-y");
517
- }),
518
- onSwipeEnd: A(e.onSwipeEnd, (s) => {
519
- const { x: p, y: g } = s.detail.delta;
520
- s.currentTarget.setAttribute("data-swipe", "end"), s.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"), s.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"), s.currentTarget.style.setProperty("--radix-toast-swipe-end-x", `${p}px`), s.currentTarget.style.setProperty("--radix-toast-swipe-end-y", `${g}px`), v(!1);
521
- })
522
- }
523
- ) });
524
- }
525
- );
526
- Ae.displayName = H;
527
- var [St, It] = xe(H, {
528
- onClose() {
529
- }
530
- }), Dt = o.forwardRef(
531
- (e, t) => {
532
- const {
533
- __scopeToast: n,
534
- type: r = "foreground",
535
- duration: a,
536
- open: i,
537
- onClose: u,
538
- onEscapeKeyDown: l,
539
- onPause: v,
540
- onResume: s,
541
- onSwipeStart: p,
542
- onSwipeMove: g,
543
- onSwipeCancel: b,
544
- onSwipeEnd: x,
545
- ...P
546
- } = e, f = q(H, n), [c, h] = o.useState(null), w = k(t, (m) => h(m)), y = o.useRef(null), T = o.useRef(null), N = a || f.duration, C = o.useRef(0), E = o.useRef(N), I = o.useRef(0), { onToastAdd: O, onToastRemove: _ } = f, V = W(() => {
547
- var S;
548
- (c == null ? void 0 : c.contains(document.activeElement)) && ((S = f.viewport) == null || S.focus()), u();
549
- }), M = o.useCallback(
550
- (m) => {
551
- !m || m === 1 / 0 || (window.clearTimeout(I.current), C.current = (/* @__PURE__ */ new Date()).getTime(), I.current = window.setTimeout(V, m));
552
- },
553
- [V]
554
- );
555
- o.useEffect(() => {
556
- const m = f.viewport;
557
- if (m) {
558
- const S = () => {
559
- M(E.current), s == null || s();
560
- }, L = () => {
561
- const U = (/* @__PURE__ */ new Date()).getTime() - C.current;
562
- E.current = E.current - U, window.clearTimeout(I.current), v == null || v();
563
- };
564
- return m.addEventListener(ee, L), m.addEventListener(te, S), () => {
565
- m.removeEventListener(ee, L), m.removeEventListener(te, S);
566
- };
567
- }
568
- }, [f.viewport, N, v, s, M]), o.useEffect(() => {
569
- i && !f.isClosePausedRef.current && M(N);
570
- }, [i, N, f.isClosePausedRef, M]), o.useEffect(() => (O(), () => _()), [O, _]);
571
- const B = o.useMemo(() => c ? Me(c) : null, [c]);
572
- return f.viewport ? /* @__PURE__ */ re(fe, { children: [
573
- B && /* @__PURE__ */ d(
574
- Ot,
575
- {
576
- __scopeToast: n,
577
- role: "status",
578
- "aria-live": r === "foreground" ? "assertive" : "polite",
579
- children: B
580
- }
581
- ),
582
- /* @__PURE__ */ d(St, { scope: n, onClose: V, children: ve.createPortal(
583
- /* @__PURE__ */ d(ae.ItemSlot, { scope: n, children: /* @__PURE__ */ d(
584
- pt,
585
- {
586
- asChild: !0,
587
- onEscapeKeyDown: A(l, () => {
588
- f.isFocusedToastEscapeKeyDownRef.current || V(), f.isFocusedToastEscapeKeyDownRef.current = !1;
589
- }),
590
- children: /* @__PURE__ */ d(
591
- D.li,
592
- {
593
- tabIndex: 0,
594
- "data-state": i ? "open" : "closed",
595
- "data-swipe-direction": f.swipeDirection,
596
- ...P,
597
- ref: w,
598
- style: { userSelect: "none", touchAction: "none", ...e.style },
599
- onKeyDown: A(e.onKeyDown, (m) => {
600
- m.key === "Escape" && (l == null || l(m.nativeEvent), m.nativeEvent.defaultPrevented || (f.isFocusedToastEscapeKeyDownRef.current = !0, V()));
601
- }),
602
- onPointerDown: A(e.onPointerDown, (m) => {
603
- m.button === 0 && (y.current = { x: m.clientX, y: m.clientY });
604
- }),
605
- onPointerMove: A(e.onPointerMove, (m) => {
606
- if (!y.current) return;
607
- const S = m.clientX - y.current.x, L = m.clientY - y.current.y, U = !!T.current, K = ["left", "right"].includes(f.swipeDirection), $ = ["left", "up"].includes(f.swipeDirection) ? Math.min : Math.max, He = K ? $(0, S) : 0, Be = K ? 0 : $(0, L), G = m.pointerType === "touch" ? 10 : 2, j = { x: He, y: Be }, ce = { originalEvent: m, delta: j };
608
- U ? (T.current = j, Y(Rt, g, ce, {
609
- discrete: !1
610
- })) : ue(j, f.swipeDirection, G) ? (T.current = j, Y(Nt, p, ce, {
611
- discrete: !1
612
- }), m.target.setPointerCapture(m.pointerId)) : (Math.abs(S) > G || Math.abs(L) > G) && (y.current = null);
613
- }),
614
- onPointerUp: A(e.onPointerUp, (m) => {
615
- const S = T.current, L = m.target;
616
- if (L.hasPointerCapture(m.pointerId) && L.releasePointerCapture(m.pointerId), T.current = null, y.current = null, S) {
617
- const U = m.currentTarget, K = { originalEvent: m, delta: S };
618
- ue(S, f.swipeDirection, f.swipeThreshold) ? Y(At, x, K, {
619
- discrete: !0
620
- }) : Y(
621
- Pt,
622
- b,
623
- K,
624
- {
625
- discrete: !0
626
- }
627
- ), U.addEventListener("click", ($) => $.preventDefault(), {
628
- once: !0
629
- });
630
- }
631
- })
632
- }
633
- )
634
- }
635
- ) }),
636
- f.viewport
637
- ) })
638
- ] }) : null;
639
- }
640
- ), Ot = (e) => {
641
- const { __scopeToast: t, children: n, ...r } = e, a = q(H, t), [i, u] = o.useState(!1), [l, v] = o.useState(!1);
642
- return Mt(() => u(!0)), o.useEffect(() => {
643
- const s = window.setTimeout(() => v(!0), 1e3);
644
- return () => window.clearTimeout(s);
645
- }, []), l ? null : /* @__PURE__ */ d(he, { asChild: !0, children: /* @__PURE__ */ d(oe, { ...r, children: i && /* @__PURE__ */ re(fe, { children: [
646
- a.label,
647
- " ",
648
- n
649
- ] }) }) });
650
- }, Lt = "ToastTitle", Se = o.forwardRef(
651
- (e, t) => {
652
- const { __scopeToast: n, ...r } = e;
653
- return /* @__PURE__ */ d(D.div, { ...r, ref: t });
654
- }
655
- );
656
- Se.displayName = Lt;
657
- var _t = "ToastDescription", Ie = o.forwardRef(
658
- (e, t) => {
659
- const { __scopeToast: n, ...r } = e;
660
- return /* @__PURE__ */ d(D.div, { ...r, ref: t });
661
- }
662
- );
663
- Ie.displayName = _t;
664
- var De = "ToastAction", Oe = o.forwardRef(
665
- (e, t) => {
666
- const { altText: n, ...r } = e;
667
- return n.trim() ? /* @__PURE__ */ d(_e, { altText: n, asChild: !0, children: /* @__PURE__ */ d(ie, { ...r, ref: t }) }) : (console.error(
668
- `Invalid prop \`altText\` supplied to \`${De}\`. Expected non-empty \`string\`.`
669
- ), null);
670
- }
671
- );
672
- Oe.displayName = De;
673
- var Le = "ToastClose", ie = o.forwardRef(
674
- (e, t) => {
675
- const { __scopeToast: n, ...r } = e, a = It(Le, n);
676
- return /* @__PURE__ */ d(_e, { asChild: !0, children: /* @__PURE__ */ d(
677
- D.button,
678
- {
679
- type: "button",
680
- ...r,
681
- ref: t,
682
- onClick: A(e.onClick, a.onClose)
683
- }
684
- ) });
685
- }
686
- );
687
- ie.displayName = Le;
688
- var _e = o.forwardRef((e, t) => {
689
- const { __scopeToast: n, altText: r, ...a } = e;
690
- return /* @__PURE__ */ d(
691
- D.div,
692
- {
693
- "data-radix-toast-announce-exclude": "",
694
- "data-radix-toast-announce-alt": r || void 0,
695
- ...a,
696
- ref: t
697
- }
698
- );
699
- });
700
- function Me(e) {
701
- const t = [];
702
- return Array.from(e.childNodes).forEach((r) => {
703
- if (r.nodeType === r.TEXT_NODE && r.textContent && t.push(r.textContent), Ft(r)) {
704
- const a = r.ariaHidden || r.hidden || r.style.display === "none", i = r.dataset.radixToastAnnounceExclude === "";
705
- if (!a)
706
- if (i) {
707
- const u = r.dataset.radixToastAnnounceAlt;
708
- u && t.push(u);
709
- } else
710
- t.push(...Me(r));
711
- }
712
- }), t;
713
- }
714
- function Y(e, t, n, { discrete: r }) {
715
- const a = n.originalEvent.currentTarget, i = new CustomEvent(e, { bubbles: !0, cancelable: !0, detail: n });
716
- t && a.addEventListener(e, t, { once: !0 }), r ? we(a, i) : a.dispatchEvent(i);
717
- }
718
- var ue = (e, t, n = 0) => {
719
- const r = Math.abs(e.x), a = Math.abs(e.y), i = r > a;
720
- return t === "left" || t === "right" ? i && r > n : !i && a > n;
721
- };
722
- function Mt(e = () => {
723
- }) {
724
- const t = W(e);
725
- z(() => {
726
- let n = 0, r = 0;
727
- return n = window.requestAnimationFrame(() => r = window.requestAnimationFrame(t)), () => {
728
- window.cancelAnimationFrame(n), window.cancelAnimationFrame(r);
729
- };
730
- }, [t]);
731
- }
732
- function Ft(e) {
733
- return e.nodeType === e.ELEMENT_NODE;
734
- }
735
- function kt(e) {
736
- const t = [], n = document.createTreeWalker(e, NodeFilter.SHOW_ELEMENT, {
737
- acceptNode: (r) => {
738
- const a = r.tagName === "INPUT" && r.type === "hidden";
739
- return r.disabled || r.hidden || a ? NodeFilter.FILTER_SKIP : r.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
740
- }
741
- });
742
- for (; n.nextNode(); ) t.push(n.currentNode);
743
- return t;
744
- }
745
- function J(e) {
746
- const t = document.activeElement;
747
- return e.some((n) => n === t ? !0 : (n.focus(), document.activeElement !== t));
748
- }
749
- var Vt = Ce, Fe = Re, ke = Ae, Ve = Se, We = Ie, Ue = Oe, Ke = ie;
750
- /**
751
- * @license lucide-react v1.16.0 - ISC
752
- *
753
- * This source code is licensed under the ISC license.
754
- * See the LICENSE file in the root directory of this source tree.
755
- */
756
- const Wt = [
757
- ["path", { d: "M18 6 6 18", key: "1bl5f8" }],
758
- ["path", { d: "m6 6 12 12", key: "d8bk6v" }]
759
- ], Ut = Ye("x", Wt), en = Vt, Kt = o.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ d(
760
- Fe,
761
- {
762
- ref: n,
763
- className: R(
764
- "fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",
765
- e
766
- ),
767
- ...t
768
- }
769
- ));
770
- Kt.displayName = Fe.displayName;
771
- const Ht = pe(
772
- "group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",
773
- {
774
- variants: {
775
- variant: {
776
- default: "border bg-background text-foreground",
777
- destructive: "destructive group border-destructive bg-destructive text-destructive-foreground"
778
- }
779
- },
780
- defaultVariants: {
781
- variant: "default"
782
- }
783
- }
784
- ), Bt = o.forwardRef(({ className: e, variant: t, ...n }, r) => /* @__PURE__ */ d(
785
- ke,
786
- {
787
- ref: r,
788
- className: R(Ht({ variant: t }), e),
789
- ...n
790
- }
791
- ));
792
- Bt.displayName = ke.displayName;
793
- const $t = o.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ d(
794
- Ue,
795
- {
796
- ref: n,
797
- className: R(
798
- "inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors group-[.destructive]:border-muted/40 hover:bg-secondary group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 group-[.destructive]:focus:ring-destructive disabled:pointer-events-none disabled:opacity-50",
799
- e
800
- ),
801
- ...t
802
- }
803
- ));
804
- $t.displayName = Ue.displayName;
805
- const jt = o.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ d(
806
- Ke,
807
- {
808
- ref: n,
809
- className: R(
810
- "absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity group-hover:opacity-100 group-[.destructive]:text-red-300 hover:text-foreground group-[.destructive]:hover:text-red-50 focus:opacity-100 focus:outline-none focus:ring-2 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",
811
- e
812
- ),
813
- "toast-close": "",
814
- ...t,
815
- children: /* @__PURE__ */ d(Ut, { className: "size-4" })
816
- }
817
- ));
818
- jt.displayName = Ke.displayName;
819
- const Xt = o.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ d(
820
- Ve,
821
- {
822
- ref: n,
823
- className: R("text-sm font-semibold", e),
824
- ...t
825
- }
826
- ));
827
- Xt.displayName = Ve.displayName;
828
- const Yt = o.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ d(
829
- We,
830
- {
831
- ref: n,
832
- className: R("text-sm opacity-90", e),
833
- ...t
834
- }
835
- ));
836
- Yt.displayName = We.displayName;
837
- export {
838
- qe as A,
839
- Qe as C,
840
- ot as I,
841
- Bt as T,
842
- Ut as X,
843
- Je as a,
844
- Ge as b,
845
- nt as c,
846
- tt as d,
847
- rt as e,
848
- Ze as f,
849
- et as g,
850
- $t as h,
851
- jt as i,
852
- Yt as j,
853
- en as k,
854
- Xt as l,
855
- Kt as m
856
- };