flemo 1.3.5 → 1.3.7

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.
Files changed (2) hide show
  1. package/dist/index.mjs +159 -155
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -1,10 +1,10 @@
1
1
  import { jsx as D, jsxs as ct } from "react/jsx-runtime";
2
- import nt, { useEffect as K, createContext as dt, useContext as pt, useReducer as Ht, Children as It, Suspense as _t, useImperativeHandle as Ft, useState as mt, useRef as H, useLayoutEffect as Et } from "react";
3
- import { transform as ft, useAnimate as Lt, motion as z, useDragControls as Qt, AnimatePresence as jt, MotionConfig as qt } from "motion/react";
2
+ import nt, { useEffect as z, createContext as dt, useContext as pt, useReducer as Ht, Children as It, Suspense as _t, useImperativeHandle as jt, useState as mt, useRef as H, useLayoutEffect as Et } from "react";
3
+ import { transform as ft, useAnimate as Lt, motion as J, useDragControls as Ft, AnimatePresence as Qt, MotionConfig as qt } from "motion/react";
4
4
  var _ = {}, wt;
5
5
  function Yt() {
6
6
  if (wt) return _;
7
- wt = 1, Object.defineProperty(_, "__esModule", { value: !0 }), _.PathError = _.TokenData = void 0, _.parse = l, _.compile = m, _.match = P, _.pathToRegexp = I, _.stringify = $;
7
+ wt = 1, Object.defineProperty(_, "__esModule", { value: !0 }), _.PathError = _.TokenData = void 0, _.parse = l, _.compile = m, _.match = P, _.pathToRegexp = L, _.stringify = U;
8
8
  const n = "/", e = (i) => i, t = /^[$_\p{ID_Start}]$/u, r = /^[$\u200c\u200d\p{ID_Continue}]$/u, s = {
9
9
  // Groups.
10
10
  "{": "{",
@@ -39,7 +39,7 @@ function Yt() {
39
39
  _.PathError = h;
40
40
  function l(i, y = {}) {
41
41
  const { encodePath: g = e } = y, E = [...i], p = [];
42
- let f = 0, L = 0;
42
+ let f = 0, I = 0;
43
43
  function T() {
44
44
  let S = "";
45
45
  if (t.test(E[f]))
@@ -67,16 +67,16 @@ function Yt() {
67
67
  M ? p.push({ type: M, index: f++, value: S }) : S === "\\" ? p.push({ type: "escape", index: f++, value: E[f++] }) : S === ":" ? p.push({ type: "param", index: f++, value: T() }) : S === "*" ? p.push({ type: "wildcard", index: f++, value: T() }) : p.push({ type: "char", index: f++, value: S });
68
68
  }
69
69
  p.push({ type: "end", index: f, value: "" });
70
- function R(S) {
70
+ function O(S) {
71
71
  const M = [];
72
72
  for (; ; ) {
73
- const x = p[L++];
73
+ const x = p[I++];
74
74
  if (x.type === S)
75
75
  break;
76
76
  if (x.type === "char" || x.type === "escape") {
77
- let C = x.value, A = p[L];
78
- for (; A.type === "char" || A.type === "escape"; )
79
- C += A.value, A = p[++L];
77
+ let C = x.value, b = p[I];
78
+ for (; b.type === "char" || b.type === "escape"; )
79
+ C += b.value, b = p[++I];
80
80
  M.push({
81
81
  type: "text",
82
82
  value: g(C)
@@ -93,7 +93,7 @@ function Yt() {
93
93
  if (x.type === "{") {
94
94
  M.push({
95
95
  type: "group",
96
- tokens: R("}")
96
+ tokens: O("}")
97
97
  });
98
98
  continue;
99
99
  }
@@ -101,24 +101,24 @@ function Yt() {
101
101
  }
102
102
  return M;
103
103
  }
104
- return new c(R("end"), i);
104
+ return new c(O("end"), i);
105
105
  }
106
106
  function m(i, y = {}) {
107
107
  const { encode: g = encodeURIComponent, delimiter: E = n } = y, p = typeof i == "object" ? i : l(i, y), f = d(p.tokens, E, g);
108
108
  return function(T = {}) {
109
- const [R, ...S] = f(T);
109
+ const [O, ...S] = f(T);
110
110
  if (S.length)
111
111
  throw new TypeError(`Missing parameters: ${S.join(", ")}`);
112
- return R;
112
+ return O;
113
113
  };
114
114
  }
115
115
  function d(i, y, g) {
116
116
  const E = i.map((p) => u(p, y, g));
117
117
  return (p) => {
118
118
  const f = [""];
119
- for (const L of E) {
120
- const [T, ...R] = L(p);
121
- f[0] += T, f.push(...R);
119
+ for (const I of E) {
120
+ const [T, ...O] = I(p);
121
+ f[0] += T, f.push(...O);
122
122
  }
123
123
  return f;
124
124
  };
@@ -129,8 +129,8 @@ function Yt() {
129
129
  if (i.type === "group") {
130
130
  const p = d(i.tokens, y, g);
131
131
  return (f) => {
132
- const [L, ...T] = p(f);
133
- return T.length ? [""] : [L];
132
+ const [I, ...T] = p(f);
133
+ return T.length ? [""] : [I];
134
134
  };
135
135
  }
136
136
  const E = g || e;
@@ -141,10 +141,10 @@ function Yt() {
141
141
  if (!Array.isArray(f) || f.length === 0)
142
142
  throw new TypeError(`Expected "${i.name}" to be a non-empty array`);
143
143
  return [
144
- f.map((L, T) => {
145
- if (typeof L != "string")
144
+ f.map((I, T) => {
145
+ if (typeof I != "string")
146
146
  throw new TypeError(`Expected "${i.name}/${T}" to be a string`);
147
- return E(L);
147
+ return E(I);
148
148
  }).join(y)
149
149
  ];
150
150
  } : (p) => {
@@ -157,30 +157,30 @@ function Yt() {
157
157
  };
158
158
  }
159
159
  function P(i, y = {}) {
160
- const { decode: g = decodeURIComponent, delimiter: E = n } = y, { regexp: p, keys: f } = I(i, y), L = f.map((T) => g === !1 ? e : T.type === "param" ? g : (R) => R.split(E).map(g));
161
- return function(R) {
162
- const S = p.exec(R);
160
+ const { decode: g = decodeURIComponent, delimiter: E = n } = y, { regexp: p, keys: f } = L(i, y), I = f.map((T) => g === !1 ? e : T.type === "param" ? g : (O) => O.split(E).map(g));
161
+ return function(O) {
162
+ const S = p.exec(O);
163
163
  if (!S)
164
164
  return !1;
165
165
  const M = S[0], x = /* @__PURE__ */ Object.create(null);
166
166
  for (let C = 1; C < S.length; C++) {
167
167
  if (S[C] === void 0)
168
168
  continue;
169
- const A = f[C - 1], V = L[C - 1];
170
- x[A.name] = V(S[C]);
169
+ const b = f[C - 1], W = I[C - 1];
170
+ x[b.name] = W(S[C]);
171
171
  }
172
172
  return { path: M, params: x };
173
173
  };
174
174
  }
175
- function I(i, y = {}) {
176
- const { delimiter: g = n, end: E = !0, sensitive: p = !1, trailing: f = !0 } = y, L = [], T = p ? "" : "i", R = [];
175
+ function L(i, y = {}) {
176
+ const { delimiter: g = n, end: E = !0, sensitive: p = !1, trailing: f = !0 } = y, I = [], T = p ? "" : "i", O = [];
177
177
  for (const x of N(i, [])) {
178
178
  const C = typeof x == "object" ? x : l(x, y);
179
- for (const A of w(C.tokens, 0, []))
180
- R.push(k(A, g, L, C.originalPath));
179
+ for (const b of w(C.tokens, 0, []))
180
+ O.push(k(b, g, I, C.originalPath));
181
181
  }
182
- let S = `^(?:${R.join("|")})`;
183
- return f && (S += `(?:${o(g)}$)?`), S += E ? "$" : `(?=${o(g)}|$)`, { regexp: new RegExp(S, T), keys: L };
182
+ let S = `^(?:${O.join("|")})`;
183
+ return f && (S += `(?:${o(g)}$)?`), S += E ? "$" : `(?=${o(g)}|$)`, { regexp: new RegExp(S, T), keys: I };
184
184
  }
185
185
  function N(i, y) {
186
186
  if (Array.isArray(i))
@@ -202,28 +202,28 @@ function Yt() {
202
202
  yield* w(i, y + 1, g);
203
203
  }
204
204
  function k(i, y, g, E) {
205
- let p = "", f = "", L = !0;
205
+ let p = "", f = "", I = !0;
206
206
  for (const T of i) {
207
207
  if (T.type === "text") {
208
- p += o(T.value), f += T.value, L || (L = T.value.includes(y));
208
+ p += o(T.value), f += T.value, I || (I = T.value.includes(y));
209
209
  continue;
210
210
  }
211
211
  if (T.type === "param" || T.type === "wildcard") {
212
- if (!L && !f)
212
+ if (!I && !f)
213
213
  throw new h(`Missing text before "${T.name}" ${T.type}`, E);
214
- T.type === "param" ? p += `(${U(y, L ? "" : f)}+)` : p += "([\\s\\S]+)", g.push(T), f = "", L = !1;
214
+ T.type === "param" ? p += `(${F(y, I ? "" : f)}+)` : p += "([\\s\\S]+)", g.push(T), f = "", I = !1;
215
215
  continue;
216
216
  }
217
217
  }
218
218
  return p;
219
219
  }
220
- function U(i, y) {
220
+ function F(i, y) {
221
221
  return y.length < 2 ? i.length < 2 ? `[^${o(i + y)}]` : `(?:(?!${o(i)})[^${o(y)}])` : i.length < 2 ? `(?:(?!${o(y)})[^${o(i)}])` : `(?:(?!${o(y)}|${o(i)})[\\s\\S])`;
222
222
  }
223
- function b(i) {
223
+ function Q(i) {
224
224
  let y = "", g = 0;
225
225
  function E(p) {
226
- return tt(p) && J(i[g]) ? p : JSON.stringify(p);
226
+ return R(p) && A(i[g]) ? p : JSON.stringify(p);
227
227
  }
228
228
  for (; g < i.length; ) {
229
229
  const p = i[g++];
@@ -232,7 +232,7 @@ function Yt() {
232
232
  continue;
233
233
  }
234
234
  if (p.type === "group") {
235
- y += `{${b(p.tokens)}}`;
235
+ y += `{${Q(p.tokens)}}`;
236
236
  continue;
237
237
  }
238
238
  if (p.type === "param") {
@@ -247,21 +247,21 @@ function Yt() {
247
247
  }
248
248
  return y;
249
249
  }
250
- function $(i) {
251
- return b(i.tokens);
250
+ function U(i) {
251
+ return Q(i.tokens);
252
252
  }
253
- function tt(i) {
253
+ function R(i) {
254
254
  const [y, ...g] = i;
255
255
  return t.test(y) && g.every((E) => r.test(E));
256
256
  }
257
- function J(i) {
257
+ function A(i) {
258
258
  return i && i.type === "text" ? !r.test(i.value[0]) : !0;
259
259
  }
260
260
  return _;
261
261
  }
262
- var X = Yt();
262
+ var V = Yt();
263
263
  function Bt(n, e, t) {
264
- const r = Array.isArray(n) ? n.find((c) => X.pathToRegexp(c).regexp.test(e)) || "" : X.pathToRegexp(n).regexp.test(e) ? n : "", s = X.match(r)(e), a = new URLSearchParams(t), o = Object.fromEntries(a.entries());
264
+ const r = Array.isArray(n) ? n.find((c) => V.pathToRegexp(c).regexp.test(e)) || "" : V.pathToRegexp(n).regexp.test(e) ? n : "", s = V.match(r)(e), a = new URLSearchParams(t), o = Object.fromEntries(a.entries());
265
265
  return s ? { ...s.params, ...o } : {};
266
266
  }
267
267
  function St() {
@@ -348,7 +348,7 @@ class Xt {
348
348
  control: o,
349
349
  abortController: d
350
350
  };
351
- this.tasks.set(u.id, u), this.pendingTaskQueue.length > 0 && (this.pendingTaskQueue.push(u), await this.waitForPendingTasks(), this.pendingTaskQueue = this.pendingTaskQueue.filter((I) => I.id !== u.id));
351
+ this.tasks.set(u.id, u), this.pendingTaskQueue.length > 0 && (this.pendingTaskQueue.push(u), await this.waitForPendingTasks(), this.pendingTaskQueue = this.pendingTaskQueue.filter((L) => L.id !== u.id));
352
352
  try {
353
353
  if (!await this.acquireLock(u.id))
354
354
  throw u.status = "FAILED", new Error("FAILED");
@@ -405,8 +405,8 @@ class Xt {
405
405
  } finally {
406
406
  this.releaseLock(u.id);
407
407
  }
408
- } catch (I) {
409
- a(I);
408
+ } catch (L) {
409
+ a(L);
410
410
  }
411
411
  } catch (o) {
412
412
  a(o);
@@ -440,7 +440,7 @@ class Xt {
440
440
  await Promise.all(e.map((t) => this.resolveTask(t.id)));
441
441
  }
442
442
  }
443
- const Q = new Xt(), Pt = (n) => {
443
+ const q = new Xt(), Pt = (n) => {
444
444
  let e;
445
445
  const t = /* @__PURE__ */ new Set(), r = (l, m) => {
446
446
  const d = typeof l == "function" ? l(e) : l;
@@ -462,7 +462,7 @@ function zt(n, e = Vt) {
462
462
  const Tt = (n) => {
463
463
  const e = Kt(n), t = (r) => zt(e, r);
464
464
  return Object.assign(t, e), t;
465
- }, st = ((n) => n ? Tt(n) : Tt), j = st((n) => ({
465
+ }, st = ((n) => n ? Tt(n) : Tt), Y = st((n) => ({
466
466
  index: -1,
467
467
  histories: [],
468
468
  addHistory: (e) => n((t) => ({
@@ -477,22 +477,22 @@ const Tt = (n) => {
477
477
  index: t.index - 1,
478
478
  histories: t.histories.filter((r, s) => s !== e)
479
479
  }))
480
- })), F = st((n) => ({
480
+ })), j = st((n) => ({
481
481
  status: "IDLE",
482
482
  setStatus: (e) => n({ status: e })
483
483
  }));
484
484
  function Wt() {
485
- return K(() => {
485
+ return z(() => {
486
486
  const n = async (e) => {
487
487
  const t = e.state?.id;
488
- (await Q.addTask(
488
+ (await q.addTask(
489
489
  async (r) => {
490
- const s = e.state?.index, a = e.state?.status, o = e.state?.params, c = e.state?.transitionName, h = e.state?.layoutId, l = F.getState().setStatus, { index: m, addHistory: d, popHistory: u } = j.getState(), P = s < m, I = a === "PUSHING" && s > m, N = a === "REPLACING" && s > m, w = window.location.pathname;
491
- if (!P && !I && !N) {
490
+ const s = e.state?.index, a = e.state?.status, o = e.state?.params, c = e.state?.transitionName, h = e.state?.layoutId, l = j.getState().setStatus, { index: m, addHistory: d, popHistory: u } = Y.getState(), P = s < m, L = a === "PUSHING" && s > m, N = a === "REPLACING" && s > m, w = window.location.pathname;
491
+ if (!P && !L && !N) {
492
492
  r.abort();
493
493
  return;
494
494
  }
495
- return P ? l("POPPING") : I ? (l("PUSHING"), d({
495
+ return P ? l("POPPING") : L ? (l("PUSHING"), d({
496
496
  id: t,
497
497
  pathname: w,
498
498
  params: o,
@@ -543,14 +543,14 @@ const kt = dt({
543
543
  prevTransitionName: "none",
544
544
  layoutId: null
545
545
  });
546
- function Z() {
546
+ function tt() {
547
547
  return pt(kt);
548
548
  }
549
549
  function Zt({ children: n }) {
550
- const { isActive: e, params: t } = Z(), [r, s] = Ht(Jt, t);
551
- return K(() => {
550
+ const { isActive: e, params: t } = tt(), [r, s] = Ht(Jt, t);
551
+ return z(() => {
552
552
  const a = async (o) => {
553
- o.state?.step && await Q.addTask(async () => {
553
+ o.state?.step && await q.addTask(async () => {
554
554
  s({ type: "SET", params: o.state?.params || {} });
555
555
  });
556
556
  };
@@ -560,10 +560,10 @@ function Zt({ children: n }) {
560
560
  }, [e, s]), /* @__PURE__ */ D(Nt.Provider, { value: s, children: /* @__PURE__ */ D(xt.Provider, { value: r, children: n }) });
561
561
  }
562
562
  function te({ children: n }) {
563
- const e = j((r) => r.index), t = j((r) => r.histories);
563
+ const e = Y((r) => r.index), t = Y((r) => r.histories);
564
564
  return t.map(
565
565
  (r) => It.toArray(n).filter(
566
- (s) => X.pathToRegexp(s.props.path).regexp.test(
566
+ (s) => V.pathToRegexp(s.props.path).regexp.test(
567
567
  r.pathname
568
568
  )
569
569
  )
@@ -943,8 +943,8 @@ const se = rt({
943
943
  swipeDirection: "y",
944
944
  onSwipeStart: async () => !0,
945
945
  onSwipe: (n, e, { animate: t, currentScreen: r, prevScreen: s, onProgress: a }) => {
946
- const { offset: o } = e, c = o.y, h = Math.max(0, Math.min(56, c)), l = ft(h, [0, 56], [1, 0.96]), m = Math.max(0, c - 56), d = Math.min(1, m / 160), u = Math.sqrt(d) * 12, P = Math.max(0, h + u), I = Math.min(56, P);
947
- return a?.(!0, I), t(
946
+ const { offset: o } = e, c = o.y, h = Math.max(0, Math.min(56, c)), l = ft(h, [0, 56], [1, 0.96]), m = Math.max(0, c - 56), d = Math.min(1, m / 160), u = Math.sqrt(d) * 12, P = Math.max(0, h + u), L = Math.min(56, P);
947
+ return a?.(!0, L), t(
948
948
  r,
949
949
  {
950
950
  y: P,
@@ -956,11 +956,11 @@ const se = rt({
956
956
  ), t(
957
957
  s,
958
958
  {
959
- y: -56 + I,
960
- opacity: I / 56
959
+ y: -56 + L,
960
+ opacity: L / 56
961
961
  },
962
962
  { duration: 0 }
963
- ), I;
963
+ ), L;
964
964
  },
965
965
  onSwipeEnd: async (n, e, { animate: t, currentScreen: r, prevScreen: s, onStart: a }) => {
966
966
  const { offset: o, velocity: c } = e, l = o.y > 56 || c.y > 20;
@@ -1047,7 +1047,7 @@ function ye({
1047
1047
  const a = St() ? e || "/" : window.location.pathname, o = St() ? a.split("?")[1] || "" : window.location.search;
1048
1048
  return ut.setState({
1049
1049
  defaultTransitionName: t
1050
- }), j.setState({
1050
+ }), Y.setState({
1051
1051
  index: 0,
1052
1052
  histories: [
1053
1053
  {
@@ -1062,7 +1062,7 @@ function ye({
1062
1062
  layoutId: null
1063
1063
  }
1064
1064
  ]
1065
- }), K(() => {
1065
+ }), z(() => {
1066
1066
  window.history.state?.index || window.history.replaceState(
1067
1067
  {
1068
1068
  id: "root",
@@ -1075,9 +1075,9 @@ function ye({
1075
1075
  "",
1076
1076
  window.location.pathname
1077
1077
  );
1078
- }, [t]), K(() => {
1078
+ }, [t]), z(() => {
1079
1079
  r.forEach((c) => et.set(c.name, c));
1080
- }, [r]), K(() => {
1080
+ }, [r]), z(() => {
1081
1081
  s.forEach((c) => ht.set(c.name, c));
1082
1082
  }, [s]), /* @__PURE__ */ ct(
1083
1083
  "div",
@@ -1102,16 +1102,18 @@ function ge({ element: n }) {
1102
1102
  function me() {
1103
1103
  return {
1104
1104
  push: async (r, s, a = {}) => {
1105
- const { status: o, setStatus: c } = F.getState();
1105
+ const { status: o, setStatus: c } = j.getState();
1106
1106
  if (o !== "COMPLETED" && o !== "IDLE")
1107
1107
  return;
1108
- const { index: h, addHistory: l } = j.getState(), m = ut.getState().defaultTransitionName, { transitionName: d = m, layoutId: u = null } = a, P = Q.generateTaskId();
1109
- (await Q.addTask(
1108
+ const { index: h, addHistory: l } = Y.getState(), m = ut.getState().defaultTransitionName, { transitionName: d = m, layoutId: u = null } = a, P = q.generateTaskId();
1109
+ (await q.addTask(
1110
1110
  async () => {
1111
1111
  c("PUSHING");
1112
- const I = X.compile(r)(s), N = X.parse(r).tokens.filter((b) => b.type === "param").map((b) => b.name), w = Object.fromEntries(
1113
- Object.entries(s).filter(([b]) => !N.includes(b))
1114
- ), k = new URLSearchParams(w).toString(), U = `${I}${k ? `?${k}` : ""}`;
1112
+ const L = V.compile(r), N = Object.fromEntries(
1113
+ Object.entries(s).map(([R, A]) => [R, String(A)])
1114
+ ), w = L(N), k = V.parse(r).tokens.filter((R) => R.type === "param").map((R) => R.name), F = Object.fromEntries(
1115
+ Object.entries(s).filter(([R]) => !k.includes(R))
1116
+ ), Q = new URLSearchParams(F).toString(), U = `${w}${Q ? `?${Q}` : ""}`;
1115
1117
  return window.history.pushState(
1116
1118
  {
1117
1119
  id: P,
@@ -1125,7 +1127,7 @@ function me() {
1125
1127
  U
1126
1128
  ), l({
1127
1129
  id: P,
1128
- pathname: I,
1130
+ pathname: w,
1129
1131
  params: s,
1130
1132
  transitionName: d,
1131
1133
  layoutId: u
@@ -1142,19 +1144,21 @@ function me() {
1142
1144
  )).result?.();
1143
1145
  },
1144
1146
  replace: async (r, s, a = {}) => {
1145
- const { status: o, setStatus: c } = F.getState();
1147
+ const { status: o, setStatus: c } = j.getState();
1146
1148
  if (o !== "COMPLETED" && o !== "IDLE")
1147
1149
  return;
1148
- const { index: h, addHistory: l } = j.getState(), m = j.getState().replaceHistory, d = ut.getState().defaultTransitionName, { transitionName: u = d, layoutId: P = null } = a, I = Q.generateTaskId();
1149
- (await Q.addTask(
1150
+ const { index: h, addHistory: l } = Y.getState(), m = Y.getState().replaceHistory, d = ut.getState().defaultTransitionName, { transitionName: u = d, layoutId: P = null } = a, L = q.generateTaskId();
1151
+ (await q.addTask(
1150
1152
  async () => {
1151
1153
  c("REPLACING");
1152
- const N = X.compile(r)(s), w = X.parse(r).tokens.filter(($) => $.type === "param").map(($) => $.name), k = Object.fromEntries(
1153
- Object.entries(s).filter(([$]) => !w.includes($))
1154
- ), U = new URLSearchParams(k).toString(), b = `${N}${U ? `?${U}` : ""}`;
1154
+ const N = V.compile(r), w = Object.fromEntries(
1155
+ Object.entries(s).map(([A, i]) => [A, String(i)])
1156
+ ), k = N(w), F = V.parse(r).tokens.filter((A) => A.type === "param").map((A) => A.name), Q = Object.fromEntries(
1157
+ Object.entries(s).filter(([A]) => !F.includes(A))
1158
+ ), U = new URLSearchParams(Q).toString(), R = `${k}${U ? `?${U}` : ""}`;
1155
1159
  return window.history.replaceState(
1156
1160
  {
1157
- id: I,
1161
+ id: L,
1158
1162
  index: h,
1159
1163
  status: "REPLACING",
1160
1164
  params: s,
@@ -1162,10 +1166,10 @@ function me() {
1162
1166
  layoutId: P
1163
1167
  },
1164
1168
  "",
1165
- b
1169
+ R
1166
1170
  ), l({
1167
- id: I,
1168
- pathname: N,
1171
+ id: L,
1172
+ pathname: k,
1169
1173
  params: s,
1170
1174
  transitionName: u,
1171
1175
  layoutId: P
@@ -1174,7 +1178,7 @@ function me() {
1174
1178
  };
1175
1179
  },
1176
1180
  {
1177
- id: I,
1181
+ id: L,
1178
1182
  control: {
1179
1183
  manual: !0
1180
1184
  }
@@ -1182,7 +1186,7 @@ function me() {
1182
1186
  )).result?.();
1183
1187
  },
1184
1188
  pop: () => {
1185
- const r = F.getState().status;
1189
+ const r = j.getState().status;
1186
1190
  r !== "COMPLETED" && r !== "IDLE" || window.history.back();
1187
1191
  }
1188
1192
  };
@@ -1191,8 +1195,8 @@ function Ee() {
1191
1195
  const n = pt(Nt);
1192
1196
  return {
1193
1197
  pushStep: async (s) => {
1194
- const a = F.getState().status;
1195
- a !== "COMPLETED" && a !== "IDLE" || (await Q.addTask(async () => {
1198
+ const a = j.getState().status;
1199
+ a !== "COMPLETED" && a !== "IDLE" || (await q.addTask(async () => {
1196
1200
  const o = new URLSearchParams(s).toString(), c = `${window.location.pathname}${o ? `?${o}` : ""}`;
1197
1201
  return window.history.state?.step || window.history.replaceState(
1198
1202
  {
@@ -1213,8 +1217,8 @@ function Ee() {
1213
1217
  })).result?.();
1214
1218
  },
1215
1219
  replaceStep: async (s) => {
1216
- const a = F.getState().status;
1217
- a !== "COMPLETED" && a !== "IDLE" || (await Q.addTask(async () => {
1220
+ const a = j.getState().status;
1221
+ a !== "COMPLETED" && a !== "IDLE" || (await q.addTask(async () => {
1218
1222
  const o = new URLSearchParams(s).toString(), c = `${window.location.pathname}${o ? `?${o}` : ""}`;
1219
1223
  return window.history.replaceState(
1220
1224
  {
@@ -1228,7 +1232,7 @@ function Ee() {
1228
1232
  })).result?.();
1229
1233
  },
1230
1234
  popStep: () => {
1231
- const s = F.getState().status;
1235
+ const s = j.getState().status;
1232
1236
  s !== "COMPLETED" && s !== "IDLE" || window.history.back();
1233
1237
  }
1234
1238
  };
@@ -1363,15 +1367,15 @@ function Dt(n, e) {
1363
1367
  }
1364
1368
  }
1365
1369
  function de({ children: n, ref: e, ...t }) {
1366
- const { isActive: r, transitionName: s } = Z(), [a, o] = Lt();
1367
- Ft(e, () => a.current);
1368
- const c = F((u) => u.status), h = et.get(s), { decoratorName: l } = h, { initial: m, variants: d } = ht.get(l);
1369
- return K(() => {
1370
+ const { isActive: r, transitionName: s } = tt(), [a, o] = Lt();
1371
+ jt(e, () => a.current);
1372
+ const c = j((u) => u.status), h = et.get(s), { decoratorName: l } = h, { initial: m, variants: d } = ht.get(l);
1373
+ return z(() => {
1370
1374
  if (!a.current) return;
1371
1375
  const { value: u, options: P } = d[`${c}-${r}`];
1372
1376
  o(a.current, u, P);
1373
1377
  }, [c, r, o, d, a]), /* @__PURE__ */ D(
1374
- z.div,
1378
+ J.div,
1375
1379
  {
1376
1380
  ref: a,
1377
1381
  initial: m,
@@ -1388,7 +1392,7 @@ function de({ children: n, ref: e, ...t }) {
1388
1392
  }
1389
1393
  );
1390
1394
  }
1391
- const W = st((n) => ({
1395
+ const Z = st((n) => ({
1392
1396
  dragStatus: "IDLE",
1393
1397
  replaceTransitionStatus: "IDLE",
1394
1398
  setDragStatus: (e) => n({ dragStatus: e }),
@@ -1406,15 +1410,15 @@ function Ct({
1406
1410
  hideSystemNavigationBar: h,
1407
1411
  ...l
1408
1412
  }) {
1409
- const [m, d] = Lt(), { id: u, isActive: P, isRoot: I, transitionName: N, prevTransitionName: w } = Z(), k = Qt(), U = F((v) => v.status), b = W((v) => v.dragStatus), $ = W.getState().setDragStatus, tt = W.getState().setReplaceTransitionStatus, J = et.get(N), { variants: i, initial: y, swipeDirection: g, decoratorName: E } = J, p = ht.get(E), [f, L] = mt(0), [T, R] = mt(0), S = H(null), M = H(null), x = H(null), C = H(null), A = H(!1), V = H(!1), q = H({
1413
+ const [m, d] = Lt(), { id: u, isActive: P, isRoot: L, transitionName: N, prevTransitionName: w } = tt(), k = Ft(), F = j((v) => v.status), Q = Z((v) => v.dragStatus), U = Z.getState().setDragStatus, R = Z.getState().setReplaceTransitionStatus, A = et.get(N), { variants: i, initial: y, swipeDirection: g, decoratorName: E } = A, p = ht.get(E), [f, I] = mt(0), [T, O] = mt(0), S = H(null), M = H(null), x = H(null), C = H(null), b = H(!1), W = H(!1), B = H({
1410
1414
  element: null,
1411
1415
  hasMarker: !1
1412
- }), Y = H({ element: null, hasMarker: !1 }), yt = H(0), gt = H(0), at = H(null), ot = H(null), At = async (v, O) => {
1416
+ }), X = H({ element: null, hasMarker: !1 }), yt = H(0), gt = H(0), at = H(null), ot = H(null), bt = async (v, G) => {
1413
1417
  if (!g)
1414
1418
  return;
1415
- const G = S.current?.previousSibling;
1416
- M.current = G?.querySelector("[data-screen]"), C.current = G?.querySelector("[data-decorator]");
1417
- const B = await J?.onSwipeStart(v, O, {
1419
+ const $ = S.current?.previousSibling;
1420
+ M.current = $?.querySelector("[data-screen]"), C.current = $?.querySelector("[data-decorator]");
1421
+ const K = await A?.onSwipeStart(v, G, {
1418
1422
  animate: d,
1419
1423
  currentScreen: m.current,
1420
1424
  prevScreen: M.current,
@@ -1425,73 +1429,73 @@ function Ct({
1425
1429
  prevDecorator: C.current
1426
1430
  })
1427
1431
  });
1428
- $(B ? "PENDING" : "IDLE");
1429
- }, Rt = (v, O) => {
1430
- !g || b !== "PENDING" || J?.onSwipe(v, O, {
1432
+ U(K ? "PENDING" : "IDLE");
1433
+ }, At = (v, G) => {
1434
+ !g || Q !== "PENDING" || A?.onSwipe(v, G, {
1431
1435
  animate: d,
1432
1436
  currentScreen: m.current,
1433
1437
  prevScreen: M.current,
1434
1438
  dragControls: k,
1435
- onProgress: (G, B) => p?.onSwipe?.(G, B, {
1439
+ onProgress: ($, K) => p?.onSwipe?.($, K, {
1436
1440
  animate: d,
1437
1441
  currentDecorator: x.current,
1438
1442
  prevDecorator: C.current
1439
1443
  })
1440
1444
  });
1441
- }, bt = async (v, O) => {
1442
- if (!g || b !== "PENDING")
1445
+ }, Rt = async (v, G) => {
1446
+ if (!g || Q !== "PENDING")
1443
1447
  return;
1444
- await J?.onSwipeEnd(v, O, {
1448
+ await A?.onSwipeEnd(v, G, {
1445
1449
  animate: d,
1446
1450
  currentScreen: m.current,
1447
1451
  prevScreen: M.current,
1448
- onStart: (B) => p?.onSwipeEnd?.(B, {
1452
+ onStart: (K) => p?.onSwipeEnd?.(K, {
1449
1453
  animate: d,
1450
1454
  currentDecorator: x.current,
1451
1455
  prevDecorator: C.current
1452
1456
  })
1453
- }) ? window.history.back() : $("IDLE");
1457
+ }) ? window.history.back() : U("IDLE");
1454
1458
  }, Ot = (v) => {
1455
- if (!(!I && P && U === "COMPLETED" && b === "IDLE" && !!g))
1459
+ if (!(!L && P && F === "COMPLETED" && Q === "IDLE" && !!g))
1456
1460
  return;
1457
- q.current = vt(v.target, {
1461
+ B.current = vt(v.target, {
1458
1462
  direction: "x",
1459
1463
  verifyByScroll: !0
1460
- }), Y.current = vt(v.target, {
1464
+ }), X.current = vt(v.target, {
1461
1465
  direction: "y",
1462
1466
  verifyByScroll: !0
1463
- }), yt.current = v.clientX, gt.current = v.clientY, (!q.current.element && !Y.current.element || q.current.element || Y.current.element) && (A.current = !0);
1467
+ }), yt.current = v.clientX, gt.current = v.clientY, (!B.current.element && !X.current.element || B.current.element || X.current.element) && (b.current = !0);
1464
1468
  }, Gt = (v) => {
1465
- const O = !q.current.element && !Y.current.element;
1466
- if (A.current && O)
1467
- A.current = !1, V.current = !0, k.start(v);
1468
- else if (A.current && !O) {
1469
- const G = v.clientX - yt.current, B = v.clientY - gt.current, it = Y.current.element && Y.current.element.scrollTop <= 0 && Y.current.hasMarker, Ut = q.current.element && q.current.element.scrollLeft <= 0 && q.current.hasMarker;
1470
- (g === "y" && (it || q.current.element) && B > 0 && Math.abs(G) < 4 || g === "x" && (Ut || Y.current.element) && G > 0 && Math.abs(B) < 4) && (A.current = !1, V.current = !0, k.start(v));
1469
+ const G = !B.current.element && !X.current.element;
1470
+ if (b.current && G)
1471
+ b.current = !1, W.current = !0, k.start(v);
1472
+ else if (b.current && !G) {
1473
+ const $ = v.clientX - yt.current, K = v.clientY - gt.current, it = X.current.element && X.current.element.scrollTop <= 0 && X.current.hasMarker, Ut = B.current.element && B.current.element.scrollLeft <= 0 && B.current.hasMarker;
1474
+ (g === "y" && (it || B.current.element) && K > 0 && Math.abs($) < 4 || g === "x" && (Ut || X.current.element) && $ > 0 && Math.abs(K) < 4) && (b.current = !1, W.current = !0, k.start(v));
1471
1475
  }
1472
1476
  }, $t = () => {
1473
- A.current = !1, V.current = !1;
1477
+ b.current = !1, W.current = !1;
1474
1478
  };
1475
- return K(() => {
1479
+ return z(() => {
1476
1480
  const v = m.current;
1477
1481
  if (!v) return;
1478
- const O = (G) => {
1479
- V.current && G.preventDefault(), G.target?.dataset.swipeAtEdgeBar === "true" && G.preventDefault();
1482
+ const G = ($) => {
1483
+ W.current && $.preventDefault(), $.target?.dataset.swipeAtEdgeBar === "true" && $.preventDefault();
1480
1484
  };
1481
- return v.addEventListener("touchmove", O, {
1485
+ return v.addEventListener("touchmove", G, {
1482
1486
  passive: !1
1483
1487
  }), () => {
1484
- v.removeEventListener("touchmove", O);
1488
+ v.removeEventListener("touchmove", G);
1485
1489
  };
1486
- }, [m]), K(() => {
1490
+ }, [m]), z(() => {
1487
1491
  m.current && (async () => {
1488
- const { value: v, options: O } = i[`${U}-${P}`];
1489
- !P && U === "REPLACING" && w !== N && (tt("PENDING"), await d(m.current, ie, {
1492
+ const { value: v, options: G } = i[`${F}-${P}`];
1493
+ !P && F === "REPLACING" && w !== N && (R("PENDING"), await d(m.current, ie, {
1490
1494
  duration: 0.1
1491
- })), P && U === "COMPLETED" && ($("IDLE"), tt("IDLE")), await d(m.current, v, O), await Q.resolveTask(u);
1495
+ })), P && F === "COMPLETED" && (U("IDLE"), R("IDLE")), await d(m.current, v, G), await q.resolveTask(u);
1492
1496
  })();
1493
1497
  }, [
1494
- U,
1498
+ F,
1495
1499
  P,
1496
1500
  u,
1497
1501
  w,
@@ -1499,14 +1503,14 @@ function Ct({
1499
1503
  d,
1500
1504
  m,
1501
1505
  i,
1502
- $,
1503
- tt
1506
+ U,
1507
+ R
1504
1508
  ]), Et(() => {
1505
- at.current && L(at.current.offsetHeight);
1509
+ at.current && I(at.current.offsetHeight);
1506
1510
  }, [a]), Et(() => {
1507
- ot.current && R(ot.current.offsetHeight);
1511
+ ot.current && O(ot.current.offsetHeight);
1508
1512
  }, [o]), /* @__PURE__ */ ct(
1509
- z.div,
1513
+ J.div,
1510
1514
  {
1511
1515
  ref: S,
1512
1516
  style: {
@@ -1538,7 +1542,7 @@ function Ct({
1538
1542
  }
1539
1543
  ),
1540
1544
  a && /* @__PURE__ */ D(
1541
- z.div,
1545
+ J.div,
1542
1546
  {
1543
1547
  ref: at,
1544
1548
  style: {
@@ -1551,7 +1555,7 @@ function Ct({
1551
1555
  }
1552
1556
  ),
1553
1557
  /* @__PURE__ */ ct(
1554
- z.div,
1558
+ J.div,
1555
1559
  {
1556
1560
  ref: m,
1557
1561
  ...l,
@@ -1559,9 +1563,9 @@ function Ct({
1559
1563
  drag: g,
1560
1564
  dragListener: !1,
1561
1565
  dragControls: k,
1562
- onDragStart: At,
1563
- onDrag: Rt,
1564
- onDragEnd: bt,
1566
+ onDragStart: bt,
1567
+ onDrag: At,
1568
+ onDragEnd: Rt,
1565
1569
  onPointerDown: Ot,
1566
1570
  onPointerMove: Gt,
1567
1571
  onPointerUp: $t,
@@ -1577,7 +1581,7 @@ function Ct({
1577
1581
  },
1578
1582
  children: [
1579
1583
  !c && e && /* @__PURE__ */ D(
1580
- z.div,
1584
+ J.div,
1581
1585
  {
1582
1586
  animate: {
1583
1587
  backgroundColor: t
@@ -1608,7 +1612,7 @@ function Ct({
1608
1612
  }
1609
1613
  ),
1610
1614
  !h && r && /* @__PURE__ */ D(
1611
- z.div,
1615
+ J.div,
1612
1616
  {
1613
1617
  animate: {
1614
1618
  backgroundColor: s
@@ -1623,7 +1627,7 @@ function Ct({
1623
1627
  }
1624
1628
  ),
1625
1629
  o && /* @__PURE__ */ D(
1626
- z.div,
1630
+ J.div,
1627
1631
  {
1628
1632
  ref: ot,
1629
1633
  style: {
@@ -1655,11 +1659,11 @@ function Ct({
1655
1659
  );
1656
1660
  }
1657
1661
  function Te({ children: n, ...e }) {
1658
- const { isActive: t, isPrev: r, zIndex: s } = Z(), a = j((d) => d.index), o = F((d) => d.status), c = W((d) => d.dragStatus), h = W((d) => d.replaceTransitionStatus), m = !t && (o === "COMPLETED" && c === "IDLE") || r && a - 2 <= s && h === "IDLE" || r && a - 2 > s;
1662
+ const { isActive: t, isPrev: r, zIndex: s } = tt(), a = Y((d) => d.index), o = j((d) => d.status), c = Z((d) => d.dragStatus), h = Z((d) => d.replaceTransitionStatus), m = !t && (o === "COMPLETED" && c === "IDLE") || r && a - 2 <= s && h === "IDLE" || r && a - 2 > s;
1659
1663
  return /* @__PURE__ */ D(Mt, { freeze: m, children: /* @__PURE__ */ D(Ct, { ...e, children: n }) });
1660
1664
  }
1661
1665
  function ve({ children: n, ...e }) {
1662
- const { isActive: t, isPrev: r, zIndex: s } = Z(), a = j((d) => d.index), o = F((d) => d.status), c = W((d) => d.dragStatus), h = W((d) => d.replaceTransitionStatus), m = !t && (o === "COMPLETED" && c === "IDLE") || r && a - 2 <= s && h === "IDLE" || r && a - 2 > s;
1666
+ const { isActive: t, isPrev: r, zIndex: s } = tt(), a = Y((d) => d.index), o = j((d) => d.status), c = Z((d) => d.dragStatus), h = Z((d) => d.replaceTransitionStatus), m = !t && (o === "COMPLETED" && c === "IDLE") || r && a - 2 <= s && h === "IDLE" || r && a - 2 > s;
1663
1667
  return /* @__PURE__ */ D(Mt, { freeze: m, children: /* @__PURE__ */ D(
1664
1668
  Ct,
1665
1669
  {
@@ -1668,12 +1672,12 @@ function ve({ children: n, ...e }) {
1668
1672
  backgroundColor: "transparent",
1669
1673
  ...e.style
1670
1674
  },
1671
- children: /* @__PURE__ */ D(jt, { children: n })
1675
+ children: /* @__PURE__ */ D(Qt, { children: n })
1672
1676
  }
1673
1677
  ) });
1674
1678
  }
1675
1679
  function De({ children: n, ...e }) {
1676
- const { isActive: t, transitionName: r } = Z(), s = F((o) => o.status), a = et.get(r);
1680
+ const { isActive: t, transitionName: r } = tt(), s = j((o) => o.status), a = et.get(r);
1677
1681
  return /* @__PURE__ */ D(
1678
1682
  qt,
1679
1683
  {
@@ -1695,6 +1699,6 @@ export {
1695
1699
  rt as createTransition,
1696
1700
  me as useNavigate,
1697
1701
  we as useParams,
1698
- Z as useScreen,
1702
+ tt as useScreen,
1699
1703
  Ee as useStep
1700
1704
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flemo",
3
- "version": "1.3.5",
3
+ "version": "1.3.7",
4
4
  "description": "A modern React router library with built-in motion animations and smooth transitions",
5
5
  "main": "./dist/index.mjs",
6
6
  "module": "./dist/index.mjs",