@paciu/ui 0.0.55 → 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.
- package/dist/chunks/index.es.js +51 -0
- package/dist/index.d.ts +0 -35
- package/dist/index.es.js +44 -49
- package/dist/provider.d.ts +6 -9
- package/dist/provider.es.js +105 -7
- package/package.json +1 -1
- package/dist/chunks/provider-core.es.js +0 -152
- /package/dist/{provider-core.css → index2.css} +0 -0
|
@@ -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
|
|
2
|
-
import m, { useState as
|
|
3
|
-
import { c as f, s as d
|
|
4
|
-
import { D as
|
|
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
|
-
},
|
|
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:
|
|
38
|
-
onClick:
|
|
39
|
-
stopPropagation:
|
|
37
|
+
size: k,
|
|
38
|
+
onClick: h,
|
|
39
|
+
stopPropagation: x,
|
|
40
40
|
stopImmediatePropagation: E,
|
|
41
41
|
...R
|
|
42
|
-
} = i, [C, v] =
|
|
43
|
-
if (
|
|
44
|
-
const N =
|
|
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
|
-
|
|
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
|
-
|
|
82
|
-
const
|
|
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
|
-
},
|
|
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(
|
|
93
|
+
return /* @__PURE__ */ a("div", { ref: e, className: f(j["paciu-ui-row"], o && j[`size-${o}`], s), ..._, children: r });
|
|
94
94
|
});
|
|
95
|
-
|
|
96
|
-
const
|
|
97
|
-
flex:
|
|
98
|
-
inline:
|
|
99
|
-
grow:
|
|
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
|
-
},
|
|
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
|
-
|
|
147
|
-
const
|
|
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
|
-
},
|
|
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(
|
|
158
|
+
return /* @__PURE__ */ a("div", { ref: e, className: f(P["paciu-ui-card"], r && P[`size-${r}`], o), ..._, children: s });
|
|
159
159
|
});
|
|
160
|
-
|
|
161
|
-
const
|
|
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__ */
|
|
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
|
-
] }),
|
|
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
|
-
},
|
|
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
|
-
},
|
|
185
|
-
const [i, e] =
|
|
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
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
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
|
};
|
package/dist/provider.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { Context } from 'react';
|
|
2
1
|
import { JSX } from 'react/jsx-runtime';
|
|
3
2
|
|
|
4
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
68
|
+
export declare const usePaciu: () => PaciuContextType;
|
|
72
69
|
|
|
73
70
|
export { }
|
package/dist/provider.es.js
CHANGED
|
@@ -1,10 +1,108 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import "react/jsx-runtime";
|
|
3
|
-
import "react";
|
|
4
|
-
import "react-dom";
|
|
5
|
-
import {
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
s as usePaciuContext
|
|
106
|
+
Y as PaciuProvider,
|
|
107
|
+
q as usePaciu
|
|
10
108
|
};
|
package/package.json
CHANGED
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import { jsxs as A, jsx as L } from "react/jsx-runtime";
|
|
2
|
-
import { createContext as $, useState as y, useRef as z, useCallback as w, useMemo as k, useEffect as u, useContext as H } from "react";
|
|
3
|
-
import { createPortal as I } from "react-dom";
|
|
4
|
-
import '../provider-core.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 _ = t.length;
|
|
9
|
-
for (r = 0; r < _; 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 K() {
|
|
14
|
-
for (var t, r, a = 0, s = "", _ = arguments.length; a < _; a++) (t = arguments[a]) && (r = O(t)) && (s && (s += " "), s += r);
|
|
15
|
-
return s;
|
|
16
|
-
}
|
|
17
|
-
const N = "_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: N,
|
|
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 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 || {});
|
|
48
|
-
const T = $(void 0), q = () => H(T), F = ({ children: t, initialTheme: r, defaultDialogPosition: a }) => {
|
|
49
|
-
const [s, _] = y(!1), [g, E] = y(r || null), [m, B] = y(r || null), [d, h] = y([]), R = z(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], M = l.length - 1;
|
|
55
|
-
if (l[M].status === i.Opening)
|
|
56
|
-
return o;
|
|
57
|
-
}
|
|
58
|
-
return [...o, { id: ++R.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 === p.Light ? p.Dark : p.Light : null;
|
|
70
|
-
}, [g, m]), j = 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 u(() => {
|
|
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]), u(() => {
|
|
87
|
-
const e = window.matchMedia("(prefers-color-scheme: dark)"), n = (o) => {
|
|
88
|
-
B(o.matches ? p.Dark : p.Light);
|
|
89
|
-
};
|
|
90
|
-
return n(e), e.addEventListener("change", n), () => e.removeEventListener("change", n);
|
|
91
|
-
}, []), u(() => {
|
|
92
|
-
document.body.style.overflowY = d.length ? "hidden" : "";
|
|
93
|
-
}, [d]), u(() => {
|
|
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
|
-
}, []), u(() => {
|
|
105
|
-
_(!0);
|
|
106
|
-
}), /* @__PURE__ */ A(T.Provider, { value: j, children: [
|
|
107
|
-
t,
|
|
108
|
-
s && I(
|
|
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: K(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
|
-
};
|
|
143
|
-
export {
|
|
144
|
-
x as D,
|
|
145
|
-
T as P,
|
|
146
|
-
p as T,
|
|
147
|
-
i as a,
|
|
148
|
-
F as b,
|
|
149
|
-
K as c,
|
|
150
|
-
c as s,
|
|
151
|
-
q as u
|
|
152
|
-
};
|
|
File without changes
|