@paciu/ui 0.0.56 → 0.0.58
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/chunks/provider-chunk.es.js +155 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.es.js +2 -2
- package/dist/provider.es.js +6 -105
- package/package.json +1 -1
- package/dist/chunks/index.es.js +0 -51
- /package/dist/{index2.css → provider-chunk.css} +0 -0
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { jsxs as M, jsx as L } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as A, useState as y, useRef as $, useCallback as w, useMemo as k, useEffect as _, useContext as z } from "react";
|
|
3
|
+
import { createPortal as H } from "react-dom";
|
|
4
|
+
import '../provider-chunk.css';function O(t) {
|
|
5
|
+
var r, a, s = "";
|
|
6
|
+
if (typeof t == "string" || typeof t == "number") s += t;
|
|
7
|
+
else if (typeof t == "object") if (Array.isArray(t)) {
|
|
8
|
+
var p = t.length;
|
|
9
|
+
for (r = 0; r < p; r++) t[r] && (a = O(t[r])) && (s && (s += " "), s += a);
|
|
10
|
+
} else for (a in t) t[a] && (s && (s += " "), s += a);
|
|
11
|
+
return s;
|
|
12
|
+
}
|
|
13
|
+
function I() {
|
|
14
|
+
for (var t, r, a = 0, s = "", p = arguments.length; a < p; a++) (t = arguments[a]) && (r = O(t)) && (s && (s += " "), s += r);
|
|
15
|
+
return s;
|
|
16
|
+
}
|
|
17
|
+
const K = "_active_1rsd6_164", c = {
|
|
18
|
+
"dialog-overlay": "_dialog-overlay_1rsd6_45",
|
|
19
|
+
"dialog-compose": "_dialog-compose_1rsd6_62",
|
|
20
|
+
"dialog-close": "_dialog-close_1rsd6_68",
|
|
21
|
+
"dialog-close-cross": "_dialog-close-cross_1rsd6_85",
|
|
22
|
+
"dialog-window": "_dialog-window_1rsd6_109",
|
|
23
|
+
"dialog-window-header": "_dialog-window-header_1rsd6_123",
|
|
24
|
+
"dialog-window-body": "_dialog-window-body_1rsd6_136",
|
|
25
|
+
"dialog-window-footer": "_dialog-window-footer_1rsd6_142",
|
|
26
|
+
"full-height": "_full-height_1rsd6_155",
|
|
27
|
+
"full-width": "_full-width_1rsd6_158",
|
|
28
|
+
"un-closable": "_un-closable_1rsd6_161",
|
|
29
|
+
active: K,
|
|
30
|
+
"position-top-center": "_position-top-center_1rsd6_170",
|
|
31
|
+
"position-center": "_position-center_1rsd6_176",
|
|
32
|
+
"position-bottom-center": "_position-bottom-center_1rsd6_180",
|
|
33
|
+
"position-left-top": "_position-left-top_1rsd6_186",
|
|
34
|
+
"position-left-center": "_position-left-center_1rsd6_192",
|
|
35
|
+
"position-left-bottom": "_position-left-bottom_1rsd6_198",
|
|
36
|
+
"position-right-top": "_position-right-top_1rsd6_204",
|
|
37
|
+
"position-right-center": "_position-right-center_1rsd6_210",
|
|
38
|
+
"position-right-bottom": "_position-right-bottom_1rsd6_216",
|
|
39
|
+
"animated-opening": "_animated-opening_1rsd6_222",
|
|
40
|
+
"animated-opening-opacity": "_animated-opening-opacity_1rsd6_1",
|
|
41
|
+
"animated-opening-translate": "_animated-opening-translate_1rsd6_1",
|
|
42
|
+
"animated-closing": "_animated-closing_1rsd6_228",
|
|
43
|
+
"animated-closing-opacity": "_animated-closing-opacity_1rsd6_1",
|
|
44
|
+
"animated-closing-translate": "_animated-closing-translate_1rsd6_1",
|
|
45
|
+
"paciu-ui-blink-animation": "_paciu-ui-blink-animation_1rsd6_1"
|
|
46
|
+
};
|
|
47
|
+
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 || {});
|
|
48
|
+
const T = A(void 0), N = () => z(T), q = ({ children: t, initialTheme: r, defaultDialogPosition: a }) => {
|
|
49
|
+
const [s, p] = y(!1), [g, E] = y(r || null), [m, B] = y(r || null), [d, h] = y([]), P = $(0), C = w((e) => {
|
|
50
|
+
document.documentElement.dataset.theme = e || void 0, E(e);
|
|
51
|
+
}, []), b = w((e, n) => {
|
|
52
|
+
h((o) => {
|
|
53
|
+
if (o.length > 0) {
|
|
54
|
+
const l = [...o], j = l.length - 1;
|
|
55
|
+
if (l[j].status === i.Opening)
|
|
56
|
+
return o;
|
|
57
|
+
}
|
|
58
|
+
return [...o, { id: ++P.current, status: i.Opening, node: e, options: n }];
|
|
59
|
+
});
|
|
60
|
+
}, []), f = w((e) => {
|
|
61
|
+
h((n) => {
|
|
62
|
+
if (n.length === 0)
|
|
63
|
+
return n;
|
|
64
|
+
const o = [...n], l = o.length - 1;
|
|
65
|
+
return o[l].status === i.Closing || (e?.esc || e?.outside) && o[l]?.options?.unClosable ? n : (o[l] = { ...o[l], status: i.Closing }, o);
|
|
66
|
+
});
|
|
67
|
+
}, []), v = k(() => {
|
|
68
|
+
const e = g || m;
|
|
69
|
+
return e ? e === u.Light ? u.Dark : u.Light : null;
|
|
70
|
+
}, [g, m]), R = k(
|
|
71
|
+
() => ({ theme: g, nextTheme: v, systemTheme: m, toggleTheme: C, openDialog: b, closeDialog: f, dialogsQueue: d }),
|
|
72
|
+
[g, v, m, C, b, f, d]
|
|
73
|
+
);
|
|
74
|
+
return _(() => {
|
|
75
|
+
if (d.length) {
|
|
76
|
+
const e = d[d.length - 1];
|
|
77
|
+
e.status === i.Opening && (e?.options?.onOpen && e.options.onOpen(), setTimeout(() => {
|
|
78
|
+
h((n) => {
|
|
79
|
+
const o = [...n];
|
|
80
|
+
return o[o.length - 1].status = i.Opened, o;
|
|
81
|
+
}), e?.options?.onOpened && e.options.onOpened();
|
|
82
|
+
}, 240)), e.status === i.Closing && (e?.options?.onClose && e.options.onClose(), setTimeout(() => {
|
|
83
|
+
h((n) => n.slice(0, -1)), e?.options?.onClosed && e.options.onClosed();
|
|
84
|
+
}, 240));
|
|
85
|
+
}
|
|
86
|
+
}, [d]), _(() => {
|
|
87
|
+
const e = window.matchMedia("(prefers-color-scheme: dark)"), n = (o) => {
|
|
88
|
+
B(o.matches ? u.Dark : u.Light);
|
|
89
|
+
};
|
|
90
|
+
return n(e), e.addEventListener("change", n), () => e.removeEventListener("change", n);
|
|
91
|
+
}, []), _(() => {
|
|
92
|
+
document.body.style.overflowY = d.length ? "hidden" : "";
|
|
93
|
+
}, [d]), _(() => {
|
|
94
|
+
const e = (l) => {
|
|
95
|
+
l.key === "Escape" && (l.stopPropagation(), f({ esc: !0 }));
|
|
96
|
+
}, n = () => {
|
|
97
|
+
document.addEventListener("keydown", e);
|
|
98
|
+
}, o = () => {
|
|
99
|
+
document.removeEventListener("keydown", e);
|
|
100
|
+
};
|
|
101
|
+
return n(), () => {
|
|
102
|
+
o();
|
|
103
|
+
};
|
|
104
|
+
}, []), _(() => {
|
|
105
|
+
p(!0);
|
|
106
|
+
}), /* @__PURE__ */ M(T.Provider, { value: R, children: [
|
|
107
|
+
t,
|
|
108
|
+
s && H(
|
|
109
|
+
/* @__PURE__ */ L("div", { id: "paciu-ui-dialogs", children: d.map((e, n) => {
|
|
110
|
+
const o = e?.options?.position || a || x.Center;
|
|
111
|
+
return /* @__PURE__ */ L(
|
|
112
|
+
"div",
|
|
113
|
+
{
|
|
114
|
+
className: I(c["dialog-overlay"], {
|
|
115
|
+
[c["animated-opening"]]: [
|
|
116
|
+
i.Opening,
|
|
117
|
+
i.Opened
|
|
118
|
+
].includes(e.status),
|
|
119
|
+
[c["animated-closing"]]: [
|
|
120
|
+
i.Closing,
|
|
121
|
+
i.Closed
|
|
122
|
+
].includes(e.status),
|
|
123
|
+
[c.active]: n === d.length - 1,
|
|
124
|
+
[c["full-height"]]: e?.options?.fullHeight,
|
|
125
|
+
[c["full-width"]]: e?.options?.fullWidth,
|
|
126
|
+
[c["un-closable"]]: e?.options?.unClosable,
|
|
127
|
+
[c[`position-${o}`]]: !!o
|
|
128
|
+
}),
|
|
129
|
+
onClick: () => f({ outside: !0 }),
|
|
130
|
+
style: {
|
|
131
|
+
zIndex: n + 1e3,
|
|
132
|
+
transform: `scale(calc(1 - ${(d.length - n - 1) * 0.02}))`
|
|
133
|
+
},
|
|
134
|
+
children: e.node()
|
|
135
|
+
},
|
|
136
|
+
e.id
|
|
137
|
+
);
|
|
138
|
+
}) }),
|
|
139
|
+
document.body
|
|
140
|
+
)
|
|
141
|
+
] });
|
|
142
|
+
}, F = () => {
|
|
143
|
+
const t = N();
|
|
144
|
+
if (!t) throw new Error("usePaciu must be used within PaciuProvider");
|
|
145
|
+
return t;
|
|
146
|
+
};
|
|
147
|
+
export {
|
|
148
|
+
x as D,
|
|
149
|
+
q as P,
|
|
150
|
+
u as T,
|
|
151
|
+
i as a,
|
|
152
|
+
I as c,
|
|
153
|
+
c as s,
|
|
154
|
+
F as u
|
|
155
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -87,9 +87,9 @@ export declare const useScroll: () => {
|
|
|
87
87
|
isScrolled: boolean;
|
|
88
88
|
};
|
|
89
89
|
|
|
90
|
-
export declare const useSkipEffect: (cb:
|
|
90
|
+
export declare const useSkipEffect: (cb: React.EffectCallback, deps?: React.DependencyList, options?: UseSkipEffectOptions) => void;
|
|
91
91
|
|
|
92
|
-
declare interface UseSkipEffectOptions {
|
|
92
|
+
export declare interface UseSkipEffectOptions {
|
|
93
93
|
count?: number;
|
|
94
94
|
}
|
|
95
95
|
|
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/
|
|
4
|
-
import { D as V, a as W, T as X } from "./chunks/
|
|
3
|
+
import { c as f, s as d } from "./chunks/provider-chunk.es.js";
|
|
4
|
+
import { D as V, a as W, T as X } from "./chunks/provider-chunk.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",
|
package/dist/provider.es.js
CHANGED
|
@@ -1,108 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
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
|
-
};
|
|
2
|
+
import "react/jsx-runtime";
|
|
3
|
+
import "react";
|
|
4
|
+
import "react-dom";
|
|
5
|
+
import { P as u, u as a } from "./chunks/provider-chunk.es.js";
|
|
105
6
|
export {
|
|
106
|
-
|
|
107
|
-
|
|
7
|
+
u as PaciuProvider,
|
|
8
|
+
a as usePaciu
|
|
108
9
|
};
|
package/package.json
CHANGED
package/dist/chunks/index.es.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
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
|
-
};
|
|
File without changes
|