@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
@@ -0,0 +1,23 @@
1
+ /// <reference types="react" />
2
+ /**
3
+ * 路由转场:Next.js App Router 的 `template.tsx` 模式。
4
+ *
5
+ * ```tsx
6
+ * // app/template.tsx —— PageTransition 从本包入口导入
7
+ * 'use client';
8
+ * export default function Template({ children }: { children: React.ReactNode }) {
9
+ * return <PageTransition transitionKey={usePathname()}>{children}</PageTransition>;
10
+ * }
11
+ * ```
12
+ */
13
+ import { type HTMLMotionProps } from 'motion/react';
14
+ import { type DurationToken } from '../tokens';
15
+ export interface PageTransitionProps extends Omit<HTMLMotionProps<'div'>, 'initial' | 'animate' | 'exit' | 'transition'> {
16
+ /** 路由标识(如 usePathname() 的返回值);变化即触发转场 */
17
+ transitionKey: string;
18
+ /** wait = 旧页退完新页再进;sync = 交叉过渡(需要父容器相对定位) */
19
+ mode?: 'wait' | 'sync';
20
+ duration?: DurationToken;
21
+ }
22
+ export declare function PageTransition({ transitionKey, mode, duration, style, children, ...rest }: PageTransitionProps): import("react").JSX.Element;
23
+ //# sourceMappingURL=page-transition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"page-transition.d.ts","sourceRoot":"","sources":["page-transition.tsx"],"names":[],"mappings":";AAEA;;;;;;;;;;GAUG;AAEH,OAAO,EAA2B,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAC7E,OAAO,EAAgC,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC;AAE7E,MAAM,WAAW,mBACf,SAAQ,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,MAAM,GAAG,YAAY,CAAC;IACnF,yCAAyC;IACzC,aAAa,EAAE,MAAM,CAAC;IACtB,6CAA6C;IAC7C,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,aAAa,CAAC;CAC1B;AAED,wBAAgB,cAAc,CAAC,EAC7B,aAAa,EACb,IAAa,EACb,QAAmB,EACnB,KAAK,EACL,QAAQ,EACR,GAAG,IAAI,EACR,EAAE,mBAAmB,+BAgBrB"}
@@ -0,0 +1,53 @@
1
+ 'use client';
2
+
3
+ /**
4
+ * 路由转场:Next.js App Router 的 `template.tsx` 模式。
5
+ *
6
+ * ```tsx
7
+ * // app/template.tsx —— PageTransition 从本包入口导入
8
+ * 'use client';
9
+ * export default function Template({ children }: { children: React.ReactNode }) {
10
+ * return <PageTransition transitionKey={usePathname()}>{children}</PageTransition>;
11
+ * }
12
+ * ```
13
+ */
14
+ import { AnimatePresence, motion } from 'motion/react';
15
+ import { motionDurations, motionEases } from "../tokens";
16
+ import { jsx as _jsx } from "react/jsx-runtime";
17
+ export function PageTransition({
18
+ transitionKey,
19
+ mode = 'wait',
20
+ duration = 'normal',
21
+ style,
22
+ children,
23
+ ...rest
24
+ }) {
25
+ return /*#__PURE__*/_jsx(AnimatePresence, {
26
+ mode: mode,
27
+ initial: false,
28
+ children: /*#__PURE__*/_jsx(motion.div, {
29
+ initial: {
30
+ opacity: 0,
31
+ y: 12
32
+ },
33
+ animate: {
34
+ opacity: 1,
35
+ y: 0
36
+ },
37
+ exit: {
38
+ opacity: 0,
39
+ y: -8
40
+ },
41
+ transition: {
42
+ duration: motionDurations[duration],
43
+ ease: motionEases.standard
44
+ },
45
+ style: mode === 'sync' ? {
46
+ position: 'relative',
47
+ ...style
48
+ } : style,
49
+ ...rest,
50
+ children: children
51
+ }, transitionKey)
52
+ });
53
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * 多层视差:每层以不同速度因子跟随滚动位移(负值反向)。
3
+ * 仅位移 transform,合成器友好。
4
+ */
5
+ import { type ReactNode } from 'react';
6
+ export interface ParallaxLayerSpec {
7
+ /** 速度因子:0.3 = 滚动 100px 该层移动 30px;负值反向 */
8
+ speed: number;
9
+ node: ReactNode;
10
+ }
11
+ export interface ParallaxProps {
12
+ layers: ParallaxLayerSpec[];
13
+ /** 位移弹簧平滑(0 关闭,视差一般不需要) */
14
+ smooth?: number;
15
+ style?: React.CSSProperties;
16
+ className?: string;
17
+ }
18
+ export declare function Parallax({ layers, smooth, style, className }: ParallaxProps): import("react").JSX.Element;
19
+ //# sourceMappingURL=parallax.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parallax.d.ts","sourceRoot":"","sources":["parallax.tsx"],"names":[],"mappings":"AAEA;;;GAGG;AAEH,OAAO,EAAU,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAG/C,MAAM,WAAW,iBAAiB;IAChC,yCAAyC;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,SAAS,CAAC;CACjB;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,iBAAiB,EAAE,CAAC;IAC5B,2BAA2B;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAgBD,wBAAgB,QAAQ,CAAC,EAAE,MAAM,EAAE,MAAU,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,aAAa,+BAiB/E"}
@@ -0,0 +1,59 @@
1
+ 'use client';
2
+
3
+ /**
4
+ * 多层视差:每层以不同速度因子跟随滚动位移(负值反向)。
5
+ * 仅位移 transform,合成器友好。
6
+ */
7
+ import { useRef } from 'react';
8
+ import { motion, useScroll, useSpring, useTransform } from 'motion/react';
9
+ import { jsx as _jsx } from "react/jsx-runtime";
10
+ function useLayerOffset(containerRef, speed, smooth) {
11
+ const {
12
+ scrollYProgress
13
+ } = useScroll({
14
+ target: containerRef,
15
+ offset: ['start end', 'end start']
16
+ });
17
+ const raw = useTransform(scrollYProgress, [0, 1], [speed * 100, speed * -100]);
18
+ const springed = useSpring(raw, {
19
+ stiffness: 150,
20
+ damping: 30
21
+ });
22
+ return smooth > 0 ? springed : raw;
23
+ }
24
+ export function Parallax({
25
+ layers,
26
+ smooth = 0,
27
+ style,
28
+ className
29
+ }) {
30
+ const containerRef = useRef(null);
31
+ return /*#__PURE__*/_jsx("div", {
32
+ ref: containerRef,
33
+ className: className,
34
+ style: {
35
+ position: 'relative',
36
+ ...style
37
+ },
38
+ children: layers.map((layer, i) => /*#__PURE__*/_jsx(ParallaxLayer, {
39
+ containerRef: containerRef,
40
+ speed: layer.speed,
41
+ smooth: smooth,
42
+ children: layer.node
43
+ }, i))
44
+ });
45
+ }
46
+ function ParallaxLayer({
47
+ containerRef,
48
+ speed,
49
+ smooth,
50
+ children
51
+ }) {
52
+ const y = useLayerOffset(containerRef, speed, smooth);
53
+ return /*#__PURE__*/_jsx(motion.div, {
54
+ style: {
55
+ y
56
+ },
57
+ children: children
58
+ });
59
+ }
@@ -0,0 +1,22 @@
1
+ /// <reference types="react" />
2
+ import { type DurationToken, type EaseToken } from '../tokens';
3
+ export interface PathDrawProps {
4
+ /** 一条或多条 SVG path 的 d 属性;多条时按顺序描边 */
5
+ paths: string[];
6
+ /** SVG viewBox */
7
+ viewBox?: string;
8
+ width?: number | string;
9
+ /** 描边颜色(stroke) */
10
+ stroke?: string;
11
+ strokeWidth?: number;
12
+ /** 每条路径的描边时长(秒),或令牌档位名 */
13
+ duration?: number | DurationToken;
14
+ /** 循环:true 无限;数字为次数;默认不循环(画完保持) */
15
+ loop?: boolean | number;
16
+ ease?: EaseToken;
17
+ delay?: number;
18
+ className?: string;
19
+ style?: React.CSSProperties;
20
+ }
21
+ export declare function PathDraw({ paths, viewBox, width, stroke, strokeWidth, duration, loop, ease, delay, className, style, }: PathDrawProps): import("react").JSX.Element;
22
+ //# sourceMappingURL=path-draw.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path-draw.d.ts","sourceRoot":"","sources":["path-draw.tsx"],"names":[],"mappings":";AAQA,OAAO,EAAgC,KAAK,aAAa,EAAE,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AAE7F,MAAM,WAAW,aAAa;IAC5B,qCAAqC;IACrC,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,kBAAkB;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,mBAAmB;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0BAA0B;IAC1B,QAAQ,CAAC,EAAE,MAAM,GAAG,aAAa,CAAC;IAClC,mCAAmC;IACnC,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACxB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B;AAED,wBAAgB,QAAQ,CAAC,EACvB,KAAK,EACL,OAAuB,EACvB,KAAW,EACX,MAAuB,EACvB,WAAe,EACf,QAAiB,EACjB,IAAY,EACZ,IAAmB,EACnB,KAAS,EACT,SAAS,EACT,KAAK,GACN,EAAE,aAAa,+BAiCf"}
@@ -0,0 +1,53 @@
1
+ 'use client';
2
+
3
+ /**
4
+ * SVG 路径描边:logo / 插画 / 图表线条的"一笔画出"效果。
5
+ * 支持 loop 与多条路径的顺序衔接。
6
+ */
7
+ import { motion } from 'motion/react';
8
+ import { motionDurations, motionEases } from "../tokens";
9
+ import { jsx as _jsx } from "react/jsx-runtime";
10
+ export function PathDraw({
11
+ paths,
12
+ viewBox = '0 0 100 100',
13
+ width = 120,
14
+ stroke = 'currentColor',
15
+ strokeWidth = 2,
16
+ duration = 'slow',
17
+ loop = false,
18
+ ease = 'decelerate',
19
+ delay = 0,
20
+ className,
21
+ style
22
+ }) {
23
+ const seconds = typeof duration === 'number' ? duration : motionDurations[duration];
24
+ const repeat = loop === true ? Infinity : loop || 0;
25
+ return /*#__PURE__*/_jsx("svg", {
26
+ viewBox: viewBox,
27
+ width: width,
28
+ fill: "none",
29
+ className: className,
30
+ style: style,
31
+ "aria-hidden": true,
32
+ children: paths.map((d, i) => /*#__PURE__*/_jsx(motion.path, {
33
+ d: d,
34
+ stroke: stroke,
35
+ strokeWidth: strokeWidth,
36
+ strokeLinecap: "round",
37
+ strokeLinejoin: "round",
38
+ initial: {
39
+ pathLength: 0
40
+ },
41
+ animate: {
42
+ pathLength: 1
43
+ },
44
+ transition: {
45
+ duration: seconds,
46
+ ease: motionEases[ease],
47
+ delay: delay + i * seconds,
48
+ repeat,
49
+ repeatDelay: paths.length * seconds
50
+ }
51
+ }, i))
52
+ });
53
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 拖拽排序:转发引擎 Reorder(Group / Item),保持本包出口统一。
3
+ * 用法见引擎文档;跨容器排序属 M3 增强。
4
+ */
5
+ export { Reorder } from 'motion/react';
6
+ //# sourceMappingURL=reorder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reorder.d.ts","sourceRoot":"","sources":["reorder.ts"],"names":[],"mappings":"AAEA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,7 @@
1
+ 'use client';
2
+
3
+ /**
4
+ * 拖拽排序:转发引擎 Reorder(Group / Item),保持本包出口统一。
5
+ * 用法见引擎文档;跨容器排序属 M3 增强。
6
+ */
7
+ export { Reorder } from 'motion/react';
@@ -0,0 +1,23 @@
1
+ /**
2
+ * 滚动进度驱动:容器在视口内的滚动进度(0~1)通过 render prop 暴露,
3
+ * 接到任意 MotionValue 消费点(style、SVG 属性、数字……)。
4
+ */
5
+ import { type ReactNode } from 'react';
6
+ import { useScroll, type MotionValue } from 'motion/react';
7
+ /** 直接复用引擎的 offset 类型(字符串联合 + 模板字面量,比自造类型精确) */
8
+ type ScrollOffsetOption = NonNullable<Parameters<typeof useScroll>[0]>['offset'];
9
+ export interface ScrollDrivenProps {
10
+ children: (progress: MotionValue<number>) => ReactNode;
11
+ offset?: ScrollOffsetOption;
12
+ /** 给进度加一层弹簧平滑(0 关闭) */
13
+ smooth?: number;
14
+ style?: React.CSSProperties;
15
+ className?: string;
16
+ }
17
+ export declare function ScrollDriven({ children, offset, smooth, style, className, }: ScrollDrivenProps): import("react").JSX.Element;
18
+ /** 预置:顶部线性进度条(跟随页面纵向滚动) */
19
+ export declare function ScrollProgressBar({ smooth }: {
20
+ smooth?: number;
21
+ }): import("react").JSX.Element;
22
+ export {};
23
+ //# sourceMappingURL=scroll-driven.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scroll-driven.d.ts","sourceRoot":"","sources":["scroll-driven.tsx"],"names":[],"mappings":"AAEA;;;GAGG;AAEH,OAAO,EAAU,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,EAAU,SAAS,EAAa,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAE9E,+CAA+C;AAC/C,KAAK,kBAAkB,GAAG,WAAW,CAAC,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;AAEjF,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,CAAC,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,KAAK,SAAS,CAAC;IACvD,MAAM,CAAC,EAAE,kBAAkB,CAAC;IAC5B,uBAAuB;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,YAAY,CAAC,EAC3B,QAAQ,EACR,MAAmC,EACnC,MAAU,EACV,KAAK,EACL,SAAS,GACV,EAAE,iBAAiB,+BAWnB;AAED,2BAA2B;AAC3B,wBAAgB,iBAAiB,CAAC,EAAE,MAAY,EAAE,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,+BAmBtE"}
@@ -0,0 +1,62 @@
1
+ 'use client';
2
+
3
+ /**
4
+ * 滚动进度驱动:容器在视口内的滚动进度(0~1)通过 render prop 暴露,
5
+ * 接到任意 MotionValue 消费点(style、SVG 属性、数字……)。
6
+ */
7
+ import { useRef } from 'react';
8
+ import { motion, useScroll, useSpring } from 'motion/react';
9
+
10
+ /** 直接复用引擎的 offset 类型(字符串联合 + 模板字面量,比自造类型精确) */
11
+ import { jsx as _jsx } from "react/jsx-runtime";
12
+ export function ScrollDriven({
13
+ children,
14
+ offset = ['start end', 'end start'],
15
+ smooth = 0,
16
+ style,
17
+ className
18
+ }) {
19
+ const ref = useRef(null);
20
+ const raw = useScroll({
21
+ target: ref,
22
+ offset
23
+ });
24
+ const springed = useSpring(raw.scrollYProgress, {
25
+ stiffness: 200,
26
+ damping: 40
27
+ });
28
+ const progress = smooth > 0 ? springed : raw.scrollYProgress;
29
+ return /*#__PURE__*/_jsx("div", {
30
+ ref: ref,
31
+ className: className,
32
+ style: style,
33
+ children: children(progress)
34
+ });
35
+ }
36
+
37
+ /** 预置:顶部线性进度条(跟随页面纵向滚动) */
38
+ export function ScrollProgressBar({
39
+ smooth = 0.2
40
+ }) {
41
+ const {
42
+ scrollYProgress
43
+ } = useScroll();
44
+ const springed = useSpring(scrollYProgress, {
45
+ stiffness: 300,
46
+ damping: 40
47
+ });
48
+ const scaleX = smooth > 0 ? springed : scrollYProgress;
49
+ return /*#__PURE__*/_jsx(motion.div, {
50
+ "aria-hidden": true,
51
+ style: {
52
+ position: 'fixed',
53
+ top: 0,
54
+ left: 0,
55
+ right: 0,
56
+ height: 3,
57
+ transformOrigin: '0 50%',
58
+ background: 'var(--aura-motion-focus-color, #534ab7)',
59
+ scaleX
60
+ }
61
+ });
62
+ }
@@ -0,0 +1,37 @@
1
+ /**
2
+ * 时间线编排:进入视口后按 `at`(秒,相对序列起点)依次触发各 Step。
3
+ * loop / 倒放的完整编排器属 M3;本版覆盖"依次揭示"这一最高频场景。
4
+ */
5
+ import { type ReactNode } from 'react';
6
+ import { type HTMLMotionProps } from 'motion/react';
7
+ import { type DurationToken } from '../tokens';
8
+ export interface TimelineProps {
9
+ children: ReactNode;
10
+ /** 进入视口自动播放;默认 true。false 时配合受控 state 手动触发 */
11
+ autoplay?: boolean;
12
+ className?: string;
13
+ style?: React.CSSProperties;
14
+ }
15
+ export declare function Timeline({ children, autoplay, className, style }: TimelineProps): import("react").JSX.Element;
16
+ export interface TimelineStepProps extends Omit<HTMLMotionProps<'div'>, 'initial' | 'animate' | 'transition'> {
17
+ /** 相对序列起点的触发时刻(秒) */
18
+ at: number;
19
+ duration?: DurationToken;
20
+ }
21
+ declare function TimelineStepBase({ at, duration, ...rest }: TimelineStepProps): import("react").JSX.Element;
22
+ export declare const TimelineWithStep: typeof Timeline & {
23
+ Step: typeof TimelineStepBase;
24
+ };
25
+ export interface SequenceStep {
26
+ /** 绝对触发时刻(秒) */
27
+ at: number;
28
+ target: React.RefObject<HTMLElement | null>;
29
+ to: Record<string, number | string>;
30
+ options?: {
31
+ duration?: number;
32
+ ease?: [number, number, number, number];
33
+ };
34
+ }
35
+ export declare function useSequence(): (steps: SequenceStep[]) => Promise<void>;
36
+ export {};
37
+ //# sourceMappingURL=timeline.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timeline.d.ts","sourceRoot":"","sources":["timeline.tsx"],"names":[],"mappings":"AAEA;;;GAGG;AAEH,OAAO,EAA0D,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAC/F,OAAO,EAAU,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAgC,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC;AAI7E,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,SAAS,CAAC;IACpB,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B;AAED,wBAAgB,QAAQ,CAAC,EAAE,QAAQ,EAAE,QAAe,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,aAAa,+BAyBtF;AAED,MAAM,WAAW,iBACf,SAAQ,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,YAAY,CAAC;IAC1E,qBAAqB;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,CAAC,EAAE,aAAa,CAAC;CAC1B;AAED,iBAAS,gBAAgB,CAAC,EAAE,EAAE,EAAE,QAAmB,EAAE,GAAG,IAAI,EAAE,EAAE,iBAAiB,+BAchF;AAED,eAAO,MAAM,gBAAgB;UACrB,uBAAuB;CAC9B,CAAC;AAoBF,MAAM,WAAW,YAAY;IAC3B,gBAAgB;IAChB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IAC5C,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;IACpC,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,CAAC;CAC1E;AAED,wBAAgB,WAAW,YACQ,YAAY,EAAE,mBAehD"}
@@ -0,0 +1,106 @@
1
+ 'use client';
2
+
3
+ /**
4
+ * 时间线编排:进入视口后按 `at`(秒,相对序列起点)依次触发各 Step。
5
+ * loop / 倒放的完整编排器属 M3;本版覆盖"依次揭示"这一最高频场景。
6
+ */
7
+ import { createContext, useContext, useEffect, useRef, useState } from 'react';
8
+ import { motion } from 'motion/react';
9
+ import { motionDurations, motionEases } from "../tokens";
10
+ const TimelineContext = /*#__PURE__*/createContext({
11
+ playing: false
12
+ });
13
+ export function Timeline({
14
+ children,
15
+ autoplay = true,
16
+ className,
17
+ style
18
+ }) {
19
+ const ref = useRef(null);
20
+ const [playing, setPlaying] = useState(false);
21
+ useEffect(() => {
22
+ if (!autoplay) return;
23
+ const el = ref.current;
24
+ if (!el) return;
25
+ const io = new IntersectionObserver(([entry]) => {
26
+ if (entry.isIntersecting) setPlaying(true);
27
+ }, {
28
+ threshold: 0.2
29
+ });
30
+ io.observe(el);
31
+ return () => io.disconnect();
32
+ }, [autoplay]);
33
+ return /*#__PURE__*/_jsx(TimelineContext.Provider, {
34
+ value: {
35
+ playing
36
+ },
37
+ children: /*#__PURE__*/_jsx("div", {
38
+ ref: ref,
39
+ className: className,
40
+ style: style,
41
+ children: children
42
+ })
43
+ });
44
+ }
45
+ function TimelineStepBase({
46
+ at,
47
+ duration = 'normal',
48
+ ...rest
49
+ }) {
50
+ const {
51
+ playing
52
+ } = useContext(TimelineContext);
53
+ return /*#__PURE__*/_jsx(motion.div, {
54
+ initial: {
55
+ opacity: 0,
56
+ y: 12
57
+ },
58
+ animate: playing ? {
59
+ opacity: 1,
60
+ y: 0
61
+ } : {
62
+ opacity: 0,
63
+ y: 12
64
+ },
65
+ transition: {
66
+ duration: motionDurations[duration],
67
+ ease: motionEases.decelerate,
68
+ delay: playing ? at : 0
69
+ },
70
+ ...rest
71
+ });
72
+ }
73
+ export const TimelineWithStep = Timeline;
74
+ TimelineWithStep.Step = TimelineStepBase;
75
+
76
+ /**
77
+ * 命令式编排:按绝对时刻(秒)调度多个元素的动画,支持并行与精确时序。
78
+ *
79
+ * ```ts
80
+ * const play = useSequence();
81
+ * const onClick = () => play([
82
+ * { at: 0, target: cardRef, to: { scale: 1.06 } },
83
+ * { at: 0.2, target: badgeRef, to: { opacity: 1, y: 0 } },
84
+ * ]);
85
+ * ```
86
+ */
87
+
88
+ import { animate } from 'motion/react';
89
+ import { useCallback } from 'react';
90
+ import { jsx as _jsx } from "react/jsx-runtime";
91
+ const waitMs = ms => new Promise(r => setTimeout(r, ms));
92
+ export function useSequence() {
93
+ return useCallback(async steps => {
94
+ const start = performance.now();
95
+ await Promise.all(steps.map(async step => {
96
+ const wait = step.at * 1000 - (performance.now() - start);
97
+ if (wait > 0) await waitMs(wait);
98
+ if (step.target.current) {
99
+ await animate(step.target.current, step.to, {
100
+ duration: 0.4,
101
+ ...step.options
102
+ });
103
+ }
104
+ }));
105
+ }, []);
106
+ }
@@ -0,0 +1,16 @@
1
+ /// <reference types="react" />
2
+ /**
3
+ * 以原生 View Transition 执行一次 DOM 更新。
4
+ * 浏览器不支持时直接同步执行更新(渐进增强,功能零损失)。
5
+ */
6
+ export declare function useViewTransition(): (update: () => void) => void;
7
+ export interface ViewTransitionProps {
8
+ /** 共享元素名:更新前后同名的元素会被浏览器自动衔接(对应 CSS view-transition-name) */
9
+ name: string;
10
+ children: React.ReactNode;
11
+ className?: string;
12
+ style?: React.CSSProperties;
13
+ }
14
+ /** 为元素标记共享元素名(等价于 CSS 的 view-transition-name) */
15
+ export declare function ViewTransition({ name, children, className, style }: ViewTransitionProps): import("react").JSX.Element;
16
+ //# sourceMappingURL=view-transition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"view-transition.d.ts","sourceRoot":"","sources":["view-transition.tsx"],"names":[],"mappings":";AAaA;;;GAGG;AACH,wBAAgB,iBAAiB,aACH,MAAM,IAAI,UAYvC;AAED,MAAM,WAAW,mBAAmB;IAClC,4DAA4D;IAC5D,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B;AAED,iDAAiD;AACjD,wBAAgB,cAAc,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,mBAAmB,+BAQvF"}
@@ -0,0 +1,47 @@
1
+ 'use client';
2
+
3
+ /**
4
+ * 浏览器原生 View Transitions API 的渐进增强封装。
5
+ *
6
+ * - 支持的浏览器(Chrome/Edge 111+、Safari 18+):`useViewTransition` 包裹的
7
+ * DOM 更新以原生转场呈现,`name` 元素参与共享元素过渡;
8
+ * - 不支持的浏览器(Firefox):保持原行为(无转场),功能完全不受影响。
9
+ */
10
+ import { useCallback } from 'react';
11
+ import { motion } from 'motion/react';
12
+
13
+ /**
14
+ * 以原生 View Transition 执行一次 DOM 更新。
15
+ * 浏览器不支持时直接同步执行更新(渐进增强,功能零损失)。
16
+ */
17
+ import { jsx as _jsx } from "react/jsx-runtime";
18
+ export function useViewTransition() {
19
+ return useCallback(update => {
20
+ // TS lib.dom 已收录 startViewTransition 但签名与运行时存在版本差,
21
+ // 这里用最小结构探测,不与 lib 类型对接
22
+ const doc = document;
23
+ if (typeof doc.startViewTransition === 'function') {
24
+ doc.startViewTransition(update);
25
+ return;
26
+ }
27
+ update();
28
+ }, []);
29
+ }
30
+ /** 为元素标记共享元素名(等价于 CSS 的 view-transition-name) */
31
+ export function ViewTransition({
32
+ name,
33
+ children,
34
+ className,
35
+ style
36
+ }) {
37
+ // React 的 CSSProperties 尚未收录该属性,显式断言
38
+ const styleWithVT = {
39
+ ...style,
40
+ viewTransitionName: name
41
+ };
42
+ return /*#__PURE__*/_jsx(motion.div, {
43
+ className: className,
44
+ style: styleWithVT,
45
+ children: children
46
+ });
47
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 全局动效配置 —— 统一从本包出口取用,业务代码不直接依赖 `motion/react`。
3
+ * 这样引擎被替换时,业务代码的 import 路径不变。
4
+ */
5
+ export { MotionConfig } from 'motion/react';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * 全局动效配置 —— 统一从本包出口取用,业务代码不直接依赖 `motion/react`。
3
+ * 这样引擎被替换时,业务代码的 import 路径不变。
4
+ */
5
+ export { MotionConfig } from 'motion/react';
@@ -0,0 +1,5 @@
1
+ /**
2
+ * 动效 Hooks —— 同样从本包出口统一转发,保持引擎隔离层。
3
+ */
4
+ export { useReducedMotion, useInView, useAnimationControls } from 'motion/react';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 动效 Hooks —— 同样从本包出口统一转发,保持引擎隔离层。
3
+ */
4
+ export { useReducedMotion, useInView, useAnimationControls } from 'motion/react';