react-modal-navigation 1.2.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.js +618 -604
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as p, jsxs as be } from "react/jsx-runtime";
|
|
2
|
-
import Se, { createContext as we, useState as xe, useEffect as U, useRef as
|
|
2
|
+
import Se, { createContext as we, useState as xe, useEffect as U, useRef as T, useMemo as Q, useSyncExternalStore as Oe, useContext as ee, memo as rt, useCallback as _, useReducer as dn, useLayoutEffect as Ae, Suspense as Wt, useInsertionEffect as mn } from "react";
|
|
3
3
|
import { createPortal as pn } from "react-dom";
|
|
4
4
|
function je(e) {
|
|
5
5
|
let t = e;
|
|
@@ -14,10 +14,10 @@ function je(e) {
|
|
|
14
14
|
for (const a of [...n])
|
|
15
15
|
if (!(r || !n.has(a)))
|
|
16
16
|
try {
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
} catch (
|
|
20
|
-
console.error(
|
|
17
|
+
const c = a();
|
|
18
|
+
c && typeof c.then == "function" && Promise.resolve(c).catch((f) => console.error(f));
|
|
19
|
+
} catch (c) {
|
|
20
|
+
console.error(c);
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
},
|
|
@@ -57,7 +57,7 @@ function mt(e, t) {
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
function $t(e, t, n = 1 / 0, r = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set()) {
|
|
60
|
-
const a = n === 1 / 0 ? 1 / 0 : Math.max(0, Math.floor(Number(n) || 0)),
|
|
60
|
+
const a = n === 1 / 0 ? 1 / 0 : Math.max(0, Math.floor(Number(n) || 0)), c = e.slice(0, -1).filter((u) => t[u.name]?.keepAlive !== !1), f = new Set((a === 0 ? [] : c.slice(-a)).map((u) => u.key));
|
|
61
61
|
return e.filter((u, i) => i === e.length - 1 || (f.has(u.key) || o.has(u.key)) && !r.has(u.key));
|
|
62
62
|
}
|
|
63
63
|
function hn(e, t, n) {
|
|
@@ -67,8 +67,8 @@ function hn(e, t, n) {
|
|
|
67
67
|
function gn(e, t) {
|
|
68
68
|
const n = e.responsive;
|
|
69
69
|
if (!n) return e;
|
|
70
|
-
const { sm: r, md: o, lg: a, xl:
|
|
71
|
-
return { ...e, ...t < 768 ? r : t < 1024 ? o : t < 1280 ? a :
|
|
70
|
+
const { sm: r, md: o, lg: a, xl: c } = n;
|
|
71
|
+
return { ...e, ...t < 768 ? r : t < 1024 ? o : t < 1280 ? a : c, ...e.runtimeLayout };
|
|
72
72
|
}
|
|
73
73
|
function yn(e, t, n, r) {
|
|
74
74
|
const o = Math.max(0, Math.min(n ?? 1 / 0, r));
|
|
@@ -96,49 +96,49 @@ function bn() {
|
|
|
96
96
|
}
|
|
97
97
|
const wn = 'a[href],button:not([disabled]),input:not([disabled]),textarea:not([disabled]),select:not([disabled]),[tabindex]:not([tabindex="-1"])', kn = (e) => !e.closest('[inert], [hidden], [aria-hidden="true"]') && e.getClientRects().length > 0 && getComputedStyle(e).visibility !== "hidden" && getComputedStyle(e).display !== "none";
|
|
98
98
|
function xn({ dialogRef: e, options: t, requestClose: n, children: r, exiting: o = !1 }) {
|
|
99
|
-
const [a,
|
|
99
|
+
const [a, c] = xe(() => typeof window > "u" ? 1024 : window.innerWidth), f = !!t.responsive;
|
|
100
100
|
U(() => {
|
|
101
101
|
if (!f) return;
|
|
102
|
-
const
|
|
103
|
-
return window.addEventListener("resize",
|
|
102
|
+
const P = () => c(window.innerWidth < 768 ? 0 : window.innerWidth < 1024 ? 768 : window.innerWidth < 1280 ? 1024 : 1280);
|
|
103
|
+
return window.addEventListener("resize", P), P(), () => window.removeEventListener("resize", P);
|
|
104
104
|
}, [f]), t = gn(t, a);
|
|
105
105
|
const [u, i] = xe(null);
|
|
106
106
|
U(() => i(null), [t.width, t.placement]);
|
|
107
|
-
const d =
|
|
107
|
+
const d = T(null), h = T(0);
|
|
108
108
|
U(() => () => {
|
|
109
|
-
|
|
109
|
+
h.current && cancelAnimationFrame(h.current);
|
|
110
110
|
}, []);
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
const s =
|
|
111
|
+
const v = T(null), k = T(null), b = T(n);
|
|
112
|
+
b.current = n;
|
|
113
|
+
const s = T(t.closeOnEsc);
|
|
114
114
|
s.current = t.closeOnEsc;
|
|
115
|
-
const [
|
|
115
|
+
const [y, A] = xe(It), O = t.theme === "light" || t.theme === "dark" ? t.theme : y;
|
|
116
116
|
U(() => {
|
|
117
117
|
if (t.theme === "light" || t.theme === "dark") return;
|
|
118
|
-
const
|
|
118
|
+
const P = () => A(It()), G = new MutationObserver(P);
|
|
119
119
|
for (const Ce of [document.documentElement, document.body]) G.observe(Ce, { attributes: !0, attributeFilter: ["class", "data-theme"] });
|
|
120
120
|
const ke = window.matchMedia?.("(prefers-color-scheme: dark)");
|
|
121
|
-
return ke?.addEventListener?.("change",
|
|
122
|
-
G.disconnect(), ke?.removeEventListener?.("change",
|
|
121
|
+
return ke?.addEventListener?.("change", P), P(), () => {
|
|
122
|
+
G.disconnect(), ke?.removeEventListener?.("change", P);
|
|
123
123
|
};
|
|
124
124
|
}, [t.theme]), U(() => {
|
|
125
|
-
|
|
126
|
-
const
|
|
125
|
+
k.current = document.activeElement;
|
|
126
|
+
const P = bn(), G = v.current;
|
|
127
127
|
Ke.push(G), e.current?.focus({ preventScroll: !0 });
|
|
128
128
|
const ke = (K) => {
|
|
129
129
|
const de = e.current;
|
|
130
130
|
if (!de || Ke.at(-1) !== G) return;
|
|
131
131
|
if (K.key === "Escape" && s.current !== !1) {
|
|
132
|
-
K.preventDefault(),
|
|
132
|
+
K.preventDefault(), b.current("escape");
|
|
133
133
|
return;
|
|
134
134
|
}
|
|
135
135
|
if (K.key !== "Tab") return;
|
|
136
|
-
const
|
|
137
|
-
if (!
|
|
136
|
+
const x = [...de.querySelectorAll(wn)].filter(kn);
|
|
137
|
+
if (!x.length) {
|
|
138
138
|
K.preventDefault(), de.focus();
|
|
139
139
|
return;
|
|
140
140
|
}
|
|
141
|
-
const ce =
|
|
141
|
+
const ce = x[0], ne = x.at(-1);
|
|
142
142
|
de.contains(document.activeElement) ? K.shiftKey && (document.activeElement === ce || document.activeElement === de) ? (K.preventDefault(), ne.focus()) : !K.shiftKey && (document.activeElement === ne || document.activeElement === de) && (K.preventDefault(), ce.focus()) : (K.preventDefault(), (K.shiftKey ? ne : ce).focus());
|
|
143
143
|
}, Ce = (K) => {
|
|
144
144
|
Ke.at(-1) === G && e.current && !e.current.contains(K.target) && e.current.focus({ preventScroll: !0 });
|
|
@@ -146,23 +146,23 @@ function xn({ dialogRef: e, options: t, requestClose: n, children: r, exiting: o
|
|
|
146
146
|
return document.addEventListener("keydown", ke), document.addEventListener("focusin", Ce), () => {
|
|
147
147
|
document.removeEventListener("keydown", ke), document.removeEventListener("focusin", Ce);
|
|
148
148
|
const K = Ke.at(-1) === G, de = Ke.indexOf(G);
|
|
149
|
-
if (de !== -1 && Ke.splice(de, 1),
|
|
150
|
-
const
|
|
151
|
-
|
|
149
|
+
if (de !== -1 && Ke.splice(de, 1), P(), K) {
|
|
150
|
+
const x = k.current;
|
|
151
|
+
x?.isConnected && !x.closest("[inert], [hidden]") ? x.focus?.({ preventScroll: !0 }) : Ke.at(-1)?.querySelector("[role=dialog]")?.focus?.({ preventScroll: !0 });
|
|
152
152
|
}
|
|
153
153
|
};
|
|
154
154
|
}, [e]);
|
|
155
|
-
const
|
|
156
|
-
!d.current || d.current.id !==
|
|
155
|
+
const L = t.backgroundColor ?? t.backgroudColor, E = typeof L == "string" ? L : L?.[O], D = typeof E == "string" && /^(#|(?:rgb|rgba|hsl|hsla|hwb|oklch|oklab|lab|lch|color|color-mix|light-dark|var)\(|transparent$|currentColor$|[a-z]+$)/i.test(E.trim()) ? E.trim() : null, z = typeof E == "string" && !D ? E.trim() : "", N = !!(D || z), F = ["center", "left", "right", "top", "bottom"].includes(t.placement) ? t.placement : "right", j = Ie(u ?? t.width ?? vn[t.size] ?? 460), Z = Ie(t.height), ue = Ie(t.maxHeight), C = Ie(t.maxWidth), $ = Number(t.viewportGap ?? 5), I = Number.isFinite($) ? Math.max(0, $) : 5, X = t.top == null ? null : Ie(t.top), q = F !== "bottom" && X !== null ? X : null, te = typeof t.borderRadius == "number" ? `${t.borderRadius}px` : t.borderRadius ?? "12px", V = t.resizable && !t.fullscreen && ["left", "right"].includes(F), oe = (P) => yn(P, t.minWidth, typeof t.maxWidth == "number" ? t.maxWidth : void 0, v.current?.clientWidth - I * 2 || window.innerWidth), J = (P) => {
|
|
156
|
+
!d.current || d.current.id !== P.pointerId || (cancelAnimationFrame(h.current), i(d.current.width), e.current?.style.removeProperty("--pmn-drag-width"), d.current = null);
|
|
157
157
|
};
|
|
158
158
|
return pn(/* @__PURE__ */ p(
|
|
159
159
|
"div",
|
|
160
160
|
{
|
|
161
|
-
ref:
|
|
162
|
-
className: `pmn-overlay ${o ? "pmn-exiting" : "pmn-entering"} ${t.animation === !1 ? "pmn-no-animation" : ""} pmn-place-${
|
|
163
|
-
style: { padding:
|
|
164
|
-
onMouseDown: (
|
|
165
|
-
|
|
161
|
+
ref: v,
|
|
162
|
+
className: `pmn-overlay ${o ? "pmn-exiting" : "pmn-entering"} ${t.animation === !1 ? "pmn-no-animation" : ""} pmn-place-${F} ${t.fullscreen ? "pmn-fullscreen" : ""} ${t.mobileFullscreen ? "pmn-mobile-fullscreen" : ""}`,
|
|
163
|
+
style: { padding: I, ...t.bottom != null ? { paddingBottom: Ie(t.bottom) } : {}, ...t.left != null ? { paddingLeft: Ie(t.left) } : {}, ...t.right != null ? { paddingRight: Ie(t.right) } : {}, ...q !== null ? { paddingTop: q, "--pmn-top-offset": q } : {}, "--pmn-animation-duration": `${Math.min(1e3, Math.max(0, Number(t.animationDuration ?? 220) || 0))}ms` },
|
|
164
|
+
onMouseDown: (P) => {
|
|
165
|
+
P.target === P.currentTarget && t.closeOnOverlay === !0 && b.current("overlay");
|
|
166
166
|
},
|
|
167
167
|
children: /* @__PURE__ */ be(
|
|
168
168
|
"section",
|
|
@@ -172,11 +172,11 @@ function xn({ dialogRef: e, options: t, requestClose: n, children: r, exiting: o
|
|
|
172
172
|
role: "dialog",
|
|
173
173
|
"aria-modal": "true",
|
|
174
174
|
"aria-label": t.ariaLabel ?? "Dialog",
|
|
175
|
-
"data-modal-theme":
|
|
176
|
-
className: `pmn-dialog ${
|
|
177
|
-
style: { "--pmn-width":
|
|
175
|
+
"data-modal-theme": O,
|
|
176
|
+
className: `pmn-dialog ${O === "dark" ? "dark" : ""} ${N ? "pmn-has-custom-background" : ""} ${t.className ?? ""}`,
|
|
177
|
+
style: { "--pmn-width": j, "--pmn-gap": `${I}px`, ...q !== null ? { "--pmn-top-offset": q } : {}, ...Z !== void 0 ? { "--pmn-height": Z } : {}, ...ue !== void 0 ? { "--pmn-max-height": ue } : {}, ...C !== void 0 ? { "--pmn-max-width": C } : {}, borderRadius: te },
|
|
178
178
|
children: [
|
|
179
|
-
|
|
179
|
+
N && /* @__PURE__ */ p("div", { "aria-hidden": "true", className: `pmn-custom-background-layer ${z}`, style: D ? { backgroundColor: D } : void 0 }),
|
|
180
180
|
r,
|
|
181
181
|
V && /* @__PURE__ */ p(
|
|
182
182
|
"div",
|
|
@@ -185,19 +185,19 @@ function xn({ dialogRef: e, options: t, requestClose: n, children: r, exiting: o
|
|
|
185
185
|
"aria-label": "调整弹窗宽度",
|
|
186
186
|
"aria-orientation": "vertical",
|
|
187
187
|
tabIndex: 0,
|
|
188
|
-
className: `pmn-resize-handle pmn-resize-${
|
|
189
|
-
onKeyDown: (
|
|
190
|
-
["ArrowLeft", "ArrowRight"].includes(
|
|
188
|
+
className: `pmn-resize-handle pmn-resize-${F}`,
|
|
189
|
+
onKeyDown: (P) => {
|
|
190
|
+
["ArrowLeft", "ArrowRight"].includes(P.key) && (P.preventDefault(), i(oe(e.current.getBoundingClientRect().width + (P.key === "ArrowRight" ? 16 : -16) * (F === "left" ? 1 : -1))));
|
|
191
191
|
},
|
|
192
|
-
onPointerDown: (
|
|
193
|
-
if (
|
|
194
|
-
|
|
192
|
+
onPointerDown: (P) => {
|
|
193
|
+
if (P.button !== 0) return;
|
|
194
|
+
P.preventDefault(), P.currentTarget.setPointerCapture(P.pointerId);
|
|
195
195
|
const G = e.current.getBoundingClientRect().width;
|
|
196
|
-
d.current = { id:
|
|
196
|
+
d.current = { id: P.pointerId, x: P.clientX, start: G, width: G };
|
|
197
197
|
},
|
|
198
|
-
onPointerMove: (
|
|
198
|
+
onPointerMove: (P) => {
|
|
199
199
|
const G = d.current;
|
|
200
|
-
!G || G.id !==
|
|
200
|
+
!G || G.id !== P.pointerId || (G.width = oe(G.start + (P.clientX - G.x) * (F === "left" ? 1 : -1)), cancelAnimationFrame(h.current), h.current = requestAnimationFrame(() => e.current?.style.setProperty("--pmn-drag-width", `${G.width}px`)));
|
|
201
201
|
},
|
|
202
202
|
onPointerUp: J,
|
|
203
203
|
onPointerCancel: J,
|
|
@@ -212,19 +212,19 @@ function xn({ dialogRef: e, options: t, requestClose: n, children: r, exiting: o
|
|
|
212
212
|
}
|
|
213
213
|
const Sn = (e) => e;
|
|
214
214
|
function Pe(e, t = Sn, n = Object.is) {
|
|
215
|
-
const r =
|
|
216
|
-
let
|
|
215
|
+
const r = T({ store: null, initialized: !1, selection: void 0 }), o = Q(() => {
|
|
216
|
+
let c = !1, f, u;
|
|
217
217
|
return () => {
|
|
218
218
|
const i = e.getSnapshot();
|
|
219
|
-
if (
|
|
219
|
+
if (c && Object.is(f, i)) return u;
|
|
220
220
|
const d = t(i);
|
|
221
|
-
if (
|
|
221
|
+
if (c)
|
|
222
222
|
n(u, d) || (u = d);
|
|
223
223
|
else {
|
|
224
|
-
const
|
|
225
|
-
u =
|
|
224
|
+
const h = r.current;
|
|
225
|
+
u = h.initialized && h.store === e && n(h.selection, d) ? h.selection : d;
|
|
226
226
|
}
|
|
227
|
-
return f = i,
|
|
227
|
+
return f = i, c = !0, u;
|
|
228
228
|
};
|
|
229
229
|
}, [e, t, n]), a = Oe(e.subscribe, o, o);
|
|
230
230
|
return U(() => {
|
|
@@ -247,18 +247,18 @@ function Tn(e, t) {
|
|
|
247
247
|
}
|
|
248
248
|
const Zt = {}, Ln = () => Zt, zn = () => () => {
|
|
249
249
|
}, An = Se.memo(function({ action: t, context: n }) {
|
|
250
|
-
const r =
|
|
251
|
-
return U(() => (
|
|
252
|
-
|
|
250
|
+
const r = T(!1), [o, a] = xe(!1), c = T(!1);
|
|
251
|
+
return U(() => (c.current = !0, () => {
|
|
252
|
+
c.current = !1;
|
|
253
253
|
}), []), /* @__PURE__ */ p("button", { type: "button", className: "pmn-icon-button", "aria-label": t.tooltip ?? t.key, title: t.tooltip, disabled: o || t.disabled || t.loading, onClick: async () => {
|
|
254
|
-
if (!(r.current || !
|
|
254
|
+
if (!(r.current || !c.current || t.disabled || t.loading)) {
|
|
255
255
|
r.current = !0, a(!0);
|
|
256
256
|
try {
|
|
257
257
|
await t.onClick?.(n);
|
|
258
258
|
} catch (f) {
|
|
259
259
|
console.error("[react-modal-navigation] header action", f);
|
|
260
260
|
} finally {
|
|
261
|
-
r.current = !1,
|
|
261
|
+
r.current = !1, c.current && a(!1);
|
|
262
262
|
}
|
|
263
263
|
}
|
|
264
264
|
}, children: o ? "…" : t.icon ?? t.label });
|
|
@@ -266,19 +266,19 @@ const Zt = {}, Ln = () => Zt, zn = () => () => {
|
|
|
266
266
|
function Dt({ back: e }) {
|
|
267
267
|
return /* @__PURE__ */ p("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", width: "20", height: "20", fill: "none", stroke: "currentColor", strokeWidth: "2", children: e ? /* @__PURE__ */ p("path", { d: "m15 18-6-6 6-6" }) : /* @__PURE__ */ p("path", { d: "M18 6 6 18M6 6l12 12" }) });
|
|
268
268
|
}
|
|
269
|
-
function Nn({ options: e, screen: t, route: n, navigation: r, requestClose: o, translate: a, canGoBack:
|
|
269
|
+
function Nn({ options: e, screen: t, route: n, navigation: r, requestClose: o, translate: a, canGoBack: c }) {
|
|
270
270
|
const f = ee(yt), u = () => f?.getSnapshot()[n.key] ?? Zt, i = Oe(f?.subscribe ?? zn, u, Ln);
|
|
271
271
|
t = { ...t, ...i };
|
|
272
|
-
const d = a ?? ((
|
|
272
|
+
const d = a ?? ((y) => y), h = t.showTitle ?? e.showTitle ?? !0, v = typeof t.title == "function" ? t.title({ t: d, route: n, navigation: r }) : t.title ?? n.name, k = Q(() => ({ route: n, navigation: r, close: o, canGoBack: c, title: v, t: d }), [n, r, o, c, v, d]);
|
|
273
273
|
if (e.showHeader === !1) return null;
|
|
274
|
-
const
|
|
275
|
-
if (
|
|
274
|
+
const b = t.renderHeader ?? e.renderHeader;
|
|
275
|
+
if (b) return b(k);
|
|
276
276
|
const s = t.renderHeaderRight ?? e.renderHeaderRight;
|
|
277
277
|
return /* @__PURE__ */ be("header", { className: `pmn-header ${t.showHeaderBorder ?? e.showHeaderBorder ? "pmn-border-bottom" : ""} ${e.headerClassName ?? ""}`, children: [
|
|
278
|
-
(t.showBackButton ?? e.showBackButton) !== !1 &&
|
|
279
|
-
|
|
280
|
-
s?.(
|
|
281
|
-
i.actions?.filter((
|
|
278
|
+
(t.showBackButton ?? e.showBackButton) !== !1 && c && /* @__PURE__ */ p("button", { type: "button", className: "pmn-icon-button", "aria-label": d("modal.back"), onClick: () => r.goBack(), children: /* @__PURE__ */ p(Dt, { back: !0 }) }),
|
|
279
|
+
h ? /* @__PURE__ */ p("h2", { children: v }) : /* @__PURE__ */ p("div", { className: "pmn-header-spacer" }),
|
|
280
|
+
s?.(k),
|
|
281
|
+
i.actions?.filter((y) => !y.hidden).map((y) => /* @__PURE__ */ p(An, { action: y, context: k }, `${n.key}:${y.key}`)),
|
|
282
282
|
/* @__PURE__ */ p(jn, { hidden: t.showFullscreenButton === !1 }),
|
|
283
283
|
(t.showCloseButton ?? e.showCloseButton) !== !1 && /* @__PURE__ */ p("button", { type: "button", className: "pmn-icon-button", "aria-label": d("modal.close"), onClick: () => o("header"), children: /* @__PURE__ */ p(Dt, {}) })
|
|
284
284
|
] });
|
|
@@ -287,26 +287,26 @@ const jn = Se.memo(function({ hidden: t }) {
|
|
|
287
287
|
const n = ee(Lt), r = ee(at), o = Pe(r.stores.layout, Mn, He);
|
|
288
288
|
return t || !o.fullscreenable ? null : /* @__PURE__ */ p("button", { type: "button", className: "pmn-icon-button", "aria-label": o.fullscreen ? "还原" : "全屏", onClick: n?.toggleFullscreen, children: /* @__PURE__ */ p("svg", { "aria-hidden": "true", width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ p("path", { d: o.fullscreen ? "M3 9h6V3 M21 9h-6V3 M3 15h6v6 M21 15h-6v6" : "M3 9V3h6 M15 3h6v6 M3 15v6h6 M15 21h6v-6" }) }) });
|
|
289
289
|
}), Xt = rt(function({ store: t, screenOptions: n, ...r }) {
|
|
290
|
-
const o = _((
|
|
290
|
+
const o = _((c) => Pn(c, n), [n]), a = Pe(t, o, Tn);
|
|
291
291
|
return /* @__PURE__ */ p(xn, { ...r, options: a });
|
|
292
292
|
}), Jt = rt(function({ store: t, ...n }) {
|
|
293
293
|
const r = Pe(t, Rn, He);
|
|
294
294
|
return /* @__PURE__ */ p(Nn, { ...n, options: r });
|
|
295
295
|
}), Bn = Se.memo(function({ action: t, context: n, loadingApi: r, onError: o, loadingText: a }) {
|
|
296
|
-
const
|
|
296
|
+
const c = T(!1), [f, u] = xe(!1), i = T(!1);
|
|
297
297
|
U(() => (i.current = !0, () => {
|
|
298
298
|
i.current = !1;
|
|
299
299
|
}), []);
|
|
300
|
-
const d = f || t.loading === !0,
|
|
301
|
-
if (!i.current ||
|
|
302
|
-
|
|
303
|
-
const
|
|
300
|
+
const d = f || t.loading === !0, h = t.loadingText ?? a ?? n.t("modal.processing"), v = async () => {
|
|
301
|
+
if (!i.current || c.current || t.disabled || t.loading || typeof t.onClick != "function") return;
|
|
302
|
+
c.current = !0, u(!0);
|
|
303
|
+
const k = r?.begin(n.route.key, h);
|
|
304
304
|
try {
|
|
305
305
|
await t.onClick(n);
|
|
306
|
-
} catch (
|
|
307
|
-
o?.(
|
|
306
|
+
} catch (b) {
|
|
307
|
+
o?.(b, { phase: "footer", action: t.key, route: n.route });
|
|
308
308
|
} finally {
|
|
309
|
-
|
|
309
|
+
k != null && r?.end(n.route.key, k), c.current = !1, i.current && u(!1);
|
|
310
310
|
}
|
|
311
311
|
};
|
|
312
312
|
return /* @__PURE__ */ p(
|
|
@@ -315,39 +315,39 @@ const jn = Se.memo(function({ hidden: t }) {
|
|
|
315
315
|
type: "button",
|
|
316
316
|
disabled: t.disabled === !0 || d,
|
|
317
317
|
className: `pmn-button ${t.variant === "primary" || t.variant === "danger" ? "pmn-button-primary" : "pmn-button-secondary"} ${t.variant === "danger" ? "pmn-button-danger" : ""}`,
|
|
318
|
-
onClick:
|
|
319
|
-
children: d ?
|
|
318
|
+
onClick: v,
|
|
319
|
+
children: d ? h : t.label
|
|
320
320
|
}
|
|
321
321
|
);
|
|
322
322
|
});
|
|
323
|
-
function en({ screen: e, options: t, override: n, route: r, navigation: o, requestClose: a, translate:
|
|
324
|
-
const [i, d] = xe(null),
|
|
325
|
-
U(() => (
|
|
326
|
-
|
|
323
|
+
function en({ screen: e, options: t, override: n, route: r, navigation: o, requestClose: a, translate: c, onError: f, loadingApi: u }) {
|
|
324
|
+
const [i, d] = xe(null), h = T(/* @__PURE__ */ new Set()), v = T(!0);
|
|
325
|
+
U(() => (v.current = !0, () => {
|
|
326
|
+
v.current = !1;
|
|
327
327
|
}), []);
|
|
328
|
-
const
|
|
328
|
+
const k = c ?? ((j) => j), b = { ...t, ...e, ...n }, { showFooter: s, renderFooter: y, done: A, cancel: O, cancle: L } = b, E = O ?? L, D = Q(() => ({ route: r, navigation: o, close: a, t: k }), [r, o, a, k]);
|
|
329
329
|
if (s === !1) return null;
|
|
330
|
-
const
|
|
331
|
-
if (typeof
|
|
332
|
-
const
|
|
333
|
-
if (!
|
|
334
|
-
const
|
|
335
|
-
if (!
|
|
336
|
-
|
|
337
|
-
const C = u?.begin(r.key,
|
|
330
|
+
const z = `pmn-footer ${b.showFooterBorder ? "pmn-border-top" : ""} ${b.footerClassName ?? ""}`;
|
|
331
|
+
if (typeof y == "function") return /* @__PURE__ */ p("footer", { className: z, children: y({ ...D, pending: h.current.size > 0 }) });
|
|
332
|
+
const N = Array.isArray(b.actions) ? b.actions : null;
|
|
333
|
+
if (!N && typeof A != "function" && typeof E != "function") return null;
|
|
334
|
+
const F = async (j, Z, ue) => {
|
|
335
|
+
if (!v.current || h.current.size > 0 || h.current.has(j) || typeof Z != "function") return;
|
|
336
|
+
h.current.add(j), d(j);
|
|
337
|
+
const C = u?.begin(r.key, b.loadingText ?? k("modal.processing"));
|
|
338
338
|
try {
|
|
339
339
|
await Z(D);
|
|
340
|
-
} catch (
|
|
341
|
-
f?.(
|
|
340
|
+
} catch ($) {
|
|
341
|
+
f?.($, { phase: "footer", action: j, route: r });
|
|
342
342
|
} finally {
|
|
343
|
-
C != null && u?.end(r.key, C),
|
|
343
|
+
C != null && u?.end(r.key, C), h.current.delete(j), v.current && d(($) => $ === j ? null : $);
|
|
344
344
|
}
|
|
345
345
|
};
|
|
346
|
-
return
|
|
347
|
-
(
|
|
348
|
-
) }) : /* @__PURE__ */ be("footer", { className:
|
|
349
|
-
typeof E == "function" && /* @__PURE__ */ p("button", { type: "button", disabled: i !== null, onClick: () =>
|
|
350
|
-
typeof
|
|
346
|
+
return N ? /* @__PURE__ */ p("footer", { className: z, children: N.filter((j) => !j.hidden).map(
|
|
347
|
+
(j) => /* @__PURE__ */ p(Bn, { action: j, context: D, loadingApi: u, onError: f, loadingText: b.loadingText }, `${r.key}:${j.key}`)
|
|
348
|
+
) }) : /* @__PURE__ */ be("footer", { className: z, children: [
|
|
349
|
+
typeof E == "function" && /* @__PURE__ */ p("button", { type: "button", disabled: i !== null, onClick: () => F("cancel", E), className: "pmn-button pmn-button-secondary", children: b.cancelText ?? k("modal.cancel") }),
|
|
350
|
+
typeof A == "function" && /* @__PURE__ */ p("button", { type: "button", disabled: i !== null || b.doneDisabled === !0, onClick: () => F("done", A), className: "pmn-button pmn-button-primary", children: i === "done" ? b.loadingText ?? k("modal.processing") : b.doneText ?? k("modal.done") })
|
|
351
351
|
] });
|
|
352
352
|
}
|
|
353
353
|
function tn({ loading: e, translate: t }) {
|
|
@@ -388,36 +388,36 @@ function nn({ items: e, dismiss: t }) {
|
|
|
388
388
|
] }, n.id)) }) : null;
|
|
389
389
|
}
|
|
390
390
|
function rn(e, t, n) {
|
|
391
|
-
const r =
|
|
391
|
+
const r = T(0), o = T(/* @__PURE__ */ new Map()), a = _((u) => {
|
|
392
392
|
clearTimeout(o.current.get(u)), o.current.delete(u), t.current && e.current.publish(e.current.getSnapshot().filter((i) => i.id !== u));
|
|
393
|
-
}, []),
|
|
393
|
+
}, []), c = _((u, i = {}) => {
|
|
394
394
|
if (typeof u != "string" || !u.trim()) throw new TypeError("[react-modal-navigation] toast message must be a non-empty string");
|
|
395
|
-
const d = typeof i == "string" ? { type: i } : i ?? {},
|
|
395
|
+
const d = typeof i == "string" ? { type: i } : i ?? {}, h = ["success", "error", "warning", "info"].includes(d.type) ? d.type : "info", v = ++r.current, k = Number.isFinite(d.duration) ? Math.max(0, d.duration) : 3e3;
|
|
396
396
|
if (!t.current) return null;
|
|
397
|
-
const
|
|
398
|
-
for (const
|
|
399
|
-
clearTimeout(o.current.get(
|
|
400
|
-
return e.current.publish([...
|
|
397
|
+
const b = e.current.getSnapshot(), s = b.slice(0, Math.max(0, b.length - 4));
|
|
398
|
+
for (const y of s)
|
|
399
|
+
clearTimeout(o.current.get(y.id)), o.current.delete(y.id);
|
|
400
|
+
return e.current.publish([...b.slice(-4), { id: v, message: u, type: h, dismissible: d.dismissible !== !1 }]), k > 0 && o.current.set(v, setTimeout(() => a(v), k)), v;
|
|
401
401
|
}, [a]), f = Q(() => {
|
|
402
|
-
const u = (i, d) =>
|
|
403
|
-
for (const i of ["success", "error", "warning", "info"]) u[i] = (d,
|
|
404
|
-
return u.promise = async (i, d,
|
|
405
|
-
const
|
|
402
|
+
const u = (i, d) => c(i, d);
|
|
403
|
+
for (const i of ["success", "error", "warning", "info"]) u[i] = (d, h = {}) => c(d, { ...h, type: i });
|
|
404
|
+
return u.promise = async (i, d, h = {}) => {
|
|
405
|
+
const v = c(d.loading, { ...h, type: "info", duration: 0 });
|
|
406
406
|
try {
|
|
407
|
-
const
|
|
408
|
-
|
|
409
|
-
const
|
|
410
|
-
return
|
|
411
|
-
} catch (
|
|
412
|
-
|
|
413
|
-
const
|
|
414
|
-
throw
|
|
407
|
+
const k = await (typeof i == "function" ? i() : i);
|
|
408
|
+
v != null && a(v);
|
|
409
|
+
const b = typeof d.success == "function" ? d.success(k) : d.success;
|
|
410
|
+
return b && c(b, { ...h, type: "success" }), k;
|
|
411
|
+
} catch (k) {
|
|
412
|
+
v != null && a(v);
|
|
413
|
+
const b = typeof d.error == "function" ? d.error(k) : d.error;
|
|
414
|
+
throw b && c(b, { ...h, type: "error" }), k;
|
|
415
415
|
}
|
|
416
416
|
}, u.dismiss = a, u.clear = () => {
|
|
417
417
|
for (const i of o.current.values()) clearTimeout(i);
|
|
418
418
|
o.current.clear(), e.current.publish([]);
|
|
419
419
|
}, u;
|
|
420
|
-
}, [
|
|
420
|
+
}, [c, a]);
|
|
421
421
|
return U(() => {
|
|
422
422
|
const u = () => {
|
|
423
423
|
for (const d of o.current.values()) clearTimeout(d);
|
|
@@ -444,26 +444,26 @@ function Fn(e) {
|
|
|
444
444
|
};
|
|
445
445
|
}
|
|
446
446
|
function on(e, t, n, r) {
|
|
447
|
-
const o = r.loadingTasks, a = r.loadingSequence,
|
|
447
|
+
const o = r.loadingTasks, a = r.loadingSequence, c = Q(() => Fn(o.current), [o]), f = _(() => {
|
|
448
448
|
if (!t.current) return;
|
|
449
|
-
const
|
|
450
|
-
(s.visible !==
|
|
451
|
-
}, [
|
|
452
|
-
if (!t.current ||
|
|
453
|
-
const
|
|
454
|
-
return o.current.set(
|
|
455
|
-
}, [f,
|
|
449
|
+
const b = c.read(), s = e.current.getSnapshot();
|
|
450
|
+
(s.visible !== b.visible || s.text !== b.text || s.count !== b.count) && e.current.publish(b);
|
|
451
|
+
}, [c]), u = _((b, s) => {
|
|
452
|
+
if (!t.current || b !== "global" && n.current !== b) return null;
|
|
453
|
+
const y = ++a.current;
|
|
454
|
+
return o.current.set(y, { owner: b, text: s }), c.added(y), f(), y;
|
|
455
|
+
}, [f, c]), i = _((b, s) => {
|
|
456
456
|
if (s != null)
|
|
457
|
-
o.current.get(s)?.owner ===
|
|
457
|
+
o.current.get(s)?.owner === b && o.current.delete(s);
|
|
458
458
|
else
|
|
459
|
-
for (const [
|
|
459
|
+
for (const [y, A] of o.current) A.owner === b && o.current.delete(y);
|
|
460
460
|
f();
|
|
461
|
-
}, [f]), d = _((
|
|
462
|
-
|
|
463
|
-
}, [u, i]),
|
|
464
|
-
s ? (i(
|
|
461
|
+
}, [f]), d = _((b, s) => {
|
|
462
|
+
b ? (i("global"), u("global", s)) : i("global");
|
|
463
|
+
}, [u, i]), h = _((b, s, y) => {
|
|
464
|
+
s ? (i(b), u(b, y)) : i(b);
|
|
465
465
|
}, [u, i]);
|
|
466
|
-
return { loadingApi: Q(() => ({ setLoading: d, setScreenLoading:
|
|
466
|
+
return { loadingApi: Q(() => ({ setLoading: d, setScreenLoading: h, begin: u, end: i }), [d, h, u, i]), refreshLoading: f, loadingTasks: o, setLoading: d };
|
|
467
467
|
}
|
|
468
468
|
const $n = Se.memo(function({ store: t, translate: n }) {
|
|
469
469
|
const r = Oe(t.subscribe, t.getSnapshot, t.getSnapshot);
|
|
@@ -472,162 +472,162 @@ const $n = Se.memo(function({ store: t, translate: n }) {
|
|
|
472
472
|
const r = Oe(t.subscribe, t.getSnapshot, t.getSnapshot);
|
|
473
473
|
return /* @__PURE__ */ p(nn, { items: r, dismiss: n });
|
|
474
474
|
}), Dn = Se.memo(function({ store: t, layoutStore: n, routeKey: r, ...o }) {
|
|
475
|
-
const a = () => t.getSnapshot()[r],
|
|
476
|
-
return /* @__PURE__ */ p(en, { ...o, options: f, override:
|
|
477
|
-
}), Kn = Se.memo(function({ route: t, screen: n, navigation: r, focused: o, resultEvent: a, setFooter:
|
|
478
|
-
const
|
|
475
|
+
const a = () => t.getSnapshot()[r], c = Oe(t.subscribe, a, a), f = Pe(n, Qt, He);
|
|
476
|
+
return /* @__PURE__ */ p(en, { ...o, options: f, override: c });
|
|
477
|
+
}), Kn = Se.memo(function({ route: t, screen: n, navigation: r, focused: o, resultEvent: a, setFooter: c, loadingApi: f, loadingStore: u, bodyClassName: i, notifyError: d, registerDirtyGuard: h, pageMotion: v, lazyFallback: k }) {
|
|
478
|
+
const b = n.component, s = T(null), y = T(!1);
|
|
479
479
|
Ae(() => {
|
|
480
|
-
const E = o && !
|
|
481
|
-
if (
|
|
482
|
-
const D =
|
|
480
|
+
const E = o && !y.current;
|
|
481
|
+
if (y.current = o, !E || !v?.enabled || !s.current?.animate) return;
|
|
482
|
+
const D = v.direction === "back" ? -100 : 100;
|
|
483
483
|
s.current.style.zIndex = "2";
|
|
484
|
-
const
|
|
484
|
+
const z = s.current.animate([
|
|
485
485
|
{ opacity: 1, transform: `translate3d(${D}%,0,0)` },
|
|
486
486
|
{ opacity: 1, transform: "translate3d(0,0,0)" }
|
|
487
|
-
], { duration:
|
|
487
|
+
], { duration: v.duration, easing: "cubic-bezier(.22,1,.36,1)" });
|
|
488
488
|
return () => {
|
|
489
|
-
|
|
489
|
+
z.cancel(), s.current && (s.current.style.zIndex = "");
|
|
490
490
|
};
|
|
491
|
-
}, [o,
|
|
492
|
-
const
|
|
491
|
+
}, [o, v?.enabled, v?.direction, v?.duration, v?.distance]);
|
|
492
|
+
const A = Q(() => ({ isFocused: o, resultEvent: a, routeKey: t.key, setFooter: c }), [o, a, t.key, c]), O = Q(() => ({
|
|
493
493
|
setLoading: (E, D) => f.setScreenLoading(t.key, E, D),
|
|
494
494
|
showLoading: (E) => f.begin(t.key, E),
|
|
495
495
|
hideLoading: (E) => f.end(t.key, E)
|
|
496
|
-
}), [f, t.key]),
|
|
497
|
-
return /* @__PURE__ */ p(Ve.Provider, { value: t, children: /* @__PURE__ */ p(Pt.Provider, { value:
|
|
496
|
+
}), [f, t.key]), L = Q(() => ({ routeKey: t.key, registerDirtyGuard: h }), [t.key, h]);
|
|
497
|
+
return /* @__PURE__ */ p(Ve.Provider, { value: t, children: /* @__PURE__ */ p(Pt.Provider, { value: L, children: /* @__PURE__ */ p(ot.Provider, { value: A, children: /* @__PURE__ */ p(Ue.Provider, { value: O, children: /* @__PURE__ */ p(wt.Provider, { value: u, children: /* @__PURE__ */ p("div", { ref: s, hidden: !o, inert: !o, "data-modal-route-key": t.key, tabIndex: -1, className: `pmn-body ${o && v?.enabled && typeof Element < "u" && !Element.prototype.animate ? `pmn-page-enter pmn-page-${v.direction}` : ""} ${i ?? ""}`, style: o && v?.enabled ? { "--pmn-page-duration": `${v.duration}ms`, "--pmn-page-distance": `${v.distance}px` } : void 0, children: /* @__PURE__ */ p(Nt, { route: t, onError: d, children: /* @__PURE__ */ p(Wt, { fallback: k ?? /* @__PURE__ */ p("div", { className: "pmn-lazy-loading", role: "status", "aria-live": "polite", children: "加载中..." }), children: /* @__PURE__ */ p(b, { route: t, navigation: r }) }) }) }) }) }) }) }) });
|
|
498
498
|
});
|
|
499
|
-
function Hn({ runtime: e, config: t, initialScreen: n, params: r, translate: o, onRequestClose: a, onOpened:
|
|
500
|
-
const s = Pe(e.stores.layout, Cn, He), [
|
|
499
|
+
function Hn({ runtime: e, config: t, initialScreen: n, params: r, translate: o, onRequestClose: a, onOpened: c, registerLoading: f, notifyError: u, error: i, clearError: d, registerDirtyGuard: h, getProtectedCacheKeys: v, canNavigate: k, exiting: b = !1 }) {
|
|
500
|
+
const s = Pe(e.stores.layout, Cn, He), [y, A] = dn(mt, e.stores.navigation.getSnapshot().stack), { navigation: O, loading: L, footer: E, toast: D } = e.refs, z = e.alive, N = T(0), { toast: F, dismissToast: j } = rn(D, z, e);
|
|
501
501
|
U(() => () => {
|
|
502
|
-
|
|
502
|
+
N.current++;
|
|
503
503
|
}, []);
|
|
504
|
-
const [Z, ue] = xe({}), [C,
|
|
504
|
+
const [Z, ue] = xe({}), [C, $] = xe(() => /* @__PURE__ */ new Set()), I = T(/* @__PURE__ */ new Map()), X = T(null), q = T(null), te = T(null), V = T(null), oe = T(null), J = T(!1), P = T(!1), G = e.pageRequests, ke = T(0), Ce = _((m, M, B) => {
|
|
505
505
|
for (const [Y, fe] of G.current)
|
|
506
|
-
m.includes(fe.key) && (G.current.delete(Y), fe.resolve({ status: M, ...M === "returned" ? { value:
|
|
507
|
-
}, []), K =
|
|
508
|
-
K.current =
|
|
509
|
-
const de =
|
|
510
|
-
de.current =
|
|
511
|
-
const
|
|
512
|
-
We && (Be.current = { key: re, depth:
|
|
513
|
-
const Qe = Math.min(1e3, Math.max(0, Number(s.pageAnimationDuration ?? 360) || 0)), ct = Math.min(300, Math.max(0, Number(s.pageAnimationDistance ?? 96) || 0)), Ne = Q(() => ({ distance: ct, enabled: s.pageAnimation !== !1 && s.animation !== !1 && Qe > 0 && We, direction: it, duration: Qe }), [ct, s.pageAnimation, s.animation, Qe, We, it]), lt =
|
|
506
|
+
m.includes(fe.key) && (G.current.delete(Y), fe.resolve({ status: M, ...M === "returned" ? { value: B } : {} }));
|
|
507
|
+
}, []), K = T(y);
|
|
508
|
+
K.current = y;
|
|
509
|
+
const de = T(k);
|
|
510
|
+
de.current = k;
|
|
511
|
+
const x = T(!1), ce = T(0), ne = y.at(-1), re = ne.key, Be = T({ key: re, depth: y.length }), st = Be.current, We = st.key !== re, it = y.length < st.depth ? "back" : "forward";
|
|
512
|
+
We && (Be.current = { key: re, depth: y.length });
|
|
513
|
+
const Qe = Math.min(1e3, Math.max(0, Number(s.pageAnimationDuration ?? 360) || 0)), ct = Math.min(300, Math.max(0, Number(s.pageAnimationDistance ?? 96) || 0)), Ne = Q(() => ({ distance: ct, enabled: s.pageAnimation !== !1 && s.animation !== !1 && Qe > 0 && We, direction: it, duration: Qe }), [ct, s.pageAnimation, s.animation, Qe, We, it]), lt = T(re);
|
|
514
514
|
lt.current = re;
|
|
515
|
-
const { loadingApi: Ze, refreshLoading: Ge, loadingTasks: ut, setLoading: De } = on(
|
|
515
|
+
const { loadingApi: Ze, refreshLoading: Ge, loadingTasks: ut, setLoading: De } = on(L, z, lt, e), Ee = t.screens, Te = L, _e = T(f);
|
|
516
516
|
_e.current = f, U(() => (_e.current?.({ setLoading: De }), () => _e.current?.(null)), [De]);
|
|
517
517
|
const qt = _((m, M) => {
|
|
518
|
-
if (!
|
|
519
|
-
const
|
|
518
|
+
if (!z.current) return;
|
|
519
|
+
const B = E.current.getSnapshot();
|
|
520
520
|
if (M === null) {
|
|
521
|
-
if (!(m in
|
|
522
|
-
const Y = { ...
|
|
521
|
+
if (!(m in B)) return;
|
|
522
|
+
const Y = { ...B };
|
|
523
523
|
delete Y[m], E.current.publish(Y);
|
|
524
524
|
return;
|
|
525
525
|
}
|
|
526
|
-
|
|
526
|
+
B[m] !== M && E.current.publish({ ...B, [m]: M });
|
|
527
527
|
}, []), kt = _(() => {
|
|
528
528
|
if (typeof document > "u") return;
|
|
529
529
|
const m = document.activeElement;
|
|
530
530
|
if (!(m instanceof HTMLElement) || !X.current?.contains(m)) return;
|
|
531
531
|
const M = m.closest("[data-modal-route-key]");
|
|
532
|
-
M &&
|
|
532
|
+
M && I.current.set(M.dataset.modalRouteKey, m), X.current.focus({ preventScroll: !0 });
|
|
533
533
|
}, []), xt = _((m) => {
|
|
534
534
|
if (!Object.prototype.hasOwnProperty.call(Ee, m)) throw new Error(`[react-modal-navigation] Unknown modal screen: ${m}`);
|
|
535
|
-
}, [Ee]),
|
|
535
|
+
}, [Ee]), l = _((m, M) => {
|
|
536
536
|
try {
|
|
537
|
-
Promise.resolve(s[m]?.(M)).catch((
|
|
538
|
-
} catch (
|
|
539
|
-
u(
|
|
537
|
+
Promise.resolve(s[m]?.(M)).catch((B) => u(B, { phase: m }));
|
|
538
|
+
} catch (B) {
|
|
539
|
+
u(B, { phase: m });
|
|
540
540
|
}
|
|
541
|
-
}, [s, u]),
|
|
542
|
-
if (!
|
|
543
|
-
const ve =
|
|
544
|
-
if (m !== "BACK" && m !== "POP" && xt(M), m === "POP" && (!Number.isInteger(
|
|
545
|
-
const Ft = m === "NAVIGATE" ? se.findIndex((Je) => Je.name === M) : -1, $e = m === "POP" ? se.slice(Math.max(1, se.length -
|
|
546
|
-
|
|
541
|
+
}, [s, u]), g = _(async (m, M, B, Y, fe) => {
|
|
542
|
+
if (!z.current || P.current) return !1;
|
|
543
|
+
const ve = N.current, se = K.current, Xe = se.at(-1);
|
|
544
|
+
if (m !== "BACK" && m !== "POP" && xt(M), m === "POP" && (!Number.isInteger(B) || B < 1 || se.length <= 1) || m === "BACK" && se.length <= 1) return !1;
|
|
545
|
+
const Ft = m === "NAVIGATE" ? se.findIndex((Je) => Je.name === M) : -1, $e = m === "POP" ? se.slice(Math.max(1, se.length - B)) : m === "RESET" ? se : m === "BACK" || m === "REPLACE" ? [Xe] : Ft >= 0 ? se.slice(Ft + 1) : [];
|
|
546
|
+
P.current = !0;
|
|
547
547
|
try {
|
|
548
548
|
if ($e.length && de.current && !await de.current($e.map((Me) => Me.key), {
|
|
549
549
|
reason: "navigation",
|
|
550
550
|
action: m,
|
|
551
551
|
from: Xe,
|
|
552
|
-
to: m === "POP" ? se[Math.max(0, se.length -
|
|
553
|
-
}) || $e.length && !await e.canRemove($e.map((ge) => ge.key), { reason: "navigation", action: m, from: Xe, to: M }) || !
|
|
552
|
+
to: m === "POP" ? se[Math.max(0, se.length - B - 1)]?.name : m === "BACK" ? se.at(-2)?.name : M
|
|
553
|
+
}) || $e.length && !await e.canRemove($e.map((ge) => ge.key), { reason: "navigation", action: m, from: Xe, to: M }) || !z.current || ve !== N.current || K.current.at(-1)?.key !== Xe.key) return !1;
|
|
554
554
|
if (m === "BACK" && Y !== void 0) {
|
|
555
555
|
const ge = se.at(-2);
|
|
556
556
|
ue((Me) => ({ ...Me, [ge.key]: { id: ++ce.current, data: Y } }));
|
|
557
557
|
}
|
|
558
558
|
if ($e.length) {
|
|
559
559
|
const ge = new Set($e.map((Me) => Me.key));
|
|
560
|
-
ge.forEach((Me) =>
|
|
560
|
+
ge.forEach((Me) => I.current.delete(Me)), ue((Me) => Object.fromEntries(Object.entries(Me).filter(([et]) => !ge.has(et))));
|
|
561
561
|
}
|
|
562
562
|
e.tasks.cancelRoutes($e.map((ge) => ge.key)), Ce($e.map((ge) => ge.key), m === "BACK" ? "returned" : "removed", Y);
|
|
563
|
-
const Je = [...
|
|
563
|
+
const Je = [...q.current?.querySelectorAll("[data-modal-route-key]") ?? []].find((ge) => ge.dataset.modalRouteKey === Xe.key);
|
|
564
564
|
te.current = Je?.cloneNode(!0) ?? null, kt();
|
|
565
|
-
const un = { type: m, name: M, params:
|
|
565
|
+
const un = { type: m, name: M, params: B, count: B };
|
|
566
566
|
K.current = mt(K.current, un);
|
|
567
567
|
const Rt = K.current;
|
|
568
|
-
return
|
|
568
|
+
return $((ge) => {
|
|
569
569
|
const Me = new Set(Rt.slice(0, -1).filter((et) => ge.has(et.key)).map((et) => et.key));
|
|
570
570
|
return Me.size === ge.size ? ge : Me;
|
|
571
|
-
}), fe?.(Rt.at(-1)),
|
|
571
|
+
}), fe?.(Rt.at(-1)), A({ type: "COMMIT", stack: Rt }), !0;
|
|
572
572
|
} catch (Je) {
|
|
573
|
-
return
|
|
573
|
+
return z.current && u(Je, { phase: "navigationGuard", action: m }), !1;
|
|
574
574
|
} finally {
|
|
575
|
-
|
|
575
|
+
P.current = !1;
|
|
576
576
|
}
|
|
577
|
-
}, [xt, kt, u, Ce]), R = _((m, M) =>
|
|
578
|
-
const M = K.current.findLastIndex((
|
|
577
|
+
}, [xt, kt, u, Ce]), R = _((m, M) => g("NAVIGATE", m, M), [g]), w = _((m, M) => g("PUSH", m, M), [g]), H = _((m = 1) => g("POP", null, m), [g]), W = _(() => H(K.current.length - 1), [H]), ae = _((m) => {
|
|
578
|
+
const M = K.current.findLastIndex((B) => B.name === m);
|
|
579
579
|
return M < 0 ? Promise.resolve(!1) : H(K.current.length - M - 1);
|
|
580
580
|
}, [H]), me = _(async (m, M) => {
|
|
581
|
-
if (!
|
|
582
|
-
let
|
|
583
|
-
return await
|
|
584
|
-
|
|
581
|
+
if (!z.current) return { status: "cancelled" };
|
|
582
|
+
let B;
|
|
583
|
+
return await g("NAVIGATE", m, M, void 0, (fe) => {
|
|
584
|
+
B = new Promise((ve) => {
|
|
585
585
|
const se = ++ke.current;
|
|
586
586
|
G.current.set(se, { key: fe.key, resolve: ve });
|
|
587
587
|
});
|
|
588
|
-
}) &&
|
|
589
|
-
}, [
|
|
588
|
+
}) && B ? B : { status: "cancelled" };
|
|
589
|
+
}, [g]), ie = _((m, M) => g("REPLACE", m, M), [g]), pe = _((m, M) => g("RESET", m, M), [g]), Re = _((m) => {
|
|
590
590
|
if (!m || typeof m != "object" || Array.isArray(m)) throw new TypeError("[react-modal-navigation] setParams expects an object");
|
|
591
|
-
if (!
|
|
591
|
+
if (!z.current) return;
|
|
592
592
|
const M = { type: "SET_PARAMS", params: m };
|
|
593
|
-
K.current = mt(K.current, M),
|
|
593
|
+
K.current = mt(K.current, M), A({ type: "COMMIT", stack: K.current });
|
|
594
594
|
}, []), S = _((m) => {
|
|
595
595
|
if (!m || typeof m != "object" || Array.isArray(m)) throw new TypeError("[react-modal-navigation] setOptions expects an object");
|
|
596
|
-
if (!
|
|
596
|
+
if (!z.current) return;
|
|
597
597
|
const M = { type: "SET_OPTIONS", options: m };
|
|
598
|
-
K.current = mt(K.current, M),
|
|
599
|
-
}, []), le = _((m) =>
|
|
598
|
+
K.current = mt(K.current, M), A({ type: "COMMIT", stack: K.current });
|
|
599
|
+
}, []), le = _((m) => g("BACK", null, void 0, m), [g]), Le = _((m, M) => !z.current || Te.current.getSnapshot().visible && s.lockCloseWhileLoading !== !1 ? Promise.resolve(!1) : a(m, M, { route: ne, stack: y }), [s.lockCloseWhileLoading, a, ne, y]), ye = T(Le);
|
|
600
600
|
ye.current = Le;
|
|
601
601
|
const he = _((m) => ye.current("api", m), []), ze = _(async (m) => {
|
|
602
|
-
if (!
|
|
603
|
-
const M = K.current,
|
|
604
|
-
if (!
|
|
605
|
-
|
|
602
|
+
if (!z.current || P.current) return !1;
|
|
603
|
+
const M = K.current, B = $t(M, Ee, s.maxCachedScreens, C, v?.()).slice(0, -1).filter((Y) => m === void 0 || Y.name === m).map((Y) => Y.key);
|
|
604
|
+
if (!B.length) return !1;
|
|
605
|
+
P.current = !0;
|
|
606
606
|
try {
|
|
607
607
|
const Y = { reason: "cache", action: "CLEAR_CACHE", from: M.at(-1) };
|
|
608
|
-
return de.current && !await de.current(
|
|
608
|
+
return de.current && !await de.current(B, Y) || !await e.canRemove(B, Y) || !z.current || K.current !== M ? !1 : (e.tasks.cancelRoutes(B), B.forEach((fe) => I.current.delete(fe)), $((fe) => /* @__PURE__ */ new Set([...fe, ...B])), !0);
|
|
609
609
|
} catch (Y) {
|
|
610
|
-
return
|
|
610
|
+
return z.current && u(Y, { phase: "clearCache" }), !1;
|
|
611
611
|
} finally {
|
|
612
|
-
|
|
612
|
+
P.current = !1;
|
|
613
613
|
}
|
|
614
|
-
}, [e, u, Ee, s.maxCachedScreens, C,
|
|
614
|
+
}, [e, u, Ee, s.maxCachedScreens, C, v]), qe = Q(() => ({ navigate: R, navigateAsync: me, push: w, pop: H, popTo: ae, popToTop: W, replace: ie, reset: pe, setParams: Re, setOptions: S, goBack: le, close: he, setLoading: De, clearCache: ze }), [R, me, w, H, ae, W, ie, pe, Re, S, le, he, De, ze]);
|
|
615
615
|
Ae(() => e.registerNavigation(qe), [e, qe]);
|
|
616
|
-
const Fe = Q(() => ({ canGoBack:
|
|
617
|
-
Ae(() =>
|
|
618
|
-
const St =
|
|
616
|
+
const Fe = Q(() => ({ canGoBack: y.length > 1, stack: y, currentRoute: ne }), [y]);
|
|
617
|
+
Ae(() => O.current.publish(Fe), [Fe]);
|
|
618
|
+
const St = T(null);
|
|
619
619
|
St.current || (St.current = Object.defineProperties({}, {
|
|
620
|
-
canGoBack: { enumerable: !0, get: () =>
|
|
621
|
-
stack: { enumerable: !0, get: () =>
|
|
622
|
-
currentRoute: { enumerable: !0, get: () =>
|
|
620
|
+
canGoBack: { enumerable: !0, get: () => O.current.getSnapshot().canGoBack },
|
|
621
|
+
stack: { enumerable: !0, get: () => O.current.getSnapshot().stack },
|
|
622
|
+
currentRoute: { enumerable: !0, get: () => O.current.getSnapshot().currentRoute }
|
|
623
623
|
}));
|
|
624
624
|
const dt = Q(() => Object.assign(St.current, qe), [qe]);
|
|
625
625
|
Ae(() => {
|
|
626
626
|
const m = te.current;
|
|
627
|
-
if (te.current = null, V.current?.cancel?.(), V.current = null,
|
|
628
|
-
const M =
|
|
627
|
+
if (te.current = null, V.current?.cancel?.(), V.current = null, q.current?.querySelectorAll("[data-pmn-outgoing]").forEach((se) => se.remove()), !We || !Ne.enabled || !m || !q.current || typeof window < "u" && window.matchMedia?.("(prefers-reduced-motion: reduce)").matches) return;
|
|
628
|
+
const M = q.current;
|
|
629
629
|
m.removeAttribute("hidden"), m.removeAttribute("tabindex"), m.setAttribute("aria-hidden", "true"), m.setAttribute("inert", ""), m.dataset.pmnOutgoing = "true", m.querySelectorAll("[id]").forEach((se) => se.removeAttribute("id")), m.querySelectorAll("[autofocus]").forEach((se) => se.removeAttribute("autofocus")), m.style.cssText += ";position:absolute;inset:0;width:100%;height:100%;z-index:1;pointer-events:none;overflow:hidden;background:var(--pmn-body);", M.appendChild(m);
|
|
630
|
-
const
|
|
630
|
+
const B = Ne.direction === "back" ? 1 : -1, Y = [...M.querySelectorAll("[data-modal-route-key]")].find((se) => se.dataset.modalRouteKey === re);
|
|
631
631
|
Y && (Y.style.zIndex = "2");
|
|
632
632
|
const fe = () => {
|
|
633
633
|
m.remove(), Y && (Y.style.zIndex = ""), V.current === ve && (V.current = null);
|
|
@@ -636,7 +636,7 @@ function Hn({ runtime: e, config: t, initialScreen: n, params: r, translate: o,
|
|
|
636
636
|
if (m.animate)
|
|
637
637
|
ve = m.animate([
|
|
638
638
|
{ opacity: 1, transform: "translate3d(0,0,0)" },
|
|
639
|
-
{ opacity: 1, transform: `translate3d(${
|
|
639
|
+
{ opacity: 1, transform: `translate3d(${B * 100}%,0,0)` }
|
|
640
640
|
], { duration: Ne.duration, easing: "cubic-bezier(.22,1,.36,1)", fill: "forwards" }), ve.addEventListener("finish", fe, { once: !0 }), ve.addEventListener("cancel", fe, { once: !0 }), V.current = ve;
|
|
641
641
|
else {
|
|
642
642
|
m.classList.add("pmn-page-exit", `pmn-page-exit-${Ne.direction}`), m.style.setProperty("--pmn-page-duration", `${Ne.duration}ms`), m.style.setProperty("--pmn-page-distance", "100%");
|
|
@@ -652,44 +652,44 @@ function Hn({ runtime: e, config: t, initialScreen: n, params: r, translate: o,
|
|
|
652
652
|
J.current = !1;
|
|
653
653
|
const m = [...X.current?.querySelectorAll("[data-modal-route-key]") ?? []].find((Y) => Y.dataset.modalRouteKey === re);
|
|
654
654
|
if (!m) return;
|
|
655
|
-
const M =
|
|
655
|
+
const M = I.current.get(re);
|
|
656
656
|
(M?.isConnected && m.contains(M) && !M.matches(":disabled") && !M.closest("[inert], [hidden]") ? M : m).focus({ preventScroll: !0 });
|
|
657
657
|
}, [re]), U(() => {
|
|
658
658
|
let m = !1;
|
|
659
|
-
for (const [
|
|
660
|
-
Y.owner !== "global" && Y.owner !== re && (ut.current.delete(
|
|
659
|
+
for (const [B, Y] of ut.current)
|
|
660
|
+
Y.owner !== "global" && Y.owner !== re && (ut.current.delete(B), m = !0);
|
|
661
661
|
m && Ge();
|
|
662
|
-
const M = new Set(
|
|
663
|
-
ue((
|
|
664
|
-
const Y = Object.keys(
|
|
665
|
-
if (!Y.length) return
|
|
666
|
-
const fe = { ...
|
|
662
|
+
const M = new Set(y.map((B) => B.key));
|
|
663
|
+
ue((B) => {
|
|
664
|
+
const Y = Object.keys(B).filter((ve) => !M.has(ve));
|
|
665
|
+
if (!Y.length) return B;
|
|
666
|
+
const fe = { ...B };
|
|
667
667
|
return Y.forEach((ve) => delete fe[ve]), fe;
|
|
668
668
|
});
|
|
669
|
-
for (const
|
|
670
|
-
}, [re,
|
|
669
|
+
for (const B of I.current.keys()) M.has(B) || I.current.delete(B);
|
|
670
|
+
}, [re, y, Ge]), U(() => {
|
|
671
671
|
if (oe.current?.key !== re) {
|
|
672
672
|
if (oe.current) {
|
|
673
|
-
const m = { from: oe.current, to: ne, stack:
|
|
674
|
-
|
|
673
|
+
const m = { from: oe.current, to: ne, stack: y };
|
|
674
|
+
l("onBlur", { route: oe.current, ...m }), l("onNavigate", m), l("onRouteChange", m);
|
|
675
675
|
}
|
|
676
|
-
|
|
676
|
+
l("onFocus", { route: ne, stack: y }), oe.current = ne;
|
|
677
677
|
}
|
|
678
|
-
}, [ne, re,
|
|
679
|
-
ut.current.clear(),
|
|
678
|
+
}, [ne, re, y, l]), U(() => () => {
|
|
679
|
+
ut.current.clear(), I.current.clear();
|
|
680
680
|
for (const m of G.current.values()) m.resolve({ status: "dismissed" });
|
|
681
681
|
G.current.clear();
|
|
682
682
|
}, []), U(() => {
|
|
683
|
-
|
|
683
|
+
x.current || (x.current = !0, c?.({ route: ne, stack: y }));
|
|
684
684
|
}, []);
|
|
685
|
-
const Ct = $t(
|
|
685
|
+
const Ct = $t(y, Ee, s.maxCachedScreens, C, v?.());
|
|
686
686
|
Ae(() => {
|
|
687
|
-
|
|
688
|
-
}, [
|
|
687
|
+
$((m) => hn(y, Ct, m));
|
|
688
|
+
}, [y, Ct]);
|
|
689
689
|
const Et = Q(() => ({ ...Ee[ne.name], ...ne.options ?? {} }), [Ee, ne.name, ne.options]), ln = e.refs.header;
|
|
690
|
-
return /* @__PURE__ */ p(yt.Provider, { value: ln.current, children: /* @__PURE__ */ p(Tt.Provider, { value:
|
|
691
|
-
/* @__PURE__ */ p(Jt, { store: e.stores.layout, screen: Et, route: ne, navigation: dt, requestClose: Le, translate: o, canGoBack:
|
|
692
|
-
/* @__PURE__ */ p("main", { ref:
|
|
690
|
+
return /* @__PURE__ */ p(yt.Provider, { value: ln.current, children: /* @__PURE__ */ p(Tt.Provider, { value: F, children: /* @__PURE__ */ p(Vt.Provider, { value: D.current, children: /* @__PURE__ */ p(Ut.Provider, { value: E.current, children: /* @__PURE__ */ p(_t.Provider, { value: dt, children: /* @__PURE__ */ p(vt.Provider, { value: qe, children: /* @__PURE__ */ p(bt.Provider, { value: O.current, children: /* @__PURE__ */ p(Ue.Provider, { value: Ze, children: /* @__PURE__ */ be(Xt, { store: e.stores.layout, screenOptions: Et.modalOptions, dialogRef: X, requestClose: Le, exiting: b, children: [
|
|
691
|
+
/* @__PURE__ */ p(Jt, { store: e.stores.layout, screen: Et, route: ne, navigation: dt, requestClose: Le, translate: o, canGoBack: y.length > 1 }),
|
|
692
|
+
/* @__PURE__ */ p("main", { ref: q, className: "pmn-main", children: Ct.map((m) => /* @__PURE__ */ p(
|
|
693
693
|
Kn,
|
|
694
694
|
{
|
|
695
695
|
route: m,
|
|
@@ -700,9 +700,9 @@ function Hn({ runtime: e, config: t, initialScreen: n, params: r, translate: o,
|
|
|
700
700
|
bodyClassName: s.bodyClassName,
|
|
701
701
|
setFooter: qt,
|
|
702
702
|
loadingApi: Ze,
|
|
703
|
-
loadingStore:
|
|
703
|
+
loadingStore: L.current,
|
|
704
704
|
notifyError: u,
|
|
705
|
-
registerDirtyGuard:
|
|
705
|
+
registerDirtyGuard: h,
|
|
706
706
|
pageMotion: m.key === re ? Ne : null,
|
|
707
707
|
lazyFallback: s.lazyFallback
|
|
708
708
|
},
|
|
@@ -724,8 +724,8 @@ function Hn({ runtime: e, config: t, initialScreen: n, params: r, translate: o,
|
|
|
724
724
|
},
|
|
725
725
|
re
|
|
726
726
|
),
|
|
727
|
-
/* @__PURE__ */ p($n, { store:
|
|
728
|
-
/* @__PURE__ */ p(In, { store: D.current, dismiss:
|
|
727
|
+
/* @__PURE__ */ p($n, { store: L.current, translate: o }),
|
|
728
|
+
/* @__PURE__ */ p(In, { store: D.current, dismiss: j }),
|
|
729
729
|
i && /* @__PURE__ */ be("div", { className: "pmn-error", role: "alert", children: [
|
|
730
730
|
/* @__PURE__ */ p("span", { children: i.message || String(i) }),
|
|
731
731
|
/* @__PURE__ */ p("button", { type: "button", onClick: d, "aria-label": "Dismiss error", children: "×" })
|
|
@@ -752,9 +752,9 @@ async function an(e, t) {
|
|
|
752
752
|
return n;
|
|
753
753
|
}
|
|
754
754
|
async function Wn(e, t, n) {
|
|
755
|
-
const r = await an(e, t), a = (Array.isArray(n) ? n : [n ?? r.initialRoute ?? Object.keys(r.screens ?? {})[0]]).map((
|
|
756
|
-
if (a.some((
|
|
757
|
-
return await Promise.all(a.map((
|
|
755
|
+
const r = await an(e, t), a = (Array.isArray(n) ? n : [n ?? r.initialRoute ?? Object.keys(r.screens ?? {})[0]]).map((c) => r.screens ? Object.hasOwn(r.screens, c) ? r.screens[c] : null : r);
|
|
756
|
+
if (a.some((c) => !c)) throw new Error("[react-modal-navigation] Unknown preload screen");
|
|
757
|
+
return await Promise.all(a.map((c) => c.loader ? gt(c.loader) : void 0)), r;
|
|
758
758
|
}
|
|
759
759
|
function Gn(e) {
|
|
760
760
|
return function(n) {
|
|
@@ -764,28 +764,28 @@ function Gn(e) {
|
|
|
764
764
|
}
|
|
765
765
|
function _n(e, { limit: t = 100 } = {}) {
|
|
766
766
|
const n = Number.isFinite(t) ? Math.max(1, Math.min(1e3, Math.floor(t))) : 100, r = je({ active: null, queueSize: 0, events: [] });
|
|
767
|
-
let o, a = 0,
|
|
768
|
-
const u = (
|
|
769
|
-
if (
|
|
770
|
-
const
|
|
771
|
-
let
|
|
772
|
-
const
|
|
773
|
-
|
|
767
|
+
let o, a = 0, c = !1, f = [];
|
|
768
|
+
const u = (h, v) => {
|
|
769
|
+
if (c) return;
|
|
770
|
+
const k = r.getSnapshot(), b = e.hostStore.getSnapshot().active, s = b?.runtime.alive.current ? b : null, y = s?.runtime.stores.navigation.getSnapshot(), A = s?.runtime.stores.loading.getSnapshot();
|
|
771
|
+
let O = s ? { id: s.id, name: s.name, routes: y.stack.map(({ key: z, name: N }) => ({ key: z, name: N })), focusedKey: y.currentRoute?.key, loadingCount: A.count, taskCount: s.runtime.tasks.count() } : null;
|
|
772
|
+
const L = h ? [...k.events, { sequence: ++a, time: Date.now(), type: h, id: v }].slice(-n) : k.events, E = k.active;
|
|
773
|
+
O && E && O.id === E.id && O.name === E.name && O.focusedKey === E.focusedKey && O.loadingCount === E.loadingCount && O.taskCount === E.taskCount && O.routes.length === E.routes.length && O.routes.every((z, N) => z.key === E.routes[N].key && z.name === E.routes[N].name) && (O = E);
|
|
774
774
|
const D = e.statusStore.getSnapshot().queueSize;
|
|
775
|
-
|
|
775
|
+
O === E && D === k.queueSize && L === k.events || r.publish({ active: O, queueSize: D, events: L });
|
|
776
776
|
}, i = () => {
|
|
777
|
-
const
|
|
778
|
-
|
|
779
|
-
}, d = [e.hostStore.subscribe(i), e.statusStore.subscribe(() => u()), ...["open", "close", "queueChange"].map((
|
|
777
|
+
const h = e.hostStore.getSnapshot().active?.runtime;
|
|
778
|
+
h !== o && (f.forEach((v) => v()), o = h, f = h ? ["ready", "destroy", "change", "routeChange", "routeRemove", "routeBlur", "routeFocus"].map((v) => h.events.on(v, (k) => u(v === "change" ? `store.${k.store}` : `instance.${v}`, k.id))) : []), u();
|
|
779
|
+
}, d = [e.hostStore.subscribe(i), e.statusStore.subscribe(() => u()), ...["open", "close", "queueChange"].map((h) => e.commands.on(h, (v) => u(`manager.${h}`, v.id)))];
|
|
780
780
|
return i(), {
|
|
781
781
|
getSnapshot: r.getSnapshot,
|
|
782
782
|
subscribe: r.subscribe,
|
|
783
783
|
refresh: () => u(),
|
|
784
784
|
clear() {
|
|
785
|
-
!
|
|
785
|
+
!c && r.getSnapshot().events.length && r.publish({ ...r.getSnapshot(), events: [] });
|
|
786
786
|
},
|
|
787
787
|
dispose() {
|
|
788
|
-
|
|
788
|
+
c || (c = !0, d.forEach((h) => h()), f.forEach((h) => h()), f = [], o = null, r.publish({ active: null, queueSize: 0, events: [] }), r.destroy());
|
|
789
789
|
}
|
|
790
790
|
};
|
|
791
791
|
}
|
|
@@ -809,9 +809,9 @@ function sn() {
|
|
|
809
809
|
for (const a of [...e.get(r) ?? []])
|
|
810
810
|
if (!(t || !e.get(r)?.has(a)))
|
|
811
811
|
try {
|
|
812
|
-
Promise.resolve(a(o)).catch((
|
|
813
|
-
} catch (
|
|
814
|
-
console.error(
|
|
812
|
+
Promise.resolve(a(o)).catch((c) => console.error(c));
|
|
813
|
+
} catch (c) {
|
|
814
|
+
console.error(c);
|
|
815
815
|
}
|
|
816
816
|
}
|
|
817
817
|
},
|
|
@@ -825,8 +825,8 @@ function sn() {
|
|
|
825
825
|
}
|
|
826
826
|
function Un(e, t, n, r) {
|
|
827
827
|
const o = n.currentRoute, a = r.currentRoute;
|
|
828
|
-
if (o?.key === a?.key && n.stack.length === r.stack.length && n.stack.every((
|
|
829
|
-
const
|
|
828
|
+
if (o?.key === a?.key && n.stack.length === r.stack.length && n.stack.every((h, v) => h.key === r.stack[v].key)) return;
|
|
829
|
+
const c = new Set(n.stack.map((h) => h.key)), f = new Set(r.stack.map((h) => h.key)), u = n.stack.filter((h) => !f.has(h.key)), i = r.stack.filter((h) => !c.has(h.key));
|
|
830
830
|
if (o?.key === a?.key && !u.length && !i.length) return;
|
|
831
831
|
const d = { id: t, from: o, to: a, added: i, removed: u, stack: r.stack };
|
|
832
832
|
e.emit("routeChange", d), u.length && e.emit("routeRemove", d), o?.key !== a?.key && (o && e.emit("routeBlur", { ...d, route: o }), a && e.emit("routeFocus", { ...d, route: a }));
|
|
@@ -836,24 +836,24 @@ function Vn() {
|
|
|
836
836
|
let t = !1;
|
|
837
837
|
const n = /* @__PURE__ */ new Set(), r = (a) => {
|
|
838
838
|
try {
|
|
839
|
-
Promise.resolve(a.cancel()).catch((
|
|
840
|
-
} catch (
|
|
841
|
-
console.error(
|
|
839
|
+
Promise.resolve(a.cancel()).catch((c) => console.error(c));
|
|
840
|
+
} catch (c) {
|
|
841
|
+
console.error(c);
|
|
842
842
|
}
|
|
843
843
|
}, o = (a) => {
|
|
844
|
-
for (const [
|
|
845
|
-
!a(f) || !e.delete(
|
|
844
|
+
for (const [c, f] of [...e])
|
|
845
|
+
!a(f) || !e.delete(c) || r(c);
|
|
846
846
|
};
|
|
847
847
|
return {
|
|
848
|
-
register(a,
|
|
849
|
-
return t || n.has(a) ? (r(
|
|
850
|
-
}) : (e.set(
|
|
848
|
+
register(a, c) {
|
|
849
|
+
return t || n.has(a) ? (r(c), () => {
|
|
850
|
+
}) : (e.set(c, a), () => e.delete(c));
|
|
851
851
|
},
|
|
852
852
|
cancelRoutes(a) {
|
|
853
|
-
const
|
|
853
|
+
const c = new Set(a), f = [...c].filter((u) => !n.has(u));
|
|
854
854
|
f.forEach((u) => n.add(u));
|
|
855
855
|
try {
|
|
856
|
-
o((u) =>
|
|
856
|
+
o((u) => c.has(u));
|
|
857
857
|
} finally {
|
|
858
858
|
f.forEach((u) => n.delete(u));
|
|
859
859
|
}
|
|
@@ -866,11 +866,11 @@ function Vn() {
|
|
|
866
866
|
}
|
|
867
867
|
function Yn(e, t) {
|
|
868
868
|
const n = e.config.singlePage || Object.keys(e.config.screens).length === 1, r = n ? [{ key: "single", name: e.screen, params: e.params ?? {}, options: {} }] : Yt(e.screen, e.params), o = je({});
|
|
869
|
-
o.set = (C,
|
|
870
|
-
const
|
|
871
|
-
if (
|
|
872
|
-
const X = {
|
|
873
|
-
|
|
869
|
+
o.set = (C, $) => {
|
|
870
|
+
const I = o.getSnapshot();
|
|
871
|
+
if ($ == null && !(C in I) || Object.is(I[C], $)) return;
|
|
872
|
+
const X = { ...I };
|
|
873
|
+
$ == null ? delete X[C] : X[C] = $, o.publish(X);
|
|
874
874
|
};
|
|
875
875
|
const a = {
|
|
876
876
|
layout: je(t),
|
|
@@ -879,15 +879,15 @@ function Yn(e, t) {
|
|
|
879
879
|
footer: je({}),
|
|
880
880
|
loading: je({ visible: !1, text: null, count: 0 }),
|
|
881
881
|
toast: je([])
|
|
882
|
-
},
|
|
882
|
+
}, c = Object.fromEntries(Object.entries(a).map(([C, $]) => [C, { current: $ }])), f = sn();
|
|
883
883
|
let u;
|
|
884
884
|
const i = () => {
|
|
885
885
|
const C = Object.entries(a);
|
|
886
|
-
return (!u || C.some(([
|
|
887
|
-
}, d = (C,
|
|
886
|
+
return (!u || C.some(([$, I]) => !Object.is(u[$], I.getSnapshot()))) && (u = Object.freeze(Object.fromEntries(C.map(([$, I]) => [$, I.getSnapshot()])))), u;
|
|
887
|
+
}, d = (C, $, I = Object.is, X) => {
|
|
888
888
|
if (!s.current) return () => {
|
|
889
889
|
};
|
|
890
|
-
const
|
|
890
|
+
const q = X === void 0 ? Object.values(a) : [...new Set(X)].map((J) => {
|
|
891
891
|
if (!Object.hasOwn(a, J)) throw new Error(`Unknown runtime store: ${J}`);
|
|
892
892
|
return a[J];
|
|
893
893
|
});
|
|
@@ -895,56 +895,56 @@ function Yn(e, t) {
|
|
|
895
895
|
const V = () => {
|
|
896
896
|
try {
|
|
897
897
|
const J = C(i());
|
|
898
|
-
if (
|
|
899
|
-
const
|
|
900
|
-
te = J, Promise.resolve(
|
|
898
|
+
if (I(te, J)) return;
|
|
899
|
+
const P = te;
|
|
900
|
+
te = J, Promise.resolve($(J, P)).catch((G) => console.error(G));
|
|
901
901
|
} catch (J) {
|
|
902
902
|
console.error(J);
|
|
903
903
|
}
|
|
904
|
-
}, oe =
|
|
904
|
+
}, oe = q.map((J) => J.subscribe(V));
|
|
905
905
|
return () => oe.forEach((J) => J());
|
|
906
|
-
},
|
|
906
|
+
}, h = Vn(), v = /* @__PURE__ */ new Map(), k = (C, $) => {
|
|
907
907
|
if (!s.current) return () => {
|
|
908
908
|
};
|
|
909
|
-
const
|
|
910
|
-
return
|
|
911
|
-
|
|
909
|
+
const I = v.get(C) ?? /* @__PURE__ */ new Set();
|
|
910
|
+
return v.set(C, I), I.add($), () => {
|
|
911
|
+
I.delete($), !I.size && v.get(C) === I && v.delete(C);
|
|
912
912
|
};
|
|
913
|
-
},
|
|
914
|
-
for (const
|
|
913
|
+
}, b = async (C, $) => {
|
|
914
|
+
for (const I of C) for (const X of [...v.get(I) ?? []]) {
|
|
915
915
|
if (!s.current) return !1;
|
|
916
|
-
if (
|
|
916
|
+
if (v.get(I)?.has(X) && await X($) === !1)
|
|
917
917
|
return !1;
|
|
918
918
|
}
|
|
919
919
|
return s.current;
|
|
920
920
|
}, s = { current: !0 };
|
|
921
|
-
let
|
|
922
|
-
const
|
|
923
|
-
|
|
924
|
-
}),
|
|
925
|
-
|
|
921
|
+
let y;
|
|
922
|
+
const A = new Promise((C) => {
|
|
923
|
+
y = C;
|
|
924
|
+
}), O = (C) => s.current ? (j.navigationCommands = C, y(!0), j.hasRegistered || (j.hasRegistered = !0, f.emit("ready", { id: e.id })), () => {
|
|
925
|
+
j.navigationCommands === C && (j.navigationCommands = null);
|
|
926
926
|
}) : () => {
|
|
927
|
-
},
|
|
928
|
-
}),
|
|
927
|
+
}, L = /* @__PURE__ */ new Set(), E = { current: /* @__PURE__ */ new Map() }, D = { current: /* @__PURE__ */ new Map() }, z = { current: 0 }, N = (C) => s.current ? (L.add(C), () => L.delete(C)) : (C(), () => {
|
|
928
|
+
}), F = () => {
|
|
929
929
|
if (s.current) {
|
|
930
|
-
s.current = !1,
|
|
931
|
-
for (const C of
|
|
930
|
+
s.current = !1, y(!1), j.navigationCommands = null, h.destroy(), v.clear();
|
|
931
|
+
for (const C of L)
|
|
932
932
|
try {
|
|
933
933
|
C();
|
|
934
|
-
} catch (
|
|
935
|
-
console.error(
|
|
934
|
+
} catch ($) {
|
|
935
|
+
console.error($);
|
|
936
936
|
}
|
|
937
|
-
|
|
937
|
+
L.clear(), E.current.clear();
|
|
938
938
|
for (const C of D.current.values()) C.resolve({ status: "dismissed" });
|
|
939
939
|
D.current.clear(), a.layout.destroy({}), a.navigation.destroy({ canGoBack: !1, stack: [], currentRoute: null }), a.header.destroy({}), a.footer.destroy({}), a.loading.destroy({ visible: !1, text: null, count: 0 }), a.toast.destroy([]), u = void 0, f.emit("destroy", { id: e.id }), f.destroy();
|
|
940
940
|
}
|
|
941
|
-
},
|
|
941
|
+
}, j = { events: f, getSnapshot: i, subscribeState: d, ready: A, registerNavigation: O, id: e.id, single: n, stores: a, refs: c, alive: s, loadingTasks: E, loadingSequence: z, pageRequests: D, tasks: h, registerRemovalGuard: k, canRemove: b, addCleanup: N, destroy: F }, Z = [];
|
|
942
942
|
let ue = !1;
|
|
943
|
-
for (const [C,
|
|
944
|
-
let
|
|
945
|
-
|
|
946
|
-
const X =
|
|
947
|
-
if (
|
|
943
|
+
for (const [C, $] of Object.entries(a)) {
|
|
944
|
+
let I = $.getSnapshot();
|
|
945
|
+
$.subscribe(() => {
|
|
946
|
+
const X = $.getSnapshot(), q = I;
|
|
947
|
+
if (I = X, Z.push({ key: C, old: q, next: X }), !ue) {
|
|
948
948
|
ue = !0;
|
|
949
949
|
try {
|
|
950
950
|
for (let te = 0; te < Z.length && s.current; te++) {
|
|
@@ -957,7 +957,7 @@ function Yn(e, t) {
|
|
|
957
957
|
}
|
|
958
958
|
});
|
|
959
959
|
}
|
|
960
|
-
return
|
|
960
|
+
return j;
|
|
961
961
|
}
|
|
962
962
|
function nt(e, t, n) {
|
|
963
963
|
if (typeof e == "string") {
|
|
@@ -967,17 +967,17 @@ function nt(e, t, n) {
|
|
|
967
967
|
if (e === null || typeof e != "object" || Array.isArray(e))
|
|
968
968
|
throw new TypeError("[react-modal-navigation] open expects a modal name or a configuration object");
|
|
969
969
|
if (e.component || e.loader || e.screens || e.definitionLoader) {
|
|
970
|
-
const { params: u, options: i, screen: d, ...
|
|
971
|
-
return { name:
|
|
970
|
+
const { params: u, options: i, screen: d, ...h } = e;
|
|
971
|
+
return { name: h, params: t ?? u ?? {}, options: { ...i, ...n }, screen: d };
|
|
972
972
|
}
|
|
973
|
-
const { name: r, screen: o, params: a = {}, options:
|
|
973
|
+
const { name: r, screen: o, params: a = {}, options: c = {}, ...f } = e;
|
|
974
974
|
if (typeof r != "string" || !r.trim())
|
|
975
975
|
throw new TypeError("[react-modal-navigation] open config requires a non-empty string name");
|
|
976
|
-
if (
|
|
976
|
+
if (c === null || typeof c != "object" || Array.isArray(c))
|
|
977
977
|
throw new TypeError("[react-modal-navigation] open config options must be an object");
|
|
978
978
|
if (o !== void 0 && (typeof o != "string" || !o.trim()))
|
|
979
979
|
throw new TypeError("[react-modal-navigation] screen must be a non-empty string");
|
|
980
|
-
return { name: r, ...o === void 0 ? {} : { screen: o }, params: a, options: { ...f, ...
|
|
980
|
+
return { name: r, ...o === void 0 ? {} : { screen: o }, params: a, options: { ...f, ...c } };
|
|
981
981
|
}
|
|
982
982
|
function Qn() {
|
|
983
983
|
const e = /* @__PURE__ */ new Map();
|
|
@@ -1001,170 +1001,170 @@ function Qn() {
|
|
|
1001
1001
|
const Zn = { placement: "right", showHeader: !0, showBackButton: !0, showCloseButton: !0, viewportGap: 5, borderRadius: 12, closeOnOverlay: !1, closeOnEsc: !0 };
|
|
1002
1002
|
function Xn(e, t) {
|
|
1003
1003
|
let n = e;
|
|
1004
|
-
const r = sn(), o = /* @__PURE__ */ new Set(), { confirmDiscard: a, onError:
|
|
1004
|
+
const r = sn(), o = /* @__PURE__ */ new Set(), { confirmDiscard: a, onError: c } = n, f = je({ isOpen: !1, activeName: null, isFullscreen: !1, queueSize: 0, error: null }), u = je({ active: null, options: null, exiting: !1, error: null, translate: n.translate });
|
|
1005
1005
|
let i = null;
|
|
1006
|
-
const d = (
|
|
1007
|
-
i =
|
|
1006
|
+
const d = (l) => {
|
|
1007
|
+
i = l, Te();
|
|
1008
1008
|
};
|
|
1009
|
-
let
|
|
1010
|
-
const
|
|
1011
|
-
|
|
1009
|
+
let h = null;
|
|
1010
|
+
const v = (l) => {
|
|
1011
|
+
h = l, Te();
|
|
1012
1012
|
};
|
|
1013
|
-
let
|
|
1014
|
-
const
|
|
1015
|
-
|
|
1016
|
-
}, s = { current: null },
|
|
1013
|
+
let k = 0;
|
|
1014
|
+
const b = (l) => {
|
|
1015
|
+
k = l, Te();
|
|
1016
|
+
}, s = { current: null }, y = { current: /* @__PURE__ */ new Map() }, A = { current: [] }, O = { current: null }, L = { current: null }, E = { current: 0 }, D = { current: null }, z = { current: !1 }, N = { current: 0 }, F = { current: null }, j = { current: /* @__PURE__ */ new Map() };
|
|
1017
1017
|
let Z = !1;
|
|
1018
|
-
const ue = (
|
|
1019
|
-
Z =
|
|
1020
|
-
}, C = { current: a },
|
|
1021
|
-
const R =
|
|
1022
|
-
return
|
|
1023
|
-
R.delete(
|
|
1018
|
+
const ue = (l) => {
|
|
1019
|
+
Z = l, Te();
|
|
1020
|
+
}, C = { current: a }, $ = (l, g) => {
|
|
1021
|
+
const R = j.current.get(l) ?? /* @__PURE__ */ new Set();
|
|
1022
|
+
return j.current.set(l, R), R.add(g), () => {
|
|
1023
|
+
R.delete(g), !R.size && j.current.get(l) === R && j.current.delete(l);
|
|
1024
1024
|
};
|
|
1025
|
-
},
|
|
1026
|
-
for (const R of
|
|
1027
|
-
if (!
|
|
1028
|
-
if ((w.onBeforeDiscard ? await w.onBeforeDiscard(
|
|
1025
|
+
}, I = async (l, g) => {
|
|
1026
|
+
for (const R of l) for (const w of [...j.current.get(R) ?? []]) {
|
|
1027
|
+
if (!j.current.get(R)?.has(w) || !w.dirty) continue;
|
|
1028
|
+
if ((w.onBeforeDiscard ? await w.onBeforeDiscard(g) : C.current ? await C.current(g) : typeof window < "u" && typeof window.confirm == "function" ? window.confirm(w.message || "有未保存的修改,确定放弃吗?") : !1) === !1) return !1;
|
|
1029
1029
|
}
|
|
1030
1030
|
return !0;
|
|
1031
|
-
}, X = (
|
|
1031
|
+
}, X = (l) => I([...j.current.keys()], l), q = { current: !0 }, te = { current: null };
|
|
1032
1032
|
te.current || (te.current = Qn());
|
|
1033
|
-
const V = { current:
|
|
1034
|
-
|
|
1033
|
+
const V = { current: c }, oe = ((l, g) => {
|
|
1034
|
+
q.current && v(l);
|
|
1035
1035
|
try {
|
|
1036
|
-
V.current ? V.current(
|
|
1036
|
+
V.current ? V.current(l, g) : console.error("[react-modal-navigation]", l);
|
|
1037
1037
|
} catch (R) {
|
|
1038
1038
|
console.error("[react-modal-navigation] onError failed", R);
|
|
1039
1039
|
}
|
|
1040
|
-
}), J = ((
|
|
1041
|
-
const R =
|
|
1042
|
-
|
|
1043
|
-
for (const w of R ?? []) w(
|
|
1044
|
-
}),
|
|
1040
|
+
}), J = ((l, g) => {
|
|
1041
|
+
const R = y.current.get(l);
|
|
1042
|
+
y.current.delete(l);
|
|
1043
|
+
for (const w of R ?? []) w(g);
|
|
1044
|
+
}), P = ((l) => ({ ...Zn, ...n.defaultOptions, ...n.theme !== void 0 ? { theme: n.theme } : {}, ...n.backgroundColor !== void 0 ? { backgroundColor: n.backgroundColor } : {}, ...l.config.modalOptions, ...l.overrides, runtimeLayout: l.runtimeLayout })), G = (async (l = "api", g, R = {}) => {
|
|
1045
1045
|
const w = s.current;
|
|
1046
|
-
if (!w || D.current ||
|
|
1047
|
-
const H =
|
|
1048
|
-
D.current = w.id,
|
|
1049
|
-
const W =
|
|
1046
|
+
if (!w || D.current || z.current) return !1;
|
|
1047
|
+
const H = N.current;
|
|
1048
|
+
D.current = w.id, z.current = !0;
|
|
1049
|
+
const W = P(w), ae = { ...R, reason: l, result: g, name: w.name };
|
|
1050
1050
|
try {
|
|
1051
|
-
if (!await X(ae) || H !==
|
|
1051
|
+
if (!await X(ae) || H !== N.current || s.current?.id !== w.id || !await w.runtime.canRemove(w.runtime.stores.navigation.getSnapshot().stack.map((pe) => pe.key), ae) || H !== N.current || s.current?.id !== w.id || await W.onBeforeClose?.(ae) === !1 || H !== N.current || s.current?.id !== w.id || !q.current) return !1;
|
|
1052
1052
|
ue(!0);
|
|
1053
1053
|
const me = W.animation === !1 || typeof window < "u" && window.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? 0 : Math.max(0, Number(W.animationDuration ?? 220) || 0);
|
|
1054
|
-
if (await te.current.wait(Math.min(me, 1e3)), !
|
|
1055
|
-
w.runtime.destroy(), s.current = null,
|
|
1056
|
-
const ie = R.confirmed ||
|
|
1054
|
+
if (await te.current.wait(Math.min(me, 1e3)), !q.current || s.current?.id !== w.id) return !1;
|
|
1055
|
+
w.runtime.destroy(), s.current = null, F.current = null, Z = !1, d(null), j.current.clear();
|
|
1056
|
+
const ie = R.confirmed || g !== void 0 ? { status: "confirmed", value: g, reason: l } : { status: "dismissed", reason: l };
|
|
1057
1057
|
J(w.id, ie), r.emit("close", { id: w.id, name: w.name, result: ie });
|
|
1058
1058
|
try {
|
|
1059
|
-
(R.confirmed ||
|
|
1059
|
+
(R.confirmed || g !== void 0) && await W.onConfirmed?.(g), await W.onClose?.(ae), await W.onClosed?.(ae);
|
|
1060
1060
|
} catch (pe) {
|
|
1061
|
-
H ===
|
|
1061
|
+
H === N.current && oe(pe, { phase: "onClose", name: w.name });
|
|
1062
1062
|
}
|
|
1063
1063
|
return !0;
|
|
1064
1064
|
} catch (me) {
|
|
1065
|
-
return H ===
|
|
1065
|
+
return H === N.current && s.current?.id === w.id && oe(me, { phase: "onBeforeClose", name: w.name }), !1;
|
|
1066
1066
|
} finally {
|
|
1067
|
-
D.current === w.id && (D.current = null), H ===
|
|
1067
|
+
D.current === w.id && (D.current = null), H === N.current && (z.current = !1), !s.current && q.current && queueMicrotask(() => L.current?.());
|
|
1068
1068
|
}
|
|
1069
|
-
}), ke = (async (
|
|
1070
|
-
if (!
|
|
1071
|
-
|
|
1072
|
-
const W =
|
|
1069
|
+
}), ke = (async (l, g = {}, R = {}, w, H) => {
|
|
1070
|
+
if (!q.current || z.current || D.current) return null;
|
|
1071
|
+
z.current = !0;
|
|
1072
|
+
const W = N.current;
|
|
1073
1073
|
try {
|
|
1074
|
-
const ae = await an(
|
|
1075
|
-
if (!
|
|
1074
|
+
const ae = await an(l, n.registry);
|
|
1075
|
+
if (!q.current || W !== N.current) return null;
|
|
1076
1076
|
const me = (he) => he.loader && !he.component ? { ...he, component: t(he.loader) } : he, ie = ae.screens ? { ...ae, screens: Object.fromEntries(Object.entries(ae.screens).map(([he, ze]) => [he, me(ze)])) } : me(ae);
|
|
1077
|
-
|
|
1077
|
+
l = typeof l == "string" ? l : ae.name ?? "inline";
|
|
1078
1078
|
const pe = ie?.component && !ie.screens ? { ...ie, singlePage: !0, initialRoute: "__single__", screens: { __single__: { component: ie.component, title: ie.title, ...ae.screenOptions ?? {} } } } : ie;
|
|
1079
|
-
if (!pe) throw new Error(`[react-modal-navigation] Unknown modal: ${
|
|
1079
|
+
if (!pe) throw new Error(`[react-modal-navigation] Unknown modal: ${l}`);
|
|
1080
1080
|
const Re = H ?? pe.initialRoute ?? Object.keys(pe.screens ?? {})[0];
|
|
1081
|
-
if (!pe.screens || !Object.hasOwn(pe.screens, Re) || !pe.screens[Re]) throw new Error(`[react-modal-navigation] Unknown initial screen '${Re}' in modal '${
|
|
1081
|
+
if (!pe.screens || !Object.hasOwn(pe.screens, Re) || !pe.screens[Re]) throw new Error(`[react-modal-navigation] Unknown initial screen '${Re}' in modal '${l}'`);
|
|
1082
1082
|
const S = s.current, le = R.instanceKey ?? pe.modalOptions?.instanceKey, Le = R.duplicateStrategy ?? pe.modalOptions?.duplicateStrategy;
|
|
1083
1083
|
if (S && le != null && S.instanceKey === le) {
|
|
1084
1084
|
if (Le === "ignore") return null;
|
|
1085
1085
|
if (Le === "reuse") {
|
|
1086
1086
|
if (w) {
|
|
1087
|
-
const he =
|
|
1088
|
-
he.push(w),
|
|
1087
|
+
const he = y.current.get(S.id) ?? [];
|
|
1088
|
+
he.push(w), y.current.set(S.id, he);
|
|
1089
1089
|
}
|
|
1090
1090
|
return S.id;
|
|
1091
1091
|
}
|
|
1092
1092
|
}
|
|
1093
1093
|
if (S) {
|
|
1094
|
-
const he =
|
|
1094
|
+
const he = P(S), ze = { reason: "replace", name: S.name, nextName: l };
|
|
1095
1095
|
try {
|
|
1096
|
-
if (!await X(ze) || W !==
|
|
1096
|
+
if (!await X(ze) || W !== N.current || s.current?.id !== S.id || !await S.runtime.canRemove(S.runtime.stores.navigation.getSnapshot().stack.map((Fe) => Fe.key), ze) || W !== N.current || s.current?.id !== S.id || await he.onBeforeClose?.(ze) === !1) return null;
|
|
1097
1097
|
} catch (Fe) {
|
|
1098
|
-
return W ===
|
|
1098
|
+
return W === N.current && s.current?.id === S.id && oe(Fe, { phase: "onBeforeClose", name: S.name }), null;
|
|
1099
1099
|
}
|
|
1100
|
-
if (!
|
|
1101
|
-
S.runtime.destroy(), s.current = null,
|
|
1100
|
+
if (!q.current || W !== N.current || s.current?.id !== S.id) return null;
|
|
1101
|
+
S.runtime.destroy(), s.current = null, F.current = null, d(null), j.current.clear();
|
|
1102
1102
|
const qe = { status: "replaced", reason: "replace" };
|
|
1103
1103
|
J(S.id, qe), r.emit("close", { id: S.id, name: S.name, result: qe });
|
|
1104
1104
|
try {
|
|
1105
1105
|
await he.onClose?.(ze), await he.onClosed?.(ze);
|
|
1106
1106
|
} catch (Fe) {
|
|
1107
|
-
W ===
|
|
1107
|
+
W === N.current && oe(Fe, { phase: "onClose", name: S.name });
|
|
1108
1108
|
}
|
|
1109
|
-
if (!
|
|
1109
|
+
if (!q.current || W !== N.current) return null;
|
|
1110
1110
|
}
|
|
1111
|
-
const ye = { id: ++E.current, name:
|
|
1112
|
-
return ye.runtime = Yn(ye,
|
|
1111
|
+
const ye = { id: ++E.current, name: l, screen: Re, params: g, config: pe, overrides: R, instanceKey: le };
|
|
1112
|
+
return ye.runtime = Yn(ye, P(ye)), ye.runtime.bindings = _e(ye.id), s.current = ye, F.current = null, w && y.current.set(ye.id, [w]), h = null, d(ye), r.emit("open", { id: ye.id, name: ye.name }), ye.id;
|
|
1113
1113
|
} finally {
|
|
1114
|
-
W ===
|
|
1114
|
+
W === N.current && (z.current = !1), !s.current && q.current && queueMicrotask(() => L.current?.());
|
|
1115
1115
|
}
|
|
1116
1116
|
});
|
|
1117
|
-
|
|
1117
|
+
O.current = ke;
|
|
1118
1118
|
const Ce = (async () => {
|
|
1119
|
-
if (!
|
|
1120
|
-
const
|
|
1121
|
-
if (
|
|
1122
|
-
o.add(
|
|
1119
|
+
if (!q.current || s.current || z.current || D.current) return;
|
|
1120
|
+
const l = A.current.shift();
|
|
1121
|
+
if (l) {
|
|
1122
|
+
o.add(l), b(A.current.length);
|
|
1123
1123
|
try {
|
|
1124
|
-
const
|
|
1125
|
-
|
|
1126
|
-
} catch (
|
|
1127
|
-
|
|
1124
|
+
const g = await O.current(l.args.name, l.args.params, l.args.options, l.resolveResult, l.args.screen);
|
|
1125
|
+
g === null ? (l.resolveResult?.({ status: "dismissed", reason: "blocked" }), l.resolveId?.(null), queueMicrotask(() => L.current?.())) : l.resolveId?.(g);
|
|
1126
|
+
} catch (g) {
|
|
1127
|
+
l.reject?.(g), queueMicrotask(() => L.current?.());
|
|
1128
1128
|
} finally {
|
|
1129
|
-
o.delete(
|
|
1129
|
+
o.delete(l);
|
|
1130
1130
|
}
|
|
1131
1131
|
}
|
|
1132
1132
|
});
|
|
1133
|
-
|
|
1134
|
-
const K = ((
|
|
1135
|
-
if (!
|
|
1136
|
-
const w = nt(
|
|
1133
|
+
L.current = Ce;
|
|
1134
|
+
const K = ((l, g, R) => {
|
|
1135
|
+
if (!q.current) return Promise.resolve(null);
|
|
1136
|
+
const w = nt(l, g, R);
|
|
1137
1137
|
return typeof w.name == "string" && !n.registry?.[w.name] ? Promise.reject(new Error(`[react-modal-navigation] Unknown modal: ${w.name}`)) : new Promise((H, W) => {
|
|
1138
|
-
|
|
1138
|
+
A.current.push({ args: w, resolveId: H, reject: W }), b(A.current.length), queueMicrotask(() => L.current?.());
|
|
1139
1139
|
});
|
|
1140
|
-
}), de = ((
|
|
1141
|
-
if (!
|
|
1142
|
-
const w = nt(
|
|
1140
|
+
}), de = ((l, g, R) => {
|
|
1141
|
+
if (!q.current) return Promise.resolve({ status: "dismissed", reason: "unmount" });
|
|
1142
|
+
const w = nt(l, g, R);
|
|
1143
1143
|
return typeof w.name == "string" && !n.registry?.[w.name] ? Promise.reject(new Error(`[react-modal-navigation] Unknown modal: ${w.name}`)) : new Promise((H, W) => {
|
|
1144
|
-
|
|
1144
|
+
A.current.push({ args: w, resolveResult: H, reject: W }), b(A.current.length), queueMicrotask(() => L.current?.());
|
|
1145
1145
|
});
|
|
1146
|
-
}),
|
|
1147
|
-
if (!
|
|
1148
|
-
const
|
|
1149
|
-
return !
|
|
1150
|
-
}), ce = ((
|
|
1151
|
-
const
|
|
1152
|
-
|
|
1153
|
-
for (const R of
|
|
1154
|
-
R.resolveId?.(null), R.resolveResult?.({ status: "dismissed", reason:
|
|
1155
|
-
return
|
|
1156
|
-
}), st = ((
|
|
1157
|
-
const w = nt(
|
|
1146
|
+
}), x = ((l) => {
|
|
1147
|
+
if (!l || typeof l != "object" || Array.isArray(l)) throw new TypeError("[react-modal-navigation] update expects an options object");
|
|
1148
|
+
const g = s.current;
|
|
1149
|
+
return !g || z.current ? !1 : (Object.keys(l).every((R) => Object.is(P(g)[R], l[R])) || (g.overrides = { ...g.overrides, ...l }, g.runtimeLayout = { ...g.runtimeLayout, ...l }, Te()), !0);
|
|
1150
|
+
}), ce = ((l, g) => Wn(l, n.registry, g)), ne = ((l) => x({ fullscreen: !!l })), re = (() => ne(!(s.current && P(s.current).fullscreen))), Be = ((l = "queue-cleared") => {
|
|
1151
|
+
const g = A.current.splice(0);
|
|
1152
|
+
b(0);
|
|
1153
|
+
for (const R of g)
|
|
1154
|
+
R.resolveId?.(null), R.resolveResult?.({ status: "dismissed", reason: l });
|
|
1155
|
+
return g.length;
|
|
1156
|
+
}), st = ((l, g, R) => {
|
|
1157
|
+
const w = nt(l, g, R);
|
|
1158
1158
|
return ke(w.name, w.params, w.options, void 0, w.screen);
|
|
1159
|
-
}), We = ((
|
|
1160
|
-
const w = nt(
|
|
1159
|
+
}), We = ((l, g, R) => {
|
|
1160
|
+
const w = nt(l, g, R);
|
|
1161
1161
|
return new Promise((H, W) => {
|
|
1162
1162
|
ke(w.name, w.params, w.options, H, w.screen).then((ae) => {
|
|
1163
1163
|
ae === null && H({ status: "dismissed", reason: "blocked" });
|
|
1164
1164
|
}, W);
|
|
1165
1165
|
});
|
|
1166
|
-
}), it = (async (
|
|
1167
|
-
const w = nt(
|
|
1166
|
+
}), it = (async (l, g, R) => {
|
|
1167
|
+
const w = nt(l, g, R);
|
|
1168
1168
|
let H;
|
|
1169
1169
|
const W = new Promise((S) => {
|
|
1170
1170
|
H = S;
|
|
@@ -1176,16 +1176,16 @@ function Xn(e, t) {
|
|
|
1176
1176
|
result: W,
|
|
1177
1177
|
isActive: me,
|
|
1178
1178
|
replaceOptions: (S) => {
|
|
1179
|
-
if (!me() ||
|
|
1179
|
+
if (!me() || z.current) return !1;
|
|
1180
1180
|
const le = s.current;
|
|
1181
1181
|
return le.overrides = { ...S }, le.runtimeLayout = void 0, Te(), !0;
|
|
1182
1182
|
},
|
|
1183
1183
|
dispose: () => {
|
|
1184
1184
|
if (!me()) return !1;
|
|
1185
1185
|
const S = s.current;
|
|
1186
|
-
|
|
1186
|
+
N.current++, te.current.cancelAll(), s.current = null, F.current = null, D.current = null, z.current = !1, Z = !1, j.current.clear(), S.runtime.destroy(), d(null);
|
|
1187
1187
|
const le = { status: "dismissed", reason: "unmount" };
|
|
1188
|
-
return J(ae, le), r.emit("close", { id: ae, name: S.name, result: le }), queueMicrotask(() =>
|
|
1188
|
+
return J(ae, le), r.emit("close", { id: ae, name: S.name, result: le }), queueMicrotask(() => L.current?.()), !0;
|
|
1189
1189
|
},
|
|
1190
1190
|
ready: pe,
|
|
1191
1191
|
on: (S, le) => ie()?.events.on(S, le) ?? (() => {
|
|
@@ -1201,65 +1201,65 @@ function Xn(e, t) {
|
|
|
1201
1201
|
navigate: async (...S) => !!await Re("navigate", ...S),
|
|
1202
1202
|
setParams: (S) => ie()?.navigationCommands ? (Re("setParams", S), !0) : !1,
|
|
1203
1203
|
setLoading: (S, le) => ie()?.navigationCommands?.setLoading ? (Re("setLoading", S, le), !0) : !1,
|
|
1204
|
-
setOptions: (S) => me() &&
|
|
1205
|
-
setFullscreen: (S) => me() &&
|
|
1204
|
+
setOptions: (S) => me() && x(S),
|
|
1205
|
+
setFullscreen: (S) => me() && x({ fullscreen: !!S }),
|
|
1206
1206
|
close: (S) => me() ? G("api", S) : Promise.resolve(!1),
|
|
1207
1207
|
confirm: (S) => me() ? G("confirm", S, { confirmed: !0 }) : Promise.resolve(!1)
|
|
1208
1208
|
};
|
|
1209
|
-
}), Qe = ((
|
|
1210
|
-
const
|
|
1211
|
-
return
|
|
1212
|
-
Ge.delete(
|
|
1213
|
-
}, Ge.add(
|
|
1214
|
-
}, on: r.on, off: r.off, open: st, openInstance: it, openAsync: We, enqueue: K, enqueueAsync: de, update:
|
|
1209
|
+
}), Qe = ((l) => G("api", l)), ct = ((l = "api") => G(l)), Ne = ((l) => G("confirm", l, { confirmed: !0 })), lt = ((l, g) => F.current?.setLoading(l, g)), Ze = () => v(null), Ge = /* @__PURE__ */ new Set(), De = { inspect: (l) => {
|
|
1210
|
+
const g = _n({ hostStore: u, statusStore: f, commands: De }, l), R = g.dispose;
|
|
1211
|
+
return g.dispose = () => {
|
|
1212
|
+
Ge.delete(g), R();
|
|
1213
|
+
}, Ge.add(g), q.current || g.dispose(), g;
|
|
1214
|
+
}, on: r.on, off: r.off, open: st, openInstance: it, openAsync: We, enqueue: K, enqueueAsync: de, update: x, setOptions: x, preload: ce, setFullscreen: ne, toggleFullscreen: re, clearQueue: Be, close: Qe, dismiss: ct, confirm: Ne, setLoading: lt, clearError: Ze }, Ee = (l, g) => Object.keys(l).length === Object.keys(g).length && Object.keys(l).every((R) => Object.is(l[R], g[R]));
|
|
1215
1215
|
function Te() {
|
|
1216
|
-
const
|
|
1217
|
-
i && !Ee(
|
|
1218
|
-
const R = i ?
|
|
1219
|
-
Ee(w, W) || f.publish(w), Ee(H,
|
|
1216
|
+
const l = i ? P(i) : null, g = u.getSnapshot();
|
|
1217
|
+
i && !Ee(l, i.runtime.stores.layout.getSnapshot()) && i.runtime.stores.layout.publish(l);
|
|
1218
|
+
const R = i ? g.active === i ? g.options : l : null, w = { isOpen: !!i, activeName: i?.name ?? null, isFullscreen: !!l?.fullscreen, queueSize: k, error: h }, H = { active: i, options: R, exiting: Z, error: h, translate: n.translate }, W = f.getSnapshot();
|
|
1219
|
+
Ee(w, W) || f.publish(w), Ee(H, g) || u.publish(H), W.queueSize !== w.queueSize && r.emit("queueChange", { previous: W.queueSize, current: w.queueSize });
|
|
1220
1220
|
}
|
|
1221
|
-
const _e = (
|
|
1222
|
-
registerLoading: (
|
|
1223
|
-
s.current?.id ===
|
|
1221
|
+
const _e = (l) => ({
|
|
1222
|
+
registerLoading: (g) => {
|
|
1223
|
+
s.current?.id === l && (F.current = g);
|
|
1224
1224
|
},
|
|
1225
|
-
registerDirtyGuard: (
|
|
1225
|
+
registerDirtyGuard: (g, R) => s.current?.id === l ? $(g, R) : () => {
|
|
1226
1226
|
},
|
|
1227
|
-
getProtectedCacheKeys: () => s.current?.id ===
|
|
1228
|
-
canNavigate: (
|
|
1229
|
-
onRequestClose: (...
|
|
1230
|
-
onOpened: (
|
|
1231
|
-
if (s.current?.id !==
|
|
1232
|
-
const R =
|
|
1233
|
-
s.current?.id ===
|
|
1227
|
+
getProtectedCacheKeys: () => s.current?.id === l ? new Set([...j.current].filter(([, g]) => [...g].some((R) => R.dirty)).map(([g]) => g)) : /* @__PURE__ */ new Set(),
|
|
1228
|
+
canNavigate: (g, R) => s.current?.id === l ? I(g, R) : Promise.resolve(!1),
|
|
1229
|
+
onRequestClose: (...g) => s.current?.id === l ? G(...g) : Promise.resolve(!1),
|
|
1230
|
+
onOpened: (g) => {
|
|
1231
|
+
if (s.current?.id !== l) return;
|
|
1232
|
+
const R = P(s.current), w = (H, W) => {
|
|
1233
|
+
s.current?.id === l && oe(H, { phase: W });
|
|
1234
1234
|
};
|
|
1235
1235
|
for (const H of ["onOpen", "onOpened"])
|
|
1236
1236
|
try {
|
|
1237
|
-
Promise.resolve(R[H]?.(
|
|
1237
|
+
Promise.resolve(R[H]?.(g)).catch((W) => w(W, H));
|
|
1238
1238
|
} catch (W) {
|
|
1239
1239
|
w(W, H);
|
|
1240
1240
|
}
|
|
1241
1241
|
}
|
|
1242
1242
|
});
|
|
1243
|
-
return { commands: De, statusStore: f, hostStore: u, bindInstance: _e, configure: (
|
|
1244
|
-
n =
|
|
1243
|
+
return { commands: De, statusStore: f, hostStore: u, bindInstance: _e, configure: (l) => {
|
|
1244
|
+
n = l, C.current = l.confirmDiscard, V.current = l.onError, Te();
|
|
1245
1245
|
}, mount: () => {
|
|
1246
|
-
|
|
1246
|
+
q.current = !0;
|
|
1247
1247
|
}, destroy: () => {
|
|
1248
|
-
|
|
1249
|
-
for (const
|
|
1250
|
-
r.clear(),
|
|
1251
|
-
for (const
|
|
1252
|
-
|
|
1253
|
-
for (const
|
|
1254
|
-
|
|
1248
|
+
q.current = !1;
|
|
1249
|
+
for (const l of Ge) l.dispose();
|
|
1250
|
+
r.clear(), N.current += 1, te.current.cancelAll(), s.current?.runtime.destroy(), s.current = null, F.current = null, D.current = null, z.current = !1;
|
|
1251
|
+
for (const l of y.current.keys()) J(l, { status: "dismissed", reason: "unmount" });
|
|
1252
|
+
y.current.clear(), j.current.clear(), i = null, Z = !1, h = null;
|
|
1253
|
+
for (const l of o)
|
|
1254
|
+
l.resolveId?.(null), l.resolveResult?.({ status: "dismissed", reason: "unmount" });
|
|
1255
1255
|
o.clear(), Be("unmount"), Te();
|
|
1256
1256
|
}, reportError: oe };
|
|
1257
1257
|
}
|
|
1258
1258
|
const Jn = Se.memo(function({ Screen: t, route: n, navigation: r }) {
|
|
1259
1259
|
return /* @__PURE__ */ p(t, { route: n, navigation: r });
|
|
1260
1260
|
}), er = Se.memo(function({ store: t, layoutStore: n, route: r, ...o }) {
|
|
1261
|
-
const a = () => t.getSnapshot()[r.key],
|
|
1262
|
-
return /* @__PURE__ */ p(en, { ...o, options: f, route: r, override:
|
|
1261
|
+
const a = () => t.getSnapshot()[r.key], c = Oe(t.subscribe, a, a), f = Pe(n, Qt, He);
|
|
1262
|
+
return /* @__PURE__ */ p(en, { ...o, options: f, route: r, override: c });
|
|
1263
1263
|
}), tr = Se.memo(function({ store: t, translate: n }) {
|
|
1264
1264
|
const r = Oe(t.subscribe, t.getSnapshot, t.getSnapshot);
|
|
1265
1265
|
return /* @__PURE__ */ p(tn, { loading: r, translate: n });
|
|
@@ -1267,73 +1267,73 @@ const Jn = Se.memo(function({ Screen: t, route: n, navigation: r }) {
|
|
|
1267
1267
|
const r = Oe(t.subscribe, t.getSnapshot, t.getSnapshot);
|
|
1268
1268
|
return /* @__PURE__ */ p(nn, { items: r, dismiss: n });
|
|
1269
1269
|
});
|
|
1270
|
-
function rr({ runtime: e, config: t, initialScreen: n, params: r, translate: o, onRequestClose: a, onOpened:
|
|
1271
|
-
const
|
|
1272
|
-
|
|
1273
|
-
const
|
|
1274
|
-
const ne =
|
|
1270
|
+
function rr({ runtime: e, config: t, initialScreen: n, params: r, translate: o, onRequestClose: a, onOpened: c, registerLoading: f, notifyError: u, error: i, clearError: d, registerDirtyGuard: h, exiting: v = !1 }) {
|
|
1271
|
+
const k = Pe(e.stores.layout, En, He), b = n ?? t.initialRoute ?? Object.keys(t.screens)[0], [s, y] = xe(() => e.stores.navigation.getSnapshot().currentRoute), A = T(s);
|
|
1272
|
+
A.current = s;
|
|
1273
|
+
const O = t.screens[b], L = e.alive, E = T(null), { navigation: D, footer: z, loading: N, toast: F } = e.refs, j = T("single"), { loadingApi: Z, setLoading: ue } = on(N, L, j, e), { toast: C, dismissToast: $ } = rn(F, L, e), I = _((x, ce) => {
|
|
1274
|
+
const ne = z.current, re = ne.getSnapshot();
|
|
1275
1275
|
if (ce === null) {
|
|
1276
|
-
if (re[
|
|
1276
|
+
if (re[x] !== void 0) {
|
|
1277
1277
|
const Be = { ...re };
|
|
1278
|
-
delete Be[
|
|
1278
|
+
delete Be[x], ne.publish(Be);
|
|
1279
1279
|
}
|
|
1280
|
-
} else re[
|
|
1281
|
-
}, []), X = _((
|
|
1282
|
-
navigate:
|
|
1280
|
+
} else re[x] !== ce && ne.publish({ ...re, [x]: ce });
|
|
1281
|
+
}, []), X = _((x = "api", ce) => !L.current || N.current.getSnapshot().visible && e.stores.layout.getSnapshot().lockCloseWhileLoading !== !1 ? Promise.resolve(!1) : a(x, ce), [a, e]), q = _(() => Promise.resolve(!1), []), te = Q(() => ({
|
|
1282
|
+
navigate: q,
|
|
1283
1283
|
navigateAsync: async () => ({ status: "cancelled" }),
|
|
1284
|
-
replace:
|
|
1285
|
-
reset:
|
|
1286
|
-
clearCache:
|
|
1287
|
-
goBack:
|
|
1288
|
-
push:
|
|
1289
|
-
pop:
|
|
1290
|
-
popToTop:
|
|
1291
|
-
popTo:
|
|
1292
|
-
setParams: (
|
|
1293
|
-
setOptions: (
|
|
1284
|
+
replace: q,
|
|
1285
|
+
reset: q,
|
|
1286
|
+
clearCache: q,
|
|
1287
|
+
goBack: q,
|
|
1288
|
+
push: q,
|
|
1289
|
+
pop: q,
|
|
1290
|
+
popToTop: q,
|
|
1291
|
+
popTo: q,
|
|
1292
|
+
setParams: (x) => L.current ? (y((ce) => ({ ...ce, params: { ...ce.params, ...typeof x == "function" ? x(ce.params) : x } })), !0) : !1,
|
|
1293
|
+
setOptions: (x) => L.current ? (y((ce) => ({ ...ce, options: { ...ce.options, ...x } })), !0) : !1,
|
|
1294
1294
|
close: X,
|
|
1295
1295
|
setLoading: ue,
|
|
1296
1296
|
canGoBack: !1,
|
|
1297
1297
|
stack: [s],
|
|
1298
1298
|
currentRoute: s
|
|
1299
|
-
}), [X, s, ue,
|
|
1299
|
+
}), [X, s, ue, q]), V = T(te);
|
|
1300
1300
|
V.current = te;
|
|
1301
1301
|
const oe = Q(() => ({
|
|
1302
|
-
clearCache: (...
|
|
1303
|
-
navigate: (...
|
|
1304
|
-
navigateAsync: (...
|
|
1305
|
-
replace: (...
|
|
1306
|
-
reset: (...
|
|
1307
|
-
goBack: (...
|
|
1308
|
-
push: (...
|
|
1309
|
-
pop: (...
|
|
1310
|
-
popToTop: (...
|
|
1311
|
-
popTo: (...
|
|
1312
|
-
setParams: (...
|
|
1313
|
-
setOptions: (...
|
|
1314
|
-
close: (...
|
|
1315
|
-
setLoading: (...
|
|
1302
|
+
clearCache: (...x) => V.current.clearCache(...x),
|
|
1303
|
+
navigate: (...x) => V.current.navigate(...x),
|
|
1304
|
+
navigateAsync: (...x) => V.current.navigateAsync(...x),
|
|
1305
|
+
replace: (...x) => V.current.replace(...x),
|
|
1306
|
+
reset: (...x) => V.current.reset(...x),
|
|
1307
|
+
goBack: (...x) => V.current.goBack(...x),
|
|
1308
|
+
push: (...x) => V.current.push(...x),
|
|
1309
|
+
pop: (...x) => V.current.pop(...x),
|
|
1310
|
+
popToTop: (...x) => V.current.popToTop(...x),
|
|
1311
|
+
popTo: (...x) => V.current.popTo(...x),
|
|
1312
|
+
setParams: (...x) => V.current.setParams(...x),
|
|
1313
|
+
setOptions: (...x) => V.current.setOptions(...x),
|
|
1314
|
+
close: (...x) => V.current.close(...x),
|
|
1315
|
+
setLoading: (...x) => V.current.setLoading(...x)
|
|
1316
1316
|
}), []);
|
|
1317
1317
|
Ae(() => e.registerNavigation(oe), [e, oe]);
|
|
1318
1318
|
const J = Q(() => ({
|
|
1319
|
-
setLoading: (
|
|
1320
|
-
showLoading: (
|
|
1321
|
-
hideLoading: (
|
|
1322
|
-
}), [Z]),
|
|
1319
|
+
setLoading: (x, ce) => Z.setScreenLoading("single", x, ce),
|
|
1320
|
+
showLoading: (x) => Z.begin("single", x),
|
|
1321
|
+
hideLoading: (x) => Z.end("single", x)
|
|
1322
|
+
}), [Z]), P = Q(() => ({ isFocused: !0, resultEvent: null, routeKey: "single", setFooter: I }), [I]), G = Q(() => ({ routeKey: "single", registerDirtyGuard: h }), [h]);
|
|
1323
1323
|
U(() => {
|
|
1324
1324
|
D.current.publish({ canGoBack: !1, stack: [s], currentRoute: s });
|
|
1325
1325
|
}, [s]);
|
|
1326
|
-
const ke =
|
|
1327
|
-
U(() => (f?.({ setLoading: ue }), ke.current || (ke.current = !0,
|
|
1326
|
+
const ke = T(!1);
|
|
1327
|
+
U(() => (f?.({ setLoading: ue }), ke.current || (ke.current = !0, c?.({ route: A.current, stack: [A.current] })), () => {
|
|
1328
1328
|
f?.(null);
|
|
1329
1329
|
}), []);
|
|
1330
|
-
const Ce = Q(() => ({ ...
|
|
1331
|
-
return /* @__PURE__ */ p(yt.Provider, { value: de.current, children: /* @__PURE__ */ p(Tt.Provider, { value: C, children: /* @__PURE__ */ p(Vt.Provider, { value:
|
|
1330
|
+
const Ce = Q(() => ({ ...O, ...s.options }), [O, s.options]), K = O.component, de = e.refs.header;
|
|
1331
|
+
return /* @__PURE__ */ p(yt.Provider, { value: de.current, children: /* @__PURE__ */ p(Tt.Provider, { value: C, children: /* @__PURE__ */ p(Vt.Provider, { value: F.current, children: /* @__PURE__ */ p(Ut.Provider, { value: z.current, children: /* @__PURE__ */ p(_t.Provider, { value: te, children: /* @__PURE__ */ p(vt.Provider, { value: oe, children: /* @__PURE__ */ p(bt.Provider, { value: D.current, children: /* @__PURE__ */ p(Ue.Provider, { value: Z, children: /* @__PURE__ */ be(Xt, { store: e.stores.layout, screenOptions: Ce.modalOptions, dialogRef: E, requestClose: X, exiting: v, children: [
|
|
1332
1332
|
/* @__PURE__ */ p(Jt, { store: e.stores.layout, screen: Ce, route: s, navigation: te, requestClose: X, translate: o, canGoBack: !1 }),
|
|
1333
|
-
/* @__PURE__ */ p("main", { className: "pmn-main", children: /* @__PURE__ */ p(Ve.Provider, { value: s, children: /* @__PURE__ */ p(Pt.Provider, { value: G, children: /* @__PURE__ */ p(ot.Provider, { value:
|
|
1334
|
-
/* @__PURE__ */ p(er, { store:
|
|
1335
|
-
/* @__PURE__ */ p(tr, { store:
|
|
1336
|
-
/* @__PURE__ */ p(nr, { store:
|
|
1333
|
+
/* @__PURE__ */ p("main", { className: "pmn-main", children: /* @__PURE__ */ p(Ve.Provider, { value: s, children: /* @__PURE__ */ p(Pt.Provider, { value: G, children: /* @__PURE__ */ p(ot.Provider, { value: P, children: /* @__PURE__ */ p(Ue.Provider, { value: J, children: /* @__PURE__ */ p(wt.Provider, { value: N.current, children: /* @__PURE__ */ p("div", { className: `pmn-body ${k.bodyClassName ?? ""}`, "data-modal-route-key": "single", tabIndex: -1, children: /* @__PURE__ */ p(Nt, { route: s, onError: u, children: /* @__PURE__ */ p(Wt, { fallback: k.lazyFallback ?? /* @__PURE__ */ p("div", { className: "pmn-lazy-loading", role: "status", "aria-live": "polite", children: "加载中..." }), children: /* @__PURE__ */ p(Jn, { Screen: K, route: s, navigation: te }) }) }) }) }) }) }) }) }) }),
|
|
1334
|
+
/* @__PURE__ */ p(er, { store: z.current, route: s, screen: Ce, layoutStore: e.stores.layout, navigation: te, requestClose: X, translate: o, onError: u, loadingApi: Z }),
|
|
1335
|
+
/* @__PURE__ */ p(tr, { store: N.current, translate: o }),
|
|
1336
|
+
/* @__PURE__ */ p(nr, { store: F.current, dismiss: $ }),
|
|
1337
1337
|
i && /* @__PURE__ */ be("div", { className: "pmn-error", role: "alert", children: [
|
|
1338
1338
|
/* @__PURE__ */ p("span", { children: i.message || String(i) }),
|
|
1339
1339
|
/* @__PURE__ */ p("button", { type: "button", onClick: d, children: "×" })
|
|
@@ -1341,12 +1341,12 @@ function rr({ runtime: e, config: t, initialScreen: n, params: r, translate: o,
|
|
|
1341
1341
|
] }) }) }) }) }) }) }) }) });
|
|
1342
1342
|
}
|
|
1343
1343
|
const or = rt(Hn), ar = rt(rr), sr = rt(function({ manager: t }) {
|
|
1344
|
-
const { active: n, options: r, exiting: o, error: a, translate:
|
|
1345
|
-
n?.runtime.alive.current && t.hostStore.getSnapshot().active?.id === f && t.reportError(
|
|
1344
|
+
const { active: n, options: r, exiting: o, error: a, translate: c } = Oe(t.hostStore.subscribe, t.hostStore.getSnapshot, t.hostStore.getSnapshot), f = n?.id, u = n?.runtime.bindings, i = Q(() => (h, v) => {
|
|
1345
|
+
n?.runtime.alive.current && t.hostStore.getSnapshot().active?.id === f && t.reportError(h, v);
|
|
1346
1346
|
}, [t, n, f]);
|
|
1347
1347
|
if (!n) return null;
|
|
1348
1348
|
const d = n.config.singlePage || Object.keys(n.config.screens ?? {}).length === 1 ? ar : or;
|
|
1349
|
-
return /* @__PURE__ */ p(at.Provider, { value: n.runtime, children: /* @__PURE__ */ p(d, { runtime: n.runtime, config: n.config, initialScreen: n.screen, params: n.params, options: r, translate:
|
|
1349
|
+
return /* @__PURE__ */ p(at.Provider, { value: n.runtime, children: /* @__PURE__ */ p(d, { runtime: n.runtime, config: n.config, initialScreen: n.screen, params: n.params, options: r, translate: c, notifyError: i, error: a, clearError: t.commands.clearError, exiting: o, ...u }, f) });
|
|
1350
1350
|
}), ir = ".pmn-overlay,.pmn-dialog,.pmn-dialog *{box-sizing:border-box}.pmn-overlay{position:fixed;inset:0;z-index:1000;display:flex;overscroll-behavior:none;background:#00000073}.pmn-place-right{justify-content:flex-end;align-items:stretch}.pmn-place-left{justify-content:flex-start;align-items:stretch}.pmn-place-center{justify-content:center;align-items:center}.pmn-place-top{justify-content:center;align-items:flex-start}.pmn-place-bottom{justify-content:center;align-items:flex-end}.pmn-dialog{--pmn-surface:#fff;--pmn-body:#fff;--pmn-text:#0f172a;--pmn-muted:#475569;--pmn-border:#e2e8f0;--pmn-hover:#f1f5f9;--pmn-overlay-card:rgba(255,255,255,.92);color-scheme:light;position:relative;display:flex;flex-direction:column;min-height:0;width:100%;max-width:min(calc(100vw - var(--pmn-gap)*2),var(--pmn-max-width, var(--pmn-width)));max-height:min(calc(100dvh - var(--pmn-gap)*2),var(--pmn-max-height, 100dvh));height:var(--pmn-height, 100%);overflow:hidden;outline:none;box-shadow:0 25px 50px -12px #00000040;background:var(--pmn-surface);color:var(--pmn-text)}.pmn-place-left .pmn-dialog,.pmn-place-right .pmn-dialog{height:calc(100dvh - var(--pmn-gap)*2);max-height:calc(100dvh - var(--pmn-gap)*2)}.pmn-place-center .pmn-dialog{height:var(--pmn-height, auto);min-height:150px}.pmn-place-top .pmn-dialog,.pmn-place-bottom .pmn-dialog{height:var(--pmn-height, auto);min-height:0}.pmn-dialog[data-modal-theme=dark]{--pmn-surface:#334155;--pmn-body:#334155;--pmn-text:#f1f5f9;--pmn-muted:#cbd5e1;--pmn-border:#475569;--pmn-hover:#1e293b;--pmn-overlay-card:rgba(51,65,85,.94);color-scheme:dark}.pmn-main{min-height:0;flex:1;overflow:hidden;display:flex;flex-direction:column;background:transparent}.pmn-body{height:100%;min-height:0;overflow-y:auto;overscroll-behavior:contain;padding:16px;flex:1}.pmn-body[hidden]{display:none!important}.pmn-header{display:flex;flex-shrink:0;height:64px;align-items:center;gap:12px;padding:0 20px;background:transparent}.pmn-header h2{font-size:18px;font-weight:600;min-width:0;flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;margin:0}.pmn-header-spacer{flex:1}.pmn-border-bottom{border-bottom:1px solid var(--pmn-border)}.pmn-icon-button{display:inline-flex;align-items:center;justify-content:center;padding:8px;border:0;background:transparent;color:inherit;border-radius:8px;cursor:pointer}.pmn-icon-button:hover{background:var(--pmn-hover)}.pmn-footer{display:flex;flex-shrink:0;align-items:center;justify-content:flex-end;gap:12px;padding:16px 20px;background:transparent}.pmn-border-top{border-top:1px solid var(--pmn-border)}.pmn-button{padding:8px 16px;border-radius:8px;font-size:14px;font-weight:500;cursor:pointer}.pmn-button:disabled{opacity:.5;cursor:not-allowed}.pmn-button-secondary{border:1px solid var(--pmn-border);background:transparent;color:var(--pmn-text)}.pmn-button-secondary:hover:not(:disabled){background:var(--pmn-hover)}.pmn-button-primary{border:1px solid #2563eb;background:#2563eb;color:#fff}.pmn-button-primary:hover:not(:disabled){background:#1d4ed8}.pmn-loading-overlay{position:absolute;inset:0;z-index:50;display:flex;align-items:center;justify-content:center;background:#ffffffb8;backdrop-filter:blur(2px);-webkit-backdrop-filter:blur(2px);cursor:progress}.pmn-dialog[data-modal-theme=dark] .pmn-loading-overlay{background:#0f172ab8}.pmn-loading-content{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:14px;max-width:85%;text-align:center;color:var(--pmn-text);pointer-events:none}.pmn-loading-text{font-size:14px;font-weight:500;line-height:1.5;overflow-wrap:anywhere}.pmn-spinner{width:38px;height:38px;border:3px solid rgba(37,99,235,.2);border-top-color:#2563eb;border-radius:50%;animation:pmn-spin .8s linear infinite}@keyframes pmn-spin{to{transform:rotate(360deg)}}@media(prefers-reduced-motion:reduce){.pmn-spinner{animation-duration:1.8s}}.pmn-error{position:absolute;z-index:60;bottom:8px;left:12px;right:12px;display:flex;justify-content:space-between;gap:12px;padding:12px;border:1px solid #fca5a5;border-radius:8px;background:#fef2f2;color:#991b1b;font-size:13px}.pmn-error button{border:0;background:transparent;font-size:20px;cursor:pointer;color:inherit}.pmn-dialog input:not([type=checkbox]):not([type=radio]),.pmn-dialog textarea,.pmn-dialog select{color:var(--pmn-text);border-color:var(--pmn-border)}.pmn-error-screen{padding:24px;color:var(--pmn-text)}.pmn-error-screen p{color:#dc2626;overflow-wrap:anywhere}@media(max-width:640px){.pmn-overlay.pmn-mobile-fullscreen{padding:0!important}.pmn-mobile-fullscreen .pmn-dialog{max-width:100%;width:100%;height:100dvh;max-height:100dvh;border-radius:0!important}}@media(prefers-reduced-motion:reduce){.pmn-spinner{animation-duration:2s}}@keyframes pmn-fade-in{0%{opacity:0}to{opacity:1}}@keyframes pmn-fade-out{0%{opacity:1}to{opacity:0}}@keyframes pmn-scale-in{0%{opacity:0;transform:translateY(10px) scale(.97)}to{opacity:1;transform:none}}@keyframes pmn-scale-out{0%{opacity:1;transform:none}to{opacity:0;transform:translateY(10px) scale(.97)}}@keyframes pmn-right-in{0%{transform:translate(105%)}to{transform:none}}@keyframes pmn-right-out{0%{transform:none}to{transform:translate(105%)}}@keyframes pmn-left-in{0%{transform:translate(-105%)}to{transform:none}}@keyframes pmn-left-out{0%{transform:none}to{transform:translate(-105%)}}@keyframes pmn-top-in{0%{transform:translateY(-105%)}to{transform:none}}@keyframes pmn-top-out{0%{transform:none}to{transform:translateY(-105%)}}@keyframes pmn-bottom-in{0%{transform:translateY(105%)}to{transform:none}}@keyframes pmn-bottom-out{0%{transform:none}to{transform:translateY(105%)}}.pmn-entering{animation:pmn-fade-in var(--pmn-animation-duration) ease-out both}.pmn-exiting{animation:pmn-fade-out var(--pmn-animation-duration) ease-in both;pointer-events:none}.pmn-entering .pmn-dialog{animation:pmn-scale-in var(--pmn-animation-duration) cubic-bezier(.2,.8,.2,1) both}.pmn-exiting .pmn-dialog{animation:pmn-scale-out var(--pmn-animation-duration) ease-in both}.pmn-entering.pmn-place-right .pmn-dialog{animation-name:pmn-right-in}.pmn-exiting.pmn-place-right .pmn-dialog{animation-name:pmn-right-out}.pmn-entering.pmn-place-left .pmn-dialog{animation-name:pmn-left-in}.pmn-exiting.pmn-place-left .pmn-dialog{animation-name:pmn-left-out}.pmn-entering.pmn-place-top .pmn-dialog{animation-name:pmn-top-in}.pmn-exiting.pmn-place-top .pmn-dialog{animation-name:pmn-top-out}.pmn-entering.pmn-place-bottom .pmn-dialog{animation-name:pmn-bottom-in}.pmn-exiting.pmn-place-bottom .pmn-dialog{animation-name:pmn-bottom-out}.pmn-no-animation,.pmn-no-animation .pmn-dialog{animation:none!important}@media(prefers-reduced-motion:reduce){.pmn-entering,.pmn-exiting,.pmn-entering .pmn-dialog,.pmn-exiting .pmn-dialog{animation:none!important}}.pmn-toast-region{position:absolute;top:56px;left:12px;right:12px;z-index:80;display:flex;flex-direction:column;align-items:center;gap:8px;pointer-events:none;max-height:calc(100% - 72px);overflow:hidden}.pmn-toast{pointer-events:auto;display:flex;align-items:flex-start;gap:10px;width:max-content;max-width:100%;min-width:min(260px,100%);padding:11px 13px;border:1px solid var(--pmn-border);border-radius:9px;background:var(--pmn-surface);color:var(--pmn-text);box-shadow:0 5px 18px #0000001a;font-size:13px;line-height:1.5;overflow-wrap:anywhere}.pmn-toast-symbol{flex:0 0 20px;display:grid;place-items:center;width:20px;height:20px;border-radius:50%;font-size:13px;font-weight:700;background:var(--pmn-hover);color:var(--pmn-muted)}.pmn-toast-success .pmn-toast-symbol{background:#dcfce7;color:#15803d}.pmn-toast-error .pmn-toast-symbol{background:#fee2e2;color:#b91c1c}.pmn-toast-warning .pmn-toast-symbol{background:#fef3c7;color:#b45309}.pmn-toast-info .pmn-toast-symbol{background:#dbeafe;color:#1d4ed8}.pmn-toast-message{flex:1;min-width:0;white-space:pre-wrap}.pmn-toast-close{border:0;background:transparent;color:var(--pmn-muted);cursor:pointer;font-size:19px;line-height:18px;padding:0 1px}.pmn-toast-close:hover{color:var(--pmn-text)}.pmn-button-danger{background:#dc2626!important;color:#fff!important;border-color:#dc2626!important}@keyframes pmn-page-forward-in{0%{opacity:.18;transform:translate3d(var(--pmn-page-distance,96px),0,0) scale(.985)}to{opacity:1;transform:translateZ(0)}}@keyframes pmn-page-back-in{0%{opacity:.18;transform:translate3d(calc(-1 * var(--pmn-page-distance,96px)),0,0) scale(.985)}to{opacity:1;transform:translateZ(0)}}.pmn-page-enter{animation-duration:var(--pmn-page-duration,.36s);animation-timing-function:cubic-bezier(.2,.8,.2,1);animation-fill-mode:both;will-change:transform,opacity}.pmn-page-forward{animation-name:pmn-page-forward-in}.pmn-page-back{animation-name:pmn-page-back-in}@media(prefers-reduced-motion:reduce){.pmn-page-enter{animation:none!important;will-change:auto}}.pmn-main{position:relative;isolation:isolate}.pmn-page-exit{animation-duration:var(--pmn-page-duration,.36s);animation-timing-function:cubic-bezier(.22,1,.36,1);animation-fill-mode:forwards}@keyframes pmn-page-forward-out{to{opacity:.45;transform:translate3d(calc(-1 * var(--pmn-page-distance,96px)),0,0) scale(.985)}}@keyframes pmn-page-back-out{to{opacity:.45;transform:translate3d(var(--pmn-page-distance,96px),0,0) scale(.985)}}.pmn-page-exit-forward{animation-name:pmn-page-forward-out}.pmn-page-exit-back{animation-name:pmn-page-back-out}@media(prefers-reduced-motion:reduce){.pmn-page-exit{animation:none!important}}.pmn-main>.pmn-body{position:relative;width:100%;flex:1 0 100%;background:var(--pmn-body)}.pmn-page-forward,.pmn-page-back{z-index:2}@keyframes pmn-page-forward-in{0%{opacity:1;transform:translate3d(100%,0,0)}to{opacity:1;transform:translateZ(0)}}@keyframes pmn-page-back-in{0%{opacity:1;transform:translate3d(-100%,0,0)}to{opacity:1;transform:translateZ(0)}}@keyframes pmn-page-forward-out{to{opacity:1;transform:translate3d(-100%,0,0)}}@keyframes pmn-page-back-out{to{opacity:1;transform:translate3d(100%,0,0)}}.pmn-lazy-loading{display:flex;min-height:80px;align-items:center;justify-content:center;color:var(--pmn-muted);font-size:14px}.pmn-place-top .pmn-dialog{max-height:min(calc(100dvh - var(--pmn-top-offset, var(--pmn-gap)) - var(--pmn-gap)),var(--pmn-max-height,100dvh))}.pmn-dialog.pmn-has-custom-background{isolation:isolate;--pmn-body:transparent}.pmn-custom-background-layer{position:absolute;inset:0;z-index:0;pointer-events:none}.pmn-dialog.pmn-has-custom-background>:not(.pmn-custom-background-layer){position:relative;z-index:1}.pmn-dialog.pmn-has-custom-background .pmn-main>.pmn-body{background:transparent}.pmn-overlay.pmn-fullscreen{padding:0!important;align-items:stretch;justify-content:stretch}.pmn-overlay.pmn-fullscreen .pmn-dialog{width:100%;max-width:100%;height:100%;max-height:100%;border-radius:0!important}.pmn-place-left .pmn-dialog,.pmn-place-right .pmn-dialog{height:100%;max-height:100%}.pmn-place-center .pmn-dialog{max-height:100%}.pmn-dialog{max-width:min(100%,var(--pmn-drag-width,var(--pmn-max-width,var(--pmn-width))));max-height:min(100%,var(--pmn-max-height,100dvh))}.pmn-dialog .pmn-resize-handle{position:absolute;z-index:5;top:0;bottom:0;width:10px;cursor:ew-resize;touch-action:none;-webkit-user-select:none;user-select:none}.pmn-resize-left{right:0}.pmn-resize-right{left:0}.pmn-resize-handle:hover,.pmn-resize-handle:focus-visible{background:var(--pmn-border)}@media(max-width:640px){.pmn-mobile-fullscreen .pmn-resize-handle{display:none}}.pmn-dialog{max-width:min(100%,var(--pmn-max-width,100%),var(--pmn-drag-width,var(--pmn-width)))}.pmn-overlay.pmn-fullscreen .pmn-dialog{max-width:100%}", Kt = "react-modal-navigation-styles", Ot = /* @__PURE__ */ new WeakMap();
|
|
1351
1351
|
function cr() {
|
|
1352
1352
|
mn(() => {
|
|
@@ -1364,12 +1364,12 @@ function cr() {
|
|
|
1364
1364
|
}, []);
|
|
1365
1365
|
}
|
|
1366
1366
|
const lr = Object.freeze({}), ur = (e) => ({ "modal.loading": "加载中...", "modal.processing": "处理中...", "modal.back": "返回", "modal.close": "关闭", "modal.cancel": "取消", "modal.done": "完成" })[e] ?? e;
|
|
1367
|
-
function Tr({ children: e, registry: t, defaultOptions: n = lr, backgroundColor: r, theme: o, translate: a = ur, onError:
|
|
1367
|
+
function Tr({ children: e, registry: t, defaultOptions: n = lr, backgroundColor: r, theme: o, translate: a = ur, onError: c, confirmDiscard: f }) {
|
|
1368
1368
|
cr();
|
|
1369
|
-
const u = { registry: t, defaultOptions: n, backgroundColor: r, theme: o, translate: a, onError:
|
|
1369
|
+
const u = { registry: t, defaultOptions: n, backgroundColor: r, theme: o, translate: a, onError: c, confirmDiscard: f }, [i] = xe(() => Xn(u, Gn));
|
|
1370
1370
|
return Ae(() => (i.mount(), i.destroy), [i]), Ae(() => {
|
|
1371
1371
|
i.configure(u);
|
|
1372
|
-
}, [i, t, n, r, o, a,
|
|
1372
|
+
}, [i, t, n, r, o, a, c, f]), /* @__PURE__ */ p(Lt.Provider, { value: i.commands, children: /* @__PURE__ */ p(zt.Provider, { value: i.statusStore, children: /* @__PURE__ */ be(Gt.Provider, { value: i.commands, children: [
|
|
1373
1373
|
e,
|
|
1374
1374
|
/* @__PURE__ */ p(sr, { manager: i })
|
|
1375
1375
|
] }) }) });
|
|
@@ -1377,7 +1377,7 @@ function Tr({ children: e, registry: t, defaultOptions: n = lr, backgroundColor:
|
|
|
1377
1377
|
const dr = Object.freeze({ canGoBack: !1, stack: [], currentRoute: null }), Ht = () => () => {
|
|
1378
1378
|
}, ft = () => dr;
|
|
1379
1379
|
function Lr({ subscribe: e = !0 } = {}) {
|
|
1380
|
-
const t = ee(Gt), n = ee(zt), r = Oe(e && n?.subscribe || Ht, e && n?.getSnapshot || ft, e && n?.getSnapshot || ft), o = Q(() => t ? e ? { ...t, ...r } : t : null, [t, r, e]), a = ee(vt),
|
|
1380
|
+
const t = ee(Gt), n = ee(zt), r = Oe(e && n?.subscribe || Ht, e && n?.getSnapshot || ft, e && n?.getSnapshot || ft), o = Q(() => t ? e ? { ...t, ...r } : t : null, [t, r, e]), a = ee(vt), c = ee(bt), f = Oe(e && c?.subscribe || Ht, e && c?.getSnapshot || ft, e && c?.getSnapshot || ft);
|
|
1381
1381
|
if (!o) throw new Error("[react-modal-navigation] useModal requires <ModalProvider>");
|
|
1382
1382
|
const u = Q(() => {
|
|
1383
1383
|
const i = () => {
|
|
@@ -1433,7 +1433,7 @@ function Ar(e) {
|
|
|
1433
1433
|
function Nr(e) {
|
|
1434
1434
|
const t = ee(ot);
|
|
1435
1435
|
if (!t) throw new Error("useNavigationResult requires an active modal screen");
|
|
1436
|
-
const n =
|
|
1436
|
+
const n = T(e), r = T(null);
|
|
1437
1437
|
U(() => {
|
|
1438
1438
|
n.current = e;
|
|
1439
1439
|
}, [e]), U(() => {
|
|
@@ -1443,35 +1443,35 @@ function Nr(e) {
|
|
|
1443
1443
|
function jr(e = {}) {
|
|
1444
1444
|
const t = ee(ot);
|
|
1445
1445
|
if (!t) throw new Error("[react-modal-navigation] useModalFooter requires an active modal screen");
|
|
1446
|
-
const { setFooter: n, routeKey: r } = t, o =
|
|
1446
|
+
const { setFooter: n, routeKey: r } = t, o = T(e);
|
|
1447
1447
|
o.current = e;
|
|
1448
|
-
const a = Q(() => (...
|
|
1449
|
-
|
|
1450
|
-
const Z = E[
|
|
1451
|
-
return [.../* @__PURE__ */ new Set([...Object.keys(
|
|
1452
|
-
}) || (
|
|
1453
|
-
source:
|
|
1454
|
-
normalized:
|
|
1455
|
-
...
|
|
1456
|
-
onClick: (...Z) => (o.current.actions?.find((C) => C.key ===
|
|
1448
|
+
const a = Q(() => (...F) => o.current.done?.(...F), []), c = Q(() => (...F) => (o.current.cancel ?? o.current.cancle)?.(...F), []), f = Q(() => (...F) => o.current.renderFooter?.(...F), []), u = typeof e.done == "function", i = typeof (e.cancel ?? e.cancle) == "function", d = typeof e.renderFooter == "function", { showFooter: h, showFooterBorder: v, doneDisabled: k, doneText: b, cancelText: s, loadingText: y, footerClassName: A } = e, O = T({ source: null, normalized: void 0 }), L = Array.isArray(e.actions) ? e.actions : null, E = O.current.source;
|
|
1449
|
+
L === E || L && E && L.length === E.length && L.every((F, j) => {
|
|
1450
|
+
const Z = E[j];
|
|
1451
|
+
return [.../* @__PURE__ */ new Set([...Object.keys(F), ...Object.keys(Z)])].every((C) => C === "onClick" || Object.is(F[C], Z[C]));
|
|
1452
|
+
}) || (O.current = {
|
|
1453
|
+
source: L?.map((F) => ({ ...F })) ?? null,
|
|
1454
|
+
normalized: L?.map((F, j) => ({
|
|
1455
|
+
...F,
|
|
1456
|
+
onClick: (...Z) => (o.current.actions?.find((C) => C.key === F.key) ?? o.current.actions?.[j])?.onClick?.(...Z)
|
|
1457
1457
|
}))
|
|
1458
1458
|
});
|
|
1459
|
-
const
|
|
1460
|
-
showFooter:
|
|
1461
|
-
showFooterBorder:
|
|
1462
|
-
doneDisabled:
|
|
1463
|
-
doneText:
|
|
1459
|
+
const z = O.current.normalized, N = Q(() => ({
|
|
1460
|
+
showFooter: h,
|
|
1461
|
+
showFooterBorder: v,
|
|
1462
|
+
doneDisabled: k,
|
|
1463
|
+
doneText: b,
|
|
1464
1464
|
cancelText: s,
|
|
1465
|
-
loadingText:
|
|
1466
|
-
footerClassName:
|
|
1467
|
-
...
|
|
1465
|
+
loadingText: y,
|
|
1466
|
+
footerClassName: A,
|
|
1467
|
+
...z !== void 0 ? { actions: z } : {},
|
|
1468
1468
|
...u ? { done: a } : {},
|
|
1469
|
-
...i ? { cancel:
|
|
1469
|
+
...i ? { cancel: c } : {},
|
|
1470
1470
|
...d ? { renderFooter: f } : {}
|
|
1471
|
-
}), [
|
|
1471
|
+
}), [h, v, k, b, s, y, A, z, u, i, d, a, c, f]);
|
|
1472
1472
|
U(() => {
|
|
1473
|
-
n(r,
|
|
1474
|
-
}, [r, n,
|
|
1473
|
+
n(r, N);
|
|
1474
|
+
}, [r, n, N]), U(() => () => n(r, null), [r, n]);
|
|
1475
1475
|
}
|
|
1476
1476
|
const pr = (e) => e.visible;
|
|
1477
1477
|
function Br() {
|
|
@@ -1491,55 +1491,55 @@ function qr(e, t) {
|
|
|
1491
1491
|
return Pe(n, e, t);
|
|
1492
1492
|
}
|
|
1493
1493
|
function Fr() {
|
|
1494
|
-
const e = ee(at), t = ee(Ve), n = fr(), r = jt(), o =
|
|
1495
|
-
if (!
|
|
1496
|
-
a.current = null,
|
|
1494
|
+
const e = ee(at), t = ee(Ve), n = fr(), r = jt(), o = T(!0), a = T(null), [c, f] = xe(!1), [u, i] = xe(null), d = _((k) => {
|
|
1495
|
+
if (!k || a.current !== k) return !1;
|
|
1496
|
+
a.current = null, k.unregister?.(), o.current && f(!1);
|
|
1497
1497
|
try {
|
|
1498
|
-
|
|
1498
|
+
k.controller.abort();
|
|
1499
1499
|
} finally {
|
|
1500
|
-
|
|
1500
|
+
k.release();
|
|
1501
1501
|
}
|
|
1502
1502
|
return !0;
|
|
1503
|
-
}, []),
|
|
1503
|
+
}, []), h = _(() => d(a.current), [d]);
|
|
1504
1504
|
return U(() => (o.current = !0, () => {
|
|
1505
|
-
o.current = !1,
|
|
1506
|
-
}), [
|
|
1505
|
+
o.current = !1, h();
|
|
1506
|
+
}), [h]), { run: _(async (k, b = {}) => {
|
|
1507
1507
|
if (!o.current || e && !e.alive.current) return { status: "cancelled" };
|
|
1508
1508
|
if (a.current) return { status: "busy" };
|
|
1509
|
-
if (typeof
|
|
1509
|
+
if (typeof k != "function") throw new TypeError("[react-modal-navigation] run requires a function");
|
|
1510
1510
|
const s = new AbortController();
|
|
1511
|
-
let
|
|
1512
|
-
const
|
|
1513
|
-
|
|
1511
|
+
let y, A = !1;
|
|
1512
|
+
const O = { controller: s, release: () => {
|
|
1513
|
+
A || (A = !0, y != null && n.hideLoading(y));
|
|
1514
1514
|
} };
|
|
1515
|
-
a.current =
|
|
1516
|
-
const
|
|
1515
|
+
a.current = O, O.cancel = () => d(O), O.unregister = e?.tasks.register(t?.key, O);
|
|
1516
|
+
const L = () => o.current && a.current === O && !s.signal.aborted;
|
|
1517
1517
|
try {
|
|
1518
|
-
if (!
|
|
1519
|
-
if (f(!0), i(null),
|
|
1520
|
-
return
|
|
1521
|
-
const E = await
|
|
1522
|
-
return
|
|
1518
|
+
if (!L()) return { status: "cancelled" };
|
|
1519
|
+
if (f(!0), i(null), y = n.showLoading(b.loadingText), !L())
|
|
1520
|
+
return y != null && A && n.hideLoading(y), { status: "cancelled" };
|
|
1521
|
+
const E = await k({ signal: s.signal });
|
|
1522
|
+
return L() ? (await b.onSuccess?.(E), L() ? { status: "success", value: E } : { status: "cancelled" }) : { status: "cancelled" };
|
|
1523
1523
|
} catch (E) {
|
|
1524
|
-
if (!
|
|
1524
|
+
if (!L()) return { status: "cancelled" };
|
|
1525
1525
|
i(E);
|
|
1526
1526
|
try {
|
|
1527
|
-
await
|
|
1527
|
+
await b.onError?.(E);
|
|
1528
1528
|
} catch (D) {
|
|
1529
1529
|
console.error("[react-modal-navigation] onError failed", D);
|
|
1530
1530
|
}
|
|
1531
|
-
if (!
|
|
1532
|
-
if (
|
|
1531
|
+
if (!L()) return { status: "cancelled" };
|
|
1532
|
+
if (b.throwOnError) throw E;
|
|
1533
1533
|
return { status: "error", error: E };
|
|
1534
1534
|
} finally {
|
|
1535
|
-
|
|
1535
|
+
O.unregister?.(), O.release(), a.current === O && (a.current = null, o.current && f(!1));
|
|
1536
1536
|
}
|
|
1537
|
-
}, [n, e, t?.key, d]), cancel:
|
|
1537
|
+
}, [n, e, t?.key, d]), cancel: h, pending: c, error: u, clearError: () => i(null), isFocused: r };
|
|
1538
1538
|
}
|
|
1539
1539
|
function hr(e, t = {}) {
|
|
1540
1540
|
const n = ee(Pt);
|
|
1541
1541
|
if (!n) throw new Error("[react-modal-navigation] useModalUnsavedChanges must be used inside a modal screen");
|
|
1542
|
-
const r =
|
|
1542
|
+
const r = T({ dirty: e, ...t });
|
|
1543
1543
|
r.current = { dirty: e, ...t };
|
|
1544
1544
|
const { routeKey: o, registerDirtyGuard: a } = n;
|
|
1545
1545
|
U(() => a(o, {
|
|
@@ -1586,7 +1586,7 @@ function Ir() {
|
|
|
1586
1586
|
function Dr(e = {}) {
|
|
1587
1587
|
const t = ee(yt), n = ee(Ve);
|
|
1588
1588
|
if (!t || !n) throw new Error("[react-modal-navigation] useModalHeader requires a modal screen");
|
|
1589
|
-
const r =
|
|
1589
|
+
const r = T(e);
|
|
1590
1590
|
r.current = e, U(() => {
|
|
1591
1591
|
t.set(n.key, r.current);
|
|
1592
1592
|
}), U(() => () => t.set(n.key, null), [t, n.key]);
|
|
@@ -1597,7 +1597,7 @@ function Kr(e, t) {
|
|
|
1597
1597
|
return Pe(n.stores.layout, e, t);
|
|
1598
1598
|
}
|
|
1599
1599
|
function Hr(e = {}) {
|
|
1600
|
-
const t = ee(at), n = ee(Ve), r = jt(), o =
|
|
1600
|
+
const t = ee(at), n = ee(Ve), r = jt(), o = T(e);
|
|
1601
1601
|
U(() => {
|
|
1602
1602
|
o.current = e;
|
|
1603
1603
|
}), U(() => (o.current.onMount?.(), () => o.current.onDestroy?.()), []), U(() => {
|
|
@@ -1606,89 +1606,103 @@ function Hr(e = {}) {
|
|
|
1606
1606
|
}, [r]), U(() => t?.registerRemovalGuard(n?.key, (a) => o.current.onBeforeRemove?.(a)), [t, n?.key]);
|
|
1607
1607
|
}
|
|
1608
1608
|
function Wr({ values: e, initialValues: t, equals: n = Object.is, message: r, onBeforeDiscard: o }) {
|
|
1609
|
-
const [a,
|
|
1609
|
+
const [a, c] = xe(() => t), f = !n(a, e);
|
|
1610
1610
|
hr(f, { message: r, onBeforeDiscard: o });
|
|
1611
|
-
const u = _((i = e) =>
|
|
1611
|
+
const u = _((i = e) => c(() => i), [e]);
|
|
1612
1612
|
return { dirty: f, markSaved: u };
|
|
1613
1613
|
}
|
|
1614
|
-
const kr = (e, t) => e && t && Object.keys(e).length === Object.keys(t).length && Object.keys(e).every(
|
|
1614
|
+
const kr = (e, t) => e && t && Object.keys(e).length === Object.keys(t).length && Object.keys(e).every(
|
|
1615
|
+
(n) => Object.hasOwn(t, n) && Object.is(e[n], t[n])
|
|
1616
|
+
);
|
|
1615
1617
|
function xr(e, t) {
|
|
1616
|
-
let n, r, o, a = !1,
|
|
1617
|
-
const
|
|
1618
|
+
let n, r, o, a = !1, c = !1, f = !1, u = 0, i = -1, d = !1;
|
|
1619
|
+
const h = (s) => {
|
|
1618
1620
|
try {
|
|
1619
|
-
a && n?.onError ? Promise.resolve(n.onError(
|
|
1620
|
-
} catch (
|
|
1621
|
-
console.error(
|
|
1621
|
+
a && n?.onError ? Promise.resolve(n.onError(s)).catch((y) => console.error(y)) : console.error(s);
|
|
1622
|
+
} catch (y) {
|
|
1623
|
+
console.error(y);
|
|
1622
1624
|
}
|
|
1623
|
-
},
|
|
1625
|
+
}, v = (s, ...y) => {
|
|
1624
1626
|
if (a)
|
|
1625
1627
|
try {
|
|
1626
|
-
Promise.resolve(n[
|
|
1627
|
-
} catch (
|
|
1628
|
-
|
|
1628
|
+
Promise.resolve(n[s]?.(...y)).catch(h);
|
|
1629
|
+
} catch (A) {
|
|
1630
|
+
h(A);
|
|
1629
1631
|
}
|
|
1630
|
-
},
|
|
1631
|
-
f = !0,
|
|
1632
|
+
}, k = () => {
|
|
1633
|
+
f = !0, !(c || d) && (d = !0, queueMicrotask(() => {
|
|
1634
|
+
d = !1, !c && f && b();
|
|
1635
|
+
}));
|
|
1632
1636
|
};
|
|
1633
|
-
async function
|
|
1634
|
-
|
|
1637
|
+
async function b() {
|
|
1638
|
+
c = !0;
|
|
1635
1639
|
try {
|
|
1636
1640
|
for (; f; ) {
|
|
1637
1641
|
if (f = !1, !a) {
|
|
1638
1642
|
r?.dispose();
|
|
1639
1643
|
continue;
|
|
1640
1644
|
}
|
|
1641
|
-
const
|
|
1642
|
-
if (!
|
|
1643
|
-
const
|
|
1644
|
-
if (!
|
|
1645
|
-
r?.isActive() && i !==
|
|
1645
|
+
const s = n;
|
|
1646
|
+
if (!s) continue;
|
|
1647
|
+
const y = u;
|
|
1648
|
+
if (!s.open) {
|
|
1649
|
+
r?.isActive() && i !== y && (i = y, !await r.close() && u === y && v("onBlocked", "close"));
|
|
1646
1650
|
continue;
|
|
1647
1651
|
}
|
|
1648
1652
|
if (!r?.isActive()) {
|
|
1649
|
-
if (i ===
|
|
1650
|
-
i =
|
|
1651
|
-
const
|
|
1652
|
-
{
|
|
1653
|
-
|
|
1654
|
-
|
|
1653
|
+
if (i === y) continue;
|
|
1654
|
+
i = y;
|
|
1655
|
+
const A = await e.openInstance(
|
|
1656
|
+
{
|
|
1657
|
+
component: t,
|
|
1658
|
+
title: s.title
|
|
1659
|
+
},
|
|
1660
|
+
{
|
|
1661
|
+
children: s.children,
|
|
1662
|
+
title: s.title
|
|
1663
|
+
},
|
|
1664
|
+
s.options
|
|
1655
1665
|
);
|
|
1656
|
-
if (r =
|
|
1657
|
-
u ===
|
|
1666
|
+
if (r = A, o = s, !A.isActive()) {
|
|
1667
|
+
u === y && v("onBlocked", "open");
|
|
1658
1668
|
continue;
|
|
1659
1669
|
}
|
|
1660
|
-
if (
|
|
1661
|
-
r ===
|
|
1662
|
-
}).catch(
|
|
1663
|
-
|
|
1670
|
+
if (A.result.then((O) => {
|
|
1671
|
+
r === A && (r = null, o = null, n.open && u === i && v("onOpenChange", !1, O), k());
|
|
1672
|
+
}).catch(h), !a) {
|
|
1673
|
+
A.dispose();
|
|
1664
1674
|
continue;
|
|
1665
1675
|
}
|
|
1666
1676
|
if (!n.open) {
|
|
1667
1677
|
f = !0;
|
|
1668
1678
|
continue;
|
|
1669
1679
|
}
|
|
1670
|
-
if (!await
|
|
1680
|
+
if (!await A.ready || !A.isActive())
|
|
1681
|
+
continue;
|
|
1671
1682
|
f = !0;
|
|
1672
1683
|
continue;
|
|
1673
1684
|
}
|
|
1674
|
-
i =
|
|
1685
|
+
i = y, !(!kr(o?.options, s.options) && !r.replaceOptions(s.options)) && ((!o || !Object.is(o.children, s.children) || !Object.is(o.title, s.title)) && !r.setParams({
|
|
1686
|
+
children: s.children,
|
|
1687
|
+
title: s.title
|
|
1688
|
+
}) || (o = s));
|
|
1675
1689
|
}
|
|
1676
|
-
} catch (
|
|
1677
|
-
|
|
1690
|
+
} catch (s) {
|
|
1691
|
+
h(s);
|
|
1678
1692
|
} finally {
|
|
1679
|
-
|
|
1693
|
+
c = !1, f && k();
|
|
1680
1694
|
}
|
|
1681
1695
|
}
|
|
1682
1696
|
return {
|
|
1683
1697
|
mount() {
|
|
1684
1698
|
a = !0;
|
|
1685
1699
|
},
|
|
1686
|
-
update(
|
|
1687
|
-
(!n || n.open !==
|
|
1700
|
+
update(s) {
|
|
1701
|
+
(!n || n.open !== s.open) && u++, n = s, k();
|
|
1688
1702
|
},
|
|
1689
1703
|
unmount() {
|
|
1690
1704
|
a = !1, queueMicrotask(() => {
|
|
1691
|
-
a || (r?.dispose(),
|
|
1705
|
+
a || (r?.dispose(), k());
|
|
1692
1706
|
});
|
|
1693
1707
|
}
|
|
1694
1708
|
};
|
|
@@ -1699,7 +1713,7 @@ function Sr() {
|
|
|
1699
1713
|
n.setOptions({ title: t });
|
|
1700
1714
|
}, [n, t]), e;
|
|
1701
1715
|
}
|
|
1702
|
-
function Gr({ open: e, onOpenChange: t, onBlocked: n, onError: r, children: o, title: a, ...
|
|
1716
|
+
function Gr({ open: e, onOpenChange: t, onBlocked: n, onError: r, children: o, title: a, ...c }) {
|
|
1703
1717
|
const f = Bt(), u = Q(() => xr(f, Sr), [f]);
|
|
1704
1718
|
return U(() => (u.mount(), u.unmount), [u]), U(() => {
|
|
1705
1719
|
u.update({
|
|
@@ -1709,7 +1723,7 @@ function Gr({ open: e, onOpenChange: t, onBlocked: n, onError: r, children: o, t
|
|
|
1709
1723
|
onError: r,
|
|
1710
1724
|
children: o,
|
|
1711
1725
|
title: a,
|
|
1712
|
-
options: { ...
|
|
1726
|
+
options: { ...c, instanceKey: void 0, duplicateStrategy: "allow" }
|
|
1713
1727
|
});
|
|
1714
1728
|
}), null;
|
|
1715
1729
|
}
|