@myzbox/react-overlay 1.0.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.
@@ -0,0 +1,865 @@
1
+ import re, { useRef as S, useCallback as O, useEffect as N, useState as A, createContext as he, useContext as be } from "react";
2
+ import { createPortal as ve } from "react-dom";
3
+ function ge(r) {
4
+ return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
5
+ }
6
+ var X = { exports: {} }, D = {};
7
+ /**
8
+ * @license React
9
+ * react-jsx-runtime.production.js
10
+ *
11
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
12
+ *
13
+ * This source code is licensed under the MIT license found in the
14
+ * LICENSE file in the root directory of this source tree.
15
+ */
16
+ var ue;
17
+ function we() {
18
+ if (ue) return D;
19
+ ue = 1;
20
+ var r = Symbol.for("react.transitional.element"), a = Symbol.for("react.fragment");
21
+ function s(c, n, t) {
22
+ var o = null;
23
+ if (t !== void 0 && (o = "" + t), n.key !== void 0 && (o = "" + n.key), "key" in n) {
24
+ t = {};
25
+ for (var l in n)
26
+ l !== "key" && (t[l] = n[l]);
27
+ } else t = n;
28
+ return n = t.ref, {
29
+ $$typeof: r,
30
+ type: c,
31
+ key: o,
32
+ ref: n !== void 0 ? n : null,
33
+ props: t
34
+ };
35
+ }
36
+ return D.Fragment = a, D.jsx = s, D.jsxs = s, D;
37
+ }
38
+ var Y = {};
39
+ /**
40
+ * @license React
41
+ * react-jsx-runtime.development.js
42
+ *
43
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
44
+ *
45
+ * This source code is licensed under the MIT license found in the
46
+ * LICENSE file in the root directory of this source tree.
47
+ */
48
+ var de;
49
+ function xe() {
50
+ return de || (de = 1, process.env.NODE_ENV !== "production" && (function() {
51
+ function r(e) {
52
+ if (e == null) return null;
53
+ if (typeof e == "function")
54
+ return e.$$typeof === C ? null : e.displayName || e.name || null;
55
+ if (typeof e == "string") return e;
56
+ switch (e) {
57
+ case P:
58
+ return "Fragment";
59
+ case M:
60
+ return "Profiler";
61
+ case G:
62
+ return "StrictMode";
63
+ case L:
64
+ return "Suspense";
65
+ case H:
66
+ return "SuspenseList";
67
+ case v:
68
+ return "Activity";
69
+ }
70
+ if (typeof e == "object")
71
+ switch (typeof e.tag == "number" && console.error(
72
+ "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
73
+ ), e.$$typeof) {
74
+ case J:
75
+ return "Portal";
76
+ case W:
77
+ return e.displayName || "Context";
78
+ case F:
79
+ return (e._context.displayName || "Context") + ".Consumer";
80
+ case q:
81
+ var u = e.render;
82
+ return e = e.displayName, e || (e = u.displayName || u.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
83
+ case Z:
84
+ return u = e.displayName || null, u !== null ? u : r(e.type) || "Memo";
85
+ case B:
86
+ u = e._payload, e = e._init;
87
+ try {
88
+ return r(e(u));
89
+ } catch {
90
+ }
91
+ }
92
+ return null;
93
+ }
94
+ function a(e) {
95
+ return "" + e;
96
+ }
97
+ function s(e) {
98
+ try {
99
+ a(e);
100
+ var u = !1;
101
+ } catch {
102
+ u = !0;
103
+ }
104
+ if (u) {
105
+ u = console;
106
+ var m = u.error, p = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
107
+ return m.call(
108
+ u,
109
+ "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
110
+ p
111
+ ), a(e);
112
+ }
113
+ }
114
+ function c(e) {
115
+ if (e === P) return "<>";
116
+ if (typeof e == "object" && e !== null && e.$$typeof === B)
117
+ return "<...>";
118
+ try {
119
+ var u = r(e);
120
+ return u ? "<" + u + ">" : "<...>";
121
+ } catch {
122
+ return "<...>";
123
+ }
124
+ }
125
+ function n() {
126
+ var e = j.A;
127
+ return e === null ? null : e.getOwner();
128
+ }
129
+ function t() {
130
+ return Error("react-stack-top-frame");
131
+ }
132
+ function o(e) {
133
+ if ($.call(e, "key")) {
134
+ var u = Object.getOwnPropertyDescriptor(e, "key").get;
135
+ if (u && u.isReactWarning) return !1;
136
+ }
137
+ return e.key !== void 0;
138
+ }
139
+ function l(e, u) {
140
+ function m() {
141
+ se || (se = !0, console.error(
142
+ "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
143
+ u
144
+ ));
145
+ }
146
+ m.isReactWarning = !0, Object.defineProperty(e, "key", {
147
+ get: m,
148
+ configurable: !0
149
+ });
150
+ }
151
+ function i() {
152
+ var e = r(this.type);
153
+ return ae[e] || (ae[e] = !0, console.error(
154
+ "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
155
+ )), e = this.props.ref, e !== void 0 ? e : null;
156
+ }
157
+ function _(e, u, m, p, z, K) {
158
+ var h = m.ref;
159
+ return e = {
160
+ $$typeof: k,
161
+ type: e,
162
+ key: u,
163
+ props: m,
164
+ _owner: p
165
+ }, (h !== void 0 ? h : null) !== null ? Object.defineProperty(e, "ref", {
166
+ enumerable: !1,
167
+ get: i
168
+ }) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
169
+ configurable: !1,
170
+ enumerable: !1,
171
+ writable: !0,
172
+ value: 0
173
+ }), Object.defineProperty(e, "_debugInfo", {
174
+ configurable: !1,
175
+ enumerable: !1,
176
+ writable: !0,
177
+ value: null
178
+ }), Object.defineProperty(e, "_debugStack", {
179
+ configurable: !1,
180
+ enumerable: !1,
181
+ writable: !0,
182
+ value: z
183
+ }), Object.defineProperty(e, "_debugTask", {
184
+ configurable: !1,
185
+ enumerable: !1,
186
+ writable: !0,
187
+ value: K
188
+ }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
189
+ }
190
+ function f(e, u, m, p, z, K) {
191
+ var h = u.children;
192
+ if (h !== void 0)
193
+ if (p)
194
+ if (U(h)) {
195
+ for (p = 0; p < h.length; p++)
196
+ b(h[p]);
197
+ Object.freeze && Object.freeze(h);
198
+ } else
199
+ console.error(
200
+ "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
201
+ );
202
+ else b(h);
203
+ if ($.call(u, "key")) {
204
+ h = r(e);
205
+ var I = Object.keys(u).filter(function(pe) {
206
+ return pe !== "key";
207
+ });
208
+ p = 0 < I.length ? "{key: someKey, " + I.join(": ..., ") + ": ...}" : "{key: someKey}", ie[h + p] || (I = 0 < I.length ? "{" + I.join(": ..., ") + ": ...}" : "{}", console.error(
209
+ `A props object containing a "key" prop is being spread into JSX:
210
+ let props = %s;
211
+ <%s {...props} />
212
+ React keys must be passed directly to JSX without using spread:
213
+ let props = %s;
214
+ <%s key={someKey} {...props} />`,
215
+ p,
216
+ h,
217
+ I,
218
+ h
219
+ ), ie[h + p] = !0);
220
+ }
221
+ if (h = null, m !== void 0 && (s(m), h = "" + m), o(u) && (s(u.key), h = "" + u.key), "key" in u) {
222
+ m = {};
223
+ for (var Q in u)
224
+ Q !== "key" && (m[Q] = u[Q]);
225
+ } else m = u;
226
+ return h && l(
227
+ m,
228
+ typeof e == "function" ? e.displayName || e.name || "Unknown" : e
229
+ ), _(
230
+ e,
231
+ h,
232
+ m,
233
+ n(),
234
+ z,
235
+ K
236
+ );
237
+ }
238
+ function b(e) {
239
+ g(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === B && (e._payload.status === "fulfilled" ? g(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
240
+ }
241
+ function g(e) {
242
+ return typeof e == "object" && e !== null && e.$$typeof === k;
243
+ }
244
+ var y = re, k = Symbol.for("react.transitional.element"), J = Symbol.for("react.portal"), P = Symbol.for("react.fragment"), G = Symbol.for("react.strict_mode"), M = Symbol.for("react.profiler"), F = Symbol.for("react.consumer"), W = Symbol.for("react.context"), q = Symbol.for("react.forward_ref"), L = Symbol.for("react.suspense"), H = Symbol.for("react.suspense_list"), Z = Symbol.for("react.memo"), B = Symbol.for("react.lazy"), v = Symbol.for("react.activity"), C = Symbol.for("react.client.reference"), j = y.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, $ = Object.prototype.hasOwnProperty, U = Array.isArray, R = console.createTask ? console.createTask : function() {
245
+ return null;
246
+ };
247
+ y = {
248
+ react_stack_bottom_frame: function(e) {
249
+ return e();
250
+ }
251
+ };
252
+ var se, ae = {}, ce = y.react_stack_bottom_frame.bind(
253
+ y,
254
+ t
255
+ )(), le = R(c(t)), ie = {};
256
+ Y.Fragment = P, Y.jsx = function(e, u, m) {
257
+ var p = 1e4 > j.recentlyCreatedOwnerStacks++;
258
+ return f(
259
+ e,
260
+ u,
261
+ m,
262
+ !1,
263
+ p ? Error("react-stack-top-frame") : ce,
264
+ p ? R(c(e)) : le
265
+ );
266
+ }, Y.jsxs = function(e, u, m) {
267
+ var p = 1e4 > j.recentlyCreatedOwnerStacks++;
268
+ return f(
269
+ e,
270
+ u,
271
+ m,
272
+ !0,
273
+ p ? Error("react-stack-top-frame") : ce,
274
+ p ? R(c(e)) : le
275
+ );
276
+ };
277
+ })()), Y;
278
+ }
279
+ var _e;
280
+ function Ee() {
281
+ return _e || (_e = 1, process.env.NODE_ENV === "production" ? X.exports = we() : X.exports = xe()), X.exports;
282
+ }
283
+ var d = Ee();
284
+ const ye = "_overlay_1pta6_15", Te = "_open_1pta6_32", ke = "_center_1pta6_38", je = "_top_1pta6_44", Re = "_bottom_1pta6_50", Ne = "_left_1pta6_55", Se = "_right_1pta6_61", Oe = "_modal_1pta6_94", Ae = "_openScale_1pta6_1", Pe = "_sm_1pta6_124", Ce = "_md_1pta6_128", $e = "_lg_1pta6_132", Ie = "_xl_1pta6_136", Me = "_full_1pta6_140", Le = "_auto_1pta6_147", Be = "_fade_1pta6_180", De = "_header_1pta6_237", Ye = "_draggable_1pta6_247", Ve = "_title_1pta6_252", Fe = "_closeButton_1pta6_259", We = "_content_1pta6_294", qe = "_footer_1pta6_305", w = {
285
+ overlay: ye,
286
+ open: Te,
287
+ center: ke,
288
+ top: je,
289
+ bottom: Re,
290
+ left: Ne,
291
+ right: Se,
292
+ "top-left": "_top-left_1pta6_66",
293
+ "top-right": "_top-right_1pta6_73",
294
+ "bottom-left": "_bottom-left_1pta6_80",
295
+ "bottom-right": "_bottom-right_1pta6_87",
296
+ modal: Oe,
297
+ openScale: Ae,
298
+ sm: Pe,
299
+ md: Ce,
300
+ lg: $e,
301
+ xl: Ie,
302
+ full: Me,
303
+ auto: Le,
304
+ "slide-up": "_slide-up_1pta6_164",
305
+ "slide-down": "_slide-down_1pta6_172",
306
+ fade: Be,
307
+ "slide-left": "_slide-left_1pta6_188",
308
+ "slide-right": "_slide-right_1pta6_196",
309
+ "drawer-slide-right": "_drawer-slide-right_1pta6_205",
310
+ "drawer-slide-left": "_drawer-slide-left_1pta6_213",
311
+ "drawer-slide-up": "_drawer-slide-up_1pta6_221",
312
+ "drawer-slide-down": "_drawer-slide-down_1pta6_229",
313
+ header: De,
314
+ draggable: Ye,
315
+ title: Ve,
316
+ closeButton: Fe,
317
+ content: We,
318
+ footer: qe
319
+ };
320
+ var ee = { exports: {} };
321
+ /*!
322
+ Copyright (c) 2018 Jed Watson.
323
+ Licensed under the MIT License (MIT), see
324
+ http://jedwatson.github.io/classnames
325
+ */
326
+ var fe;
327
+ function Ue() {
328
+ return fe || (fe = 1, (function(r) {
329
+ (function() {
330
+ var a = {}.hasOwnProperty;
331
+ function s() {
332
+ for (var t = "", o = 0; o < arguments.length; o++) {
333
+ var l = arguments[o];
334
+ l && (t = n(t, c(l)));
335
+ }
336
+ return t;
337
+ }
338
+ function c(t) {
339
+ if (typeof t == "string" || typeof t == "number")
340
+ return t;
341
+ if (typeof t != "object")
342
+ return "";
343
+ if (Array.isArray(t))
344
+ return s.apply(null, t);
345
+ if (t.toString !== Object.prototype.toString && !t.toString.toString().includes("[native code]"))
346
+ return t.toString();
347
+ var o = "";
348
+ for (var l in t)
349
+ a.call(t, l) && t[l] && (o = n(o, l));
350
+ return o;
351
+ }
352
+ function n(t, o) {
353
+ return o ? t ? t + " " + o : t + o : t;
354
+ }
355
+ r.exports ? (s.default = s, r.exports = s) : window.classNames = s;
356
+ })();
357
+ })(ee)), ee.exports;
358
+ }
359
+ var ze = Ue();
360
+ const E = /* @__PURE__ */ ge(ze), oe = (r, a) => {
361
+ const s = S(!1), c = S({ x: 0, y: 0 }), n = S({ x: 0, y: 0 }), t = O((i) => {
362
+ if (!s.current || !a.current) return;
363
+ const _ = i.clientX - c.current.x, f = i.clientY - c.current.y, b = n.current.x + _, g = n.current.y + f;
364
+ a.current.style.transform = `translate(${b}px, ${g}px)`;
365
+ }, [a]), o = O((i) => {
366
+ if (!s.current) return;
367
+ s.current = !1;
368
+ const _ = i.clientX - c.current.x, f = i.clientY - c.current.y;
369
+ n.current = {
370
+ x: n.current.x + _,
371
+ y: n.current.y + f
372
+ }, a.current && (a.current.style.transition = ""), document.body.style.userSelect = "", window.removeEventListener("mousemove", t), window.removeEventListener("mouseup", o);
373
+ }, [a, t]), l = (i) => {
374
+ !r || !a.current || (s.current = !0, c.current = { x: i.clientX, y: i.clientY }, a.current.style.transition = "none", document.body.style.userSelect = "none", window.addEventListener("mousemove", t), window.addEventListener("mouseup", o));
375
+ };
376
+ return N(() => () => {
377
+ window.removeEventListener("mousemove", t), window.removeEventListener("mouseup", o);
378
+ }, [t, o]), N(() => {
379
+ r || (n.current = { x: 0, y: 0 });
380
+ }, [r]), { onMouseDown: l };
381
+ }, ne = ({
382
+ isOpen: r,
383
+ onClose: a,
384
+ children: s,
385
+ title: c,
386
+ footer: n,
387
+ closeOnOverlayClick: t = !0,
388
+ closeOnEsc: o = !0,
389
+ overlayClassName: l,
390
+ className: i,
391
+ overlayStyle: _,
392
+ style: f,
393
+ position: b = "center",
394
+ size: g = "md",
395
+ animation: y = "zoom",
396
+ initialFocusRef: k,
397
+ zIndex: J,
398
+ draggable: P = !1,
399
+ hideHeader: G = !1
400
+ }) => {
401
+ const [M, F] = A(!1), [W, q] = A(!1), L = S(null), { onMouseDown: H } = oe(P, L);
402
+ if (N(() => {
403
+ if (r)
404
+ F(!0), requestAnimationFrame(() => q(!0));
405
+ else {
406
+ q(!1);
407
+ const v = setTimeout(() => {
408
+ F(!1);
409
+ }, 200);
410
+ return () => clearTimeout(v);
411
+ }
412
+ }, [r]), N(() => {
413
+ if (!r || !o) return;
414
+ const v = (C) => {
415
+ C.key === "Escape" && a();
416
+ };
417
+ return document.addEventListener("keydown", v), () => document.removeEventListener("keydown", v);
418
+ }, [r, o, a]), N(() => {
419
+ if (!r || !M) return;
420
+ const v = L.current;
421
+ if (!v) return;
422
+ k != null && k.current ? k.current.focus() : v.focus();
423
+ const C = v.querySelectorAll(
424
+ 'a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])'
425
+ ), j = C[0], $ = C[C.length - 1], U = (R) => {
426
+ R.key === "Tab" && (R.shiftKey ? document.activeElement === j && (R.preventDefault(), $ == null || $.focus()) : document.activeElement === $ && (R.preventDefault(), j == null || j.focus()));
427
+ };
428
+ return v.addEventListener("keydown", U), () => v.removeEventListener("keydown", U);
429
+ }, [r, M, k]), N(() => {
430
+ if (r) {
431
+ const v = window.getComputedStyle(document.body).overflow;
432
+ return document.body.style.overflow = "hidden", () => {
433
+ document.body.style.overflow = v;
434
+ };
435
+ }
436
+ }, [r]), !M) return null;
437
+ const Z = (v) => {
438
+ v.target === v.currentTarget && t && a();
439
+ }, B = /* @__PURE__ */ d.jsx(
440
+ "div",
441
+ {
442
+ className: E(w.overlay, { [w.open]: W }, w[b], l),
443
+ style: { zIndex: J, ..._ },
444
+ onClick: Z,
445
+ role: "presentation",
446
+ children: /* @__PURE__ */ d.jsxs(
447
+ "div",
448
+ {
449
+ ref: L,
450
+ className: E(
451
+ w.modal,
452
+ { [w.open]: W },
453
+ w[g],
454
+ w[y],
455
+ i
456
+ ),
457
+ style: f,
458
+ role: "dialog",
459
+ "aria-modal": "true",
460
+ "aria-labelledby": c ? "modal-title" : void 0,
461
+ tabIndex: -1,
462
+ children: [
463
+ !G && /* @__PURE__ */ d.jsxs(
464
+ "div",
465
+ {
466
+ className: E(w.header, { [w.draggable]: P }),
467
+ onMouseDown: H,
468
+ style: { cursor: P ? "move" : "default" },
469
+ children: [
470
+ c ? /* @__PURE__ */ d.jsx("h2", { id: "modal-title", className: w.title, children: c }) : /* @__PURE__ */ d.jsx("div", {}),
471
+ /* @__PURE__ */ d.jsx(
472
+ "button",
473
+ {
474
+ type: "button",
475
+ className: w.closeButton,
476
+ onClick: a,
477
+ "aria-label": "Close modal",
478
+ children: /* @__PURE__ */ d.jsxs("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", children: [
479
+ /* @__PURE__ */ d.jsx("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
480
+ /* @__PURE__ */ d.jsx("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
481
+ ] })
482
+ }
483
+ )
484
+ ]
485
+ }
486
+ ),
487
+ /* @__PURE__ */ d.jsx("div", { className: w.content, children: s }),
488
+ n && /* @__PURE__ */ d.jsx("div", { className: w.footer, children: n })
489
+ ]
490
+ }
491
+ )
492
+ }
493
+ );
494
+ return ve(B, document.body);
495
+ }, Xe = "_drawer_43ihb_24", Je = "_left_43ihb_29", Ge = "_right_43ihb_30", He = "_top_43ihb_35", Ze = "_bottom_43ihb_36", Ke = "_alertModal_43ihb_41", Qe = "_alertContent_43ihb_47", et = "_icon_43ihb_53", tt = "_success_43ihb_64", rt = "_error_43ihb_69", ot = "_warning_43ihb_74", nt = "_info_43ihb_79", st = "_okButton_43ihb_84", at = "_confirmButton_43ihb_85", ct = "_cancelButton_43ihb_107", lt = "_destructive_43ihb_126", x = {
496
+ drawer: Xe,
497
+ left: Je,
498
+ right: Ge,
499
+ top: He,
500
+ bottom: Ze,
501
+ alertModal: Ke,
502
+ alertContent: Qe,
503
+ icon: et,
504
+ success: tt,
505
+ error: rt,
506
+ warning: ot,
507
+ info: nt,
508
+ okButton: st,
509
+ confirmButton: at,
510
+ cancelButton: ct,
511
+ destructive: lt
512
+ }, Wt = ({
513
+ type: r = "info",
514
+ message: a,
515
+ onOk: s,
516
+ okText: c = "OK",
517
+ onClose: n,
518
+ className: t,
519
+ showHeader: o = !0,
520
+ ...l
521
+ }) => {
522
+ const i = () => {
523
+ s == null || s(), n();
524
+ };
525
+ return /* @__PURE__ */ d.jsx(
526
+ ne,
527
+ {
528
+ ...l,
529
+ onClose: n,
530
+ className: E(x.alertModal, x[r], t),
531
+ size: "sm",
532
+ hideHeader: !o,
533
+ footer: /* @__PURE__ */ d.jsx("button", { className: x.okButton, onClick: i, children: c }),
534
+ children: /* @__PURE__ */ d.jsxs("div", { className: x.alertContent, children: [
535
+ /* @__PURE__ */ d.jsxs("div", { className: x.icon, children: [
536
+ r === "success" && "✓",
537
+ r === "error" && "✕",
538
+ r === "warning" && "!",
539
+ r === "info" && "i"
540
+ ] }),
541
+ /* @__PURE__ */ d.jsx("div", { className: x.message, children: a })
542
+ ] })
543
+ }
544
+ );
545
+ }, qt = ({
546
+ message: r,
547
+ onConfirm: a,
548
+ onCancel: s,
549
+ confirmText: c = "Confirm",
550
+ cancelText: n = "Cancel",
551
+ isDestructive: t = !1,
552
+ onClose: o,
553
+ className: l,
554
+ ...i
555
+ }) => {
556
+ const [_, f] = A(!1), b = async () => {
557
+ try {
558
+ f(!0), await a(), o();
559
+ } catch (y) {
560
+ console.error(y);
561
+ } finally {
562
+ f(!1);
563
+ }
564
+ }, g = () => {
565
+ s == null || s(), o();
566
+ };
567
+ return /* @__PURE__ */ d.jsx(
568
+ ne,
569
+ {
570
+ ...i,
571
+ onClose: o,
572
+ className: E(x.confirmModal, l),
573
+ size: "sm",
574
+ closeOnOverlayClick: !_,
575
+ closeOnEsc: !_,
576
+ footer: /* @__PURE__ */ d.jsxs(d.Fragment, { children: [
577
+ /* @__PURE__ */ d.jsx(
578
+ "button",
579
+ {
580
+ className: x.cancelButton,
581
+ onClick: g,
582
+ disabled: _,
583
+ children: n
584
+ }
585
+ ),
586
+ /* @__PURE__ */ d.jsx(
587
+ "button",
588
+ {
589
+ className: E(x.confirmButton, { [x.destructive]: t }),
590
+ onClick: b,
591
+ disabled: _,
592
+ children: _ ? "Processing..." : c
593
+ }
594
+ )
595
+ ] }),
596
+ children: /* @__PURE__ */ d.jsx("div", { className: x.confirmContent, children: r })
597
+ }
598
+ );
599
+ }, Ut = ({
600
+ placement: r = "right",
601
+ className: a,
602
+ ...s
603
+ }) => {
604
+ let c = "right", n = "slide-right";
605
+ switch (r) {
606
+ case "left":
607
+ c = "left", n = "drawer-slide-left";
608
+ break;
609
+ case "top":
610
+ c = "top", n = "drawer-slide-down";
611
+ break;
612
+ case "bottom":
613
+ c = "bottom", n = "drawer-slide-up";
614
+ break;
615
+ case "right":
616
+ default:
617
+ c = "right", n = "drawer-slide-right";
618
+ break;
619
+ }
620
+ return /* @__PURE__ */ d.jsx(
621
+ ne,
622
+ {
623
+ ...s,
624
+ position: c,
625
+ animation: n,
626
+ className: E(x.drawer, x[r], a)
627
+ }
628
+ );
629
+ }, it = "_wrapper_1bfkp_1", ut = "_trigger_1bfkp_6", dt = "_popover_1bfkp_11", _t = "_fadeIn_1bfkp_1", ft = "_draggable_1bfkp_24", mt = "_bottom_1bfkp_30", pt = "_top_1bfkp_37", ht = "_left_1bfkp_44", bt = "_right_1bfkp_51", V = {
630
+ wrapper: it,
631
+ trigger: ut,
632
+ popover: dt,
633
+ fadeIn: _t,
634
+ draggable: ft,
635
+ bottom: mt,
636
+ top: pt,
637
+ left: ht,
638
+ right: bt
639
+ }, vt = (r, a) => {
640
+ N(() => {
641
+ const s = (c) => {
642
+ !r.current || r.current.contains(c.target) || a(c);
643
+ };
644
+ return document.addEventListener("mousedown", s), document.addEventListener("touchstart", s), () => {
645
+ document.removeEventListener("mousedown", s), document.removeEventListener("touchstart", s);
646
+ };
647
+ }, [r, a]);
648
+ }, zt = ({
649
+ children: r,
650
+ content: a,
651
+ position: s = "bottom",
652
+ className: c,
653
+ style: n,
654
+ width: t,
655
+ draggable: o = !1
656
+ }) => {
657
+ const [l, i] = A(!1), _ = S(null), f = S(null);
658
+ vt(_, () => {
659
+ l && i(!1);
660
+ });
661
+ const { onMouseDown: b } = oe(o, f), g = () => i(!l);
662
+ return /* @__PURE__ */ d.jsxs("div", { className: V.wrapper, ref: _, children: [
663
+ /* @__PURE__ */ d.jsx("div", { onClick: g, className: V.trigger, children: r }),
664
+ l && /* @__PURE__ */ d.jsx(
665
+ "div",
666
+ {
667
+ ref: f,
668
+ className: E(
669
+ V.popover,
670
+ V[s],
671
+ c,
672
+ { [V.draggable]: o }
673
+ ),
674
+ style: { width: t, ...n },
675
+ role: "dialog",
676
+ "aria-modal": "false",
677
+ onMouseDown: b,
678
+ children: typeof a == "function" ? a(() => i(!1)) : a
679
+ }
680
+ )
681
+ ] });
682
+ }, gt = "_toast_15h14_1", wt = "_slideIn_15h14_1", xt = "_draggable_15h14_19", Et = "_exiting_15h14_24", yt = "_success_15h14_31", Tt = "_error_15h14_35", kt = "_warning_15h14_39", jt = "_info_15h14_43", Rt = "_icon_15h14_47", Nt = "_content_15h14_78", St = "_closeBtn_15h14_85", Ot = "_container_15h14_119", At = "_slideInBottom_15h14_1", T = {
683
+ toast: gt,
684
+ slideIn: wt,
685
+ draggable: xt,
686
+ exiting: Et,
687
+ success: yt,
688
+ error: Tt,
689
+ warning: kt,
690
+ info: jt,
691
+ icon: Rt,
692
+ content: Nt,
693
+ closeBtn: St,
694
+ container: Ot,
695
+ "top-left": "_top-left_15h14_129",
696
+ "top-right": "_top-right_15h14_135",
697
+ "top-center": "_top-center_15h14_141",
698
+ "bottom-left": "_bottom-left_15h14_148",
699
+ "bottom-right": "_bottom-right_15h14_155",
700
+ "bottom-center": "_bottom-center_15h14_162",
701
+ slideInBottom: At
702
+ }, Pt = ({
703
+ id: r,
704
+ type: a,
705
+ content: s,
706
+ duration: c = 3e3,
707
+ onDismiss: n,
708
+ draggable: t = !1
709
+ }) => {
710
+ const [o, l] = A(!1), i = S(null), { onMouseDown: _ } = oe(t, i), f = re.useCallback(() => {
711
+ l(!0), setTimeout(() => {
712
+ n(r);
713
+ }, 300);
714
+ }, [r, n]);
715
+ return N(() => {
716
+ if (c > 0) {
717
+ const b = setTimeout(() => {
718
+ f();
719
+ }, c);
720
+ return () => clearTimeout(b);
721
+ }
722
+ }, [c, f]), /* @__PURE__ */ d.jsxs(
723
+ "div",
724
+ {
725
+ ref: i,
726
+ className: E(
727
+ T.toast,
728
+ T[a],
729
+ {
730
+ [T.exiting]: o,
731
+ [T.draggable]: t
732
+ }
733
+ ),
734
+ role: "alert",
735
+ onMouseDown: _,
736
+ children: [
737
+ /* @__PURE__ */ d.jsxs("div", { className: T.icon, children: [
738
+ a === "success" && "✓",
739
+ a === "error" && "✕",
740
+ a === "warning" && "!",
741
+ a === "info" && "i"
742
+ ] }),
743
+ /* @__PURE__ */ d.jsx("div", { className: T.content, children: s }),
744
+ /* @__PURE__ */ d.jsx("button", { className: T.closeBtn, onClick: f, children: "×" })
745
+ ]
746
+ }
747
+ );
748
+ }, me = he(void 0);
749
+ let Ct = 0;
750
+ const Xt = ({ children: r }) => {
751
+ const [a, s] = A([]), c = O(({ closeOthers: l, delay: i = 0, ..._ }) => {
752
+ const f = `toast-${Ct++}`, b = { ..._, duration: _.duration, delay: i, id: f }, g = () => {
753
+ s((y) => l ? [b] : [...y, b]);
754
+ };
755
+ i > 0 ? setTimeout(g, i) : g();
756
+ }, []), n = O((l) => {
757
+ s((i) => i.filter((_) => _.id !== l));
758
+ }, []), t = O(() => {
759
+ s([]);
760
+ }, []), o = a.reduce((l, i) => {
761
+ const _ = i.position || "top-right";
762
+ return l[_] || (l[_] = []), l[_].push(i), l;
763
+ }, {});
764
+ return /* @__PURE__ */ d.jsxs(me.Provider, { value: { addToast: c, removeToast: n, clearAll: t }, children: [
765
+ r,
766
+ Object.keys(o).map((l) => /* @__PURE__ */ d.jsx("div", { className: E(T.container, T[l]), children: o[l].map((i) => /* @__PURE__ */ d.jsx(Pt, { ...i, onDismiss: n }, i.id)) }, l))
767
+ ] });
768
+ }, Jt = () => {
769
+ const r = be(me);
770
+ if (!r)
771
+ throw new Error("useToast must be used within a ToastProvider");
772
+ const { addToast: a, removeToast: s, clearAll: c } = r, n = (t, o, l = {}) => {
773
+ let i, _ = { ...l };
774
+ if (typeof o == "object" && o !== null && "content" in o && !re.isValidElement(o)) {
775
+ const f = o;
776
+ i = f.content, _ = { ..._, ...f };
777
+ } else
778
+ i = o;
779
+ a({
780
+ type: t,
781
+ content: i,
782
+ duration: 3e3,
783
+ position: "top-right",
784
+ ..._
785
+ });
786
+ };
787
+ return {
788
+ success: (t, o) => n("success", t, o),
789
+ error: (t, o) => n("error", t, o),
790
+ warning: (t, o) => n("warning", t, o),
791
+ info: (t, o) => n("info", t, o),
792
+ dismiss: (t) => s(t),
793
+ dismissAll: () => c()
794
+ };
795
+ }, $t = "_wrapper_1dham_1", It = "_tooltip_1dham_6", Mt = "_fadeIn_1dham_1", Lt = "_top_1dham_22", Bt = "_bottom_1dham_28", Dt = "_left_1dham_34", Yt = "_right_1dham_40", te = {
796
+ wrapper: $t,
797
+ tooltip: It,
798
+ fadeIn: Mt,
799
+ top: Lt,
800
+ bottom: Bt,
801
+ left: Dt,
802
+ right: Yt
803
+ }, Gt = ({
804
+ children: r,
805
+ content: a,
806
+ position: s = "top",
807
+ delay: c = 200,
808
+ width: n,
809
+ height: t,
810
+ className: o,
811
+ style: l
812
+ }) => {
813
+ const [i, _] = A(!1), f = S(null), b = () => {
814
+ f.current = setTimeout(() => {
815
+ _(!0);
816
+ }, c);
817
+ }, g = () => {
818
+ f.current && clearTimeout(f.current), _(!1);
819
+ };
820
+ return /* @__PURE__ */ d.jsxs(
821
+ "div",
822
+ {
823
+ className: te.wrapper,
824
+ onMouseEnter: b,
825
+ onMouseLeave: g,
826
+ onFocus: b,
827
+ onBlur: g,
828
+ children: [
829
+ r,
830
+ i && /* @__PURE__ */ d.jsx(
831
+ "div",
832
+ {
833
+ className: E(te.tooltip, te[s], o),
834
+ style: { width: n, height: t, ...l },
835
+ role: "tooltip",
836
+ children: a
837
+ }
838
+ )
839
+ ]
840
+ }
841
+ );
842
+ }, Ht = (r = !1) => {
843
+ const [a, s] = A(r), c = O(() => s(!0), []), n = O(() => s(!1), []), t = O(() => s((o) => !o), []);
844
+ return {
845
+ isOpen: a,
846
+ open: c,
847
+ close: n,
848
+ toggle: t
849
+ };
850
+ };
851
+ export {
852
+ Wt as AlertModal,
853
+ qt as ConfirmModal,
854
+ Ut as Drawer,
855
+ ne as Modal,
856
+ zt as Popover,
857
+ Pt as Toast,
858
+ me as ToastContext,
859
+ Xt as ToastProvider,
860
+ Gt as Tooltip,
861
+ vt as useClickOutside,
862
+ oe as useDraggable,
863
+ Ht as useModal,
864
+ Jt as useToast
865
+ };