@momo-kits/foundation 0.92.2 → 0.92.3-beta.10
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/Application/BottomTab/BottomTabBar.tsx +1 -2
- package/Application/BottomTab/index.tsx +9 -3
- package/Application/Components.tsx +27 -34
- package/Application/NavigationContainer.tsx +2 -7
- package/Application/StackScreen.tsx +70 -67
- package/Application/index.ts +8 -8
- package/Application/types.ts +2 -2
- package/Application/utils.tsx +0 -37
- package/Button/index.tsx +11 -32
- package/CheckBox/index.tsx +10 -32
- package/CheckBox/types.ts +4 -6
- package/Icon/index.tsx +8 -8
- package/IconButton/index.tsx +8 -21
- package/Image/index.tsx +49 -39
- package/Image/types.ts +2 -0
- package/Input/Input.tsx +7 -35
- package/Input/InputDropDown.tsx +8 -35
- package/Input/InputMoney.tsx +7 -32
- package/Input/InputOTP.tsx +11 -29
- package/Input/InputSearch.tsx +6 -17
- package/Input/InputTextArea.tsx +1 -23
- package/Input/index.tsx +1 -9
- package/Input/styles.ts +2 -2
- package/Layout/Screen.tsx +3 -2
- package/Layout/styles.ts +0 -14
- package/Popup/PopupNotify.tsx +5 -9
- package/Popup/PopupPromotion.tsx +6 -15
- package/Radio/index.tsx +9 -27
- package/Radio/types.ts +4 -7
- package/Switch/index.tsx +15 -26
- package/Switch/types.ts +4 -6
- package/Title/index.tsx +18 -10
- package/Title/styles.ts +4 -1
- package/Title/types.ts +4 -0
- package/code-scanner.js +131 -39
- package/migrate_typo.js +56 -0
- package/package.json +4 -4
package/CheckBox/index.tsx
CHANGED
|
@@ -2,33 +2,22 @@ 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} from '../Application';
|
|
5
|
+
import {ApplicationContext, ComponentContext} from '../Application';
|
|
6
6
|
import {Text} from '../Text';
|
|
7
7
|
import {Icon} from '../Icon';
|
|
8
|
-
import {
|
|
9
|
-
cleanNameForTracking,
|
|
10
|
-
formatNameLength,
|
|
11
|
-
getAccessibilityID,
|
|
12
|
-
} from '../Application/utils';
|
|
13
|
-
|
|
14
|
-
const {
|
|
15
|
-
ScreenContext,
|
|
16
|
-
MiniAppContext,
|
|
17
|
-
} = require('react-native/Libraries/Components/ScreenContext');
|
|
8
|
+
import {formatNameLength} from '../Application/utils';
|
|
18
9
|
|
|
19
10
|
const CheckBox: FC<CheckBoxProps> = ({
|
|
20
11
|
value,
|
|
21
|
-
disabled,
|
|
12
|
+
disabled = false,
|
|
22
13
|
onChange,
|
|
23
14
|
style,
|
|
24
15
|
label,
|
|
25
16
|
indeterminate,
|
|
26
17
|
params,
|
|
27
|
-
|
|
18
|
+
accessibilityLabel,
|
|
28
19
|
}) => {
|
|
29
|
-
const {appId, code} = useContext<any>(MiniAppContext);
|
|
30
20
|
const {theme} = useContext(ApplicationContext);
|
|
31
|
-
const screenInfo = useContext<any>(ScreenContext);
|
|
32
21
|
const haveValue = value || indeterminate;
|
|
33
22
|
const iconSource = indeterminate ? 'ic_minus' : 'ic_checked';
|
|
34
23
|
let borderColor = theme.colors.text.default;
|
|
@@ -48,26 +37,19 @@ const CheckBox: FC<CheckBoxProps> = ({
|
|
|
48
37
|
}
|
|
49
38
|
}
|
|
50
39
|
|
|
51
|
-
const accessibilityID = getAccessibilityID(
|
|
52
|
-
`${appId}/${code}/${screenInfo.screenName}/cbx_${cleanNameForTracking(
|
|
53
|
-
label,
|
|
54
|
-
)}_${indeterminate ? 'na' : value}`,
|
|
55
|
-
);
|
|
56
|
-
|
|
57
40
|
return (
|
|
58
|
-
<
|
|
41
|
+
<ComponentContext.Provider
|
|
59
42
|
value={{
|
|
60
|
-
|
|
61
|
-
componentName: 'Button',
|
|
43
|
+
componentName: 'CheckBox',
|
|
62
44
|
params,
|
|
63
45
|
state: disabled ? 'disabled' : 'filled',
|
|
64
|
-
componentId,
|
|
46
|
+
componentId: accessibilityLabel,
|
|
65
47
|
action: 'click',
|
|
66
48
|
componentLabel: formatNameLength(label || ''),
|
|
67
|
-
componentValue: indeterminate ? '
|
|
49
|
+
componentValue: indeterminate ? 'undetermined' : value,
|
|
68
50
|
}}>
|
|
69
51
|
<TouchableOpacity
|
|
70
|
-
{
|
|
52
|
+
accessibilityLabel={accessibilityLabel}
|
|
71
53
|
activeOpacity={0.8}
|
|
72
54
|
onPress={() => onChange?.(!value)}
|
|
73
55
|
disabled={disabled}
|
|
@@ -87,12 +69,8 @@ const CheckBox: FC<CheckBoxProps> = ({
|
|
|
87
69
|
</View>
|
|
88
70
|
{!!label && <Text typography={'body_default_regular'}>{label}</Text>}
|
|
89
71
|
</TouchableOpacity>
|
|
90
|
-
</
|
|
72
|
+
</ComponentContext.Provider>
|
|
91
73
|
);
|
|
92
74
|
};
|
|
93
75
|
|
|
94
|
-
CheckBox.defaultProps = {
|
|
95
|
-
disabled: false,
|
|
96
|
-
};
|
|
97
|
-
|
|
98
76
|
export {CheckBox};
|
package/CheckBox/types.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {ViewStyle} from 'react-native';
|
|
1
|
+
import {TouchableOpacityProps, ViewStyle} from 'react-native';
|
|
2
2
|
|
|
3
|
-
export
|
|
3
|
+
export interface CheckBoxProps extends TouchableOpacityProps {
|
|
4
4
|
/**
|
|
5
5
|
* Represents whether the CheckBox is currently checked (`true`) or unchecked (`false`).
|
|
6
6
|
*/
|
|
@@ -36,7 +36,5 @@ export type CheckBoxProps = {
|
|
|
36
36
|
*/
|
|
37
37
|
style?: ViewStyle;
|
|
38
38
|
|
|
39
|
-
params?: any
|
|
40
|
-
|
|
41
|
-
componentId?: string
|
|
42
|
-
};
|
|
39
|
+
params?: any;
|
|
40
|
+
}
|
package/Icon/index.tsx
CHANGED
|
@@ -5,7 +5,12 @@ import {IconProps} from './types';
|
|
|
5
5
|
import {ApplicationContext} from '../Application';
|
|
6
6
|
import {Image} from '../Image';
|
|
7
7
|
|
|
8
|
-
const Icon: React.FC<IconProps> = ({
|
|
8
|
+
const Icon: React.FC<IconProps> = ({
|
|
9
|
+
source = 'ic_back',
|
|
10
|
+
size = 24,
|
|
11
|
+
color,
|
|
12
|
+
style = {},
|
|
13
|
+
}) => {
|
|
9
14
|
const {theme} = useContext(ApplicationContext);
|
|
10
15
|
|
|
11
16
|
/**
|
|
@@ -20,8 +25,8 @@ const Icon: React.FC<IconProps> = ({source, size, color, style = {}}) => {
|
|
|
20
25
|
};
|
|
21
26
|
|
|
22
27
|
const tintColorProps = color !== null && {
|
|
23
|
-
tintColor: color ?? theme.colors.text.default
|
|
24
|
-
}
|
|
28
|
+
tintColor: color ?? theme.colors.text.default,
|
|
29
|
+
};
|
|
25
30
|
|
|
26
31
|
return (
|
|
27
32
|
<Image
|
|
@@ -33,9 +38,4 @@ const Icon: React.FC<IconProps> = ({source, size, color, style = {}}) => {
|
|
|
33
38
|
);
|
|
34
39
|
};
|
|
35
40
|
|
|
36
|
-
Icon.defaultProps = {
|
|
37
|
-
source: 'ic_back',
|
|
38
|
-
size: 24,
|
|
39
|
-
};
|
|
40
|
-
|
|
41
41
|
export {Icon, IconSources, IconBankSources};
|
package/IconButton/index.tsx
CHANGED
|
@@ -5,15 +5,10 @@ import {
|
|
|
5
5
|
TouchableOpacity,
|
|
6
6
|
TouchableOpacityProps,
|
|
7
7
|
} from 'react-native';
|
|
8
|
-
import {ApplicationContext} from '../Application';
|
|
8
|
+
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
|
-
|
|
14
|
-
const {
|
|
15
|
-
ScreenContext,
|
|
16
|
-
} = require('react-native/Libraries/Components/ScreenContext');
|
|
17
12
|
|
|
18
13
|
export interface IconButtonProps extends TouchableOpacityProps {
|
|
19
14
|
/**
|
|
@@ -33,21 +28,18 @@ export interface IconButtonProps extends TouchableOpacityProps {
|
|
|
33
28
|
size?: 'large' | 'small';
|
|
34
29
|
|
|
35
30
|
params?: any;
|
|
36
|
-
|
|
37
|
-
componentId?: string;
|
|
38
31
|
}
|
|
39
32
|
|
|
40
33
|
const IconButton: React.FC<IconButtonProps> = ({
|
|
41
|
-
type,
|
|
34
|
+
type = 'primary',
|
|
42
35
|
icon,
|
|
43
36
|
size,
|
|
44
37
|
onPress,
|
|
45
38
|
params,
|
|
46
|
-
|
|
39
|
+
accessibilityLabel,
|
|
47
40
|
...rest
|
|
48
41
|
}) => {
|
|
49
42
|
const {theme} = useContext(ApplicationContext);
|
|
50
|
-
const screenInfo = useContext<any>(ScreenContext);
|
|
51
43
|
|
|
52
44
|
/**
|
|
53
45
|
* get size icon button
|
|
@@ -133,30 +125,25 @@ const IconButton: React.FC<IconButtonProps> = ({
|
|
|
133
125
|
const iconSize = size === 'small' ? 16 : 24;
|
|
134
126
|
|
|
135
127
|
return (
|
|
136
|
-
<
|
|
128
|
+
<ComponentContext.Provider
|
|
137
129
|
value={{
|
|
138
|
-
...screenInfo,
|
|
139
130
|
componentName: 'IconButton',
|
|
140
131
|
params,
|
|
141
132
|
state: type === 'disabled' ? 'disabled' : 'enabled',
|
|
142
|
-
componentId,
|
|
143
|
-
componentValue:
|
|
133
|
+
componentId: accessibilityLabel,
|
|
134
|
+
componentValue: icon,
|
|
144
135
|
action: 'click',
|
|
145
136
|
}}>
|
|
146
137
|
<TouchableOpacity
|
|
147
138
|
{...rest}
|
|
139
|
+
accessibilityLabel={accessibilityLabel}
|
|
148
140
|
activeOpacity={activeOpacity}
|
|
149
141
|
onPress={onPressButton}
|
|
150
142
|
style={buttonStyle}>
|
|
151
143
|
<Icon size={iconSize} source={icon} color={getIconColor()} />
|
|
152
144
|
</TouchableOpacity>
|
|
153
|
-
</
|
|
145
|
+
</ComponentContext.Provider>
|
|
154
146
|
);
|
|
155
147
|
};
|
|
156
148
|
|
|
157
|
-
IconButton.defaultProps = {
|
|
158
|
-
type: 'primary',
|
|
159
|
-
disabled: false,
|
|
160
|
-
};
|
|
161
|
-
|
|
162
149
|
export {IconButton};
|
package/Image/index.tsx
CHANGED
|
@@ -1,27 +1,41 @@
|
|
|
1
|
-
import React, {useContext, useRef, useState} from 'react';
|
|
1
|
+
import React, {useContext, useEffect, useRef, useState} from 'react';
|
|
2
2
|
import {StyleSheet, View} from 'react-native';
|
|
3
3
|
import FastImage, {Source} from 'react-native-fast-image';
|
|
4
4
|
import styles from './styles';
|
|
5
|
-
import {ApplicationContext} from '../Application';
|
|
5
|
+
import {ApplicationContext, ComponentContext, MiniAppContext} from '../Application';
|
|
6
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
|
|
|
14
13
|
const Image: React.FC<ImageProps> = ({
|
|
15
14
|
style,
|
|
16
15
|
source,
|
|
17
|
-
loading,
|
|
16
|
+
loading = true,
|
|
18
17
|
children,
|
|
18
|
+
params,
|
|
19
|
+
accessibilityLabel,
|
|
19
20
|
...rest
|
|
20
21
|
}) => {
|
|
21
22
|
const {theme} = useContext(ApplicationContext);
|
|
23
|
+
const app = useContext<any>(MiniAppContext);
|
|
24
|
+
const component = useContext<any>(ComponentContext);
|
|
22
25
|
const error = useRef(false);
|
|
23
26
|
const [status, setStatus] = useState<Status>('success');
|
|
24
27
|
|
|
28
|
+
const test: any = {
|
|
29
|
+
accessibilityLabel: accessibilityLabel || `img|${(source as Source).uri}`,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
if(app.enableAutoId){
|
|
34
|
+
component?.addChildren?.(test.accessibilityLabel, 'add');
|
|
35
|
+
return () => component?.addChildren(test.accessibilityLabel, 'remove');
|
|
36
|
+
}
|
|
37
|
+
}, []);
|
|
38
|
+
|
|
25
39
|
/**
|
|
26
40
|
* render content loading | fail | rendered
|
|
27
41
|
*/
|
|
@@ -43,42 +57,38 @@ const Image: React.FC<ImageProps> = ({
|
|
|
43
57
|
};
|
|
44
58
|
|
|
45
59
|
return (
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
60
|
+
<FastImage
|
|
61
|
+
{...rest}
|
|
62
|
+
{...test}
|
|
63
|
+
source={source}
|
|
64
|
+
style={[styles.container, style]}
|
|
65
|
+
onProgress={() => {
|
|
66
|
+
error.current = false;
|
|
67
|
+
if (status !== 'loading' && loading) {
|
|
68
|
+
setStatus('loading');
|
|
69
|
+
}
|
|
70
|
+
}}
|
|
71
|
+
onLoadStart={() => {
|
|
72
|
+
error.current = false;
|
|
73
|
+
}}
|
|
74
|
+
onLoad={() => {
|
|
75
|
+
error.current = false;
|
|
76
|
+
}}
|
|
77
|
+
onLoadEnd={() => {
|
|
78
|
+
let current: Status = 'success';
|
|
79
|
+
if (error.current) {
|
|
80
|
+
current = 'error';
|
|
81
|
+
}
|
|
82
|
+
if (status !== current) {
|
|
83
|
+
setStatus(current);
|
|
84
|
+
}
|
|
85
|
+
}}
|
|
86
|
+
onError={() => {
|
|
87
|
+
error.current = true;
|
|
88
|
+
}}>
|
|
89
|
+
{renderContent()}
|
|
90
|
+
</FastImage>
|
|
77
91
|
);
|
|
78
92
|
};
|
|
79
93
|
|
|
80
|
-
Image.defaultProps = {
|
|
81
|
-
loading: true,
|
|
82
|
-
};
|
|
83
|
-
|
|
84
94
|
export {Image};
|
package/Image/types.ts
CHANGED
package/Input/Input.tsx
CHANGED
|
@@ -7,23 +7,13 @@ import {
|
|
|
7
7
|
TouchableOpacity,
|
|
8
8
|
View,
|
|
9
9
|
} from 'react-native';
|
|
10
|
-
import {ApplicationContext} from '../Application';
|
|
10
|
+
import {ApplicationContext, ComponentContext} from '../Application';
|
|
11
11
|
import styles from './styles';
|
|
12
12
|
import {ErrorView, FloatingView, getBorderColor, getSizeStyle} from './common';
|
|
13
13
|
import {InputProps} from './index';
|
|
14
14
|
import {Icon} from '../Icon';
|
|
15
15
|
import {checkTyping} from './utils';
|
|
16
16
|
import {Loader} from '../Loader';
|
|
17
|
-
import {
|
|
18
|
-
formatComponentName,
|
|
19
|
-
getAccessibilityID,
|
|
20
|
-
cleanNameForTracking,
|
|
21
|
-
} from '../Application/utils';
|
|
22
|
-
|
|
23
|
-
const {
|
|
24
|
-
ScreenContext,
|
|
25
|
-
MiniAppContext,
|
|
26
|
-
} = require('react-native/Libraries/Components/ScreenContext');
|
|
27
17
|
|
|
28
18
|
const Input = forwardRef(
|
|
29
19
|
(
|
|
@@ -52,18 +42,16 @@ const Input = forwardRef(
|
|
|
52
42
|
keyboardType,
|
|
53
43
|
style,
|
|
54
44
|
params,
|
|
55
|
-
|
|
45
|
+
accessibilityLabel,
|
|
56
46
|
...props
|
|
57
47
|
}: InputProps,
|
|
58
48
|
ref,
|
|
59
49
|
) => {
|
|
60
50
|
const {theme} = useContext(ApplicationContext);
|
|
61
|
-
const {appId, code} = useContext<any>(MiniAppContext);
|
|
62
51
|
const [focused, setFocused] = useState(false);
|
|
63
52
|
const [haveValue, setHaveValue] = useState(!!value || !!props.defaultValue);
|
|
64
53
|
const [secureTextInput, setSecureTextInput] = useState(secureTextEntry);
|
|
65
54
|
const inputRef = (ref as React.RefObject<TextInput>) ?? useRef<TextInput>();
|
|
66
|
-
const screenInfo = useContext<any>(ScreenContext);
|
|
67
55
|
|
|
68
56
|
const onClearText = () => {
|
|
69
57
|
inputRef?.current?.clear();
|
|
@@ -122,21 +110,6 @@ const Input = forwardRef(
|
|
|
122
110
|
let textColor = theme.colors.text.default;
|
|
123
111
|
let placeholderColor = theme.colors.text.hint;
|
|
124
112
|
let iconTintColor = iconColor;
|
|
125
|
-
const accessibilityID = disabled
|
|
126
|
-
? getAccessibilityID(
|
|
127
|
-
`${appId}/${code}/${
|
|
128
|
-
screenInfo.screenName
|
|
129
|
-
}/input_${cleanNameForTracking(
|
|
130
|
-
floatingValue ?? placeholder,
|
|
131
|
-
)}_disabled`,
|
|
132
|
-
)
|
|
133
|
-
: getAccessibilityID(
|
|
134
|
-
`${appId}/${code}/${
|
|
135
|
-
screenInfo.screenName
|
|
136
|
-
}/input_${cleanNameForTracking(
|
|
137
|
-
floatingValue ?? placeholder ?? value,
|
|
138
|
-
)}`,
|
|
139
|
-
);
|
|
140
113
|
|
|
141
114
|
if (disabled) {
|
|
142
115
|
textColor = disabledColor;
|
|
@@ -178,7 +151,7 @@ const Input = forwardRef(
|
|
|
178
151
|
)}
|
|
179
152
|
<TextInput
|
|
180
153
|
{...props}
|
|
181
|
-
{
|
|
154
|
+
accessibilityLabel={accessibilityLabel}
|
|
182
155
|
editable={props.editable && !disabled}
|
|
183
156
|
secureTextEntry={secure}
|
|
184
157
|
textAlignVertical="center"
|
|
@@ -234,20 +207,19 @@ const Input = forwardRef(
|
|
|
234
207
|
}
|
|
235
208
|
|
|
236
209
|
return (
|
|
237
|
-
<
|
|
210
|
+
<ComponentContext.Provider
|
|
238
211
|
value={{
|
|
239
|
-
...screenInfo,
|
|
240
212
|
componentName: 'Input',
|
|
241
213
|
params,
|
|
242
|
-
componentLabel:
|
|
214
|
+
componentLabel: floatingValue,
|
|
243
215
|
state: inputState,
|
|
244
|
-
componentId,
|
|
216
|
+
componentId: accessibilityLabel,
|
|
245
217
|
}}>
|
|
246
218
|
<View style={[style, styles.wrapper]}>
|
|
247
219
|
{renderInputView()}
|
|
248
220
|
<ErrorView errorMessage={errorMessage} errorSpacing={errorSpacing} />
|
|
249
221
|
</View>
|
|
250
|
-
</
|
|
222
|
+
</ComponentContext.Provider>
|
|
251
223
|
);
|
|
252
224
|
},
|
|
253
225
|
);
|
package/Input/InputDropDown.tsx
CHANGED
|
@@ -1,22 +1,12 @@
|
|
|
1
1
|
import React, {useContext} from 'react';
|
|
2
2
|
import {TextInput, TouchableOpacity, View} from 'react-native';
|
|
3
|
-
import {ApplicationContext} from '../Application';
|
|
3
|
+
import {ApplicationContext, ComponentContext} from '../Application';
|
|
4
4
|
import styles from './styles';
|
|
5
5
|
import {ErrorView, FloatingView, getBorderColor, getSizeStyle} from './common';
|
|
6
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 {
|
|
11
|
-
cleanNameForTracking,
|
|
12
|
-
formatComponentName,
|
|
13
|
-
getAccessibilityID,
|
|
14
|
-
} from '../Application/utils';
|
|
15
|
-
|
|
16
|
-
const {
|
|
17
|
-
ScreenContext,
|
|
18
|
-
MiniAppContext,
|
|
19
|
-
} = require('react-native/Libraries/Components/ScreenContext');
|
|
20
10
|
|
|
21
11
|
const InputDropDown = ({
|
|
22
12
|
value,
|
|
@@ -37,13 +27,11 @@ const InputDropDown = ({
|
|
|
37
27
|
leadingIconColor,
|
|
38
28
|
style,
|
|
39
29
|
params,
|
|
40
|
-
|
|
30
|
+
accessibilityLabel,
|
|
41
31
|
...props
|
|
42
32
|
}: InputDropDownProps) => {
|
|
43
|
-
const {appId, code} = useContext<any>(MiniAppContext);
|
|
44
33
|
const {theme} = useContext(ApplicationContext);
|
|
45
34
|
const full = !!value || !!placeholder;
|
|
46
|
-
const screenInfo = useContext<any>(ScreenContext);
|
|
47
35
|
|
|
48
36
|
const renderIcon = (color: string | undefined) => {
|
|
49
37
|
if (loading) {
|
|
@@ -59,19 +47,6 @@ const InputDropDown = ({
|
|
|
59
47
|
let textColor = theme.colors.text.default;
|
|
60
48
|
let placeholderColor = theme.colors.text.hint;
|
|
61
49
|
let iconTintColor = iconColor;
|
|
62
|
-
const accessibilityID = disabled
|
|
63
|
-
? getAccessibilityID(
|
|
64
|
-
`${appId}/${code}/${
|
|
65
|
-
screenInfo.screenName
|
|
66
|
-
}/input_${cleanNameForTracking(
|
|
67
|
-
floatingValue ?? placeholder,
|
|
68
|
-
)}_disabled`,
|
|
69
|
-
)
|
|
70
|
-
: getAccessibilityID(
|
|
71
|
-
`${appId}/${code}/${
|
|
72
|
-
screenInfo.screenName
|
|
73
|
-
}/input_${cleanNameForTracking(floatingValue ?? placeholder)}`,
|
|
74
|
-
);
|
|
75
50
|
|
|
76
51
|
if (disabled) {
|
|
77
52
|
textColor = disabledColor;
|
|
@@ -107,10 +82,9 @@ const InputDropDown = ({
|
|
|
107
82
|
{full && (
|
|
108
83
|
<TextInput
|
|
109
84
|
{...props}
|
|
110
|
-
{
|
|
85
|
+
accessibilityLabel={accessibilityLabel}
|
|
111
86
|
onPressIn={onPress}
|
|
112
87
|
editable={false}
|
|
113
|
-
textAlignVertical="top"
|
|
114
88
|
style={[
|
|
115
89
|
styles.input,
|
|
116
90
|
{
|
|
@@ -132,14 +106,13 @@ const InputDropDown = ({
|
|
|
132
106
|
};
|
|
133
107
|
|
|
134
108
|
return (
|
|
135
|
-
<
|
|
109
|
+
<ComponentContext.Provider
|
|
136
110
|
value={{
|
|
137
|
-
|
|
138
|
-
componentName: 'InputOTP',
|
|
111
|
+
componentName: 'InputDropDown',
|
|
139
112
|
params,
|
|
140
113
|
state: 'enabled',
|
|
141
|
-
componentLabel:
|
|
142
|
-
componentId,
|
|
114
|
+
componentLabel: floatingValue,
|
|
115
|
+
componentId: accessibilityLabel,
|
|
143
116
|
}}>
|
|
144
117
|
<TouchableOpacity
|
|
145
118
|
onPress={onPress}
|
|
@@ -147,7 +120,7 @@ const InputDropDown = ({
|
|
|
147
120
|
{renderInputView()}
|
|
148
121
|
<ErrorView errorMessage={errorMessage} errorSpacing={errorSpacing} />
|
|
149
122
|
</TouchableOpacity>
|
|
150
|
-
</
|
|
123
|
+
</ComponentContext.Provider>
|
|
151
124
|
);
|
|
152
125
|
};
|
|
153
126
|
|
package/Input/InputMoney.tsx
CHANGED
|
@@ -12,22 +12,12 @@ import {
|
|
|
12
12
|
TouchableOpacity,
|
|
13
13
|
View,
|
|
14
14
|
} from 'react-native';
|
|
15
|
-
import {ApplicationContext} from '../Application';
|
|
15
|
+
import {ApplicationContext, ComponentContext} from '../Application';
|
|
16
16
|
import styles from './styles';
|
|
17
17
|
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 {
|
|
22
|
-
cleanNameForTracking,
|
|
23
|
-
formatComponentName,
|
|
24
|
-
getAccessibilityID,
|
|
25
|
-
} from '../Application/utils';
|
|
26
|
-
|
|
27
|
-
const {
|
|
28
|
-
ScreenContext,
|
|
29
|
-
MiniAppContext,
|
|
30
|
-
} = require('react-native/Libraries/Components/ScreenContext');
|
|
31
21
|
|
|
32
22
|
const InputMoney = forwardRef(
|
|
33
23
|
(
|
|
@@ -48,16 +38,14 @@ const InputMoney = forwardRef(
|
|
|
48
38
|
style,
|
|
49
39
|
params,
|
|
50
40
|
defaultValue = '',
|
|
51
|
-
|
|
41
|
+
accessibilityLabel,
|
|
52
42
|
...props
|
|
53
43
|
}: InputMoneyProps,
|
|
54
44
|
ref,
|
|
55
45
|
) => {
|
|
56
46
|
const {theme} = useContext(ApplicationContext);
|
|
57
|
-
const {appId, code} = useContext<any>(MiniAppContext);
|
|
58
47
|
const [focused, setFocused] = useState(false);
|
|
59
48
|
const inputRef = (ref as React.RefObject<TextInput>) ?? useRef<TextInput>();
|
|
60
|
-
const screenInfo = useContext<any>(ScreenContext);
|
|
61
49
|
|
|
62
50
|
const validateText = (text: string) => {
|
|
63
51
|
const valueFormat = formatMoneyToNumber(text, 'đ');
|
|
@@ -103,17 +91,6 @@ const InputMoney = forwardRef(
|
|
|
103
91
|
let textColor = theme.colors.text.default;
|
|
104
92
|
let placeholderColor = theme.colors.text.hint;
|
|
105
93
|
let iconTintColor = iconColor;
|
|
106
|
-
const accessibilityID = disabled
|
|
107
|
-
? getAccessibilityID(
|
|
108
|
-
`${appId}/${code}/${
|
|
109
|
-
screenInfo.screenName
|
|
110
|
-
}/input_${cleanNameForTracking(floatingValue)}_disabled`,
|
|
111
|
-
)
|
|
112
|
-
: getAccessibilityID(
|
|
113
|
-
`${appId}/${code}/${
|
|
114
|
-
screenInfo.screenName
|
|
115
|
-
}/input_${cleanNameForTracking(floatingValue)}`,
|
|
116
|
-
);
|
|
117
94
|
|
|
118
95
|
if (disabled) {
|
|
119
96
|
textColor = disabledColor;
|
|
@@ -139,9 +116,8 @@ const InputMoney = forwardRef(
|
|
|
139
116
|
<View style={styles.inputView}>
|
|
140
117
|
<TextInput
|
|
141
118
|
{...props}
|
|
142
|
-
{
|
|
119
|
+
accessibilityLabel={accessibilityLabel}
|
|
143
120
|
editable={!disabled}
|
|
144
|
-
textAlignVertical="top"
|
|
145
121
|
ref={inputRef}
|
|
146
122
|
keyboardType={'number-pad'}
|
|
147
123
|
style={[
|
|
@@ -191,20 +167,19 @@ const InputMoney = forwardRef(
|
|
|
191
167
|
}
|
|
192
168
|
|
|
193
169
|
return (
|
|
194
|
-
<
|
|
170
|
+
<ComponentContext.Provider
|
|
195
171
|
value={{
|
|
196
|
-
...screenInfo,
|
|
197
172
|
componentName: 'InputMoney',
|
|
198
173
|
params,
|
|
199
|
-
componentLabel:
|
|
174
|
+
componentLabel: floatingValue,
|
|
200
175
|
state: inputState,
|
|
201
|
-
componentId,
|
|
176
|
+
componentId: accessibilityLabel,
|
|
202
177
|
}}>
|
|
203
178
|
<View style={[style, styles.wrapper]}>
|
|
204
179
|
{renderInputView()}
|
|
205
180
|
<ErrorView errorMessage={errorMessage} errorSpacing={errorSpacing} />
|
|
206
181
|
</View>
|
|
207
|
-
</
|
|
182
|
+
</ComponentContext.Provider>
|
|
208
183
|
);
|
|
209
184
|
},
|
|
210
185
|
);
|