@momo-kits/foundation 0.81.51-beta.0 → 0.81.52
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/Application/{BottomTab/index.tsx → BottomTab.tsx} +18 -42
- package/Application/Components.tsx +91 -356
- package/Application/ModalScreen.tsx +185 -14
- package/Application/Navigation.ts +19 -5
- package/Application/NavigationContainer.tsx +72 -62
- package/Application/Navigator.ts +48 -154
- package/Application/StackScreen.tsx +32 -289
- package/Application/index.ts +15 -13
- package/Application/types.ts +35 -81
- package/Application/utils.tsx +30 -76
- package/Assets/icon_bank.json +1 -1
- package/Badge/Badge.tsx +1 -1
- package/Badge/index.tsx +1 -2
- package/Badge/styles.ts +6 -50
- package/Button/index.tsx +26 -44
- package/CheckBox/index.tsx +26 -37
- package/CheckBox/types.ts +3 -5
- package/Consts/colors+spacing+radius.ts +0 -14
- package/Icon/index.tsx +8 -9
- package/Icon/types.ts +2 -2
- package/IconButton/index.tsx +14 -24
- package/Image/index.tsx +8 -23
- package/Image/types.ts +0 -2
- package/Input/Input.tsx +26 -116
- package/Input/InputDropDown.tsx +51 -66
- package/Input/InputMoney.tsx +15 -106
- package/Input/InputOTP.tsx +26 -49
- package/Input/InputSearch.tsx +99 -252
- package/Input/InputTextArea.tsx +6 -26
- package/Input/common.tsx +22 -48
- package/Input/index.tsx +77 -112
- package/Input/styles.ts +11 -48
- package/Input/utils.ts +1 -1
- package/Layout/Card.tsx +3 -4
- package/Layout/GridSystem.tsx +1 -1
- package/Layout/ItemList.tsx +2 -3
- package/Layout/Screen.tsx +121 -242
- package/Layout/Section.tsx +3 -4
- package/Layout/styles.ts +13 -11
- package/Layout/types.ts +1 -1
- package/Layout/utils.ts +4 -4
- package/Loader/index.tsx +0 -2
- package/Pagination/PaginationScroll.tsx +2 -2
- package/Pagination/styles.ts +1 -1
- package/Popup/PopupNotify.tsx +46 -57
- package/Popup/PopupPromotion.tsx +8 -6
- package/Popup/types.ts +7 -1
- package/Radio/index.tsx +20 -35
- package/Radio/types.ts +3 -5
- package/Switch/index.tsx +18 -32
- package/Switch/types.ts +3 -5
- package/Tag/index.tsx +2 -9
- package/Tag/styles.ts +2 -3
- package/Tag/types.ts +0 -12
- package/Text/index.tsx +5 -24
- package/Text/styles.ts +8 -8
- package/Title/index.tsx +103 -170
- package/Title/styles.ts +9 -36
- package/Title/types.ts +48 -16
- package/code-scanner.js +16 -125
- package/index.ts +0 -7
- package/package.json +7 -8
- package/publish.sh +21 -16
- package/tsconfig.json +1 -1
- package/Application/BottomSheet.tsx +0 -216
- package/Application/BottomTab/BottomTabBar.tsx +0 -278
- package/Application/Localize.ts +0 -44
- package/Application/constants.ts +0 -9
- package/Badge/BadgeDotAnimation.tsx +0 -95
- package/Input/TextTyping.tsx +0 -113
- package/Layout/FloatingButton.tsx +0 -168
package/Title/index.tsx
CHANGED
|
@@ -1,196 +1,129 @@
|
|
|
1
1
|
import React, {FC, useContext, useState} from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
LayoutChangeEvent,
|
|
4
|
+
NativeSyntheticEvent,
|
|
5
|
+
Text as RNText,
|
|
6
|
+
TextLayoutEventData,
|
|
7
|
+
TouchableOpacity,
|
|
8
|
+
View,
|
|
9
|
+
} from 'react-native';
|
|
10
|
+
import {TitleProps} from './types';
|
|
3
11
|
import {Icon} from '../Icon';
|
|
4
|
-
import {scaleSize, Text} from '../Text';
|
|
5
|
-
import {ApplicationContext} from '../Application';
|
|
6
|
-
import {Badge} from '../Badge';
|
|
7
|
-
import {Colors} from '../Consts';
|
|
8
12
|
import styles from './styles';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
13
|
+
import {ApplicationContext} from '../Application';
|
|
14
|
+
import {Colors, Spacing} from '../Consts';
|
|
15
|
+
import {scaleSize, Text} from '../Text';
|
|
11
16
|
|
|
12
17
|
const Title: FC<TitleProps> = ({
|
|
13
|
-
|
|
18
|
+
size = 'large',
|
|
14
19
|
type = 'section',
|
|
15
|
-
|
|
20
|
+
onPressAction,
|
|
21
|
+
actionTitle,
|
|
22
|
+
title = 'Title',
|
|
23
|
+
titleFlex = true,
|
|
24
|
+
showAction = true,
|
|
16
25
|
icon,
|
|
17
26
|
description,
|
|
18
|
-
|
|
19
|
-
iconAlign = 'top',
|
|
20
|
-
showRightAction = false,
|
|
21
|
-
showTrailingAction = false,
|
|
22
|
-
badgeLabel,
|
|
23
|
-
buttonTitle,
|
|
24
|
-
onPressRightAction = () => {},
|
|
25
|
-
onPressTrailingAction = () => {},
|
|
26
|
-
buttonSize = 'small',
|
|
27
|
-
textOnly = false,
|
|
28
|
-
style,
|
|
27
|
+
usePadding = true,
|
|
29
28
|
}) => {
|
|
30
29
|
const {theme} = useContext(ApplicationContext);
|
|
31
|
-
const [
|
|
32
|
-
const [
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
const numberOfLines =
|
|
39
|
-
const buttonTypo: Typography =
|
|
40
|
-
buttonSize === 'small' ? 'action_xs_bold' : 'action_s_bold';
|
|
41
|
-
const flexStyle = showTrailingAction && {maxWidth: '70%'};
|
|
42
|
-
|
|
43
|
-
const renderIcon = () => {
|
|
44
|
-
if (!icon) return null;
|
|
45
|
-
|
|
46
|
-
let iconStyle: ViewStyle = {
|
|
47
|
-
justifyContent: 'flex-start',
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
if (iconAlign === 'middle') {
|
|
51
|
-
iconStyle = {justifyContent: 'center'};
|
|
52
|
-
}
|
|
30
|
+
const [containerWidth, setContainerWidth] = useState(0);
|
|
31
|
+
const [textLines, setTextLines] = useState(0);
|
|
32
|
+
const typeStyle =
|
|
33
|
+
type === 'screen' ? styles.screen : styles[`${type}_${size}`];
|
|
34
|
+
const titleWeight = type === 'screen' ? 'Semibold' : 'Bold';
|
|
35
|
+
const marginStyle =
|
|
36
|
+
type === 'section' && usePadding ? {marginTop: Spacing.S} : {};
|
|
37
|
+
const numberOfLines = type === 'section' ? 1 : 2;
|
|
53
38
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
<RNText
|
|
76
|
-
numberOfLines={numberOfLines}
|
|
77
|
-
style={[
|
|
78
|
-
styleSheet[typography],
|
|
79
|
-
styles.title,
|
|
80
|
-
{
|
|
81
|
-
maxWidth:
|
|
82
|
-
contentWidth > 0 ? contentWidth - badgeWidth : undefined,
|
|
83
|
-
},
|
|
84
|
-
]}>
|
|
85
|
-
{title}
|
|
86
|
-
</RNText>
|
|
87
|
-
{badgeLabel && (
|
|
88
|
-
<View
|
|
89
|
-
onLayout={e => {
|
|
90
|
-
if (e.nativeEvent.layout.width !== badgeWidth) {
|
|
91
|
-
setBadgeWidth(e.nativeEvent.layout.width);
|
|
92
|
-
}
|
|
93
|
-
}}
|
|
94
|
-
style={{
|
|
95
|
-
alignItems: 'center',
|
|
96
|
-
}}>
|
|
97
|
-
<Badge style={styles.badge} label={badgeLabel} />
|
|
98
|
-
</View>
|
|
99
|
-
)}
|
|
100
|
-
{renderActionLeft()}
|
|
101
|
-
</View>
|
|
102
|
-
{description && (
|
|
103
|
-
<Text
|
|
104
|
-
style={styles.description}
|
|
105
|
-
color={theme.colors.text.secondary}
|
|
106
|
-
typography={'description_default_regular'}>
|
|
107
|
-
{description}
|
|
108
|
-
</Text>
|
|
109
|
-
)}
|
|
110
|
-
</View>
|
|
39
|
+
const renderAction = () => {
|
|
40
|
+
return !!actionTitle && titleFlex ? (
|
|
41
|
+
<TouchableOpacity onPress={onPressAction}>
|
|
42
|
+
<Text typography={'action_s_bold'} color={theme.colors.primary}>
|
|
43
|
+
{actionTitle}
|
|
44
|
+
</Text>
|
|
45
|
+
</TouchableOpacity>
|
|
46
|
+
) : (
|
|
47
|
+
<TouchableOpacity
|
|
48
|
+
style={[
|
|
49
|
+
{backgroundColor: theme.colors.primary + '0F'},
|
|
50
|
+
styles.actionIcon,
|
|
51
|
+
{width: scaleSize(22), height: scaleSize(22)},
|
|
52
|
+
]}
|
|
53
|
+
onPress={onPressAction}>
|
|
54
|
+
<Icon
|
|
55
|
+
size={scaleSize(22)}
|
|
56
|
+
color={theme.colors.primary}
|
|
57
|
+
source={'arrow_chevron_right_small'}
|
|
58
|
+
/>
|
|
59
|
+
</TouchableOpacity>
|
|
111
60
|
);
|
|
112
61
|
};
|
|
113
62
|
|
|
114
|
-
const
|
|
63
|
+
const renderSemiAction = () => {
|
|
64
|
+
if (textLines > 1) return null;
|
|
115
65
|
return (
|
|
116
66
|
<TouchableOpacity
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
]}>
|
|
129
|
-
<Icon
|
|
130
|
-
source={'arrow_chevron_right_small'}
|
|
131
|
-
size={scaleSize(18)}
|
|
132
|
-
color={theme.colors.text.default}
|
|
133
|
-
/>
|
|
134
|
-
</View>
|
|
135
|
-
)}
|
|
67
|
+
style={[
|
|
68
|
+
{backgroundColor: Colors.black_06},
|
|
69
|
+
styles.actionIcon,
|
|
70
|
+
{width: scaleSize(18), height: scaleSize(18)},
|
|
71
|
+
]}
|
|
72
|
+
onPress={onPressAction}>
|
|
73
|
+
<Icon
|
|
74
|
+
size={scaleSize(18)}
|
|
75
|
+
color={theme.colors.text.default}
|
|
76
|
+
source={'arrow_chevron_right_small'}
|
|
77
|
+
/>
|
|
136
78
|
</TouchableOpacity>
|
|
137
79
|
);
|
|
138
80
|
};
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
if (!showRightAction || showTrailingAction) return false;
|
|
142
|
-
|
|
143
|
-
const lineHeight = styleSheet[typography].lineHeight;
|
|
144
|
-
|
|
145
|
-
return (
|
|
146
|
-
<View
|
|
147
|
-
style={{
|
|
148
|
-
height: lineHeight,
|
|
149
|
-
justifyContent: 'center',
|
|
150
|
-
}}>
|
|
151
|
-
{!buttonTitle ? (
|
|
152
|
-
<TouchableOpacity
|
|
153
|
-
onPress={onPressRightAction}
|
|
154
|
-
style={[
|
|
155
|
-
styles.iconRight,
|
|
156
|
-
{
|
|
157
|
-
backgroundColor: theme.colors.primary + '0F',
|
|
158
|
-
},
|
|
159
|
-
]}>
|
|
160
|
-
<Icon
|
|
161
|
-
source={'arrow_chevron_right_small'}
|
|
162
|
-
size={scaleSize(22)}
|
|
163
|
-
color={theme.colors.primary}
|
|
164
|
-
/>
|
|
165
|
-
</TouchableOpacity>
|
|
166
|
-
) : (
|
|
167
|
-
<TouchableOpacity onPress={onPressRightAction}>
|
|
168
|
-
<Text color={theme.colors.primary} typography={buttonTypo}>
|
|
169
|
-
{buttonTitle}
|
|
170
|
-
</Text>
|
|
171
|
-
</TouchableOpacity>
|
|
172
|
-
)}
|
|
173
|
-
</View>
|
|
174
|
-
);
|
|
81
|
+
const onLayout = (e: LayoutChangeEvent) => {
|
|
82
|
+
setContainerWidth(e.nativeEvent.layout.width);
|
|
175
83
|
};
|
|
176
84
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
<RNText
|
|
181
|
-
numberOfLines={numberOfLines}
|
|
182
|
-
style={[styleSheet[typography], styles.title]}>
|
|
183
|
-
{title}
|
|
184
|
-
</RNText>
|
|
185
|
-
</View>
|
|
186
|
-
);
|
|
187
|
-
}
|
|
85
|
+
const onTextLayout = (e: NativeSyntheticEvent<TextLayoutEventData>) => {
|
|
86
|
+
setTextLines(e.nativeEvent.lines.length);
|
|
87
|
+
};
|
|
188
88
|
|
|
189
89
|
return (
|
|
190
|
-
<View style={[
|
|
191
|
-
{
|
|
192
|
-
|
|
193
|
-
|
|
90
|
+
<View onLayout={onLayout} style={[styles.wrapper, marginStyle]}>
|
|
91
|
+
{!!icon && type !== 'screen' && (
|
|
92
|
+
<Icon style={styles.icon} source={icon} />
|
|
93
|
+
)}
|
|
94
|
+
<View style={{flex: 1, flexDirection: 'row'}}>
|
|
95
|
+
<View style={styles.textContent}>
|
|
96
|
+
<View
|
|
97
|
+
style={{
|
|
98
|
+
flexDirection: 'row',
|
|
99
|
+
maxWidth: containerWidth - scaleSize(22),
|
|
100
|
+
}}>
|
|
101
|
+
<RNText
|
|
102
|
+
onTextLayout={onTextLayout}
|
|
103
|
+
numberOfLines={numberOfLines}
|
|
104
|
+
style={[
|
|
105
|
+
typeStyle,
|
|
106
|
+
{
|
|
107
|
+
fontFamily: `${theme.font}-${titleWeight}`,
|
|
108
|
+
color: theme.colors.text.default,
|
|
109
|
+
marginRight: Spacing.S,
|
|
110
|
+
},
|
|
111
|
+
]}>
|
|
112
|
+
{title}
|
|
113
|
+
</RNText>
|
|
114
|
+
{!titleFlex && renderSemiAction()}
|
|
115
|
+
</View>
|
|
116
|
+
{!!description && type !== 'screen' && (
|
|
117
|
+
<Text
|
|
118
|
+
numberOfLines={1}
|
|
119
|
+
typography={'description_default_regular'}
|
|
120
|
+
color={theme.colors.text.secondary}>
|
|
121
|
+
{description}
|
|
122
|
+
</Text>
|
|
123
|
+
)}
|
|
124
|
+
</View>
|
|
125
|
+
{showAction && titleFlex && type !== 'screen' && renderAction()}
|
|
126
|
+
</View>
|
|
194
127
|
</View>
|
|
195
128
|
);
|
|
196
129
|
};
|
package/Title/styles.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {StyleSheet} from 'react-native';
|
|
2
2
|
import {scaleSize} from '../Text';
|
|
3
|
-
import {
|
|
3
|
+
import {Radius, Spacing} from '../Consts';
|
|
4
4
|
|
|
5
5
|
export default StyleSheet.create({
|
|
6
6
|
card_small: {
|
|
@@ -27,6 +27,10 @@ export default StyleSheet.create({
|
|
|
27
27
|
fontSize: scaleSize(24),
|
|
28
28
|
lineHeight: scaleSize(34),
|
|
29
29
|
},
|
|
30
|
+
screen: {
|
|
31
|
+
fontSize: scaleSize(36),
|
|
32
|
+
lineHeight: scaleSize(44),
|
|
33
|
+
},
|
|
30
34
|
actionIcon: {
|
|
31
35
|
borderRadius: Radius.M,
|
|
32
36
|
alignItems: 'center',
|
|
@@ -37,43 +41,12 @@ export default StyleSheet.create({
|
|
|
37
41
|
borderRadius: Radius.XS,
|
|
38
42
|
},
|
|
39
43
|
wrapper: {
|
|
44
|
+
width: '100%',
|
|
40
45
|
flexDirection: 'row',
|
|
41
|
-
},
|
|
42
|
-
margin: {
|
|
43
|
-
marginTop: Spacing.S,
|
|
44
|
-
},
|
|
45
|
-
iconView: {
|
|
46
|
-
marginRight: Spacing.S,
|
|
47
|
-
},
|
|
48
|
-
iconRight: {
|
|
49
|
-
width: 22,
|
|
50
|
-
height: 22,
|
|
51
|
-
borderRadius: Radius.M,
|
|
52
46
|
alignItems: 'center',
|
|
53
|
-
justifyContent: 'center',
|
|
54
|
-
marginLeft: Spacing.S,
|
|
55
47
|
},
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
borderRadius: Radius.M,
|
|
60
|
-
alignItems: 'center',
|
|
61
|
-
justifyContent: 'center',
|
|
62
|
-
marginHorizontal: Spacing.XS,
|
|
63
|
-
},
|
|
64
|
-
iconLeftView: {
|
|
65
|
-
flexDirection: 'row',
|
|
66
|
-
alignItems: 'center',
|
|
67
|
-
},
|
|
68
|
-
contentView: {marginRight: Spacing.S, flex: 1},
|
|
69
|
-
title: {
|
|
70
|
-
fontWeight: 'bold',
|
|
71
|
-
color: Colors.black_17,
|
|
72
|
-
},
|
|
73
|
-
badge: {
|
|
74
|
-
marginLeft: Spacing.XS,
|
|
75
|
-
},
|
|
76
|
-
description: {
|
|
77
|
-
marginTop: Spacing.XS,
|
|
48
|
+
textContent: {
|
|
49
|
+
marginRight: Spacing.S,
|
|
50
|
+
flex: 1,
|
|
78
51
|
},
|
|
79
52
|
});
|
package/Title/types.ts
CHANGED
|
@@ -1,20 +1,52 @@
|
|
|
1
|
-
import {ViewStyle} from 'react-native';
|
|
2
|
-
|
|
3
1
|
export type TitleProps = {
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Optional. Defines the type of Title component.
|
|
4
|
+
* 'screen' - Used for screen titles.
|
|
5
|
+
* 'section' - Used for section titles within a screen.
|
|
6
|
+
* 'card' - Used for titles within a card component.
|
|
7
|
+
*/
|
|
8
|
+
type?: 'screen' | 'section' | 'card';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Required. The text of the title.
|
|
12
|
+
*/
|
|
6
13
|
title: string;
|
|
7
|
-
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Optional. A description or subtitle that appears below the title.
|
|
17
|
+
*/
|
|
8
18
|
description?: string;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Optional. Defines the size of the Title component.
|
|
22
|
+
* 'large' - A larger, more prominent title.
|
|
23
|
+
* 'small' - A smaller, less prominent title.
|
|
24
|
+
*/
|
|
25
|
+
size?: 'large' | 'medium' | 'small';
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Optional. Represents the name or key of the icon to be displayed alongside the title.
|
|
29
|
+
*/
|
|
30
|
+
icon?: string;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Optional. If `true`, the title will be flexible in its container, adjusting its width dynamically.
|
|
34
|
+
*/
|
|
35
|
+
titleFlex?: boolean;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Optional. Text for an action button associated with the title.
|
|
39
|
+
*/
|
|
40
|
+
actionTitle?: string;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Optional. Function to be called when the action associated with the title is pressed.
|
|
44
|
+
*/
|
|
45
|
+
onPressAction?: () => void;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Optional. If `true`, an action button or icon is displayed alongside the title.
|
|
49
|
+
*/
|
|
50
|
+
showAction?: boolean;
|
|
51
|
+
usePadding?: boolean;
|
|
20
52
|
};
|
package/code-scanner.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const scanner = require('react-scanner');
|
|
2
|
-
const fs = require('fs');
|
|
3
2
|
const path = require('path');
|
|
4
3
|
|
|
5
4
|
const scan = async config => {
|
|
@@ -10,151 +9,43 @@ const calcSum = array => {
|
|
|
10
9
|
return array.reduce((a, b) => a + b, 0);
|
|
11
10
|
};
|
|
12
11
|
|
|
13
|
-
const calculateAdoptionRate =
|
|
14
|
-
branchName,
|
|
15
|
-
kitJsonPath,
|
|
16
|
-
miniappJsonPath,
|
|
17
|
-
reactNativeJsonPath,
|
|
18
|
-
fsJsonPath
|
|
19
|
-
) => {
|
|
12
|
+
const calculateAdoptionRate = (kitJsonPath, miniappJsonPath) => {
|
|
20
13
|
const kitJson = require(kitJsonPath);
|
|
21
14
|
const miniAppJson = require(miniappJsonPath);
|
|
22
|
-
const reactNativeJson = require(reactNativeJsonPath);
|
|
23
|
-
const fsJson = require(fsJsonPath);
|
|
24
|
-
|
|
25
15
|
const numOfKitComponents = calcSum(Object.values(kitJson));
|
|
26
16
|
const numOfMiniAppComponents = calcSum(Object.values(miniAppJson));
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
((numOfKitComponents + numOfReactNativeComponents + numOfFSComponents) /
|
|
32
|
-
numOfMiniAppComponents) *
|
|
33
|
-
100;
|
|
34
|
-
|
|
35
|
-
return {
|
|
36
|
-
miniAppName: branchName,
|
|
37
|
-
numOfKitComponents: numOfKitComponents,
|
|
38
|
-
numOfMiniAppComponents: numOfMiniAppComponents,
|
|
39
|
-
numOfReactNativeComponents: numOfReactNativeComponents,
|
|
40
|
-
numOfFSComponents: numOfFSComponents,
|
|
41
|
-
adoptionRate: adoptionRate.toFixed(2) + '%',
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
function ensureFileExists(filePath, defaultContent = {}) {
|
|
46
|
-
if (!fs.existsSync(filePath)) {
|
|
47
|
-
fs.mkdirSync(path.dirname(filePath), {recursive: true});
|
|
48
|
-
fs.writeFileSync(filePath, JSON.stringify(defaultContent, null, 2));
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const sendMessage = ({
|
|
53
|
-
numOfKitComponents,
|
|
54
|
-
numOfMiniAppComponents,
|
|
55
|
-
numOfFSComponents,
|
|
56
|
-
numOfReactNativeComponents,
|
|
57
|
-
adoptionRate,
|
|
58
|
-
miniAppName = '',
|
|
59
|
-
}) => {
|
|
60
|
-
const url =
|
|
61
|
-
'https://chat.googleapis.com/v1/spaces/AAAAL9P6G8M/messages?key=AIzaSyDdI0hCZtE6vySjMm-WEfRq3CPzqKqqsHI&token=fnwfYuH_u0KicBnKTSSm9S0qV6azJH5v6URm8HR7V2g';
|
|
62
|
-
|
|
63
|
-
const data = {
|
|
64
|
-
text: `MiniApp: ${miniAppName}\nNumber of kit's components: ${numOfKitComponents}\nNumber of miniapp's components: ${numOfMiniAppComponents}\nNumber of FS's components: ${numOfFSComponents}\nNumber of React Native's components: ${numOfReactNativeComponents}\nAdoption rate: ${adoptionRate}`,
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
fetch(url, {
|
|
68
|
-
method: 'POST',
|
|
69
|
-
headers: {
|
|
70
|
-
'Content-Type': 'application/json',
|
|
71
|
-
},
|
|
72
|
-
body: JSON.stringify(data),
|
|
73
|
-
})
|
|
74
|
-
.then(response => response.json())
|
|
75
|
-
.then(data => {
|
|
76
|
-
console.log('Success:', data);
|
|
77
|
-
})
|
|
78
|
-
.catch(error => {
|
|
79
|
-
console.error('Error:', error);
|
|
80
|
-
});
|
|
17
|
+
const adoptionRate = (numOfKitComponents / numOfMiniAppComponents) * 100;
|
|
18
|
+
console.log("Number of kit's components: ", numOfKitComponents);
|
|
19
|
+
console.log("Number of miniapp's components: ", numOfMiniAppComponents);
|
|
20
|
+
console.log('Adoption rate: ', adoptionRate);
|
|
81
21
|
};
|
|
82
22
|
|
|
83
23
|
const main = async () => {
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
const appJson = require(app);
|
|
87
|
-
const branchName = appJson.appId;
|
|
88
|
-
|
|
89
|
-
if (!branchName || !branchName.includes('vn.momo')) {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
24
|
+
const [scanPath, kitJsonRelativePath, miniappJsonRelativePath] =
|
|
25
|
+
process.argv.slice(2);
|
|
92
26
|
|
|
93
|
-
const
|
|
94
|
-
const
|
|
95
|
-
const miniappJsonPath = path.join(rootPath, './scan/miniapp.json');
|
|
96
|
-
const reactNativeJsonPath = path.join(rootPath, './scan/RN.json');
|
|
97
|
-
const fsJsonPath = path.join(rootPath, './scan/verLib.json');
|
|
98
|
-
|
|
99
|
-
const allKitsReg = /@momo-kits/;
|
|
100
|
-
const fsReg =
|
|
101
|
-
/^(?:@fs-mobile-platform\/(components(\/.*)?|investment(\/.*)?|screens(\/.*)?|foundation(\/.*)?)|@miniapp-platform\/(components(\/.*)?|foundation(\/.*)?))$/;
|
|
102
|
-
const RNReg = /react-native|react-native-svg/;
|
|
27
|
+
const kitJsonPath = path.resolve(process.cwd(), kitJsonRelativePath);
|
|
28
|
+
const miniappJsonPath = path.resolve(process.cwd(), miniappJsonRelativePath);
|
|
103
29
|
|
|
104
30
|
const config1 = {
|
|
105
31
|
crawlFrom: scanPath,
|
|
106
32
|
includeSubComponents: true,
|
|
107
|
-
importedFrom:
|
|
33
|
+
importedFrom: /@momo-kits\/.+/,
|
|
108
34
|
processors: [['count-components', {outputTo: kitJsonPath}]],
|
|
109
|
-
rootDir:
|
|
35
|
+
rootDir: './',
|
|
110
36
|
};
|
|
111
37
|
|
|
112
38
|
const config2 = {
|
|
113
39
|
crawlFrom: scanPath,
|
|
114
40
|
includeSubComponents: true,
|
|
115
41
|
processors: [['count-components', {outputTo: miniappJsonPath}]],
|
|
116
|
-
rootDir:
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
const config3 = {
|
|
120
|
-
crawlFrom: scanPath,
|
|
121
|
-
includeSubComponents: true,
|
|
122
|
-
importedFrom: RNReg,
|
|
123
|
-
processors: [['count-components', {outputTo: reactNativeJsonPath}]],
|
|
124
|
-
rootDir: process.cwd(),
|
|
42
|
+
rootDir: './',
|
|
125
43
|
};
|
|
126
44
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
includeSubComponents: true,
|
|
130
|
-
importedFrom: fsReg,
|
|
131
|
-
processors: [['count-components', {outputTo: fsJsonPath}]],
|
|
132
|
-
rootDir: process.cwd(),
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
try {
|
|
136
|
-
ensureFileExists(kitJsonPath, {});
|
|
137
|
-
ensureFileExists(miniappJsonPath, {});
|
|
138
|
-
ensureFileExists(reactNativeJsonPath, {});
|
|
139
|
-
ensureFileExists(fsJsonPath, {});
|
|
140
|
-
|
|
141
|
-
await scan(config1);
|
|
142
|
-
await scan(config2);
|
|
143
|
-
await scan(config3);
|
|
144
|
-
await scan(config4);
|
|
45
|
+
await scan(config1);
|
|
46
|
+
await scan(config2);
|
|
145
47
|
|
|
146
|
-
|
|
147
|
-
branchName,
|
|
148
|
-
kitJsonPath,
|
|
149
|
-
miniappJsonPath,
|
|
150
|
-
reactNativeJsonPath,
|
|
151
|
-
fsJsonPath
|
|
152
|
-
);
|
|
153
|
-
sendMessage(result);
|
|
154
|
-
console.log(result);
|
|
155
|
-
} catch (error) {
|
|
156
|
-
console.error('Error during scan or calculation:', error);
|
|
157
|
-
}
|
|
48
|
+
calculateAdoptionRate(kitJsonPath, miniappJsonPath);
|
|
158
49
|
};
|
|
159
50
|
|
|
160
|
-
main();
|
|
51
|
+
main().catch(console.error);
|
package/index.ts
CHANGED
|
@@ -49,10 +49,3 @@ export * from './Title';
|
|
|
49
49
|
export * from './Title/types';
|
|
50
50
|
export * from './Badge';
|
|
51
51
|
export * from './Badge/types';
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* export trick for keep old mini app working
|
|
55
|
-
* @deprecated
|
|
56
|
-
*/
|
|
57
|
-
export * from 'react-native-modalize';
|
|
58
|
-
export * from '@gorhom/bottom-sheet';
|
package/package.json
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@momo-kits/foundation",
|
|
3
|
-
"version": "0.81.
|
|
3
|
+
"version": "0.81.52",
|
|
4
4
|
"description": "React Native Component Kits",
|
|
5
5
|
"main": "index.ts",
|
|
6
|
-
"scripts": {
|
|
6
|
+
"scripts": {
|
|
7
|
+
"postinstall": "node verify.js"
|
|
8
|
+
},
|
|
7
9
|
"keywords": [
|
|
8
10
|
"@momo-kits/foundation"
|
|
9
11
|
],
|
|
10
12
|
"dependencies": {
|
|
11
|
-
"@gorhom/bottom-sheet": "
|
|
13
|
+
"@gorhom/bottom-sheet": "git+https://gitlab.com/momo-platform/bottom-sheet.git#main",
|
|
12
14
|
"react-native-safe-area-context": "3.1.4",
|
|
13
15
|
"react-native-linear-gradient": "2.8.3",
|
|
14
16
|
"react-native-gesture-handler": "1.10.3",
|
|
15
|
-
"react-native-modalize": "2.1.1",
|
|
16
17
|
"react-native-fast-image": "8.1.5",
|
|
17
18
|
"@react-navigation/bottom-tabs": "https://gitlab.mservice.com.vn/momo-platform/react-native-bottom-tabs.git",
|
|
18
19
|
"@react-navigation/core": "5.16.1",
|
|
19
20
|
"@react-navigation/native": "5.9.8",
|
|
20
21
|
"@react-navigation/routers": "5.7.4",
|
|
21
|
-
"lottie-react-native": "
|
|
22
|
+
"lottie-react-native": "3.3.2",
|
|
22
23
|
"@react-navigation/stack": "https://gitlab.mservice.com.vn/momo-platform/react-navigation-stack.git"
|
|
23
24
|
},
|
|
24
25
|
"peerDependencies": {
|
|
@@ -31,7 +32,6 @@
|
|
|
31
32
|
"@types/jest": "26.0.23",
|
|
32
33
|
"@types/react-native": "0.64.4",
|
|
33
34
|
"@types/react-test-renderer": "16.9.2",
|
|
34
|
-
"@types/d3-shape": "1.3.7",
|
|
35
35
|
"babel-jest": "^26.6.3",
|
|
36
36
|
"eslint": "^7.14.0",
|
|
37
37
|
"jest": "^26.6.3",
|
|
@@ -39,8 +39,7 @@
|
|
|
39
39
|
"react-test-renderer": "17.0.1",
|
|
40
40
|
"typescript": "^4.0.3",
|
|
41
41
|
"@momo-platform/versions": "4.1.11",
|
|
42
|
-
"react-scanner": "^1.1.0"
|
|
43
|
-
"@types/color": "3.0.6"
|
|
42
|
+
"react-scanner": "^1.1.0"
|
|
44
43
|
},
|
|
45
44
|
"author": "@momo-kits/foundation",
|
|
46
45
|
"license": "ISC"
|