react-native-skeleton-native 0.0.0-stage → 0.1.1

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.
Files changed (222) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +104 -2
  3. package/android/build.gradle +89 -0
  4. package/android/src/main/AndroidManifest.xml +3 -0
  5. package/android/src/main/AndroidManifestNew.xml +2 -0
  6. package/android/src/main/java/com/skeletonnative/SkeletonEpoch.java +10 -0
  7. package/android/src/main/java/com/skeletonnative/SkeletonGroupManager.java +22 -0
  8. package/android/src/main/java/com/skeletonnative/SkeletonGroupView.java +19 -0
  9. package/android/src/main/java/com/skeletonnative/SkeletonHighlightView.java +66 -0
  10. package/android/src/main/java/com/skeletonnative/SkeletonMotion.java +79 -0
  11. package/android/src/main/java/com/skeletonnative/SkeletonNativePackage.java +28 -0
  12. package/android/src/main/java/com/skeletonnative/SkeletonPainter.java +418 -0
  13. package/android/src/main/java/com/skeletonnative/SkeletonResources.java +123 -0
  14. package/android/src/main/java/com/skeletonnative/SkeletonShimmerManager.java +72 -0
  15. package/android/src/main/java/com/skeletonnative/SkeletonShimmerView.java +74 -0
  16. package/android/src/main/java/com/skeletonnative/SkeletonView.java +81 -0
  17. package/android/src/main/java/com/skeletonnative/SkeletonViewManager.java +89 -0
  18. package/android/src/main/res/animator/skeleton_native_slide_1000.xml +6 -0
  19. package/android/src/main/res/animator/skeleton_native_slide_1100.xml +6 -0
  20. package/android/src/main/res/animator/skeleton_native_slide_1200.xml +6 -0
  21. package/android/src/main/res/animator/skeleton_native_slide_1300.xml +6 -0
  22. package/android/src/main/res/animator/skeleton_native_slide_1400.xml +6 -0
  23. package/android/src/main/res/animator/skeleton_native_slide_1500.xml +6 -0
  24. package/android/src/main/res/animator/skeleton_native_slide_1600.xml +6 -0
  25. package/android/src/main/res/animator/skeleton_native_slide_1700.xml +6 -0
  26. package/android/src/main/res/animator/skeleton_native_slide_1800.xml +6 -0
  27. package/android/src/main/res/animator/skeleton_native_slide_1900.xml +6 -0
  28. package/android/src/main/res/animator/skeleton_native_slide_2000.xml +6 -0
  29. package/android/src/main/res/animator/skeleton_native_slide_2100.xml +6 -0
  30. package/android/src/main/res/animator/skeleton_native_slide_2200.xml +6 -0
  31. package/android/src/main/res/animator/skeleton_native_slide_2300.xml +6 -0
  32. package/android/src/main/res/animator/skeleton_native_slide_2400.xml +6 -0
  33. package/android/src/main/res/animator/skeleton_native_slide_2500.xml +6 -0
  34. package/android/src/main/res/animator/skeleton_native_slide_2600.xml +6 -0
  35. package/android/src/main/res/animator/skeleton_native_slide_2700.xml +6 -0
  36. package/android/src/main/res/animator/skeleton_native_slide_2800.xml +6 -0
  37. package/android/src/main/res/animator/skeleton_native_slide_2900.xml +6 -0
  38. package/android/src/main/res/animator/skeleton_native_slide_300.xml +6 -0
  39. package/android/src/main/res/animator/skeleton_native_slide_3000.xml +6 -0
  40. package/android/src/main/res/animator/skeleton_native_slide_3100.xml +6 -0
  41. package/android/src/main/res/animator/skeleton_native_slide_3200.xml +6 -0
  42. package/android/src/main/res/animator/skeleton_native_slide_3300.xml +6 -0
  43. package/android/src/main/res/animator/skeleton_native_slide_3400.xml +6 -0
  44. package/android/src/main/res/animator/skeleton_native_slide_3500.xml +6 -0
  45. package/android/src/main/res/animator/skeleton_native_slide_3600.xml +6 -0
  46. package/android/src/main/res/animator/skeleton_native_slide_3700.xml +6 -0
  47. package/android/src/main/res/animator/skeleton_native_slide_3800.xml +6 -0
  48. package/android/src/main/res/animator/skeleton_native_slide_3900.xml +6 -0
  49. package/android/src/main/res/animator/skeleton_native_slide_400.xml +6 -0
  50. package/android/src/main/res/animator/skeleton_native_slide_4000.xml +6 -0
  51. package/android/src/main/res/animator/skeleton_native_slide_4100.xml +6 -0
  52. package/android/src/main/res/animator/skeleton_native_slide_4200.xml +6 -0
  53. package/android/src/main/res/animator/skeleton_native_slide_4300.xml +6 -0
  54. package/android/src/main/res/animator/skeleton_native_slide_4400.xml +6 -0
  55. package/android/src/main/res/animator/skeleton_native_slide_4500.xml +6 -0
  56. package/android/src/main/res/animator/skeleton_native_slide_4600.xml +6 -0
  57. package/android/src/main/res/animator/skeleton_native_slide_4700.xml +6 -0
  58. package/android/src/main/res/animator/skeleton_native_slide_4800.xml +6 -0
  59. package/android/src/main/res/animator/skeleton_native_slide_4900.xml +6 -0
  60. package/android/src/main/res/animator/skeleton_native_slide_500.xml +6 -0
  61. package/android/src/main/res/animator/skeleton_native_slide_5000.xml +6 -0
  62. package/android/src/main/res/animator/skeleton_native_slide_600.xml +6 -0
  63. package/android/src/main/res/animator/skeleton_native_slide_700.xml +6 -0
  64. package/android/src/main/res/animator/skeleton_native_slide_800.xml +6 -0
  65. package/android/src/main/res/animator/skeleton_native_slide_900.xml +6 -0
  66. package/android/src/main/res/drawable/skeleton_native_pulse.xml +22 -0
  67. package/android/src/main/res/drawable/skeleton_native_pulse_1000.xml +5 -0
  68. package/android/src/main/res/drawable/skeleton_native_pulse_1100.xml +5 -0
  69. package/android/src/main/res/drawable/skeleton_native_pulse_1200.xml +5 -0
  70. package/android/src/main/res/drawable/skeleton_native_pulse_1300.xml +5 -0
  71. package/android/src/main/res/drawable/skeleton_native_pulse_1400.xml +5 -0
  72. package/android/src/main/res/drawable/skeleton_native_pulse_1500.xml +5 -0
  73. package/android/src/main/res/drawable/skeleton_native_pulse_1600.xml +5 -0
  74. package/android/src/main/res/drawable/skeleton_native_pulse_1700.xml +5 -0
  75. package/android/src/main/res/drawable/skeleton_native_pulse_1800.xml +5 -0
  76. package/android/src/main/res/drawable/skeleton_native_pulse_1900.xml +5 -0
  77. package/android/src/main/res/drawable/skeleton_native_pulse_2000.xml +5 -0
  78. package/android/src/main/res/drawable/skeleton_native_pulse_2100.xml +5 -0
  79. package/android/src/main/res/drawable/skeleton_native_pulse_2200.xml +5 -0
  80. package/android/src/main/res/drawable/skeleton_native_pulse_2300.xml +5 -0
  81. package/android/src/main/res/drawable/skeleton_native_pulse_2400.xml +5 -0
  82. package/android/src/main/res/drawable/skeleton_native_pulse_2500.xml +5 -0
  83. package/android/src/main/res/drawable/skeleton_native_pulse_2600.xml +5 -0
  84. package/android/src/main/res/drawable/skeleton_native_pulse_2700.xml +5 -0
  85. package/android/src/main/res/drawable/skeleton_native_pulse_2800.xml +5 -0
  86. package/android/src/main/res/drawable/skeleton_native_pulse_2900.xml +5 -0
  87. package/android/src/main/res/drawable/skeleton_native_pulse_300.xml +5 -0
  88. package/android/src/main/res/drawable/skeleton_native_pulse_3000.xml +5 -0
  89. package/android/src/main/res/drawable/skeleton_native_pulse_3100.xml +5 -0
  90. package/android/src/main/res/drawable/skeleton_native_pulse_3200.xml +5 -0
  91. package/android/src/main/res/drawable/skeleton_native_pulse_3300.xml +5 -0
  92. package/android/src/main/res/drawable/skeleton_native_pulse_3400.xml +5 -0
  93. package/android/src/main/res/drawable/skeleton_native_pulse_3500.xml +5 -0
  94. package/android/src/main/res/drawable/skeleton_native_pulse_3600.xml +5 -0
  95. package/android/src/main/res/drawable/skeleton_native_pulse_3700.xml +5 -0
  96. package/android/src/main/res/drawable/skeleton_native_pulse_3800.xml +5 -0
  97. package/android/src/main/res/drawable/skeleton_native_pulse_3900.xml +5 -0
  98. package/android/src/main/res/drawable/skeleton_native_pulse_400.xml +5 -0
  99. package/android/src/main/res/drawable/skeleton_native_pulse_4000.xml +5 -0
  100. package/android/src/main/res/drawable/skeleton_native_pulse_4100.xml +5 -0
  101. package/android/src/main/res/drawable/skeleton_native_pulse_4200.xml +5 -0
  102. package/android/src/main/res/drawable/skeleton_native_pulse_4300.xml +5 -0
  103. package/android/src/main/res/drawable/skeleton_native_pulse_4400.xml +5 -0
  104. package/android/src/main/res/drawable/skeleton_native_pulse_4500.xml +5 -0
  105. package/android/src/main/res/drawable/skeleton_native_pulse_4600.xml +5 -0
  106. package/android/src/main/res/drawable/skeleton_native_pulse_4700.xml +5 -0
  107. package/android/src/main/res/drawable/skeleton_native_pulse_4800.xml +5 -0
  108. package/android/src/main/res/drawable/skeleton_native_pulse_4900.xml +5 -0
  109. package/android/src/main/res/drawable/skeleton_native_pulse_500.xml +5 -0
  110. package/android/src/main/res/drawable/skeleton_native_pulse_5000.xml +5 -0
  111. package/android/src/main/res/drawable/skeleton_native_pulse_600.xml +5 -0
  112. package/android/src/main/res/drawable/skeleton_native_pulse_700.xml +5 -0
  113. package/android/src/main/res/drawable/skeleton_native_pulse_800.xml +5 -0
  114. package/android/src/main/res/drawable/skeleton_native_pulse_900.xml +5 -0
  115. package/android/src/main/res/drawable/skeleton_native_shimmer.xml +22 -0
  116. package/android/src/main/res/drawable/skeleton_native_shimmer_1000.xml +5 -0
  117. package/android/src/main/res/drawable/skeleton_native_shimmer_1100.xml +5 -0
  118. package/android/src/main/res/drawable/skeleton_native_shimmer_1200.xml +5 -0
  119. package/android/src/main/res/drawable/skeleton_native_shimmer_1300.xml +5 -0
  120. package/android/src/main/res/drawable/skeleton_native_shimmer_1400.xml +5 -0
  121. package/android/src/main/res/drawable/skeleton_native_shimmer_1500.xml +5 -0
  122. package/android/src/main/res/drawable/skeleton_native_shimmer_1600.xml +5 -0
  123. package/android/src/main/res/drawable/skeleton_native_shimmer_1700.xml +5 -0
  124. package/android/src/main/res/drawable/skeleton_native_shimmer_1800.xml +5 -0
  125. package/android/src/main/res/drawable/skeleton_native_shimmer_1900.xml +5 -0
  126. package/android/src/main/res/drawable/skeleton_native_shimmer_2000.xml +5 -0
  127. package/android/src/main/res/drawable/skeleton_native_shimmer_2100.xml +5 -0
  128. package/android/src/main/res/drawable/skeleton_native_shimmer_2200.xml +5 -0
  129. package/android/src/main/res/drawable/skeleton_native_shimmer_2300.xml +5 -0
  130. package/android/src/main/res/drawable/skeleton_native_shimmer_2400.xml +5 -0
  131. package/android/src/main/res/drawable/skeleton_native_shimmer_2500.xml +5 -0
  132. package/android/src/main/res/drawable/skeleton_native_shimmer_2600.xml +5 -0
  133. package/android/src/main/res/drawable/skeleton_native_shimmer_2700.xml +5 -0
  134. package/android/src/main/res/drawable/skeleton_native_shimmer_2800.xml +5 -0
  135. package/android/src/main/res/drawable/skeleton_native_shimmer_2900.xml +5 -0
  136. package/android/src/main/res/drawable/skeleton_native_shimmer_300.xml +5 -0
  137. package/android/src/main/res/drawable/skeleton_native_shimmer_3000.xml +5 -0
  138. package/android/src/main/res/drawable/skeleton_native_shimmer_3100.xml +5 -0
  139. package/android/src/main/res/drawable/skeleton_native_shimmer_3200.xml +5 -0
  140. package/android/src/main/res/drawable/skeleton_native_shimmer_3300.xml +5 -0
  141. package/android/src/main/res/drawable/skeleton_native_shimmer_3400.xml +5 -0
  142. package/android/src/main/res/drawable/skeleton_native_shimmer_3500.xml +5 -0
  143. package/android/src/main/res/drawable/skeleton_native_shimmer_3600.xml +5 -0
  144. package/android/src/main/res/drawable/skeleton_native_shimmer_3700.xml +5 -0
  145. package/android/src/main/res/drawable/skeleton_native_shimmer_3800.xml +5 -0
  146. package/android/src/main/res/drawable/skeleton_native_shimmer_3900.xml +5 -0
  147. package/android/src/main/res/drawable/skeleton_native_shimmer_400.xml +5 -0
  148. package/android/src/main/res/drawable/skeleton_native_shimmer_4000.xml +5 -0
  149. package/android/src/main/res/drawable/skeleton_native_shimmer_4100.xml +5 -0
  150. package/android/src/main/res/drawable/skeleton_native_shimmer_4200.xml +5 -0
  151. package/android/src/main/res/drawable/skeleton_native_shimmer_4300.xml +5 -0
  152. package/android/src/main/res/drawable/skeleton_native_shimmer_4400.xml +5 -0
  153. package/android/src/main/res/drawable/skeleton_native_shimmer_4500.xml +5 -0
  154. package/android/src/main/res/drawable/skeleton_native_shimmer_4600.xml +5 -0
  155. package/android/src/main/res/drawable/skeleton_native_shimmer_4700.xml +5 -0
  156. package/android/src/main/res/drawable/skeleton_native_shimmer_4800.xml +5 -0
  157. package/android/src/main/res/drawable/skeleton_native_shimmer_4900.xml +5 -0
  158. package/android/src/main/res/drawable/skeleton_native_shimmer_500.xml +5 -0
  159. package/android/src/main/res/drawable/skeleton_native_shimmer_5000.xml +5 -0
  160. package/android/src/main/res/drawable/skeleton_native_shimmer_600.xml +5 -0
  161. package/android/src/main/res/drawable/skeleton_native_shimmer_700.xml +5 -0
  162. package/android/src/main/res/drawable/skeleton_native_shimmer_800.xml +5 -0
  163. package/android/src/main/res/drawable/skeleton_native_shimmer_900.xml +5 -0
  164. package/android/src/newarch/java/com/skeletonnative/SkeletonGroupManagerSpec.java +19 -0
  165. package/android/src/newarch/java/com/skeletonnative/SkeletonShimmerManagerSpec.java +19 -0
  166. package/android/src/newarch/java/com/skeletonnative/SkeletonViewManagerSpec.java +19 -0
  167. package/android/src/oldarch/java/com/skeletonnative/SkeletonGroupManagerSpec.java +6 -0
  168. package/android/src/oldarch/java/com/skeletonnative/SkeletonShimmerManagerSpec.java +21 -0
  169. package/android/src/oldarch/java/com/skeletonnative/SkeletonViewManagerSpec.java +25 -0
  170. package/ios/RNSkeletonAnimator.h +75 -0
  171. package/ios/RNSkeletonAnimator.mm +406 -0
  172. package/ios/RNSkeletonComponentViews.mm +256 -0
  173. package/ios/RNSkeletonGroupRegistry.h +14 -0
  174. package/ios/RNSkeletonGroupRegistry.mm +37 -0
  175. package/ios/RNSkeletonLegacyViews.h +22 -0
  176. package/ios/RNSkeletonLegacyViews.mm +99 -0
  177. package/ios/RNSkeletonView.h +29 -0
  178. package/ios/RNSkeletonView.mm +77 -0
  179. package/ios/RNSkeletonViewManagers.mm +65 -0
  180. package/lib/commonjs/Shimmer.js +55 -0
  181. package/lib/commonjs/Skeleton.js +113 -0
  182. package/lib/commonjs/SkeletonGroup.js +58 -0
  183. package/lib/commonjs/context.js +10 -0
  184. package/lib/commonjs/index.js +15 -0
  185. package/lib/commonjs/props.js +113 -0
  186. package/lib/commonjs/specs/SkeletonNativeGroupNativeComponent.js +8 -0
  187. package/lib/commonjs/specs/SkeletonNativeShimmerNativeComponent.js +8 -0
  188. package/lib/commonjs/specs/SkeletonNativeViewNativeComponent.js +8 -0
  189. package/lib/commonjs/types.js +3 -0
  190. package/lib/module/Shimmer.js +16 -0
  191. package/lib/module/Skeleton.js +73 -0
  192. package/lib/module/SkeletonGroup.js +19 -0
  193. package/lib/module/context.js +6 -0
  194. package/lib/module/index.js +5 -0
  195. package/lib/module/props.js +103 -0
  196. package/lib/module/specs/SkeletonNativeGroupNativeComponent.js +3 -0
  197. package/lib/module/specs/SkeletonNativeShimmerNativeComponent.js +3 -0
  198. package/lib/module/specs/SkeletonNativeViewNativeComponent.js +3 -0
  199. package/lib/module/types.js +2 -0
  200. package/lib/typescript/Shimmer.d.ts +13 -0
  201. package/lib/typescript/Skeleton.d.ts +17 -0
  202. package/lib/typescript/SkeletonGroup.d.ts +17 -0
  203. package/lib/typescript/context.d.ts +7 -0
  204. package/lib/typescript/index.d.ts +7 -0
  205. package/lib/typescript/props.d.ts +42 -0
  206. package/lib/typescript/specs/SkeletonNativeGroupNativeComponent.d.ts +5 -0
  207. package/lib/typescript/specs/SkeletonNativeShimmerNativeComponent.d.ts +13 -0
  208. package/lib/typescript/specs/SkeletonNativeViewNativeComponent.d.ts +15 -0
  209. package/lib/typescript/types.d.ts +60 -0
  210. package/package.json +83 -4
  211. package/react-native-skeleton-native.podspec +20 -0
  212. package/react-native.config.js +10 -0
  213. package/src/Shimmer.tsx +38 -0
  214. package/src/Skeleton.tsx +125 -0
  215. package/src/SkeletonGroup.tsx +46 -0
  216. package/src/context.ts +13 -0
  217. package/src/index.ts +15 -0
  218. package/src/props.ts +126 -0
  219. package/src/specs/SkeletonNativeGroupNativeComponent.ts +9 -0
  220. package/src/specs/SkeletonNativeShimmerNativeComponent.ts +17 -0
  221. package/src/specs/SkeletonNativeViewNativeComponent.ts +20 -0
  222. package/src/types.ts +66 -0
@@ -0,0 +1,22 @@
1
+ // Old architecture container views. On the New Architecture the Fabric
2
+ // component views in RNSkeletonComponentViews.mm are used instead.
3
+ #import <React/RCTView.h>
4
+ #import "RNSkeletonAnimator.h"
5
+
6
+ NS_ASSUME_NONNULL_BEGIN
7
+
8
+ @interface RNSkeletonGroupView : RCTView <RNSkeletonGroupHost>
9
+ @end
10
+
11
+ @interface RNSkeletonShimmerView : RCTView <RNSkeletonMember>
12
+ @property (nonatomic, readonly) RNSkeletonAnimator *animator;
13
+ @property (nonatomic, strong, nullable) UIColor *highlightColor;
14
+ @property (nonatomic, assign) NSInteger duration;
15
+ @property (nonatomic, copy, nullable) NSString *direction;
16
+ @property (nonatomic, assign) CGFloat angle;
17
+ @property (nonatomic, copy, nullable) NSString *variant;
18
+ @property (nonatomic, assign) BOOL animated;
19
+ @property (nonatomic, copy, nullable) NSString *reduceMotion;
20
+ @end
21
+
22
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,99 @@
1
+ #import "RNSkeletonLegacyViews.h"
2
+ #import "RNSkeletonGroupRegistry.h"
3
+
4
+ @implementation RNSkeletonGroupView {
5
+ RNSkeletonGroupRegistry *_registry;
6
+ }
7
+
8
+ - (instancetype)initWithFrame:(CGRect)frame
9
+ {
10
+ if (self = [super initWithFrame:frame]) {
11
+ _registry = [RNSkeletonGroupRegistry new];
12
+ }
13
+ return self;
14
+ }
15
+
16
+ - (CFTimeInterval)skeletonEpoch
17
+ {
18
+ return _registry.epoch;
19
+ }
20
+
21
+ - (void)skeletonAddMember:(UIView *)member
22
+ {
23
+ [_registry add:member];
24
+ }
25
+
26
+ - (void)skeletonRemoveMember:(UIView *)member
27
+ {
28
+ [_registry remove:member];
29
+ }
30
+
31
+ - (void)layoutSubviews
32
+ {
33
+ [super layoutSubviews];
34
+ [_registry groupDidLayout];
35
+ }
36
+
37
+ @end
38
+
39
+ @implementation RNSkeletonShimmerView
40
+
41
+ - (instancetype)initWithFrame:(CGRect)frame
42
+ {
43
+ if (self = [super initWithFrame:frame]) {
44
+ _animator = [[RNSkeletonAnimator alloc] initWithHost:self overlay:YES];
45
+ _duration = 1400;
46
+ _angle = 20;
47
+ _animated = YES;
48
+ }
49
+ return self;
50
+ }
51
+
52
+ - (void)didSetProps:(NSArray<NSString *> *)changedProps
53
+ {
54
+ _animator.highlightColor = _highlightColor;
55
+ _animator.durationMs = _duration;
56
+ _animator.rtl = [_direction isEqualToString:@"rtl"];
57
+ _animator.angle = MAX(-45, MIN(45, _angle));
58
+ _animator.variant = RNSkeletonVariantFromString(_variant);
59
+ _animator.animated = _animated;
60
+ _animator.reduceMotion = RNSkeletonReduceMotionFromString(_reduceMotion);
61
+ [_animator update];
62
+ }
63
+
64
+ - (void)layoutSubviews
65
+ {
66
+ [super layoutSubviews];
67
+ [_animator hostDidLayout];
68
+ }
69
+
70
+ - (void)didMoveToWindow
71
+ {
72
+ [super didMoveToWindow];
73
+ [_animator hostDidMoveToWindow];
74
+ }
75
+
76
+ - (void)didAddSubview:(UIView *)subview
77
+ {
78
+ [super didAddSubview:subview];
79
+ [_animator setNeedsSnapshot];
80
+ }
81
+
82
+ - (void)willRemoveSubview:(UIView *)subview
83
+ {
84
+ [super willRemoveSubview:subview];
85
+ [_animator setNeedsSnapshot];
86
+ }
87
+
88
+ - (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection
89
+ {
90
+ [super traitCollectionDidChange:previousTraitCollection];
91
+ [_animator hostTraitsDidChange];
92
+ }
93
+
94
+ - (void)skeletonGroupDidLayout
95
+ {
96
+ [_animator hostDidLayout];
97
+ }
98
+
99
+ @end
@@ -0,0 +1,29 @@
1
+ #import <UIKit/UIKit.h>
2
+ #import "RNSkeletonAnimator.h"
3
+
4
+ NS_ASSUME_NONNULL_BEGIN
5
+
6
+ /**
7
+ * One placeholder block: base colour, corner radius and the highlight layers.
8
+ * The old architecture uses it directly; on Fabric it is the content view of
9
+ * RNSkeletonNativeComponentView.
10
+ */
11
+ @interface RNSkeletonView : UIView <RNSkeletonMember>
12
+
13
+ @property (nonatomic, readonly) RNSkeletonAnimator *animator;
14
+ @property (nonatomic, strong, nullable) UIColor *baseColor;
15
+ @property (nonatomic, strong, nullable) UIColor *highlightColor;
16
+ @property (nonatomic, assign) NSInteger duration;
17
+ @property (nonatomic, copy, nullable) NSString *direction;
18
+ @property (nonatomic, assign) CGFloat angle;
19
+ @property (nonatomic, copy, nullable) NSString *variant;
20
+ @property (nonatomic, assign) BOOL animated;
21
+ @property (nonatomic, copy, nullable) NSString *reduceMotion;
22
+ @property (nonatomic, assign) CGFloat cornerRadius;
23
+
24
+ /** Apply the props set since the last call. */
25
+ - (void)commitProps;
26
+
27
+ @end
28
+
29
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,77 @@
1
+ #import "RNSkeletonView.h"
2
+
3
+ @implementation RNSkeletonView
4
+
5
+ - (instancetype)initWithFrame:(CGRect)frame
6
+ {
7
+ if (self = [super initWithFrame:frame]) {
8
+ _animator = [[RNSkeletonAnimator alloc] initWithHost:self overlay:NO];
9
+ _duration = 1400;
10
+ _angle = 20;
11
+ _animated = YES;
12
+ self.layer.masksToBounds = YES;
13
+ self.userInteractionEnabled = NO;
14
+ [self applyBaseColor];
15
+ }
16
+ return self;
17
+ }
18
+
19
+ - (void)applyBaseColor
20
+ {
21
+ UIColor *color = _baseColor ?: RNSkeletonDefaultBaseColor();
22
+ if (@available(iOS 13.0, *)) {
23
+ color = [color resolvedColorWithTraitCollection:self.traitCollection];
24
+ }
25
+ [CATransaction begin];
26
+ [CATransaction setDisableActions:YES];
27
+ self.layer.backgroundColor = color.CGColor;
28
+ CGFloat maxRadius = MIN(self.bounds.size.width, self.bounds.size.height) / 2;
29
+ self.layer.cornerRadius = MAX(0, MIN(_cornerRadius, maxRadius));
30
+ [CATransaction commit];
31
+ }
32
+
33
+ - (void)commitProps
34
+ {
35
+ _animator.highlightColor = _highlightColor;
36
+ _animator.durationMs = _duration;
37
+ _animator.rtl = [_direction isEqualToString:@"rtl"];
38
+ _animator.angle = MAX(-45, MIN(45, _angle));
39
+ _animator.variant = RNSkeletonVariantFromString(_variant);
40
+ _animator.animated = _animated;
41
+ _animator.reduceMotion = RNSkeletonReduceMotionFromString(_reduceMotion);
42
+ [self applyBaseColor];
43
+ [_animator update];
44
+ }
45
+
46
+ // Old architecture: called once after each batch of prop updates.
47
+ - (void)didSetProps:(NSArray<NSString *> *)changedProps
48
+ {
49
+ [self commitProps];
50
+ }
51
+
52
+ - (void)layoutSubviews
53
+ {
54
+ [super layoutSubviews];
55
+ [self applyBaseColor];
56
+ [_animator hostDidLayout];
57
+ }
58
+
59
+ - (void)didMoveToWindow
60
+ {
61
+ [super didMoveToWindow];
62
+ [_animator hostDidMoveToWindow];
63
+ }
64
+
65
+ - (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection
66
+ {
67
+ [super traitCollectionDidChange:previousTraitCollection];
68
+ [self applyBaseColor];
69
+ [_animator hostTraitsDidChange];
70
+ }
71
+
72
+ - (void)skeletonGroupDidLayout
73
+ {
74
+ [_animator hostDidLayout];
75
+ }
76
+
77
+ @end
@@ -0,0 +1,65 @@
1
+ // Old architecture view managers. With the New Architecture, Fabric uses the
2
+ // component views in RNSkeletonComponentViews.mm for the same names.
3
+ #import <React/RCTViewManager.h>
4
+ #import "RNSkeletonLegacyViews.h"
5
+ #import "RNSkeletonView.h"
6
+
7
+ @interface RNSkeletonViewManager : RCTViewManager
8
+ @end
9
+
10
+ @implementation RNSkeletonViewManager
11
+
12
+ RCT_EXPORT_MODULE(SkeletonNativeView)
13
+
14
+ - (UIView *)view
15
+ {
16
+ return [RNSkeletonView new];
17
+ }
18
+
19
+ RCT_EXPORT_VIEW_PROPERTY(baseColor, UIColor)
20
+ RCT_EXPORT_VIEW_PROPERTY(highlightColor, UIColor)
21
+ RCT_EXPORT_VIEW_PROPERTY(duration, NSInteger)
22
+ RCT_EXPORT_VIEW_PROPERTY(direction, NSString)
23
+ RCT_EXPORT_VIEW_PROPERTY(angle, CGFloat)
24
+ RCT_EXPORT_VIEW_PROPERTY(variant, NSString)
25
+ RCT_EXPORT_VIEW_PROPERTY(animated, BOOL)
26
+ RCT_EXPORT_VIEW_PROPERTY(reduceMotion, NSString)
27
+ RCT_EXPORT_VIEW_PROPERTY(cornerRadius, CGFloat)
28
+
29
+ @end
30
+
31
+ @interface RNSkeletonGroupManager : RCTViewManager
32
+ @end
33
+
34
+ @implementation RNSkeletonGroupManager
35
+
36
+ RCT_EXPORT_MODULE(SkeletonNativeGroup)
37
+
38
+ - (UIView *)view
39
+ {
40
+ return [RNSkeletonGroupView new];
41
+ }
42
+
43
+ @end
44
+
45
+ @interface RNSkeletonShimmerManager : RCTViewManager
46
+ @end
47
+
48
+ @implementation RNSkeletonShimmerManager
49
+
50
+ RCT_EXPORT_MODULE(SkeletonNativeShimmer)
51
+
52
+ - (UIView *)view
53
+ {
54
+ return [RNSkeletonShimmerView new];
55
+ }
56
+
57
+ RCT_EXPORT_VIEW_PROPERTY(highlightColor, UIColor)
58
+ RCT_EXPORT_VIEW_PROPERTY(duration, NSInteger)
59
+ RCT_EXPORT_VIEW_PROPERTY(direction, NSString)
60
+ RCT_EXPORT_VIEW_PROPERTY(angle, CGFloat)
61
+ RCT_EXPORT_VIEW_PROPERTY(variant, NSString)
62
+ RCT_EXPORT_VIEW_PROPERTY(animated, BOOL)
63
+ RCT_EXPORT_VIEW_PROPERTY(reduceMotion, NSString)
64
+
65
+ @end
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.Shimmer = Shimmer;
40
+ const React = __importStar(require("react"));
41
+ const context_1 = require("./context");
42
+ const Skeleton_1 = require("./Skeleton");
43
+ const props_1 = require("./props");
44
+ const SkeletonNativeShimmerNativeComponent_1 = __importDefault(require("./specs/SkeletonNativeShimmerNativeComponent"));
45
+ /**
46
+ * Draws the moving highlight over arbitrary children, limited to the pixels the
47
+ * children draw. Android composites it live over the children (SRC_ATOP); iOS
48
+ * masks it with a snapshot of the children taken on layout. See the README.
49
+ */
50
+ function Shimmer(props) {
51
+ const group = (0, context_1.useSkeletonGroup)();
52
+ const anim = (0, props_1.resolveAnimationProps)(props, group ? group.props : null);
53
+ return (React.createElement(SkeletonNativeShimmerNativeComponent_1.default, Object.assign({ highlightColor: anim.highlightColor, duration: anim.duration, direction: anim.direction, angle: anim.angle, variant: anim.variant, animated: anim.animated, reduceMotion: anim.reduceMotion }, (0, Skeleton_1.accessibilityProps)(group != null, props.accessibilityLabel), { testID: props.testID, style: props.style }), props.children));
54
+ }
55
+ //# sourceMappingURL=Shimmer.js.map
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.Skeleton = void 0;
40
+ exports.accessibilityProps = accessibilityProps;
41
+ const React = __importStar(require("react"));
42
+ const react_native_1 = require("react-native");
43
+ const context_1 = require("./context");
44
+ const props_1 = require("./props");
45
+ const SkeletonNativeViewNativeComponent_1 = __importDefault(require("./specs/SkeletonNativeViewNativeComponent"));
46
+ const BUSY = { busy: true };
47
+ /**
48
+ * Accessibility props for one placeholder. Outside a group each placeholder is
49
+ * one "Loading" progress bar; inside a group the group is the only element and
50
+ * every placeholder is hidden from screen readers.
51
+ */
52
+ function accessibilityProps(inGroup, label) {
53
+ if (inGroup) {
54
+ return { accessible: false, importantForAccessibility: 'no-hide-descendants', accessibilityElementsHidden: true };
55
+ }
56
+ return {
57
+ accessible: true,
58
+ accessibilityRole: 'progressbar',
59
+ accessibilityState: BUSY,
60
+ accessibilityLabel: label !== null && label !== void 0 ? label : props_1.DEFAULT_LABEL,
61
+ };
62
+ }
63
+ const HIDDEN = accessibilityProps(true, undefined);
64
+ function nativeProps(p) {
65
+ return {
66
+ baseColor: p.baseColor,
67
+ highlightColor: p.highlightColor,
68
+ duration: p.duration,
69
+ direction: p.direction,
70
+ angle: p.angle,
71
+ variant: p.variant,
72
+ animated: p.animated,
73
+ reduceMotion: p.reduceMotion,
74
+ };
75
+ }
76
+ function SkeletonBlock(props) {
77
+ const group = (0, context_1.useSkeletonGroup)();
78
+ const anim = (0, props_1.resolveAnimationProps)(props, group ? group.props : null);
79
+ const width = (0, props_1.normalizeDimension)('width', props.width, '100%');
80
+ const height = (0, props_1.normalizeDimension)('height', props.height, 16);
81
+ const radius = (0, props_1.normalizeRadius)(props.radius, 4);
82
+ return (React.createElement(SkeletonNativeViewNativeComponent_1.default, Object.assign({}, nativeProps(anim), accessibilityProps(group != null, props.accessibilityLabel), { cornerRadius: radius, testID: props.testID, style: [{ width, height }, props.style] })));
83
+ }
84
+ function SkeletonCircle(props) {
85
+ const size = typeof props.size === 'number' && Number.isFinite(props.size) && props.size >= 0 ? props.size : 40;
86
+ return React.createElement(SkeletonBlock, Object.assign({}, props, { width: size, height: size, radius: size / 2 }));
87
+ }
88
+ function SkeletonText(props) {
89
+ const group = (0, context_1.useSkeletonGroup)();
90
+ const anim = (0, props_1.resolveAnimationProps)(props, group ? group.props : null);
91
+ const lines = (0, props_1.normalizeLines)(props.lines);
92
+ const lastLineWidth = (0, props_1.normalizeDimension)('lastLineWidth', props.lastLineWidth, '60%');
93
+ const lineHeight = (0, props_1.normalizeRadius)(props.lineHeight, 12);
94
+ const gap = (0, props_1.normalizeRadius)(props.gap, 8);
95
+ const radius = (0, props_1.normalizeRadius)(props.radius, 4);
96
+ const rows = [];
97
+ for (let i = 0; i < lines; i++) {
98
+ const last = lines > 1 && i === lines - 1;
99
+ rows.push(React.createElement(SkeletonNativeViewNativeComponent_1.default, Object.assign({ key: i }, nativeProps(anim), HIDDEN, { cornerRadius: radius, style: { width: last ? lastLineWidth : '100%', height: lineHeight, marginTop: i === 0 ? 0 : gap } })));
100
+ }
101
+ return (React.createElement(react_native_1.View, Object.assign({}, accessibilityProps(group != null, props.accessibilityLabel), { testID: props.testID, style: [styles.text, props.style] }), rows));
102
+ }
103
+ const styles = react_native_1.StyleSheet.create({
104
+ text: { width: '100%' },
105
+ });
106
+ const Circle = React.memo(SkeletonCircle);
107
+ Circle.displayName = 'Skeleton.Circle';
108
+ const Text = React.memo(SkeletonText);
109
+ Text.displayName = 'Skeleton.Text';
110
+ /** One placeholder block. `Skeleton.Circle` and `Skeleton.Text` are shortcuts. */
111
+ exports.Skeleton = Object.assign(React.memo(SkeletonBlock), { Circle, Text });
112
+ exports.Skeleton.displayName = 'Skeleton';
113
+ //# sourceMappingURL=Skeleton.js.map
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.SkeletonGroup = SkeletonGroup;
40
+ const React = __importStar(require("react"));
41
+ const context_1 = require("./context");
42
+ const props_1 = require("./props");
43
+ const SkeletonNativeGroupNativeComponent_1 = __importDefault(require("./specs/SkeletonNativeGroupNativeComponent"));
44
+ const BUSY = { busy: true };
45
+ /**
46
+ * Wraps many skeletons. Every skeleton and <Shimmer> inside shares one native
47
+ * animation epoch and the group's coordinate space, so one highlight sweeps
48
+ * across the whole group. Animation props set here are inherited.
49
+ * The group is one accessibility element; the blocks inside are hidden.
50
+ */
51
+ function SkeletonGroup(props) {
52
+ const { children, style, accessibilityLabel, testID } = props;
53
+ const { baseColor, highlightColor, duration, direction, angle, variant, animated, reduceMotion } = props;
54
+ const value = React.useMemo(() => ({ props: { baseColor, highlightColor, duration, direction, angle, variant, animated, reduceMotion } }), [baseColor, highlightColor, duration, direction, angle, variant, animated, reduceMotion]);
55
+ return (React.createElement(context_1.SkeletonGroupContext.Provider, { value: value },
56
+ React.createElement(SkeletonNativeGroupNativeComponent_1.default, { accessible: true, accessibilityRole: "progressbar", accessibilityState: BUSY, accessibilityLabel: accessibilityLabel !== null && accessibilityLabel !== void 0 ? accessibilityLabel : props_1.DEFAULT_LABEL, testID: testID, style: style }, children)));
57
+ }
58
+ //# sourceMappingURL=SkeletonGroup.js.map
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SkeletonGroupContext = void 0;
4
+ exports.useSkeletonGroup = useSkeletonGroup;
5
+ const react_1 = require("react");
6
+ exports.SkeletonGroupContext = (0, react_1.createContext)(null);
7
+ function useSkeletonGroup() {
8
+ return (0, react_1.useContext)(exports.SkeletonGroupContext);
9
+ }
10
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_LABEL = exports.DEFAULT_DURATION_MS = exports.DEFAULT_COLORS = exports.DEFAULT_ANGLE = exports.Shimmer = exports.SkeletonGroup = exports.Skeleton = void 0;
4
+ var Skeleton_1 = require("./Skeleton");
5
+ Object.defineProperty(exports, "Skeleton", { enumerable: true, get: function () { return Skeleton_1.Skeleton; } });
6
+ var SkeletonGroup_1 = require("./SkeletonGroup");
7
+ Object.defineProperty(exports, "SkeletonGroup", { enumerable: true, get: function () { return SkeletonGroup_1.SkeletonGroup; } });
8
+ var Shimmer_1 = require("./Shimmer");
9
+ Object.defineProperty(exports, "Shimmer", { enumerable: true, get: function () { return Shimmer_1.Shimmer; } });
10
+ var props_1 = require("./props");
11
+ Object.defineProperty(exports, "DEFAULT_ANGLE", { enumerable: true, get: function () { return props_1.DEFAULT_ANGLE; } });
12
+ Object.defineProperty(exports, "DEFAULT_COLORS", { enumerable: true, get: function () { return props_1.DEFAULT_COLORS; } });
13
+ Object.defineProperty(exports, "DEFAULT_DURATION_MS", { enumerable: true, get: function () { return props_1.DEFAULT_DURATION_MS; } });
14
+ Object.defineProperty(exports, "DEFAULT_LABEL", { enumerable: true, get: function () { return props_1.DEFAULT_LABEL; } });
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_COLORS = exports.DEFAULT_LABEL = exports.MAX_ANGLE = exports.DEFAULT_ANGLE = exports.MAX_DURATION_MS = exports.MIN_DURATION_MS = exports.DEFAULT_DURATION_MS = void 0;
4
+ exports.normalizeDuration = normalizeDuration;
5
+ exports.normalizeAngle = normalizeAngle;
6
+ exports.resolveDirection = resolveDirection;
7
+ exports.resolveAnimationProps = resolveAnimationProps;
8
+ exports.normalizeDimension = normalizeDimension;
9
+ exports.normalizeRadius = normalizeRadius;
10
+ exports.normalizeLines = normalizeLines;
11
+ const react_native_1 = require("react-native");
12
+ exports.DEFAULT_DURATION_MS = 1400;
13
+ exports.MIN_DURATION_MS = 100;
14
+ exports.MAX_DURATION_MS = 60000;
15
+ exports.DEFAULT_ANGLE = 20;
16
+ exports.MAX_ANGLE = 45;
17
+ exports.DEFAULT_LABEL = 'Loading';
18
+ /**
19
+ * The colours the native views use when `baseColor` / `highlightColor` are not
20
+ * given. They are applied natively, so they follow the system theme without a
21
+ * React re-render.
22
+ */
23
+ exports.DEFAULT_COLORS = {
24
+ light: { base: '#E1E4E8', highlight: '#F5F7F9' },
25
+ dark: { base: '#2B2E33', highlight: '#3D4148' },
26
+ };
27
+ const VARIANTS = ['shimmer', 'pulse', 'none'];
28
+ const DIRECTIONS = ['ltr', 'rtl', 'auto'];
29
+ const REDUCE_MOTION = ['system', 'always', 'never'];
30
+ function warn(message) {
31
+ if (typeof __DEV__ !== 'undefined' && __DEV__) {
32
+ console.warn(`react-native-skeleton-native: ${message}`);
33
+ }
34
+ }
35
+ function normalizeDuration(value) {
36
+ if (value === undefined)
37
+ return exports.DEFAULT_DURATION_MS;
38
+ if (typeof value !== 'number' || !Number.isFinite(value) || value <= 0) {
39
+ warn(`duration must be a positive number of ms, got ${String(value)}; using ${exports.DEFAULT_DURATION_MS}.`);
40
+ return exports.DEFAULT_DURATION_MS;
41
+ }
42
+ return Math.round(Math.min(exports.MAX_DURATION_MS, Math.max(exports.MIN_DURATION_MS, value)));
43
+ }
44
+ function normalizeAngle(value) {
45
+ if (value === undefined)
46
+ return exports.DEFAULT_ANGLE;
47
+ if (typeof value !== 'number' || !Number.isFinite(value)) {
48
+ warn(`angle must be a number of degrees, got ${String(value)}; using ${exports.DEFAULT_ANGLE}.`);
49
+ return exports.DEFAULT_ANGLE;
50
+ }
51
+ return Math.min(exports.MAX_ANGLE, Math.max(-exports.MAX_ANGLE, value));
52
+ }
53
+ function oneOf(name, value, allowed, fallback) {
54
+ if (value === undefined)
55
+ return fallback;
56
+ if (allowed.indexOf(value) === -1) {
57
+ warn(`${name} must be one of ${allowed.join(', ')}, got ${String(value)}; using ${fallback}.`);
58
+ return fallback;
59
+ }
60
+ return value;
61
+ }
62
+ function resolveDirection(value, isRTL = react_native_1.I18nManager.isRTL) {
63
+ const d = oneOf('direction', value, DIRECTIONS, 'auto');
64
+ if (d === 'auto')
65
+ return isRTL ? 'rtl' : 'ltr';
66
+ return d;
67
+ }
68
+ /** Merge own props over group props, validate, and fill defaults. */
69
+ function resolveAnimationProps(own, inherited) {
70
+ const pick = (key) => own[key] !== undefined ? own[key] : inherited ? inherited[key] : undefined;
71
+ return {
72
+ baseColor: pick('baseColor'),
73
+ highlightColor: pick('highlightColor'),
74
+ duration: normalizeDuration(pick('duration')),
75
+ direction: resolveDirection(pick('direction')),
76
+ angle: normalizeAngle(pick('angle')),
77
+ variant: oneOf('variant', pick('variant'), VARIANTS, 'shimmer'),
78
+ animated: pick('animated') !== false,
79
+ reduceMotion: oneOf('reduceMotion', pick('reduceMotion'), REDUCE_MOTION, 'system'),
80
+ };
81
+ }
82
+ function normalizeDimension(name, value, fallback) {
83
+ if (value === undefined)
84
+ return fallback;
85
+ if (typeof value === 'number') {
86
+ if (Number.isFinite(value) && value >= 0)
87
+ return value;
88
+ }
89
+ else if (typeof value === 'string' && /^\d+(\.\d+)?%$/.test(value)) {
90
+ return value;
91
+ }
92
+ warn(`${name} must be a non-negative number or a percentage string, got ${String(value)}; using ${String(fallback)}.`);
93
+ return fallback;
94
+ }
95
+ function normalizeRadius(value, fallback) {
96
+ if (value === undefined)
97
+ return fallback;
98
+ if (typeof value !== 'number' || !Number.isFinite(value) || value < 0) {
99
+ warn(`radius must be a non-negative number, got ${String(value)}; using ${fallback}.`);
100
+ return fallback;
101
+ }
102
+ return value;
103
+ }
104
+ function normalizeLines(value) {
105
+ if (value === undefined)
106
+ return 3;
107
+ if (typeof value !== 'number' || !Number.isFinite(value) || value < 1) {
108
+ warn(`lines must be a number of at least 1, got ${String(value)}; using 1.`);
109
+ return 1;
110
+ }
111
+ return Math.min(100, Math.floor(value));
112
+ }
113
+ //# sourceMappingURL=props.js.map
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const codegenNativeComponent_1 = __importDefault(require("react-native/Libraries/Utilities/codegenNativeComponent"));
7
+ exports.default = (0, codegenNativeComponent_1.default)('SkeletonNativeGroup');
8
+ //# sourceMappingURL=SkeletonNativeGroupNativeComponent.js.map