@alea-design/motion 0.6.0 → 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 +344 -320
- package/dist/react.d.ts +8 -7
- package/dist/row-motion.d.ts +22 -0
- package/package.json +1 -1
- package/src/motion.css +13 -3
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 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
|
-
|
|
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])), 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
|
-
|
|
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,402 +29,420 @@ const W = {
|
|
|
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 [i,
|
|
30
|
-
if (
|
|
31
|
-
for (const [i,
|
|
32
|
-
for (const [i,
|
|
33
|
-
|
|
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
|
|
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 i =
|
|
44
|
-
return !i || !
|
|
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
|
|
49
|
-
const [
|
|
50
|
-
return
|
|
51
|
-
var
|
|
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 = (
|
|
54
|
-
const
|
|
55
|
-
|
|
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
|
-
|
|
58
|
-
const i = new MutationObserver(
|
|
63
|
+
r(), (a = n == null ? void 0 : n.addEventListener) == null || a.call(n, "change", r);
|
|
64
|
+
const i = new MutationObserver(r);
|
|
59
65
|
return i.observe(document.documentElement, { attributes: !0, attributeFilter: ["data-alea-motion", "data-alea-reduced"] }), () => {
|
|
60
|
-
var
|
|
61
|
-
(
|
|
66
|
+
var s;
|
|
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
|
|
69
|
-
if (!
|
|
70
|
-
|
|
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;
|
|
75
|
+
if (!s || typeof IntersectionObserver > "u") {
|
|
76
|
+
a(!0);
|
|
71
77
|
return;
|
|
72
78
|
}
|
|
73
|
-
const d = new IntersectionObserver(([
|
|
74
|
-
|
|
75
|
-
}, { rootMargin: n, threshold:
|
|
76
|
-
return d.observe(
|
|
77
|
-
}, [
|
|
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
|
|
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
|
|
98
|
+
function Ee(e = 8) {
|
|
99
|
+
const [t, n] = L("up");
|
|
100
|
+
return h(() => {
|
|
101
|
+
let r = window.scrollY;
|
|
96
102
|
const i = () => {
|
|
97
|
-
const
|
|
98
|
-
Math.abs(
|
|
103
|
+
const o = window.scrollY;
|
|
104
|
+
Math.abs(o - r) < e || (n(o > r && o > 64 ? "down" : "up"), r = o);
|
|
99
105
|
};
|
|
100
106
|
return window.addEventListener("scroll", i, { passive: !0 }), () => window.removeEventListener("scroll", i);
|
|
101
|
-
}, [
|
|
107
|
+
}, [e]), t;
|
|
102
108
|
}
|
|
103
|
-
function
|
|
104
|
-
return { onPointerDown:
|
|
105
|
-
const n =
|
|
106
|
-
|
|
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
|
|
110
|
-
const
|
|
111
|
-
|
|
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
|
|
114
|
-
const [
|
|
115
|
-
|
|
116
|
-
const
|
|
117
|
-
|
|
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
|
|
120
|
-
return
|
|
125
|
+
const g = typeof t == "string" ? { enter: t } : t;
|
|
126
|
+
return $(e, {
|
|
121
127
|
...d,
|
|
122
|
-
ref:
|
|
123
|
-
className:
|
|
124
|
-
"data-reveal":
|
|
128
|
+
ref: l,
|
|
129
|
+
className: o,
|
|
130
|
+
"data-reveal": u && !c ? "pending" : u ? "in" : void 0,
|
|
125
131
|
"data-stagger": i ? "reveal" : void 0,
|
|
126
|
-
style: { ...i ? {} :
|
|
127
|
-
},
|
|
132
|
+
style: { ...i ? {} : V({ ...g, delay: n ?? g.delay }), ...a }
|
|
133
|
+
}, s);
|
|
128
134
|
}
|
|
129
|
-
function
|
|
130
|
-
const [
|
|
131
|
-
return
|
|
132
|
-
var
|
|
133
|
-
if (
|
|
134
|
-
i(!0),
|
|
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 (!
|
|
138
|
-
|
|
139
|
-
const d =
|
|
140
|
-
i(!1),
|
|
141
|
-
},
|
|
142
|
-
if (!d || !
|
|
143
|
-
const
|
|
144
|
-
return () => window.clearTimeout(
|
|
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(
|
|
147
|
-
}))).then(
|
|
148
|
-
}, [
|
|
149
|
-
var d,
|
|
150
|
-
|
|
151
|
-
}, [
|
|
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
|
|
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 [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
|
|
159
|
-
if (
|
|
160
|
-
|
|
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
|
-
|
|
164
|
-
}, [
|
|
165
|
-
|
|
166
|
-
{ className: ["alea-swap", n].filter(Boolean).join(" "), "data-variant": i === "scale" ? "scale" : void 0, style: { "--alea-swap-dir":
|
|
167
|
-
|
|
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
|
|
171
|
-
const
|
|
172
|
-
return /* @__PURE__ */
|
|
173
|
-
/* @__PURE__ */
|
|
174
|
-
/* @__PURE__ */
|
|
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
|
|
178
|
-
const
|
|
179
|
-
return
|
|
180
|
-
const
|
|
181
|
-
if (!
|
|
182
|
-
const
|
|
183
|
-
return
|
|
184
|
-
}, []),
|
|
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
|
|
187
|
-
const
|
|
188
|
-
return
|
|
189
|
-
var
|
|
190
|
-
if (typeof CSS < "u" && ((
|
|
191
|
-
|
|
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
200
|
const i = () => {
|
|
195
|
-
var
|
|
196
|
-
const
|
|
197
|
-
(
|
|
201
|
+
var s;
|
|
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
205
|
return i(), window.addEventListener("scroll", i, { passive: !0 }), window.addEventListener("resize", i), () => {
|
|
200
206
|
window.removeEventListener("scroll", i), window.removeEventListener("resize", i);
|
|
201
207
|
};
|
|
202
|
-
}, []), /* @__PURE__ */
|
|
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
|
|
205
|
-
return
|
|
206
|
-
|
|
207
|
-
{ className: ["alea-stream", n].filter(Boolean).join(" "), "data-streaming":
|
|
208
|
-
|
|
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
|
|
212
|
-
const
|
|
213
|
-
return { x:
|
|
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
|
|
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:
|
|
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
|
-
|
|
229
|
-
const
|
|
230
|
-
|
|
234
|
+
R.set(e, g);
|
|
235
|
+
const y = () => {
|
|
236
|
+
u.isConnected && R.set(e, X(u));
|
|
231
237
|
};
|
|
232
|
-
window.addEventListener("scroll",
|
|
233
|
-
const
|
|
234
|
-
return
|
|
235
|
-
|
|
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
|
-
}, [
|
|
243
|
+
}, [e]), $(t, { ...d, ref: l, className: o, style: a, "data-morph": e }, s);
|
|
238
244
|
}
|
|
239
|
-
function
|
|
240
|
-
return /* @__PURE__ */
|
|
241
|
-
/* @__PURE__ */
|
|
242
|
-
/* @__PURE__ */
|
|
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
|
|
246
|
-
function
|
|
247
|
-
const
|
|
248
|
-
|
|
249
|
-
const
|
|
250
|
-
if (
|
|
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
|
-
|
|
258
|
+
c.setAttribute("data-m-in", "");
|
|
253
259
|
return;
|
|
254
260
|
}
|
|
255
|
-
const
|
|
256
|
-
for (const
|
|
257
|
-
|
|
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
|
|
260
|
-
}, [
|
|
261
|
-
const
|
|
262
|
-
|
|
263
|
-
if (
|
|
264
|
-
|
|
265
|
-
const
|
|
266
|
-
|
|
267
|
-
}, [
|
|
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;
|
|
270
|
+
s.current = n;
|
|
271
|
+
const c = a.current;
|
|
272
|
+
c && (c.removeAttribute("data-m-run"), c.offsetWidth, c.setAttribute("data-m-run", ""));
|
|
273
|
+
}, [t, n]);
|
|
268
274
|
const d = {};
|
|
269
|
-
if (
|
|
270
|
-
const
|
|
271
|
-
return
|
|
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
|
|
274
|
-
const
|
|
275
|
-
if (!
|
|
276
|
-
const
|
|
277
|
-
|
|
278
|
-
}, { ref:
|
|
279
|
-
return
|
|
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
|
|
282
|
-
const
|
|
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
|
-
|
|
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;
|
|
300
|
+
const p = () => {
|
|
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
|
|
301
|
-
|
|
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
|
-
}, [d, n]),
|
|
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
|
|
306
|
-
return
|
|
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
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
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);
|
|
317
324
|
}
|
|
318
325
|
let d = !0;
|
|
319
|
-
return Promise.all(
|
|
326
|
+
return Promise.all(s.map((c) => c.finished.catch(() => {
|
|
320
327
|
}))).then(() => {
|
|
321
|
-
d && i(
|
|
328
|
+
d && i(e.key);
|
|
322
329
|
}), () => {
|
|
323
330
|
d = !1;
|
|
324
331
|
};
|
|
325
|
-
}, [
|
|
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);
|
|
326
333
|
}
|
|
327
|
-
function
|
|
328
|
-
const [
|
|
329
|
-
|
|
330
|
-
const
|
|
331
|
-
return
|
|
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 $(
|
|
332
339
|
i,
|
|
333
|
-
{ ...d, className: ["alea-page-transition",
|
|
334
|
-
|
|
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 }))
|
|
335
342
|
);
|
|
336
343
|
}
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
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 };
|
|
346
355
|
});
|
|
347
|
-
return
|
|
348
|
-
|
|
349
|
-
}),
|
|
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;
|
|
350
359
|
}));
|
|
351
|
-
const
|
|
352
|
-
|
|
353
|
-
for (const
|
|
354
|
-
const
|
|
355
|
-
|
|
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);
|
|
364
|
+
m && m.style.setProperty("--alea-row-h", `${m.offsetHeight}px`);
|
|
356
365
|
}
|
|
357
|
-
}, [
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
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 = () => {
|
|
372
|
+
var M;
|
|
373
|
+
if (!m) return;
|
|
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;
|
|
381
|
+
}));
|
|
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);
|
|
386
|
+
};
|
|
387
|
+
return x(), () => {
|
|
388
|
+
m = !1, window.clearTimeout(A);
|
|
389
|
+
};
|
|
390
|
+
};
|
|
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));
|
|
397
|
+
});
|
|
398
|
+
}, [y]), h(() => () => {
|
|
399
|
+
p.current.forEach((f) => f()), p.current.clear();
|
|
400
|
+
}, []);
|
|
401
|
+
const b = C((f) => (m) => {
|
|
402
|
+
m ? u.current.set(f, m) : u.current.delete(f);
|
|
380
403
|
}, []);
|
|
381
|
-
return { entries:
|
|
404
|
+
return { entries: s, ref: b };
|
|
382
405
|
}
|
|
383
|
-
function
|
|
384
|
-
const { entries: i, ref:
|
|
385
|
-
return
|
|
386
|
-
const
|
|
387
|
-
if (!
|
|
388
|
-
const d = [
|
|
389
|
-
|
|
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);
|
|
390
413
|
};
|
|
391
|
-
return
|
|
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 });
|
|
392
415
|
}));
|
|
393
416
|
}
|
|
394
417
|
export {
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
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
|
|
424
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. */
|
|
@@ -104,7 +106,7 @@ export declare function TextSwap({ children, as, className, direction, variant }
|
|
|
104
106
|
}): ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
|
105
107
|
/** A number whose digits roll to the new value (the roll pattern). Screen readers get the formatted value once. */
|
|
106
108
|
export declare function NumberRoll({ value, format, locale, className, live, label }: {
|
|
107
|
-
value: number; /** Intl.NumberFormat options: currency, percent, compact. */
|
|
109
|
+
value: number | string; /** Intl.NumberFormat options: currency, percent, compact. */
|
|
108
110
|
format?: Intl.NumberFormatOptions; /** A BCP 47 locale. Default the browser's. */
|
|
109
111
|
locale?: string;
|
|
110
112
|
className?: string; /** Announce each change to screen readers (default true). Set false when the number sits inside a heading or another live region, so it does not change that name and speak on every update. */
|
|
@@ -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.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-
|
|
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 */
|