@aura-react-comp/motion 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -2
- package/esm/composed/aurora.d.ts +14 -0
- package/esm/composed/aurora.d.ts.map +1 -0
- package/esm/composed/aurora.js +66 -0
- package/esm/composed/confetti.d.ts +14 -0
- package/esm/composed/confetti.d.ts.map +1 -0
- package/esm/composed/confetti.js +99 -0
- package/esm/composed/cursor.d.ts +12 -0
- package/esm/composed/cursor.d.ts.map +1 -0
- package/esm/composed/cursor.js +112 -0
- package/esm/composed/draggable.d.ts +19 -0
- package/esm/composed/draggable.d.ts.map +1 -0
- package/esm/composed/draggable.js +62 -0
- package/esm/composed/flip-list.d.ts +21 -0
- package/esm/composed/flip-list.d.ts.map +1 -0
- package/esm/composed/flip-list.js +53 -0
- package/esm/composed/layout-group.d.ts +6 -0
- package/esm/composed/layout-group.d.ts.map +1 -0
- package/esm/composed/layout-group.js +7 -0
- package/esm/composed/lottie-player.d.ts +13 -0
- package/esm/composed/lottie-player.d.ts.map +1 -0
- package/esm/composed/lottie-player.js +57 -0
- package/esm/composed/page-transition.d.ts +23 -0
- package/esm/composed/page-transition.d.ts.map +1 -0
- package/esm/composed/page-transition.js +53 -0
- package/esm/composed/parallax.d.ts +19 -0
- package/esm/composed/parallax.d.ts.map +1 -0
- package/esm/composed/parallax.js +59 -0
- package/esm/composed/path-draw.d.ts +22 -0
- package/esm/composed/path-draw.d.ts.map +1 -0
- package/esm/composed/path-draw.js +53 -0
- package/esm/composed/reorder.d.ts +6 -0
- package/esm/composed/reorder.d.ts.map +1 -0
- package/esm/composed/reorder.js +7 -0
- package/esm/composed/scroll-driven.d.ts +23 -0
- package/esm/composed/scroll-driven.d.ts.map +1 -0
- package/esm/composed/scroll-driven.js +62 -0
- package/esm/composed/timeline.d.ts +37 -0
- package/esm/composed/timeline.d.ts.map +1 -0
- package/esm/composed/timeline.js +106 -0
- package/esm/composed/view-transition.d.ts +16 -0
- package/esm/composed/view-transition.d.ts.map +1 -0
- package/esm/composed/view-transition.js +47 -0
- package/esm/config/index.d.ts +6 -0
- package/esm/config/index.d.ts.map +1 -0
- package/esm/config/index.js +5 -0
- package/esm/hooks/index.d.ts +5 -0
- package/esm/hooks/index.d.ts.map +1 -0
- package/esm/hooks/index.js +4 -0
- package/esm/index.d.ts +58 -0
- package/esm/index.d.ts.map +1 -0
- package/esm/index.js +42 -0
- package/esm/primitive/focus-ring.d.ts +18 -0
- package/esm/primitive/focus-ring.d.ts.map +1 -0
- package/esm/primitive/focus-ring.js +81 -0
- package/esm/primitive/in-viewport.d.ts +19 -0
- package/esm/primitive/in-viewport.d.ts.map +1 -0
- package/esm/primitive/in-viewport.js +41 -0
- package/esm/primitive/keyframes.d.ts +23 -0
- package/esm/primitive/keyframes.d.ts.map +1 -0
- package/esm/primitive/keyframes.js +41 -0
- package/esm/primitive/magnetic.d.ts +14 -0
- package/esm/primitive/magnetic.d.ts.map +1 -0
- package/esm/primitive/magnetic.js +51 -0
- package/esm/primitive/number-ticker.d.ts +16 -0
- package/esm/primitive/number-ticker.d.ts.map +1 -0
- package/esm/primitive/number-ticker.js +42 -0
- package/esm/primitive/reveal.d.ts +22 -0
- package/esm/primitive/reveal.d.ts.map +1 -0
- package/esm/primitive/reveal.js +45 -0
- package/esm/primitive/skeleton-shimmer.d.ts +12 -0
- package/esm/primitive/skeleton-shimmer.d.ts.map +1 -0
- package/esm/primitive/skeleton-shimmer.js +50 -0
- package/esm/primitive/split-text.d.ts +17 -0
- package/esm/primitive/split-text.d.ts.map +1 -0
- package/esm/primitive/split-text.js +97 -0
- package/esm/primitive/transition.d.ts +54 -0
- package/esm/primitive/transition.d.ts.map +1 -0
- package/esm/primitive/transition.js +174 -0
- package/esm/primitive/typewriter.d.ts +15 -0
- package/esm/primitive/typewriter.d.ts.map +1 -0
- package/esm/primitive/typewriter.js +75 -0
- package/esm/tokens.css +32 -0
- package/esm/tokens.d.ts +33 -0
- package/esm/tokens.d.ts.map +1 -0
- package/esm/tokens.js +52 -0
- package/package.json +65 -4
package/esm/index.d.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @aura-react-comp/motion — 令牌驱动的场景化动画组件库。
|
|
3
|
+
*
|
|
4
|
+
* 三条使用约定:
|
|
5
|
+
* 1. 所有组件从本入口导入,不要直接依赖 `motion/react`(引擎隔离层,便于将来替换);
|
|
6
|
+
* 2. 时长 / 缓动 / 位移一律传**令牌档位名**,不传裸数值;
|
|
7
|
+
* 3. 一次性引入本包的 `tokens.css` 子路径(或经 ui 联动包级联引入)。
|
|
8
|
+
*/
|
|
9
|
+
export * from './tokens';
|
|
10
|
+
export { MotionConfig } from './config';
|
|
11
|
+
export { useReducedMotion, useInView, useAnimationControls } from './hooks';
|
|
12
|
+
export { Slide, Fade, Zoom, Collapse } from './primitive/transition';
|
|
13
|
+
export type { SlideProps, FadeProps, ZoomProps, CollapseProps, TransitionBaseProps, } from './primitive/transition';
|
|
14
|
+
export { Reveal } from './primitive/reveal';
|
|
15
|
+
export type { RevealProps } from './primitive/reveal';
|
|
16
|
+
export { NumberTicker } from './primitive/number-ticker';
|
|
17
|
+
export type { NumberTickerProps } from './primitive/number-ticker';
|
|
18
|
+
export { SplitText } from './primitive/split-text';
|
|
19
|
+
export type { SplitTextProps } from './primitive/split-text';
|
|
20
|
+
export { Typewriter } from './primitive/typewriter';
|
|
21
|
+
export type { TypewriterProps } from './primitive/typewriter';
|
|
22
|
+
export { InViewport } from './primitive/in-viewport';
|
|
23
|
+
export type { InViewportProps } from './primitive/in-viewport';
|
|
24
|
+
export { Magnetic } from './primitive/magnetic';
|
|
25
|
+
export type { MagneticProps } from './primitive/magnetic';
|
|
26
|
+
export { SkeletonShimmer } from './primitive/skeleton-shimmer';
|
|
27
|
+
export type { SkeletonShimmerProps } from './primitive/skeleton-shimmer';
|
|
28
|
+
export { FocusRing } from './primitive/focus-ring';
|
|
29
|
+
export type { FocusRingProps } from './primitive/focus-ring';
|
|
30
|
+
export { Keyframes, KEYFRAMES_ALLOWED_PROPS } from './primitive/keyframes';
|
|
31
|
+
export type { KeyframesProps } from './primitive/keyframes';
|
|
32
|
+
export { FlipList } from './composed/flip-list';
|
|
33
|
+
export type { FlipListProps, FlipListItem } from './composed/flip-list';
|
|
34
|
+
export { LayoutGroup } from './composed/layout-group';
|
|
35
|
+
export { Reorder } from './composed/reorder';
|
|
36
|
+
export { PageTransition } from './composed/page-transition';
|
|
37
|
+
export type { PageTransitionProps } from './composed/page-transition';
|
|
38
|
+
export { ViewTransition, useViewTransition } from './composed/view-transition';
|
|
39
|
+
export type { ViewTransitionProps } from './composed/view-transition';
|
|
40
|
+
export { ScrollDriven, ScrollProgressBar } from './composed/scroll-driven';
|
|
41
|
+
export type { ScrollDrivenProps } from './composed/scroll-driven';
|
|
42
|
+
export { Parallax } from './composed/parallax';
|
|
43
|
+
export type { ParallaxProps } from './composed/parallax';
|
|
44
|
+
export { PathDraw } from './composed/path-draw';
|
|
45
|
+
export type { PathDrawProps } from './composed/path-draw';
|
|
46
|
+
export { TimelineWithStep as Timeline, useSequence } from './composed/timeline';
|
|
47
|
+
export type { TimelineProps, TimelineStepProps, SequenceStep, } from './composed/timeline';
|
|
48
|
+
export { Draggable } from './composed/draggable';
|
|
49
|
+
export type { DraggableProps } from './composed/draggable';
|
|
50
|
+
export { Cursor } from './composed/cursor';
|
|
51
|
+
export type { CursorProps } from './composed/cursor';
|
|
52
|
+
export { Confetti } from './composed/confetti';
|
|
53
|
+
export type { ConfettiProps } from './composed/confetti';
|
|
54
|
+
export { Aurora } from './composed/aurora';
|
|
55
|
+
export type { AuroraProps } from './composed/aurora';
|
|
56
|
+
export { LottiePlayer } from './composed/lottie-player';
|
|
57
|
+
export type { LottiePlayerProps } from './composed/lottie-player';
|
|
58
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"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"}
|
package/esm/index.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @aura-react-comp/motion — 令牌驱动的场景化动画组件库。
|
|
3
|
+
*
|
|
4
|
+
* 三条使用约定:
|
|
5
|
+
* 1. 所有组件从本入口导入,不要直接依赖 `motion/react`(引擎隔离层,便于将来替换);
|
|
6
|
+
* 2. 时长 / 缓动 / 位移一律传**令牌档位名**,不传裸数值;
|
|
7
|
+
* 3. 一次性引入本包的 `tokens.css` 子路径(或经 ui 联动包级联引入)。
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
// ---- 令牌 ----
|
|
11
|
+
export * from "./tokens";
|
|
12
|
+
|
|
13
|
+
// ---- 全局配置与偏好 ----
|
|
14
|
+
export { MotionConfig } from "./config";
|
|
15
|
+
export { useReducedMotion, useInView, useAnimationControls } from "./hooks";
|
|
16
|
+
|
|
17
|
+
// ---- 基础组件 ----
|
|
18
|
+
export { Slide, Fade, Zoom, Collapse } from "./primitive/transition";
|
|
19
|
+
export { Reveal } from "./primitive/reveal";
|
|
20
|
+
export { NumberTicker } from "./primitive/number-ticker";
|
|
21
|
+
export { SplitText } from "./primitive/split-text";
|
|
22
|
+
export { Typewriter } from "./primitive/typewriter";
|
|
23
|
+
export { InViewport } from "./primitive/in-viewport";
|
|
24
|
+
export { Magnetic } from "./primitive/magnetic";
|
|
25
|
+
export { SkeletonShimmer } from "./primitive/skeleton-shimmer";
|
|
26
|
+
export { FocusRing } from "./primitive/focus-ring";
|
|
27
|
+
export { Keyframes, KEYFRAMES_ALLOWED_PROPS } from "./primitive/keyframes";
|
|
28
|
+
// ---- 复杂场景 ----
|
|
29
|
+
export { FlipList } from "./composed/flip-list";
|
|
30
|
+
export { LayoutGroup } from "./composed/layout-group";
|
|
31
|
+
export { Reorder } from "./composed/reorder";
|
|
32
|
+
export { PageTransition } from "./composed/page-transition";
|
|
33
|
+
export { ViewTransition, useViewTransition } from "./composed/view-transition";
|
|
34
|
+
export { ScrollDriven, ScrollProgressBar } from "./composed/scroll-driven";
|
|
35
|
+
export { Parallax } from "./composed/parallax";
|
|
36
|
+
export { PathDraw } from "./composed/path-draw";
|
|
37
|
+
export { TimelineWithStep as Timeline, useSequence } from "./composed/timeline";
|
|
38
|
+
export { Draggable } from "./composed/draggable";
|
|
39
|
+
export { Cursor } from "./composed/cursor";
|
|
40
|
+
export { Confetti } from "./composed/confetti";
|
|
41
|
+
export { Aurora } from "./composed/aurora";
|
|
42
|
+
export { LottiePlayer } from "./composed/lottie-player";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 键盘焦点环的圆角跟随:容器内 focusin/focusout 委托,
|
|
3
|
+
* 环以弹簧动画移动到焦点元素的位置与尺寸(对齐 Material focus ring 的体验)。
|
|
4
|
+
*
|
|
5
|
+
* 环为 aria-hidden 装饰层,不拦截指针与焦点。
|
|
6
|
+
*/
|
|
7
|
+
import { type ReactNode } from 'react';
|
|
8
|
+
export interface FocusRingProps {
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
/** 环的圆角(px) */
|
|
11
|
+
radius?: number;
|
|
12
|
+
/** 环颜色;默认读 --aura-motion-focus-color(可在主题层覆盖),回退紫色 */
|
|
13
|
+
color?: string;
|
|
14
|
+
className?: string;
|
|
15
|
+
style?: React.CSSProperties;
|
|
16
|
+
}
|
|
17
|
+
export declare function FocusRing({ children, radius, color, className, style, }: FocusRingProps): import("react").JSX.Element;
|
|
18
|
+
//# sourceMappingURL=focus-ring.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"focus-ring.d.ts","sourceRoot":"","sources":["focus-ring.tsx"],"names":[],"mappings":"AAEA;;;;;GAKG;AAEH,OAAO,EAA+B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAGpE,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,SAAS,CAAC;IACpB,eAAe;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,sDAAsD;IACtD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B;AASD,wBAAgB,SAAS,CAAC,EACxB,QAAQ,EACR,MAAW,EACX,KAAK,EACL,SAAS,EACT,KAAK,GACN,EAAE,cAAc,+BA6DhB"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 键盘焦点环的圆角跟随:容器内 focusin/focusout 委托,
|
|
5
|
+
* 环以弹簧动画移动到焦点元素的位置与尺寸(对齐 Material focus ring 的体验)。
|
|
6
|
+
*
|
|
7
|
+
* 环为 aria-hidden 装饰层,不拦截指针与焦点。
|
|
8
|
+
*/
|
|
9
|
+
import { useEffect, useRef, useState } from 'react';
|
|
10
|
+
import { motion, useReducedMotion } from 'motion/react';
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
export function FocusRing({
|
|
14
|
+
children,
|
|
15
|
+
radius = 10,
|
|
16
|
+
color,
|
|
17
|
+
className,
|
|
18
|
+
style
|
|
19
|
+
}) {
|
|
20
|
+
const containerRef = useRef(null);
|
|
21
|
+
const [rect, setRect] = useState(null);
|
|
22
|
+
const reduced = useReducedMotion();
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
const el = containerRef.current;
|
|
25
|
+
if (!el) return;
|
|
26
|
+
const onFocusIn = e => {
|
|
27
|
+
const target = e.target;
|
|
28
|
+
const container = el.getBoundingClientRect();
|
|
29
|
+
const r = target.getBoundingClientRect();
|
|
30
|
+
setRect({
|
|
31
|
+
top: r.top - container.top,
|
|
32
|
+
left: r.left - container.left,
|
|
33
|
+
width: r.width,
|
|
34
|
+
height: r.height
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
const onFocusOut = () => setRect(null);
|
|
38
|
+
el.addEventListener('focusin', onFocusIn);
|
|
39
|
+
el.addEventListener('focusout', onFocusOut);
|
|
40
|
+
return () => {
|
|
41
|
+
el.removeEventListener('focusin', onFocusIn);
|
|
42
|
+
el.removeEventListener('focusout', onFocusOut);
|
|
43
|
+
};
|
|
44
|
+
}, []);
|
|
45
|
+
const ringColor = color ?? 'var(--aura-motion-focus-color, #534ab7)';
|
|
46
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
47
|
+
ref: containerRef,
|
|
48
|
+
className: className,
|
|
49
|
+
style: {
|
|
50
|
+
position: 'relative',
|
|
51
|
+
...style
|
|
52
|
+
}
|
|
53
|
+
// 容器自身不产生焦点,环只在子元素聚焦时出现
|
|
54
|
+
,
|
|
55
|
+
tabIndex: -1,
|
|
56
|
+
children: [rect && /*#__PURE__*/_jsx(motion.div, {
|
|
57
|
+
"aria-hidden": true,
|
|
58
|
+
initial: false,
|
|
59
|
+
animate: {
|
|
60
|
+
top: rect.top,
|
|
61
|
+
left: rect.left,
|
|
62
|
+
width: rect.width,
|
|
63
|
+
height: rect.height,
|
|
64
|
+
opacity: 1
|
|
65
|
+
},
|
|
66
|
+
transition: reduced ? {
|
|
67
|
+
duration: 0
|
|
68
|
+
} : {
|
|
69
|
+
type: 'spring',
|
|
70
|
+
stiffness: 400,
|
|
71
|
+
damping: 32
|
|
72
|
+
},
|
|
73
|
+
style: {
|
|
74
|
+
position: 'absolute',
|
|
75
|
+
pointerEvents: 'none',
|
|
76
|
+
borderRadius: radius,
|
|
77
|
+
boxShadow: `0 0 0 2px ${ringColor}`
|
|
78
|
+
}
|
|
79
|
+
}), children]
|
|
80
|
+
});
|
|
81
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
/**
|
|
3
|
+
* 进入视口触发:包装任意内容,进入视口时淡入上移。
|
|
4
|
+
* 与 Reveal 的区别:InViewport 语义是「触发器」,Reveal 是「揭示样式」——
|
|
5
|
+
* 需要自定义进场形态(缩放、滑入等)时用 InViewport 包 motion 子元素。
|
|
6
|
+
*/
|
|
7
|
+
import { type HTMLMotionProps } from 'motion/react';
|
|
8
|
+
import { type DurationToken } from '../tokens';
|
|
9
|
+
export interface InViewportProps extends Omit<HTMLMotionProps<'div'>, 'initial' | 'whileInView' | 'viewport' | 'transition'> {
|
|
10
|
+
/** 只播放一次;默认 true */
|
|
11
|
+
once?: boolean;
|
|
12
|
+
/** IntersectionObserver rootMargin(提前/延后触发) */
|
|
13
|
+
margin?: string;
|
|
14
|
+
duration?: DurationToken;
|
|
15
|
+
/** 进场位移距离(px);0 则只淡入 */
|
|
16
|
+
offset?: number;
|
|
17
|
+
}
|
|
18
|
+
export declare function InViewport({ once, margin, duration, offset, style, children, ...rest }: InViewportProps): import("react").JSX.Element;
|
|
19
|
+
//# sourceMappingURL=in-viewport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"in-viewport.d.ts","sourceRoot":"","sources":["in-viewport.tsx"],"names":[],"mappings":";AAEA;;;;GAIG;AAEH,OAAO,EAAU,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAgC,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC;AAE7E,MAAM,WAAW,eACf,SAAQ,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE,SAAS,GAAG,aAAa,GAAG,UAAU,GAAG,YAAY,CAAC;IAC3F,oBAAoB;IACpB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,+CAA+C;IAC/C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,wBAAwB;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,UAAU,CAAC,EACzB,IAAW,EACX,MAA4B,EAC5B,QAAmB,EACnB,MAAW,EACX,KAAK,EACL,QAAQ,EACR,GAAG,IAAI,EACR,EAAE,eAAe,+BAajB"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 进入视口触发:包装任意内容,进入视口时淡入上移。
|
|
5
|
+
* 与 Reveal 的区别:InViewport 语义是「触发器」,Reveal 是「揭示样式」——
|
|
6
|
+
* 需要自定义进场形态(缩放、滑入等)时用 InViewport 包 motion 子元素。
|
|
7
|
+
*/
|
|
8
|
+
import { motion } from 'motion/react';
|
|
9
|
+
import { motionDurations, motionEases } from "../tokens";
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
export function InViewport({
|
|
12
|
+
once = true,
|
|
13
|
+
margin = '0px 0px -64px 0px',
|
|
14
|
+
duration = 'normal',
|
|
15
|
+
offset = 16,
|
|
16
|
+
style,
|
|
17
|
+
children,
|
|
18
|
+
...rest
|
|
19
|
+
}) {
|
|
20
|
+
return /*#__PURE__*/_jsx(motion.div, {
|
|
21
|
+
initial: {
|
|
22
|
+
opacity: 0,
|
|
23
|
+
y: offset
|
|
24
|
+
},
|
|
25
|
+
whileInView: {
|
|
26
|
+
opacity: 1,
|
|
27
|
+
y: 0
|
|
28
|
+
},
|
|
29
|
+
viewport: {
|
|
30
|
+
once,
|
|
31
|
+
margin
|
|
32
|
+
},
|
|
33
|
+
transition: {
|
|
34
|
+
duration: motionDurations[duration],
|
|
35
|
+
ease: motionEases.decelerate
|
|
36
|
+
},
|
|
37
|
+
style: style,
|
|
38
|
+
...rest,
|
|
39
|
+
children: children
|
|
40
|
+
});
|
|
41
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
/**
|
|
3
|
+
* 令牌驱动的关键帧循环/播放。
|
|
4
|
+
*
|
|
5
|
+
* 白名单属性(合成器友好):opacity、scale、x、y、rotate、rotateX、rotateY、skewX、skewY。
|
|
6
|
+
* 传入白名单外的属性会在开发环境告警(不阻断渲染)。
|
|
7
|
+
*/
|
|
8
|
+
import { type HTMLMotionProps } from 'motion/react';
|
|
9
|
+
import { type DurationToken, type EaseToken } from '../tokens';
|
|
10
|
+
/** 允许做关键帧动画的属性白名单(全部为 transform/opacity 家族) */
|
|
11
|
+
export declare const KEYFRAMES_ALLOWED_PROPS: Set<string>;
|
|
12
|
+
export interface KeyframesProps extends Omit<HTMLMotionProps<'div'>, 'animate' | 'transition'> {
|
|
13
|
+
/** 关键帧数组:如 { scale: [1, 1.08, 1] }、{ opacity: [1, 0.4, 1] } */
|
|
14
|
+
animate: Record<string, (number | string)[]>;
|
|
15
|
+
duration?: DurationToken;
|
|
16
|
+
ease?: EaseToken;
|
|
17
|
+
/** 重复次数;Infinity 表示无限循环 */
|
|
18
|
+
repeat?: number;
|
|
19
|
+
/** 每轮之间的停顿(秒) */
|
|
20
|
+
repeatDelay?: number;
|
|
21
|
+
}
|
|
22
|
+
export declare function Keyframes({ animate, duration, ease, repeat, repeatDelay, ...rest }: KeyframesProps): import("react").JSX.Element;
|
|
23
|
+
//# sourceMappingURL=keyframes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keyframes.d.ts","sourceRoot":"","sources":["keyframes.tsx"],"names":[],"mappings":";AAEA;;;;;GAKG;AAEH,OAAO,EAAU,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAgC,KAAK,aAAa,EAAE,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AAE7F,+CAA+C;AAC/C,eAAO,MAAM,uBAAuB,aAUlC,CAAC;AAEH,MAAM,WAAW,cACf,SAAQ,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE,SAAS,GAAG,YAAY,CAAC;IAC9D,+DAA+D;IAC/D,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC;IAC7C,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,2BAA2B;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iBAAiB;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,SAAS,CAAC,EACxB,OAAO,EACP,QAAmB,EACnB,IAAiB,EACjB,MAAU,EACV,WAAe,EACf,GAAG,IAAI,EACR,EAAE,cAAc,+BAwBhB"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 令牌驱动的关键帧循环/播放。
|
|
5
|
+
*
|
|
6
|
+
* 白名单属性(合成器友好):opacity、scale、x、y、rotate、rotateX、rotateY、skewX、skewY。
|
|
7
|
+
* 传入白名单外的属性会在开发环境告警(不阻断渲染)。
|
|
8
|
+
*/
|
|
9
|
+
import { motion } from 'motion/react';
|
|
10
|
+
import { motionDurations, motionEases } from "../tokens";
|
|
11
|
+
|
|
12
|
+
/** 允许做关键帧动画的属性白名单(全部为 transform/opacity 家族) */
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
export const KEYFRAMES_ALLOWED_PROPS = new Set(['opacity', 'scale', 'x', 'y', 'rotate', 'rotateX', 'rotateY', 'skewX', 'skewY']);
|
|
15
|
+
export function Keyframes({
|
|
16
|
+
animate,
|
|
17
|
+
duration = 'normal',
|
|
18
|
+
ease = 'standard',
|
|
19
|
+
repeat = 0,
|
|
20
|
+
repeatDelay = 0,
|
|
21
|
+
...rest
|
|
22
|
+
}) {
|
|
23
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
24
|
+
for (const key of Object.keys(animate)) {
|
|
25
|
+
if (!KEYFRAMES_ALLOWED_PROPS.has(key)) {
|
|
26
|
+
// 开发期告警:非合成器友好属性会造成布局抖动
|
|
27
|
+
console.warn(`[motion] Keyframes 仅支持合成器友好属性,收到 "${key}"。` + `允许:${[...KEYFRAMES_ALLOWED_PROPS].join(', ')}`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return /*#__PURE__*/_jsx(motion.div, {
|
|
32
|
+
animate: animate,
|
|
33
|
+
transition: {
|
|
34
|
+
duration: motionDurations[duration],
|
|
35
|
+
ease: motionEases[ease],
|
|
36
|
+
repeat,
|
|
37
|
+
repeatDelay
|
|
38
|
+
},
|
|
39
|
+
...rest
|
|
40
|
+
});
|
|
41
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 磁吸悬停:children 跟随指针做弹簧偏移,离开后回位。
|
|
3
|
+
* reduced-motion 下不跟随。
|
|
4
|
+
*/
|
|
5
|
+
import { type ReactNode } from 'react';
|
|
6
|
+
export interface MagneticProps {
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
/** 跟随强度 0~1:1 表示完全贴合指针相对中心的偏移 */
|
|
9
|
+
strength?: number;
|
|
10
|
+
className?: string;
|
|
11
|
+
style?: React.CSSProperties;
|
|
12
|
+
}
|
|
13
|
+
export declare function Magnetic({ children, strength, className, style, }: MagneticProps): import("react").JSX.Element;
|
|
14
|
+
//# sourceMappingURL=magnetic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"magnetic.d.ts","sourceRoot":"","sources":["magnetic.tsx"],"names":[],"mappings":"AAEA;;;GAGG;AAEH,OAAO,EAAU,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAI/C,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,SAAS,CAAC;IACpB,iCAAiC;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B;AAED,wBAAgB,QAAQ,CAAC,EACvB,QAAQ,EACR,QAAe,EACf,SAAS,EACT,KAAK,GACN,EAAE,aAAa,+BAmCf"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 磁吸悬停:children 跟随指针做弹簧偏移,离开后回位。
|
|
5
|
+
* reduced-motion 下不跟随。
|
|
6
|
+
*/
|
|
7
|
+
import { useRef } from 'react';
|
|
8
|
+
import { motion, useMotionValue, useReducedMotion, useSpring } from 'motion/react';
|
|
9
|
+
import { motionSprings } from "../tokens";
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
export function Magnetic({
|
|
12
|
+
children,
|
|
13
|
+
strength = 0.35,
|
|
14
|
+
className,
|
|
15
|
+
style
|
|
16
|
+
}) {
|
|
17
|
+
const ref = useRef(null);
|
|
18
|
+
const reduced = useReducedMotion();
|
|
19
|
+
const mx = useMotionValue(0);
|
|
20
|
+
const my = useMotionValue(0);
|
|
21
|
+
const x = useSpring(mx, motionSprings.spring);
|
|
22
|
+
const y = useSpring(my, motionSprings.spring);
|
|
23
|
+
if (reduced) {
|
|
24
|
+
return /*#__PURE__*/_jsx("div", {
|
|
25
|
+
className: className,
|
|
26
|
+
style: style,
|
|
27
|
+
children: children
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
return /*#__PURE__*/_jsx(motion.div, {
|
|
31
|
+
ref: ref,
|
|
32
|
+
className: className,
|
|
33
|
+
style: {
|
|
34
|
+
display: 'inline-block',
|
|
35
|
+
...style,
|
|
36
|
+
x,
|
|
37
|
+
y
|
|
38
|
+
},
|
|
39
|
+
onMouseMove: e => {
|
|
40
|
+
const rect = ref.current?.getBoundingClientRect();
|
|
41
|
+
if (!rect) return;
|
|
42
|
+
mx.set((e.clientX - (rect.left + rect.width / 2)) * strength);
|
|
43
|
+
my.set((e.clientY - (rect.top + rect.height / 2)) * strength);
|
|
44
|
+
},
|
|
45
|
+
onMouseLeave: () => {
|
|
46
|
+
mx.set(0);
|
|
47
|
+
my.set(0);
|
|
48
|
+
},
|
|
49
|
+
children: children
|
|
50
|
+
});
|
|
51
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { type SpringToken } from '../tokens';
|
|
3
|
+
export interface NumberTickerProps {
|
|
4
|
+
/** 目标数值;变化时从当前展示值过渡过去 */
|
|
5
|
+
value: number;
|
|
6
|
+
/** 数字格式化;默认按 zh-CN 千分位取整 */
|
|
7
|
+
format?: (n: number) => string;
|
|
8
|
+
/** 弹簧档位;'spring' 稳定、'bouncy' 轻微回弹 */
|
|
9
|
+
spring?: SpringToken;
|
|
10
|
+
/** reduced-motion 时也用它渲染终值 */
|
|
11
|
+
className?: string;
|
|
12
|
+
style?: React.CSSProperties;
|
|
13
|
+
'aria-label'?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function NumberTicker({ value, format, spring, className, style, ...rest }: NumberTickerProps): import("react").JSX.Element;
|
|
16
|
+
//# sourceMappingURL=number-ticker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number-ticker.d.ts","sourceRoot":"","sources":["number-ticker.tsx"],"names":[],"mappings":";AAiBA,OAAO,EAAiB,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAE5D,MAAM,WAAW,iBAAiB;IAChC,yBAAyB;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,4BAA4B;IAC5B,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAC/B,qCAAqC;IACrC,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,8BAA8B;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,wBAAgB,YAAY,CAAC,EAC3B,KAAK,EACL,MAA6D,EAC7D,MAAiB,EACjB,SAAS,EACT,KAAK,EACL,GAAG,IAAI,EACR,EAAE,iBAAiB,+BAuBnB"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 数字滚动:计数器、金额、指标变化。
|
|
5
|
+
*
|
|
6
|
+
* value 变化时从**当前值**弹簧过渡到新值(流式场景不会从 0 重播);
|
|
7
|
+
* reduced-motion 下直接呈现终值。
|
|
8
|
+
*/
|
|
9
|
+
import { useEffect } from 'react';
|
|
10
|
+
import { motion, useMotionValue, useReducedMotion, useSpring, useTransform } from 'motion/react';
|
|
11
|
+
import { motionSprings } from "../tokens";
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
export function NumberTicker({
|
|
14
|
+
value,
|
|
15
|
+
format = n => Math.round(n).toLocaleString('zh-CN'),
|
|
16
|
+
spring = 'spring',
|
|
17
|
+
className,
|
|
18
|
+
style,
|
|
19
|
+
...rest
|
|
20
|
+
}) {
|
|
21
|
+
const reduced = useReducedMotion();
|
|
22
|
+
const raw = useMotionValue(value);
|
|
23
|
+
const springed = useSpring(raw, motionSprings[spring]);
|
|
24
|
+
const text = useTransform(springed, v => format(v));
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
raw.set(value);
|
|
27
|
+
}, [value, raw]);
|
|
28
|
+
if (reduced) {
|
|
29
|
+
return /*#__PURE__*/_jsx("span", {
|
|
30
|
+
className: className,
|
|
31
|
+
style: style,
|
|
32
|
+
...rest,
|
|
33
|
+
children: format(value)
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return /*#__PURE__*/_jsx(motion.span, {
|
|
37
|
+
className: className,
|
|
38
|
+
style: style,
|
|
39
|
+
...rest,
|
|
40
|
+
children: text
|
|
41
|
+
});
|
|
42
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
/**
|
|
3
|
+
* 进入视口时揭示:滚动浏览场景的默认进场(淡入 + 上移 16px)。
|
|
4
|
+
*
|
|
5
|
+
* 多个 Reveal 需要依次揭示时,用 `index` 传入序号(内部换算为 delay);
|
|
6
|
+
* 复杂的时序编排请用 `<Timeline>`。
|
|
7
|
+
*/
|
|
8
|
+
import { type HTMLMotionProps } from 'motion/react';
|
|
9
|
+
import { type DurationToken } from '../tokens';
|
|
10
|
+
export interface RevealProps extends Omit<HTMLMotionProps<'div'>, 'initial' | 'animate' | 'transition'> {
|
|
11
|
+
/** 兄弟 Reveal 的序号,自动换算 80ms 步进延迟;缺省 0 */
|
|
12
|
+
index?: number;
|
|
13
|
+
/** 显式延迟(秒),与 index 二选一 */
|
|
14
|
+
delay?: number;
|
|
15
|
+
duration?: DurationToken;
|
|
16
|
+
/** 视口判定边距,负值提前/正值延后触发;同 IntersectionObserver rootMargin */
|
|
17
|
+
margin?: string;
|
|
18
|
+
/** 是否只播放一次;默认 true(滚回上方不重播) */
|
|
19
|
+
once?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export declare function Reveal({ index, delay, duration, margin, once, style, ...rest }: RevealProps): import("react").JSX.Element;
|
|
22
|
+
//# sourceMappingURL=reveal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reveal.d.ts","sourceRoot":"","sources":["reveal.tsx"],"names":[],"mappings":";AAEA;;;;;GAKG;AAEH,OAAO,EAAU,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAgC,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC;AAG7E,MAAM,WAAW,WACf,SAAQ,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,YAAY,CAAC;IAC1E,wCAAwC;IACxC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,0BAA0B;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,2DAA2D;IAC3D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,+BAA+B;IAC/B,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,wBAAgB,MAAM,CAAC,EACrB,KAAS,EACT,KAAK,EACL,QAAmB,EACnB,MAA4B,EAC5B,IAAW,EACX,KAAK,EACL,GAAG,IAAI,EACR,EAAE,WAAW,+BAiBb"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 进入视口时揭示:滚动浏览场景的默认进场(淡入 + 上移 16px)。
|
|
5
|
+
*
|
|
6
|
+
* 多个 Reveal 需要依次揭示时,用 `index` 传入序号(内部换算为 delay);
|
|
7
|
+
* 复杂的时序编排请用 `<Timeline>`。
|
|
8
|
+
*/
|
|
9
|
+
import { motion } from 'motion/react';
|
|
10
|
+
import { motionDurations, motionEases } from "../tokens";
|
|
11
|
+
import { useReducedMotion } from 'motion/react';
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
export function Reveal({
|
|
14
|
+
index = 0,
|
|
15
|
+
delay,
|
|
16
|
+
duration = 'normal',
|
|
17
|
+
margin = '0px 0px -64px 0px',
|
|
18
|
+
once = true,
|
|
19
|
+
style,
|
|
20
|
+
...rest
|
|
21
|
+
}) {
|
|
22
|
+
const reduced = useReducedMotion();
|
|
23
|
+
const resolvedDelay = delay ?? index * 0.08;
|
|
24
|
+
return /*#__PURE__*/_jsx(motion.div, {
|
|
25
|
+
initial: reduced ? false : {
|
|
26
|
+
opacity: 0,
|
|
27
|
+
y: 16
|
|
28
|
+
},
|
|
29
|
+
whileInView: {
|
|
30
|
+
opacity: 1,
|
|
31
|
+
y: 0
|
|
32
|
+
},
|
|
33
|
+
viewport: {
|
|
34
|
+
once,
|
|
35
|
+
margin
|
|
36
|
+
},
|
|
37
|
+
transition: {
|
|
38
|
+
duration: reduced ? 0 : motionDurations[duration],
|
|
39
|
+
ease: motionEases.decelerate,
|
|
40
|
+
delay: reduced ? 0 : resolvedDelay
|
|
41
|
+
},
|
|
42
|
+
style: style,
|
|
43
|
+
...rest
|
|
44
|
+
});
|
|
45
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export interface SkeletonShimmerProps {
|
|
3
|
+
width?: number | string;
|
|
4
|
+
height?: number | string;
|
|
5
|
+
radius?: number | string;
|
|
6
|
+
/** 扫过一轮的时长(秒) */
|
|
7
|
+
duration?: number;
|
|
8
|
+
className?: string;
|
|
9
|
+
style?: React.CSSProperties;
|
|
10
|
+
}
|
|
11
|
+
export declare function SkeletonShimmer({ width, height, radius, duration, className, style, }: SkeletonShimmerProps): import("react").JSX.Element;
|
|
12
|
+
//# sourceMappingURL=skeleton-shimmer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skeleton-shimmer.d.ts","sourceRoot":"","sources":["skeleton-shimmer.tsx"],"names":[],"mappings":";AASA,MAAM,WAAW,oBAAoB;IACnC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,iBAAiB;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B;AAED,wBAAgB,eAAe,CAAC,EAC9B,KAAc,EACd,MAAW,EACX,MAAU,EACV,QAAc,EACd,SAAS,EACT,KAAK,GACN,EAAE,oBAAoB,+BA+BtB"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 骨架屏光泽扫过:引擎驱动的 transform 循环(合成器友好),
|
|
5
|
+
* reduced-motion 下呈现静止底色。
|
|
6
|
+
*/
|
|
7
|
+
import { motion, useReducedMotion } from 'motion/react';
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
export function SkeletonShimmer({
|
|
10
|
+
width = '100%',
|
|
11
|
+
height = 16,
|
|
12
|
+
radius = 8,
|
|
13
|
+
duration = 1.4,
|
|
14
|
+
className,
|
|
15
|
+
style
|
|
16
|
+
}) {
|
|
17
|
+
const reduced = useReducedMotion();
|
|
18
|
+
return /*#__PURE__*/_jsx("div", {
|
|
19
|
+
className: className,
|
|
20
|
+
style: {
|
|
21
|
+
position: 'relative',
|
|
22
|
+
overflow: 'hidden',
|
|
23
|
+
width,
|
|
24
|
+
height,
|
|
25
|
+
borderRadius: radius,
|
|
26
|
+
background: 'rgba(127, 127, 127, 0.16)',
|
|
27
|
+
...style
|
|
28
|
+
},
|
|
29
|
+
children: !reduced && /*#__PURE__*/_jsx(motion.div, {
|
|
30
|
+
"aria-hidden": true,
|
|
31
|
+
style: {
|
|
32
|
+
position: 'absolute',
|
|
33
|
+
inset: 0,
|
|
34
|
+
background: 'linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.5), transparent)'
|
|
35
|
+
},
|
|
36
|
+
initial: {
|
|
37
|
+
x: '-100%'
|
|
38
|
+
},
|
|
39
|
+
animate: {
|
|
40
|
+
x: '100%'
|
|
41
|
+
},
|
|
42
|
+
transition: {
|
|
43
|
+
repeat: Infinity,
|
|
44
|
+
duration,
|
|
45
|
+
ease: 'linear',
|
|
46
|
+
repeatDelay: 0.2
|
|
47
|
+
}
|
|
48
|
+
})
|
|
49
|
+
});
|
|
50
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
type Granularity = 'char' | 'word' | 'line';
|
|
3
|
+
export interface SplitTextProps {
|
|
4
|
+
text: string;
|
|
5
|
+
granularity?: Granularity;
|
|
6
|
+
/** 相邻片段的步进延迟(秒) */
|
|
7
|
+
stagger?: number;
|
|
8
|
+
duration?: 'fast' | 'normal' | 'slow';
|
|
9
|
+
/** mount 时播放(默认);inView = 进入视口时播放 */
|
|
10
|
+
mode?: 'mount' | 'inView';
|
|
11
|
+
className?: string;
|
|
12
|
+
/** 片段元素上附加的样式(如 inline-block 间距) */
|
|
13
|
+
style?: React.CSSProperties;
|
|
14
|
+
}
|
|
15
|
+
export declare function SplitText({ text, granularity, stagger, duration, mode, className, style, }: SplitTextProps): import("react").JSX.Element;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=split-text.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"split-text.d.ts","sourceRoot":"","sources":["split-text.tsx"],"names":[],"mappings":";AAWA,KAAK,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAE5C,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,mBAAmB;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,MAAM,CAAC;IACtC,qCAAqC;IACrC,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oCAAoC;IACpC,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CAC7B;AAQD,wBAAgB,SAAS,CAAC,EACxB,IAAI,EACJ,WAAoB,EACpB,OAAc,EACd,QAAmB,EACnB,IAAc,EACd,SAAS,EACT,KAAK,GACN,EAAE,cAAc,+BAqEhB"}
|