@flemo/react 1.5.4 → 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 +225 -211
- 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 R = 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 V(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,106 +117,108 @@ function J(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
|
-
var
|
|
153
|
-
function
|
|
154
|
-
let m = a(
|
|
155
|
-
routePaths: (
|
|
156
|
-
pathname:
|
|
157
|
-
search:
|
|
152
|
+
var ke = [], Ae = [], je = [], X = { contained: !0 };
|
|
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(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__ */
|
|
180
|
-
value:
|
|
181
|
-
children:
|
|
182
|
-
}) :
|
|
179
|
+
children: /* @__PURE__ */ ve(z.Provider, {
|
|
180
|
+
value: M,
|
|
181
|
+
children: [!g && /* @__PURE__ */ R(be, {}), h ? /* @__PURE__ */ R(J.Provider, {
|
|
182
|
+
value: X,
|
|
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",
|
|
189
191
|
overflow: "hidden",
|
|
190
192
|
...ee
|
|
191
193
|
},
|
|
192
|
-
children:
|
|
193
|
-
}) :
|
|
194
|
+
children: re
|
|
195
|
+
}) : re;
|
|
194
196
|
}
|
|
195
197
|
//#endregion
|
|
196
198
|
//#region src/Route.tsx
|
|
197
|
-
function
|
|
199
|
+
function Ne({ element: e }) {
|
|
198
200
|
return e;
|
|
199
201
|
}
|
|
200
202
|
//#endregion
|
|
201
203
|
//#region src/screen/LayerMountContext.ts
|
|
202
|
-
var
|
|
204
|
+
var Pe = r(null);
|
|
203
205
|
//#endregion
|
|
204
206
|
//#region src/screen/Layer.tsx
|
|
205
|
-
function
|
|
206
|
-
let t = a(
|
|
207
|
-
return t ?
|
|
207
|
+
function Fe({ children: e }) {
|
|
208
|
+
let t = a(Pe);
|
|
209
|
+
return t ? ye(e, t) : e;
|
|
208
210
|
}
|
|
209
211
|
//#endregion
|
|
210
212
|
//#region src/utils/buildRoutePath.ts
|
|
211
|
-
function
|
|
213
|
+
function Z(e, t) {
|
|
212
214
|
return h(e, t);
|
|
213
215
|
}
|
|
214
216
|
//#endregion
|
|
215
217
|
//#region src/navigate/useNavigate.ts
|
|
216
|
-
function
|
|
217
|
-
let e =
|
|
218
|
+
function Ie() {
|
|
219
|
+
let e = B(), t = w({
|
|
218
220
|
stores: e,
|
|
219
|
-
buildPathname: (e, t) =>
|
|
221
|
+
buildPathname: (e, t) => Z(e, t),
|
|
220
222
|
driver: e.driver,
|
|
221
223
|
markSelfInduced: e.markSelfInduced
|
|
222
224
|
});
|
|
@@ -228,21 +230,21 @@ function Pe() {
|
|
|
228
230
|
}
|
|
229
231
|
//#endregion
|
|
230
232
|
//#region src/navigate/usePathname.ts
|
|
231
|
-
function
|
|
232
|
-
return
|
|
233
|
+
function Le() {
|
|
234
|
+
return K((e) => e.histories[e.pendingIndex]?.pathname ?? "/");
|
|
233
235
|
}
|
|
234
236
|
//#endregion
|
|
235
237
|
//#region src/navigate/useStep.ts
|
|
236
|
-
function
|
|
237
|
-
let { routePath: e } =
|
|
238
|
+
function Re() {
|
|
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
|
-
let l =
|
|
243
|
+
let l = j({
|
|
242
244
|
stores: t,
|
|
243
245
|
driver: r,
|
|
244
246
|
markSelfInduced: i,
|
|
245
|
-
buildStepPathname: (t) => e ?
|
|
247
|
+
buildStepPathname: (t) => e ? Z(e, t).pathname : m(r.readPathname(), t),
|
|
246
248
|
applyParams: (t) => {
|
|
247
249
|
n({
|
|
248
250
|
type: "SET",
|
|
@@ -259,13 +261,13 @@ function Ie() {
|
|
|
259
261
|
}
|
|
260
262
|
//#endregion
|
|
261
263
|
//#region src/screen/ParamsProvider/useParams.ts
|
|
262
|
-
function
|
|
263
|
-
return a(
|
|
264
|
+
function ze() {
|
|
265
|
+
return a(xe);
|
|
264
266
|
}
|
|
265
267
|
//#endregion
|
|
266
268
|
//#region src/screen/ScreenFreeze.tsx
|
|
267
|
-
function
|
|
268
|
-
return /* @__PURE__ */
|
|
269
|
+
function Be({ freeze: e, children: n }) {
|
|
270
|
+
return /* @__PURE__ */ R(t, {
|
|
269
271
|
mode: e ? "hidden" : "visible",
|
|
270
272
|
children: n
|
|
271
273
|
});
|
|
@@ -273,15 +275,15 @@ function Re({ 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
|
-
function
|
|
281
|
-
let { isActive: r, transitionName: i } =
|
|
282
|
+
function Ve({ ref: e, style: t, ...n }) {
|
|
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 } = ge(i), l =
|
|
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,
|
|
@@ -302,9 +304,9 @@ function ze({ ref: e, style: t, ...n }) {
|
|
|
302
304
|
}
|
|
303
305
|
//#endregion
|
|
304
306
|
//#region src/screen/useViewportScrollHeight.ts
|
|
305
|
-
function
|
|
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,106 +316,108 @@ function Be() {
|
|
|
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
|
-
function
|
|
322
|
-
let { id: y, isActive: b, isRoot: x, zIndex:
|
|
323
|
-
le.current ||=
|
|
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 }) {
|
|
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({
|
|
324
326
|
getTransitionTaskId: () => E.navigate.getState().transitionTaskId,
|
|
325
327
|
setDragStatus: ne,
|
|
326
|
-
setReplaceTransitionStatus:
|
|
328
|
+
setReplaceTransitionStatus: k
|
|
327
329
|
});
|
|
328
|
-
let de = le.current,
|
|
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
338
|
status: D,
|
|
337
339
|
dragStatus: O,
|
|
338
|
-
index:
|
|
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
350
|
status: D,
|
|
349
351
|
dragStatus: O,
|
|
350
|
-
index:
|
|
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 =
|
|
373
|
+
let e = J.current, t = E.history.getState().histories, n = e.isActive ? t[e.index - 1]?.id : t[e.index]?.id;
|
|
372
374
|
return n ? E.screen.getState().sharedBars[n] : void 0;
|
|
373
375
|
},
|
|
374
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);
|
|
382
|
+
}, []), o(() => {
|
|
383
|
+
let e = U.current;
|
|
380
384
|
if (!e) return;
|
|
381
385
|
let t = (e) => {
|
|
382
|
-
|
|
386
|
+
Y.shouldPreventTouch() && e.preventDefault(), e.target?.dataset.swipeAtEdgeBar === "true" && e.preventDefault();
|
|
383
387
|
};
|
|
384
388
|
return e.addEventListener("touchmove", t, { passive: !1 }), () => {
|
|
385
389
|
e.removeEventListener("touchmove", t);
|
|
386
390
|
};
|
|
387
|
-
}, [
|
|
391
|
+
}, [Y]), u(() => de.driveScreenLifecycle({
|
|
388
392
|
getElements: () => ({
|
|
389
|
-
scope:
|
|
390
|
-
decorator:
|
|
391
|
-
bars: [
|
|
393
|
+
scope: U.current,
|
|
394
|
+
decorator: W.current,
|
|
395
|
+
bars: [G.current, q.current]
|
|
392
396
|
}),
|
|
393
|
-
transitionName:
|
|
394
|
-
prevTransitionName:
|
|
397
|
+
transitionName: S,
|
|
398
|
+
prevTransitionName: C,
|
|
395
399
|
status: D,
|
|
396
400
|
isActive: b
|
|
397
401
|
}), [
|
|
398
402
|
de,
|
|
399
403
|
D,
|
|
400
404
|
b,
|
|
401
|
-
|
|
402
|
-
|
|
405
|
+
C,
|
|
406
|
+
S
|
|
403
407
|
]), u(() => {
|
|
404
|
-
let e =
|
|
408
|
+
let e = G.current;
|
|
405
409
|
if (!e) {
|
|
406
|
-
|
|
410
|
+
z(0);
|
|
407
411
|
return;
|
|
408
412
|
}
|
|
409
|
-
return
|
|
413
|
+
return pe(e, z);
|
|
410
414
|
}, [a]), u(() => {
|
|
411
|
-
let e =
|
|
415
|
+
let e = q.current;
|
|
412
416
|
if (!e) {
|
|
413
|
-
|
|
417
|
+
V(0);
|
|
414
418
|
return;
|
|
415
419
|
}
|
|
416
|
-
return
|
|
420
|
+
return pe(e, V);
|
|
417
421
|
}, [s]), u(() => {
|
|
418
422
|
let { registerSharedBars: e, unregisterSharedBars: t } = E.screen.getState();
|
|
419
423
|
return e(y, {
|
|
@@ -425,39 +429,49 @@ function Ve({ children: e, statusBarHeight: t, statusBarColor: n, systemNavigati
|
|
|
425
429
|
a,
|
|
426
430
|
s,
|
|
427
431
|
E.screen
|
|
432
|
+
]), u(() => {
|
|
433
|
+
let e = U.current;
|
|
434
|
+
if (!e) return;
|
|
435
|
+
let { registerScreenSurface: t, unregisterScreenSurface: n } = E.screen.getState();
|
|
436
|
+
return t(y, { opaqueBackground: ue(getComputedStyle(e).backgroundColor) }), () => n(y);
|
|
437
|
+
}, [
|
|
438
|
+
y,
|
|
439
|
+
h,
|
|
440
|
+
D,
|
|
441
|
+
E.screen
|
|
428
442
|
]);
|
|
429
|
-
let
|
|
443
|
+
let ke = b || te === A - 1, { app: Ae, nav: je } = g({
|
|
430
444
|
status: D,
|
|
431
|
-
isTopOrTopPrev:
|
|
445
|
+
isTopOrTopPrev: ke,
|
|
432
446
|
hasTopBar: !!a,
|
|
433
447
|
hasNavBar: !!s,
|
|
434
|
-
partnerBars:
|
|
448
|
+
partnerBars: ie
|
|
435
449
|
}), X = ee({
|
|
436
450
|
status: D,
|
|
437
|
-
isTopOrTopPrev:
|
|
438
|
-
transitionName:
|
|
439
|
-
}), [
|
|
451
|
+
isTopOrTopPrev: ke,
|
|
452
|
+
transitionName: S
|
|
453
|
+
}), [Me, Ne] = p({
|
|
440
454
|
key: X,
|
|
441
455
|
released: X === null
|
|
442
456
|
});
|
|
443
|
-
|
|
457
|
+
Me.key !== X && Ne({
|
|
444
458
|
key: X,
|
|
445
459
|
released: X === null
|
|
446
460
|
});
|
|
447
|
-
let
|
|
461
|
+
let Fe = X !== null && Me.key === X && !Me.released, Z = Fe ? !b && se?.opaqueBackground ? "park" : "true" : "false";
|
|
448
462
|
o(() => {
|
|
449
|
-
if (
|
|
463
|
+
if (Fe) return _e(() => Ne((e) => e.key === X && !e.released ? {
|
|
450
464
|
key: X,
|
|
451
465
|
released: !0
|
|
452
466
|
} : e));
|
|
453
|
-
}, [
|
|
454
|
-
let
|
|
467
|
+
}, [Fe, X]);
|
|
468
|
+
let Ie = ce({
|
|
455
469
|
initial: fe,
|
|
456
470
|
isActive: b,
|
|
457
471
|
status: D
|
|
458
472
|
});
|
|
459
|
-
return /* @__PURE__ */
|
|
460
|
-
ref:
|
|
473
|
+
return /* @__PURE__ */ ve("div", {
|
|
474
|
+
ref: Ce,
|
|
461
475
|
style: {
|
|
462
476
|
position: T,
|
|
463
477
|
top: 0,
|
|
@@ -471,7 +485,7 @@ function Ve({ children: e, statusBarHeight: t, statusBarColor: n, systemNavigati
|
|
|
471
485
|
overscrollBehavior: "contain"
|
|
472
486
|
},
|
|
473
487
|
children: [
|
|
474
|
-
/* @__PURE__ */
|
|
488
|
+
/* @__PURE__ */ R("div", {
|
|
475
489
|
"data-swipe-at-edge-bar": !0,
|
|
476
490
|
style: {
|
|
477
491
|
position: T,
|
|
@@ -482,32 +496,32 @@ function Ve({ children: e, statusBarHeight: t, statusBarColor: n, systemNavigati
|
|
|
482
496
|
zIndex: 1
|
|
483
497
|
}
|
|
484
498
|
}),
|
|
485
|
-
/* @__PURE__ */
|
|
486
|
-
ref:
|
|
499
|
+
/* @__PURE__ */ ve("div", {
|
|
500
|
+
ref: U,
|
|
487
501
|
...v,
|
|
488
|
-
onPointerDown:
|
|
489
|
-
onPointerMove:
|
|
490
|
-
onPointerUp:
|
|
491
|
-
onPointerCancel:
|
|
502
|
+
onPointerDown: Ee,
|
|
503
|
+
onPointerMove: De,
|
|
504
|
+
onPointerUp: Oe,
|
|
505
|
+
onPointerCancel: Oe,
|
|
492
506
|
"data-flemo-screen": !0,
|
|
493
|
-
"data-flemo-transition":
|
|
507
|
+
"data-flemo-transition": S,
|
|
494
508
|
"data-flemo-status": D,
|
|
495
509
|
"data-flemo-active": b ? "true" : "false",
|
|
496
|
-
"data-flemo-anim-hold": Z
|
|
510
|
+
"data-flemo-anim-hold": Z,
|
|
497
511
|
style: {
|
|
498
512
|
display: "flex",
|
|
499
513
|
flexDirection: "column",
|
|
500
514
|
height: "100%",
|
|
501
515
|
backgroundColor: h,
|
|
502
516
|
overflowY: _ ? void 0 : "auto",
|
|
503
|
-
touchAction:
|
|
504
|
-
...
|
|
517
|
+
touchAction: me === "x" ? "pan-y" : me === "y" ? "pan-x" : "auto",
|
|
518
|
+
...Ie,
|
|
505
519
|
...v.style
|
|
506
520
|
},
|
|
507
521
|
children: [
|
|
508
|
-
!d && t && /* @__PURE__ */
|
|
522
|
+
!d && t && /* @__PURE__ */ R("div", {
|
|
509
523
|
style: { minHeight: t },
|
|
510
|
-
children: /* @__PURE__ */
|
|
524
|
+
children: /* @__PURE__ */ R("div", { style: {
|
|
511
525
|
position: T,
|
|
512
526
|
top: 0,
|
|
513
527
|
width: "100%",
|
|
@@ -515,12 +529,12 @@ function Ve({ children: e, statusBarHeight: t, statusBarColor: n, systemNavigati
|
|
|
515
529
|
backgroundColor: n
|
|
516
530
|
} })
|
|
517
531
|
}),
|
|
518
|
-
a && /* @__PURE__ */
|
|
532
|
+
a && /* @__PURE__ */ R("div", { style: {
|
|
519
533
|
width: "100%",
|
|
520
|
-
minHeight:
|
|
534
|
+
minHeight: ye
|
|
521
535
|
} }),
|
|
522
536
|
c,
|
|
523
|
-
/* @__PURE__ */
|
|
537
|
+
/* @__PURE__ */ R("div", {
|
|
524
538
|
style: {
|
|
525
539
|
display: "flex",
|
|
526
540
|
flexDirection: "column",
|
|
@@ -531,23 +545,23 @@ function Ve({ children: e, statusBarHeight: t, statusBarColor: n, systemNavigati
|
|
|
531
545
|
willChange: "transform"
|
|
532
546
|
} : null
|
|
533
547
|
},
|
|
534
|
-
children: /* @__PURE__ */
|
|
535
|
-
value:
|
|
548
|
+
children: /* @__PURE__ */ R(Pe.Provider, {
|
|
549
|
+
value: xe,
|
|
536
550
|
children: e
|
|
537
551
|
})
|
|
538
552
|
}),
|
|
539
553
|
l,
|
|
540
|
-
s && /* @__PURE__ */
|
|
541
|
-
display:
|
|
554
|
+
s && /* @__PURE__ */ R("div", { style: {
|
|
555
|
+
display: L ? "none" : void 0,
|
|
542
556
|
width: "100%",
|
|
543
|
-
minHeight:
|
|
557
|
+
minHeight: be
|
|
544
558
|
} }),
|
|
545
|
-
!m && r && /* @__PURE__ */
|
|
559
|
+
!m && r && /* @__PURE__ */ R("div", {
|
|
546
560
|
style: {
|
|
547
|
-
display:
|
|
561
|
+
display: L ? "none" : void 0,
|
|
548
562
|
minHeight: r
|
|
549
563
|
},
|
|
550
|
-
children: /* @__PURE__ */
|
|
564
|
+
children: /* @__PURE__ */ R("div", { style: {
|
|
551
565
|
position: T,
|
|
552
566
|
bottom: 0,
|
|
553
567
|
width: "100%",
|
|
@@ -555,20 +569,20 @@ function Ve({ children: e, statusBarHeight: t, statusBarColor: n, systemNavigati
|
|
|
555
569
|
backgroundColor: i
|
|
556
570
|
} })
|
|
557
571
|
}),
|
|
558
|
-
/* @__PURE__ */
|
|
572
|
+
/* @__PURE__ */ R("div", {
|
|
559
573
|
ref: Se,
|
|
560
574
|
"data-flemo-layer-mount": !0
|
|
561
575
|
})
|
|
562
576
|
]
|
|
563
577
|
}),
|
|
564
|
-
a && /* @__PURE__ */
|
|
565
|
-
ref:
|
|
578
|
+
a && /* @__PURE__ */ R("div", {
|
|
579
|
+
ref: G,
|
|
566
580
|
"data-flemo-bar": "app",
|
|
567
|
-
"data-flemo-bar-transition":
|
|
581
|
+
"data-flemo-bar-transition": S,
|
|
568
582
|
"data-flemo-bar-status": D,
|
|
569
583
|
"data-flemo-bar-active": b ? "true" : "false",
|
|
570
|
-
"data-flemo-bar-riding":
|
|
571
|
-
"data-flemo-anim-hold": Z
|
|
584
|
+
"data-flemo-bar-riding": Ae ? "true" : "false",
|
|
585
|
+
"data-flemo-anim-hold": Z,
|
|
572
586
|
style: {
|
|
573
587
|
position: T,
|
|
574
588
|
top: d ? 0 : t,
|
|
@@ -578,16 +592,16 @@ function Ve({ children: e, statusBarHeight: t, statusBarColor: n, systemNavigati
|
|
|
578
592
|
},
|
|
579
593
|
children: a
|
|
580
594
|
}),
|
|
581
|
-
s && /* @__PURE__ */
|
|
582
|
-
ref:
|
|
595
|
+
s && /* @__PURE__ */ R("div", {
|
|
596
|
+
ref: q,
|
|
583
597
|
"data-flemo-bar": "nav",
|
|
584
|
-
"data-flemo-bar-transition":
|
|
598
|
+
"data-flemo-bar-transition": S,
|
|
585
599
|
"data-flemo-bar-status": D,
|
|
586
600
|
"data-flemo-bar-active": b ? "true" : "false",
|
|
587
|
-
"data-flemo-bar-riding":
|
|
588
|
-
"data-flemo-anim-hold": Z
|
|
601
|
+
"data-flemo-bar-riding": je ? "true" : "false",
|
|
602
|
+
"data-flemo-anim-hold": Z,
|
|
589
603
|
style: {
|
|
590
|
-
display:
|
|
604
|
+
display: L ? "none" : void 0,
|
|
591
605
|
position: T,
|
|
592
606
|
bottom: m ? 0 : r,
|
|
593
607
|
left: 0,
|
|
@@ -596,11 +610,11 @@ function Ve({ children: e, statusBarHeight: t, statusBarColor: n, systemNavigati
|
|
|
596
610
|
},
|
|
597
611
|
children: s
|
|
598
612
|
}),
|
|
599
|
-
|
|
600
|
-
ref:
|
|
601
|
-
"data-flemo-anim-hold": Z
|
|
613
|
+
F && /* @__PURE__ */ R(Ve, {
|
|
614
|
+
ref: W,
|
|
615
|
+
"data-flemo-anim-hold": Z
|
|
602
616
|
}),
|
|
603
|
-
/* @__PURE__ */
|
|
617
|
+
/* @__PURE__ */ R("div", {
|
|
604
618
|
"data-swipe-at-edge-bar": !0,
|
|
605
619
|
style: {
|
|
606
620
|
position: T,
|
|
@@ -616,19 +630,19 @@ function Ve({ children: e, statusBarHeight: t, statusBarColor: n, systemNavigati
|
|
|
616
630
|
}
|
|
617
631
|
//#endregion
|
|
618
632
|
//#region src/screen/Screen.tsx
|
|
619
|
-
function
|
|
620
|
-
let { isActive: n, isPrev: r, zIndex: i } =
|
|
621
|
-
return /* @__PURE__ */
|
|
633
|
+
function We({ children: e, ...t }) {
|
|
634
|
+
let { isActive: n, isPrev: r, zIndex: i } = H();
|
|
635
|
+
return /* @__PURE__ */ R(Be, {
|
|
622
636
|
freeze: _({
|
|
623
637
|
isActive: n,
|
|
624
638
|
isPrev: r,
|
|
625
639
|
zIndex: i,
|
|
626
|
-
index:
|
|
640
|
+
index: K((e) => e.index),
|
|
627
641
|
status: Q((e) => e.status),
|
|
628
642
|
dragStatus: $((e) => e.dragStatus),
|
|
629
643
|
replaceTransitionStatus: $((e) => e.replaceTransitionStatus)
|
|
630
644
|
}),
|
|
631
|
-
children: /* @__PURE__ */
|
|
645
|
+
children: /* @__PURE__ */ R(Ue, {
|
|
632
646
|
...t,
|
|
633
647
|
children: e
|
|
634
648
|
})
|
|
@@ -636,9 +650,9 @@ function He({ children: e, ...t }) {
|
|
|
636
650
|
}
|
|
637
651
|
//#endregion
|
|
638
652
|
//#region src/screen/Part.tsx
|
|
639
|
-
function
|
|
640
|
-
let { isActive: a } =
|
|
641
|
-
return /* @__PURE__ */
|
|
653
|
+
function Ge({ ref: e, name: t, style: n, children: r, ...i }) {
|
|
654
|
+
let { isActive: a } = H();
|
|
655
|
+
return /* @__PURE__ */ R("div", {
|
|
642
656
|
ref: e,
|
|
643
657
|
"data-flemo-part-name": t,
|
|
644
658
|
"data-flemo-status": Q((e) => e.status),
|
|
@@ -650,20 +664,20 @@ function Ue({ ref: e, name: t, style: n, children: r, ...i }) {
|
|
|
650
664
|
}
|
|
651
665
|
//#endregion
|
|
652
666
|
//#region src/stores/RouterScopeProvider.tsx
|
|
653
|
-
function
|
|
667
|
+
function Ke({ children: e }) {
|
|
654
668
|
let [t] = p(() => ({
|
|
655
|
-
history:
|
|
656
|
-
navigate:
|
|
657
|
-
transition:
|
|
658
|
-
screen:
|
|
669
|
+
history: te(),
|
|
670
|
+
navigate: C(),
|
|
671
|
+
transition: ie(),
|
|
672
|
+
screen: A(),
|
|
659
673
|
driver: b(),
|
|
660
|
-
markSelfInduced:
|
|
674
|
+
markSelfInduced: P,
|
|
661
675
|
consume: v
|
|
662
676
|
}));
|
|
663
|
-
return /* @__PURE__ */
|
|
677
|
+
return /* @__PURE__ */ R(z.Provider, {
|
|
664
678
|
value: t,
|
|
665
679
|
children: e
|
|
666
680
|
});
|
|
667
681
|
}
|
|
668
682
|
//#endregion
|
|
669
|
-
export {
|
|
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.
|
|
39
|
+
"@flemo/core": "1.10.1"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@testing-library/jest-dom": "^6.9.1",
|