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