react-native-skelo 0.0.1 → 0.0.3
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 +149 -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 +52 -0
- package/lib/commonjs/animations/PulseAnimation.js.map +1 -0
- package/lib/commonjs/animations/ShimmerAnimation.js +73 -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 +45 -0
- package/lib/module/animations/PulseAnimation.js.map +1 -0
- package/lib/module/animations/ShimmerAnimation.js +66 -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 +15 -0
- package/lib/typescript/animations/PulseAnimation.d.ts.map +1 -0
- package/lib/typescript/animations/ShimmerAnimation.d.ts +15 -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 +169 -11
- package/src/Skelo.ts +103 -0
- package/src/animations/AnimationWrapper.tsx +139 -0
- package/src/animations/PulseAnimation.tsx +76 -0
- package/src/animations/ShimmerAnimation.tsx +101 -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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styleUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/styleUtils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,GAAG,GAAG,aAAa,CAetD;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,aAAa,GAAG;IACvD,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,MAAM,CAAC,EAAE,cAAc,CAAC;CACzB,CAKA;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAE7D;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAEhD;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAExD"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,52 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-skelo",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.0.3",
|
|
4
|
+
"description": "Automatic skeleton loading for React Native. Write your UI once, Skelo builds the loading state automatically.",
|
|
5
|
+
"main": "lib/commonjs/index.js",
|
|
6
|
+
"module": "lib/module/index.js",
|
|
7
|
+
"types": "lib/typescript/index.d.ts",
|
|
8
|
+
"react-native": "src/index.ts",
|
|
9
|
+
"source": "src/index.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./lib/typescript/index.d.ts",
|
|
13
|
+
"react-native": "./src/index.ts",
|
|
14
|
+
"import": "./lib/module/index.js",
|
|
15
|
+
"require": "./lib/commonjs/index.js",
|
|
16
|
+
"default": "./lib/commonjs/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./deep": {
|
|
19
|
+
"types": "./lib/typescript/deep.d.ts",
|
|
20
|
+
"react-native": "./src/deep.ts",
|
|
21
|
+
"import": "./lib/module/deep.js",
|
|
22
|
+
"require": "./lib/commonjs/deep.js",
|
|
23
|
+
"default": "./lib/commonjs/deep.js"
|
|
24
|
+
},
|
|
25
|
+
"./package.json": "./package.json"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"src",
|
|
29
|
+
"lib",
|
|
30
|
+
"!**/__tests__",
|
|
31
|
+
"!**/__mocks__"
|
|
32
|
+
],
|
|
33
|
+
"scripts": {
|
|
34
|
+
"test": "jest",
|
|
35
|
+
"test:watch": "jest --watch",
|
|
36
|
+
"test:coverage": "jest --coverage",
|
|
37
|
+
"typecheck": "tsc --noEmit",
|
|
38
|
+
"build": "bob build",
|
|
39
|
+
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
40
|
+
"lint:fix": "eslint \"**/*.{js,ts,tsx}\" --fix",
|
|
41
|
+
"format": "prettier --write \"**/*.{js,ts,tsx,json,md}\"",
|
|
42
|
+
"prepare": "bob build",
|
|
43
|
+
"prepublishOnly": "bob build",
|
|
44
|
+
"publish:npm": "npm publish --access public",
|
|
45
|
+
"publish:alpha": "npm publish --tag alpha --access public",
|
|
46
|
+
"publish:git": "git push origin HEAD --tags",
|
|
47
|
+
"release": "npm run build && npm publish --access public && git push origin HEAD --tags",
|
|
48
|
+
"clean": "del-cli lib"
|
|
49
|
+
},
|
|
5
50
|
"keywords": [
|
|
6
51
|
"react-native",
|
|
7
52
|
"skeleton",
|
|
@@ -11,23 +56,136 @@
|
|
|
11
56
|
"skeleton-screen",
|
|
12
57
|
"skeleton-loader",
|
|
13
58
|
"loading-state",
|
|
14
|
-
"reanimated"
|
|
59
|
+
"reanimated",
|
|
60
|
+
"fabric",
|
|
61
|
+
"automatic",
|
|
62
|
+
"zero-config"
|
|
15
63
|
],
|
|
16
|
-
"homepage": "https://github.com/shubhanshubb/react-native-skelo#readme",
|
|
17
|
-
"bugs": {
|
|
18
|
-
"url": "https://github.com/shubhanshubb/react-native-skelo/issues"
|
|
19
|
-
},
|
|
20
64
|
"repository": {
|
|
21
65
|
"type": "git",
|
|
22
66
|
"url": "git+https://github.com/shubhanshubb/react-native-skelo.git"
|
|
23
67
|
},
|
|
24
|
-
"license": "MIT",
|
|
25
68
|
"author": "Shubhanshu Barnwal <connect@shubhanshubb.dev> (https://shubhanshubb.dev)",
|
|
26
|
-
"
|
|
27
|
-
|
|
69
|
+
"maintainers": [
|
|
70
|
+
{
|
|
71
|
+
"name": "Shubhanshu Barnwal",
|
|
72
|
+
"email": "connect@shubhanshubb.dev",
|
|
73
|
+
"url": "https://shubhanshubb.dev"
|
|
74
|
+
}
|
|
28
75
|
],
|
|
76
|
+
"license": "MIT",
|
|
77
|
+
"bugs": {
|
|
78
|
+
"url": "https://github.com/shubhanshubb/react-native-skelo/issues"
|
|
79
|
+
},
|
|
80
|
+
"homepage": "https://github.com/shubhanshubb/react-native-skelo#readme",
|
|
81
|
+
"funding": {
|
|
82
|
+
"type": "individual",
|
|
83
|
+
"url": "https://buymeacoffee.com/shubhanshubb"
|
|
84
|
+
},
|
|
29
85
|
"publishConfig": {
|
|
30
|
-
"access": "public",
|
|
31
86
|
"registry": "https://registry.npmjs.org/"
|
|
87
|
+
},
|
|
88
|
+
"peerDependencies": {
|
|
89
|
+
"react": "*",
|
|
90
|
+
"react-native": "*",
|
|
91
|
+
"react-native-reanimated": ">=3.0.0",
|
|
92
|
+
"react-reconciler": ">=0.29.0"
|
|
93
|
+
},
|
|
94
|
+
"peerDependenciesMeta": {
|
|
95
|
+
"react-reconciler": {
|
|
96
|
+
"optional": true
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
"devDependencies": {
|
|
100
|
+
"@commitlint/config-conventional": "^18.4.3",
|
|
101
|
+
"@react-native/eslint-config": "^0.73.1",
|
|
102
|
+
"@release-it/conventional-changelog": "^8.0.1",
|
|
103
|
+
"@testing-library/react-native": "^12.4.2",
|
|
104
|
+
"@types/jest": "^29.5.11",
|
|
105
|
+
"@types/react": "^18.2.45",
|
|
106
|
+
"del-cli": "^5.1.0",
|
|
107
|
+
"eslint": "^8.56.0",
|
|
108
|
+
"eslint-config-prettier": "^9.1.0",
|
|
109
|
+
"eslint-plugin-prettier": "^5.1.2",
|
|
110
|
+
"jest": "^29.7.0",
|
|
111
|
+
"prettier": "^3.1.1",
|
|
112
|
+
"react": "18.2.0",
|
|
113
|
+
"react-native": "0.73.1",
|
|
114
|
+
"react-native-builder-bob": "^0.23.2",
|
|
115
|
+
"react-native-reanimated": "^3.6.1",
|
|
116
|
+
"react-reconciler": "^0.29.2",
|
|
117
|
+
"react-test-renderer": "18.2.0",
|
|
118
|
+
"release-it": "^17.0.1",
|
|
119
|
+
"typescript": "^5.3.3"
|
|
120
|
+
},
|
|
121
|
+
"jest": {
|
|
122
|
+
"preset": "react-native",
|
|
123
|
+
"setupFiles": [
|
|
124
|
+
"<rootDir>/jest.setup.js"
|
|
125
|
+
],
|
|
126
|
+
"modulePathIgnorePatterns": [
|
|
127
|
+
"<rootDir>/lib/"
|
|
128
|
+
],
|
|
129
|
+
"transformIgnorePatterns": [
|
|
130
|
+
"node_modules/(?!(@react-native|react-native|react-native-reanimated)/)"
|
|
131
|
+
],
|
|
132
|
+
"collectCoverageFrom": [
|
|
133
|
+
"src/**/*.{ts,tsx}",
|
|
134
|
+
"!src/**/*.d.ts",
|
|
135
|
+
"!src/**/index.ts",
|
|
136
|
+
"!src/types/**"
|
|
137
|
+
],
|
|
138
|
+
"coverageThreshold": {
|
|
139
|
+
"global": {
|
|
140
|
+
"branches": 80,
|
|
141
|
+
"functions": 80,
|
|
142
|
+
"lines": 80,
|
|
143
|
+
"statements": 80
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
"commitlint": {
|
|
148
|
+
"extends": [
|
|
149
|
+
"@commitlint/config-conventional"
|
|
150
|
+
]
|
|
151
|
+
},
|
|
152
|
+
"release-it": {
|
|
153
|
+
"git": {
|
|
154
|
+
"commitMessage": "chore: release ${version}",
|
|
155
|
+
"tagName": "v${version}"
|
|
156
|
+
},
|
|
157
|
+
"npm": {
|
|
158
|
+
"publish": true
|
|
159
|
+
},
|
|
160
|
+
"github": {
|
|
161
|
+
"release": true
|
|
162
|
+
},
|
|
163
|
+
"plugins": {
|
|
164
|
+
"@release-it/conventional-changelog": {
|
|
165
|
+
"preset": "angular"
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
"react-native-builder-bob": {
|
|
170
|
+
"source": "src",
|
|
171
|
+
"output": "lib",
|
|
172
|
+
"targets": [
|
|
173
|
+
"commonjs",
|
|
174
|
+
"module",
|
|
175
|
+
[
|
|
176
|
+
"typescript",
|
|
177
|
+
{
|
|
178
|
+
"project": "tsconfig.build.json"
|
|
179
|
+
}
|
|
180
|
+
]
|
|
181
|
+
]
|
|
182
|
+
},
|
|
183
|
+
"prettier": {
|
|
184
|
+
"singleQuote": true,
|
|
185
|
+
"trailingComma": "es5",
|
|
186
|
+
"tabWidth": 2,
|
|
187
|
+
"semi": true,
|
|
188
|
+
"printWidth": 100,
|
|
189
|
+
"arrowParens": "avoid"
|
|
32
190
|
}
|
|
33
191
|
}
|
package/src/Skelo.ts
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ComponentType, ReactElement } from 'react';
|
|
3
|
+
import type { SkeletonConfig, SkeletonPlugin } from './types';
|
|
4
|
+
import { registry } from './core/registry';
|
|
5
|
+
import { StyleSkeleton, type StyleInput } from './core/generator/StyleSkeleton';
|
|
6
|
+
import { DEFAULT_CONFIG } from './constants/defaults';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Global Skelo API for plugin management
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* import { Skelo } from 'react-native-skelo';
|
|
14
|
+
* import { Avatar } from 'my-ui-library';
|
|
15
|
+
*
|
|
16
|
+
* Skelo.register({
|
|
17
|
+
* name: 'Avatar',
|
|
18
|
+
* component: Avatar,
|
|
19
|
+
* strategy: (props, { primitives }) => {
|
|
20
|
+
* return <primitives.Circle size={props.size || 40} />;
|
|
21
|
+
* },
|
|
22
|
+
* });
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export const Skelo = {
|
|
26
|
+
/**
|
|
27
|
+
* Register a plugin
|
|
28
|
+
*
|
|
29
|
+
* @param plugin - Plugin configuration
|
|
30
|
+
*/
|
|
31
|
+
register<P = any>(plugin: SkeletonPlugin<P>): void {
|
|
32
|
+
registry.register(plugin);
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Unregister a plugin
|
|
37
|
+
*
|
|
38
|
+
* @param component - Component type to unregister
|
|
39
|
+
*/
|
|
40
|
+
unregister(component: ComponentType): void {
|
|
41
|
+
registry.unregister(component);
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Get plugin for component
|
|
46
|
+
*
|
|
47
|
+
* @param component - Component type
|
|
48
|
+
* @returns Plugin or undefined
|
|
49
|
+
*/
|
|
50
|
+
getPlugin(component: ComponentType): SkeletonPlugin | undefined {
|
|
51
|
+
return registry.getPlugin(component);
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Check if plugin exists
|
|
56
|
+
*
|
|
57
|
+
* @param component - Component type
|
|
58
|
+
* @returns True if plugin is registered
|
|
59
|
+
*/
|
|
60
|
+
hasPlugin(component: ComponentType): boolean {
|
|
61
|
+
return registry.hasPlugin(component);
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Get all plugins
|
|
66
|
+
*
|
|
67
|
+
* @returns Array of all registered plugins
|
|
68
|
+
*/
|
|
69
|
+
getAllPlugins(): SkeletonPlugin[] {
|
|
70
|
+
return registry.getAllPlugins();
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Clear all plugins (useful for testing)
|
|
75
|
+
*/
|
|
76
|
+
clearPlugins(): void {
|
|
77
|
+
registry.clear();
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Generate a skeleton element directly from a set of styles.
|
|
82
|
+
*
|
|
83
|
+
* @param styles - A `StyleSheet.create` object or an array of styles
|
|
84
|
+
* @param config - Optional animation/color overrides
|
|
85
|
+
* @returns A skeleton React element
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```tsx
|
|
89
|
+
* {loading ? Skelo.fromStyles(styles) : <Screen />}
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
fromStyles(styles: StyleInput, config: Partial<SkeletonConfig> = {}): ReactElement {
|
|
93
|
+
return React.createElement(StyleSkeleton, {
|
|
94
|
+
styles,
|
|
95
|
+
config: { ...DEFAULT_CONFIG, ...config },
|
|
96
|
+
});
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Library version
|
|
101
|
+
*/
|
|
102
|
+
version: '0.1.0',
|
|
103
|
+
};
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { DimensionValue, StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
import { View } from 'react-native';
|
|
4
|
+
import { ShimmerAnimation } from './ShimmerAnimation';
|
|
5
|
+
import { PulseAnimation } from './PulseAnimation';
|
|
6
|
+
|
|
7
|
+
export type AnimationType = 'shimmer' | 'pulse' | 'none';
|
|
8
|
+
|
|
9
|
+
interface AnimationWrapperProps {
|
|
10
|
+
/**
|
|
11
|
+
* Type of animation to use
|
|
12
|
+
* @default 'shimmer'
|
|
13
|
+
*/
|
|
14
|
+
animation?: AnimationType;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Width of the animated element
|
|
18
|
+
*/
|
|
19
|
+
width?: DimensionValue;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Height of the animated element
|
|
23
|
+
*/
|
|
24
|
+
height?: DimensionValue;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Base color of the skeleton
|
|
28
|
+
* @default '#E1E9EE'
|
|
29
|
+
*/
|
|
30
|
+
baseColor?: string;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Highlight color for animation
|
|
34
|
+
* @default '#F2F8FC'
|
|
35
|
+
*/
|
|
36
|
+
highlightColor?: string;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Animation duration in milliseconds
|
|
40
|
+
* @default 1500 for shimmer, 1000 for pulse
|
|
41
|
+
*/
|
|
42
|
+
duration?: number;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Border radius
|
|
46
|
+
* @default 4
|
|
47
|
+
*/
|
|
48
|
+
borderRadius?: number;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Additional styles
|
|
52
|
+
*/
|
|
53
|
+
style?: StyleProp<ViewStyle>;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Child content
|
|
57
|
+
*/
|
|
58
|
+
children?: React.ReactNode;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Animation wrapper that selects the appropriate animation type
|
|
63
|
+
*
|
|
64
|
+
* Provides a unified interface for all skeleton animations:
|
|
65
|
+
* - shimmer: Left-to-right shimmer effect
|
|
66
|
+
* - pulse: Breathing/pulsing opacity
|
|
67
|
+
* - none: Static skeleton (no animation)
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```tsx
|
|
71
|
+
* <AnimationWrapper
|
|
72
|
+
* animation="shimmer"
|
|
73
|
+
* width={200}
|
|
74
|
+
* height={20}
|
|
75
|
+
* />
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
export function AnimationWrapper({
|
|
79
|
+
animation = 'shimmer',
|
|
80
|
+
width,
|
|
81
|
+
height,
|
|
82
|
+
baseColor = '#E1E9EE',
|
|
83
|
+
highlightColor = '#F2F8FC',
|
|
84
|
+
duration,
|
|
85
|
+
borderRadius = 4,
|
|
86
|
+
style,
|
|
87
|
+
children,
|
|
88
|
+
}: AnimationWrapperProps) {
|
|
89
|
+
// No animation - static skeleton
|
|
90
|
+
if (animation === 'none') {
|
|
91
|
+
return (
|
|
92
|
+
<View
|
|
93
|
+
style={[
|
|
94
|
+
{
|
|
95
|
+
width,
|
|
96
|
+
height,
|
|
97
|
+
borderRadius,
|
|
98
|
+
backgroundColor: baseColor,
|
|
99
|
+
},
|
|
100
|
+
style,
|
|
101
|
+
]}
|
|
102
|
+
>
|
|
103
|
+
{children}
|
|
104
|
+
</View>
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Shimmer animation
|
|
109
|
+
if (animation === 'shimmer') {
|
|
110
|
+
return (
|
|
111
|
+
<ShimmerAnimation
|
|
112
|
+
width={width}
|
|
113
|
+
height={height}
|
|
114
|
+
baseColor={baseColor}
|
|
115
|
+
highlightColor={highlightColor}
|
|
116
|
+
duration={duration ?? 1500}
|
|
117
|
+
borderRadius={borderRadius}
|
|
118
|
+
style={style}
|
|
119
|
+
>
|
|
120
|
+
{children}
|
|
121
|
+
</ShimmerAnimation>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Pulse animation
|
|
126
|
+
return (
|
|
127
|
+
<PulseAnimation
|
|
128
|
+
width={width}
|
|
129
|
+
height={height}
|
|
130
|
+
baseColor={baseColor}
|
|
131
|
+
highlightColor={highlightColor}
|
|
132
|
+
duration={duration ?? 1000}
|
|
133
|
+
borderRadius={borderRadius}
|
|
134
|
+
style={style}
|
|
135
|
+
>
|
|
136
|
+
{children}
|
|
137
|
+
</PulseAnimation>
|
|
138
|
+
);
|
|
139
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
import type { DimensionValue, StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
import { StyleSheet } from 'react-native';
|
|
4
|
+
import Animated, {
|
|
5
|
+
useSharedValue,
|
|
6
|
+
useAnimatedStyle,
|
|
7
|
+
withRepeat,
|
|
8
|
+
withSequence,
|
|
9
|
+
withTiming,
|
|
10
|
+
Easing,
|
|
11
|
+
} from 'react-native-reanimated';
|
|
12
|
+
|
|
13
|
+
interface PulseProps {
|
|
14
|
+
width?: DimensionValue;
|
|
15
|
+
height?: DimensionValue;
|
|
16
|
+
baseColor?: string;
|
|
17
|
+
highlightColor?: string;
|
|
18
|
+
duration?: number;
|
|
19
|
+
borderRadius?: number;
|
|
20
|
+
style?: StyleProp<ViewStyle>;
|
|
21
|
+
children?: React.ReactNode;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Breathing opacity loop on the UI thread with Reanimated.
|
|
25
|
+
export function PulseAnimation({
|
|
26
|
+
width,
|
|
27
|
+
height,
|
|
28
|
+
baseColor = '#E1E9EE',
|
|
29
|
+
duration = 1000,
|
|
30
|
+
borderRadius = 4,
|
|
31
|
+
style,
|
|
32
|
+
children,
|
|
33
|
+
}: PulseProps) {
|
|
34
|
+
const opacity = useSharedValue(1);
|
|
35
|
+
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
opacity.value = withRepeat(
|
|
38
|
+
withSequence(
|
|
39
|
+
withTiming(0.5, {
|
|
40
|
+
duration: duration / 2,
|
|
41
|
+
easing: Easing.inOut(Easing.ease),
|
|
42
|
+
}),
|
|
43
|
+
withTiming(1, {
|
|
44
|
+
duration: duration / 2,
|
|
45
|
+
easing: Easing.inOut(Easing.ease),
|
|
46
|
+
})
|
|
47
|
+
),
|
|
48
|
+
-1,
|
|
49
|
+
false
|
|
50
|
+
);
|
|
51
|
+
}, [duration, opacity]);
|
|
52
|
+
|
|
53
|
+
const animatedStyle = useAnimatedStyle(() => {
|
|
54
|
+
'worklet';
|
|
55
|
+
return { opacity: opacity.value };
|
|
56
|
+
}, []);
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<Animated.View
|
|
60
|
+
style={[
|
|
61
|
+
styles.container,
|
|
62
|
+
{ width, height, borderRadius, backgroundColor: baseColor },
|
|
63
|
+
animatedStyle,
|
|
64
|
+
style,
|
|
65
|
+
]}
|
|
66
|
+
>
|
|
67
|
+
{children}
|
|
68
|
+
</Animated.View>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const styles = StyleSheet.create({
|
|
73
|
+
container: {
|
|
74
|
+
overflow: 'hidden',
|
|
75
|
+
},
|
|
76
|
+
});
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import type {
|
|
3
|
+
DimensionValue,
|
|
4
|
+
LayoutChangeEvent,
|
|
5
|
+
StyleProp,
|
|
6
|
+
ViewStyle,
|
|
7
|
+
} from 'react-native';
|
|
8
|
+
import { StyleSheet, View } from 'react-native';
|
|
9
|
+
import Animated, {
|
|
10
|
+
useSharedValue,
|
|
11
|
+
useAnimatedStyle,
|
|
12
|
+
withRepeat,
|
|
13
|
+
withTiming,
|
|
14
|
+
interpolate,
|
|
15
|
+
Easing,
|
|
16
|
+
} from 'react-native-reanimated';
|
|
17
|
+
|
|
18
|
+
interface ShimmerProps {
|
|
19
|
+
width?: DimensionValue;
|
|
20
|
+
height?: DimensionValue;
|
|
21
|
+
baseColor?: string;
|
|
22
|
+
highlightColor?: string;
|
|
23
|
+
duration?: number;
|
|
24
|
+
borderRadius?: number;
|
|
25
|
+
style?: StyleProp<ViewStyle>;
|
|
26
|
+
children?: React.ReactNode;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Shimmer with no gradient library: the sweeping overlay uses React Native's
|
|
30
|
+
// built-in `experimental_backgroundImage` CSS gradient (New Architecture),
|
|
31
|
+
// animated on the UI thread with Reanimated.
|
|
32
|
+
export function ShimmerAnimation({
|
|
33
|
+
width,
|
|
34
|
+
height,
|
|
35
|
+
baseColor = '#E1E9EE',
|
|
36
|
+
highlightColor = '#F2F8FC',
|
|
37
|
+
duration = 1500,
|
|
38
|
+
borderRadius = 4,
|
|
39
|
+
style,
|
|
40
|
+
children,
|
|
41
|
+
}: ShimmerProps) {
|
|
42
|
+
const progress = useSharedValue(0);
|
|
43
|
+
const [measuredWidth, setMeasuredWidth] = useState(0);
|
|
44
|
+
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
progress.value = withRepeat(
|
|
47
|
+
withTiming(1, { duration, easing: Easing.linear }),
|
|
48
|
+
-1,
|
|
49
|
+
false
|
|
50
|
+
);
|
|
51
|
+
}, [duration, progress]);
|
|
52
|
+
|
|
53
|
+
const onLayout = (event: LayoutChangeEvent) => {
|
|
54
|
+
const w = event.nativeEvent.layout.width;
|
|
55
|
+
setMeasuredWidth(prev => (prev === w ? prev : w));
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const containerWidth = typeof width === 'number' ? width : measuredWidth;
|
|
59
|
+
|
|
60
|
+
const animatedStyle = useAnimatedStyle(() => {
|
|
61
|
+
'worklet';
|
|
62
|
+
const translateX = interpolate(
|
|
63
|
+
progress.value,
|
|
64
|
+
[0, 1],
|
|
65
|
+
[-containerWidth, containerWidth]
|
|
66
|
+
);
|
|
67
|
+
return { transform: [{ translateX }] };
|
|
68
|
+
}, [containerWidth]);
|
|
69
|
+
|
|
70
|
+
// `experimental_backgroundImage` isn't in the ViewStyle types yet.
|
|
71
|
+
const gradientStyle = {
|
|
72
|
+
...StyleSheet.absoluteFillObject,
|
|
73
|
+
experimental_backgroundImage: `linear-gradient(to right, ${baseColor}, ${highlightColor}, ${baseColor})`,
|
|
74
|
+
} as unknown as ViewStyle;
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<View
|
|
78
|
+
onLayout={onLayout}
|
|
79
|
+
style={[
|
|
80
|
+
styles.container,
|
|
81
|
+
{ width, height, borderRadius, backgroundColor: baseColor },
|
|
82
|
+
style,
|
|
83
|
+
]}
|
|
84
|
+
>
|
|
85
|
+
<Animated.View
|
|
86
|
+
pointerEvents="none"
|
|
87
|
+
style={[StyleSheet.absoluteFill, animatedStyle]}
|
|
88
|
+
>
|
|
89
|
+
<View style={gradientStyle} />
|
|
90
|
+
</Animated.View>
|
|
91
|
+
|
|
92
|
+
{children}
|
|
93
|
+
</View>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const styles = StyleSheet.create({
|
|
98
|
+
container: {
|
|
99
|
+
overflow: 'hidden',
|
|
100
|
+
},
|
|
101
|
+
});
|