react-modal-navigation 1.1.10 → 1.2.0
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/CHANGELOG.md +10 -0
- package/README.md +56 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +170 -15
- package/dist/index.js +1589 -840
- package/dist/style.css +11 -0
- package/docs/ARCHITECTURE-1.1.11.md +5 -0
- package/docs/ASYNC-1.2.0.md +8 -0
- package/docs/CACHE-1.2.0.md +9 -0
- package/docs/DECLARATIVE-1.2.0.md +11 -0
- package/docs/DECLARATIVE-HARDENING-1.2.0.md +7 -0
- package/docs/DEVELOPMENT-1.2.0.md +7 -0
- package/docs/DEVTOOLS-1.2.0.md +5 -0
- package/docs/EVENTS-1.2.0.md +7 -0
- package/docs/FINAL-OPTIMIZATION-1.1.11.md +10 -0
- package/docs/MANAGER-EVENTS-1.2.0.md +7 -0
- package/docs/RC1-1.2.0.md +2 -0
- package/docs/RC2-1.2.0.md +3 -0
- package/docs/RC3-1.2.0.md +9 -0
- package/docs/RC3B-1.2.0.md +7 -0
- package/docs/RC3C-1.2.0.md +2 -0
- package/docs/RESOURCE-1.2.0.md +7 -0
- package/docs/ROUTE-EVENTS-1.2.0.md +3 -0
- package/docs/RUNTIME-1.1.11.md +5 -0
- package/docs/RUNTIME-1.2.0.md +9 -0
- package/docs/STABILITY-1.1.11.md +9 -0
- package/docs/STAGE3-1.2.0.md +7 -0
- package/docs/SUBSCRIPTIONS-1.1.11.md +7 -0
- package/docs/UPGRADE-1.1.11.md +18 -0
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -1,1040 +1,1789 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import { createPortal as
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { jsx as p, jsxs as be } from "react/jsx-runtime";
|
|
2
|
+
import Se, { createContext as we, useState as xe, useEffect as U, useRef as P, useMemo as Q, useSyncExternalStore as Oe, useContext as ee, memo as rt, useCallback as _, useReducer as dn, useLayoutEffect as Ae, Suspense as Wt, useInsertionEffect as mn } from "react";
|
|
3
|
+
import { createPortal as pn } from "react-dom";
|
|
4
|
+
function je(e) {
|
|
5
|
+
let t = e;
|
|
6
|
+
const n = /* @__PURE__ */ new Set();
|
|
7
|
+
let r = !1;
|
|
8
8
|
return {
|
|
9
|
-
getSnapshot: () =>
|
|
10
|
-
subscribe: (
|
|
11
|
-
publish(
|
|
12
|
-
if (
|
|
13
|
-
|
|
14
|
-
for (const
|
|
9
|
+
getSnapshot: () => t,
|
|
10
|
+
subscribe: (o) => (r || n.add(o), () => n.delete(o)),
|
|
11
|
+
publish(o) {
|
|
12
|
+
if (!(r || Object.is(t, o))) {
|
|
13
|
+
t = o;
|
|
14
|
+
for (const a of [...n])
|
|
15
|
+
if (!(r || !n.has(a)))
|
|
16
|
+
try {
|
|
17
|
+
const l = a();
|
|
18
|
+
l && typeof l.then == "function" && Promise.resolve(l).catch((f) => console.error(f));
|
|
19
|
+
} catch (l) {
|
|
20
|
+
console.error(l);
|
|
21
|
+
}
|
|
15
22
|
}
|
|
16
23
|
},
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
function Te(e) {
|
|
21
|
-
let n = e;
|
|
22
|
-
const r = /* @__PURE__ */ new Set();
|
|
23
|
-
return {
|
|
24
|
-
getSnapshot: () => n,
|
|
25
|
-
subscribe: (t) => (r.add(t), () => r.delete(t)),
|
|
26
|
-
publish(t) {
|
|
27
|
-
if (!Object.is(n, t)) {
|
|
28
|
-
n = t;
|
|
29
|
-
for (const i of [...r]) i();
|
|
30
|
-
}
|
|
24
|
+
destroy(...o) {
|
|
25
|
+
r = !0, n.clear(), o.length && (t = o[0]);
|
|
31
26
|
},
|
|
32
|
-
listenerCount: () =>
|
|
27
|
+
listenerCount: () => n.size
|
|
33
28
|
};
|
|
34
29
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
30
|
+
const yt = we(null), Gt = we(null), _t = we(null), ot = we(null), Ue = we(null), Pt = we(null), Tt = we(null), vt = we(null), bt = we(null), wt = we(null), Ut = we(null), Vt = we(null), Ve = we(null), Lt = we(null), zt = we(null), at = we(null);
|
|
31
|
+
let fn = 0;
|
|
32
|
+
const ht = (e, t) => ({ key: `modal-route-${++fn}`, name: e, params: t ?? {} }), Yt = (e, t) => [ht(e, t)];
|
|
33
|
+
function mt(e, t) {
|
|
34
|
+
switch (t.type) {
|
|
35
|
+
case "COMMIT":
|
|
36
|
+
return t.stack;
|
|
37
|
+
case "PUSH":
|
|
38
|
+
return [...e, ht(t.name, t.params)];
|
|
39
|
+
case "POP":
|
|
40
|
+
return e.slice(0, Math.max(1, e.length - t.count));
|
|
39
41
|
case "RESET":
|
|
40
|
-
return
|
|
42
|
+
return Yt(t.name, t.params);
|
|
41
43
|
case "NAVIGATE": {
|
|
42
|
-
const
|
|
43
|
-
return
|
|
44
|
+
const n = e.findIndex((r) => r.name === t.name);
|
|
45
|
+
return n < 0 ? [...e, ht(t.name, t.params)] : e.slice(0, n + 1).map((r, o) => o === n ? { ...r, params: t.params ?? {} } : r);
|
|
44
46
|
}
|
|
45
47
|
case "SET_OPTIONS":
|
|
46
|
-
return e.map((
|
|
48
|
+
return e.map((n, r) => r === e.length - 1 ? { ...n, options: { ...n.options ?? {}, ...t.options ?? {} } } : n);
|
|
47
49
|
case "SET_PARAMS":
|
|
48
|
-
return e.map((
|
|
50
|
+
return e.map((n, r) => r === e.length - 1 ? { ...n, params: { ...n.params ?? {}, ...t.params ?? {} } } : n);
|
|
49
51
|
case "BACK":
|
|
50
52
|
return e.length > 1 ? e.slice(0, -1) : e;
|
|
51
53
|
case "REPLACE":
|
|
52
|
-
return e.length ? [...e.slice(0, -1),
|
|
54
|
+
return e.length ? [...e.slice(0, -1), ht(t.name, t.params)] : e;
|
|
53
55
|
default:
|
|
54
56
|
return e;
|
|
55
57
|
}
|
|
56
58
|
}
|
|
57
|
-
function $
|
|
58
|
-
const
|
|
59
|
-
return e.filter((
|
|
59
|
+
function $t(e, t, n = 1 / 0, r = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set()) {
|
|
60
|
+
const a = n === 1 / 0 ? 1 / 0 : Math.max(0, Math.floor(Number(n) || 0)), l = e.slice(0, -1).filter((u) => t[u.name]?.keepAlive !== !1), f = new Set((a === 0 ? [] : l.slice(-a)).map((u) => u.key));
|
|
61
|
+
return e.filter((u, i) => i === e.length - 1 || (f.has(u.key) || o.has(u.key)) && !r.has(u.key));
|
|
62
|
+
}
|
|
63
|
+
function hn(e, t, n) {
|
|
64
|
+
const r = new Set(t.map((a) => a.key)), o = new Set(e.slice(0, -1).filter((a) => n.has(a.key) || !r.has(a.key)).map((a) => a.key));
|
|
65
|
+
return o.size === n.size && [...o].every((a) => n.has(a)) ? n : o;
|
|
60
66
|
}
|
|
61
|
-
|
|
67
|
+
function gn(e, t) {
|
|
68
|
+
const n = e.responsive;
|
|
69
|
+
if (!n) return e;
|
|
70
|
+
const { sm: r, md: o, lg: a, xl: l } = n;
|
|
71
|
+
return { ...e, ...t < 768 ? r : t < 1024 ? o : t < 1280 ? a : l, ...e.runtimeLayout };
|
|
72
|
+
}
|
|
73
|
+
function yn(e, t, n, r) {
|
|
74
|
+
const o = Math.max(0, Math.min(n ?? 1 / 0, r));
|
|
75
|
+
return Math.min(o, Math.max(Math.min(t ?? 240, o), e));
|
|
76
|
+
}
|
|
77
|
+
const vn = Object.freeze({ sm: 400, md: 560, lg: 720, xl: 960, full: "100%" }), Ie = (e) => typeof e == "number" ? `${e}px` : e, It = () => {
|
|
62
78
|
if (typeof document > "u") return "light";
|
|
63
|
-
const e = document.documentElement,
|
|
64
|
-
return e.classList.contains("dark") ||
|
|
79
|
+
const e = document.documentElement, t = document.body;
|
|
80
|
+
return e.classList.contains("dark") || t.classList.contains("dark") || e.dataset.theme === "dark" || t.dataset.theme === "dark" ? "dark" : e.classList.contains("light") || t.classList.contains("light") || e.dataset.theme === "light" || t.dataset.theme === "light" ? "light" : window.matchMedia?.("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
65
81
|
};
|
|
66
|
-
let
|
|
67
|
-
const
|
|
68
|
-
let
|
|
69
|
-
function
|
|
70
|
-
if (
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
82
|
+
let tt = 0;
|
|
83
|
+
const Ke = [];
|
|
84
|
+
let Mt = null;
|
|
85
|
+
function bn() {
|
|
86
|
+
if (tt++, tt === 1) {
|
|
87
|
+
const t = document.documentElement, n = document.body, r = { html: t.style.overflow, body: n.style.overflow, padding: n.style.paddingRight, width: n.style.getPropertyValue("--modal-scrollbar-width") }, o = Math.max(0, window.innerWidth - t.clientWidth), a = parseFloat(getComputedStyle(n).paddingRight) || 0;
|
|
88
|
+
o && (n.style.paddingRight = `${a + o}px`), n.style.setProperty("--modal-scrollbar-width", `${o}px`), t.style.overflow = "hidden", n.style.overflow = "hidden", Mt = () => {
|
|
89
|
+
t.style.overflow = r.html, n.style.overflow = r.body, n.style.paddingRight = r.padding, r.width ? n.style.setProperty("--modal-scrollbar-width", r.width) : n.style.removeProperty("--modal-scrollbar-width");
|
|
74
90
|
};
|
|
75
91
|
}
|
|
76
92
|
let e = !1;
|
|
77
93
|
return () => {
|
|
78
|
-
e || (e = !0,
|
|
94
|
+
e || (e = !0, tt = Math.max(0, tt - 1), tt || (Mt?.(), Mt = null));
|
|
79
95
|
};
|
|
80
96
|
}
|
|
81
|
-
const
|
|
82
|
-
function
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
97
|
+
const wn = 'a[href],button:not([disabled]),input:not([disabled]),textarea:not([disabled]),select:not([disabled]),[tabindex]:not([tabindex="-1"])', kn = (e) => !e.closest('[inert], [hidden], [aria-hidden="true"]') && e.getClientRects().length > 0 && getComputedStyle(e).visibility !== "hidden" && getComputedStyle(e).display !== "none";
|
|
98
|
+
function xn({ dialogRef: e, options: t, requestClose: n, children: r, exiting: o = !1 }) {
|
|
99
|
+
const [a, l] = xe(() => typeof window > "u" ? 1024 : window.innerWidth), f = !!t.responsive;
|
|
100
|
+
U(() => {
|
|
101
|
+
if (!f) return;
|
|
102
|
+
const O = () => l(window.innerWidth < 768 ? 0 : window.innerWidth < 1024 ? 768 : window.innerWidth < 1280 ? 1024 : 1280);
|
|
103
|
+
return window.addEventListener("resize", O), O(), () => window.removeEventListener("resize", O);
|
|
104
|
+
}, [f]), t = gn(t, a);
|
|
105
|
+
const [u, i] = xe(null);
|
|
106
|
+
U(() => i(null), [t.width, t.placement]);
|
|
107
|
+
const d = P(null), g = P(0);
|
|
108
|
+
U(() => () => {
|
|
109
|
+
g.current && cancelAnimationFrame(g.current);
|
|
110
|
+
}, []);
|
|
111
|
+
const b = P(null), x = P(null), h = P(n);
|
|
112
|
+
h.current = n;
|
|
113
|
+
const s = P(t.closeOnEsc);
|
|
114
|
+
s.current = t.closeOnEsc;
|
|
115
|
+
const [v, I] = xe(It), z = t.theme === "light" || t.theme === "dark" ? t.theme : v;
|
|
116
|
+
U(() => {
|
|
117
|
+
if (t.theme === "light" || t.theme === "dark") return;
|
|
118
|
+
const O = () => I(It()), G = new MutationObserver(O);
|
|
119
|
+
for (const Ce of [document.documentElement, document.body]) G.observe(Ce, { attributes: !0, attributeFilter: ["class", "data-theme"] });
|
|
120
|
+
const ke = window.matchMedia?.("(prefers-color-scheme: dark)");
|
|
121
|
+
return ke?.addEventListener?.("change", O), O(), () => {
|
|
122
|
+
G.disconnect(), ke?.removeEventListener?.("change", O);
|
|
95
123
|
};
|
|
96
|
-
}, [
|
|
97
|
-
|
|
98
|
-
const O =
|
|
99
|
-
|
|
100
|
-
const
|
|
101
|
-
const
|
|
102
|
-
if (!
|
|
103
|
-
if (
|
|
104
|
-
|
|
124
|
+
}, [t.theme]), U(() => {
|
|
125
|
+
x.current = document.activeElement;
|
|
126
|
+
const O = bn(), G = b.current;
|
|
127
|
+
Ke.push(G), e.current?.focus({ preventScroll: !0 });
|
|
128
|
+
const ke = (K) => {
|
|
129
|
+
const de = e.current;
|
|
130
|
+
if (!de || Ke.at(-1) !== G) return;
|
|
131
|
+
if (K.key === "Escape" && s.current !== !1) {
|
|
132
|
+
K.preventDefault(), h.current("escape");
|
|
105
133
|
return;
|
|
106
134
|
}
|
|
107
|
-
if (
|
|
108
|
-
const
|
|
109
|
-
if (!
|
|
110
|
-
|
|
135
|
+
if (K.key !== "Tab") return;
|
|
136
|
+
const k = [...de.querySelectorAll(wn)].filter(kn);
|
|
137
|
+
if (!k.length) {
|
|
138
|
+
K.preventDefault(), de.focus();
|
|
111
139
|
return;
|
|
112
140
|
}
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
},
|
|
116
|
-
|
|
141
|
+
const ce = k[0], ne = k.at(-1);
|
|
142
|
+
de.contains(document.activeElement) ? K.shiftKey && (document.activeElement === ce || document.activeElement === de) ? (K.preventDefault(), ne.focus()) : !K.shiftKey && (document.activeElement === ne || document.activeElement === de) && (K.preventDefault(), ce.focus()) : (K.preventDefault(), (K.shiftKey ? ne : ce).focus());
|
|
143
|
+
}, Ce = (K) => {
|
|
144
|
+
Ke.at(-1) === G && e.current && !e.current.contains(K.target) && e.current.focus({ preventScroll: !0 });
|
|
117
145
|
};
|
|
118
|
-
return document.addEventListener("keydown",
|
|
119
|
-
document.removeEventListener("keydown",
|
|
120
|
-
const
|
|
121
|
-
if (
|
|
122
|
-
const
|
|
123
|
-
|
|
146
|
+
return document.addEventListener("keydown", ke), document.addEventListener("focusin", Ce), () => {
|
|
147
|
+
document.removeEventListener("keydown", ke), document.removeEventListener("focusin", Ce);
|
|
148
|
+
const K = Ke.at(-1) === G, de = Ke.indexOf(G);
|
|
149
|
+
if (de !== -1 && Ke.splice(de, 1), O(), K) {
|
|
150
|
+
const k = x.current;
|
|
151
|
+
k?.isConnected && !k.closest("[inert], [hidden]") ? k.focus?.({ preventScroll: !0 }) : Ke.at(-1)?.querySelector("[role=dialog]")?.focus?.({ preventScroll: !0 });
|
|
124
152
|
}
|
|
125
153
|
};
|
|
126
154
|
}, [e]);
|
|
127
|
-
const
|
|
128
|
-
|
|
155
|
+
const T = t.backgroundColor ?? t.backgroudColor, E = typeof T == "string" ? T : T?.[z], D = typeof E == "string" && /^(#|(?:rgb|rgba|hsl|hsla|hwb|oklch|oklab|lab|lch|color|color-mix|light-dark|var)\(|transparent$|currentColor$|[a-z]+$)/i.test(E.trim()) ? E.trim() : null, L = typeof E == "string" && !D ? E.trim() : "", A = !!(D || L), q = ["center", "left", "right", "top", "bottom"].includes(t.placement) ? t.placement : "right", N = Ie(u ?? t.width ?? vn[t.size] ?? 460), Z = Ie(t.height), ue = Ie(t.maxHeight), C = Ie(t.maxWidth), F = Number(t.viewportGap ?? 5), $ = Number.isFinite(F) ? Math.max(0, F) : 5, X = t.top == null ? null : Ie(t.top), B = q !== "bottom" && X !== null ? X : null, te = typeof t.borderRadius == "number" ? `${t.borderRadius}px` : t.borderRadius ?? "12px", V = t.resizable && !t.fullscreen && ["left", "right"].includes(q), oe = (O) => yn(O, t.minWidth, typeof t.maxWidth == "number" ? t.maxWidth : void 0, b.current?.clientWidth - $ * 2 || window.innerWidth), J = (O) => {
|
|
156
|
+
!d.current || d.current.id !== O.pointerId || (cancelAnimationFrame(g.current), i(d.current.width), e.current?.style.removeProperty("--pmn-drag-width"), d.current = null);
|
|
157
|
+
};
|
|
158
|
+
return pn(/* @__PURE__ */ p(
|
|
129
159
|
"div",
|
|
130
160
|
{
|
|
131
|
-
ref:
|
|
132
|
-
className: `pmn-overlay ${
|
|
133
|
-
style: { padding:
|
|
161
|
+
ref: b,
|
|
162
|
+
className: `pmn-overlay ${o ? "pmn-exiting" : "pmn-entering"} ${t.animation === !1 ? "pmn-no-animation" : ""} pmn-place-${q} ${t.fullscreen ? "pmn-fullscreen" : ""} ${t.mobileFullscreen ? "pmn-mobile-fullscreen" : ""}`,
|
|
163
|
+
style: { padding: $, ...t.bottom != null ? { paddingBottom: Ie(t.bottom) } : {}, ...t.left != null ? { paddingLeft: Ie(t.left) } : {}, ...t.right != null ? { paddingRight: Ie(t.right) } : {}, ...B !== null ? { paddingTop: B, "--pmn-top-offset": B } : {}, "--pmn-animation-duration": `${Math.min(1e3, Math.max(0, Number(t.animationDuration ?? 220) || 0))}ms` },
|
|
134
164
|
onMouseDown: (O) => {
|
|
135
|
-
O.target === O.currentTarget &&
|
|
165
|
+
O.target === O.currentTarget && t.closeOnOverlay === !0 && h.current("overlay");
|
|
136
166
|
},
|
|
137
|
-
children: /* @__PURE__ */
|
|
167
|
+
children: /* @__PURE__ */ be(
|
|
138
168
|
"section",
|
|
139
169
|
{
|
|
140
170
|
ref: e,
|
|
141
171
|
tabIndex: -1,
|
|
142
172
|
role: "dialog",
|
|
143
173
|
"aria-modal": "true",
|
|
144
|
-
"aria-label":
|
|
145
|
-
"data-modal-theme":
|
|
146
|
-
className: `pmn-dialog ${
|
|
147
|
-
style: { "--pmn-width":
|
|
174
|
+
"aria-label": t.ariaLabel ?? "Dialog",
|
|
175
|
+
"data-modal-theme": z,
|
|
176
|
+
className: `pmn-dialog ${z === "dark" ? "dark" : ""} ${A ? "pmn-has-custom-background" : ""} ${t.className ?? ""}`,
|
|
177
|
+
style: { "--pmn-width": N, "--pmn-gap": `${$}px`, ...B !== null ? { "--pmn-top-offset": B } : {}, ...Z !== void 0 ? { "--pmn-height": Z } : {}, ...ue !== void 0 ? { "--pmn-max-height": ue } : {}, ...C !== void 0 ? { "--pmn-max-width": C } : {}, borderRadius: te },
|
|
148
178
|
children: [
|
|
149
|
-
|
|
150
|
-
|
|
179
|
+
A && /* @__PURE__ */ p("div", { "aria-hidden": "true", className: `pmn-custom-background-layer ${L}`, style: D ? { backgroundColor: D } : void 0 }),
|
|
180
|
+
r,
|
|
181
|
+
V && /* @__PURE__ */ p(
|
|
182
|
+
"div",
|
|
183
|
+
{
|
|
184
|
+
role: "separator",
|
|
185
|
+
"aria-label": "调整弹窗宽度",
|
|
186
|
+
"aria-orientation": "vertical",
|
|
187
|
+
tabIndex: 0,
|
|
188
|
+
className: `pmn-resize-handle pmn-resize-${q}`,
|
|
189
|
+
onKeyDown: (O) => {
|
|
190
|
+
["ArrowLeft", "ArrowRight"].includes(O.key) && (O.preventDefault(), i(oe(e.current.getBoundingClientRect().width + (O.key === "ArrowRight" ? 16 : -16) * (q === "left" ? 1 : -1))));
|
|
191
|
+
},
|
|
192
|
+
onPointerDown: (O) => {
|
|
193
|
+
if (O.button !== 0) return;
|
|
194
|
+
O.preventDefault(), O.currentTarget.setPointerCapture(O.pointerId);
|
|
195
|
+
const G = e.current.getBoundingClientRect().width;
|
|
196
|
+
d.current = { id: O.pointerId, x: O.clientX, start: G, width: G };
|
|
197
|
+
},
|
|
198
|
+
onPointerMove: (O) => {
|
|
199
|
+
const G = d.current;
|
|
200
|
+
!G || G.id !== O.pointerId || (G.width = oe(G.start + (O.clientX - G.x) * (q === "left" ? 1 : -1)), cancelAnimationFrame(g.current), g.current = requestAnimationFrame(() => e.current?.style.setProperty("--pmn-drag-width", `${G.width}px`)));
|
|
201
|
+
},
|
|
202
|
+
onPointerUp: J,
|
|
203
|
+
onPointerCancel: J,
|
|
204
|
+
onLostPointerCapture: J
|
|
205
|
+
}
|
|
206
|
+
)
|
|
151
207
|
]
|
|
152
208
|
}
|
|
153
209
|
)
|
|
154
210
|
}
|
|
155
211
|
), document.body);
|
|
156
212
|
}
|
|
157
|
-
|
|
158
|
-
|
|
213
|
+
const Sn = (e) => e;
|
|
214
|
+
function Pe(e, t = Sn, n = Object.is) {
|
|
215
|
+
const r = P({ store: null, initialized: !1, selection: void 0 }), o = Q(() => {
|
|
216
|
+
let l = !1, f, u;
|
|
217
|
+
return () => {
|
|
218
|
+
const i = e.getSnapshot();
|
|
219
|
+
if (l && Object.is(f, i)) return u;
|
|
220
|
+
const d = t(i);
|
|
221
|
+
if (l)
|
|
222
|
+
n(u, d) || (u = d);
|
|
223
|
+
else {
|
|
224
|
+
const g = r.current;
|
|
225
|
+
u = g.initialized && g.store === e && n(g.selection, d) ? g.selection : d;
|
|
226
|
+
}
|
|
227
|
+
return f = i, l = !0, u;
|
|
228
|
+
};
|
|
229
|
+
}, [e, t, n]), a = Oe(e.subscribe, o, o);
|
|
230
|
+
return U(() => {
|
|
231
|
+
r.current = { store: e, initialized: !0, selection: a };
|
|
232
|
+
}, [e, a]), a;
|
|
233
|
+
}
|
|
234
|
+
function He(e, t) {
|
|
235
|
+
if (Object.is(e, t)) return !0;
|
|
236
|
+
if (!e || !t || typeof e != "object" || typeof t != "object") return !1;
|
|
237
|
+
const n = Object.keys(e);
|
|
238
|
+
return n.length === Object.keys(t).length && n.every((r) => Object.hasOwn(t, r) && Object.is(e[r], t[r]));
|
|
239
|
+
}
|
|
240
|
+
const Ye = (e) => (t) => Object.fromEntries(e.map((n) => [n, t[n]])), Cn = Ye(["pageAnimationDuration", "pageAnimationDistance", "pageAnimation", "animation", "lockCloseWhileLoading", "maxCachedScreens", "bodyClassName", "lazyFallback", "onBlur", "onNavigate", "onRouteChange", "onFocus"]), En = Ye(["bodyClassName", "lazyFallback"]), Rn = Ye(["showHeader", "showTitle", "renderHeader", "renderHeaderRight", "showHeaderBorder", "headerClassName", "showBackButton", "showCloseButton"]), Qt = Ye(["showFooter", "renderFooter", "done", "cancel", "cancle", "showFooterBorder", "footerClassName", "actions", "loadingText", "cancelText", "doneText", "doneDisabled"]), Mn = Ye(["fullscreenable", "fullscreen"]), At = ["responsive", "width", "height", "maxWidth", "maxHeight", "minWidth", "size", "placement", "viewportGap", "top", "bottom", "left", "right", "borderRadius", "resizable", "fullscreen", "mobileFullscreen", "animation", "animationDuration", "closeOnEsc", "closeOnOverlay", "theme", "backgroundColor", "backgroudColor", "ariaLabel", "className"], On = Ye(At);
|
|
241
|
+
function Pn(e, t) {
|
|
242
|
+
const n = { ...e, ...t, ...e.runtimeLayout };
|
|
243
|
+
return { ...On(n), runtimeLayout: Object.fromEntries(At.filter((r) => Object.hasOwn(e.runtimeLayout ?? {}, r)).map((r) => [r, e.runtimeLayout[r]])) };
|
|
244
|
+
}
|
|
245
|
+
function Tn(e, t) {
|
|
246
|
+
return He(e.runtimeLayout, t.runtimeLayout) && At.every((n) => Object.is(e[n], t[n]));
|
|
159
247
|
}
|
|
160
|
-
|
|
248
|
+
const Zt = {}, Ln = () => Zt, zn = () => () => {
|
|
249
|
+
}, An = Se.memo(function({ action: t, context: n }) {
|
|
250
|
+
const r = P(!1), [o, a] = xe(!1), l = P(!1);
|
|
251
|
+
return U(() => (l.current = !0, () => {
|
|
252
|
+
l.current = !1;
|
|
253
|
+
}), []), /* @__PURE__ */ p("button", { type: "button", className: "pmn-icon-button", "aria-label": t.tooltip ?? t.key, title: t.tooltip, disabled: o || t.disabled || t.loading, onClick: async () => {
|
|
254
|
+
if (!(r.current || !l.current || t.disabled || t.loading)) {
|
|
255
|
+
r.current = !0, a(!0);
|
|
256
|
+
try {
|
|
257
|
+
await t.onClick?.(n);
|
|
258
|
+
} catch (f) {
|
|
259
|
+
console.error("[react-modal-navigation] header action", f);
|
|
260
|
+
} finally {
|
|
261
|
+
r.current = !1, l.current && a(!1);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}, children: o ? "…" : t.icon ?? t.label });
|
|
265
|
+
});
|
|
266
|
+
function Dt({ back: e }) {
|
|
267
|
+
return /* @__PURE__ */ p("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", width: "20", height: "20", fill: "none", stroke: "currentColor", strokeWidth: "2", children: e ? /* @__PURE__ */ p("path", { d: "m15 18-6-6 6-6" }) : /* @__PURE__ */ p("path", { d: "M18 6 6 18M6 6l12 12" }) });
|
|
268
|
+
}
|
|
269
|
+
function Nn({ options: e, screen: t, route: n, navigation: r, requestClose: o, translate: a, canGoBack: l }) {
|
|
270
|
+
const f = ee(yt), u = () => f?.getSnapshot()[n.key] ?? Zt, i = Oe(f?.subscribe ?? zn, u, Ln);
|
|
271
|
+
t = { ...t, ...i };
|
|
272
|
+
const d = a ?? ((v) => v), g = t.showTitle ?? e.showTitle ?? !0, b = typeof t.title == "function" ? t.title({ t: d, route: n, navigation: r }) : t.title ?? n.name, x = Q(() => ({ route: n, navigation: r, close: o, canGoBack: l, title: b, t: d }), [n, r, o, l, b, d]);
|
|
161
273
|
if (e.showHeader === !1) return null;
|
|
162
|
-
const
|
|
163
|
-
if (
|
|
164
|
-
const
|
|
165
|
-
return /* @__PURE__ */
|
|
166
|
-
(
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
274
|
+
const h = t.renderHeader ?? e.renderHeader;
|
|
275
|
+
if (h) return h(x);
|
|
276
|
+
const s = t.renderHeaderRight ?? e.renderHeaderRight;
|
|
277
|
+
return /* @__PURE__ */ be("header", { className: `pmn-header ${t.showHeaderBorder ?? e.showHeaderBorder ? "pmn-border-bottom" : ""} ${e.headerClassName ?? ""}`, children: [
|
|
278
|
+
(t.showBackButton ?? e.showBackButton) !== !1 && l && /* @__PURE__ */ p("button", { type: "button", className: "pmn-icon-button", "aria-label": d("modal.back"), onClick: () => r.goBack(), children: /* @__PURE__ */ p(Dt, { back: !0 }) }),
|
|
279
|
+
g ? /* @__PURE__ */ p("h2", { children: b }) : /* @__PURE__ */ p("div", { className: "pmn-header-spacer" }),
|
|
280
|
+
s?.(x),
|
|
281
|
+
i.actions?.filter((v) => !v.hidden).map((v) => /* @__PURE__ */ p(An, { action: v, context: x }, `${n.key}:${v.key}`)),
|
|
282
|
+
/* @__PURE__ */ p(jn, { hidden: t.showFullscreenButton === !1 }),
|
|
283
|
+
(t.showCloseButton ?? e.showCloseButton) !== !1 && /* @__PURE__ */ p("button", { type: "button", className: "pmn-icon-button", "aria-label": d("modal.close"), onClick: () => o("header"), children: /* @__PURE__ */ p(Dt, {}) })
|
|
170
284
|
] });
|
|
171
285
|
}
|
|
172
|
-
|
|
173
|
-
const
|
|
174
|
-
|
|
175
|
-
|
|
286
|
+
const jn = Se.memo(function({ hidden: t }) {
|
|
287
|
+
const n = ee(Lt), r = ee(at), o = Pe(r.stores.layout, Mn, He);
|
|
288
|
+
return t || !o.fullscreenable ? null : /* @__PURE__ */ p("button", { type: "button", className: "pmn-icon-button", "aria-label": o.fullscreen ? "还原" : "全屏", onClick: n?.toggleFullscreen, children: /* @__PURE__ */ p("svg", { "aria-hidden": "true", width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ p("path", { d: o.fullscreen ? "M3 9h6V3 M21 9h-6V3 M3 15h6v6 M21 15h-6v6" : "M3 9V3h6 M15 3h6v6 M3 15v6h6 M15 21h6v-6" }) }) });
|
|
289
|
+
}), Xt = rt(function({ store: t, screenOptions: n, ...r }) {
|
|
290
|
+
const o = _((l) => Pn(l, n), [n]), a = Pe(t, o, Tn);
|
|
291
|
+
return /* @__PURE__ */ p(xn, { ...r, options: a });
|
|
292
|
+
}), Jt = rt(function({ store: t, ...n }) {
|
|
293
|
+
const r = Pe(t, Rn, He);
|
|
294
|
+
return /* @__PURE__ */ p(Nn, { ...n, options: r });
|
|
295
|
+
}), Bn = Se.memo(function({ action: t, context: n, loadingApi: r, onError: o, loadingText: a }) {
|
|
296
|
+
const l = P(!1), [f, u] = xe(!1), i = P(!1);
|
|
297
|
+
U(() => (i.current = !0, () => {
|
|
298
|
+
i.current = !1;
|
|
176
299
|
}), []);
|
|
177
|
-
const
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
const H = Array.isArray(a.actions) ? a.actions : null;
|
|
182
|
-
if (!H && typeof D != "function" && typeof x != "function") return null;
|
|
183
|
-
const T = async (v, j, O) => {
|
|
184
|
-
if (k.current.has(v) || typeof j != "function") return;
|
|
185
|
-
k.current.add(v), M(v);
|
|
186
|
-
const F = u?.begin(t.key, O ?? a.loadingText ?? m("modal.processing"));
|
|
300
|
+
const d = f || t.loading === !0, g = t.loadingText ?? a ?? n.t("modal.processing"), b = async () => {
|
|
301
|
+
if (!i.current || l.current || t.disabled || t.loading || typeof t.onClick != "function") return;
|
|
302
|
+
l.current = !0, u(!0);
|
|
303
|
+
const x = r?.begin(n.route.key, g);
|
|
187
304
|
try {
|
|
188
|
-
await
|
|
189
|
-
} catch (
|
|
190
|
-
|
|
305
|
+
await t.onClick(n);
|
|
306
|
+
} catch (h) {
|
|
307
|
+
o?.(h, { phase: "footer", action: t.key, route: n.route });
|
|
191
308
|
} finally {
|
|
192
|
-
|
|
309
|
+
x != null && r?.end(n.route.key, x), l.current = !1, i.current && u(!1);
|
|
193
310
|
}
|
|
194
311
|
};
|
|
195
|
-
return
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
"button",
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
312
|
+
return /* @__PURE__ */ p(
|
|
313
|
+
"button",
|
|
314
|
+
{
|
|
315
|
+
type: "button",
|
|
316
|
+
disabled: t.disabled === !0 || d,
|
|
317
|
+
className: `pmn-button ${t.variant === "primary" || t.variant === "danger" ? "pmn-button-primary" : "pmn-button-secondary"} ${t.variant === "danger" ? "pmn-button-danger" : ""}`,
|
|
318
|
+
onClick: b,
|
|
319
|
+
children: d ? g : t.label
|
|
320
|
+
}
|
|
321
|
+
);
|
|
322
|
+
});
|
|
323
|
+
function en({ screen: e, options: t, override: n, route: r, navigation: o, requestClose: a, translate: l, onError: f, loadingApi: u }) {
|
|
324
|
+
const [i, d] = xe(null), g = P(/* @__PURE__ */ new Set()), b = P(!0);
|
|
325
|
+
U(() => (b.current = !0, () => {
|
|
326
|
+
b.current = !1;
|
|
327
|
+
}), []);
|
|
328
|
+
const x = l ?? ((N) => N), h = { ...t, ...e, ...n }, { showFooter: s, renderFooter: v, done: I, cancel: z, cancle: T } = h, E = z ?? T, D = Q(() => ({ route: r, navigation: o, close: a, t: x }), [r, o, a, x]);
|
|
329
|
+
if (s === !1) return null;
|
|
330
|
+
const L = `pmn-footer ${h.showFooterBorder ? "pmn-border-top" : ""} ${h.footerClassName ?? ""}`;
|
|
331
|
+
if (typeof v == "function") return /* @__PURE__ */ p("footer", { className: L, children: v({ ...D, pending: g.current.size > 0 }) });
|
|
332
|
+
const A = Array.isArray(h.actions) ? h.actions : null;
|
|
333
|
+
if (!A && typeof I != "function" && typeof E != "function") return null;
|
|
334
|
+
const q = async (N, Z, ue) => {
|
|
335
|
+
if (!b.current || g.current.size > 0 || g.current.has(N) || typeof Z != "function") return;
|
|
336
|
+
g.current.add(N), d(N);
|
|
337
|
+
const C = u?.begin(r.key, h.loadingText ?? x("modal.processing"));
|
|
338
|
+
try {
|
|
339
|
+
await Z(D);
|
|
340
|
+
} catch (F) {
|
|
341
|
+
f?.(F, { phase: "footer", action: N, route: r });
|
|
342
|
+
} finally {
|
|
343
|
+
C != null && u?.end(r.key, C), g.current.delete(N), b.current && d((F) => F === N ? null : F);
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
return A ? /* @__PURE__ */ p("footer", { className: L, children: A.filter((N) => !N.hidden).map(
|
|
347
|
+
(N) => /* @__PURE__ */ p(Bn, { action: N, context: D, loadingApi: u, onError: f, loadingText: h.loadingText }, `${r.key}:${N.key}`)
|
|
348
|
+
) }) : /* @__PURE__ */ be("footer", { className: L, children: [
|
|
349
|
+
typeof E == "function" && /* @__PURE__ */ p("button", { type: "button", disabled: i !== null, onClick: () => q("cancel", E), className: "pmn-button pmn-button-secondary", children: h.cancelText ?? x("modal.cancel") }),
|
|
350
|
+
typeof I == "function" && /* @__PURE__ */ p("button", { type: "button", disabled: i !== null || h.doneDisabled === !0, onClick: () => q("done", I), className: "pmn-button pmn-button-primary", children: i === "done" ? h.loadingText ?? x("modal.processing") : h.doneText ?? x("modal.done") })
|
|
211
351
|
] });
|
|
212
352
|
}
|
|
213
|
-
function
|
|
353
|
+
function tn({ loading: e, translate: t }) {
|
|
214
354
|
if (!e.visible) return null;
|
|
215
|
-
const
|
|
216
|
-
return /* @__PURE__ */
|
|
217
|
-
/* @__PURE__ */
|
|
218
|
-
|
|
355
|
+
const r = (t ?? ((a) => a))("modal.loading"), o = e.text ?? (r === "modal.loading" ? "加载中..." : r);
|
|
356
|
+
return /* @__PURE__ */ p("div", { className: "pmn-loading-overlay", role: "status", "aria-live": "polite", "aria-busy": "true", children: /* @__PURE__ */ be("div", { className: "pmn-loading-content", children: [
|
|
357
|
+
/* @__PURE__ */ p("span", { className: "pmn-spinner", "aria-hidden": "true" }),
|
|
358
|
+
o && /* @__PURE__ */ p("span", { className: "pmn-loading-text", children: o })
|
|
219
359
|
] }) });
|
|
220
360
|
}
|
|
221
|
-
class
|
|
361
|
+
class Nt extends Se.Component {
|
|
222
362
|
state = { error: null };
|
|
223
|
-
static getDerivedStateFromError(
|
|
224
|
-
return { error:
|
|
363
|
+
static getDerivedStateFromError(t) {
|
|
364
|
+
return { error: t };
|
|
225
365
|
}
|
|
226
|
-
componentDidCatch(
|
|
227
|
-
this.props.onError?.(
|
|
366
|
+
componentDidCatch(t, n) {
|
|
367
|
+
this.props.onError?.(t, { phase: "render", route: this.props.route, componentStack: n.componentStack });
|
|
228
368
|
}
|
|
229
|
-
componentDidUpdate(
|
|
230
|
-
|
|
369
|
+
componentDidUpdate(t) {
|
|
370
|
+
t.route?.key !== this.props.route?.key && this.state.error && this.setState({ error: null });
|
|
231
371
|
}
|
|
232
372
|
render() {
|
|
233
|
-
return this.state.error ? /* @__PURE__ */
|
|
234
|
-
/* @__PURE__ */
|
|
235
|
-
/* @__PURE__ */
|
|
236
|
-
/* @__PURE__ */
|
|
373
|
+
return this.state.error ? /* @__PURE__ */ be("div", { role: "alert", className: "pmn-error-screen", children: [
|
|
374
|
+
/* @__PURE__ */ p("strong", { children: "页面加载失败" }),
|
|
375
|
+
/* @__PURE__ */ p("p", { children: this.state.error.message }),
|
|
376
|
+
/* @__PURE__ */ p("button", { type: "button", className: "pmn-button pmn-button-secondary", onClick: () => {
|
|
377
|
+
this.props.onRetry?.(), this.setState({ error: null });
|
|
378
|
+
}, children: "重试" })
|
|
237
379
|
] }) : this.props.children;
|
|
238
380
|
}
|
|
239
381
|
}
|
|
240
|
-
const
|
|
241
|
-
function
|
|
242
|
-
return e.length ? /* @__PURE__ */
|
|
243
|
-
/* @__PURE__ */
|
|
244
|
-
/* @__PURE__ */
|
|
245
|
-
|
|
246
|
-
] },
|
|
247
|
-
}
|
|
248
|
-
function
|
|
249
|
-
const r =
|
|
250
|
-
clearTimeout(
|
|
251
|
-
}, []),
|
|
252
|
-
if (typeof
|
|
253
|
-
const
|
|
254
|
-
if (!
|
|
255
|
-
const
|
|
256
|
-
for (const
|
|
257
|
-
clearTimeout(
|
|
258
|
-
return e.current.publish([...
|
|
259
|
-
}, [
|
|
260
|
-
const
|
|
261
|
-
for (const
|
|
262
|
-
return
|
|
263
|
-
const
|
|
382
|
+
const qn = { success: "✓", error: "×", warning: "!", info: "i" };
|
|
383
|
+
function nn({ items: e, dismiss: t }) {
|
|
384
|
+
return e.length ? /* @__PURE__ */ p("div", { className: "pmn-toast-region", "aria-label": "Notifications", children: e.map((n) => /* @__PURE__ */ be("div", { className: `pmn-toast pmn-toast-${n.type}`, role: n.type === "error" || n.type === "warning" ? "alert" : "status", children: [
|
|
385
|
+
/* @__PURE__ */ p("span", { className: "pmn-toast-symbol", "aria-hidden": "true", children: qn[n.type] }),
|
|
386
|
+
/* @__PURE__ */ p("span", { className: "pmn-toast-message", children: n.message }),
|
|
387
|
+
n.dismissible && /* @__PURE__ */ p("button", { type: "button", className: "pmn-toast-close", "aria-label": "Dismiss notification", onClick: () => t(n.id), children: "×" })
|
|
388
|
+
] }, n.id)) }) : null;
|
|
389
|
+
}
|
|
390
|
+
function rn(e, t, n) {
|
|
391
|
+
const r = P(0), o = P(/* @__PURE__ */ new Map()), a = _((u) => {
|
|
392
|
+
clearTimeout(o.current.get(u)), o.current.delete(u), t.current && e.current.publish(e.current.getSnapshot().filter((i) => i.id !== u));
|
|
393
|
+
}, []), l = _((u, i = {}) => {
|
|
394
|
+
if (typeof u != "string" || !u.trim()) throw new TypeError("[react-modal-navigation] toast message must be a non-empty string");
|
|
395
|
+
const d = typeof i == "string" ? { type: i } : i ?? {}, g = ["success", "error", "warning", "info"].includes(d.type) ? d.type : "info", b = ++r.current, x = Number.isFinite(d.duration) ? Math.max(0, d.duration) : 3e3;
|
|
396
|
+
if (!t.current) return null;
|
|
397
|
+
const h = e.current.getSnapshot(), s = h.slice(0, Math.max(0, h.length - 4));
|
|
398
|
+
for (const v of s)
|
|
399
|
+
clearTimeout(o.current.get(v.id)), o.current.delete(v.id);
|
|
400
|
+
return e.current.publish([...h.slice(-4), { id: b, message: u, type: g, dismissible: d.dismissible !== !1 }]), x > 0 && o.current.set(b, setTimeout(() => a(b), x)), b;
|
|
401
|
+
}, [a]), f = Q(() => {
|
|
402
|
+
const u = (i, d) => l(i, d);
|
|
403
|
+
for (const i of ["success", "error", "warning", "info"]) u[i] = (d, g = {}) => l(d, { ...g, type: i });
|
|
404
|
+
return u.promise = async (i, d, g = {}) => {
|
|
405
|
+
const b = l(d.loading, { ...g, type: "info", duration: 0 });
|
|
264
406
|
try {
|
|
265
|
-
const
|
|
266
|
-
|
|
267
|
-
const
|
|
268
|
-
return
|
|
269
|
-
} catch (
|
|
270
|
-
|
|
271
|
-
const
|
|
272
|
-
throw
|
|
407
|
+
const x = await (typeof i == "function" ? i() : i);
|
|
408
|
+
b != null && a(b);
|
|
409
|
+
const h = typeof d.success == "function" ? d.success(x) : d.success;
|
|
410
|
+
return h && l(h, { ...g, type: "success" }), x;
|
|
411
|
+
} catch (x) {
|
|
412
|
+
b != null && a(b);
|
|
413
|
+
const h = typeof d.error == "function" ? d.error(x) : d.error;
|
|
414
|
+
throw h && l(h, { ...g, type: "error" }), x;
|
|
415
|
+
}
|
|
416
|
+
}, u.dismiss = a, u.clear = () => {
|
|
417
|
+
for (const i of o.current.values()) clearTimeout(i);
|
|
418
|
+
o.current.clear(), e.current.publish([]);
|
|
419
|
+
}, u;
|
|
420
|
+
}, [l, a]);
|
|
421
|
+
return U(() => {
|
|
422
|
+
const u = () => {
|
|
423
|
+
for (const d of o.current.values()) clearTimeout(d);
|
|
424
|
+
o.current.clear();
|
|
425
|
+
}, i = n?.addCleanup(u);
|
|
426
|
+
return () => {
|
|
427
|
+
i?.(), u();
|
|
428
|
+
};
|
|
429
|
+
}, [n]), { toast: f, dismissToast: a };
|
|
430
|
+
}
|
|
431
|
+
function Fn(e) {
|
|
432
|
+
let t;
|
|
433
|
+
return {
|
|
434
|
+
added(n) {
|
|
435
|
+
t = n;
|
|
436
|
+
},
|
|
437
|
+
read() {
|
|
438
|
+
if (!e.has(t)) {
|
|
439
|
+
t = void 0;
|
|
440
|
+
for (const n of e.keys()) t = n;
|
|
273
441
|
}
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
(
|
|
289
|
-
|
|
290
|
-
if (!n.current || d !== "global" && r.current !== d) return null;
|
|
291
|
-
const a = ++i.current;
|
|
292
|
-
return t.current.set(a, { owner: d, text: m }), g(), a;
|
|
293
|
-
}, [g]), f = w((d, m) => {
|
|
294
|
-
if (m != null)
|
|
295
|
-
t.current.get(m)?.owner === d && t.current.delete(m);
|
|
442
|
+
return { visible: e.size > 0, text: e.get(t)?.text ?? null, count: e.size };
|
|
443
|
+
}
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
function on(e, t, n, r) {
|
|
447
|
+
const o = r.loadingTasks, a = r.loadingSequence, l = Q(() => Fn(o.current), [o]), f = _(() => {
|
|
448
|
+
if (!t.current) return;
|
|
449
|
+
const h = l.read(), s = e.current.getSnapshot();
|
|
450
|
+
(s.visible !== h.visible || s.text !== h.text || s.count !== h.count) && e.current.publish(h);
|
|
451
|
+
}, [l]), u = _((h, s) => {
|
|
452
|
+
if (!t.current || h !== "global" && n.current !== h) return null;
|
|
453
|
+
const v = ++a.current;
|
|
454
|
+
return o.current.set(v, { owner: h, text: s }), l.added(v), f(), v;
|
|
455
|
+
}, [f, l]), i = _((h, s) => {
|
|
456
|
+
if (s != null)
|
|
457
|
+
o.current.get(s)?.owner === h && o.current.delete(s);
|
|
296
458
|
else
|
|
297
|
-
for (const [
|
|
298
|
-
|
|
299
|
-
}, [
|
|
300
|
-
|
|
301
|
-
}, [
|
|
302
|
-
|
|
303
|
-
}, [
|
|
304
|
-
return { loadingApi:
|
|
305
|
-
}
|
|
306
|
-
const
|
|
307
|
-
const
|
|
308
|
-
return /* @__PURE__ */
|
|
309
|
-
}),
|
|
310
|
-
const
|
|
311
|
-
return /* @__PURE__ */
|
|
312
|
-
}),
|
|
313
|
-
const
|
|
314
|
-
return /* @__PURE__ */
|
|
315
|
-
}),
|
|
316
|
-
const
|
|
317
|
-
|
|
318
|
-
const
|
|
319
|
-
if (
|
|
320
|
-
const
|
|
321
|
-
|
|
322
|
-
const
|
|
323
|
-
{ opacity: 1, transform: `translate3d(${
|
|
459
|
+
for (const [v, I] of o.current) I.owner === h && o.current.delete(v);
|
|
460
|
+
f();
|
|
461
|
+
}, [f]), d = _((h, s) => {
|
|
462
|
+
h ? (i("global"), u("global", s)) : i("global");
|
|
463
|
+
}, [u, i]), g = _((h, s, v) => {
|
|
464
|
+
s ? (i(h), u(h, v)) : i(h);
|
|
465
|
+
}, [u, i]);
|
|
466
|
+
return { loadingApi: Q(() => ({ setLoading: d, setScreenLoading: g, begin: u, end: i }), [d, g, u, i]), refreshLoading: f, loadingTasks: o, setLoading: d };
|
|
467
|
+
}
|
|
468
|
+
const $n = Se.memo(function({ store: t, translate: n }) {
|
|
469
|
+
const r = Oe(t.subscribe, t.getSnapshot, t.getSnapshot);
|
|
470
|
+
return /* @__PURE__ */ p(tn, { loading: r, translate: n });
|
|
471
|
+
}), In = Se.memo(function({ store: t, dismiss: n }) {
|
|
472
|
+
const r = Oe(t.subscribe, t.getSnapshot, t.getSnapshot);
|
|
473
|
+
return /* @__PURE__ */ p(nn, { items: r, dismiss: n });
|
|
474
|
+
}), Dn = Se.memo(function({ store: t, layoutStore: n, routeKey: r, ...o }) {
|
|
475
|
+
const a = () => t.getSnapshot()[r], l = Oe(t.subscribe, a, a), f = Pe(n, Qt, He);
|
|
476
|
+
return /* @__PURE__ */ p(en, { ...o, options: f, override: l });
|
|
477
|
+
}), Kn = Se.memo(function({ route: t, screen: n, navigation: r, focused: o, resultEvent: a, setFooter: l, loadingApi: f, loadingStore: u, bodyClassName: i, notifyError: d, registerDirtyGuard: g, pageMotion: b, lazyFallback: x }) {
|
|
478
|
+
const h = n.component, s = P(null), v = P(!1);
|
|
479
|
+
Ae(() => {
|
|
480
|
+
const E = o && !v.current;
|
|
481
|
+
if (v.current = o, !E || !b?.enabled || !s.current?.animate) return;
|
|
482
|
+
const D = b.direction === "back" ? -100 : 100;
|
|
483
|
+
s.current.style.zIndex = "2";
|
|
484
|
+
const L = s.current.animate([
|
|
485
|
+
{ opacity: 1, transform: `translate3d(${D}%,0,0)` },
|
|
324
486
|
{ opacity: 1, transform: "translate3d(0,0,0)" }
|
|
325
|
-
], { duration:
|
|
487
|
+
], { duration: b.duration, easing: "cubic-bezier(.22,1,.36,1)" });
|
|
326
488
|
return () => {
|
|
327
|
-
|
|
489
|
+
L.cancel(), s.current && (s.current.style.zIndex = "");
|
|
328
490
|
};
|
|
329
|
-
}, [
|
|
330
|
-
const
|
|
331
|
-
setLoading: (
|
|
332
|
-
showLoading: (
|
|
333
|
-
hideLoading: (
|
|
334
|
-
}), [f,
|
|
335
|
-
return /* @__PURE__ */
|
|
491
|
+
}, [o, b?.enabled, b?.direction, b?.duration, b?.distance]);
|
|
492
|
+
const I = Q(() => ({ isFocused: o, resultEvent: a, routeKey: t.key, setFooter: l }), [o, a, t.key, l]), z = Q(() => ({
|
|
493
|
+
setLoading: (E, D) => f.setScreenLoading(t.key, E, D),
|
|
494
|
+
showLoading: (E) => f.begin(t.key, E),
|
|
495
|
+
hideLoading: (E) => f.end(t.key, E)
|
|
496
|
+
}), [f, t.key]), T = Q(() => ({ routeKey: t.key, registerDirtyGuard: g }), [t.key, g]);
|
|
497
|
+
return /* @__PURE__ */ p(Ve.Provider, { value: t, children: /* @__PURE__ */ p(Pt.Provider, { value: T, children: /* @__PURE__ */ p(ot.Provider, { value: I, children: /* @__PURE__ */ p(Ue.Provider, { value: z, children: /* @__PURE__ */ p(wt.Provider, { value: u, children: /* @__PURE__ */ p("div", { ref: s, hidden: !o, inert: !o, "data-modal-route-key": t.key, tabIndex: -1, className: `pmn-body ${o && b?.enabled && typeof Element < "u" && !Element.prototype.animate ? `pmn-page-enter pmn-page-${b.direction}` : ""} ${i ?? ""}`, style: o && b?.enabled ? { "--pmn-page-duration": `${b.duration}ms`, "--pmn-page-distance": `${b.distance}px` } : void 0, children: /* @__PURE__ */ p(Nt, { route: t, onError: d, children: /* @__PURE__ */ p(Wt, { fallback: x ?? /* @__PURE__ */ p("div", { className: "pmn-lazy-loading", role: "status", "aria-live": "polite", children: "加载中..." }), children: /* @__PURE__ */ p(h, { route: t, navigation: r }) }) }) }) }) }) }) }) });
|
|
336
498
|
});
|
|
337
|
-
function
|
|
338
|
-
const [
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
const
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
const
|
|
352
|
-
|
|
353
|
-
const
|
|
354
|
-
|
|
355
|
-
const
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
if (S === null) {
|
|
363
|
-
if (!(o in z)) return;
|
|
364
|
-
const I = { ...z };
|
|
365
|
-
delete I[o], L.current.publish(I);
|
|
499
|
+
function Hn({ runtime: e, config: t, initialScreen: n, params: r, translate: o, onRequestClose: a, onOpened: l, registerLoading: f, notifyError: u, error: i, clearError: d, registerDirtyGuard: g, getProtectedCacheKeys: b, canNavigate: x, exiting: h = !1 }) {
|
|
500
|
+
const s = Pe(e.stores.layout, Cn, He), [v, I] = dn(mt, e.stores.navigation.getSnapshot().stack), { navigation: z, loading: T, footer: E, toast: D } = e.refs, L = e.alive, A = P(0), { toast: q, dismissToast: N } = rn(D, L, e);
|
|
501
|
+
U(() => () => {
|
|
502
|
+
A.current++;
|
|
503
|
+
}, []);
|
|
504
|
+
const [Z, ue] = xe({}), [C, F] = xe(() => /* @__PURE__ */ new Set()), $ = P(/* @__PURE__ */ new Map()), X = P(null), B = P(null), te = P(null), V = P(null), oe = P(null), J = P(!1), O = P(!1), G = e.pageRequests, ke = P(0), Ce = _((m, M, j) => {
|
|
505
|
+
for (const [Y, fe] of G.current)
|
|
506
|
+
m.includes(fe.key) && (G.current.delete(Y), fe.resolve({ status: M, ...M === "returned" ? { value: j } : {} }));
|
|
507
|
+
}, []), K = P(v);
|
|
508
|
+
K.current = v;
|
|
509
|
+
const de = P(x);
|
|
510
|
+
de.current = x;
|
|
511
|
+
const k = P(!1), ce = P(0), ne = v.at(-1), re = ne.key, Be = P({ key: re, depth: v.length }), st = Be.current, We = st.key !== re, it = v.length < st.depth ? "back" : "forward";
|
|
512
|
+
We && (Be.current = { key: re, depth: v.length });
|
|
513
|
+
const Qe = Math.min(1e3, Math.max(0, Number(s.pageAnimationDuration ?? 360) || 0)), ct = Math.min(300, Math.max(0, Number(s.pageAnimationDistance ?? 96) || 0)), Ne = Q(() => ({ distance: ct, enabled: s.pageAnimation !== !1 && s.animation !== !1 && Qe > 0 && We, direction: it, duration: Qe }), [ct, s.pageAnimation, s.animation, Qe, We, it]), lt = P(re);
|
|
514
|
+
lt.current = re;
|
|
515
|
+
const { loadingApi: Ze, refreshLoading: Ge, loadingTasks: ut, setLoading: De } = on(T, L, lt, e), Ee = t.screens, Te = T, _e = P(f);
|
|
516
|
+
_e.current = f, U(() => (_e.current?.({ setLoading: De }), () => _e.current?.(null)), [De]);
|
|
517
|
+
const qt = _((m, M) => {
|
|
518
|
+
if (!L.current) return;
|
|
519
|
+
const j = E.current.getSnapshot();
|
|
520
|
+
if (M === null) {
|
|
521
|
+
if (!(m in j)) return;
|
|
522
|
+
const Y = { ...j };
|
|
523
|
+
delete Y[m], E.current.publish(Y);
|
|
366
524
|
return;
|
|
367
525
|
}
|
|
368
|
-
|
|
369
|
-
}, []),
|
|
526
|
+
j[m] !== M && E.current.publish({ ...j, [m]: M });
|
|
527
|
+
}, []), kt = _(() => {
|
|
370
528
|
if (typeof document > "u") return;
|
|
371
|
-
const
|
|
372
|
-
if (!(
|
|
373
|
-
const
|
|
374
|
-
|
|
375
|
-
}, []),
|
|
376
|
-
if (!Object.prototype.hasOwnProperty.call(
|
|
377
|
-
}, [
|
|
529
|
+
const m = document.activeElement;
|
|
530
|
+
if (!(m instanceof HTMLElement) || !X.current?.contains(m)) return;
|
|
531
|
+
const M = m.closest("[data-modal-route-key]");
|
|
532
|
+
M && $.current.set(M.dataset.modalRouteKey, m), X.current.focus({ preventScroll: !0 });
|
|
533
|
+
}, []), xt = _((m) => {
|
|
534
|
+
if (!Object.prototype.hasOwnProperty.call(Ee, m)) throw new Error(`[react-modal-navigation] Unknown modal screen: ${m}`);
|
|
535
|
+
}, [Ee]), c = _((m, M) => {
|
|
378
536
|
try {
|
|
379
|
-
Promise.resolve(
|
|
380
|
-
} catch (
|
|
381
|
-
u(
|
|
537
|
+
Promise.resolve(s[m]?.(M)).catch((j) => u(j, { phase: m }));
|
|
538
|
+
} catch (j) {
|
|
539
|
+
u(j, { phase: m });
|
|
382
540
|
}
|
|
383
|
-
}, [
|
|
384
|
-
if (!
|
|
385
|
-
const
|
|
386
|
-
if (
|
|
387
|
-
const
|
|
388
|
-
|
|
541
|
+
}, [s, u]), y = _(async (m, M, j, Y, fe) => {
|
|
542
|
+
if (!L.current || O.current) return !1;
|
|
543
|
+
const ve = A.current, se = K.current, Xe = se.at(-1);
|
|
544
|
+
if (m !== "BACK" && m !== "POP" && xt(M), m === "POP" && (!Number.isInteger(j) || j < 1 || se.length <= 1) || m === "BACK" && se.length <= 1) return !1;
|
|
545
|
+
const Ft = m === "NAVIGATE" ? se.findIndex((Je) => Je.name === M) : -1, $e = m === "POP" ? se.slice(Math.max(1, se.length - j)) : m === "RESET" ? se : m === "BACK" || m === "REPLACE" ? [Xe] : Ft >= 0 ? se.slice(Ft + 1) : [];
|
|
546
|
+
O.current = !0;
|
|
389
547
|
try {
|
|
390
|
-
if (
|
|
548
|
+
if ($e.length && de.current && !await de.current($e.map((Me) => Me.key), {
|
|
391
549
|
reason: "navigation",
|
|
392
|
-
action:
|
|
393
|
-
from:
|
|
394
|
-
to:
|
|
395
|
-
}) || !
|
|
396
|
-
if (
|
|
397
|
-
const
|
|
398
|
-
|
|
550
|
+
action: m,
|
|
551
|
+
from: Xe,
|
|
552
|
+
to: m === "POP" ? se[Math.max(0, se.length - j - 1)]?.name : m === "BACK" ? se.at(-2)?.name : M
|
|
553
|
+
}) || $e.length && !await e.canRemove($e.map((ge) => ge.key), { reason: "navigation", action: m, from: Xe, to: M }) || !L.current || ve !== A.current || K.current.at(-1)?.key !== Xe.key) return !1;
|
|
554
|
+
if (m === "BACK" && Y !== void 0) {
|
|
555
|
+
const ge = se.at(-2);
|
|
556
|
+
ue((Me) => ({ ...Me, [ge.key]: { id: ++ce.current, data: Y } }));
|
|
557
|
+
}
|
|
558
|
+
if ($e.length) {
|
|
559
|
+
const ge = new Set($e.map((Me) => Me.key));
|
|
560
|
+
ge.forEach((Me) => $.current.delete(Me)), ue((Me) => Object.fromEntries(Object.entries(Me).filter(([et]) => !ge.has(et))));
|
|
399
561
|
}
|
|
400
|
-
|
|
401
|
-
const
|
|
402
|
-
|
|
403
|
-
const
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
return
|
|
562
|
+
e.tasks.cancelRoutes($e.map((ge) => ge.key)), Ce($e.map((ge) => ge.key), m === "BACK" ? "returned" : "removed", Y);
|
|
563
|
+
const Je = [...B.current?.querySelectorAll("[data-modal-route-key]") ?? []].find((ge) => ge.dataset.modalRouteKey === Xe.key);
|
|
564
|
+
te.current = Je?.cloneNode(!0) ?? null, kt();
|
|
565
|
+
const un = { type: m, name: M, params: j, count: j };
|
|
566
|
+
K.current = mt(K.current, un);
|
|
567
|
+
const Rt = K.current;
|
|
568
|
+
return F((ge) => {
|
|
569
|
+
const Me = new Set(Rt.slice(0, -1).filter((et) => ge.has(et.key)).map((et) => et.key));
|
|
570
|
+
return Me.size === ge.size ? ge : Me;
|
|
571
|
+
}), fe?.(Rt.at(-1)), I({ type: "COMMIT", stack: Rt }), !0;
|
|
572
|
+
} catch (Je) {
|
|
573
|
+
return L.current && u(Je, { phase: "navigationGuard", action: m }), !1;
|
|
407
574
|
} finally {
|
|
408
|
-
|
|
575
|
+
O.current = !1;
|
|
409
576
|
}
|
|
410
|
-
}, [
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
if (!
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
577
|
+
}, [xt, kt, u, Ce]), R = _((m, M) => y("NAVIGATE", m, M), [y]), w = _((m, M) => y("PUSH", m, M), [y]), H = _((m = 1) => y("POP", null, m), [y]), W = _(() => H(K.current.length - 1), [H]), ae = _((m) => {
|
|
578
|
+
const M = K.current.findLastIndex((j) => j.name === m);
|
|
579
|
+
return M < 0 ? Promise.resolve(!1) : H(K.current.length - M - 1);
|
|
580
|
+
}, [H]), me = _(async (m, M) => {
|
|
581
|
+
if (!L.current) return { status: "cancelled" };
|
|
582
|
+
let j;
|
|
583
|
+
return await y("NAVIGATE", m, M, void 0, (fe) => {
|
|
584
|
+
j = new Promise((ve) => {
|
|
585
|
+
const se = ++ke.current;
|
|
586
|
+
G.current.set(se, { key: fe.key, resolve: ve });
|
|
587
|
+
});
|
|
588
|
+
}) && j ? j : { status: "cancelled" };
|
|
589
|
+
}, [y]), ie = _((m, M) => y("REPLACE", m, M), [y]), pe = _((m, M) => y("RESET", m, M), [y]), Re = _((m) => {
|
|
590
|
+
if (!m || typeof m != "object" || Array.isArray(m)) throw new TypeError("[react-modal-navigation] setParams expects an object");
|
|
591
|
+
if (!L.current) return;
|
|
592
|
+
const M = { type: "SET_PARAMS", params: m };
|
|
593
|
+
K.current = mt(K.current, M), I({ type: "COMMIT", stack: K.current });
|
|
594
|
+
}, []), S = _((m) => {
|
|
595
|
+
if (!m || typeof m != "object" || Array.isArray(m)) throw new TypeError("[react-modal-navigation] setOptions expects an object");
|
|
596
|
+
if (!L.current) return;
|
|
597
|
+
const M = { type: "SET_OPTIONS", options: m };
|
|
598
|
+
K.current = mt(K.current, M), I({ type: "COMMIT", stack: K.current });
|
|
599
|
+
}, []), le = _((m) => y("BACK", null, void 0, m), [y]), Le = _((m, M) => !L.current || Te.current.getSnapshot().visible && s.lockCloseWhileLoading !== !1 ? Promise.resolve(!1) : a(m, M, { route: ne, stack: v }), [s.lockCloseWhileLoading, a, ne, v]), ye = P(Le);
|
|
600
|
+
ye.current = Le;
|
|
601
|
+
const he = _((m) => ye.current("api", m), []), ze = _(async (m) => {
|
|
602
|
+
if (!L.current || O.current) return !1;
|
|
603
|
+
const M = K.current, j = $t(M, Ee, s.maxCachedScreens, C, b?.()).slice(0, -1).filter((Y) => m === void 0 || Y.name === m).map((Y) => Y.key);
|
|
604
|
+
if (!j.length) return !1;
|
|
605
|
+
O.current = !0;
|
|
606
|
+
try {
|
|
607
|
+
const Y = { reason: "cache", action: "CLEAR_CACHE", from: M.at(-1) };
|
|
608
|
+
return de.current && !await de.current(j, Y) || !await e.canRemove(j, Y) || !L.current || K.current !== M ? !1 : (e.tasks.cancelRoutes(j), j.forEach((fe) => $.current.delete(fe)), F((fe) => /* @__PURE__ */ new Set([...fe, ...j])), !0);
|
|
609
|
+
} catch (Y) {
|
|
610
|
+
return L.current && u(Y, { phase: "clearCache" }), !1;
|
|
611
|
+
} finally {
|
|
612
|
+
O.current = !1;
|
|
613
|
+
}
|
|
614
|
+
}, [e, u, Ee, s.maxCachedScreens, C, b]), qe = Q(() => ({ navigate: R, navigateAsync: me, push: w, pop: H, popTo: ae, popToTop: W, replace: ie, reset: pe, setParams: Re, setOptions: S, goBack: le, close: he, setLoading: De, clearCache: ze }), [R, me, w, H, ae, W, ie, pe, Re, S, le, he, De, ze]);
|
|
615
|
+
Ae(() => e.registerNavigation(qe), [e, qe]);
|
|
616
|
+
const Fe = Q(() => ({ canGoBack: v.length > 1, stack: v, currentRoute: ne }), [v]);
|
|
617
|
+
Ae(() => z.current.publish(Fe), [Fe]);
|
|
618
|
+
const St = P(null);
|
|
619
|
+
St.current || (St.current = Object.defineProperties({}, {
|
|
620
|
+
canGoBack: { enumerable: !0, get: () => z.current.getSnapshot().canGoBack },
|
|
621
|
+
stack: { enumerable: !0, get: () => z.current.getSnapshot().stack },
|
|
622
|
+
currentRoute: { enumerable: !0, get: () => z.current.getSnapshot().currentRoute }
|
|
437
623
|
}));
|
|
438
|
-
const
|
|
439
|
-
|
|
440
|
-
const
|
|
441
|
-
if (
|
|
442
|
-
const
|
|
443
|
-
|
|
444
|
-
const
|
|
445
|
-
|
|
446
|
-
const
|
|
447
|
-
|
|
624
|
+
const dt = Q(() => Object.assign(St.current, qe), [qe]);
|
|
625
|
+
Ae(() => {
|
|
626
|
+
const m = te.current;
|
|
627
|
+
if (te.current = null, V.current?.cancel?.(), V.current = null, B.current?.querySelectorAll("[data-pmn-outgoing]").forEach((se) => se.remove()), !We || !Ne.enabled || !m || !B.current || typeof window < "u" && window.matchMedia?.("(prefers-reduced-motion: reduce)").matches) return;
|
|
628
|
+
const M = B.current;
|
|
629
|
+
m.removeAttribute("hidden"), m.removeAttribute("tabindex"), m.setAttribute("aria-hidden", "true"), m.setAttribute("inert", ""), m.dataset.pmnOutgoing = "true", m.querySelectorAll("[id]").forEach((se) => se.removeAttribute("id")), m.querySelectorAll("[autofocus]").forEach((se) => se.removeAttribute("autofocus")), m.style.cssText += ";position:absolute;inset:0;width:100%;height:100%;z-index:1;pointer-events:none;overflow:hidden;background:var(--pmn-body);", M.appendChild(m);
|
|
630
|
+
const j = Ne.direction === "back" ? 1 : -1, Y = [...M.querySelectorAll("[data-modal-route-key]")].find((se) => se.dataset.modalRouteKey === re);
|
|
631
|
+
Y && (Y.style.zIndex = "2");
|
|
632
|
+
const fe = () => {
|
|
633
|
+
m.remove(), Y && (Y.style.zIndex = ""), V.current === ve && (V.current = null);
|
|
448
634
|
};
|
|
449
|
-
let
|
|
450
|
-
if (
|
|
451
|
-
|
|
635
|
+
let ve;
|
|
636
|
+
if (m.animate)
|
|
637
|
+
ve = m.animate([
|
|
452
638
|
{ opacity: 1, transform: "translate3d(0,0,0)" },
|
|
453
|
-
{ opacity: 1, transform: `translate3d(${
|
|
454
|
-
], { duration:
|
|
639
|
+
{ opacity: 1, transform: `translate3d(${j * 100}%,0,0)` }
|
|
640
|
+
], { duration: Ne.duration, easing: "cubic-bezier(.22,1,.36,1)", fill: "forwards" }), ve.addEventListener("finish", fe, { once: !0 }), ve.addEventListener("cancel", fe, { once: !0 }), V.current = ve;
|
|
455
641
|
else {
|
|
456
|
-
|
|
457
|
-
const se = setTimeout(
|
|
458
|
-
|
|
459
|
-
clearTimeout(se),
|
|
460
|
-
} },
|
|
642
|
+
m.classList.add("pmn-page-exit", `pmn-page-exit-${Ne.direction}`), m.style.setProperty("--pmn-page-duration", `${Ne.duration}ms`), m.style.setProperty("--pmn-page-distance", "100%");
|
|
643
|
+
const se = setTimeout(fe, Ne.duration + 40);
|
|
644
|
+
ve = { cancel: () => {
|
|
645
|
+
clearTimeout(se), fe();
|
|
646
|
+
} }, V.current = ve;
|
|
461
647
|
}
|
|
462
648
|
return () => {
|
|
463
|
-
|
|
649
|
+
ve?.cancel?.(), m.remove();
|
|
464
650
|
};
|
|
465
|
-
}, [
|
|
466
|
-
|
|
467
|
-
const
|
|
468
|
-
if (!
|
|
469
|
-
const
|
|
470
|
-
(
|
|
471
|
-
}, [
|
|
472
|
-
let
|
|
473
|
-
for (const [
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
const
|
|
477
|
-
|
|
478
|
-
const
|
|
479
|
-
if (!
|
|
480
|
-
const
|
|
481
|
-
return
|
|
651
|
+
}, [re]), Ae(() => {
|
|
652
|
+
J.current = !1;
|
|
653
|
+
const m = [...X.current?.querySelectorAll("[data-modal-route-key]") ?? []].find((Y) => Y.dataset.modalRouteKey === re);
|
|
654
|
+
if (!m) return;
|
|
655
|
+
const M = $.current.get(re);
|
|
656
|
+
(M?.isConnected && m.contains(M) && !M.matches(":disabled") && !M.closest("[inert], [hidden]") ? M : m).focus({ preventScroll: !0 });
|
|
657
|
+
}, [re]), U(() => {
|
|
658
|
+
let m = !1;
|
|
659
|
+
for (const [j, Y] of ut.current)
|
|
660
|
+
Y.owner !== "global" && Y.owner !== re && (ut.current.delete(j), m = !0);
|
|
661
|
+
m && Ge();
|
|
662
|
+
const M = new Set(v.map((j) => j.key));
|
|
663
|
+
ue((j) => {
|
|
664
|
+
const Y = Object.keys(j).filter((ve) => !M.has(ve));
|
|
665
|
+
if (!Y.length) return j;
|
|
666
|
+
const fe = { ...j };
|
|
667
|
+
return Y.forEach((ve) => delete fe[ve]), fe;
|
|
482
668
|
});
|
|
483
|
-
for (const
|
|
484
|
-
}, [
|
|
485
|
-
if (
|
|
486
|
-
if (
|
|
487
|
-
const
|
|
488
|
-
|
|
669
|
+
for (const j of $.current.keys()) M.has(j) || $.current.delete(j);
|
|
670
|
+
}, [re, v, Ge]), U(() => {
|
|
671
|
+
if (oe.current?.key !== re) {
|
|
672
|
+
if (oe.current) {
|
|
673
|
+
const m = { from: oe.current, to: ne, stack: v };
|
|
674
|
+
c("onBlur", { route: oe.current, ...m }), c("onNavigate", m), c("onRouteChange", m);
|
|
489
675
|
}
|
|
490
|
-
|
|
676
|
+
c("onFocus", { route: ne, stack: v }), oe.current = ne;
|
|
491
677
|
}
|
|
492
|
-
}, [
|
|
493
|
-
|
|
494
|
-
for (const
|
|
495
|
-
|
|
496
|
-
}, []),
|
|
497
|
-
|
|
678
|
+
}, [ne, re, v, c]), U(() => () => {
|
|
679
|
+
ut.current.clear(), $.current.clear();
|
|
680
|
+
for (const m of G.current.values()) m.resolve({ status: "dismissed" });
|
|
681
|
+
G.current.clear();
|
|
682
|
+
}, []), U(() => {
|
|
683
|
+
k.current || (k.current = !0, l?.({ route: ne, stack: v }));
|
|
498
684
|
}, []);
|
|
499
|
-
const
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
685
|
+
const Ct = $t(v, Ee, s.maxCachedScreens, C, b?.());
|
|
686
|
+
Ae(() => {
|
|
687
|
+
F((m) => hn(v, Ct, m));
|
|
688
|
+
}, [v, Ct]);
|
|
689
|
+
const Et = Q(() => ({ ...Ee[ne.name], ...ne.options ?? {} }), [Ee, ne.name, ne.options]), ln = e.refs.header;
|
|
690
|
+
return /* @__PURE__ */ p(yt.Provider, { value: ln.current, children: /* @__PURE__ */ p(Tt.Provider, { value: q, children: /* @__PURE__ */ p(Vt.Provider, { value: D.current, children: /* @__PURE__ */ p(Ut.Provider, { value: E.current, children: /* @__PURE__ */ p(_t.Provider, { value: dt, children: /* @__PURE__ */ p(vt.Provider, { value: qe, children: /* @__PURE__ */ p(bt.Provider, { value: z.current, children: /* @__PURE__ */ p(Ue.Provider, { value: Ze, children: /* @__PURE__ */ be(Xt, { store: e.stores.layout, screenOptions: Et.modalOptions, dialogRef: X, requestClose: Le, exiting: h, children: [
|
|
691
|
+
/* @__PURE__ */ p(Jt, { store: e.stores.layout, screen: Et, route: ne, navigation: dt, requestClose: Le, translate: o, canGoBack: v.length > 1 }),
|
|
692
|
+
/* @__PURE__ */ p("main", { ref: B, className: "pmn-main", children: Ct.map((m) => /* @__PURE__ */ p(
|
|
693
|
+
Kn,
|
|
504
694
|
{
|
|
505
|
-
route:
|
|
506
|
-
screen:
|
|
507
|
-
navigation:
|
|
508
|
-
focused:
|
|
509
|
-
resultEvent:
|
|
510
|
-
bodyClassName:
|
|
511
|
-
setFooter:
|
|
512
|
-
loadingApi:
|
|
513
|
-
loadingStore:
|
|
695
|
+
route: m,
|
|
696
|
+
screen: Ee[m.name],
|
|
697
|
+
navigation: dt,
|
|
698
|
+
focused: m.key === re,
|
|
699
|
+
resultEvent: Z[m.key] ?? null,
|
|
700
|
+
bodyClassName: s.bodyClassName,
|
|
701
|
+
setFooter: qt,
|
|
702
|
+
loadingApi: Ze,
|
|
703
|
+
loadingStore: T.current,
|
|
514
704
|
notifyError: u,
|
|
515
|
-
registerDirtyGuard:
|
|
516
|
-
pageMotion:
|
|
517
|
-
lazyFallback:
|
|
705
|
+
registerDirtyGuard: g,
|
|
706
|
+
pageMotion: m.key === re ? Ne : null,
|
|
707
|
+
lazyFallback: s.lazyFallback
|
|
518
708
|
},
|
|
519
|
-
|
|
709
|
+
m.key
|
|
520
710
|
)) }),
|
|
521
|
-
/* @__PURE__ */
|
|
522
|
-
|
|
711
|
+
/* @__PURE__ */ p(
|
|
712
|
+
Dn,
|
|
523
713
|
{
|
|
524
|
-
store:
|
|
525
|
-
routeKey:
|
|
526
|
-
screen:
|
|
527
|
-
|
|
528
|
-
route:
|
|
529
|
-
navigation:
|
|
530
|
-
requestClose:
|
|
531
|
-
translate:
|
|
714
|
+
store: E.current,
|
|
715
|
+
routeKey: re,
|
|
716
|
+
screen: Et,
|
|
717
|
+
layoutStore: e.stores.layout,
|
|
718
|
+
route: ne,
|
|
719
|
+
navigation: dt,
|
|
720
|
+
requestClose: Le,
|
|
721
|
+
translate: o,
|
|
532
722
|
onError: u,
|
|
533
|
-
loadingApi:
|
|
723
|
+
loadingApi: Ze
|
|
534
724
|
},
|
|
535
|
-
|
|
725
|
+
re
|
|
536
726
|
),
|
|
537
|
-
/* @__PURE__ */
|
|
538
|
-
/* @__PURE__ */
|
|
539
|
-
|
|
540
|
-
/* @__PURE__ */
|
|
541
|
-
/* @__PURE__ */
|
|
727
|
+
/* @__PURE__ */ p($n, { store: T.current, translate: o }),
|
|
728
|
+
/* @__PURE__ */ p(In, { store: D.current, dismiss: N }),
|
|
729
|
+
i && /* @__PURE__ */ be("div", { className: "pmn-error", role: "alert", children: [
|
|
730
|
+
/* @__PURE__ */ p("span", { children: i.message || String(i) }),
|
|
731
|
+
/* @__PURE__ */ p("button", { type: "button", onClick: d, "aria-label": "Dismiss error", children: "×" })
|
|
542
732
|
] })
|
|
543
|
-
] }) }) }) }) }) }) }) });
|
|
544
|
-
}
|
|
545
|
-
const
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
return
|
|
554
|
-
}
|
|
555
|
-
function
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
733
|
+
] }) }) }) }) }) }) }) }) });
|
|
734
|
+
}
|
|
735
|
+
const Or = (e) => e, Pr = (e) => ({ definitionLoader: e }), pt = /* @__PURE__ */ new WeakMap();
|
|
736
|
+
function gt(e) {
|
|
737
|
+
if (!pt.has(e)) {
|
|
738
|
+
const t = Promise.resolve().then(e).catch((n) => {
|
|
739
|
+
throw pt.delete(e), n;
|
|
740
|
+
});
|
|
741
|
+
pt.set(e, t);
|
|
742
|
+
}
|
|
743
|
+
return pt.get(e);
|
|
744
|
+
}
|
|
745
|
+
async function an(e, t) {
|
|
746
|
+
let n = typeof e == "string" ? t && Object.hasOwn(t, e) ? t[e] : void 0 : e;
|
|
747
|
+
if (n?.definitionLoader) {
|
|
748
|
+
const r = await gt(n.definitionLoader);
|
|
749
|
+
n = r.default ?? r;
|
|
750
|
+
}
|
|
751
|
+
if (!n || !(n.component || n.loader || n.screens)) throw new Error(`[react-modal-navigation] Unknown or invalid modal: ${typeof e == "string" ? e : "inline"}`);
|
|
752
|
+
return n;
|
|
753
|
+
}
|
|
754
|
+
async function Wn(e, t, n) {
|
|
755
|
+
const r = await an(e, t), a = (Array.isArray(n) ? n : [n ?? r.initialRoute ?? Object.keys(r.screens ?? {})[0]]).map((l) => r.screens ? Object.hasOwn(r.screens, l) ? r.screens[l] : null : r);
|
|
756
|
+
if (a.some((l) => !l)) throw new Error("[react-modal-navigation] Unknown preload screen");
|
|
757
|
+
return await Promise.all(a.map((l) => l.loader ? gt(l.loader) : void 0)), r;
|
|
758
|
+
}
|
|
759
|
+
function Gn(e) {
|
|
760
|
+
return function(n) {
|
|
761
|
+
const [r, o] = xe(() => Se.lazy(() => gt(e)));
|
|
762
|
+
return /* @__PURE__ */ p(Nt, { route: n.route, onRetry: () => o(() => Se.lazy(() => gt(e))), children: /* @__PURE__ */ p(r, { ...n }) });
|
|
763
|
+
};
|
|
764
|
+
}
|
|
765
|
+
function _n(e, { limit: t = 100 } = {}) {
|
|
766
|
+
const n = Number.isFinite(t) ? Math.max(1, Math.min(1e3, Math.floor(t))) : 100, r = je({ active: null, queueSize: 0, events: [] });
|
|
767
|
+
let o, a = 0, l = !1, f = [];
|
|
768
|
+
const u = (g, b) => {
|
|
769
|
+
if (l) return;
|
|
770
|
+
const x = r.getSnapshot(), h = e.hostStore.getSnapshot().active, s = h?.runtime.alive.current ? h : null, v = s?.runtime.stores.navigation.getSnapshot(), I = s?.runtime.stores.loading.getSnapshot();
|
|
771
|
+
let z = s ? { id: s.id, name: s.name, routes: v.stack.map(({ key: L, name: A }) => ({ key: L, name: A })), focusedKey: v.currentRoute?.key, loadingCount: I.count, taskCount: s.runtime.tasks.count() } : null;
|
|
772
|
+
const T = g ? [...x.events, { sequence: ++a, time: Date.now(), type: g, id: b }].slice(-n) : x.events, E = x.active;
|
|
773
|
+
z && E && z.id === E.id && z.name === E.name && z.focusedKey === E.focusedKey && z.loadingCount === E.loadingCount && z.taskCount === E.taskCount && z.routes.length === E.routes.length && z.routes.every((L, A) => L.key === E.routes[A].key && L.name === E.routes[A].name) && (z = E);
|
|
774
|
+
const D = e.statusStore.getSnapshot().queueSize;
|
|
775
|
+
z === E && D === x.queueSize && T === x.events || r.publish({ active: z, queueSize: D, events: T });
|
|
776
|
+
}, i = () => {
|
|
777
|
+
const g = e.hostStore.getSnapshot().active?.runtime;
|
|
778
|
+
g !== o && (f.forEach((b) => b()), o = g, f = g ? ["ready", "destroy", "change", "routeChange", "routeRemove", "routeBlur", "routeFocus"].map((b) => g.events.on(b, (x) => u(b === "change" ? `store.${x.store}` : `instance.${b}`, x.id))) : []), u();
|
|
779
|
+
}, d = [e.hostStore.subscribe(i), e.statusStore.subscribe(() => u()), ...["open", "close", "queueChange"].map((g) => e.commands.on(g, (b) => u(`manager.${g}`, b.id)))];
|
|
780
|
+
return i(), {
|
|
781
|
+
getSnapshot: r.getSnapshot,
|
|
782
|
+
subscribe: r.subscribe,
|
|
783
|
+
refresh: () => u(),
|
|
784
|
+
clear() {
|
|
785
|
+
!l && r.getSnapshot().events.length && r.publish({ ...r.getSnapshot(), events: [] });
|
|
786
|
+
},
|
|
787
|
+
dispose() {
|
|
788
|
+
l || (l = !0, d.forEach((g) => g()), f.forEach((g) => g()), f = [], o = null, r.publish({ active: null, queueSize: 0, events: [] }), r.destroy());
|
|
789
|
+
}
|
|
790
|
+
};
|
|
791
|
+
}
|
|
792
|
+
function sn() {
|
|
793
|
+
const e = /* @__PURE__ */ new Map();
|
|
794
|
+
let t = !1;
|
|
795
|
+
const n = (r, o) => {
|
|
796
|
+
const a = e.get(r);
|
|
797
|
+
a?.delete(o), a?.size || e.delete(r);
|
|
798
|
+
};
|
|
799
|
+
return {
|
|
800
|
+
on(r, o) {
|
|
801
|
+
if (t) return () => {
|
|
802
|
+
};
|
|
803
|
+
const a = e.get(r) ?? /* @__PURE__ */ new Set();
|
|
804
|
+
return e.set(r, a), a.add(o), () => n(r, o);
|
|
805
|
+
},
|
|
806
|
+
off: n,
|
|
807
|
+
emit(r, o) {
|
|
808
|
+
if (!t) {
|
|
809
|
+
for (const a of [...e.get(r) ?? []])
|
|
810
|
+
if (!(t || !e.get(r)?.has(a)))
|
|
811
|
+
try {
|
|
812
|
+
Promise.resolve(a(o)).catch((l) => console.error(l));
|
|
813
|
+
} catch (l) {
|
|
814
|
+
console.error(l);
|
|
815
|
+
}
|
|
566
816
|
}
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
popTo: E,
|
|
576
|
-
setParams: (b) => (P((C) => ({ ...C, params: { ...C.params, ...typeof b == "function" ? b(C.params) : b } })), !0),
|
|
577
|
-
setOptions: (b) => (P((C) => ({ ...C, options: { ...C.options, ...b } })), !0),
|
|
578
|
-
close: J,
|
|
579
|
-
setLoading: j,
|
|
580
|
-
canGoBack: !1,
|
|
581
|
-
stack: [a],
|
|
582
|
-
currentRoute: a
|
|
583
|
-
}), [J, a, j, E]), q = l(_);
|
|
584
|
-
q.current = _;
|
|
585
|
-
const re = K(() => ({
|
|
586
|
-
navigate: (...b) => q.current.navigate(...b),
|
|
587
|
-
navigateAsync: (...b) => q.current.navigateAsync(...b),
|
|
588
|
-
replace: (...b) => q.current.replace(...b),
|
|
589
|
-
reset: (...b) => q.current.reset(...b),
|
|
590
|
-
goBack: (...b) => q.current.goBack(...b),
|
|
591
|
-
popToTop: (...b) => q.current.popToTop(...b),
|
|
592
|
-
popTo: (...b) => q.current.popTo(...b),
|
|
593
|
-
setParams: (...b) => q.current.setParams(...b),
|
|
594
|
-
setOptions: (...b) => q.current.setOptions(...b),
|
|
595
|
-
close: (...b) => q.current.close(...b),
|
|
596
|
-
setLoading: (...b) => q.current.setLoading(...b)
|
|
597
|
-
}), []), X = K(() => ({
|
|
598
|
-
setLoading: (b, C) => v.setScreenLoading("single", b, C),
|
|
599
|
-
showLoading: (b) => v.begin("single", b),
|
|
600
|
-
hideLoading: (b) => v.end("single", b)
|
|
601
|
-
}), [v]), ge = K(() => ({ isFocused: !0, resultEvent: null, routeKey: "single", setFooter: U }), [U]), V = K(() => ({ routeKey: "single", registerDirtyGuard: k }), [k]);
|
|
602
|
-
Q(() => {
|
|
603
|
-
x.current.publish({ canGoBack: !1, stack: [a], currentRoute: a });
|
|
604
|
-
}, [a]), Q(() => (L.current = !0, f?.({ setLoading: j }), p?.({ route: N.current, stack: [N.current] }), () => {
|
|
605
|
-
L.current = !1;
|
|
606
|
-
}), []);
|
|
607
|
-
const le = { ...D, ...a.options }, ye = D.component;
|
|
608
|
-
return /* @__PURE__ */ s(rn.Provider, { value: O, children: /* @__PURE__ */ s(wn.Provider, { value: H.current, children: /* @__PURE__ */ s(xn.Provider, { value: B.current, children: /* @__PURE__ */ s(vn.Provider, { value: _, children: /* @__PURE__ */ s(_e.Provider, { value: re, children: /* @__PURE__ */ s(We.Provider, { value: x.current, children: /* @__PURE__ */ s(Me.Provider, { value: v, children: /* @__PURE__ */ ce(En, { dialogRef: G, options: t, requestClose: J, exiting: d, children: [
|
|
609
|
-
/* @__PURE__ */ s(Rn, { options: t, screen: le, route: a, navigation: _, requestClose: J, translate: i, canGoBack: !1 }),
|
|
610
|
-
/* @__PURE__ */ s("main", { className: "pmn-main", children: /* @__PURE__ */ s(on.Provider, { value: a, children: /* @__PURE__ */ s(tn.Provider, { value: V, children: /* @__PURE__ */ s(je.Provider, { value: ge, children: /* @__PURE__ */ s(Me.Provider, { value: X, children: /* @__PURE__ */ s(Ue.Provider, { value: $.current, children: /* @__PURE__ */ s("div", { className: `pmn-body ${t.bodyClassName ?? ""}`, "data-modal-route-key": "single", tabIndex: -1, children: /* @__PURE__ */ s(Mn, { route: a, onError: u, children: /* @__PURE__ */ s(bn, { fallback: t.lazyFallback ?? /* @__PURE__ */ s("div", { className: "pmn-lazy-loading", role: "status", "aria-live": "polite", children: "加载中..." }), children: /* @__PURE__ */ s(ye, { route: a, navigation: _ }) }) }) }) }) }) }) }) }) }),
|
|
611
|
-
/* @__PURE__ */ s(Vn, { store: B.current, route: a, screen: le, options: t, navigation: _, requestClose: J, translate: i, onError: u, loadingApi: v }),
|
|
612
|
-
/* @__PURE__ */ s(Zn, { store: $.current, translate: i }),
|
|
613
|
-
/* @__PURE__ */ s(Qn, { store: H.current, dismiss: F }),
|
|
614
|
-
y && /* @__PURE__ */ ce("div", { className: "pmn-error", role: "alert", children: [
|
|
615
|
-
/* @__PURE__ */ s("span", { children: y.message || String(y) }),
|
|
616
|
-
/* @__PURE__ */ s("button", { type: "button", onClick: M, children: "×" })
|
|
617
|
-
] })
|
|
618
|
-
] }) }) }) }) }) }) }) });
|
|
817
|
+
},
|
|
818
|
+
clear() {
|
|
819
|
+
e.clear();
|
|
820
|
+
},
|
|
821
|
+
destroy() {
|
|
822
|
+
t = !0, e.clear();
|
|
823
|
+
}
|
|
824
|
+
};
|
|
619
825
|
}
|
|
620
|
-
const Xn = ".pmn-overlay,.pmn-dialog,.pmn-dialog *{box-sizing:border-box}.pmn-overlay{position:fixed;inset:0;z-index:1000;display:flex;overscroll-behavior:none;background:#00000073}.pmn-place-right{justify-content:flex-end;align-items:stretch}.pmn-place-left{justify-content:flex-start;align-items:stretch}.pmn-place-center{justify-content:center;align-items:center}.pmn-place-top{justify-content:center;align-items:flex-start}.pmn-place-bottom{justify-content:center;align-items:flex-end}.pmn-dialog{--pmn-surface:#fff;--pmn-body:#fff;--pmn-text:#0f172a;--pmn-muted:#475569;--pmn-border:#e2e8f0;--pmn-hover:#f1f5f9;--pmn-overlay-card:rgba(255,255,255,.92);color-scheme:light;position:relative;display:flex;flex-direction:column;min-height:0;width:100%;max-width:min(calc(100vw - var(--pmn-gap)*2),var(--pmn-max-width, var(--pmn-width)));max-height:min(calc(100dvh - var(--pmn-gap)*2),var(--pmn-max-height, 100dvh));height:var(--pmn-height, 100%);overflow:hidden;outline:none;box-shadow:0 25px 50px -12px #00000040;background:var(--pmn-surface);color:var(--pmn-text)}.pmn-place-left .pmn-dialog,.pmn-place-right .pmn-dialog{height:calc(100dvh - var(--pmn-gap)*2);max-height:calc(100dvh - var(--pmn-gap)*2)}.pmn-place-center .pmn-dialog{height:var(--pmn-height, auto);min-height:150px}.pmn-place-top .pmn-dialog,.pmn-place-bottom .pmn-dialog{height:var(--pmn-height, auto);min-height:0}.pmn-dialog[data-modal-theme=dark]{--pmn-surface:#334155;--pmn-body:#334155;--pmn-text:#f1f5f9;--pmn-muted:#cbd5e1;--pmn-border:#475569;--pmn-hover:#1e293b;--pmn-overlay-card:rgba(51,65,85,.94);color-scheme:dark}.pmn-main{min-height:0;flex:1;overflow:hidden;display:flex;flex-direction:column;background:transparent}.pmn-body{height:100%;min-height:0;overflow-y:auto;overscroll-behavior:contain;padding:16px;flex:1}.pmn-body[hidden]{display:none!important}.pmn-header{display:flex;flex-shrink:0;height:64px;align-items:center;gap:12px;padding:0 20px;background:transparent}.pmn-header h2{font-size:18px;font-weight:600;min-width:0;flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;margin:0}.pmn-header-spacer{flex:1}.pmn-border-bottom{border-bottom:1px solid var(--pmn-border)}.pmn-icon-button{display:inline-flex;align-items:center;justify-content:center;padding:8px;border:0;background:transparent;color:inherit;border-radius:8px;cursor:pointer}.pmn-icon-button:hover{background:var(--pmn-hover)}.pmn-footer{display:flex;flex-shrink:0;align-items:center;justify-content:flex-end;gap:12px;padding:16px 20px;background:transparent}.pmn-border-top{border-top:1px solid var(--pmn-border)}.pmn-button{padding:8px 16px;border-radius:8px;font-size:14px;font-weight:500;cursor:pointer}.pmn-button:disabled{opacity:.5;cursor:not-allowed}.pmn-button-secondary{border:1px solid var(--pmn-border);background:transparent;color:var(--pmn-text)}.pmn-button-secondary:hover:not(:disabled){background:var(--pmn-hover)}.pmn-button-primary{border:1px solid #2563eb;background:#2563eb;color:#fff}.pmn-button-primary:hover:not(:disabled){background:#1d4ed8}.pmn-loading-overlay{position:absolute;inset:0;z-index:50;display:flex;align-items:center;justify-content:center;background:#ffffffb8;backdrop-filter:blur(2px);-webkit-backdrop-filter:blur(2px);cursor:progress}.pmn-dialog[data-modal-theme=dark] .pmn-loading-overlay{background:#0f172ab8}.pmn-loading-content{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:14px;max-width:85%;text-align:center;color:var(--pmn-text);pointer-events:none}.pmn-loading-text{font-size:14px;font-weight:500;line-height:1.5;overflow-wrap:anywhere}.pmn-spinner{width:38px;height:38px;border:3px solid rgba(37,99,235,.2);border-top-color:#2563eb;border-radius:50%;animation:pmn-spin .8s linear infinite}@keyframes pmn-spin{to{transform:rotate(360deg)}}@media(prefers-reduced-motion:reduce){.pmn-spinner{animation-duration:1.8s}}.pmn-error{position:absolute;z-index:60;bottom:8px;left:12px;right:12px;display:flex;justify-content:space-between;gap:12px;padding:12px;border:1px solid #fca5a5;border-radius:8px;background:#fef2f2;color:#991b1b;font-size:13px}.pmn-error button{border:0;background:transparent;font-size:20px;cursor:pointer;color:inherit}.pmn-dialog input:not([type=checkbox]):not([type=radio]),.pmn-dialog textarea,.pmn-dialog select{color:var(--pmn-text);border-color:var(--pmn-border)}.pmn-error-screen{padding:24px;color:var(--pmn-text)}.pmn-error-screen p{color:#dc2626;overflow-wrap:anywhere}@media(max-width:640px){.pmn-overlay.pmn-mobile-fullscreen{padding:0!important}.pmn-mobile-fullscreen .pmn-dialog{max-width:100%;width:100%;height:100dvh;max-height:100dvh;border-radius:0!important}}@media(prefers-reduced-motion:reduce){.pmn-spinner{animation-duration:2s}}@keyframes pmn-fade-in{0%{opacity:0}to{opacity:1}}@keyframes pmn-fade-out{0%{opacity:1}to{opacity:0}}@keyframes pmn-scale-in{0%{opacity:0;transform:translateY(10px) scale(.97)}to{opacity:1;transform:none}}@keyframes pmn-scale-out{0%{opacity:1;transform:none}to{opacity:0;transform:translateY(10px) scale(.97)}}@keyframes pmn-right-in{0%{transform:translate(105%)}to{transform:none}}@keyframes pmn-right-out{0%{transform:none}to{transform:translate(105%)}}@keyframes pmn-left-in{0%{transform:translate(-105%)}to{transform:none}}@keyframes pmn-left-out{0%{transform:none}to{transform:translate(-105%)}}@keyframes pmn-top-in{0%{transform:translateY(-105%)}to{transform:none}}@keyframes pmn-top-out{0%{transform:none}to{transform:translateY(-105%)}}@keyframes pmn-bottom-in{0%{transform:translateY(105%)}to{transform:none}}@keyframes pmn-bottom-out{0%{transform:none}to{transform:translateY(105%)}}.pmn-entering{animation:pmn-fade-in var(--pmn-animation-duration) ease-out both}.pmn-exiting{animation:pmn-fade-out var(--pmn-animation-duration) ease-in both;pointer-events:none}.pmn-entering .pmn-dialog{animation:pmn-scale-in var(--pmn-animation-duration) cubic-bezier(.2,.8,.2,1) both}.pmn-exiting .pmn-dialog{animation:pmn-scale-out var(--pmn-animation-duration) ease-in both}.pmn-entering.pmn-place-right .pmn-dialog{animation-name:pmn-right-in}.pmn-exiting.pmn-place-right .pmn-dialog{animation-name:pmn-right-out}.pmn-entering.pmn-place-left .pmn-dialog{animation-name:pmn-left-in}.pmn-exiting.pmn-place-left .pmn-dialog{animation-name:pmn-left-out}.pmn-entering.pmn-place-top .pmn-dialog{animation-name:pmn-top-in}.pmn-exiting.pmn-place-top .pmn-dialog{animation-name:pmn-top-out}.pmn-entering.pmn-place-bottom .pmn-dialog{animation-name:pmn-bottom-in}.pmn-exiting.pmn-place-bottom .pmn-dialog{animation-name:pmn-bottom-out}.pmn-no-animation,.pmn-no-animation .pmn-dialog{animation:none!important}@media(prefers-reduced-motion:reduce){.pmn-entering,.pmn-exiting,.pmn-entering .pmn-dialog,.pmn-exiting .pmn-dialog{animation:none!important}}.pmn-toast-region{position:absolute;top:56px;left:12px;right:12px;z-index:80;display:flex;flex-direction:column;align-items:center;gap:8px;pointer-events:none;max-height:calc(100% - 72px);overflow:hidden}.pmn-toast{pointer-events:auto;display:flex;align-items:flex-start;gap:10px;width:max-content;max-width:100%;min-width:min(260px,100%);padding:11px 13px;border:1px solid var(--pmn-border);border-radius:9px;background:var(--pmn-surface);color:var(--pmn-text);box-shadow:0 5px 18px #0000001a;font-size:13px;line-height:1.5;overflow-wrap:anywhere}.pmn-toast-symbol{flex:0 0 20px;display:grid;place-items:center;width:20px;height:20px;border-radius:50%;font-size:13px;font-weight:700;background:var(--pmn-hover);color:var(--pmn-muted)}.pmn-toast-success .pmn-toast-symbol{background:#dcfce7;color:#15803d}.pmn-toast-error .pmn-toast-symbol{background:#fee2e2;color:#b91c1c}.pmn-toast-warning .pmn-toast-symbol{background:#fef3c7;color:#b45309}.pmn-toast-info .pmn-toast-symbol{background:#dbeafe;color:#1d4ed8}.pmn-toast-message{flex:1;min-width:0;white-space:pre-wrap}.pmn-toast-close{border:0;background:transparent;color:var(--pmn-muted);cursor:pointer;font-size:19px;line-height:18px;padding:0 1px}.pmn-toast-close:hover{color:var(--pmn-text)}.pmn-button-danger{background:#dc2626!important;color:#fff!important;border-color:#dc2626!important}@keyframes pmn-page-forward-in{0%{opacity:.18;transform:translate3d(var(--pmn-page-distance,96px),0,0) scale(.985)}to{opacity:1;transform:translateZ(0)}}@keyframes pmn-page-back-in{0%{opacity:.18;transform:translate3d(calc(-1 * var(--pmn-page-distance,96px)),0,0) scale(.985)}to{opacity:1;transform:translateZ(0)}}.pmn-page-enter{animation-duration:var(--pmn-page-duration,.36s);animation-timing-function:cubic-bezier(.2,.8,.2,1);animation-fill-mode:both;will-change:transform,opacity}.pmn-page-forward{animation-name:pmn-page-forward-in}.pmn-page-back{animation-name:pmn-page-back-in}@media(prefers-reduced-motion:reduce){.pmn-page-enter{animation:none!important;will-change:auto}}.pmn-main{position:relative;isolation:isolate}.pmn-page-exit{animation-duration:var(--pmn-page-duration,.36s);animation-timing-function:cubic-bezier(.22,1,.36,1);animation-fill-mode:forwards}@keyframes pmn-page-forward-out{to{opacity:.45;transform:translate3d(calc(-1 * var(--pmn-page-distance,96px)),0,0) scale(.985)}}@keyframes pmn-page-back-out{to{opacity:.45;transform:translate3d(var(--pmn-page-distance,96px),0,0) scale(.985)}}.pmn-page-exit-forward{animation-name:pmn-page-forward-out}.pmn-page-exit-back{animation-name:pmn-page-back-out}@media(prefers-reduced-motion:reduce){.pmn-page-exit{animation:none!important}}.pmn-main>.pmn-body{position:relative;width:100%;flex:1 0 100%;background:var(--pmn-body)}.pmn-page-forward,.pmn-page-back{z-index:2}@keyframes pmn-page-forward-in{0%{opacity:1;transform:translate3d(100%,0,0)}to{opacity:1;transform:translateZ(0)}}@keyframes pmn-page-back-in{0%{opacity:1;transform:translate3d(-100%,0,0)}to{opacity:1;transform:translateZ(0)}}@keyframes pmn-page-forward-out{to{opacity:1;transform:translate3d(-100%,0,0)}}@keyframes pmn-page-back-out{to{opacity:1;transform:translate3d(100%,0,0)}}.pmn-lazy-loading{display:flex;min-height:80px;align-items:center;justify-content:center;color:var(--pmn-muted);font-size:14px}.pmn-place-top .pmn-dialog{max-height:min(calc(100dvh - var(--pmn-top-offset, var(--pmn-gap)) - var(--pmn-gap)),var(--pmn-max-height,100dvh))}.pmn-dialog.pmn-has-custom-background{isolation:isolate;--pmn-body:transparent}.pmn-custom-background-layer{position:absolute;inset:0;z-index:0;pointer-events:none}.pmn-dialog.pmn-has-custom-background>:not(.pmn-custom-background-layer){position:relative;z-index:1}.pmn-dialog.pmn-has-custom-background .pmn-main>.pmn-body{background:transparent}", gn = "react-modal-navigation-styles", en = /* @__PURE__ */ new WeakMap();
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
826
|
+
function Un(e, t, n, r) {
|
|
827
|
+
const o = n.currentRoute, a = r.currentRoute;
|
|
828
|
+
if (o?.key === a?.key && n.stack.length === r.stack.length && n.stack.every((g, b) => g.key === r.stack[b].key)) return;
|
|
829
|
+
const l = new Set(n.stack.map((g) => g.key)), f = new Set(r.stack.map((g) => g.key)), u = n.stack.filter((g) => !f.has(g.key)), i = r.stack.filter((g) => !l.has(g.key));
|
|
830
|
+
if (o?.key === a?.key && !u.length && !i.length) return;
|
|
831
|
+
const d = { id: t, from: o, to: a, added: i, removed: u, stack: r.stack };
|
|
832
|
+
e.emit("routeChange", d), u.length && e.emit("routeRemove", d), o?.key !== a?.key && (o && e.emit("routeBlur", { ...d, route: o }), a && e.emit("routeFocus", { ...d, route: a }));
|
|
833
|
+
}
|
|
834
|
+
function Vn() {
|
|
835
|
+
const e = /* @__PURE__ */ new Map();
|
|
836
|
+
let t = !1;
|
|
837
|
+
const n = /* @__PURE__ */ new Set(), r = (a) => {
|
|
838
|
+
try {
|
|
839
|
+
Promise.resolve(a.cancel()).catch((l) => console.error(l));
|
|
840
|
+
} catch (l) {
|
|
841
|
+
console.error(l);
|
|
630
842
|
}
|
|
631
|
-
|
|
632
|
-
|
|
843
|
+
}, o = (a) => {
|
|
844
|
+
for (const [l, f] of [...e])
|
|
845
|
+
!a(f) || !e.delete(l) || r(l);
|
|
846
|
+
};
|
|
847
|
+
return {
|
|
848
|
+
register(a, l) {
|
|
849
|
+
return t || n.has(a) ? (r(l), () => {
|
|
850
|
+
}) : (e.set(l, a), () => e.delete(l));
|
|
851
|
+
},
|
|
852
|
+
cancelRoutes(a) {
|
|
853
|
+
const l = new Set(a), f = [...l].filter((u) => !n.has(u));
|
|
854
|
+
f.forEach((u) => n.add(u));
|
|
855
|
+
try {
|
|
856
|
+
o((u) => l.has(u));
|
|
857
|
+
} finally {
|
|
858
|
+
f.forEach((u) => n.delete(u));
|
|
859
|
+
}
|
|
860
|
+
},
|
|
861
|
+
destroy() {
|
|
862
|
+
t || (t = !0, o(() => !0));
|
|
863
|
+
},
|
|
864
|
+
count: () => e.size
|
|
865
|
+
};
|
|
866
|
+
}
|
|
867
|
+
function Yn(e, t) {
|
|
868
|
+
const n = e.config.singlePage || Object.keys(e.config.screens).length === 1, r = n ? [{ key: "single", name: e.screen, params: e.params ?? {}, options: {} }] : Yt(e.screen, e.params), o = je({});
|
|
869
|
+
o.set = (C, F) => {
|
|
870
|
+
const $ = o.getSnapshot();
|
|
871
|
+
if (F == null && !(C in $) || Object.is($[C], F)) return;
|
|
872
|
+
const X = { ...$ };
|
|
873
|
+
F == null ? delete X[C] : X[C] = F, o.publish(X);
|
|
874
|
+
};
|
|
875
|
+
const a = {
|
|
876
|
+
layout: je(t),
|
|
877
|
+
navigation: je({ canGoBack: !1, stack: r, currentRoute: r[0] }),
|
|
878
|
+
header: o,
|
|
879
|
+
footer: je({}),
|
|
880
|
+
loading: je({ visible: !1, text: null, count: 0 }),
|
|
881
|
+
toast: je([])
|
|
882
|
+
}, l = Object.fromEntries(Object.entries(a).map(([C, F]) => [C, { current: F }])), f = sn();
|
|
883
|
+
let u;
|
|
884
|
+
const i = () => {
|
|
885
|
+
const C = Object.entries(a);
|
|
886
|
+
return (!u || C.some(([F, $]) => !Object.is(u[F], $.getSnapshot()))) && (u = Object.freeze(Object.fromEntries(C.map(([F, $]) => [F, $.getSnapshot()])))), u;
|
|
887
|
+
}, d = (C, F, $ = Object.is, X) => {
|
|
888
|
+
if (!s.current) return () => {
|
|
633
889
|
};
|
|
634
|
-
|
|
890
|
+
const B = X === void 0 ? Object.values(a) : [...new Set(X)].map((J) => {
|
|
891
|
+
if (!Object.hasOwn(a, J)) throw new Error(`Unknown runtime store: ${J}`);
|
|
892
|
+
return a[J];
|
|
893
|
+
});
|
|
894
|
+
let te = C(i());
|
|
895
|
+
const V = () => {
|
|
896
|
+
try {
|
|
897
|
+
const J = C(i());
|
|
898
|
+
if ($(te, J)) return;
|
|
899
|
+
const O = te;
|
|
900
|
+
te = J, Promise.resolve(F(J, O)).catch((G) => console.error(G));
|
|
901
|
+
} catch (J) {
|
|
902
|
+
console.error(J);
|
|
903
|
+
}
|
|
904
|
+
}, oe = B.map((J) => J.subscribe(V));
|
|
905
|
+
return () => oe.forEach((J) => J());
|
|
906
|
+
}, g = Vn(), b = /* @__PURE__ */ new Map(), x = (C, F) => {
|
|
907
|
+
if (!s.current) return () => {
|
|
908
|
+
};
|
|
909
|
+
const $ = b.get(C) ?? /* @__PURE__ */ new Set();
|
|
910
|
+
return b.set(C, $), $.add(F), () => {
|
|
911
|
+
$.delete(F), !$.size && b.get(C) === $ && b.delete(C);
|
|
912
|
+
};
|
|
913
|
+
}, h = async (C, F) => {
|
|
914
|
+
for (const $ of C) for (const X of [...b.get($) ?? []]) {
|
|
915
|
+
if (!s.current) return !1;
|
|
916
|
+
if (b.get($)?.has(X) && await X(F) === !1)
|
|
917
|
+
return !1;
|
|
918
|
+
}
|
|
919
|
+
return s.current;
|
|
920
|
+
}, s = { current: !0 };
|
|
921
|
+
let v;
|
|
922
|
+
const I = new Promise((C) => {
|
|
923
|
+
v = C;
|
|
924
|
+
}), z = (C) => s.current ? (N.navigationCommands = C, v(!0), N.hasRegistered || (N.hasRegistered = !0, f.emit("ready", { id: e.id })), () => {
|
|
925
|
+
N.navigationCommands === C && (N.navigationCommands = null);
|
|
926
|
+
}) : () => {
|
|
927
|
+
}, T = /* @__PURE__ */ new Set(), E = { current: /* @__PURE__ */ new Map() }, D = { current: /* @__PURE__ */ new Map() }, L = { current: 0 }, A = (C) => s.current ? (T.add(C), () => T.delete(C)) : (C(), () => {
|
|
928
|
+
}), q = () => {
|
|
929
|
+
if (s.current) {
|
|
930
|
+
s.current = !1, v(!1), N.navigationCommands = null, g.destroy(), b.clear();
|
|
931
|
+
for (const C of T)
|
|
932
|
+
try {
|
|
933
|
+
C();
|
|
934
|
+
} catch (F) {
|
|
935
|
+
console.error(F);
|
|
936
|
+
}
|
|
937
|
+
T.clear(), E.current.clear();
|
|
938
|
+
for (const C of D.current.values()) C.resolve({ status: "dismissed" });
|
|
939
|
+
D.current.clear(), a.layout.destroy({}), a.navigation.destroy({ canGoBack: !1, stack: [], currentRoute: null }), a.header.destroy({}), a.footer.destroy({}), a.loading.destroy({ visible: !1, text: null, count: 0 }), a.toast.destroy([]), u = void 0, f.emit("destroy", { id: e.id }), f.destroy();
|
|
940
|
+
}
|
|
941
|
+
}, N = { events: f, getSnapshot: i, subscribeState: d, ready: I, registerNavigation: z, id: e.id, single: n, stores: a, refs: l, alive: s, loadingTasks: E, loadingSequence: L, pageRequests: D, tasks: g, registerRemovalGuard: x, canRemove: h, addCleanup: A, destroy: q }, Z = [];
|
|
942
|
+
let ue = !1;
|
|
943
|
+
for (const [C, F] of Object.entries(a)) {
|
|
944
|
+
let $ = F.getSnapshot();
|
|
945
|
+
F.subscribe(() => {
|
|
946
|
+
const X = F.getSnapshot(), B = $;
|
|
947
|
+
if ($ = X, Z.push({ key: C, old: B, next: X }), !ue) {
|
|
948
|
+
ue = !0;
|
|
949
|
+
try {
|
|
950
|
+
for (let te = 0; te < Z.length && s.current; te++) {
|
|
951
|
+
const { key: V, old: oe, next: J } = Z[te];
|
|
952
|
+
f.emit("change", { id: e.id, store: V, previous: oe, current: J }), V === "navigation" && s.current && Un(f, e.id, oe, J);
|
|
953
|
+
}
|
|
954
|
+
} finally {
|
|
955
|
+
Z.length = 0, ue = !1;
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
});
|
|
959
|
+
}
|
|
960
|
+
return N;
|
|
635
961
|
}
|
|
636
|
-
function
|
|
962
|
+
function nt(e, t, n) {
|
|
637
963
|
if (typeof e == "string") {
|
|
638
964
|
if (!e.trim()) throw new TypeError("[react-modal-navigation] modal name must not be empty");
|
|
639
|
-
return { name: e, params:
|
|
965
|
+
return { name: e, params: t ?? {}, options: n ?? {} };
|
|
640
966
|
}
|
|
641
967
|
if (e === null || typeof e != "object" || Array.isArray(e))
|
|
642
968
|
throw new TypeError("[react-modal-navigation] open expects a modal name or a configuration object");
|
|
643
|
-
|
|
644
|
-
|
|
969
|
+
if (e.component || e.loader || e.screens || e.definitionLoader) {
|
|
970
|
+
const { params: u, options: i, screen: d, ...g } = e;
|
|
971
|
+
return { name: g, params: t ?? u ?? {}, options: { ...i, ...n }, screen: d };
|
|
972
|
+
}
|
|
973
|
+
const { name: r, screen: o, params: a = {}, options: l = {}, ...f } = e;
|
|
974
|
+
if (typeof r != "string" || !r.trim())
|
|
645
975
|
throw new TypeError("[react-modal-navigation] open config requires a non-empty string name");
|
|
646
|
-
if (
|
|
976
|
+
if (l === null || typeof l != "object" || Array.isArray(l))
|
|
647
977
|
throw new TypeError("[react-modal-navigation] open config options must be an object");
|
|
648
|
-
if (
|
|
978
|
+
if (o !== void 0 && (typeof o != "string" || !o.trim()))
|
|
649
979
|
throw new TypeError("[react-modal-navigation] screen must be a non-empty string");
|
|
650
|
-
return { name:
|
|
980
|
+
return { name: r, ...o === void 0 ? {} : { screen: o }, params: a, options: { ...f, ...l } };
|
|
651
981
|
}
|
|
652
|
-
function
|
|
982
|
+
function Qn() {
|
|
653
983
|
const e = /* @__PURE__ */ new Map();
|
|
654
984
|
return {
|
|
655
|
-
wait(
|
|
656
|
-
return new Promise((
|
|
657
|
-
const
|
|
658
|
-
e.delete(
|
|
659
|
-
}, Math.max(0,
|
|
660
|
-
e.set(
|
|
985
|
+
wait(t) {
|
|
986
|
+
return t <= 0 ? Promise.resolve() : new Promise((n) => {
|
|
987
|
+
const r = setTimeout(() => {
|
|
988
|
+
e.delete(r), n();
|
|
989
|
+
}, Math.max(0, t));
|
|
990
|
+
e.set(r, n);
|
|
661
991
|
});
|
|
662
992
|
},
|
|
663
993
|
cancelAll() {
|
|
664
|
-
for (const [
|
|
665
|
-
clearTimeout(
|
|
994
|
+
for (const [t, n] of e)
|
|
995
|
+
clearTimeout(t), n();
|
|
666
996
|
e.clear();
|
|
667
997
|
},
|
|
668
998
|
pendingCount: () => e.size
|
|
669
999
|
};
|
|
670
1000
|
}
|
|
671
|
-
const
|
|
672
|
-
function
|
|
673
|
-
|
|
674
|
-
const
|
|
675
|
-
|
|
676
|
-
const
|
|
677
|
-
|
|
678
|
-
}
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
1001
|
+
const Zn = { placement: "right", showHeader: !0, showBackButton: !0, showCloseButton: !0, viewportGap: 5, borderRadius: 12, closeOnOverlay: !1, closeOnEsc: !0 };
|
|
1002
|
+
function Xn(e, t) {
|
|
1003
|
+
let n = e;
|
|
1004
|
+
const r = sn(), o = /* @__PURE__ */ new Set(), { confirmDiscard: a, onError: l } = n, f = je({ isOpen: !1, activeName: null, isFullscreen: !1, queueSize: 0, error: null }), u = je({ active: null, options: null, exiting: !1, error: null, translate: n.translate });
|
|
1005
|
+
let i = null;
|
|
1006
|
+
const d = (c) => {
|
|
1007
|
+
i = c, Te();
|
|
1008
|
+
};
|
|
1009
|
+
let g = null;
|
|
1010
|
+
const b = (c) => {
|
|
1011
|
+
g = c, Te();
|
|
1012
|
+
};
|
|
1013
|
+
let x = 0;
|
|
1014
|
+
const h = (c) => {
|
|
1015
|
+
x = c, Te();
|
|
1016
|
+
}, s = { current: null }, v = { current: /* @__PURE__ */ new Map() }, I = { current: [] }, z = { current: null }, T = { current: null }, E = { current: 0 }, D = { current: null }, L = { current: !1 }, A = { current: 0 }, q = { current: null }, N = { current: /* @__PURE__ */ new Map() };
|
|
1017
|
+
let Z = !1;
|
|
1018
|
+
const ue = (c) => {
|
|
1019
|
+
Z = c, Te();
|
|
1020
|
+
}, C = { current: a }, F = (c, y) => {
|
|
1021
|
+
const R = N.current.get(c) ?? /* @__PURE__ */ new Set();
|
|
1022
|
+
return N.current.set(c, R), R.add(y), () => {
|
|
1023
|
+
R.delete(y), !R.size && N.current.get(c) === R && N.current.delete(c);
|
|
1024
|
+
};
|
|
1025
|
+
}, $ = async (c, y) => {
|
|
1026
|
+
for (const R of c) for (const w of [...N.current.get(R) ?? []]) {
|
|
1027
|
+
if (!N.current.get(R)?.has(w) || !w.dirty) continue;
|
|
1028
|
+
if ((w.onBeforeDiscard ? await w.onBeforeDiscard(y) : C.current ? await C.current(y) : typeof window < "u" && typeof window.confirm == "function" ? window.confirm(w.message || "有未保存的修改,确定放弃吗?") : !1) === !1) return !1;
|
|
689
1029
|
}
|
|
690
1030
|
return !0;
|
|
691
|
-
}, []),
|
|
692
|
-
|
|
693
|
-
const
|
|
694
|
-
|
|
695
|
-
const X = w((c, h) => {
|
|
696
|
-
E.current && k(c);
|
|
1031
|
+
}, X = (c) => $([...N.current.keys()], c), B = { current: !0 }, te = { current: null };
|
|
1032
|
+
te.current || (te.current = Qn());
|
|
1033
|
+
const V = { current: l }, oe = ((c, y) => {
|
|
1034
|
+
B.current && b(c);
|
|
697
1035
|
try {
|
|
698
|
-
|
|
699
|
-
} catch (
|
|
700
|
-
console.error("[react-modal-navigation] onError failed",
|
|
1036
|
+
V.current ? V.current(c, y) : console.error("[react-modal-navigation]", c);
|
|
1037
|
+
} catch (R) {
|
|
1038
|
+
console.error("[react-modal-navigation] onError failed", R);
|
|
701
1039
|
}
|
|
702
|
-
}
|
|
703
|
-
const
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
const
|
|
1040
|
+
}), J = ((c, y) => {
|
|
1041
|
+
const R = v.current.get(c);
|
|
1042
|
+
v.current.delete(c);
|
|
1043
|
+
for (const w of R ?? []) w(y);
|
|
1044
|
+
}), O = ((c) => ({ ...Zn, ...n.defaultOptions, ...n.theme !== void 0 ? { theme: n.theme } : {}, ...n.backgroundColor !== void 0 ? { backgroundColor: n.backgroundColor } : {}, ...c.config.modalOptions, ...c.overrides, runtimeLayout: c.runtimeLayout })), G = (async (c = "api", y, R = {}) => {
|
|
1045
|
+
const w = s.current;
|
|
1046
|
+
if (!w || D.current || L.current) return !1;
|
|
1047
|
+
const H = A.current;
|
|
1048
|
+
D.current = w.id, L.current = !0;
|
|
1049
|
+
const W = O(w), ae = { ...R, reason: c, result: y, name: w.name };
|
|
712
1050
|
try {
|
|
713
|
-
if (!await
|
|
714
|
-
|
|
715
|
-
const
|
|
716
|
-
if (await
|
|
717
|
-
|
|
1051
|
+
if (!await X(ae) || H !== A.current || s.current?.id !== w.id || !await w.runtime.canRemove(w.runtime.stores.navigation.getSnapshot().stack.map((pe) => pe.key), ae) || H !== A.current || s.current?.id !== w.id || await W.onBeforeClose?.(ae) === !1 || H !== A.current || s.current?.id !== w.id || !B.current) return !1;
|
|
1052
|
+
ue(!0);
|
|
1053
|
+
const me = W.animation === !1 || typeof window < "u" && window.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? 0 : Math.max(0, Number(W.animationDuration ?? 220) || 0);
|
|
1054
|
+
if (await te.current.wait(Math.min(me, 1e3)), !B.current || s.current?.id !== w.id) return !1;
|
|
1055
|
+
w.runtime.destroy(), s.current = null, q.current = null, Z = !1, d(null), N.current.clear();
|
|
1056
|
+
const ie = R.confirmed || y !== void 0 ? { status: "confirmed", value: y, reason: c } : { status: "dismissed", reason: c };
|
|
1057
|
+
J(w.id, ie), r.emit("close", { id: w.id, name: w.name, result: ie });
|
|
718
1058
|
try {
|
|
719
|
-
await
|
|
720
|
-
} catch (
|
|
721
|
-
|
|
1059
|
+
(R.confirmed || y !== void 0) && await W.onConfirmed?.(y), await W.onClose?.(ae), await W.onClosed?.(ae);
|
|
1060
|
+
} catch (pe) {
|
|
1061
|
+
H === A.current && oe(pe, { phase: "onClose", name: w.name });
|
|
722
1062
|
}
|
|
723
1063
|
return !0;
|
|
724
|
-
} catch (
|
|
725
|
-
return
|
|
1064
|
+
} catch (me) {
|
|
1065
|
+
return H === A.current && s.current?.id === w.id && oe(me, { phase: "onBeforeClose", name: w.name }), !1;
|
|
726
1066
|
} finally {
|
|
727
|
-
|
|
1067
|
+
D.current === w.id && (D.current = null), H === A.current && (L.current = !1), !s.current && B.current && queueMicrotask(() => T.current?.());
|
|
728
1068
|
}
|
|
729
|
-
}
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
const
|
|
733
|
-
if (!ne.screens?.[te]) throw new Error(`[react-modal-navigation] Unknown initial screen '${te}' in modal '${c}'`);
|
|
734
|
-
if (!E.current || B.current || x.current) return null;
|
|
735
|
-
B.current = !0;
|
|
736
|
-
const Be = $.current;
|
|
1069
|
+
}), ke = (async (c, y = {}, R = {}, w, H) => {
|
|
1070
|
+
if (!B.current || L.current || D.current) return null;
|
|
1071
|
+
L.current = !0;
|
|
1072
|
+
const W = A.current;
|
|
737
1073
|
try {
|
|
738
|
-
const
|
|
739
|
-
if (
|
|
740
|
-
|
|
1074
|
+
const ae = await an(c, n.registry);
|
|
1075
|
+
if (!B.current || W !== A.current) return null;
|
|
1076
|
+
const me = (he) => he.loader && !he.component ? { ...he, component: t(he.loader) } : he, ie = ae.screens ? { ...ae, screens: Object.fromEntries(Object.entries(ae.screens).map(([he, ze]) => [he, me(ze)])) } : me(ae);
|
|
1077
|
+
c = typeof c == "string" ? c : ae.name ?? "inline";
|
|
1078
|
+
const pe = ie?.component && !ie.screens ? { ...ie, singlePage: !0, initialRoute: "__single__", screens: { __single__: { component: ie.component, title: ie.title, ...ae.screenOptions ?? {} } } } : ie;
|
|
1079
|
+
if (!pe) throw new Error(`[react-modal-navigation] Unknown modal: ${c}`);
|
|
1080
|
+
const Re = H ?? pe.initialRoute ?? Object.keys(pe.screens ?? {})[0];
|
|
1081
|
+
if (!pe.screens || !Object.hasOwn(pe.screens, Re) || !pe.screens[Re]) throw new Error(`[react-modal-navigation] Unknown initial screen '${Re}' in modal '${c}'`);
|
|
1082
|
+
const S = s.current, le = R.instanceKey ?? pe.modalOptions?.instanceKey, Le = R.duplicateStrategy ?? pe.modalOptions?.duplicateStrategy;
|
|
1083
|
+
if (S && le != null && S.instanceKey === le) {
|
|
1084
|
+
if (Le === "ignore") return null;
|
|
1085
|
+
if (Le === "reuse") {
|
|
1086
|
+
if (w) {
|
|
1087
|
+
const he = v.current.get(S.id) ?? [];
|
|
1088
|
+
he.push(w), v.current.set(S.id, he);
|
|
1089
|
+
}
|
|
1090
|
+
return S.id;
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
if (S) {
|
|
1094
|
+
const he = O(S), ze = { reason: "replace", name: S.name, nextName: c };
|
|
741
1095
|
try {
|
|
742
|
-
if (!await
|
|
743
|
-
} catch (
|
|
744
|
-
return
|
|
1096
|
+
if (!await X(ze) || W !== A.current || s.current?.id !== S.id || !await S.runtime.canRemove(S.runtime.stores.navigation.getSnapshot().stack.map((Fe) => Fe.key), ze) || W !== A.current || s.current?.id !== S.id || await he.onBeforeClose?.(ze) === !1) return null;
|
|
1097
|
+
} catch (Fe) {
|
|
1098
|
+
return W === A.current && s.current?.id === S.id && oe(Fe, { phase: "onBeforeClose", name: S.name }), null;
|
|
745
1099
|
}
|
|
746
|
-
if (!
|
|
747
|
-
|
|
1100
|
+
if (!B.current || W !== A.current || s.current?.id !== S.id) return null;
|
|
1101
|
+
S.runtime.destroy(), s.current = null, q.current = null, d(null), N.current.clear();
|
|
1102
|
+
const qe = { status: "replaced", reason: "replace" };
|
|
1103
|
+
J(S.id, qe), r.emit("close", { id: S.id, name: S.name, result: qe });
|
|
748
1104
|
try {
|
|
749
|
-
await
|
|
750
|
-
} catch (
|
|
751
|
-
|
|
1105
|
+
await he.onClose?.(ze), await he.onClosed?.(ze);
|
|
1106
|
+
} catch (Fe) {
|
|
1107
|
+
W === A.current && oe(Fe, { phase: "onClose", name: S.name });
|
|
752
1108
|
}
|
|
753
|
-
if (!
|
|
1109
|
+
if (!B.current || W !== A.current) return null;
|
|
754
1110
|
}
|
|
755
|
-
const
|
|
756
|
-
return
|
|
1111
|
+
const ye = { id: ++E.current, name: c, screen: Re, params: y, config: pe, overrides: R, instanceKey: le };
|
|
1112
|
+
return ye.runtime = Yn(ye, O(ye)), ye.runtime.bindings = _e(ye.id), s.current = ye, q.current = null, w && v.current.set(ye.id, [w]), g = null, d(ye), r.emit("open", { id: ye.id, name: ye.name }), ye.id;
|
|
757
1113
|
} finally {
|
|
758
|
-
|
|
1114
|
+
W === A.current && (L.current = !1), !s.current && B.current && queueMicrotask(() => T.current?.());
|
|
759
1115
|
}
|
|
760
|
-
}
|
|
761
|
-
|
|
762
|
-
const
|
|
763
|
-
if (!
|
|
764
|
-
const c =
|
|
1116
|
+
});
|
|
1117
|
+
z.current = ke;
|
|
1118
|
+
const Ce = (async () => {
|
|
1119
|
+
if (!B.current || s.current || L.current || D.current) return;
|
|
1120
|
+
const c = I.current.shift();
|
|
765
1121
|
if (c) {
|
|
766
|
-
|
|
1122
|
+
o.add(c), h(I.current.length);
|
|
767
1123
|
try {
|
|
768
|
-
const
|
|
769
|
-
|
|
770
|
-
} catch (
|
|
771
|
-
c.reject?.(
|
|
1124
|
+
const y = await z.current(c.args.name, c.args.params, c.args.options, c.resolveResult, c.args.screen);
|
|
1125
|
+
y === null ? (c.resolveResult?.({ status: "dismissed", reason: "blocked" }), c.resolveId?.(null), queueMicrotask(() => T.current?.())) : c.resolveId?.(y);
|
|
1126
|
+
} catch (y) {
|
|
1127
|
+
c.reject?.(y), queueMicrotask(() => T.current?.());
|
|
1128
|
+
} finally {
|
|
1129
|
+
o.delete(c);
|
|
772
1130
|
}
|
|
773
1131
|
}
|
|
774
|
-
}
|
|
775
|
-
|
|
776
|
-
const
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
1132
|
+
});
|
|
1133
|
+
T.current = Ce;
|
|
1134
|
+
const K = ((c, y, R) => {
|
|
1135
|
+
if (!B.current) return Promise.resolve(null);
|
|
1136
|
+
const w = nt(c, y, R);
|
|
1137
|
+
return typeof w.name == "string" && !n.registry?.[w.name] ? Promise.reject(new Error(`[react-modal-navigation] Unknown modal: ${w.name}`)) : new Promise((H, W) => {
|
|
1138
|
+
I.current.push({ args: w, resolveId: H, reject: W }), h(I.current.length), queueMicrotask(() => T.current?.());
|
|
1139
|
+
});
|
|
1140
|
+
}), de = ((c, y, R) => {
|
|
1141
|
+
if (!B.current) return Promise.resolve({ status: "dismissed", reason: "unmount" });
|
|
1142
|
+
const w = nt(c, y, R);
|
|
1143
|
+
return typeof w.name == "string" && !n.registry?.[w.name] ? Promise.reject(new Error(`[react-modal-navigation] Unknown modal: ${w.name}`)) : new Promise((H, W) => {
|
|
1144
|
+
I.current.push({ args: w, resolveResult: H, reject: W }), h(I.current.length), queueMicrotask(() => T.current?.());
|
|
1145
|
+
});
|
|
1146
|
+
}), k = ((c) => {
|
|
787
1147
|
if (!c || typeof c != "object" || Array.isArray(c)) throw new TypeError("[react-modal-navigation] update expects an options object");
|
|
788
|
-
const
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
const
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
ne === null && ee({ status: "dismissed", reason: "blocked" });
|
|
806
|
-
}, Z);
|
|
1148
|
+
const y = s.current;
|
|
1149
|
+
return !y || L.current ? !1 : (Object.keys(c).every((R) => Object.is(O(y)[R], c[R])) || (y.overrides = { ...y.overrides, ...c }, y.runtimeLayout = { ...y.runtimeLayout, ...c }, Te()), !0);
|
|
1150
|
+
}), ce = ((c, y) => Wn(c, n.registry, y)), ne = ((c) => k({ fullscreen: !!c })), re = (() => ne(!(s.current && O(s.current).fullscreen))), Be = ((c = "queue-cleared") => {
|
|
1151
|
+
const y = I.current.splice(0);
|
|
1152
|
+
h(0);
|
|
1153
|
+
for (const R of y)
|
|
1154
|
+
R.resolveId?.(null), R.resolveResult?.({ status: "dismissed", reason: c });
|
|
1155
|
+
return y.length;
|
|
1156
|
+
}), st = ((c, y, R) => {
|
|
1157
|
+
const w = nt(c, y, R);
|
|
1158
|
+
return ke(w.name, w.params, w.options, void 0, w.screen);
|
|
1159
|
+
}), We = ((c, y, R) => {
|
|
1160
|
+
const w = nt(c, y, R);
|
|
1161
|
+
return new Promise((H, W) => {
|
|
1162
|
+
ke(w.name, w.params, w.options, H, w.screen).then((ae) => {
|
|
1163
|
+
ae === null && H({ status: "dismissed", reason: "blocked" });
|
|
1164
|
+
}, W);
|
|
807
1165
|
});
|
|
808
|
-
}
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
initialScreen: u.screen,
|
|
825
|
-
params: u.params,
|
|
826
|
-
options: le,
|
|
827
|
-
translate: g,
|
|
828
|
-
notifyError: X,
|
|
829
|
-
error: M,
|
|
830
|
-
clearError: () => k(null),
|
|
831
|
-
registerLoading: (c) => {
|
|
832
|
-
H.current = c;
|
|
833
|
-
},
|
|
834
|
-
registerDirtyGuard: F,
|
|
835
|
-
canNavigate: J,
|
|
836
|
-
exiting: v,
|
|
837
|
-
onRequestClose: b,
|
|
838
|
-
onOpened: (c) => {
|
|
839
|
-
try {
|
|
840
|
-
const h = ye.current?.onOpen?.(c);
|
|
841
|
-
Promise.resolve(h).catch((A) => X(A, { phase: "onOpen" }));
|
|
842
|
-
} catch (h) {
|
|
843
|
-
X(h, { phase: "onOpen" });
|
|
844
|
-
}
|
|
845
|
-
}
|
|
1166
|
+
}), it = (async (c, y, R) => {
|
|
1167
|
+
const w = nt(c, y, R);
|
|
1168
|
+
let H;
|
|
1169
|
+
const W = new Promise((S) => {
|
|
1170
|
+
H = S;
|
|
1171
|
+
}), ae = await ke(w.name, w.params, w.options, H, w.screen);
|
|
1172
|
+
ae === null && H({ status: "dismissed", reason: "blocked" });
|
|
1173
|
+
const me = () => ae !== null && s.current?.id === ae && s.current.runtime.alive.current, ie = () => me() ? s.current.runtime : null, pe = ie()?.ready.then((S) => S && me()) ?? Promise.resolve(!1), Re = (S, ...le) => ie()?.navigationCommands?.[S]?.(...le) ?? !1;
|
|
1174
|
+
return {
|
|
1175
|
+
id: ae,
|
|
1176
|
+
result: W,
|
|
1177
|
+
isActive: me,
|
|
1178
|
+
replaceOptions: (S) => {
|
|
1179
|
+
if (!me() || L.current) return !1;
|
|
1180
|
+
const le = s.current;
|
|
1181
|
+
return le.overrides = { ...S }, le.runtimeLayout = void 0, Te(), !0;
|
|
846
1182
|
},
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
1183
|
+
dispose: () => {
|
|
1184
|
+
if (!me()) return !1;
|
|
1185
|
+
const S = s.current;
|
|
1186
|
+
A.current++, te.current.cancelAll(), s.current = null, q.current = null, D.current = null, L.current = !1, Z = !1, N.current.clear(), S.runtime.destroy(), d(null);
|
|
1187
|
+
const le = { status: "dismissed", reason: "unmount" };
|
|
1188
|
+
return J(ae, le), r.emit("close", { id: ae, name: S.name, result: le }), queueMicrotask(() => T.current?.()), !0;
|
|
1189
|
+
},
|
|
1190
|
+
ready: pe,
|
|
1191
|
+
on: (S, le) => ie()?.events.on(S, le) ?? (() => {
|
|
1192
|
+
}),
|
|
1193
|
+
off: (S, le) => ie()?.events.off(S, le),
|
|
1194
|
+
getSnapshot: () => ie()?.getSnapshot() ?? null,
|
|
1195
|
+
subscribeState: (S, le, Le, ye) => ie()?.subscribeState(S, le, Le, ye) ?? (() => {
|
|
1196
|
+
}),
|
|
1197
|
+
getState: () => ie()?.stores.navigation.getSnapshot() ?? null,
|
|
1198
|
+
subscribe: (S) => ie()?.stores.navigation.subscribe(S) ?? (() => {
|
|
1199
|
+
}),
|
|
1200
|
+
clearCache: async (S) => !!await Re("clearCache", S),
|
|
1201
|
+
navigate: async (...S) => !!await Re("navigate", ...S),
|
|
1202
|
+
setParams: (S) => ie()?.navigationCommands ? (Re("setParams", S), !0) : !1,
|
|
1203
|
+
setLoading: (S, le) => ie()?.navigationCommands?.setLoading ? (Re("setLoading", S, le), !0) : !1,
|
|
1204
|
+
setOptions: (S) => me() && k(S),
|
|
1205
|
+
setFullscreen: (S) => me() && k({ fullscreen: !!S }),
|
|
1206
|
+
close: (S) => me() ? G("api", S) : Promise.resolve(!1),
|
|
1207
|
+
confirm: (S) => me() ? G("confirm", S, { confirmed: !0 }) : Promise.resolve(!1)
|
|
1208
|
+
};
|
|
1209
|
+
}), Qe = ((c) => G("api", c)), ct = ((c = "api") => G(c)), Ne = ((c) => G("confirm", c, { confirmed: !0 })), lt = ((c, y) => q.current?.setLoading(c, y)), Ze = () => b(null), Ge = /* @__PURE__ */ new Set(), De = { inspect: (c) => {
|
|
1210
|
+
const y = _n({ hostStore: u, statusStore: f, commands: De }, c), R = y.dispose;
|
|
1211
|
+
return y.dispose = () => {
|
|
1212
|
+
Ge.delete(y), R();
|
|
1213
|
+
}, Ge.add(y), B.current || y.dispose(), y;
|
|
1214
|
+
}, on: r.on, off: r.off, open: st, openInstance: it, openAsync: We, enqueue: K, enqueueAsync: de, update: k, setOptions: k, preload: ce, setFullscreen: ne, toggleFullscreen: re, clearQueue: Be, close: Qe, dismiss: ct, confirm: Ne, setLoading: lt, clearError: Ze }, Ee = (c, y) => Object.keys(c).length === Object.keys(y).length && Object.keys(c).every((R) => Object.is(c[R], y[R]));
|
|
1215
|
+
function Te() {
|
|
1216
|
+
const c = i ? O(i) : null, y = u.getSnapshot();
|
|
1217
|
+
i && !Ee(c, i.runtime.stores.layout.getSnapshot()) && i.runtime.stores.layout.publish(c);
|
|
1218
|
+
const R = i ? y.active === i ? y.options : c : null, w = { isOpen: !!i, activeName: i?.name ?? null, isFullscreen: !!c?.fullscreen, queueSize: x, error: g }, H = { active: i, options: R, exiting: Z, error: g, translate: n.translate }, W = f.getSnapshot();
|
|
1219
|
+
Ee(w, W) || f.publish(w), Ee(H, y) || u.publish(H), W.queueSize !== w.queueSize && r.emit("queueChange", { previous: W.queueSize, current: w.queueSize });
|
|
1220
|
+
}
|
|
1221
|
+
const _e = (c) => ({
|
|
1222
|
+
registerLoading: (y) => {
|
|
1223
|
+
s.current?.id === c && (q.current = y);
|
|
1224
|
+
},
|
|
1225
|
+
registerDirtyGuard: (y, R) => s.current?.id === c ? F(y, R) : () => {
|
|
1226
|
+
},
|
|
1227
|
+
getProtectedCacheKeys: () => s.current?.id === c ? new Set([...N.current].filter(([, y]) => [...y].some((R) => R.dirty)).map(([y]) => y)) : /* @__PURE__ */ new Set(),
|
|
1228
|
+
canNavigate: (y, R) => s.current?.id === c ? $(y, R) : Promise.resolve(!1),
|
|
1229
|
+
onRequestClose: (...y) => s.current?.id === c ? G(...y) : Promise.resolve(!1),
|
|
1230
|
+
onOpened: (y) => {
|
|
1231
|
+
if (s.current?.id !== c) return;
|
|
1232
|
+
const R = O(s.current), w = (H, W) => {
|
|
1233
|
+
s.current?.id === c && oe(H, { phase: W });
|
|
1234
|
+
};
|
|
1235
|
+
for (const H of ["onOpen", "onOpened"])
|
|
1236
|
+
try {
|
|
1237
|
+
Promise.resolve(R[H]?.(y)).catch((W) => w(W, H));
|
|
1238
|
+
} catch (W) {
|
|
1239
|
+
w(W, H);
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
});
|
|
1243
|
+
return { commands: De, statusStore: f, hostStore: u, bindInstance: _e, configure: (c) => {
|
|
1244
|
+
n = c, C.current = c.confirmDiscard, V.current = c.onError, Te();
|
|
1245
|
+
}, mount: () => {
|
|
1246
|
+
B.current = !0;
|
|
1247
|
+
}, destroy: () => {
|
|
1248
|
+
B.current = !1;
|
|
1249
|
+
for (const c of Ge) c.dispose();
|
|
1250
|
+
r.clear(), A.current += 1, te.current.cancelAll(), s.current?.runtime.destroy(), s.current = null, q.current = null, D.current = null, L.current = !1;
|
|
1251
|
+
for (const c of v.current.keys()) J(c, { status: "dismissed", reason: "unmount" });
|
|
1252
|
+
v.current.clear(), N.current.clear(), i = null, Z = !1, g = null;
|
|
1253
|
+
for (const c of o)
|
|
1254
|
+
c.resolveId?.(null), c.resolveResult?.({ status: "dismissed", reason: "unmount" });
|
|
1255
|
+
o.clear(), Be("unmount"), Te();
|
|
1256
|
+
}, reportError: oe };
|
|
1257
|
+
}
|
|
1258
|
+
const Jn = Se.memo(function({ Screen: t, route: n, navigation: r }) {
|
|
1259
|
+
return /* @__PURE__ */ p(t, { route: n, navigation: r });
|
|
1260
|
+
}), er = Se.memo(function({ store: t, layoutStore: n, route: r, ...o }) {
|
|
1261
|
+
const a = () => t.getSnapshot()[r.key], l = Oe(t.subscribe, a, a), f = Pe(n, Qt, He);
|
|
1262
|
+
return /* @__PURE__ */ p(en, { ...o, options: f, route: r, override: l });
|
|
1263
|
+
}), tr = Se.memo(function({ store: t, translate: n }) {
|
|
1264
|
+
const r = Oe(t.subscribe, t.getSnapshot, t.getSnapshot);
|
|
1265
|
+
return /* @__PURE__ */ p(tn, { loading: r, translate: n });
|
|
1266
|
+
}), nr = Se.memo(function({ store: t, dismiss: n }) {
|
|
1267
|
+
const r = Oe(t.subscribe, t.getSnapshot, t.getSnapshot);
|
|
1268
|
+
return /* @__PURE__ */ p(nn, { items: r, dismiss: n });
|
|
1269
|
+
});
|
|
1270
|
+
function rr({ runtime: e, config: t, initialScreen: n, params: r, translate: o, onRequestClose: a, onOpened: l, registerLoading: f, notifyError: u, error: i, clearError: d, registerDirtyGuard: g, exiting: b = !1 }) {
|
|
1271
|
+
const x = Pe(e.stores.layout, En, He), h = n ?? t.initialRoute ?? Object.keys(t.screens)[0], [s, v] = xe(() => e.stores.navigation.getSnapshot().currentRoute), I = P(s);
|
|
1272
|
+
I.current = s;
|
|
1273
|
+
const z = t.screens[h], T = e.alive, E = P(null), { navigation: D, footer: L, loading: A, toast: q } = e.refs, N = P("single"), { loadingApi: Z, setLoading: ue } = on(A, T, N, e), { toast: C, dismissToast: F } = rn(q, T, e), $ = _((k, ce) => {
|
|
1274
|
+
const ne = L.current, re = ne.getSnapshot();
|
|
1275
|
+
if (ce === null) {
|
|
1276
|
+
if (re[k] !== void 0) {
|
|
1277
|
+
const Be = { ...re };
|
|
1278
|
+
delete Be[k], ne.publish(Be);
|
|
1279
|
+
}
|
|
1280
|
+
} else re[k] !== ce && ne.publish({ ...re, [k]: ce });
|
|
1281
|
+
}, []), X = _((k = "api", ce) => !T.current || A.current.getSnapshot().visible && e.stores.layout.getSnapshot().lockCloseWhileLoading !== !1 ? Promise.resolve(!1) : a(k, ce), [a, e]), B = _(() => Promise.resolve(!1), []), te = Q(() => ({
|
|
1282
|
+
navigate: B,
|
|
1283
|
+
navigateAsync: async () => ({ status: "cancelled" }),
|
|
1284
|
+
replace: B,
|
|
1285
|
+
reset: B,
|
|
1286
|
+
clearCache: B,
|
|
1287
|
+
goBack: B,
|
|
1288
|
+
push: B,
|
|
1289
|
+
pop: B,
|
|
1290
|
+
popToTop: B,
|
|
1291
|
+
popTo: B,
|
|
1292
|
+
setParams: (k) => T.current ? (v((ce) => ({ ...ce, params: { ...ce.params, ...typeof k == "function" ? k(ce.params) : k } })), !0) : !1,
|
|
1293
|
+
setOptions: (k) => T.current ? (v((ce) => ({ ...ce, options: { ...ce.options, ...k } })), !0) : !1,
|
|
1294
|
+
close: X,
|
|
1295
|
+
setLoading: ue,
|
|
1296
|
+
canGoBack: !1,
|
|
1297
|
+
stack: [s],
|
|
1298
|
+
currentRoute: s
|
|
1299
|
+
}), [X, s, ue, B]), V = P(te);
|
|
1300
|
+
V.current = te;
|
|
1301
|
+
const oe = Q(() => ({
|
|
1302
|
+
clearCache: (...k) => V.current.clearCache(...k),
|
|
1303
|
+
navigate: (...k) => V.current.navigate(...k),
|
|
1304
|
+
navigateAsync: (...k) => V.current.navigateAsync(...k),
|
|
1305
|
+
replace: (...k) => V.current.replace(...k),
|
|
1306
|
+
reset: (...k) => V.current.reset(...k),
|
|
1307
|
+
goBack: (...k) => V.current.goBack(...k),
|
|
1308
|
+
push: (...k) => V.current.push(...k),
|
|
1309
|
+
pop: (...k) => V.current.pop(...k),
|
|
1310
|
+
popToTop: (...k) => V.current.popToTop(...k),
|
|
1311
|
+
popTo: (...k) => V.current.popTo(...k),
|
|
1312
|
+
setParams: (...k) => V.current.setParams(...k),
|
|
1313
|
+
setOptions: (...k) => V.current.setOptions(...k),
|
|
1314
|
+
close: (...k) => V.current.close(...k),
|
|
1315
|
+
setLoading: (...k) => V.current.setLoading(...k)
|
|
1316
|
+
}), []);
|
|
1317
|
+
Ae(() => e.registerNavigation(oe), [e, oe]);
|
|
1318
|
+
const J = Q(() => ({
|
|
1319
|
+
setLoading: (k, ce) => Z.setScreenLoading("single", k, ce),
|
|
1320
|
+
showLoading: (k) => Z.begin("single", k),
|
|
1321
|
+
hideLoading: (k) => Z.end("single", k)
|
|
1322
|
+
}), [Z]), O = Q(() => ({ isFocused: !0, resultEvent: null, routeKey: "single", setFooter: $ }), [$]), G = Q(() => ({ routeKey: "single", registerDirtyGuard: g }), [g]);
|
|
1323
|
+
U(() => {
|
|
1324
|
+
D.current.publish({ canGoBack: !1, stack: [s], currentRoute: s });
|
|
1325
|
+
}, [s]);
|
|
1326
|
+
const ke = P(!1);
|
|
1327
|
+
U(() => (f?.({ setLoading: ue }), ke.current || (ke.current = !0, l?.({ route: I.current, stack: [I.current] })), () => {
|
|
1328
|
+
f?.(null);
|
|
1329
|
+
}), []);
|
|
1330
|
+
const Ce = Q(() => ({ ...z, ...s.options }), [z, s.options]), K = z.component, de = e.refs.header;
|
|
1331
|
+
return /* @__PURE__ */ p(yt.Provider, { value: de.current, children: /* @__PURE__ */ p(Tt.Provider, { value: C, children: /* @__PURE__ */ p(Vt.Provider, { value: q.current, children: /* @__PURE__ */ p(Ut.Provider, { value: L.current, children: /* @__PURE__ */ p(_t.Provider, { value: te, children: /* @__PURE__ */ p(vt.Provider, { value: oe, children: /* @__PURE__ */ p(bt.Provider, { value: D.current, children: /* @__PURE__ */ p(Ue.Provider, { value: Z, children: /* @__PURE__ */ be(Xt, { store: e.stores.layout, screenOptions: Ce.modalOptions, dialogRef: E, requestClose: X, exiting: b, children: [
|
|
1332
|
+
/* @__PURE__ */ p(Jt, { store: e.stores.layout, screen: Ce, route: s, navigation: te, requestClose: X, translate: o, canGoBack: !1 }),
|
|
1333
|
+
/* @__PURE__ */ p("main", { className: "pmn-main", children: /* @__PURE__ */ p(Ve.Provider, { value: s, children: /* @__PURE__ */ p(Pt.Provider, { value: G, children: /* @__PURE__ */ p(ot.Provider, { value: O, children: /* @__PURE__ */ p(Ue.Provider, { value: J, children: /* @__PURE__ */ p(wt.Provider, { value: A.current, children: /* @__PURE__ */ p("div", { className: `pmn-body ${x.bodyClassName ?? ""}`, "data-modal-route-key": "single", tabIndex: -1, children: /* @__PURE__ */ p(Nt, { route: s, onError: u, children: /* @__PURE__ */ p(Wt, { fallback: x.lazyFallback ?? /* @__PURE__ */ p("div", { className: "pmn-lazy-loading", role: "status", "aria-live": "polite", children: "加载中..." }), children: /* @__PURE__ */ p(Jn, { Screen: K, route: s, navigation: te }) }) }) }) }) }) }) }) }) }),
|
|
1334
|
+
/* @__PURE__ */ p(er, { store: L.current, route: s, screen: Ce, layoutStore: e.stores.layout, navigation: te, requestClose: X, translate: o, onError: u, loadingApi: Z }),
|
|
1335
|
+
/* @__PURE__ */ p(tr, { store: A.current, translate: o }),
|
|
1336
|
+
/* @__PURE__ */ p(nr, { store: q.current, dismiss: F }),
|
|
1337
|
+
i && /* @__PURE__ */ be("div", { className: "pmn-error", role: "alert", children: [
|
|
1338
|
+
/* @__PURE__ */ p("span", { children: i.message || String(i) }),
|
|
1339
|
+
/* @__PURE__ */ p("button", { type: "button", onClick: d, children: "×" })
|
|
1340
|
+
] })
|
|
1341
|
+
] }) }) }) }) }) }) }) }) });
|
|
1342
|
+
}
|
|
1343
|
+
const or = rt(Hn), ar = rt(rr), sr = rt(function({ manager: t }) {
|
|
1344
|
+
const { active: n, options: r, exiting: o, error: a, translate: l } = Oe(t.hostStore.subscribe, t.hostStore.getSnapshot, t.hostStore.getSnapshot), f = n?.id, u = n?.runtime.bindings, i = Q(() => (g, b) => {
|
|
1345
|
+
n?.runtime.alive.current && t.hostStore.getSnapshot().active?.id === f && t.reportError(g, b);
|
|
1346
|
+
}, [t, n, f]);
|
|
1347
|
+
if (!n) return null;
|
|
1348
|
+
const d = n.config.singlePage || Object.keys(n.config.screens ?? {}).length === 1 ? ar : or;
|
|
1349
|
+
return /* @__PURE__ */ p(at.Provider, { value: n.runtime, children: /* @__PURE__ */ p(d, { runtime: n.runtime, config: n.config, initialScreen: n.screen, params: n.params, options: r, translate: l, notifyError: i, error: a, clearError: t.commands.clearError, exiting: o, ...u }, f) });
|
|
1350
|
+
}), ir = ".pmn-overlay,.pmn-dialog,.pmn-dialog *{box-sizing:border-box}.pmn-overlay{position:fixed;inset:0;z-index:1000;display:flex;overscroll-behavior:none;background:#00000073}.pmn-place-right{justify-content:flex-end;align-items:stretch}.pmn-place-left{justify-content:flex-start;align-items:stretch}.pmn-place-center{justify-content:center;align-items:center}.pmn-place-top{justify-content:center;align-items:flex-start}.pmn-place-bottom{justify-content:center;align-items:flex-end}.pmn-dialog{--pmn-surface:#fff;--pmn-body:#fff;--pmn-text:#0f172a;--pmn-muted:#475569;--pmn-border:#e2e8f0;--pmn-hover:#f1f5f9;--pmn-overlay-card:rgba(255,255,255,.92);color-scheme:light;position:relative;display:flex;flex-direction:column;min-height:0;width:100%;max-width:min(calc(100vw - var(--pmn-gap)*2),var(--pmn-max-width, var(--pmn-width)));max-height:min(calc(100dvh - var(--pmn-gap)*2),var(--pmn-max-height, 100dvh));height:var(--pmn-height, 100%);overflow:hidden;outline:none;box-shadow:0 25px 50px -12px #00000040;background:var(--pmn-surface);color:var(--pmn-text)}.pmn-place-left .pmn-dialog,.pmn-place-right .pmn-dialog{height:calc(100dvh - var(--pmn-gap)*2);max-height:calc(100dvh - var(--pmn-gap)*2)}.pmn-place-center .pmn-dialog{height:var(--pmn-height, auto);min-height:150px}.pmn-place-top .pmn-dialog,.pmn-place-bottom .pmn-dialog{height:var(--pmn-height, auto);min-height:0}.pmn-dialog[data-modal-theme=dark]{--pmn-surface:#334155;--pmn-body:#334155;--pmn-text:#f1f5f9;--pmn-muted:#cbd5e1;--pmn-border:#475569;--pmn-hover:#1e293b;--pmn-overlay-card:rgba(51,65,85,.94);color-scheme:dark}.pmn-main{min-height:0;flex:1;overflow:hidden;display:flex;flex-direction:column;background:transparent}.pmn-body{height:100%;min-height:0;overflow-y:auto;overscroll-behavior:contain;padding:16px;flex:1}.pmn-body[hidden]{display:none!important}.pmn-header{display:flex;flex-shrink:0;height:64px;align-items:center;gap:12px;padding:0 20px;background:transparent}.pmn-header h2{font-size:18px;font-weight:600;min-width:0;flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;margin:0}.pmn-header-spacer{flex:1}.pmn-border-bottom{border-bottom:1px solid var(--pmn-border)}.pmn-icon-button{display:inline-flex;align-items:center;justify-content:center;padding:8px;border:0;background:transparent;color:inherit;border-radius:8px;cursor:pointer}.pmn-icon-button:hover{background:var(--pmn-hover)}.pmn-footer{display:flex;flex-shrink:0;align-items:center;justify-content:flex-end;gap:12px;padding:16px 20px;background:transparent}.pmn-border-top{border-top:1px solid var(--pmn-border)}.pmn-button{padding:8px 16px;border-radius:8px;font-size:14px;font-weight:500;cursor:pointer}.pmn-button:disabled{opacity:.5;cursor:not-allowed}.pmn-button-secondary{border:1px solid var(--pmn-border);background:transparent;color:var(--pmn-text)}.pmn-button-secondary:hover:not(:disabled){background:var(--pmn-hover)}.pmn-button-primary{border:1px solid #2563eb;background:#2563eb;color:#fff}.pmn-button-primary:hover:not(:disabled){background:#1d4ed8}.pmn-loading-overlay{position:absolute;inset:0;z-index:50;display:flex;align-items:center;justify-content:center;background:#ffffffb8;backdrop-filter:blur(2px);-webkit-backdrop-filter:blur(2px);cursor:progress}.pmn-dialog[data-modal-theme=dark] .pmn-loading-overlay{background:#0f172ab8}.pmn-loading-content{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:14px;max-width:85%;text-align:center;color:var(--pmn-text);pointer-events:none}.pmn-loading-text{font-size:14px;font-weight:500;line-height:1.5;overflow-wrap:anywhere}.pmn-spinner{width:38px;height:38px;border:3px solid rgba(37,99,235,.2);border-top-color:#2563eb;border-radius:50%;animation:pmn-spin .8s linear infinite}@keyframes pmn-spin{to{transform:rotate(360deg)}}@media(prefers-reduced-motion:reduce){.pmn-spinner{animation-duration:1.8s}}.pmn-error{position:absolute;z-index:60;bottom:8px;left:12px;right:12px;display:flex;justify-content:space-between;gap:12px;padding:12px;border:1px solid #fca5a5;border-radius:8px;background:#fef2f2;color:#991b1b;font-size:13px}.pmn-error button{border:0;background:transparent;font-size:20px;cursor:pointer;color:inherit}.pmn-dialog input:not([type=checkbox]):not([type=radio]),.pmn-dialog textarea,.pmn-dialog select{color:var(--pmn-text);border-color:var(--pmn-border)}.pmn-error-screen{padding:24px;color:var(--pmn-text)}.pmn-error-screen p{color:#dc2626;overflow-wrap:anywhere}@media(max-width:640px){.pmn-overlay.pmn-mobile-fullscreen{padding:0!important}.pmn-mobile-fullscreen .pmn-dialog{max-width:100%;width:100%;height:100dvh;max-height:100dvh;border-radius:0!important}}@media(prefers-reduced-motion:reduce){.pmn-spinner{animation-duration:2s}}@keyframes pmn-fade-in{0%{opacity:0}to{opacity:1}}@keyframes pmn-fade-out{0%{opacity:1}to{opacity:0}}@keyframes pmn-scale-in{0%{opacity:0;transform:translateY(10px) scale(.97)}to{opacity:1;transform:none}}@keyframes pmn-scale-out{0%{opacity:1;transform:none}to{opacity:0;transform:translateY(10px) scale(.97)}}@keyframes pmn-right-in{0%{transform:translate(105%)}to{transform:none}}@keyframes pmn-right-out{0%{transform:none}to{transform:translate(105%)}}@keyframes pmn-left-in{0%{transform:translate(-105%)}to{transform:none}}@keyframes pmn-left-out{0%{transform:none}to{transform:translate(-105%)}}@keyframes pmn-top-in{0%{transform:translateY(-105%)}to{transform:none}}@keyframes pmn-top-out{0%{transform:none}to{transform:translateY(-105%)}}@keyframes pmn-bottom-in{0%{transform:translateY(105%)}to{transform:none}}@keyframes pmn-bottom-out{0%{transform:none}to{transform:translateY(105%)}}.pmn-entering{animation:pmn-fade-in var(--pmn-animation-duration) ease-out both}.pmn-exiting{animation:pmn-fade-out var(--pmn-animation-duration) ease-in both;pointer-events:none}.pmn-entering .pmn-dialog{animation:pmn-scale-in var(--pmn-animation-duration) cubic-bezier(.2,.8,.2,1) both}.pmn-exiting .pmn-dialog{animation:pmn-scale-out var(--pmn-animation-duration) ease-in both}.pmn-entering.pmn-place-right .pmn-dialog{animation-name:pmn-right-in}.pmn-exiting.pmn-place-right .pmn-dialog{animation-name:pmn-right-out}.pmn-entering.pmn-place-left .pmn-dialog{animation-name:pmn-left-in}.pmn-exiting.pmn-place-left .pmn-dialog{animation-name:pmn-left-out}.pmn-entering.pmn-place-top .pmn-dialog{animation-name:pmn-top-in}.pmn-exiting.pmn-place-top .pmn-dialog{animation-name:pmn-top-out}.pmn-entering.pmn-place-bottom .pmn-dialog{animation-name:pmn-bottom-in}.pmn-exiting.pmn-place-bottom .pmn-dialog{animation-name:pmn-bottom-out}.pmn-no-animation,.pmn-no-animation .pmn-dialog{animation:none!important}@media(prefers-reduced-motion:reduce){.pmn-entering,.pmn-exiting,.pmn-entering .pmn-dialog,.pmn-exiting .pmn-dialog{animation:none!important}}.pmn-toast-region{position:absolute;top:56px;left:12px;right:12px;z-index:80;display:flex;flex-direction:column;align-items:center;gap:8px;pointer-events:none;max-height:calc(100% - 72px);overflow:hidden}.pmn-toast{pointer-events:auto;display:flex;align-items:flex-start;gap:10px;width:max-content;max-width:100%;min-width:min(260px,100%);padding:11px 13px;border:1px solid var(--pmn-border);border-radius:9px;background:var(--pmn-surface);color:var(--pmn-text);box-shadow:0 5px 18px #0000001a;font-size:13px;line-height:1.5;overflow-wrap:anywhere}.pmn-toast-symbol{flex:0 0 20px;display:grid;place-items:center;width:20px;height:20px;border-radius:50%;font-size:13px;font-weight:700;background:var(--pmn-hover);color:var(--pmn-muted)}.pmn-toast-success .pmn-toast-symbol{background:#dcfce7;color:#15803d}.pmn-toast-error .pmn-toast-symbol{background:#fee2e2;color:#b91c1c}.pmn-toast-warning .pmn-toast-symbol{background:#fef3c7;color:#b45309}.pmn-toast-info .pmn-toast-symbol{background:#dbeafe;color:#1d4ed8}.pmn-toast-message{flex:1;min-width:0;white-space:pre-wrap}.pmn-toast-close{border:0;background:transparent;color:var(--pmn-muted);cursor:pointer;font-size:19px;line-height:18px;padding:0 1px}.pmn-toast-close:hover{color:var(--pmn-text)}.pmn-button-danger{background:#dc2626!important;color:#fff!important;border-color:#dc2626!important}@keyframes pmn-page-forward-in{0%{opacity:.18;transform:translate3d(var(--pmn-page-distance,96px),0,0) scale(.985)}to{opacity:1;transform:translateZ(0)}}@keyframes pmn-page-back-in{0%{opacity:.18;transform:translate3d(calc(-1 * var(--pmn-page-distance,96px)),0,0) scale(.985)}to{opacity:1;transform:translateZ(0)}}.pmn-page-enter{animation-duration:var(--pmn-page-duration,.36s);animation-timing-function:cubic-bezier(.2,.8,.2,1);animation-fill-mode:both;will-change:transform,opacity}.pmn-page-forward{animation-name:pmn-page-forward-in}.pmn-page-back{animation-name:pmn-page-back-in}@media(prefers-reduced-motion:reduce){.pmn-page-enter{animation:none!important;will-change:auto}}.pmn-main{position:relative;isolation:isolate}.pmn-page-exit{animation-duration:var(--pmn-page-duration,.36s);animation-timing-function:cubic-bezier(.22,1,.36,1);animation-fill-mode:forwards}@keyframes pmn-page-forward-out{to{opacity:.45;transform:translate3d(calc(-1 * var(--pmn-page-distance,96px)),0,0) scale(.985)}}@keyframes pmn-page-back-out{to{opacity:.45;transform:translate3d(var(--pmn-page-distance,96px),0,0) scale(.985)}}.pmn-page-exit-forward{animation-name:pmn-page-forward-out}.pmn-page-exit-back{animation-name:pmn-page-back-out}@media(prefers-reduced-motion:reduce){.pmn-page-exit{animation:none!important}}.pmn-main>.pmn-body{position:relative;width:100%;flex:1 0 100%;background:var(--pmn-body)}.pmn-page-forward,.pmn-page-back{z-index:2}@keyframes pmn-page-forward-in{0%{opacity:1;transform:translate3d(100%,0,0)}to{opacity:1;transform:translateZ(0)}}@keyframes pmn-page-back-in{0%{opacity:1;transform:translate3d(-100%,0,0)}to{opacity:1;transform:translateZ(0)}}@keyframes pmn-page-forward-out{to{opacity:1;transform:translate3d(-100%,0,0)}}@keyframes pmn-page-back-out{to{opacity:1;transform:translate3d(100%,0,0)}}.pmn-lazy-loading{display:flex;min-height:80px;align-items:center;justify-content:center;color:var(--pmn-muted);font-size:14px}.pmn-place-top .pmn-dialog{max-height:min(calc(100dvh - var(--pmn-top-offset, var(--pmn-gap)) - var(--pmn-gap)),var(--pmn-max-height,100dvh))}.pmn-dialog.pmn-has-custom-background{isolation:isolate;--pmn-body:transparent}.pmn-custom-background-layer{position:absolute;inset:0;z-index:0;pointer-events:none}.pmn-dialog.pmn-has-custom-background>:not(.pmn-custom-background-layer){position:relative;z-index:1}.pmn-dialog.pmn-has-custom-background .pmn-main>.pmn-body{background:transparent}.pmn-overlay.pmn-fullscreen{padding:0!important;align-items:stretch;justify-content:stretch}.pmn-overlay.pmn-fullscreen .pmn-dialog{width:100%;max-width:100%;height:100%;max-height:100%;border-radius:0!important}.pmn-place-left .pmn-dialog,.pmn-place-right .pmn-dialog{height:100%;max-height:100%}.pmn-place-center .pmn-dialog{max-height:100%}.pmn-dialog{max-width:min(100%,var(--pmn-drag-width,var(--pmn-max-width,var(--pmn-width))));max-height:min(100%,var(--pmn-max-height,100dvh))}.pmn-dialog .pmn-resize-handle{position:absolute;z-index:5;top:0;bottom:0;width:10px;cursor:ew-resize;touch-action:none;-webkit-user-select:none;user-select:none}.pmn-resize-left{right:0}.pmn-resize-right{left:0}.pmn-resize-handle:hover,.pmn-resize-handle:focus-visible{background:var(--pmn-border)}@media(max-width:640px){.pmn-mobile-fullscreen .pmn-resize-handle{display:none}}.pmn-dialog{max-width:min(100%,var(--pmn-max-width,100%),var(--pmn-drag-width,var(--pmn-width)))}.pmn-overlay.pmn-fullscreen .pmn-dialog{max-width:100%}", Kt = "react-modal-navigation-styles", Ot = /* @__PURE__ */ new WeakMap();
|
|
1351
|
+
function cr() {
|
|
1352
|
+
mn(() => {
|
|
1353
|
+
if (typeof document > "u") return;
|
|
1354
|
+
const e = document;
|
|
1355
|
+
let t = Ot.get(e);
|
|
1356
|
+
if (!t) {
|
|
1357
|
+
let n = e.getElementById(Kt);
|
|
1358
|
+
const r = !n;
|
|
1359
|
+
n || (n = e.createElement("style"), n.id = Kt, n.setAttribute("data-react-modal-navigation", ""), n.textContent = ir, e.head.appendChild(n)), t = { element: n, owned: r, count: 0 }, Ot.set(e, t);
|
|
1360
|
+
}
|
|
1361
|
+
return t.count += 1, () => {
|
|
1362
|
+
t.count -= 1, t.count === 0 && (t.owned && t.element.remove(), Ot.delete(e));
|
|
1363
|
+
};
|
|
1364
|
+
}, []);
|
|
1365
|
+
}
|
|
1366
|
+
const lr = Object.freeze({}), ur = (e) => ({ "modal.loading": "加载中...", "modal.processing": "处理中...", "modal.back": "返回", "modal.close": "关闭", "modal.cancel": "取消", "modal.done": "完成" })[e] ?? e;
|
|
1367
|
+
function Tr({ children: e, registry: t, defaultOptions: n = lr, backgroundColor: r, theme: o, translate: a = ur, onError: l, confirmDiscard: f }) {
|
|
1368
|
+
cr();
|
|
1369
|
+
const u = { registry: t, defaultOptions: n, backgroundColor: r, theme: o, translate: a, onError: l, confirmDiscard: f }, [i] = xe(() => Xn(u, Gn));
|
|
1370
|
+
return Ae(() => (i.mount(), i.destroy), [i]), Ae(() => {
|
|
1371
|
+
i.configure(u);
|
|
1372
|
+
}, [i, t, n, r, o, a, l, f]), /* @__PURE__ */ p(Lt.Provider, { value: i.commands, children: /* @__PURE__ */ p(zt.Provider, { value: i.statusStore, children: /* @__PURE__ */ be(Gt.Provider, { value: i.commands, children: [
|
|
1373
|
+
e,
|
|
1374
|
+
/* @__PURE__ */ p(sr, { manager: i })
|
|
1375
|
+
] }) }) });
|
|
850
1376
|
}
|
|
851
|
-
const
|
|
852
|
-
},
|
|
853
|
-
function
|
|
854
|
-
const
|
|
855
|
-
if (!
|
|
856
|
-
const
|
|
857
|
-
const
|
|
858
|
-
if (!
|
|
859
|
-
return
|
|
1377
|
+
const dr = Object.freeze({ canGoBack: !1, stack: [], currentRoute: null }), Ht = () => () => {
|
|
1378
|
+
}, ft = () => dr;
|
|
1379
|
+
function Lr({ subscribe: e = !0 } = {}) {
|
|
1380
|
+
const t = ee(Gt), n = ee(zt), r = Oe(e && n?.subscribe || Ht, e && n?.getSnapshot || ft, e && n?.getSnapshot || ft), o = Q(() => t ? e ? { ...t, ...r } : t : null, [t, r, e]), a = ee(vt), l = ee(bt), f = Oe(e && l?.subscribe || Ht, e && l?.getSnapshot || ft, e && l?.getSnapshot || ft);
|
|
1381
|
+
if (!o) throw new Error("[react-modal-navigation] useModal requires <ModalProvider>");
|
|
1382
|
+
const u = Q(() => {
|
|
1383
|
+
const i = () => {
|
|
1384
|
+
if (!a) throw new Error("[react-modal-navigation] navigation requires an active modal screen; use modal.open() outside a modal");
|
|
1385
|
+
return a;
|
|
860
1386
|
};
|
|
861
1387
|
return {
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
1388
|
+
clearCache: (...d) => i().clearCache(...d),
|
|
1389
|
+
navigateAsync: (...d) => i().navigateAsync(...d),
|
|
1390
|
+
navigate: (...d) => i().navigate(...d),
|
|
1391
|
+
push: (...d) => i().push(...d),
|
|
1392
|
+
pop: (...d) => i().pop(...d),
|
|
1393
|
+
popTo: (...d) => i().popTo(...d),
|
|
1394
|
+
popToTop: (...d) => i().popToTop(...d),
|
|
1395
|
+
replace: (...d) => i().replace(...d),
|
|
1396
|
+
reset: (...d) => i().reset(...d),
|
|
1397
|
+
setParams: (...d) => i().setParams(...d),
|
|
1398
|
+
setOptions: (...d) => i().setOptions(...d),
|
|
1399
|
+
goBack: (...d) => i().goBack(...d),
|
|
1400
|
+
close: (...d) => i().close(...d),
|
|
1401
|
+
setLoading: (...d) => i().setLoading(...d),
|
|
1402
|
+
...e ? { canGoBack: f.canGoBack, stack: f.stack, currentRoute: f.currentRoute } : {}
|
|
873
1403
|
};
|
|
874
|
-
}, [
|
|
875
|
-
return
|
|
1404
|
+
}, [a, f, e]);
|
|
1405
|
+
return Q(() => ({ ...o, modal: o, navigation: u }), [o, u]);
|
|
876
1406
|
}
|
|
877
|
-
function
|
|
878
|
-
const e =
|
|
1407
|
+
function cn() {
|
|
1408
|
+
const e = ee(vt);
|
|
879
1409
|
if (!e) throw new Error("useModalNavigationCommands requires an active modal screen");
|
|
880
1410
|
return e;
|
|
881
1411
|
}
|
|
882
|
-
function
|
|
883
|
-
const
|
|
884
|
-
if (!
|
|
885
|
-
return
|
|
1412
|
+
function mr(e, t) {
|
|
1413
|
+
const n = ee(bt);
|
|
1414
|
+
if (!n) throw new Error("useModalNavigationState requires an active modal screen");
|
|
1415
|
+
return Pe(n, e, t);
|
|
886
1416
|
}
|
|
887
|
-
function
|
|
888
|
-
const e =
|
|
889
|
-
return
|
|
1417
|
+
function zr() {
|
|
1418
|
+
const e = cn(), t = mr();
|
|
1419
|
+
return Q(() => ({ ...e, ...t }), [e, t]);
|
|
890
1420
|
}
|
|
891
|
-
function
|
|
892
|
-
const e =
|
|
1421
|
+
function jt() {
|
|
1422
|
+
const e = ee(ot);
|
|
893
1423
|
if (!e) throw new Error("useIsFocused must be called inside a modal screen");
|
|
894
1424
|
return e.isFocused;
|
|
895
1425
|
}
|
|
896
|
-
function
|
|
897
|
-
const
|
|
898
|
-
|
|
899
|
-
if (
|
|
1426
|
+
function Ar(e) {
|
|
1427
|
+
const t = jt();
|
|
1428
|
+
U(() => {
|
|
1429
|
+
if (t)
|
|
900
1430
|
return e();
|
|
901
|
-
}, [
|
|
902
|
-
}
|
|
903
|
-
function
|
|
904
|
-
const
|
|
905
|
-
if (!
|
|
906
|
-
const
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
}, [e]),
|
|
910
|
-
!
|
|
911
|
-
}, [
|
|
912
|
-
}
|
|
913
|
-
function
|
|
914
|
-
const
|
|
915
|
-
if (!
|
|
916
|
-
const { setFooter:
|
|
917
|
-
|
|
918
|
-
const
|
|
919
|
-
|
|
920
|
-
const
|
|
921
|
-
return [.../* @__PURE__ */ new Set([...Object.keys(
|
|
922
|
-
}) || (
|
|
923
|
-
source:
|
|
924
|
-
normalized:
|
|
925
|
-
...
|
|
926
|
-
onClick: (...
|
|
1431
|
+
}, [t, e]);
|
|
1432
|
+
}
|
|
1433
|
+
function Nr(e) {
|
|
1434
|
+
const t = ee(ot);
|
|
1435
|
+
if (!t) throw new Error("useNavigationResult requires an active modal screen");
|
|
1436
|
+
const n = P(e), r = P(null);
|
|
1437
|
+
U(() => {
|
|
1438
|
+
n.current = e;
|
|
1439
|
+
}, [e]), U(() => {
|
|
1440
|
+
!t.isFocused || !t.resultEvent || r.current !== t.resultEvent.id && (r.current = t.resultEvent.id, n.current(t.resultEvent.data));
|
|
1441
|
+
}, [t.isFocused, t.resultEvent]);
|
|
1442
|
+
}
|
|
1443
|
+
function jr(e = {}) {
|
|
1444
|
+
const t = ee(ot);
|
|
1445
|
+
if (!t) throw new Error("[react-modal-navigation] useModalFooter requires an active modal screen");
|
|
1446
|
+
const { setFooter: n, routeKey: r } = t, o = P(e);
|
|
1447
|
+
o.current = e;
|
|
1448
|
+
const a = Q(() => (...q) => o.current.done?.(...q), []), l = Q(() => (...q) => (o.current.cancel ?? o.current.cancle)?.(...q), []), f = Q(() => (...q) => o.current.renderFooter?.(...q), []), u = typeof e.done == "function", i = typeof (e.cancel ?? e.cancle) == "function", d = typeof e.renderFooter == "function", { showFooter: g, showFooterBorder: b, doneDisabled: x, doneText: h, cancelText: s, loadingText: v, footerClassName: I } = e, z = P({ source: null, normalized: void 0 }), T = Array.isArray(e.actions) ? e.actions : null, E = z.current.source;
|
|
1449
|
+
T === E || T && E && T.length === E.length && T.every((q, N) => {
|
|
1450
|
+
const Z = E[N];
|
|
1451
|
+
return [.../* @__PURE__ */ new Set([...Object.keys(q), ...Object.keys(Z)])].every((C) => C === "onClick" || Object.is(q[C], Z[C]));
|
|
1452
|
+
}) || (z.current = {
|
|
1453
|
+
source: T?.map((q) => ({ ...q })) ?? null,
|
|
1454
|
+
normalized: T?.map((q, N) => ({
|
|
1455
|
+
...q,
|
|
1456
|
+
onClick: (...Z) => (o.current.actions?.find((C) => C.key === q.key) ?? o.current.actions?.[N])?.onClick?.(...Z)
|
|
927
1457
|
}))
|
|
928
1458
|
});
|
|
929
|
-
const
|
|
930
|
-
showFooter:
|
|
931
|
-
showFooterBorder:
|
|
932
|
-
doneDisabled:
|
|
933
|
-
doneText:
|
|
934
|
-
cancelText:
|
|
935
|
-
loadingText:
|
|
936
|
-
footerClassName:
|
|
937
|
-
|
|
938
|
-
...u ? { done:
|
|
939
|
-
...
|
|
940
|
-
...
|
|
941
|
-
}), [
|
|
942
|
-
|
|
943
|
-
r
|
|
944
|
-
}, [
|
|
945
|
-
}
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
}
|
|
952
|
-
|
|
953
|
-
|
|
1459
|
+
const L = z.current.normalized, A = Q(() => ({
|
|
1460
|
+
showFooter: g,
|
|
1461
|
+
showFooterBorder: b,
|
|
1462
|
+
doneDisabled: x,
|
|
1463
|
+
doneText: h,
|
|
1464
|
+
cancelText: s,
|
|
1465
|
+
loadingText: v,
|
|
1466
|
+
footerClassName: I,
|
|
1467
|
+
...L !== void 0 ? { actions: L } : {},
|
|
1468
|
+
...u ? { done: a } : {},
|
|
1469
|
+
...i ? { cancel: l } : {},
|
|
1470
|
+
...d ? { renderFooter: f } : {}
|
|
1471
|
+
}), [g, b, x, h, s, v, I, L, u, i, d, a, l, f]);
|
|
1472
|
+
U(() => {
|
|
1473
|
+
n(r, A);
|
|
1474
|
+
}, [r, n, A]), U(() => () => n(r, null), [r, n]);
|
|
1475
|
+
}
|
|
1476
|
+
const pr = (e) => e.visible;
|
|
1477
|
+
function Br() {
|
|
1478
|
+
const e = ee(Ue), t = ee(wt);
|
|
1479
|
+
if (!e || !t) throw new Error("[react-modal-navigation] useModalLoading requires an active modal screen");
|
|
1480
|
+
const n = Pe(t, pr);
|
|
1481
|
+
return Q(() => ({ ...e, isLoading: n }), [e, n]);
|
|
1482
|
+
}
|
|
1483
|
+
function fr() {
|
|
1484
|
+
const e = ee(Ue);
|
|
954
1485
|
if (!e) throw new Error("[react-modal-navigation] useModalLoadingCommands requires an active modal screen");
|
|
955
1486
|
return e;
|
|
956
1487
|
}
|
|
957
|
-
function
|
|
958
|
-
const
|
|
959
|
-
if (!
|
|
960
|
-
return
|
|
961
|
-
}
|
|
962
|
-
function
|
|
963
|
-
const e =
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
}), []), { run: w(async (M, k = {}) => {
|
|
967
|
-
if (t.current) return { status: "busy" };
|
|
968
|
-
if (typeof M != "function") throw new TypeError("[react-modal-navigation] run requires a function");
|
|
969
|
-
t.current = !0, r.current && (g(!0), f(null));
|
|
970
|
-
const d = u.current.showLoading(k.loadingText);
|
|
1488
|
+
function qr(e, t) {
|
|
1489
|
+
const n = ee(wt);
|
|
1490
|
+
if (!n) throw new Error("[react-modal-navigation] useModalLoadingState requires an active modal screen");
|
|
1491
|
+
return Pe(n, e, t);
|
|
1492
|
+
}
|
|
1493
|
+
function Fr() {
|
|
1494
|
+
const e = ee(at), t = ee(Ve), n = fr(), r = jt(), o = P(!0), a = P(null), [l, f] = xe(!1), [u, i] = xe(null), d = _((x) => {
|
|
1495
|
+
if (!x || a.current !== x) return !1;
|
|
1496
|
+
a.current = null, x.unregister?.(), o.current && f(!1);
|
|
971
1497
|
try {
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
1498
|
+
x.controller.abort();
|
|
1499
|
+
} finally {
|
|
1500
|
+
x.release();
|
|
1501
|
+
}
|
|
1502
|
+
return !0;
|
|
1503
|
+
}, []), g = _(() => d(a.current), [d]);
|
|
1504
|
+
return U(() => (o.current = !0, () => {
|
|
1505
|
+
o.current = !1, g();
|
|
1506
|
+
}), [g]), { run: _(async (x, h = {}) => {
|
|
1507
|
+
if (!o.current || e && !e.alive.current) return { status: "cancelled" };
|
|
1508
|
+
if (a.current) return { status: "busy" };
|
|
1509
|
+
if (typeof x != "function") throw new TypeError("[react-modal-navigation] run requires a function");
|
|
1510
|
+
const s = new AbortController();
|
|
1511
|
+
let v, I = !1;
|
|
1512
|
+
const z = { controller: s, release: () => {
|
|
1513
|
+
I || (I = !0, v != null && n.hideLoading(v));
|
|
1514
|
+
} };
|
|
1515
|
+
a.current = z, z.cancel = () => d(z), z.unregister = e?.tasks.register(t?.key, z);
|
|
1516
|
+
const T = () => o.current && a.current === z && !s.signal.aborted;
|
|
1517
|
+
try {
|
|
1518
|
+
if (!T()) return { status: "cancelled" };
|
|
1519
|
+
if (f(!0), i(null), v = n.showLoading(h.loadingText), !T())
|
|
1520
|
+
return v != null && I && n.hideLoading(v), { status: "cancelled" };
|
|
1521
|
+
const E = await x({ signal: s.signal });
|
|
1522
|
+
return T() ? (await h.onSuccess?.(E), T() ? { status: "success", value: E } : { status: "cancelled" }) : { status: "cancelled" };
|
|
1523
|
+
} catch (E) {
|
|
1524
|
+
if (!T()) return { status: "cancelled" };
|
|
1525
|
+
i(E);
|
|
1526
|
+
try {
|
|
1527
|
+
await h.onError?.(E);
|
|
1528
|
+
} catch (D) {
|
|
1529
|
+
console.error("[react-modal-navigation] onError failed", D);
|
|
982
1530
|
}
|
|
983
|
-
if (
|
|
984
|
-
|
|
1531
|
+
if (!T()) return { status: "cancelled" };
|
|
1532
|
+
if (h.throwOnError) throw E;
|
|
1533
|
+
return { status: "error", error: E };
|
|
985
1534
|
} finally {
|
|
986
|
-
|
|
1535
|
+
z.unregister?.(), z.release(), a.current === z && (a.current = null, o.current && f(!1));
|
|
987
1536
|
}
|
|
988
|
-
}, []), pending:
|
|
989
|
-
}
|
|
990
|
-
function
|
|
991
|
-
const
|
|
992
|
-
if (!
|
|
993
|
-
const
|
|
994
|
-
|
|
995
|
-
const { routeKey:
|
|
996
|
-
|
|
1537
|
+
}, [n, e, t?.key, d]), cancel: g, pending: l, error: u, clearError: () => i(null), isFocused: r };
|
|
1538
|
+
}
|
|
1539
|
+
function hr(e, t = {}) {
|
|
1540
|
+
const n = ee(Pt);
|
|
1541
|
+
if (!n) throw new Error("[react-modal-navigation] useModalUnsavedChanges must be used inside a modal screen");
|
|
1542
|
+
const r = P({ dirty: e, ...t });
|
|
1543
|
+
r.current = { dirty: e, ...t };
|
|
1544
|
+
const { routeKey: o, registerDirtyGuard: a } = n;
|
|
1545
|
+
U(() => a(o, {
|
|
997
1546
|
get dirty() {
|
|
998
|
-
return !!
|
|
1547
|
+
return !!r.current.dirty;
|
|
999
1548
|
},
|
|
1000
1549
|
get message() {
|
|
1001
|
-
return
|
|
1550
|
+
return r.current.message;
|
|
1002
1551
|
},
|
|
1003
1552
|
get onBeforeDiscard() {
|
|
1004
|
-
return
|
|
1553
|
+
return r.current.onBeforeDiscard;
|
|
1005
1554
|
}
|
|
1006
|
-
}), [
|
|
1555
|
+
}), [o, a]);
|
|
1007
1556
|
}
|
|
1008
|
-
const
|
|
1009
|
-
const e =
|
|
1557
|
+
const $r = () => {
|
|
1558
|
+
const e = ee(Tt);
|
|
1010
1559
|
if (!e) throw new Error("[react-modal-navigation] useToast requires an active modal");
|
|
1011
1560
|
return e;
|
|
1012
1561
|
};
|
|
1013
|
-
function
|
|
1014
|
-
const e =
|
|
1562
|
+
function gr() {
|
|
1563
|
+
const e = ee(Ve);
|
|
1015
1564
|
if (!e) throw new Error("[react-modal-navigation] useModalRoute requires a modal screen");
|
|
1016
1565
|
return e;
|
|
1017
1566
|
}
|
|
1018
|
-
function
|
|
1019
|
-
return
|
|
1567
|
+
function yr() {
|
|
1568
|
+
return gr().params;
|
|
1569
|
+
}
|
|
1570
|
+
function Bt() {
|
|
1571
|
+
const e = ee(Lt);
|
|
1572
|
+
if (!e) throw new Error("[react-modal-navigation] ModalProvider required");
|
|
1573
|
+
return e;
|
|
1574
|
+
}
|
|
1575
|
+
const vr = (e) => e;
|
|
1576
|
+
function br(e = vr, t = Object.is) {
|
|
1577
|
+
const n = ee(zt);
|
|
1578
|
+
if (!n) throw new Error("[react-modal-navigation] ModalProvider required");
|
|
1579
|
+
return Pe(n, e, t);
|
|
1580
|
+
}
|
|
1581
|
+
const wr = (e) => e.isFullscreen;
|
|
1582
|
+
function Ir() {
|
|
1583
|
+
const { setFullscreen: e, toggleFullscreen: t } = Bt();
|
|
1584
|
+
return { isFullscreen: br(wr), setFullscreen: e, toggleFullscreen: t };
|
|
1585
|
+
}
|
|
1586
|
+
function Dr(e = {}) {
|
|
1587
|
+
const t = ee(yt), n = ee(Ve);
|
|
1588
|
+
if (!t || !n) throw new Error("[react-modal-navigation] useModalHeader requires a modal screen");
|
|
1589
|
+
const r = P(e);
|
|
1590
|
+
r.current = e, U(() => {
|
|
1591
|
+
t.set(n.key, r.current);
|
|
1592
|
+
}), U(() => () => t.set(n.key, null), [t, n.key]);
|
|
1593
|
+
}
|
|
1594
|
+
function Kr(e, t) {
|
|
1595
|
+
const n = ee(at);
|
|
1596
|
+
if (!n) throw new Error("[react-modal-navigation] useModalLayout requires an active modal");
|
|
1597
|
+
return Pe(n.stores.layout, e, t);
|
|
1598
|
+
}
|
|
1599
|
+
function Hr(e = {}) {
|
|
1600
|
+
const t = ee(at), n = ee(Ve), r = jt(), o = P(e);
|
|
1601
|
+
U(() => {
|
|
1602
|
+
o.current = e;
|
|
1603
|
+
}), U(() => (o.current.onMount?.(), () => o.current.onDestroy?.()), []), U(() => {
|
|
1604
|
+
if (r)
|
|
1605
|
+
return o.current.onFocus?.(), () => o.current.onBlur?.();
|
|
1606
|
+
}, [r]), U(() => t?.registerRemovalGuard(n?.key, (a) => o.current.onBeforeRemove?.(a)), [t, n?.key]);
|
|
1607
|
+
}
|
|
1608
|
+
function Wr({ values: e, initialValues: t, equals: n = Object.is, message: r, onBeforeDiscard: o }) {
|
|
1609
|
+
const [a, l] = xe(() => t), f = !n(a, e);
|
|
1610
|
+
hr(f, { message: r, onBeforeDiscard: o });
|
|
1611
|
+
const u = _((i = e) => l(() => i), [e]);
|
|
1612
|
+
return { dirty: f, markSaved: u };
|
|
1613
|
+
}
|
|
1614
|
+
const kr = (e, t) => e && t && Object.keys(e).length === Object.keys(t).length && Object.keys(e).every((n) => Object.hasOwn(t, n) && Object.is(e[n], t[n]));
|
|
1615
|
+
function xr(e, t) {
|
|
1616
|
+
let n, r, o, a = !1, l = !1, f = !1, u = 0, i = -1;
|
|
1617
|
+
const d = (h) => {
|
|
1618
|
+
try {
|
|
1619
|
+
a && n?.onError ? Promise.resolve(n.onError(h)).catch((s) => console.error(s)) : console.error(h);
|
|
1620
|
+
} catch (s) {
|
|
1621
|
+
console.error(s);
|
|
1622
|
+
}
|
|
1623
|
+
}, g = (h, ...s) => {
|
|
1624
|
+
if (a)
|
|
1625
|
+
try {
|
|
1626
|
+
Promise.resolve(n[h]?.(...s)).catch(d);
|
|
1627
|
+
} catch (v) {
|
|
1628
|
+
d(v);
|
|
1629
|
+
}
|
|
1630
|
+
}, b = () => {
|
|
1631
|
+
f = !0, l || x();
|
|
1632
|
+
};
|
|
1633
|
+
async function x() {
|
|
1634
|
+
l = !0;
|
|
1635
|
+
try {
|
|
1636
|
+
for (; f; ) {
|
|
1637
|
+
if (f = !1, !a) {
|
|
1638
|
+
r?.dispose();
|
|
1639
|
+
continue;
|
|
1640
|
+
}
|
|
1641
|
+
const h = n;
|
|
1642
|
+
if (!h) continue;
|
|
1643
|
+
const s = u;
|
|
1644
|
+
if (!h.open) {
|
|
1645
|
+
r?.isActive() && i !== s && (i = s, !await r.close() && u === s && g("onBlocked", "close"));
|
|
1646
|
+
continue;
|
|
1647
|
+
}
|
|
1648
|
+
if (!r?.isActive()) {
|
|
1649
|
+
if (i === s) continue;
|
|
1650
|
+
i = s;
|
|
1651
|
+
const v = await e.openInstance(
|
|
1652
|
+
{ component: t, title: h.title },
|
|
1653
|
+
{ children: h.children, title: h.title },
|
|
1654
|
+
h.options
|
|
1655
|
+
);
|
|
1656
|
+
if (r = v, o = h, !v.isActive()) {
|
|
1657
|
+
u === s && g("onBlocked", "open");
|
|
1658
|
+
continue;
|
|
1659
|
+
}
|
|
1660
|
+
if (v.result.then((I) => {
|
|
1661
|
+
r === v && (r = null, o = null, n.open && u === i && g("onOpenChange", !1, I), b());
|
|
1662
|
+
}).catch(d), !a) {
|
|
1663
|
+
v.dispose();
|
|
1664
|
+
continue;
|
|
1665
|
+
}
|
|
1666
|
+
if (!n.open) {
|
|
1667
|
+
f = !0;
|
|
1668
|
+
continue;
|
|
1669
|
+
}
|
|
1670
|
+
if (!await v.ready || !v.isActive()) continue;
|
|
1671
|
+
f = !0;
|
|
1672
|
+
continue;
|
|
1673
|
+
}
|
|
1674
|
+
i = s, !(!kr(o?.options, h.options) && !r.replaceOptions(h.options)) && ((!o || !Object.is(o.children, h.children) || !Object.is(o.title, h.title)) && !r.setParams({ children: h.children, title: h.title }) || (o = h));
|
|
1675
|
+
}
|
|
1676
|
+
} catch (h) {
|
|
1677
|
+
d(h);
|
|
1678
|
+
} finally {
|
|
1679
|
+
l = !1, f && b();
|
|
1680
|
+
}
|
|
1681
|
+
}
|
|
1682
|
+
return {
|
|
1683
|
+
mount() {
|
|
1684
|
+
a = !0;
|
|
1685
|
+
},
|
|
1686
|
+
update(h) {
|
|
1687
|
+
(!n || n.open !== h.open) && u++, n = h, b();
|
|
1688
|
+
},
|
|
1689
|
+
unmount() {
|
|
1690
|
+
a = !1, queueMicrotask(() => {
|
|
1691
|
+
a || (r?.dispose(), b());
|
|
1692
|
+
});
|
|
1693
|
+
}
|
|
1694
|
+
};
|
|
1695
|
+
}
|
|
1696
|
+
function Sr() {
|
|
1697
|
+
const { children: e, title: t } = yr(), n = cn();
|
|
1698
|
+
return Ae(() => {
|
|
1699
|
+
n.setOptions({ title: t });
|
|
1700
|
+
}, [n, t]), e;
|
|
1701
|
+
}
|
|
1702
|
+
function Gr({ open: e, onOpenChange: t, onBlocked: n, onError: r, children: o, title: a, ...l }) {
|
|
1703
|
+
const f = Bt(), u = Q(() => xr(f, Sr), [f]);
|
|
1704
|
+
return U(() => (u.mount(), u.unmount), [u]), U(() => {
|
|
1705
|
+
u.update({
|
|
1706
|
+
open: e,
|
|
1707
|
+
onOpenChange: t,
|
|
1708
|
+
onBlocked: n,
|
|
1709
|
+
onError: r,
|
|
1710
|
+
children: o,
|
|
1711
|
+
title: a,
|
|
1712
|
+
options: { ...l, instanceKey: void 0, duplicateStrategy: "allow" }
|
|
1713
|
+
});
|
|
1714
|
+
}), null;
|
|
1715
|
+
}
|
|
1716
|
+
function Cr({ inspector: e }) {
|
|
1717
|
+
const { active: t, queueSize: n, events: r } = Oe(e.subscribe, e.getSnapshot, e.getSnapshot);
|
|
1718
|
+
return /* @__PURE__ */ be("details", { style: { font: "12px monospace", padding: 12, border: "1px solid #888", borderRadius: 8 }, children: [
|
|
1719
|
+
/* @__PURE__ */ be("summary", { children: [
|
|
1720
|
+
"Modal DevTools · ",
|
|
1721
|
+
t?.name ?? "Idle"
|
|
1722
|
+
] }),
|
|
1723
|
+
/* @__PURE__ */ be("p", { children: [
|
|
1724
|
+
"Queue: ",
|
|
1725
|
+
n,
|
|
1726
|
+
" · Loading: ",
|
|
1727
|
+
t?.loadingCount ?? 0,
|
|
1728
|
+
" · Tasks: ",
|
|
1729
|
+
t?.taskCount ?? 0
|
|
1730
|
+
] }),
|
|
1731
|
+
/* @__PURE__ */ p("button", { type: "button", onClick: e.refresh, children: "Refresh" }),
|
|
1732
|
+
" ",
|
|
1733
|
+
/* @__PURE__ */ p("button", { type: "button", onClick: e.clear, children: "Clear events" }),
|
|
1734
|
+
/* @__PURE__ */ p("ol", { children: t?.routes.map((o) => /* @__PURE__ */ be("li", { children: [
|
|
1735
|
+
o.name,
|
|
1736
|
+
o.key === t.focusedKey ? " (focused)" : ""
|
|
1737
|
+
] }, o.key)) }),
|
|
1738
|
+
/* @__PURE__ */ p("ol", { style: { maxHeight: 240, overflow: "auto" }, children: r.map((o) => /* @__PURE__ */ be("li", { children: [
|
|
1739
|
+
o.sequence,
|
|
1740
|
+
" · ",
|
|
1741
|
+
o.type,
|
|
1742
|
+
" ",
|
|
1743
|
+
o.id ?? ""
|
|
1744
|
+
] }, o.sequence)) })
|
|
1745
|
+
] });
|
|
1746
|
+
}
|
|
1747
|
+
function _r({ enabled: e = !1, limit: t = 100 }) {
|
|
1748
|
+
const n = Bt(), [r, o] = xe(null);
|
|
1749
|
+
return U(() => {
|
|
1750
|
+
if (!e) {
|
|
1751
|
+
o(null);
|
|
1752
|
+
return;
|
|
1753
|
+
}
|
|
1754
|
+
const a = n.inspect({ limit: t });
|
|
1755
|
+
return o(a), a.dispose;
|
|
1756
|
+
}, [n, e, t]), e && r ? /* @__PURE__ */ p(Cr, { inspector: r }) : null;
|
|
1020
1757
|
}
|
|
1021
1758
|
export {
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1759
|
+
Gr as Modal,
|
|
1760
|
+
_r as ModalDevTools,
|
|
1761
|
+
Hn as ModalNavigator,
|
|
1762
|
+
Tr as ModalProvider,
|
|
1763
|
+
Or as defineModal,
|
|
1764
|
+
Pr as lazyModal,
|
|
1765
|
+
He as shallowEqual,
|
|
1766
|
+
Ar as useFocusEffect,
|
|
1767
|
+
jt as useIsFocused,
|
|
1768
|
+
Lr as useModal,
|
|
1769
|
+
Bt as useModalCommands,
|
|
1770
|
+
jr as useModalFooter,
|
|
1771
|
+
Wr as useModalFormGuard,
|
|
1772
|
+
Ir as useModalFullscreen,
|
|
1773
|
+
Dr as useModalHeader,
|
|
1774
|
+
Kr as useModalLayout,
|
|
1775
|
+
Hr as useModalLifecycle,
|
|
1776
|
+
Br as useModalLoading,
|
|
1777
|
+
fr as useModalLoadingCommands,
|
|
1778
|
+
qr as useModalLoadingState,
|
|
1779
|
+
zr as useModalNavigation,
|
|
1780
|
+
cn as useModalNavigationCommands,
|
|
1781
|
+
mr as useModalNavigationState,
|
|
1782
|
+
yr as useModalParams,
|
|
1783
|
+
gr as useModalRoute,
|
|
1784
|
+
br as useModalStatus,
|
|
1785
|
+
Fr as useModalTask,
|
|
1786
|
+
hr as useModalUnsavedChanges,
|
|
1787
|
+
Nr as useNavigationResult,
|
|
1788
|
+
$r as useToast
|
|
1040
1789
|
};
|