@momo-kits/foundation 0.81.1-beta.6 → 0.81.1-optimize.11

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 (77) hide show
  1. package/Application/BottomSheet.tsx +238 -0
  2. package/Application/BottomTab/BottomTabBar.tsx +291 -0
  3. package/Application/BottomTab/index.tsx +138 -0
  4. package/Application/Components.tsx +274 -211
  5. package/Application/ModalScreen.tsx +10 -226
  6. package/Application/Navigation.ts +17 -6
  7. package/Application/NavigationContainer.tsx +66 -65
  8. package/Application/Navigator.ts +106 -53
  9. package/Application/StackScreen.tsx +123 -28
  10. package/Application/index.ts +15 -9
  11. package/Application/types.ts +56 -31
  12. package/Application/utils.tsx +36 -6
  13. package/Assets/icon.json +83 -5
  14. package/Assets/icon_bank.json +506 -0
  15. package/Assets/language.json +3 -1
  16. package/Badge/Badge.tsx +56 -0
  17. package/Badge/BadgeDot.tsx +11 -0
  18. package/Badge/BadgeRibbon.tsx +125 -0
  19. package/Badge/Shape.tsx +29 -0
  20. package/Badge/index.tsx +7 -0
  21. package/Badge/styles.ts +58 -0
  22. package/Badge/types.ts +63 -0
  23. package/Button/index.tsx +60 -24
  24. package/Button/styles.ts +19 -0
  25. package/CheckBox/index.tsx +37 -27
  26. package/CheckBox/types.ts +5 -3
  27. package/Consts/colors+spacing+radius.ts +17 -3
  28. package/Icon/index.tsx +14 -9
  29. package/Icon/types.ts +4 -3
  30. package/IconButton/index.tsx +24 -15
  31. package/Image/index.tsx +61 -55
  32. package/Image/styles.ts +1 -9
  33. package/Image/types.ts +5 -1
  34. package/Input/Input.tsx +102 -25
  35. package/Input/InputDropDown.tsx +32 -23
  36. package/Input/InputMoney.tsx +67 -18
  37. package/Input/InputOTP.tsx +194 -148
  38. package/Input/InputSearch.tsx +72 -36
  39. package/Input/InputTextArea.tsx +33 -18
  40. package/Input/common.tsx +25 -16
  41. package/Input/index.tsx +62 -16
  42. package/Input/styles.ts +5 -8
  43. package/Layout/Card.tsx +20 -11
  44. package/Layout/FloatingButton.tsx +168 -0
  45. package/Layout/GridSystem.tsx +1 -2
  46. package/Layout/Item.tsx +0 -1
  47. package/Layout/ItemList.tsx +39 -40
  48. package/Layout/ItemSectionList.tsx +39 -0
  49. package/Layout/Screen.tsx +151 -65
  50. package/Layout/Section.tsx +17 -19
  51. package/Layout/index.ts +2 -1
  52. package/Layout/styles.ts +20 -15
  53. package/Layout/types.ts +2 -5
  54. package/Layout/utils.ts +2 -2
  55. package/Pagination/PaginationNumber.tsx +1 -1
  56. package/Pagination/PaginationScroll.tsx +0 -1
  57. package/Popup/PopupNotify.tsx +105 -37
  58. package/Popup/PopupPromotion.tsx +44 -9
  59. package/Popup/types.ts +12 -9
  60. package/Radio/index.tsx +35 -21
  61. package/Radio/types.ts +5 -3
  62. package/Skeleton/index.tsx +1 -1
  63. package/Switch/index.tsx +32 -19
  64. package/Switch/types.ts +5 -3
  65. package/Tag/index.tsx +2 -4
  66. package/Text/index.tsx +26 -6
  67. package/Text/styles.ts +38 -0
  68. package/Text/types.ts +25 -13
  69. package/Title/index.tsx +172 -63
  70. package/Title/styles.ts +48 -15
  71. package/Title/types.ts +16 -47
  72. package/code-scanner.js +131 -39
  73. package/index.ts +9 -0
  74. package/migrate_typo.js +56 -0
  75. package/package.json +8 -8
  76. package/verify.js +24 -6
  77. package/Application/BottomTab.tsx +0 -65
package/code-scanner.js CHANGED
@@ -1,51 +1,143 @@
1
1
  const scanner = require('react-scanner');
2
+ const fs = require('fs');
2
3
  const path = require('path');
3
4
 
4
- const scan = async config => {
5
- return await scanner.run(config);
5
+ const scan = async (config) => {
6
+ return await scanner.run(config);
6
7
  };
7
8
 
8
- const calcSum = array => {
9
- return array.reduce((a, b) => a + b, 0);
9
+ const calcSum = (array) => {
10
+ return array.reduce((a, b) => a + b, 0);
10
11
  };
11
12
 
12
- const calculateAdoptionRate = (kitJsonPath, miniappJsonPath) => {
13
- const kitJson = require(kitJsonPath);
14
- const miniAppJson = require(miniappJsonPath);
15
- const numOfKitComponents = calcSum(Object.values(kitJson));
16
- const numOfMiniAppComponents = calcSum(Object.values(miniAppJson));
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);
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
+ }
21
34
  };
22
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
+
23
73
  const main = async () => {
24
- const [scanPath, kitJsonRelativePath, miniappJsonRelativePath] =
25
- process.argv.slice(2);
26
-
27
- const kitJsonPath = path.resolve(process.cwd(), kitJsonRelativePath);
28
- const miniappJsonPath = path.resolve(process.cwd(), miniappJsonRelativePath);
29
-
30
- const config1 = {
31
- crawlFrom: scanPath,
32
- includeSubComponents: true,
33
- importedFrom: /@momo-kits\/.+/,
34
- processors: [['count-components', {outputTo: kitJsonPath}]],
35
- rootDir: './',
36
- };
37
-
38
- const config2 = {
39
- crawlFrom: scanPath,
40
- includeSubComponents: true,
41
- processors: [['count-components', {outputTo: miniappJsonPath}]],
42
- rootDir: './',
43
- };
44
-
45
- await scan(config1);
46
- await scan(config2);
47
-
48
- calculateAdoptionRate(kitJsonPath, miniappJsonPath);
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
+ }
49
141
  };
50
142
 
51
- main().catch(console.error);
143
+ main();
package/index.ts CHANGED
@@ -47,3 +47,12 @@ export * from './Loader';
47
47
  export * from './Loader/types';
48
48
  export * from './Title';
49
49
  export * from './Title/types';
50
+ export * from './Badge';
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';
@@ -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();
package/package.json CHANGED
@@ -1,26 +1,25 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.81.1-beta.6",
3
+ "version": "0.81.1-optimize.11",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
- "scripts": {
7
- "postinstall": "node verify.js"
8
- },
6
+ "scripts": {},
9
7
  "keywords": [
10
8
  "@momo-kits/foundation"
11
9
  ],
12
10
  "dependencies": {
13
- "@gorhom/bottom-sheet": "git+https://gitlab.com/dung.huynh1/bottom-sheet.git#main",
11
+ "@gorhom/bottom-sheet": "2.4.1",
14
12
  "react-native-safe-area-context": "3.1.4",
15
- "react-native-linear-gradient": "2.5.6",
13
+ "react-native-linear-gradient": "2.8.3",
16
14
  "react-native-gesture-handler": "1.10.3",
15
+ "react-native-modalize": "2.1.1",
17
16
  "react-native-fast-image": "8.1.5",
18
- "@react-navigation/bottom-tabs": "git+https://gitlab.com/dung.huynh1/react-navigation-bottom-tabs.git#main",
17
+ "@react-navigation/bottom-tabs": "https://oauth2:5WXQLHPMxxCyvGt_Py4D@gitlab.mservice.com.vn/momo-platform/react-native-bottom-tabs.git",
19
18
  "@react-navigation/core": "5.16.1",
20
19
  "@react-navigation/native": "5.9.8",
21
20
  "@react-navigation/routers": "5.7.4",
22
21
  "lottie-react-native": "3.3.2",
23
- "@react-navigation/stack": "git+https://gitlab.com/dung.huynh1/react-navigation-stack.git#main"
22
+ "@react-navigation/stack": "https://oauth2:eX-jVhzQdLc343AjD3Sc@gitlab.mservice.com.vn/momo-platform/react-navigation-stack.git"
24
23
  },
25
24
  "peerDependencies": {
26
25
  "react-native": "*"
@@ -32,6 +31,7 @@
32
31
  "@types/jest": "26.0.23",
33
32
  "@types/react-native": "0.64.4",
34
33
  "@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",
package/verify.js CHANGED
@@ -2,19 +2,24 @@ const fs = require('fs');
2
2
  const path = require('path');
3
3
 
4
4
  try {
5
- const package = path.join(`${__dirname}`, 'package.json');
6
- const packageInfo = JSON.parse(fs.readFileSync(package, 'utf8'));
5
+ const packageInfo = JSON.parse(
6
+ fs.readFileSync(path.join(`${__dirname}`, 'package.json'), 'utf8'),
7
+ );
7
8
  const packageVersion = parseInt(packageInfo?.version.split('.')?.[1]);
8
9
 
9
10
  const app = path.join(`${__dirname}/../../../`, 'app.json');
10
- const appInfo = JSON.parse(fs.readFileSync(app, 'utf8'));
11
- const iOSAppTarget = appInfo?.client?.ios.deploymentTarget;
12
- const androidAppTarget = appInfo?.client?.android.deploymentTarget;
11
+ const miniJson = path.join(`${__dirname}/../../../`, 'package.json');
13
12
 
14
- if (appInfo.name === 'MoMoPlatform') {
13
+ if (!fs.existsSync(app) || fs.existsSync(miniJson)) {
15
14
  return;
16
15
  }
17
16
 
17
+ const appInfo = JSON.parse(fs.readFileSync(app, 'utf8'));
18
+ const miniInfo = JSON.parse(fs.readFileSync(miniJson, 'utf8'));
19
+
20
+ const iOSAppTarget = appInfo?.client?.ios.deploymentTarget;
21
+ const androidAppTarget = appInfo?.client?.android.deploymentTarget;
22
+
18
23
  if (packageVersion > iOSAppTarget || packageVersion > androidAppTarget) {
19
24
  console.error(
20
25
  `Package ${packageInfo.name} version: ${packageInfo.version} require deploymentTarget ${packageVersion}`,
@@ -23,6 +28,19 @@ try {
23
28
  `Package ${packageInfo.name} version: ${packageInfo.version} require deploymentTarget ${packageVersion}`,
24
29
  );
25
30
  }
31
+
32
+ if (
33
+ miniInfo?.dependencies?.['@momo-platform/momo-core'] &&
34
+ miniInfo?.dependencies?.['@momo-platform/momo-core'] !==
35
+ packageInfo?.version
36
+ ) {
37
+ console.error(
38
+ `Package ${packageInfo.name} version: ${packageInfo.version} require install resolutions @momo-platform/momo-core ${packageInfo.version}`,
39
+ );
40
+ throw new Error(
41
+ `Package ${packageInfo.name} version: ${packageInfo.version} require install resolutions @momo-platform/momo-core ${packageInfo.version}`,
42
+ );
43
+ }
26
44
  } catch (error) {
27
45
  console.error(`Installation failed: ${error.message}`);
28
46
  process.exit(1);
@@ -1,65 +0,0 @@
1
- import React, {useContext} from 'react';
2
- import {View} from 'react-native';
3
- import {BottomTabProps} from './types';
4
- import {createBottomTabNavigator} from '@react-navigation/bottom-tabs';
5
- import {Icon} from '../Icon';
6
- import {Text} from '../Text';
7
- import {ApplicationContext} from './index';
8
-
9
- const Tab = createBottomTabNavigator();
10
-
11
- const BottomTab: React.FC<BottomTabProps> = ({tabs, listeners, navigation}) => {
12
- const {theme} = useContext(ApplicationContext);
13
-
14
- const defaultListener = {
15
- focus: (item: any) => {
16
- const focusItem = tabs.find(i => item.target.includes(i.name));
17
- if (focusItem?.options) {
18
- navigation?.setOptions?.(focusItem.options);
19
- }
20
- },
21
- };
22
-
23
- return (
24
- <Tab.Navigator backBehavior={'firstRoute'}>
25
- {tabs.map(item => {
26
- return (
27
- <Tab.Screen
28
- key={item.name}
29
- name={item.name}
30
- component={item.screen}
31
- listeners={listeners ?? defaultListener}
32
- options={{
33
- tabBarLabel: ({color, focused}) => {
34
- return (
35
- <View style={{paddingHorizontal: 16}}>
36
- <Text
37
- typography={focused ? 'label_xs' : 'description_xs'}
38
- color={color}>
39
- {item.label}
40
- </Text>
41
- </View>
42
- );
43
- },
44
- tabBarBadge: item?.badgeLabel,
45
- tabBarBadgeStyle: {
46
- borderColor: 'white',
47
- borderWidth: 2,
48
- fontSize: 10,
49
- lineHeight: 14,
50
- fontWeight: 'bold',
51
- alignSelf: 'center',
52
- fontFamily: `${theme.font}-Bold`,
53
- },
54
- tabBarIcon: ({color}) => (
55
- <Icon source={item.icon} color={color} size={28} />
56
- ),
57
- }}
58
- />
59
- );
60
- })}
61
- </Tab.Navigator>
62
- );
63
- };
64
-
65
- export default BottomTab;