@paciu/ui 0.0.50 → 0.0.51

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/index.es.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { jsx as a, jsxs as P } from "react/jsx-runtime";
2
2
  import m, { useState as x, useEffect as w, useRef as L } from "react";
3
- import { c as f, s as d, u as S } from "./provider-DBaw9HKy.js";
4
- import { D as X, a as Z, T as ss } from "./provider-DBaw9HKy.js";
3
+ import { c as f, s as d, u as S } from "./provider-Kkk4KMCp.js";
4
+ import { D as X, a as Z, T as ss } from "./provider-Kkk4KMCp.js";
5
5
  import './index.css';const n = {
6
6
  "paciu-ui-button": "_paciu-ui-button_y249s_14",
7
7
  "size-micro": "_size-micro_y249s_23",
@@ -0,0 +1,153 @@
1
+ "use client";
2
+ import { jsxs as A, jsx as L } from "react/jsx-runtime";
3
+ import { createContext as $, useState as y, useRef as z, useCallback as w, useMemo as k, useEffect as u, useContext as H } from "react";
4
+ import { createPortal as I } from "react-dom";
5
+ import './provider.css';function O(t) {
6
+ var r, a, s = "";
7
+ if (typeof t == "string" || typeof t == "number") s += t;
8
+ else if (typeof t == "object") if (Array.isArray(t)) {
9
+ var _ = t.length;
10
+ for (r = 0; r < _; r++) t[r] && (a = O(t[r])) && (s && (s += " "), s += a);
11
+ } else for (a in t) t[a] && (s && (s += " "), s += a);
12
+ return s;
13
+ }
14
+ function K() {
15
+ for (var t, r, a = 0, s = "", _ = arguments.length; a < _; a++) (t = arguments[a]) && (r = O(t)) && (s && (s += " "), s += r);
16
+ return s;
17
+ }
18
+ const N = "_active_1rsd6_164", c = {
19
+ "dialog-overlay": "_dialog-overlay_1rsd6_45",
20
+ "dialog-compose": "_dialog-compose_1rsd6_62",
21
+ "dialog-close": "_dialog-close_1rsd6_68",
22
+ "dialog-close-cross": "_dialog-close-cross_1rsd6_85",
23
+ "dialog-window": "_dialog-window_1rsd6_109",
24
+ "dialog-window-header": "_dialog-window-header_1rsd6_123",
25
+ "dialog-window-body": "_dialog-window-body_1rsd6_136",
26
+ "dialog-window-footer": "_dialog-window-footer_1rsd6_142",
27
+ "full-height": "_full-height_1rsd6_155",
28
+ "full-width": "_full-width_1rsd6_158",
29
+ "un-closable": "_un-closable_1rsd6_161",
30
+ active: N,
31
+ "position-top-center": "_position-top-center_1rsd6_170",
32
+ "position-center": "_position-center_1rsd6_176",
33
+ "position-bottom-center": "_position-bottom-center_1rsd6_180",
34
+ "position-left-top": "_position-left-top_1rsd6_186",
35
+ "position-left-center": "_position-left-center_1rsd6_192",
36
+ "position-left-bottom": "_position-left-bottom_1rsd6_198",
37
+ "position-right-top": "_position-right-top_1rsd6_204",
38
+ "position-right-center": "_position-right-center_1rsd6_210",
39
+ "position-right-bottom": "_position-right-bottom_1rsd6_216",
40
+ "animated-opening": "_animated-opening_1rsd6_222",
41
+ "animated-opening-opacity": "_animated-opening-opacity_1rsd6_1",
42
+ "animated-opening-translate": "_animated-opening-translate_1rsd6_1",
43
+ "animated-closing": "_animated-closing_1rsd6_228",
44
+ "animated-closing-opacity": "_animated-closing-opacity_1rsd6_1",
45
+ "animated-closing-translate": "_animated-closing-translate_1rsd6_1",
46
+ "paciu-ui-blink-animation": "_paciu-ui-blink-animation_1rsd6_1"
47
+ };
48
+ var p = /* @__PURE__ */ ((t) => (t.Light = "light", t.Dark = "dark", t.System = "system", t))(p || {}), i = /* @__PURE__ */ ((t) => (t.Opening = "opening", t.Opened = "opened", t.Closing = "closing", t.Closed = "closed", t))(i || {}), x = /* @__PURE__ */ ((t) => (t.TopCenter = "top-center", t.Center = "center", t.BottomCenter = "bottom-center", t.LeftTop = "left-top", t.LeftCenter = "left-center", t.LeftBottom = "left-bottom", t.RightTop = "right-top", t.RightCenter = "right-center", t.RightBottom = "right-bottom", t))(x || {});
49
+ const T = $(void 0), q = () => H(T), F = ({ children: t, initialTheme: r, defaultDialogPosition: a }) => {
50
+ const [s, _] = y(!1), [g, E] = y(r || null), [m, B] = y(r || null), [d, h] = y([]), R = z(0), C = w((e) => {
51
+ document.documentElement.dataset.theme = e || void 0, E(e);
52
+ }, []), b = w((e, n) => {
53
+ h((o) => {
54
+ if (o.length > 0) {
55
+ const l = [...o], M = l.length - 1;
56
+ if (l[M].status === i.Opening)
57
+ return o;
58
+ }
59
+ return [...o, { id: ++R.current, status: i.Opening, node: e, options: n }];
60
+ });
61
+ }, []), f = w((e) => {
62
+ h((n) => {
63
+ if (n.length === 0)
64
+ return n;
65
+ const o = [...n], l = o.length - 1;
66
+ return o[l].status === i.Closing || (e?.esc || e?.outside) && o[l]?.options?.unClosable ? n : (o[l] = { ...o[l], status: i.Closing }, o);
67
+ });
68
+ }, []), v = k(() => {
69
+ const e = g || m;
70
+ return e ? e === p.Light ? p.Dark : p.Light : null;
71
+ }, [g, m]), j = k(
72
+ () => ({ theme: g, nextTheme: v, systemTheme: m, toggleTheme: C, openDialog: b, closeDialog: f, dialogsQueue: d }),
73
+ [g, v, m, C, b, f, d]
74
+ );
75
+ return u(() => {
76
+ if (d.length) {
77
+ const e = d[d.length - 1];
78
+ e.status === i.Opening && (e?.options?.onOpen && e.options.onOpen(), setTimeout(() => {
79
+ h((n) => {
80
+ const o = [...n];
81
+ return o[o.length - 1].status = i.Opened, o;
82
+ }), e?.options?.onOpened && e.options.onOpened();
83
+ }, 240)), e.status === i.Closing && (e?.options?.onClose && e.options.onClose(), setTimeout(() => {
84
+ h((n) => n.slice(0, -1)), e?.options?.onClosed && e.options.onClosed();
85
+ }, 240));
86
+ }
87
+ }, [d]), u(() => {
88
+ const e = window.matchMedia("(prefers-color-scheme: dark)"), n = (o) => {
89
+ B(o.matches ? p.Dark : p.Light);
90
+ };
91
+ return n(e), e.addEventListener("change", n), () => e.removeEventListener("change", n);
92
+ }, []), u(() => {
93
+ document.body.style.overflowY = d.length ? "hidden" : "";
94
+ }, [d]), u(() => {
95
+ const e = (l) => {
96
+ l.key === "Escape" && (l.stopPropagation(), f({ esc: !0 }));
97
+ }, n = () => {
98
+ document.addEventListener("keydown", e);
99
+ }, o = () => {
100
+ document.removeEventListener("keydown", e);
101
+ };
102
+ return n(), () => {
103
+ o();
104
+ };
105
+ }, []), u(() => {
106
+ _(!0);
107
+ }), /* @__PURE__ */ A(T.Provider, { value: j, children: [
108
+ t,
109
+ s && I(
110
+ /* @__PURE__ */ L("div", { id: "paciu-ui-dialogs", children: d.map((e, n) => {
111
+ const o = e?.options?.position || a || x.Center;
112
+ return /* @__PURE__ */ L(
113
+ "div",
114
+ {
115
+ className: K(c["dialog-overlay"], {
116
+ [c["animated-opening"]]: [
117
+ i.Opening,
118
+ i.Opened
119
+ ].includes(e.status),
120
+ [c["animated-closing"]]: [
121
+ i.Closing,
122
+ i.Closed
123
+ ].includes(e.status),
124
+ [c.active]: n === d.length - 1,
125
+ [c["full-height"]]: e?.options?.fullHeight,
126
+ [c["full-width"]]: e?.options?.fullWidth,
127
+ [c["un-closable"]]: e?.options?.unClosable,
128
+ [c[`position-${o}`]]: !!o
129
+ }),
130
+ onClick: () => f({ outside: !0 }),
131
+ style: {
132
+ zIndex: n + 1e3,
133
+ transform: `scale(calc(1 - ${(d.length - n - 1) * 0.02}))`
134
+ },
135
+ children: e.node()
136
+ },
137
+ e.id
138
+ );
139
+ }) }),
140
+ document.body
141
+ )
142
+ ] });
143
+ };
144
+ export {
145
+ x as D,
146
+ T as P,
147
+ p as T,
148
+ i as a,
149
+ F as b,
150
+ K as c,
151
+ c as s,
152
+ q as u
153
+ };
package/dist/provider.css CHANGED
@@ -1 +1 @@
1
- @keyframes _animated-opening-translate_1u8dn_1{0%{transform:translate(var(--animated-from-x, 0),var(--animated-from-y, 0))}to{transform:translate(0)}}@keyframes _animated-opening-opacity_1u8dn_1{0%{opacity:0}to{opacity:1}}@keyframes _animated-closing-translate_1u8dn_1{0%{transform:translate(0)}to{transform:translate(var(--animated-from-x, 0),var(--animated-from-y, 0))}}@keyframes _animated-closing-opacity_1u8dn_1{0%{opacity:1}to{opacity:0}}._dialog-overlay_1u8dn_33{--window-background-color: var(--base-color-100);--window-shadow: var(--dialog-shadow, rgba(12, 12, 12, .06) 0px 0px 12px 0px);--window-width: var(--dialog-width, 768px);cursor:pointer;position:fixed;width:100%;height:100%;display:flex;flex-direction:column;opacity:0;left:0;top:0;padding:24px;transition:var(--transition-normal) transform;background:none}._dialog-overlay_1u8dn_33 ._dialog-compose_1u8dn_50{position:relative;max-height:100%;width:100%;max-width:var(--window-width)}._dialog-overlay_1u8dn_33 ._dialog-compose_1u8dn_50 ._dialog-close_1u8dn_56{width:32px;height:32px;background:var(--window-background-color);box-shadow:var(--window-shadow);border-radius:16px;position:fixed;top:-6px;right:-6px;z-index:2;display:flex;align-items:center;justify-content:center;cursor:pointer;opacity:0;transition:var(--transition-normal)}._dialog-overlay_1u8dn_33 ._dialog-compose_1u8dn_50 ._dialog-close_1u8dn_56 ._dialog-close-cross_1u8dn_73{position:relative;width:16px;height:16px;cursor:pointer}._dialog-overlay_1u8dn_33 ._dialog-compose_1u8dn_50 ._dialog-close_1u8dn_56 ._dialog-close-cross_1u8dn_73:before,._dialog-overlay_1u8dn_33 ._dialog-compose_1u8dn_50 ._dialog-close_1u8dn_56 ._dialog-close-cross_1u8dn_73:after{content:"";position:absolute;top:50%;left:0;width:100%;height:2px;background-color:var(--base-color-900);transition:var(--transition-normal) background;border-radius:2px}._dialog-overlay_1u8dn_33 ._dialog-compose_1u8dn_50 ._dialog-close_1u8dn_56 ._dialog-close-cross_1u8dn_73:before{transform:translateY(-50%) rotate(45deg)}._dialog-overlay_1u8dn_33 ._dialog-compose_1u8dn_50 ._dialog-close_1u8dn_56 ._dialog-close-cross_1u8dn_73:after{transform:translateY(-50%) rotate(-45deg)}._dialog-overlay_1u8dn_33 ._dialog-compose_1u8dn_50 ._dialog-window_1u8dn_97{position:relative;cursor:default;width:100%;height:100%;border-radius:32px;background:var(--window-background-color);transition:var(--transition-normal) background;display:flex;flex-direction:column;box-shadow:var(--window-shadow);overflow:auto;filter:blur(2px)}._dialog-overlay_1u8dn_33 ._dialog-compose_1u8dn_50 ._dialog-window_1u8dn_97 ._dialog-window-header_1u8dn_111{position:sticky;top:0;z-index:1;background:var(--window-background-color);transition:var(--transition-normal) background;padding:12px;border-radius:inherit;box-shadow:var(--window-shadow);display:flex;flex-direction:column;justify-content:center}._dialog-overlay_1u8dn_33 ._dialog-compose_1u8dn_50 ._dialog-window_1u8dn_97 ._dialog-window-body_1u8dn_124{flex-grow:1;padding:12px;position:relative;z-index:0}._dialog-overlay_1u8dn_33 ._dialog-compose_1u8dn_50 ._dialog-window_1u8dn_97 ._dialog-window-footer_1u8dn_130{position:sticky;bottom:0;z-index:1;background:var(--window-background-color);transition:var(--transition-normal) background;padding:12px;border-radius:inherit;box-shadow:var(--window-shadow);display:flex;flex-direction:column;justify-content:center}._dialog-overlay_1u8dn_33._full-height_1u8dn_143 ._dialog-compose_1u8dn_50{height:100%}._dialog-overlay_1u8dn_33._full-width_1u8dn_146 ._dialog-compose_1u8dn_50{max-width:unset}._dialog-overlay_1u8dn_33._un-closable_1u8dn_149 ._dialog-compose_1u8dn_50 ._dialog-close_1u8dn_56{display:none}._dialog-overlay_1u8dn_33._active_1u8dn_152 ._dialog-compose_1u8dn_50 ._dialog-close_1u8dn_56{opacity:1}._dialog-overlay_1u8dn_33._active_1u8dn_152 ._dialog-compose_1u8dn_50 ._dialog-window_1u8dn_97{filter:unset}._dialog-overlay_1u8dn_33._position-top-center_1u8dn_158{--animated-from-x: 0;--animated-from-y: -24px;justify-content:start;align-items:center}._dialog-overlay_1u8dn_33._position-center_1u8dn_164{justify-content:center;align-items:center}._dialog-overlay_1u8dn_33._position-bottom-center_1u8dn_168{--animated-from-x: 0;--animated-from-y: 24px;justify-content:end;align-items:center}._dialog-overlay_1u8dn_33._position-left-top_1u8dn_174{--animated-from-x: -24px;--animated-from-y: -24px;justify-content:start;align-items:start}._dialog-overlay_1u8dn_33._position-left-center_1u8dn_180{--animated-from-x: -24px;--animated-from-y: 0;justify-content:center;align-items:start}._dialog-overlay_1u8dn_33._position-left-bottom_1u8dn_186{--animated-from-x: -24px;--animated-from-y: 24px;justify-content:end;align-items:start}._dialog-overlay_1u8dn_33._position-right-top_1u8dn_192{--animated-from-x: 24px;--animated-from-y: -24px;justify-content:start;align-items:end}._dialog-overlay_1u8dn_33._position-right-center_1u8dn_198{--animated-from-x: 24px;--animated-from-y: 0;justify-content:center;align-items:end}._dialog-overlay_1u8dn_33._position-right-bottom_1u8dn_204{--animated-from-x: 24px;--animated-from-y: 24px;justify-content:end;align-items:end}._dialog-overlay_1u8dn_33._animated-opening_1u8dn_210{animation:_animated-opening-opacity_1u8dn_1 .24s linear forwards}._dialog-overlay_1u8dn_33._animated-opening_1u8dn_210 ._dialog-compose_1u8dn_50{animation:_animated-opening-translate_1u8dn_1 .24s linear forwards}._dialog-overlay_1u8dn_33._animated-closing_1u8dn_216{pointer-events:none;animation:_animated-closing-opacity_1u8dn_1 .24s linear forwards}._dialog-overlay_1u8dn_33._animated-closing_1u8dn_216 ._dialog-compose_1u8dn_50{animation:_animated-closing-translate_1u8dn_1 .24s linear forwards}
1
+ @keyframes _paciu-ui-blink-animation_1rsd6_1{0%{opacity:1}50%{opacity:.32}to{opacity:1}}@keyframes _animated-opening-translate_1rsd6_1{0%{transform:translate(var(--animated-from-x, 0),var(--animated-from-y, 0))}to{transform:translate(0)}}@keyframes _animated-opening-opacity_1rsd6_1{0%{opacity:0}to{opacity:1}}@keyframes _animated-closing-translate_1rsd6_1{0%{transform:translate(0)}to{transform:translate(var(--animated-from-x, 0),var(--animated-from-y, 0))}}@keyframes _animated-closing-opacity_1rsd6_1{0%{opacity:1}to{opacity:0}}._dialog-overlay_1rsd6_45{--window-background-color: var(--base-color-100);--window-shadow: var(--dialog-shadow, rgba(12, 12, 12, .06) 0px 0px 12px 0px);--window-width: var(--dialog-width, 768px);cursor:pointer;position:fixed;width:100%;height:100%;display:flex;flex-direction:column;opacity:0;left:0;top:0;padding:24px;transition:var(--transition-normal) transform;background:none}._dialog-overlay_1rsd6_45 ._dialog-compose_1rsd6_62{position:relative;max-height:100%;width:100%;max-width:var(--window-width)}._dialog-overlay_1rsd6_45 ._dialog-compose_1rsd6_62 ._dialog-close_1rsd6_68{width:32px;height:32px;background:var(--window-background-color);box-shadow:var(--window-shadow);border-radius:16px;position:fixed;top:-6px;right:-6px;z-index:2;display:flex;align-items:center;justify-content:center;cursor:pointer;opacity:0;transition:var(--transition-normal)}._dialog-overlay_1rsd6_45 ._dialog-compose_1rsd6_62 ._dialog-close_1rsd6_68 ._dialog-close-cross_1rsd6_85{position:relative;width:16px;height:16px;cursor:pointer}._dialog-overlay_1rsd6_45 ._dialog-compose_1rsd6_62 ._dialog-close_1rsd6_68 ._dialog-close-cross_1rsd6_85:before,._dialog-overlay_1rsd6_45 ._dialog-compose_1rsd6_62 ._dialog-close_1rsd6_68 ._dialog-close-cross_1rsd6_85:after{content:"";position:absolute;top:50%;left:0;width:100%;height:2px;background-color:var(--base-color-900);transition:var(--transition-normal) background;border-radius:2px}._dialog-overlay_1rsd6_45 ._dialog-compose_1rsd6_62 ._dialog-close_1rsd6_68 ._dialog-close-cross_1rsd6_85:before{transform:translateY(-50%) rotate(45deg)}._dialog-overlay_1rsd6_45 ._dialog-compose_1rsd6_62 ._dialog-close_1rsd6_68 ._dialog-close-cross_1rsd6_85:after{transform:translateY(-50%) rotate(-45deg)}._dialog-overlay_1rsd6_45 ._dialog-compose_1rsd6_62 ._dialog-window_1rsd6_109{position:relative;cursor:default;width:100%;height:100%;border-radius:32px;background:var(--window-background-color);transition:var(--transition-normal) background;display:flex;flex-direction:column;box-shadow:var(--window-shadow);overflow:auto;filter:blur(2px)}._dialog-overlay_1rsd6_45 ._dialog-compose_1rsd6_62 ._dialog-window_1rsd6_109 ._dialog-window-header_1rsd6_123{position:sticky;top:0;z-index:1;background:var(--window-background-color);transition:var(--transition-normal) background;padding:12px;border-radius:inherit;box-shadow:var(--window-shadow);display:flex;flex-direction:column;justify-content:center}._dialog-overlay_1rsd6_45 ._dialog-compose_1rsd6_62 ._dialog-window_1rsd6_109 ._dialog-window-body_1rsd6_136{flex-grow:1;padding:12px;position:relative;z-index:0}._dialog-overlay_1rsd6_45 ._dialog-compose_1rsd6_62 ._dialog-window_1rsd6_109 ._dialog-window-footer_1rsd6_142{position:sticky;bottom:0;z-index:1;background:var(--window-background-color);transition:var(--transition-normal) background;padding:12px;border-radius:inherit;box-shadow:var(--window-shadow);display:flex;flex-direction:column;justify-content:center}._dialog-overlay_1rsd6_45._full-height_1rsd6_155 ._dialog-compose_1rsd6_62{height:100%}._dialog-overlay_1rsd6_45._full-width_1rsd6_158 ._dialog-compose_1rsd6_62{max-width:unset}._dialog-overlay_1rsd6_45._un-closable_1rsd6_161 ._dialog-compose_1rsd6_62 ._dialog-close_1rsd6_68{display:none}._dialog-overlay_1rsd6_45._active_1rsd6_164 ._dialog-compose_1rsd6_62 ._dialog-close_1rsd6_68{opacity:1}._dialog-overlay_1rsd6_45._active_1rsd6_164 ._dialog-compose_1rsd6_62 ._dialog-window_1rsd6_109{filter:unset}._dialog-overlay_1rsd6_45._position-top-center_1rsd6_170{--animated-from-x: 0;--animated-from-y: -24px;justify-content:start;align-items:center}._dialog-overlay_1rsd6_45._position-center_1rsd6_176{justify-content:center;align-items:center}._dialog-overlay_1rsd6_45._position-bottom-center_1rsd6_180{--animated-from-x: 0;--animated-from-y: 24px;justify-content:end;align-items:center}._dialog-overlay_1rsd6_45._position-left-top_1rsd6_186{--animated-from-x: -24px;--animated-from-y: -24px;justify-content:start;align-items:start}._dialog-overlay_1rsd6_45._position-left-center_1rsd6_192{--animated-from-x: -24px;--animated-from-y: 0;justify-content:center;align-items:start}._dialog-overlay_1rsd6_45._position-left-bottom_1rsd6_198{--animated-from-x: -24px;--animated-from-y: 24px;justify-content:end;align-items:start}._dialog-overlay_1rsd6_45._position-right-top_1rsd6_204{--animated-from-x: 24px;--animated-from-y: -24px;justify-content:start;align-items:end}._dialog-overlay_1rsd6_45._position-right-center_1rsd6_210{--animated-from-x: 24px;--animated-from-y: 0;justify-content:center;align-items:end}._dialog-overlay_1rsd6_45._position-right-bottom_1rsd6_216{--animated-from-x: 24px;--animated-from-y: 24px;justify-content:end;align-items:end}._dialog-overlay_1rsd6_45._animated-opening_1rsd6_222{animation:_animated-opening-opacity_1rsd6_1 .24s linear forwards}._dialog-overlay_1rsd6_45._animated-opening_1rsd6_222 ._dialog-compose_1rsd6_62{animation:_animated-opening-translate_1rsd6_1 .24s linear forwards}._dialog-overlay_1rsd6_45._animated-closing_1rsd6_228{pointer-events:none;animation:_animated-closing-opacity_1rsd6_1 .24s linear forwards}._dialog-overlay_1rsd6_45._animated-closing_1rsd6_228 ._dialog-compose_1rsd6_62{animation:_animated-closing-translate_1rsd6_1 .24s linear forwards}
@@ -1,7 +1,7 @@
1
1
  import "react/jsx-runtime";
2
2
  import "react";
3
3
  import "react-dom";
4
- import { P as e, b as u, u as P } from "./provider-DBaw9HKy.js";
4
+ import { P as e, b as u, u as P } from "./provider-Kkk4KMCp.js";
5
5
  export {
6
6
  e as PaciuContext,
7
7
  u as PaciuProvider,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paciu/ui",
3
- "version": "0.0.50",
3
+ "version": "0.0.51",
4
4
  "type": "module",
5
5
  "main": "./dist/index.umd.js",
6
6
  "module": "./dist/index.es.js",
@@ -1,152 +0,0 @@
1
- "use client";
2
- import { jsxs as A, jsx as L } from "react/jsx-runtime";
3
- import { createContext as $, useState as y, useRef as z, useCallback as w, useMemo as O, useEffect as _, useContext as H } from "react";
4
- import { createPortal as I } from "react-dom";
5
- import './provider.css';function k(t) {
6
- var d, a, s = "";
7
- if (typeof t == "string" || typeof t == "number") s += t;
8
- else if (typeof t == "object") if (Array.isArray(t)) {
9
- var p = t.length;
10
- for (d = 0; d < p; d++) t[d] && (a = k(t[d])) && (s && (s += " "), s += a);
11
- } else for (a in t) t[a] && (s && (s += " "), s += a);
12
- return s;
13
- }
14
- function K() {
15
- for (var t, d, a = 0, s = "", p = arguments.length; a < p; a++) (t = arguments[a]) && (d = k(t)) && (s && (s += " "), s += d);
16
- return s;
17
- }
18
- const N = "_active_1u8dn_152", c = {
19
- "dialog-overlay": "_dialog-overlay_1u8dn_33",
20
- "dialog-compose": "_dialog-compose_1u8dn_50",
21
- "dialog-close": "_dialog-close_1u8dn_56",
22
- "dialog-close-cross": "_dialog-close-cross_1u8dn_73",
23
- "dialog-window": "_dialog-window_1u8dn_97",
24
- "dialog-window-header": "_dialog-window-header_1u8dn_111",
25
- "dialog-window-body": "_dialog-window-body_1u8dn_124",
26
- "dialog-window-footer": "_dialog-window-footer_1u8dn_130",
27
- "full-height": "_full-height_1u8dn_143",
28
- "full-width": "_full-width_1u8dn_146",
29
- "un-closable": "_un-closable_1u8dn_149",
30
- active: N,
31
- "position-top-center": "_position-top-center_1u8dn_158",
32
- "position-center": "_position-center_1u8dn_164",
33
- "position-bottom-center": "_position-bottom-center_1u8dn_168",
34
- "position-left-top": "_position-left-top_1u8dn_174",
35
- "position-left-center": "_position-left-center_1u8dn_180",
36
- "position-left-bottom": "_position-left-bottom_1u8dn_186",
37
- "position-right-top": "_position-right-top_1u8dn_192",
38
- "position-right-center": "_position-right-center_1u8dn_198",
39
- "position-right-bottom": "_position-right-bottom_1u8dn_204",
40
- "animated-opening": "_animated-opening_1u8dn_210",
41
- "animated-opening-opacity": "_animated-opening-opacity_1u8dn_1",
42
- "animated-opening-translate": "_animated-opening-translate_1u8dn_1",
43
- "animated-closing": "_animated-closing_1u8dn_216",
44
- "animated-closing-opacity": "_animated-closing-opacity_1u8dn_1",
45
- "animated-closing-translate": "_animated-closing-translate_1u8dn_1"
46
- };
47
- var i = /* @__PURE__ */ ((t) => (t.Opening = "opening", t.Opened = "opened", t.Closing = "closing", t.Closed = "closed", t))(i || {}), x = /* @__PURE__ */ ((t) => (t.TopCenter = "top-center", t.Center = "center", t.BottomCenter = "bottom-center", t.LeftTop = "left-top", t.LeftCenter = "left-center", t.LeftBottom = "left-bottom", t.RightTop = "right-top", t.RightCenter = "right-center", t.RightBottom = "right-bottom", t))(x || {}), u = /* @__PURE__ */ ((t) => (t.Light = "light", t.Dark = "dark", t.System = "system", t))(u || {});
48
- const T = $(void 0), q = () => H(T), F = ({ children: t, initialTheme: d, defaultDialogPosition: a }) => {
49
- const [s, p] = y(!1), [g, E] = y(d || null), [m, B] = y(d || null), [r, h] = y([]), R = z(0), C = w((n) => {
50
- document.documentElement.dataset.theme = n || void 0, E(n);
51
- }, []), b = w((n, o) => {
52
- h((e) => {
53
- if (e.length > 0) {
54
- const l = [...e], M = l.length - 1;
55
- if (l[M].status === i.Opening)
56
- return e;
57
- }
58
- return [...e, { id: ++R.current, status: i.Opening, node: n, options: o }];
59
- });
60
- }, []), f = w((n) => {
61
- h((o) => {
62
- if (o.length === 0)
63
- return o;
64
- const e = [...o], l = e.length - 1;
65
- return e[l].status === i.Closing || (n?.esc || n?.outside) && e[l]?.options?.unClosable ? o : (e[l] = { ...e[l], status: i.Closing }, e);
66
- });
67
- }, []), v = O(() => {
68
- const n = g || m;
69
- return n ? n === u.Light ? u.Dark : u.Light : null;
70
- }, [g, m]), j = O(
71
- () => ({ theme: g, nextTheme: v, systemTheme: m, toggleTheme: C, openDialog: b, closeDialog: f, dialogsQueue: r }),
72
- [g, v, m, C, b, f, r]
73
- );
74
- return _(() => {
75
- if (r.length) {
76
- const n = r[r.length - 1];
77
- n.status === i.Opening && (n?.options?.onOpen && n.options.onOpen(), setTimeout(() => {
78
- h((o) => {
79
- const e = [...o];
80
- return e[e.length - 1].status = i.Opened, e;
81
- }), n?.options?.onOpened && n.options.onOpened();
82
- }, 240)), n.status === i.Closing && (n?.options?.onClose && n.options.onClose(), setTimeout(() => {
83
- h((o) => o.slice(0, -1)), n?.options?.onClosed && n.options.onClosed();
84
- }, 240));
85
- }
86
- }, [r]), _(() => {
87
- const n = window.matchMedia("(prefers-color-scheme: dark)"), o = (e) => {
88
- B(e.matches ? u.Dark : u.Light);
89
- };
90
- return o(n), n.addEventListener("change", o), () => n.removeEventListener("change", o);
91
- }, []), _(() => {
92
- document.body.style.overflowY = r.length ? "hidden" : "";
93
- }, [r]), _(() => {
94
- const n = (l) => {
95
- l.key === "Escape" && (l.stopPropagation(), f({ esc: !0 }));
96
- }, o = () => {
97
- document.addEventListener("keydown", n);
98
- }, e = () => {
99
- document.removeEventListener("keydown", n);
100
- };
101
- return o(), () => {
102
- e();
103
- };
104
- }, []), _(() => {
105
- p(!0);
106
- }), /* @__PURE__ */ A(T.Provider, { value: j, children: [
107
- t,
108
- s && I(
109
- /* @__PURE__ */ L("div", { id: "paciu-ui-dialogs", children: r.map((n, o) => {
110
- const e = n?.options?.position || a || x.Center;
111
- return /* @__PURE__ */ L(
112
- "div",
113
- {
114
- className: K(c["dialog-overlay"], {
115
- [c["animated-opening"]]: [
116
- i.Opening,
117
- i.Opened
118
- ].includes(n.status),
119
- [c["animated-closing"]]: [
120
- i.Closing,
121
- i.Closed
122
- ].includes(n.status),
123
- [c.active]: o === r.length - 1,
124
- [c["full-height"]]: n?.options?.fullHeight,
125
- [c["full-width"]]: n?.options?.fullWidth,
126
- [c["un-closable"]]: n?.options?.unClosable,
127
- [c[`position-${e}`]]: !!e
128
- }),
129
- onClick: () => f({ outside: !0 }),
130
- style: {
131
- zIndex: o + 1e3,
132
- transform: `scale(calc(1 - ${(r.length - o - 1) * 0.02}))`
133
- },
134
- children: n.node()
135
- },
136
- n.id
137
- );
138
- }) }),
139
- document.body
140
- )
141
- ] });
142
- };
143
- export {
144
- x as D,
145
- T as P,
146
- u as T,
147
- i as a,
148
- F as b,
149
- K as c,
150
- c as s,
151
- q as u
152
- };