@idealyst/animate 1.2.55 → 1.2.57
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/package.json +3 -3
- package/src/index.native.ts +9 -3
- package/src/index.ts +3 -0
- package/src/withAnimated.native.ts +30 -0
- package/src/withAnimated.ts +27 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@idealyst/animate",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.57",
|
|
4
4
|
"description": "Cross-platform animation hooks for React and React Native",
|
|
5
5
|
"readme": "README.md",
|
|
6
6
|
"main": "src/index.ts",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"publish:npm": "npm publish"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"@idealyst/theme": "^1.2.
|
|
33
|
+
"@idealyst/theme": "^1.2.57",
|
|
34
34
|
"react": ">=16.8.0",
|
|
35
35
|
"react-native": ">=0.60.0",
|
|
36
36
|
"react-native-reanimated": ">=3.0.0",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
}
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@idealyst/theme": "^1.2.
|
|
51
|
+
"@idealyst/theme": "^1.2.57",
|
|
52
52
|
"@types/react": "^19.1.0",
|
|
53
53
|
"react": "^19.1.0",
|
|
54
54
|
"react-native": "^0.80.1",
|
package/src/index.native.ts
CHANGED
|
@@ -6,18 +6,21 @@
|
|
|
6
6
|
* that work on both web and native platforms.
|
|
7
7
|
*
|
|
8
8
|
* On native, animations use Reanimated for UI thread performance.
|
|
9
|
+
* Use `withAnimated` to wrap components for use with animated styles.
|
|
9
10
|
*
|
|
10
11
|
* @example
|
|
11
12
|
* ```tsx
|
|
12
|
-
* import
|
|
13
|
-
* import { useAnimatedStyle, usePresence, useGradientBorder } from '@idealyst/animate';
|
|
13
|
+
* import { View } from '@idealyst/components';
|
|
14
|
+
* import { withAnimated, useAnimatedStyle, usePresence, useGradientBorder } from '@idealyst/animate';
|
|
15
|
+
*
|
|
16
|
+
* const AnimatedView = withAnimated(View);
|
|
14
17
|
*
|
|
15
18
|
* // State-driven animations
|
|
16
19
|
* const style = useAnimatedStyle({
|
|
17
20
|
* opacity: isVisible ? 1 : 0,
|
|
18
21
|
* }, { duration: 'normal', easing: 'easeOut' });
|
|
19
22
|
*
|
|
20
|
-
* return <
|
|
23
|
+
* return <AnimatedView style={style}>Content</AnimatedView>;
|
|
21
24
|
*
|
|
22
25
|
* // Mount/unmount animations
|
|
23
26
|
* const { isPresent, style } = usePresence(isOpen, {
|
|
@@ -62,5 +65,8 @@ export { useAnimatedValue } from './useAnimatedValue.native';
|
|
|
62
65
|
export { usePresence } from './usePresence.native';
|
|
63
66
|
export { useGradientBorder } from './useGradientBorder.native';
|
|
64
67
|
|
|
68
|
+
// HOC for wrapping components to work with Reanimated
|
|
69
|
+
export { withAnimated } from './withAnimated.native';
|
|
70
|
+
|
|
65
71
|
// Re-export animation tokens for convenience
|
|
66
72
|
export { durations, easings, presets } from '@idealyst/theme/animation';
|
package/src/index.ts
CHANGED
|
@@ -60,5 +60,8 @@ export { useAnimatedValue } from './useAnimatedValue';
|
|
|
60
60
|
export { usePresence } from './usePresence';
|
|
61
61
|
export { useGradientBorder, createGradientBorderStyle } from './useGradientBorder';
|
|
62
62
|
|
|
63
|
+
// HOC for wrapping components (no-op on web, CSS handles animations)
|
|
64
|
+
export { withAnimated } from './withAnimated';
|
|
65
|
+
|
|
63
66
|
// Re-export animation tokens for convenience
|
|
64
67
|
export { durations, easings, presets } from '@idealyst/theme/animation';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ComponentType } from 'react';
|
|
2
|
+
import Animated from 'react-native-reanimated';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Native implementation of withAnimated - wraps a component to work with Reanimated.
|
|
6
|
+
*
|
|
7
|
+
* On native, components must be wrapped with Animated.createAnimatedComponent
|
|
8
|
+
* to receive animated styles from useAnimatedStyle, usePresence, etc.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* import { View } from '@idealyst/components';
|
|
13
|
+
* import { withAnimated, useAnimatedStyle } from '@idealyst/animate';
|
|
14
|
+
*
|
|
15
|
+
* const AnimatedView = withAnimated(View);
|
|
16
|
+
*
|
|
17
|
+
* function MyComponent() {
|
|
18
|
+
* const style = useAnimatedStyle(
|
|
19
|
+
* { opacity: isVisible ? 1 : 0 },
|
|
20
|
+
* { duration: 'normal' }
|
|
21
|
+
* );
|
|
22
|
+
* return <AnimatedView style={style}>Content</AnimatedView>;
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export function withAnimated<T extends ComponentType<any>>(
|
|
27
|
+
component: T
|
|
28
|
+
): ReturnType<typeof Animated.createAnimatedComponent<T>> {
|
|
29
|
+
return Animated.createAnimatedComponent(component);
|
|
30
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ComponentType } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Web implementation of withAnimated - a no-op that returns the component as-is.
|
|
5
|
+
*
|
|
6
|
+
* On web, CSS transitions handle animations automatically on regular elements,
|
|
7
|
+
* so no HOC wrapping is needed.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* import { View } from '@idealyst/components';
|
|
12
|
+
* import { withAnimated, useAnimatedStyle } from '@idealyst/animate';
|
|
13
|
+
*
|
|
14
|
+
* const AnimatedView = withAnimated(View);
|
|
15
|
+
*
|
|
16
|
+
* function MyComponent() {
|
|
17
|
+
* const style = useAnimatedStyle(
|
|
18
|
+
* { opacity: isVisible ? 1 : 0 },
|
|
19
|
+
* { duration: 'normal' }
|
|
20
|
+
* );
|
|
21
|
+
* return <AnimatedView style={style}>Content</AnimatedView>;
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export function withAnimated<T extends ComponentType<any>>(component: T): T {
|
|
26
|
+
return component;
|
|
27
|
+
}
|