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