@momo-kits/foundation 0.89.5 → 0.92.1-tracking.2

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/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,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.89.5",
3
+ "version": "0.92.1-tracking.2",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {
package/verify.js CHANGED
@@ -13,7 +13,7 @@ try {
13
13
  const iOSAppTarget = appInfo?.client?.ios.deploymentTarget;
14
14
  const androidAppTarget = appInfo?.client?.android.deploymentTarget;
15
15
 
16
- if (appInfo.name === 'MoMoPlatform') {
16
+ if (Object.values(appInfo).length < 1) {
17
17
  return;
18
18
  }
19
19