@flemo/core 1.1.0 → 1.1.1

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 +96 -94
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { create as D } from "zustand";
2
- import { pathToRegexp as w, match as U } from "path-to-regexp";
3
- class Y {
2
+ import { pathToRegexp as S, match as Y } from "path-to-regexp";
3
+ class B {
4
4
  tasks = /* @__PURE__ */ new Map();
5
5
  instanceId = Date.now().toString();
6
6
  isLocked = !1;
@@ -173,7 +173,7 @@ class Y {
173
173
  await Promise.all(t.map((e) => this.resolveTask(e.id)));
174
174
  }
175
175
  }
176
- const dt = new Y(), mt = D((n) => ({
176
+ const pt = new B(), yt = D((n) => ({
177
177
  index: -1,
178
178
  histories: [],
179
179
  addHistory: (t) => n((e) => ({
@@ -188,17 +188,17 @@ const dt = new Y(), mt = D((n) => ({
188
188
  index: e.index - 1,
189
189
  histories: e.histories.filter((a, s) => s !== t)
190
190
  }))
191
- })), ht = D((n) => ({
191
+ })), gt = D((n) => ({
192
192
  status: "IDLE",
193
193
  transitionTaskId: null,
194
194
  setStatus: (t) => n({ status: t }),
195
195
  setTransitionTaskId: (t) => n({ transitionTaskId: t })
196
196
  }));
197
197
  let N = 0;
198
- function pt() {
198
+ function Pt() {
199
199
  N += 1;
200
200
  }
201
- function yt() {
201
+ function Et() {
202
202
  return N > 0 ? (N -= 1, !0) : !1;
203
203
  }
204
204
  function k({
@@ -229,7 +229,7 @@ function k({
229
229
  ...c
230
230
  };
231
231
  }
232
- function gt({
232
+ function It({
233
233
  name: n,
234
234
  initial: t,
235
235
  idle: e,
@@ -261,12 +261,12 @@ function gt({
261
261
  ...m
262
262
  };
263
263
  }
264
- const B = (n, t, e) => {
264
+ const Q = (n, t, e) => {
265
265
  const [a, s] = t, [r, o] = e;
266
266
  if (s === a) return r;
267
267
  const c = (n - a) / (s - a);
268
268
  return r + c * (o - r);
269
- }, Q = k({
269
+ }, X = k({
270
270
  name: "cupertino",
271
271
  initial: {
272
272
  x: "100%"
@@ -320,7 +320,7 @@ const B = (n, t, e) => {
320
320
  swipeDirection: "x",
321
321
  onSwipeStart: async () => !0,
322
322
  onSwipe: (n, t, { animate: e, currentScreen: a, prevScreen: s, onProgress: r }) => {
323
- const { offset: o } = t, c = o.x, l = B(c, [0, window.innerWidth], [0, 100]);
323
+ const { offset: o } = t, c = o.x, l = Q(c, [0, window.innerWidth], [0, 100]);
324
324
  return r?.(!0, l), e(
325
325
  a,
326
326
  {
@@ -365,12 +365,12 @@ const B = (n, t, e) => {
365
365
  ]), u;
366
366
  }
367
367
  }
368
- }), X = (n, t, e) => {
368
+ }), F = (n, t, e) => {
369
369
  const [a, s] = t, [r, o] = e;
370
370
  if (s === a) return r;
371
371
  const c = (n - a) / (s - a);
372
372
  return r + c * (o - r);
373
- }, F = k({
373
+ }, z = k({
374
374
  name: "layout",
375
375
  initial: {
376
376
  opacity: 0.97
@@ -420,7 +420,7 @@ const B = (n, t, e) => {
420
420
  swipeDirection: "y",
421
421
  onSwipeStart: async () => !0,
422
422
  onSwipe: (n, t, { animate: e, currentScreen: a, onProgress: s }) => {
423
- const { offset: r } = t, o = r.y, c = Math.max(0, Math.min(56, o)), l = X(c, [0, 56], [1, 0.96]), u = Math.max(0, o - 56), d = Math.min(1, u / 160), m = Math.sqrt(d) * 12, i = Math.max(0, c + m), h = Math.min(56, i);
423
+ const { offset: r } = t, o = r.y, c = Math.max(0, Math.min(56, o)), l = F(c, [0, 56], [1, 0.96]), u = Math.max(0, o - 56), d = Math.min(1, u / 160), m = Math.sqrt(d) * 12, i = Math.max(0, c + m), h = Math.min(56, i);
424
424
  return s?.(!0, 100), e(
425
425
  a,
426
426
  {
@@ -458,7 +458,7 @@ const B = (n, t, e) => {
458
458
  ]), u;
459
459
  }
460
460
  }
461
- }), z = k({
461
+ }), V = k({
462
462
  name: "material",
463
463
  initial: {
464
464
  y: "100%"
@@ -554,7 +554,7 @@ const B = (n, t, e) => {
554
554
  ]), u;
555
555
  }
556
556
  }
557
- }), V = k({
557
+ }), Z = k({
558
558
  name: "none",
559
559
  initial: {},
560
560
  idle: {
@@ -587,16 +587,16 @@ const B = (n, t, e) => {
587
587
  duration: 0
588
588
  }
589
589
  }
590
- }), Pt = /* @__PURE__ */ new Map([
591
- ["none", V],
592
- ["cupertino", Q],
593
- ["material", z],
594
- ["layout", F]
595
- ]), Et = D((n) => ({
590
+ }), kt = /* @__PURE__ */ new Map([
591
+ ["none", Z],
592
+ ["cupertino", X],
593
+ ["material", V],
594
+ ["layout", z]
595
+ ]), Tt = D((n) => ({
596
596
  defaultTransitionName: "cupertino",
597
597
  setDefaultTransitionName: (t) => n({ defaultTransitionName: t })
598
598
  }));
599
- function Z({
599
+ function j({
600
600
  name: n,
601
601
  initial: t,
602
602
  idle: e,
@@ -622,7 +622,7 @@ function Z({
622
622
  ...r
623
623
  };
624
624
  }
625
- function It({
625
+ function Nt({
626
626
  name: n,
627
627
  initial: t,
628
628
  idle: e,
@@ -654,7 +654,7 @@ function It({
654
654
  ...m
655
655
  };
656
656
  }
657
- const j = Z({
657
+ const K = j({
658
658
  name: "overlay",
659
659
  initial: {
660
660
  opacity: 0,
@@ -721,7 +721,7 @@ const j = Z({
721
721
  }
722
722
  )
723
723
  }
724
- }), kt = /* @__PURE__ */ new Map([["overlay", j]]), I = {
724
+ }), Lt = /* @__PURE__ */ new Map([["overlay", K]]), I = {
725
725
  "IDLE-true": "self",
726
726
  "IDLE-false": "self",
727
727
  "PUSHING-true": "initial",
@@ -732,7 +732,7 @@ const j = Z({
732
732
  "POPPING-false": "PUSHING-false",
733
733
  "COMPLETED-true": "self",
734
734
  "COMPLETED-false": "self"
735
- }, C = Object.keys(I), K = C, q = (n) => n.replace(/[^a-zA-Z0-9_-]/g, "_"), G = (n) => typeof n == "object" && n !== null && !Array.isArray(n), W = /* @__PURE__ */ new Set([
735
+ }, G = Object.keys(I), q = G, W = (n) => n.replace(/[^a-zA-Z0-9_-]/g, "_"), O = (n) => typeof n == "object" && n !== null && !Array.isArray(n), J = /* @__PURE__ */ new Set([
736
736
  "opacity",
737
737
  "scale",
738
738
  "scaleX",
@@ -769,7 +769,7 @@ const j = Z({
769
769
  "strokeDashoffset",
770
770
  "strokeMiterlimit",
771
771
  "strokeWidth"
772
- ]), J = (n, t) => t.startsWith("--") ? `${n}` : W.has(t) ? `${n}` : t === "rotate" || t === "rotateX" || t === "rotateY" || t === "rotateZ" ? `${n}deg` : `${n}px`, O = (n, t) => typeof t == "number" ? J(t, n) : typeof t == "string" ? t : "", b = (n) => n.replace(/[A-Z]/g, (t) => `-${t.toLowerCase()}`), $ = /* @__PURE__ */ new Set([
772
+ ]), tt = (n, t) => t.startsWith("--") ? `${n}` : J.has(t) ? `${n}` : t === "rotate" || t === "rotateX" || t === "rotateY" || t === "rotateZ" ? `${n}deg` : `${n}px`, b = (n, t) => typeof t == "number" ? tt(t, n) : typeof t == "string" ? t : "", $ = (n) => n.replace(/[A-Z]/g, (t) => `-${t.toLowerCase()}`), R = /* @__PURE__ */ new Set([
773
773
  "x",
774
774
  "y",
775
775
  "z",
@@ -780,7 +780,7 @@ const j = Z({
780
780
  "rotateX",
781
781
  "rotateY",
782
782
  "rotateZ"
783
- ]), tt = /^-?0(\.0+)?(px|%|em|rem|vh|vw|vmin|vmax)?$/, et = /^-?0(\.0+)?(deg|rad|grad|turn)?$/, nt = /^1(\.0+)?$/, at = (n, t) => n === "scale" || n === "scaleX" || n === "scaleY" ? t === 1 ? !0 : typeof t == "string" ? nt.test(t.trim()) : !1 : n === "rotate" || n === "rotateX" || n === "rotateY" || n === "rotateZ" ? t === 0 ? !0 : typeof t == "string" ? et.test(t.trim()) : !1 : t === 0 ? !0 : typeof t == "string" ? tt.test(t.trim()) : !1, st = (n, t) => {
783
+ ]), et = /^-?0(\.0+)?(px|%|em|rem|vh|vw|vmin|vmax)?$/, nt = /^-?0(\.0+)?(deg|rad|grad|turn)?$/, at = /^1(\.0+)?$/, st = (n, t) => n === "scale" || n === "scaleX" || n === "scaleY" ? t === 1 ? !0 : typeof t == "string" ? at.test(t.trim()) : !1 : n === "rotate" || n === "rotateX" || n === "rotateY" || n === "rotateZ" ? t === 0 ? !0 : typeof t == "string" ? nt.test(t.trim()) : !1 : t === 0 ? !0 : typeof t == "string" ? et.test(t.trim()) : !1, rt = (n, t) => {
784
784
  switch (n) {
785
785
  case "x":
786
786
  return `translateX(${t})`;
@@ -804,14 +804,14 @@ const j = Z({
804
804
  default:
805
805
  return "";
806
806
  }
807
- }, Tt = (n) => {
807
+ }, Dt = (n) => {
808
808
  const t = /* @__PURE__ */ new Set();
809
809
  let e = !1;
810
810
  const a = (s) => {
811
- if (G(s))
811
+ if (O(s))
812
812
  for (const r of Object.keys(s)) {
813
813
  const o = s[r];
814
- O(r, o) !== "" && ($.has(r) ? e = !0 : t.add(b(r)));
814
+ b(r, o) !== "" && (R.has(r) ? e = !0 : t.add($(r)));
815
815
  }
816
816
  };
817
817
  a(n.initial);
@@ -819,20 +819,20 @@ const j = Z({
819
819
  a(s.value);
820
820
  return e && t.add("transform"), Array.from(t);
821
821
  }, P = (n) => {
822
- if (!G(n)) return [];
822
+ if (!O(n)) return [];
823
823
  const t = [];
824
824
  let e = !0;
825
825
  const a = [];
826
826
  for (const s of Object.keys(n)) {
827
- const r = n[s], o = O(s, r);
828
- o !== "" && ($.has(s) ? (t.push(st(s, o)), at(s, r) || (e = !1)) : a.push({ property: b(s), value: o }));
827
+ const r = n[s], o = b(s, r);
828
+ o !== "" && (R.has(s) ? (t.push(rt(s, o)), st(s, r) || (e = !1)) : a.push({ property: $(s), value: o }));
829
829
  }
830
830
  return t.length > 0 && a.push({
831
831
  property: "transform",
832
832
  value: e ? "none" : t.join(" ")
833
833
  }), a;
834
834
  }, E = (n) => n.map((t) => ` ${t.property}: ${t.value};`).join(`
835
- `), rt = (n) => Array.isArray(n) ? n.length === 4 && n.every((t) => typeof t == "number") ? `cubic-bezier(${n.join(", ")})` : "linear" : typeof n == "string" ? {
835
+ `), ot = (n) => Array.isArray(n) ? n.length === 4 && n.every((t) => typeof t == "number") ? `cubic-bezier(${n.join(", ")})` : "linear" : typeof n == "string" ? {
836
836
  linear: "linear",
837
837
  easeIn: "ease-in",
838
838
  easeOut: "ease-out",
@@ -842,22 +842,22 @@ const j = Z({
842
842
  backIn: "cubic-bezier(0.31, 0.01, 0.66, -0.59)",
843
843
  backOut: "cubic-bezier(0.33, 1.53, 0.69, 0.99)",
844
844
  anticipate: "cubic-bezier(0.36, 0, 0.66, -0.56)"
845
- }[n] ?? "ease" : "ease", R = (n) => {
845
+ }[n] ?? "ease" : "ease", _ = (n) => {
846
846
  if (!n) return 0;
847
847
  const t = n.duration;
848
848
  return typeof t == "number" && t >= 0 ? t : 0;
849
- }, _ = (n) => n && typeof n.delay == "number" && n.delay > 0 ? n.delay : 0, S = (n, t) => {
849
+ }, H = (n) => n && typeof n.delay == "number" && n.delay > 0 ? n.delay : 0, v = (n, t) => {
850
850
  const [e, a] = t.split("-");
851
851
  return `[data-flemo-screen][data-flemo-transition="${n}"][data-flemo-status="${e}"][data-flemo-active="${a}"]`;
852
- }, v = (n, t) => {
852
+ }, A = (n, t) => {
853
853
  const [e, a] = t.split("-");
854
854
  return `[data-flemo-decorator][data-flemo-decorator-name="${n}"][data-flemo-status="${e}"][data-flemo-active="${a}"]`;
855
- }, ot = (n, t) => {
855
+ }, it = (n, t) => {
856
856
  const [e, a] = t.split("-");
857
857
  return `[data-flemo-bar][data-flemo-bar-transition="${n}"][data-flemo-bar-status="${e}"][data-flemo-bar-active="${a}"][data-flemo-bar-riding="true"]`;
858
- }, it = (n, t, e) => `flemo-${n}-${q(t)}-${e}`, A = (n, t, e, a, s, r) => {
859
- const o = P(a), c = P(s.value), l = R(s.options), u = _(s.options), d = rt(s.options?.ease), m = r(t, e), i = n === "screen" ? `${m},
860
- ${ot(t, e)}` : m;
858
+ }, ct = (n, t, e) => `flemo-${n}-${W(t)}-${e}`, M = (n, t, e, a, s, r) => {
859
+ const o = P(a), c = P(s.value), l = _(s.options), u = H(s.options), d = ot(s.options?.ease), m = r(t, e), i = n === "screen" ? `${m},
860
+ ${it(t, e)}` : m;
861
861
  if (c.length === 0 && o.length === 0)
862
862
  return "";
863
863
  if (l <= 0 && u <= 0)
@@ -865,7 +865,7 @@ ${ot(t, e)}` : m;
865
865
  ${E(c)}
866
866
  animation: none;
867
867
  }`;
868
- const h = it(n, t, e), g = [
868
+ const h = ct(n, t, e), g = [
869
869
  `@keyframes ${h} {`,
870
870
  " from {",
871
871
  E(o).replace(/^/gm, " "),
@@ -884,49 +884,51 @@ ${E(c)}
884
884
  ].filter(Boolean).join(" "), f = Array.from(
885
885
  /* @__PURE__ */ new Set([...o.map((T) => T.property), ...c.map((T) => T.property)])
886
886
  ), y = f.length > 0 ? ` will-change: ${f.join(", ")};
887
- ` : "", H = `${i} {
887
+ ` : "", w = e.split("-")[0], U = `${i} {
888
888
  animation: ${p};
889
- ${y}}`;
889
+ ${y}${w === "PUSHING" || w === "REPLACING" ? ` contain: layout;
890
+ pointer-events: none;
891
+ ` : ""}}`;
890
892
  return `${g}
891
- ${H}`;
892
- }, M = (n, t, e, a) => {
893
+ ${U}`;
894
+ }, x = (n, t, e, a) => {
893
895
  const s = P(a.value);
894
896
  return s.length === 0 ? "" : `${n(t, e)} {
895
897
  ${E(s)}
896
898
  }`;
897
- }, Nt = (n, t) => {
899
+ }, wt = (n, t) => {
898
900
  const e = [];
899
901
  for (const a of n) {
900
902
  const s = a.name;
901
- for (const r of C) {
903
+ for (const r of G) {
902
904
  const o = a.variants[r], c = I[r];
903
905
  if (c === "self") {
904
- e.push(M(S, s, r, o));
906
+ e.push(x(v, s, r, o));
905
907
  continue;
906
908
  }
907
909
  const l = c === "initial" ? a.initial : a.variants[c].value;
908
910
  e.push(
909
- A("screen", s, r, l, o, S)
911
+ M("screen", s, r, l, o, v)
910
912
  );
911
913
  }
912
914
  }
913
915
  for (const a of t) {
914
916
  const s = a.name;
915
- for (const r of K) {
917
+ for (const r of q) {
916
918
  const o = a.variants[r], c = I[r];
917
919
  if (c === "self") {
918
- e.push(M(v, s, r, o));
920
+ e.push(x(A, s, r, o));
919
921
  continue;
920
922
  }
921
923
  const l = c === "initial" ? a.initial : a.variants[c].value;
922
924
  e.push(
923
- A(
925
+ M(
924
926
  "decorator",
925
927
  s,
926
928
  r,
927
929
  l,
928
930
  o,
929
- v
931
+ A
930
932
  )
931
933
  );
932
934
  }
@@ -934,44 +936,44 @@ ${E(s)}
934
936
  return e.filter((a) => a.length > 0).join(`
935
937
 
936
938
  `);
937
- }, Lt = (n, t) => {
939
+ }, St = (n, t) => {
938
940
  const e = I[t];
939
941
  if (e === "self") return !1;
940
- const a = n.variants[t], s = R(a.options), r = _(a.options);
942
+ const a = n.variants[t], s = _(a.options), r = H(a.options);
941
943
  if (s <= 0 && r <= 0) return !1;
942
944
  const o = e === "initial" ? n.initial : n.variants[e].value, c = P(o), l = P(a.value);
943
945
  return c.length > 0 || l.length > 0;
944
946
  };
945
- function Dt() {
947
+ function vt() {
946
948
  return typeof document > "u";
947
949
  }
948
- function ct(n, t) {
949
- return Array.isArray(n) ? n.find((e) => w(e).regexp.test(t)) ?? "" : w(n).regexp.test(t) ? n : "";
950
+ function ut(n, t) {
951
+ return Array.isArray(n) ? n.find((e) => S(e).regexp.test(t)) ?? "" : S(n).regexp.test(t) ? n : "";
950
952
  }
951
- function wt(n, t, e) {
952
- const a = ct(n, t), s = U(a)(t), r = new URLSearchParams(e), o = Object.fromEntries(r.entries());
953
+ function At(n, t, e) {
954
+ const a = ut(n, t), s = Y(a)(t), r = new URLSearchParams(e), o = Object.fromEntries(r.entries());
953
955
  return s ? { ...s.params, ...o } : {};
954
956
  }
955
- function St(n, t) {
957
+ function Mt(n, t) {
956
958
  const {
957
959
  direction: e = "x",
958
960
  markerSelector: a = "[data-swipe-at-edge]",
959
961
  depthLimit: s = 24,
960
962
  verifyByScroll: r = !1
961
- } = t ?? {}, o = ut(n);
963
+ } = t ?? {}, o = lt(n);
962
964
  if (!o) return { element: null, hasMarker: !1 };
963
965
  const c = o.closest?.(a);
964
- if (c instanceof HTMLElement && L(c, e) && (!r || x(c, e)))
966
+ if (c instanceof HTMLElement && L(c, e) && (!r || C(c, e)))
965
967
  return { element: c, hasMarker: !0 };
966
968
  let l = o, u = 0;
967
969
  for (; l && u < s; ) {
968
- if (L(l, e) && (!r || x(l, e)))
970
+ if (L(l, e) && (!r || C(l, e)))
969
971
  return { element: l, hasMarker: !1 };
970
972
  l = l.parentElement, u++;
971
973
  }
972
974
  return { element: null, hasMarker: !1 };
973
975
  }
974
- function ut(n) {
976
+ function lt(n) {
975
977
  if (!n) return null;
976
978
  const t = n, e = typeof t.composedPath == "function" ? t.composedPath() : void 0;
977
979
  if (e && e.length) {
@@ -983,39 +985,39 @@ function ut(n) {
983
985
  function L(n, t) {
984
986
  return t === "y" ? n.scrollHeight - n.clientHeight > 1 : n.scrollWidth - n.clientWidth > 1;
985
987
  }
986
- function x(n, t) {
988
+ function C(n, t) {
987
989
  if (!L(n, t) || typeof window > "u") return !1;
988
990
  const e = window.getComputedStyle(n), a = t === "y" ? e.overflowY : e.overflowX;
989
991
  return a === "auto" || a === "scroll" || a === "overlay";
990
992
  }
991
993
  export {
992
- dt as TaskManger,
993
- it as animationName,
994
- x as canProgrammaticallyScroll,
995
- Tt as collectAnimatedProperties,
996
- Nt as compileTransitionStyles,
997
- yt as consumeSelfInducedPop,
998
- Z as createDecorator,
999
- It as createRawDecorator,
1000
- gt as createRawTransition,
994
+ pt as TaskManger,
995
+ ct as animationName,
996
+ C as canProgrammaticallyScroll,
997
+ Dt as collectAnimatedProperties,
998
+ wt as compileTransitionStyles,
999
+ Et as consumeSelfInducedPop,
1000
+ j as createDecorator,
1001
+ Nt as createRawDecorator,
1002
+ It as createRawTransition,
1001
1003
  k as createTransition,
1002
- Q as cupertino,
1003
- kt as decoratorMap,
1004
- rt as easingToCss,
1005
- St as findScrollable,
1006
- ct as getMatchedPathPattern,
1007
- wt as getParams,
1008
- Dt as isServer,
1009
- F as layout,
1010
- pt as markSelfInducedPop,
1011
- z as material,
1012
- V as none,
1004
+ X as cupertino,
1005
+ Lt as decoratorMap,
1006
+ ot as easingToCss,
1007
+ Mt as findScrollable,
1008
+ ut as getMatchedPathPattern,
1009
+ At as getParams,
1010
+ vt as isServer,
1011
+ z as layout,
1012
+ Pt as markSelfInducedPop,
1013
+ V as material,
1014
+ Z as none,
1013
1015
  L as overflowsAxis,
1014
- j as overlay,
1016
+ K as overlay,
1015
1017
  P as targetToDecls,
1016
- Pt as transitionMap,
1017
- mt as useHistoryStore,
1018
- ht as useNavigateStore,
1019
- Et as useTransitionStore,
1020
- Lt as variantHasAnimation
1018
+ kt as transitionMap,
1019
+ yt as useHistoryStore,
1020
+ gt as useNavigateStore,
1021
+ Tt as useTransitionStore,
1022
+ St as variantHasAnimation
1021
1023
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flemo/core",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "Framework-agnostic primitives for flemo: history, navigation, transitions, task manager.",
5
5
  "main": "./dist/index.mjs",
6
6
  "module": "./dist/index.mjs",