react-native-skelo 0.0.1 → 0.0.2
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/LICENSE +21 -0
- package/README.md +147 -20
- package/lib/commonjs/Skelo.js +104 -0
- package/lib/commonjs/Skelo.js.map +1 -0
- package/lib/commonjs/animations/AnimationWrapper.js +76 -0
- package/lib/commonjs/animations/AnimationWrapper.js.map +1 -0
- package/lib/commonjs/animations/PulseAnimation.js +76 -0
- package/lib/commonjs/animations/PulseAnimation.js.map +1 -0
- package/lib/commonjs/animations/ShimmerAnimation.js +103 -0
- package/lib/commonjs/animations/ShimmerAnimation.js.map +1 -0
- package/lib/commonjs/animations/index.js +27 -0
- package/lib/commonjs/animations/index.js.map +1 -0
- package/lib/commonjs/components/MeasuredBlock.js +64 -0
- package/lib/commonjs/components/MeasuredBlock.js.map +1 -0
- package/lib/commonjs/components/Skeleton.js +144 -0
- package/lib/commonjs/components/Skeleton.js.map +1 -0
- package/lib/commonjs/components/SkeletonIgnore.js +30 -0
- package/lib/commonjs/components/SkeletonIgnore.js.map +1 -0
- package/lib/commonjs/components/SkeletonRenderer.js +270 -0
- package/lib/commonjs/components/SkeletonRenderer.js.map +1 -0
- package/lib/commonjs/components/primitives/SkeletonBox.js +47 -0
- package/lib/commonjs/components/primitives/SkeletonBox.js.map +1 -0
- package/lib/commonjs/components/primitives/SkeletonCircle.js +44 -0
- package/lib/commonjs/components/primitives/SkeletonCircle.js.map +1 -0
- package/lib/commonjs/components/primitives/SkeletonImage.js +46 -0
- package/lib/commonjs/components/primitives/SkeletonImage.js.map +1 -0
- package/lib/commonjs/components/primitives/SkeletonText.js +60 -0
- package/lib/commonjs/components/primitives/SkeletonText.js.map +1 -0
- package/lib/commonjs/components/primitives/index.js +34 -0
- package/lib/commonjs/components/primitives/index.js.map +1 -0
- package/lib/commonjs/components/withSkeleton.js +45 -0
- package/lib/commonjs/components/withSkeleton.js.map +1 -0
- package/lib/commonjs/constants/defaults.js +43 -0
- package/lib/commonjs/constants/defaults.js.map +1 -0
- package/lib/commonjs/core/deepRegistry.js +18 -0
- package/lib/commonjs/core/deepRegistry.js.map +1 -0
- package/lib/commonjs/core/generator/StyleSkeleton.js +101 -0
- package/lib/commonjs/core/generator/StyleSkeleton.js.map +1 -0
- package/lib/commonjs/core/parser/Parser.js +84 -0
- package/lib/commonjs/core/parser/Parser.js.map +1 -0
- package/lib/commonjs/core/parser/expandOffline.js +83 -0
- package/lib/commonjs/core/parser/expandOffline.js.map +1 -0
- package/lib/commonjs/core/parser/hostTreeReconciler.js +228 -0
- package/lib/commonjs/core/parser/hostTreeReconciler.js.map +1 -0
- package/lib/commonjs/core/parser/index.js +13 -0
- package/lib/commonjs/core/parser/index.js.map +1 -0
- package/lib/commonjs/core/registry/SkeletonRegistry.js +113 -0
- package/lib/commonjs/core/registry/SkeletonRegistry.js.map +1 -0
- package/lib/commonjs/core/registry/index.js +19 -0
- package/lib/commonjs/core/registry/index.js.map +1 -0
- package/lib/commonjs/core/resolver/StyleResolver.js +83 -0
- package/lib/commonjs/core/resolver/StyleResolver.js.map +1 -0
- package/lib/commonjs/core/resolver/index.js +13 -0
- package/lib/commonjs/core/resolver/index.js.map +1 -0
- package/lib/commonjs/deep.js +18 -0
- package/lib/commonjs/deep.js.map +1 -0
- package/lib/commonjs/index.js +66 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/plugins/ImagePlugin.js +60 -0
- package/lib/commonjs/plugins/ImagePlugin.js.map +1 -0
- package/lib/commonjs/plugins/TextPlugin.js +70 -0
- package/lib/commonjs/plugins/TextPlugin.js.map +1 -0
- package/lib/commonjs/plugins/ViewPlugin.js +71 -0
- package/lib/commonjs/plugins/ViewPlugin.js.map +1 -0
- package/lib/commonjs/plugins/index.js +27 -0
- package/lib/commonjs/plugins/index.js.map +1 -0
- package/lib/commonjs/types/index.js +2 -0
- package/lib/commonjs/types/index.js.map +1 -0
- package/lib/commonjs/types/plugin.js +6 -0
- package/lib/commonjs/types/plugin.js.map +1 -0
- package/lib/commonjs/types/skeleton.js +6 -0
- package/lib/commonjs/types/skeleton.js.map +1 -0
- package/lib/commonjs/utils/componentUtils.js +138 -0
- package/lib/commonjs/utils/componentUtils.js.map +1 -0
- package/lib/commonjs/utils/index.js +62 -0
- package/lib/commonjs/utils/index.js.map +1 -0
- package/lib/commonjs/utils/styleUtils.js +76 -0
- package/lib/commonjs/utils/styleUtils.js.map +1 -0
- package/lib/module/Skelo.js +98 -0
- package/lib/module/Skelo.js.map +1 -0
- package/lib/module/animations/AnimationWrapper.js +69 -0
- package/lib/module/animations/AnimationWrapper.js.map +1 -0
- package/lib/module/animations/PulseAnimation.js +69 -0
- package/lib/module/animations/PulseAnimation.js.map +1 -0
- package/lib/module/animations/ShimmerAnimation.js +96 -0
- package/lib/module/animations/ShimmerAnimation.js.map +1 -0
- package/lib/module/animations/index.js +4 -0
- package/lib/module/animations/index.js.map +1 -0
- package/lib/module/components/MeasuredBlock.js +57 -0
- package/lib/module/components/MeasuredBlock.js.map +1 -0
- package/lib/module/components/Skeleton.js +138 -0
- package/lib/module/components/Skeleton.js.map +1 -0
- package/lib/module/components/SkeletonIgnore.js +23 -0
- package/lib/module/components/SkeletonIgnore.js.map +1 -0
- package/lib/module/components/SkeletonRenderer.js +264 -0
- package/lib/module/components/SkeletonRenderer.js.map +1 -0
- package/lib/module/components/primitives/SkeletonBox.js +40 -0
- package/lib/module/components/primitives/SkeletonBox.js.map +1 -0
- package/lib/module/components/primitives/SkeletonCircle.js +37 -0
- package/lib/module/components/primitives/SkeletonCircle.js.map +1 -0
- package/lib/module/components/primitives/SkeletonImage.js +39 -0
- package/lib/module/components/primitives/SkeletonImage.js.map +1 -0
- package/lib/module/components/primitives/SkeletonText.js +53 -0
- package/lib/module/components/primitives/SkeletonText.js.map +1 -0
- package/lib/module/components/primitives/index.js +5 -0
- package/lib/module/components/primitives/index.js.map +1 -0
- package/lib/module/components/withSkeleton.js +38 -0
- package/lib/module/components/withSkeleton.js.map +1 -0
- package/lib/module/constants/defaults.js +37 -0
- package/lib/module/constants/defaults.js.map +1 -0
- package/lib/module/core/deepRegistry.js +11 -0
- package/lib/module/core/deepRegistry.js.map +1 -0
- package/lib/module/core/generator/StyleSkeleton.js +95 -0
- package/lib/module/core/generator/StyleSkeleton.js.map +1 -0
- package/lib/module/core/parser/Parser.js +77 -0
- package/lib/module/core/parser/Parser.js.map +1 -0
- package/lib/module/core/parser/expandOffline.js +77 -0
- package/lib/module/core/parser/expandOffline.js.map +1 -0
- package/lib/module/core/parser/hostTreeReconciler.js +222 -0
- package/lib/module/core/parser/hostTreeReconciler.js.map +1 -0
- package/lib/module/core/parser/index.js +2 -0
- package/lib/module/core/parser/index.js.map +1 -0
- package/lib/module/core/registry/SkeletonRegistry.js +106 -0
- package/lib/module/core/registry/SkeletonRegistry.js.map +1 -0
- package/lib/module/core/registry/index.js +2 -0
- package/lib/module/core/registry/index.js.map +1 -0
- package/lib/module/core/resolver/StyleResolver.js +77 -0
- package/lib/module/core/resolver/StyleResolver.js.map +1 -0
- package/lib/module/core/resolver/index.js +2 -0
- package/lib/module/core/resolver/index.js.map +1 -0
- package/lib/module/deep.js +11 -0
- package/lib/module/deep.js.map +1 -0
- package/lib/module/index.js +21 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/plugins/ImagePlugin.js +53 -0
- package/lib/module/plugins/ImagePlugin.js.map +1 -0
- package/lib/module/plugins/TextPlugin.js +63 -0
- package/lib/module/plugins/TextPlugin.js.map +1 -0
- package/lib/module/plugins/ViewPlugin.js +64 -0
- package/lib/module/plugins/ViewPlugin.js.map +1 -0
- package/lib/module/plugins/index.js +4 -0
- package/lib/module/plugins/index.js.map +1 -0
- package/lib/module/types/index.js +2 -0
- package/lib/module/types/index.js.map +1 -0
- package/lib/module/types/plugin.js +2 -0
- package/lib/module/types/plugin.js.map +1 -0
- package/lib/module/types/skeleton.js +2 -0
- package/lib/module/types/skeleton.js.map +1 -0
- package/lib/module/utils/componentUtils.js +123 -0
- package/lib/module/utils/componentUtils.js.map +1 -0
- package/lib/module/utils/index.js +3 -0
- package/lib/module/utils/index.js.map +1 -0
- package/lib/module/utils/styleUtils.js +66 -0
- package/lib/module/utils/styleUtils.js.map +1 -0
- package/lib/typescript/Skelo.d.ts +76 -0
- package/lib/typescript/Skelo.d.ts.map +1 -0
- package/lib/typescript/animations/AnimationWrapper.d.ts +66 -0
- package/lib/typescript/animations/AnimationWrapper.d.ts.map +1 -0
- package/lib/typescript/animations/PulseAnimation.d.ts +59 -0
- package/lib/typescript/animations/PulseAnimation.d.ts.map +1 -0
- package/lib/typescript/animations/ShimmerAnimation.d.ts +59 -0
- package/lib/typescript/animations/ShimmerAnimation.d.ts.map +1 -0
- package/lib/typescript/animations/index.d.ts +5 -0
- package/lib/typescript/animations/index.d.ts.map +1 -0
- package/lib/typescript/components/MeasuredBlock.d.ts +32 -0
- package/lib/typescript/components/MeasuredBlock.d.ts.map +1 -0
- package/lib/typescript/components/Skeleton.d.ts +37 -0
- package/lib/typescript/components/Skeleton.d.ts.map +1 -0
- package/lib/typescript/components/SkeletonIgnore.d.ts +26 -0
- package/lib/typescript/components/SkeletonIgnore.d.ts.map +1 -0
- package/lib/typescript/components/SkeletonRenderer.d.ts +39 -0
- package/lib/typescript/components/SkeletonRenderer.d.ts.map +1 -0
- package/lib/typescript/components/primitives/SkeletonBox.d.ts +21 -0
- package/lib/typescript/components/primitives/SkeletonBox.d.ts.map +1 -0
- package/lib/typescript/components/primitives/SkeletonCircle.d.ts +21 -0
- package/lib/typescript/components/primitives/SkeletonCircle.d.ts.map +1 -0
- package/lib/typescript/components/primitives/SkeletonImage.d.ts +21 -0
- package/lib/typescript/components/primitives/SkeletonImage.d.ts.map +1 -0
- package/lib/typescript/components/primitives/SkeletonText.d.ts +21 -0
- package/lib/typescript/components/primitives/SkeletonText.d.ts.map +1 -0
- package/lib/typescript/components/primitives/index.d.ts +5 -0
- package/lib/typescript/components/primitives/index.d.ts.map +1 -0
- package/lib/typescript/components/withSkeleton.d.ts +37 -0
- package/lib/typescript/components/withSkeleton.d.ts.map +1 -0
- package/lib/typescript/constants/defaults.d.ts +29 -0
- package/lib/typescript/constants/defaults.d.ts.map +1 -0
- package/lib/typescript/core/deepRegistry.d.ts +7 -0
- package/lib/typescript/core/deepRegistry.d.ts.map +1 -0
- package/lib/typescript/core/generator/StyleSkeleton.d.ts +36 -0
- package/lib/typescript/core/generator/StyleSkeleton.d.ts.map +1 -0
- package/lib/typescript/core/parser/Parser.d.ts +30 -0
- package/lib/typescript/core/parser/Parser.d.ts.map +1 -0
- package/lib/typescript/core/parser/expandOffline.d.ts +10 -0
- package/lib/typescript/core/parser/expandOffline.d.ts.map +1 -0
- package/lib/typescript/core/parser/hostTreeReconciler.d.ts +28 -0
- package/lib/typescript/core/parser/hostTreeReconciler.d.ts.map +1 -0
- package/lib/typescript/core/parser/index.d.ts +2 -0
- package/lib/typescript/core/parser/index.d.ts.map +1 -0
- package/lib/typescript/core/registry/SkeletonRegistry.d.ts +57 -0
- package/lib/typescript/core/registry/SkeletonRegistry.d.ts.map +1 -0
- package/lib/typescript/core/registry/index.d.ts +2 -0
- package/lib/typescript/core/registry/index.d.ts.map +1 -0
- package/lib/typescript/core/resolver/StyleResolver.d.ts +54 -0
- package/lib/typescript/core/resolver/StyleResolver.d.ts.map +1 -0
- package/lib/typescript/core/resolver/index.d.ts +2 -0
- package/lib/typescript/core/resolver/index.d.ts.map +1 -0
- package/lib/typescript/deep.d.ts +2 -0
- package/lib/typescript/deep.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +17 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/plugins/ImagePlugin.d.ts +11 -0
- package/lib/typescript/plugins/ImagePlugin.d.ts.map +1 -0
- package/lib/typescript/plugins/TextPlugin.d.ts +12 -0
- package/lib/typescript/plugins/TextPlugin.d.ts.map +1 -0
- package/lib/typescript/plugins/ViewPlugin.d.ts +11 -0
- package/lib/typescript/plugins/ViewPlugin.d.ts.map +1 -0
- package/lib/typescript/plugins/index.d.ts +4 -0
- package/lib/typescript/plugins/index.d.ts.map +1 -0
- package/lib/typescript/types/index.d.ts +3 -0
- package/lib/typescript/types/index.d.ts.map +1 -0
- package/lib/typescript/types/plugin.d.ts +144 -0
- package/lib/typescript/types/plugin.d.ts.map +1 -0
- package/lib/typescript/types/skeleton.d.ts +176 -0
- package/lib/typescript/types/skeleton.d.ts.map +1 -0
- package/lib/typescript/utils/componentUtils.d.ts +40 -0
- package/lib/typescript/utils/componentUtils.d.ts.map +1 -0
- package/lib/typescript/utils/index.d.ts +3 -0
- package/lib/typescript/utils/index.d.ts.map +1 -0
- package/lib/typescript/utils/styleUtils.d.ts +41 -0
- package/lib/typescript/utils/styleUtils.d.ts.map +1 -0
- package/package.json +171 -11
- package/src/Skelo.ts +103 -0
- package/src/animations/AnimationWrapper.tsx +139 -0
- package/src/animations/PulseAnimation.tsx +138 -0
- package/src/animations/ShimmerAnimation.tsx +169 -0
- package/src/animations/index.ts +4 -0
- package/src/components/MeasuredBlock.tsx +85 -0
- package/src/components/Skeleton.tsx +149 -0
- package/src/components/SkeletonIgnore.tsx +27 -0
- package/src/components/SkeletonRenderer.tsx +341 -0
- package/src/components/primitives/SkeletonBox.tsx +53 -0
- package/src/components/primitives/SkeletonCircle.tsx +48 -0
- package/src/components/primitives/SkeletonImage.tsx +50 -0
- package/src/components/primitives/SkeletonText.tsx +69 -0
- package/src/components/primitives/index.ts +4 -0
- package/src/components/withSkeleton.tsx +62 -0
- package/src/constants/defaults.ts +38 -0
- package/src/core/deepRegistry.ts +16 -0
- package/src/core/generator/StyleSkeleton.tsx +138 -0
- package/src/core/parser/Parser.ts +86 -0
- package/src/core/parser/expandOffline.tsx +83 -0
- package/src/core/parser/hostTreeReconciler.tsx +271 -0
- package/src/core/parser/index.ts +1 -0
- package/src/core/registry/SkeletonRegistry.ts +111 -0
- package/src/core/registry/index.ts +1 -0
- package/src/core/resolver/StyleResolver.ts +80 -0
- package/src/core/resolver/index.ts +1 -0
- package/src/deep.ts +12 -0
- package/src/index.ts +30 -0
- package/src/plugins/ImagePlugin.tsx +65 -0
- package/src/plugins/TextPlugin.tsx +71 -0
- package/src/plugins/ViewPlugin.tsx +67 -0
- package/src/plugins/index.ts +3 -0
- package/src/types/index.ts +14 -0
- package/src/types/plugin.ts +164 -0
- package/src/types/skeleton.ts +197 -0
- package/src/utils/componentUtils.ts +166 -0
- package/src/utils/index.ts +9 -0
- package/src/utils/styleUtils.ts +72 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Shubhanshu
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -2,41 +2,168 @@
|
|
|
2
2
|
|
|
3
3
|
# react-native-skelo
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
**Write your UI once. Skelo builds the loading state automatically.**
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
[](https://www.npmjs.com/package/react-native-skelo)
|
|
8
|
+
[](./LICENSE)
|
|
9
9
|
|
|
10
10
|
</div>
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
> ⚠️ **Pre-release (`0.0.x`).** Early and evolving — the API may change. The first **stable** release will be **`0.1.0`**. The `deep` engine is experimental — see [caveats](#deep-mode-caveats-experimental).
|
|
13
|
+
|
|
14
|
+
Skeleton loading screens usually mean building — and maintaining — a second copy of your UI. Skelo derives the skeleton from the UI you already wrote.
|
|
13
15
|
|
|
14
16
|
```tsx
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
import { Skeleton } from 'react-native-skelo';
|
|
18
|
+
|
|
19
|
+
<Skeleton loading={isLoading}>
|
|
20
|
+
<View style={styles.card}>
|
|
21
|
+
<Image style={styles.avatar} />
|
|
22
|
+
<Text style={styles.name}>{user.name}</Text>
|
|
23
|
+
</View>
|
|
24
|
+
</Skeleton>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
While `loading`, Skelo reads the tree and its styles and renders a matching skeleton (circle avatar, text bar). When `loading` is `false`, it renders your real content.
|
|
28
|
+
|
|
29
|
+
## Installation
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npm install react-native-skelo
|
|
33
|
+
npm install react-native-reanimated react-native-linear-gradient
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
That's all you need for the basic (inline) and `styles` usage.
|
|
37
|
+
|
|
38
|
+
### To enable `deep` mode (optional)
|
|
39
|
+
|
|
40
|
+
`deep` mode is opt-in so the core library never bundles a reconciler you don't
|
|
41
|
+
use. Install `react-reconciler` (matching your React version) and import the
|
|
42
|
+
deep entry **once** in your app's entry file:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
# React 19:
|
|
46
|
+
npm install react-reconciler@0.31.0
|
|
47
|
+
# React 18:
|
|
48
|
+
npm install react-reconciler@0.29.2
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
```js
|
|
52
|
+
// index.js (app entry)
|
|
53
|
+
import 'react-native-skelo/deep';
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Without this, `<Skeleton deep>` simply falls back to static parsing (no crash).
|
|
57
|
+
|
|
58
|
+
## Usage
|
|
59
|
+
|
|
60
|
+
### Basic — inline host elements
|
|
61
|
+
|
|
62
|
+
Skelo traverses the `View` / `Text` / `Image` tree you pass and mirrors it:
|
|
63
|
+
|
|
64
|
+
```tsx
|
|
65
|
+
<Skeleton loading={loading} animation="shimmer">
|
|
66
|
+
<View style={styles.row}>
|
|
67
|
+
<Image style={styles.avatar} /> {/* → circle / box */}
|
|
68
|
+
<Text style={styles.title}>Title</Text> {/* → text bar */}
|
|
69
|
+
</View>
|
|
70
|
+
</Skeleton>
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Structure comes from the JSX; dimensions come from each element's `style`.
|
|
74
|
+
|
|
75
|
+
### `deep` — wrap any component (experimental)
|
|
76
|
+
|
|
77
|
+
Don't want to inline? Wrap an opaque component and let Skelo introspect it:
|
|
78
|
+
|
|
79
|
+
```tsx
|
|
80
|
+
import { Skeleton, withSkeleton } from 'react-native-skelo';
|
|
81
|
+
|
|
82
|
+
<Skeleton loading={loading} deep>
|
|
17
83
|
<ProfileScreen />
|
|
18
84
|
</Skeleton>
|
|
19
85
|
|
|
20
|
-
//
|
|
86
|
+
// or as an HOC:
|
|
87
|
+
const Home = withSkeleton(HomeScreen);
|
|
88
|
+
<Home loading={loading} {...props} />
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Requires `react-reconciler` + `import 'react-native-skelo/deep'` (see [Installation](#to-enable-deep-mode-optional)). See also [caveats](#deep-mode-caveats-experimental).
|
|
92
|
+
|
|
93
|
+
### `styles` — generate from a StyleSheet
|
|
94
|
+
|
|
95
|
+
Pass styles directly to get a stack of skeleton shapes (no children needed):
|
|
96
|
+
|
|
97
|
+
```tsx
|
|
98
|
+
<Skeleton loading={loading} styles={styles} excludeStyles={['container']} />
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
A StyleSheet has no hierarchy, so this produces one shape per style that has visual dimensions.
|
|
102
|
+
|
|
103
|
+
### `Skeleton.Ignore` — keep something visible
|
|
104
|
+
|
|
105
|
+
```tsx
|
|
106
|
+
<Skeleton loading={loading}>
|
|
107
|
+
<Skeleton.Ignore>
|
|
108
|
+
<Text style={styles.heading}>Profile</Text> {/* stays real */}
|
|
109
|
+
</Skeleton.Ignore>
|
|
110
|
+
<ProfileBody />
|
|
111
|
+
</Skeleton>
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Custom components — register a plugin
|
|
115
|
+
|
|
116
|
+
```tsx
|
|
117
|
+
import { Skelo } from 'react-native-skelo';
|
|
118
|
+
import { Avatar } from 'my-design-system';
|
|
119
|
+
|
|
120
|
+
Skelo.register({
|
|
121
|
+
name: 'Avatar',
|
|
122
|
+
component: Avatar,
|
|
123
|
+
strategy: (props, { primitives }) => (
|
|
124
|
+
<primitives.Circle size={props.size ?? 40} />
|
|
125
|
+
),
|
|
126
|
+
});
|
|
21
127
|
```
|
|
22
128
|
|
|
23
|
-
##
|
|
129
|
+
## API
|
|
130
|
+
|
|
131
|
+
### `<Skeleton>` props
|
|
132
|
+
|
|
133
|
+
| Prop | Type | Default | Description |
|
|
134
|
+
|---|---|---|---|
|
|
135
|
+
| `loading` | `boolean` | — | Show skeleton (`true`) or real content (`false`) |
|
|
136
|
+
| `animation` | `'shimmer' \| 'pulse' \| 'none'` | `'shimmer'` | Animation style |
|
|
137
|
+
| `duration` | `number` | `1200` | Animation duration (ms) |
|
|
138
|
+
| `baseColor` / `highlightColor` | `string` | theme | Skeleton colors |
|
|
139
|
+
| `borderRadius` | `number` | `4` | Default corner radius |
|
|
140
|
+
| `deep` | `boolean` | `false` | Expand opaque components (experimental) |
|
|
141
|
+
| `styles` | `StyleSheet \| style[]` | — | Generate from styles instead of children |
|
|
142
|
+
| `excludeStyles` | `string[]` | — | Style keys to skip in `styles` mode |
|
|
143
|
+
| `accessibilityLabel` | `string` | `'Loading content'` | Screen-reader label |
|
|
144
|
+
|
|
145
|
+
Also exported: `withSkeleton`, `SkeletonIgnore`, `StyleSkeleton`, the primitives (`SkeletonBox`, `SkeletonText`, `SkeletonImage`, `SkeletonCircle`), and `Skelo` (plugin registry + `Skelo.fromStyles`).
|
|
146
|
+
|
|
147
|
+
## How it works
|
|
148
|
+
|
|
149
|
+
- **Inline mode** — static traversal of the host-element tree (`React.Children` + `StyleSheet.flatten`).
|
|
150
|
+
- **`deep` mode** — a JS-only `react-reconciler` renderer renders the component off-screen to recover its real host tree + styles, then feeds the same skeleton renderer.
|
|
151
|
+
- Anything Skelo can't introspect (a custom component without `deep`, or native content) is measured and shown as a single size-matched block.
|
|
24
152
|
|
|
25
|
-
|
|
153
|
+
## `deep` mode caveats (experimental)
|
|
26
154
|
|
|
27
|
-
|
|
28
|
-
- 🐛 Issues & ideas: https://github.com/shubhanshubb/react-native-skelo/issues
|
|
155
|
+
`deep` renders your component offline to read its structure, which means:
|
|
29
156
|
|
|
30
|
-
|
|
31
|
-
|
|
157
|
+
- **Mount effects run** during introspection — a screen that fetches on mount may fetch twice. Prefer `deep` for presentational trees; register a plugin or provide a manual skeleton for effectful screens.
|
|
158
|
+
- **Renders outside your providers** — components that require navigation/theme/redux context may fail to expand; Skelo catches this and falls back to a measured block.
|
|
159
|
+
- Only the **React host tree** is visible. `WebView`, `MapView`, `Video`, etc. render their content natively (outside React), so they can only become a single sized block.
|
|
32
160
|
|
|
33
|
-
##
|
|
161
|
+
## Requirements
|
|
34
162
|
|
|
35
|
-
-
|
|
36
|
-
-
|
|
37
|
-
-
|
|
38
|
-
- Full TypeScript support
|
|
163
|
+
- React Native (Fabric / New Architecture recommended)
|
|
164
|
+
- `react-native-reanimated` ≥ 3
|
|
165
|
+
- `react-reconciler` (optional, for `deep`) — must match your React version
|
|
39
166
|
|
|
40
|
-
|
|
167
|
+
## License
|
|
41
168
|
|
|
42
|
-
|
|
169
|
+
MIT © [Shubhanshu Barnwal](https://shubhanshubb.dev)
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Skelo = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _registry = require("./core/registry");
|
|
9
|
+
var _StyleSkeleton = require("./core/generator/StyleSkeleton");
|
|
10
|
+
var _defaults = require("./constants/defaults");
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
/**
|
|
13
|
+
* Global Skelo API for plugin management
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```tsx
|
|
17
|
+
* import { Skelo } from 'react-native-skelo';
|
|
18
|
+
* import { Avatar } from 'my-ui-library';
|
|
19
|
+
*
|
|
20
|
+
* Skelo.register({
|
|
21
|
+
* name: 'Avatar',
|
|
22
|
+
* component: Avatar,
|
|
23
|
+
* strategy: (props, { primitives }) => {
|
|
24
|
+
* return <primitives.Circle size={props.size || 40} />;
|
|
25
|
+
* },
|
|
26
|
+
* });
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
const Skelo = exports.Skelo = {
|
|
30
|
+
/**
|
|
31
|
+
* Register a plugin
|
|
32
|
+
*
|
|
33
|
+
* @param plugin - Plugin configuration
|
|
34
|
+
*/
|
|
35
|
+
register(plugin) {
|
|
36
|
+
_registry.registry.register(plugin);
|
|
37
|
+
},
|
|
38
|
+
/**
|
|
39
|
+
* Unregister a plugin
|
|
40
|
+
*
|
|
41
|
+
* @param component - Component type to unregister
|
|
42
|
+
*/
|
|
43
|
+
unregister(component) {
|
|
44
|
+
_registry.registry.unregister(component);
|
|
45
|
+
},
|
|
46
|
+
/**
|
|
47
|
+
* Get plugin for component
|
|
48
|
+
*
|
|
49
|
+
* @param component - Component type
|
|
50
|
+
* @returns Plugin or undefined
|
|
51
|
+
*/
|
|
52
|
+
getPlugin(component) {
|
|
53
|
+
return _registry.registry.getPlugin(component);
|
|
54
|
+
},
|
|
55
|
+
/**
|
|
56
|
+
* Check if plugin exists
|
|
57
|
+
*
|
|
58
|
+
* @param component - Component type
|
|
59
|
+
* @returns True if plugin is registered
|
|
60
|
+
*/
|
|
61
|
+
hasPlugin(component) {
|
|
62
|
+
return _registry.registry.hasPlugin(component);
|
|
63
|
+
},
|
|
64
|
+
/**
|
|
65
|
+
* Get all plugins
|
|
66
|
+
*
|
|
67
|
+
* @returns Array of all registered plugins
|
|
68
|
+
*/
|
|
69
|
+
getAllPlugins() {
|
|
70
|
+
return _registry.registry.getAllPlugins();
|
|
71
|
+
},
|
|
72
|
+
/**
|
|
73
|
+
* Clear all plugins (useful for testing)
|
|
74
|
+
*/
|
|
75
|
+
clearPlugins() {
|
|
76
|
+
_registry.registry.clear();
|
|
77
|
+
},
|
|
78
|
+
/**
|
|
79
|
+
* Generate a skeleton element directly from a set of styles.
|
|
80
|
+
*
|
|
81
|
+
* @param styles - A `StyleSheet.create` object or an array of styles
|
|
82
|
+
* @param config - Optional animation/color overrides
|
|
83
|
+
* @returns A skeleton React element
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```tsx
|
|
87
|
+
* {loading ? Skelo.fromStyles(styles) : <Screen />}
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
fromStyles(styles, config = {}) {
|
|
91
|
+
return /*#__PURE__*/_react.default.createElement(_StyleSkeleton.StyleSkeleton, {
|
|
92
|
+
styles,
|
|
93
|
+
config: {
|
|
94
|
+
..._defaults.DEFAULT_CONFIG,
|
|
95
|
+
...config
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
},
|
|
99
|
+
/**
|
|
100
|
+
* Library version
|
|
101
|
+
*/
|
|
102
|
+
version: '0.1.0'
|
|
103
|
+
};
|
|
104
|
+
//# sourceMappingURL=Skelo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireDefault","require","_registry","_StyleSkeleton","_defaults","e","__esModule","default","Skelo","exports","register","plugin","registry","unregister","component","getPlugin","hasPlugin","getAllPlugins","clearPlugins","clear","fromStyles","styles","config","React","createElement","StyleSkeleton","DEFAULT_CONFIG","version"],"sourceRoot":"../../src","sources":["Skelo.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AAAsD,SAAAD,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEtD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMG,KAAK,GAAAC,OAAA,CAAAD,KAAA,GAAG;EACnB;AACF;AACA;AACA;AACA;EACEE,QAAQA,CAAUC,MAAyB,EAAQ;IACjDC,kBAAQ,CAACF,QAAQ,CAACC,MAAM,CAAC;EAC3B,CAAC;EAED;AACF;AACA;AACA;AACA;EACEE,UAAUA,CAACC,SAAwB,EAAQ;IACzCF,kBAAQ,CAACC,UAAU,CAACC,SAAS,CAAC;EAChC,CAAC;EAED;AACF;AACA;AACA;AACA;AACA;EACEC,SAASA,CAACD,SAAwB,EAA8B;IAC9D,OAAOF,kBAAQ,CAACG,SAAS,CAACD,SAAS,CAAC;EACtC,CAAC;EAED;AACF;AACA;AACA;AACA;AACA;EACEE,SAASA,CAACF,SAAwB,EAAW;IAC3C,OAAOF,kBAAQ,CAACI,SAAS,CAACF,SAAS,CAAC;EACtC,CAAC;EAED;AACF;AACA;AACA;AACA;EACEG,aAAaA,CAAA,EAAqB;IAChC,OAAOL,kBAAQ,CAACK,aAAa,CAAC,CAAC;EACjC,CAAC;EAED;AACF;AACA;EACEC,YAAYA,CAAA,EAAS;IACnBN,kBAAQ,CAACO,KAAK,CAAC,CAAC;EAClB,CAAC;EAED;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,UAAUA,CAACC,MAAkB,EAAEC,MAA+B,GAAG,CAAC,CAAC,EAAgB;IACjF,oBAAOC,cAAK,CAACC,aAAa,CAACC,4BAAa,EAAE;MACxCJ,MAAM;MACNC,MAAM,EAAE;QAAE,GAAGI,wBAAc;QAAE,GAAGJ;MAAO;IACzC,CAAC,CAAC;EACJ,CAAC;EAED;AACF;AACA;EACEK,OAAO,EAAE;AACX,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.AnimationWrapper = AnimationWrapper;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _ShimmerAnimation = require("./ShimmerAnimation");
|
|
10
|
+
var _PulseAnimation = require("./PulseAnimation");
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
/**
|
|
13
|
+
* Animation wrapper that selects the appropriate animation type
|
|
14
|
+
*
|
|
15
|
+
* Provides a unified interface for all skeleton animations:
|
|
16
|
+
* - shimmer: Left-to-right shimmer effect
|
|
17
|
+
* - pulse: Breathing/pulsing opacity
|
|
18
|
+
* - none: Static skeleton (no animation)
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```tsx
|
|
22
|
+
* <AnimationWrapper
|
|
23
|
+
* animation="shimmer"
|
|
24
|
+
* width={200}
|
|
25
|
+
* height={20}
|
|
26
|
+
* />
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
function AnimationWrapper({
|
|
30
|
+
animation = 'shimmer',
|
|
31
|
+
width,
|
|
32
|
+
height,
|
|
33
|
+
baseColor = '#E1E9EE',
|
|
34
|
+
highlightColor = '#F2F8FC',
|
|
35
|
+
duration,
|
|
36
|
+
borderRadius = 4,
|
|
37
|
+
style,
|
|
38
|
+
children
|
|
39
|
+
}) {
|
|
40
|
+
// No animation - static skeleton
|
|
41
|
+
if (animation === 'none') {
|
|
42
|
+
return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
43
|
+
style: [{
|
|
44
|
+
width,
|
|
45
|
+
height,
|
|
46
|
+
borderRadius,
|
|
47
|
+
backgroundColor: baseColor
|
|
48
|
+
}, style]
|
|
49
|
+
}, children);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Shimmer animation
|
|
53
|
+
if (animation === 'shimmer') {
|
|
54
|
+
return /*#__PURE__*/_react.default.createElement(_ShimmerAnimation.ShimmerAnimation, {
|
|
55
|
+
width: width,
|
|
56
|
+
height: height,
|
|
57
|
+
baseColor: baseColor,
|
|
58
|
+
highlightColor: highlightColor,
|
|
59
|
+
duration: duration ?? 1500,
|
|
60
|
+
borderRadius: borderRadius,
|
|
61
|
+
style: style
|
|
62
|
+
}, children);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Pulse animation
|
|
66
|
+
return /*#__PURE__*/_react.default.createElement(_PulseAnimation.PulseAnimation, {
|
|
67
|
+
width: width,
|
|
68
|
+
height: height,
|
|
69
|
+
baseColor: baseColor,
|
|
70
|
+
highlightColor: highlightColor,
|
|
71
|
+
duration: duration ?? 1000,
|
|
72
|
+
borderRadius: borderRadius,
|
|
73
|
+
style: style
|
|
74
|
+
}, children);
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=AnimationWrapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireDefault","require","_reactNative","_ShimmerAnimation","_PulseAnimation","e","__esModule","default","AnimationWrapper","animation","width","height","baseColor","highlightColor","duration","borderRadius","style","children","createElement","View","backgroundColor","ShimmerAnimation","PulseAnimation"],"sourceRoot":"../../../src","sources":["animations/AnimationWrapper.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AAAkD,SAAAD,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAwDlD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASG,gBAAgBA,CAAC;EAC/BC,SAAS,GAAG,SAAS;EACrBC,KAAK;EACLC,MAAM;EACNC,SAAS,GAAG,SAAS;EACrBC,cAAc,GAAG,SAAS;EAC1BC,QAAQ;EACRC,YAAY,GAAG,CAAC;EAChBC,KAAK;EACLC;AACqB,CAAC,EAAE;EACxB;EACA,IAAIR,SAAS,KAAK,MAAM,EAAE;IACxB,oBACEV,MAAA,CAAAQ,OAAA,CAAAW,aAAA,CAAChB,YAAA,CAAAiB,IAAI;MACHH,KAAK,EAAE,CACL;QACEN,KAAK;QACLC,MAAM;QACNI,YAAY;QACZK,eAAe,EAAER;MACnB,CAAC,EACDI,KAAK;IACL,GAEDC,QACG,CAAC;EAEX;;EAEA;EACA,IAAIR,SAAS,KAAK,SAAS,EAAE;IAC3B,oBACEV,MAAA,CAAAQ,OAAA,CAAAW,aAAA,CAACf,iBAAA,CAAAkB,gBAAgB;MACfX,KAAK,EAAEA,KAAM;MACbC,MAAM,EAAEA,MAAO;MACfC,SAAS,EAAEA,SAAU;MACrBC,cAAc,EAAEA,cAAe;MAC/BC,QAAQ,EAAEA,QAAQ,IAAI,IAAK;MAC3BC,YAAY,EAAEA,YAAa;MAC3BC,KAAK,EAAEA;IAAM,GAEZC,QACe,CAAC;EAEvB;;EAEA;EACA,oBACElB,MAAA,CAAAQ,OAAA,CAAAW,aAAA,CAACd,eAAA,CAAAkB,cAAc;IACbZ,KAAK,EAAEA,KAAM;IACbC,MAAM,EAAEA,MAAO;IACfC,SAAS,EAAEA,SAAU;IACrBC,cAAc,EAAEA,cAAe;IAC/BC,QAAQ,EAAEA,QAAQ,IAAI,IAAK;IAC3BC,YAAY,EAAEA,YAAa;IAC3BC,KAAK,EAAEA;EAAM,GAEZC,QACa,CAAC;AAErB","ignoreList":[]}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.PulseAnimation = PulseAnimation;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
|
|
10
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
11
|
+
/**
|
|
12
|
+
* Pulse animation component using Reanimated 3
|
|
13
|
+
*
|
|
14
|
+
* Creates a subtle breathing/pulsing effect using:
|
|
15
|
+
* - Shared values for performance
|
|
16
|
+
* - Worklets for 60 FPS on UI thread
|
|
17
|
+
* - Opacity animation for pulse effect
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* <PulseAnimation
|
|
22
|
+
* width={200}
|
|
23
|
+
* height={20}
|
|
24
|
+
* borderRadius={4}
|
|
25
|
+
* />
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
function PulseAnimation({
|
|
29
|
+
width,
|
|
30
|
+
height,
|
|
31
|
+
baseColor = '#E1E9EE',
|
|
32
|
+
duration = 1000,
|
|
33
|
+
borderRadius = 4,
|
|
34
|
+
style,
|
|
35
|
+
children
|
|
36
|
+
}) {
|
|
37
|
+
// Shared value for opacity (0 to 1)
|
|
38
|
+
const opacity = (0, _reactNativeReanimated.useSharedValue)(1);
|
|
39
|
+
(0, _react.useEffect)(() => {
|
|
40
|
+
// Start infinite pulse animation
|
|
41
|
+
// Sequence: fade out -> fade in
|
|
42
|
+
opacity.value = (0, _reactNativeReanimated.withRepeat)((0, _reactNativeReanimated.withSequence)((0, _reactNativeReanimated.withTiming)(0.5, {
|
|
43
|
+
duration: duration / 2,
|
|
44
|
+
easing: _reactNativeReanimated.Easing.inOut(_reactNativeReanimated.Easing.ease)
|
|
45
|
+
}), (0, _reactNativeReanimated.withTiming)(1, {
|
|
46
|
+
duration: duration / 2,
|
|
47
|
+
easing: _reactNativeReanimated.Easing.inOut(_reactNativeReanimated.Easing.ease)
|
|
48
|
+
})), -1,
|
|
49
|
+
// Infinite repeat
|
|
50
|
+
false // Don't reverse
|
|
51
|
+
);
|
|
52
|
+
}, [duration, opacity]);
|
|
53
|
+
|
|
54
|
+
// Animated style for pulse effect
|
|
55
|
+
const animatedStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => {
|
|
56
|
+
'worklet';
|
|
57
|
+
|
|
58
|
+
return {
|
|
59
|
+
opacity: opacity.value
|
|
60
|
+
};
|
|
61
|
+
}, []);
|
|
62
|
+
return /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.View, {
|
|
63
|
+
style: [styles.container, {
|
|
64
|
+
width,
|
|
65
|
+
height,
|
|
66
|
+
borderRadius,
|
|
67
|
+
backgroundColor: baseColor
|
|
68
|
+
}, animatedStyle, style]
|
|
69
|
+
}, children);
|
|
70
|
+
}
|
|
71
|
+
const styles = _reactNative.StyleSheet.create({
|
|
72
|
+
container: {
|
|
73
|
+
overflow: 'hidden'
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
//# sourceMappingURL=PulseAnimation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeReanimated","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","PulseAnimation","width","height","baseColor","duration","borderRadius","style","children","opacity","useSharedValue","useEffect","value","withRepeat","withSequence","withTiming","easing","Easing","inOut","ease","animatedStyle","useAnimatedStyle","createElement","View","styles","container","backgroundColor","StyleSheet","create","overflow"],"sourceRoot":"../../../src","sources":["animations/PulseAnimation.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,sBAAA,GAAAH,uBAAA,CAAAC,OAAA;AAOiC,SAAAD,wBAAAI,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAN,uBAAA,YAAAA,CAAAI,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAA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AG,CAAC;MACtBW,MAAM,EAAEC,6BAAM,CAACC,KAAK,CAACD,6BAAM,CAACE,IAAI;IAClC,CAAC,CACH,CAAC,EACD,CAAC,CAAC;IAAE;IACJ,KAAK,CAAC;IACR,CAAC;EACH,CAAC,EAAE,CAACd,QAAQ,EAAEI,OAAO,CAAC,CAAC;;EAEvB;EACA,MAAMW,aAAa,GAAG,IAAAC,uCAAgB,EAAC,MAAM;IAC3C,SAAS;;IAET,OAAO;MACLZ,OAAO,EAAEA,OAAO,CAACG;IACnB,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EAEN,oBACEnC,MAAA,CAAAe,OAAA,CAAA8B,aAAA,CAACzC,sBAAA,CAAAW,OAAQ,CAAC+B,IAAI;IACZhB,KAAK,EAAE,CACLiB,MAAM,CAACC,SAAS,EAChB;MACEvB,KAAK;MACLC,MAAM;MACNG,YAAY;MACZoB,eAAe,EAAEtB;IACnB,CAAC,EACDgB,aAAa,EACbb,KAAK;EACL,GAEDC,QACY,CAAC;AAEpB;AAEA,MAAMgB,MAAM,GAAGG,uBAAU,CAACC,MAAM,CAAC;EAC/BH,SAAS,EAAE;IACTI,QAAQ,EAAE;EACZ;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ShimmerAnimation = ShimmerAnimation;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
|
|
10
|
+
var _reactNativeLinearGradient = require("react-native-linear-gradient");
|
|
11
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
12
|
+
/**
|
|
13
|
+
* Shimmer animation component using Reanimated 3
|
|
14
|
+
*
|
|
15
|
+
* Creates a smooth left-to-right shimmer effect using:
|
|
16
|
+
* - Shared values for performance
|
|
17
|
+
* - Worklets for 60 FPS on UI thread
|
|
18
|
+
* - Linear gradient for shimmer effect
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```tsx
|
|
22
|
+
* <ShimmerAnimation
|
|
23
|
+
* width={200}
|
|
24
|
+
* height={20}
|
|
25
|
+
* borderRadius={4}
|
|
26
|
+
* />
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
function ShimmerAnimation({
|
|
30
|
+
width,
|
|
31
|
+
height,
|
|
32
|
+
baseColor = '#E1E9EE',
|
|
33
|
+
highlightColor = '#F2F8FC',
|
|
34
|
+
duration = 1500,
|
|
35
|
+
borderRadius = 4,
|
|
36
|
+
style,
|
|
37
|
+
children
|
|
38
|
+
}) {
|
|
39
|
+
// Shared value for animation progress (0 to 1)
|
|
40
|
+
const progress = (0, _reactNativeReanimated.useSharedValue)(0);
|
|
41
|
+
(0, _react.useEffect)(() => {
|
|
42
|
+
// Start infinite shimmer animation
|
|
43
|
+
progress.value = (0, _reactNativeReanimated.withRepeat)((0, _reactNativeReanimated.withTiming)(1, {
|
|
44
|
+
duration,
|
|
45
|
+
easing: _reactNativeReanimated.Easing.linear
|
|
46
|
+
}), -1,
|
|
47
|
+
// Infinite repeat
|
|
48
|
+
false // Don't reverse
|
|
49
|
+
);
|
|
50
|
+
}, [duration, progress]);
|
|
51
|
+
|
|
52
|
+
// Animated style for shimmer overlay
|
|
53
|
+
const animatedStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => {
|
|
54
|
+
'worklet';
|
|
55
|
+
|
|
56
|
+
// Calculate shimmer position
|
|
57
|
+
// Interpolate from -100% to 100% to create left-to-right sweep
|
|
58
|
+
const translateX = (0, _reactNativeReanimated.interpolate)(progress.value, [0, 1], [-1, 1]);
|
|
59
|
+
return {
|
|
60
|
+
transform: [{
|
|
61
|
+
translateX: translateX * (typeof width === 'number' ? width : 200)
|
|
62
|
+
}]
|
|
63
|
+
};
|
|
64
|
+
}, [width]);
|
|
65
|
+
return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
|
|
66
|
+
style: [styles.container, {
|
|
67
|
+
width,
|
|
68
|
+
height,
|
|
69
|
+
borderRadius,
|
|
70
|
+
backgroundColor: baseColor
|
|
71
|
+
}, style]
|
|
72
|
+
}, /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.View, {
|
|
73
|
+
style: [_reactNative.StyleSheet.absoluteFill, {
|
|
74
|
+
overflow: 'hidden',
|
|
75
|
+
borderRadius
|
|
76
|
+
}]
|
|
77
|
+
}, /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.View, {
|
|
78
|
+
style: [styles.shimmer, {
|
|
79
|
+
width: typeof width === 'number' ? width : '100%',
|
|
80
|
+
height: '100%'
|
|
81
|
+
}, animatedStyle]
|
|
82
|
+
}, /*#__PURE__*/_react.default.createElement(_reactNativeLinearGradient.LinearGradient, {
|
|
83
|
+
colors: [baseColor, highlightColor, highlightColor, baseColor],
|
|
84
|
+
start: {
|
|
85
|
+
x: 0,
|
|
86
|
+
y: 0
|
|
87
|
+
},
|
|
88
|
+
end: {
|
|
89
|
+
x: 1,
|
|
90
|
+
y: 0
|
|
91
|
+
},
|
|
92
|
+
style: _reactNative.StyleSheet.absoluteFill
|
|
93
|
+
}))), children);
|
|
94
|
+
}
|
|
95
|
+
const styles = _reactNative.StyleSheet.create({
|
|
96
|
+
container: {
|
|
97
|
+
overflow: 'hidden'
|
|
98
|
+
},
|
|
99
|
+
shimmer: {
|
|
100
|
+
position: 'absolute'
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
//# sourceMappingURL=ShimmerAnimation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeReanimated","_reactNativeLinearGradient","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ShimmerAnimation","width","height","baseColor","highlightColor","duration","borderRadius","style","children","progress","useSharedValue","useEffect","value","withRepeat","withTiming","easing","Easing","linear","animatedStyle","useAnimatedStyle","translateX","interpolate","transform","createElement","View","styles","container","backgroundColor","StyleSheet","absoluteFill","overflow","shimmer","LinearGradient","colors","start","x","y","end","create","position"],"sourceRoot":"../../../src","sources":["animations/ShimmerAnimation.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,sBAAA,GAAAH,uBAAA,CAAAC,OAAA;AAQA,IAAAG,0BAAA,GAAAH,OAAA;AAA8D,SAAAD,wBAAAK,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAP,uBAAA,YAAAA,CAAAK,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,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;IAAE,CAAE;IACpB7B,KAAK,EAAEqB,uBAAU,CAACC;EAAa,CAChC,CACY,CACF,CAAC,EAGfrB,QACG,CAAC;AAEX;AAEA,MAAMiB,MAAM,GAAGG,uBAAU,CAACU,MAAM,CAAC;EAC/BZ,SAAS,EAAE;IACTI,QAAQ,EAAE;EACZ,CAAC;EACDC,OAAO,EAAE;IACPQ,QAAQ,EAAE;EACZ;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "AnimationWrapper", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _AnimationWrapper.AnimationWrapper;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "PulseAnimation", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _PulseAnimation.PulseAnimation;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "ShimmerAnimation", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _ShimmerAnimation.ShimmerAnimation;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
var _ShimmerAnimation = require("./ShimmerAnimation");
|
|
25
|
+
var _PulseAnimation = require("./PulseAnimation");
|
|
26
|
+
var _AnimationWrapper = require("./AnimationWrapper");
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_ShimmerAnimation","require","_PulseAnimation","_AnimationWrapper"],"sourceRoot":"../../../src","sources":["animations/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA","ignoreList":[]}
|