@paciu/ui 0.0.57 → 0.0.59

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.es.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { jsx as a, jsxs as b } from "react/jsx-runtime";
2
2
  import m, { useState as $, useEffect as w, useRef as L } from "react";
3
- import { c as f, s as d } from "./chunks/provider.es.js";
4
- import { D as V, a as W, T as X } from "./chunks/provider.es.js";
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",
@@ -1,9 +1,108 @@
1
1
  "use client";
2
- import "react/jsx-runtime";
3
- import "react";
4
- import "react-dom";
5
- import { P as u, u as a } from "./chunks/provider.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
- u as PaciuProvider,
8
- a as usePaciu
106
+ Y as PaciuProvider,
107
+ q as usePaciu
9
108
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paciu/ui",
3
- "version": "0.0.57",
3
+ "version": "0.0.59",
4
4
  "type": "module",
5
5
  "main": "./dist/index.umd.js",
6
6
  "module": "./dist/index.es.js",
@@ -1,156 +0,0 @@
1
- "use client";
2
- import { jsxs as M, jsx as L } from "react/jsx-runtime";
3
- import { createContext as A, useState as y, useRef as $, useCallback as w, useMemo as k, useEffect as _, useContext as z } from "react";
4
- import { createPortal as H } 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 p = t.length;
10
- for (r = 0; r < p; 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 I() {
15
- for (var t, r, a = 0, s = "", p = arguments.length; a < p; a++) (t = arguments[a]) && (r = O(t)) && (s && (s += " "), s += r);
16
- return s;
17
- }
18
- const K = "_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: K,
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 u = /* @__PURE__ */ ((t) => (t.Light = "light", t.Dark = "dark", t.System = "system", t))(u || {}), 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 = A(void 0), N = () => z(T), q = ({ children: t, initialTheme: r, defaultDialogPosition: a }) => {
50
- const [s, p] = y(!1), [g, E] = y(r || null), [m, B] = y(r || null), [d, h] = y([]), P = $(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], j = l.length - 1;
56
- if (l[j].status === i.Opening)
57
- return o;
58
- }
59
- return [...o, { id: ++P.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 === u.Light ? u.Dark : u.Light : null;
71
- }, [g, m]), R = 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 _(() => {
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]), _(() => {
88
- const e = window.matchMedia("(prefers-color-scheme: dark)"), n = (o) => {
89
- B(o.matches ? u.Dark : u.Light);
90
- };
91
- return n(e), e.addEventListener("change", n), () => e.removeEventListener("change", n);
92
- }, []), _(() => {
93
- document.body.style.overflowY = d.length ? "hidden" : "";
94
- }, [d]), _(() => {
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
- }, []), _(() => {
106
- p(!0);
107
- }), /* @__PURE__ */ M(T.Provider, { value: R, children: [
108
- t,
109
- s && H(
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: I(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
- }, F = () => {
144
- const t = N();
145
- if (!t) throw new Error("usePaciu must be used within PaciuProvider");
146
- return t;
147
- };
148
- export {
149
- x as D,
150
- q as P,
151
- u as T,
152
- i as a,
153
- I as c,
154
- c as s,
155
- F as u
156
- };
File without changes