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.
- package/LICENSE +21 -0
- package/README.md +104 -2
- package/android/build.gradle +89 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/com/skeletonnative/SkeletonEpoch.java +10 -0
- package/android/src/main/java/com/skeletonnative/SkeletonGroupManager.java +22 -0
- package/android/src/main/java/com/skeletonnative/SkeletonGroupView.java +19 -0
- package/android/src/main/java/com/skeletonnative/SkeletonHighlightView.java +66 -0
- package/android/src/main/java/com/skeletonnative/SkeletonMotion.java +79 -0
- package/android/src/main/java/com/skeletonnative/SkeletonNativePackage.java +28 -0
- package/android/src/main/java/com/skeletonnative/SkeletonPainter.java +418 -0
- package/android/src/main/java/com/skeletonnative/SkeletonResources.java +123 -0
- package/android/src/main/java/com/skeletonnative/SkeletonShimmerManager.java +72 -0
- package/android/src/main/java/com/skeletonnative/SkeletonShimmerView.java +74 -0
- package/android/src/main/java/com/skeletonnative/SkeletonView.java +81 -0
- package/android/src/main/java/com/skeletonnative/SkeletonViewManager.java +89 -0
- package/android/src/main/res/animator/skeleton_native_slide_1000.xml +6 -0
- package/android/src/main/res/animator/skeleton_native_slide_1100.xml +6 -0
- package/android/src/main/res/animator/skeleton_native_slide_1200.xml +6 -0
- package/android/src/main/res/animator/skeleton_native_slide_1300.xml +6 -0
- package/android/src/main/res/animator/skeleton_native_slide_1400.xml +6 -0
- package/android/src/main/res/animator/skeleton_native_slide_1500.xml +6 -0
- package/android/src/main/res/animator/skeleton_native_slide_1600.xml +6 -0
- package/android/src/main/res/animator/skeleton_native_slide_1700.xml +6 -0
- package/android/src/main/res/animator/skeleton_native_slide_1800.xml +6 -0
- package/android/src/main/res/animator/skeleton_native_slide_1900.xml +6 -0
- package/android/src/main/res/animator/skeleton_native_slide_2000.xml +6 -0
- package/android/src/main/res/animator/skeleton_native_slide_2100.xml +6 -0
- package/android/src/main/res/animator/skeleton_native_slide_2200.xml +6 -0
- package/android/src/main/res/animator/skeleton_native_slide_2300.xml +6 -0
- package/android/src/main/res/animator/skeleton_native_slide_2400.xml +6 -0
- package/android/src/main/res/animator/skeleton_native_slide_2500.xml +6 -0
- package/android/src/main/res/animator/skeleton_native_slide_2600.xml +6 -0
- package/android/src/main/res/animator/skeleton_native_slide_2700.xml +6 -0
- package/android/src/main/res/animator/skeleton_native_slide_2800.xml +6 -0
- package/android/src/main/res/animator/skeleton_native_slide_2900.xml +6 -0
- package/android/src/main/res/animator/skeleton_native_slide_300.xml +6 -0
- package/android/src/main/res/animator/skeleton_native_slide_3000.xml +6 -0
- package/android/src/main/res/animator/skeleton_native_slide_3100.xml +6 -0
- package/android/src/main/res/animator/skeleton_native_slide_3200.xml +6 -0
- package/android/src/main/res/animator/skeleton_native_slide_3300.xml +6 -0
- package/android/src/main/res/animator/skeleton_native_slide_3400.xml +6 -0
- package/android/src/main/res/animator/skeleton_native_slide_3500.xml +6 -0
- package/android/src/main/res/animator/skeleton_native_slide_3600.xml +6 -0
- package/android/src/main/res/animator/skeleton_native_slide_3700.xml +6 -0
- package/android/src/main/res/animator/skeleton_native_slide_3800.xml +6 -0
- package/android/src/main/res/animator/skeleton_native_slide_3900.xml +6 -0
- package/android/src/main/res/animator/skeleton_native_slide_400.xml +6 -0
- package/android/src/main/res/animator/skeleton_native_slide_4000.xml +6 -0
- package/android/src/main/res/animator/skeleton_native_slide_4100.xml +6 -0
- package/android/src/main/res/animator/skeleton_native_slide_4200.xml +6 -0
- package/android/src/main/res/animator/skeleton_native_slide_4300.xml +6 -0
- package/android/src/main/res/animator/skeleton_native_slide_4400.xml +6 -0
- package/android/src/main/res/animator/skeleton_native_slide_4500.xml +6 -0
- package/android/src/main/res/animator/skeleton_native_slide_4600.xml +6 -0
- package/android/src/main/res/animator/skeleton_native_slide_4700.xml +6 -0
- package/android/src/main/res/animator/skeleton_native_slide_4800.xml +6 -0
- package/android/src/main/res/animator/skeleton_native_slide_4900.xml +6 -0
- package/android/src/main/res/animator/skeleton_native_slide_500.xml +6 -0
- package/android/src/main/res/animator/skeleton_native_slide_5000.xml +6 -0
- package/android/src/main/res/animator/skeleton_native_slide_600.xml +6 -0
- package/android/src/main/res/animator/skeleton_native_slide_700.xml +6 -0
- package/android/src/main/res/animator/skeleton_native_slide_800.xml +6 -0
- package/android/src/main/res/animator/skeleton_native_slide_900.xml +6 -0
- package/android/src/main/res/drawable/skeleton_native_pulse.xml +22 -0
- package/android/src/main/res/drawable/skeleton_native_pulse_1000.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_pulse_1100.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_pulse_1200.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_pulse_1300.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_pulse_1400.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_pulse_1500.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_pulse_1600.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_pulse_1700.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_pulse_1800.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_pulse_1900.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_pulse_2000.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_pulse_2100.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_pulse_2200.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_pulse_2300.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_pulse_2400.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_pulse_2500.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_pulse_2600.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_pulse_2700.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_pulse_2800.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_pulse_2900.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_pulse_300.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_pulse_3000.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_pulse_3100.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_pulse_3200.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_pulse_3300.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_pulse_3400.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_pulse_3500.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_pulse_3600.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_pulse_3700.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_pulse_3800.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_pulse_3900.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_pulse_400.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_pulse_4000.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_pulse_4100.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_pulse_4200.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_pulse_4300.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_pulse_4400.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_pulse_4500.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_pulse_4600.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_pulse_4700.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_pulse_4800.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_pulse_4900.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_pulse_500.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_pulse_5000.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_pulse_600.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_pulse_700.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_pulse_800.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_pulse_900.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_shimmer.xml +22 -0
- package/android/src/main/res/drawable/skeleton_native_shimmer_1000.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_shimmer_1100.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_shimmer_1200.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_shimmer_1300.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_shimmer_1400.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_shimmer_1500.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_shimmer_1600.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_shimmer_1700.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_shimmer_1800.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_shimmer_1900.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_shimmer_2000.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_shimmer_2100.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_shimmer_2200.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_shimmer_2300.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_shimmer_2400.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_shimmer_2500.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_shimmer_2600.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_shimmer_2700.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_shimmer_2800.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_shimmer_2900.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_shimmer_300.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_shimmer_3000.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_shimmer_3100.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_shimmer_3200.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_shimmer_3300.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_shimmer_3400.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_shimmer_3500.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_shimmer_3600.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_shimmer_3700.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_shimmer_3800.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_shimmer_3900.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_shimmer_400.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_shimmer_4000.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_shimmer_4100.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_shimmer_4200.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_shimmer_4300.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_shimmer_4400.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_shimmer_4500.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_shimmer_4600.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_shimmer_4700.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_shimmer_4800.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_shimmer_4900.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_shimmer_500.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_shimmer_5000.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_shimmer_600.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_shimmer_700.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_shimmer_800.xml +5 -0
- package/android/src/main/res/drawable/skeleton_native_shimmer_900.xml +5 -0
- package/android/src/newarch/java/com/skeletonnative/SkeletonGroupManagerSpec.java +19 -0
- package/android/src/newarch/java/com/skeletonnative/SkeletonShimmerManagerSpec.java +19 -0
- package/android/src/newarch/java/com/skeletonnative/SkeletonViewManagerSpec.java +19 -0
- package/android/src/oldarch/java/com/skeletonnative/SkeletonGroupManagerSpec.java +6 -0
- package/android/src/oldarch/java/com/skeletonnative/SkeletonShimmerManagerSpec.java +21 -0
- package/android/src/oldarch/java/com/skeletonnative/SkeletonViewManagerSpec.java +25 -0
- package/ios/RNSkeletonAnimator.h +75 -0
- package/ios/RNSkeletonAnimator.mm +406 -0
- package/ios/RNSkeletonComponentViews.mm +256 -0
- package/ios/RNSkeletonGroupRegistry.h +14 -0
- package/ios/RNSkeletonGroupRegistry.mm +37 -0
- package/ios/RNSkeletonLegacyViews.h +22 -0
- package/ios/RNSkeletonLegacyViews.mm +99 -0
- package/ios/RNSkeletonView.h +29 -0
- package/ios/RNSkeletonView.mm +77 -0
- package/ios/RNSkeletonViewManagers.mm +65 -0
- package/lib/commonjs/Shimmer.js +55 -0
- package/lib/commonjs/Skeleton.js +113 -0
- package/lib/commonjs/SkeletonGroup.js +58 -0
- package/lib/commonjs/context.js +10 -0
- package/lib/commonjs/index.js +15 -0
- package/lib/commonjs/props.js +113 -0
- package/lib/commonjs/specs/SkeletonNativeGroupNativeComponent.js +8 -0
- package/lib/commonjs/specs/SkeletonNativeShimmerNativeComponent.js +8 -0
- package/lib/commonjs/specs/SkeletonNativeViewNativeComponent.js +8 -0
- package/lib/commonjs/types.js +3 -0
- package/lib/module/Shimmer.js +16 -0
- package/lib/module/Skeleton.js +73 -0
- package/lib/module/SkeletonGroup.js +19 -0
- package/lib/module/context.js +6 -0
- package/lib/module/index.js +5 -0
- package/lib/module/props.js +103 -0
- package/lib/module/specs/SkeletonNativeGroupNativeComponent.js +3 -0
- package/lib/module/specs/SkeletonNativeShimmerNativeComponent.js +3 -0
- package/lib/module/specs/SkeletonNativeViewNativeComponent.js +3 -0
- package/lib/module/types.js +2 -0
- package/lib/typescript/Shimmer.d.ts +13 -0
- package/lib/typescript/Skeleton.d.ts +17 -0
- package/lib/typescript/SkeletonGroup.d.ts +17 -0
- package/lib/typescript/context.d.ts +7 -0
- package/lib/typescript/index.d.ts +7 -0
- package/lib/typescript/props.d.ts +42 -0
- package/lib/typescript/specs/SkeletonNativeGroupNativeComponent.d.ts +5 -0
- package/lib/typescript/specs/SkeletonNativeShimmerNativeComponent.d.ts +13 -0
- package/lib/typescript/specs/SkeletonNativeViewNativeComponent.d.ts +15 -0
- package/lib/typescript/types.d.ts +60 -0
- package/package.json +83 -4
- package/react-native-skeleton-native.podspec +20 -0
- package/react-native.config.js +10 -0
- package/src/Shimmer.tsx +38 -0
- package/src/Skeleton.tsx +125 -0
- package/src/SkeletonGroup.tsx +46 -0
- package/src/context.ts +13 -0
- package/src/index.ts +15 -0
- package/src/props.ts +126 -0
- package/src/specs/SkeletonNativeGroupNativeComponent.ts +9 -0
- package/src/specs/SkeletonNativeShimmerNativeComponent.ts +17 -0
- package/src/specs/SkeletonNativeViewNativeComponent.ts +20 -0
- package/src/types.ts +66 -0
|
@@ -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)('SkeletonNativeShimmer');
|
|
8
|
+
//# sourceMappingURL=SkeletonNativeShimmerNativeComponent.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)('SkeletonNativeView');
|
|
8
|
+
//# sourceMappingURL=SkeletonNativeViewNativeComponent.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useSkeletonGroup } from './context';
|
|
3
|
+
import { accessibilityProps } from './Skeleton';
|
|
4
|
+
import { resolveAnimationProps } from './props';
|
|
5
|
+
import SkeletonNativeShimmer from './specs/SkeletonNativeShimmerNativeComponent';
|
|
6
|
+
/**
|
|
7
|
+
* Draws the moving highlight over arbitrary children, limited to the pixels the
|
|
8
|
+
* children draw. Android composites it live over the children (SRC_ATOP); iOS
|
|
9
|
+
* masks it with a snapshot of the children taken on layout. See the README.
|
|
10
|
+
*/
|
|
11
|
+
export function Shimmer(props) {
|
|
12
|
+
const group = useSkeletonGroup();
|
|
13
|
+
const anim = resolveAnimationProps(props, group ? group.props : null);
|
|
14
|
+
return (React.createElement(SkeletonNativeShimmer, Object.assign({ highlightColor: anim.highlightColor, duration: anim.duration, direction: anim.direction, angle: anim.angle, variant: anim.variant, animated: anim.animated, reduceMotion: anim.reduceMotion }, accessibilityProps(group != null, props.accessibilityLabel), { testID: props.testID, style: props.style }), props.children));
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=Shimmer.js.map
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { StyleSheet, View } from 'react-native';
|
|
3
|
+
import { useSkeletonGroup } from './context';
|
|
4
|
+
import { DEFAULT_LABEL, normalizeDimension, normalizeLines, normalizeRadius, resolveAnimationProps, } from './props';
|
|
5
|
+
import SkeletonNativeView from './specs/SkeletonNativeViewNativeComponent';
|
|
6
|
+
const BUSY = { busy: true };
|
|
7
|
+
/**
|
|
8
|
+
* Accessibility props for one placeholder. Outside a group each placeholder is
|
|
9
|
+
* one "Loading" progress bar; inside a group the group is the only element and
|
|
10
|
+
* every placeholder is hidden from screen readers.
|
|
11
|
+
*/
|
|
12
|
+
export function accessibilityProps(inGroup, label) {
|
|
13
|
+
if (inGroup) {
|
|
14
|
+
return { accessible: false, importantForAccessibility: 'no-hide-descendants', accessibilityElementsHidden: true };
|
|
15
|
+
}
|
|
16
|
+
return {
|
|
17
|
+
accessible: true,
|
|
18
|
+
accessibilityRole: 'progressbar',
|
|
19
|
+
accessibilityState: BUSY,
|
|
20
|
+
accessibilityLabel: label !== null && label !== void 0 ? label : DEFAULT_LABEL,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
const HIDDEN = accessibilityProps(true, undefined);
|
|
24
|
+
function nativeProps(p) {
|
|
25
|
+
return {
|
|
26
|
+
baseColor: p.baseColor,
|
|
27
|
+
highlightColor: p.highlightColor,
|
|
28
|
+
duration: p.duration,
|
|
29
|
+
direction: p.direction,
|
|
30
|
+
angle: p.angle,
|
|
31
|
+
variant: p.variant,
|
|
32
|
+
animated: p.animated,
|
|
33
|
+
reduceMotion: p.reduceMotion,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function SkeletonBlock(props) {
|
|
37
|
+
const group = useSkeletonGroup();
|
|
38
|
+
const anim = resolveAnimationProps(props, group ? group.props : null);
|
|
39
|
+
const width = normalizeDimension('width', props.width, '100%');
|
|
40
|
+
const height = normalizeDimension('height', props.height, 16);
|
|
41
|
+
const radius = normalizeRadius(props.radius, 4);
|
|
42
|
+
return (React.createElement(SkeletonNativeView, Object.assign({}, nativeProps(anim), accessibilityProps(group != null, props.accessibilityLabel), { cornerRadius: radius, testID: props.testID, style: [{ width, height }, props.style] })));
|
|
43
|
+
}
|
|
44
|
+
function SkeletonCircle(props) {
|
|
45
|
+
const size = typeof props.size === 'number' && Number.isFinite(props.size) && props.size >= 0 ? props.size : 40;
|
|
46
|
+
return React.createElement(SkeletonBlock, Object.assign({}, props, { width: size, height: size, radius: size / 2 }));
|
|
47
|
+
}
|
|
48
|
+
function SkeletonText(props) {
|
|
49
|
+
const group = useSkeletonGroup();
|
|
50
|
+
const anim = resolveAnimationProps(props, group ? group.props : null);
|
|
51
|
+
const lines = normalizeLines(props.lines);
|
|
52
|
+
const lastLineWidth = normalizeDimension('lastLineWidth', props.lastLineWidth, '60%');
|
|
53
|
+
const lineHeight = normalizeRadius(props.lineHeight, 12);
|
|
54
|
+
const gap = normalizeRadius(props.gap, 8);
|
|
55
|
+
const radius = normalizeRadius(props.radius, 4);
|
|
56
|
+
const rows = [];
|
|
57
|
+
for (let i = 0; i < lines; i++) {
|
|
58
|
+
const last = lines > 1 && i === lines - 1;
|
|
59
|
+
rows.push(React.createElement(SkeletonNativeView, Object.assign({ key: i }, nativeProps(anim), HIDDEN, { cornerRadius: radius, style: { width: last ? lastLineWidth : '100%', height: lineHeight, marginTop: i === 0 ? 0 : gap } })));
|
|
60
|
+
}
|
|
61
|
+
return (React.createElement(View, Object.assign({}, accessibilityProps(group != null, props.accessibilityLabel), { testID: props.testID, style: [styles.text, props.style] }), rows));
|
|
62
|
+
}
|
|
63
|
+
const styles = StyleSheet.create({
|
|
64
|
+
text: { width: '100%' },
|
|
65
|
+
});
|
|
66
|
+
const Circle = React.memo(SkeletonCircle);
|
|
67
|
+
Circle.displayName = 'Skeleton.Circle';
|
|
68
|
+
const Text = React.memo(SkeletonText);
|
|
69
|
+
Text.displayName = 'Skeleton.Text';
|
|
70
|
+
/** One placeholder block. `Skeleton.Circle` and `Skeleton.Text` are shortcuts. */
|
|
71
|
+
export const Skeleton = Object.assign(React.memo(SkeletonBlock), { Circle, Text });
|
|
72
|
+
Skeleton.displayName = 'Skeleton';
|
|
73
|
+
//# sourceMappingURL=Skeleton.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { SkeletonGroupContext } from './context';
|
|
3
|
+
import { DEFAULT_LABEL } from './props';
|
|
4
|
+
import SkeletonNativeGroup from './specs/SkeletonNativeGroupNativeComponent';
|
|
5
|
+
const BUSY = { busy: true };
|
|
6
|
+
/**
|
|
7
|
+
* Wraps many skeletons. Every skeleton and <Shimmer> inside shares one native
|
|
8
|
+
* animation epoch and the group's coordinate space, so one highlight sweeps
|
|
9
|
+
* across the whole group. Animation props set here are inherited.
|
|
10
|
+
* The group is one accessibility element; the blocks inside are hidden.
|
|
11
|
+
*/
|
|
12
|
+
export function SkeletonGroup(props) {
|
|
13
|
+
const { children, style, accessibilityLabel, testID } = props;
|
|
14
|
+
const { baseColor, highlightColor, duration, direction, angle, variant, animated, reduceMotion } = props;
|
|
15
|
+
const value = React.useMemo(() => ({ props: { baseColor, highlightColor, duration, direction, angle, variant, animated, reduceMotion } }), [baseColor, highlightColor, duration, direction, angle, variant, animated, reduceMotion]);
|
|
16
|
+
return (React.createElement(SkeletonGroupContext.Provider, { value: value },
|
|
17
|
+
React.createElement(SkeletonNativeGroup, { accessible: true, accessibilityRole: "progressbar", accessibilityState: BUSY, accessibilityLabel: accessibilityLabel !== null && accessibilityLabel !== void 0 ? accessibilityLabel : DEFAULT_LABEL, testID: testID, style: style }, children)));
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=SkeletonGroup.js.map
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { I18nManager } from 'react-native';
|
|
2
|
+
export const DEFAULT_DURATION_MS = 1400;
|
|
3
|
+
export const MIN_DURATION_MS = 100;
|
|
4
|
+
export const MAX_DURATION_MS = 60000;
|
|
5
|
+
export const DEFAULT_ANGLE = 20;
|
|
6
|
+
export const MAX_ANGLE = 45;
|
|
7
|
+
export const DEFAULT_LABEL = 'Loading';
|
|
8
|
+
/**
|
|
9
|
+
* The colours the native views use when `baseColor` / `highlightColor` are not
|
|
10
|
+
* given. They are applied natively, so they follow the system theme without a
|
|
11
|
+
* React re-render.
|
|
12
|
+
*/
|
|
13
|
+
export const DEFAULT_COLORS = {
|
|
14
|
+
light: { base: '#E1E4E8', highlight: '#F5F7F9' },
|
|
15
|
+
dark: { base: '#2B2E33', highlight: '#3D4148' },
|
|
16
|
+
};
|
|
17
|
+
const VARIANTS = ['shimmer', 'pulse', 'none'];
|
|
18
|
+
const DIRECTIONS = ['ltr', 'rtl', 'auto'];
|
|
19
|
+
const REDUCE_MOTION = ['system', 'always', 'never'];
|
|
20
|
+
function warn(message) {
|
|
21
|
+
if (typeof __DEV__ !== 'undefined' && __DEV__) {
|
|
22
|
+
console.warn(`react-native-skeleton-native: ${message}`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export function normalizeDuration(value) {
|
|
26
|
+
if (value === undefined)
|
|
27
|
+
return DEFAULT_DURATION_MS;
|
|
28
|
+
if (typeof value !== 'number' || !Number.isFinite(value) || value <= 0) {
|
|
29
|
+
warn(`duration must be a positive number of ms, got ${String(value)}; using ${DEFAULT_DURATION_MS}.`);
|
|
30
|
+
return DEFAULT_DURATION_MS;
|
|
31
|
+
}
|
|
32
|
+
return Math.round(Math.min(MAX_DURATION_MS, Math.max(MIN_DURATION_MS, value)));
|
|
33
|
+
}
|
|
34
|
+
export function normalizeAngle(value) {
|
|
35
|
+
if (value === undefined)
|
|
36
|
+
return DEFAULT_ANGLE;
|
|
37
|
+
if (typeof value !== 'number' || !Number.isFinite(value)) {
|
|
38
|
+
warn(`angle must be a number of degrees, got ${String(value)}; using ${DEFAULT_ANGLE}.`);
|
|
39
|
+
return DEFAULT_ANGLE;
|
|
40
|
+
}
|
|
41
|
+
return Math.min(MAX_ANGLE, Math.max(-MAX_ANGLE, value));
|
|
42
|
+
}
|
|
43
|
+
function oneOf(name, value, allowed, fallback) {
|
|
44
|
+
if (value === undefined)
|
|
45
|
+
return fallback;
|
|
46
|
+
if (allowed.indexOf(value) === -1) {
|
|
47
|
+
warn(`${name} must be one of ${allowed.join(', ')}, got ${String(value)}; using ${fallback}.`);
|
|
48
|
+
return fallback;
|
|
49
|
+
}
|
|
50
|
+
return value;
|
|
51
|
+
}
|
|
52
|
+
export function resolveDirection(value, isRTL = I18nManager.isRTL) {
|
|
53
|
+
const d = oneOf('direction', value, DIRECTIONS, 'auto');
|
|
54
|
+
if (d === 'auto')
|
|
55
|
+
return isRTL ? 'rtl' : 'ltr';
|
|
56
|
+
return d;
|
|
57
|
+
}
|
|
58
|
+
/** Merge own props over group props, validate, and fill defaults. */
|
|
59
|
+
export function resolveAnimationProps(own, inherited) {
|
|
60
|
+
const pick = (key) => own[key] !== undefined ? own[key] : inherited ? inherited[key] : undefined;
|
|
61
|
+
return {
|
|
62
|
+
baseColor: pick('baseColor'),
|
|
63
|
+
highlightColor: pick('highlightColor'),
|
|
64
|
+
duration: normalizeDuration(pick('duration')),
|
|
65
|
+
direction: resolveDirection(pick('direction')),
|
|
66
|
+
angle: normalizeAngle(pick('angle')),
|
|
67
|
+
variant: oneOf('variant', pick('variant'), VARIANTS, 'shimmer'),
|
|
68
|
+
animated: pick('animated') !== false,
|
|
69
|
+
reduceMotion: oneOf('reduceMotion', pick('reduceMotion'), REDUCE_MOTION, 'system'),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
export function normalizeDimension(name, value, fallback) {
|
|
73
|
+
if (value === undefined)
|
|
74
|
+
return fallback;
|
|
75
|
+
if (typeof value === 'number') {
|
|
76
|
+
if (Number.isFinite(value) && value >= 0)
|
|
77
|
+
return value;
|
|
78
|
+
}
|
|
79
|
+
else if (typeof value === 'string' && /^\d+(\.\d+)?%$/.test(value)) {
|
|
80
|
+
return value;
|
|
81
|
+
}
|
|
82
|
+
warn(`${name} must be a non-negative number or a percentage string, got ${String(value)}; using ${String(fallback)}.`);
|
|
83
|
+
return fallback;
|
|
84
|
+
}
|
|
85
|
+
export function normalizeRadius(value, fallback) {
|
|
86
|
+
if (value === undefined)
|
|
87
|
+
return fallback;
|
|
88
|
+
if (typeof value !== 'number' || !Number.isFinite(value) || value < 0) {
|
|
89
|
+
warn(`radius must be a non-negative number, got ${String(value)}; using ${fallback}.`);
|
|
90
|
+
return fallback;
|
|
91
|
+
}
|
|
92
|
+
return value;
|
|
93
|
+
}
|
|
94
|
+
export function normalizeLines(value) {
|
|
95
|
+
if (value === undefined)
|
|
96
|
+
return 3;
|
|
97
|
+
if (typeof value !== 'number' || !Number.isFinite(value) || value < 1) {
|
|
98
|
+
warn(`lines must be a number of at least 1, got ${String(value)}; using 1.`);
|
|
99
|
+
return 1;
|
|
100
|
+
}
|
|
101
|
+
return Math.min(100, Math.floor(value));
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=props.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
import type { SkeletonAccessibilityProps, SkeletonAnimationProps } from './types';
|
|
4
|
+
export interface ShimmerProps extends Omit<SkeletonAnimationProps, 'baseColor'>, SkeletonAccessibilityProps {
|
|
5
|
+
children?: React.ReactNode;
|
|
6
|
+
style?: StyleProp<ViewStyle>;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Draws the moving highlight over arbitrary children, limited to the pixels the
|
|
10
|
+
* children draw. Android composites it live over the children (SRC_ATOP); iOS
|
|
11
|
+
* masks it with a snapshot of the children taken on layout. See the README.
|
|
12
|
+
*/
|
|
13
|
+
export declare function Shimmer(props: ShimmerProps): React.ReactElement;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { ViewProps } from 'react-native';
|
|
3
|
+
import type { SkeletonCircleProps, SkeletonProps, SkeletonTextProps } from './types';
|
|
4
|
+
type A11yProps = Pick<ViewProps, 'accessible' | 'accessibilityRole' | 'accessibilityState' | 'accessibilityLabel' | 'importantForAccessibility' | 'accessibilityElementsHidden'>;
|
|
5
|
+
/**
|
|
6
|
+
* Accessibility props for one placeholder. Outside a group each placeholder is
|
|
7
|
+
* one "Loading" progress bar; inside a group the group is the only element and
|
|
8
|
+
* every placeholder is hidden from screen readers.
|
|
9
|
+
*/
|
|
10
|
+
export declare function accessibilityProps(inGroup: boolean, label: string | undefined): A11yProps;
|
|
11
|
+
type SkeletonComponent = React.NamedExoticComponent<SkeletonProps> & {
|
|
12
|
+
Circle: React.NamedExoticComponent<SkeletonCircleProps>;
|
|
13
|
+
Text: React.NamedExoticComponent<SkeletonTextProps>;
|
|
14
|
+
};
|
|
15
|
+
/** One placeholder block. `Skeleton.Circle` and `Skeleton.Text` are shortcuts. */
|
|
16
|
+
export declare const Skeleton: SkeletonComponent;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
import type { SkeletonAnimationProps } from './types';
|
|
4
|
+
export interface SkeletonGroupProps extends SkeletonAnimationProps {
|
|
5
|
+
children?: React.ReactNode;
|
|
6
|
+
style?: StyleProp<ViewStyle>;
|
|
7
|
+
/** Screen reader label for the whole group. Default `"Loading"`. */
|
|
8
|
+
accessibilityLabel?: string;
|
|
9
|
+
testID?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Wraps many skeletons. Every skeleton and <Shimmer> inside shares one native
|
|
13
|
+
* animation epoch and the group's coordinate space, so one highlight sweeps
|
|
14
|
+
* across the whole group. Animation props set here are inherited.
|
|
15
|
+
* The group is one accessibility element; the blocks inside are hidden.
|
|
16
|
+
*/
|
|
17
|
+
export declare function SkeletonGroup(props: SkeletonGroupProps): React.ReactElement;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { SkeletonAnimationProps } from './types';
|
|
2
|
+
export interface GroupContextValue {
|
|
3
|
+
/** Props set on <SkeletonGroup>, inherited by every skeleton inside it. */
|
|
4
|
+
props: SkeletonAnimationProps;
|
|
5
|
+
}
|
|
6
|
+
export declare const SkeletonGroupContext: import("react").Context<GroupContextValue | null>;
|
|
7
|
+
export declare function useSkeletonGroup(): GroupContextValue | null;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { Skeleton } from './Skeleton';
|
|
2
|
+
export { SkeletonGroup } from './SkeletonGroup';
|
|
3
|
+
export type { SkeletonGroupProps } from './SkeletonGroup';
|
|
4
|
+
export { Shimmer } from './Shimmer';
|
|
5
|
+
export type { ShimmerProps } from './Shimmer';
|
|
6
|
+
export { DEFAULT_ANGLE, DEFAULT_COLORS, DEFAULT_DURATION_MS, DEFAULT_LABEL } from './props';
|
|
7
|
+
export type { ReduceMotionMode, SkeletonAnimationProps, SkeletonCircleProps, SkeletonDirection, SkeletonProps, SkeletonTextProps, SkeletonVariant, } from './types';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { ColorValue } from 'react-native';
|
|
2
|
+
import type { ReduceMotionMode, SkeletonAnimationProps, SkeletonDirection, SkeletonVariant } from './types';
|
|
3
|
+
export declare const DEFAULT_DURATION_MS = 1400;
|
|
4
|
+
export declare const MIN_DURATION_MS = 100;
|
|
5
|
+
export declare const MAX_DURATION_MS = 60000;
|
|
6
|
+
export declare const DEFAULT_ANGLE = 20;
|
|
7
|
+
export declare const MAX_ANGLE = 45;
|
|
8
|
+
export declare const DEFAULT_LABEL = "Loading";
|
|
9
|
+
/**
|
|
10
|
+
* The colours the native views use when `baseColor` / `highlightColor` are not
|
|
11
|
+
* given. They are applied natively, so they follow the system theme without a
|
|
12
|
+
* React re-render.
|
|
13
|
+
*/
|
|
14
|
+
export declare const DEFAULT_COLORS: {
|
|
15
|
+
readonly light: {
|
|
16
|
+
readonly base: "#E1E4E8";
|
|
17
|
+
readonly highlight: "#F5F7F9";
|
|
18
|
+
};
|
|
19
|
+
readonly dark: {
|
|
20
|
+
readonly base: "#2B2E33";
|
|
21
|
+
readonly highlight: "#3D4148";
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export interface NativeAnimationProps {
|
|
25
|
+
baseColor?: ColorValue;
|
|
26
|
+
highlightColor?: ColorValue;
|
|
27
|
+
duration: number;
|
|
28
|
+
direction: 'ltr' | 'rtl';
|
|
29
|
+
angle: number;
|
|
30
|
+
variant: SkeletonVariant;
|
|
31
|
+
animated: boolean;
|
|
32
|
+
reduceMotion: ReduceMotionMode;
|
|
33
|
+
}
|
|
34
|
+
export declare function normalizeDuration(value: number | undefined): number;
|
|
35
|
+
export declare function normalizeAngle(value: number | undefined): number;
|
|
36
|
+
export declare function resolveDirection(value: SkeletonDirection | undefined, isRTL?: boolean): 'ltr' | 'rtl';
|
|
37
|
+
/** Merge own props over group props, validate, and fill defaults. */
|
|
38
|
+
export declare function resolveAnimationProps(own: SkeletonAnimationProps, inherited: SkeletonAnimationProps | null): NativeAnimationProps;
|
|
39
|
+
export type Dimension = number | `${number}%`;
|
|
40
|
+
export declare function normalizeDimension(name: string, value: Dimension | undefined, fallback: Dimension): Dimension;
|
|
41
|
+
export declare function normalizeRadius(value: number | undefined, fallback: number): number;
|
|
42
|
+
export declare function normalizeLines(value: number | undefined): number;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ColorValue, ViewProps } from 'react-native';
|
|
2
|
+
import type { Float, Int32, WithDefault } from 'react-native/Libraries/Types/CodegenTypes';
|
|
3
|
+
export interface NativeProps extends ViewProps {
|
|
4
|
+
highlightColor?: ColorValue;
|
|
5
|
+
duration?: WithDefault<Int32, 1400>;
|
|
6
|
+
direction?: WithDefault<'ltr' | 'rtl', 'ltr'>;
|
|
7
|
+
angle?: WithDefault<Float, 20>;
|
|
8
|
+
variant?: WithDefault<'shimmer' | 'pulse' | 'none', 'shimmer'>;
|
|
9
|
+
animated?: WithDefault<boolean, true>;
|
|
10
|
+
reduceMotion?: WithDefault<'system' | 'always' | 'never', 'system'>;
|
|
11
|
+
}
|
|
12
|
+
declare const _default: import("react-native").HostComponent<NativeProps>;
|
|
13
|
+
export default _default;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ColorValue, ViewProps } from 'react-native';
|
|
2
|
+
import type { Float, Int32, WithDefault } from 'react-native/Libraries/Types/CodegenTypes';
|
|
3
|
+
export interface NativeProps extends ViewProps {
|
|
4
|
+
baseColor?: ColorValue;
|
|
5
|
+
highlightColor?: ColorValue;
|
|
6
|
+
duration?: WithDefault<Int32, 1400>;
|
|
7
|
+
direction?: WithDefault<'ltr' | 'rtl', 'ltr'>;
|
|
8
|
+
angle?: WithDefault<Float, 20>;
|
|
9
|
+
variant?: WithDefault<'shimmer' | 'pulse' | 'none', 'shimmer'>;
|
|
10
|
+
animated?: WithDefault<boolean, true>;
|
|
11
|
+
reduceMotion?: WithDefault<'system' | 'always' | 'never', 'system'>;
|
|
12
|
+
cornerRadius?: WithDefault<Float, 0>;
|
|
13
|
+
}
|
|
14
|
+
declare const _default: import("react-native").HostComponent<NativeProps>;
|
|
15
|
+
export default _default;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { ColorValue, StyleProp, ViewStyle } from 'react-native';
|
|
2
|
+
export type SkeletonVariant = 'shimmer' | 'pulse' | 'none';
|
|
3
|
+
export type SkeletonDirection = 'ltr' | 'rtl' | 'auto';
|
|
4
|
+
/**
|
|
5
|
+
* `system` follows the OS setting (iOS Reduce Motion, Android "Remove
|
|
6
|
+
* animations" / animator duration scale 0). `always` behaves as if it were
|
|
7
|
+
* on, `never` ignores it.
|
|
8
|
+
*/
|
|
9
|
+
export type ReduceMotionMode = 'system' | 'always' | 'never';
|
|
10
|
+
/** Animation and colour props shared by every component. */
|
|
11
|
+
export interface SkeletonAnimationProps {
|
|
12
|
+
/** Block colour. Defaults to a grey that follows the system light/dark theme, natively. */
|
|
13
|
+
baseColor?: ColorValue;
|
|
14
|
+
/** Colour at the centre of the moving highlight. Defaults follow the system theme. */
|
|
15
|
+
highlightColor?: ColorValue;
|
|
16
|
+
/** Time for one sweep (or one pulse), in ms. Default 1400. */
|
|
17
|
+
duration?: number;
|
|
18
|
+
/** Sweep direction. `auto` follows the app's layout direction (`I18nManager.isRTL`). Default `auto`. */
|
|
19
|
+
direction?: SkeletonDirection;
|
|
20
|
+
/** Lean of the highlight band from vertical, in degrees, clamped to -45..45. Default 20. */
|
|
21
|
+
angle?: number;
|
|
22
|
+
/** Default `shimmer`. */
|
|
23
|
+
variant?: SkeletonVariant;
|
|
24
|
+
/** `false` pauses the animation and shows the static block. Default `true`. */
|
|
25
|
+
animated?: boolean;
|
|
26
|
+
/** Default `system`. */
|
|
27
|
+
reduceMotion?: ReduceMotionMode;
|
|
28
|
+
}
|
|
29
|
+
export interface SkeletonAccessibilityProps {
|
|
30
|
+
/** Screen reader label. Default `"Loading"`. */
|
|
31
|
+
accessibilityLabel?: string;
|
|
32
|
+
testID?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface SkeletonProps extends SkeletonAnimationProps, SkeletonAccessibilityProps {
|
|
35
|
+
/** Number (dp/pt) or percentage string. Default `'100%'`. */
|
|
36
|
+
width?: number | `${number}%`;
|
|
37
|
+
/** Default 16. */
|
|
38
|
+
height?: number | `${number}%`;
|
|
39
|
+
/** Corner radius. Default 4. */
|
|
40
|
+
radius?: number;
|
|
41
|
+
style?: StyleProp<ViewStyle>;
|
|
42
|
+
}
|
|
43
|
+
export interface SkeletonCircleProps extends SkeletonAnimationProps, SkeletonAccessibilityProps {
|
|
44
|
+
/** Diameter. Default 40. */
|
|
45
|
+
size?: number;
|
|
46
|
+
style?: StyleProp<ViewStyle>;
|
|
47
|
+
}
|
|
48
|
+
export interface SkeletonTextProps extends SkeletonAnimationProps, SkeletonAccessibilityProps {
|
|
49
|
+
/** Number of lines, at least 1. Default 3. */
|
|
50
|
+
lines?: number;
|
|
51
|
+
/** Width of the last line when there is more than one: number or percentage. Default `'60%'`. */
|
|
52
|
+
lastLineWidth?: number | `${number}%`;
|
|
53
|
+
/** Height of one line. Default 12. */
|
|
54
|
+
lineHeight?: number;
|
|
55
|
+
/** Space between lines. Default 8. */
|
|
56
|
+
gap?: number;
|
|
57
|
+
/** Corner radius of each line. Default 4. */
|
|
58
|
+
radius?: number;
|
|
59
|
+
style?: StyleProp<ViewStyle>;
|
|
60
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,85 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-skeleton-native",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Skeleton and shimmer placeholders for React Native whose animation runs on the platform compositor (Core Animation on iOS, RenderThread on Android), so it keeps moving while the JS thread and the UI thread are busy. Old and New Architecture.",
|
|
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
|
+
"author": "Moksh Upadhyay <mokshupadhyay4@gmail.com>",
|
|
11
|
+
"homepage": "https://github.com/mokshupadhyay/react-native-skeleton-native#readme",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/mokshupadhyay/react-native-skeleton-native.git"
|
|
15
|
+
},
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/mokshupadhyay/react-native-skeleton-native/issues"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"src",
|
|
21
|
+
"lib",
|
|
22
|
+
"android/build.gradle",
|
|
23
|
+
"android/src",
|
|
24
|
+
"ios",
|
|
25
|
+
"react-native-skeleton-native.podspec",
|
|
26
|
+
"react-native.config.js",
|
|
27
|
+
"!**/__tests__",
|
|
28
|
+
"!**/*.test.ts",
|
|
29
|
+
"!**/*.test.tsx",
|
|
30
|
+
"!**/*.map"
|
|
31
|
+
],
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "node scripts/build.mjs",
|
|
34
|
+
"typecheck": "tsc --noEmit",
|
|
35
|
+
"test": "jest",
|
|
36
|
+
"check": "npm run typecheck && npm test && npm run build",
|
|
37
|
+
"example:install": "npm pack --pack-destination example && cd example && npm install ./react-native-skeleton-native-$npm_package_version.tgz",
|
|
38
|
+
"prepack": "npm run build",
|
|
39
|
+
"prepublishOnly": "npm run typecheck && npm test"
|
|
40
|
+
},
|
|
41
|
+
"keywords": [
|
|
42
|
+
"react-native",
|
|
43
|
+
"skeleton",
|
|
44
|
+
"shimmer",
|
|
45
|
+
"placeholder",
|
|
46
|
+
"loading",
|
|
47
|
+
"content-loader",
|
|
48
|
+
"core-animation",
|
|
49
|
+
"renderthread",
|
|
50
|
+
"fabric",
|
|
51
|
+
"new-architecture"
|
|
52
|
+
],
|
|
53
|
+
"license": "MIT",
|
|
54
|
+
"peerDependencies": {
|
|
55
|
+
"react": ">=18.2.0",
|
|
56
|
+
"react-native": ">=0.71.0"
|
|
57
|
+
},
|
|
58
|
+
"codegenConfig": {
|
|
59
|
+
"name": "RNSkeletonNativeSpec",
|
|
60
|
+
"type": "components",
|
|
61
|
+
"jsSrcsDir": "src/specs",
|
|
62
|
+
"android": {
|
|
63
|
+
"javaPackageName": "com.skeletonnative"
|
|
64
|
+
},
|
|
65
|
+
"ios": {
|
|
66
|
+
"componentProvider": {
|
|
67
|
+
"SkeletonNativeView": "RNSkeletonNativeComponentView",
|
|
68
|
+
"SkeletonNativeGroup": "RNSkeletonGroupComponentView",
|
|
69
|
+
"SkeletonNativeShimmer": "RNSkeletonShimmerComponentView"
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
"devDependencies": {
|
|
74
|
+
"@react-native/babel-preset": "^0.88.1",
|
|
75
|
+
"@react-native/jest-preset": "^0.88.1",
|
|
76
|
+
"@testing-library/react-native": "^14.1.0",
|
|
77
|
+
"@types/jest": "^29.5.14",
|
|
78
|
+
"@types/react": "^19.3.0",
|
|
79
|
+
"jest": "^29.7.0",
|
|
80
|
+
"react": "^19.3.1",
|
|
81
|
+
"react-native": "^0.88.1",
|
|
82
|
+
"react-test-renderer": "^19.3.1",
|
|
83
|
+
"typescript": "^5.9.3"
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = "react-native-skeleton-native"
|
|
7
|
+
s.version = package["version"]
|
|
8
|
+
s.summary = package["description"]
|
|
9
|
+
s.homepage = package["homepage"]
|
|
10
|
+
s.license = package["license"]
|
|
11
|
+
s.authors = package["author"]
|
|
12
|
+
s.platforms = { :ios => (defined?(min_ios_version_supported) ? min_ios_version_supported : "13.0") }
|
|
13
|
+
s.source = { :git => package["repository"]["url"].sub(/^git\+/, ""), :tag => "v#{s.version}" }
|
|
14
|
+
s.source_files = "ios/**/*.{h,m,mm}"
|
|
15
|
+
s.frameworks = "QuartzCore", "UIKit"
|
|
16
|
+
|
|
17
|
+
# React Native 0.71+ (the supported range): adds React-Core, the codegen
|
|
18
|
+
# output for the components in src/specs and the New Architecture flags.
|
|
19
|
+
install_modules_dependencies(s)
|
|
20
|
+
end
|
package/src/Shimmer.tsx
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
import { useSkeletonGroup } from './context';
|
|
4
|
+
import { accessibilityProps } from './Skeleton';
|
|
5
|
+
import { resolveAnimationProps } from './props';
|
|
6
|
+
import SkeletonNativeShimmer from './specs/SkeletonNativeShimmerNativeComponent';
|
|
7
|
+
import type { SkeletonAccessibilityProps, SkeletonAnimationProps } from './types';
|
|
8
|
+
|
|
9
|
+
export interface ShimmerProps extends Omit<SkeletonAnimationProps, 'baseColor'>, SkeletonAccessibilityProps {
|
|
10
|
+
children?: React.ReactNode;
|
|
11
|
+
style?: StyleProp<ViewStyle>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Draws the moving highlight over arbitrary children, limited to the pixels the
|
|
16
|
+
* children draw. Android composites it live over the children (SRC_ATOP); iOS
|
|
17
|
+
* masks it with a snapshot of the children taken on layout. See the README.
|
|
18
|
+
*/
|
|
19
|
+
export function Shimmer(props: ShimmerProps): React.ReactElement {
|
|
20
|
+
const group = useSkeletonGroup();
|
|
21
|
+
const anim = resolveAnimationProps(props, group ? group.props : null);
|
|
22
|
+
return (
|
|
23
|
+
<SkeletonNativeShimmer
|
|
24
|
+
highlightColor={anim.highlightColor}
|
|
25
|
+
duration={anim.duration}
|
|
26
|
+
direction={anim.direction}
|
|
27
|
+
angle={anim.angle}
|
|
28
|
+
variant={anim.variant}
|
|
29
|
+
animated={anim.animated}
|
|
30
|
+
reduceMotion={anim.reduceMotion}
|
|
31
|
+
{...accessibilityProps(group != null, props.accessibilityLabel)}
|
|
32
|
+
testID={props.testID}
|
|
33
|
+
style={props.style}
|
|
34
|
+
>
|
|
35
|
+
{props.children}
|
|
36
|
+
</SkeletonNativeShimmer>
|
|
37
|
+
);
|
|
38
|
+
}
|