@flemo/react 1.6.9 → 1.7.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.mjs +180 -179
- package/dist/screen/ScreenContext.d.ts +2 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import e, { Activity as t, Children as n, createContext as r, isValidElement as i, useContext as a, useEffect as o, useId as s, useImperativeHandle as c, useInsertionEffect as l, useLayoutEffect as u, useReducer as ee, useRef as d, useState as f } from "react";
|
|
2
|
-
import { animHoldKey as te, appendParamsQuery as p, buildRoutePath as m, computeBarRiding as h, computeScreenFreeze as ne, consumeSelfInducedPop as g, createAnimHoldCoordinator as _, createBrowserHistoryDriver as v, createBrowserHistoryDriver as y, createDecorator as b, createHistoryStore as re, createNavigateStore as x, createNavigationController as S, createPartTransition as C, createRawDecorator as w, createRawPartTransition as T, createRawTransition as E, createRouterScope as D, createScreenSelector as O, createScreenStore as k, createStepController as ie, createSwipeController as A, createTransition as j, createTransitionEngine as ae, createTransitionStore as M, decoratorMap as oe, eagerlyDecodeImages as se, ensureScopeHistorySync as ce, enteringInitialStyle as le, getMatchedPathPattern as N, isOpaqueColor as ue, isServer as de, markSelfInducedPop as fe, matchesPathname as pe, observeBarHeight as me, observeViewportScrollHeight as he, partTransitionMap as ge, readStepParams as P, registerTransitionDefinitions as _e, releaseScopeHistorySync as ve, resolveTransition as ye, seedRouterEntry as be, subscribeStepParamsRestore as
|
|
3
|
-
import { jsx as
|
|
2
|
+
import { animHoldKey as te, appendParamsQuery as p, buildRoutePath as m, computeBarRiding as h, computeScreenFreeze as ne, consumeSelfInducedPop as g, createAnimHoldCoordinator as _, createBrowserHistoryDriver as v, createBrowserHistoryDriver as y, createDecorator as b, createHistoryStore as re, createNavigateStore as x, createNavigationController as S, createPartTransition as C, createRawDecorator as w, createRawPartTransition as T, createRawTransition as E, createRouterScope as D, createScreenSelector as O, createScreenStore as k, createStepController as ie, createSwipeController as A, createTransition as j, createTransitionEngine as ae, createTransitionStore as M, decoratorMap as oe, eagerlyDecodeImages as se, ensureScopeHistorySync as ce, enteringInitialStyle as le, getMatchedPathPattern as N, isOpaqueColor as ue, isServer as de, markSelfInducedPop as fe, matchesPathname as pe, observeBarHeight as me, observeViewportScrollHeight as he, partTransitionMap as ge, readStepParams as P, registerTransitionDefinitions as _e, releaseScopeHistorySync as ve, resolveTransition as ye, seedRouterEntry as be, subscribeStepParamsRestore as xe } from "@flemo/core";
|
|
3
|
+
import { jsx as F, jsxs as Se } from "react/jsx-runtime";
|
|
4
4
|
//#region src/stores/StoreContext.ts
|
|
5
|
-
var
|
|
5
|
+
var I = r(null);
|
|
6
6
|
//#endregion
|
|
7
7
|
//#region src/stores/useStores.ts
|
|
8
|
-
function
|
|
9
|
-
let e = a(
|
|
8
|
+
function L() {
|
|
9
|
+
let e = a(I);
|
|
10
10
|
if (!e) throw Error("flemo stores are missing. Render inside a <Router>.");
|
|
11
11
|
return e;
|
|
12
12
|
}
|
|
13
13
|
//#endregion
|
|
14
14
|
//#region src/history/HistoryListener.tsx
|
|
15
|
-
function
|
|
16
|
-
let e =
|
|
15
|
+
function Ce() {
|
|
16
|
+
let e = L();
|
|
17
17
|
return o(() => (ce(e), () => ve(e)), [e]), null;
|
|
18
18
|
}
|
|
19
19
|
//#endregion
|
|
20
20
|
//#region src/screen/ScreenContext.ts
|
|
21
|
-
var
|
|
21
|
+
var R = r({
|
|
22
22
|
id: "",
|
|
23
23
|
isActive: !1,
|
|
24
24
|
isRoot: !0,
|
|
@@ -33,15 +33,15 @@ var B = r({
|
|
|
33
33
|
});
|
|
34
34
|
//#endregion
|
|
35
35
|
//#region src/screen/useScreen.ts
|
|
36
|
-
function
|
|
37
|
-
return a(
|
|
36
|
+
function z() {
|
|
37
|
+
return a(R);
|
|
38
38
|
}
|
|
39
39
|
//#endregion
|
|
40
40
|
//#region src/screen/ParamsProvider/ParamsContext.ts
|
|
41
|
-
var
|
|
41
|
+
var we = r({}), Te = r(() => {});
|
|
42
42
|
//#endregion
|
|
43
43
|
//#region src/screen/ParamsProvider/ParamsReducer.ts
|
|
44
|
-
function
|
|
44
|
+
function Ee(e, t) {
|
|
45
45
|
switch (t.type) {
|
|
46
46
|
case "SET": return t.params;
|
|
47
47
|
default: return e;
|
|
@@ -49,10 +49,10 @@ function we(e, t) {
|
|
|
49
49
|
}
|
|
50
50
|
//#endregion
|
|
51
51
|
//#region src/screen/ParamsProvider/ParamsProvider.tsx
|
|
52
|
-
function
|
|
53
|
-
let { isActive: t, params: n } =
|
|
52
|
+
function De({ children: e }) {
|
|
53
|
+
let { isActive: t, params: n } = z(), { driver: r } = L(), [i, a] = ee(Ee, n);
|
|
54
54
|
return o(() => {
|
|
55
|
-
if (t) return
|
|
55
|
+
if (t) return xe(r, (e) => a({
|
|
56
56
|
type: "SET",
|
|
57
57
|
params: e
|
|
58
58
|
}));
|
|
@@ -60,9 +60,9 @@ function Te({ children: e }) {
|
|
|
60
60
|
t,
|
|
61
61
|
a,
|
|
62
62
|
r
|
|
63
|
-
]), /* @__PURE__ */
|
|
63
|
+
]), /* @__PURE__ */ F(Te.Provider, {
|
|
64
64
|
value: a,
|
|
65
|
-
children: /* @__PURE__ */
|
|
65
|
+
children: /* @__PURE__ */ F(we.Provider, {
|
|
66
66
|
value: i,
|
|
67
67
|
children: e
|
|
68
68
|
})
|
|
@@ -70,40 +70,41 @@ function Te({ children: e }) {
|
|
|
70
70
|
}
|
|
71
71
|
//#endregion
|
|
72
72
|
//#region ../../node_modules/.pnpm/zustand@5.0.14_@types+react@19.2.17_react@19.2.7/node_modules/zustand/esm/react.mjs
|
|
73
|
-
var
|
|
74
|
-
function
|
|
73
|
+
var B = (e) => e;
|
|
74
|
+
function V(t, n = B) {
|
|
75
75
|
let r = e.useSyncExternalStore(t.subscribe, e.useCallback(() => n(t.getState()), [t, n]), e.useCallback(() => n(t.getInitialState()), [t, n]));
|
|
76
76
|
return e.useDebugValue(r), r;
|
|
77
77
|
}
|
|
78
78
|
//#endregion
|
|
79
79
|
//#region src/stores/useHistoryStore.ts
|
|
80
|
-
function
|
|
81
|
-
return
|
|
80
|
+
function H(e) {
|
|
81
|
+
return V(L().history, e);
|
|
82
82
|
}
|
|
83
83
|
//#endregion
|
|
84
84
|
//#region src/renderer/Renderer.tsx
|
|
85
|
-
function
|
|
86
|
-
let t =
|
|
87
|
-
return O(
|
|
85
|
+
function U({ children: e }) {
|
|
86
|
+
let t = H((e) => e.index), r = H((e) => e.histories), i = L();
|
|
87
|
+
return O(r, t).map((t) => {
|
|
88
88
|
let [r] = n.toArray(e).filter((e) => pe(e.props.path, t.pathname));
|
|
89
|
-
return r ? /* @__PURE__ */
|
|
89
|
+
return r ? /* @__PURE__ */ F(R.Provider, {
|
|
90
90
|
value: {
|
|
91
91
|
...t,
|
|
92
|
+
navigateStore: i.navigate,
|
|
92
93
|
routePath: N(r.props.path, t.pathname)
|
|
93
94
|
},
|
|
94
|
-
children: /* @__PURE__ */
|
|
95
|
+
children: /* @__PURE__ */ F(De, { children: r })
|
|
95
96
|
}, t.id) : null;
|
|
96
97
|
});
|
|
97
98
|
}
|
|
98
99
|
//#endregion
|
|
99
100
|
//#region src/screen/ScreenViewportContext.ts
|
|
100
|
-
var
|
|
101
|
-
function
|
|
102
|
-
return a(
|
|
101
|
+
var W = r({ contained: !1 });
|
|
102
|
+
function Oe() {
|
|
103
|
+
return a(W);
|
|
103
104
|
}
|
|
104
105
|
//#endregion
|
|
105
106
|
//#region src/transition/styles.ts
|
|
106
|
-
function
|
|
107
|
+
function G(e, t, n = []) {
|
|
107
108
|
l(() => _e(e, t, n), [
|
|
108
109
|
e,
|
|
109
110
|
t,
|
|
@@ -112,58 +113,58 @@ function q(e, t, n = []) {
|
|
|
112
113
|
}
|
|
113
114
|
//#endregion
|
|
114
115
|
//#region src/RouterDepthContext.ts
|
|
115
|
-
var
|
|
116
|
-
function
|
|
117
|
-
return /* @__PURE__ */
|
|
116
|
+
var K = r(0), q = { contained: !0 };
|
|
117
|
+
function ke({ children: e, className: t, style: n }) {
|
|
118
|
+
return /* @__PURE__ */ F("div", {
|
|
118
119
|
className: t,
|
|
119
120
|
style: {
|
|
120
121
|
position: "relative",
|
|
121
122
|
overflow: "hidden",
|
|
122
123
|
...n
|
|
123
124
|
},
|
|
124
|
-
children: /* @__PURE__ */
|
|
125
|
-
value:
|
|
126
|
-
children: /* @__PURE__ */
|
|
125
|
+
children: /* @__PURE__ */ F(W.Provider, {
|
|
126
|
+
value: q,
|
|
127
|
+
children: /* @__PURE__ */ F(U, { children: e })
|
|
127
128
|
})
|
|
128
129
|
});
|
|
129
130
|
}
|
|
130
131
|
//#endregion
|
|
131
132
|
//#region src/Router.tsx
|
|
132
|
-
function
|
|
133
|
+
function Ae(e) {
|
|
133
134
|
let t = null;
|
|
134
135
|
return n.forEach(e, (e) => {
|
|
135
136
|
if (t || !i(e)) return;
|
|
136
|
-
if (e.type ===
|
|
137
|
+
if (e.type === ke) {
|
|
137
138
|
t = n.toArray(e.props.children).filter(i);
|
|
138
139
|
return;
|
|
139
140
|
}
|
|
140
141
|
let r = e.props.children;
|
|
141
142
|
if (r) {
|
|
142
|
-
let e =
|
|
143
|
+
let e = Ae(r);
|
|
143
144
|
e && (t = e);
|
|
144
145
|
}
|
|
145
146
|
}), t;
|
|
146
147
|
}
|
|
147
|
-
var
|
|
148
|
-
function
|
|
149
|
-
let p = a(
|
|
150
|
-
routePaths: (
|
|
148
|
+
var je = typeof window > "u" ? o : u, Me = [], Ne = [], Pe = [], J = { contained: !0 };
|
|
149
|
+
function Y({ children: e, initPath: t = "/", defaultTransitionName: r = "cupertino", transitions: i = Me, decorators: c = Ne, partTransitions: l = Pe, history: u = "browser", createDriver: ee, className: d, style: te }) {
|
|
150
|
+
let p = a(K), m = p > 0, h = u === "memory", ne = s(), g = a(R), _ = a(I), v = m && g.id ? `_F_${_?.routerKey ?? ""}${g.id}_` : ne, b = Ae(e), re = b !== null, x = m ? null : _, S = x !== null, C = ee ?? y, [w] = f(() => h ? null : C(S ? void 0 : v)), T = !m && !h && !de(), E = T && w ? w.readPathname() : t || "/", O = E.indexOf("?"), k = (O >= 0 ? E.slice(0, O) : E) || "/", ie = T ? window.location.search : O >= 0 ? E.slice(O) : "", [A] = f(() => D({
|
|
151
|
+
routePaths: (b ?? n.toArray(e)).map((e) => e.props.path).flat(),
|
|
151
152
|
pathname: k,
|
|
152
153
|
search: ie,
|
|
153
154
|
defaultTransitionName: r,
|
|
154
155
|
memory: h,
|
|
155
156
|
browserDriver: w,
|
|
156
157
|
hostedScope: x,
|
|
157
|
-
routerKey: S ? void 0 :
|
|
158
|
+
routerKey: S ? void 0 : v,
|
|
158
159
|
zoneEntryId: m && !S && g.id || void 0,
|
|
159
|
-
persistKey: m && !h && !S ?
|
|
160
|
+
persistKey: m && !h && !S ? v : void 0
|
|
160
161
|
}));
|
|
161
|
-
A.transition.setState({ defaultTransitionName: r }),
|
|
162
|
+
A.transition.setState({ defaultTransitionName: r }), je(() => (A.life.alive = !0, () => {
|
|
162
163
|
A.life.alive = !1;
|
|
163
|
-
}), [A]),
|
|
164
|
+
}), [A]), G(i, c, l), o(() => {
|
|
164
165
|
h || !w || be({
|
|
165
166
|
driver: w,
|
|
166
|
-
routerKey: S ? null :
|
|
167
|
+
routerKey: S ? null : v,
|
|
167
168
|
nested: m && !S,
|
|
168
169
|
seedPathname: k,
|
|
169
170
|
defaultTransitionName: r,
|
|
@@ -173,23 +174,23 @@ function Pe({ children: e, initPath: t = "/", defaultTransitionName: r = "cupert
|
|
|
173
174
|
h,
|
|
174
175
|
S,
|
|
175
176
|
m,
|
|
176
|
-
|
|
177
|
+
v,
|
|
177
178
|
k,
|
|
178
179
|
r,
|
|
179
180
|
A.history,
|
|
180
181
|
w
|
|
181
182
|
]);
|
|
182
|
-
let j =
|
|
183
|
+
let j = re ? e : /* @__PURE__ */ F(U, { children: e }), ae = /* @__PURE__ */ F(K.Provider, {
|
|
183
184
|
value: p + 1,
|
|
184
|
-
children: /* @__PURE__ */
|
|
185
|
+
children: /* @__PURE__ */ Se(I.Provider, {
|
|
185
186
|
value: A,
|
|
186
|
-
children: [!h && /* @__PURE__ */
|
|
187
|
-
value:
|
|
187
|
+
children: [!h && /* @__PURE__ */ F(Ce, {}), m ? /* @__PURE__ */ F(W.Provider, {
|
|
188
|
+
value: J,
|
|
188
189
|
children: j
|
|
189
190
|
}) : j]
|
|
190
191
|
})
|
|
191
192
|
});
|
|
192
|
-
return m ? /* @__PURE__ */
|
|
193
|
+
return m ? /* @__PURE__ */ F("div", {
|
|
193
194
|
className: d,
|
|
194
195
|
style: {
|
|
195
196
|
position: "relative",
|
|
@@ -211,8 +212,8 @@ function Ie(e, t) {
|
|
|
211
212
|
}
|
|
212
213
|
//#endregion
|
|
213
214
|
//#region src/navigate/useNavigate.ts
|
|
214
|
-
function
|
|
215
|
-
let e =
|
|
215
|
+
function X() {
|
|
216
|
+
let e = L(), t = S({
|
|
216
217
|
stores: e,
|
|
217
218
|
buildPathname: (e, t) => Ie(e, t),
|
|
218
219
|
driver: e.driver,
|
|
@@ -226,13 +227,13 @@ function Le() {
|
|
|
226
227
|
}
|
|
227
228
|
//#endregion
|
|
228
229
|
//#region src/navigate/usePathname.ts
|
|
229
|
-
function
|
|
230
|
-
return
|
|
230
|
+
function Le() {
|
|
231
|
+
return H((e) => e.histories[e.pendingIndex]?.pathname ?? "/");
|
|
231
232
|
}
|
|
232
233
|
//#endregion
|
|
233
234
|
//#region src/navigate/useStep.ts
|
|
234
|
-
function
|
|
235
|
-
let { routePath: e } =
|
|
235
|
+
function Z() {
|
|
236
|
+
let { routePath: e } = z(), t = L(), n = a(Te), { driver: r, markSelfInduced: i } = t, [s, c] = f(null);
|
|
236
237
|
o(() => {
|
|
237
238
|
if (!e) return c(P(r.readState())), r.subscribe((e) => c(P(e.state)));
|
|
238
239
|
}, [e, r]);
|
|
@@ -257,36 +258,36 @@ function X() {
|
|
|
257
258
|
}
|
|
258
259
|
//#endregion
|
|
259
260
|
//#region src/screen/ParamsProvider/useParams.ts
|
|
260
|
-
function
|
|
261
|
-
return a(
|
|
261
|
+
function Q() {
|
|
262
|
+
return a(we);
|
|
262
263
|
}
|
|
263
264
|
//#endregion
|
|
264
265
|
//#region src/screen/ScreenFreeze.tsx
|
|
265
|
-
function
|
|
266
|
-
return /* @__PURE__ */
|
|
266
|
+
function Re({ freeze: e, children: n }) {
|
|
267
|
+
return /* @__PURE__ */ F(t, {
|
|
267
268
|
mode: e ? "hidden" : "visible",
|
|
268
269
|
children: n
|
|
269
270
|
});
|
|
270
271
|
}
|
|
271
272
|
//#endregion
|
|
272
273
|
//#region src/screen/scopeAnimHoldCoordinator.ts
|
|
273
|
-
var
|
|
274
|
-
function
|
|
275
|
-
let t =
|
|
276
|
-
return t || (t = _(),
|
|
274
|
+
var ze = /* @__PURE__ */ new WeakMap();
|
|
275
|
+
function Be(e) {
|
|
276
|
+
let t = ze.get(e);
|
|
277
|
+
return t || (t = _(), ze.set(e, t)), t;
|
|
277
278
|
}
|
|
278
279
|
//#endregion
|
|
279
280
|
//#region src/stores/useNavigateStore.ts
|
|
280
|
-
function
|
|
281
|
-
return
|
|
281
|
+
function Ve(e) {
|
|
282
|
+
return V(L().navigate, e);
|
|
282
283
|
}
|
|
283
284
|
//#endregion
|
|
284
285
|
//#region src/screen/ScreenDecorator.tsx
|
|
285
286
|
function He({ ref: e, style: t, ...n }) {
|
|
286
|
-
let { isActive: r, transitionName: i } =
|
|
287
|
+
let { isActive: r, transitionName: i } = z(), a = d(null);
|
|
287
288
|
c(e, () => a.current);
|
|
288
|
-
let o =
|
|
289
|
-
return l ? /* @__PURE__ */
|
|
289
|
+
let o = Ve((e) => e.status), { decoratorName: s } = ye(i), l = oe.get(s);
|
|
290
|
+
return l ? /* @__PURE__ */ F("div", {
|
|
290
291
|
ref: a,
|
|
291
292
|
"data-flemo-decorator": !0,
|
|
292
293
|
"data-flemo-decorator-name": l.name,
|
|
@@ -319,94 +320,94 @@ function Ue() {
|
|
|
319
320
|
//#endregion
|
|
320
321
|
//#region src/stores/useScreenStore.ts
|
|
321
322
|
function $(e) {
|
|
322
|
-
return
|
|
323
|
+
return V(L().screen, e);
|
|
323
324
|
}
|
|
324
325
|
//#endregion
|
|
325
326
|
//#region src/screen/ScreenMotion.tsx
|
|
326
327
|
function We({ children: e, statusBarHeight: t, statusBarColor: n, systemNavigationBarHeight: r, systemNavigationBarColor: i, sharedTopBar: a, sharedBottomBar: s, topBar: c, bottomBar: l, hideStatusBar: ee, hideSystemNavigationBar: p, backgroundColor: m = "white", contentScrollable: g = !0, ..._ }) {
|
|
327
|
-
let { id: v, isActive: y, isRoot: b, isPrev: re, zIndex: x, transitionName: S, prevTransitionName: C } =
|
|
328
|
+
let { id: v, isActive: y, isRoot: b, isPrev: re, zIndex: x, transitionName: S, prevTransitionName: C } = z(), { contained: w } = Oe(), T = w ? "absolute" : "fixed", E = L(), D = Ve((e) => e.status), O = $((e) => e.dragStatus), k = $((e) => e.replaceTransitionStatus), ie = E.screen.getState().setDragStatus, j = E.screen.getState().setReplaceTransitionStatus, M = H((e) => e.index), ce = H((e) => e.histories), N = y ? ce[M - 1]?.id : ce[M]?.id, de = $((e) => N ? e.sharedBars[N] : void 0), fe = $((e) => N ? e.screenSurfaces[N] : void 0), pe = d(null);
|
|
328
329
|
pe.current ||= ae({
|
|
329
330
|
getTransitionTaskId: () => E.navigate.getState().transitionTaskId,
|
|
330
331
|
setDragStatus: ie,
|
|
331
332
|
setReplaceTransitionStatus: j
|
|
332
333
|
});
|
|
333
334
|
let he = pe.current, ge = d(null);
|
|
334
|
-
ge.current ||=
|
|
335
|
-
let P = ye(S), { initial: _e, swipeDirection: ve, decoratorName: be } = P,
|
|
335
|
+
ge.current ||= Be(E.navigate);
|
|
336
|
+
let P = ye(S), { initial: _e, swipeDirection: ve, decoratorName: be } = P, xe = oe.get(be), { viewportScrollHeight: I } = Ue(), Ce = I > 0, [R, we] = f(0), [Te, Ee] = f(0), De = d(null), B = d(null), V = d(null), U = d(null), W = d(null), G = d({
|
|
336
337
|
transition: P,
|
|
337
|
-
decorator:
|
|
338
|
+
decorator: xe,
|
|
338
339
|
hasSharedTopBar: !!a,
|
|
339
340
|
hasSharedBottomBar: !!s,
|
|
340
|
-
viewportScrollHeight:
|
|
341
|
+
viewportScrollHeight: I,
|
|
341
342
|
isRoot: b,
|
|
342
343
|
isActive: y,
|
|
343
344
|
status: D,
|
|
344
345
|
dragStatus: O,
|
|
345
346
|
index: M
|
|
346
347
|
});
|
|
347
|
-
|
|
348
|
+
G.current = {
|
|
348
349
|
transition: P,
|
|
349
|
-
decorator:
|
|
350
|
+
decorator: xe,
|
|
350
351
|
hasSharedTopBar: !!a,
|
|
351
352
|
hasSharedBottomBar: !!s,
|
|
352
|
-
viewportScrollHeight:
|
|
353
|
+
viewportScrollHeight: I,
|
|
353
354
|
isRoot: b,
|
|
354
355
|
isActive: y,
|
|
355
356
|
status: D,
|
|
356
357
|
dragStatus: O,
|
|
357
358
|
index: M
|
|
358
359
|
};
|
|
359
|
-
let
|
|
360
|
-
|
|
361
|
-
getTransition: () =>
|
|
362
|
-
getDecorator: () =>
|
|
360
|
+
let K = d(null);
|
|
361
|
+
K.current ||= A({
|
|
362
|
+
getTransition: () => G.current.transition,
|
|
363
|
+
getDecorator: () => G.current.decorator,
|
|
363
364
|
getElements: () => ({
|
|
364
|
-
scope:
|
|
365
|
-
screenContainer:
|
|
366
|
-
decorator:
|
|
367
|
-
sharedTopBar:
|
|
368
|
-
sharedBottomBar:
|
|
365
|
+
scope: B.current,
|
|
366
|
+
screenContainer: De.current,
|
|
367
|
+
decorator: V.current,
|
|
368
|
+
sharedTopBar: U.current,
|
|
369
|
+
sharedBottomBar: W.current
|
|
369
370
|
}),
|
|
370
|
-
hasSharedTopBar: () =>
|
|
371
|
-
hasSharedBottomBar: () =>
|
|
372
|
-
getViewportScrollHeight: () =>
|
|
371
|
+
hasSharedTopBar: () => G.current.hasSharedTopBar,
|
|
372
|
+
hasSharedBottomBar: () => G.current.hasSharedBottomBar,
|
|
373
|
+
getViewportScrollHeight: () => G.current.viewportScrollHeight,
|
|
373
374
|
isReadyForDrag: () => {
|
|
374
|
-
let e =
|
|
375
|
+
let e = G.current;
|
|
375
376
|
return !e.isRoot && e.isActive && e.status === "COMPLETED" && e.dragStatus === "IDLE" && !!e.transition.swipeDirection && e.viewportScrollHeight < 10;
|
|
376
377
|
},
|
|
377
378
|
getPartnerBars: () => {
|
|
378
|
-
let e =
|
|
379
|
+
let e = G.current, t = E.history.getState().histories, n = e.isActive ? t[e.index - 1]?.id : t[e.index]?.id;
|
|
379
380
|
return n ? E.screen.getState().sharedBars[n] : void 0;
|
|
380
381
|
},
|
|
381
382
|
setDragStatus: ie,
|
|
382
383
|
back: () => window.history.back()
|
|
383
384
|
});
|
|
384
|
-
let
|
|
385
|
+
let q = K.current, ke = (e) => q.pointerDown(e.nativeEvent), Ae = (e) => q.pointerMove(e.nativeEvent), je = (e) => q.pointerUp(e.nativeEvent);
|
|
385
386
|
o(() => {
|
|
386
|
-
se(
|
|
387
|
+
se(B.current);
|
|
387
388
|
}, []), o(() => {
|
|
388
|
-
let e =
|
|
389
|
+
let e = B.current;
|
|
389
390
|
if (!e) return;
|
|
390
391
|
let t = (e) => {
|
|
391
|
-
|
|
392
|
+
q.shouldPreventTouch() && e.preventDefault(), e.target?.dataset.swipeAtEdgeBar === "true" && e.preventDefault();
|
|
392
393
|
};
|
|
393
394
|
return e.addEventListener("touchmove", t, { passive: !1 }), () => {
|
|
394
395
|
e.removeEventListener("touchmove", t);
|
|
395
396
|
};
|
|
396
|
-
}, [
|
|
397
|
-
let e =
|
|
397
|
+
}, [q]), u(() => {
|
|
398
|
+
let e = U.current;
|
|
398
399
|
if (!e) {
|
|
399
|
-
|
|
400
|
+
we(0);
|
|
400
401
|
return;
|
|
401
402
|
}
|
|
402
|
-
return me(e,
|
|
403
|
+
return me(e, we);
|
|
403
404
|
}, [a]), u(() => {
|
|
404
|
-
let e =
|
|
405
|
+
let e = W.current;
|
|
405
406
|
if (!e) {
|
|
406
|
-
|
|
407
|
+
Ee(0);
|
|
407
408
|
return;
|
|
408
409
|
}
|
|
409
|
-
return me(e,
|
|
410
|
+
return me(e, Ee);
|
|
410
411
|
}, [s]), u(() => {
|
|
411
412
|
let { registerSharedBars: e, unregisterSharedBars: t } = E.screen.getState();
|
|
412
413
|
return e(v, {
|
|
@@ -419,7 +420,7 @@ function We({ children: e, statusBarHeight: t, statusBarColor: n, systemNavigati
|
|
|
419
420
|
s,
|
|
420
421
|
E.screen
|
|
421
422
|
]), u(() => {
|
|
422
|
-
let e =
|
|
423
|
+
let e = B.current;
|
|
423
424
|
if (!e) return;
|
|
424
425
|
let { registerScreenSurface: t, unregisterScreenSurface: n } = E.screen.getState();
|
|
425
426
|
return t(v, { opaqueBackground: ue(getComputedStyle(e).backgroundColor) }), () => n(v);
|
|
@@ -429,17 +430,17 @@ function We({ children: e, statusBarHeight: t, statusBarColor: n, systemNavigati
|
|
|
429
430
|
D,
|
|
430
431
|
E.screen
|
|
431
432
|
]);
|
|
432
|
-
let
|
|
433
|
+
let Me = y || x === M - 1, { app: Ne, nav: Pe } = h({
|
|
433
434
|
status: D,
|
|
434
|
-
isTopOrTopPrev:
|
|
435
|
+
isTopOrTopPrev: Me,
|
|
435
436
|
hasTopBar: !!a,
|
|
436
437
|
hasNavBar: !!s,
|
|
437
438
|
partnerBars: de
|
|
438
|
-
}),
|
|
439
|
+
}), J = te({
|
|
439
440
|
status: D,
|
|
440
|
-
isTopOrTopPrev:
|
|
441
|
+
isTopOrTopPrev: Me,
|
|
441
442
|
transitionName: S
|
|
442
|
-
}),
|
|
443
|
+
}), Y = ne({
|
|
443
444
|
isActive: y,
|
|
444
445
|
isPrev: re,
|
|
445
446
|
zIndex: x,
|
|
@@ -447,56 +448,56 @@ function We({ children: e, statusBarHeight: t, statusBarColor: n, systemNavigati
|
|
|
447
448
|
status: D,
|
|
448
449
|
dragStatus: O,
|
|
449
450
|
replaceTransitionStatus: k
|
|
450
|
-
}), Fe = d(
|
|
451
|
-
key:
|
|
452
|
-
released:
|
|
451
|
+
}), Fe = d(Y), Ie = d(J !== null && Y), [X, Le] = f({
|
|
452
|
+
key: J,
|
|
453
|
+
released: J === null
|
|
453
454
|
});
|
|
454
|
-
|
|
455
|
-
key:
|
|
456
|
-
released:
|
|
457
|
-
}), Ie.current =
|
|
458
|
-
let
|
|
455
|
+
X.key !== J && (Le({
|
|
456
|
+
key: J,
|
|
457
|
+
released: J === null
|
|
458
|
+
}), Ie.current = J !== null && Fe.current), Fe.current = Y;
|
|
459
|
+
let Z = J !== null && X.key === J && !X.released, Q = Z ? !y && fe?.opaqueBackground ? "park" : y && (D === "PUSHING" || D === "REPLACING") && fe?.opaqueBackground ? "park-under" : "true" : "false";
|
|
459
460
|
u(() => he.driveScreenLifecycle({
|
|
460
461
|
getElements: () => ({
|
|
461
|
-
scope:
|
|
462
|
-
decorator:
|
|
463
|
-
bars: [
|
|
462
|
+
scope: B.current,
|
|
463
|
+
decorator: V.current,
|
|
464
|
+
bars: [U.current, W.current]
|
|
464
465
|
}),
|
|
465
466
|
transitionName: S,
|
|
466
467
|
prevTransitionName: C,
|
|
467
468
|
status: D,
|
|
468
469
|
isActive: y,
|
|
469
|
-
animHoldReleased: !
|
|
470
|
+
animHoldReleased: !Z
|
|
470
471
|
}), [
|
|
471
472
|
he,
|
|
472
473
|
D,
|
|
473
474
|
y,
|
|
474
475
|
C,
|
|
475
476
|
S,
|
|
476
|
-
|
|
477
|
+
Z
|
|
477
478
|
]), o(() => {
|
|
478
|
-
if (!
|
|
479
|
-
let e =
|
|
480
|
-
return ge.current.join(n, () =>
|
|
479
|
+
if (!Z || J === null) return;
|
|
480
|
+
let e = J, t = E.navigate.getState().transitionTaskId, n = t === null ? e : `${e}#${t}`;
|
|
481
|
+
return ge.current.join(n, () => Le((t) => t.key === e && !t.released ? {
|
|
481
482
|
key: e,
|
|
482
483
|
released: !0
|
|
483
484
|
} : t), {
|
|
484
|
-
scope:
|
|
485
|
+
scope: B.current,
|
|
485
486
|
decodeWait: Ie.current
|
|
486
487
|
});
|
|
487
488
|
}, [
|
|
488
|
-
X,
|
|
489
|
-
Y,
|
|
490
489
|
Z,
|
|
490
|
+
J,
|
|
491
|
+
Q,
|
|
491
492
|
E.navigate
|
|
492
493
|
]);
|
|
493
|
-
let
|
|
494
|
+
let Re = Q === "park-under" ? {} : le({
|
|
494
495
|
initial: _e,
|
|
495
496
|
isActive: y,
|
|
496
497
|
status: D
|
|
497
498
|
});
|
|
498
|
-
return /* @__PURE__ */
|
|
499
|
-
ref:
|
|
499
|
+
return /* @__PURE__ */ Se("div", {
|
|
500
|
+
ref: De,
|
|
500
501
|
style: {
|
|
501
502
|
position: T,
|
|
502
503
|
top: 0,
|
|
@@ -504,14 +505,14 @@ function We({ children: e, statusBarHeight: t, statusBarColor: n, systemNavigati
|
|
|
504
505
|
width: "100%",
|
|
505
506
|
height: "100%",
|
|
506
507
|
display: "flex",
|
|
507
|
-
zIndex:
|
|
508
|
+
zIndex: Q === "park-under" ? -1 : void 0,
|
|
508
509
|
contain: "layout style",
|
|
509
510
|
flexDirection: "column",
|
|
510
511
|
boxSizing: "border-box",
|
|
511
512
|
overscrollBehavior: "contain"
|
|
512
513
|
},
|
|
513
514
|
children: [
|
|
514
|
-
/* @__PURE__ */
|
|
515
|
+
/* @__PURE__ */ F("div", {
|
|
515
516
|
"data-swipe-at-edge-bar": !0,
|
|
516
517
|
style: {
|
|
517
518
|
position: T,
|
|
@@ -522,18 +523,18 @@ function We({ children: e, statusBarHeight: t, statusBarColor: n, systemNavigati
|
|
|
522
523
|
zIndex: 1
|
|
523
524
|
}
|
|
524
525
|
}),
|
|
525
|
-
/* @__PURE__ */
|
|
526
|
-
ref:
|
|
526
|
+
/* @__PURE__ */ Se("div", {
|
|
527
|
+
ref: B,
|
|
527
528
|
..._,
|
|
528
|
-
onPointerDown:
|
|
529
|
-
onPointerMove:
|
|
530
|
-
onPointerUp:
|
|
531
|
-
onPointerCancel:
|
|
529
|
+
onPointerDown: ke,
|
|
530
|
+
onPointerMove: Ae,
|
|
531
|
+
onPointerUp: je,
|
|
532
|
+
onPointerCancel: je,
|
|
532
533
|
"data-flemo-screen": !0,
|
|
533
534
|
"data-flemo-transition": S,
|
|
534
535
|
"data-flemo-status": D,
|
|
535
536
|
"data-flemo-active": y ? "true" : "false",
|
|
536
|
-
"data-flemo-anim-hold":
|
|
537
|
+
"data-flemo-anim-hold": Q,
|
|
537
538
|
style: {
|
|
538
539
|
display: "flex",
|
|
539
540
|
flexDirection: "column",
|
|
@@ -541,13 +542,13 @@ function We({ children: e, statusBarHeight: t, statusBarColor: n, systemNavigati
|
|
|
541
542
|
backgroundColor: m,
|
|
542
543
|
overflowY: g ? void 0 : "auto",
|
|
543
544
|
touchAction: ve === "x" ? "pan-y" : ve === "y" ? "pan-x" : "auto",
|
|
544
|
-
...
|
|
545
|
+
...Re,
|
|
545
546
|
..._.style
|
|
546
547
|
},
|
|
547
548
|
children: [
|
|
548
|
-
!ee && t && /* @__PURE__ */
|
|
549
|
+
!ee && t && /* @__PURE__ */ F("div", {
|
|
549
550
|
style: { minHeight: t },
|
|
550
|
-
children: /* @__PURE__ */
|
|
551
|
+
children: /* @__PURE__ */ F("div", { style: {
|
|
551
552
|
position: T,
|
|
552
553
|
top: 0,
|
|
553
554
|
width: "100%",
|
|
@@ -555,12 +556,12 @@ function We({ children: e, statusBarHeight: t, statusBarColor: n, systemNavigati
|
|
|
555
556
|
backgroundColor: n
|
|
556
557
|
} })
|
|
557
558
|
}),
|
|
558
|
-
a && /* @__PURE__ */
|
|
559
|
+
a && /* @__PURE__ */ F("div", { style: {
|
|
559
560
|
width: "100%",
|
|
560
|
-
minHeight:
|
|
561
|
+
minHeight: R
|
|
561
562
|
} }),
|
|
562
563
|
c,
|
|
563
|
-
/* @__PURE__ */
|
|
564
|
+
/* @__PURE__ */ F("div", {
|
|
564
565
|
style: {
|
|
565
566
|
display: "flex",
|
|
566
567
|
flexDirection: "column",
|
|
@@ -570,17 +571,17 @@ function We({ children: e, statusBarHeight: t, statusBarColor: n, systemNavigati
|
|
|
570
571
|
children: e
|
|
571
572
|
}),
|
|
572
573
|
l,
|
|
573
|
-
s && /* @__PURE__ */
|
|
574
|
-
display:
|
|
574
|
+
s && /* @__PURE__ */ F("div", { style: {
|
|
575
|
+
display: Ce ? "none" : void 0,
|
|
575
576
|
width: "100%",
|
|
576
|
-
minHeight:
|
|
577
|
+
minHeight: Te
|
|
577
578
|
} }),
|
|
578
|
-
!p && r && /* @__PURE__ */
|
|
579
|
+
!p && r && /* @__PURE__ */ F("div", {
|
|
579
580
|
style: {
|
|
580
|
-
display:
|
|
581
|
+
display: Ce ? "none" : void 0,
|
|
581
582
|
minHeight: r
|
|
582
583
|
},
|
|
583
|
-
children: /* @__PURE__ */
|
|
584
|
+
children: /* @__PURE__ */ F("div", { style: {
|
|
584
585
|
position: T,
|
|
585
586
|
bottom: 0,
|
|
586
587
|
width: "100%",
|
|
@@ -590,14 +591,14 @@ function We({ children: e, statusBarHeight: t, statusBarColor: n, systemNavigati
|
|
|
590
591
|
})
|
|
591
592
|
]
|
|
592
593
|
}),
|
|
593
|
-
a && /* @__PURE__ */
|
|
594
|
-
ref:
|
|
594
|
+
a && /* @__PURE__ */ F("div", {
|
|
595
|
+
ref: U,
|
|
595
596
|
"data-flemo-bar": "app",
|
|
596
597
|
"data-flemo-bar-transition": S,
|
|
597
598
|
"data-flemo-bar-status": D,
|
|
598
599
|
"data-flemo-bar-active": y ? "true" : "false",
|
|
599
|
-
"data-flemo-bar-riding":
|
|
600
|
-
"data-flemo-anim-hold":
|
|
600
|
+
"data-flemo-bar-riding": Ne ? "true" : "false",
|
|
601
|
+
"data-flemo-anim-hold": Q,
|
|
601
602
|
style: {
|
|
602
603
|
position: T,
|
|
603
604
|
top: ee ? 0 : t,
|
|
@@ -607,16 +608,16 @@ function We({ children: e, statusBarHeight: t, statusBarColor: n, systemNavigati
|
|
|
607
608
|
},
|
|
608
609
|
children: a
|
|
609
610
|
}),
|
|
610
|
-
s && /* @__PURE__ */
|
|
611
|
-
ref:
|
|
611
|
+
s && /* @__PURE__ */ F("div", {
|
|
612
|
+
ref: W,
|
|
612
613
|
"data-flemo-bar": "nav",
|
|
613
614
|
"data-flemo-bar-transition": S,
|
|
614
615
|
"data-flemo-bar-status": D,
|
|
615
616
|
"data-flemo-bar-active": y ? "true" : "false",
|
|
616
|
-
"data-flemo-bar-riding":
|
|
617
|
-
"data-flemo-anim-hold":
|
|
617
|
+
"data-flemo-bar-riding": Pe ? "true" : "false",
|
|
618
|
+
"data-flemo-anim-hold": Q,
|
|
618
619
|
style: {
|
|
619
|
-
display:
|
|
620
|
+
display: Ce ? "none" : void 0,
|
|
620
621
|
position: T,
|
|
621
622
|
bottom: p ? 0 : r,
|
|
622
623
|
left: 0,
|
|
@@ -625,11 +626,11 @@ function We({ children: e, statusBarHeight: t, statusBarColor: n, systemNavigati
|
|
|
625
626
|
},
|
|
626
627
|
children: s
|
|
627
628
|
}),
|
|
628
|
-
|
|
629
|
-
ref:
|
|
630
|
-
"data-flemo-anim-hold":
|
|
629
|
+
xe && /* @__PURE__ */ F(He, {
|
|
630
|
+
ref: V,
|
|
631
|
+
"data-flemo-anim-hold": Q
|
|
631
632
|
}),
|
|
632
|
-
/* @__PURE__ */
|
|
633
|
+
/* @__PURE__ */ F("div", {
|
|
633
634
|
"data-swipe-at-edge-bar": !0,
|
|
634
635
|
style: {
|
|
635
636
|
position: T,
|
|
@@ -646,18 +647,18 @@ function We({ children: e, statusBarHeight: t, statusBarColor: n, systemNavigati
|
|
|
646
647
|
//#endregion
|
|
647
648
|
//#region src/screen/Screen.tsx
|
|
648
649
|
function Ge({ children: e, ...t }) {
|
|
649
|
-
let { isActive: n, isPrev: r, zIndex: i } =
|
|
650
|
-
return /* @__PURE__ */
|
|
650
|
+
let { isActive: n, isPrev: r, zIndex: i } = z();
|
|
651
|
+
return /* @__PURE__ */ F(Re, {
|
|
651
652
|
freeze: ne({
|
|
652
653
|
isActive: n,
|
|
653
654
|
isPrev: r,
|
|
654
655
|
zIndex: i,
|
|
655
|
-
index:
|
|
656
|
-
status:
|
|
656
|
+
index: H((e) => e.index),
|
|
657
|
+
status: Ve((e) => e.status),
|
|
657
658
|
dragStatus: $((e) => e.dragStatus),
|
|
658
659
|
replaceTransitionStatus: $((e) => e.replaceTransitionStatus)
|
|
659
660
|
}),
|
|
660
|
-
children: /* @__PURE__ */
|
|
661
|
+
children: /* @__PURE__ */ F(We, {
|
|
661
662
|
...t,
|
|
662
663
|
children: e
|
|
663
664
|
})
|
|
@@ -666,11 +667,11 @@ function Ge({ children: e, ...t }) {
|
|
|
666
667
|
//#endregion
|
|
667
668
|
//#region src/screen/Part.tsx
|
|
668
669
|
function Ke({ ref: e, name: t, style: n, children: r, ...i }) {
|
|
669
|
-
let { isActive: a } =
|
|
670
|
-
return /* @__PURE__ */
|
|
670
|
+
let { isActive: a, navigateStore: o } = z(), s = L();
|
|
671
|
+
return /* @__PURE__ */ F("div", {
|
|
671
672
|
ref: e,
|
|
672
673
|
"data-flemo-part-name": t,
|
|
673
|
-
"data-flemo-status":
|
|
674
|
+
"data-flemo-status": V(o ?? s.navigate, (e) => e.status),
|
|
674
675
|
"data-flemo-active": a ? "true" : "false",
|
|
675
676
|
style: n,
|
|
676
677
|
...i,
|
|
@@ -690,10 +691,10 @@ function qe({ children: e }) {
|
|
|
690
691
|
consume: g,
|
|
691
692
|
life: { alive: !0 }
|
|
692
693
|
}));
|
|
693
|
-
return /* @__PURE__ */ I
|
|
694
|
+
return /* @__PURE__ */ F(I.Provider, {
|
|
694
695
|
value: t,
|
|
695
696
|
children: e
|
|
696
697
|
});
|
|
697
698
|
}
|
|
698
699
|
//#endregion
|
|
699
|
-
export { Ke as Part, Fe as Route,
|
|
700
|
+
export { Ke as Part, Fe as Route, Y as Router, qe as RouterScopeProvider, Ge as Screen, R as ScreenContext, He as ScreenDecorator, Re as ScreenFreeze, We as ScreenMotion, ke as Slot, v as createBrowserHistoryDriver, b as createDecorator, C as createPartTransition, w as createRawDecorator, T as createRawPartTransition, E as createRawTransition, j as createTransition, ge as partTransitionMap, H as useHistoryStore, X as useNavigate, Ve as useNavigateStore, Q as useParams, Le as usePathname, z as useScreen, $ as useScreenStore, Z as useStep, L as useStores, Ue as useViewportScrollHeight };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { History, TransitionName } from '@flemo/core';
|
|
1
|
+
import { FlemoStores, History, TransitionName } from '@flemo/core';
|
|
2
2
|
import { Path } from 'path-to-regexp';
|
|
3
3
|
export interface ScreenContextProps extends History {
|
|
4
4
|
id: string;
|
|
@@ -8,6 +8,7 @@ export interface ScreenContextProps extends History {
|
|
|
8
8
|
zIndex: number;
|
|
9
9
|
prevTransitionName: TransitionName;
|
|
10
10
|
routePath: Path;
|
|
11
|
+
navigateStore?: FlemoStores["navigate"];
|
|
11
12
|
}
|
|
12
13
|
declare const ScreenContext: import('react').Context<ScreenContextProps>;
|
|
13
14
|
export default ScreenContext;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flemo/react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.1",
|
|
4
4
|
"description": "React bindings for flemo: Router, Route, Screen, and the screen-transition runtime.",
|
|
5
5
|
"main": "./dist/index.mjs",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"path-to-regexp": "^8.4.2",
|
|
38
38
|
"zustand": "^5.0.14",
|
|
39
|
-
"@flemo/core": "1.
|
|
39
|
+
"@flemo/core": "1.19.1"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@testing-library/jest-dom": "^6.9.1",
|