react-modal-navigation 1.1.9 → 1.1.10
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 +7 -0
- package/README.md +18 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +474 -471
- package/dist/style.css +8 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { jsx as s, jsxs as
|
|
2
|
-
import be, { createContext as
|
|
3
|
-
import { createPortal as
|
|
4
|
-
const yn =
|
|
1
|
+
import { jsx as s, jsxs as ce } from "react/jsx-runtime";
|
|
2
|
+
import be, { createContext as ie, useRef as l, useState as pe, useEffect as Q, useCallback as w, useMemo as K, useSyncExternalStore as fe, useLayoutEffect as He, Suspense as bn, useReducer as qn, useInsertionEffect as zn, useContext as oe } from "react";
|
|
3
|
+
import { createPortal as On } from "react-dom";
|
|
4
|
+
const yn = ie(null), vn = ie(null), je = ie(null), Me = ie(null), tn = ie(null), rn = ie(null), _e = ie(null), We = ie(null), Ue = ie(null), xn = ie(null), wn = ie(null), on = ie(null);
|
|
5
5
|
function kn(e) {
|
|
6
6
|
let n = e;
|
|
7
7
|
const r = /* @__PURE__ */ new Set();
|
|
@@ -11,7 +11,7 @@ function kn(e) {
|
|
|
11
11
|
publish(t) {
|
|
12
12
|
if (n !== t) {
|
|
13
13
|
n = t;
|
|
14
|
-
for (const
|
|
14
|
+
for (const i of [...r]) i();
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
17
|
listenerCount: () => r.size
|
|
@@ -26,7 +26,7 @@ function Te(e) {
|
|
|
26
26
|
publish(t) {
|
|
27
27
|
if (!Object.is(n, t)) {
|
|
28
28
|
n = t;
|
|
29
|
-
for (const
|
|
29
|
+
for (const i of [...r]) i();
|
|
30
30
|
}
|
|
31
31
|
},
|
|
32
32
|
listenerCount: () => r.size
|
|
@@ -40,7 +40,7 @@ function Ke(e, n) {
|
|
|
40
40
|
return Sn(n.name, n.params);
|
|
41
41
|
case "NAVIGATE": {
|
|
42
42
|
const r = e.findIndex((t) => t.name === n.name);
|
|
43
|
-
return r < 0 ? [...e, nn(n.name, n.params)] : e.slice(0, r + 1).map((t,
|
|
43
|
+
return r < 0 ? [...e, nn(n.name, n.params)] : e.slice(0, r + 1).map((t, i) => i === r ? { ...t, params: n.params ?? {} } : t);
|
|
44
44
|
}
|
|
45
45
|
case "SET_OPTIONS":
|
|
46
46
|
return e.map((r, t) => t === e.length - 1 ? { ...r, options: { ...r.options ?? {}, ...n.options ?? {} } } : r);
|
|
@@ -54,87 +54,87 @@ function Ke(e, n) {
|
|
|
54
54
|
return e;
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
function
|
|
58
|
-
const t = r === 1 / 0 ? 1 / 0 : Math.max(0, Math.floor(Number(r) || 0)),
|
|
57
|
+
function $n(e, n, r = 1 / 0) {
|
|
58
|
+
const t = r === 1 / 0 ? 1 / 0 : Math.max(0, Math.floor(Number(r) || 0)), i = e.slice(0, -1).filter((p) => n[p.name]?.keepAlive !== !1), g = new Set((t === 0 ? [] : i.slice(-t)).map((p) => p.key));
|
|
59
59
|
return e.filter((p, f) => f === e.length - 1 || g.has(p.key));
|
|
60
60
|
}
|
|
61
|
-
const
|
|
61
|
+
const jn = Object.freeze({ sm: 400, md: 560, lg: 720, xl: 960, full: "100%" }), Fe = (e) => typeof e == "number" ? `${e}px` : e, pn = () => {
|
|
62
62
|
if (typeof document > "u") return "light";
|
|
63
63
|
const e = document.documentElement, n = document.body;
|
|
64
64
|
return e.classList.contains("dark") || n.classList.contains("dark") || e.dataset.theme === "dark" || n.dataset.theme === "dark" ? "dark" : e.classList.contains("light") || n.classList.contains("light") || e.dataset.theme === "light" || n.dataset.theme === "light" ? "light" : window.matchMedia?.("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
65
65
|
};
|
|
66
|
-
let
|
|
66
|
+
let $e = 0;
|
|
67
67
|
const xe = [];
|
|
68
68
|
let Xe = null;
|
|
69
69
|
function In() {
|
|
70
|
-
if (
|
|
71
|
-
const n = document.documentElement, r = document.body, t = { html: n.style.overflow, body: r.style.overflow, padding: r.style.paddingRight, width: r.style.getPropertyValue("--modal-scrollbar-width") },
|
|
72
|
-
|
|
70
|
+
if ($e++, $e === 1) {
|
|
71
|
+
const n = document.documentElement, r = document.body, t = { html: n.style.overflow, body: r.style.overflow, padding: r.style.paddingRight, width: r.style.getPropertyValue("--modal-scrollbar-width") }, i = Math.max(0, window.innerWidth - n.clientWidth), g = parseFloat(getComputedStyle(r).paddingRight) || 0;
|
|
72
|
+
i && (r.style.paddingRight = `${g + i}px`), r.style.setProperty("--modal-scrollbar-width", `${i}px`), n.style.overflow = "hidden", r.style.overflow = "hidden", Xe = () => {
|
|
73
73
|
n.style.overflow = t.html, r.style.overflow = t.body, r.style.paddingRight = t.padding, t.width ? r.style.setProperty("--modal-scrollbar-width", t.width) : r.style.removeProperty("--modal-scrollbar-width");
|
|
74
74
|
};
|
|
75
75
|
}
|
|
76
76
|
let e = !1;
|
|
77
77
|
return () => {
|
|
78
|
-
e || (e = !0,
|
|
78
|
+
e || (e = !0, $e = Math.max(0, $e - 1), $e || (Xe?.(), Xe = null));
|
|
79
79
|
};
|
|
80
80
|
}
|
|
81
81
|
const Dn = '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";
|
|
82
|
-
function En({ dialogRef: e, options: n, requestClose: r, children: t, exiting:
|
|
82
|
+
function En({ dialogRef: e, options: n, requestClose: r, children: t, exiting: i = !1 }) {
|
|
83
83
|
const g = l(null), p = l(null), f = l(r);
|
|
84
84
|
f.current = r;
|
|
85
85
|
const u = l(n.closeOnEsc);
|
|
86
86
|
u.current = n.closeOnEsc;
|
|
87
|
-
const [
|
|
87
|
+
const [y, M] = pe(pn), k = n.theme === "light" || n.theme === "dark" ? n.theme : y;
|
|
88
88
|
Q(() => {
|
|
89
89
|
if (n.theme === "light" || n.theme === "dark") return;
|
|
90
|
-
const
|
|
91
|
-
for (const
|
|
92
|
-
const
|
|
93
|
-
return
|
|
94
|
-
|
|
90
|
+
const O = () => M(pn()), F = new MutationObserver(O);
|
|
91
|
+
for (const J of [document.documentElement, document.body]) F.observe(J, { attributes: !0, attributeFilter: ["class", "data-theme"] });
|
|
92
|
+
const U = window.matchMedia?.("(prefers-color-scheme: dark)");
|
|
93
|
+
return U?.addEventListener?.("change", O), O(), () => {
|
|
94
|
+
F.disconnect(), U?.removeEventListener?.("change", O);
|
|
95
95
|
};
|
|
96
96
|
}, [n.theme]), Q(() => {
|
|
97
97
|
p.current = document.activeElement;
|
|
98
|
-
const
|
|
99
|
-
xe.push(
|
|
100
|
-
const
|
|
101
|
-
const
|
|
102
|
-
if (!
|
|
103
|
-
if (
|
|
104
|
-
|
|
98
|
+
const O = In(), F = g.current;
|
|
99
|
+
xe.push(F), e.current?.focus({ preventScroll: !0 });
|
|
100
|
+
const U = (E) => {
|
|
101
|
+
const _ = e.current;
|
|
102
|
+
if (!_ || xe.at(-1) !== F) return;
|
|
103
|
+
if (E.key === "Escape" && u.current !== !1) {
|
|
104
|
+
E.preventDefault(), f.current("escape");
|
|
105
105
|
return;
|
|
106
106
|
}
|
|
107
|
-
if (
|
|
108
|
-
const
|
|
109
|
-
if (!
|
|
110
|
-
|
|
107
|
+
if (E.key !== "Tab") return;
|
|
108
|
+
const q = [..._.querySelectorAll(Dn)].filter(Kn);
|
|
109
|
+
if (!q.length) {
|
|
110
|
+
E.preventDefault(), _.focus();
|
|
111
111
|
return;
|
|
112
112
|
}
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
},
|
|
116
|
-
xe.at(-1) ===
|
|
113
|
+
const re = q[0], X = q.at(-1);
|
|
114
|
+
_.contains(document.activeElement) ? E.shiftKey && (document.activeElement === re || document.activeElement === _) ? (E.preventDefault(), X.focus()) : !E.shiftKey && (document.activeElement === X || document.activeElement === _) && (E.preventDefault(), re.focus()) : (E.preventDefault(), (E.shiftKey ? X : re).focus());
|
|
115
|
+
}, J = (E) => {
|
|
116
|
+
xe.at(-1) === F && e.current && !e.current.contains(E.target) && e.current.focus({ preventScroll: !0 });
|
|
117
117
|
};
|
|
118
|
-
return document.addEventListener("keydown",
|
|
119
|
-
document.removeEventListener("keydown",
|
|
120
|
-
const
|
|
121
|
-
if (
|
|
122
|
-
const
|
|
123
|
-
|
|
118
|
+
return document.addEventListener("keydown", U), document.addEventListener("focusin", J), () => {
|
|
119
|
+
document.removeEventListener("keydown", U), document.removeEventListener("focusin", J);
|
|
120
|
+
const E = xe.at(-1) === F, _ = xe.indexOf(F);
|
|
121
|
+
if (_ !== -1 && xe.splice(_, 1), O(), E) {
|
|
122
|
+
const q = p.current;
|
|
123
|
+
q?.isConnected && !q.closest("[inert], [hidden]") ? q.focus?.({ preventScroll: !0 }) : xe.at(-1)?.querySelector("[role=dialog]")?.focus?.({ preventScroll: !0 });
|
|
124
124
|
}
|
|
125
125
|
};
|
|
126
126
|
}, [e]);
|
|
127
|
-
const d = n.backgroundColor ?? n.backgroudColor, m = typeof d == "string" ? d : d?.[k], a = typeof m == "string" && /^(#|rgb
|
|
128
|
-
return
|
|
127
|
+
const d = n.backgroundColor ?? n.backgroudColor, m = typeof d == "string" ? d : d?.[k], a = typeof m == "string" && /^(#|(?:rgb|rgba|hsl|hsla|hwb|oklch|oklab|lab|lch|color|color-mix|light-dark|var)\(|transparent$|currentColor$|[a-z]+$)/i.test(m.trim()) ? m.trim() : null, P = typeof m == "string" && !a ? m.trim() : "", N = !!(a || P), D = ["center", "left", "right", "top", "bottom"].includes(n.placement) ? n.placement : "right", L = Fe(n.width ?? jn[n.size] ?? 460), G = Fe(n.height), x = Fe(n.maxHeight), B = Fe(n.maxWidth), $ = Number(n.viewportGap ?? 5), H = Number.isFinite($) ? Math.max(0, $) : 5, T = n.top == null ? null : Fe(n.top), v = D === "top" && T !== null ? T : null, j = typeof n.borderRadius == "number" ? `${n.borderRadius}px` : n.borderRadius ?? "12px";
|
|
128
|
+
return On(/* @__PURE__ */ s(
|
|
129
129
|
"div",
|
|
130
130
|
{
|
|
131
131
|
ref: g,
|
|
132
|
-
className: `pmn-overlay ${
|
|
133
|
-
style: { padding:
|
|
134
|
-
onMouseDown: (
|
|
135
|
-
|
|
132
|
+
className: `pmn-overlay ${i ? "pmn-exiting" : "pmn-entering"} ${n.animation === !1 ? "pmn-no-animation" : ""} pmn-place-${D} ${n.mobileFullscreen ? "pmn-mobile-fullscreen" : ""}`,
|
|
133
|
+
style: { padding: H, ...v !== null ? { paddingTop: v, "--pmn-top-offset": v } : {}, "--pmn-animation-duration": `${Math.min(1e3, Math.max(0, Number(n.animationDuration ?? 220) || 0))}ms` },
|
|
134
|
+
onMouseDown: (O) => {
|
|
135
|
+
O.target === O.currentTarget && n.closeOnOverlay === !0 && f.current("overlay");
|
|
136
136
|
},
|
|
137
|
-
children: /* @__PURE__ */
|
|
137
|
+
children: /* @__PURE__ */ ce(
|
|
138
138
|
"section",
|
|
139
139
|
{
|
|
140
140
|
ref: e,
|
|
@@ -143,9 +143,12 @@ function En({ dialogRef: e, options: n, requestClose: r, children: t, exiting: c
|
|
|
143
143
|
"aria-modal": "true",
|
|
144
144
|
"aria-label": n.ariaLabel ?? "Dialog",
|
|
145
145
|
"data-modal-theme": k,
|
|
146
|
-
className: `pmn-dialog ${k === "dark" ? "dark" : ""} ${
|
|
147
|
-
style: { "--pmn-width": L, "--pmn-gap": `${
|
|
148
|
-
children:
|
|
146
|
+
className: `pmn-dialog ${k === "dark" ? "dark" : ""} ${N ? "pmn-has-custom-background" : ""} ${n.className ?? ""}`,
|
|
147
|
+
style: { "--pmn-width": L, "--pmn-gap": `${H}px`, ...v !== null ? { "--pmn-top-offset": v } : {}, ...G !== void 0 ? { "--pmn-height": G } : {}, ...x !== void 0 ? { "--pmn-max-height": x } : {}, ...B !== void 0 ? { "--pmn-max-width": B } : {}, borderRadius: j },
|
|
148
|
+
children: [
|
|
149
|
+
N && /* @__PURE__ */ s("div", { "aria-hidden": "true", className: `pmn-custom-background-layer ${P}`, style: a ? { backgroundColor: a } : void 0 }),
|
|
150
|
+
t
|
|
151
|
+
]
|
|
149
152
|
}
|
|
150
153
|
)
|
|
151
154
|
}
|
|
@@ -154,65 +157,65 @@ function En({ dialogRef: e, options: n, requestClose: r, children: t, exiting: c
|
|
|
154
157
|
function fn({ back: e }) {
|
|
155
158
|
return /* @__PURE__ */ s("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", width: "20", height: "20", fill: "none", stroke: "currentColor", strokeWidth: "2", children: e ? /* @__PURE__ */ s("path", { d: "m15 18-6-6 6-6" }) : /* @__PURE__ */ s("path", { d: "M18 6 6 18M6 6l12 12" }) });
|
|
156
159
|
}
|
|
157
|
-
function Rn({ options: e, screen: n, route: r, navigation: t, requestClose:
|
|
160
|
+
function Rn({ options: e, screen: n, route: r, navigation: t, requestClose: i, translate: g, canGoBack: p }) {
|
|
158
161
|
if (e.showHeader === !1) return null;
|
|
159
|
-
const f = g ?? ((m) => m), u = n.showTitle ?? e.showTitle ?? !0,
|
|
160
|
-
if (k) return k(
|
|
162
|
+
const f = g ?? ((m) => m), u = n.showTitle ?? e.showTitle ?? !0, y = typeof n.title == "function" ? n.title({ t: f, route: r, navigation: t }) : n.title ?? r.name, M = { route: r, navigation: t, close: i, canGoBack: p, title: y, t: f }, k = n.renderHeader ?? e.renderHeader;
|
|
163
|
+
if (k) return k(M);
|
|
161
164
|
const d = n.renderHeaderRight ?? e.renderHeaderRight;
|
|
162
|
-
return /* @__PURE__ */
|
|
165
|
+
return /* @__PURE__ */ ce("header", { className: `pmn-header ${n.showHeaderBorder ?? e.showHeaderBorder ? "pmn-border-bottom" : ""} ${e.headerClassName ?? ""}`, children: [
|
|
163
166
|
(n.showBackButton ?? e.showBackButton) !== !1 && p && /* @__PURE__ */ s("button", { type: "button", className: "pmn-icon-button", "aria-label": f("modal.back"), onClick: () => t.goBack(), children: /* @__PURE__ */ s(fn, { back: !0 }) }),
|
|
164
|
-
u ? /* @__PURE__ */ s("h2", { children:
|
|
165
|
-
d?.(
|
|
166
|
-
e.showCloseButton !== !1 && /* @__PURE__ */ s("button", { type: "button", className: "pmn-icon-button", "aria-label": f("modal.close"), onClick: () =>
|
|
167
|
+
u ? /* @__PURE__ */ s("h2", { children: y }) : /* @__PURE__ */ s("div", { className: "pmn-header-spacer" }),
|
|
168
|
+
d?.(M),
|
|
169
|
+
e.showCloseButton !== !1 && /* @__PURE__ */ s("button", { type: "button", className: "pmn-icon-button", "aria-label": f("modal.close"), onClick: () => i("header"), children: /* @__PURE__ */ s(fn, {}) })
|
|
167
170
|
] });
|
|
168
171
|
}
|
|
169
|
-
function Cn({ screen: e, options: n, override: r, route: t, navigation:
|
|
170
|
-
const [
|
|
172
|
+
function Cn({ screen: e, options: n, override: r, route: t, navigation: i, requestClose: g, translate: p, onError: f, loadingApi: u }) {
|
|
173
|
+
const [y, M] = pe(null), k = l(/* @__PURE__ */ new Set()), d = l(!0);
|
|
171
174
|
Q(() => (d.current = !0, () => {
|
|
172
175
|
d.current = !1;
|
|
173
176
|
}), []);
|
|
174
|
-
const m = p ?? ((
|
|
175
|
-
if (
|
|
176
|
-
const
|
|
177
|
-
if (typeof
|
|
178
|
-
const
|
|
179
|
-
if (!
|
|
180
|
-
const
|
|
181
|
-
if (k.current.has(
|
|
182
|
-
k.current.add(
|
|
183
|
-
const
|
|
177
|
+
const m = p ?? ((v) => v), a = { ...n, ...e, ...r }, { showFooter: P, renderFooter: N, done: D, cancel: L, cancle: G } = a, x = L ?? G, B = { route: t, navigation: i, close: g, t: m };
|
|
178
|
+
if (P === !1) return null;
|
|
179
|
+
const $ = `pmn-footer ${a.showFooterBorder ? "pmn-border-top" : ""} ${a.footerClassName ?? ""}`;
|
|
180
|
+
if (typeof N == "function") return /* @__PURE__ */ s("footer", { className: $, children: N({ ...B, pending: k.current.size > 0 }) });
|
|
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"));
|
|
184
187
|
try {
|
|
185
|
-
await
|
|
186
|
-
} catch (
|
|
187
|
-
f?.(
|
|
188
|
+
await j(B);
|
|
189
|
+
} catch (U) {
|
|
190
|
+
f?.(U, { phase: "footer", action: v, route: t });
|
|
188
191
|
} finally {
|
|
189
|
-
u?.end(t.key,
|
|
192
|
+
u?.end(t.key, F), k.current.delete(v), d.current && M((U) => U === v ? null : U);
|
|
190
193
|
}
|
|
191
194
|
};
|
|
192
|
-
return
|
|
193
|
-
const
|
|
195
|
+
return H ? /* @__PURE__ */ s("footer", { className: $, children: H.filter((v) => !v.hidden).map((v) => {
|
|
196
|
+
const j = k.current.has(v.key) || v.loading === !0;
|
|
194
197
|
return /* @__PURE__ */ s(
|
|
195
198
|
"button",
|
|
196
199
|
{
|
|
197
200
|
type: "button",
|
|
198
|
-
disabled:
|
|
199
|
-
className: `pmn-button ${
|
|
200
|
-
onClick: () =>
|
|
201
|
-
children:
|
|
201
|
+
disabled: v.disabled === !0 || j,
|
|
202
|
+
className: `pmn-button ${v.variant === "primary" || v.variant === "danger" ? "pmn-button-primary" : "pmn-button-secondary"} ${v.variant === "danger" ? "pmn-button-danger" : ""}`,
|
|
203
|
+
onClick: () => T(v.key, v.onClick, v.loadingText),
|
|
204
|
+
children: j ? v.loadingText ?? a.loadingText ?? m("modal.processing") : v.label
|
|
202
205
|
},
|
|
203
|
-
|
|
206
|
+
v.key
|
|
204
207
|
);
|
|
205
|
-
}) }) : /* @__PURE__ */
|
|
206
|
-
typeof x == "function" && /* @__PURE__ */ s("button", { type: "button", disabled:
|
|
207
|
-
typeof D == "function" && /* @__PURE__ */ s("button", { type: "button", disabled:
|
|
208
|
+
}) }) : /* @__PURE__ */ ce("footer", { className: $, children: [
|
|
209
|
+
typeof x == "function" && /* @__PURE__ */ s("button", { type: "button", disabled: y !== null, onClick: () => T("cancel", x), className: "pmn-button pmn-button-secondary", children: a.cancelText ?? m("modal.cancel") }),
|
|
210
|
+
typeof D == "function" && /* @__PURE__ */ s("button", { type: "button", disabled: y !== null || a.doneDisabled === !0, onClick: () => T("done", D), className: "pmn-button pmn-button-primary", children: y === "done" ? a.loadingText ?? m("modal.processing") : a.doneText ?? m("modal.done") })
|
|
208
211
|
] });
|
|
209
212
|
}
|
|
210
213
|
function Tn({ loading: e, translate: n }) {
|
|
211
214
|
if (!e.visible) return null;
|
|
212
|
-
const t = (n ?? ((g) => g))("modal.loading"),
|
|
213
|
-
return /* @__PURE__ */ s("div", { className: "pmn-loading-overlay", role: "status", "aria-live": "polite", "aria-busy": "true", children: /* @__PURE__ */
|
|
215
|
+
const t = (n ?? ((g) => g))("modal.loading"), i = e.text ?? (t === "modal.loading" ? "加载中..." : t);
|
|
216
|
+
return /* @__PURE__ */ s("div", { className: "pmn-loading-overlay", role: "status", "aria-live": "polite", "aria-busy": "true", children: /* @__PURE__ */ ce("div", { className: "pmn-loading-content", children: [
|
|
214
217
|
/* @__PURE__ */ s("span", { className: "pmn-spinner", "aria-hidden": "true" }),
|
|
215
|
-
|
|
218
|
+
i && /* @__PURE__ */ s("span", { className: "pmn-loading-text", children: i })
|
|
216
219
|
] }) });
|
|
217
220
|
}
|
|
218
221
|
class Mn extends be.Component {
|
|
@@ -227,7 +230,7 @@ class Mn extends be.Component {
|
|
|
227
230
|
n.route?.key !== this.props.route?.key && this.state.error && this.setState({ error: null });
|
|
228
231
|
}
|
|
229
232
|
render() {
|
|
230
|
-
return this.state.error ? /* @__PURE__ */
|
|
233
|
+
return this.state.error ? /* @__PURE__ */ ce("div", { role: "alert", className: "pmn-error-screen", children: [
|
|
231
234
|
/* @__PURE__ */ s("strong", { children: "页面加载失败" }),
|
|
232
235
|
/* @__PURE__ */ s("p", { children: this.state.error.message }),
|
|
233
236
|
/* @__PURE__ */ s("button", { type: "button", className: "pmn-button pmn-button-secondary", onClick: () => this.setState({ error: null }), children: "重试" })
|
|
@@ -236,69 +239,69 @@ class Mn extends be.Component {
|
|
|
236
239
|
}
|
|
237
240
|
const Gn = { success: "✓", error: "×", warning: "!", info: "i" };
|
|
238
241
|
function Pn({ items: e, dismiss: n }) {
|
|
239
|
-
return e.length ? /* @__PURE__ */ s("div", { className: "pmn-toast-region", "aria-label": "Notifications", children: e.map((r) => /* @__PURE__ */
|
|
242
|
+
return e.length ? /* @__PURE__ */ s("div", { className: "pmn-toast-region", "aria-label": "Notifications", children: e.map((r) => /* @__PURE__ */ ce("div", { className: `pmn-toast pmn-toast-${r.type}`, role: r.type === "error" || r.type === "warning" ? "alert" : "status", children: [
|
|
240
243
|
/* @__PURE__ */ s("span", { className: "pmn-toast-symbol", "aria-hidden": "true", children: Gn[r.type] }),
|
|
241
244
|
/* @__PURE__ */ s("span", { className: "pmn-toast-message", children: r.message }),
|
|
242
245
|
r.dismissible && /* @__PURE__ */ s("button", { type: "button", className: "pmn-toast-close", "aria-label": "Dismiss notification", onClick: () => n(r.id), children: "×" })
|
|
243
246
|
] }, r.id)) }) : null;
|
|
244
247
|
}
|
|
245
248
|
function Nn(e, n) {
|
|
246
|
-
const r = l(0), t = l(/* @__PURE__ */ new Map()),
|
|
249
|
+
const r = l(0), t = l(/* @__PURE__ */ new Map()), i = w((f) => {
|
|
247
250
|
clearTimeout(t.current.get(f)), t.current.delete(f), n.current && e.current.publish(e.current.getSnapshot().filter((u) => u.id !== f));
|
|
248
251
|
}, []), g = w((f, u = {}) => {
|
|
249
252
|
if (typeof f != "string" || !f.trim()) throw new TypeError("[react-modal-navigation] toast message must be a non-empty string");
|
|
250
|
-
const
|
|
253
|
+
const y = typeof u == "string" ? { type: u } : u ?? {}, M = ["success", "error", "warning", "info"].includes(y.type) ? y.type : "info", k = ++r.current, d = Number.isFinite(y.duration) ? Math.max(0, y.duration) : 3e3;
|
|
251
254
|
if (!n.current) return null;
|
|
252
255
|
const m = e.current.getSnapshot(), a = m.slice(0, Math.max(0, m.length - 4));
|
|
253
|
-
for (const
|
|
254
|
-
clearTimeout(t.current.get(
|
|
255
|
-
return e.current.publish([...m.slice(-4), { id: k, message: f, type:
|
|
256
|
-
}, [
|
|
257
|
-
const f = (u,
|
|
258
|
-
for (const u of ["success", "error", "warning", "info"]) f[u] = (
|
|
259
|
-
return f.promise = async (u,
|
|
260
|
-
const k = g(
|
|
256
|
+
for (const P of a)
|
|
257
|
+
clearTimeout(t.current.get(P.id)), t.current.delete(P.id);
|
|
258
|
+
return e.current.publish([...m.slice(-4), { id: k, message: f, type: M, dismissible: y.dismissible !== !1 }]), d > 0 && t.current.set(k, setTimeout(() => i(k), d)), k;
|
|
259
|
+
}, [i]), p = K(() => {
|
|
260
|
+
const f = (u, y) => g(u, y);
|
|
261
|
+
for (const u of ["success", "error", "warning", "info"]) f[u] = (y, M = {}) => g(y, { ...M, type: u });
|
|
262
|
+
return f.promise = async (u, y, M = {}) => {
|
|
263
|
+
const k = g(y.loading, { ...M, type: "info", duration: 0 });
|
|
261
264
|
try {
|
|
262
265
|
const d = await (typeof u == "function" ? u() : u);
|
|
263
|
-
k != null &&
|
|
264
|
-
const m = typeof
|
|
265
|
-
return m && g(m, { ...
|
|
266
|
+
k != null && i(k);
|
|
267
|
+
const m = typeof y.success == "function" ? y.success(d) : y.success;
|
|
268
|
+
return m && g(m, { ...M, type: "success" }), d;
|
|
266
269
|
} catch (d) {
|
|
267
|
-
k != null &&
|
|
268
|
-
const m = typeof
|
|
269
|
-
throw m && g(m, { ...
|
|
270
|
+
k != null && i(k);
|
|
271
|
+
const m = typeof y.error == "function" ? y.error(d) : y.error;
|
|
272
|
+
throw m && g(m, { ...M, type: "error" }), d;
|
|
270
273
|
}
|
|
271
|
-
}, f.dismiss =
|
|
274
|
+
}, f.dismiss = i, f.clear = () => {
|
|
272
275
|
for (const u of t.current.values()) clearTimeout(u);
|
|
273
276
|
t.current.clear(), e.current.publish([]);
|
|
274
277
|
}, f;
|
|
275
|
-
}, [g,
|
|
278
|
+
}, [g, i]);
|
|
276
279
|
return Q(() => () => {
|
|
277
280
|
for (const f of t.current.values()) clearTimeout(f);
|
|
278
281
|
t.current.clear();
|
|
279
|
-
}, []), { toast: p, dismissToast:
|
|
282
|
+
}, []), { toast: p, dismissToast: i };
|
|
280
283
|
}
|
|
281
284
|
function An(e, n, r) {
|
|
282
|
-
const t = l(/* @__PURE__ */ new Map()),
|
|
285
|
+
const t = l(/* @__PURE__ */ new Map()), i = l(0), g = w(() => {
|
|
283
286
|
if (!n.current) return;
|
|
284
287
|
const d = [...t.current.values()], m = { visible: d.length > 0, text: d.at(-1)?.text ?? null, count: d.length }, a = e.current.getSnapshot();
|
|
285
288
|
(a.visible !== m.visible || a.text !== m.text || a.count !== m.count) && e.current.publish(m);
|
|
286
289
|
}, []), p = w((d, m) => {
|
|
287
290
|
if (!n.current || d !== "global" && r.current !== d) return null;
|
|
288
|
-
const a = ++
|
|
291
|
+
const a = ++i.current;
|
|
289
292
|
return t.current.set(a, { owner: d, text: m }), g(), a;
|
|
290
293
|
}, [g]), f = w((d, m) => {
|
|
291
294
|
if (m != null)
|
|
292
295
|
t.current.get(m)?.owner === d && t.current.delete(m);
|
|
293
296
|
else
|
|
294
|
-
for (const [a,
|
|
297
|
+
for (const [a, P] of t.current) P.owner === d && t.current.delete(a);
|
|
295
298
|
g();
|
|
296
299
|
}, [g]), u = w((d, m) => {
|
|
297
300
|
d ? (f("global"), p("global", m)) : f("global");
|
|
298
|
-
}, [p, f]),
|
|
301
|
+
}, [p, f]), y = w((d, m, a) => {
|
|
299
302
|
m ? (f(d), p(d, a)) : f(d);
|
|
300
303
|
}, [p, f]);
|
|
301
|
-
return { loadingApi:
|
|
304
|
+
return { loadingApi: K(() => ({ setLoading: u, setScreenLoading: y, begin: p, end: f }), [u, y, p, f]), refreshLoading: g, loadingTasks: t, setLoading: u };
|
|
302
305
|
}
|
|
303
306
|
const Hn = be.memo(function({ store: n, translate: r }) {
|
|
304
307
|
const t = fe(n.subscribe, n.getSnapshot, n.getSnapshot);
|
|
@@ -307,210 +310,210 @@ const Hn = be.memo(function({ store: n, translate: r }) {
|
|
|
307
310
|
const t = fe(n.subscribe, n.getSnapshot, n.getSnapshot);
|
|
308
311
|
return /* @__PURE__ */ s(Pn, { items: t, dismiss: r });
|
|
309
312
|
}), Wn = be.memo(function({ store: n, routeKey: r, ...t }) {
|
|
310
|
-
const
|
|
311
|
-
return /* @__PURE__ */ s(Cn, { ...t, override:
|
|
312
|
-
}), Un = be.memo(function({ route: n, screen: r, navigation: t, focused:
|
|
313
|
-
const a = r.component,
|
|
313
|
+
const i = fe(n.subscribe, n.getSnapshot, n.getSnapshot);
|
|
314
|
+
return /* @__PURE__ */ s(Cn, { ...t, override: i[r] });
|
|
315
|
+
}), Un = be.memo(function({ route: n, screen: r, navigation: t, focused: i, resultEvent: g, setFooter: p, loadingApi: f, loadingStore: u, bodyClassName: y, notifyError: M, registerDirtyGuard: k, pageMotion: d, lazyFallback: m }) {
|
|
316
|
+
const a = r.component, P = l(null), N = l(!1);
|
|
314
317
|
He(() => {
|
|
315
|
-
const x =
|
|
316
|
-
if (
|
|
317
|
-
const
|
|
318
|
-
|
|
319
|
-
const
|
|
320
|
-
{ opacity: 1, transform: `translate3d(${
|
|
318
|
+
const x = i && !N.current;
|
|
319
|
+
if (N.current = i, !x || !d?.enabled || !P.current?.animate) return;
|
|
320
|
+
const B = d.direction === "back" ? -100 : 100;
|
|
321
|
+
P.current.style.zIndex = "2";
|
|
322
|
+
const $ = P.current.animate([
|
|
323
|
+
{ opacity: 1, transform: `translate3d(${B}%,0,0)` },
|
|
321
324
|
{ opacity: 1, transform: "translate3d(0,0,0)" }
|
|
322
325
|
], { duration: d.duration, easing: "cubic-bezier(.22,1,.36,1)" });
|
|
323
326
|
return () => {
|
|
324
|
-
|
|
327
|
+
$.cancel(), P.current && (P.current.style.zIndex = "");
|
|
325
328
|
};
|
|
326
|
-
}, [
|
|
327
|
-
const D =
|
|
328
|
-
setLoading: (x,
|
|
329
|
+
}, [i, d?.enabled, d?.direction, d?.duration, d?.distance]);
|
|
330
|
+
const D = K(() => ({ isFocused: i, resultEvent: g, routeKey: n.key, setFooter: p }), [i, g, n.key, p]), L = K(() => ({
|
|
331
|
+
setLoading: (x, B) => f.setScreenLoading(n.key, x, B),
|
|
329
332
|
showLoading: (x) => f.begin(n.key, x),
|
|
330
333
|
hideLoading: (x) => f.end(n.key, x)
|
|
331
|
-
}), [f, n.key]),
|
|
332
|
-
return /* @__PURE__ */ s(on.Provider, { value: n, children: /* @__PURE__ */ s(tn.Provider, { value:
|
|
334
|
+
}), [f, n.key]), G = K(() => ({ routeKey: n.key, registerDirtyGuard: k }), [n.key, k]);
|
|
335
|
+
return /* @__PURE__ */ s(on.Provider, { value: n, children: /* @__PURE__ */ s(tn.Provider, { value: G, children: /* @__PURE__ */ s(je.Provider, { value: D, children: /* @__PURE__ */ s(Me.Provider, { value: L, children: /* @__PURE__ */ s(Ue.Provider, { value: u, children: /* @__PURE__ */ s("div", { ref: P, hidden: !i, inert: !i, "data-modal-route-key": n.key, tabIndex: -1, className: `pmn-body ${i && d?.enabled && typeof Element < "u" && !Element.prototype.animate ? `pmn-page-enter pmn-page-${d.direction}` : ""} ${y ?? ""}`, style: i && d?.enabled ? { "--pmn-page-duration": `${d.duration}ms`, "--pmn-page-distance": `${d.distance}px` } : void 0, children: /* @__PURE__ */ s(Mn, { route: n, onError: M, children: /* @__PURE__ */ s(bn, { fallback: m ?? /* @__PURE__ */ s("div", { className: "pmn-lazy-loading", role: "status", "aria-live": "polite", children: "加载中..." }), children: /* @__PURE__ */ s(a, { route: n, navigation: t }) }) }) }) }) }) }) }) });
|
|
333
336
|
});
|
|
334
|
-
function Yn({ config: e, initialScreen: n, params: r, options: t, translate:
|
|
335
|
-
const [a,
|
|
336
|
-
|
|
337
|
-
const D = l(null),
|
|
338
|
-
D.current || (D.current = Te({ visible: !1, text: null, count: 0 })),
|
|
339
|
-
const x = l(!0),
|
|
337
|
+
function Yn({ config: e, initialScreen: n, params: r, options: t, translate: i, onRequestClose: g, onOpened: p, registerLoading: f, notifyError: u, error: y, clearError: M, registerDirtyGuard: k, canNavigate: d, exiting: m = !1 }) {
|
|
338
|
+
const [a, P] = qn(Ke, null, () => Sn(n ?? e.initialRoute, r)), N = l(null);
|
|
339
|
+
N.current || (N.current = kn({ canGoBack: a.length > 1, stack: a, currentRoute: a.at(-1) }));
|
|
340
|
+
const D = l(null), L = l(null), G = l(null);
|
|
341
|
+
D.current || (D.current = Te({ visible: !1, text: null, count: 0 })), L.current || (L.current = Te({})), G.current || (G.current = Te([]));
|
|
342
|
+
const x = l(!0), B = l(0), { toast: $, dismissToast: H } = Nn(G, x);
|
|
340
343
|
Q(() => (x.current = !0, () => {
|
|
341
|
-
x.current = !1,
|
|
344
|
+
x.current = !1, B.current++;
|
|
342
345
|
}), []);
|
|
343
|
-
const [
|
|
344
|
-
for (const [I,
|
|
345
|
-
o.includes(
|
|
346
|
+
const [T, v] = pe({}), j = l(/* @__PURE__ */ new Map()), O = l(null), F = l(null), U = l(null), J = l(null), E = l(null), _ = l(!1), q = l(!1), re = l(/* @__PURE__ */ new Map()), X = l(0), ge = w((o, S, z) => {
|
|
347
|
+
for (const [I, ae] of re.current)
|
|
348
|
+
o.includes(ae.key) && (re.current.delete(I), ae.resolve({ status: S, ...S === "returned" ? { value: z } : {} }));
|
|
346
349
|
}, []), V = l(a);
|
|
347
350
|
V.current = a;
|
|
348
|
-
const
|
|
349
|
-
|
|
350
|
-
const ye = l(!1),
|
|
351
|
-
we && (
|
|
352
|
-
const Pe = Math.min(1e3, Math.max(0, Number(t.pageAnimationDuration ?? 360) || 0)),
|
|
353
|
-
Ne.current =
|
|
354
|
-
const { loadingApi: ke, refreshLoading: Ae, loadingTasks: Le, setLoading: Se } = An(D, x, Ne),
|
|
351
|
+
const le = l(d);
|
|
352
|
+
le.current = d;
|
|
353
|
+
const ye = l(!1), b = l(0), C = a.at(-1), W = C.key, ue = l({ key: W, depth: a.length }), he = ue.current, we = he.key !== W, Ie = a.length < he.depth ? "back" : "forward";
|
|
354
|
+
we && (ue.current = { key: W, depth: a.length });
|
|
355
|
+
const Pe = Math.min(1e3, Math.max(0, Number(t.pageAnimationDuration ?? 360) || 0)), de = { distance: Math.min(300, Math.max(0, Number(t.pageAnimationDistance ?? 96) || 0)), enabled: t.pageAnimation !== !1 && t.animation !== !1 && Pe > 0 && we, direction: Ie, duration: Pe }, Ne = l(W);
|
|
356
|
+
Ne.current = W;
|
|
357
|
+
const { loadingApi: ke, refreshLoading: Ae, loadingTasks: Le, setLoading: Se } = An(D, x, Ne), c = e.screens, h = D, A = l(f);
|
|
355
358
|
A.current = f, Q(() => (A.current?.({ setLoading: Se }), () => A.current?.(null)), [Se]);
|
|
356
|
-
const
|
|
359
|
+
const R = w((o, S) => {
|
|
357
360
|
if (!x.current) return;
|
|
358
|
-
const z =
|
|
361
|
+
const z = L.current.getSnapshot();
|
|
359
362
|
if (S === null) {
|
|
360
363
|
if (!(o in z)) return;
|
|
361
364
|
const I = { ...z };
|
|
362
|
-
delete I[o],
|
|
365
|
+
delete I[o], L.current.publish(I);
|
|
363
366
|
return;
|
|
364
367
|
}
|
|
365
|
-
z[o] !== S &&
|
|
366
|
-
}, []),
|
|
368
|
+
z[o] !== S && L.current.publish({ ...z, [o]: S });
|
|
369
|
+
}, []), ee = w(() => {
|
|
367
370
|
if (typeof document > "u") return;
|
|
368
371
|
const o = document.activeElement;
|
|
369
|
-
if (!(o instanceof HTMLElement) || !
|
|
372
|
+
if (!(o instanceof HTMLElement) || !O.current?.contains(o)) return;
|
|
370
373
|
const S = o.closest("[data-modal-route-key]");
|
|
371
|
-
S &&
|
|
374
|
+
S && j.current.set(S.dataset.modalRouteKey, o), O.current.focus({ preventScroll: !0 });
|
|
372
375
|
}, []), Z = w((o) => {
|
|
373
|
-
if (!Object.prototype.hasOwnProperty.call(
|
|
374
|
-
}, [
|
|
376
|
+
if (!Object.prototype.hasOwnProperty.call(c, o)) throw new Error(`[react-modal-navigation] Unknown modal screen: ${o}`);
|
|
377
|
+
}, [c]), ne = w((o, S) => {
|
|
375
378
|
try {
|
|
376
379
|
Promise.resolve(t[o]?.(S)).catch((z) => u(z, { phase: o }));
|
|
377
380
|
} catch (z) {
|
|
378
381
|
u(z, { phase: o });
|
|
379
382
|
}
|
|
380
|
-
}, [t, u]),
|
|
381
|
-
if (!x.current ||
|
|
382
|
-
const
|
|
383
|
+
}, [t, u]), te = w(async (o, S, z, I) => {
|
|
384
|
+
if (!x.current || q.current) return !1;
|
|
385
|
+
const ae = B.current, Y = V.current, se = Y.at(-1);
|
|
383
386
|
if (o !== "BACK" && Z(S), o === "BACK" && Y.length <= 1) return !1;
|
|
384
|
-
const dn = o === "NAVIGATE" ? Y.findIndex((
|
|
385
|
-
|
|
387
|
+
const dn = o === "NAVIGATE" ? Y.findIndex((Oe) => Oe.name === S) : -1, Qe = o === "RESET" ? Y : o === "BACK" || o === "REPLACE" ? [se] : dn >= 0 ? Y.slice(dn + 1) : [];
|
|
388
|
+
q.current = !0;
|
|
386
389
|
try {
|
|
387
|
-
if (Qe.length &&
|
|
390
|
+
if (Qe.length && le.current && !await le.current(Qe.map((Je) => Je.key), {
|
|
388
391
|
reason: "navigation",
|
|
389
392
|
action: o,
|
|
390
|
-
from:
|
|
393
|
+
from: se,
|
|
391
394
|
to: o === "BACK" ? Y.at(-2)?.name : S
|
|
392
|
-
}) || !x.current ||
|
|
395
|
+
}) || !x.current || ae !== B.current || V.current.at(-1)?.key !== se.key) return !1;
|
|
393
396
|
if (o === "BACK" && I !== void 0) {
|
|
394
397
|
const Ce = Y.at(-2);
|
|
395
|
-
|
|
398
|
+
v((Je) => ({ ...Je, [Ce.key]: { id: ++b.current, data: I } }));
|
|
396
399
|
}
|
|
397
|
-
o === "RESET" &&
|
|
398
|
-
const
|
|
399
|
-
|
|
400
|
+
o === "RESET" && v({}), ge(Qe.map((Ce) => Ce.key), o === "BACK" ? "returned" : "removed", I);
|
|
401
|
+
const Oe = [...F.current?.querySelectorAll("[data-modal-route-key]") ?? []].find((Ce) => Ce.dataset.modalRouteKey === se.key);
|
|
402
|
+
U.current = Oe?.cloneNode(!0) ?? null, ee();
|
|
400
403
|
const mn = { type: o, name: S, params: z };
|
|
401
|
-
return V.current = Ke(V.current, mn),
|
|
402
|
-
} catch (
|
|
403
|
-
return x.current && u(
|
|
404
|
+
return V.current = Ke(V.current, mn), P(mn), !0;
|
|
405
|
+
} catch (Oe) {
|
|
406
|
+
return x.current && u(Oe, { phase: "navigationGuard", action: o }), !1;
|
|
404
407
|
} finally {
|
|
405
|
-
|
|
408
|
+
q.current = !1;
|
|
406
409
|
}
|
|
407
|
-
}, [Z,
|
|
410
|
+
}, [Z, ee, u, ge]), Be = w((o, S) => te("NAVIGATE", o, S), [te]), me = w(async (o, S) => {
|
|
408
411
|
if (!x.current) return { status: "cancelled" };
|
|
409
|
-
if (V.current, !await
|
|
412
|
+
if (V.current, !await te("NAVIGATE", o, S) || !x.current) return { status: "cancelled" };
|
|
410
413
|
const I = V.current.at(-1);
|
|
411
|
-
return !I || I.name !== o ? { status: "cancelled" } : new Promise((
|
|
412
|
-
const Y = ++
|
|
413
|
-
|
|
414
|
+
return !I || I.name !== o ? { status: "cancelled" } : new Promise((ae) => {
|
|
415
|
+
const Y = ++X.current;
|
|
416
|
+
re.current.set(Y, { key: I.key, resolve: ae });
|
|
414
417
|
});
|
|
415
|
-
}, [
|
|
418
|
+
}, [te]), ve = w((o, S) => te("REPLACE", o, S), [te]), qe = w((o, S) => te("RESET", o, S), [te]), Ee = w((o) => {
|
|
416
419
|
if (!o || typeof o != "object" || Array.isArray(o)) throw new TypeError("[react-modal-navigation] setParams expects an object");
|
|
417
420
|
if (!x.current) return;
|
|
418
421
|
const S = { type: "SET_PARAMS", params: o };
|
|
419
|
-
V.current = Ke(V.current, S),
|
|
422
|
+
V.current = Ke(V.current, S), P(S);
|
|
420
423
|
}, []), Re = w((o) => {
|
|
421
424
|
if (!o || typeof o != "object" || Array.isArray(o)) throw new TypeError("[react-modal-navigation] setOptions expects an object");
|
|
422
425
|
if (!x.current) return;
|
|
423
426
|
const S = { type: "SET_OPTIONS", options: o };
|
|
424
|
-
V.current = Ke(V.current, S),
|
|
425
|
-
}, []), an = w((o) =>
|
|
426
|
-
sn.current =
|
|
427
|
-
const cn = w((o) => sn.current("api", o), []), Ve =
|
|
428
|
-
He(() =>
|
|
427
|
+
V.current = Ke(V.current, S), P(S);
|
|
428
|
+
}, []), an = w((o) => te("BACK", null, void 0, o), [te]), ze = w((o, S) => !x.current || h.current.getSnapshot().visible && t.lockCloseWhileLoading !== !1 ? Promise.resolve(!1) : g(o, S, { route: C, stack: a }), [t.lockCloseWhileLoading, g, C, a]), sn = l(ze);
|
|
429
|
+
sn.current = ze;
|
|
430
|
+
const cn = w((o) => sn.current("api", o), []), Ve = K(() => ({ navigate: Be, navigateAsync: me, replace: ve, reset: qe, setParams: Ee, setOptions: Re, goBack: an, close: cn, setLoading: Se }), [Be, me, ve, qe, Ee, Re, an, cn, Se]), ln = K(() => ({ canGoBack: a.length > 1, stack: a, currentRoute: C }), [a]);
|
|
431
|
+
He(() => N.current.publish(ln), [ln]);
|
|
429
432
|
const Ze = l(null);
|
|
430
433
|
Ze.current || (Ze.current = Object.defineProperties({}, {
|
|
431
|
-
canGoBack: { enumerable: !0, get: () =>
|
|
432
|
-
stack: { enumerable: !0, get: () =>
|
|
433
|
-
currentRoute: { enumerable: !0, get: () =>
|
|
434
|
+
canGoBack: { enumerable: !0, get: () => N.current.getSnapshot().canGoBack },
|
|
435
|
+
stack: { enumerable: !0, get: () => N.current.getSnapshot().stack },
|
|
436
|
+
currentRoute: { enumerable: !0, get: () => N.current.getSnapshot().currentRoute }
|
|
434
437
|
}));
|
|
435
|
-
const De =
|
|
438
|
+
const De = K(() => Object.assign(Ze.current, Ve), [Ve]);
|
|
436
439
|
He(() => {
|
|
437
|
-
const o =
|
|
438
|
-
if (
|
|
439
|
-
const S =
|
|
440
|
-
o.removeAttribute("hidden"), o.removeAttribute("tabindex"), o.setAttribute("aria-hidden", "true"), o.setAttribute("inert", ""), o.dataset.pmnOutgoing = "true", o.querySelectorAll("[id]").forEach((
|
|
441
|
-
const z =
|
|
440
|
+
const o = U.current;
|
|
441
|
+
if (U.current = null, J.current?.cancel?.(), J.current = null, F.current?.querySelectorAll("[data-pmn-outgoing]").forEach((se) => se.remove()), !we || !de.enabled || !o || !F.current || typeof window < "u" && window.matchMedia?.("(prefers-reduced-motion: reduce)").matches) return;
|
|
442
|
+
const S = F.current;
|
|
443
|
+
o.removeAttribute("hidden"), o.removeAttribute("tabindex"), o.setAttribute("aria-hidden", "true"), o.setAttribute("inert", ""), o.dataset.pmnOutgoing = "true", o.querySelectorAll("[id]").forEach((se) => se.removeAttribute("id")), o.querySelectorAll("[autofocus]").forEach((se) => se.removeAttribute("autofocus")), o.style.cssText += ";position:absolute;inset:0;width:100%;height:100%;z-index:1;pointer-events:none;overflow:hidden;background:var(--pmn-body);", S.appendChild(o);
|
|
444
|
+
const z = de.direction === "back" ? 1 : -1, I = [...S.querySelectorAll("[data-modal-route-key]")].find((se) => se.dataset.modalRouteKey === W);
|
|
442
445
|
I && (I.style.zIndex = "2");
|
|
443
|
-
const
|
|
444
|
-
o.remove(), I && (I.style.zIndex = ""),
|
|
446
|
+
const ae = () => {
|
|
447
|
+
o.remove(), I && (I.style.zIndex = ""), J.current === Y && (J.current = null);
|
|
445
448
|
};
|
|
446
449
|
let Y;
|
|
447
450
|
if (o.animate)
|
|
448
451
|
Y = o.animate([
|
|
449
452
|
{ opacity: 1, transform: "translate3d(0,0,0)" },
|
|
450
453
|
{ opacity: 1, transform: `translate3d(${z * 100}%,0,0)` }
|
|
451
|
-
], { duration:
|
|
454
|
+
], { duration: de.duration, easing: "cubic-bezier(.22,1,.36,1)", fill: "forwards" }), Y.addEventListener("finish", ae, { once: !0 }), Y.addEventListener("cancel", ae, { once: !0 }), J.current = Y;
|
|
452
455
|
else {
|
|
453
|
-
o.classList.add("pmn-page-exit", `pmn-page-exit-${
|
|
454
|
-
const
|
|
456
|
+
o.classList.add("pmn-page-exit", `pmn-page-exit-${de.direction}`), o.style.setProperty("--pmn-page-duration", `${de.duration}ms`), o.style.setProperty("--pmn-page-distance", "100%");
|
|
457
|
+
const se = setTimeout(ae, de.duration + 40);
|
|
455
458
|
Y = { cancel: () => {
|
|
456
|
-
clearTimeout(
|
|
457
|
-
} },
|
|
459
|
+
clearTimeout(se), ae();
|
|
460
|
+
} }, J.current = Y;
|
|
458
461
|
}
|
|
459
462
|
return () => {
|
|
460
463
|
Y?.cancel?.(), o.remove();
|
|
461
464
|
};
|
|
462
|
-
}, [
|
|
463
|
-
|
|
464
|
-
const o = [...
|
|
465
|
+
}, [W]), He(() => {
|
|
466
|
+
_.current = !1;
|
|
467
|
+
const o = [...O.current?.querySelectorAll("[data-modal-route-key]") ?? []].find((I) => I.dataset.modalRouteKey === W);
|
|
465
468
|
if (!o) return;
|
|
466
|
-
const S =
|
|
469
|
+
const S = j.current.get(W);
|
|
467
470
|
(S?.isConnected && o.contains(S) && !S.matches(":disabled") && !S.closest("[inert], [hidden]") ? S : o).focus({ preventScroll: !0 });
|
|
468
|
-
}, [
|
|
471
|
+
}, [W]), Q(() => {
|
|
469
472
|
let o = !1;
|
|
470
473
|
for (const [z, I] of Le.current)
|
|
471
|
-
I.owner !== "global" && I.owner !==
|
|
474
|
+
I.owner !== "global" && I.owner !== W && (Le.current.delete(z), o = !0);
|
|
472
475
|
o && Ae();
|
|
473
476
|
const S = new Set(a.map((z) => z.key));
|
|
474
|
-
|
|
477
|
+
v((z) => {
|
|
475
478
|
const I = Object.keys(z).filter((Y) => !S.has(Y));
|
|
476
479
|
if (!I.length) return z;
|
|
477
|
-
const
|
|
478
|
-
return I.forEach((Y) => delete
|
|
480
|
+
const ae = { ...z };
|
|
481
|
+
return I.forEach((Y) => delete ae[Y]), ae;
|
|
479
482
|
});
|
|
480
|
-
for (const z of
|
|
481
|
-
}, [
|
|
482
|
-
if (
|
|
483
|
-
if (
|
|
484
|
-
const o = { from:
|
|
485
|
-
|
|
483
|
+
for (const z of j.current.keys()) S.has(z) || j.current.delete(z);
|
|
484
|
+
}, [W, a, Ae]), Q(() => {
|
|
485
|
+
if (E.current?.key !== W) {
|
|
486
|
+
if (E.current) {
|
|
487
|
+
const o = { from: E.current, to: C, stack: a };
|
|
488
|
+
ne("onBlur", { route: E.current, ...o }), ne("onNavigate", o), ne("onRouteChange", o);
|
|
486
489
|
}
|
|
487
|
-
|
|
490
|
+
ne("onFocus", { route: C, stack: a }), E.current = C;
|
|
488
491
|
}
|
|
489
|
-
}, [
|
|
490
|
-
Le.current.clear(),
|
|
491
|
-
for (const o of
|
|
492
|
-
|
|
492
|
+
}, [C, W, a, ne]), Q(() => () => {
|
|
493
|
+
Le.current.clear(), j.current.clear();
|
|
494
|
+
for (const o of re.current.values()) o.resolve({ status: "dismissed" });
|
|
495
|
+
re.current.clear();
|
|
493
496
|
}, []), Q(() => {
|
|
494
|
-
ye.current || (ye.current = !0, p?.({ route:
|
|
497
|
+
ye.current || (ye.current = !0, p?.({ route: C, stack: a }));
|
|
495
498
|
}, []);
|
|
496
|
-
const Bn =
|
|
497
|
-
return /* @__PURE__ */ s(rn.Provider, { value:
|
|
498
|
-
/* @__PURE__ */ s(Rn, { options: t, screen: un, route:
|
|
499
|
-
/* @__PURE__ */ s("main", { ref:
|
|
499
|
+
const Bn = K(() => $n(a, c, t.maxCachedScreens), [a, c, t.maxCachedScreens]), un = K(() => ({ ...c[C.name], ...C.options ?? {} }), [c, C.name, C.options]);
|
|
500
|
+
return /* @__PURE__ */ s(rn.Provider, { value: $, children: /* @__PURE__ */ s(wn.Provider, { value: G.current, children: /* @__PURE__ */ s(xn.Provider, { value: L.current, children: /* @__PURE__ */ s(vn.Provider, { value: De, children: /* @__PURE__ */ s(_e.Provider, { value: Ve, children: /* @__PURE__ */ s(We.Provider, { value: N.current, children: /* @__PURE__ */ s(Me.Provider, { value: ke, children: /* @__PURE__ */ ce(En, { dialogRef: O, options: t, requestClose: ze, exiting: m, children: [
|
|
501
|
+
/* @__PURE__ */ s(Rn, { options: t, screen: un, route: C, navigation: De, requestClose: ze, translate: i, canGoBack: a.length > 1 }),
|
|
502
|
+
/* @__PURE__ */ s("main", { ref: F, className: "pmn-main", children: Bn.map((o) => /* @__PURE__ */ s(
|
|
500
503
|
Un,
|
|
501
504
|
{
|
|
502
505
|
route: o,
|
|
503
|
-
screen:
|
|
506
|
+
screen: c[o.name],
|
|
504
507
|
navigation: De,
|
|
505
|
-
focused: o.key ===
|
|
506
|
-
resultEvent:
|
|
508
|
+
focused: o.key === W,
|
|
509
|
+
resultEvent: T[o.key] ?? null,
|
|
507
510
|
bodyClassName: t.bodyClassName,
|
|
508
|
-
setFooter:
|
|
511
|
+
setFooter: R,
|
|
509
512
|
loadingApi: ke,
|
|
510
513
|
loadingStore: D.current,
|
|
511
514
|
notifyError: u,
|
|
512
515
|
registerDirtyGuard: k,
|
|
513
|
-
pageMotion:
|
|
516
|
+
pageMotion: de,
|
|
514
517
|
lazyFallback: t.lazyFallback
|
|
515
518
|
},
|
|
516
519
|
o.key
|
|
@@ -518,30 +521,30 @@ function Yn({ config: e, initialScreen: n, params: r, options: t, translate: c,
|
|
|
518
521
|
/* @__PURE__ */ s(
|
|
519
522
|
Wn,
|
|
520
523
|
{
|
|
521
|
-
store:
|
|
522
|
-
routeKey:
|
|
524
|
+
store: L.current,
|
|
525
|
+
routeKey: W,
|
|
523
526
|
screen: un,
|
|
524
527
|
options: t,
|
|
525
|
-
route:
|
|
528
|
+
route: C,
|
|
526
529
|
navigation: De,
|
|
527
|
-
requestClose:
|
|
528
|
-
translate:
|
|
530
|
+
requestClose: ze,
|
|
531
|
+
translate: i,
|
|
529
532
|
onError: u,
|
|
530
533
|
loadingApi: ke
|
|
531
534
|
},
|
|
532
|
-
|
|
535
|
+
W
|
|
533
536
|
),
|
|
534
|
-
/* @__PURE__ */ s(Hn, { store: D.current, translate:
|
|
535
|
-
/* @__PURE__ */ s(_n, { store:
|
|
536
|
-
|
|
537
|
-
/* @__PURE__ */ s("span", { children:
|
|
538
|
-
/* @__PURE__ */ s("button", { type: "button", onClick:
|
|
537
|
+
/* @__PURE__ */ s(Hn, { store: D.current, translate: i }),
|
|
538
|
+
/* @__PURE__ */ s(_n, { store: G.current, dismiss: H }),
|
|
539
|
+
y && /* @__PURE__ */ ce("div", { className: "pmn-error", role: "alert", children: [
|
|
540
|
+
/* @__PURE__ */ s("span", { children: y.message || String(y) }),
|
|
541
|
+
/* @__PURE__ */ s("button", { type: "button", onClick: M, "aria-label": "Dismiss error", children: "×" })
|
|
539
542
|
] })
|
|
540
543
|
] }) }) }) }) }) }) }) });
|
|
541
544
|
}
|
|
542
545
|
const Vn = be.memo(function({ store: n, route: r, ...t }) {
|
|
543
|
-
const
|
|
544
|
-
return /* @__PURE__ */ s(Cn, { ...t, route: r, override:
|
|
546
|
+
const i = fe(n.subscribe, n.getSnapshot, n.getSnapshot);
|
|
547
|
+
return /* @__PURE__ */ s(Cn, { ...t, route: r, override: i[r.key] });
|
|
545
548
|
}), Zn = be.memo(function({ store: n, translate: r }) {
|
|
546
549
|
const t = fe(n.subscribe, n.getSnapshot, n.getSnapshot);
|
|
547
550
|
return /* @__PURE__ */ s(Tn, { loading: t, translate: r });
|
|
@@ -549,74 +552,74 @@ const Vn = be.memo(function({ store: n, route: r, ...t }) {
|
|
|
549
552
|
const t = fe(n.subscribe, n.getSnapshot, n.getSnapshot);
|
|
550
553
|
return /* @__PURE__ */ s(Pn, { items: t, dismiss: r });
|
|
551
554
|
});
|
|
552
|
-
function Jn({ config: e, initialScreen: n, params: r, options: t, translate:
|
|
553
|
-
const m = n ?? e.initialRoute ?? Object.keys(e.screens)[0], [a,
|
|
554
|
-
|
|
555
|
-
const D = e.screens[m],
|
|
556
|
-
x.current || (x.current = kn({ canGoBack: !1, stack: [a], currentRoute: a })),
|
|
557
|
-
const
|
|
558
|
-
const
|
|
559
|
-
if (
|
|
560
|
-
if (
|
|
561
|
-
const he = { ...
|
|
562
|
-
delete he[
|
|
555
|
+
function Jn({ config: e, initialScreen: n, params: r, options: t, translate: i, onRequestClose: g, onOpened: p, registerLoading: f, notifyError: u, error: y, clearError: M, registerDirtyGuard: k, exiting: d = !1 }) {
|
|
556
|
+
const m = n ?? e.initialRoute ?? Object.keys(e.screens)[0], [a, P] = pe(() => ({ key: "single", name: m, params: r ?? {}, options: {} })), N = l(a);
|
|
557
|
+
N.current = a;
|
|
558
|
+
const D = e.screens[m], L = l(!0), G = l(null), x = l(null), B = l(null), $ = l(null), H = l(null);
|
|
559
|
+
x.current || (x.current = kn({ canGoBack: !1, stack: [a], currentRoute: a })), B.current || (B.current = Te({})), $.current || ($.current = Te({ visible: !1, text: null, count: 0 })), H.current || (H.current = Te([]));
|
|
560
|
+
const T = l("single"), { loadingApi: v, setLoading: j } = An($, L, T), { toast: O, dismissToast: F } = Nn(H, L), U = w((b, C) => {
|
|
561
|
+
const W = B.current, ue = W.getSnapshot();
|
|
562
|
+
if (C === null) {
|
|
563
|
+
if (ue[b] !== void 0) {
|
|
564
|
+
const he = { ...ue };
|
|
565
|
+
delete he[b], W.publish(he);
|
|
563
566
|
}
|
|
564
|
-
} else
|
|
565
|
-
}, []),
|
|
566
|
-
navigate:
|
|
567
|
+
} else ue[b] !== C && W.publish({ ...ue, [b]: C });
|
|
568
|
+
}, []), J = w((b = "api", C) => g(b, C), [g]), E = w(() => Promise.resolve(!1), []), _ = K(() => ({
|
|
569
|
+
navigate: E,
|
|
567
570
|
navigateAsync: async () => ({ status: "cancelled" }),
|
|
568
|
-
replace:
|
|
569
|
-
reset:
|
|
570
|
-
goBack:
|
|
571
|
-
popToTop:
|
|
572
|
-
popTo:
|
|
573
|
-
setParams: (
|
|
574
|
-
setOptions: (
|
|
575
|
-
close:
|
|
576
|
-
setLoading:
|
|
571
|
+
replace: E,
|
|
572
|
+
reset: E,
|
|
573
|
+
goBack: E,
|
|
574
|
+
popToTop: E,
|
|
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,
|
|
577
580
|
canGoBack: !1,
|
|
578
581
|
stack: [a],
|
|
579
582
|
currentRoute: a
|
|
580
|
-
}), [
|
|
581
|
-
|
|
582
|
-
const
|
|
583
|
-
navigate: (...
|
|
584
|
-
navigateAsync: (...
|
|
585
|
-
replace: (...
|
|
586
|
-
reset: (...
|
|
587
|
-
goBack: (...
|
|
588
|
-
popToTop: (...
|
|
589
|
-
popTo: (...
|
|
590
|
-
setParams: (...
|
|
591
|
-
setOptions: (...
|
|
592
|
-
close: (...
|
|
593
|
-
setLoading: (...
|
|
594
|
-
}), []),
|
|
595
|
-
setLoading: (
|
|
596
|
-
showLoading: (
|
|
597
|
-
hideLoading: (
|
|
598
|
-
}), [
|
|
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]);
|
|
599
602
|
Q(() => {
|
|
600
603
|
x.current.publish({ canGoBack: !1, stack: [a], currentRoute: a });
|
|
601
|
-
}, [a]), Q(() => (
|
|
602
|
-
|
|
604
|
+
}, [a]), Q(() => (L.current = !0, f?.({ setLoading: j }), p?.({ route: N.current, stack: [N.current] }), () => {
|
|
605
|
+
L.current = !1;
|
|
603
606
|
}), []);
|
|
604
|
-
const
|
|
605
|
-
return /* @__PURE__ */ s(rn.Provider, { value:
|
|
606
|
-
/* @__PURE__ */ s(Rn, { options: t, screen:
|
|
607
|
-
/* @__PURE__ */ s("main", { className: "pmn-main", children: /* @__PURE__ */ s(on.Provider, { value: a, children: /* @__PURE__ */ s(tn.Provider, { value: V, children: /* @__PURE__ */ s(
|
|
608
|
-
/* @__PURE__ */ s(Vn, { store:
|
|
609
|
-
/* @__PURE__ */ s(Zn, { store:
|
|
610
|
-
/* @__PURE__ */ s(Qn, { store:
|
|
611
|
-
|
|
612
|
-
/* @__PURE__ */ s("span", { children:
|
|
613
|
-
/* @__PURE__ */ s("button", { type: "button", onClick:
|
|
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: "×" })
|
|
614
617
|
] })
|
|
615
618
|
] }) }) }) }) }) }) }) });
|
|
616
619
|
}
|
|
617
|
-
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))}", gn = "react-modal-navigation-styles", en = /* @__PURE__ */ new WeakMap();
|
|
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();
|
|
618
621
|
function et() {
|
|
619
|
-
|
|
622
|
+
zn(() => {
|
|
620
623
|
if (typeof document > "u") return;
|
|
621
624
|
const e = document;
|
|
622
625
|
let n = en.get(e);
|
|
@@ -637,14 +640,14 @@ function Ge(e, n, r) {
|
|
|
637
640
|
}
|
|
638
641
|
if (e === null || typeof e != "object" || Array.isArray(e))
|
|
639
642
|
throw new TypeError("[react-modal-navigation] open expects a modal name or a configuration object");
|
|
640
|
-
const { name: t, screen:
|
|
643
|
+
const { name: t, screen: i, params: g = {}, options: p = {}, ...f } = e;
|
|
641
644
|
if (typeof t != "string" || !t.trim())
|
|
642
645
|
throw new TypeError("[react-modal-navigation] open config requires a non-empty string name");
|
|
643
646
|
if (p === null || typeof p != "object" || Array.isArray(p))
|
|
644
647
|
throw new TypeError("[react-modal-navigation] open config options must be an object");
|
|
645
|
-
if (
|
|
648
|
+
if (i !== void 0 && (typeof i != "string" || !i.trim()))
|
|
646
649
|
throw new TypeError("[react-modal-navigation] screen must be a non-empty string");
|
|
647
|
-
return { name: t, ...
|
|
650
|
+
return { name: t, ...i === void 0 ? {} : { screen: i }, params: g, options: { ...f, ...p } };
|
|
648
651
|
}
|
|
649
652
|
function nt() {
|
|
650
653
|
const e = /* @__PURE__ */ new Map();
|
|
@@ -666,153 +669,153 @@ function nt() {
|
|
|
666
669
|
};
|
|
667
670
|
}
|
|
668
671
|
const tt = { placement: "right", showHeader: !0, showBackButton: !0, showCloseButton: !0, viewportGap: 5, borderRadius: 12, closeOnOverlay: !1, closeOnEsc: !0 }, rt = (e) => ({ "modal.loading": "加载中...", "modal.processing": "处理中...", "modal.back": "返回", "modal.close": "关闭", "modal.cancel": "取消", "modal.done": "完成" })[e] ?? e;
|
|
669
|
-
function pt({ registry: e, children: n, defaultOptions: r = {}, backgroundColor: t, theme:
|
|
672
|
+
function pt({ registry: e, children: n, defaultOptions: r = {}, backgroundColor: t, theme: i, translate: g = rt, onError: p, confirmDiscard: f }) {
|
|
670
673
|
et();
|
|
671
|
-
const [u,
|
|
672
|
-
|
|
673
|
-
const
|
|
674
|
-
|
|
675
|
-
}), []),
|
|
676
|
-
for (const h of
|
|
674
|
+
const [u, y] = pe(null), [M, k] = pe(null), [d, m] = pe(0), a = l(null), P = l(/* @__PURE__ */ new Map()), N = l([]), D = l(null), L = l(null), G = l(0), x = l(null), B = l(!1), $ = l(0), H = l(null), T = l(/* @__PURE__ */ new Map()), [v, j] = pe(!1), O = l(f);
|
|
675
|
+
O.current = f;
|
|
676
|
+
const F = w((c, h) => (T.current.set(c, h), () => {
|
|
677
|
+
T.current.get(c) === h && T.current.delete(c);
|
|
678
|
+
}), []), U = w(async (c) => {
|
|
679
|
+
for (const h of T.current.values()) {
|
|
677
680
|
if (!h.dirty) continue;
|
|
678
|
-
if ((h.onBeforeDiscard ? await h.onBeforeDiscard(
|
|
681
|
+
if ((h.onBeforeDiscard ? await h.onBeforeDiscard(c) : O.current ? await O.current(c) : typeof window < "u" && typeof window.confirm == "function" ? window.confirm(h.message || "有未保存的修改,确定放弃吗?") : !1) === !1) return !1;
|
|
679
682
|
}
|
|
680
683
|
return !0;
|
|
681
|
-
}, []),
|
|
682
|
-
for (const A of
|
|
683
|
-
const
|
|
684
|
-
if (!
|
|
685
|
-
if ((
|
|
684
|
+
}, []), J = w(async (c, h) => {
|
|
685
|
+
for (const A of c) {
|
|
686
|
+
const R = T.current.get(A);
|
|
687
|
+
if (!R?.dirty) continue;
|
|
688
|
+
if ((R.onBeforeDiscard ? await R.onBeforeDiscard(h) : O.current ? await O.current(h) : typeof window < "u" && typeof window.confirm == "function" ? window.confirm(R.message || "有未保存的修改,确定放弃吗?") : !1) === !1) return !1;
|
|
686
689
|
}
|
|
687
690
|
return !0;
|
|
688
|
-
}, []),
|
|
689
|
-
|
|
690
|
-
const
|
|
691
|
-
|
|
692
|
-
const
|
|
693
|
-
|
|
691
|
+
}, []), E = l(!0), _ = l(null);
|
|
692
|
+
_.current || (_.current = nt());
|
|
693
|
+
const q = l(null), re = l(p);
|
|
694
|
+
re.current = p;
|
|
695
|
+
const X = w((c, h) => {
|
|
696
|
+
E.current && k(c);
|
|
694
697
|
try {
|
|
695
|
-
|
|
698
|
+
re.current ? re.current(c, h) : console.error("[react-modal-navigation]", c);
|
|
696
699
|
} catch (A) {
|
|
697
700
|
console.error("[react-modal-navigation] onError failed", A);
|
|
698
701
|
}
|
|
699
|
-
}, []), ge = w((
|
|
700
|
-
const A =
|
|
701
|
-
|
|
702
|
-
}, []), V = w((
|
|
703
|
-
ye.current =
|
|
704
|
-
const
|
|
705
|
-
const
|
|
706
|
-
if (!
|
|
707
|
-
x.current =
|
|
708
|
-
const
|
|
702
|
+
}, []), ge = w((c, h) => {
|
|
703
|
+
const A = P.current.get(c);
|
|
704
|
+
P.current.delete(c), A?.(h);
|
|
705
|
+
}, []), V = w((c) => ({ ...tt, ...r, ...i !== void 0 ? { theme: i } : {}, ...t !== void 0 ? { backgroundColor: t } : {}, ...c.config.modalOptions, ...c.overrides }), [r, i, t]), le = u ? V(u) : null, ye = l(null);
|
|
706
|
+
ye.current = le, q.current = le;
|
|
707
|
+
const b = w(async (c = "api", h, A = {}) => {
|
|
708
|
+
const R = a.current;
|
|
709
|
+
if (!R || x.current || B.current) return !1;
|
|
710
|
+
x.current = R.id, B.current = !0;
|
|
711
|
+
const ee = q.current ?? V(R), Z = { ...A, reason: c, result: h, name: R.name };
|
|
709
712
|
try {
|
|
710
|
-
if (!await
|
|
711
|
-
|
|
712
|
-
const
|
|
713
|
-
if (await
|
|
714
|
-
a.current = null,
|
|
713
|
+
if (!await U(Z) || await ee.onBeforeClose?.(Z) === !1 || a.current?.id !== R.id || !E.current) return !1;
|
|
714
|
+
j(!0);
|
|
715
|
+
const ne = ee.animation === !1 || typeof window < "u" && window.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? 0 : Math.max(0, Number(ee.animationDuration ?? 220) || 0);
|
|
716
|
+
if (await _.current.wait(Math.min(ne, 1e3)), !E.current || a.current?.id !== R.id) return !1;
|
|
717
|
+
a.current = null, H.current = null, y(null), j(!1), T.current.clear(), ge(R.id, A.confirmed || h !== void 0 ? { status: "confirmed", value: h, reason: c } : { status: "dismissed", reason: c });
|
|
715
718
|
try {
|
|
716
|
-
await
|
|
717
|
-
} catch (
|
|
718
|
-
|
|
719
|
+
await ee.onClose?.(Z);
|
|
720
|
+
} catch (te) {
|
|
721
|
+
X(te, { phase: "onClose", name: R.name });
|
|
719
722
|
}
|
|
720
723
|
return !0;
|
|
721
|
-
} catch (
|
|
722
|
-
return
|
|
724
|
+
} catch (ne) {
|
|
725
|
+
return X(ne, { phase: "onBeforeClose", name: R.name }), !1;
|
|
723
726
|
} finally {
|
|
724
|
-
x.current ===
|
|
727
|
+
x.current === R.id && (x.current = null), B.current = !1, !a.current && E.current && queueMicrotask(() => L.current?.());
|
|
725
728
|
}
|
|
726
|
-
}, [V,
|
|
727
|
-
const Z = e?.[
|
|
728
|
-
if (!
|
|
729
|
-
const
|
|
730
|
-
if (!
|
|
731
|
-
if (!
|
|
732
|
-
|
|
733
|
-
const Be =
|
|
729
|
+
}, [V, X, ge, U]), C = w(async (c, h = {}, A = {}, R, ee) => {
|
|
730
|
+
const Z = e?.[c], ne = Z?.component && !Z.screens ? { ...Z, singlePage: !0, initialRoute: "__single__", screens: { __single__: { component: Z.component, title: Z.title, ...Z.screenOptions ?? {} } } } : Z;
|
|
731
|
+
if (!ne) throw new Error(`[react-modal-navigation] Unknown modal: ${c}`);
|
|
732
|
+
const te = ee ?? ne.initialRoute ?? Object.keys(ne.screens ?? {})[0];
|
|
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;
|
|
734
737
|
try {
|
|
735
|
-
const
|
|
736
|
-
if (
|
|
737
|
-
const qe =
|
|
738
|
+
const me = a.current;
|
|
739
|
+
if (me) {
|
|
740
|
+
const qe = q.current ?? V(me), Ee = { reason: "replace", name: me.name, nextName: c };
|
|
738
741
|
try {
|
|
739
|
-
if (!await
|
|
742
|
+
if (!await U(Ee) || await qe.onBeforeClose?.(Ee) === !1) return null;
|
|
740
743
|
} catch (Re) {
|
|
741
|
-
return
|
|
744
|
+
return X(Re, { phase: "onBeforeClose", name: me.name }), null;
|
|
742
745
|
}
|
|
743
|
-
if (!
|
|
744
|
-
a.current = null,
|
|
746
|
+
if (!E.current || Be !== $.current || a.current?.id !== me.id) return null;
|
|
747
|
+
a.current = null, H.current = null, y(null), T.current.clear(), ge(me.id, { status: "replaced", reason: "replace" });
|
|
745
748
|
try {
|
|
746
749
|
await qe.onClose?.(Ee);
|
|
747
750
|
} catch (Re) {
|
|
748
|
-
|
|
751
|
+
X(Re, { phase: "onClose", name: me.name });
|
|
749
752
|
}
|
|
750
|
-
if (!
|
|
753
|
+
if (!E.current || Be !== $.current) return null;
|
|
751
754
|
}
|
|
752
|
-
const ve = { id: ++
|
|
753
|
-
return a.current = ve,
|
|
755
|
+
const ve = { id: ++G.current, name: c, screen: te, params: h, config: ne, overrides: A };
|
|
756
|
+
return a.current = ve, H.current = null, R && P.current.set(ve.id, R), k(null), y(ve), ve.id;
|
|
754
757
|
} finally {
|
|
755
|
-
|
|
758
|
+
B.current = !1;
|
|
756
759
|
}
|
|
757
|
-
}, [e, V,
|
|
758
|
-
D.current =
|
|
759
|
-
const
|
|
760
|
-
if (!
|
|
761
|
-
const
|
|
762
|
-
if (
|
|
763
|
-
m(
|
|
760
|
+
}, [e, V, X, ge, U]);
|
|
761
|
+
D.current = C;
|
|
762
|
+
const W = w(async () => {
|
|
763
|
+
if (!E.current || a.current || B.current || x.current) return;
|
|
764
|
+
const c = N.current.shift();
|
|
765
|
+
if (c) {
|
|
766
|
+
m(N.current.length);
|
|
764
767
|
try {
|
|
765
|
-
const h = await D.current(
|
|
766
|
-
h === null ? (
|
|
768
|
+
const h = await D.current(c.args.name, c.args.params, c.args.options, c.resolveResult, c.args.screen);
|
|
769
|
+
h === null ? (c.resolveResult?.({ status: "dismissed", reason: "blocked" }), c.resolveId?.(null), queueMicrotask(() => L.current?.())) : c.resolveId?.(h);
|
|
767
770
|
} catch (h) {
|
|
768
|
-
|
|
771
|
+
c.reject?.(h), queueMicrotask(() => L.current?.());
|
|
769
772
|
}
|
|
770
773
|
}
|
|
771
774
|
}, []);
|
|
772
|
-
|
|
773
|
-
const
|
|
774
|
-
const
|
|
775
|
-
return e?.[
|
|
776
|
-
|
|
777
|
-
}) : Promise.reject(new Error(`[react-modal-navigation] Unknown modal: ${
|
|
778
|
-
}, [e]), he = w((
|
|
779
|
-
const
|
|
780
|
-
return e?.[
|
|
781
|
-
|
|
782
|
-
}) : Promise.reject(new Error(`[react-modal-navigation] Unknown modal: ${
|
|
783
|
-
}, [e]), we = w((
|
|
784
|
-
if (!
|
|
775
|
+
L.current = W;
|
|
776
|
+
const ue = w((c, h, A) => {
|
|
777
|
+
const R = Ge(c, h, A);
|
|
778
|
+
return e?.[R.name] ? new Promise((ee, Z) => {
|
|
779
|
+
N.current.push({ args: R, resolveId: ee, reject: Z }), m(N.current.length), queueMicrotask(() => L.current?.());
|
|
780
|
+
}) : Promise.reject(new Error(`[react-modal-navigation] Unknown modal: ${R.name}`));
|
|
781
|
+
}, [e]), he = w((c, h, A) => {
|
|
782
|
+
const R = Ge(c, h, A);
|
|
783
|
+
return e?.[R.name] ? new Promise((ee, Z) => {
|
|
784
|
+
N.current.push({ args: R, resolveResult: ee, reject: Z }), m(N.current.length), queueMicrotask(() => L.current?.());
|
|
785
|
+
}) : Promise.reject(new Error(`[react-modal-navigation] Unknown modal: ${R.name}`));
|
|
786
|
+
}, [e]), we = w((c) => {
|
|
787
|
+
if (!c || typeof c != "object" || Array.isArray(c)) throw new TypeError("[react-modal-navigation] update expects an options object");
|
|
785
788
|
const h = a.current;
|
|
786
|
-
if (!h ||
|
|
787
|
-
const A = { ...h, overrides: { ...h.overrides, ...
|
|
788
|
-
return a.current = A,
|
|
789
|
-
}, [V]), Ie = w((
|
|
790
|
-
const h =
|
|
789
|
+
if (!h || B.current) return !1;
|
|
790
|
+
const A = { ...h, overrides: { ...h.overrides, ...c } };
|
|
791
|
+
return a.current = A, y(A), q.current = V(A), !0;
|
|
792
|
+
}, [V]), Ie = w((c = "queue-cleared") => {
|
|
793
|
+
const h = N.current.splice(0);
|
|
791
794
|
m(0);
|
|
792
795
|
for (const A of h)
|
|
793
|
-
A.resolveId?.(null), A.resolveResult?.({ status: "dismissed", reason:
|
|
796
|
+
A.resolveId?.(null), A.resolveResult?.({ status: "dismissed", reason: c });
|
|
794
797
|
return h.length;
|
|
795
|
-
}, []), Pe = w((
|
|
796
|
-
const
|
|
797
|
-
return R
|
|
798
|
-
}, [
|
|
799
|
-
const
|
|
800
|
-
return new Promise((
|
|
801
|
-
R
|
|
802
|
-
|
|
798
|
+
}, []), Pe = w((c, h, A) => {
|
|
799
|
+
const R = Ge(c, h, A);
|
|
800
|
+
return C(R.name, R.params, R.options, void 0, R.screen);
|
|
801
|
+
}, [C]), Ye = w((c, h, A) => {
|
|
802
|
+
const R = Ge(c, h, A);
|
|
803
|
+
return new Promise((ee, Z) => {
|
|
804
|
+
C(R.name, R.params, R.options, ee, R.screen).then((ne) => {
|
|
805
|
+
ne === null && ee({ status: "dismissed", reason: "blocked" });
|
|
803
806
|
}, Z);
|
|
804
807
|
});
|
|
805
|
-
}, [
|
|
806
|
-
Q(() => (
|
|
807
|
-
|
|
808
|
-
for (const h of
|
|
809
|
-
|
|
810
|
-
const
|
|
811
|
-
for (const h of
|
|
808
|
+
}, [C]), de = w((c) => b("api", c), [b]), Ne = w((c = "api") => b(c), [b]), ke = w((c) => b("confirm", c, { confirmed: !0 }), [b]), Ae = w((c, h) => H.current?.setLoading(c, h), []), Le = K(() => ({ open: Pe, openAsync: Ye, enqueue: ue, enqueueAsync: he, update: we, clearQueue: Ie, close: de, dismiss: Ne, confirm: ke, setLoading: Ae, queueSize: d, isOpen: !!u, activeName: u?.name ?? null, error: M, clearError: () => k(null) }), [Pe, Ye, ue, he, we, Ie, de, Ne, ke, Ae, u, M, d]);
|
|
809
|
+
Q(() => (E.current = !0, () => {
|
|
810
|
+
E.current = !1, _.current.cancelAll(), $.current += 1, a.current = null;
|
|
811
|
+
for (const h of P.current.values()) h({ status: "dismissed", reason: "unmount" });
|
|
812
|
+
P.current.clear(), T.current.clear();
|
|
813
|
+
const c = N.current.splice(0);
|
|
814
|
+
for (const h of c)
|
|
812
815
|
h.resolveId?.(null), h.resolveResult?.({ status: "dismissed", reason: "unmount" });
|
|
813
816
|
}), []);
|
|
814
817
|
const Se = u?.config.singlePage || u && Object.keys(u.config.screens ?? {}).length === 1 ? Jn : Yn;
|
|
815
|
-
return /* @__PURE__ */
|
|
818
|
+
return /* @__PURE__ */ ce(yn.Provider, { value: Le, children: [
|
|
816
819
|
n,
|
|
817
820
|
u && /* @__PURE__ */ s(
|
|
818
821
|
Se,
|
|
@@ -820,24 +823,24 @@ function pt({ registry: e, children: n, defaultOptions: r = {}, backgroundColor:
|
|
|
820
823
|
config: u.config,
|
|
821
824
|
initialScreen: u.screen,
|
|
822
825
|
params: u.params,
|
|
823
|
-
options:
|
|
826
|
+
options: le,
|
|
824
827
|
translate: g,
|
|
825
|
-
notifyError:
|
|
826
|
-
error:
|
|
828
|
+
notifyError: X,
|
|
829
|
+
error: M,
|
|
827
830
|
clearError: () => k(null),
|
|
828
|
-
registerLoading: (
|
|
829
|
-
|
|
831
|
+
registerLoading: (c) => {
|
|
832
|
+
H.current = c;
|
|
830
833
|
},
|
|
831
|
-
registerDirtyGuard:
|
|
832
|
-
canNavigate:
|
|
833
|
-
exiting:
|
|
834
|
-
onRequestClose:
|
|
835
|
-
onOpened: (
|
|
834
|
+
registerDirtyGuard: F,
|
|
835
|
+
canNavigate: J,
|
|
836
|
+
exiting: v,
|
|
837
|
+
onRequestClose: b,
|
|
838
|
+
onOpened: (c) => {
|
|
836
839
|
try {
|
|
837
|
-
const h = ye.current?.onOpen?.(
|
|
838
|
-
Promise.resolve(h).catch((A) =>
|
|
840
|
+
const h = ye.current?.onOpen?.(c);
|
|
841
|
+
Promise.resolve(h).catch((A) => X(A, { phase: "onOpen" }));
|
|
839
842
|
} catch (h) {
|
|
840
|
-
|
|
843
|
+
X(h, { phase: "onOpen" });
|
|
841
844
|
}
|
|
842
845
|
}
|
|
843
846
|
},
|
|
@@ -848,9 +851,9 @@ function pt({ registry: e, children: n, defaultOptions: r = {}, backgroundColor:
|
|
|
848
851
|
const ot = Object.freeze({ canGoBack: !1, stack: [], currentRoute: null }), at = () => () => {
|
|
849
852
|
}, hn = () => ot;
|
|
850
853
|
function ft() {
|
|
851
|
-
const e =
|
|
854
|
+
const e = oe(yn), n = oe(_e), r = oe(We), t = fe(r?.subscribe ?? at, r?.getSnapshot ?? hn, r?.getSnapshot ?? hn);
|
|
852
855
|
if (!e) throw new Error("[react-modal-navigation] useModal requires <ModalProvider>");
|
|
853
|
-
const
|
|
856
|
+
const i = K(() => {
|
|
854
857
|
const g = () => {
|
|
855
858
|
if (!n) throw new Error("[react-modal-navigation] navigation requires an active modal screen; use modal.open() outside a modal");
|
|
856
859
|
return n;
|
|
@@ -869,24 +872,24 @@ function ft() {
|
|
|
869
872
|
currentRoute: t.currentRoute
|
|
870
873
|
};
|
|
871
874
|
}, [n, t]);
|
|
872
|
-
return
|
|
875
|
+
return K(() => ({ ...e, modal: e, navigation: i }), [e, i]);
|
|
873
876
|
}
|
|
874
877
|
function st() {
|
|
875
|
-
const e =
|
|
878
|
+
const e = oe(_e);
|
|
876
879
|
if (!e) throw new Error("useModalNavigationCommands requires an active modal screen");
|
|
877
880
|
return e;
|
|
878
881
|
}
|
|
879
|
-
function
|
|
880
|
-
const e =
|
|
882
|
+
function it() {
|
|
883
|
+
const e = oe(We);
|
|
881
884
|
if (!e) throw new Error("useModalNavigationState requires an active modal screen");
|
|
882
885
|
return fe(e.subscribe, e.getSnapshot, e.getSnapshot);
|
|
883
886
|
}
|
|
884
887
|
function gt() {
|
|
885
|
-
const e = st(), n =
|
|
886
|
-
return
|
|
888
|
+
const e = st(), n = it();
|
|
889
|
+
return K(() => ({ ...e, ...n }), [e, n]);
|
|
887
890
|
}
|
|
888
891
|
function Ln() {
|
|
889
|
-
const e =
|
|
892
|
+
const e = oe(je);
|
|
890
893
|
if (!e) throw new Error("useIsFocused must be called inside a modal screen");
|
|
891
894
|
return e.isFocused;
|
|
892
895
|
}
|
|
@@ -898,7 +901,7 @@ function ht(e) {
|
|
|
898
901
|
}, [n, e]);
|
|
899
902
|
}
|
|
900
903
|
function bt(e) {
|
|
901
|
-
const n =
|
|
904
|
+
const n = oe(je);
|
|
902
905
|
if (!n) throw new Error("useNavigationResult requires an active modal screen");
|
|
903
906
|
const r = l(e), t = l(null);
|
|
904
907
|
Q(() => {
|
|
@@ -908,65 +911,65 @@ function bt(e) {
|
|
|
908
911
|
}, [n.isFocused, n.resultEvent]);
|
|
909
912
|
}
|
|
910
913
|
function yt(e = {}) {
|
|
911
|
-
const n =
|
|
914
|
+
const n = oe(je);
|
|
912
915
|
if (!n) throw new Error("[react-modal-navigation] useModalFooter requires an active modal screen");
|
|
913
|
-
const { setFooter: r, routeKey: t } = n,
|
|
914
|
-
|
|
915
|
-
const g =
|
|
916
|
-
|
|
917
|
-
const
|
|
918
|
-
return [.../* @__PURE__ */ new Set([...Object.keys(
|
|
919
|
-
}) || (
|
|
920
|
-
source:
|
|
921
|
-
normalized:
|
|
922
|
-
...
|
|
923
|
-
onClick: (...
|
|
916
|
+
const { setFooter: r, routeKey: t } = n, i = l(e);
|
|
917
|
+
i.current = e;
|
|
918
|
+
const g = K(() => (...T) => i.current.done?.(...T), []), p = K(() => (...T) => (i.current.cancel ?? i.current.cancle)?.(...T), []), f = K(() => (...T) => i.current.renderFooter?.(...T), []), u = typeof e.done == "function", y = typeof (e.cancel ?? e.cancle) == "function", M = typeof e.renderFooter == "function", { showFooter: k, showFooterBorder: d, doneDisabled: m, doneText: a, cancelText: P, loadingText: N, footerClassName: D } = e, L = l({ source: null, normalized: void 0 }), G = Array.isArray(e.actions) ? e.actions : null, x = L.current.source;
|
|
919
|
+
G === x || G && x && G.length === x.length && G.every((T, v) => {
|
|
920
|
+
const j = x[v];
|
|
921
|
+
return [.../* @__PURE__ */ new Set([...Object.keys(T), ...Object.keys(j)])].every((F) => F === "onClick" || Object.is(T[F], j[F]));
|
|
922
|
+
}) || (L.current = {
|
|
923
|
+
source: G?.map((T) => ({ ...T })) ?? null,
|
|
924
|
+
normalized: G?.map((T, v) => ({
|
|
925
|
+
...T,
|
|
926
|
+
onClick: (...j) => (i.current.actions?.find((F) => F.key === T.key) ?? i.current.actions?.[v])?.onClick?.(...j)
|
|
924
927
|
}))
|
|
925
928
|
});
|
|
926
|
-
const
|
|
929
|
+
const $ = L.current.normalized, H = K(() => ({
|
|
927
930
|
showFooter: k,
|
|
928
931
|
showFooterBorder: d,
|
|
929
932
|
doneDisabled: m,
|
|
930
933
|
doneText: a,
|
|
931
|
-
cancelText:
|
|
932
|
-
loadingText:
|
|
934
|
+
cancelText: P,
|
|
935
|
+
loadingText: N,
|
|
933
936
|
footerClassName: D,
|
|
934
|
-
|
|
937
|
+
...$ !== void 0 ? { actions: $ } : {},
|
|
935
938
|
...u ? { done: g } : {},
|
|
936
|
-
...
|
|
937
|
-
...
|
|
938
|
-
}), [k, d, m, a,
|
|
939
|
+
...y ? { cancel: p } : {},
|
|
940
|
+
...M ? { renderFooter: f } : {}
|
|
941
|
+
}), [k, d, m, a, P, N, D, $, u, y, M, g, p, f]);
|
|
939
942
|
Q(() => {
|
|
940
|
-
r(t,
|
|
941
|
-
}, [t, r,
|
|
943
|
+
r(t, H);
|
|
944
|
+
}, [t, r, H]), Q(() => () => r(t, null), [t, r]);
|
|
942
945
|
}
|
|
943
|
-
function
|
|
944
|
-
const e =
|
|
946
|
+
function ct() {
|
|
947
|
+
const e = oe(Me), n = oe(Ue);
|
|
945
948
|
if (!e || !n) throw new Error("[react-modal-navigation] useModalLoading requires an active modal screen");
|
|
946
949
|
const r = fe(n.subscribe, n.getSnapshot, n.getSnapshot);
|
|
947
|
-
return
|
|
950
|
+
return K(() => ({ ...e, isLoading: r.visible }), [e, r.visible]);
|
|
948
951
|
}
|
|
949
952
|
function vt() {
|
|
950
|
-
const e =
|
|
953
|
+
const e = oe(Me);
|
|
951
954
|
if (!e) throw new Error("[react-modal-navigation] useModalLoadingCommands requires an active modal screen");
|
|
952
955
|
return e;
|
|
953
956
|
}
|
|
954
957
|
function xt() {
|
|
955
|
-
const e =
|
|
958
|
+
const e = oe(Ue);
|
|
956
959
|
if (!e) throw new Error("[react-modal-navigation] useModalLoadingState requires an active modal screen");
|
|
957
960
|
return fe(e.subscribe, e.getSnapshot, e.getSnapshot);
|
|
958
961
|
}
|
|
959
962
|
function wt() {
|
|
960
|
-
const e =
|
|
963
|
+
const e = ct(), n = Ln(), r = l(!0), t = l(!1), [i, g] = pe(!1), [p, f] = pe(null), u = l(e);
|
|
961
964
|
return u.current = e, Q(() => (r.current = !0, () => {
|
|
962
965
|
r.current = !1;
|
|
963
|
-
}), []), { run: w(async (
|
|
966
|
+
}), []), { run: w(async (M, k = {}) => {
|
|
964
967
|
if (t.current) return { status: "busy" };
|
|
965
|
-
if (typeof
|
|
968
|
+
if (typeof M != "function") throw new TypeError("[react-modal-navigation] run requires a function");
|
|
966
969
|
t.current = !0, r.current && (g(!0), f(null));
|
|
967
970
|
const d = u.current.showLoading(k.loadingText);
|
|
968
971
|
try {
|
|
969
|
-
const m = await
|
|
972
|
+
const m = await M();
|
|
970
973
|
return r.current && await k.onSuccess?.(m), { status: "success", value: m };
|
|
971
974
|
} catch (m) {
|
|
972
975
|
if (r.current) {
|
|
@@ -982,15 +985,15 @@ function wt() {
|
|
|
982
985
|
} finally {
|
|
983
986
|
d != null && u.current.hideLoading(d), t.current = !1, r.current && g(!1);
|
|
984
987
|
}
|
|
985
|
-
}, []), pending:
|
|
988
|
+
}, []), pending: i, error: p, clearError: () => f(null), isFocused: n };
|
|
986
989
|
}
|
|
987
990
|
function kt(e, n = {}) {
|
|
988
|
-
const r =
|
|
991
|
+
const r = oe(tn);
|
|
989
992
|
if (!r) throw new Error("[react-modal-navigation] useModalUnsavedChanges must be used inside a modal screen");
|
|
990
993
|
const t = l({ dirty: e, ...n });
|
|
991
994
|
t.current = { dirty: e, ...n };
|
|
992
|
-
const { routeKey:
|
|
993
|
-
Q(() => g(
|
|
995
|
+
const { routeKey: i, registerDirtyGuard: g } = r;
|
|
996
|
+
Q(() => g(i, {
|
|
994
997
|
get dirty() {
|
|
995
998
|
return !!t.current.dirty;
|
|
996
999
|
},
|
|
@@ -1000,15 +1003,15 @@ function kt(e, n = {}) {
|
|
|
1000
1003
|
get onBeforeDiscard() {
|
|
1001
1004
|
return t.current.onBeforeDiscard;
|
|
1002
1005
|
}
|
|
1003
|
-
}), [
|
|
1006
|
+
}), [i, g]);
|
|
1004
1007
|
}
|
|
1005
1008
|
const St = () => {
|
|
1006
|
-
const e =
|
|
1009
|
+
const e = oe(rn);
|
|
1007
1010
|
if (!e) throw new Error("[react-modal-navigation] useToast requires an active modal");
|
|
1008
1011
|
return e;
|
|
1009
1012
|
};
|
|
1010
1013
|
function lt() {
|
|
1011
|
-
const e =
|
|
1014
|
+
const e = oe(on);
|
|
1012
1015
|
if (!e) throw new Error("[react-modal-navigation] useModalRoute requires a modal screen");
|
|
1013
1016
|
return e;
|
|
1014
1017
|
}
|
|
@@ -1022,12 +1025,12 @@ export {
|
|
|
1022
1025
|
Ln as useIsFocused,
|
|
1023
1026
|
ft as useModal,
|
|
1024
1027
|
yt as useModalFooter,
|
|
1025
|
-
|
|
1028
|
+
ct as useModalLoading,
|
|
1026
1029
|
vt as useModalLoadingCommands,
|
|
1027
1030
|
xt as useModalLoadingState,
|
|
1028
1031
|
gt as useModalNavigation,
|
|
1029
1032
|
st as useModalNavigationCommands,
|
|
1030
|
-
|
|
1033
|
+
it as useModalNavigationState,
|
|
1031
1034
|
Et as useModalParams,
|
|
1032
1035
|
lt as useModalRoute,
|
|
1033
1036
|
wt as useModalTask,
|