@alea-design/motion 0.6.1 → 0.7.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.
- package/dist/index.js +351 -335
- package/dist/react.d.ts +7 -6
- package/dist/row-motion.d.ts +22 -0
- package/package.json +1 -1
- package/src/motion.css +13 -3
- package/src/patterns.css +5 -1
package/dist/index.js
CHANGED
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
if (
|
|
7
|
-
const
|
|
8
|
-
return
|
|
2
|
+
import { jsx as M, jsxs as C } from "react/jsx-runtime";
|
|
3
|
+
import { useRef as w, useState as L, useEffect as h, createElement as $, Children as U, isValidElement as V, cloneElement as Y, useCallback as F, 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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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])), X = 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, H = (e, t) => e === "none" ? "none" : `alea-m-${e}-${t}`;
|
|
11
|
+
function z(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"] = H(t.enter, "in"), n["--alea-exit"] = H(t.exit || t.enter, "out")) : t.exit && (n["--alea-exit"] = H(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
|
-
|
|
16
|
+
function we(e, t) {
|
|
17
|
+
const n = z(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,426 @@ const J = {
|
|
|
23
29
|
hovercard: ".alea-hovercard",
|
|
24
30
|
datepicker: ".alea-cal-popover",
|
|
25
31
|
tour: ".alea-tour-card"
|
|
26
|
-
},
|
|
27
|
-
function
|
|
28
|
-
const
|
|
29
|
-
if (n != null && n !== 1) for (const [
|
|
30
|
-
if (
|
|
31
|
-
for (const [
|
|
32
|
-
for (const [
|
|
33
|
-
|
|
32
|
+
}, ae = { instant: 120, fast: 200, base: 320, slow: 480, slower: 720 }, oe = { 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, a] of Object.entries(ae)) t[`--alea-motion-duration-${i}`] = `${Math.round(a * n)}ms`;
|
|
36
|
+
if (r != null && r !== 1) {
|
|
37
|
+
for (const [i, a] of Object.entries(oe)) t[`--alea-motion-distance-${i}`] = `${+(a * r).toFixed(2)}px`;
|
|
38
|
+
for (const [i, a] of Object.entries(ie)) t[`--alea-motion-blur-${i}`] = `${+(a * 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
|
|
41
|
+
return t;
|
|
36
42
|
}
|
|
37
|
-
function
|
|
38
|
-
const
|
|
39
|
-
return
|
|
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
|
|
42
|
-
return Object.entries(
|
|
43
|
-
const
|
|
44
|
-
return !
|
|
47
|
+
function xe(e = {}, t = ":root") {
|
|
48
|
+
return Object.entries(e).map(([n, r]) => {
|
|
49
|
+
const i = z(r), a = re[n];
|
|
50
|
+
return !i || !a ? "" : `${t} ${a} { ${Object.entries(i).map(([o, s]) => `${o}: ${s};`).join(" ")} }`;
|
|
45
51
|
}).filter(Boolean).join(`
|
|
46
52
|
`);
|
|
47
53
|
}
|
|
48
|
-
function
|
|
49
|
-
const [
|
|
50
|
-
return
|
|
51
|
-
var
|
|
54
|
+
function W() {
|
|
55
|
+
const [e, t] = L(!1);
|
|
56
|
+
return h(() => {
|
|
57
|
+
var a, o;
|
|
52
58
|
if (typeof window > "u") return;
|
|
53
|
-
const n = (
|
|
54
|
-
const s = document.documentElement,
|
|
55
|
-
|
|
59
|
+
const n = (a = window.matchMedia) == null ? void 0 : a.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
|
-
|
|
58
|
-
const
|
|
59
|
-
return
|
|
63
|
+
r(), (o = n == null ? void 0 : n.addEventListener) == null || o.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",
|
|
67
|
+
(s = n == null ? void 0 : n.removeEventListener) == null || s.call(n, "change", r), i.disconnect();
|
|
62
68
|
};
|
|
63
|
-
}, []),
|
|
69
|
+
}, []), e;
|
|
64
70
|
}
|
|
65
|
-
function
|
|
66
|
-
const { once:
|
|
67
|
-
return
|
|
68
|
-
const s =
|
|
71
|
+
function se(e = {}) {
|
|
72
|
+
const { once: t = !0, margin: n = "0px 0px -10% 0px", threshold: r = 0.1 } = e, i = w(null), [a, o] = L(!1);
|
|
73
|
+
return h(() => {
|
|
74
|
+
const s = i.current;
|
|
69
75
|
if (!s || typeof IntersectionObserver > "u") {
|
|
70
|
-
|
|
76
|
+
o(!0);
|
|
71
77
|
return;
|
|
72
78
|
}
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
}, { rootMargin: n, threshold:
|
|
76
|
-
return
|
|
77
|
-
}, [
|
|
79
|
+
const d = new IntersectionObserver(([l]) => {
|
|
80
|
+
l.isIntersecting ? (o(!0), t && d.disconnect()) : t || o(!1);
|
|
81
|
+
}, { rootMargin: n, threshold: r });
|
|
82
|
+
return d.observe(s), () => d.disconnect();
|
|
83
|
+
}, [t, n, r]), [i, a];
|
|
78
84
|
}
|
|
79
|
-
let
|
|
80
|
-
function
|
|
85
|
+
let P = null;
|
|
86
|
+
function le(e) {
|
|
81
87
|
return typeof IntersectionObserver > "u" ? () => {
|
|
82
|
-
} : (
|
|
83
|
-
for (const n of
|
|
84
|
-
}, { rootMargin: "64px" })),
|
|
85
|
-
|
|
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
|
|
89
|
-
const
|
|
90
|
-
return
|
|
94
|
+
function be() {
|
|
95
|
+
const e = w(null);
|
|
96
|
+
return h(() => e.current ? le(e.current) : void 0, []), e;
|
|
91
97
|
}
|
|
92
|
-
function
|
|
93
|
-
const [
|
|
94
|
-
return
|
|
95
|
-
let
|
|
96
|
-
const
|
|
97
|
-
const
|
|
98
|
-
Math.abs(
|
|
98
|
+
function Ee(e = 8) {
|
|
99
|
+
const [t, n] = L("up");
|
|
100
|
+
return h(() => {
|
|
101
|
+
let r = window.scrollY;
|
|
102
|
+
const i = () => {
|
|
103
|
+
const a = window.scrollY;
|
|
104
|
+
Math.abs(a - r) < e || (n(a > r && a > 64 ? "down" : "up"), r = a);
|
|
99
105
|
};
|
|
100
|
-
return window.addEventListener("scroll",
|
|
101
|
-
}, [
|
|
106
|
+
return window.addEventListener("scroll", i, { passive: !0 }), () => window.removeEventListener("scroll", i);
|
|
107
|
+
}, [e]), t;
|
|
102
108
|
}
|
|
103
|
-
function
|
|
104
|
-
return { onPointerDown:
|
|
105
|
-
const n =
|
|
106
|
-
|
|
109
|
+
function Ne() {
|
|
110
|
+
return { onPointerDown: F((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, a = document.createElement("span");
|
|
112
|
+
a.className = "alea-ripple", a.setAttribute("aria-hidden", "true"), a.style.setProperty("--alea-ripple-x", `${t.clientX - r.left}px`), a.style.setProperty("--alea-ripple-y", `${t.clientY - r.top}px`), a.style.setProperty("--alea-ripple-size", `${i}px`), n.appendChild(a), a.addEventListener("animationend", () => a.remove()), window.setTimeout(() => a.remove(), 1200);
|
|
107
113
|
}, []), className: "alea-ripple-host" };
|
|
108
114
|
}
|
|
109
|
-
function
|
|
110
|
-
const
|
|
111
|
-
|
|
115
|
+
function Se(e) {
|
|
116
|
+
const t = typeof document < "u" ? document : null;
|
|
117
|
+
t != null && t.startViewTransition ? t.startViewTransition(e) : e();
|
|
112
118
|
}
|
|
113
|
-
function
|
|
114
|
-
const [
|
|
115
|
-
|
|
116
|
-
const
|
|
117
|
-
|
|
119
|
+
function Me({ as: e = "div", motion: t = "rise", delay: n, once: r = !0, stagger: i, className: a, style: o, children: s, ...d }) {
|
|
120
|
+
const [l, c] = se({ once: r }), [u, v] = L(!1);
|
|
121
|
+
X(() => {
|
|
122
|
+
const m = l.current;
|
|
123
|
+
m && m.getBoundingClientRect().top > window.innerHeight && v(!0);
|
|
118
124
|
}, []);
|
|
119
|
-
const
|
|
120
|
-
return
|
|
121
|
-
...
|
|
122
|
-
ref:
|
|
123
|
-
className:
|
|
124
|
-
"data-reveal":
|
|
125
|
-
"data-stagger":
|
|
126
|
-
style: { ...
|
|
125
|
+
const g = typeof t == "string" ? { enter: t } : t;
|
|
126
|
+
return $(e, {
|
|
127
|
+
...d,
|
|
128
|
+
ref: l,
|
|
129
|
+
className: a,
|
|
130
|
+
"data-reveal": u && !c ? "pending" : u ? "in" : void 0,
|
|
131
|
+
"data-stagger": i ? "reveal" : void 0,
|
|
132
|
+
style: { ...i ? {} : z({ ...g, delay: n ?? g.delay }), ...o }
|
|
127
133
|
}, s);
|
|
128
134
|
}
|
|
129
|
-
function
|
|
130
|
-
const [
|
|
131
|
-
return
|
|
132
|
-
var
|
|
133
|
-
if (
|
|
134
|
-
|
|
135
|
+
function Le({ show: e, exitClassName: t = "alea-dissolve-out", children: n }) {
|
|
136
|
+
const [r, i] = L(e), [a, o] = L(!1), s = w(null);
|
|
137
|
+
return h(() => {
|
|
138
|
+
var u;
|
|
139
|
+
if (e) {
|
|
140
|
+
i(!0), o(!1);
|
|
135
141
|
return;
|
|
136
142
|
}
|
|
137
|
-
if (!
|
|
138
|
-
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
},
|
|
142
|
-
if (!
|
|
143
|
-
const
|
|
144
|
-
return () => window.clearTimeout(
|
|
143
|
+
if (!r) return;
|
|
144
|
+
o(!0);
|
|
145
|
+
const d = s.current, l = () => {
|
|
146
|
+
i(!1), o(!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(
|
|
147
|
-
}))).then(
|
|
148
|
-
}, [
|
|
149
|
-
var
|
|
150
|
-
|
|
151
|
-
}, [
|
|
152
|
+
Promise.all(c.map((v) => v.finished.catch(() => {
|
|
153
|
+
}))).then(l);
|
|
154
|
+
}, [e]), h(() => {
|
|
155
|
+
var d, l;
|
|
156
|
+
a && s.current && !((l = (d = s.current).getAnimations) != null && l.call(d).length) && (i(!1), o(!1));
|
|
157
|
+
}, [a]), !r || !V(n) ? null : Y(n, { ref: s, className: [n.props.className, a && t].filter(Boolean).join(" ") });
|
|
152
158
|
}
|
|
153
|
-
function
|
|
154
|
-
const [
|
|
155
|
-
var
|
|
156
|
-
return typeof
|
|
159
|
+
function $e({ children: e, as: t = "span", className: n, direction: r = "up", variant: i = "blur" }) {
|
|
160
|
+
const [a, o] = 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) : V(c) ? String(c.key ?? "") + JSON.stringify(((u = c.props) == null ? void 0 : u.children) ?? "") : "";
|
|
157
163
|
};
|
|
158
|
-
return
|
|
159
|
-
if (
|
|
160
|
-
|
|
164
|
+
return h(() => {
|
|
165
|
+
if (l(e) === l(s.current)) {
|
|
166
|
+
o((c) => c.map((u) => u.out ? u : { ...u, node: e }));
|
|
161
167
|
return;
|
|
162
168
|
}
|
|
163
|
-
s.current =
|
|
164
|
-
}, [
|
|
165
|
-
|
|
166
|
-
{ className: ["alea-swap", n].filter(Boolean).join(" "), "data-variant":
|
|
167
|
-
|
|
169
|
+
s.current = e, d.current += 1, o((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
|
+
a.map((c) => /* @__PURE__ */ M("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 ? () => o((u) => u.filter((v) => v.id !== c.id)) : void 0, children: c.node }, c.id))
|
|
168
174
|
);
|
|
169
175
|
}
|
|
170
|
-
function
|
|
171
|
-
const
|
|
172
|
-
return /* @__PURE__ */
|
|
173
|
-
/* @__PURE__ */
|
|
174
|
-
|
|
176
|
+
function ke({ value: e, format: t, locale: n, className: r, live: i = !0, label: a }) {
|
|
177
|
+
const o = new Intl.NumberFormat(n, t).format(e);
|
|
178
|
+
return /* @__PURE__ */ C("span", { className: ["alea-roll", r].filter(Boolean).join(" "), children: [
|
|
179
|
+
/* @__PURE__ */ C("span", { className: "alea-roll-text", "aria-live": i ? "polite" : void 0, children: [
|
|
180
|
+
a && /* @__PURE__ */ C("span", { className: "alea-roll-label", children: [
|
|
181
|
+
a,
|
|
182
|
+
" "
|
|
183
|
+
] }),
|
|
184
|
+
o
|
|
185
|
+
] }),
|
|
186
|
+
/* @__PURE__ */ M("span", { className: "alea-roll-digits", "aria-hidden": "true", children: [...o].map((s, d) => /\d/.test(s) ? /* @__PURE__ */ M("span", { className: "alea-roll-digit", children: /* @__PURE__ */ M("span", { className: "alea-roll-strip", style: { "--alea-roll-n": s }, children: "0123456789".split("").map((l) => /* @__PURE__ */ M("span", { children: l }, l)) }) }, o.length - d) : /* @__PURE__ */ M("span", { children: s }, `s${o.length - d}`)) })
|
|
175
187
|
] });
|
|
176
188
|
}
|
|
177
|
-
function
|
|
178
|
-
const
|
|
179
|
-
return
|
|
180
|
-
const
|
|
181
|
-
if (!
|
|
182
|
-
const s = new ResizeObserver(() =>
|
|
183
|
-
return s.observe(
|
|
184
|
-
}, []),
|
|
189
|
+
function Ae({ children: e, className: t, as: n = "div" }) {
|
|
190
|
+
const r = w(null), [i, a] = L(void 0);
|
|
191
|
+
return h(() => {
|
|
192
|
+
const o = r.current;
|
|
193
|
+
if (!o || typeof ResizeObserver > "u") return;
|
|
194
|
+
const s = new ResizeObserver(() => a(o.offsetHeight));
|
|
195
|
+
return s.observe(o), () => s.disconnect();
|
|
196
|
+
}, []), $(n, { className: ["alea-autoheight", t].filter(Boolean).join(" "), style: i != null ? { height: i } : void 0 }, /* @__PURE__ */ M("div", { ref: r, children: e }));
|
|
185
197
|
}
|
|
186
|
-
function
|
|
187
|
-
const
|
|
188
|
-
return
|
|
189
|
-
var
|
|
190
|
-
if (typeof CSS < "u" && ((
|
|
191
|
-
|
|
198
|
+
function Ie({ className: e }) {
|
|
199
|
+
const t = w(null), [n, r] = L(!1);
|
|
200
|
+
return h(() => {
|
|
201
|
+
var a;
|
|
202
|
+
if (typeof CSS < "u" && ((a = CSS.supports) != null && a.call(CSS, "animation-timeline: scroll()"))) {
|
|
203
|
+
r(!0);
|
|
192
204
|
return;
|
|
193
205
|
}
|
|
194
|
-
const
|
|
206
|
+
const i = () => {
|
|
195
207
|
var s;
|
|
196
|
-
const
|
|
197
|
-
(s =
|
|
208
|
+
const o = document.documentElement.scrollHeight - window.innerHeight;
|
|
209
|
+
(s = t.current) == null || s.style.setProperty("--alea-scroll", String(o > 0 ? Math.min(1, window.scrollY / o) : 0));
|
|
198
210
|
};
|
|
199
|
-
return
|
|
200
|
-
window.removeEventListener("scroll",
|
|
211
|
+
return i(), window.addEventListener("scroll", i, { passive: !0 }), window.addEventListener("resize", i), () => {
|
|
212
|
+
window.removeEventListener("scroll", i), window.removeEventListener("resize", i);
|
|
201
213
|
};
|
|
202
|
-
}, []), /* @__PURE__ */
|
|
214
|
+
}, []), /* @__PURE__ */ M("div", { ref: t, className: ["alea-scroll-progress", e].filter(Boolean).join(" "), "data-css": n || void 0, "aria-hidden": "true" });
|
|
203
215
|
}
|
|
204
|
-
function
|
|
205
|
-
return
|
|
206
|
-
|
|
207
|
-
{ className: ["alea-stream", n].filter(Boolean).join(" "), "data-streaming":
|
|
208
|
-
|
|
216
|
+
function je({ chunks: e, streaming: t = !1, className: n, as: r = "p" }) {
|
|
217
|
+
return $(
|
|
218
|
+
r,
|
|
219
|
+
{ className: ["alea-stream", n].filter(Boolean).join(" "), "data-streaming": t || void 0, "aria-busy": t || void 0 },
|
|
220
|
+
U.toArray(e.map((i, a) => /* @__PURE__ */ M("span", { className: "alea-stream-chunk", children: i }, a)))
|
|
209
221
|
);
|
|
210
222
|
}
|
|
211
|
-
const
|
|
212
|
-
const
|
|
213
|
-
return { x:
|
|
223
|
+
const R = /* @__PURE__ */ new Map(), _ = (e) => {
|
|
224
|
+
const t = e.getBoundingClientRect();
|
|
225
|
+
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
226
|
};
|
|
215
|
-
function
|
|
216
|
-
const
|
|
217
|
-
return
|
|
218
|
-
const
|
|
219
|
-
if (!
|
|
220
|
-
const
|
|
221
|
-
if (
|
|
222
|
-
const
|
|
223
|
-
if (
|
|
224
|
-
{ transformOrigin: "0 0", transform: `translate(${
|
|
225
|
-
{ transformOrigin: "0 0", transform: "none", borderRadius:
|
|
226
|
-
], { duration:
|
|
227
|
+
function Oe({ id: e, as: t = "div", duration: n, easing: r, fadeContent: i = !0, className: a, style: o, children: s, ...d }) {
|
|
228
|
+
const l = w(null), c = W();
|
|
229
|
+
return X(() => {
|
|
230
|
+
const u = l.current;
|
|
231
|
+
if (!u) return;
|
|
232
|
+
const v = R.get(e), g = _(u);
|
|
233
|
+
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") {
|
|
234
|
+
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), p = v.h / Math.max(1, g.h);
|
|
235
|
+
if (u.animate([
|
|
236
|
+
{ transformOrigin: "0 0", transform: `translate(${v.x - g.x}px, ${v.y - g.y}px) scale(${f}, ${p})`, borderRadius: v.radius },
|
|
237
|
+
{ transformOrigin: "0 0", transform: "none", borderRadius: g.radius }
|
|
238
|
+
], { 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
239
|
}
|
|
228
|
-
|
|
229
|
-
const
|
|
230
|
-
|
|
240
|
+
R.set(e, g);
|
|
241
|
+
const y = () => {
|
|
242
|
+
u.isConnected && R.set(e, _(u));
|
|
231
243
|
};
|
|
232
|
-
window.addEventListener("scroll",
|
|
233
|
-
const
|
|
234
|
-
return
|
|
235
|
-
|
|
244
|
+
window.addEventListener("scroll", y, { passive: !0 });
|
|
245
|
+
const m = typeof ResizeObserver < "u" ? new ResizeObserver(y) : null;
|
|
246
|
+
return m == null || m.observe(u), () => {
|
|
247
|
+
y(), R.set(e, { ...R.get(e) || g, time: performance.now() }), window.removeEventListener("scroll", y), m == null || m.disconnect();
|
|
236
248
|
};
|
|
237
|
-
}, [
|
|
249
|
+
}, [e]), $(t, { ...d, ref: l, className: a, style: o, "data-morph": e }, s);
|
|
238
250
|
}
|
|
239
|
-
function
|
|
240
|
-
return /* @__PURE__ */
|
|
241
|
-
/* @__PURE__ */
|
|
242
|
-
/* @__PURE__ */
|
|
251
|
+
function Te({ from: e, to: t, active: n, className: r }) {
|
|
252
|
+
return /* @__PURE__ */ C("span", { className: ["alea-morph-icon", r].filter(Boolean).join(" "), "data-active": n || void 0, "aria-hidden": "true", children: [
|
|
253
|
+
/* @__PURE__ */ M("span", { className: "alea-morph-icon-a", children: e }),
|
|
254
|
+
/* @__PURE__ */ M("span", { className: "alea-morph-icon-b", children: t })
|
|
243
255
|
] });
|
|
244
256
|
}
|
|
245
|
-
const
|
|
246
|
-
function
|
|
247
|
-
const
|
|
248
|
-
|
|
249
|
-
const
|
|
250
|
-
if (
|
|
257
|
+
const ce = { lift: "alea-hover-lift", press: "alea-press", tint: "alea-hover-tint", glow: "alea-hover-glow", hint: "alea-hint" };
|
|
258
|
+
function ue(e, { on: t = "mount", value: n, delay: r, duration: i, once: a = !0 } = {}) {
|
|
259
|
+
const o = w(null);
|
|
260
|
+
h(() => {
|
|
261
|
+
const c = o.current;
|
|
262
|
+
if (t !== "visible" || !c) return;
|
|
251
263
|
if (typeof IntersectionObserver > "u") {
|
|
252
|
-
|
|
264
|
+
c.setAttribute("data-m-in", "");
|
|
253
265
|
return;
|
|
254
266
|
}
|
|
255
|
-
const
|
|
256
|
-
for (const
|
|
257
|
-
|
|
267
|
+
const u = new IntersectionObserver((v) => {
|
|
268
|
+
for (const g of v)
|
|
269
|
+
g.isIntersecting ? (c.setAttribute("data-m-in", ""), a && u.disconnect()) : a || c.removeAttribute("data-m-in");
|
|
258
270
|
}, { rootMargin: "0px 0px -8% 0px" });
|
|
259
|
-
return
|
|
260
|
-
}, [
|
|
261
|
-
const s =
|
|
262
|
-
|
|
263
|
-
if (
|
|
271
|
+
return u.observe(c), () => u.disconnect();
|
|
272
|
+
}, [t, a]);
|
|
273
|
+
const s = w(n);
|
|
274
|
+
h(() => {
|
|
275
|
+
if (t !== "change" || Object.is(s.current, n)) return;
|
|
264
276
|
s.current = n;
|
|
265
|
-
const
|
|
266
|
-
|
|
267
|
-
}, [
|
|
268
|
-
const
|
|
269
|
-
if (
|
|
270
|
-
const
|
|
271
|
-
return
|
|
277
|
+
const c = o.current;
|
|
278
|
+
c && (c.removeAttribute("data-m-run"), c.offsetWidth, c.setAttribute("data-m-run", ""));
|
|
279
|
+
}, [t, n]);
|
|
280
|
+
const d = {};
|
|
281
|
+
if (r != null && (d["--alea-m-delay"] = `${r}ms`), i != null && (d["--alea-m-duration"] = `${i}ms`), e === "stagger") return { ref: o, "data-stagger": "", style: d };
|
|
282
|
+
const l = ce[e];
|
|
283
|
+
return l ? { ref: o, className: l, style: d } : { ref: o, className: "alea-m", "data-m": e, "data-m-on": t, ...t === "loop" ? { "data-alea-loop": "" } : {}, style: d };
|
|
272
284
|
}
|
|
273
|
-
function
|
|
274
|
-
const
|
|
275
|
-
if (!
|
|
276
|
-
const
|
|
277
|
-
|
|
278
|
-
}, { ref: s, className:
|
|
279
|
-
return
|
|
285
|
+
function Pe({ pattern: e, children: t, ...n }) {
|
|
286
|
+
const r = ue(e, n), i = U.only(t);
|
|
287
|
+
if (!V(i)) return t;
|
|
288
|
+
const a = i.props.ref, o = (u) => {
|
|
289
|
+
r.ref.current = u, typeof a == "function" ? a(u) : a && typeof a == "object" && (a.current = u);
|
|
290
|
+
}, { ref: s, className: d, style: l, ...c } = r;
|
|
291
|
+
return Y(i, { ...c, ref: o, className: [i.props.className, d].filter(Boolean).join(" ") || void 0, style: { ...i.props.style, ...l } });
|
|
280
292
|
}
|
|
281
|
-
function
|
|
282
|
-
const s =
|
|
283
|
-
return
|
|
284
|
-
var
|
|
285
|
-
const
|
|
286
|
-
if (!
|
|
287
|
-
const
|
|
288
|
-
|
|
289
|
-
},
|
|
290
|
-
const
|
|
291
|
-
|
|
292
|
-
},
|
|
293
|
-
let
|
|
294
|
-
const
|
|
295
|
-
cancelAnimationFrame(
|
|
296
|
-
const
|
|
297
|
-
|
|
293
|
+
function Re({ as: e = "div", strength: t = 16, scroll: n = !1, className: r, style: i, children: a, ...o }) {
|
|
294
|
+
const s = w(null), d = W();
|
|
295
|
+
return h(() => {
|
|
296
|
+
var k;
|
|
297
|
+
const l = s.current;
|
|
298
|
+
if (!l || d || typeof window > "u") return;
|
|
299
|
+
const c = (k = window.matchMedia) == null ? void 0 : k.call(window, "(pointer: fine)").matches, u = (b, f) => {
|
|
300
|
+
l.style.setProperty("--alea-par-x", b.toFixed(3)), l.style.setProperty("--alea-par-y", f.toFixed(3));
|
|
301
|
+
}, v = (b) => {
|
|
302
|
+
const f = l.getBoundingClientRect();
|
|
303
|
+
u(((b.clientX - f.left) / f.width - 0.5) * 2, ((b.clientY - f.top) / f.height - 0.5) * 2);
|
|
304
|
+
}, g = () => u(0, 0);
|
|
305
|
+
let y = 0;
|
|
306
|
+
const m = () => {
|
|
307
|
+
cancelAnimationFrame(y), y = requestAnimationFrame(() => {
|
|
308
|
+
const b = l.getBoundingClientRect(), f = b.top + b.height / 2 - window.innerHeight / 2;
|
|
309
|
+
l.style.setProperty("--alea-par-s", Math.max(-1, Math.min(1, f / window.innerHeight)).toFixed(3));
|
|
298
310
|
});
|
|
299
311
|
};
|
|
300
|
-
return
|
|
301
|
-
|
|
312
|
+
return c && (l.addEventListener("pointermove", v), l.addEventListener("pointerleave", g)), n && (window.addEventListener("scroll", m, { passive: !0 }), m()), () => {
|
|
313
|
+
l.removeEventListener("pointermove", v), l.removeEventListener("pointerleave", g), window.removeEventListener("scroll", m), cancelAnimationFrame(y);
|
|
302
314
|
};
|
|
303
|
-
}, [
|
|
315
|
+
}, [d, n]), $(e, { ...o, ref: s, className: ["alea-parallax", r].filter(Boolean).join(" "), style: { "--alea-par-strength": `${t}px`, ...i } }, a);
|
|
304
316
|
}
|
|
305
|
-
function
|
|
306
|
-
return
|
|
317
|
+
function Be({ as: e = "div", depth: t = 0.5, className: n, style: r, children: i, ...a }) {
|
|
318
|
+
return $(e, { ...a, className: ["alea-parallax-layer", n].filter(Boolean).join(" "), style: { "--alea-depth": t, ...r } }, i);
|
|
307
319
|
}
|
|
308
|
-
const
|
|
309
|
-
function
|
|
310
|
-
const
|
|
311
|
-
return
|
|
312
|
-
var
|
|
313
|
-
if (!
|
|
314
|
-
const
|
|
315
|
-
if (!
|
|
316
|
-
const
|
|
317
|
-
return () => window.clearTimeout(
|
|
320
|
+
const de = parseInt(Z, 10) >= 19 ? !0 : "";
|
|
321
|
+
function fe({ layer: e, leaving: t, entering: n, style: r, onDone: i }) {
|
|
322
|
+
const a = w(null);
|
|
323
|
+
return h(() => {
|
|
324
|
+
var l;
|
|
325
|
+
if (!t) return;
|
|
326
|
+
const o = a.current, s = ((l = o == null ? void 0 : o.getAnimations) == null ? void 0 : l.call(o)) || [];
|
|
327
|
+
if (!o || !s.length) {
|
|
328
|
+
const c = window.setTimeout(() => i(e.key), 0);
|
|
329
|
+
return () => window.clearTimeout(c);
|
|
318
330
|
}
|
|
319
|
-
let
|
|
320
|
-
return Promise.all(s.map((
|
|
331
|
+
let d = !0;
|
|
332
|
+
return Promise.all(s.map((c) => c.finished.catch(() => {
|
|
321
333
|
}))).then(() => {
|
|
322
|
-
|
|
334
|
+
d && i(e.key);
|
|
323
335
|
}), () => {
|
|
324
|
-
|
|
336
|
+
d = !1;
|
|
325
337
|
};
|
|
326
|
-
}, [
|
|
338
|
+
}, [t]), $("div", { ref: a, 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
339
|
}
|
|
328
|
-
function
|
|
329
|
-
const [
|
|
330
|
-
|
|
331
|
-
const
|
|
332
|
-
return
|
|
333
|
-
|
|
334
|
-
{ ...
|
|
335
|
-
|
|
340
|
+
function Ce({ routeKey: e, pattern: t = "fade", duration: n, exitDuration: r, as: i = "div", className: a, style: o, children: s, ...d }) {
|
|
341
|
+
const [l, c] = L({ key: e, leaving: [], changed: !1 }), u = w(s);
|
|
342
|
+
l.key !== e ? c({ key: e, leaving: [...l.leaving.filter((m) => m.key !== e), { key: l.key, node: u.current }], changed: !0 }) : u.current = s;
|
|
343
|
+
const v = F((m) => c((k) => ({ ...k, leaving: k.leaving.filter((b) => b.key !== m) })), []), g = z({ enter: t, exit: t, duration: n, exitDuration: r }), y = [...l.leaving.map((m) => ({ ...m, leaving: !0 })), { key: e, node: s, leaving: !1 }];
|
|
344
|
+
return $(
|
|
345
|
+
i,
|
|
346
|
+
{ ...d, className: ["alea-page-transition", a].filter(Boolean).join(" "), style: o },
|
|
347
|
+
y.map((m) => $(fe, { key: m.key, layer: m, leaving: m.leaving, entering: !m.leaving && l.changed, style: g, onDone: v }))
|
|
336
348
|
);
|
|
337
349
|
}
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
i
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
350
|
+
const G = "alea-row-leave", me = 1e3;
|
|
351
|
+
function pe(e, t, n = !0) {
|
|
352
|
+
const r = e ?? [], { enter: i, leave: a } = K(n, r.length), o = q(n), [s, d] = L(() => r.map((f, p) => ({ item: f, key: t(f), leaving: !1, entering: !1, enterIndex: p }))), l = w(e), c = w(o), u = w(/* @__PURE__ */ new Map()), v = !ee(c.current, o);
|
|
353
|
+
(l.current !== e || v) && (l.current = e, c.current = o, d((f) => {
|
|
354
|
+
const p = r.map(t);
|
|
355
|
+
if (v) return r.map((x, E) => ({ item: x, key: p[E], leaving: !1, entering: !1, enterIndex: E }));
|
|
356
|
+
const N = new Set(p), A = new Map(f.map((x) => [x.key, x]));
|
|
357
|
+
let D = 0;
|
|
358
|
+
const I = r.map((x, E) => {
|
|
359
|
+
const j = p[E], S = A.get(j), O = !S || S.leaving;
|
|
360
|
+
return { item: x, key: j, leaving: !1, entering: i && (O || !!(S != null && S.entering)), enterIndex: O ? D++ : (S == null ? void 0 : S.enterIndex) ?? 0 };
|
|
347
361
|
});
|
|
348
|
-
return
|
|
349
|
-
|
|
350
|
-
}),
|
|
362
|
+
return a && f.forEach((x, E) => {
|
|
363
|
+
N.has(x.key) || I.splice(Math.min(E, I.length), 0, { ...x, leaving: !0, entering: !1 });
|
|
364
|
+
}), I;
|
|
351
365
|
}));
|
|
352
|
-
const
|
|
353
|
-
|
|
354
|
-
for (const
|
|
355
|
-
const
|
|
356
|
-
|
|
366
|
+
const g = F((f) => d((p) => p.filter((N) => !(N.key === f && N.leaving))), []), y = s.filter((f) => f.leaving).map((f) => String(f.key)).join("|");
|
|
367
|
+
X(() => {
|
|
368
|
+
for (const f of s) if (f.leaving) {
|
|
369
|
+
const p = u.current.get(f.key);
|
|
370
|
+
p && p.style.setProperty("--alea-row-h", `${p.offsetHeight}px`);
|
|
357
371
|
}
|
|
358
|
-
}, [
|
|
359
|
-
const
|
|
360
|
-
let
|
|
361
|
-
const
|
|
362
|
-
|
|
363
|
-
},
|
|
364
|
-
var
|
|
365
|
-
if (!
|
|
366
|
-
const
|
|
367
|
-
if (!
|
|
368
|
-
const
|
|
369
|
-
if (
|
|
370
|
-
const O = Math.max(0,
|
|
371
|
-
var
|
|
372
|
-
return Number((
|
|
372
|
+
}, [y]);
|
|
373
|
+
const m = w(/* @__PURE__ */ new Map()), k = (f) => {
|
|
374
|
+
let p = !0, N = 0, A;
|
|
375
|
+
const D = performance.now(), I = () => {
|
|
376
|
+
p && (p = !1, window.clearTimeout(A), m.current.delete(f), g(f));
|
|
377
|
+
}, x = () => {
|
|
378
|
+
var S;
|
|
379
|
+
if (!p) return;
|
|
380
|
+
const E = u.current.get(f);
|
|
381
|
+
if (!E || E.closest('[data-alea-motion="off"]')) return I();
|
|
382
|
+
const j = (((S = E.getAnimations) == null ? void 0 : S.call(E)) ?? []).filter((O) => O.playState !== "finished");
|
|
383
|
+
if (j.length) {
|
|
384
|
+
const O = Math.max(0, ...j.map((T) => {
|
|
385
|
+
var B;
|
|
386
|
+
return Number((B = T.effect) == null ? void 0 : B.getComputedTiming().endTime) || 0;
|
|
373
387
|
}));
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
388
|
+
A = window.setTimeout(I, O + 100), Promise.allSettled(j.map((T) => T.finished)).then((T) => {
|
|
389
|
+
window.clearTimeout(A), T.some((B) => B.status === "fulfilled") ? I() : x();
|
|
390
|
+
});
|
|
391
|
+
} else !E.classList.contains(G) && performance.now() - D < me ? A = window.setTimeout(x, 16) : ++N > 4 ? I() : A = window.setTimeout(x, 16);
|
|
377
392
|
};
|
|
378
|
-
return
|
|
379
|
-
|
|
393
|
+
return x(), () => {
|
|
394
|
+
p = !1, window.clearTimeout(A);
|
|
380
395
|
};
|
|
381
396
|
};
|
|
382
|
-
|
|
383
|
-
const
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
}),
|
|
387
|
-
|
|
397
|
+
h(() => {
|
|
398
|
+
const f = new Set(s.filter((p) => p.leaving).map((p) => p.key));
|
|
399
|
+
m.current.forEach((p, N) => {
|
|
400
|
+
f.has(N) || (p(), m.current.delete(N));
|
|
401
|
+
}), f.forEach((p) => {
|
|
402
|
+
m.current.has(p) || m.current.set(p, k(p));
|
|
388
403
|
});
|
|
389
|
-
}, [
|
|
390
|
-
|
|
404
|
+
}, [y]), h(() => () => {
|
|
405
|
+
m.current.forEach((f) => f()), m.current.clear();
|
|
391
406
|
}, []);
|
|
392
|
-
const
|
|
393
|
-
|
|
407
|
+
const b = F((f) => (p) => {
|
|
408
|
+
p ? u.current.set(f, p) : u.current.delete(f);
|
|
394
409
|
}, []);
|
|
395
|
-
return { entries:
|
|
410
|
+
return { entries: s, ref: b };
|
|
396
411
|
}
|
|
397
|
-
function
|
|
398
|
-
const { entries:
|
|
399
|
-
return
|
|
400
|
-
const s = n(
|
|
401
|
-
if (!
|
|
402
|
-
const
|
|
403
|
-
|
|
412
|
+
function Fe({ items: e, getKey: t, children: n, animate: r = !0 }) {
|
|
413
|
+
const { entries: i, ref: a } = pe(e, t, r);
|
|
414
|
+
return $(J, null, i.map((o) => {
|
|
415
|
+
const s = n(o.item, { leaving: o.leaving, entering: o.entering });
|
|
416
|
+
if (!V(s)) return null;
|
|
417
|
+
const d = [s.props.className, o.leaving ? G : o.entering ? "alea-row-enter" : ""].filter(Boolean).join(" "), l = s.props.ref, c = (u) => {
|
|
418
|
+
a(o.key)(u), typeof l == "function" ? l(u) : l && typeof l == "object" && (l.current = u);
|
|
404
419
|
};
|
|
405
|
-
return
|
|
420
|
+
return Y(s, { key: o.key, className: d, ref: c, "data-leaving": o.leaving || void 0, style: o.entering ? { ...s.props.style, "--alea-i": Math.min(o.enterIndex, 11) } : s.props.style });
|
|
406
421
|
}));
|
|
407
422
|
}
|
|
408
423
|
export {
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
424
|
+
Ae as AutoHeight,
|
|
425
|
+
re as MOTION_SELECTORS,
|
|
426
|
+
Oe as Morph,
|
|
427
|
+
Te as MorphIcon,
|
|
428
|
+
Pe as Motion,
|
|
429
|
+
ke as NumberRoll,
|
|
430
|
+
Ce as PageTransition,
|
|
431
|
+
Re as Parallax,
|
|
432
|
+
Be as ParallaxLayer,
|
|
433
|
+
Le as Presence,
|
|
434
|
+
Fe as PresenceList,
|
|
435
|
+
Me as Reveal,
|
|
436
|
+
Ie as ScrollProgress,
|
|
437
|
+
je as StreamingText,
|
|
438
|
+
$e as TextSwap,
|
|
439
|
+
ye as motionAttributes,
|
|
440
|
+
xe as motionComponentCss,
|
|
441
|
+
z as motionStyle,
|
|
442
|
+
he as motionVariables,
|
|
443
|
+
le as pauseWhenOffscreen,
|
|
444
|
+
K as resolveRowMotion,
|
|
445
|
+
Se as startViewTransition,
|
|
446
|
+
se as useInView,
|
|
447
|
+
ue as useMotion,
|
|
448
|
+
be as useOffscreenPause,
|
|
449
|
+
pe as usePresenceList,
|
|
450
|
+
W as useReducedMotion,
|
|
451
|
+
Ne as useRipple,
|
|
452
|
+
Ee as useScrollDirection,
|
|
453
|
+
we as withMotionStyle
|
|
438
454
|
};
|
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': "
|
|
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,
|
|
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?:
|
|
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.
|
|
3
|
+
"version": "0.7.1",
|
|
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-
|
|
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-
|
|
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 */
|
package/src/patterns.css
CHANGED
|
@@ -28,7 +28,11 @@
|
|
|
28
28
|
@keyframes alea-swap-out { to { opacity: 0.01; filter: blur(var(--alea-motion-blur-sm)); transform: translateY(calc(var(--alea-motion-distance-sm) * var(--alea-swap-dir, 1) * -1)); } }
|
|
29
29
|
|
|
30
30
|
/* ------------------------------------------------------------------ roll */
|
|
31
|
-
.alea-roll { display: inline-flex; font-variant-numeric: tabular-nums; white-space: nowrap; }
|
|
31
|
+
.alea-roll { position: relative; display: inline-flex; font-variant-numeric: tabular-nums; white-space: nowrap; }
|
|
32
|
+
.alea-roll-digits { display: inline-flex; user-select: none; } /* the strips hold 0 to 9 in every column: never part of a selection */
|
|
33
|
+
/* the figure itself sits invisible over the digits, so selecting the number highlights it and copying gives "1,204", not "0123456789" */
|
|
34
|
+
.alea-roll-text { position: absolute; inset: 0; color: transparent; forced-color-adjust: none; }
|
|
35
|
+
.alea-roll-label { position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden; clip-path: inset(50%); user-select: none; } /* spoken before the figure, never copied */
|
|
32
36
|
.alea-roll-digit { display: inline-block; height: 1lh; overflow: hidden; }
|
|
33
37
|
.alea-roll-strip { display: flex; flex-direction: column; transform: translateY(calc(var(--alea-roll-n, 0) * -1lh)); transition: transform var(--alea-motion-duration-slow) var(--alea-motion-ease-emphasized); }
|
|
34
38
|
.alea-roll-strip > span { height: 1lh; }
|