@enact-ui/animate 0.1.0 → 0.2.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/api-schema.json +206 -0
- package/dist/components/CountUp.d.ts +84 -0
- package/dist/components/CountUp.d.ts.map +1 -0
- package/dist/components/CountUp.js +68 -0
- package/dist/components/CountUp.js.map +1 -0
- package/dist/components/MotionDiv.d.ts +159 -0
- package/dist/components/MotionDiv.d.ts.map +1 -0
- package/dist/components/MotionDiv.js +162 -0
- package/dist/components/MotionDiv.js.map +1 -0
- package/dist/components/StaggerContainer.d.ts +136 -0
- package/dist/components/StaggerContainer.d.ts.map +1 -0
- package/dist/components/StaggerContainer.js +166 -0
- package/dist/components/StaggerContainer.js.map +1 -0
- package/dist/hooks/use-component-animation.d.ts +156 -0
- package/dist/hooks/use-component-animation.d.ts.map +1 -0
- package/dist/hooks/use-component-animation.js +231 -0
- package/dist/hooks/use-component-animation.js.map +1 -0
- package/dist/hooks/use-count-up.d.ts +111 -0
- package/dist/hooks/use-count-up.d.ts.map +1 -0
- package/dist/hooks/use-count-up.js +246 -0
- package/dist/hooks/use-count-up.js.map +1 -0
- package/dist/hooks/use-draw-path.d.ts +96 -0
- package/dist/hooks/use-draw-path.d.ts.map +1 -0
- package/dist/hooks/use-draw-path.js +227 -0
- package/dist/hooks/use-draw-path.js.map +1 -0
- package/dist/hooks/use-motion-preset.d.ts.map +1 -1
- package/dist/hooks/use-motion-preset.js +17 -16
- package/dist/hooks/use-motion-preset.js.map +1 -1
- package/dist/hooks/use-stagger.d.ts +174 -0
- package/dist/hooks/use-stagger.d.ts.map +1 -0
- package/dist/hooks/use-stagger.js +256 -0
- package/dist/hooks/use-stagger.js.map +1 -0
- package/dist/index.d.ts +17 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2442 -26
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2335 -25
- package/dist/index.mjs.map +1 -1
- package/dist/presets/component-presets.d.ts +246 -0
- package/dist/presets/component-presets.d.ts.map +1 -0
- package/dist/presets/component-presets.js +472 -0
- package/dist/presets/component-presets.js.map +1 -0
- package/dist/presets/micro-interactions.d.ts +451 -0
- package/dist/presets/micro-interactions.d.ts.map +1 -0
- package/dist/presets/micro-interactions.js +856 -0
- package/dist/presets/micro-interactions.js.map +1 -0
- package/dist/presets/motion-presets.d.ts.map +1 -1
- package/dist/presets/motion-presets.js +0 -1
- package/dist/presets/motion-presets.js.map +1 -1
- package/dist/presets/motion-styles.d.ts +186 -0
- package/dist/presets/motion-styles.d.ts.map +1 -0
- package/dist/presets/motion-styles.js +204 -0
- package/dist/presets/motion-styles.js.map +1 -0
- package/dist/presets/stagger-presets.d.ts +378 -0
- package/dist/presets/stagger-presets.d.ts.map +1 -0
- package/dist/presets/stagger-presets.js +582 -0
- package/dist/presets/stagger-presets.js.map +1 -0
- package/dist/showcase/motion-presets.demo.d.ts +25 -0
- package/dist/showcase/motion-presets.demo.d.ts.map +1 -0
- package/dist/showcase/motion-presets.demo.js +96 -0
- package/dist/showcase/motion-presets.demo.js.map +1 -0
- package/dist/showcase/motion-presets.story.d.ts +37 -0
- package/dist/showcase/motion-presets.story.d.ts.map +1 -0
- package/dist/showcase/motion-presets.story.js +151 -0
- package/dist/showcase/motion-presets.story.js.map +1 -0
- package/dist/utils/easing.d.ts +294 -0
- package/dist/utils/easing.d.ts.map +1 -0
- package/dist/utils/easing.js +265 -0
- package/dist/utils/easing.js.map +1 -0
- package/dist/utils/reduced-motion.d.ts +322 -0
- package/dist/utils/reduced-motion.d.ts.map +1 -0
- package/dist/utils/reduced-motion.js +362 -0
- package/dist/utils/reduced-motion.js.map +1 -0
- package/dist/utils/select-preset.d.ts +186 -0
- package/dist/utils/select-preset.d.ts.map +1 -0
- package/dist/utils/select-preset.js +320 -0
- package/dist/utils/select-preset.js.map +1 -0
- package/dist/utils/spring-configs.d.ts +187 -0
- package/dist/utils/spring-configs.d.ts.map +1 -0
- package/dist/utils/spring-configs.js +169 -0
- package/dist/utils/spring-configs.js.map +1 -0
- package/package.json +4 -3
package/api-schema.json
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
{
|
|
2
|
+
"package": "@enact-ui/animate",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"extractedAt": "2026-01-04T19:10:38.245Z",
|
|
5
|
+
"components": {
|
|
6
|
+
"StaggerContainer": {
|
|
7
|
+
"name": "StaggerContainer",
|
|
8
|
+
"props": {
|
|
9
|
+
"children": {
|
|
10
|
+
"name": "children",
|
|
11
|
+
"type": "ReactNode",
|
|
12
|
+
"required": true
|
|
13
|
+
},
|
|
14
|
+
"style": {
|
|
15
|
+
"name": "style",
|
|
16
|
+
"type": "MotionStyle",
|
|
17
|
+
"required": false
|
|
18
|
+
},
|
|
19
|
+
"direction": {
|
|
20
|
+
"name": "direction",
|
|
21
|
+
"type": "StaggerDirection",
|
|
22
|
+
"required": false
|
|
23
|
+
},
|
|
24
|
+
"delay": {
|
|
25
|
+
"name": "delay",
|
|
26
|
+
"type": "number",
|
|
27
|
+
"required": false
|
|
28
|
+
},
|
|
29
|
+
"maxDelay": {
|
|
30
|
+
"name": "maxDelay",
|
|
31
|
+
"type": "number",
|
|
32
|
+
"required": false
|
|
33
|
+
},
|
|
34
|
+
"useSpring": {
|
|
35
|
+
"name": "useSpring",
|
|
36
|
+
"type": "boolean",
|
|
37
|
+
"required": false
|
|
38
|
+
},
|
|
39
|
+
"getDelay": {
|
|
40
|
+
"name": "getDelay",
|
|
41
|
+
"type": "(index: number, total: number) => number",
|
|
42
|
+
"required": false
|
|
43
|
+
},
|
|
44
|
+
"className": {
|
|
45
|
+
"name": "className",
|
|
46
|
+
"type": "string",
|
|
47
|
+
"required": false
|
|
48
|
+
},
|
|
49
|
+
"as": {
|
|
50
|
+
"name": "as",
|
|
51
|
+
"type": "\"div\" | \"ul\" | \"ol\" | \"section\" | \"article\" | \"nav\"",
|
|
52
|
+
"values": ["div", "ul", "ol", "section", "article", "nav"],
|
|
53
|
+
"required": false
|
|
54
|
+
},
|
|
55
|
+
"animate": {
|
|
56
|
+
"name": "animate",
|
|
57
|
+
"type": "boolean",
|
|
58
|
+
"required": false
|
|
59
|
+
},
|
|
60
|
+
"onAnimationComplete": {
|
|
61
|
+
"name": "onAnimationComplete",
|
|
62
|
+
"type": "() => void",
|
|
63
|
+
"required": false
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"sourceFile": "src/components/StaggerContainer.tsx"
|
|
67
|
+
},
|
|
68
|
+
"MotionDiv": {
|
|
69
|
+
"name": "MotionDiv",
|
|
70
|
+
"props": {
|
|
71
|
+
"preset": {
|
|
72
|
+
"name": "preset",
|
|
73
|
+
"type": "ComponentPreset",
|
|
74
|
+
"required": true
|
|
75
|
+
},
|
|
76
|
+
"exit": {
|
|
77
|
+
"name": "exit",
|
|
78
|
+
"type": "ComponentPreset",
|
|
79
|
+
"required": false
|
|
80
|
+
},
|
|
81
|
+
"as": {
|
|
82
|
+
"name": "as",
|
|
83
|
+
"type": "MotionElements",
|
|
84
|
+
"required": false
|
|
85
|
+
},
|
|
86
|
+
"motionStyle": {
|
|
87
|
+
"name": "motionStyle",
|
|
88
|
+
"type": "MotionStyle",
|
|
89
|
+
"required": false
|
|
90
|
+
},
|
|
91
|
+
"presetOptions": {
|
|
92
|
+
"name": "presetOptions",
|
|
93
|
+
"type": "PresetOptions",
|
|
94
|
+
"required": false
|
|
95
|
+
},
|
|
96
|
+
"enabled": {
|
|
97
|
+
"name": "enabled",
|
|
98
|
+
"type": "boolean",
|
|
99
|
+
"required": false
|
|
100
|
+
},
|
|
101
|
+
"skipInitial": {
|
|
102
|
+
"name": "skipInitial",
|
|
103
|
+
"type": "boolean",
|
|
104
|
+
"required": false
|
|
105
|
+
},
|
|
106
|
+
"children": {
|
|
107
|
+
"name": "children",
|
|
108
|
+
"type": "ReactNode",
|
|
109
|
+
"required": false
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
"sourceFile": "src/components/MotionDiv.tsx"
|
|
113
|
+
},
|
|
114
|
+
"CountUp": {
|
|
115
|
+
"name": "CountUp",
|
|
116
|
+
"props": {
|
|
117
|
+
"to": {
|
|
118
|
+
"name": "to",
|
|
119
|
+
"type": "number",
|
|
120
|
+
"required": true
|
|
121
|
+
},
|
|
122
|
+
"from": {
|
|
123
|
+
"name": "from",
|
|
124
|
+
"type": "number",
|
|
125
|
+
"required": false
|
|
126
|
+
},
|
|
127
|
+
"duration": {
|
|
128
|
+
"name": "duration",
|
|
129
|
+
"type": "number",
|
|
130
|
+
"required": false
|
|
131
|
+
},
|
|
132
|
+
"motionStyle": {
|
|
133
|
+
"name": "motionStyle",
|
|
134
|
+
"type": "MotionStyle",
|
|
135
|
+
"required": false
|
|
136
|
+
},
|
|
137
|
+
"easing": {
|
|
138
|
+
"name": "easing",
|
|
139
|
+
"type": "CountUpEasing",
|
|
140
|
+
"required": false
|
|
141
|
+
},
|
|
142
|
+
"decimals": {
|
|
143
|
+
"name": "decimals",
|
|
144
|
+
"type": "number",
|
|
145
|
+
"required": false
|
|
146
|
+
},
|
|
147
|
+
"useLocale": {
|
|
148
|
+
"name": "useLocale",
|
|
149
|
+
"type": "boolean",
|
|
150
|
+
"required": false
|
|
151
|
+
},
|
|
152
|
+
"locale": {
|
|
153
|
+
"name": "locale",
|
|
154
|
+
"type": "string",
|
|
155
|
+
"required": false
|
|
156
|
+
},
|
|
157
|
+
"formatter": {
|
|
158
|
+
"name": "formatter",
|
|
159
|
+
"type": "(value: number) => string",
|
|
160
|
+
"required": false
|
|
161
|
+
},
|
|
162
|
+
"delay": {
|
|
163
|
+
"name": "delay",
|
|
164
|
+
"type": "number",
|
|
165
|
+
"required": false
|
|
166
|
+
},
|
|
167
|
+
"autoStart": {
|
|
168
|
+
"name": "autoStart",
|
|
169
|
+
"type": "boolean",
|
|
170
|
+
"required": false
|
|
171
|
+
},
|
|
172
|
+
"onComplete": {
|
|
173
|
+
"name": "onComplete",
|
|
174
|
+
"type": "() => void",
|
|
175
|
+
"required": false
|
|
176
|
+
},
|
|
177
|
+
"onUpdate": {
|
|
178
|
+
"name": "onUpdate",
|
|
179
|
+
"type": "(value: number) => void",
|
|
180
|
+
"required": false
|
|
181
|
+
},
|
|
182
|
+
"prefix": {
|
|
183
|
+
"name": "prefix",
|
|
184
|
+
"type": "string",
|
|
185
|
+
"required": false
|
|
186
|
+
},
|
|
187
|
+
"suffix": {
|
|
188
|
+
"name": "suffix",
|
|
189
|
+
"type": "string",
|
|
190
|
+
"required": false
|
|
191
|
+
},
|
|
192
|
+
"enabled": {
|
|
193
|
+
"name": "enabled",
|
|
194
|
+
"type": "boolean",
|
|
195
|
+
"required": false
|
|
196
|
+
},
|
|
197
|
+
"children": {
|
|
198
|
+
"name": "children",
|
|
199
|
+
"type": "(props: { value: number",
|
|
200
|
+
"required": false
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
"sourceFile": "src/components/CountUp.tsx"
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CountUp Component
|
|
3
|
+
*
|
|
4
|
+
* Renders an animated number that counts from one value to another.
|
|
5
|
+
* Uses useCountUp hook internally with a convenient component API.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
import type { FC, HTMLAttributes } from "react";
|
|
10
|
+
import { type CountUpEasing } from "../hooks/use-count-up";
|
|
11
|
+
import type { MotionStyle } from "../presets/motion-styles";
|
|
12
|
+
export interface CountUpProps extends Omit<HTMLAttributes<HTMLSpanElement>, "children"> {
|
|
13
|
+
/** Target value to count to. Required. */
|
|
14
|
+
to: number;
|
|
15
|
+
/** Starting value. Defaults to 0. */
|
|
16
|
+
from?: number;
|
|
17
|
+
/** Duration in milliseconds. */
|
|
18
|
+
duration?: number;
|
|
19
|
+
/** Motion style for timing. Defaults to "standard". */
|
|
20
|
+
motionStyle?: MotionStyle;
|
|
21
|
+
/** Easing function. Defaults to "easeOutExpo". */
|
|
22
|
+
easing?: CountUpEasing;
|
|
23
|
+
/** Number of decimal places. Defaults to 0. */
|
|
24
|
+
decimals?: number;
|
|
25
|
+
/** Whether to use locale-specific formatting. Defaults to true. */
|
|
26
|
+
useLocale?: boolean;
|
|
27
|
+
/** Locale for formatting. */
|
|
28
|
+
locale?: string;
|
|
29
|
+
/** Custom formatter function. */
|
|
30
|
+
formatter?: (value: number) => string;
|
|
31
|
+
/** Delay before starting in ms. */
|
|
32
|
+
delay?: number;
|
|
33
|
+
/** Whether to start automatically. Defaults to true. */
|
|
34
|
+
autoStart?: boolean;
|
|
35
|
+
/** Callback when animation completes. */
|
|
36
|
+
onComplete?: () => void;
|
|
37
|
+
/** Callback on each value update. */
|
|
38
|
+
onUpdate?: (value: number) => void;
|
|
39
|
+
/** Prefix before the number (e.g., "$"). */
|
|
40
|
+
prefix?: string;
|
|
41
|
+
/** Suffix after the number (e.g., "%"). */
|
|
42
|
+
suffix?: string;
|
|
43
|
+
/** Whether animation is enabled. Defaults to true. */
|
|
44
|
+
enabled?: boolean;
|
|
45
|
+
/** Render prop for custom rendering. Receives value and displayValue. */
|
|
46
|
+
children?: (props: {
|
|
47
|
+
value: number;
|
|
48
|
+
displayValue: string;
|
|
49
|
+
isAnimating: boolean;
|
|
50
|
+
}) => React.ReactNode;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* CountUp - Animated number counter component
|
|
54
|
+
*
|
|
55
|
+
* Displays a number that animates from a starting value to a target value.
|
|
56
|
+
* Supports formatting, prefixes, suffixes, and custom rendering.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```tsx
|
|
60
|
+
* // Basic usage
|
|
61
|
+
* <CountUp to={1000} />
|
|
62
|
+
*
|
|
63
|
+
* // With formatting
|
|
64
|
+
* <CountUp to={99.5} decimals={1} suffix="%" />
|
|
65
|
+
*
|
|
66
|
+
* // Currency
|
|
67
|
+
* <CountUp to={1234567} prefix="$" useLocale />
|
|
68
|
+
*
|
|
69
|
+
* // Custom duration and easing
|
|
70
|
+
* <CountUp to={500} duration={2000} easing="spring" />
|
|
71
|
+
*
|
|
72
|
+
* // Render prop for custom styling
|
|
73
|
+
* <CountUp to={100}>
|
|
74
|
+
* {({ displayValue, isAnimating }) => (
|
|
75
|
+
* <span className={isAnimating ? "text-blue-500" : "text-green-500"}>
|
|
76
|
+
* {displayValue}
|
|
77
|
+
* </span>
|
|
78
|
+
* )}
|
|
79
|
+
* </CountUp>
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
export declare const CountUp: FC<CountUpProps>;
|
|
83
|
+
export default CountUp;
|
|
84
|
+
//# sourceMappingURL=CountUp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CountUp.d.ts","sourceRoot":"","sources":["../../src/components/CountUp.tsx"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,EAAE,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAChD,OAAO,EAAE,KAAK,aAAa,EAAsC,MAAM,uBAAuB,CAAC;AAC/F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAM5D,MAAM,WAAW,YAAa,SAAQ,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,EAAE,UAAU,CAAC;IACnF,0CAA0C;IAC1C,EAAE,EAAE,MAAM,CAAC;IACX,qCAAqC;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gCAAgC;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,uDAAuD;IACvD,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,kDAAkD;IAClD,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,mEAAmE;IACnE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,6BAA6B;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iCAAiC;IACjC,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IACtC,mCAAmC;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wDAAwD;IACxD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,yCAAyC;IACzC,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB,qCAAqC;IACrC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,4CAA4C;IAC5C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,2CAA2C;IAC3C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,sDAAsD;IACtD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,yEAAyE;IACzE,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,OAAO,CAAA;KAAE,KAAK,KAAK,CAAC,SAAS,CAAC;CACxG;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,eAAO,MAAM,OAAO,EAAE,EAAE,CAAC,YAAY,CAkDpC,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// Copyright (c) 2026 Amsterdam Data Labs
|
|
2
|
+
"use client";
|
|
3
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
+
import { useCountUp } from "../hooks/use-count-up";
|
|
5
|
+
// =============================================================================
|
|
6
|
+
// Component
|
|
7
|
+
// =============================================================================
|
|
8
|
+
/**
|
|
9
|
+
* CountUp - Animated number counter component
|
|
10
|
+
*
|
|
11
|
+
* Displays a number that animates from a starting value to a target value.
|
|
12
|
+
* Supports formatting, prefixes, suffixes, and custom rendering.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```tsx
|
|
16
|
+
* // Basic usage
|
|
17
|
+
* <CountUp to={1000} />
|
|
18
|
+
*
|
|
19
|
+
* // With formatting
|
|
20
|
+
* <CountUp to={99.5} decimals={1} suffix="%" />
|
|
21
|
+
*
|
|
22
|
+
* // Currency
|
|
23
|
+
* <CountUp to={1234567} prefix="$" useLocale />
|
|
24
|
+
*
|
|
25
|
+
* // Custom duration and easing
|
|
26
|
+
* <CountUp to={500} duration={2000} easing="spring" />
|
|
27
|
+
*
|
|
28
|
+
* // Render prop for custom styling
|
|
29
|
+
* <CountUp to={100}>
|
|
30
|
+
* {({ displayValue, isAnimating }) => (
|
|
31
|
+
* <span className={isAnimating ? "text-blue-500" : "text-green-500"}>
|
|
32
|
+
* {displayValue}
|
|
33
|
+
* </span>
|
|
34
|
+
* )}
|
|
35
|
+
* </CountUp>
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export const CountUp = ({ to, from = 0, duration, motionStyle = "standard", easing = "easeOutExpo", decimals = 0, useLocale = true, locale, formatter, delay = 0, autoStart = true, onComplete, onUpdate, prefix = "", suffix = "", enabled = true, children, ...spanProps }) => {
|
|
39
|
+
// Build hook options, only including defined optional values
|
|
40
|
+
const hookOptions = {
|
|
41
|
+
from,
|
|
42
|
+
to,
|
|
43
|
+
motionStyle,
|
|
44
|
+
easing,
|
|
45
|
+
decimals,
|
|
46
|
+
useLocale,
|
|
47
|
+
delay,
|
|
48
|
+
autoStart,
|
|
49
|
+
prefix,
|
|
50
|
+
suffix,
|
|
51
|
+
enabled,
|
|
52
|
+
// Only include optional props if they are defined
|
|
53
|
+
...(duration !== undefined && { duration }),
|
|
54
|
+
...(locale !== undefined && { locale }),
|
|
55
|
+
...(formatter !== undefined && { formatter }),
|
|
56
|
+
...(onComplete !== undefined && { onComplete }),
|
|
57
|
+
...(onUpdate !== undefined && { onUpdate }),
|
|
58
|
+
};
|
|
59
|
+
const { value, displayValue, isAnimating } = useCountUp(hookOptions);
|
|
60
|
+
// Render prop pattern
|
|
61
|
+
if (typeof children === "function") {
|
|
62
|
+
return _jsx(_Fragment, { children: children({ value, displayValue, isAnimating }) });
|
|
63
|
+
}
|
|
64
|
+
// Default rendering
|
|
65
|
+
return _jsx("span", { ...spanProps, children: displayValue });
|
|
66
|
+
};
|
|
67
|
+
export default CountUp;
|
|
68
|
+
//# sourceMappingURL=CountUp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CountUp.js","sourceRoot":"","sources":["../../src/components/CountUp.tsx"],"names":[],"mappings":"AAAA,yCAAyC;AAEzC,YAAY,CAAC;;AAYb,OAAO,EAA8C,UAAU,EAAE,MAAM,uBAAuB,CAAC;AA4C/F,gFAAgF;AAChF,YAAY;AACZ,gFAAgF;AAEhF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,CAAC,MAAM,OAAO,GAAqB,CAAC,EACtC,EAAE,EACF,IAAI,GAAG,CAAC,EACR,QAAQ,EACR,WAAW,GAAG,UAAU,EACxB,MAAM,GAAG,aAAa,EACtB,QAAQ,GAAG,CAAC,EACZ,SAAS,GAAG,IAAI,EAChB,MAAM,EACN,SAAS,EACT,KAAK,GAAG,CAAC,EACT,SAAS,GAAG,IAAI,EAChB,UAAU,EACV,QAAQ,EACR,MAAM,GAAG,EAAE,EACX,MAAM,GAAG,EAAE,EACX,OAAO,GAAG,IAAI,EACd,QAAQ,EACR,GAAG,SAAS,EACf,EAAE,EAAE;IACD,6DAA6D;IAC7D,MAAM,WAAW,GAAsB;QACnC,IAAI;QACJ,EAAE;QACF,WAAW;QACX,MAAM;QACN,QAAQ;QACR,SAAS;QACT,KAAK;QACL,SAAS;QACT,MAAM;QACN,MAAM;QACN,OAAO;QACP,kDAAkD;QAClD,GAAG,CAAC,QAAQ,KAAK,SAAS,IAAI,EAAE,QAAQ,EAAE,CAAC;QAC3C,GAAG,CAAC,MAAM,KAAK,SAAS,IAAI,EAAE,MAAM,EAAE,CAAC;QACvC,GAAG,CAAC,SAAS,KAAK,SAAS,IAAI,EAAE,SAAS,EAAE,CAAC;QAC7C,GAAG,CAAC,UAAU,KAAK,SAAS,IAAI,EAAE,UAAU,EAAE,CAAC;QAC/C,GAAG,CAAC,QAAQ,KAAK,SAAS,IAAI,EAAE,QAAQ,EAAE,CAAC;KAC9C,CAAC;IAEF,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;IAErE,sBAAsB;IACtB,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE,CAAC;QACjC,OAAO,4BAAG,QAAQ,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,CAAC,GAAI,CAAC;IACjE,CAAC;IAED,oBAAoB;IACpB,OAAO,kBAAU,SAAS,YAAG,YAAY,GAAQ,CAAC;AACtD,CAAC,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MotionDiv Component
|
|
3
|
+
*
|
|
4
|
+
* A typed wrapper around motion.div that integrates with the preset system.
|
|
5
|
+
* Provides a convenient way to apply animation presets without manually
|
|
6
|
+
* spreading props.
|
|
7
|
+
*
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
*/
|
|
10
|
+
import { motion } from "motion/react";
|
|
11
|
+
import type { ComponentPropsWithoutRef, ReactElement, ReactNode } from "react";
|
|
12
|
+
import type { ComponentPreset, PresetOptions } from "../presets/component-presets";
|
|
13
|
+
import type { MotionStyle } from "../presets/motion-styles";
|
|
14
|
+
/**
|
|
15
|
+
* Supported HTML elements for the `as` prop.
|
|
16
|
+
* Motion components are created dynamically for these elements.
|
|
17
|
+
*/
|
|
18
|
+
type MotionElements = "div" | "span" | "section" | "article" | "main" | "aside" | "header" | "footer" | "nav" | "ul" | "ol" | "li" | "button" | "a";
|
|
19
|
+
/**
|
|
20
|
+
* Props for the MotionDiv component.
|
|
21
|
+
*/
|
|
22
|
+
export interface MotionDivProps extends Omit<ComponentPropsWithoutRef<typeof motion.div>, "initial" | "animate" | "exit" | "transition"> {
|
|
23
|
+
/** The animation preset to apply */
|
|
24
|
+
preset: ComponentPreset;
|
|
25
|
+
/**
|
|
26
|
+
* Exit animation preset (for use with AnimatePresence).
|
|
27
|
+
* If not provided, uses the main preset's exit animation.
|
|
28
|
+
*/
|
|
29
|
+
exit?: ComponentPreset;
|
|
30
|
+
/**
|
|
31
|
+
* Render as a different HTML element.
|
|
32
|
+
* Supports semantic HTML elements for accessibility.
|
|
33
|
+
* @default "div"
|
|
34
|
+
*/
|
|
35
|
+
as?: MotionElements;
|
|
36
|
+
/** Motion style (subtle, standard, bold, playful) */
|
|
37
|
+
motionStyle?: MotionStyle;
|
|
38
|
+
/** Preset customization options */
|
|
39
|
+
presetOptions?: PresetOptions;
|
|
40
|
+
/** Whether animation is enabled */
|
|
41
|
+
enabled?: boolean;
|
|
42
|
+
/** Skip initial animation (useful for SSR) */
|
|
43
|
+
skipInitial?: boolean;
|
|
44
|
+
/** Child content */
|
|
45
|
+
children?: ReactNode;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* A motion.div wrapper that integrates with animation presets.
|
|
49
|
+
*
|
|
50
|
+
* This component simplifies the use of animation presets by handling
|
|
51
|
+
* the hook usage internally and providing a clean component API.
|
|
52
|
+
*
|
|
53
|
+
* Note: This component requires motion/react to be installed.
|
|
54
|
+
* It's a convenience wrapper that re-exports motion.div with preset support.
|
|
55
|
+
*
|
|
56
|
+
* @ai-hint Use MotionDiv when you want a simple way to animate a div
|
|
57
|
+
* with a preset. For more control, use useComponentAnimation directly.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```tsx
|
|
61
|
+
* import { MotionDiv, fadeIn } from "@enact-ui/animate";
|
|
62
|
+
*
|
|
63
|
+
* function AnimatedCard() {
|
|
64
|
+
* return (
|
|
65
|
+
* <MotionDiv preset={fadeIn} motionStyle="standard">
|
|
66
|
+
* <Card>Content</Card>
|
|
67
|
+
* </MotionDiv>
|
|
68
|
+
* );
|
|
69
|
+
* }
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```tsx
|
|
74
|
+
* // With custom options
|
|
75
|
+
* <MotionDiv
|
|
76
|
+
* preset={slideUp}
|
|
77
|
+
* motionStyle="bold"
|
|
78
|
+
* presetOptions={{ distance: 40, delay: 100 }}
|
|
79
|
+
* className="my-class"
|
|
80
|
+
* >
|
|
81
|
+
* Content
|
|
82
|
+
* </MotionDiv>
|
|
83
|
+
* ```
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```tsx
|
|
87
|
+
* // With AnimatePresence for exit animations
|
|
88
|
+
* import { AnimatePresence } from "motion/react";
|
|
89
|
+
*
|
|
90
|
+
* function Modal({ isOpen }) {
|
|
91
|
+
* return (
|
|
92
|
+
* <AnimatePresence>
|
|
93
|
+
* {isOpen && (
|
|
94
|
+
* <MotionDiv preset={scale} motionStyle="standard">
|
|
95
|
+
* Modal content
|
|
96
|
+
* </MotionDiv>
|
|
97
|
+
* )}
|
|
98
|
+
* </AnimatePresence>
|
|
99
|
+
* );
|
|
100
|
+
* }
|
|
101
|
+
* ```
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```tsx
|
|
105
|
+
* // With separate exit animation
|
|
106
|
+
* <MotionDiv preset={slideUp} exit={fadeOut}>
|
|
107
|
+
* Content that slides up on enter, fades out on exit
|
|
108
|
+
* </MotionDiv>
|
|
109
|
+
* ```
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```tsx
|
|
113
|
+
* // Polymorphic - render as semantic HTML element
|
|
114
|
+
* <MotionDiv preset={fadeIn} as="section" className="my-section">
|
|
115
|
+
* <h2>Section Title</h2>
|
|
116
|
+
* <p>Section content...</p>
|
|
117
|
+
* </MotionDiv>
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
export declare function MotionDiv({ preset, exit: exitPreset, as, motionStyle, presetOptions, enabled, skipInitial, children, ...motionProps }: MotionDivProps): ReactElement;
|
|
121
|
+
/**
|
|
122
|
+
* Factory function to create motion props from a preset.
|
|
123
|
+
*
|
|
124
|
+
* Use this when you need the animation props without a component wrapper.
|
|
125
|
+
* This is useful when you want to spread props onto your own motion element.
|
|
126
|
+
*
|
|
127
|
+
* @param preset - The animation preset
|
|
128
|
+
* @param style - Motion style
|
|
129
|
+
* @param options - Preset options
|
|
130
|
+
* @returns Props object to spread on motion.div
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```tsx
|
|
134
|
+
* import { motion } from "motion/react";
|
|
135
|
+
* import { createMotionProps, fadeIn } from "@enact-ui/animate";
|
|
136
|
+
*
|
|
137
|
+
* function MyComponent() {
|
|
138
|
+
* const props = createMotionProps(fadeIn, "standard");
|
|
139
|
+
*
|
|
140
|
+
* return (
|
|
141
|
+
* <motion.div {...props}>
|
|
142
|
+
* Content
|
|
143
|
+
* </motion.div>
|
|
144
|
+
* );
|
|
145
|
+
* }
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
148
|
+
export declare function createMotionProps(preset: ComponentPreset, style?: MotionStyle, options?: PresetOptions): import("..").ComponentAnimationProps;
|
|
149
|
+
/**
|
|
150
|
+
* Alias for createMotionProps. Use createMotionProps directly.
|
|
151
|
+
*
|
|
152
|
+
* @param preset - The animation preset
|
|
153
|
+
* @param style - Motion style
|
|
154
|
+
* @param options - Preset options
|
|
155
|
+
* @returns Props object to spread on motion.div
|
|
156
|
+
*/
|
|
157
|
+
export declare function createAccessibleMotionProps(preset: ComponentPreset, style?: MotionStyle, options?: PresetOptions): import("..").ComponentAnimationProps;
|
|
158
|
+
export default MotionDiv;
|
|
159
|
+
//# sourceMappingURL=MotionDiv.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MotionDiv.d.ts","sourceRoot":"","sources":["../../src/components/MotionDiv.tsx"],"names":[],"mappings":"AAIA;;;;;;;;GAQG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,EAAE,wBAAwB,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE/E,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AACnF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAS5D;;;GAGG;AACH,KAAK,cAAc,GAAG,KAAK,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,KAAK,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,QAAQ,GAAG,GAAG,CAAC;AAMpJ;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,IAAI,CAAC,wBAAwB,CAAC,OAAO,MAAM,CAAC,GAAG,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,MAAM,GAAG,YAAY,CAAC;IACpI,oCAAoC;IACpC,MAAM,EAAE,eAAe,CAAC;IACxB;;;OAGG;IACH,IAAI,CAAC,EAAE,eAAe,CAAC;IACvB;;;;OAIG;IACH,EAAE,CAAC,EAAE,cAAc,CAAC;IACpB,qDAAqD;IACrD,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,mCAAmC;IACnC,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,mCAAmC;IACnC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,8CAA8C;IAC9C,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,oBAAoB;IACpB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACxB;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwEG;AACH,wBAAgB,SAAS,CAAC,EACtB,MAAM,EACN,IAAI,EAAE,UAAU,EAChB,EAAU,EACV,WAAwB,EACxB,aAAa,EACb,OAAc,EACd,WAAmB,EACnB,QAAQ,EACR,GAAG,WAAW,EACjB,EAAE,cAAc,GAAG,YAAY,CAmC/B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,eAAe,EAAE,KAAK,GAAE,WAAwB,EAAE,OAAO,CAAC,EAAE,aAAa,wCAElH;AAED;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,eAAe,EAAE,KAAK,GAAE,WAAwB,EAAE,OAAO,CAAC,EAAE,aAAa,wCAE5H;AAED,eAAe,SAAS,CAAC"}
|