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