@alea-design/motion 0.6.1 → 0.7.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/dist/index.js CHANGED
@@ -1,17 +1,23 @@
1
1
  "use client";
2
- import { jsx as E, jsxs as D } from "react/jsx-runtime";
3
- import { useState as N, useEffect as y, useRef as h, useCallback as T, createElement as S, isValidElement as A, cloneElement as C, Children as H, Fragment as X, useLayoutEffect as U, version as W } from "react";
4
- const F = typeof window > "u" ? y : U, _ = ["out", "in", "in-out", "standard", "emphasized", "spring"], G = (t) => _.includes(t) ? `var(--alea-motion-${t === "spring" ? "spring" : "ease-" + t})` : t, B = (t, e) => t === "none" ? "none" : `alea-m-${t}-${e}`;
5
- function R(t) {
6
- if (t === void 0) return;
7
- const e = t === !1 ? { enter: "none" } : typeof t == "string" ? { enter: t } : t, n = {};
8
- return e.enter ? (n["--alea-enter"] = B(e.enter, "in"), n["--alea-exit"] = B(e.exit || e.enter, "out")) : e.exit && (n["--alea-exit"] = B(e.exit, "out")), e.duration != null ? (n["--alea-enter-duration"] = `${e.duration}ms`, n["--alea-exit-duration"] = `${e.exitDuration ?? Math.round(e.duration * 0.6)}ms`) : e.exitDuration != null && (n["--alea-exit-duration"] = `${e.exitDuration}ms`), e.easing && (n["--alea-enter-ease"] = G(e.easing)), e.delay != null && (n["--alea-enter-delay"] = `${e.delay}ms`), n;
2
+ import { jsx as S, jsxs as _ } from "react/jsx-runtime";
3
+ import { useRef as w, useState as L, useEffect as h, createElement as $, Children as U, isValidElement as F, cloneElement as H, useCallback as C, Fragment as J, useLayoutEffect as Q, version as Z } from "react";
4
+ function K(e, t) {
5
+ if (!e) return { enter: !1, leave: !1 };
6
+ if (e === !0) return { enter: !0, leave: !0 };
7
+ const n = e.max === void 0 || t <= e.max;
8
+ return { enter: n && e.enter !== !1, leave: n && e.leave !== !1 };
9
9
  }
10
- function le(t, e) {
11
- const n = R(e);
12
- return n ? typeof t == "function" ? ((o) => ({ ...n, ...t(o) })) : { ...n, ...t } : t;
10
+ const q = (e) => typeof e == "object" ? e.resetOn ?? [] : [], ee = (e, t) => e.length === t.length && e.every((n, r) => Object.is(n, t[r])), Y = typeof window > "u" ? h : Q, te = ["out", "in", "in-out", "standard", "emphasized", "spring"], ne = (e) => te.includes(e) ? `var(--alea-motion-${e === "spring" ? "spring" : "ease-" + e})` : e, D = (e, t) => e === "none" ? "none" : `alea-m-${e}-${t}`;
11
+ function V(e) {
12
+ if (e === void 0) return;
13
+ const t = e === !1 ? { enter: "none" } : typeof e == "string" ? { enter: e } : e, n = {};
14
+ return t.enter ? (n["--alea-enter"] = D(t.enter, "in"), n["--alea-exit"] = D(t.exit || t.enter, "out")) : t.exit && (n["--alea-exit"] = D(t.exit, "out")), t.duration != null ? (n["--alea-enter-duration"] = `${t.duration}ms`, n["--alea-exit-duration"] = `${t.exitDuration ?? Math.round(t.duration * 0.6)}ms`) : t.exitDuration != null && (n["--alea-exit-duration"] = `${t.exitDuration}ms`), t.easing && (n["--alea-enter-ease"] = ne(t.easing)), t.delay != null && (n["--alea-enter-delay"] = `${t.delay}ms`), n;
13
15
  }
14
- const J = {
16
+ function we(e, t) {
17
+ const n = V(t);
18
+ return n ? typeof e == "function" ? ((r) => ({ ...n, ...e(r) })) : { ...n, ...e } : e;
19
+ }
20
+ const re = {
15
21
  popover: ".alea-popover",
16
22
  select: ".alea-select-popover",
17
23
  menu: ".alea-menu-popover",
@@ -23,416 +29,420 @@ const J = {
23
29
  hovercard: ".alea-hovercard",
24
30
  datepicker: ".alea-cal-popover",
25
31
  tour: ".alea-tour-card"
26
- }, Q = { instant: 120, fast: 200, base: 320, slow: 480, slower: 720 }, Z = { sm: 8, md: 12, lg: 24 }, K = { sm: 4, md: 8, lg: 16 };
27
- function ce(t = {}) {
28
- const e = {}, n = t.speed, o = t.intensity;
29
- if (n != null && n !== 1) for (const [a, r] of Object.entries(Q)) e[`--alea-motion-duration-${a}`] = `${Math.round(r * n)}ms`;
30
- if (o != null && o !== 1) {
31
- for (const [a, r] of Object.entries(Z)) e[`--alea-motion-distance-${a}`] = `${+(r * o).toFixed(2)}px`;
32
- for (const [a, r] of Object.entries(K)) e[`--alea-motion-blur-${a}`] = `${+(r * o).toFixed(2)}px`;
33
- e["--alea-motion-scale-from"] = String(+(1 - 0.08 * o).toFixed(3)), e["--alea-motion-scale-press"] = String(+(1 - 0.04 * o).toFixed(3)), e["--alea-motion-lift"] = `${+(-4 * o).toFixed(2)}px`;
32
+ }, oe = { instant: 120, fast: 200, base: 320, slow: 480, slower: 720 }, ae = { sm: 8, md: 12, lg: 24 }, ie = { sm: 4, md: 8, lg: 16 };
33
+ function he(e = {}) {
34
+ const t = {}, n = e.speed, r = e.intensity;
35
+ if (n != null && n !== 1) for (const [i, o] of Object.entries(oe)) t[`--alea-motion-duration-${i}`] = `${Math.round(o * n)}ms`;
36
+ if (r != null && r !== 1) {
37
+ for (const [i, o] of Object.entries(ae)) t[`--alea-motion-distance-${i}`] = `${+(o * r).toFixed(2)}px`;
38
+ for (const [i, o] of Object.entries(ie)) t[`--alea-motion-blur-${i}`] = `${+(o * r).toFixed(2)}px`;
39
+ t["--alea-motion-scale-from"] = String(+(1 - 0.08 * r).toFixed(3)), t["--alea-motion-scale-press"] = String(+(1 - 0.04 * r).toFixed(3)), t["--alea-motion-lift"] = `${+(-4 * r).toFixed(2)}px`;
34
40
  }
35
- return e;
41
+ return t;
36
42
  }
37
- function ue(t = {}) {
38
- const e = {};
39
- return t.mode && t.mode !== "expressive" && (e["data-alea-motion"] = t.mode), t.reduced && t.reduced !== "system" && (e["data-alea-reduced"] = t.reduced), e;
43
+ function ye(e = {}) {
44
+ const t = {};
45
+ return e.mode && e.mode !== "expressive" && (t["data-alea-motion"] = e.mode), e.reduced && e.reduced !== "system" && (t["data-alea-reduced"] = e.reduced), t;
40
46
  }
41
- function de(t = {}, e = ":root") {
42
- return Object.entries(t).map(([n, o]) => {
43
- const a = R(o), r = J[n];
44
- return !a || !r ? "" : `${e} ${r} { ${Object.entries(a).map(([i, s]) => `${i}: ${s};`).join(" ")} }`;
47
+ function xe(e = {}, t = ":root") {
48
+ return Object.entries(e).map(([n, r]) => {
49
+ const i = V(r), o = re[n];
50
+ return !i || !o ? "" : `${t} ${o} { ${Object.entries(i).map(([a, s]) => `${a}: ${s};`).join(" ")} }`;
45
51
  }).filter(Boolean).join(`
46
52
  `);
47
53
  }
48
- function Y() {
49
- const [t, e] = N(!1);
50
- return y(() => {
51
- var r, i;
54
+ function W() {
55
+ const [e, t] = L(!1);
56
+ return h(() => {
57
+ var o, a;
52
58
  if (typeof window > "u") return;
53
- const n = (r = window.matchMedia) == null ? void 0 : r.call(window, "(prefers-reduced-motion: reduce)"), o = () => {
54
- const s = document.documentElement, f = s.getAttribute("data-alea-reduced"), c = s.getAttribute("data-alea-motion");
55
- e(c === "off" || c === "reduced" || f === "always" || f !== "never" && !!(n != null && n.matches));
59
+ const n = (o = window.matchMedia) == null ? void 0 : o.call(window, "(prefers-reduced-motion: reduce)"), r = () => {
60
+ const s = document.documentElement, d = s.getAttribute("data-alea-reduced"), l = s.getAttribute("data-alea-motion");
61
+ t(l === "off" || l === "reduced" || d === "always" || d !== "never" && !!(n != null && n.matches));
56
62
  };
57
- o(), (i = n == null ? void 0 : n.addEventListener) == null || i.call(n, "change", o);
58
- const a = new MutationObserver(o);
59
- return a.observe(document.documentElement, { attributes: !0, attributeFilter: ["data-alea-motion", "data-alea-reduced"] }), () => {
63
+ r(), (a = n == null ? void 0 : n.addEventListener) == null || a.call(n, "change", r);
64
+ const i = new MutationObserver(r);
65
+ return i.observe(document.documentElement, { attributes: !0, attributeFilter: ["data-alea-motion", "data-alea-reduced"] }), () => {
60
66
  var s;
61
- (s = n == null ? void 0 : n.removeEventListener) == null || s.call(n, "change", o), a.disconnect();
67
+ (s = n == null ? void 0 : n.removeEventListener) == null || s.call(n, "change", r), i.disconnect();
62
68
  };
63
- }, []), t;
69
+ }, []), e;
64
70
  }
65
- function q(t = {}) {
66
- const { once: e = !0, margin: n = "0px 0px -10% 0px", threshold: o = 0.1 } = t, a = h(null), [r, i] = N(!1);
67
- return y(() => {
68
- const s = a.current;
71
+ function se(e = {}) {
72
+ const { once: t = !0, margin: n = "0px 0px -10% 0px", threshold: r = 0.1 } = e, i = w(null), [o, a] = L(!1);
73
+ return h(() => {
74
+ const s = i.current;
69
75
  if (!s || typeof IntersectionObserver > "u") {
70
- i(!0);
76
+ a(!0);
71
77
  return;
72
78
  }
73
- const f = new IntersectionObserver(([c]) => {
74
- c.isIntersecting ? (i(!0), e && f.disconnect()) : e || i(!1);
75
- }, { rootMargin: n, threshold: o });
76
- return f.observe(s), () => f.disconnect();
77
- }, [e, n, o]), [a, r];
79
+ const d = new IntersectionObserver(([l]) => {
80
+ l.isIntersecting ? (a(!0), t && d.disconnect()) : t || a(!1);
81
+ }, { rootMargin: n, threshold: r });
82
+ return d.observe(s), () => d.disconnect();
83
+ }, [t, n, r]), [i, o];
78
84
  }
79
- let j = null;
80
- function ee(t) {
85
+ let P = null;
86
+ function le(e) {
81
87
  return typeof IntersectionObserver > "u" ? () => {
82
- } : (j ?? (j = new IntersectionObserver((e) => {
83
- for (const n of e) n.target.toggleAttribute("data-alea-offscreen", !n.isIntersecting);
84
- }, { rootMargin: "64px" })), j.observe(t), () => {
85
- j == null || j.unobserve(t), t.removeAttribute("data-alea-offscreen");
88
+ } : (P ?? (P = new IntersectionObserver((t) => {
89
+ for (const n of t) n.target.toggleAttribute("data-alea-offscreen", !n.isIntersecting);
90
+ }, { rootMargin: "64px" })), P.observe(e), () => {
91
+ P == null || P.unobserve(e), e.removeAttribute("data-alea-offscreen");
86
92
  });
87
93
  }
88
- function fe() {
89
- const t = h(null);
90
- return y(() => t.current ? ee(t.current) : void 0, []), t;
94
+ function be() {
95
+ const e = w(null);
96
+ return h(() => e.current ? le(e.current) : void 0, []), e;
91
97
  }
92
- function me(t = 8) {
93
- const [e, n] = N("up");
94
- return y(() => {
95
- let o = window.scrollY;
96
- const a = () => {
97
- const r = window.scrollY;
98
- Math.abs(r - o) < t || (n(r > o && r > 64 ? "down" : "up"), o = r);
98
+ function Ee(e = 8) {
99
+ const [t, n] = L("up");
100
+ return h(() => {
101
+ let r = window.scrollY;
102
+ const i = () => {
103
+ const o = window.scrollY;
104
+ Math.abs(o - r) < e || (n(o > r && o > 64 ? "down" : "up"), r = o);
99
105
  };
100
- return window.addEventListener("scroll", a, { passive: !0 }), () => window.removeEventListener("scroll", a);
101
- }, [t]), e;
106
+ return window.addEventListener("scroll", i, { passive: !0 }), () => window.removeEventListener("scroll", i);
107
+ }, [e]), t;
102
108
  }
103
- function pe() {
104
- return { onPointerDown: T((e) => {
105
- const n = e.currentTarget, o = n.getBoundingClientRect(), a = Math.hypot(Math.max(e.clientX - o.left, o.right - e.clientX), Math.max(e.clientY - o.top, o.bottom - e.clientY)) * 2, r = document.createElement("span");
106
- r.className = "alea-ripple", r.setAttribute("aria-hidden", "true"), r.style.setProperty("--alea-ripple-x", `${e.clientX - o.left}px`), r.style.setProperty("--alea-ripple-y", `${e.clientY - o.top}px`), r.style.setProperty("--alea-ripple-size", `${a}px`), n.appendChild(r), r.addEventListener("animationend", () => r.remove()), window.setTimeout(() => r.remove(), 1200);
109
+ function Se() {
110
+ return { onPointerDown: C((t) => {
111
+ const n = t.currentTarget, r = n.getBoundingClientRect(), i = Math.hypot(Math.max(t.clientX - r.left, r.right - t.clientX), Math.max(t.clientY - r.top, r.bottom - t.clientY)) * 2, o = document.createElement("span");
112
+ o.className = "alea-ripple", o.setAttribute("aria-hidden", "true"), o.style.setProperty("--alea-ripple-x", `${t.clientX - r.left}px`), o.style.setProperty("--alea-ripple-y", `${t.clientY - r.top}px`), o.style.setProperty("--alea-ripple-size", `${i}px`), n.appendChild(o), o.addEventListener("animationend", () => o.remove()), window.setTimeout(() => o.remove(), 1200);
107
113
  }, []), className: "alea-ripple-host" };
108
114
  }
109
- function ge(t) {
110
- const e = typeof document < "u" ? document : null;
111
- e != null && e.startViewTransition ? e.startViewTransition(t) : t();
115
+ function Ne(e) {
116
+ const t = typeof document < "u" ? document : null;
117
+ t != null && t.startViewTransition ? t.startViewTransition(e) : e();
112
118
  }
113
- function ve({ as: t = "div", motion: e = "rise", delay: n, once: o = !0, stagger: a, className: r, style: i, children: s, ...f }) {
114
- const [c, l] = q({ once: o }), [d, g] = N(!1);
115
- F(() => {
116
- const p = c.current;
117
- p && p.getBoundingClientRect().top > window.innerHeight && g(!0);
119
+ function Me({ as: e = "div", motion: t = "rise", delay: n, once: r = !0, stagger: i, className: o, style: a, children: s, ...d }) {
120
+ const [l, c] = se({ once: r }), [u, v] = L(!1);
121
+ Y(() => {
122
+ const p = l.current;
123
+ p && p.getBoundingClientRect().top > window.innerHeight && v(!0);
118
124
  }, []);
119
- const u = typeof e == "string" ? { enter: e } : e;
120
- return S(t, {
121
- ...f,
122
- ref: c,
123
- className: r,
124
- "data-reveal": d && !l ? "pending" : d ? "in" : void 0,
125
- "data-stagger": a ? "reveal" : void 0,
126
- style: { ...a ? {} : R({ ...u, delay: n ?? u.delay }), ...i }
125
+ const g = typeof t == "string" ? { enter: t } : t;
126
+ return $(e, {
127
+ ...d,
128
+ ref: l,
129
+ className: o,
130
+ "data-reveal": u && !c ? "pending" : u ? "in" : void 0,
131
+ "data-stagger": i ? "reveal" : void 0,
132
+ style: { ...i ? {} : V({ ...g, delay: n ?? g.delay }), ...a }
127
133
  }, s);
128
134
  }
129
- function we({ show: t, exitClassName: e = "alea-dissolve-out", children: n }) {
130
- const [o, a] = N(t), [r, i] = N(!1), s = h(null);
131
- return y(() => {
132
- var d;
133
- if (t) {
134
- a(!0), i(!1);
135
+ function Le({ show: e, exitClassName: t = "alea-dissolve-out", children: n }) {
136
+ const [r, i] = L(e), [o, a] = L(!1), s = w(null);
137
+ return h(() => {
138
+ var u;
139
+ if (e) {
140
+ i(!0), a(!1);
135
141
  return;
136
142
  }
137
- if (!o) return;
138
- i(!0);
139
- const f = s.current, c = () => {
140
- a(!1), i(!1);
141
- }, l = ((d = f == null ? void 0 : f.getAnimations) == null ? void 0 : d.call(f)) || [];
142
- if (!f || !l.length) {
143
- const g = window.setTimeout(c, 0);
144
- return () => window.clearTimeout(g);
143
+ if (!r) return;
144
+ a(!0);
145
+ const d = s.current, l = () => {
146
+ i(!1), a(!1);
147
+ }, c = ((u = d == null ? void 0 : d.getAnimations) == null ? void 0 : u.call(d)) || [];
148
+ if (!d || !c.length) {
149
+ const v = window.setTimeout(l, 0);
150
+ return () => window.clearTimeout(v);
145
151
  }
146
- Promise.all(l.map((g) => g.finished.catch(() => {
147
- }))).then(c);
148
- }, [t]), y(() => {
149
- var f, c;
150
- r && s.current && !((c = (f = s.current).getAnimations) != null && c.call(f).length) && (a(!1), i(!1));
151
- }, [r]), !o || !A(n) ? null : C(n, { ref: s, className: [n.props.className, r && e].filter(Boolean).join(" ") });
152
+ Promise.all(c.map((v) => v.finished.catch(() => {
153
+ }))).then(l);
154
+ }, [e]), h(() => {
155
+ var d, l;
156
+ o && s.current && !((l = (d = s.current).getAnimations) != null && l.call(d).length) && (i(!1), a(!1));
157
+ }, [o]), !r || !F(n) ? null : H(n, { ref: s, className: [n.props.className, o && t].filter(Boolean).join(" ") });
152
158
  }
153
- function he({ children: t, as: e = "span", className: n, direction: o = "up", variant: a = "blur" }) {
154
- const [r, i] = N([{ id: 0, node: t }]), s = h(t), f = h(0), c = (l) => {
155
- var d;
156
- return typeof l == "string" || typeof l == "number" ? String(l) : A(l) ? String(l.key ?? "") + JSON.stringify(((d = l.props) == null ? void 0 : d.children) ?? "") : "";
159
+ function $e({ children: e, as: t = "span", className: n, direction: r = "up", variant: i = "blur" }) {
160
+ const [o, a] = L([{ id: 0, node: e }]), s = w(e), d = w(0), l = (c) => {
161
+ var u;
162
+ return typeof c == "string" || typeof c == "number" ? String(c) : F(c) ? String(c.key ?? "") + JSON.stringify(((u = c.props) == null ? void 0 : u.children) ?? "") : "";
157
163
  };
158
- return y(() => {
159
- if (c(t) === c(s.current)) {
160
- i((l) => l.map((d) => d.out ? d : { ...d, node: t }));
164
+ return h(() => {
165
+ if (l(e) === l(s.current)) {
166
+ a((c) => c.map((u) => u.out ? u : { ...u, node: e }));
161
167
  return;
162
168
  }
163
- s.current = t, f.current += 1, i((l) => [...l.filter((d) => !d.out).map((d) => ({ ...d, out: !0 })), { id: f.current, node: t }]);
164
- }, [t]), S(
165
- e,
166
- { className: ["alea-swap", n].filter(Boolean).join(" "), "data-variant": a === "scale" ? "scale" : void 0, style: { "--alea-swap-dir": o === "up" ? 1 : -1 }, "aria-live": "polite" },
167
- r.map((l) => /* @__PURE__ */ E("span", { className: l.id === 0 && !l.out ? void 0 : l.out ? "alea-swap-out" : "alea-swap-in", "aria-hidden": l.out || void 0, onAnimationEnd: l.out ? () => i((d) => d.filter((g) => g.id !== l.id)) : void 0, children: l.node }, l.id))
169
+ s.current = e, d.current += 1, a((c) => [...c.filter((u) => !u.out).map((u) => ({ ...u, out: !0 })), { id: d.current, node: e }]);
170
+ }, [e]), $(
171
+ t,
172
+ { className: ["alea-swap", n].filter(Boolean).join(" "), "data-variant": i === "scale" ? "scale" : void 0, style: { "--alea-swap-dir": r === "up" ? 1 : -1 }, "aria-live": "polite" },
173
+ o.map((c) => /* @__PURE__ */ S("span", { className: c.id === 0 && !c.out ? void 0 : c.out ? "alea-swap-out" : "alea-swap-in", "aria-hidden": c.out || void 0, onAnimationEnd: c.out ? () => a((u) => u.filter((v) => v.id !== c.id)) : void 0, children: c.node }, c.id))
168
174
  );
169
175
  }
170
- function ye({ value: t, format: e, locale: n, className: o, live: a = !0, label: r }) {
171
- const i = new Intl.NumberFormat(n, e).format(t);
172
- return /* @__PURE__ */ D("span", { className: ["alea-roll", o].filter(Boolean).join(" "), children: [
173
- /* @__PURE__ */ E("span", { className: "alea-visually-hidden", "aria-live": a ? "polite" : void 0, children: r ? `${r} ${i}` : i }),
174
- /* @__PURE__ */ E("span", { "aria-hidden": "true", style: { display: "inline-flex" }, children: [...i].map((s, f) => /\d/.test(s) ? /* @__PURE__ */ E("span", { className: "alea-roll-digit", children: /* @__PURE__ */ E("span", { className: "alea-roll-strip", style: { "--alea-roll-n": s }, children: "0123456789".split("").map((c) => /* @__PURE__ */ E("span", { children: c }, c)) }) }, i.length - f) : /* @__PURE__ */ E("span", { children: s }, `s${i.length - f}`)) })
176
+ function ke({ value: e, format: t, locale: n, className: r, live: i = !0, label: o }) {
177
+ const a = new Intl.NumberFormat(n, t).format(e);
178
+ return /* @__PURE__ */ _("span", { className: ["alea-roll", r].filter(Boolean).join(" "), children: [
179
+ /* @__PURE__ */ S("span", { className: "alea-visually-hidden", "aria-live": i ? "polite" : void 0, children: o ? `${o} ${a}` : a }),
180
+ /* @__PURE__ */ S("span", { "aria-hidden": "true", style: { display: "inline-flex" }, children: [...a].map((s, d) => /\d/.test(s) ? /* @__PURE__ */ S("span", { className: "alea-roll-digit", children: /* @__PURE__ */ S("span", { className: "alea-roll-strip", style: { "--alea-roll-n": s }, children: "0123456789".split("").map((l) => /* @__PURE__ */ S("span", { children: l }, l)) }) }, a.length - d) : /* @__PURE__ */ S("span", { children: s }, `s${a.length - d}`)) })
175
181
  ] });
176
182
  }
177
- function xe({ children: t, className: e, as: n = "div" }) {
178
- const o = h(null), [a, r] = N(void 0);
179
- return y(() => {
180
- const i = o.current;
181
- if (!i || typeof ResizeObserver > "u") return;
182
- const s = new ResizeObserver(() => r(i.offsetHeight));
183
- return s.observe(i), () => s.disconnect();
184
- }, []), S(n, { className: ["alea-autoheight", e].filter(Boolean).join(" "), style: a != null ? { height: a } : void 0 }, /* @__PURE__ */ E("div", { ref: o, children: t }));
183
+ function Ae({ children: e, className: t, as: n = "div" }) {
184
+ const r = w(null), [i, o] = L(void 0);
185
+ return h(() => {
186
+ const a = r.current;
187
+ if (!a || typeof ResizeObserver > "u") return;
188
+ const s = new ResizeObserver(() => o(a.offsetHeight));
189
+ return s.observe(a), () => s.disconnect();
190
+ }, []), $(n, { className: ["alea-autoheight", t].filter(Boolean).join(" "), style: i != null ? { height: i } : void 0 }, /* @__PURE__ */ S("div", { ref: r, children: e }));
185
191
  }
186
- function be({ className: t }) {
187
- const e = h(null), [n, o] = N(!1);
188
- return y(() => {
189
- var r;
190
- if (typeof CSS < "u" && ((r = CSS.supports) != null && r.call(CSS, "animation-timeline: scroll()"))) {
191
- o(!0);
192
+ function Ie({ className: e }) {
193
+ const t = w(null), [n, r] = L(!1);
194
+ return h(() => {
195
+ var o;
196
+ if (typeof CSS < "u" && ((o = CSS.supports) != null && o.call(CSS, "animation-timeline: scroll()"))) {
197
+ r(!0);
192
198
  return;
193
199
  }
194
- const a = () => {
200
+ const i = () => {
195
201
  var s;
196
- const i = document.documentElement.scrollHeight - window.innerHeight;
197
- (s = e.current) == null || s.style.setProperty("--alea-scroll", String(i > 0 ? Math.min(1, window.scrollY / i) : 0));
202
+ const a = document.documentElement.scrollHeight - window.innerHeight;
203
+ (s = t.current) == null || s.style.setProperty("--alea-scroll", String(a > 0 ? Math.min(1, window.scrollY / a) : 0));
198
204
  };
199
- return a(), window.addEventListener("scroll", a, { passive: !0 }), window.addEventListener("resize", a), () => {
200
- window.removeEventListener("scroll", a), window.removeEventListener("resize", a);
205
+ return i(), window.addEventListener("scroll", i, { passive: !0 }), window.addEventListener("resize", i), () => {
206
+ window.removeEventListener("scroll", i), window.removeEventListener("resize", i);
201
207
  };
202
- }, []), /* @__PURE__ */ E("div", { ref: e, className: ["alea-scroll-progress", t].filter(Boolean).join(" "), "data-css": n || void 0, "aria-hidden": "true" });
208
+ }, []), /* @__PURE__ */ S("div", { ref: t, className: ["alea-scroll-progress", e].filter(Boolean).join(" "), "data-css": n || void 0, "aria-hidden": "true" });
203
209
  }
204
- function Ee({ chunks: t, streaming: e = !1, className: n, as: o = "p" }) {
205
- return S(
206
- o,
207
- { className: ["alea-stream", n].filter(Boolean).join(" "), "data-streaming": e || void 0, "aria-busy": e || void 0 },
208
- H.toArray(t.map((a, r) => /* @__PURE__ */ E("span", { className: "alea-stream-chunk", children: a }, r)))
210
+ function je({ chunks: e, streaming: t = !1, className: n, as: r = "p" }) {
211
+ return $(
212
+ r,
213
+ { className: ["alea-stream", n].filter(Boolean).join(" "), "data-streaming": t || void 0, "aria-busy": t || void 0 },
214
+ U.toArray(e.map((i, o) => /* @__PURE__ */ S("span", { className: "alea-stream-chunk", children: i }, o)))
209
215
  );
210
216
  }
211
- const P = /* @__PURE__ */ new Map(), z = (t) => {
212
- const e = t.getBoundingClientRect();
213
- return { x: e.left + window.scrollX, y: e.top + window.scrollY, w: e.width, h: e.height, radius: getComputedStyle(t).borderRadius, time: performance.now() };
217
+ const R = /* @__PURE__ */ new Map(), X = (e) => {
218
+ const t = e.getBoundingClientRect();
219
+ return { x: t.left + window.scrollX, y: t.top + window.scrollY, w: t.width, h: t.height, radius: getComputedStyle(e).borderRadius, time: performance.now() };
214
220
  };
215
- function Ne({ id: t, as: e = "div", duration: n, easing: o, fadeContent: a = !0, className: r, style: i, children: s, ...f }) {
216
- const c = h(null), l = Y();
217
- return F(() => {
218
- const d = c.current;
219
- if (!d) return;
220
- const g = P.get(t), u = z(d);
221
- if (g && !l && performance.now() - g.time < 1500 && (g.w !== u.w || g.h !== u.h || g.x !== u.x || g.y !== u.y) && typeof d.animate == "function") {
222
- const x = n ?? (parseFloat(getComputedStyle(d).getPropertyValue("--alea-motion-duration-slow")) || 480), v = o ?? (getComputedStyle(d).getPropertyValue("--alea-motion-ease-standard").trim() || "cubic-bezier(0.2, 0, 0, 1)"), w = g.w / Math.max(1, u.w), b = g.h / Math.max(1, u.h);
223
- if (d.animate([
224
- { transformOrigin: "0 0", transform: `translate(${g.x - u.x}px, ${g.y - u.y}px) scale(${w}, ${b})`, borderRadius: g.radius },
225
- { transformOrigin: "0 0", transform: "none", borderRadius: u.radius }
226
- ], { duration: x, easing: v }), a) for (const $ of Array.from(d.children)) $.animate([{ opacity: 0 }, { opacity: 0, offset: 0.35 }, { opacity: 1 }], { duration: x, easing: "ease-out" });
221
+ function Oe({ id: e, as: t = "div", duration: n, easing: r, fadeContent: i = !0, className: o, style: a, children: s, ...d }) {
222
+ const l = w(null), c = W();
223
+ return Y(() => {
224
+ const u = l.current;
225
+ if (!u) return;
226
+ const v = R.get(e), g = X(u);
227
+ if (v && !c && performance.now() - v.time < 1500 && (v.w !== g.w || v.h !== g.h || v.x !== g.x || v.y !== g.y) && typeof u.animate == "function") {
228
+ const k = n ?? (parseFloat(getComputedStyle(u).getPropertyValue("--alea-motion-duration-slow")) || 480), b = r ?? (getComputedStyle(u).getPropertyValue("--alea-motion-ease-standard").trim() || "cubic-bezier(0.2, 0, 0, 1)"), f = v.w / Math.max(1, g.w), m = v.h / Math.max(1, g.h);
229
+ if (u.animate([
230
+ { transformOrigin: "0 0", transform: `translate(${v.x - g.x}px, ${v.y - g.y}px) scale(${f}, ${m})`, borderRadius: v.radius },
231
+ { transformOrigin: "0 0", transform: "none", borderRadius: g.radius }
232
+ ], { duration: k, easing: b }), i) for (const N of Array.from(u.children)) N.animate([{ opacity: 0 }, { opacity: 0, offset: 0.35 }, { opacity: 1 }], { duration: k, easing: "ease-out" });
227
233
  }
228
- P.set(t, u);
229
- const m = () => {
230
- d.isConnected && P.set(t, z(d));
234
+ R.set(e, g);
235
+ const y = () => {
236
+ u.isConnected && R.set(e, X(u));
231
237
  };
232
- window.addEventListener("scroll", m, { passive: !0 });
233
- const p = typeof ResizeObserver < "u" ? new ResizeObserver(m) : null;
234
- return p == null || p.observe(d), () => {
235
- m(), P.set(t, { ...P.get(t) || u, time: performance.now() }), window.removeEventListener("scroll", m), p == null || p.disconnect();
238
+ window.addEventListener("scroll", y, { passive: !0 });
239
+ const p = typeof ResizeObserver < "u" ? new ResizeObserver(y) : null;
240
+ return p == null || p.observe(u), () => {
241
+ y(), R.set(e, { ...R.get(e) || g, time: performance.now() }), window.removeEventListener("scroll", y), p == null || p.disconnect();
236
242
  };
237
- }, [t]), S(e, { ...f, ref: c, className: r, style: i, "data-morph": t }, s);
243
+ }, [e]), $(t, { ...d, ref: l, className: o, style: a, "data-morph": e }, s);
238
244
  }
239
- function Se({ from: t, to: e, active: n, className: o }) {
240
- return /* @__PURE__ */ D("span", { className: ["alea-morph-icon", o].filter(Boolean).join(" "), "data-active": n || void 0, "aria-hidden": "true", children: [
241
- /* @__PURE__ */ E("span", { className: "alea-morph-icon-a", children: t }),
242
- /* @__PURE__ */ E("span", { className: "alea-morph-icon-b", children: e })
245
+ function Te({ from: e, to: t, active: n, className: r }) {
246
+ return /* @__PURE__ */ _("span", { className: ["alea-morph-icon", r].filter(Boolean).join(" "), "data-active": n || void 0, "aria-hidden": "true", children: [
247
+ /* @__PURE__ */ S("span", { className: "alea-morph-icon-a", children: e }),
248
+ /* @__PURE__ */ S("span", { className: "alea-morph-icon-b", children: t })
243
249
  ] });
244
250
  }
245
- const te = { lift: "alea-hover-lift", press: "alea-press", tint: "alea-hover-tint", glow: "alea-hover-glow", hint: "alea-hint" };
246
- function ne(t, { on: e = "mount", value: n, delay: o, duration: a, once: r = !0 } = {}) {
247
- const i = h(null);
248
- y(() => {
249
- const l = i.current;
250
- if (e !== "visible" || !l) return;
251
+ const ce = { lift: "alea-hover-lift", press: "alea-press", tint: "alea-hover-tint", glow: "alea-hover-glow", hint: "alea-hint" };
252
+ function ue(e, { on: t = "mount", value: n, delay: r, duration: i, once: o = !0 } = {}) {
253
+ const a = w(null);
254
+ h(() => {
255
+ const c = a.current;
256
+ if (t !== "visible" || !c) return;
251
257
  if (typeof IntersectionObserver > "u") {
252
- l.setAttribute("data-m-in", "");
258
+ c.setAttribute("data-m-in", "");
253
259
  return;
254
260
  }
255
- const d = new IntersectionObserver((g) => {
256
- for (const u of g)
257
- u.isIntersecting ? (l.setAttribute("data-m-in", ""), r && d.disconnect()) : r || l.removeAttribute("data-m-in");
261
+ const u = new IntersectionObserver((v) => {
262
+ for (const g of v)
263
+ g.isIntersecting ? (c.setAttribute("data-m-in", ""), o && u.disconnect()) : o || c.removeAttribute("data-m-in");
258
264
  }, { rootMargin: "0px 0px -8% 0px" });
259
- return d.observe(l), () => d.disconnect();
260
- }, [e, r]);
261
- const s = h(n);
262
- y(() => {
263
- if (e !== "change" || Object.is(s.current, n)) return;
265
+ return u.observe(c), () => u.disconnect();
266
+ }, [t, o]);
267
+ const s = w(n);
268
+ h(() => {
269
+ if (t !== "change" || Object.is(s.current, n)) return;
264
270
  s.current = n;
265
- const l = i.current;
266
- l && (l.removeAttribute("data-m-run"), l.offsetWidth, l.setAttribute("data-m-run", ""));
267
- }, [e, n]);
268
- const f = {};
269
- if (o != null && (f["--alea-m-delay"] = `${o}ms`), a != null && (f["--alea-m-duration"] = `${a}ms`), t === "stagger") return { ref: i, "data-stagger": "", style: f };
270
- const c = te[t];
271
- return c ? { ref: i, className: c, style: f } : { ref: i, className: "alea-m", "data-m": t, "data-m-on": e, ...e === "loop" ? { "data-alea-loop": "" } : {}, style: f };
271
+ const c = a.current;
272
+ c && (c.removeAttribute("data-m-run"), c.offsetWidth, c.setAttribute("data-m-run", ""));
273
+ }, [t, n]);
274
+ const d = {};
275
+ if (r != null && (d["--alea-m-delay"] = `${r}ms`), i != null && (d["--alea-m-duration"] = `${i}ms`), e === "stagger") return { ref: a, "data-stagger": "", style: d };
276
+ const l = ce[e];
277
+ return l ? { ref: a, className: l, style: d } : { ref: a, className: "alea-m", "data-m": e, "data-m-on": t, ...t === "loop" ? { "data-alea-loop": "" } : {}, style: d };
272
278
  }
273
- function $e({ pattern: t, children: e, ...n }) {
274
- const o = ne(t, n), a = H.only(e);
275
- if (!A(a)) return e;
276
- const r = a.props.ref, i = (d) => {
277
- o.ref.current = d, typeof r == "function" ? r(d) : r && typeof r == "object" && (r.current = d);
278
- }, { ref: s, className: f, style: c, ...l } = o;
279
- return C(a, { ...l, ref: i, className: [a.props.className, f].filter(Boolean).join(" ") || void 0, style: { ...a.props.style, ...c } });
279
+ function Pe({ pattern: e, children: t, ...n }) {
280
+ const r = ue(e, n), i = U.only(t);
281
+ if (!F(i)) return t;
282
+ const o = i.props.ref, a = (u) => {
283
+ r.ref.current = u, typeof o == "function" ? o(u) : o && typeof o == "object" && (o.current = u);
284
+ }, { ref: s, className: d, style: l, ...c } = r;
285
+ return H(i, { ...c, ref: a, className: [i.props.className, d].filter(Boolean).join(" ") || void 0, style: { ...i.props.style, ...l } });
280
286
  }
281
- function Me({ as: t = "div", strength: e = 16, scroll: n = !1, className: o, style: a, children: r, ...i }) {
282
- const s = h(null), f = Y();
283
- return y(() => {
284
- var x;
285
- const c = s.current;
286
- if (!c || f || typeof window > "u") return;
287
- const l = (x = window.matchMedia) == null ? void 0 : x.call(window, "(pointer: fine)").matches, d = (v, w) => {
288
- c.style.setProperty("--alea-par-x", v.toFixed(3)), c.style.setProperty("--alea-par-y", w.toFixed(3));
289
- }, g = (v) => {
290
- const w = c.getBoundingClientRect();
291
- d(((v.clientX - w.left) / w.width - 0.5) * 2, ((v.clientY - w.top) / w.height - 0.5) * 2);
292
- }, u = () => d(0, 0);
293
- let m = 0;
287
+ function Re({ as: e = "div", strength: t = 16, scroll: n = !1, className: r, style: i, children: o, ...a }) {
288
+ const s = w(null), d = W();
289
+ return h(() => {
290
+ var k;
291
+ const l = s.current;
292
+ if (!l || d || typeof window > "u") return;
293
+ const c = (k = window.matchMedia) == null ? void 0 : k.call(window, "(pointer: fine)").matches, u = (b, f) => {
294
+ l.style.setProperty("--alea-par-x", b.toFixed(3)), l.style.setProperty("--alea-par-y", f.toFixed(3));
295
+ }, v = (b) => {
296
+ const f = l.getBoundingClientRect();
297
+ u(((b.clientX - f.left) / f.width - 0.5) * 2, ((b.clientY - f.top) / f.height - 0.5) * 2);
298
+ }, g = () => u(0, 0);
299
+ let y = 0;
294
300
  const p = () => {
295
- cancelAnimationFrame(m), m = requestAnimationFrame(() => {
296
- const v = c.getBoundingClientRect(), w = v.top + v.height / 2 - window.innerHeight / 2;
297
- c.style.setProperty("--alea-par-s", Math.max(-1, Math.min(1, w / window.innerHeight)).toFixed(3));
301
+ cancelAnimationFrame(y), y = requestAnimationFrame(() => {
302
+ const b = l.getBoundingClientRect(), f = b.top + b.height / 2 - window.innerHeight / 2;
303
+ l.style.setProperty("--alea-par-s", Math.max(-1, Math.min(1, f / window.innerHeight)).toFixed(3));
298
304
  });
299
305
  };
300
- return l && (c.addEventListener("pointermove", g), c.addEventListener("pointerleave", u)), n && (window.addEventListener("scroll", p, { passive: !0 }), p()), () => {
301
- c.removeEventListener("pointermove", g), c.removeEventListener("pointerleave", u), window.removeEventListener("scroll", p), cancelAnimationFrame(m);
306
+ return c && (l.addEventListener("pointermove", v), l.addEventListener("pointerleave", g)), n && (window.addEventListener("scroll", p, { passive: !0 }), p()), () => {
307
+ l.removeEventListener("pointermove", v), l.removeEventListener("pointerleave", g), window.removeEventListener("scroll", p), cancelAnimationFrame(y);
302
308
  };
303
- }, [f, n]), S(t, { ...i, ref: s, className: ["alea-parallax", o].filter(Boolean).join(" "), style: { "--alea-par-strength": `${e}px`, ...a } }, r);
309
+ }, [d, n]), $(e, { ...a, ref: s, className: ["alea-parallax", r].filter(Boolean).join(" "), style: { "--alea-par-strength": `${t}px`, ...i } }, o);
304
310
  }
305
- function ke({ as: t = "div", depth: e = 0.5, className: n, style: o, children: a, ...r }) {
306
- return S(t, { ...r, className: ["alea-parallax-layer", n].filter(Boolean).join(" "), style: { "--alea-depth": e, ...o } }, a);
311
+ function Be({ as: e = "div", depth: t = 0.5, className: n, style: r, children: i, ...o }) {
312
+ return $(e, { ...o, className: ["alea-parallax-layer", n].filter(Boolean).join(" "), style: { "--alea-depth": t, ...r } }, i);
307
313
  }
308
- const re = parseInt(W, 10) >= 19 ? !0 : "";
309
- function oe({ layer: t, leaving: e, entering: n, style: o, onDone: a }) {
310
- const r = h(null);
311
- return y(() => {
312
- var c;
313
- if (!e) return;
314
- const i = r.current, s = ((c = i == null ? void 0 : i.getAnimations) == null ? void 0 : c.call(i)) || [];
315
- if (!i || !s.length) {
316
- const l = window.setTimeout(() => a(t.key), 0);
317
- return () => window.clearTimeout(l);
314
+ const de = parseInt(Z, 10) >= 19 ? !0 : "";
315
+ function fe({ layer: e, leaving: t, entering: n, style: r, onDone: i }) {
316
+ const o = w(null);
317
+ return h(() => {
318
+ var l;
319
+ if (!t) return;
320
+ const a = o.current, s = ((l = a == null ? void 0 : a.getAnimations) == null ? void 0 : l.call(a)) || [];
321
+ if (!a || !s.length) {
322
+ const c = window.setTimeout(() => i(e.key), 0);
323
+ return () => window.clearTimeout(c);
318
324
  }
319
- let f = !0;
320
- return Promise.all(s.map((l) => l.finished.catch(() => {
325
+ let d = !0;
326
+ return Promise.all(s.map((c) => c.finished.catch(() => {
321
327
  }))).then(() => {
322
- f && a(t.key);
328
+ d && i(e.key);
323
329
  }), () => {
324
- f = !1;
330
+ d = !1;
325
331
  };
326
- }, [e]), S("div", { ref: r, className: "alea-page-layer", "data-leaving": e || void 0, "data-entering": n || void 0, style: o, inert: e ? re : void 0, "aria-hidden": e || void 0 }, t.node);
332
+ }, [t]), $("div", { ref: o, className: "alea-page-layer", "data-leaving": t || void 0, "data-entering": n || void 0, style: r, inert: t ? de : void 0, "aria-hidden": t || void 0 }, e.node);
327
333
  }
328
- function Le({ routeKey: t, pattern: e = "fade", duration: n, exitDuration: o, as: a = "div", className: r, style: i, children: s, ...f }) {
329
- const [c, l] = N({ key: t, leaving: [], changed: !1 }), d = h(s);
330
- c.key !== t ? l({ key: t, leaving: [...c.leaving.filter((p) => p.key !== t), { key: c.key, node: d.current }], changed: !0 }) : d.current = s;
331
- const g = T((p) => l((x) => ({ ...x, leaving: x.leaving.filter((v) => v.key !== p) })), []), u = R({ enter: e, exit: e, duration: n, exitDuration: o }), m = [...c.leaving.map((p) => ({ ...p, leaving: !0 })), { key: t, node: s, leaving: !1 }];
332
- return S(
333
- a,
334
- { ...f, className: ["alea-page-transition", r].filter(Boolean).join(" "), style: i },
335
- m.map((p) => S(oe, { key: p.key, layer: p, leaving: p.leaving, entering: !p.leaving && c.changed, style: u, onDone: g }))
334
+ function Ce({ routeKey: e, pattern: t = "fade", duration: n, exitDuration: r, as: i = "div", className: o, style: a, children: s, ...d }) {
335
+ const [l, c] = L({ key: e, leaving: [], changed: !1 }), u = w(s);
336
+ l.key !== e ? c({ key: e, leaving: [...l.leaving.filter((p) => p.key !== e), { key: l.key, node: u.current }], changed: !0 }) : u.current = s;
337
+ const v = C((p) => c((k) => ({ ...k, leaving: k.leaving.filter((b) => b.key !== p) })), []), g = V({ enter: t, exit: t, duration: n, exitDuration: r }), y = [...l.leaving.map((p) => ({ ...p, leaving: !0 })), { key: e, node: s, leaving: !1 }];
338
+ return $(
339
+ i,
340
+ { ...d, className: ["alea-page-transition", o].filter(Boolean).join(" "), style: a },
341
+ y.map((p) => $(fe, { key: p.key, layer: p, leaving: p.leaving, entering: !p.leaving && l.changed, style: g, onDone: v }))
336
342
  );
337
343
  }
338
- function ae(t, e, n = !0) {
339
- const o = t ?? [], [a, r] = N(() => o.map((u, m) => ({ item: u, key: e(u), leaving: !1, entering: !1, enterIndex: m }))), i = h(t), s = h(/* @__PURE__ */ new Map());
340
- i.current !== t && (i.current = t, r((u) => {
341
- const m = o.map(e), p = new Set(m), x = new Set(u.map((b) => b.key));
342
- let v = 0;
343
- const w = o.map((b, $) => {
344
- var k, L, V;
345
- const M = m[$], O = !x.has(M) || ((k = u.find((I) => I.key === M)) == null ? void 0 : k.leaving) === !0;
346
- return { item: b, key: M, leaving: !1, entering: n && (O || !!((L = u.find((I) => I.key === M)) != null && L.entering)), enterIndex: O ? v++ : ((V = u.find((I) => I.key === M)) == null ? void 0 : V.enterIndex) ?? 0 };
344
+ const G = "alea-row-leave", pe = 1e3;
345
+ function me(e, t, n = !0) {
346
+ const r = e ?? [], { enter: i, leave: o } = K(n, r.length), a = q(n), [s, d] = L(() => r.map((f, m) => ({ item: f, key: t(f), leaving: !1, entering: !1, enterIndex: m }))), l = w(e), c = w(a), u = w(/* @__PURE__ */ new Map()), v = !ee(c.current, a);
347
+ (l.current !== e || v) && (l.current = e, c.current = a, d((f) => {
348
+ const m = r.map(t);
349
+ if (v) return r.map((x, E) => ({ item: x, key: m[E], leaving: !1, entering: !1, enterIndex: E }));
350
+ const N = new Set(m), A = new Map(f.map((x) => [x.key, x]));
351
+ let z = 0;
352
+ const I = r.map((x, E) => {
353
+ const j = m[E], M = A.get(j), O = !M || M.leaving;
354
+ return { item: x, key: j, leaving: !1, entering: i && (O || !!(M != null && M.entering)), enterIndex: O ? z++ : (M == null ? void 0 : M.enterIndex) ?? 0 };
347
355
  });
348
- return n && u.forEach((b, $) => {
349
- p.has(b.key) || w.splice(Math.min($, w.length), 0, { ...b, leaving: !0, entering: !1 });
350
- }), w;
356
+ return o && f.forEach((x, E) => {
357
+ N.has(x.key) || I.splice(Math.min(E, I.length), 0, { ...x, leaving: !0, entering: !1 });
358
+ }), I;
351
359
  }));
352
- const f = T((u) => r((m) => m.filter((p) => !(p.key === u && p.leaving))), []), c = a.filter((u) => u.leaving).map((u) => String(u.key)).join("|");
353
- F(() => {
354
- for (const u of a) if (u.leaving) {
355
- const m = s.current.get(u.key);
360
+ const g = C((f) => d((m) => m.filter((N) => !(N.key === f && N.leaving))), []), y = s.filter((f) => f.leaving).map((f) => String(f.key)).join("|");
361
+ Y(() => {
362
+ for (const f of s) if (f.leaving) {
363
+ const m = u.current.get(f.key);
356
364
  m && m.style.setProperty("--alea-row-h", `${m.offsetHeight}px`);
357
365
  }
358
- }, [c]);
359
- const l = h(/* @__PURE__ */ new Map()), d = (u) => {
360
- let m = !0, p = 0, x;
361
- const v = () => {
362
- m && (m = !1, window.clearTimeout(x), l.current.delete(u), f(u));
363
- }, w = () => {
366
+ }, [y]);
367
+ const p = w(/* @__PURE__ */ new Map()), k = (f) => {
368
+ let m = !0, N = 0, A;
369
+ const z = performance.now(), I = () => {
370
+ m && (m = !1, window.clearTimeout(A), p.current.delete(f), g(f));
371
+ }, x = () => {
364
372
  var M;
365
373
  if (!m) return;
366
- const b = s.current.get(u);
367
- if (!b || b.closest('[data-alea-motion="off"]')) return v();
368
- const $ = ((M = b.getAnimations) == null ? void 0 : M.call(b)) ?? [];
369
- if ($.length) {
370
- const O = Math.max(0, ...$.map((k) => {
371
- var L;
372
- return Number((L = k.effect) == null ? void 0 : L.getComputedTiming().endTime) || 0;
374
+ const E = u.current.get(f);
375
+ if (!E || E.closest('[data-alea-motion="off"]')) return I();
376
+ const j = (((M = E.getAnimations) == null ? void 0 : M.call(E)) ?? []).filter((O) => O.playState !== "finished");
377
+ if (j.length) {
378
+ const O = Math.max(0, ...j.map((T) => {
379
+ var B;
380
+ return Number((B = T.effect) == null ? void 0 : B.getComputedTiming().endTime) || 0;
373
381
  }));
374
- x = window.setTimeout(v, O + 100), Promise.all($.map((k) => k.finished.catch(() => {
375
- }))).then(v);
376
- } else ++p > 4 ? v() : x = window.setTimeout(w, 16);
382
+ A = window.setTimeout(I, O + 100), Promise.allSettled(j.map((T) => T.finished)).then((T) => {
383
+ window.clearTimeout(A), T.some((B) => B.status === "fulfilled") ? I() : x();
384
+ });
385
+ } else !E.classList.contains(G) && performance.now() - z < pe ? A = window.setTimeout(x, 16) : ++N > 4 ? I() : A = window.setTimeout(x, 16);
377
386
  };
378
- return w(), () => {
379
- m = !1, window.clearTimeout(x);
387
+ return x(), () => {
388
+ m = !1, window.clearTimeout(A);
380
389
  };
381
390
  };
382
- y(() => {
383
- const u = new Set(a.filter((m) => m.leaving).map((m) => m.key));
384
- l.current.forEach((m, p) => {
385
- u.has(p) || (m(), l.current.delete(p));
386
- }), u.forEach((m) => {
387
- l.current.has(m) || l.current.set(m, d(m));
391
+ h(() => {
392
+ const f = new Set(s.filter((m) => m.leaving).map((m) => m.key));
393
+ p.current.forEach((m, N) => {
394
+ f.has(N) || (m(), p.current.delete(N));
395
+ }), f.forEach((m) => {
396
+ p.current.has(m) || p.current.set(m, k(m));
388
397
  });
389
- }, [c]), y(() => () => {
390
- l.current.forEach((u) => u()), l.current.clear();
398
+ }, [y]), h(() => () => {
399
+ p.current.forEach((f) => f()), p.current.clear();
391
400
  }, []);
392
- const g = T((u) => (m) => {
393
- m ? s.current.set(u, m) : s.current.delete(u);
401
+ const b = C((f) => (m) => {
402
+ m ? u.current.set(f, m) : u.current.delete(f);
394
403
  }, []);
395
- return { entries: a, ref: g };
404
+ return { entries: s, ref: b };
396
405
  }
397
- function Ie({ items: t, getKey: e, children: n, animate: o = !0 }) {
398
- const { entries: a, ref: r } = ae(t, e, o);
399
- return S(X, null, a.map((i) => {
400
- const s = n(i.item, { leaving: i.leaving, entering: i.entering });
401
- if (!A(s)) return null;
402
- const f = [s.props.className, i.leaving ? "alea-row-leave" : i.entering ? "alea-row-enter" : ""].filter(Boolean).join(" "), c = s.props.ref, l = (d) => {
403
- r(i.key)(d), typeof c == "function" ? c(d) : c && typeof c == "object" && (c.current = d);
406
+ function Fe({ items: e, getKey: t, children: n, animate: r = !0 }) {
407
+ const { entries: i, ref: o } = me(e, t, r);
408
+ return $(J, null, i.map((a) => {
409
+ const s = n(a.item, { leaving: a.leaving, entering: a.entering });
410
+ if (!F(s)) return null;
411
+ const d = [s.props.className, a.leaving ? G : a.entering ? "alea-row-enter" : ""].filter(Boolean).join(" "), l = s.props.ref, c = (u) => {
412
+ o(a.key)(u), typeof l == "function" ? l(u) : l && typeof l == "object" && (l.current = u);
404
413
  };
405
- return C(s, { key: i.key, className: f, ref: l, "data-leaving": i.leaving || void 0, style: i.entering ? { ...s.props.style, "--alea-i": Math.min(i.enterIndex, 11) } : s.props.style });
414
+ return H(s, { key: a.key, className: d, ref: c, "data-leaving": a.leaving || void 0, style: a.entering ? { ...s.props.style, "--alea-i": Math.min(a.enterIndex, 11) } : s.props.style });
406
415
  }));
407
416
  }
408
417
  export {
409
- xe as AutoHeight,
410
- J as MOTION_SELECTORS,
411
- Ne as Morph,
412
- Se as MorphIcon,
413
- $e as Motion,
414
- ye as NumberRoll,
415
- Le as PageTransition,
416
- Me as Parallax,
417
- ke as ParallaxLayer,
418
- we as Presence,
419
- Ie as PresenceList,
420
- ve as Reveal,
421
- be as ScrollProgress,
422
- Ee as StreamingText,
423
- he as TextSwap,
424
- ue as motionAttributes,
425
- de as motionComponentCss,
426
- R as motionStyle,
427
- ce as motionVariables,
428
- ee as pauseWhenOffscreen,
429
- ge as startViewTransition,
430
- q as useInView,
431
- ne as useMotion,
432
- fe as useOffscreenPause,
433
- ae as usePresenceList,
434
- Y as useReducedMotion,
435
- pe as useRipple,
436
- me as useScrollDirection,
437
- le as withMotionStyle
418
+ Ae as AutoHeight,
419
+ re as MOTION_SELECTORS,
420
+ Oe as Morph,
421
+ Te as MorphIcon,
422
+ Pe as Motion,
423
+ ke as NumberRoll,
424
+ Ce as PageTransition,
425
+ Re as Parallax,
426
+ Be as ParallaxLayer,
427
+ Le as Presence,
428
+ Fe as PresenceList,
429
+ Me as Reveal,
430
+ Ie as ScrollProgress,
431
+ je as StreamingText,
432
+ $e as TextSwap,
433
+ ye as motionAttributes,
434
+ xe as motionComponentCss,
435
+ V as motionStyle,
436
+ he as motionVariables,
437
+ le as pauseWhenOffscreen,
438
+ K as resolveRowMotion,
439
+ Ne as startViewTransition,
440
+ se as useInView,
441
+ ue as useMotion,
442
+ be as useOffscreenPause,
443
+ me as usePresenceList,
444
+ W as useReducedMotion,
445
+ Se as useRipple,
446
+ Ee as useScrollDirection,
447
+ we as withMotionStyle
438
448
  };
package/dist/react.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  import { type CSSProperties, type ElementType, type PointerEvent as ReactPointerEvent, type ReactElement, type ReactNode } from 'react';
2
+ import { type RowMotion } from './row-motion.js';
3
+ export { resolveRowMotion, type RowMotion, type RowMotionOptions } from './row-motion.js';
2
4
  /** The enter/exit presets. Each maps to the keyframes alea-m-<preset>-in and -out in motion.css. */
3
5
  export type MotionPreset = 'fade' | 'scale' | 'pop' | 'rise' | 'drop' | 'slide-up' | 'slide-down' | 'slide-left' | 'slide-right' | 'blur' | 'zoom' | 'flip' | 'morph' | 'none';
4
6
  /** The easing tokens, or any CSS easing. */
@@ -185,7 +187,7 @@ export declare function useMotion<T extends HTMLElement = HTMLElement>(pattern:
185
187
  'data-alea-loop'?: string | undefined;
186
188
  ref: import("react").RefObject<T | null>;
187
189
  className: string;
188
- 'data-m': "fade" | "scale" | "pop" | "rise" | "drop" | "slide-up" | "slide-down" | "slide-left" | "slide-right" | "blur" | "zoom" | "flip" | "badge" | "nudge" | "pulse" | "draw" | "lift" | "press" | "tint" | "glow" | "hint";
190
+ 'data-m': "pop" | "fade" | "scale" | "rise" | "drop" | "slide-up" | "slide-down" | "slide-left" | "slide-right" | "blur" | "zoom" | "flip" | "badge" | "nudge" | "pulse" | "draw" | "lift" | "press" | "tint" | "glow" | "hint";
189
191
  'data-m-on': MotionTrigger;
190
192
  'data-stagger'?: undefined;
191
193
  };
@@ -232,8 +234,8 @@ export interface PresenceEntry<T> {
232
234
  /** Position among the items added in the same update (the stagger), 0 for the first. */
233
235
  enterIndex: number;
234
236
  }
235
- /** The items of a list with the removed ones kept mounted until their exit animation ends. Hand `entries` to your list, put `ref(key)` on each row, and style `leaving` and `entering` rows (the class names alea-row-enter and alea-row-leave do it). */
236
- export declare function usePresenceList<T>(items: readonly T[] | undefined, getKey: (item: T) => string | number, enabled?: boolean): {
237
+ /** The items of a list with the removed ones kept mounted until their exit animation ends. Hand `entries` to your list, put `ref(key)` on each row, and style `leaving` and `entering` rows (the class names alea-row-enter and alea-row-leave do it). `motion` is true (default), false, or a policy: see RowMotionOptions. */
238
+ export declare function usePresenceList<T>(items: readonly T[] | undefined, getKey: (item: T) => string | number, motion?: RowMotion): {
237
239
  entries: PresenceEntry<T>[];
238
240
  ref: (key: string | number) => (node: HTMLElement | null) => void;
239
241
  };
@@ -251,7 +253,6 @@ export declare function PresenceList<T>({ items, getKey, children, animate }: {
251
253
  style?: CSSProperties;
252
254
  ref?: unknown;
253
255
  }>;
254
- /** false renders the items as they are, with no entrance and no exit. Default true. */
255
- animate?: boolean;
256
+ /** false renders the items as they are, with no entrance and no exit. An object chooses what animates and when the list starts over (max, resetOn, enter, leave). Default true. */
257
+ animate?: RowMotion;
256
258
  }): import("react").FunctionComponentElement<import("react").FragmentProps>;
257
- export {};
@@ -0,0 +1,22 @@
1
+ /** Which changes of a list are news worth animating. */
2
+ export interface RowMotionOptions {
3
+ /** Above this many rows nothing animates: a long list stays still. No limit by default. */
4
+ max?: number;
5
+ /** Values that decide which rows exist without being an add or a remove (a search text, a filter, a page). When any of them changes the list starts over: the rows now in it are not animated in, and the rows that left do not play their exit. */
6
+ resetOn?: readonly unknown[];
7
+ /** Rows added to the list rise in. Default true. */
8
+ enter?: boolean;
9
+ /** Rows removed from the list dissolve before they go. Default true. */
10
+ leave?: boolean;
11
+ }
12
+ /** `true` animates every add and remove, `false` nothing; an object says which ones and when to forget the rows it had. */
13
+ export type RowMotion = boolean | RowMotionOptions;
14
+ /** What a list animates right now, given how many rows it holds. */
15
+ export declare function resolveRowMotion(motion: RowMotion | undefined, count: number): {
16
+ enter: boolean;
17
+ leave: boolean;
18
+ };
19
+ /** The `resetOn` values of a policy (none for a boolean). */
20
+ export declare const resetValues: (motion: RowMotion | undefined) => readonly unknown[];
21
+ /** Same values in the same order, compared one by one with Object.is: a new array with equal contents is not a change. */
22
+ export declare const sameValues: (a: readonly unknown[], b: readonly unknown[]) => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alea-design/motion",
3
- "version": "0.6.1",
3
+ "version": "0.7.0",
4
4
  "description": "Alea Motion: a motion system for interfaces. Tokens, named patterns, microinteractions and effects in CSS for any stack, plus small React helpers. Reduced motion built in.",
5
5
  "keywords": [
6
6
  "motion",
package/src/motion.css CHANGED
@@ -224,12 +224,12 @@
224
224
  /* ------------------------------------------------------------------ reduced motion: fade, don't move; stop decorative loops.
225
225
  Applies with the OS setting (unless data-alea-reduced="never"), or always with data-alea-reduced="always" or data-alea-motion="reduced". */
226
226
  @media (prefers-reduced-motion: reduce) {
227
- :root:not([data-alea-reduced='never']), :root:not([data-alea-reduced='never']) :is(.alea-root, [data-theme], [data-alea-motion]) {
227
+ :root:not([data-alea-reduced='never']), :root:not([data-alea-reduced='never']) :is(.alea-root, [data-theme], [data-alea-motion]):not([data-alea-reduced='never']) {
228
228
  --alea-motion-distance-sm: 0px; --alea-motion-distance-md: 0px; --alea-motion-distance-lg: 0px; --alea-motion-rotate: 0deg;
229
229
  --alea-motion-scale-from: 1; --alea-motion-scale-press: 1; --alea-motion-lift: 0px; --alea-motion-stagger: 0ms; --alea-motion-slide: 0%; --alea-slide-distance: 0px;
230
230
  --alea-motion-blur-sm: 0px; --alea-motion-blur-md: 0px; --alea-motion-blur-lg: 0px;
231
231
  --alea-motion-ease-emphasized: var(--alea-motion-ease-out); --alea-motion-ease-spring: var(--alea-motion-ease-out); --alea-motion-spring: var(--alea-motion-ease-out);
232
- --alea-motion-duration-slow: var(--alea-motion-duration-base); --alea-motion-duration-slower: var(--alea-motion-duration-base);
232
+ --alea-motion-duration-instant: var(--alea-motion-reduced-duration, 1ms); --alea-motion-duration-fast: var(--alea-motion-reduced-duration, 1ms); --alea-motion-duration-base: var(--alea-motion-reduced-duration, 1ms); --alea-motion-duration-slow: var(--alea-motion-reduced-duration, 1ms); --alea-motion-duration-slower: var(--alea-motion-reduced-duration, 1ms);
233
233
  }
234
234
  :root:not([data-alea-reduced='never']) :is(.alea-field[data-invalid] :is(.alea-input-wrap, .alea-select-trigger, .alea-textarea, .alea-date-wrap), [data-alea-loop], .alea-image[data-state='loading'], .alea-orb, .alea-orbs *) { animation: none !important; }
235
235
  /* decorative loops stop (a pseudo-element cannot sit inside :is(), so these are listed on their own) */
@@ -245,13 +245,18 @@
245
245
  :root:not([data-alea-reduced='never']) :is(.alea-chart-line, .alea-success-check path) { stroke-dashoffset: 0; }
246
246
  :root:not([data-alea-reduced='never']) .alea-ripple { display: none; }
247
247
  :root:not([data-alea-reduced='never'])[data-motion='morph'], :root:not([data-alea-reduced='never']) [data-motion='morph'] { --alea-enter: alea-m-fade-in; --alea-exit: alea-m-fade-out; }
248
+ /* the sweep: an animation or transition that is left (a duration set inline, a literal one, a keyframe nobody listed) is cut to a blink, a loop plays once and scrolling jumps. Spinners and
249
+ indeterminate bars keep turning because they say "working"; the rules above already slowed them */
250
+ :root:not([data-alea-reduced='never']) :not([data-alea-reduced='never'], [data-alea-reduced='never'] *):not(:is(.alea-spinner svg, .alea-dot-loader i, .alea-progress-circle svg[data-indeterminate], .alea-progress-fill[data-indeterminate], .alea-agentrun-status svg, .alea-tool-status svg), :is(.alea-spinner svg, .alea-dot-loader i, .alea-progress-circle svg[data-indeterminate], .alea-progress-fill[data-indeterminate], .alea-agentrun-status svg, .alea-tool-status svg) *),
251
+ :root:not([data-alea-reduced='never']) :not([data-alea-reduced='never'], [data-alea-reduced='never'] *):not(:is(.alea-spinner svg, .alea-dot-loader i, .alea-progress-circle svg[data-indeterminate], .alea-progress-fill[data-indeterminate], .alea-agentrun-status svg, .alea-tool-status svg), :is(.alea-spinner svg, .alea-dot-loader i, .alea-progress-circle svg[data-indeterminate], .alea-progress-fill[data-indeterminate], .alea-agentrun-status svg, .alea-tool-status svg) *)::before,
252
+ :root:not([data-alea-reduced='never']) :not([data-alea-reduced='never'], [data-alea-reduced='never'] *):not(:is(.alea-spinner svg, .alea-dot-loader i, .alea-progress-circle svg[data-indeterminate], .alea-progress-fill[data-indeterminate], .alea-agentrun-status svg, .alea-tool-status svg), :is(.alea-spinner svg, .alea-dot-loader i, .alea-progress-circle svg[data-indeterminate], .alea-progress-fill[data-indeterminate], .alea-agentrun-status svg, .alea-tool-status svg) *)::after { animation-duration: var(--alea-motion-reduced-duration, 1ms) !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: var(--alea-motion-reduced-duration, 1ms) !important; scroll-behavior: auto !important; }
248
253
  }
249
254
  :is([data-alea-motion='reduced'], [data-alea-reduced='always']), :is([data-alea-motion='reduced'], [data-alea-reduced='always']) :is(.alea-root, [data-theme]) {
250
255
  --alea-motion-distance-sm: 0px; --alea-motion-distance-md: 0px; --alea-motion-distance-lg: 0px; --alea-motion-rotate: 0deg;
251
256
  --alea-motion-scale-from: 1; --alea-motion-scale-press: 1; --alea-motion-lift: 0px; --alea-motion-stagger: 0ms; --alea-motion-slide: 0%; --alea-slide-distance: 0px;
252
257
  --alea-motion-blur-sm: 0px; --alea-motion-blur-md: 0px; --alea-motion-blur-lg: 0px;
253
258
  --alea-motion-ease-emphasized: var(--alea-motion-ease-out); --alea-motion-ease-spring: var(--alea-motion-ease-out); --alea-motion-spring: var(--alea-motion-ease-out);
254
- --alea-motion-duration-slow: var(--alea-motion-duration-base); --alea-motion-duration-slower: var(--alea-motion-duration-base);
259
+ --alea-motion-duration-instant: var(--alea-motion-reduced-duration, 1ms); --alea-motion-duration-fast: var(--alea-motion-reduced-duration, 1ms); --alea-motion-duration-base: var(--alea-motion-reduced-duration, 1ms); --alea-motion-duration-slow: var(--alea-motion-reduced-duration, 1ms); --alea-motion-duration-slower: var(--alea-motion-reduced-duration, 1ms);
255
260
  }
256
261
  :is([data-alea-motion='reduced'], [data-alea-reduced='always']) :is(.alea-field[data-invalid] :is(.alea-input-wrap, .alea-select-trigger, .alea-textarea, .alea-date-wrap), [data-alea-loop], .alea-image[data-state='loading'], .alea-orb, .alea-orbs *) { animation: none !important; }
257
262
  :is([data-alea-motion='reduced'], [data-alea-reduced='always']) :is(.alea-avatar-status[data-pulse], .alea-status-dot[data-pulse], .alea-indicator[data-processing])::before,
@@ -265,6 +270,11 @@
265
270
  :is([data-alea-motion='reduced'], [data-alea-reduced='always']) :is(.alea-chart-line, .alea-success-check path) { stroke-dashoffset: 0; }
266
271
  :is([data-alea-motion='reduced'], [data-alea-reduced='always']) .alea-ripple { display: none; }
267
272
  :is([data-alea-motion='reduced'], [data-alea-reduced='always'])[data-motion='morph'], :is([data-alea-motion='reduced'], [data-alea-reduced='always']) [data-motion='morph'] { --alea-enter: alea-m-fade-in; --alea-exit: alea-m-fade-out; }
273
+ /* the sweep: an animation or transition that is left (a duration set inline, a literal one, a keyframe nobody listed) is cut to a blink, a loop plays once and scrolling jumps. Spinners and
274
+ indeterminate bars keep turning because they say "working"; the rules above already slowed them */
275
+ :is([data-alea-motion='reduced'], [data-alea-reduced='always']) :not(:is(.alea-spinner svg, .alea-dot-loader i, .alea-progress-circle svg[data-indeterminate], .alea-progress-fill[data-indeterminate], .alea-agentrun-status svg, .alea-tool-status svg), :is(.alea-spinner svg, .alea-dot-loader i, .alea-progress-circle svg[data-indeterminate], .alea-progress-fill[data-indeterminate], .alea-agentrun-status svg, .alea-tool-status svg) *),
276
+ :is([data-alea-motion='reduced'], [data-alea-reduced='always']) :not(:is(.alea-spinner svg, .alea-dot-loader i, .alea-progress-circle svg[data-indeterminate], .alea-progress-fill[data-indeterminate], .alea-agentrun-status svg, .alea-tool-status svg), :is(.alea-spinner svg, .alea-dot-loader i, .alea-progress-circle svg[data-indeterminate], .alea-progress-fill[data-indeterminate], .alea-agentrun-status svg, .alea-tool-status svg) *)::before,
277
+ :is([data-alea-motion='reduced'], [data-alea-reduced='always']) :not(:is(.alea-spinner svg, .alea-dot-loader i, .alea-progress-circle svg[data-indeterminate], .alea-progress-fill[data-indeterminate], .alea-agentrun-status svg, .alea-tool-status svg), :is(.alea-spinner svg, .alea-dot-loader i, .alea-progress-circle svg[data-indeterminate], .alea-progress-fill[data-indeterminate], .alea-agentrun-status svg, .alea-tool-status svg) *)::after { animation-duration: var(--alea-motion-reduced-duration, 1ms) !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: var(--alea-motion-reduced-duration, 1ms) !important; scroll-behavior: auto !important; }
268
278
 
269
279
  /* ------------------------------------------------------------------ the patterns, applied to the rest of the kit */
270
280
  /* rise: content that appears as a state of its own */