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