@flemo/react 1.4.2 → 1.5.0
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/README.md +4 -3
- package/dist/Router.d.ts +7 -3
- package/dist/RouterDepthContext.d.ts +2 -0
- package/dist/Slot.d.ts +7 -0
- package/dist/__tests__/Router.test.d.ts +1 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.mjs +417 -294
- package/dist/navigate/__tests__/usePathname.test.d.ts +1 -0
- package/dist/navigate/usePathname.d.ts +1 -0
- package/dist/navigate/useStep.d.ts +6 -3
- package/dist/screen/Layer.d.ts +3 -0
- package/dist/screen/LayerMountContext.d.ts +2 -0
- package/dist/screen/Screen.d.ts +4 -4
- package/dist/screen/ScreenMotion.d.ts +1 -1
- package/dist/screen/ScreenViewportContext.d.ts +6 -0
- package/dist/screen/__tests__/Layer.test.d.ts +1 -0
- package/dist/stores/StoreContext.d.ts +4 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
<h1>flemo</h1>
|
|
5
5
|
|
|
6
|
-
**Native-like screen transitions for
|
|
6
|
+
**Native-like screen transitions for the web**
|
|
7
7
|
|
|
8
8
|
[](https://www.npmjs.com/package/@flemo/react)
|
|
9
9
|
[](https://opensource.org/licenses/MIT)
|
|
@@ -12,9 +12,10 @@
|
|
|
12
12
|
|
|
13
13
|
---
|
|
14
14
|
|
|
15
|
-
flemo is a
|
|
15
|
+
flemo is a router whose unit of routing is a **screen**, not a page. Push, pop, and the
|
|
16
16
|
animations and gestures between screens are handled by flemo, so you don't need to wire a
|
|
17
|
-
router and a motion library together yourself.
|
|
17
|
+
router and a motion library together yourself. `@flemo/react` is the React binding (the
|
|
18
|
+
framework-agnostic core lives in `@flemo/core`).
|
|
18
19
|
|
|
19
20
|
## Install
|
|
20
21
|
|
package/dist/Router.d.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import { PropsWithChildren } from 'react';
|
|
2
|
-
import { PartTransition, Decorator, Transition, TransitionName } from '@flemo/core';
|
|
1
|
+
import { CSSProperties, PropsWithChildren } from 'react';
|
|
2
|
+
import { HistoryDriver, PartTransition, Decorator, Transition, TransitionName } from '@flemo/core';
|
|
3
3
|
interface RouterProps {
|
|
4
4
|
initPath?: string;
|
|
5
5
|
defaultTransitionName?: TransitionName;
|
|
6
6
|
transitions?: Transition[];
|
|
7
7
|
decorators?: Decorator[];
|
|
8
8
|
partTransitions?: PartTransition[];
|
|
9
|
+
history?: "browser" | "memory";
|
|
10
|
+
createDriver?: (routerKey?: string) => HistoryDriver;
|
|
11
|
+
className?: string;
|
|
12
|
+
style?: CSSProperties;
|
|
9
13
|
}
|
|
10
|
-
declare function Router({ children, initPath, defaultTransitionName, transitions, decorators, partTransitions }: PropsWithChildren<RouterProps>): import("react").JSX.Element;
|
|
14
|
+
declare function Router({ children, initPath, defaultTransitionName, transitions, decorators, partTransitions, history, createDriver, className, style }: PropsWithChildren<RouterProps>): import("react").JSX.Element;
|
|
11
15
|
export default Router;
|
package/dist/Slot.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CSSProperties, PropsWithChildren } from 'react';
|
|
2
|
+
export interface SlotProps {
|
|
3
|
+
className?: string;
|
|
4
|
+
style?: CSSProperties;
|
|
5
|
+
}
|
|
6
|
+
declare function Slot({ children, className, style }: PropsWithChildren<SlotProps>): import("react").JSX.Element;
|
|
7
|
+
export default Slot;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
export { default as Router } from './Router';
|
|
2
2
|
export { default as Route, type RegisterRoute } from './Route';
|
|
3
|
+
export { default as Slot, type SlotProps } from './Slot';
|
|
4
|
+
export { default as Layer } from './screen/Layer';
|
|
3
5
|
export { default as useNavigate } from './navigate/useNavigate';
|
|
6
|
+
export { default as usePathname } from './navigate/usePathname';
|
|
4
7
|
export { default as useStep } from './navigate/useStep';
|
|
5
8
|
export { default as useScreen } from './screen/useScreen';
|
|
6
9
|
export { default as useParams } from './screen/ParamsProvider/useParams';
|
|
@@ -18,5 +21,5 @@ export { default as RouterScopeProvider } from './stores/RouterScopeProvider';
|
|
|
18
21
|
export { type FlemoStores } from './stores/StoreContext';
|
|
19
22
|
export { type SharedBarPresence } from './screen/store';
|
|
20
23
|
export { default as useViewportScrollHeight } from './screen/useViewportScrollHeight';
|
|
21
|
-
export { createTransition, createRawTransition, createDecorator, createRawDecorator, createPartTransition, createRawPartTransition, partTransitionMap } from '@flemo/core';
|
|
22
|
-
export type { TransitionName, RegisterTransition, DecoratorName, RegisterDecorator, PartTransitionName, RegisterPartTransition, PartTransitionOptions } from '@flemo/core';
|
|
24
|
+
export { createTransition, createRawTransition, createDecorator, createRawDecorator, createPartTransition, createRawPartTransition, partTransitionMap, createBrowserHistoryDriver } from '@flemo/core';
|
|
25
|
+
export type { TransitionName, RegisterTransition, DecoratorName, RegisterDecorator, PartTransitionName, RegisterPartTransition, PartTransitionOptions, HistoryDriver, HistoryNavEvent } from '@flemo/core';
|
package/dist/index.mjs
CHANGED
|
@@ -1,24 +1,29 @@
|
|
|
1
|
-
import e, {
|
|
2
|
-
import { TaskManger as
|
|
3
|
-
import { jsx as
|
|
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 { TaskManger as m, applyTransitionStyles as h, computeScreenFreeze as g, consumeSelfInducedPop as _, createBrowserHistoryDriver as v, createBrowserHistoryDriver as y, createDecorator as b, createHistoryStore as ee, createHistorySync as x, createMemoryHistoryDriver as te, createNavigateStore as ne, createNavigationController as S, createPartTransition as C, createRawDecorator as w, createRawPartTransition as T, createRawTransition as E, createScreenSelector as re, createScreenStore as D, createSelfPopGuard as ie, createSwipeController as O, createTransition as k, createTransitionEngine as A, createTransitionStore as j, decoratorMap as M, driveBarRiding as N, ensureWindowHistoryState as P, getMatchedPathPattern as F, isServer as ae, markSelfInducedPop as I, partTransitionMap as L, partTransitionMap as R, seedInitialHistory as oe, transitionMap as z } from "@flemo/core";
|
|
3
|
+
import { jsx as B, jsxs as se } from "react/jsx-runtime";
|
|
4
|
+
import { createPortal as ce } from "react-dom";
|
|
4
5
|
//#region \0rolldown/runtime.js
|
|
5
|
-
var
|
|
6
|
+
var le = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), V = r(null);
|
|
6
7
|
//#endregion
|
|
7
8
|
//#region src/stores/useStores.ts
|
|
8
|
-
function
|
|
9
|
-
let e =
|
|
9
|
+
function H() {
|
|
10
|
+
let e = a(V);
|
|
10
11
|
if (!e) throw Error("flemo stores are missing. Render inside a <Router>.");
|
|
11
12
|
return e;
|
|
12
13
|
}
|
|
13
14
|
//#endregion
|
|
14
15
|
//#region src/history/HistoryListener.tsx
|
|
15
|
-
function
|
|
16
|
-
let e =
|
|
17
|
-
return
|
|
16
|
+
function ue() {
|
|
17
|
+
let e = H();
|
|
18
|
+
return o(() => x({
|
|
19
|
+
stores: e,
|
|
20
|
+
driver: e.driver,
|
|
21
|
+
consume: e.consume
|
|
22
|
+
}), [e]), null;
|
|
18
23
|
}
|
|
19
24
|
//#endregion
|
|
20
25
|
//#region src/screen/ScreenContext.ts
|
|
21
|
-
var
|
|
26
|
+
var de = (/* @__PURE__ */ le(((e) => {
|
|
22
27
|
Object.defineProperty(e, "__esModule", { value: !0 }), e.PathError = e.TokenData = void 0, e.parse = c, e.compile = l, e.pathToRegexp = f;
|
|
23
28
|
var t = "/", n = (e) => e, r = /^[$_\p{ID_Start}]$/u, i = /^[$\u200c\u200d\p{ID_Continue}]$/u;
|
|
24
29
|
function a(e) {
|
|
@@ -205,7 +210,7 @@ var I = (/* @__PURE__ */ ce(((e) => {
|
|
|
205
210
|
function h(e, t) {
|
|
206
211
|
return t.length > e.length ? h(t, e) : (e === t && (t = ""), t.length > 1 ? `(?:(?!${a(e)}|${a(t)})[^])` : e.length > 1 ? `(?:(?!${a(e)})[^${a(t)}])` : `[^${a(e + t)}]`);
|
|
207
212
|
}
|
|
208
|
-
})))(),
|
|
213
|
+
})))(), U = r({
|
|
209
214
|
id: "",
|
|
210
215
|
isActive: !1,
|
|
211
216
|
isRoot: !0,
|
|
@@ -220,15 +225,15 @@ var I = (/* @__PURE__ */ ce(((e) => {
|
|
|
220
225
|
});
|
|
221
226
|
//#endregion
|
|
222
227
|
//#region src/screen/useScreen.ts
|
|
223
|
-
function
|
|
224
|
-
return
|
|
228
|
+
function W() {
|
|
229
|
+
return a(U);
|
|
225
230
|
}
|
|
226
231
|
//#endregion
|
|
227
232
|
//#region src/screen/ParamsProvider/ParamsContext.ts
|
|
228
|
-
var
|
|
233
|
+
var G = r({}), K = r(() => {});
|
|
229
234
|
//#endregion
|
|
230
235
|
//#region src/screen/ParamsProvider/ParamsReducer.ts
|
|
231
|
-
function
|
|
236
|
+
function q(e, t) {
|
|
232
237
|
switch (t.type) {
|
|
233
238
|
case "SET": return t.params;
|
|
234
239
|
default: return e;
|
|
@@ -236,67 +241,75 @@ function ue(e, t) {
|
|
|
236
241
|
}
|
|
237
242
|
//#endregion
|
|
238
243
|
//#region src/screen/ParamsProvider/ParamsProvider.tsx
|
|
239
|
-
function
|
|
240
|
-
let { isActive: t, params: n } =
|
|
241
|
-
return
|
|
242
|
-
|
|
243
|
-
|
|
244
|
+
function J({ children: e }) {
|
|
245
|
+
let { isActive: t, params: n } = W(), { driver: r } = H(), [i, a] = d(q, n);
|
|
246
|
+
return o(() => {
|
|
247
|
+
if (t) return r.subscribe((e) => {
|
|
248
|
+
let t = e.state;
|
|
249
|
+
t?.step && m.addTask(async () => {
|
|
244
250
|
a({
|
|
245
251
|
type: "SET",
|
|
246
|
-
params:
|
|
252
|
+
params: t.params ?? {}
|
|
247
253
|
});
|
|
248
254
|
});
|
|
249
|
-
};
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
255
|
+
});
|
|
256
|
+
}, [
|
|
257
|
+
t,
|
|
258
|
+
a,
|
|
259
|
+
r
|
|
260
|
+
]), /* @__PURE__ */ B(K.Provider, {
|
|
254
261
|
value: a,
|
|
255
|
-
children: /* @__PURE__ */
|
|
256
|
-
value:
|
|
262
|
+
children: /* @__PURE__ */ B(G.Provider, {
|
|
263
|
+
value: i,
|
|
257
264
|
children: e
|
|
258
265
|
})
|
|
259
266
|
});
|
|
260
267
|
}
|
|
261
268
|
//#endregion
|
|
262
269
|
//#region ../../node_modules/.pnpm/zustand@5.0.14_@types+react@19.2.17_react@19.2.7/node_modules/zustand/esm/react.mjs
|
|
263
|
-
var
|
|
264
|
-
function
|
|
270
|
+
var Y = (e) => e;
|
|
271
|
+
function X(t, n = Y) {
|
|
265
272
|
let r = e.useSyncExternalStore(t.subscribe, e.useCallback(() => n(t.getState()), [t, n]), e.useCallback(() => n(t.getInitialState()), [t, n]));
|
|
266
273
|
return e.useDebugValue(r), r;
|
|
267
274
|
}
|
|
268
275
|
//#endregion
|
|
269
276
|
//#region src/stores/useHistoryStore.ts
|
|
270
|
-
function
|
|
271
|
-
return H(
|
|
277
|
+
function Z(e) {
|
|
278
|
+
return X(H().history, e);
|
|
272
279
|
}
|
|
273
280
|
//#endregion
|
|
274
281
|
//#region src/renderer/Renderer.tsx
|
|
275
|
-
function
|
|
276
|
-
let
|
|
277
|
-
return
|
|
278
|
-
let [r] =
|
|
279
|
-
return /* @__PURE__ */
|
|
282
|
+
function Q({ children: e }) {
|
|
283
|
+
let t = Z((e) => e.index);
|
|
284
|
+
return re(Z((e) => e.histories), t).map((t) => {
|
|
285
|
+
let [r] = n.toArray(e).filter((e) => (0, de.pathToRegexp)(e.props.path).regexp.test(t.pathname));
|
|
286
|
+
return /* @__PURE__ */ B(U.Provider, {
|
|
280
287
|
value: {
|
|
281
|
-
...
|
|
282
|
-
routePath:
|
|
288
|
+
...t,
|
|
289
|
+
routePath: F(r.props.path, t.pathname)
|
|
283
290
|
},
|
|
284
|
-
children: /* @__PURE__ */
|
|
285
|
-
},
|
|
291
|
+
children: /* @__PURE__ */ B(J, { children: r })
|
|
292
|
+
}, t.id);
|
|
286
293
|
});
|
|
287
294
|
}
|
|
288
295
|
//#endregion
|
|
296
|
+
//#region src/screen/ScreenViewportContext.ts
|
|
297
|
+
var fe = r({ contained: !1 });
|
|
298
|
+
function pe() {
|
|
299
|
+
return a(fe);
|
|
300
|
+
}
|
|
301
|
+
//#endregion
|
|
289
302
|
//#region src/transition/styles.ts
|
|
290
|
-
function
|
|
291
|
-
|
|
292
|
-
for (let t of e)
|
|
293
|
-
for (let e of t)
|
|
294
|
-
for (let e of n)
|
|
295
|
-
return
|
|
296
|
-
for (let t of e)
|
|
297
|
-
for (let e of t)
|
|
298
|
-
for (let e of n)
|
|
299
|
-
|
|
303
|
+
function me(e, t, n = []) {
|
|
304
|
+
l(() => {
|
|
305
|
+
for (let t of e) z.set(t.name, t);
|
|
306
|
+
for (let e of t) M.set(e.name, e);
|
|
307
|
+
for (let e of n) R.set(e.name, e);
|
|
308
|
+
return h(), () => {
|
|
309
|
+
for (let t of e) z.delete(t.name);
|
|
310
|
+
for (let e of t) M.delete(e.name);
|
|
311
|
+
for (let e of n) R.delete(e.name);
|
|
312
|
+
h();
|
|
300
313
|
};
|
|
301
314
|
}, [
|
|
302
315
|
e,
|
|
@@ -305,37 +318,121 @@ function G(e, t, n = []) {
|
|
|
305
318
|
]);
|
|
306
319
|
}
|
|
307
320
|
//#endregion
|
|
321
|
+
//#region src/RouterDepthContext.ts
|
|
322
|
+
var he = r(0), ge = { contained: !0 };
|
|
323
|
+
function _e({ children: e, className: t, style: n }) {
|
|
324
|
+
return /* @__PURE__ */ B("div", {
|
|
325
|
+
className: t,
|
|
326
|
+
style: {
|
|
327
|
+
position: "relative",
|
|
328
|
+
overflow: "hidden",
|
|
329
|
+
...n
|
|
330
|
+
},
|
|
331
|
+
children: /* @__PURE__ */ B(fe.Provider, {
|
|
332
|
+
value: ge,
|
|
333
|
+
children: /* @__PURE__ */ B(Q, { children: e })
|
|
334
|
+
})
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
//#endregion
|
|
308
338
|
//#region src/Router.tsx
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
339
|
+
function ve(e) {
|
|
340
|
+
let t = null;
|
|
341
|
+
return n.forEach(e, (e) => {
|
|
342
|
+
if (t || !i(e)) return;
|
|
343
|
+
if (e.type === _e) {
|
|
344
|
+
t = n.toArray(e.props.children).filter(i);
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
let r = e.props.children;
|
|
348
|
+
if (r) {
|
|
349
|
+
let e = ve(r);
|
|
350
|
+
e && (t = e);
|
|
351
|
+
}
|
|
352
|
+
}), t;
|
|
353
|
+
}
|
|
354
|
+
var ye = {
|
|
355
|
+
mark: () => {},
|
|
356
|
+
consume: () => !1
|
|
357
|
+
}, be = [], xe = [], Se = [], Ce = { contained: !0 };
|
|
358
|
+
function we({ children: e, initPath: t = "/", defaultTransitionName: r = "cupertino", transitions: i = be, decorators: c = xe, partTransitions: l = Se, history: u = "browser", createDriver: d, className: f, style: m }) {
|
|
359
|
+
let h = a(he), g = h > 0, _ = u === "memory", v = s(), b = ve(e), x = b !== null, S = a(V), C = g ? null : S, w = C !== null, T = d ?? y, [E] = p(() => _ ? null : T(w ? void 0 : v)), re = !g && !_ && !ae(), O = re && E ? E.readPathname() : t || "/", k = O.indexOf("?"), A = (k >= 0 ? O.slice(0, k) : O) || "/", M = re ? window.location.search : k >= 0 ? O.slice(k) : "", [N] = p(() => {
|
|
360
|
+
let t = oe((b ?? n.toArray(e)).map((e) => e.props.path).flat(), A, M, r);
|
|
361
|
+
if (C) return C.history.getState().index === -1 && C.history.setState({
|
|
314
362
|
index: 0,
|
|
315
|
-
histories: [
|
|
316
|
-
}),
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
363
|
+
histories: [t]
|
|
364
|
+
}), C;
|
|
365
|
+
let i = _ ? te({
|
|
366
|
+
state: {
|
|
367
|
+
id: t.id,
|
|
368
|
+
index: 0,
|
|
369
|
+
status: "IDLE",
|
|
370
|
+
params: t.params,
|
|
371
|
+
transitionName: t.transitionName,
|
|
372
|
+
layoutId: t.layoutId
|
|
373
|
+
},
|
|
374
|
+
url: t.pathname
|
|
375
|
+
}) : E, a = _ ? ye : ie();
|
|
376
|
+
return {
|
|
377
|
+
history: ee([t], 0),
|
|
378
|
+
navigate: ne(),
|
|
379
|
+
transition: j(r),
|
|
380
|
+
screen: D(),
|
|
381
|
+
driver: i,
|
|
382
|
+
markSelfInduced: a.mark,
|
|
383
|
+
consume: a.consume
|
|
321
384
|
};
|
|
322
385
|
});
|
|
323
|
-
|
|
324
|
-
E(
|
|
325
|
-
}, [
|
|
326
|
-
|
|
327
|
-
|
|
386
|
+
N.transition.setState({ defaultTransitionName: r }), me(i, c, l), o(() => {
|
|
387
|
+
_ || ae() || (P(w ? null : v, r, N.history.getState().histories[0]?.params ?? {}), g && !w && E && E.readPathname() !== A && E.replaceState(E.readState(), A));
|
|
388
|
+
}, [
|
|
389
|
+
_,
|
|
390
|
+
w,
|
|
391
|
+
g,
|
|
392
|
+
v,
|
|
393
|
+
A,
|
|
394
|
+
r,
|
|
395
|
+
N.history,
|
|
396
|
+
E
|
|
397
|
+
]);
|
|
398
|
+
let F = x ? e : /* @__PURE__ */ B(Q, { children: e }), I = /* @__PURE__ */ B(he.Provider, {
|
|
399
|
+
value: h + 1,
|
|
400
|
+
children: /* @__PURE__ */ se(V.Provider, {
|
|
401
|
+
value: N,
|
|
402
|
+
children: [!_ && /* @__PURE__ */ B(ue, {}), g ? /* @__PURE__ */ B(fe.Provider, {
|
|
403
|
+
value: Ce,
|
|
404
|
+
children: F
|
|
405
|
+
}) : F]
|
|
406
|
+
})
|
|
328
407
|
});
|
|
408
|
+
return g ? /* @__PURE__ */ B("div", {
|
|
409
|
+
className: f,
|
|
410
|
+
style: {
|
|
411
|
+
position: "relative",
|
|
412
|
+
overflow: "hidden",
|
|
413
|
+
...m
|
|
414
|
+
},
|
|
415
|
+
children: I
|
|
416
|
+
}) : I;
|
|
329
417
|
}
|
|
330
418
|
//#endregion
|
|
331
419
|
//#region src/Route.tsx
|
|
332
|
-
function
|
|
420
|
+
function Te({ element: e }) {
|
|
333
421
|
return e;
|
|
334
422
|
}
|
|
335
423
|
//#endregion
|
|
424
|
+
//#region src/screen/LayerMountContext.ts
|
|
425
|
+
var Ee = r(null);
|
|
426
|
+
//#endregion
|
|
427
|
+
//#region src/screen/Layer.tsx
|
|
428
|
+
function De({ children: e }) {
|
|
429
|
+
let t = a(Ee);
|
|
430
|
+
return t ? ce(e, t) : e;
|
|
431
|
+
}
|
|
432
|
+
//#endregion
|
|
336
433
|
//#region src/utils/buildRoutePath.ts
|
|
337
|
-
function
|
|
338
|
-
let n = t ?? {}, r = (0,
|
|
434
|
+
function Oe(e, t) {
|
|
435
|
+
let n = t ?? {}, r = (0, de.compile)(e)(Object.fromEntries(Object.entries(n).map(([e, t]) => [e, String(t)]))), i = (typeof e == "string" ? (0, de.parse)(e) : e).tokens.filter((e) => e.type === "param").map((e) => e.name), a = Object.fromEntries(Object.entries(n).filter(([e]) => !i.includes(e))), o = new URLSearchParams(a).toString();
|
|
339
436
|
return {
|
|
340
437
|
pathname: `${r}${o ? `?${o}` : ""}`,
|
|
341
438
|
toPathname: r
|
|
@@ -343,73 +440,90 @@ function X(e, t) {
|
|
|
343
440
|
}
|
|
344
441
|
//#endregion
|
|
345
442
|
//#region src/navigate/useNavigate.ts
|
|
346
|
-
function
|
|
347
|
-
let e =
|
|
348
|
-
stores:
|
|
349
|
-
buildPathname: (e, t) =>
|
|
443
|
+
function ke() {
|
|
444
|
+
let e = H(), t = S({
|
|
445
|
+
stores: e,
|
|
446
|
+
buildPathname: (e, t) => Oe(e, t),
|
|
447
|
+
driver: e.driver,
|
|
448
|
+
markSelfInduced: e.markSelfInduced
|
|
350
449
|
});
|
|
351
450
|
return {
|
|
352
|
-
push: (
|
|
353
|
-
replace: (
|
|
354
|
-
pop: (
|
|
451
|
+
push: (e, n, r) => t.push(e, n ?? {}, r),
|
|
452
|
+
replace: (e, n, r) => t.replace(e, n ?? {}, r),
|
|
453
|
+
pop: (e) => t.pop(e)
|
|
355
454
|
};
|
|
356
455
|
}
|
|
357
456
|
//#endregion
|
|
457
|
+
//#region src/navigate/usePathname.ts
|
|
458
|
+
function Ae() {
|
|
459
|
+
return Z((e) => e.histories[e.pendingIndex]?.pathname ?? "/");
|
|
460
|
+
}
|
|
461
|
+
//#endregion
|
|
358
462
|
//#region src/navigate/useStep.ts
|
|
359
|
-
|
|
360
|
-
let
|
|
463
|
+
var je = (e) => {
|
|
464
|
+
let t = e;
|
|
465
|
+
return t?.step ? t.params ?? {} : null;
|
|
466
|
+
}, Me = (e, t) => {
|
|
467
|
+
let n = new URLSearchParams(Object.fromEntries(Object.entries(t).map(([e, t]) => [e, String(t)]))).toString();
|
|
468
|
+
return n ? `${e}?${n}` : e;
|
|
469
|
+
};
|
|
470
|
+
function Ne() {
|
|
471
|
+
let { routePath: e } = W(), t = H(), n = a(K), { driver: r, markSelfInduced: i } = t, [s, c] = p(null);
|
|
472
|
+
o(() => {
|
|
473
|
+
if (!e) return c(je(r.readState())), r.subscribe((e) => c(je(e.state)));
|
|
474
|
+
}, [e, r]);
|
|
475
|
+
let l = (t) => e ? Oe(e, t).pathname : Me(r.readPathname(), t), u = (t) => {
|
|
476
|
+
n({
|
|
477
|
+
type: "SET",
|
|
478
|
+
params: t
|
|
479
|
+
}), e || c(t);
|
|
480
|
+
};
|
|
361
481
|
return {
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
482
|
+
step: s,
|
|
483
|
+
pushStep: async (e) => {
|
|
484
|
+
(await m.addTask(async () => {
|
|
485
|
+
let t = l(e), n = r.readState();
|
|
486
|
+
return n?.step || r.replaceState({
|
|
487
|
+
...n,
|
|
367
488
|
step: !0
|
|
368
|
-
},
|
|
369
|
-
...
|
|
489
|
+
}, r.readPathname()), r.pushState({
|
|
490
|
+
...r.readState(),
|
|
370
491
|
step: !0,
|
|
371
|
-
params:
|
|
372
|
-
},
|
|
373
|
-
type: "SET",
|
|
374
|
-
params: t
|
|
375
|
-
});
|
|
492
|
+
params: e
|
|
493
|
+
}, t), async () => u(e);
|
|
376
494
|
})).result?.();
|
|
377
495
|
},
|
|
378
|
-
replaceStep: async (
|
|
379
|
-
(await
|
|
380
|
-
let
|
|
381
|
-
return
|
|
382
|
-
...
|
|
496
|
+
replaceStep: async (e) => {
|
|
497
|
+
(await m.addTask(async () => {
|
|
498
|
+
let t = l(e);
|
|
499
|
+
return r.replaceState({
|
|
500
|
+
...r.readState(),
|
|
383
501
|
step: !0,
|
|
384
|
-
params:
|
|
385
|
-
},
|
|
386
|
-
type: "SET",
|
|
387
|
-
params: t
|
|
388
|
-
});
|
|
502
|
+
params: e
|
|
503
|
+
}, t), async () => u(e);
|
|
389
504
|
})).result?.();
|
|
390
505
|
},
|
|
391
506
|
popStep: async () => {
|
|
392
|
-
let e =
|
|
393
|
-
(await
|
|
394
|
-
let
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
507
|
+
let e = m.generateTaskId();
|
|
508
|
+
(await m.addTask(async (n) => {
|
|
509
|
+
let a = new Promise((e) => {
|
|
510
|
+
let t = r.subscribe((n) => {
|
|
511
|
+
t(), e(n.state);
|
|
512
|
+
});
|
|
513
|
+
}), o = new Promise((e) => setTimeout(() => e(void 0), 200));
|
|
514
|
+
i(), r.back();
|
|
515
|
+
let s = await Promise.race([a, o]);
|
|
516
|
+
if (!s) {
|
|
517
|
+
n.abort();
|
|
401
518
|
return;
|
|
402
519
|
}
|
|
403
|
-
if (
|
|
404
|
-
n(
|
|
405
|
-
type: "SET",
|
|
406
|
-
params: o.params ?? {}
|
|
407
|
-
}), r.abort();
|
|
520
|
+
if (s.step) {
|
|
521
|
+
u(s.params ?? {}), n.abort();
|
|
408
522
|
return;
|
|
409
523
|
}
|
|
410
|
-
let { setStatus:
|
|
411
|
-
return
|
|
412
|
-
|
|
524
|
+
let { setStatus: c, setTransitionTaskId: l } = t.navigate.getState(), { index: d, popHistory: f } = t.history.getState();
|
|
525
|
+
return c("POPPING"), l(e), async () => {
|
|
526
|
+
f(d), c("COMPLETED");
|
|
413
527
|
};
|
|
414
528
|
}, {
|
|
415
529
|
id: e,
|
|
@@ -420,34 +534,33 @@ function pe() {
|
|
|
420
534
|
}
|
|
421
535
|
//#endregion
|
|
422
536
|
//#region src/screen/ParamsProvider/useParams.ts
|
|
423
|
-
function
|
|
424
|
-
return
|
|
537
|
+
function Pe() {
|
|
538
|
+
return a(G);
|
|
425
539
|
}
|
|
426
540
|
//#endregion
|
|
427
541
|
//#region src/screen/ScreenFreeze.tsx
|
|
428
|
-
function
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
children: n.current
|
|
542
|
+
function Fe({ freeze: e, children: n }) {
|
|
543
|
+
return /* @__PURE__ */ B(t, {
|
|
544
|
+
mode: e ? "hidden" : "visible",
|
|
545
|
+
children: n
|
|
433
546
|
});
|
|
434
547
|
}
|
|
435
548
|
//#endregion
|
|
436
549
|
//#region src/stores/useNavigateStore.ts
|
|
437
|
-
function
|
|
438
|
-
return H(
|
|
550
|
+
function $(e) {
|
|
551
|
+
return X(H().navigate, e);
|
|
439
552
|
}
|
|
440
553
|
//#endregion
|
|
441
554
|
//#region src/screen/ScreenDecorator.tsx
|
|
442
|
-
function
|
|
443
|
-
let { isActive: r, transitionName: i } =
|
|
444
|
-
|
|
445
|
-
let
|
|
446
|
-
return
|
|
447
|
-
ref:
|
|
555
|
+
function Ie({ ref: e, style: t, ...n }) {
|
|
556
|
+
let { isActive: r, transitionName: i } = W(), a = f(null);
|
|
557
|
+
c(e, () => a.current);
|
|
558
|
+
let o = $((e) => e.status), { decoratorName: s } = z.get(i) ?? z.get("none"), l = M.get(s);
|
|
559
|
+
return l ? /* @__PURE__ */ B("div", {
|
|
560
|
+
ref: a,
|
|
448
561
|
"data-flemo-decorator": !0,
|
|
449
|
-
"data-flemo-decorator-name":
|
|
450
|
-
"data-flemo-status":
|
|
562
|
+
"data-flemo-decorator-name": l.name,
|
|
563
|
+
"data-flemo-status": o,
|
|
451
564
|
"data-flemo-active": r ? "true" : "false",
|
|
452
565
|
style: {
|
|
453
566
|
position: "absolute",
|
|
@@ -464,16 +577,16 @@ function he({ ref: e, style: t, ...n }) {
|
|
|
464
577
|
}
|
|
465
578
|
//#endregion
|
|
466
579
|
//#region src/screen/useViewportScrollHeight.ts
|
|
467
|
-
var
|
|
468
|
-
function
|
|
469
|
-
let [e, t] =
|
|
470
|
-
return
|
|
580
|
+
var Le = 0;
|
|
581
|
+
function Re() {
|
|
582
|
+
let [e, t] = p(0), [n, r] = p(0);
|
|
583
|
+
return o(() => {
|
|
471
584
|
let e = 0, n = () => {
|
|
472
585
|
cancelAnimationFrame(e), e = requestAnimationFrame(() => {
|
|
473
586
|
let e = document.documentElement.scrollHeight - (window.visualViewport?.height || 0);
|
|
474
587
|
e = e < 0 ? 0 : e;
|
|
475
|
-
let n = e -
|
|
476
|
-
n = n < 0 ? 0 : n,
|
|
588
|
+
let n = e - Le;
|
|
589
|
+
n = n < 0 ? 0 : n, Le ||= e, r(n), t(e);
|
|
477
590
|
});
|
|
478
591
|
};
|
|
479
592
|
return window.visualViewport?.addEventListener("resize", n), window.visualViewport?.addEventListener("scroll", n), () => {
|
|
@@ -486,164 +599,164 @@ function _e() {
|
|
|
486
599
|
}
|
|
487
600
|
//#endregion
|
|
488
601
|
//#region src/stores/useScreenStore.ts
|
|
489
|
-
function
|
|
490
|
-
return H(
|
|
602
|
+
function ze(e) {
|
|
603
|
+
return X(H().screen, e);
|
|
491
604
|
}
|
|
492
605
|
//#endregion
|
|
493
606
|
//#region src/screen/ScreenMotion.tsx
|
|
494
|
-
function
|
|
495
|
-
let { id: v, isActive: y, isRoot: b, zIndex: ee, transitionName: x, prevTransitionName: te } =
|
|
496
|
-
|
|
497
|
-
getTransitionTaskId: () =>
|
|
607
|
+
function Be({ 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: g = !0, ..._ }) {
|
|
608
|
+
let { id: v, isActive: y, isRoot: b, zIndex: ee, transitionName: x, prevTransitionName: te } = W(), { contained: ne } = pe(), S = ne ? "absolute" : "fixed", C = H(), w = $((e) => e.status), T = ze((e) => e.dragStatus), E = C.screen.getState().setDragStatus, re = C.screen.getState().setReplaceTransitionStatus, D = Z((e) => e.index), ie = f(null);
|
|
609
|
+
ie.current ||= A({
|
|
610
|
+
getTransitionTaskId: () => C.navigate.getState().transitionTaskId,
|
|
498
611
|
setDragStatus: E,
|
|
499
|
-
setReplaceTransitionStatus:
|
|
612
|
+
setReplaceTransitionStatus: re
|
|
500
613
|
});
|
|
501
|
-
let
|
|
502
|
-
transition:
|
|
503
|
-
decorator:
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
viewportScrollHeight:
|
|
614
|
+
let k = ie.current, j = z.get(x) ?? z.get("none"), { initial: P, swipeDirection: F, decoratorName: ae } = j, I = M.get(ae), { viewportScrollHeight: L } = Re(), R = L > 0, [oe, ce] = p(0), [le, V] = p(0), [ue, de] = p(null), U = f(null), G = f(null), K = f(null), q = f(null), J = f(null), Y = f({
|
|
615
|
+
transition: j,
|
|
616
|
+
decorator: I,
|
|
617
|
+
hasSharedTopBar: !!a,
|
|
618
|
+
hasSharedBottomBar: !!s,
|
|
619
|
+
viewportScrollHeight: L,
|
|
507
620
|
isRoot: b,
|
|
508
621
|
isActive: y,
|
|
509
|
-
status:
|
|
510
|
-
dragStatus:
|
|
622
|
+
status: w,
|
|
623
|
+
dragStatus: T,
|
|
511
624
|
index: D
|
|
512
625
|
});
|
|
513
|
-
|
|
514
|
-
transition:
|
|
515
|
-
decorator:
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
viewportScrollHeight:
|
|
626
|
+
Y.current = {
|
|
627
|
+
transition: j,
|
|
628
|
+
decorator: I,
|
|
629
|
+
hasSharedTopBar: !!a,
|
|
630
|
+
hasSharedBottomBar: !!s,
|
|
631
|
+
viewportScrollHeight: L,
|
|
519
632
|
isRoot: b,
|
|
520
633
|
isActive: y,
|
|
521
|
-
status:
|
|
522
|
-
dragStatus:
|
|
634
|
+
status: w,
|
|
635
|
+
dragStatus: T,
|
|
523
636
|
index: D
|
|
524
637
|
};
|
|
525
|
-
let
|
|
526
|
-
|
|
527
|
-
getTransition: () =>
|
|
528
|
-
getDecorator: () =>
|
|
638
|
+
let X = f(null);
|
|
639
|
+
X.current ||= O({
|
|
640
|
+
getTransition: () => Y.current.transition,
|
|
641
|
+
getDecorator: () => Y.current.decorator,
|
|
529
642
|
getElements: () => ({
|
|
530
|
-
scope:
|
|
531
|
-
screenContainer:
|
|
532
|
-
decorator:
|
|
533
|
-
|
|
534
|
-
|
|
643
|
+
scope: G.current,
|
|
644
|
+
screenContainer: U.current,
|
|
645
|
+
decorator: K.current,
|
|
646
|
+
sharedTopBar: q.current,
|
|
647
|
+
sharedBottomBar: J.current
|
|
535
648
|
}),
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
getViewportScrollHeight: () =>
|
|
649
|
+
hasSharedTopBar: () => Y.current.hasSharedTopBar,
|
|
650
|
+
hasSharedBottomBar: () => Y.current.hasSharedBottomBar,
|
|
651
|
+
getViewportScrollHeight: () => Y.current.viewportScrollHeight,
|
|
539
652
|
isReadyForDrag: () => {
|
|
540
|
-
let e =
|
|
653
|
+
let e = Y.current;
|
|
541
654
|
return !e.isRoot && e.isActive && e.status === "COMPLETED" && e.dragStatus === "IDLE" && !!e.transition.swipeDirection && e.viewportScrollHeight < 10;
|
|
542
655
|
},
|
|
543
656
|
getPartnerBars: () => {
|
|
544
|
-
let e =
|
|
545
|
-
return n ?
|
|
657
|
+
let e = Y.current, t = C.history.getState().histories, n = e.isActive ? t[e.index - 1]?.id : t[e.index]?.id;
|
|
658
|
+
return n ? C.screen.getState().sharedBars[n] : void 0;
|
|
546
659
|
},
|
|
547
660
|
setDragStatus: E,
|
|
548
661
|
back: () => window.history.back()
|
|
549
662
|
});
|
|
550
|
-
let
|
|
551
|
-
|
|
552
|
-
let e =
|
|
663
|
+
let Q = X.current, fe = (e) => Q.pointerDown(e.nativeEvent), me = (e) => Q.pointerMove(e.nativeEvent), he = (e) => Q.pointerUp(e.nativeEvent);
|
|
664
|
+
o(() => {
|
|
665
|
+
let e = G.current;
|
|
553
666
|
if (!e) return;
|
|
554
667
|
let t = (e) => {
|
|
555
|
-
|
|
668
|
+
Q.shouldPreventTouch() && e.preventDefault(), e.target?.dataset.swipeAtEdgeBar === "true" && e.preventDefault();
|
|
556
669
|
};
|
|
557
670
|
return e.addEventListener("touchmove", t, { passive: !1 }), () => {
|
|
558
671
|
e.removeEventListener("touchmove", t);
|
|
559
672
|
};
|
|
560
|
-
}, [
|
|
673
|
+
}, [Q]), u(() => k.driveScreenLifecycle({
|
|
561
674
|
getElements: () => ({
|
|
562
|
-
scope:
|
|
563
|
-
decorator:
|
|
564
|
-
bars: [
|
|
675
|
+
scope: G.current,
|
|
676
|
+
decorator: K.current,
|
|
677
|
+
bars: [q.current, J.current]
|
|
565
678
|
}),
|
|
566
679
|
transitionName: x,
|
|
567
680
|
prevTransitionName: te,
|
|
568
|
-
status:
|
|
681
|
+
status: w,
|
|
569
682
|
isActive: y
|
|
570
683
|
}), [
|
|
571
|
-
|
|
572
|
-
|
|
684
|
+
k,
|
|
685
|
+
w,
|
|
573
686
|
y,
|
|
574
687
|
te,
|
|
575
688
|
x
|
|
576
|
-
]),
|
|
577
|
-
let e =
|
|
689
|
+
]), u(() => {
|
|
690
|
+
let e = q.current;
|
|
578
691
|
if (!e) {
|
|
579
|
-
|
|
692
|
+
ce(0);
|
|
580
693
|
return;
|
|
581
694
|
}
|
|
582
|
-
e.offsetHeight > 0 &&
|
|
695
|
+
e.offsetHeight > 0 && ce(e.offsetHeight);
|
|
583
696
|
let t = new ResizeObserver(([e]) => {
|
|
584
|
-
e.contentRect.height > 0 &&
|
|
697
|
+
e.contentRect.height > 0 && ce(e.contentRect.height);
|
|
585
698
|
});
|
|
586
699
|
return t.observe(e), () => {
|
|
587
700
|
t.disconnect();
|
|
588
701
|
};
|
|
589
|
-
}, [
|
|
590
|
-
let e =
|
|
702
|
+
}, [a]), u(() => {
|
|
703
|
+
let e = J.current;
|
|
591
704
|
if (!e) {
|
|
592
|
-
|
|
705
|
+
V(0);
|
|
593
706
|
return;
|
|
594
707
|
}
|
|
595
|
-
e.offsetHeight > 0 &&
|
|
708
|
+
e.offsetHeight > 0 && V(e.offsetHeight);
|
|
596
709
|
let t = new ResizeObserver(([e]) => {
|
|
597
|
-
e.contentRect.height > 0 &&
|
|
710
|
+
e.contentRect.height > 0 && V(e.contentRect.height);
|
|
598
711
|
});
|
|
599
712
|
return t.observe(e), () => {
|
|
600
713
|
t.disconnect();
|
|
601
714
|
};
|
|
602
|
-
}, [
|
|
603
|
-
let { registerSharedBars: e, unregisterSharedBars: t } =
|
|
715
|
+
}, [s]), u(() => {
|
|
716
|
+
let { registerSharedBars: e, unregisterSharedBars: t } = C.screen.getState();
|
|
604
717
|
return e(v, {
|
|
605
|
-
|
|
606
|
-
|
|
718
|
+
topBar: !!a,
|
|
719
|
+
bottomBar: !!s
|
|
607
720
|
}), () => t(v);
|
|
608
721
|
}, [
|
|
609
722
|
v,
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
723
|
+
a,
|
|
724
|
+
s,
|
|
725
|
+
C.screen
|
|
613
726
|
]);
|
|
614
|
-
let
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
navBar:
|
|
618
|
-
isTopOrTopPrev:
|
|
727
|
+
let ge = y || ee === D - 1, _e = !!a, ve = !!s;
|
|
728
|
+
u(() => N({
|
|
729
|
+
topBar: q.current,
|
|
730
|
+
navBar: J.current,
|
|
731
|
+
isTopOrTopPrev: ge,
|
|
619
732
|
isActive: y,
|
|
620
733
|
index: D,
|
|
621
|
-
|
|
622
|
-
hasNavBar:
|
|
623
|
-
getStatus: () =>
|
|
624
|
-
getHistories: () =>
|
|
625
|
-
getSharedBars: () =>
|
|
626
|
-
subscribeStatus: (e) =>
|
|
627
|
-
subscribeSharedBars: (e) =>
|
|
734
|
+
hasTopBar: _e,
|
|
735
|
+
hasNavBar: ve,
|
|
736
|
+
getStatus: () => C.navigate.getState().status,
|
|
737
|
+
getHistories: () => C.history.getState().histories,
|
|
738
|
+
getSharedBars: () => C.screen.getState().sharedBars,
|
|
739
|
+
subscribeStatus: (e) => C.navigate.subscribe(e),
|
|
740
|
+
subscribeSharedBars: (e) => C.screen.subscribe(e)
|
|
628
741
|
}), [
|
|
629
|
-
|
|
742
|
+
ge,
|
|
630
743
|
y,
|
|
631
744
|
D,
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
745
|
+
_e,
|
|
746
|
+
ve,
|
|
747
|
+
C.history,
|
|
748
|
+
C.navigate,
|
|
749
|
+
C.screen
|
|
637
750
|
]);
|
|
638
|
-
let
|
|
639
|
-
if (!y ||
|
|
751
|
+
let ye = (() => {
|
|
752
|
+
if (!y || w !== "PUSHING" && w !== "REPLACING") return {};
|
|
640
753
|
let e = {};
|
|
641
|
-
return typeof
|
|
754
|
+
return typeof P.x == "number" && (e.transform = `translateX(${P.x}px)`), typeof P.x == "string" && (e.transform = `translateX(${P.x})`), typeof P.y == "number" && (e.transform = `translateY(${P.y}px)`), typeof P.y == "string" && (e.transform = `translateY(${P.y})`), typeof P.opacity == "number" && (e.opacity = `${P.opacity}`), e;
|
|
642
755
|
})();
|
|
643
756
|
return /* @__PURE__ */ se("div", {
|
|
644
|
-
ref:
|
|
757
|
+
ref: U,
|
|
645
758
|
style: {
|
|
646
|
-
position:
|
|
759
|
+
position: S,
|
|
647
760
|
top: 0,
|
|
648
761
|
left: 0,
|
|
649
762
|
width: "100%",
|
|
@@ -655,10 +768,10 @@ function ve({ children: e, statusBarHeight: t, statusBarColor: n, systemNavigati
|
|
|
655
768
|
overscrollBehavior: "contain"
|
|
656
769
|
},
|
|
657
770
|
children: [
|
|
658
|
-
/* @__PURE__ */
|
|
771
|
+
/* @__PURE__ */ B("div", {
|
|
659
772
|
"data-swipe-at-edge-bar": !0,
|
|
660
773
|
style: {
|
|
661
|
-
position:
|
|
774
|
+
position: S,
|
|
662
775
|
top: 0,
|
|
663
776
|
left: 0,
|
|
664
777
|
width: 8,
|
|
@@ -667,15 +780,15 @@ function ve({ children: e, statusBarHeight: t, statusBarColor: n, systemNavigati
|
|
|
667
780
|
}
|
|
668
781
|
}),
|
|
669
782
|
/* @__PURE__ */ se("div", {
|
|
670
|
-
ref:
|
|
783
|
+
ref: G,
|
|
671
784
|
..._,
|
|
672
|
-
onPointerDown:
|
|
673
|
-
onPointerMove:
|
|
674
|
-
onPointerUp:
|
|
675
|
-
onPointerCancel:
|
|
785
|
+
onPointerDown: fe,
|
|
786
|
+
onPointerMove: me,
|
|
787
|
+
onPointerUp: he,
|
|
788
|
+
onPointerCancel: he,
|
|
676
789
|
"data-flemo-screen": !0,
|
|
677
790
|
"data-flemo-transition": x,
|
|
678
|
-
"data-flemo-status":
|
|
791
|
+
"data-flemo-status": w,
|
|
679
792
|
"data-flemo-active": y ? "true" : "false",
|
|
680
793
|
style: {
|
|
681
794
|
display: "flex",
|
|
@@ -683,96 +796,103 @@ function ve({ children: e, statusBarHeight: t, statusBarColor: n, systemNavigati
|
|
|
683
796
|
height: "100%",
|
|
684
797
|
backgroundColor: h,
|
|
685
798
|
overflowY: g ? void 0 : "auto",
|
|
686
|
-
touchAction:
|
|
687
|
-
...
|
|
799
|
+
touchAction: F === "x" ? "pan-y" : F === "y" ? "pan-x" : "auto",
|
|
800
|
+
...ye,
|
|
688
801
|
..._.style
|
|
689
802
|
},
|
|
690
803
|
children: [
|
|
691
|
-
!
|
|
804
|
+
!d && t && /* @__PURE__ */ B("div", {
|
|
692
805
|
style: { minHeight: t },
|
|
693
|
-
children: /* @__PURE__ */
|
|
694
|
-
position:
|
|
806
|
+
children: /* @__PURE__ */ B("div", { style: {
|
|
807
|
+
position: S,
|
|
695
808
|
top: 0,
|
|
696
809
|
width: "100%",
|
|
697
810
|
minHeight: t,
|
|
698
811
|
backgroundColor: n
|
|
699
812
|
} })
|
|
700
813
|
}),
|
|
701
|
-
|
|
814
|
+
a && /* @__PURE__ */ B("div", { style: {
|
|
702
815
|
width: "100%",
|
|
703
|
-
minHeight:
|
|
816
|
+
minHeight: oe
|
|
704
817
|
} }),
|
|
705
|
-
|
|
706
|
-
/* @__PURE__ */
|
|
818
|
+
c,
|
|
819
|
+
/* @__PURE__ */ B("div", {
|
|
707
820
|
style: {
|
|
708
821
|
display: "flex",
|
|
709
822
|
flexDirection: "column",
|
|
710
823
|
flexGrow: 1,
|
|
711
824
|
overflowY: g ? "auto" : void 0,
|
|
712
|
-
...
|
|
825
|
+
...w !== "IDLE" && w !== "COMPLETED" ? {
|
|
713
826
|
transform: "translateZ(0)",
|
|
714
827
|
willChange: "transform"
|
|
715
828
|
} : null
|
|
716
829
|
},
|
|
717
|
-
children:
|
|
830
|
+
children: /* @__PURE__ */ B(Ee.Provider, {
|
|
831
|
+
value: ue,
|
|
832
|
+
children: e
|
|
833
|
+
})
|
|
718
834
|
}),
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
display:
|
|
835
|
+
l,
|
|
836
|
+
s && /* @__PURE__ */ B("div", { style: {
|
|
837
|
+
display: R ? "none" : void 0,
|
|
722
838
|
width: "100%",
|
|
723
|
-
minHeight:
|
|
839
|
+
minHeight: le
|
|
724
840
|
} }),
|
|
725
|
-
!m && r && /* @__PURE__ */
|
|
841
|
+
!m && r && /* @__PURE__ */ B("div", {
|
|
726
842
|
style: {
|
|
727
|
-
display:
|
|
843
|
+
display: R ? "none" : void 0,
|
|
728
844
|
minHeight: r
|
|
729
845
|
},
|
|
730
|
-
children: /* @__PURE__ */
|
|
731
|
-
position:
|
|
846
|
+
children: /* @__PURE__ */ B("div", { style: {
|
|
847
|
+
position: S,
|
|
732
848
|
bottom: 0,
|
|
733
849
|
width: "100%",
|
|
734
850
|
minHeight: r,
|
|
735
|
-
backgroundColor:
|
|
851
|
+
backgroundColor: i
|
|
736
852
|
} })
|
|
853
|
+
}),
|
|
854
|
+
/* @__PURE__ */ B("div", {
|
|
855
|
+
ref: de,
|
|
856
|
+
"data-flemo-layer-mount": !0
|
|
737
857
|
})
|
|
738
858
|
]
|
|
739
859
|
}),
|
|
740
|
-
|
|
741
|
-
ref:
|
|
860
|
+
a && /* @__PURE__ */ B("div", {
|
|
861
|
+
ref: q,
|
|
742
862
|
"data-flemo-bar": "app",
|
|
743
863
|
"data-flemo-bar-transition": x,
|
|
744
|
-
"data-flemo-bar-status":
|
|
864
|
+
"data-flemo-bar-status": w,
|
|
745
865
|
"data-flemo-bar-active": y ? "true" : "false",
|
|
746
866
|
style: {
|
|
747
|
-
position:
|
|
748
|
-
top:
|
|
867
|
+
position: S,
|
|
868
|
+
top: d ? 0 : t,
|
|
749
869
|
left: 0,
|
|
750
870
|
width: "100%",
|
|
751
871
|
zIndex: 1
|
|
752
872
|
},
|
|
753
|
-
children:
|
|
873
|
+
children: a
|
|
754
874
|
}),
|
|
755
|
-
|
|
756
|
-
ref:
|
|
875
|
+
s && /* @__PURE__ */ B("div", {
|
|
876
|
+
ref: J,
|
|
757
877
|
"data-flemo-bar": "nav",
|
|
758
878
|
"data-flemo-bar-transition": x,
|
|
759
|
-
"data-flemo-bar-status":
|
|
879
|
+
"data-flemo-bar-status": w,
|
|
760
880
|
"data-flemo-bar-active": y ? "true" : "false",
|
|
761
881
|
style: {
|
|
762
|
-
display:
|
|
763
|
-
position:
|
|
882
|
+
display: R ? "none" : void 0,
|
|
883
|
+
position: S,
|
|
764
884
|
bottom: m ? 0 : r,
|
|
765
885
|
left: 0,
|
|
766
886
|
width: "100%",
|
|
767
887
|
zIndex: 1
|
|
768
888
|
},
|
|
769
|
-
children:
|
|
889
|
+
children: s
|
|
770
890
|
}),
|
|
771
|
-
|
|
772
|
-
/* @__PURE__ */
|
|
891
|
+
I && /* @__PURE__ */ B(Ie, { ref: K }),
|
|
892
|
+
/* @__PURE__ */ B("div", {
|
|
773
893
|
"data-swipe-at-edge-bar": !0,
|
|
774
894
|
style: {
|
|
775
|
-
position:
|
|
895
|
+
position: S,
|
|
776
896
|
top: 0,
|
|
777
897
|
right: 0,
|
|
778
898
|
width: 8,
|
|
@@ -785,19 +905,19 @@ function ve({ children: e, statusBarHeight: t, statusBarColor: n, systemNavigati
|
|
|
785
905
|
}
|
|
786
906
|
//#endregion
|
|
787
907
|
//#region src/screen/Screen.tsx
|
|
788
|
-
function
|
|
789
|
-
let { isActive: n, isPrev: r, zIndex: i } =
|
|
790
|
-
return /* @__PURE__ */
|
|
791
|
-
freeze:
|
|
908
|
+
function Ve({ children: e, ...t }) {
|
|
909
|
+
let { isActive: n, isPrev: r, zIndex: i } = W();
|
|
910
|
+
return /* @__PURE__ */ B(Fe, {
|
|
911
|
+
freeze: g({
|
|
792
912
|
isActive: n,
|
|
793
913
|
isPrev: r,
|
|
794
914
|
zIndex: i,
|
|
795
|
-
index:
|
|
796
|
-
status:
|
|
797
|
-
dragStatus:
|
|
798
|
-
replaceTransitionStatus:
|
|
915
|
+
index: Z((e) => e.index),
|
|
916
|
+
status: $((e) => e.status),
|
|
917
|
+
dragStatus: ze((e) => e.dragStatus),
|
|
918
|
+
replaceTransitionStatus: ze((e) => e.replaceTransitionStatus)
|
|
799
919
|
}),
|
|
800
|
-
children: /* @__PURE__ */
|
|
920
|
+
children: /* @__PURE__ */ B(Be, {
|
|
801
921
|
...t,
|
|
802
922
|
children: e
|
|
803
923
|
})
|
|
@@ -805,12 +925,12 @@ function ye({ children: e, ...t }) {
|
|
|
805
925
|
}
|
|
806
926
|
//#endregion
|
|
807
927
|
//#region src/screen/Part.tsx
|
|
808
|
-
function
|
|
809
|
-
let { isActive: a } =
|
|
810
|
-
return /* @__PURE__ */
|
|
928
|
+
function He({ ref: e, name: t, style: n, children: r, ...i }) {
|
|
929
|
+
let { isActive: a } = W();
|
|
930
|
+
return /* @__PURE__ */ B("div", {
|
|
811
931
|
ref: e,
|
|
812
932
|
"data-flemo-part-name": t,
|
|
813
|
-
"data-flemo-status":
|
|
933
|
+
"data-flemo-status": $((e) => e.status),
|
|
814
934
|
"data-flemo-active": a ? "true" : "false",
|
|
815
935
|
style: n,
|
|
816
936
|
...i,
|
|
@@ -819,17 +939,20 @@ function be({ ref: e, name: t, style: n, children: r, ...i }) {
|
|
|
819
939
|
}
|
|
820
940
|
//#endregion
|
|
821
941
|
//#region src/stores/RouterScopeProvider.tsx
|
|
822
|
-
function
|
|
823
|
-
let [t] =
|
|
824
|
-
history:
|
|
825
|
-
navigate:
|
|
826
|
-
transition:
|
|
827
|
-
screen:
|
|
942
|
+
function Ue({ children: e }) {
|
|
943
|
+
let [t] = p(() => ({
|
|
944
|
+
history: ee(),
|
|
945
|
+
navigate: ne(),
|
|
946
|
+
transition: j(),
|
|
947
|
+
screen: D(),
|
|
948
|
+
driver: y(),
|
|
949
|
+
markSelfInduced: I,
|
|
950
|
+
consume: _
|
|
828
951
|
}));
|
|
829
|
-
return /* @__PURE__ */
|
|
952
|
+
return /* @__PURE__ */ B(V.Provider, {
|
|
830
953
|
value: t,
|
|
831
954
|
children: e
|
|
832
955
|
});
|
|
833
956
|
}
|
|
834
957
|
//#endregion
|
|
835
|
-
export {
|
|
958
|
+
export { De as Layer, He as Part, Te as Route, we as Router, Ue as RouterScopeProvider, Ve as Screen, U as ScreenContext, Ie as ScreenDecorator, Fe as ScreenFreeze, Be as ScreenMotion, _e as Slot, v as createBrowserHistoryDriver, b as createDecorator, C as createPartTransition, w as createRawDecorator, T as createRawPartTransition, E as createRawTransition, k as createTransition, L as partTransitionMap, Z as useHistoryStore, ke as useNavigate, $ as useNavigateStore, Pe as useParams, Ae as usePathname, W as useScreen, ze as useScreenStore, Ne as useStep, H as useStores, Re as useViewportScrollHeight };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function usePathname(): string;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { RegisterRoute } from '../Route';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
type StepParams<T> = [T] extends [never] ? Record<string, unknown> : T extends keyof RegisterRoute ? RegisterRoute[T] : T;
|
|
3
|
+
export default function useStep<T extends keyof RegisterRoute | object = never>(): {
|
|
4
|
+
step: StepParams<T> | null;
|
|
5
|
+
pushStep: (params: StepParams<T>) => Promise<void>;
|
|
6
|
+
replaceStep: (params: StepParams<T>) => Promise<void>;
|
|
5
7
|
popStep: () => Promise<void>;
|
|
6
8
|
};
|
|
9
|
+
export {};
|
package/dist/screen/Screen.d.ts
CHANGED
|
@@ -5,10 +5,10 @@ export interface ScreenProps extends PropsWithChildren<Omit<ComponentPropsWithou
|
|
|
5
5
|
systemNavigationBarHeight?: string;
|
|
6
6
|
systemNavigationBarColor?: string;
|
|
7
7
|
backgroundColor?: string;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
sharedTopBar?: ReactNode;
|
|
9
|
+
sharedBottomBar?: ReactNode;
|
|
10
|
+
topBar?: ReactNode;
|
|
11
|
+
bottomBar?: ReactNode;
|
|
12
12
|
hideStatusBar?: boolean;
|
|
13
13
|
hideSystemNavigationBar?: boolean;
|
|
14
14
|
contentScrollable?: boolean;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ScreenProps } from './Screen';
|
|
2
|
-
declare function ScreenMotion({ children, statusBarHeight, statusBarColor, systemNavigationBarHeight, systemNavigationBarColor,
|
|
2
|
+
declare function ScreenMotion({ children, statusBarHeight, statusBarColor, systemNavigationBarHeight, systemNavigationBarColor, sharedTopBar, sharedBottomBar, topBar, bottomBar, hideStatusBar, hideSystemNavigationBar, backgroundColor, contentScrollable, ...props }: ScreenProps): import("react").JSX.Element;
|
|
3
3
|
export default ScreenMotion;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export interface ScreenViewportContextValue {
|
|
2
|
+
contained: boolean;
|
|
3
|
+
}
|
|
4
|
+
declare const ScreenViewportContext: import('react').Context<ScreenViewportContextValue>;
|
|
5
|
+
export declare function useScreenViewport(): ScreenViewportContextValue;
|
|
6
|
+
export default ScreenViewportContext;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import { HistoryStoreApi, NavigateStoreApi, TransitionStoreApi } from '@flemo/core';
|
|
1
|
+
import { HistoryDriver, HistoryStoreApi, NavigateStoreApi, TransitionStoreApi } from '@flemo/core';
|
|
2
2
|
import { ScreenStoreApi } from '../screen/store';
|
|
3
3
|
export interface FlemoStores {
|
|
4
4
|
history: HistoryStoreApi;
|
|
5
5
|
navigate: NavigateStoreApi;
|
|
6
6
|
transition: TransitionStoreApi;
|
|
7
7
|
screen: ScreenStoreApi;
|
|
8
|
+
driver: HistoryDriver;
|
|
9
|
+
markSelfInduced: () => void;
|
|
10
|
+
consume: () => boolean;
|
|
8
11
|
}
|
|
9
12
|
declare const StoreContext: import('react').Context<FlemoStores | null>;
|
|
10
13
|
export default StoreContext;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flemo/react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
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.6.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@testing-library/jest-dom": "^6.9.1",
|
|
@@ -54,8 +54,8 @@
|
|
|
54
54
|
"vite": "^8.0.16",
|
|
55
55
|
"vite-plugin-dts": "^5.0.2",
|
|
56
56
|
"vitest": "^4.1.9",
|
|
57
|
-
"@flemo/
|
|
58
|
-
"@flemo/
|
|
57
|
+
"@flemo/tsconfig": "0.0.0",
|
|
58
|
+
"@flemo/eslint-config": "0.0.0"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
61
|
"react": "^19.2.7",
|