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