@momo-kits/foundation 0.92.3-tracking.4 → 0.92.3-tracking.6

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.
@@ -317,7 +317,7 @@ export default function BottomTabBar({
317
317
  labelStyle={labelStyle}
318
318
  iconStyle={iconStyle}
319
319
  style={tabStyle}
320
- {...getAccessibilityID(`btn_tabbar_${route.name}`)}
320
+ {...getAccessibilityID(`BottomTabBarItem/${route.name}`)}
321
321
  />
322
322
  </NavigationRouteContext.Provider>
323
323
  </NavigationContext.Provider>
@@ -67,7 +67,7 @@ const BottomTab: React.FC<BottomTabProps> = ({
67
67
  backBehavior={'firstRoute'}
68
68
  tabBar={props => (
69
69
  <BottomTabBar
70
- {...getAccessibilityID('tbr_main_bottom')}
70
+ {...getAccessibilityID('BottomTabBar')}
71
71
  {...props}
72
72
  floatingButton={floatingButton}
73
73
  />
@@ -29,7 +29,6 @@ import {scaleSize, Text} from '../Text';
29
29
  import {Icon} from '../Icon';
30
30
  import {PopupNotify} from '../Popup';
31
31
  import {Badge, BadgeDot} from '../Badge';
32
- import {getAccessibilityID} from './utils';
33
32
 
34
33
  const NavigationButton: React.FC<NavigationButtonProps> = ({
35
34
  icon,
@@ -38,7 +37,7 @@ const NavigationButton: React.FC<NavigationButtonProps> = ({
38
37
  useBorder = true,
39
38
  badgeType,
40
39
  badgeValue,
41
- accessibilityID = '',
40
+ accessibilityLabel = '',
42
41
  }) => {
43
42
  const {theme} = useContext(ApplicationContext);
44
43
  let buttonStyle: ViewStyle = {backgroundColor: '#00000066'};
@@ -66,10 +65,9 @@ const NavigationButton: React.FC<NavigationButtonProps> = ({
66
65
  }, [badgeType, badgeValue]);
67
66
 
68
67
  return (
69
- <View
70
- {...getAccessibilityID(accessibilityID)}
71
- style={{width: scaleSize(28)}}>
68
+ <View style={{width: scaleSize(28)}}>
72
69
  <TouchableOpacity
70
+ accessibilityLabel={accessibilityLabel}
73
71
  style={[styles.navigationButton, buttonStyle]}
74
72
  onPress={onPress}>
75
73
  <Icon
@@ -94,7 +92,7 @@ const HeaderTitle: React.FC<any> = props => {
94
92
  return (
95
93
  <Animated.Text
96
94
  {...props}
97
- {...getAccessibilityID('title_navigation_header')}
95
+ accessibilityLabel={'title_navigation_header'}
98
96
  style={[
99
97
  styles.title,
100
98
  {fontFamily: `${theme.font}-Bold`, opacity, color: props.tintColor},
@@ -173,7 +171,7 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
173
171
  return (
174
172
  <View style={styles.headerLeft}>
175
173
  <NavigationButton
176
- accessibilityID="btn_navigation_back"
174
+ accessibilityLabel="btn_navigation_back"
177
175
  icon="ic_back"
178
176
  tintColor={tintColor}
179
177
  onPress={goBackSafe}
@@ -248,7 +246,7 @@ const HeaderCustom: React.FC<TitleCustomProps> = ({
248
246
  </View>
249
247
  <View style={[Styles.flex, {paddingHorizontal: 8}]}>
250
248
  <Text
251
- {...getAccessibilityID('title_navigation_header')}
249
+ accessibilityLabel={'title_navigation_header'}
252
250
  typography="header_default_bold"
253
251
  color={tintColor}>
254
252
  {title}
@@ -376,7 +374,7 @@ const HeaderToolkitAction: React.FC<any> = ({
376
374
  if (pinTool)
377
375
  return (
378
376
  <NavigationButton
379
- accessibilityID="btn_navigation_pin"
377
+ accessibilityLabel="btn_navigation_pin"
380
378
  icon={pinTool.icon as string}
381
379
  tintColor={tintColor}
382
380
  badgeValue={badgeValue}
@@ -407,13 +405,13 @@ const HeaderToolkitAction: React.FC<any> = ({
407
405
  },
408
406
  ]}>
409
407
  <TouchableOpacity
410
- {...getAccessibilityID('btn_navigation_more')}
408
+ accessibilityLabel={'btn_navigation_more'}
411
409
  onPress={onMore}>
412
410
  <Icon color={tintColor} source="navigation_more_horiz" size={20} />
413
411
  </TouchableOpacity>
414
412
  <View style={[styles.divider, {backgroundColor: tintColor}]} />
415
413
  <TouchableOpacity
416
- {...getAccessibilityID('btn_navigation_close')}
414
+ accessibilityLabel={'btn_navigation_close'}
417
415
  onPress={onClose}>
418
416
  <Icon
419
417
  color={tintColor}
@@ -130,7 +130,7 @@ export type NavigationButtonProps = {
130
130
  onPress: () => void;
131
131
  badgeType?: 'dot' | 'number';
132
132
  badgeValue?: number;
133
- accessibilityID?: string;
133
+ accessibilityLabel?: string;
134
134
  };
135
135
 
136
136
  export type PinnedToolType = {
@@ -158,41 +158,6 @@ const getAccessibilityID = (
158
158
  }
159
159
  };
160
160
 
161
- const cleanNameForTracking = (word = ''): string => {
162
- return word
163
- .normalize('NFD')
164
- .replace(/[\u0300-\u036f |\s]/g, '')
165
- .toLowerCase();
166
- };
167
-
168
- const formatComponentName = (word = '') => {
169
- const accentsMap = {
170
- a: 'á|à|ả|ã|ạ|â|ấ|ầ|ẩ|ẫ|ậ|ă|ắ|ằ|ẳ|ẵ|ặ',
171
- A: 'Á|À|Ả|Ã|Ạ|Â|Ấ|Ầ|Ẩ|Ẫ|Ậ|Ă|Ắ|Ằ|Ẳ|Ẵ|Ặ',
172
- e: 'é|è|ẻ|ẽ|ẹ|ê|ế|ề|ể|ễ|ệ',
173
- E: 'É|È|Ẻ|Ẽ|Ẹ|Ê|Ế|Ề|Ể|Ễ|Ệ',
174
- i: 'í|ì|ỉ|ĩ|ị',
175
- I: 'Í|Ì|Ỉ|Ĩ|Ị',
176
- o: 'ó|ò|ỏ|õ|ọ|ô|ố|ồ|ổ|ỗ|ộ|ơ|ớ|ờ|ở|ỡ|ợ',
177
- O: 'Ó|Ò|Ỏ|Õ|Ọ|Ô|Ố|Ồ|Ổ|Ỗ|Ộ|Ơ|Ớ|Ờ|Ở|Ỡ|Ợ',
178
- u: 'ú|ù|ủ|ũ|ụ|ư|ứ|ừ|ử|ữ|ự',
179
- U: 'Ú|Ù|Ủ|Ũ|Ụ|Ư|Ứ|Ừ|Ử|Ữ|Ự',
180
- y: 'ý|ỳ|ỷ|ỹ|ỵ',
181
- Y: 'Ý|Ỳ|Ỷ|Ỹ|Ỵ',
182
- d: 'đ',
183
- D: 'Đ',
184
- };
185
-
186
- for (const [nonAccent, accentGroup] of Object.entries(accentsMap)) {
187
- const accents = new RegExp(accentGroup, 'g');
188
- word = word.replace(accents, nonAccent);
189
- }
190
-
191
- word = word.replace(/\s+/g, '_').toLowerCase();
192
-
193
- return word;
194
- };
195
-
196
161
  const formatNameLength = (name = '') => {
197
162
  let formattedName = name;
198
163
  if (formattedName.length > 100) {
@@ -205,8 +170,6 @@ export {
205
170
  getDialogOptions,
206
171
  getModalOptions,
207
172
  getOptions,
208
- formatComponentName,
209
173
  formatNameLength,
210
174
  getAccessibilityID,
211
- cleanNameForTracking,
212
175
  };
package/Button/index.tsx CHANGED
@@ -14,7 +14,6 @@ import {Colors, Spacing} from '../Consts';
14
14
  import styles from './styles';
15
15
  import {Icon} from '../Icon';
16
16
  import {Loader} from '../Loader';
17
- import {formatComponentName} from '../Application/utils';
18
17
 
19
18
  const AnimationLinear = Animated.createAnimatedComponent(LinearGradient);
20
19
 
@@ -306,7 +305,7 @@ const Button: FC<ButtonProps> = ({
306
305
  params,
307
306
  state: state,
308
307
  componentId: accessibilityLabel,
309
- componentValue: formatComponentName(title),
308
+ componentValue: title,
310
309
  action: 'click',
311
310
  }}>
312
311
  <TouchableOpacity
@@ -46,7 +46,7 @@ const CheckBox: FC<CheckBoxProps> = ({
46
46
  componentId: accessibilityLabel,
47
47
  action: 'click',
48
48
  componentLabel: formatNameLength(label || ''),
49
- componentValue: indeterminate ? 'indetermine' : value,
49
+ componentValue: indeterminate ? 'undetermined' : value,
50
50
  }}>
51
51
  <TouchableOpacity
52
52
  accessibilityLabel={accessibilityLabel}
@@ -9,7 +9,6 @@ import {ApplicationContext, ComponentContext} from '../Application';
9
9
  import {Colors} from '../Consts';
10
10
  import {Icon} from '../Icon';
11
11
  import styles from './styles';
12
- import {formatComponentName} from '../Application/utils';
13
12
 
14
13
  export interface IconButtonProps extends TouchableOpacityProps {
15
14
  /**
@@ -132,7 +131,7 @@ const IconButton: React.FC<IconButtonProps> = ({
132
131
  params,
133
132
  state: type === 'disabled' ? 'disabled' : 'enabled',
134
133
  componentId: accessibilityLabel,
135
- componentValue: formatComponentName(icon),
134
+ componentValue: icon,
136
135
  action: 'click',
137
136
  }}>
138
137
  <TouchableOpacity
package/Image/index.tsx CHANGED
@@ -7,7 +7,6 @@ import {Skeleton} from '../Skeleton';
7
7
  import {Icon} from '../Icon';
8
8
  import {Styles} from '../Consts';
9
9
  import {ImageProps} from './types';
10
- import {getAccessibilityID} from '../Application/utils';
11
10
 
12
11
  type Status = 'success' | 'loading' | 'error';
13
12
 
@@ -16,6 +15,7 @@ const Image: React.FC<ImageProps> = ({
16
15
  source,
17
16
  loading = true,
18
17
  children,
18
+ params,
19
19
  accessibilityLabel,
20
20
  ...rest
21
21
  }) => {
@@ -24,13 +24,13 @@ const Image: React.FC<ImageProps> = ({
24
24
  const error = useRef(false);
25
25
  const [status, setStatus] = useState<Status>('success');
26
26
 
27
- const id = getAccessibilityID(
28
- `img|${(source as Source).uri}`,
29
- accessibilityLabel,
30
- );
27
+ const test: any = {
28
+ accessibilityLabel: accessibilityLabel || `img|${(source as Source).uri}`,
29
+ };
31
30
 
32
31
  useEffect(() => {
33
- component?.addChild?.(id.testID || id.accessibilityLabel);
32
+ component?.addChildren?.(test.accessibilityLabel, 'add');
33
+ return () => component?.addChildren(test.accessibilityLabel, 'remove');
34
34
  }, []);
35
35
 
36
36
  /**
@@ -54,37 +54,45 @@ const Image: React.FC<ImageProps> = ({
54
54
  };
55
55
 
56
56
  return (
57
- <FastImage
58
- {...rest}
59
- {...id}
60
- source={source}
61
- style={[styles.container, style]}
62
- onProgress={() => {
63
- error.current = false;
64
- if (status !== 'loading' && loading) {
65
- setStatus('loading');
66
- }
67
- }}
68
- onLoadStart={() => {
69
- error.current = false;
70
- }}
71
- onLoad={() => {
72
- error.current = false;
73
- }}
74
- onLoadEnd={() => {
75
- let current: Status = 'success';
76
- if (error.current) {
77
- current = 'error';
78
- }
79
- if (status !== current) {
80
- setStatus(current);
81
- }
82
- }}
83
- onError={() => {
84
- error.current = true;
57
+ <ComponentContext.Provider
58
+ value={{
59
+ componentName: 'Image',
60
+ params,
61
+ state: loading ? 'loading' : 'loaded',
62
+ componentId: test.accessibilityLabel,
85
63
  }}>
86
- {renderContent()}
87
- </FastImage>
64
+ <FastImage
65
+ {...rest}
66
+ {...test}
67
+ source={source}
68
+ style={[styles.container, style]}
69
+ onProgress={() => {
70
+ error.current = false;
71
+ if (status !== 'loading' && loading) {
72
+ setStatus('loading');
73
+ }
74
+ }}
75
+ onLoadStart={() => {
76
+ error.current = false;
77
+ }}
78
+ onLoad={() => {
79
+ error.current = false;
80
+ }}
81
+ onLoadEnd={() => {
82
+ let current: Status = 'success';
83
+ if (error.current) {
84
+ current = 'error';
85
+ }
86
+ if (status !== current) {
87
+ setStatus(current);
88
+ }
89
+ }}
90
+ onError={() => {
91
+ error.current = true;
92
+ }}>
93
+ {renderContent()}
94
+ </FastImage>
95
+ </ComponentContext.Provider>
88
96
  );
89
97
  };
90
98
 
package/Image/types.ts CHANGED
@@ -3,4 +3,5 @@ import {FastImageProps} from 'react-native-fast-image';
3
3
  export interface ImageProps extends FastImageProps {
4
4
  loading?: boolean;
5
5
  accessibilityLabel?: string;
6
+ params?: any;
6
7
  }
package/Input/Input.tsx CHANGED
@@ -14,7 +14,6 @@ import {InputProps} from './index';
14
14
  import {Icon} from '../Icon';
15
15
  import {checkTyping} from './utils';
16
16
  import {Loader} from '../Loader';
17
- import {formatComponentName} from '../Application/utils';
18
17
 
19
18
  const Input = forwardRef(
20
19
  (
@@ -212,7 +211,7 @@ const Input = forwardRef(
212
211
  value={{
213
212
  componentName: 'Input',
214
213
  params,
215
- componentLabel: formatComponentName(floatingValue || ''),
214
+ componentLabel: floatingValue,
216
215
  state: inputState,
217
216
  componentId: accessibilityLabel,
218
217
  }}>
@@ -7,7 +7,6 @@ import {InputDropDownProps} from './index';
7
7
  import {Icon} from '../Icon';
8
8
  import {Loader} from '../Loader';
9
9
  import {Styles} from '../Consts';
10
- import {formatComponentName} from '../Application/utils';
11
10
 
12
11
  const InputDropDown = ({
13
12
  value,
@@ -109,10 +108,10 @@ const InputDropDown = ({
109
108
  return (
110
109
  <ComponentContext.Provider
111
110
  value={{
112
- componentName: 'InputOTP',
111
+ componentName: 'InputDropDown',
113
112
  params,
114
113
  state: 'enabled',
115
- componentLabel: formatComponentName(floatingValue || ''),
114
+ componentLabel: floatingValue,
116
115
  componentId: accessibilityLabel,
117
116
  }}>
118
117
  <TouchableOpacity
@@ -18,7 +18,6 @@ import {ErrorView, FloatingView, getBorderColor, getSizeStyle} from './common';
18
18
  import {InputMoneyProps} from './index';
19
19
  import {Icon} from '../Icon';
20
20
  import {formatMoneyToNumber, formatNumberToMoney} from './utils';
21
- import {formatComponentName} from '../Application/utils';
22
21
 
23
22
  const InputMoney = forwardRef(
24
23
  (
@@ -172,7 +171,7 @@ const InputMoney = forwardRef(
172
171
  value={{
173
172
  componentName: 'InputMoney',
174
173
  params,
175
- componentLabel: formatComponentName(floatingValue || ''),
174
+ componentLabel: floatingValue,
176
175
  state: inputState,
177
176
  componentId: accessibilityLabel,
178
177
  }}>
@@ -21,7 +21,6 @@ import styles from './styles';
21
21
  import {ErrorView, getBorderColor} from './common';
22
22
  import {ApplicationContext, ComponentContext} from '../Application';
23
23
  import {Spacing} from '../Consts';
24
- import {formatComponentName} from '../Application/utils';
25
24
 
26
25
  const OTPCaret: FC<CaretProps> = ({index, length}) => {
27
26
  const DURATION = 300;
@@ -229,7 +228,7 @@ const InputOTP = forwardRef(
229
228
  value={{
230
229
  componentName: 'InputOTP',
231
230
  params,
232
- componentLabel: formatComponentName(floatingValue || ''),
231
+ componentLabel: floatingValue,
233
232
  state: 'enabled',
234
233
  componentId: accessibilityLabel,
235
234
  }}>
@@ -7,7 +7,6 @@ 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';
11
10
 
12
11
  const PopupNotify: React.FC<PopupNotifyProps> = ({
13
12
  id,
@@ -163,7 +162,7 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
163
162
  const buildCloseIcon = () => {
164
163
  return (
165
164
  <TouchableOpacity
166
- {...getAccessibilityID?.('ic_popup_close')}
165
+ accessibilityLabel={'ic_popup_close'}
167
166
  style={styles.iconCloseContainer}
168
167
  onPress={() => {
169
168
  closeAction.current = 'icon_close';
@@ -189,7 +188,7 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
189
188
 
190
189
  return (
191
190
  <View
192
- {...getAccessibilityID?.(`pu_${context.code}_notify`)}
191
+ accessibilityLabel={'PopupNotify'}
193
192
  style={[
194
193
  styles.container,
195
194
  {backgroundColor: theme.colors.background.surface},
@@ -5,7 +5,6 @@ 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';
9
8
 
10
9
  const PopupPromotion: React.FC<PopupPromotionProps> = ({
11
10
  id,
@@ -51,10 +50,9 @@ const PopupPromotion: React.FC<PopupPromotionProps> = ({
51
50
  */
52
51
  const buildCloseIcon = () => {
53
52
  return (
54
- <View
55
- {...getAccessibilityID?.('ic_popup_close')}
56
- style={styles.iconCloseContainer}>
53
+ <View style={styles.iconCloseContainer}>
57
54
  <TouchableOpacity
55
+ accessibilityLabel={'ic_popup_close'}
58
56
  onPress={() => {
59
57
  closeAction.current = 'icon_close';
60
58
  navigator?.pop();
@@ -81,7 +79,7 @@ const PopupPromotion: React.FC<PopupPromotionProps> = ({
81
79
  };
82
80
 
83
81
  return (
84
- <View {...getAccessibilityID?.(`pu_${context.code}_promotion`)}>
82
+ <View accessibilityLabel={'PopupPromotion'}>
85
83
  <Image
86
84
  source={{
87
85
  uri: image,
package/Radio/index.tsx CHANGED
@@ -43,12 +43,12 @@ const Radio: FC<RadioProps> = ({
43
43
  return (
44
44
  <ComponentContext.Provider
45
45
  value={{
46
- componentName: 'Button',
46
+ componentName: 'Radio',
47
47
  params,
48
48
  state: disabled ? 'disabled' : 'enabled',
49
49
  componentId: accessibilityLabel,
50
50
  componentLabel: formatNameLength(label || ''),
51
- componentValue: value,
51
+ componentValue: selected,
52
52
  action: 'click',
53
53
  }}>
54
54
  <TouchableOpacity
package/Switch/index.tsx CHANGED
@@ -24,7 +24,7 @@ const Switch: FC<SwitchProps> = ({
24
24
  return (
25
25
  <ComponentContext.Provider
26
26
  value={{
27
- componentName: 'Button',
27
+ componentName: 'Switch',
28
28
  params,
29
29
  state: disabled ? 'disabled' : 'enabled',
30
30
  componentId: accessibilityLabel,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.92.3-tracking.4",
3
+ "version": "0.92.3-tracking.6",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {