@alea-design/motion 0.5.1 → 0.6.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 +314 -225
- package/dist/react.d.ts +48 -2
- package/package.json +1 -1
- package/src/motion.css +4 -3
- package/src/patterns.css +13 -0
package/dist/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { useState as
|
|
4
|
-
const
|
|
5
|
-
function
|
|
2
|
+
import { jsx as b, jsxs as V } from "react/jsx-runtime";
|
|
3
|
+
import { useState as k, useEffect as w, useRef as h, useCallback as j, createElement as E, isValidElement as P, cloneElement as A, Children as z, Fragment as H, useLayoutEffect as Y } from "react";
|
|
4
|
+
const R = typeof window > "u" ? w : Y, X = ["out", "in", "in-out", "standard", "emphasized", "spring"], U = (t) => X.includes(t) ? `var(--alea-motion-${t === "spring" ? "spring" : "ease-" + t})` : t, O = (t, e) => t === "none" ? "none" : `alea-m-${t}-${e}`;
|
|
5
|
+
function I(t) {
|
|
6
6
|
if (t === void 0) return;
|
|
7
7
|
const e = t === !1 ? { enter: "none" } : typeof t == "string" ? { enter: t } : t, n = {};
|
|
8
|
-
return e.enter ? (n["--alea-enter"] =
|
|
8
|
+
return e.enter ? (n["--alea-enter"] = O(e.enter, "in"), n["--alea-exit"] = O(e.exit || e.enter, "out")) : e.exit && (n["--alea-exit"] = O(e.exit, "out")), e.duration != null ? (n["--alea-enter-duration"] = `${e.duration}ms`, n["--alea-exit-duration"] = `${e.exitDuration ?? Math.round(e.duration * 0.6)}ms`) : e.exitDuration != null && (n["--alea-exit-duration"] = `${e.exitDuration}ms`), e.easing && (n["--alea-enter-ease"] = U(e.easing)), e.delay != null && (n["--alea-enter-delay"] = `${e.delay}ms`), n;
|
|
9
9
|
}
|
|
10
|
-
function
|
|
11
|
-
const n =
|
|
12
|
-
return n ? typeof t == "function" ? ((
|
|
10
|
+
function oe(t, e) {
|
|
11
|
+
const n = I(e);
|
|
12
|
+
return n ? typeof t == "function" ? ((a) => ({ ...n, ...t(a) })) : { ...n, ...t } : t;
|
|
13
13
|
}
|
|
14
|
-
const
|
|
14
|
+
const W = {
|
|
15
15
|
popover: ".alea-popover",
|
|
16
16
|
select: ".alea-select-popover",
|
|
17
17
|
menu: ".alea-menu-popover",
|
|
@@ -23,313 +23,402 @@ const Y = {
|
|
|
23
23
|
hovercard: ".alea-hovercard",
|
|
24
24
|
datepicker: ".alea-cal-popover",
|
|
25
25
|
tour: ".alea-tour-card"
|
|
26
|
-
},
|
|
27
|
-
function
|
|
28
|
-
const e = {}, n = t.speed,
|
|
29
|
-
if (n != null && n !== 1) for (const [
|
|
30
|
-
if (
|
|
31
|
-
for (const [
|
|
32
|
-
for (const [
|
|
33
|
-
e["--alea-motion-scale-from"] = String(+(1 - 0.08 *
|
|
26
|
+
}, _ = { instant: 120, fast: 200, base: 320, slow: 480, slower: 720 }, G = { sm: 8, md: 12, lg: 24 }, J = { sm: 4, md: 8, lg: 16 };
|
|
27
|
+
function ae(t = {}) {
|
|
28
|
+
const e = {}, n = t.speed, a = t.intensity;
|
|
29
|
+
if (n != null && n !== 1) for (const [i, r] of Object.entries(_)) e[`--alea-motion-duration-${i}`] = `${Math.round(r * n)}ms`;
|
|
30
|
+
if (a != null && a !== 1) {
|
|
31
|
+
for (const [i, r] of Object.entries(G)) e[`--alea-motion-distance-${i}`] = `${+(r * a).toFixed(2)}px`;
|
|
32
|
+
for (const [i, r] of Object.entries(J)) e[`--alea-motion-blur-${i}`] = `${+(r * a).toFixed(2)}px`;
|
|
33
|
+
e["--alea-motion-scale-from"] = String(+(1 - 0.08 * a).toFixed(3)), e["--alea-motion-scale-press"] = String(+(1 - 0.04 * a).toFixed(3)), e["--alea-motion-lift"] = `${+(-4 * a).toFixed(2)}px`;
|
|
34
34
|
}
|
|
35
35
|
return e;
|
|
36
36
|
}
|
|
37
|
-
function
|
|
37
|
+
function ie(t = {}) {
|
|
38
38
|
const e = {};
|
|
39
39
|
return t.mode && t.mode !== "expressive" && (e["data-alea-motion"] = t.mode), t.reduced && t.reduced !== "system" && (e["data-alea-reduced"] = t.reduced), e;
|
|
40
40
|
}
|
|
41
|
-
function
|
|
42
|
-
return Object.entries(t).map(([n,
|
|
43
|
-
const
|
|
44
|
-
return !
|
|
41
|
+
function se(t = {}, e = ":root") {
|
|
42
|
+
return Object.entries(t).map(([n, a]) => {
|
|
43
|
+
const i = I(a), r = W[n];
|
|
44
|
+
return !i || !r ? "" : `${e} ${r} { ${Object.entries(i).map(([s, l]) => `${s}: ${l};`).join(" ")} }`;
|
|
45
45
|
}).filter(Boolean).join(`
|
|
46
46
|
`);
|
|
47
47
|
}
|
|
48
|
-
function
|
|
49
|
-
const [t, e] =
|
|
50
|
-
return
|
|
51
|
-
var r,
|
|
48
|
+
function D() {
|
|
49
|
+
const [t, e] = k(!1);
|
|
50
|
+
return w(() => {
|
|
51
|
+
var r, s;
|
|
52
52
|
if (typeof window > "u") return;
|
|
53
|
-
const n = (r = window.matchMedia) == null ? void 0 : r.call(window, "(prefers-reduced-motion: reduce)"),
|
|
54
|
-
const
|
|
55
|
-
e(
|
|
53
|
+
const n = (r = window.matchMedia) == null ? void 0 : r.call(window, "(prefers-reduced-motion: reduce)"), a = () => {
|
|
54
|
+
const l = document.documentElement, d = l.getAttribute("data-alea-reduced"), c = l.getAttribute("data-alea-motion");
|
|
55
|
+
e(c === "off" || c === "reduced" || d === "always" || d !== "never" && !!(n != null && n.matches));
|
|
56
56
|
};
|
|
57
|
-
|
|
58
|
-
const
|
|
59
|
-
return
|
|
60
|
-
var
|
|
61
|
-
(
|
|
57
|
+
a(), (s = n == null ? void 0 : n.addEventListener) == null || s.call(n, "change", a);
|
|
58
|
+
const i = new MutationObserver(a);
|
|
59
|
+
return i.observe(document.documentElement, { attributes: !0, attributeFilter: ["data-alea-motion", "data-alea-reduced"] }), () => {
|
|
60
|
+
var l;
|
|
61
|
+
(l = n == null ? void 0 : n.removeEventListener) == null || l.call(n, "change", a), i.disconnect();
|
|
62
62
|
};
|
|
63
63
|
}, []), t;
|
|
64
64
|
}
|
|
65
|
-
function
|
|
66
|
-
const { once: e = !0, margin: n = "0px 0px -10% 0px", threshold:
|
|
67
|
-
return
|
|
68
|
-
const
|
|
69
|
-
if (!
|
|
70
|
-
|
|
65
|
+
function Q(t = {}) {
|
|
66
|
+
const { once: e = !0, margin: n = "0px 0px -10% 0px", threshold: a = 0.1 } = t, i = h(null), [r, s] = k(!1);
|
|
67
|
+
return w(() => {
|
|
68
|
+
const l = i.current;
|
|
69
|
+
if (!l || typeof IntersectionObserver > "u") {
|
|
70
|
+
s(!0);
|
|
71
71
|
return;
|
|
72
72
|
}
|
|
73
|
-
const d = new IntersectionObserver(([
|
|
74
|
-
|
|
75
|
-
}, { rootMargin: n, threshold:
|
|
76
|
-
return d.observe(
|
|
77
|
-
}, [e, n,
|
|
73
|
+
const d = new IntersectionObserver(([c]) => {
|
|
74
|
+
c.isIntersecting ? (s(!0), e && d.disconnect()) : e || s(!1);
|
|
75
|
+
}, { rootMargin: n, threshold: a });
|
|
76
|
+
return d.observe(l), () => d.disconnect();
|
|
77
|
+
}, [e, n, a]), [i, r];
|
|
78
78
|
}
|
|
79
|
-
let
|
|
80
|
-
function
|
|
79
|
+
let S = null;
|
|
80
|
+
function Z(t) {
|
|
81
81
|
return typeof IntersectionObserver > "u" ? () => {
|
|
82
|
-
} : (
|
|
82
|
+
} : (S ?? (S = new IntersectionObserver((e) => {
|
|
83
83
|
for (const n of e) n.target.toggleAttribute("data-alea-offscreen", !n.isIntersecting);
|
|
84
|
-
}, { rootMargin: "64px" })),
|
|
85
|
-
|
|
84
|
+
}, { rootMargin: "64px" })), S.observe(t), () => {
|
|
85
|
+
S == null || S.unobserve(t), t.removeAttribute("data-alea-offscreen");
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
|
-
function
|
|
89
|
-
const t =
|
|
90
|
-
return
|
|
88
|
+
function le() {
|
|
89
|
+
const t = h(null);
|
|
90
|
+
return w(() => t.current ? Z(t.current) : void 0, []), t;
|
|
91
91
|
}
|
|
92
|
-
function
|
|
93
|
-
const [e, n] =
|
|
94
|
-
return
|
|
95
|
-
let
|
|
96
|
-
const
|
|
92
|
+
function ce(t = 8) {
|
|
93
|
+
const [e, n] = k("up");
|
|
94
|
+
return w(() => {
|
|
95
|
+
let a = window.scrollY;
|
|
96
|
+
const i = () => {
|
|
97
97
|
const r = window.scrollY;
|
|
98
|
-
Math.abs(r -
|
|
98
|
+
Math.abs(r - a) < t || (n(r > a && r > 64 ? "down" : "up"), a = r);
|
|
99
99
|
};
|
|
100
|
-
return window.addEventListener("scroll",
|
|
100
|
+
return window.addEventListener("scroll", i, { passive: !0 }), () => window.removeEventListener("scroll", i);
|
|
101
101
|
}, [t]), e;
|
|
102
102
|
}
|
|
103
|
-
function
|
|
104
|
-
return { onPointerDown:
|
|
105
|
-
const n = e.currentTarget,
|
|
106
|
-
r.className = "alea-ripple", r.setAttribute("aria-hidden", "true"), r.style.setProperty("--alea-ripple-x", `${e.clientX -
|
|
103
|
+
function ue() {
|
|
104
|
+
return { onPointerDown: j((e) => {
|
|
105
|
+
const n = e.currentTarget, a = n.getBoundingClientRect(), i = Math.hypot(Math.max(e.clientX - a.left, a.right - e.clientX), Math.max(e.clientY - a.top, a.bottom - e.clientY)) * 2, r = document.createElement("span");
|
|
106
|
+
r.className = "alea-ripple", r.setAttribute("aria-hidden", "true"), r.style.setProperty("--alea-ripple-x", `${e.clientX - a.left}px`), r.style.setProperty("--alea-ripple-y", `${e.clientY - a.top}px`), r.style.setProperty("--alea-ripple-size", `${i}px`), n.appendChild(r), r.addEventListener("animationend", () => r.remove()), window.setTimeout(() => r.remove(), 1200);
|
|
107
107
|
}, []), className: "alea-ripple-host" };
|
|
108
108
|
}
|
|
109
|
-
function
|
|
109
|
+
function de(t) {
|
|
110
110
|
const e = typeof document < "u" ? document : null;
|
|
111
111
|
e != null && e.startViewTransition ? e.startViewTransition(t) : t();
|
|
112
112
|
}
|
|
113
|
-
function
|
|
114
|
-
const [
|
|
115
|
-
|
|
116
|
-
const m =
|
|
113
|
+
function fe({ as: t = "div", motion: e = "rise", delay: n, once: a = !0, stagger: i, className: r, style: s, children: l, ...d }) {
|
|
114
|
+
const [c, u] = Q({ once: a }), [o, f] = k(!1);
|
|
115
|
+
R(() => {
|
|
116
|
+
const m = c.current;
|
|
117
117
|
m && m.getBoundingClientRect().top > window.innerHeight && f(!0);
|
|
118
118
|
}, []);
|
|
119
119
|
const p = typeof e == "string" ? { enter: e } : e;
|
|
120
120
|
return E(t, {
|
|
121
121
|
...d,
|
|
122
|
-
ref:
|
|
122
|
+
ref: c,
|
|
123
123
|
className: r,
|
|
124
|
-
"data-reveal":
|
|
125
|
-
"data-stagger":
|
|
126
|
-
style: { ...
|
|
127
|
-
},
|
|
124
|
+
"data-reveal": o && !u ? "pending" : o ? "in" : void 0,
|
|
125
|
+
"data-stagger": i ? "reveal" : void 0,
|
|
126
|
+
style: { ...i ? {} : I({ ...p, delay: n ?? p.delay }), ...s }
|
|
127
|
+
}, l);
|
|
128
128
|
}
|
|
129
|
-
function
|
|
130
|
-
const [
|
|
131
|
-
return
|
|
132
|
-
var
|
|
129
|
+
function pe({ show: t, exitClassName: e = "alea-dissolve-out", children: n }) {
|
|
130
|
+
const [a, i] = k(t), [r, s] = k(!1), l = h(null);
|
|
131
|
+
return w(() => {
|
|
132
|
+
var o;
|
|
133
133
|
if (t) {
|
|
134
|
-
|
|
134
|
+
i(!0), s(!1);
|
|
135
135
|
return;
|
|
136
136
|
}
|
|
137
|
-
if (!
|
|
138
|
-
|
|
139
|
-
const d =
|
|
140
|
-
|
|
141
|
-
},
|
|
142
|
-
if (!d || !
|
|
143
|
-
const f = window.setTimeout(
|
|
137
|
+
if (!a) return;
|
|
138
|
+
s(!0);
|
|
139
|
+
const d = l.current, c = () => {
|
|
140
|
+
i(!1), s(!1);
|
|
141
|
+
}, u = ((o = d == null ? void 0 : d.getAnimations) == null ? void 0 : o.call(d)) || [];
|
|
142
|
+
if (!d || !u.length) {
|
|
143
|
+
const f = window.setTimeout(c, 0);
|
|
144
144
|
return () => window.clearTimeout(f);
|
|
145
145
|
}
|
|
146
|
-
Promise.all(
|
|
147
|
-
}))).then(
|
|
148
|
-
}, [t]),
|
|
149
|
-
var d,
|
|
150
|
-
r &&
|
|
151
|
-
}, [r]), !
|
|
146
|
+
Promise.all(u.map((f) => f.finished.catch(() => {
|
|
147
|
+
}))).then(c);
|
|
148
|
+
}, [t]), w(() => {
|
|
149
|
+
var d, c;
|
|
150
|
+
r && l.current && !((c = (d = l.current).getAnimations) != null && c.call(d).length) && (i(!1), s(!1));
|
|
151
|
+
}, [r]), !a || !P(n) ? null : A(n, { ref: l, className: [n.props.className, r && e].filter(Boolean).join(" ") });
|
|
152
152
|
}
|
|
153
|
-
function
|
|
154
|
-
const [r,
|
|
155
|
-
var
|
|
156
|
-
return typeof
|
|
153
|
+
function me({ children: t, as: e = "span", className: n, direction: a = "up", variant: i = "blur" }) {
|
|
154
|
+
const [r, s] = k([{ id: 0, node: t }]), l = h(t), d = h(0), c = (u) => {
|
|
155
|
+
var o;
|
|
156
|
+
return typeof u == "string" || typeof u == "number" ? String(u) : P(u) ? String(u.key ?? "") + JSON.stringify(((o = u.props) == null ? void 0 : o.children) ?? "") : "";
|
|
157
157
|
};
|
|
158
|
-
return
|
|
159
|
-
if (
|
|
160
|
-
|
|
158
|
+
return w(() => {
|
|
159
|
+
if (c(t) === c(l.current)) {
|
|
160
|
+
s((u) => u.map((o) => o.out ? o : { ...o, node: t }));
|
|
161
161
|
return;
|
|
162
162
|
}
|
|
163
|
-
|
|
163
|
+
l.current = t, d.current += 1, s((u) => [...u.filter((o) => !o.out).map((o) => ({ ...o, out: !0 })), { id: d.current, node: t }]);
|
|
164
164
|
}, [t]), E(
|
|
165
165
|
e,
|
|
166
|
-
{ className: ["alea-swap", n].filter(Boolean).join(" "), "data-variant":
|
|
167
|
-
r.map((
|
|
166
|
+
{ className: ["alea-swap", n].filter(Boolean).join(" "), "data-variant": i === "scale" ? "scale" : void 0, style: { "--alea-swap-dir": a === "up" ? 1 : -1 }, "aria-live": "polite" },
|
|
167
|
+
r.map((u) => /* @__PURE__ */ b("span", { className: u.id === 0 && !u.out ? void 0 : u.out ? "alea-swap-out" : "alea-swap-in", "aria-hidden": u.out || void 0, onAnimationEnd: u.out ? () => s((o) => o.filter((f) => f.id !== u.id)) : void 0, children: u.node }, u.id))
|
|
168
168
|
);
|
|
169
169
|
}
|
|
170
|
-
function
|
|
171
|
-
const
|
|
172
|
-
return /* @__PURE__ */
|
|
173
|
-
/* @__PURE__ */
|
|
174
|
-
/* @__PURE__ */
|
|
170
|
+
function ge({ value: t, format: e, locale: n, className: a, live: i = !0, label: r }) {
|
|
171
|
+
const s = new Intl.NumberFormat(n, e).format(t);
|
|
172
|
+
return /* @__PURE__ */ V("span", { className: ["alea-roll", a].filter(Boolean).join(" "), children: [
|
|
173
|
+
/* @__PURE__ */ b("span", { className: "alea-visually-hidden", "aria-live": i ? "polite" : void 0, children: r ? `${r} ${s}` : s }),
|
|
174
|
+
/* @__PURE__ */ b("span", { "aria-hidden": "true", style: { display: "inline-flex" }, children: [...s].map((l, d) => /\d/.test(l) ? /* @__PURE__ */ b("span", { className: "alea-roll-digit", children: /* @__PURE__ */ b("span", { className: "alea-roll-strip", style: { "--alea-roll-n": l }, children: "0123456789".split("").map((c) => /* @__PURE__ */ b("span", { children: c }, c)) }) }, s.length - d) : /* @__PURE__ */ b("span", { children: l }, `s${s.length - d}`)) })
|
|
175
175
|
] });
|
|
176
176
|
}
|
|
177
|
-
function
|
|
178
|
-
const
|
|
179
|
-
return
|
|
180
|
-
const
|
|
181
|
-
if (!
|
|
182
|
-
const
|
|
183
|
-
return
|
|
184
|
-
}, []), E(n, { className: ["alea-autoheight", e].filter(Boolean).join(" "), style:
|
|
177
|
+
function ve({ children: t, className: e, as: n = "div" }) {
|
|
178
|
+
const a = h(null), [i, r] = k(void 0);
|
|
179
|
+
return w(() => {
|
|
180
|
+
const s = a.current;
|
|
181
|
+
if (!s || typeof ResizeObserver > "u") return;
|
|
182
|
+
const l = new ResizeObserver(() => r(s.offsetHeight));
|
|
183
|
+
return l.observe(s), () => l.disconnect();
|
|
184
|
+
}, []), E(n, { className: ["alea-autoheight", e].filter(Boolean).join(" "), style: i != null ? { height: i } : void 0 }, /* @__PURE__ */ b("div", { ref: a, children: t }));
|
|
185
185
|
}
|
|
186
|
-
function
|
|
187
|
-
const e =
|
|
188
|
-
return
|
|
186
|
+
function ye({ className: t }) {
|
|
187
|
+
const e = h(null), [n, a] = k(!1);
|
|
188
|
+
return w(() => {
|
|
189
189
|
var r;
|
|
190
190
|
if (typeof CSS < "u" && ((r = CSS.supports) != null && r.call(CSS, "animation-timeline: scroll()"))) {
|
|
191
|
-
|
|
191
|
+
a(!0);
|
|
192
192
|
return;
|
|
193
193
|
}
|
|
194
|
-
const
|
|
195
|
-
var
|
|
196
|
-
const
|
|
197
|
-
(
|
|
194
|
+
const i = () => {
|
|
195
|
+
var l;
|
|
196
|
+
const s = document.documentElement.scrollHeight - window.innerHeight;
|
|
197
|
+
(l = e.current) == null || l.style.setProperty("--alea-scroll", String(s > 0 ? Math.min(1, window.scrollY / s) : 0));
|
|
198
198
|
};
|
|
199
|
-
return
|
|
200
|
-
window.removeEventListener("scroll",
|
|
199
|
+
return i(), window.addEventListener("scroll", i, { passive: !0 }), window.addEventListener("resize", i), () => {
|
|
200
|
+
window.removeEventListener("scroll", i), window.removeEventListener("resize", i);
|
|
201
201
|
};
|
|
202
|
-
}, []), /* @__PURE__ */
|
|
202
|
+
}, []), /* @__PURE__ */ b("div", { ref: e, className: ["alea-scroll-progress", t].filter(Boolean).join(" "), "data-css": n || void 0, "aria-hidden": "true" });
|
|
203
203
|
}
|
|
204
|
-
function
|
|
204
|
+
function we({ chunks: t, streaming: e = !1, className: n, as: a = "p" }) {
|
|
205
205
|
return E(
|
|
206
|
-
|
|
206
|
+
a,
|
|
207
207
|
{ className: ["alea-stream", n].filter(Boolean).join(" "), "data-streaming": e || void 0, "aria-busy": e || void 0 },
|
|
208
|
-
|
|
208
|
+
z.toArray(t.map((i, r) => /* @__PURE__ */ b("span", { className: "alea-stream-chunk", children: i }, r)))
|
|
209
209
|
);
|
|
210
210
|
}
|
|
211
|
-
const M = /* @__PURE__ */ new Map(),
|
|
211
|
+
const M = /* @__PURE__ */ new Map(), F = (t) => {
|
|
212
212
|
const e = t.getBoundingClientRect();
|
|
213
213
|
return { x: e.left + window.scrollX, y: e.top + window.scrollY, w: e.width, h: e.height, radius: getComputedStyle(t).borderRadius, time: performance.now() };
|
|
214
214
|
};
|
|
215
|
-
function
|
|
216
|
-
const
|
|
217
|
-
return
|
|
218
|
-
const
|
|
219
|
-
if (!
|
|
220
|
-
const f = M.get(t), p =
|
|
221
|
-
if (f && !
|
|
222
|
-
const
|
|
223
|
-
if (
|
|
224
|
-
{ transformOrigin: "0 0", transform: `translate(${f.x - p.x}px, ${f.y - p.y}px) scale(${
|
|
215
|
+
function he({ id: t, as: e = "div", duration: n, easing: a, fadeContent: i = !0, className: r, style: s, children: l, ...d }) {
|
|
216
|
+
const c = h(null), u = D();
|
|
217
|
+
return R(() => {
|
|
218
|
+
const o = c.current;
|
|
219
|
+
if (!o) return;
|
|
220
|
+
const f = M.get(t), p = F(o);
|
|
221
|
+
if (f && !u && performance.now() - f.time < 1500 && (f.w !== p.w || f.h !== p.h || f.x !== p.x || f.y !== p.y) && typeof o.animate == "function") {
|
|
222
|
+
const y = n ?? (parseFloat(getComputedStyle(o).getPropertyValue("--alea-motion-duration-slow")) || 480), g = a ?? (getComputedStyle(o).getPropertyValue("--alea-motion-ease-standard").trim() || "cubic-bezier(0.2, 0, 0, 1)"), x = f.w / Math.max(1, p.w), N = f.h / Math.max(1, p.h);
|
|
223
|
+
if (o.animate([
|
|
224
|
+
{ transformOrigin: "0 0", transform: `translate(${f.x - p.x}px, ${f.y - p.y}px) scale(${x}, ${N})`, borderRadius: f.radius },
|
|
225
225
|
{ transformOrigin: "0 0", transform: "none", borderRadius: p.radius }
|
|
226
|
-
], { duration:
|
|
226
|
+
], { duration: y, easing: g }), i) for (const L of Array.from(o.children)) L.animate([{ opacity: 0 }, { opacity: 0, offset: 0.35 }, { opacity: 1 }], { duration: y, easing: "ease-out" });
|
|
227
227
|
}
|
|
228
228
|
M.set(t, p);
|
|
229
|
-
const
|
|
230
|
-
|
|
229
|
+
const v = () => {
|
|
230
|
+
o.isConnected && M.set(t, F(o));
|
|
231
231
|
};
|
|
232
|
-
window.addEventListener("scroll",
|
|
233
|
-
const m = typeof ResizeObserver < "u" ? new ResizeObserver(
|
|
234
|
-
return m == null || m.observe(
|
|
235
|
-
|
|
232
|
+
window.addEventListener("scroll", v, { passive: !0 });
|
|
233
|
+
const m = typeof ResizeObserver < "u" ? new ResizeObserver(v) : null;
|
|
234
|
+
return m == null || m.observe(o), () => {
|
|
235
|
+
v(), M.set(t, { ...M.get(t) || p, time: performance.now() }), window.removeEventListener("scroll", v), m == null || m.disconnect();
|
|
236
236
|
};
|
|
237
|
-
}, [t]), E(e, { ...d, ref:
|
|
237
|
+
}, [t]), E(e, { ...d, ref: c, className: r, style: s, "data-morph": t }, l);
|
|
238
238
|
}
|
|
239
|
-
function
|
|
240
|
-
return /* @__PURE__ */
|
|
241
|
-
/* @__PURE__ */
|
|
242
|
-
/* @__PURE__ */
|
|
239
|
+
function xe({ from: t, to: e, active: n, className: a }) {
|
|
240
|
+
return /* @__PURE__ */ V("span", { className: ["alea-morph-icon", a].filter(Boolean).join(" "), "data-active": n || void 0, "aria-hidden": "true", children: [
|
|
241
|
+
/* @__PURE__ */ b("span", { className: "alea-morph-icon-a", children: t }),
|
|
242
|
+
/* @__PURE__ */ b("span", { className: "alea-morph-icon-b", children: e })
|
|
243
243
|
] });
|
|
244
244
|
}
|
|
245
|
-
const
|
|
246
|
-
function
|
|
247
|
-
const
|
|
248
|
-
|
|
249
|
-
const
|
|
250
|
-
if (e !== "visible" || !
|
|
245
|
+
const K = { lift: "alea-hover-lift", press: "alea-press", tint: "alea-hover-tint", glow: "alea-hover-glow", hint: "alea-hint" };
|
|
246
|
+
function q(t, { on: e = "mount", value: n, delay: a, duration: i, once: r = !0 } = {}) {
|
|
247
|
+
const s = h(null);
|
|
248
|
+
w(() => {
|
|
249
|
+
const u = s.current;
|
|
250
|
+
if (e !== "visible" || !u) return;
|
|
251
251
|
if (typeof IntersectionObserver > "u") {
|
|
252
|
-
|
|
252
|
+
u.setAttribute("data-m-in", "");
|
|
253
253
|
return;
|
|
254
254
|
}
|
|
255
|
-
const
|
|
255
|
+
const o = new IntersectionObserver((f) => {
|
|
256
256
|
for (const p of f)
|
|
257
|
-
p.isIntersecting ? (
|
|
257
|
+
p.isIntersecting ? (u.setAttribute("data-m-in", ""), r && o.disconnect()) : r || u.removeAttribute("data-m-in");
|
|
258
258
|
}, { rootMargin: "0px 0px -8% 0px" });
|
|
259
|
-
return
|
|
259
|
+
return o.observe(u), () => o.disconnect();
|
|
260
260
|
}, [e, r]);
|
|
261
|
-
const
|
|
262
|
-
|
|
263
|
-
if (e !== "change" || Object.is(
|
|
264
|
-
|
|
265
|
-
const
|
|
266
|
-
|
|
261
|
+
const l = h(n);
|
|
262
|
+
w(() => {
|
|
263
|
+
if (e !== "change" || Object.is(l.current, n)) return;
|
|
264
|
+
l.current = n;
|
|
265
|
+
const u = s.current;
|
|
266
|
+
u && (u.removeAttribute("data-m-run"), u.offsetWidth, u.setAttribute("data-m-run", ""));
|
|
267
267
|
}, [e, n]);
|
|
268
268
|
const d = {};
|
|
269
|
-
if (
|
|
270
|
-
const
|
|
271
|
-
return
|
|
269
|
+
if (a != null && (d["--alea-m-delay"] = `${a}ms`), i != null && (d["--alea-m-duration"] = `${i}ms`), t === "stagger") return { ref: s, "data-stagger": "", style: d };
|
|
270
|
+
const c = K[t];
|
|
271
|
+
return c ? { ref: s, className: c, style: d } : { ref: s, className: "alea-m", "data-m": t, "data-m-on": e, ...e === "loop" ? { "data-alea-loop": "" } : {}, style: d };
|
|
272
272
|
}
|
|
273
|
-
function
|
|
274
|
-
const
|
|
275
|
-
if (!
|
|
276
|
-
const r =
|
|
277
|
-
|
|
278
|
-
}, { ref:
|
|
279
|
-
return
|
|
273
|
+
function be({ pattern: t, children: e, ...n }) {
|
|
274
|
+
const a = q(t, n), i = z.only(e);
|
|
275
|
+
if (!P(i)) return e;
|
|
276
|
+
const r = i.props.ref, s = (o) => {
|
|
277
|
+
a.ref.current = o, typeof r == "function" ? r(o) : r && typeof r == "object" && (r.current = o);
|
|
278
|
+
}, { ref: l, className: d, style: c, ...u } = a;
|
|
279
|
+
return A(i, { ...u, ref: s, className: [i.props.className, d].filter(Boolean).join(" ") || void 0, style: { ...i.props.style, ...c } });
|
|
280
280
|
}
|
|
281
|
-
function
|
|
282
|
-
const
|
|
283
|
-
return
|
|
284
|
-
var
|
|
285
|
-
const
|
|
286
|
-
if (!
|
|
287
|
-
const
|
|
288
|
-
|
|
289
|
-
}, f = (
|
|
290
|
-
const
|
|
291
|
-
|
|
292
|
-
}, p = () =>
|
|
293
|
-
let
|
|
281
|
+
function ke({ as: t = "div", strength: e = 16, scroll: n = !1, className: a, style: i, children: r, ...s }) {
|
|
282
|
+
const l = h(null), d = D();
|
|
283
|
+
return w(() => {
|
|
284
|
+
var y;
|
|
285
|
+
const c = l.current;
|
|
286
|
+
if (!c || d || typeof window > "u") return;
|
|
287
|
+
const u = (y = window.matchMedia) == null ? void 0 : y.call(window, "(pointer: fine)").matches, o = (g, x) => {
|
|
288
|
+
c.style.setProperty("--alea-par-x", g.toFixed(3)), c.style.setProperty("--alea-par-y", x.toFixed(3));
|
|
289
|
+
}, f = (g) => {
|
|
290
|
+
const x = c.getBoundingClientRect();
|
|
291
|
+
o(((g.clientX - x.left) / x.width - 0.5) * 2, ((g.clientY - x.top) / x.height - 0.5) * 2);
|
|
292
|
+
}, p = () => o(0, 0);
|
|
293
|
+
let v = 0;
|
|
294
294
|
const m = () => {
|
|
295
|
-
cancelAnimationFrame(
|
|
296
|
-
const
|
|
297
|
-
|
|
295
|
+
cancelAnimationFrame(v), v = requestAnimationFrame(() => {
|
|
296
|
+
const g = c.getBoundingClientRect(), x = g.top + g.height / 2 - window.innerHeight / 2;
|
|
297
|
+
c.style.setProperty("--alea-par-s", Math.max(-1, Math.min(1, x / window.innerHeight)).toFixed(3));
|
|
298
298
|
});
|
|
299
299
|
};
|
|
300
|
-
return
|
|
301
|
-
|
|
300
|
+
return u && (c.addEventListener("pointermove", f), c.addEventListener("pointerleave", p)), n && (window.addEventListener("scroll", m, { passive: !0 }), m()), () => {
|
|
301
|
+
c.removeEventListener("pointermove", f), c.removeEventListener("pointerleave", p), window.removeEventListener("scroll", m), cancelAnimationFrame(v);
|
|
302
302
|
};
|
|
303
|
-
}, [d, n]), E(t, { ...
|
|
303
|
+
}, [d, n]), E(t, { ...s, ref: l, className: ["alea-parallax", a].filter(Boolean).join(" "), style: { "--alea-par-strength": `${e}px`, ...i } }, r);
|
|
304
|
+
}
|
|
305
|
+
function Ee({ as: t = "div", depth: e = 0.5, className: n, style: a, children: i, ...r }) {
|
|
306
|
+
return E(t, { ...r, className: ["alea-parallax-layer", n].filter(Boolean).join(" "), style: { "--alea-depth": e, ...a } }, i);
|
|
304
307
|
}
|
|
305
|
-
function
|
|
306
|
-
|
|
308
|
+
function ee({ layer: t, leaving: e, entering: n, style: a, onDone: i }) {
|
|
309
|
+
const r = h(null);
|
|
310
|
+
return w(() => {
|
|
311
|
+
var c;
|
|
312
|
+
if (!e) return;
|
|
313
|
+
const s = r.current, l = ((c = s == null ? void 0 : s.getAnimations) == null ? void 0 : c.call(s)) || [];
|
|
314
|
+
if (!s || !l.length) {
|
|
315
|
+
const u = window.setTimeout(() => i(t.key), 0);
|
|
316
|
+
return () => window.clearTimeout(u);
|
|
317
|
+
}
|
|
318
|
+
let d = !0;
|
|
319
|
+
return Promise.all(l.map((u) => u.finished.catch(() => {
|
|
320
|
+
}))).then(() => {
|
|
321
|
+
d && i(t.key);
|
|
322
|
+
}), () => {
|
|
323
|
+
d = !1;
|
|
324
|
+
};
|
|
325
|
+
}, [e]), E("div", { ref: r, className: "alea-page-layer", "data-leaving": e || void 0, "data-entering": n || void 0, style: a, inert: e || void 0, "aria-hidden": e || void 0 }, t.node);
|
|
326
|
+
}
|
|
327
|
+
function Ne({ routeKey: t, pattern: e = "fade", duration: n, exitDuration: a, as: i = "div", className: r, style: s, children: l, ...d }) {
|
|
328
|
+
const [c, u] = k({ key: t, leaving: [], changed: !1 }), o = h(l);
|
|
329
|
+
c.key !== t ? u({ key: t, leaving: [...c.leaving.filter((m) => m.key !== t), { key: c.key, node: o.current }], changed: !0 }) : o.current = l;
|
|
330
|
+
const f = j((m) => u((y) => ({ ...y, leaving: y.leaving.filter((g) => g.key !== m) })), []), p = I({ enter: e, exit: e, duration: n, exitDuration: a }), v = [...c.leaving.map((m) => ({ ...m, leaving: !0 })), { key: t, node: l, leaving: !1 }];
|
|
331
|
+
return E(
|
|
332
|
+
i,
|
|
333
|
+
{ ...d, className: ["alea-page-transition", r].filter(Boolean).join(" "), style: s },
|
|
334
|
+
v.map((m) => E(ee, { key: m.key, layer: m, leaving: m.leaving, entering: !m.leaving && c.changed, style: p, onDone: f }))
|
|
335
|
+
);
|
|
336
|
+
}
|
|
337
|
+
function te(t, e, n = !0) {
|
|
338
|
+
const a = t ?? [], [i, r] = k(() => a.map((o, f) => ({ item: o, key: e(o), leaving: !1, entering: !1, enterIndex: f }))), s = h(t), l = h(/* @__PURE__ */ new Map());
|
|
339
|
+
s.current !== t && (s.current = t, r((o) => {
|
|
340
|
+
const f = a.map(e), p = new Set(f), v = new Set(o.map((g) => g.key));
|
|
341
|
+
let m = 0;
|
|
342
|
+
const y = a.map((g, x) => {
|
|
343
|
+
var B, T, C;
|
|
344
|
+
const N = f[x], L = !v.has(N) || ((B = o.find(($) => $.key === N)) == null ? void 0 : B.leaving) === !0;
|
|
345
|
+
return { item: g, key: N, leaving: !1, entering: n && (L || !!((T = o.find(($) => $.key === N)) != null && T.entering)), enterIndex: L ? m++ : ((C = o.find(($) => $.key === N)) == null ? void 0 : C.enterIndex) ?? 0 };
|
|
346
|
+
});
|
|
347
|
+
return n && o.forEach((g, x) => {
|
|
348
|
+
p.has(g.key) || y.splice(Math.min(x, y.length), 0, { ...g, leaving: !0, entering: !1 });
|
|
349
|
+
}), y;
|
|
350
|
+
}));
|
|
351
|
+
const d = j((o) => r((f) => f.filter((p) => !(p.key === o && p.leaving))), []), c = i.filter((o) => o.leaving).map((o) => String(o.key)).join("|");
|
|
352
|
+
R(() => {
|
|
353
|
+
for (const o of i) if (o.leaving) {
|
|
354
|
+
const f = l.current.get(o.key);
|
|
355
|
+
f && f.style.setProperty("--alea-row-h", `${f.offsetHeight}px`);
|
|
356
|
+
}
|
|
357
|
+
}, [c]), w(() => {
|
|
358
|
+
var f;
|
|
359
|
+
const o = [];
|
|
360
|
+
for (const p of i) {
|
|
361
|
+
if (!p.leaving) continue;
|
|
362
|
+
const v = l.current.get(p.key), m = ((f = v == null ? void 0 : v.getAnimations) == null ? void 0 : f.call(v)) || [];
|
|
363
|
+
if (!v || !m.length) {
|
|
364
|
+
const g = window.setTimeout(() => d(p.key), 0);
|
|
365
|
+
o.push(() => window.clearTimeout(g));
|
|
366
|
+
continue;
|
|
367
|
+
}
|
|
368
|
+
let y = !0;
|
|
369
|
+
Promise.all(m.map((g) => g.finished.catch(() => {
|
|
370
|
+
}))).then(() => {
|
|
371
|
+
y && d(p.key);
|
|
372
|
+
}), o.push(() => {
|
|
373
|
+
y = !1;
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
return () => o.forEach((p) => p());
|
|
377
|
+
}, [c]);
|
|
378
|
+
const u = j((o) => (f) => {
|
|
379
|
+
f ? l.current.set(o, f) : l.current.delete(o);
|
|
380
|
+
}, []);
|
|
381
|
+
return { entries: i, ref: u };
|
|
382
|
+
}
|
|
383
|
+
function $e({ items: t, getKey: e, children: n, animate: a = !0 }) {
|
|
384
|
+
const { entries: i, ref: r } = te(t, e, a);
|
|
385
|
+
return E(H, null, i.map((s) => {
|
|
386
|
+
const l = n(s.item, { leaving: s.leaving, entering: s.entering });
|
|
387
|
+
if (!P(l)) return null;
|
|
388
|
+
const d = [l.props.className, s.leaving ? "alea-row-leave" : s.entering ? "alea-row-enter" : ""].filter(Boolean).join(" "), c = l.props.ref, u = (o) => {
|
|
389
|
+
r(s.key)(o), typeof c == "function" ? c(o) : c && typeof c == "object" && (c.current = o);
|
|
390
|
+
};
|
|
391
|
+
return A(l, { key: s.key, className: d, ref: u, "data-leaving": s.leaving || void 0, style: s.entering ? { ...l.props.style, "--alea-i": Math.min(s.enterIndex, 11) } : l.props.style });
|
|
392
|
+
}));
|
|
307
393
|
}
|
|
308
394
|
export {
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
395
|
+
ve as AutoHeight,
|
|
396
|
+
W as MOTION_SELECTORS,
|
|
397
|
+
he as Morph,
|
|
398
|
+
xe as MorphIcon,
|
|
399
|
+
be as Motion,
|
|
400
|
+
ge as NumberRoll,
|
|
401
|
+
Ne as PageTransition,
|
|
402
|
+
ke as Parallax,
|
|
403
|
+
Ee as ParallaxLayer,
|
|
404
|
+
pe as Presence,
|
|
405
|
+
$e as PresenceList,
|
|
406
|
+
fe as Reveal,
|
|
407
|
+
ye as ScrollProgress,
|
|
408
|
+
we as StreamingText,
|
|
409
|
+
me as TextSwap,
|
|
410
|
+
ie as motionAttributes,
|
|
411
|
+
se as motionComponentCss,
|
|
412
|
+
I as motionStyle,
|
|
413
|
+
ae as motionVariables,
|
|
414
|
+
Z as pauseWhenOffscreen,
|
|
415
|
+
de as startViewTransition,
|
|
416
|
+
Q as useInView,
|
|
417
|
+
q as useMotion,
|
|
418
|
+
le as useOffscreenPause,
|
|
419
|
+
te as usePresenceList,
|
|
420
|
+
D as useReducedMotion,
|
|
421
|
+
ue as useRipple,
|
|
422
|
+
ce as useScrollDirection,
|
|
423
|
+
oe as withMotionStyle
|
|
335
424
|
};
|
package/dist/react.d.ts
CHANGED
|
@@ -103,11 +103,13 @@ export declare function TextSwap({ children, as, className, direction, variant }
|
|
|
103
103
|
variant?: 'blur' | 'scale';
|
|
104
104
|
}): ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
|
105
105
|
/** A number whose digits roll to the new value (the roll pattern). Screen readers get the formatted value once. */
|
|
106
|
-
export declare function NumberRoll({ value, format, locale, className }: {
|
|
106
|
+
export declare function NumberRoll({ value, format, locale, className, live, label }: {
|
|
107
107
|
value: number; /** Intl.NumberFormat options: currency, percent, compact. */
|
|
108
108
|
format?: Intl.NumberFormatOptions; /** A BCP 47 locale. Default the browser's. */
|
|
109
109
|
locale?: string;
|
|
110
|
-
className?: string;
|
|
110
|
+
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. */
|
|
111
|
+
live?: boolean; /** Read before the number when it is announced: "Open operations" gives "Open operations 12". Only for live={true}; otherwise name the container yourself. */
|
|
112
|
+
label?: string;
|
|
111
113
|
}): import("react").JSX.Element;
|
|
112
114
|
/** Animates its height when its content changes size (the resize pattern). */
|
|
113
115
|
export declare function AutoHeight({ children, className, as }: {
|
|
@@ -208,4 +210,48 @@ export declare function Parallax({ as, strength, scroll, className, style, child
|
|
|
208
210
|
export declare function ParallaxLayer({ as, depth, className, style, children, ...rest }: AsProps & {
|
|
209
211
|
depth?: number;
|
|
210
212
|
}): ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
|
213
|
+
/** Wraps the routed page: when `routeKey` changes the old page fades out as the new one fades in, in the same place. Subtle by default (a short fade); no animation on the first render. */
|
|
214
|
+
export declare function PageTransition({ routeKey, pattern, duration, exitDuration, as, className, style, children, ...rest }: AsProps & {
|
|
215
|
+
/** Changes when the page changes: the path, the route id. Same key, same page: nothing plays. */
|
|
216
|
+
routeKey: string;
|
|
217
|
+
/** The enter and exit preset. Default fade; rise and the slide presets move a little (the distance is a token, zero with reduced motion). */
|
|
218
|
+
pattern?: MotionPreset;
|
|
219
|
+
/** Enter duration in ms. Default the fast token (200 ms; shorter in productive mode). */
|
|
220
|
+
duration?: number;
|
|
221
|
+
/** Exit duration in ms. Default 60% of the enter. */
|
|
222
|
+
exitDuration?: number;
|
|
223
|
+
}): ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
|
224
|
+
/** One row of a PresenceList: the item, and whether it is arriving or leaving. */
|
|
225
|
+
export interface PresenceEntry<T> {
|
|
226
|
+
item: T;
|
|
227
|
+
key: string | number;
|
|
228
|
+
/** Removed from the list, still mounted while its exit plays. */
|
|
229
|
+
leaving: boolean;
|
|
230
|
+
/** Added after the first render: plays its entrance. */
|
|
231
|
+
entering: boolean;
|
|
232
|
+
/** Position among the items added in the same update (the stagger), 0 for the first. */
|
|
233
|
+
enterIndex: number;
|
|
234
|
+
}
|
|
235
|
+
/** The items of a list with the removed ones kept mounted until their exit animation ends. Hand `entries` to your list, put `ref(key)` on each row, and style `leaving` and `entering` rows (the class names alea-row-enter and alea-row-leave do it). */
|
|
236
|
+
export declare function usePresenceList<T>(items: readonly T[] | undefined, getKey: (item: T) => string | number, enabled?: boolean): {
|
|
237
|
+
entries: PresenceEntry<T>[];
|
|
238
|
+
ref: (key: string | number) => (node: HTMLElement | null) => void;
|
|
239
|
+
};
|
|
240
|
+
/** Lists that keep a removed row on screen until its exit finishes, and let a new row enter. No wrapper element: it renders what you return for each item. Rows enter with `rise` and leave with `dissolve`, staggered by the stagger token (capped at 12). */
|
|
241
|
+
export declare function PresenceList<T>({ items, getKey, children, animate }: {
|
|
242
|
+
items: readonly T[];
|
|
243
|
+
/** A stable key for an item. */
|
|
244
|
+
getKey: (item: T) => string | number;
|
|
245
|
+
/** The row for an item: return one element (a li, a div, a Row). It gets the class names, the stagger and a ref; use `state.leaving` to disable controls. */
|
|
246
|
+
children: (item: T, state: {
|
|
247
|
+
leaving: boolean;
|
|
248
|
+
entering: boolean;
|
|
249
|
+
}) => ReactElement<{
|
|
250
|
+
className?: string;
|
|
251
|
+
style?: CSSProperties;
|
|
252
|
+
ref?: unknown;
|
|
253
|
+
}>;
|
|
254
|
+
/** false renders the items as they are, with no entrance and no exit. Default true. */
|
|
255
|
+
animate?: boolean;
|
|
256
|
+
}): import("react").FunctionComponentElement<import("react").FragmentProps>;
|
|
211
257
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alea-design/motion",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.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
|
@@ -148,6 +148,7 @@
|
|
|
148
148
|
.alea-spoiler-body { transition-duration: var(--alea-motion-duration-slow); transition-timing-function: var(--alea-motion-ease-out); }
|
|
149
149
|
|
|
150
150
|
/* ------------------------------------------------------------------ glide: one indicator per group moves between items (React Aria SelectionIndicator) */
|
|
151
|
+
/* Tabs indicators are scoped to `.alea-tab > .alea-sel-indicator`, never a bare descendant: a SegmentedControl or a ToggleGroup inside a TabPanel keeps its own indicator */
|
|
151
152
|
.alea-tab, .alea-segmented-item { position: relative; isolation: isolate; }
|
|
152
153
|
.alea-tab-label, .alea-segmented-label, .alea-toggle-label, .alea-toggle-icon { position: relative; z-index: 1; }
|
|
153
154
|
.alea-sel-indicator {
|
|
@@ -156,9 +157,9 @@
|
|
|
156
157
|
}
|
|
157
158
|
.alea-sel-indicator[data-entering] { animation: alea-m-fade-in var(--alea-motion-duration-fast) var(--alea-motion-ease-out); }
|
|
158
159
|
.alea-sel-indicator[data-exiting] { animation: alea-m-fade-out var(--alea-motion-duration-fast) var(--alea-motion-ease-in) forwards; }
|
|
159
|
-
.alea-tabs[data-variant='underline'] .alea-sel-indicator { inset: auto 0 0; left: var(--alea-
|
|
160
|
-
.alea-tabs[data-orientation='vertical'][data-variant='underline'] .alea-sel-indicator { inset: var(--alea-space-2, 8px) auto var(--alea-space-2, 8px) 0; left: 0; width: 2px; height: calc(100% - var(--alea-space-2) * 2); }
|
|
161
|
-
.alea-tabs[data-variant='pills'] .alea-sel-indicator, .alea-segmented .alea-sel-indicator { background: var(--alea-chip-bg); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18); }
|
|
160
|
+
.alea-tabs[data-variant='underline'] .alea-tab > .alea-sel-indicator { inset: auto 0 0; left: max(0.75rem, var(--alea-control-pad-x-3, 0.75rem)); width: calc(100% - max(0.75rem, var(--alea-control-pad-x-3, 0.75rem)) * 2); height: 2px; border-radius: var(--alea-radius-2xs, 2px); background: var(--alea-gradient-accent-linear); }
|
|
161
|
+
.alea-tabs[data-orientation='vertical'][data-variant='underline'] .alea-tab > .alea-sel-indicator { inset: var(--alea-space-2, 8px) auto var(--alea-space-2, 8px) 0; left: 0; width: 2px; height: calc(100% - var(--alea-space-2) * 2); }
|
|
162
|
+
.alea-tabs[data-variant='pills'] .alea-tab > .alea-sel-indicator, .alea-segmented .alea-sel-indicator { background: var(--alea-chip-bg); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18); }
|
|
162
163
|
.alea-toggle-group .alea-sel-indicator { background: var(--alea-surface-raised); box-shadow: var(--alea-shadow-card), inset 0 0 0 1px var(--alea-border-strong); }
|
|
163
164
|
|
|
164
165
|
/* ------------------------------------------------------------------ lift */
|
package/src/patterns.css
CHANGED
|
@@ -144,3 +144,16 @@
|
|
|
144
144
|
.alea-morph-icon-b { opacity: 0; transform: rotate(calc(var(--alea-motion-rotate, 12deg) * -7.5)) scale(calc(1 - (1 - var(--alea-motion-scale-from)) * 6)); filter: blur(var(--alea-motion-blur-sm)); }
|
|
145
145
|
.alea-morph-icon[data-active] .alea-morph-icon-a { opacity: 0; transform: rotate(calc(var(--alea-motion-rotate, 12deg) * 7.5)) scale(calc(1 - (1 - var(--alea-motion-scale-from)) * 6)); filter: blur(var(--alea-motion-blur-sm)); }
|
|
146
146
|
.alea-morph-icon[data-active] .alea-morph-icon-b { opacity: 1; transform: none; filter: none; }
|
|
147
|
+
|
|
148
|
+
/* ------------------------------------------------------------------ page transition and animated rows */
|
|
149
|
+
/* PageTransition: the old and the new page share one grid cell, so they crossfade in place. Enter and exit read --alea-enter / --alea-exit (the pattern prop sets them). */
|
|
150
|
+
.alea-page-transition { display: grid; }
|
|
151
|
+
.alea-page-layer { grid-area: 1 / 1; min-width: 0; }
|
|
152
|
+
.alea-page-layer[data-entering] { animation: var(--alea-enter-duration, var(--alea-motion-duration-fast)) var(--alea-enter-ease, var(--alea-motion-ease-out)) var(--alea-enter-delay, 0s) both var(--alea-enter, alea-m-fade-in); }
|
|
153
|
+
.alea-page-layer[data-leaving] { pointer-events: none; animation: var(--alea-exit-duration, var(--alea-motion-duration-instant)) var(--alea-exit-ease, var(--alea-motion-ease-in)) both var(--alea-exit, alea-m-fade-out); }
|
|
154
|
+
:is([data-alea-motion='off']) .alea-page-layer { animation: none; }
|
|
155
|
+
/* rows: a new row rises in (staggered, 40 ms apiece up to 12), a removed row dissolves and gives its space back */
|
|
156
|
+
.alea-row-enter { animation: alea-m-rise-in var(--alea-motion-duration-base) var(--alea-motion-ease-out) both; animation-delay: calc(var(--alea-i, 0) * var(--alea-motion-stagger)); }
|
|
157
|
+
.alea-row-leave { pointer-events: none; overflow: hidden; animation: alea-row-leave var(--alea-motion-duration-base) var(--alea-motion-ease-in) forwards; }
|
|
158
|
+
@keyframes alea-row-leave { from { height: var(--alea-row-h, auto); } to { opacity: 0.01; filter: blur(var(--alea-motion-blur-md)); height: 0; min-height: 0; padding-block: 0; margin-block: 0; border-width: 0; } }
|
|
159
|
+
:is([data-alea-motion='off']) :is(.alea-row-enter, .alea-row-leave) { animation: none; }
|