@herca/rn-kit 0.1.31 → 0.1.33
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/README.md +5 -3
- package/lib/module/Chip/Chip.js +17 -7
- package/lib/module/Chip/Chip.js.map +1 -1
- package/lib/module/Chip/ChipItem.js +3 -1
- package/lib/module/Chip/ChipItem.js.map +1 -1
- package/lib/module/Chip/README_CHIP_ITEM.md +73 -0
- package/lib/module/Select/README.md +26 -17
- package/lib/module/Select/Select.js +42 -30
- package/lib/module/Select/Select.js.map +1 -1
- package/lib/module/Skeleton/README.md +79 -0
- package/lib/module/Skeleton/Skeleton.js +73 -0
- package/lib/module/Skeleton/Skeleton.js.map +1 -0
- package/lib/module/Skeleton/type.js +4 -0
- package/lib/module/Skeleton/type.js.map +1 -0
- package/lib/module/index.js +3 -0
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/Chip/Chip.d.ts.map +1 -1
- package/lib/typescript/src/Chip/ChipItem.d.ts +1 -1
- package/lib/typescript/src/Chip/ChipItem.d.ts.map +1 -1
- package/lib/typescript/src/Chip/type.d.ts +2 -1
- package/lib/typescript/src/Chip/type.d.ts.map +1 -1
- package/lib/typescript/src/Select/Select.d.ts +1 -1
- package/lib/typescript/src/Select/Select.d.ts.map +1 -1
- package/lib/typescript/src/Select/type.d.ts +2 -0
- package/lib/typescript/src/Select/type.d.ts.map +1 -1
- package/lib/typescript/src/Skeleton/Skeleton.d.ts +5 -0
- package/lib/typescript/src/Skeleton/Skeleton.d.ts.map +1 -0
- package/lib/typescript/src/Skeleton/type.d.ts +10 -0
- package/lib/typescript/src/Skeleton/type.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +4 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/Chip/Chip.tsx +19 -4
- package/src/Chip/ChipItem.tsx +2 -0
- package/src/Chip/README_CHIP_ITEM.md +73 -0
- package/src/Chip/type.tsx +2 -1
- package/src/Select/README.md +26 -17
- package/src/Select/Select.tsx +47 -34
- package/src/Select/type.tsx +2 -0
- package/src/Skeleton/README.md +79 -0
- package/src/Skeleton/Skeleton.tsx +99 -0
- package/src/Skeleton/type.ts +10 -0
- package/src/index.tsx +4 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import React, { useEffect, useRef } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Animated,
|
|
4
|
+
Easing,
|
|
5
|
+
StyleSheet,
|
|
6
|
+
View,
|
|
7
|
+
type LayoutChangeEvent,
|
|
8
|
+
type StyleProp,
|
|
9
|
+
type ViewStyle,
|
|
10
|
+
} from 'react-native';
|
|
11
|
+
import type { SkeletonProps } from './type';
|
|
12
|
+
|
|
13
|
+
const Skeleton: React.FC<SkeletonProps> = ({
|
|
14
|
+
width = '100%',
|
|
15
|
+
height = 50,
|
|
16
|
+
rounded = 8,
|
|
17
|
+
backgroundColor = '#F0F0F0',
|
|
18
|
+
shimmerColor = 'rgba(255, 255, 255, 0.7)',
|
|
19
|
+
duration = 1500,
|
|
20
|
+
}) => {
|
|
21
|
+
const shimmerAnimation = useRef(new Animated.Value(0)).current;
|
|
22
|
+
const skeletonWidth = useRef(0);
|
|
23
|
+
|
|
24
|
+
const handleLayout = (event: LayoutChangeEvent) => {
|
|
25
|
+
skeletonWidth.current = event.nativeEvent.layout.width;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
const animateShimmer = () => {
|
|
30
|
+
Animated.loop(
|
|
31
|
+
Animated.sequence([
|
|
32
|
+
Animated.timing(shimmerAnimation, {
|
|
33
|
+
toValue: 1,
|
|
34
|
+
duration: duration,
|
|
35
|
+
easing: Easing.linear,
|
|
36
|
+
useNativeDriver: true,
|
|
37
|
+
}),
|
|
38
|
+
Animated.timing(shimmerAnimation, {
|
|
39
|
+
toValue: 0,
|
|
40
|
+
duration: 0,
|
|
41
|
+
useNativeDriver: true,
|
|
42
|
+
}),
|
|
43
|
+
])
|
|
44
|
+
).start();
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
animateShimmer();
|
|
48
|
+
|
|
49
|
+
return () => {
|
|
50
|
+
shimmerAnimation.stopAnimation();
|
|
51
|
+
};
|
|
52
|
+
}, [shimmerAnimation, duration]);
|
|
53
|
+
|
|
54
|
+
const shimmerTranslate = shimmerAnimation.interpolate({
|
|
55
|
+
inputRange: [0, 1],
|
|
56
|
+
// Gunakan lebar skeleton untuk perhitungan yang presisi
|
|
57
|
+
outputRange: [-200, skeletonWidth.current + 200],
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<View
|
|
62
|
+
onLayout={handleLayout}
|
|
63
|
+
style={[
|
|
64
|
+
styles.skeletonCard,
|
|
65
|
+
{
|
|
66
|
+
width,
|
|
67
|
+
height,
|
|
68
|
+
backgroundColor,
|
|
69
|
+
borderRadius: rounded,
|
|
70
|
+
} as StyleProp<ViewStyle>,
|
|
71
|
+
]}
|
|
72
|
+
>
|
|
73
|
+
<Animated.View
|
|
74
|
+
style={[
|
|
75
|
+
styles.shimmer,
|
|
76
|
+
{
|
|
77
|
+
backgroundColor: shimmerColor,
|
|
78
|
+
transform: [{ translateX: shimmerTranslate }],
|
|
79
|
+
borderRadius: rounded,
|
|
80
|
+
},
|
|
81
|
+
]}
|
|
82
|
+
/>
|
|
83
|
+
</View>
|
|
84
|
+
);
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export default Skeleton;
|
|
88
|
+
|
|
89
|
+
const styles = StyleSheet.create({
|
|
90
|
+
skeletonCard: {
|
|
91
|
+
overflow: 'hidden',
|
|
92
|
+
},
|
|
93
|
+
shimmer: {
|
|
94
|
+
...StyleSheet.absoluteFillObject,
|
|
95
|
+
width: '90%',
|
|
96
|
+
height: '100%',
|
|
97
|
+
opacity: 0.3,
|
|
98
|
+
},
|
|
99
|
+
});
|
package/src/index.tsx
CHANGED
|
@@ -26,6 +26,7 @@ export { default as Gap } from './Ui/Gap';
|
|
|
26
26
|
export { default as Grid } from './Ui/Grid';
|
|
27
27
|
export { default as Col } from './Ui/Col';
|
|
28
28
|
export { default as Chip } from './Chip/Chip';
|
|
29
|
+
export { default as ChipItem } from './Chip/ChipItem';
|
|
29
30
|
export type {
|
|
30
31
|
ChipSelectedProps,
|
|
31
32
|
ChipOnSelectProps,
|
|
@@ -82,3 +83,6 @@ export { default as TextArea } from './Input/TextArea';
|
|
|
82
83
|
export { default as TextEditor } from './TextEditor/TextEditor';
|
|
83
84
|
// export { default as PdfView } from './FileView/PdfView';
|
|
84
85
|
export { ToastProvider, useToast } from './Toast/ToastContext';
|
|
86
|
+
export { default as Skeleton } from './Skeleton/Skeleton';
|
|
87
|
+
export type { SkeletonProps } from './Skeleton/type';
|
|
88
|
+
export { default as CounterButton } from './CounterButton/CounterButton';
|