@momo-kits/foundation 0.89.5-beta.18 → 0.92.1-tracking.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/Input/index.tsx CHANGED
@@ -80,6 +80,9 @@ export interface InputProps extends TextInputProps {
80
80
  fontWeight?: 'Regular' | 'Bold';
81
81
 
82
82
  onPressIcon?: () => void;
83
+
84
+ params?: any;
85
+ componentId?: string;
83
86
  }
84
87
 
85
88
  type InputPropsWithoutSizeAndIcon = Omit<
@@ -121,7 +124,14 @@ export interface InputSearchProps extends TextInputProps {
121
124
  */
122
125
  icon?: string;
123
126
 
124
- hasColorBG?: boolean
127
+ /**
128
+ *
129
+ */
130
+ hasColorBG?: boolean;
131
+
132
+ params?: any;
133
+
134
+ componentId?: string;
125
135
  }
126
136
 
127
137
  export interface InputMoneyProps extends InputPropsWithoutPlaceholder {}
@@ -245,7 +255,22 @@ export interface InputDropDownProps {
245
255
  */
246
256
  leadingIconColor?: string;
247
257
 
248
- style: ViewStyle | ViewStyle[];
258
+ /**
259
+ * Optional. params for element tracking.
260
+ */
261
+ params?: {
262
+ [key: string]: any;
263
+ };
264
+
265
+ /**
266
+ * component id for element tracking.
267
+ */
268
+ componentId?: string;
269
+
270
+ /**
271
+ * Optional. Represents the style of the InputDropDown component.
272
+ */
273
+ style?: ViewStyle | ViewStyle[];
249
274
  }
250
275
 
251
276
  export {Input, InputTextArea, InputSearch, InputMoney, InputOTP, InputDropDown};
@@ -7,6 +7,7 @@ import {Text} from '../Text';
7
7
  import {ApplicationContext, MiniAppContext} from '../Application';
8
8
  import {Button} from '../Button';
9
9
  import {Icon} from '../Icon';
10
+ import {getAccessibilityID} from "../Application/utils";
10
11
 
11
12
  const PopupNotify: React.FC<PopupNotifyProps> = ({
12
13
  id,
@@ -108,9 +109,13 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
108
109
  );
109
110
  };
110
111
  const renderColumn = () => {
112
+ const accessibilityPrimaryID = getAccessibilityID('btn_popup_allow')
113
+ const accessibilitySecondID = getAccessibilityID('btn_popup_cancel')
114
+
111
115
  return (
112
116
  <View style={Styles.columnCenter}>
113
117
  <Button
118
+ {...accessibilityPrimaryID}
114
119
  title={primary.title}
115
120
  size="medium"
116
121
  onPress={() => {
@@ -122,6 +127,7 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
122
127
  <>
123
128
  <View style={styles.buttonSpace} />
124
129
  <Button
130
+ {...accessibilitySecondID}
125
131
  title={secondary?.title}
126
132
  type="text"
127
133
  size="medium"
@@ -155,8 +161,11 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
155
161
  * build close action
156
162
  */
157
163
  const buildCloseIcon = () => {
164
+ const accessibilityCloseID = getAccessibilityID('ic_popup_close')
165
+
158
166
  return (
159
167
  <TouchableOpacity
168
+ {...accessibilityCloseID}
160
169
  style={styles.iconCloseContainer}
161
170
  onPress={() => {
162
171
  closeAction.current = 'icon_close';
@@ -180,8 +189,11 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
180
189
  );
181
190
  };
182
191
 
192
+ const accessibilityID = getAccessibilityID(`pu_${context.code}_notify`)
193
+
183
194
  return (
184
195
  <View
196
+ {...accessibilityID}
185
197
  style={[
186
198
  styles.container,
187
199
  {backgroundColor: theme.colors.background.surface},
@@ -5,6 +5,7 @@ import {ApplicationContext, MiniAppContext} from '../Application';
5
5
  import {Image} from '../Image';
6
6
  import {Radius, Spacing} from '../Consts';
7
7
  import {Icon} from '../Icon';
8
+ import {getAccessibilityID} from "../Application/utils";
8
9
 
9
10
  const PopupPromotion: React.FC<PopupPromotionProps> = ({
10
11
  id,
@@ -48,8 +49,10 @@ const PopupPromotion: React.FC<PopupPromotionProps> = ({
48
49
  * build close action
49
50
  */
50
51
  const buildCloseIcon = () => {
52
+ const accessibilityCloseID = getAccessibilityID('ic_popup_close')
53
+
51
54
  return (
52
- <View style={styles.iconCloseContainer}>
55
+ <View {...accessibilityCloseID} style={styles.iconCloseContainer}>
53
56
  <TouchableOpacity
54
57
  onPress={() => {
55
58
  closeAction.current = 'icon_close';
@@ -75,9 +78,12 @@ const PopupPromotion: React.FC<PopupPromotionProps> = ({
75
78
  </View>
76
79
  );
77
80
  };
81
+ const accessibilityID = getAccessibilityID(`pu_${context.code}_promotion`)
78
82
 
79
83
  return (
80
- <View>
84
+ <View
85
+ {...accessibilityID}
86
+ >
81
87
  <Image
82
88
  source={{
83
89
  uri: image,
package/Radio/index.tsx CHANGED
@@ -4,8 +4,13 @@ import {TouchableOpacity, View} from 'react-native';
4
4
  import {RadioProps} from './types';
5
5
  import {Text} from '../Text';
6
6
  import styles from './styles';
7
- import {ApplicationContext} from '../Application';
7
+ import {ApplicationContext, MiniAppContext} from '../Application';
8
8
  import {Spacing} from '../Consts';
9
+ import {formatNameLength, getAccessibilityID} from '../Application/utils';
10
+
11
+ const {
12
+ ScreenContext,
13
+ } = require('react-native/Libraries/Components/ScreenContext');
9
14
 
10
15
  const Radio: FC<RadioProps> = ({
11
16
  value,
@@ -14,8 +19,12 @@ const Radio: FC<RadioProps> = ({
14
19
  onChange,
15
20
  label,
16
21
  style,
22
+ params,
23
+ componentId,
17
24
  }) => {
25
+ const {appId} = useContext(MiniAppContext)
18
26
  const {theme} = useContext(ApplicationContext);
27
+ const screenInfo = useContext<any>(ScreenContext);
19
28
  const selected = value === groupValue;
20
29
  let disabledStyle = {};
21
30
  let checkBoxStyle = {
@@ -36,28 +45,42 @@ const Radio: FC<RadioProps> = ({
36
45
  : theme.colors.text.disable,
37
46
  };
38
47
  }
48
+ const accessibilityID = getAccessibilityID(`${appId}|${screenInfo.screenName}|rdo_${label}_${value}`)
39
49
 
40
50
  return (
41
- <TouchableOpacity
42
- onPress={onChange}
43
- disabled={disabled}
44
- style={[
45
- style,
46
- {
47
- flexDirection: 'row',
48
- alignItems: 'center',
49
- },
50
- ]}>
51
- <View
51
+ <ScreenContext.Provider
52
+ value={{
53
+ ...screenInfo,
54
+ componentName: 'Button',
55
+ params,
56
+ state: disabled ? 'disabled' : 'enabled',
57
+ componentId,
58
+ componentLabel: formatNameLength(label || ''),
59
+ componentValue: value,
60
+ action: 'click',
61
+ }}>
62
+ <TouchableOpacity
63
+ {...accessibilityID}
64
+ onPress={onChange}
65
+ disabled={disabled}
52
66
  style={[
53
- styles.radio,
54
- checkBoxStyle,
55
- disabledStyle,
56
- {marginRight: label ? Spacing.XS : 0},
57
- ]}
58
- />
59
- {!!label && <Text typography={'body_default_regular'}>{label}</Text>}
60
- </TouchableOpacity>
67
+ style,
68
+ {
69
+ flexDirection: 'row',
70
+ alignItems: 'center',
71
+ },
72
+ ]}>
73
+ <View
74
+ style={[
75
+ styles.radio,
76
+ checkBoxStyle,
77
+ disabledStyle,
78
+ {marginRight: label ? Spacing.XS : 0},
79
+ ]}
80
+ />
81
+ {!!label && <Text typography={'body_default_regular'}>{label}</Text>}
82
+ </TouchableOpacity>
83
+ </ScreenContext.Provider>
61
84
  );
62
85
  };
63
86
 
package/Radio/types.ts CHANGED
@@ -35,4 +35,9 @@ export type RadioProps = {
35
35
  * Accepts an object of style properties.
36
36
  */
37
37
  style?: ViewStyle;
38
+
39
+
40
+ params?: any
41
+
42
+ componentId?: string
38
43
  };
package/Switch/index.tsx CHANGED
@@ -1,11 +1,20 @@
1
- import React, {FC} from 'react';
1
+ import React, {FC, useContext} from 'react';
2
2
  import {TouchableOpacity, View} from 'react-native';
3
3
  import {SwitchProps} from './types';
4
4
  import styles from './styles';
5
5
  import {Colors} from '../Consts';
6
+ import {getAccessibilityID} from "../Application/utils";
7
+ import {MiniAppContext} from "../Application";
8
+
9
+ const {
10
+ ScreenContext,
11
+ } = require('react-native/Libraries/Components/ScreenContext');
6
12
 
7
13
  const Switch: FC<SwitchProps> = props => {
8
- const {value, onChange, disabled, style} = props;
14
+ const {appId} = useContext(MiniAppContext)
15
+ const {value, onChange, disabled, style, params, componentId} = props;
16
+ const screenInfo = useContext<any>(ScreenContext);
17
+
9
18
  const circleBackgroundColor = value ? Colors.black_01 : Colors.black_03;
10
19
  const circleAlign = value ? 'flex-end' : 'flex-start';
11
20
 
@@ -13,20 +22,33 @@ const Switch: FC<SwitchProps> = props => {
13
22
  if (disabled) {
14
23
  backgroundColor = value ? Colors.green_09 : Colors.black_05;
15
24
  }
25
+ const accessibilityID = getAccessibilityID(`${appId}|${screenInfo.screenName}|swt_${value}`)
16
26
 
17
27
  return (
18
- <TouchableOpacity
19
- disabled={disabled}
20
- onPress={() => onChange?.(!value)}
21
- style={[
22
- style,
23
- styles.container,
24
- {backgroundColor, alignItems: circleAlign},
25
- ]}>
26
- <View style={[styles.circle, {backgroundColor: circleBackgroundColor}]}>
27
- <View style={[styles.circleSmall, {backgroundColor}]} />
28
- </View>
29
- </TouchableOpacity>
28
+ <ScreenContext.Provider
29
+ value={{
30
+ ...screenInfo,
31
+ componentName: 'Button',
32
+ params,
33
+ state: disabled ? 'disabled' : 'enabled',
34
+ componentId,
35
+ componentValue: value,
36
+ action: 'click',
37
+ }}>
38
+ <TouchableOpacity
39
+ {...accessibilityID}
40
+ disabled={disabled}
41
+ onPress={() => onChange?.(!value)}
42
+ style={[
43
+ style,
44
+ styles.container,
45
+ {backgroundColor, alignItems: circleAlign},
46
+ ]}>
47
+ <View style={[styles.circle, {backgroundColor: circleBackgroundColor}]}>
48
+ <View style={[styles.circleSmall, {backgroundColor}]} />
49
+ </View>
50
+ </TouchableOpacity>
51
+ </ScreenContext.Provider>
30
52
  );
31
53
  };
32
54
 
package/Switch/types.ts CHANGED
@@ -23,4 +23,8 @@ export type SwitchProps = {
23
23
  * Accepts an object of style properties.
24
24
  */
25
25
  style?: ViewStyle;
26
+
27
+ params?: any
28
+
29
+ componentId?: string
26
30
  };
package/code-scanner.js CHANGED
@@ -1,143 +1,51 @@
1
1
  const scanner = require('react-scanner');
2
- const fs = require('fs');
3
2
  const path = require('path');
4
3
 
5
- const scan = async (config) => {
6
- return await scanner.run(config);
4
+ const scan = async config => {
5
+ return await scanner.run(config);
7
6
  };
8
7
 
9
- const calcSum = (array) => {
10
- return array.reduce((a, b) => a + b, 0);
8
+ const calcSum = array => {
9
+ return array.reduce((a, b) => a + b, 0);
11
10
  };
12
11
 
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
- }
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);
34
21
  };
35
22
 
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
23
  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
- }
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);
141
49
  };
142
50
 
143
- main();
51
+ main().catch(console.error);
package/index.ts CHANGED
@@ -4,11 +4,12 @@ import {
4
4
  useSafeAreaInsets,
5
5
  } from 'react-native-safe-area-context';
6
6
  import LinearGradient from 'react-native-linear-gradient';
7
+ import {getAccessibilityID} from "./Application/utils";
7
8
 
8
9
  /**
9
10
  * native export
10
11
  */
11
- export {SafeAreaView, useSafeAreaInsets, SafeAreaProvider, LinearGradient};
12
+ export {SafeAreaView, useSafeAreaInsets, SafeAreaProvider, LinearGradient, getAccessibilityID};
12
13
 
13
14
  /**
14
15
  * foundation component
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.89.5-beta.18",
3
+ "version": "0.92.1-tracking.1",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {
7
- "postinstall": "node code-scanner.js"
7
+ "postinstall": "node verify.js"
8
8
  },
9
9
  "keywords": [
10
10
  "@momo-kits/foundation"
@@ -20,8 +20,7 @@
20
20
  "@react-navigation/native": "5.9.8",
21
21
  "@react-navigation/routers": "5.7.4",
22
22
  "lottie-react-native": "3.3.2",
23
- "@react-navigation/stack": "git+https://gitlab.com/momo-platform/react-navigation-stack.git#main",
24
- "react-scanner": "^1.1.0"
23
+ "@react-navigation/stack": "git+https://gitlab.com/momo-platform/react-navigation-stack.git#main"
25
24
  },
26
25
  "peerDependencies": {
27
26
  "react-native": "*"
package/verify.js CHANGED
@@ -13,10 +13,6 @@ try {
13
13
  const iOSAppTarget = appInfo?.client?.ios.deploymentTarget;
14
14
  const androidAppTarget = appInfo?.client?.android.deploymentTarget;
15
15
 
16
- if (Object.values(appInfo).length < 1) {
17
- return
18
- }
19
-
20
16
  if (appInfo.name === 'MoMoPlatform') {
21
17
  return;
22
18
  }