@paciu/ui 0.0.54 → 0.0.56

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,51 @@
1
+ import '../index2.css';function r(t) {
2
+ var n, i, o = "";
3
+ if (typeof t == "string" || typeof t == "number") o += t;
4
+ else if (typeof t == "object") if (Array.isArray(t)) {
5
+ var e = t.length;
6
+ for (n = 0; n < e; n++) t[n] && (i = r(t[n])) && (o && (o += " "), o += i);
7
+ } else for (i in t) t[i] && (o && (o += " "), o += i);
8
+ return o;
9
+ }
10
+ function l() {
11
+ for (var t, n, i = 0, o = "", e = arguments.length; i < e; i++) (t = arguments[i]) && (n = r(t)) && (o && (o += " "), o += n);
12
+ return o;
13
+ }
14
+ const _ = "_active_1rsd6_164", p = {
15
+ "dialog-overlay": "_dialog-overlay_1rsd6_45",
16
+ "dialog-compose": "_dialog-compose_1rsd6_62",
17
+ "dialog-close": "_dialog-close_1rsd6_68",
18
+ "dialog-close-cross": "_dialog-close-cross_1rsd6_85",
19
+ "dialog-window": "_dialog-window_1rsd6_109",
20
+ "dialog-window-header": "_dialog-window-header_1rsd6_123",
21
+ "dialog-window-body": "_dialog-window-body_1rsd6_136",
22
+ "dialog-window-footer": "_dialog-window-footer_1rsd6_142",
23
+ "full-height": "_full-height_1rsd6_155",
24
+ "full-width": "_full-width_1rsd6_158",
25
+ "un-closable": "_un-closable_1rsd6_161",
26
+ active: _,
27
+ "position-top-center": "_position-top-center_1rsd6_170",
28
+ "position-center": "_position-center_1rsd6_176",
29
+ "position-bottom-center": "_position-bottom-center_1rsd6_180",
30
+ "position-left-top": "_position-left-top_1rsd6_186",
31
+ "position-left-center": "_position-left-center_1rsd6_192",
32
+ "position-left-bottom": "_position-left-bottom_1rsd6_198",
33
+ "position-right-top": "_position-right-top_1rsd6_204",
34
+ "position-right-center": "_position-right-center_1rsd6_210",
35
+ "position-right-bottom": "_position-right-bottom_1rsd6_216",
36
+ "animated-opening": "_animated-opening_1rsd6_222",
37
+ "animated-opening-opacity": "_animated-opening-opacity_1rsd6_1",
38
+ "animated-opening-translate": "_animated-opening-translate_1rsd6_1",
39
+ "animated-closing": "_animated-closing_1rsd6_228",
40
+ "animated-closing-opacity": "_animated-closing-opacity_1rsd6_1",
41
+ "animated-closing-translate": "_animated-closing-translate_1rsd6_1",
42
+ "paciu-ui-blink-animation": "_paciu-ui-blink-animation_1rsd6_1"
43
+ };
44
+ var s = /* @__PURE__ */ ((t) => (t.Light = "light", t.Dark = "dark", t.System = "system", t))(s || {}), d = /* @__PURE__ */ ((t) => (t.Opening = "opening", t.Opened = "opened", t.Closing = "closing", t.Closed = "closed", t))(d || {}), a = /* @__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))(a || {});
45
+ export {
46
+ a as D,
47
+ s as T,
48
+ d as a,
49
+ l as c,
50
+ p as s
51
+ };
package/dist/index.d.ts CHANGED
@@ -13,11 +13,6 @@ export declare const Card: default_2.ForwardRefExoticComponent<CardProps & defau
13
13
  declare interface CardProps extends default_2.HTMLAttributes<HTMLDivElement>, Pick<Modifiers, 'size'> {
14
14
  }
15
15
 
16
- declare interface CloseDialogOptions {
17
- esc?: boolean;
18
- outside?: boolean;
19
- }
20
-
21
16
  export declare type ColorType = 'opposite' | 'accent' | 'error';
22
17
 
23
18
  export declare const Dialog: React.FC<DialogProps>;
@@ -39,13 +34,6 @@ declare interface DialogProps extends React.PropsWithChildren {
39
34
  footer?: React.ReactNode;
40
35
  }
41
36
 
42
- declare interface DialogQueueItem {
43
- id: number;
44
- status: DialogQueueItemStatus;
45
- node: () => React.ReactNode;
46
- options?: OpenDialogOptions;
47
- }
48
-
49
37
  export declare enum DialogQueueItemStatus {
50
38
  Opening = "opening",
51
39
  Opened = "opened",
@@ -77,27 +65,6 @@ export declare interface Modifiers {
77
65
  color?: ColorType;
78
66
  }
79
67
 
80
- declare interface OpenDialogOptions {
81
- position?: DialogPosition;
82
- unClosable?: boolean;
83
- fullHeight?: boolean;
84
- fullWidth?: boolean;
85
- onClose?: () => boolean | void;
86
- onClosed?: () => boolean | void;
87
- onOpen?: () => boolean | void;
88
- onOpened?: () => boolean | void;
89
- }
90
-
91
- declare interface PaciuContextType {
92
- theme: Theme | null;
93
- nextTheme: Theme | null;
94
- systemTheme: Theme | null;
95
- toggleTheme: (theme: Theme) => void;
96
- dialogsQueue: DialogQueueItem[];
97
- openDialog: (node: () => React.ReactNode, options?: OpenDialogOptions) => void;
98
- closeDialog: (options?: CloseDialogOptions) => void;
99
- }
100
-
101
68
  /** row */
102
69
  export declare const Row: default_2.ForwardRefExoticComponent<RowProps & default_2.RefAttributes<HTMLDivElement>>;
103
70
 
@@ -116,8 +83,6 @@ export declare type ThemeType = 'light' | 'dark' | 'system';
116
83
 
117
84
  export declare const useEscape: (callback: () => void) => void;
118
85
 
119
- export declare const usePaciu: () => PaciuContextType;
120
-
121
86
  export declare const useScroll: () => {
122
87
  isScrolled: boolean;
123
88
  };
package/dist/index.es.js CHANGED
@@ -1,7 +1,7 @@
1
- import { jsx as a, jsxs as P } from "react/jsx-runtime";
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 "./chunks/provider-core.es.js";
4
- import { D as X, a as Z, T as ss } from "./chunks/provider-core.es.js";
1
+ import { jsx as a, jsxs as b } from "react/jsx-runtime";
2
+ import m, { useState as $, useEffect as w, useRef as L } from "react";
3
+ import { c as f, s as d } from "./chunks/index.es.js";
4
+ import { D as V, a as W, T as X } from "./chunks/index.es.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",
@@ -21,7 +21,7 @@ import './index.css';const n = {
21
21
  "color-opposite": "_color-opposite_y249s_139",
22
22
  "color-accent": "_color-accent_y249s_207",
23
23
  "color-error": "_color-error_y249s_275"
24
- }, D = m.forwardRef((i, e) => {
24
+ }, S = m.forwardRef((i, e) => {
25
25
  const {
26
26
  children: s,
27
27
  className: o,
@@ -34,14 +34,14 @@ import './index.css';const n = {
34
34
  outline: z,
35
35
  // opaque,
36
36
  rounded: g,
37
- size: h,
38
- onClick: k,
39
- stopPropagation: $,
37
+ size: k,
38
+ onClick: h,
39
+ stopPropagation: x,
40
40
  stopImmediatePropagation: E,
41
41
  ...R
42
- } = i, [C, v] = x(!1), I = async (y) => {
43
- if ($ && y?.stopPropagation(), E && y?.nativeEvent?.stopImmediatePropagation(), k) {
44
- const N = k(y);
42
+ } = i, [C, v] = $(!1), I = async (y) => {
43
+ if (x && y?.stopPropagation(), E && y?.nativeEvent?.stopImmediatePropagation(), h) {
44
+ const N = h(y);
45
45
  if (N instanceof Promise) {
46
46
  v(!0);
47
47
  try {
@@ -69,7 +69,7 @@ import './index.css';const n = {
69
69
  [n["modifier-solid"]]: p,
70
70
  ...r && { [n[`color-${r}`]]: r }
71
71
  },
72
- h && n[`size-${h}`],
72
+ k && n[`size-${k}`],
73
73
  o
74
74
  ),
75
75
  onClick: I,
@@ -78,8 +78,8 @@ import './index.css';const n = {
78
78
  }
79
79
  );
80
80
  });
81
- D.displayName = "Button";
82
- const b = {
81
+ S.displayName = "Button";
82
+ const j = {
83
83
  "paciu-ui-row": "_paciu-ui-row_kd3dr_14",
84
84
  "size-micro": "_size-micro_kd3dr_23",
85
85
  "size-mini": "_size-mini_kd3dr_27",
@@ -88,15 +88,15 @@ const b = {
88
88
  "size-huge": "_size-huge_kd3dr_39",
89
89
  "size-enormous": "_size-enormous_kd3dr_43",
90
90
  "paciu-ui-blink-animation": "_paciu-ui-blink-animation_kd3dr_1"
91
- }, q = m.forwardRef((i, e) => {
91
+ }, D = m.forwardRef((i, e) => {
92
92
  const { className: s, size: o, children: r, ..._ } = i;
93
- return /* @__PURE__ */ a("div", { ref: e, className: f(b["paciu-ui-row"], o && b[`size-${o}`], s), ..._, children: r });
93
+ return /* @__PURE__ */ a("div", { ref: e, className: f(j["paciu-ui-row"], o && j[`size-${o}`], s), ..._, children: r });
94
94
  });
95
- q.displayName = "Row";
96
- const B = "_flex_ssd0s_14", F = "_inline_ssd0s_22", T = "_grow_ssd0s_25", t = {
97
- flex: B,
98
- inline: F,
99
- grow: T,
95
+ D.displayName = "Row";
96
+ const q = "_flex_ssd0s_14", B = "_inline_ssd0s_22", F = "_grow_ssd0s_25", t = {
97
+ flex: q,
98
+ inline: B,
99
+ grow: F,
100
100
  "direction-column": "_direction-column_ssd0s_28",
101
101
  "direction-row-reverse": "_direction-row-reverse_ssd0s_31",
102
102
  "direction-column-reverse": "_direction-column-reverse_ssd0s_34",
@@ -119,7 +119,7 @@ const B = "_flex_ssd0s_14", F = "_inline_ssd0s_22", T = "_grow_ssd0s_25", t = {
119
119
  "size-huge": "_size-huge_ssd0s_95",
120
120
  "size-enormous": "_size-enormous_ssd0s_99",
121
121
  "paciu-ui-blink-animation": "_paciu-ui-blink-animation_ssd0s_1"
122
- }, O = m.forwardRef((i, e) => {
122
+ }, T = m.forwardRef((i, e) => {
123
123
  const { children: s, className: o, direction: r, align: _, justify: l, wrap: c, size: u, inline: p, grow: z, ...g } = i;
124
124
  return /* @__PURE__ */ a(
125
125
  "div",
@@ -143,8 +143,8 @@ const B = "_flex_ssd0s_14", F = "_inline_ssd0s_22", T = "_grow_ssd0s_25", t = {
143
143
  }
144
144
  );
145
145
  });
146
- O.displayName = "Flex";
147
- const j = {
146
+ T.displayName = "Flex";
147
+ const P = {
148
148
  "paciu-ui-card": "_paciu-ui-card_a6huo_14",
149
149
  "size-micro": "_size-micro_a6huo_28",
150
150
  "size-mini": "_size-mini_a6huo_33",
@@ -153,26 +153,26 @@ const j = {
153
153
  "size-huge": "_size-huge_a6huo_48",
154
154
  "size-enormous": "_size-enormous_a6huo_53",
155
155
  "paciu-ui-blink-animation": "_paciu-ui-blink-animation_a6huo_1"
156
- }, Q = m.forwardRef((i, e) => {
156
+ }, O = m.forwardRef((i, e) => {
157
157
  const { children: s, className: o, size: r, ..._ } = i;
158
- return /* @__PURE__ */ a("div", { ref: e, className: f(j["paciu-ui-card"], r && j[`size-${r}`], o), ..._, children: s });
158
+ return /* @__PURE__ */ a("div", { ref: e, className: f(P["paciu-ui-card"], r && P[`size-${r}`], o), ..._, children: s });
159
159
  });
160
- Q.displayName = "Card";
161
- const H = ({ header: i, children: e, footer: s }) => /* @__PURE__ */ P("div", { className: d["dialog-compose"], children: [
160
+ O.displayName = "Card";
161
+ const G = ({ header: i, children: e, footer: s }) => /* @__PURE__ */ b("div", { className: d["dialog-compose"], children: [
162
162
  /* @__PURE__ */ a("div", { className: d["dialog-close"], children: /* @__PURE__ */ a("div", { className: d["dialog-close-cross"] }) }),
163
- /* @__PURE__ */ P("div", { className: d["dialog-window"], onClick: (o) => o.stopPropagation(), children: [
163
+ /* @__PURE__ */ b("div", { className: d["dialog-window"], onClick: (o) => o.stopPropagation(), children: [
164
164
  i && /* @__PURE__ */ a("div", { className: d["dialog-window-header"], children: i }),
165
165
  e && /* @__PURE__ */ a("div", { className: d["dialog-window-body"], children: e }),
166
166
  s && /* @__PURE__ */ a("div", { className: d["dialog-window-footer"], children: s })
167
167
  ] })
168
- ] }), J = (i) => {
168
+ ] }), H = (i) => {
169
169
  w(() => {
170
170
  const e = (s) => {
171
171
  s.key === "Escape" && (s.preventDefault(), s.stopPropagation(), s.stopImmediatePropagation(), i());
172
172
  };
173
173
  return document.addEventListener("keydown", e, !0), () => document.removeEventListener("keydown", e, !0);
174
174
  }, [i]);
175
- }, K = (i, e = [], s) => {
175
+ }, J = (i, e = [], s) => {
176
176
  const o = L(s?.count || 1);
177
177
  w(() => {
178
178
  if (o.current > 0) {
@@ -181,30 +181,25 @@ const H = ({ header: i, children: e, footer: s }) => /* @__PURE__ */ P("div", {
181
181
  }
182
182
  return i();
183
183
  }, e);
184
- }, M = () => {
185
- const [i, e] = x(!1);
184
+ }, K = () => {
185
+ const [i, e] = $(!1);
186
186
  return w(() => {
187
187
  const s = () => e(window.scrollY > 0);
188
188
  return s(), document.addEventListener("scroll", s), () => {
189
189
  document.removeEventListener("scroll", s);
190
190
  };
191
191
  }, []), { isScrolled: i };
192
- }, U = () => {
193
- const i = S();
194
- if (!i) throw new Error("usePaciu must be used within PaciuProvider");
195
- return i;
196
192
  };
197
193
  export {
198
- D as Button,
199
- Q as Card,
200
- H as Dialog,
201
- X as DialogPosition,
202
- Z as DialogQueueItemStatus,
203
- O as Flex,
204
- q as Row,
205
- ss as Theme,
206
- J as useEscape,
207
- U as usePaciu,
208
- M as useScroll,
209
- K as useSkipEffect
194
+ S as Button,
195
+ O as Card,
196
+ G as Dialog,
197
+ V as DialogPosition,
198
+ W as DialogQueueItemStatus,
199
+ T as Flex,
200
+ D as Row,
201
+ X as Theme,
202
+ H as useEscape,
203
+ K as useScroll,
204
+ J as useSkipEffect
210
205
  };
@@ -1,7 +1,6 @@
1
- import { Context } from 'react';
2
1
  import { JSX } from 'react/jsx-runtime';
3
2
 
4
- export declare interface CloseDialogOptions {
3
+ declare interface CloseDialogOptions {
5
4
  esc?: boolean;
6
5
  outside?: boolean;
7
6
  }
@@ -18,7 +17,7 @@ declare enum DialogPosition {
18
17
  RightBottom = "right-bottom"
19
18
  }
20
19
 
21
- export declare interface DialogQueueItem {
20
+ declare interface DialogQueueItem {
22
21
  id: number;
23
22
  status: DialogQueueItemStatus;
24
23
  node: () => React.ReactNode;
@@ -32,7 +31,7 @@ declare enum DialogQueueItemStatus {
32
31
  Closed = "closed"
33
32
  }
34
33
 
35
- export declare interface OpenDialogOptions {
34
+ declare interface OpenDialogOptions {
36
35
  position?: DialogPosition;
37
36
  unClosable?: boolean;
38
37
  fullHeight?: boolean;
@@ -43,9 +42,7 @@ export declare interface OpenDialogOptions {
43
42
  onOpened?: () => boolean | void;
44
43
  }
45
44
 
46
- export declare const PaciuContext: Context<PaciuContextType | undefined>;
47
-
48
- export declare interface PaciuContextType {
45
+ declare interface PaciuContextType {
49
46
  theme: Theme | null;
50
47
  nextTheme: Theme | null;
51
48
  systemTheme: Theme | null;
@@ -57,7 +54,7 @@ export declare interface PaciuContextType {
57
54
 
58
55
  export declare const PaciuProvider: ({ children, initialTheme, defaultDialogPosition }: PaciuProviderProps) => JSX.Element;
59
56
 
60
- export declare interface PaciuProviderProps extends React.PropsWithChildren {
57
+ declare interface PaciuProviderProps extends React.PropsWithChildren {
61
58
  initialTheme?: Theme;
62
59
  defaultDialogPosition?: DialogPosition;
63
60
  }
@@ -68,6 +65,6 @@ declare enum Theme {
68
65
  System = "system"
69
66
  }
70
67
 
71
- export declare const usePaciuContext: () => PaciuContextType | undefined;
68
+ export declare const usePaciu: () => PaciuContextType;
72
69
 
73
70
  export { }
@@ -1,10 +1,108 @@
1
1
  "use client";
2
- import "react/jsx-runtime";
3
- import "react";
4
- import "react-dom";
5
- import { P as a, b as u, u as s } from "./chunks/provider-core.es.js";
2
+ import { jsxs as S, jsx as x } from "react/jsx-runtime";
3
+ import { createContext as M, useState as m, useRef as j, useCallback as p, useMemo as v, useEffect as l, useContext as Q } from "react";
4
+ import { createPortal as $ } from "react-dom";
5
+ import { a as s, T as u, D as z, c as B, s as a } from "./chunks/index.es.js";
6
+ const w = M(void 0), H = () => Q(w), Y = ({ children: c, initialTheme: f, defaultDialogPosition: O }) => {
7
+ const [T, D] = m(!1), [r, L] = m(f || null), [d, k] = m(f || null), [o, g] = m([]), E = j(0), C = p((e) => {
8
+ document.documentElement.dataset.theme = e || void 0, L(e);
9
+ }, []), y = p((e, n) => {
10
+ g((t) => {
11
+ if (t.length > 0) {
12
+ const i = [...t], I = i.length - 1;
13
+ if (i[I].status === s.Opening)
14
+ return t;
15
+ }
16
+ return [...t, { id: ++E.current, status: s.Opening, node: e, options: n }];
17
+ });
18
+ }, []), h = p((e) => {
19
+ g((n) => {
20
+ if (n.length === 0)
21
+ return n;
22
+ const t = [...n], i = t.length - 1;
23
+ return t[i].status === s.Closing || (e?.esc || e?.outside) && t[i]?.options?.unClosable ? n : (t[i] = { ...t[i], status: s.Closing }, t);
24
+ });
25
+ }, []), P = v(() => {
26
+ const e = r || d;
27
+ return e ? e === u.Light ? u.Dark : u.Light : null;
28
+ }, [r, d]), b = v(
29
+ () => ({ theme: r, nextTheme: P, systemTheme: d, toggleTheme: C, openDialog: y, closeDialog: h, dialogsQueue: o }),
30
+ [r, P, d, C, y, h, o]
31
+ );
32
+ return l(() => {
33
+ if (o.length) {
34
+ const e = o[o.length - 1];
35
+ e.status === s.Opening && (e?.options?.onOpen && e.options.onOpen(), setTimeout(() => {
36
+ g((n) => {
37
+ const t = [...n];
38
+ return t[t.length - 1].status = s.Opened, t;
39
+ }), e?.options?.onOpened && e.options.onOpened();
40
+ }, 240)), e.status === s.Closing && (e?.options?.onClose && e.options.onClose(), setTimeout(() => {
41
+ g((n) => n.slice(0, -1)), e?.options?.onClosed && e.options.onClosed();
42
+ }, 240));
43
+ }
44
+ }, [o]), l(() => {
45
+ const e = window.matchMedia("(prefers-color-scheme: dark)"), n = (t) => {
46
+ k(t.matches ? u.Dark : u.Light);
47
+ };
48
+ return n(e), e.addEventListener("change", n), () => e.removeEventListener("change", n);
49
+ }, []), l(() => {
50
+ document.body.style.overflowY = o.length ? "hidden" : "";
51
+ }, [o]), l(() => {
52
+ const e = (i) => {
53
+ i.key === "Escape" && (i.stopPropagation(), h({ esc: !0 }));
54
+ }, n = () => {
55
+ document.addEventListener("keydown", e);
56
+ }, t = () => {
57
+ document.removeEventListener("keydown", e);
58
+ };
59
+ return n(), () => {
60
+ t();
61
+ };
62
+ }, []), l(() => {
63
+ D(!0);
64
+ }), /* @__PURE__ */ S(w.Provider, { value: b, children: [
65
+ c,
66
+ T && $(
67
+ /* @__PURE__ */ x("div", { id: "paciu-ui-dialogs", children: o.map((e, n) => {
68
+ const t = e?.options?.position || O || z.Center;
69
+ return /* @__PURE__ */ x(
70
+ "div",
71
+ {
72
+ className: B(a["dialog-overlay"], {
73
+ [a["animated-opening"]]: [
74
+ s.Opening,
75
+ s.Opened
76
+ ].includes(e.status),
77
+ [a["animated-closing"]]: [
78
+ s.Closing,
79
+ s.Closed
80
+ ].includes(e.status),
81
+ [a.active]: n === o.length - 1,
82
+ [a["full-height"]]: e?.options?.fullHeight,
83
+ [a["full-width"]]: e?.options?.fullWidth,
84
+ [a["un-closable"]]: e?.options?.unClosable,
85
+ [a[`position-${t}`]]: !!t
86
+ }),
87
+ onClick: () => h({ outside: !0 }),
88
+ style: {
89
+ zIndex: n + 1e3,
90
+ transform: `scale(calc(1 - ${(o.length - n - 1) * 0.02}))`
91
+ },
92
+ children: e.node()
93
+ },
94
+ e.id
95
+ );
96
+ }) }),
97
+ document.body
98
+ )
99
+ ] });
100
+ }, q = () => {
101
+ const c = H();
102
+ if (!c) throw new Error("usePaciu must be used within PaciuProvider");
103
+ return c;
104
+ };
6
105
  export {
7
- a as PaciuContext,
8
- u as PaciuProvider,
9
- s as usePaciuContext
106
+ Y as PaciuProvider,
107
+ q as usePaciu
10
108
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paciu/ui",
3
- "version": "0.0.54",
3
+ "version": "0.0.56",
4
4
  "type": "module",
5
5
  "main": "./dist/index.umd.js",
6
6
  "module": "./dist/index.es.js",
@@ -1,153 +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 k, useEffect as u, useContext as H } from "react";
4
- import { createPortal as I } from "react-dom";
5
- import '../provider-core.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
- };
File without changes