@aura-react-comp/motion 0.2.11 → 0.3.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.
@@ -1 +1 @@
1
- {"version":3,"file":"confetti.d.ts","sourceRoot":"","sources":["confetti.tsx"],"names":[],"mappings":";AAgBA,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;AAsBD,wBAAgB,QAAQ,CAAC,EACvB,IAAI,EACJ,KAAW,EACX,MAA2B,EAC3B,MAAuB,GACxB,EAAE,aAAa,sCAuGf"}
1
+ {"version":3,"file":"confetti.d.ts","sourceRoot":"","sources":["confetti.tsx"],"names":[],"mappings":";AAgBA,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;AAgDD,wBAAgB,QAAQ,CAAC,EACvB,IAAI,EACJ,KAAW,EACX,MAA2B,EAC3B,MAAM,GACP,EAAE,aAAa,sCA0Gf"}
@@ -14,6 +14,21 @@ import { useReducedMotion } from 'motion/react';
14
14
  import { motionConfettiColors } from "../tokens";
15
15
  import { jsx as _jsx } from "react/jsx-runtime";
16
16
  const DEFAULT_COLORS = [...motionConfettiColors];
17
+
18
+ /**
19
+ * 从全局令牌实时读取 Confetti 默认色板:
20
+ * --aura-motion-accent / cyan / blue / fuchsia 随双轴主题
21
+ * (data-mode × data-palette)切换,fire 时读取即与当前主题一致。
22
+ * 令牌缺失(SSR / 未引入 tokens.css)时回退 motionConfettiColors。
23
+ */
24
+ function readThemeConfettiColors() {
25
+ if (typeof getComputedStyle !== 'function' || typeof document === 'undefined') {
26
+ return DEFAULT_COLORS;
27
+ }
28
+ const styles = getComputedStyle(document.documentElement);
29
+ const token = (name, fallback) => styles.getPropertyValue(name).trim() || fallback;
30
+ return [token('--aura-motion-accent', DEFAULT_COLORS[0]), token('--aura-motion-cyan', DEFAULT_COLORS[1]), token('--aura-motion-blue', DEFAULT_COLORS[2]), token('--aura-motion-fuchsia', DEFAULT_COLORS[3]), token('--aura-motion-accent-strong', DEFAULT_COLORS[4]), token('--aura-motion-cyan', DEFAULT_COLORS[5])];
31
+ }
17
32
  export function Confetti({
18
33
  fire,
19
34
  count = 120,
@@ -21,7 +36,7 @@ export function Confetti({
21
36
  x: 0.5,
22
37
  y: 0.6
23
38
  },
24
- colors = DEFAULT_COLORS
39
+ colors
25
40
  }) {
26
41
  const canvasRef = useRef(null);
27
42
  const reduced = useReducedMotion();
@@ -35,6 +50,9 @@ export function Confetti({
35
50
  canvas.height = window.innerHeight;
36
51
  const ox = origin.x * canvas.width;
37
52
  const oy = origin.y * canvas.height;
53
+
54
+ // 发射瞬间取色:未显式传 colors 时跟当前主题(令牌实时值)
55
+ const palette = colors ?? readThemeConfettiColors();
38
56
  const parts = Array.from({
39
57
  length: count
40
58
  }, (_, i) => {
@@ -53,7 +71,7 @@ export function Confetti({
53
71
  tiltSpeed: 0.12 + Math.random() * 0.22,
54
72
  w: ribbon ? 5 + Math.random() * 4 : 7 + Math.random() * 5,
55
73
  h: ribbon ? 16 + Math.random() * 8 : 7 + Math.random() * 5,
56
- color: colors[i % colors.length],
74
+ color: palette[i % palette.length],
57
75
  life: 1,
58
76
  decay: 0.007 + Math.random() * 0.007,
59
77
  ribbon
@@ -11,7 +11,7 @@
11
11
  * ```
12
12
  */
13
13
  import { type HTMLMotionProps } from 'motion/react';
14
- import { type DurationToken } from '../tokens';
14
+ import { type DurationToken } from '../tokens.js';
15
15
  export interface PageTransitionProps extends Omit<HTMLMotionProps<'div'>, 'initial' | 'animate' | 'exit' | 'transition'> {
16
16
  /** 路由标识(如 usePathname() 的返回值);变化即触发转场 */
17
17
  transitionKey: string;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { type DurationToken, type EaseToken } from '../tokens';
2
+ import { type DurationToken, type EaseToken } from '../tokens.js';
3
3
  export interface PathDrawProps {
4
4
  /** 一条或多条 SVG path 的 d 属性;多条时按顺序描边 */
5
5
  paths: string[];
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import { type ReactNode } from 'react';
6
6
  import { type HTMLMotionProps } from 'motion/react';
7
- import { type DurationToken } from '../tokens';
7
+ import { type DurationToken } from '../tokens.js';
8
8
  export interface TimelineProps {
9
9
  children: ReactNode;
10
10
  /** 进入视口自动播放;默认 true。false 时配合受控 state 手动触发 */
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  /**
2
3
  * 全局动效配置 —— 统一从本包出口取用,业务代码不直接依赖 `motion/react`。
3
4
  * 这样引擎被替换时,业务代码的 import 路径不变。
@@ -2,5 +2,5 @@
2
2
  * 动效 Hooks —— 同样从本包出口统一转发,保持引擎隔离层。
3
3
  */
4
4
  export { useReducedMotion, useInView, useAnimationControls, } from 'motion/react';
5
- export { useScrollContainer, findScrollableAncestor, } from './use-scroll-container';
5
+ export { useScrollContainer, findScrollableAncestor, } from './use-scroll-container.js';
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  /**
2
3
  * 动效 Hooks —— 同样从本包出口统一转发,保持引擎隔离层。
3
4
  */
package/esm/index.d.ts CHANGED
@@ -6,67 +6,67 @@
6
6
  * 2. 时长 / 缓动 / 位移一律传**令牌档位名**,不传裸数值;
7
7
  * 3. 一次性引入本包的 `tokens.css` 子路径(或经 ui 联动包级联引入)。
8
8
  */
9
- export * from './tokens';
10
- export { MotionConfig } from './config';
11
- export { useReducedMotion, useInView, useAnimationControls, useScrollContainer, findScrollableAncestor, } from './hooks';
9
+ export * from './tokens.js';
10
+ export { MotionConfig } from './config/index.js';
11
+ export { useReducedMotion, useInView, useAnimationControls, useScrollContainer, findScrollableAncestor, } from './hooks/index.js';
12
12
  export { AnimatePresence } from 'motion/react';
13
13
  export { motion } from 'motion/react';
14
- export { Slide, Fade, Zoom, Collapse } from './primitive/transition';
15
- export type { SlideProps, FadeProps, ZoomProps, CollapseProps, TransitionBaseProps, } from './primitive/transition';
16
- export { Reveal } from './primitive/reveal';
17
- export type { RevealProps } from './primitive/reveal';
18
- export { NumberTicker } from './primitive/number-ticker';
19
- export type { NumberTickerProps } from './primitive/number-ticker';
20
- export { SplitText } from './primitive/split-text';
21
- export type { SplitTextProps } from './primitive/split-text';
22
- export { Typewriter } from './primitive/typewriter';
23
- export type { TypewriterProps } from './primitive/typewriter';
24
- export { InViewport } from './primitive/in-viewport';
25
- export type { InViewportProps } from './primitive/in-viewport';
26
- export { Magnetic } from './primitive/magnetic';
27
- export type { MagneticProps } from './primitive/magnetic';
28
- export { SkeletonShimmer } from './primitive/skeleton-shimmer';
29
- export type { SkeletonShimmerProps } from './primitive/skeleton-shimmer';
30
- export { FocusRing } from './primitive/focus-ring';
31
- export type { FocusRingProps } from './primitive/focus-ring';
32
- export { Keyframes, KEYFRAMES_ALLOWED_PROPS } from './primitive/keyframes';
33
- export type { KeyframesProps } from './primitive/keyframes';
34
- export { TextShimmer } from './primitive/text-shimmer';
35
- export type { TextShimmerProps } from './primitive/text-shimmer';
36
- export { TypingDots } from './primitive/typing-dots';
37
- export type { TypingDotsProps } from './primitive/typing-dots';
38
- export { GradientBorder } from './primitive/gradient-border';
39
- export type { GradientBorderProps } from './primitive/gradient-border';
40
- export { Marquee } from './primitive/marquee';
41
- export type { MarqueeProps } from './primitive/marquee';
42
- export { FlipList } from './composed/flip-list';
43
- export type { FlipListProps, FlipListItem } from './composed/flip-list';
44
- export { LayoutGroup } from './composed/layout-group';
45
- export { Reorder, ReorderGroup, ReorderItem } from './composed/reorder';
46
- export { PageTransition } from './composed/page-transition';
47
- export type { PageTransitionProps } from './composed/page-transition';
48
- export { ViewTransition, useViewTransition } from './composed/view-transition';
49
- export type { ViewTransitionProps } from './composed/view-transition';
50
- export { ScrollDriven, ScrollProgressBar } from './composed/scroll-driven';
51
- export type { ScrollDrivenProps } from './composed/scroll-driven';
52
- export { Parallax } from './composed/parallax';
53
- export type { ParallaxProps } from './composed/parallax';
54
- export { PathDraw } from './composed/path-draw';
55
- export type { PathDrawProps } from './composed/path-draw';
56
- export { TimelineWithStep as Timeline, TimelineStepBase as TimelineStep, useSequence, } from './composed/timeline';
57
- export type { TimelineProps, TimelineStepProps, SequenceStep, } from './composed/timeline';
58
- export { Draggable } from './composed/draggable';
59
- export type { DraggableProps } from './composed/draggable';
60
- export { Cursor } from './composed/cursor';
61
- export type { CursorProps } from './composed/cursor';
62
- export { Confetti } from './composed/confetti';
63
- export type { ConfettiProps } from './composed/confetti';
64
- export { Aurora } from './composed/aurora';
65
- export type { AuroraProps } from './composed/aurora';
66
- export { LottiePlayer } from './composed/lottie-player';
67
- export type { LottiePlayerProps } from './composed/lottie-player';
68
- export { TiltCard } from './composed/tilt-card';
69
- export type { TiltCardProps } from './composed/tilt-card';
70
- export { ScrollScaleCard } from './composed/scroll-scale-card';
71
- export type { ScrollScaleCardProps } from './composed/scroll-scale-card';
14
+ export { Slide, Fade, Zoom, Collapse } from './primitive/transition.js';
15
+ export type { SlideProps, FadeProps, ZoomProps, CollapseProps, TransitionBaseProps, } from './primitive/transition.js';
16
+ export { Reveal } from './primitive/reveal.js';
17
+ export type { RevealProps } from './primitive/reveal.js';
18
+ export { NumberTicker } from './primitive/number-ticker.js';
19
+ export type { NumberTickerProps } from './primitive/number-ticker.js';
20
+ export { SplitText } from './primitive/split-text.js';
21
+ export type { SplitTextProps } from './primitive/split-text.js';
22
+ export { Typewriter } from './primitive/typewriter.js';
23
+ export type { TypewriterProps } from './primitive/typewriter.js';
24
+ export { InViewport } from './primitive/in-viewport.js';
25
+ export type { InViewportProps } from './primitive/in-viewport.js';
26
+ export { Magnetic } from './primitive/magnetic.js';
27
+ export type { MagneticProps } from './primitive/magnetic.js';
28
+ export { SkeletonShimmer } from './primitive/skeleton-shimmer.js';
29
+ export type { SkeletonShimmerProps } from './primitive/skeleton-shimmer.js';
30
+ export { FocusRing } from './primitive/focus-ring.js';
31
+ export type { FocusRingProps } from './primitive/focus-ring.js';
32
+ export { Keyframes, KEYFRAMES_ALLOWED_PROPS } from './primitive/keyframes.js';
33
+ export type { KeyframesProps } from './primitive/keyframes.js';
34
+ export { TextShimmer } from './primitive/text-shimmer.js';
35
+ export type { TextShimmerProps } from './primitive/text-shimmer.js';
36
+ export { TypingDots } from './primitive/typing-dots.js';
37
+ export type { TypingDotsProps } from './primitive/typing-dots.js';
38
+ export { GradientBorder } from './primitive/gradient-border.js';
39
+ export type { GradientBorderProps } from './primitive/gradient-border.js';
40
+ export { Marquee } from './primitive/marquee.js';
41
+ export type { MarqueeProps } from './primitive/marquee.js';
42
+ export { FlipList } from './composed/flip-list.js';
43
+ export type { FlipListProps, FlipListItem } from './composed/flip-list.js';
44
+ export { LayoutGroup } from './composed/layout-group.js';
45
+ export { Reorder, ReorderGroup, ReorderItem } from './composed/reorder.js';
46
+ export { PageTransition } from './composed/page-transition.js';
47
+ export type { PageTransitionProps } from './composed/page-transition.js';
48
+ export { ViewTransition, useViewTransition } from './composed/view-transition.js';
49
+ export type { ViewTransitionProps } from './composed/view-transition.js';
50
+ export { ScrollDriven, ScrollProgressBar } from './composed/scroll-driven.js';
51
+ export type { ScrollDrivenProps } from './composed/scroll-driven.js';
52
+ export { Parallax } from './composed/parallax.js';
53
+ export type { ParallaxProps } from './composed/parallax.js';
54
+ export { PathDraw } from './composed/path-draw.js';
55
+ export type { PathDrawProps } from './composed/path-draw.js';
56
+ export { TimelineWithStep as Timeline, TimelineStepBase as TimelineStep, useSequence, } from './composed/timeline.js';
57
+ export type { TimelineProps, TimelineStepProps, SequenceStep, } from './composed/timeline.js';
58
+ export { Draggable } from './composed/draggable.js';
59
+ export type { DraggableProps } from './composed/draggable.js';
60
+ export { Cursor } from './composed/cursor.js';
61
+ export type { CursorProps } from './composed/cursor.js';
62
+ export { Confetti } from './composed/confetti.js';
63
+ export type { ConfettiProps } from './composed/confetti.js';
64
+ export { Aurora } from './composed/aurora.js';
65
+ export type { AuroraProps } from './composed/aurora.js';
66
+ export { LottiePlayer } from './composed/lottie-player.js';
67
+ export type { LottiePlayerProps } from './composed/lottie-player.js';
68
+ export { TiltCard } from './composed/tilt-card.js';
69
+ export type { TiltCardProps } from './composed/tilt-card.js';
70
+ export { ScrollScaleCard } from './composed/scroll-scale-card.js';
71
+ export type { ScrollScaleCardProps } from './composed/scroll-scale-card.js';
72
72
  //# sourceMappingURL=index.d.ts.map
package/esm/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  /**
2
3
  * @aura-react-comp/motion — 令牌驱动的场景化动画组件库。
3
4
  *
@@ -5,7 +5,7 @@
5
5
  * 需要自定义进场形态(缩放、滑入等)时用 InViewport 包 motion 子元素。
6
6
  */
7
7
  import { type HTMLMotionProps } from 'motion/react';
8
- import { type DurationToken } from '../tokens';
8
+ import { type DurationToken } from '../tokens.js';
9
9
  export interface InViewportProps extends Omit<HTMLMotionProps<'div'>, 'initial' | 'whileInView' | 'viewport' | 'transition'> {
10
10
  /** 只播放一次;默认 true */
11
11
  once?: boolean;
@@ -6,7 +6,7 @@
6
6
  * 传入白名单外的属性会在开发环境告警(不阻断渲染)。
7
7
  */
8
8
  import { type HTMLMotionProps } from 'motion/react';
9
- import { type DurationToken, type EaseToken } from '../tokens';
9
+ import { type DurationToken, type EaseToken } from '../tokens.js';
10
10
  /** 允许做关键帧动画的属性白名单(全部为 transform/opacity 家族) */
11
11
  export declare const KEYFRAMES_ALLOWED_PROPS: Set<string>;
12
12
  export interface KeyframesProps extends Omit<HTMLMotionProps<'div'>, 'animate' | 'transition'> {
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { type SpringToken } from '../tokens';
2
+ import { type SpringToken } from '../tokens.js';
3
3
  export interface NumberTickerProps {
4
4
  /** 目标数值;变化时从当前位值过渡过去 */
5
5
  value: number;
@@ -8,7 +8,7 @@
8
8
  * 错峰改为递增步进(0.08 + 0.04*i 累加),多卡片依次揭示节奏更有层次。
9
9
  */
10
10
  import { type HTMLMotionProps } from 'motion/react';
11
- import { type DurationToken } from '../tokens';
11
+ import { type DurationToken } from '../tokens.js';
12
12
  export type RevealVariant = 'fade' | 'blur' | 'mask' | 'scale';
13
13
  export interface RevealProps extends Omit<HTMLMotionProps<'div'>, 'initial' | 'animate' | 'transition'> {
14
14
  /** 兄弟 Reveal 的序号,自动换算递增错峰延迟;缺省 0 */
@@ -13,7 +13,7 @@
13
13
  * **意图状态**——动画完成时机会略有滞后,测试断言以意图为准)。
14
14
  */
15
15
  import { type HTMLMotionProps } from 'motion/react';
16
- import { type DistanceToken, type DurationToken, type EaseToken } from '../tokens';
16
+ import { type DistanceToken, type DurationToken, type EaseToken } from '../tokens.js';
17
17
  type Direction = 'up' | 'down' | 'left' | 'right';
18
18
  /** 保留式显隐省略时(undefined),组件默认可见,退场交给外层 AnimatePresence */
19
19
  export interface TransitionBaseProps extends Omit<HTMLMotionProps<'div'>, 'initial' | 'animate' | 'exit' | 'transition'> {
package/esm/tokens.css CHANGED
@@ -2,6 +2,10 @@
2
2
  * 动效令牌(CSS 端)—— 与 src/tokens.ts 保持一致(tokens.test.ts 守护漂移)。
3
3
  * 消费方:引入本包的 `tokens.css` 子路径,或依赖 ui/x/business
4
4
  * 等联动包的级联引入。
5
+ *
6
+ * 颜色令牌随全局双轴主题切换:
7
+ * data-mode(light|dark) × data-palette(violet|ocean|sunset),
8
+ * 历史选择器 [data-theme="dark"] 保留兼容(= dark × violet)。
5
9
  */
6
10
  :root {
7
11
  --aura-motion-duration-instant: 80ms;
@@ -37,7 +41,8 @@
37
41
  }
38
42
 
39
43
  /* 暗色:同一套语义,换成更亮的霓虹与更低的表面亮度 */
40
- [data-theme='dark'] {
44
+ [data-theme='dark'],
45
+ [data-mode='dark'][data-palette='violet'] {
41
46
  --aura-motion-accent: #a855f7;
42
47
  --aura-motion-accent-strong: #7c3aed;
43
48
  --aura-motion-accent-soft: rgba(168, 85, 247, 0.18);
@@ -53,6 +58,55 @@
53
58
  --aura-motion-focus-color: #a855f7;
54
59
  }
55
60
 
61
+ /* ===== Light × Ocean =====
62
+ 主锚 #2563eb(Tailwind blue-600),accent 系全部从主锚派生;
63
+ cyan / blue / fuchsia 为霓虹装饰阵列,刻意不跟色板。 */
64
+ [data-palette='ocean'] {
65
+ --aura-motion-accent: #2563eb;
66
+ --aura-motion-accent-strong: #1d4ed8;
67
+ --aura-motion-accent-soft: rgba(37, 99, 235, 0.12);
68
+ --aura-motion-accent-glow: rgba(37, 99, 235, 0.35);
69
+ --aura-motion-shimmer: rgba(37, 99, 235, 0.85);
70
+ --aura-motion-sheen: rgba(37, 99, 235, 0.12);
71
+ --aura-motion-focus-color: #2563eb;
72
+ }
73
+
74
+ /* ===== Dark × Ocean ===== */
75
+ [data-mode='dark'][data-palette='ocean'] {
76
+ --aura-motion-accent: #60a5fa;
77
+ --aura-motion-accent-strong: #2563eb;
78
+ --aura-motion-accent-soft: rgba(96, 165, 250, 0.18);
79
+ --aura-motion-accent-glow: rgba(96, 165, 250, 0.45);
80
+ --aura-motion-blue: #60a5fa;
81
+ --aura-motion-shimmer: rgba(255, 255, 255, 0.85);
82
+ --aura-motion-sheen: rgba(255, 255, 255, 0.18);
83
+ --aura-motion-focus-color: #60a5fa;
84
+ }
85
+
86
+ /* ===== Light × Sunset =====
87
+ 主锚 #ea580c(Tailwind orange-600)。 */
88
+ [data-palette='sunset'] {
89
+ --aura-motion-accent: #ea580c;
90
+ --aura-motion-accent-strong: #c2410c;
91
+ --aura-motion-accent-soft: rgba(234, 88, 12, 0.12);
92
+ --aura-motion-accent-glow: rgba(234, 88, 12, 0.35);
93
+ --aura-motion-shimmer: rgba(234, 88, 12, 0.85);
94
+ --aura-motion-sheen: rgba(234, 88, 12, 0.12);
95
+ --aura-motion-focus-color: #ea580c;
96
+ }
97
+
98
+ /* ===== Dark × Sunset ===== */
99
+ [data-mode='dark'][data-palette='sunset'] {
100
+ --aura-motion-accent: #fb923c;
101
+ --aura-motion-accent-strong: #ea580c;
102
+ --aura-motion-accent-soft: rgba(251, 146, 60, 0.18);
103
+ --aura-motion-accent-glow: rgba(251, 146, 60, 0.45);
104
+ --aura-motion-blue: #60a5fa;
105
+ --aura-motion-shimmer: rgba(255, 255, 255, 0.85);
106
+ --aura-motion-sheen: rgba(255, 255, 255, 0.18);
107
+ --aura-motion-focus-color: #fb923c;
108
+ }
109
+
56
110
  /* 可访问性第一层降级:令牌驱动的样式(工具类 / 业务自研 less)在此整体归零。
57
111
  引擎层与组件层的降级分别由 <MotionConfig reducedMotion> 与 useReducedMotion 承担。 */
58
112
  @media (prefers-reduced-motion: reduce) {
package/esm/tokens.js CHANGED
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  /**
2
3
  * 动效令牌 —— 单一来源。
3
4
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aura-react-comp/motion",
3
- "version": "0.2.11",
3
+ "version": "0.3.1",
4
4
  "description": "Aura 动效组件库 — 令牌驱动的场景化动画组件(进出场、数字与文字特效、滚动驱动、编排、手势)",
5
5
  "keywords": [
6
6
  "aura",