@momo-kits/foundation 0.76.1-beta.2 → 0.77.1-optimize.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/Application/BottomTab/BottomTabBar.tsx +478 -0
  2. package/Application/BottomTab/index.tsx +134 -0
  3. package/Application/Components.tsx +339 -161
  4. package/Application/ModalScreen.tsx +113 -99
  5. package/Application/Navigation.ts +22 -16
  6. package/Application/NavigationContainer.tsx +99 -48
  7. package/Application/Navigator.ts +110 -41
  8. package/Application/StackScreen.tsx +129 -8
  9. package/Application/index.ts +23 -4
  10. package/Application/types.ts +84 -33
  11. package/Application/utils.tsx +71 -49
  12. package/Assets/DotAnimation.json +256 -0
  13. package/Assets/SpinnerAnimation.json +1027 -0
  14. package/Assets/icon.json +83 -5
  15. package/Assets/icon_bank.json +506 -0
  16. package/Assets/language.json +202 -0
  17. package/Badge/Badge.tsx +56 -0
  18. package/Badge/BadgeDot.tsx +11 -0
  19. package/Badge/BadgeRibbon.tsx +125 -0
  20. package/Badge/Shape.tsx +29 -0
  21. package/Badge/index.tsx +7 -0
  22. package/Badge/styles.ts +58 -0
  23. package/Badge/types.ts +63 -0
  24. package/Button/index.tsx +90 -39
  25. package/Button/styles.ts +19 -0
  26. package/CheckBox/index.tsx +58 -43
  27. package/CheckBox/styles.ts +1 -1
  28. package/CheckBox/types.ts +6 -4
  29. package/Consts/colors+spacing+radius.ts +18 -0
  30. package/Consts/styles.ts +0 -26
  31. package/Consts/theme.ts +4 -0
  32. package/Divider/index.tsx +2 -0
  33. package/Icon/index.tsx +14 -9
  34. package/Icon/types.ts +4 -3
  35. package/IconButton/index.tsx +24 -15
  36. package/Image/index.tsx +63 -47
  37. package/Image/styles.ts +1 -9
  38. package/Image/types.ts +5 -1
  39. package/Input/Input.tsx +227 -116
  40. package/Input/InputDropDown.tsx +132 -0
  41. package/Input/InputMoney.tsx +174 -111
  42. package/Input/InputOTP.tsx +257 -0
  43. package/Input/InputSearch.tsx +160 -132
  44. package/Input/InputTextArea.tsx +150 -123
  45. package/Input/common.tsx +42 -17
  46. package/Input/index.tsx +204 -18
  47. package/Input/styles.ts +44 -7
  48. package/Input/utils.ts +2 -2
  49. package/Layout/Card.tsx +67 -29
  50. package/Layout/FloatingButton.tsx +149 -0
  51. package/Layout/GridSystem.tsx +31 -21
  52. package/Layout/Item.tsx +21 -25
  53. package/Layout/ItemList.tsx +55 -0
  54. package/Layout/ItemSectionList.tsx +39 -0
  55. package/Layout/Screen.tsx +343 -153
  56. package/Layout/Section.tsx +66 -34
  57. package/Layout/index.ts +13 -3
  58. package/Layout/styles.ts +101 -0
  59. package/Layout/types.ts +1 -39
  60. package/Layout/utils.ts +27 -52
  61. package/Loader/DotLoader.tsx +37 -0
  62. package/Loader/Loader.tsx +13 -0
  63. package/Loader/ProgressBar.tsx +44 -0
  64. package/Loader/Spinner.tsx +29 -0
  65. package/Loader/index.tsx +4 -0
  66. package/Loader/styles.ts +10 -0
  67. package/Loader/types.ts +35 -0
  68. package/Loader/utils.ts +25 -0
  69. package/Pagination/PaginationDot.tsx +7 -2
  70. package/Pagination/PaginationNumber.tsx +8 -6
  71. package/Pagination/PaginationScroll.tsx +0 -1
  72. package/Pagination/PaginationWhiteDot.tsx +8 -5
  73. package/Pagination/styles.ts +3 -0
  74. package/Pagination/types.ts +2 -0
  75. package/Popup/PopupNotify.tsx +108 -46
  76. package/Popup/PopupPromotion.tsx +63 -22
  77. package/Popup/types.ts +15 -4
  78. package/Radio/index.tsx +35 -21
  79. package/Radio/types.ts +7 -5
  80. package/Skeleton/index.tsx +1 -1
  81. package/Skeleton/types.ts +3 -0
  82. package/Switch/index.tsx +35 -24
  83. package/Switch/types.ts +5 -3
  84. package/Tag/index.tsx +2 -4
  85. package/Text/index.tsx +27 -22
  86. package/Text/styles.ts +38 -0
  87. package/Text/types.ts +25 -13
  88. package/Text/utils.ts +1 -1
  89. package/Title/index.tsx +186 -0
  90. package/Title/styles.ts +79 -0
  91. package/Title/types.ts +20 -0
  92. package/code-scanner.js +143 -0
  93. package/index.ts +6 -0
  94. package/migrate_typo.js +56 -0
  95. package/package.json +14 -9
  96. package/tsconfig.json +24 -0
  97. package/verify.js +47 -0
  98. package/Application/BottomTab.tsx +0 -52
  99. package/Application/NavigationButton.tsx +0 -54
  100. package/Assets/header-background.png +0 -0
package/Text/index.tsx CHANGED
@@ -3,7 +3,6 @@ import {Text as RNText, TextProps as RNTextProps} from 'react-native';
3
3
  import styles from './styles';
4
4
  import {Typography, TypographyWeight} from './types';
5
5
  import {ApplicationContext} from '../Application';
6
- import {GridContext} from '../Layout';
7
6
  import {scaleSize} from './utils';
8
7
 
9
8
  const SFProText: TypographyWeight = {
@@ -51,22 +50,30 @@ export interface TextProps extends RNTextProps {
51
50
  * It can be any valid color string (e.g., hex, rgb, rgba, etc.).
52
51
  */
53
52
  color?: string;
54
-
55
- /**
56
- * Optional. Represents the width of the Text component in terms of span numbers.
57
- * It can be used to set a specific width for the text based on a predefined grid system.
58
- */
59
- widthSpan?: number;
60
53
  }
54
+
55
+ const deprecatedValues: Typography[] = [
56
+ 'headline_default',
57
+ 'headline_l',
58
+ 'headline_xl',
59
+ 'title_default',
60
+ 'title_xs',
61
+ 'title_s',
62
+ 'header_default',
63
+ 'paragraph_default',
64
+ 'paragraph_bold',
65
+ 'paragraph_italic',
66
+ 'label_xxs',
67
+ 'action_s',
68
+ ];
69
+
61
70
  const Text: React.FC<TextProps> = ({
62
- typography,
71
+ typography = 'body_default_regular',
63
72
  color,
64
73
  children,
65
74
  style,
66
- widthSpan,
67
75
  ...rest
68
76
  }) => {
69
- const grid = useContext(GridContext);
70
77
  const {theme} = useContext(ApplicationContext);
71
78
 
72
79
  const getTypoStyle = (typo: Typography) => {
@@ -93,32 +100,30 @@ const Text: React.FC<TextProps> = ({
93
100
  }
94
101
 
95
102
  return {
103
+ ...typoStyle,
96
104
  fontFamily,
97
105
  fontSize: scaleSize(fontSize),
98
106
  lineHeight: scaleSize(lineHeight),
99
107
  fontStyle,
108
+ fontWeight,
100
109
  };
101
110
  };
102
111
 
103
112
  const textStyle = getTypoStyle(typography);
104
- const spanStyle = widthSpan ? {width: grid.getSizeSpan(widthSpan)} : {};
113
+
114
+ if (deprecatedValues.includes(typography)) {
115
+ console.warn(
116
+ `Warning: The typography value "${typography}" is deprecated.`,
117
+ );
118
+ }
119
+
105
120
  return (
106
121
  <RNText
107
122
  {...rest}
108
- accessibilityLabel={`Text/${children}`}
109
- style={[
110
- style,
111
- textStyle,
112
- spanStyle,
113
- {color: color ?? theme.colors.text.default},
114
- ]}>
123
+ style={[style, textStyle, {color: color ?? theme.colors.text.default}]}>
115
124
  {children ?? ''}
116
125
  </RNText>
117
126
  );
118
127
  };
119
128
 
120
- Text.defaultProps = {
121
- typography: 'paragraph_default',
122
- };
123
-
124
129
  export {Text, scaleSize};
package/Text/styles.ts CHANGED
@@ -1,4 +1,42 @@
1
1
  export default {
2
+ headline_default_bold: {fontSize: 24, lineHeight: 34, fontWeight: '700'},
3
+ header_m_bold: {fontSize: 18, lineHeight: 26, fontWeight: '700'},
4
+ header_default_bold: {fontSize: 16, lineHeight: 22, fontWeight: '700'},
5
+ header_s_semibold: {fontSize: 14, lineHeight: 20, fontWeight: '600'},
6
+ header_xs_semibold: {fontSize: 12, lineHeight: 18, fontWeight: '600'},
7
+ body_default_regular: {fontSize: 14, lineHeight: 20, fontWeight: '400'},
8
+ body_default_regularstrikethrought: {
9
+ fontSize: 14,
10
+ lineHeight: 20,
11
+ fontWeight: '400',
12
+ textDecorationLine: 'line-through',
13
+ },
14
+ description_default_regular: {
15
+ fontSize: 12,
16
+ lineHeight: 18,
17
+ fontWeight: '400',
18
+ },
19
+ description_default_regularstrikethrought: {
20
+ fontSize: 12,
21
+ lineHeight: 18,
22
+ fontWeight: '400',
23
+ textDecorationLine: 'line-through',
24
+ },
25
+ description_xs_regular: {fontSize: 10, lineHeight: 14, fontWeight: '400'},
26
+ description_xs_regularstrikethrought: {
27
+ fontSize: 10,
28
+ lineHeight: 14,
29
+ fontWeight: '400',
30
+ textDecorationLine: 'line-through',
31
+ },
32
+ label_default_medium: {fontSize: 14, lineHeight: 20, fontWeight: '500'},
33
+ label_s_medium: {fontSize: 12, lineHeight: 18, fontWeight: '500'},
34
+ label_xs_medium: {fontSize: 10, lineHeight: 14, fontWeight: '500'},
35
+ action_default_bold: {fontSize: 16, lineHeight: 22, fontWeight: '700'},
36
+ action_s_bold: {fontSize: 14, lineHeight: 20, fontWeight: '700'},
37
+ action_xs_bold: {fontSize: 12, lineHeight: 18, fontWeight: '700'},
38
+ action_xxs_bold: {fontSize: 10, lineHeight: 14, fontWeight: '700'},
39
+ /**non-support**/
2
40
  headline_default: {
3
41
  fontSize: 28,
4
42
  lineHeight: 34,
package/Text/types.ts CHANGED
@@ -14,27 +14,39 @@ export type TypographyWeight = {
14
14
  };
15
15
 
16
16
  export type Typography =
17
+ /**
18
+ * @deprecated
19
+ **/
17
20
  | 'headline_default'
18
- | 'headline_s'
19
21
  | 'headline_l'
20
22
  | 'headline_xl'
21
23
  | 'title_default'
22
24
  | 'title_xs'
23
25
  | 'title_s'
24
26
  | 'header_default'
25
- | 'header_xs'
26
- | 'header_s'
27
27
  | 'paragraph_default'
28
28
  | 'paragraph_bold'
29
29
  | 'paragraph_italic'
30
- | 'description_default'
31
- | 'description_xs'
32
- | 'description_s'
33
- | 'label_default'
34
30
  | 'label_xxs'
35
- | 'label_xs'
36
- | 'label_s'
37
- | 'action_default'
38
- | 'action_xxs'
39
- | 'action_xs'
40
- | 'action_s';
31
+ | 'action_s'
32
+ /**
33
+ * end
34
+ **/
35
+ | 'headline_default_bold'
36
+ | 'header_m_bold'
37
+ | 'header_default_bold'
38
+ | 'header_s_semibold'
39
+ | 'header_xs_semibold'
40
+ | 'body_default_regular'
41
+ | 'body_default_regularstrikethrought'
42
+ | 'description_default_regular'
43
+ | 'description_default_regularstrikethrought'
44
+ | 'description_xs_regular'
45
+ | 'description_xs_regularstrikethrought'
46
+ | 'label_default_medium'
47
+ | 'label_s_medium'
48
+ | 'label_xs_medium'
49
+ | 'action_default_bold'
50
+ | 'action_s_bold'
51
+ | 'action_xs_bold'
52
+ | 'action_xxs_bold';
package/Text/utils.ts CHANGED
@@ -6,7 +6,7 @@ const scaleSize = (size: number) => {
6
6
  const scaleRate = deviceWidth / DEFAULT_SCREEN_SIZE;
7
7
 
8
8
  if (scaleRate > 1) {
9
- return Math.min(Math.round(size * scaleRate), size + 5);
9
+ return Math.min(Math.round(size * scaleRate), size + 3);
10
10
  }
11
11
 
12
12
  return size;
@@ -0,0 +1,186 @@
1
+ import React, {FC, useContext, useState} from 'react';
2
+ import {Text as RNText, TouchableOpacity, View, ViewStyle} from 'react-native';
3
+ import styles from './styles';
4
+ import {Icon} from '../Icon';
5
+ import {scaleSize, Text} from '../Text';
6
+ import {ApplicationContext} from '../Application';
7
+ import {Badge} from '../Badge';
8
+ import {Typography} from '../Text/types';
9
+ import {TitleProps} from './types';
10
+ import {Colors} from '../Consts';
11
+
12
+ const Title: FC<TitleProps> = ({
13
+ title = 'Title',
14
+ type = 'section',
15
+ size = 'medium',
16
+ icon,
17
+ description,
18
+ iconColor = null,
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,
29
+ }) => {
30
+ const {theme} = useContext(ApplicationContext);
31
+ const [badgeWidth, setBadgeWidth] = useState(0);
32
+ const [contentWidth, setContentWidth] = useState(0);
33
+ const styleSheet: {
34
+ [key: string]: any;
35
+ } = styles;
36
+ const typography = `${type}_${size}`;
37
+ const isSection = type === 'section';
38
+ const numberOfLines = showTrailingAction || !!badgeLabel ? 1 : 2;
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
+ }
53
+
54
+ if (iconAlign === 'bottom') {
55
+ iconStyle = {justifyContent: 'flex-end'};
56
+ }
57
+
58
+ return (
59
+ <View style={[styles.iconView, iconStyle]}>
60
+ <Icon color={iconColor} source={icon} />
61
+ </View>
62
+ );
63
+ };
64
+
65
+ const renderContent = () => {
66
+ return (
67
+ <View style={styles.contentView}>
68
+ <View
69
+ onLayout={e => {
70
+ setContentWidth(e.nativeEvent.layout.width);
71
+ }}
72
+ style={[styles.iconLeftView, flexStyle]}>
73
+ <RNText
74
+ numberOfLines={numberOfLines}
75
+ style={[
76
+ styleSheet[typography],
77
+ styles.title,
78
+ {maxWidth: contentWidth - badgeWidth},
79
+ ]}>
80
+ {title}
81
+ </RNText>
82
+ {badgeLabel && (
83
+ <View
84
+ onLayout={e => {
85
+ setBadgeWidth(e.nativeEvent.layout.width);
86
+ }}
87
+ style={{
88
+ alignItems: 'center',
89
+ }}>
90
+ <Badge style={styles.badge} label={badgeLabel} />
91
+ </View>
92
+ )}
93
+ {renderActionLeft()}
94
+ </View>
95
+ {description && (
96
+ <Text
97
+ style={styles.description}
98
+ color={theme.colors.text.secondary}
99
+ typography={'description_default_regular'}>
100
+ {description}
101
+ </Text>
102
+ )}
103
+ </View>
104
+ );
105
+ };
106
+
107
+ const renderActionLeft = () => {
108
+ return (
109
+ <TouchableOpacity
110
+ onPress={onPressTrailingAction}
111
+ style={styles.iconLeftView}>
112
+ {showTrailingAction && !showRightAction && (
113
+ <View
114
+ style={[
115
+ styles.iconLeft,
116
+ {
117
+ backgroundColor: isSection
118
+ ? Colors.black_06 + '99'
119
+ : Colors.black_06 + '4D',
120
+ },
121
+ ]}>
122
+ <Icon
123
+ source={'arrow_chevron_right_small'}
124
+ size={scaleSize(18)}
125
+ color={theme.colors.text.default}
126
+ />
127
+ </View>
128
+ )}
129
+ </TouchableOpacity>
130
+ );
131
+ };
132
+
133
+ const renderActionRight = () => {
134
+ if (!showRightAction || showTrailingAction) return false;
135
+
136
+ return (
137
+ <View>
138
+ {!buttonTitle ? (
139
+ <TouchableOpacity
140
+ onPress={onPressRightAction}
141
+ style={[
142
+ styles.iconRight,
143
+ {
144
+ backgroundColor: theme.colors.primary + '0F',
145
+ },
146
+ ]}>
147
+ <Icon
148
+ source={'arrow_chevron_right_small'}
149
+ size={scaleSize(22)}
150
+ color={theme.colors.primary}
151
+ />
152
+ </TouchableOpacity>
153
+ ) : (
154
+ <TouchableOpacity onPress={onPressRightAction}>
155
+ <Text color={theme.colors.primary} typography={buttonTypo}>
156
+ {buttonTitle}
157
+ </Text>
158
+ </TouchableOpacity>
159
+ )}
160
+ </View>
161
+ );
162
+ };
163
+
164
+ if (textOnly) {
165
+ return (
166
+ <View style={isSection && styles.margin}>
167
+ <RNText
168
+ numberOfLines={numberOfLines}
169
+ style={[styleSheet[typography], styles.title]}>
170
+ {title}
171
+ </RNText>
172
+ </View>
173
+ );
174
+ }
175
+
176
+ return (
177
+ <View style={[style, styles.wrapper, isSection && styles.margin]}>
178
+ {renderIcon()}
179
+ {renderContent()}
180
+ {renderActionRight()}
181
+ </View>
182
+ );
183
+ };
184
+
185
+ export {Title};
186
+ export type {TitleProps};
@@ -0,0 +1,79 @@
1
+ import {StyleSheet} from 'react-native';
2
+ import {scaleSize} from '../Text';
3
+ import {Colors, Radius, Spacing} from '../Consts';
4
+
5
+ export default StyleSheet.create({
6
+ card_small: {
7
+ fontSize: scaleSize(14),
8
+ lineHeight: scaleSize(20),
9
+ },
10
+ card_medium: {
11
+ fontSize: scaleSize(16),
12
+ lineHeight: scaleSize(22),
13
+ },
14
+ card_large: {
15
+ fontSize: scaleSize(18),
16
+ lineHeight: scaleSize(26),
17
+ },
18
+ section_medium: {
19
+ fontSize: scaleSize(20),
20
+ lineHeight: scaleSize(28),
21
+ },
22
+ section_small: {
23
+ fontSize: scaleSize(16),
24
+ lineHeight: scaleSize(22),
25
+ },
26
+ section_large: {
27
+ fontSize: scaleSize(24),
28
+ lineHeight: scaleSize(34),
29
+ },
30
+ actionIcon: {
31
+ borderRadius: Radius.M,
32
+ alignItems: 'center',
33
+ justifyContent: 'center',
34
+ },
35
+ icon: {
36
+ marginRight: Spacing.S,
37
+ borderRadius: Radius.XS,
38
+ },
39
+ wrapper: {
40
+ flexDirection: 'row',
41
+ },
42
+ margin: {
43
+ marginTop: Spacing.S,
44
+ },
45
+ iconView: {
46
+ marginRight: Spacing.S,
47
+ },
48
+ iconRight: {
49
+ width: scaleSize(22),
50
+ height: scaleSize(22),
51
+ borderRadius: Radius.M,
52
+ alignItems: 'center',
53
+ justifyContent: 'center',
54
+ marginLeft: Spacing.S,
55
+ },
56
+ iconLeft: {
57
+ width: scaleSize(18),
58
+ height: scaleSize(18),
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,
78
+ },
79
+ });
package/Title/types.ts ADDED
@@ -0,0 +1,20 @@
1
+ import {ViewStyle} from 'react-native';
2
+
3
+ export type TitleProps = {
4
+ type?: 'card' | 'section';
5
+ size?: 'small' | 'medium' | 'large';
6
+ title: string;
7
+ icon?: string;
8
+ description?: string;
9
+ iconColor?: string;
10
+ iconAlign?: 'top' | 'middle' | 'bottom';
11
+ showRightAction?: boolean;
12
+ showTrailingAction?: boolean;
13
+ badgeLabel?: string;
14
+ buttonTitle?: string;
15
+ buttonSize?: 'small' | 'large';
16
+ onPressRightAction?: () => void;
17
+ onPressTrailingAction?: () => void;
18
+ textOnly?: boolean;
19
+ style?: ViewStyle;
20
+ };
@@ -0,0 +1,143 @@
1
+ const scanner = require('react-scanner');
2
+ const fs = require('fs');
3
+ const path = require('path');
4
+
5
+ const scan = async (config) => {
6
+ return await scanner.run(config);
7
+ };
8
+
9
+ const calcSum = (array) => {
10
+ return array.reduce((a, b) => a + b, 0);
11
+ };
12
+
13
+ const calculateAdoptionRate = async (branchName , kitJsonPath , miniappJsonPath , reactNativeJsonPath , fsJsonPath ) => {
14
+ const kitJson = require(kitJsonPath);
15
+ const miniAppJson = require(miniappJsonPath);
16
+ const reactNativeJson = require(reactNativeJsonPath);
17
+ const fsJson = require(fsJsonPath);
18
+
19
+ const numOfKitComponents = calcSum(Object.values(kitJson));
20
+ const numOfMiniAppComponents = calcSum(Object.values(miniAppJson));
21
+ const numOfReactNativeComponents = calcSum(Object.values(reactNativeJson));
22
+ const numOfFSComponents = calcSum(Object.values(fsJson));
23
+
24
+ const adoptionRate = ((numOfKitComponents + numOfReactNativeComponents + numOfFSComponents) / numOfMiniAppComponents) * 100;
25
+
26
+ return {
27
+ miniAppName: branchName,
28
+ numOfKitComponents: numOfKitComponents,
29
+ numOfMiniAppComponents: numOfMiniAppComponents,
30
+ numOfReactNativeComponents: numOfReactNativeComponents,
31
+ numOfFSComponents: numOfFSComponents,
32
+ adoptionRate: adoptionRate.toFixed(2) + '%'
33
+ }
34
+ };
35
+
36
+ function ensureFileExists(filePath , defaultContent = {}) {
37
+ if (!fs.existsSync(filePath)) {
38
+ fs.mkdirSync(path.dirname(filePath), { recursive: true });
39
+ fs.writeFileSync(filePath, JSON.stringify(defaultContent, null, 2));
40
+ }
41
+ }
42
+
43
+ const sendMessage = ({
44
+ numOfKitComponents,
45
+ numOfMiniAppComponents,
46
+ numOfFSComponents,
47
+ numOfReactNativeComponents,
48
+ adoptionRate,
49
+ miniAppName = ''
50
+ }) => {
51
+ const url = 'https://chat.googleapis.com/v1/spaces/AAAAL9P6G8M/messages?key=AIzaSyDdI0hCZtE6vySjMm-WEfRq3CPzqKqqsHI&token=fnwfYuH_u0KicBnKTSSm9S0qV6azJH5v6URm8HR7V2g';
52
+
53
+ const data = {
54
+ 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}`
55
+ };
56
+
57
+ fetch(url, {
58
+ method: 'POST',
59
+ headers: {
60
+ 'Content-Type': 'application/json'
61
+ },
62
+ body: JSON.stringify(data)
63
+ })
64
+ .then(response => response.json())
65
+ .then(data => {
66
+ console.log('Success:', data);
67
+ })
68
+ .catch((error) => {
69
+ console.error('Error:', error);
70
+ });
71
+ }
72
+
73
+ const main = async () => {
74
+ const rootPath = `${__dirname}/../../../`
75
+ const app = path.join(`${__dirname}/../../../`, 'app.json');
76
+ const appJson = require(app)
77
+ const branchName = appJson.appId
78
+
79
+ if (!branchName || !branchName.includes("vn.momo")){
80
+ return
81
+ }
82
+
83
+ const scanPath = path.join(rootPath, 'src')
84
+ const kitJsonPath = path.join(rootPath, './scan/kit.json')
85
+ const miniappJsonPath = path.join(rootPath, './scan/miniapp.json')
86
+ const reactNativeJsonPath = path.join(rootPath, './scan/RN.json')
87
+ const fsJsonPath = path.join(rootPath, './scan/verLib.json')
88
+
89
+ const allKitsReg = /@momo-kits/;
90
+ const fsReg = /^(?:@fs-mobile-platform\/(components|investment|screens)|@miniapp-platform\/(components|foundation))$/;
91
+ const RNReg = 'react-native'
92
+
93
+ const config1 = {
94
+ crawlFrom: scanPath,
95
+ includeSubComponents: true,
96
+ importedFrom: allKitsReg,
97
+ processors: [['count-components', { outputTo: kitJsonPath }]],
98
+ rootDir: process.cwd(),
99
+ };
100
+
101
+ const config2 = {
102
+ crawlFrom: scanPath,
103
+ includeSubComponents: true,
104
+ processors: [['count-components', { outputTo: miniappJsonPath }]],
105
+ rootDir: process.cwd(),
106
+ };
107
+
108
+ const config3 = {
109
+ crawlFrom: scanPath,
110
+ includeSubComponents: true,
111
+ importedFrom: RNReg,
112
+ processors: [['count-components', { outputTo: reactNativeJsonPath }]],
113
+ rootDir: process.cwd(),
114
+ };
115
+
116
+ const config4 = {
117
+ crawlFrom: scanPath,
118
+ includeSubComponents: true,
119
+ importedFrom: fsReg,
120
+ processors: [['count-components', { outputTo: fsJsonPath }]],
121
+ rootDir: process.cwd(),
122
+ };
123
+
124
+ try {
125
+ ensureFileExists(kitJsonPath, {});
126
+ ensureFileExists(miniappJsonPath, {});
127
+ ensureFileExists(reactNativeJsonPath, {});
128
+ ensureFileExists(fsJsonPath, {});
129
+
130
+ await scan(config1);
131
+ await scan(config2);
132
+ await scan(config3);
133
+ await scan(config4);
134
+
135
+ const result = await calculateAdoptionRate(branchName,kitJsonPath, miniappJsonPath, reactNativeJsonPath, fsJsonPath);
136
+ sendMessage(result)
137
+ console.log(result)
138
+ } catch (error) {
139
+ console.error("Error during scan or calculation:", error);
140
+ }
141
+ };
142
+
143
+ main();
package/index.ts CHANGED
@@ -43,3 +43,9 @@ export * from './Tag';
43
43
  export * from './Tag/types';
44
44
  export * from './Pagination';
45
45
  export * from './Pagination/types';
46
+ export * from './Loader';
47
+ export * from './Loader/types';
48
+ export * from './Title';
49
+ export * from './Title/types';
50
+ export * from './Badge';
51
+ export * from './Badge/types';
@@ -0,0 +1,56 @@
1
+ const {readFileSync, writeFileSync, readdirSync, statSync} = require('fs');
2
+ const path = require('path');
3
+ let rootPath = process.argv[2];
4
+
5
+ const migrateText = [
6
+ {typo1: 'headline_s', typo2: 'headline_default_bold'},
7
+ {typo1: 'header_s', typo2: 'header_s_semibold'},
8
+ {typo1: 'header_xs', typo2: 'header_xs_semibold'},
9
+ {typo1: 'description_default', typo2: 'body_default_regular'},
10
+ {typo1: 'description_s', typo2: 'description_default_regular'},
11
+ {typo1: 'description_xs', typo2: 'description_xs_regular'},
12
+ {typo1: 'label_default', typo2: 'label_default_medium'},
13
+ {typo1: 'label_s', typo2: 'label_s_medium'},
14
+ {typo1: 'label_xs', typo2: 'label_xs_medium'},
15
+ {typo1: 'action_default', typo2: 'action_default_bold'},
16
+ {typo1: 'action_xs', typo2: 'action_xs_bold'},
17
+ {typo1: 'action_xxs', typo2: 'action_xxs_bold'},
18
+ ];
19
+
20
+ function replaceTextInFile(oldText, newText, filePath) {
21
+ try {
22
+ let content = readFileSync(filePath, {encoding: 'utf-8'});
23
+ const regex = new RegExp(`\\b${oldText}\\b`, 'g');
24
+ content = content.replace(regex, newText);
25
+ writeFileSync(filePath, content, 'utf8');
26
+ console.log(`Replaced text in: ${filePath}`);
27
+ } catch (error) {
28
+ console.error(`Error processing file ${filePath}:`, error);
29
+ }
30
+ }
31
+
32
+ function scanDirectory(directory, oldText, newText) {
33
+ const files = readdirSync(directory);
34
+
35
+ files.forEach(file => {
36
+ const filePath = path.join(directory, file);
37
+ const stat = statSync(filePath);
38
+
39
+ if (stat.isDirectory()) {
40
+ scanDirectory(filePath, oldText, newText);
41
+ } else if (
42
+ stat.isFile() &&
43
+ (filePath.endsWith('.tsx') || filePath.endsWith('.ts'))
44
+ ) {
45
+ replaceTextInFile(oldText, newText, filePath);
46
+ }
47
+ });
48
+ }
49
+
50
+ function main() {
51
+ migrateText.forEach(({typo1, typo2}) => {
52
+ scanDirectory(rootPath, typo1, typo2);
53
+ });
54
+ }
55
+
56
+ main();