@aura-react-comp/motion 0.0.0-stage → 0.1.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.
Files changed (88) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +56 -2
  3. package/esm/composed/aurora.d.ts +14 -0
  4. package/esm/composed/aurora.d.ts.map +1 -0
  5. package/esm/composed/aurora.js +66 -0
  6. package/esm/composed/confetti.d.ts +14 -0
  7. package/esm/composed/confetti.d.ts.map +1 -0
  8. package/esm/composed/confetti.js +99 -0
  9. package/esm/composed/cursor.d.ts +12 -0
  10. package/esm/composed/cursor.d.ts.map +1 -0
  11. package/esm/composed/cursor.js +112 -0
  12. package/esm/composed/draggable.d.ts +19 -0
  13. package/esm/composed/draggable.d.ts.map +1 -0
  14. package/esm/composed/draggable.js +62 -0
  15. package/esm/composed/flip-list.d.ts +21 -0
  16. package/esm/composed/flip-list.d.ts.map +1 -0
  17. package/esm/composed/flip-list.js +53 -0
  18. package/esm/composed/layout-group.d.ts +6 -0
  19. package/esm/composed/layout-group.d.ts.map +1 -0
  20. package/esm/composed/layout-group.js +7 -0
  21. package/esm/composed/lottie-player.d.ts +13 -0
  22. package/esm/composed/lottie-player.d.ts.map +1 -0
  23. package/esm/composed/lottie-player.js +57 -0
  24. package/esm/composed/page-transition.d.ts +23 -0
  25. package/esm/composed/page-transition.d.ts.map +1 -0
  26. package/esm/composed/page-transition.js +53 -0
  27. package/esm/composed/parallax.d.ts +19 -0
  28. package/esm/composed/parallax.d.ts.map +1 -0
  29. package/esm/composed/parallax.js +59 -0
  30. package/esm/composed/path-draw.d.ts +22 -0
  31. package/esm/composed/path-draw.d.ts.map +1 -0
  32. package/esm/composed/path-draw.js +53 -0
  33. package/esm/composed/reorder.d.ts +6 -0
  34. package/esm/composed/reorder.d.ts.map +1 -0
  35. package/esm/composed/reorder.js +7 -0
  36. package/esm/composed/scroll-driven.d.ts +23 -0
  37. package/esm/composed/scroll-driven.d.ts.map +1 -0
  38. package/esm/composed/scroll-driven.js +62 -0
  39. package/esm/composed/timeline.d.ts +37 -0
  40. package/esm/composed/timeline.d.ts.map +1 -0
  41. package/esm/composed/timeline.js +106 -0
  42. package/esm/composed/view-transition.d.ts +16 -0
  43. package/esm/composed/view-transition.d.ts.map +1 -0
  44. package/esm/composed/view-transition.js +47 -0
  45. package/esm/config/index.d.ts +6 -0
  46. package/esm/config/index.d.ts.map +1 -0
  47. package/esm/config/index.js +5 -0
  48. package/esm/hooks/index.d.ts +5 -0
  49. package/esm/hooks/index.d.ts.map +1 -0
  50. package/esm/hooks/index.js +4 -0
  51. package/esm/index.d.ts +58 -0
  52. package/esm/index.d.ts.map +1 -0
  53. package/esm/index.js +42 -0
  54. package/esm/primitive/focus-ring.d.ts +18 -0
  55. package/esm/primitive/focus-ring.d.ts.map +1 -0
  56. package/esm/primitive/focus-ring.js +81 -0
  57. package/esm/primitive/in-viewport.d.ts +19 -0
  58. package/esm/primitive/in-viewport.d.ts.map +1 -0
  59. package/esm/primitive/in-viewport.js +41 -0
  60. package/esm/primitive/keyframes.d.ts +23 -0
  61. package/esm/primitive/keyframes.d.ts.map +1 -0
  62. package/esm/primitive/keyframes.js +41 -0
  63. package/esm/primitive/magnetic.d.ts +14 -0
  64. package/esm/primitive/magnetic.d.ts.map +1 -0
  65. package/esm/primitive/magnetic.js +51 -0
  66. package/esm/primitive/number-ticker.d.ts +16 -0
  67. package/esm/primitive/number-ticker.d.ts.map +1 -0
  68. package/esm/primitive/number-ticker.js +42 -0
  69. package/esm/primitive/reveal.d.ts +22 -0
  70. package/esm/primitive/reveal.d.ts.map +1 -0
  71. package/esm/primitive/reveal.js +45 -0
  72. package/esm/primitive/skeleton-shimmer.d.ts +12 -0
  73. package/esm/primitive/skeleton-shimmer.d.ts.map +1 -0
  74. package/esm/primitive/skeleton-shimmer.js +50 -0
  75. package/esm/primitive/split-text.d.ts +17 -0
  76. package/esm/primitive/split-text.d.ts.map +1 -0
  77. package/esm/primitive/split-text.js +97 -0
  78. package/esm/primitive/transition.d.ts +54 -0
  79. package/esm/primitive/transition.d.ts.map +1 -0
  80. package/esm/primitive/transition.js +174 -0
  81. package/esm/primitive/typewriter.d.ts +15 -0
  82. package/esm/primitive/typewriter.d.ts.map +1 -0
  83. package/esm/primitive/typewriter.js +75 -0
  84. package/esm/tokens.css +32 -0
  85. package/esm/tokens.d.ts +33 -0
  86. package/esm/tokens.d.ts.map +1 -0
  87. package/esm/tokens.js +52 -0
  88. package/package.json +64 -3
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026-present Aura Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,57 @@
1
- # Temporary Holding Version
1
+ # @aura-react-comp/motion
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Aura 动效组件库 —— 令牌驱动的场景化动画组件。
4
+
5
+ ## 安装
6
+
7
+ ```bash
8
+ npm i @aura-react-comp/motion
9
+ ```
10
+
11
+ `react` / `react-dom` 为 peer 依赖;`lottie-web` 为**可选** peer(仅 `<LottiePlayer>` 需要)。
12
+
13
+ ## 引入令牌
14
+
15
+ 所有组件的时长与缓动都走动效令牌,请一次性引入(或经 ui 联动包级联引入):
16
+
17
+ ```tsx
18
+ import '@aura-react-comp/motion/tokens.css';
19
+ ```
20
+
21
+ ## 快速开始
22
+
23
+ ```tsx
24
+ import { Slide, NumberTicker, Reveal } from '@aura-react-comp/motion';
25
+
26
+ // 进出场(保留式:DOM 常驻)
27
+ <Slide visible={open} direction="up" distance="md">…</Slide>
28
+
29
+ // 进出场(卸载式:配合 AnimatePresence)
30
+ <AnimatePresence>{open && <Zoom key="modal">…</Zoom>}</AnimatePresence>
31
+
32
+ // 数字滚动
33
+ <NumberTicker value={128940} />
34
+
35
+ // 进入视口揭示
36
+ <Reveal index={0}>…</Reveal>
37
+ ```
38
+
39
+ ## 设计约定
40
+
41
+ 1. **只从本包导入**,不要直接依赖 `motion/react`(引擎隔离层);
42
+ 2. 时长 / 缓动 / 位移传**令牌档位名**(`'fast'`、`'decelerate'`、`'md'`),不传裸数值;
43
+ 3. 组件只动画 `transform` / `opacity`(`Collapse` 的 height 为既有例外,勿用于长列表)。
44
+
45
+ ## 可访问性(三层降级)
46
+
47
+ | 层 | 机制 |
48
+ | ------ | -------------------------------------------------------------------- |
49
+ | 令牌层 | `prefers-reduced-motion: reduce` 时 CSS 令牌时长归零 |
50
+ | 引擎层 | `<MotionConfig reducedMotion="user">` 全局开关 |
51
+ | 组件层 | 每组件内 `useReducedMotion()` 分支(Confetti 不撒、Cursor 不跟随……) |
52
+
53
+ ## 渐进增强声明
54
+
55
+ 运行时依赖 Motion 引擎的浏览器基线(高于 ui 包的 chrome 80)。不满足时组件直接呈现
56
+ **终态**,无中间帧、无报错,页面功能不受影响;`<ViewTransition>` 在不支持的浏览器
57
+ 自动降级为普通过渡。
@@ -0,0 +1,14 @@
1
+ /// <reference types="react" />
2
+ export interface AuroraProps {
3
+ /** 色块颜色序列,循环取用 */
4
+ colors?: string[];
5
+ /** 色块数量(默认 3) */
6
+ blobs?: number;
7
+ height?: number | string;
8
+ /** 色块模糊半径(px);模糊是静态 filter,不做 blur 动画(性能) */
9
+ blur?: number;
10
+ className?: string;
11
+ style?: React.CSSProperties;
12
+ }
13
+ export declare function Aurora({ colors, blobs, height, blur, className, style, }: AuroraProps): import("react").JSX.Element;
14
+ //# sourceMappingURL=aurora.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aurora.d.ts","sourceRoot":"","sources":["aurora.tsx"],"names":[],"mappings":";AASA,MAAM,WAAW,WAAW;IAC1B,kBAAkB;IAClB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,iBAAiB;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,6CAA6C;IAC7C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B;AAED,wBAAgB,MAAM,CAAC,EACrB,MAA0C,EAC1C,KAAS,EACT,MAAY,EACZ,IAAS,EACT,SAAS,EACT,KAAK,GACN,EAAE,WAAW,+BA2Cb"}
@@ -0,0 +1,66 @@
1
+ 'use client';
2
+
3
+ /**
4
+ * 渐变氛围背景:数个大模糊色块缓慢漂移(GPU transform 循环)。
5
+ * 用于登录页、empty 态、hero 区。reduced-motion 下呈静止渐变。
6
+ */
7
+ import { motion, useReducedMotion } from 'motion/react';
8
+ import { jsx as _jsx } from "react/jsx-runtime";
9
+ export function Aurora({
10
+ colors = ['#7c3aed', '#06b6d4', '#f472b6'],
11
+ blobs = 3,
12
+ height = 320,
13
+ blur = 80,
14
+ className,
15
+ style
16
+ }) {
17
+ const reduced = useReducedMotion();
18
+ const drift = [{
19
+ x: [0, 48, -36, 0],
20
+ y: [0, -32, 24, 0]
21
+ }, {
22
+ x: [0, -40, 32, 0],
23
+ y: [0, 28, -24, 0]
24
+ }, {
25
+ x: [0, 32, 40, 0],
26
+ y: [0, 24, -28, 0]
27
+ }];
28
+ return /*#__PURE__*/_jsx("div", {
29
+ "aria-hidden": true,
30
+ className: className,
31
+ style: {
32
+ position: 'relative',
33
+ overflow: 'hidden',
34
+ height,
35
+ borderRadius: 16,
36
+ ...style
37
+ },
38
+ children: Array.from({
39
+ length: blobs
40
+ }).map((_, i) => {
41
+ const d = drift[i % drift.length];
42
+ return /*#__PURE__*/_jsx(motion.div, {
43
+ style: {
44
+ position: 'absolute',
45
+ width: 320,
46
+ height: 320,
47
+ borderRadius: '50%',
48
+ background: colors[i % colors.length],
49
+ filter: `blur(${blur}px)`,
50
+ opacity: 0.45,
51
+ left: `${8 + i * 28}%`,
52
+ top: `${16 + i % 2 * 32}%`
53
+ },
54
+ animate: reduced ? undefined : {
55
+ x: d.x,
56
+ y: d.y
57
+ },
58
+ transition: {
59
+ duration: 14 + i * 4,
60
+ repeat: Infinity,
61
+ ease: 'easeInOut'
62
+ }
63
+ }, i);
64
+ })
65
+ });
66
+ }
@@ -0,0 +1,14 @@
1
+ /// <reference types="react" />
2
+ export interface ConfettiProps {
3
+ /** 发射触发器:计数器 +1 发射一轮 */
4
+ fire: number;
5
+ count?: number;
6
+ /** 发射原点(相对视口比例 0~1) */
7
+ origin?: {
8
+ x: number;
9
+ y: number;
10
+ };
11
+ colors?: string[];
12
+ }
13
+ export declare function Confetti({ fire, count, origin, colors, }: ConfettiProps): import("react").JSX.Element | null;
14
+ //# sourceMappingURL=confetti.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"confetti.d.ts","sourceRoot":"","sources":["confetti.tsx"],"names":[],"mappings":";AAUA,MAAM,WAAW,aAAa;IAC5B,wBAAwB;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uBAAuB;IACvB,MAAM,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAClC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAyBD,wBAAgB,QAAQ,CAAC,EACvB,IAAI,EACJ,KAAW,EACX,MAA2B,EAC3B,MAAuB,GACxB,EAAE,aAAa,sCAsFf"}
@@ -0,0 +1,99 @@
1
+ 'use client';
2
+
3
+ /**
4
+ * 庆祝粒子(canvas 2d):`fire` 计数器变化时发射一轮。
5
+ * reduced-motion 下不渲染任何内容;粒子全部离场后自动停止 rAF。
6
+ */
7
+ import { useEffect, useRef } from 'react';
8
+ import { useReducedMotion } from 'motion/react';
9
+ import { jsx as _jsx } from "react/jsx-runtime";
10
+ const DEFAULT_COLORS = ['#534ab7', '#1d9e75', '#d85a30', '#d4537e', '#378add', '#ba7517'];
11
+ export function Confetti({
12
+ fire,
13
+ count = 120,
14
+ origin = {
15
+ x: 0.5,
16
+ y: 0.6
17
+ },
18
+ colors = DEFAULT_COLORS
19
+ }) {
20
+ const canvasRef = useRef(null);
21
+ const reduced = useReducedMotion();
22
+ const lastFire = useRef(0);
23
+ useEffect(() => {
24
+ if (!fire || reduced) return;
25
+ const canvas = canvasRef.current;
26
+ if (!canvas) return;
27
+ const ctx = canvas.getContext('2d');
28
+ if (!ctx) return;
29
+ canvas.width = window.innerWidth;
30
+ canvas.height = window.innerHeight;
31
+ const ox = origin.x * canvas.width;
32
+ const oy = origin.y * canvas.height;
33
+ const parts = Array.from({
34
+ length: count
35
+ }, (_, i) => ({
36
+ x: ox,
37
+ y: oy,
38
+ vx: (Math.random() - 0.5) * 16,
39
+ vy: -Math.random() * 14 - 4,
40
+ rot: Math.random() * Math.PI,
41
+ vr: (Math.random() - 0.5) * 0.3,
42
+ size: 6 + Math.random() * 6,
43
+ color: colors[i % colors.length],
44
+ life: 1,
45
+ decay: 0.008 + Math.random() * 0.008,
46
+ rect: Math.random() > 0.5
47
+ }));
48
+ let raf = 0;
49
+ const tick = () => {
50
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
51
+ let alive = false;
52
+ for (const p of parts) {
53
+ p.life -= p.decay;
54
+ if (p.life <= 0) continue;
55
+ alive = true;
56
+ p.vy += 0.35;
57
+ p.x += p.vx;
58
+ p.y += p.vy;
59
+ p.rot += p.vr;
60
+ ctx.save();
61
+ ctx.globalAlpha = Math.max(p.life, 0);
62
+ ctx.translate(p.x, p.y);
63
+ ctx.rotate(p.rot);
64
+ ctx.fillStyle = p.color;
65
+ if (p.rect) {
66
+ ctx.fillRect(-p.size / 2, -p.size / 4, p.size, p.size / 2);
67
+ } else {
68
+ ctx.beginPath();
69
+ ctx.arc(0, 0, p.size / 2, 0, Math.PI * 2);
70
+ ctx.fill();
71
+ }
72
+ ctx.restore();
73
+ }
74
+ if (alive) {
75
+ raf = requestAnimationFrame(tick);
76
+ } else {
77
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
78
+ }
79
+ };
80
+ raf = requestAnimationFrame(tick);
81
+ lastFire.current = fire;
82
+ return () => cancelAnimationFrame(raf);
83
+ // origin/colors 变化不重发;fire 是唯一触发器
84
+ // eslint-disable-next-line react-hooks/exhaustive-deps
85
+ }, [fire, reduced, count]);
86
+ if (reduced) return null;
87
+ return /*#__PURE__*/_jsx("canvas", {
88
+ ref: canvasRef,
89
+ "aria-hidden": true,
90
+ style: {
91
+ position: 'fixed',
92
+ inset: 0,
93
+ width: '100%',
94
+ height: '100%',
95
+ pointerEvents: 'none',
96
+ zIndex: 9998
97
+ }
98
+ });
99
+ }
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ export interface CursorProps {
3
+ variant?: 'dot-ring' | 'blob';
4
+ /** 触发放大的选择器(事件委托) */
5
+ hoverTargets?: string;
6
+ /** 点的尺寸(px) */
7
+ size?: number;
8
+ /** 环放大倍数 */
9
+ hoverScale?: number;
10
+ }
11
+ export declare function Cursor({ variant, hoverTargets, size, hoverScale, }: CursorProps): import("react").JSX.Element | null;
12
+ //# sourceMappingURL=cursor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cursor.d.ts","sourceRoot":"","sources":["cursor.tsx"],"names":[],"mappings":";AAYA,MAAM,WAAW,WAAW;IAC1B,OAAO,CAAC,EAAE,UAAU,GAAG,MAAM,CAAC;IAC9B,qBAAqB;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY;IACZ,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,MAAM,CAAC,EACrB,OAAoB,EACpB,YAA8B,EAC9B,IAAQ,EACR,UAAgB,GACjB,EAAE,WAAW,sCA+Eb"}
@@ -0,0 +1,112 @@
1
+ 'use client';
2
+
3
+ /**
4
+ * 自定义光标跟随:点 + 环双层弹簧跟随,悬停 [data-cursor] 元素时环放大。
5
+ *
6
+ * 触屏设备与 reduced-motion 环境不渲染(不做任何 DOM)。
7
+ * 提醒:启用后建议在容器层为鼠标环境隐藏系统光标(cursor: none 由业务决定)。
8
+ */
9
+ import { useEffect, useState } from 'react';
10
+ import { motion, useMotionValue, useReducedMotion, useSpring } from 'motion/react';
11
+ import { jsx as _jsx } from "react/jsx-runtime";
12
+ import { jsxs as _jsxs } from "react/jsx-runtime";
13
+ export function Cursor({
14
+ variant = 'dot-ring',
15
+ hoverTargets = '[data-cursor]',
16
+ size = 8,
17
+ hoverScale = 2.4
18
+ }) {
19
+ const reduced = useReducedMotion();
20
+ const [enabled, setEnabled] = useState(false);
21
+ const [hovering, setHovering] = useState(false);
22
+ const dotX = useMotionValue(-100);
23
+ const dotY = useMotionValue(-100);
24
+ const dotSpring = useSpring(dotX, {
25
+ stiffness: 900,
26
+ damping: 50
27
+ });
28
+ const dotSpringY = useSpring(dotY, {
29
+ stiffness: 900,
30
+ damping: 50
31
+ });
32
+ const ringX = useSpring(dotX, {
33
+ stiffness: 250,
34
+ damping: 28
35
+ });
36
+ const ringY = useSpring(dotY, {
37
+ stiffness: 250,
38
+ damping: 28
39
+ });
40
+ useEffect(() => {
41
+ if (typeof window === 'undefined') return;
42
+ setEnabled(window.matchMedia('(pointer: fine)').matches);
43
+ }, []);
44
+ useEffect(() => {
45
+ if (!enabled || reduced) return;
46
+ const move = e => {
47
+ dotX.set(e.clientX);
48
+ dotY.set(e.clientY);
49
+ };
50
+ const over = e => {
51
+ setHovering(!!e.target.closest?.(hoverTargets));
52
+ };
53
+ window.addEventListener('mousemove', move, {
54
+ passive: true
55
+ });
56
+ window.addEventListener('mouseover', over, {
57
+ passive: true
58
+ });
59
+ return () => {
60
+ window.removeEventListener('mousemove', move);
61
+ window.removeEventListener('mouseover', over);
62
+ };
63
+ }, [enabled, reduced, hoverTargets, dotX, dotY]);
64
+ if (!enabled || reduced) return null;
65
+ const isBlob = variant === 'blob';
66
+ return /*#__PURE__*/_jsxs("div", {
67
+ "aria-hidden": true,
68
+ style: {
69
+ pointerEvents: 'none'
70
+ },
71
+ children: [/*#__PURE__*/_jsx(motion.div, {
72
+ style: {
73
+ position: 'fixed',
74
+ top: 0,
75
+ left: 0,
76
+ x: ringX,
77
+ y: ringY,
78
+ translateX: '-50%',
79
+ translateY: '-50%',
80
+ width: size * 4,
81
+ height: size * 4,
82
+ borderRadius: '50%',
83
+ border: '1.5px solid var(--aura-motion-focus-color, #534ab7)',
84
+ pointerEvents: 'none',
85
+ zIndex: 9999
86
+ },
87
+ animate: {
88
+ scale: hovering ? hoverScale : 1,
89
+ opacity: hovering ? 0.9 : 0.5
90
+ },
91
+ transition: {
92
+ duration: 0.18
93
+ }
94
+ }), /*#__PURE__*/_jsx(motion.div, {
95
+ style: {
96
+ position: 'fixed',
97
+ top: 0,
98
+ left: 0,
99
+ x: dotSpring,
100
+ y: dotSpringY,
101
+ translateX: '-50%',
102
+ translateY: '-50%',
103
+ width: isBlob ? size : size,
104
+ height: isBlob ? size : size,
105
+ borderRadius: '50%',
106
+ background: 'var(--aura-motion-focus-color, #534ab7)',
107
+ pointerEvents: 'none',
108
+ zIndex: 9999
109
+ }
110
+ })]
111
+ });
112
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * 自由拖拽:约束在包装容器内、可选网格吸附与惯性。
3
+ * reduced-motion 下退化为静态内容(不可拖)。
4
+ */
5
+ import { type ReactNode } from 'react';
6
+ export interface DraggableProps {
7
+ children: ReactNode;
8
+ /** 约束在包装容器内;false = 自由(仍受视口物理限制) */
9
+ bounds?: 'parent' | false;
10
+ /** 松手后吸附的网格尺寸 [x, y](px) */
11
+ grid?: [number, number];
12
+ /** 拖拽释放后的惯性;默认开 */
13
+ inertia?: boolean;
14
+ axis?: 'x' | 'y' | 'both';
15
+ className?: string;
16
+ style?: React.CSSProperties;
17
+ }
18
+ export declare function Draggable({ children, bounds, grid, inertia, axis, className, style, }: DraggableProps): import("react").JSX.Element;
19
+ //# sourceMappingURL=draggable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"draggable.d.ts","sourceRoot":"","sources":["draggable.tsx"],"names":[],"mappings":"AAEA;;;GAGG;AAEH,OAAO,EAAU,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAG/C,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,SAAS,CAAC;IACpB,oCAAoC;IACpC,MAAM,CAAC,EAAE,QAAQ,GAAG,KAAK,CAAC;IAC1B,4BAA4B;IAC5B,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxB,mBAAmB;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,MAAM,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B;AAED,wBAAgB,SAAS,CAAC,EACxB,QAAQ,EACR,MAAiB,EACjB,IAAI,EACJ,OAAc,EACd,IAAa,EACb,SAAS,EACT,KAAK,GACN,EAAE,cAAc,+BA2ChB"}
@@ -0,0 +1,62 @@
1
+ 'use client';
2
+
3
+ /**
4
+ * 自由拖拽:约束在包装容器内、可选网格吸附与惯性。
5
+ * reduced-motion 下退化为静态内容(不可拖)。
6
+ */
7
+ import { useRef } from 'react';
8
+ import { motion, useMotionValue, useReducedMotion } from 'motion/react';
9
+ import { jsx as _jsx } from "react/jsx-runtime";
10
+ export function Draggable({
11
+ children,
12
+ bounds = 'parent',
13
+ grid,
14
+ inertia = true,
15
+ axis = 'both',
16
+ className,
17
+ style
18
+ }) {
19
+ const wrapRef = useRef(null);
20
+ const reduced = useReducedMotion();
21
+ const x = useMotionValue(0);
22
+ const y = useMotionValue(0);
23
+ if (reduced) {
24
+ return /*#__PURE__*/_jsx("div", {
25
+ className: className,
26
+ style: style,
27
+ children: children
28
+ });
29
+ }
30
+ return /*#__PURE__*/_jsx("div", {
31
+ ref: wrapRef,
32
+ className: className,
33
+ style: {
34
+ position: 'relative',
35
+ minHeight: 48,
36
+ minWidth: 48,
37
+ ...style
38
+ },
39
+ children: /*#__PURE__*/_jsx(motion.div, {
40
+ drag: axis === 'both' ? true : axis,
41
+ dragConstraints: bounds === 'parent' ? wrapRef : false,
42
+ dragMomentum: inertia,
43
+ style: {
44
+ x,
45
+ y,
46
+ touchAction: 'none',
47
+ display: 'inline-block',
48
+ cursor: 'grab'
49
+ },
50
+ whileDrag: {
51
+ cursor: 'grabbing'
52
+ },
53
+ onDragEnd: () => {
54
+ if (grid) {
55
+ x.set(Math.round(x.get() / grid[0]) * grid[0]);
56
+ y.set(Math.round(y.get() / grid[1]) * grid[1]);
57
+ }
58
+ },
59
+ children: children
60
+ })
61
+ });
62
+ }
@@ -0,0 +1,21 @@
1
+ /// <reference types="react" />
2
+ /**
3
+ * 列表增删 / 排序的自动重排(FLIP)。
4
+ * items 变化时:新增项淡入、删除项淡出、存量项平滑移动到新位置。
5
+ */
6
+ import { type HTMLMotionProps } from 'motion/react';
7
+ export interface FlipListItem<T extends string = string> {
8
+ /** 稳定唯一键(同时也是 AnimatePresence 的 key) */
9
+ id: T;
10
+ node: React.ReactNode;
11
+ }
12
+ export interface FlipListProps<T extends string = string> extends Omit<HTMLMotionProps<'ul'>, 'children'> {
13
+ items: FlipListItem<T>[];
14
+ /** 渲染为哪种列表标签 */
15
+ as?: 'ul' | 'ol';
16
+ duration?: 'fast' | 'normal' | 'slow';
17
+ /** 100+ 行时建议配合虚拟列表;开启后关闭离场动画以避免布局抖动叠加 */
18
+ virtualized?: boolean;
19
+ }
20
+ export declare function FlipList<T extends string = string>({ items, as: Tag, duration, virtualized, style, ...rest }: FlipListProps<T>): import("react").JSX.Element;
21
+ //# sourceMappingURL=flip-list.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flip-list.d.ts","sourceRoot":"","sources":["flip-list.tsx"],"names":[],"mappings":";AAEA;;;GAGG;AAEH,OAAO,EAA2B,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAG7E,MAAM,WAAW,YAAY,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM;IACrD,wCAAwC;IACxC,EAAE,EAAE,CAAC,CAAC;IACN,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC;CACvB;AAED,MAAM,WAAW,aAAa,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,CACtD,SAAQ,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC;IAC/C,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;IACzB,gBAAgB;IAChB,EAAE,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,MAAM,CAAC;IACtC,yCAAyC;IACzC,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,wBAAgB,QAAQ,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,EAClD,KAAK,EACL,EAAE,EAAE,GAAU,EACd,QAAmB,EACnB,WAAmB,EACnB,KAAK,EACL,GAAG,IAAI,EACR,EAAE,aAAa,CAAC,CAAC,CAAC,+BAsBlB"}
@@ -0,0 +1,53 @@
1
+ 'use client';
2
+
3
+ /**
4
+ * 列表增删 / 排序的自动重排(FLIP)。
5
+ * items 变化时:新增项淡入、删除项淡出、存量项平滑移动到新位置。
6
+ */
7
+ import { AnimatePresence, motion } from 'motion/react';
8
+ import { motionDurations, motionEases } from "../tokens";
9
+ import { jsx as _jsx } from "react/jsx-runtime";
10
+ export function FlipList({
11
+ items,
12
+ as: Tag = 'ul',
13
+ duration = 'normal',
14
+ virtualized = false,
15
+ style,
16
+ ...rest
17
+ }) {
18
+ const ListTag = motion[Tag];
19
+ const transition = {
20
+ duration: motionDurations[duration],
21
+ ease: motionEases.standard
22
+ };
23
+ return /*#__PURE__*/_jsx(ListTag, {
24
+ style: {
25
+ listStyle: 'none',
26
+ margin: 0,
27
+ padding: 0,
28
+ ...style
29
+ },
30
+ ...rest,
31
+ children: /*#__PURE__*/_jsx(AnimatePresence, {
32
+ initial: false,
33
+ mode: "popLayout",
34
+ children: items.map(item => /*#__PURE__*/_jsx(motion.li, {
35
+ layout: true,
36
+ initial: {
37
+ opacity: 0,
38
+ y: 8
39
+ },
40
+ animate: {
41
+ opacity: 1,
42
+ y: 0
43
+ },
44
+ exit: virtualized ? undefined : {
45
+ opacity: 0,
46
+ scale: 0.96
47
+ },
48
+ transition: transition,
49
+ children: item.node
50
+ }, item.id))
51
+ })
52
+ });
53
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 共享布局分组:组内的 layoutId 元素可以互相"飞"过去(共享元素过渡)。
3
+ * 直接转发引擎实现,保持本包出口统一。
4
+ */
5
+ export { LayoutGroup } from 'motion/react';
6
+ //# sourceMappingURL=layout-group.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout-group.d.ts","sourceRoot":"","sources":["layout-group.ts"],"names":[],"mappings":"AAEA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,7 @@
1
+ 'use client';
2
+
3
+ /**
4
+ * 共享布局分组:组内的 layoutId 元素可以互相"飞"过去(共享元素过渡)。
5
+ * 直接转发引擎实现,保持本包出口统一。
6
+ */
7
+ export { LayoutGroup } from 'motion/react';
@@ -0,0 +1,13 @@
1
+ /// <reference types="react" />
2
+ export interface LottiePlayerProps {
3
+ /** 动画 JSON 的 URL(lottie-web 的 path 参数) */
4
+ src: string;
5
+ loop?: boolean;
6
+ autoplay?: boolean;
7
+ width?: number | string;
8
+ height?: number | string;
9
+ className?: string;
10
+ style?: React.CSSProperties;
11
+ }
12
+ export declare function LottiePlayer({ src, loop, autoplay, width, height, className, style, }: LottiePlayerProps): import("react").JSX.Element;
13
+ //# sourceMappingURL=lottie-player.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lottie-player.d.ts","sourceRoot":"","sources":["lottie-player.tsx"],"names":[],"mappings":";AAUA,MAAM,WAAW,iBAAiB;IAChC,0CAA0C;IAC1C,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B;AAMD,wBAAgB,YAAY,CAAC,EAC3B,GAAG,EACH,IAAW,EACX,QAAe,EACf,KAAW,EACX,MAAY,EACZ,SAAS,EACT,KAAK,GACN,EAAE,iBAAiB,+BAyCnB"}
@@ -0,0 +1,57 @@
1
+ 'use client';
2
+
3
+ /**
4
+ * Lottie 封装:lottie-web 为可选 peer,未安装时渲染占位并告警。
5
+ * reduced-motion 下加载但停在首帧(不自动播放)。
6
+ */
7
+ import { useEffect, useRef } from 'react';
8
+ import { useReducedMotion } from 'motion/react';
9
+ import { jsx as _jsx } from "react/jsx-runtime";
10
+ export function LottiePlayer({
11
+ src,
12
+ loop = true,
13
+ autoplay = true,
14
+ width = 120,
15
+ height = 120,
16
+ className,
17
+ style
18
+ }) {
19
+ const ref = useRef(null);
20
+ const reduced = useReducedMotion();
21
+ useEffect(() => {
22
+ let destroyed = false;
23
+ let instance;
24
+ (async () => {
25
+ try {
26
+ const mod = await import('lottie-web');
27
+ if (destroyed || !ref.current) return;
28
+ instance = mod.default.loadAnimation({
29
+ container: ref.current,
30
+ renderer: 'svg',
31
+ loop: reduced ? false : loop,
32
+ autoplay: reduced ? false : autoplay,
33
+ path: src
34
+ });
35
+ } catch {
36
+ // lottie-web 未安装(可选 peer):渲染占位,开发环境提示
37
+ if (process.env.NODE_ENV !== 'production' && ref.current) {
38
+ ref.current.textContent = 'lottie-web 未安装';
39
+ }
40
+ }
41
+ })();
42
+ return () => {
43
+ destroyed = true;
44
+ instance?.destroy();
45
+ };
46
+ }, [src, loop, autoplay, reduced]);
47
+ return /*#__PURE__*/_jsx("div", {
48
+ ref: ref,
49
+ className: className,
50
+ style: {
51
+ width,
52
+ height,
53
+ ...style
54
+ },
55
+ role: "img"
56
+ });
57
+ }