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

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.
@@ -1,13 +1,14 @@
1
1
  import React, {useContext, useEffect, useLayoutEffect, useRef} from 'react';
2
2
  import {ScreenParams} from './types';
3
3
  import Navigation from './Navigation';
4
- import {ApplicationContext, MiniAppContext} from './index';
4
+ import {ApplicationContext} from './index';
5
5
  import {GridSystem} from '../Layout';
6
6
  import {useHeaderHeight} from '@react-navigation/stack';
7
7
  import {Alert, InteractionManager} from 'react-native';
8
8
 
9
9
  const {
10
10
  ScreenContext,
11
+ MiniAppContext,
11
12
  } = require('react-native/Libraries/Components/ScreenContext');
12
13
 
13
14
  const StackScreen: React.FC<ScreenParams> = props => {
@@ -17,29 +18,31 @@ const StackScreen: React.FC<ScreenParams> = props => {
17
18
  const timeLoad = useRef(0);
18
19
  const timeout = useRef<any>();
19
20
 
20
- const context = useContext(MiniAppContext);
21
+ const context = useContext<any>(MiniAppContext);
21
22
 
22
- const {screen: Component, options, params}: ScreenParams = props.route.params;
23
+ const {screen: Component, options} = props.route.params;
23
24
  const navigation = new Navigation(props.navigation, theme);
24
25
  const heightHeader = useHeaderHeight();
25
26
 
26
- const data = {
27
+ const params = {
27
28
  ...props.route.params,
28
- params,
29
29
  navigation,
30
30
  };
31
31
 
32
- delete data.screen;
32
+ delete params.screen;
33
+
34
+ const screenName = Component?.name || Component?.type?.name || '';
33
35
 
34
36
  /**
35
37
  * set options for screen
36
38
  */
37
39
  useLayoutEffect(() => {
38
- startTime.current = Date.now();
40
+ const host = (global as any).miniAppApi?.currentHost || {};
41
+ host.screenName = screenName;
39
42
  InteractionManager.runAfterInteractions(() => {
40
43
  navigator?.maxApi?.showToastDebug?.({
41
- appId: context.appId,
42
- message: `${Component.name} screen_interaction_time ${
44
+ appId: `auto - ${context.appId}`,
45
+ message: `${screenName} screen_interaction_time ${
43
46
  Date.now() - startTime.current
44
47
  }`,
45
48
  });
@@ -54,17 +57,17 @@ const StackScreen: React.FC<ScreenParams> = props => {
54
57
  */
55
58
  useEffect(() => {
56
59
  if (__DEV__) {
57
- if (!Component.name || Component.name === 'screen') {
60
+ if (!screenName || screenName === 'screen') {
58
61
  Alert.alert(
59
62
  'Design system',
60
- `Unvalidated screen name "${Component.name}" !`,
63
+ `Unvalidated screen name "${screenName}" !`,
61
64
  );
62
65
  }
63
66
  }
64
67
 
65
68
  const tracking = {
66
69
  ...context,
67
- screen_name: Component.name,
70
+ screen_name: screenName,
68
71
  };
69
72
 
70
73
  const routes = props.navigation.getState()?.routes || [];
@@ -81,8 +84,8 @@ const StackScreen: React.FC<ScreenParams> = props => {
81
84
  };
82
85
  navigator?.maxApi?.trackEvent?.('service_frame_displayed', params);
83
86
  navigator?.maxApi?.showToastDebug?.({
84
- appId: context.appId,
85
- message: `${Component.name} service_frame_displayed`,
87
+ appId: `auto - ${context.appId}`,
88
+ message: `${screenName} service_frame_displayed`,
86
89
  params,
87
90
  });
88
91
 
@@ -94,8 +97,8 @@ const StackScreen: React.FC<ScreenParams> = props => {
94
97
  };
95
98
  navigator?.maxApi?.trackEvent?.('service_icon_clicked', params);
96
99
  navigator?.maxApi?.showToastDebug?.({
97
- appId: context.appId,
98
- message: `${Component.name} service_icon_clicked`,
100
+ appId: `auto - ${context.appId}`,
101
+ message: `${screenName} service_icon_clicked`,
99
102
  params,
100
103
  });
101
104
  });
@@ -106,7 +109,7 @@ const StackScreen: React.FC<ScreenParams> = props => {
106
109
  value={{
107
110
  appId: context.appId,
108
111
  code: context.code,
109
- screenName: Component.name,
112
+ screenName,
110
113
  autoTracking: (data: any) => {
111
114
  navigator?.maxApi?.dispatchFunction?.('autoTracking', data);
112
115
  },
@@ -114,15 +117,21 @@ const StackScreen: React.FC<ScreenParams> = props => {
114
117
  endTime.current = Date.now();
115
118
  clearTimeout(timeout.current);
116
119
  timeout.current = setTimeout(() => {
117
- timeLoad.current = endTime.current - startTime.current;
118
- navigator?.maxApi?.showToastDebug?.({
119
- appId: context.appId,
120
- message: `${Component.name} screen_load_time ${timeLoad.current}`,
121
- });
122
- }, 1000);
120
+ if (timeLoad.current === 0) {
121
+ timeLoad.current = endTime.current - startTime.current;
122
+ navigator?.maxApi?.showToastDebug?.({
123
+ appId: `auto - ${context.appId}`,
124
+ message: `${screenName} screen_load_time ${timeLoad.current}`,
125
+ });
126
+ }
127
+ }, 2000);
123
128
  },
124
129
  }}>
125
- <Component heightHeader={heightHeader} {...data} />
130
+ <Component
131
+ heightHeader={heightHeader}
132
+ {...params}
133
+ onScreenLoad={() => {}}
134
+ />
126
135
  {showGrid && <GridSystem />}
127
136
  </ScreenContext.Provider>
128
137
  );
@@ -4,10 +4,8 @@ import {
4
4
  HeaderAnimated,
5
5
  HeaderBackground,
6
6
  HeaderCustom,
7
- HeaderLeft,
8
7
  HeaderRightAction,
9
8
  HeaderTitle,
10
- HeaderToolkitAction,
11
9
  NavigationButton,
12
10
  } from './Components';
13
11
  import BottomTab from './BottomTab';
@@ -32,10 +30,8 @@ export {
32
30
  BottomTab,
33
31
  NavigationButton,
34
32
  HeaderTitle,
35
- HeaderLeft,
36
33
  HeaderBackground,
37
34
  HeaderRightAction,
38
- HeaderToolkitAction,
39
35
  HeaderCustom,
40
36
  HeaderAnimated,
41
37
  };
@@ -1,4 +1,4 @@
1
- import {Animated} from 'react-native';
1
+ import {Animated, FlatListProps, ViewProps} from 'react-native';
2
2
  import {StackNavigationOptions} from '@react-navigation/stack';
3
3
  import React from 'react';
4
4
  import Navigator from './Navigator';
@@ -94,7 +94,6 @@ export type NavigationContainerProps = {
94
94
  options?: NavigationOptions;
95
95
  theme: Theme;
96
96
  maxApi: any;
97
- params: Record<string, any>;
98
97
  localization?: LocalizationObject;
99
98
  };
100
99
 
@@ -119,8 +118,8 @@ export interface ModalParams extends ScreenParams {
119
118
  export interface BottomSheetParams extends ScreenParams {
120
119
  [key: string]: any;
121
120
  onDismiss?: () => void;
122
- snapPoint?: '30%' | '50%' | '70%' | '90%' | 'content';
123
- indicatorColor?: string;
121
+ footerComponent?: React.ReactNode;
122
+ flatListProps: FlatListProps<any>;
124
123
  }
125
124
 
126
125
  export type NavigationButtonProps = {
@@ -154,6 +153,7 @@ export interface NavigationOptions extends StackNavigationOptions {
154
153
  toolkitParams?: {
155
154
  pinnedTool?: PinnedToolType;
156
155
  runtimeTools?: RuntimeToolType[];
156
+ preventClose?: PopupNotifyProps;
157
157
  };
158
158
  }
159
159
 
@@ -185,11 +185,10 @@ export type HeaderToolkitProps = {
185
185
  configs: any[];
186
186
  };
187
187
 
188
- export type HeaderAnimatedProps = {
188
+ export interface HeaderAnimatedProps extends ViewProps {
189
189
  animatedValue: Animated.Value;
190
190
  image: string;
191
- onPress?: () => void;
192
- };
191
+ }
193
192
 
194
193
  export type BottomTabItemProps = {
195
194
  name: string;
@@ -131,14 +131,7 @@ const getOptions = (params: NavigationOptions, theme: Theme) => {
131
131
  options = {
132
132
  ...options,
133
133
  headerRight: (props: any) => {
134
- return (
135
- <HeaderToolkitAction
136
- preventBack={params.preventBack}
137
- pinnedTool={params.toolkitParams?.pinnedTool}
138
- runtimeTools={params.toolkitParams?.runtimeTools}
139
- {...props}
140
- />
141
- );
134
+ return <HeaderToolkitAction {...params.toolkitParams} {...props} />;
142
135
  },
143
136
  };
144
137
  }
@@ -149,20 +142,23 @@ const getOptions = (params: NavigationOptions, theme: Theme) => {
149
142
  };
150
143
  };
151
144
 
152
- const getAccessibilityID = (key = '') => {
145
+ const getAccessibilityID = (
146
+ key = '',
147
+ override: string | undefined = undefined,
148
+ ) => {
153
149
  if (isIOS) {
154
150
  return {
155
151
  accessible: true,
156
- testID: key,
152
+ testID: override || key,
157
153
  };
158
154
  } else {
159
155
  return {
160
- accessibilityLabel: key,
156
+ accessibilityLabel: override || key,
161
157
  };
162
158
  }
163
159
  };
164
160
 
165
- const formatComponentName = (word: string) => {
161
+ const formatComponentName = (word = '') => {
166
162
  const accentsMap = {
167
163
  a: 'á|à|ả|ã|ạ|â|ấ|ầ|ẩ|ẫ|ậ|ă|ắ|ằ|ẳ|ẵ|ặ',
168
164
  A: 'Á|À|Ả|Ã|Ạ|Â|Ấ|Ầ|Ẩ|Ẫ|Ậ|Ă|Ắ|Ằ|Ẳ|Ẵ|Ặ',
@@ -190,7 +186,7 @@ const formatComponentName = (word: string) => {
190
186
  return word;
191
187
  };
192
188
 
193
- const formatNameLength = (name: string) => {
189
+ const formatNameLength = (name = '') => {
194
190
  let formattedName = name;
195
191
  if (formattedName.length > 100) {
196
192
  formattedName = formattedName.substring(0, 100);
package/Button/index.tsx CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  View,
8
8
  } from 'react-native';
9
9
  import LinearGradient from 'react-native-linear-gradient';
10
- import {ApplicationContext, MiniAppContext} from '../Application';
10
+ import {ApplicationContext} from '../Application';
11
11
  import {Text} from '../Text';
12
12
  import {Typography} from '../Text/types';
13
13
  import {Colors, Spacing} from '../Consts';
@@ -18,6 +18,7 @@ import {formatComponentName, getAccessibilityID} from '../Application/utils';
18
18
 
19
19
  const {
20
20
  ScreenContext,
21
+ MiniAppContext,
21
22
  } = require('react-native/Libraries/Components/ScreenContext');
22
23
 
23
24
  const AnimationLinear = Animated.createAnimatedComponent(LinearGradient);
@@ -96,7 +97,7 @@ const Button: FC<ButtonProps> = ({
96
97
  ...rest
97
98
  }) => {
98
99
  const {theme, config} = useContext(ApplicationContext);
99
- const {appId, code} = useContext(MiniAppContext)
100
+ const {appId, code} = useContext<any>(MiniAppContext);
100
101
  const {gradient, color} = config?.navigationBar?.buttonColors ?? {};
101
102
  let gradientPros;
102
103
  if (gradient?.length > 0 && type == 'primary') {
@@ -303,7 +304,7 @@ const Button: FC<ButtonProps> = ({
303
304
  };
304
305
 
305
306
  const activeOpacity = type === 'disabled' ? 0.75 : 0.5;
306
- const accessibilityID = getAccessibilityID(`${appId}|${screenInfo.screenName}|btn_${title}`)
307
+
307
308
  return (
308
309
  <ScreenContext.Provider
309
310
  value={{
@@ -321,7 +322,10 @@ const Button: FC<ButtonProps> = ({
321
322
  }}>
322
323
  <TouchableOpacity
323
324
  {...rest}
324
- {...accessibilityID}
325
+ {...getAccessibilityID(
326
+ `${appId}/${code}/${screenInfo.screenName}/btn_${title}`,
327
+ accessibilityLabel,
328
+ )}
325
329
  activeOpacity={activeOpacity}
326
330
  onPress={onPressButton}
327
331
  style={buttonStyle}>
@@ -2,13 +2,14 @@ import React, {FC, useContext} from 'react';
2
2
  import {TouchableOpacity, View} from 'react-native';
3
3
  import {CheckBoxProps} from './types';
4
4
  import styles from './styles';
5
- import {ApplicationContext, MiniAppContext} from '../Application';
5
+ import {ApplicationContext} from '../Application';
6
6
  import {Text} from '../Text';
7
7
  import {Icon} from '../Icon';
8
8
  import {formatNameLength, getAccessibilityID} from '../Application/utils';
9
9
 
10
10
  const {
11
11
  ScreenContext,
12
+ MiniAppContext,
12
13
  } = require('react-native/Libraries/Components/ScreenContext');
13
14
 
14
15
  const CheckBox: FC<CheckBoxProps> = ({
@@ -21,7 +22,7 @@ const CheckBox: FC<CheckBoxProps> = ({
21
22
  params,
22
23
  componentId,
23
24
  }) => {
24
- const {appId} = useContext(MiniAppContext)
25
+ const {appId} = useContext<any>(MiniAppContext);
25
26
  const {theme} = useContext(ApplicationContext);
26
27
  const screenInfo = useContext<any>(ScreenContext);
27
28
  const haveValue = value || indeterminate;
@@ -42,7 +43,10 @@ const CheckBox: FC<CheckBoxProps> = ({
42
43
  backgroundColor = theme.colors.background.tonal;
43
44
  }
44
45
  }
45
- const accessibilityID = getAccessibilityID(`${appId}|${screenInfo.screenName}|cbx_${label}_${value}`)
46
+
47
+ const accessibilityID = getAccessibilityID(
48
+ `${appId}/${screenInfo.screenName}/cbx_${label}_${value}`,
49
+ );
46
50
 
47
51
  return (
48
52
  <ScreenContext.Provider
@@ -57,7 +61,7 @@ const CheckBox: FC<CheckBoxProps> = ({
57
61
  componentValue: indeterminate ? 'indetermine' : value,
58
62
  }}>
59
63
  <TouchableOpacity
60
- {...accessibilityID}
64
+ {...accessibilityID}
61
65
  activeOpacity={0.8}
62
66
  onPress={() => onChange?.(!value)}
63
67
  disabled={disabled}
package/Image/index.tsx CHANGED
@@ -7,7 +7,7 @@ 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";
10
+ import {getAccessibilityID} from '../Application/utils';
11
11
 
12
12
  type Status = 'success' | 'loading' | 'error';
13
13
 
@@ -42,11 +42,10 @@ const Image: React.FC<ImageProps> = ({
42
42
  return children;
43
43
  };
44
44
 
45
- const accessibilityID = getAccessibilityID(`img|${source}`)
46
45
  return (
47
46
  <FastImage
48
47
  {...rest}
49
- {...accessibilityID}
48
+ {...getAccessibilityID(`img|${source}`)}
50
49
  source={source}
51
50
  style={[styles.container, style]}
52
51
  onProgress={() => {
package/Input/Input.tsx CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  TouchableOpacity,
7
7
  View,
8
8
  } from 'react-native';
9
- import {ApplicationContext, MiniAppContext} from '../Application';
9
+ import {ApplicationContext} from '../Application';
10
10
  import styles from './styles';
11
11
  import {ErrorView, FloatingView, getBorderColor, getSizeStyle} from './common';
12
12
  import {InputProps} from './index';
@@ -17,6 +17,7 @@ import {formatComponentName, getAccessibilityID} from '../Application/utils';
17
17
 
18
18
  const {
19
19
  ScreenContext,
20
+ MiniAppContext,
20
21
  } = require('react-native/Libraries/Components/ScreenContext');
21
22
 
22
23
  const Input = forwardRef(
@@ -51,7 +52,7 @@ const Input = forwardRef(
51
52
  ref,
52
53
  ) => {
53
54
  const {theme} = useContext(ApplicationContext);
54
- const {appId} = useContext(MiniAppContext)
55
+ const {appId} = useContext<any>(MiniAppContext);
55
56
  const [focused, setFocused] = useState(false);
56
57
  const [haveValue, setHaveValue] = useState(!!value || !!props.defaultValue);
57
58
  const [secureTextInput, setSecureTextInput] = useState(secureTextEntry);
@@ -122,6 +123,12 @@ const Input = forwardRef(
122
123
  iconTintColor = disabledColor;
123
124
  }
124
125
 
126
+ const accessibilityID = getAccessibilityID(
127
+ `${appId}/${screenInfo.screenName}/input_${floatingValue}${
128
+ disabled && '_disabled'
129
+ }`,
130
+ );
131
+
125
132
  return (
126
133
  <View
127
134
  style={[
@@ -149,6 +156,7 @@ const Input = forwardRef(
149
156
  )}
150
157
  <TextInput
151
158
  {...props}
159
+ {...accessibilityID}
152
160
  editable={!disabled}
153
161
  secureTextEntry={secure}
154
162
  textAlignVertical="center"
@@ -202,8 +210,6 @@ const Input = forwardRef(
202
210
  inputState = 'disabled';
203
211
  }
204
212
 
205
- const accessibilityID = getAccessibilityID(`${appId}|${screenInfo.screenName}|input_${floatingValue}${disabled && "_disabled" }`)
206
-
207
213
  return (
208
214
  <ScreenContext.Provider
209
215
  value={{
@@ -214,7 +220,7 @@ const Input = forwardRef(
214
220
  state: inputState,
215
221
  componentId,
216
222
  }}>
217
- <View {...accessibilityID} style={[style, styles.wrapper]}>
223
+ <View style={[style, styles.wrapper]}>
218
224
  {renderInputView()}
219
225
  <ErrorView errorMessage={errorMessage} errorSpacing={errorSpacing} />
220
226
  </View>
@@ -1,6 +1,6 @@
1
1
  import React, {useContext} from 'react';
2
2
  import {TextInput, TouchableOpacity, View} from 'react-native';
3
- import {ApplicationContext, MiniAppContext} from '../Application';
3
+ import {ApplicationContext} from '../Application';
4
4
  import styles from './styles';
5
5
  import {ErrorView, FloatingView, getBorderColor, getSizeStyle} from './common';
6
6
  import {InputDropDownProps} from './index';
@@ -11,6 +11,7 @@ import {formatComponentName, getAccessibilityID} from '../Application/utils';
11
11
 
12
12
  const {
13
13
  ScreenContext,
14
+ MiniAppContext,
14
15
  } = require('react-native/Libraries/Components/ScreenContext');
15
16
 
16
17
  const InputDropDown = ({
@@ -35,7 +36,7 @@ const InputDropDown = ({
35
36
  componentId,
36
37
  ...props
37
38
  }: InputDropDownProps) => {
38
- const {appId} = useContext(MiniAppContext)
39
+ const {appId} = useContext<any>(MiniAppContext);
39
40
  const {theme} = useContext(ApplicationContext);
40
41
  const full = !!value || !!placeholder;
41
42
  const screenInfo = useContext<any>(ScreenContext);
@@ -61,6 +62,12 @@ const InputDropDown = ({
61
62
  iconTintColor = disabledColor;
62
63
  }
63
64
 
65
+ const accessibilityID = getAccessibilityID(
66
+ `${appId}/${screenInfo.screenName}/input_${floatingValue}${
67
+ disabled && '_disabled'
68
+ }`,
69
+ );
70
+
64
71
  return (
65
72
  <View
66
73
  style={[
@@ -89,6 +96,7 @@ const InputDropDown = ({
89
96
  {full && (
90
97
  <TextInput
91
98
  {...props}
99
+ {...accessibilityID}
92
100
  onPressIn={onPress}
93
101
  editable={false}
94
102
  textAlignVertical="top"
@@ -112,9 +120,6 @@ const InputDropDown = ({
112
120
  );
113
121
  };
114
122
 
115
- const accessibilityID = getAccessibilityID(`${appId}|${screenInfo.screenName}|input_${floatingValue}${disabled && "_disabled" }`)
116
-
117
-
118
123
  return (
119
124
  <ScreenContext.Provider
120
125
  value={{
@@ -126,7 +131,6 @@ const InputDropDown = ({
126
131
  componentId,
127
132
  }}>
128
133
  <TouchableOpacity
129
- {...accessibilityID}
130
134
  onPress={onPress}
131
135
  style={[style, full && styles.wrapper]}>
132
136
  {renderInputView()}
@@ -12,7 +12,7 @@ import {
12
12
  TouchableOpacity,
13
13
  View,
14
14
  } from 'react-native';
15
- import {ApplicationContext, MiniAppContext} from '../Application';
15
+ import {ApplicationContext} from '../Application';
16
16
  import styles from './styles';
17
17
  import {ErrorView, FloatingView, getBorderColor, getSizeStyle} from './common';
18
18
  import {InputMoneyProps} from './index';
@@ -22,6 +22,7 @@ import {formatComponentName, getAccessibilityID} from '../Application/utils';
22
22
 
23
23
  const {
24
24
  ScreenContext,
25
+ MiniAppContext,
25
26
  } = require('react-native/Libraries/Components/ScreenContext');
26
27
 
27
28
  const InputMoney = forwardRef(
@@ -49,7 +50,7 @@ const InputMoney = forwardRef(
49
50
  ref,
50
51
  ) => {
51
52
  const {theme} = useContext(ApplicationContext);
52
- const {appId} = useContext(MiniAppContext)
53
+ const {appId} = useContext<any>(MiniAppContext);
53
54
  const [focused, setFocused] = useState(false);
54
55
  const inputRef = (ref as React.RefObject<TextInput>) ?? useRef<TextInput>();
55
56
  const screenInfo = useContext<any>(ScreenContext);
@@ -105,6 +106,12 @@ const InputMoney = forwardRef(
105
106
  iconTintColor = disabledColor;
106
107
  }
107
108
 
109
+ const accessibilityID = getAccessibilityID(
110
+ `${appId}/${screenInfo.screenName}/input_${floatingValue}${
111
+ disabled && '_disabled'
112
+ }`,
113
+ );
114
+
108
115
  return (
109
116
  <View
110
117
  style={[
@@ -123,6 +130,7 @@ const InputMoney = forwardRef(
123
130
  <View style={styles.inputView}>
124
131
  <TextInput
125
132
  {...props}
133
+ {...accessibilityID}
126
134
  editable={!disabled}
127
135
  textAlignVertical="top"
128
136
  ref={inputRef}
@@ -173,8 +181,6 @@ const InputMoney = forwardRef(
173
181
  inputState = 'disabled';
174
182
  }
175
183
 
176
- const accessibilityID = getAccessibilityID(`${appId}|${screenInfo.screenName}|input_${floatingValue}${disabled && "_disabled" }`)
177
-
178
184
  return (
179
185
  <ScreenContext.Provider
180
186
  value={{
@@ -185,9 +191,7 @@ const InputMoney = forwardRef(
185
191
  state: inputState,
186
192
  componentId,
187
193
  }}>
188
- <View
189
- {...accessibilityID}
190
- style={[style, styles.wrapper]}>
194
+ <View style={[style, styles.wrapper]}>
191
195
  {renderInputView()}
192
196
  <ErrorView errorMessage={errorMessage} errorSpacing={errorSpacing} />
193
197
  </View>
@@ -19,17 +19,17 @@ import {CaretProps, InputOTPProps} from './index';
19
19
  import {scaleSize, Text} from '../Text';
20
20
  import styles from './styles';
21
21
  import {ErrorView, getBorderColor} from './common';
22
- import {ApplicationContext, MiniAppContext} from '../Application';
22
+ import {ApplicationContext} from '../Application';
23
23
  import {Spacing} from '../Consts';
24
24
  import {formatComponentName, getAccessibilityID} from '../Application/utils';
25
25
 
26
26
  const {
27
27
  ScreenContext,
28
+ MiniAppContext,
28
29
  } = require('react-native/Libraries/Components/ScreenContext');
29
30
 
30
31
  const OTPCaret: FC<CaretProps> = ({index, length}) => {
31
32
  const DURATION = 300;
32
- const {appId} = useContext(MiniAppContext)
33
33
  const {theme} = useContext(ApplicationContext);
34
34
  const opacity = useRef(new Animated.Value(0)).current;
35
35
 
@@ -92,7 +92,7 @@ const InputOTP = forwardRef(
92
92
  ref,
93
93
  ) => {
94
94
  const MAX_LENGTH = 10;
95
- const {appId} = useContext(MiniAppContext)
95
+ const {appId} = useContext<any>(MiniAppContext);
96
96
 
97
97
  const [value, setValue] = useState('');
98
98
  const [focused, setFocused] = useState(false);
@@ -191,6 +191,10 @@ const InputOTP = forwardRef(
191
191
  );
192
192
  };
193
193
 
194
+ const accessibilityID = getAccessibilityID(
195
+ `${appId}/${screenInfo.screenName}/input_${floatingValue}`,
196
+ );
197
+
194
198
  const renderInputView = () => {
195
199
  return (
196
200
  <View
@@ -216,6 +220,7 @@ const InputOTP = forwardRef(
216
220
  <View style={styles.inputView}>
217
221
  <TextInput
218
222
  {...props}
223
+ {...accessibilityID}
219
224
  ref={inputRef}
220
225
  value={value}
221
226
  onChangeText={_onChangeText}
@@ -230,7 +235,6 @@ const InputOTP = forwardRef(
230
235
  </View>
231
236
  );
232
237
  };
233
- const accessibilityID = getAccessibilityID(`${appId}|${screenInfo.screenName}|input_${floatingValue}${disabled && "_disabled" }`)
234
238
 
235
239
  return (
236
240
  <ScreenContext.Provider
@@ -243,7 +247,6 @@ const InputOTP = forwardRef(
243
247
  componentId,
244
248
  }}>
245
249
  <TouchableOpacity
246
- {...accessibilityID}
247
250
  activeOpacity={1}
248
251
  onPress={onFocusInput}
249
252
  style={[style, styles.otpWrapper]}>
@@ -7,15 +7,16 @@ import {
7
7
  View,
8
8
  } from 'react-native';
9
9
  import {InputSearchProps} from './index';
10
- import {ApplicationContext, MiniAppContext} from '../Application';
10
+ import {ApplicationContext} from '../Application';
11
11
  import styles from './styles';
12
12
  import {Icon} from '../Icon';
13
13
  import {Text} from '../Text';
14
14
  import {checkTyping} from './utils';
15
- import {getAccessibilityID} from "../Application/utils";
15
+ import {getAccessibilityID} from '../Application/utils';
16
16
 
17
17
  const {
18
18
  ScreenContext,
19
+ MiniAppContext,
19
20
  } = require('react-native/Libraries/Components/ScreenContext');
20
21
 
21
22
  const InputSearch = forwardRef(
@@ -41,7 +42,7 @@ const InputSearch = forwardRef(
41
42
  ref,
42
43
  ) => {
43
44
  const {theme} = useContext(ApplicationContext);
44
- const {appId} = useContext(MiniAppContext)
45
+ const {appId} = useContext<any>(MiniAppContext);
45
46
  const [focused, setFocused] = useState(false);
46
47
  const [haveValue, setHaveValue] = useState(!!value || !!defaultValue);
47
48
  const inputRef = (ref as React.RefObject<TextInput>) ?? useRef<TextInput>();
@@ -71,6 +72,9 @@ const InputSearch = forwardRef(
71
72
  return (
72
73
  <TextInput
73
74
  {...props}
75
+ {...getAccessibilityID(
76
+ `${appId}/${screenInfo.screenName}/input_search`,
77
+ )}
74
78
  textAlignVertical="center"
75
79
  ref={inputRef}
76
80
  style={[
@@ -139,11 +143,9 @@ const InputSearch = forwardRef(
139
143
  const backgroundColor = hasColorBG
140
144
  ? theme.colors.background.default
141
145
  : theme.colors.background.surface;
142
- const accessibilityID = getAccessibilityID(`${appId}|${screenInfo.screenName}|input_search`)
143
146
 
144
147
  return (
145
148
  <ScreenContext.Provider
146
- {...accessibilityID}
147
149
  value={{
148
150
  ...screenInfo,
149
151
  componentName: 'InputSearch',