@momo-kits/foundation 0.89.5 → 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/Application/BottomTab.tsx +6 -1
- package/Application/Components.tsx +21 -8
- package/Application/NavigationContainer.tsx +8 -3
- package/Application/Navigator.ts +51 -31
- package/Application/StackScreen.tsx +69 -9
- package/Application/types.ts +2 -0
- package/Application/utils.tsx +61 -2
- package/Button/index.tsx +46 -16
- package/CheckBox/index.tsx +44 -21
- package/CheckBox/types.ts +4 -0
- package/IconButton/index.tsx +30 -7
- package/Image/index.tsx +3 -0
- package/Input/Input.tsx +39 -5
- package/Input/InputDropDown.tsx +30 -5
- package/Input/InputMoney.tsx +41 -5
- package/Input/InputOTP.tsx +31 -8
- package/Input/InputSearch.tsx +60 -26
- package/Input/InputTextArea.tsx +12 -2
- package/Input/index.tsx +27 -2
- package/Popup/PopupNotify.tsx +12 -0
- package/Popup/PopupPromotion.tsx +8 -2
- package/Radio/index.tsx +43 -20
- package/Radio/types.ts +5 -0
- package/Switch/index.tsx +36 -14
- package/Switch/types.ts +4 -0
- package/index.ts +2 -1
- package/package.json +1 -1
package/CheckBox/index.tsx
CHANGED
|
@@ -2,9 +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} from '../Application';
|
|
5
|
+
import {ApplicationContext, MiniAppContext} from '../Application';
|
|
6
6
|
import {Text} from '../Text';
|
|
7
7
|
import {Icon} from '../Icon';
|
|
8
|
+
import {formatNameLength, getAccessibilityID} from '../Application/utils';
|
|
9
|
+
|
|
10
|
+
const {
|
|
11
|
+
ScreenContext,
|
|
12
|
+
} = require('react-native/Libraries/Components/ScreenContext');
|
|
8
13
|
|
|
9
14
|
const CheckBox: FC<CheckBoxProps> = ({
|
|
10
15
|
value,
|
|
@@ -13,8 +18,12 @@ const CheckBox: FC<CheckBoxProps> = ({
|
|
|
13
18
|
style,
|
|
14
19
|
label,
|
|
15
20
|
indeterminate,
|
|
21
|
+
params,
|
|
22
|
+
componentId,
|
|
16
23
|
}) => {
|
|
24
|
+
const {appId} = useContext(MiniAppContext)
|
|
17
25
|
const {theme} = useContext(ApplicationContext);
|
|
26
|
+
const screenInfo = useContext<any>(ScreenContext);
|
|
18
27
|
const haveValue = value || indeterminate;
|
|
19
28
|
const iconSource = indeterminate ? 'ic_minus' : 'ic_checked';
|
|
20
29
|
let borderColor = theme.colors.text.default;
|
|
@@ -33,28 +42,42 @@ const CheckBox: FC<CheckBoxProps> = ({
|
|
|
33
42
|
backgroundColor = theme.colors.background.tonal;
|
|
34
43
|
}
|
|
35
44
|
}
|
|
45
|
+
const accessibilityID = getAccessibilityID(`${appId}|${screenInfo.screenName}|cbx_${label}_${value}`)
|
|
36
46
|
|
|
37
47
|
return (
|
|
38
|
-
<
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
48
|
+
<ScreenContext.Provider
|
|
49
|
+
value={{
|
|
50
|
+
...screenInfo,
|
|
51
|
+
componentName: 'Button',
|
|
52
|
+
params,
|
|
53
|
+
state: disabled ? 'disabled' : 'filled',
|
|
54
|
+
componentId,
|
|
55
|
+
action: 'click',
|
|
56
|
+
componentLabel: formatNameLength(label || ''),
|
|
57
|
+
componentValue: indeterminate ? 'indetermine' : value,
|
|
58
|
+
}}>
|
|
59
|
+
<TouchableOpacity
|
|
60
|
+
{...accessibilityID}
|
|
61
|
+
activeOpacity={0.8}
|
|
62
|
+
onPress={() => onChange?.(!value)}
|
|
63
|
+
disabled={disabled}
|
|
64
|
+
style={[style, styles.container]}>
|
|
65
|
+
<View
|
|
66
|
+
style={[
|
|
67
|
+
{borderColor, backgroundColor, borderWidth: 1},
|
|
68
|
+
styles.checkbox,
|
|
69
|
+
]}>
|
|
70
|
+
{haveValue && (
|
|
71
|
+
<Icon
|
|
72
|
+
color={theme.colors.background.surface}
|
|
73
|
+
size={20}
|
|
74
|
+
source={iconSource}
|
|
75
|
+
/>
|
|
76
|
+
)}
|
|
77
|
+
</View>
|
|
78
|
+
{!!label && <Text typography={'body_default_regular'}>{label}</Text>}
|
|
79
|
+
</TouchableOpacity>
|
|
80
|
+
</ScreenContext.Provider>
|
|
58
81
|
);
|
|
59
82
|
};
|
|
60
83
|
|
package/CheckBox/types.ts
CHANGED
package/IconButton/index.tsx
CHANGED
|
@@ -9,6 +9,11 @@ import {ApplicationContext} 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');
|
|
12
17
|
|
|
13
18
|
export interface IconButtonProps extends TouchableOpacityProps {
|
|
14
19
|
/**
|
|
@@ -26,6 +31,10 @@ export interface IconButtonProps extends TouchableOpacityProps {
|
|
|
26
31
|
* Optional. Defines the size of the IconButton.
|
|
27
32
|
*/
|
|
28
33
|
size?: 'large' | 'small';
|
|
34
|
+
|
|
35
|
+
params?: any;
|
|
36
|
+
|
|
37
|
+
componentId?: string;
|
|
29
38
|
}
|
|
30
39
|
|
|
31
40
|
const IconButton: React.FC<IconButtonProps> = ({
|
|
@@ -33,9 +42,12 @@ const IconButton: React.FC<IconButtonProps> = ({
|
|
|
33
42
|
icon,
|
|
34
43
|
size,
|
|
35
44
|
onPress,
|
|
45
|
+
params,
|
|
46
|
+
componentId,
|
|
36
47
|
...rest
|
|
37
48
|
}) => {
|
|
38
49
|
const {theme} = useContext(ApplicationContext);
|
|
50
|
+
const screenInfo = useContext<any>(ScreenContext);
|
|
39
51
|
|
|
40
52
|
/**
|
|
41
53
|
* get size icon button
|
|
@@ -121,13 +133,24 @@ const IconButton: React.FC<IconButtonProps> = ({
|
|
|
121
133
|
const iconSize = size === 'small' ? 16 : 24;
|
|
122
134
|
|
|
123
135
|
return (
|
|
124
|
-
<
|
|
125
|
-
{
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
136
|
+
<ScreenContext.Provider
|
|
137
|
+
value={{
|
|
138
|
+
...screenInfo,
|
|
139
|
+
componentName: 'IconButton',
|
|
140
|
+
params,
|
|
141
|
+
state: type === 'disabled' ? 'disabled' : 'enabled',
|
|
142
|
+
componentId,
|
|
143
|
+
componentValue: formatComponentName(icon),
|
|
144
|
+
action: 'click',
|
|
145
|
+
}}>
|
|
146
|
+
<TouchableOpacity
|
|
147
|
+
{...rest}
|
|
148
|
+
activeOpacity={activeOpacity}
|
|
149
|
+
onPress={onPressButton}
|
|
150
|
+
style={buttonStyle}>
|
|
151
|
+
<Icon size={iconSize} source={icon} color={getIconColor()} />
|
|
152
|
+
</TouchableOpacity>
|
|
153
|
+
</ScreenContext.Provider>
|
|
131
154
|
);
|
|
132
155
|
};
|
|
133
156
|
|
package/Image/index.tsx
CHANGED
|
@@ -7,6 +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
11
|
|
|
11
12
|
type Status = 'success' | 'loading' | 'error';
|
|
12
13
|
|
|
@@ -41,9 +42,11 @@ const Image: React.FC<ImageProps> = ({
|
|
|
41
42
|
return children;
|
|
42
43
|
};
|
|
43
44
|
|
|
45
|
+
const accessibilityID = getAccessibilityID(`img|${source}`)
|
|
44
46
|
return (
|
|
45
47
|
<FastImage
|
|
46
48
|
{...rest}
|
|
49
|
+
{...accessibilityID}
|
|
47
50
|
source={source}
|
|
48
51
|
style={[styles.container, style]}
|
|
49
52
|
onProgress={() => {
|
package/Input/Input.tsx
CHANGED
|
@@ -6,13 +6,18 @@ import {
|
|
|
6
6
|
TouchableOpacity,
|
|
7
7
|
View,
|
|
8
8
|
} from 'react-native';
|
|
9
|
-
import {ApplicationContext} from '../Application';
|
|
9
|
+
import {ApplicationContext, MiniAppContext} from '../Application';
|
|
10
10
|
import styles from './styles';
|
|
11
11
|
import {ErrorView, FloatingView, getBorderColor, getSizeStyle} from './common';
|
|
12
12
|
import {InputProps} from './index';
|
|
13
13
|
import {Icon} from '../Icon';
|
|
14
14
|
import {checkTyping} from './utils';
|
|
15
15
|
import {Loader} from '../Loader';
|
|
16
|
+
import {formatComponentName, getAccessibilityID} from '../Application/utils';
|
|
17
|
+
|
|
18
|
+
const {
|
|
19
|
+
ScreenContext,
|
|
20
|
+
} = require('react-native/Libraries/Components/ScreenContext');
|
|
16
21
|
|
|
17
22
|
const Input = forwardRef(
|
|
18
23
|
(
|
|
@@ -39,15 +44,19 @@ const Input = forwardRef(
|
|
|
39
44
|
onPressIcon,
|
|
40
45
|
secureTextEntry,
|
|
41
46
|
style,
|
|
47
|
+
params,
|
|
48
|
+
componentId,
|
|
42
49
|
...props
|
|
43
50
|
}: InputProps,
|
|
44
51
|
ref,
|
|
45
52
|
) => {
|
|
46
53
|
const {theme} = useContext(ApplicationContext);
|
|
54
|
+
const {appId} = useContext(MiniAppContext)
|
|
47
55
|
const [focused, setFocused] = useState(false);
|
|
48
56
|
const [haveValue, setHaveValue] = useState(!!value || !!props.defaultValue);
|
|
49
57
|
const [secureTextInput, setSecureTextInput] = useState(secureTextEntry);
|
|
50
58
|
const inputRef = (ref as React.RefObject<TextInput>) ?? useRef<TextInput>();
|
|
59
|
+
const screenInfo = useContext<any>(ScreenContext);
|
|
51
60
|
|
|
52
61
|
const onClearText = () => {
|
|
53
62
|
inputRef?.current?.clear();
|
|
@@ -180,11 +189,36 @@ const Input = forwardRef(
|
|
|
180
189
|
);
|
|
181
190
|
};
|
|
182
191
|
|
|
192
|
+
let inputState = 'active';
|
|
193
|
+
|
|
194
|
+
if (value && value?.length > 0) {
|
|
195
|
+
inputState = 'filled';
|
|
196
|
+
}
|
|
197
|
+
if (errorMessage && errorMessage?.length > 0) {
|
|
198
|
+
inputState = 'error';
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
if (disabled) {
|
|
202
|
+
inputState = 'disabled';
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const accessibilityID = getAccessibilityID(`${appId}|${screenInfo.screenName}|input_${floatingValue}${disabled && "_disabled" }`)
|
|
206
|
+
|
|
183
207
|
return (
|
|
184
|
-
<
|
|
185
|
-
{
|
|
186
|
-
|
|
187
|
-
|
|
208
|
+
<ScreenContext.Provider
|
|
209
|
+
value={{
|
|
210
|
+
...screenInfo,
|
|
211
|
+
componentName: 'Input',
|
|
212
|
+
params,
|
|
213
|
+
componentLabel: formatComponentName(floatingValue || ''),
|
|
214
|
+
state: inputState,
|
|
215
|
+
componentId,
|
|
216
|
+
}}>
|
|
217
|
+
<View {...accessibilityID} style={[style, styles.wrapper]}>
|
|
218
|
+
{renderInputView()}
|
|
219
|
+
<ErrorView errorMessage={errorMessage} errorSpacing={errorSpacing} />
|
|
220
|
+
</View>
|
|
221
|
+
</ScreenContext.Provider>
|
|
188
222
|
);
|
|
189
223
|
},
|
|
190
224
|
);
|
package/Input/InputDropDown.tsx
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import React, {useContext} from 'react';
|
|
2
2
|
import {TextInput, TouchableOpacity, View} from 'react-native';
|
|
3
|
-
import {ApplicationContext} from '../Application';
|
|
3
|
+
import {ApplicationContext, MiniAppContext} 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 {formatComponentName, getAccessibilityID} from '../Application/utils';
|
|
11
|
+
|
|
12
|
+
const {
|
|
13
|
+
ScreenContext,
|
|
14
|
+
} = require('react-native/Libraries/Components/ScreenContext');
|
|
10
15
|
|
|
11
16
|
const InputDropDown = ({
|
|
12
17
|
value,
|
|
@@ -26,10 +31,14 @@ const InputDropDown = ({
|
|
|
26
31
|
leadingIcon,
|
|
27
32
|
leadingIconColor,
|
|
28
33
|
style,
|
|
34
|
+
params,
|
|
35
|
+
componentId,
|
|
29
36
|
...props
|
|
30
37
|
}: InputDropDownProps) => {
|
|
38
|
+
const {appId} = useContext(MiniAppContext)
|
|
31
39
|
const {theme} = useContext(ApplicationContext);
|
|
32
40
|
const full = !!value || !!placeholder;
|
|
41
|
+
const screenInfo = useContext<any>(ScreenContext);
|
|
33
42
|
|
|
34
43
|
const renderIcon = (color: string | undefined) => {
|
|
35
44
|
if (loading) {
|
|
@@ -103,11 +112,27 @@ const InputDropDown = ({
|
|
|
103
112
|
);
|
|
104
113
|
};
|
|
105
114
|
|
|
115
|
+
const accessibilityID = getAccessibilityID(`${appId}|${screenInfo.screenName}|input_${floatingValue}${disabled && "_disabled" }`)
|
|
116
|
+
|
|
117
|
+
|
|
106
118
|
return (
|
|
107
|
-
<
|
|
108
|
-
{
|
|
109
|
-
|
|
110
|
-
|
|
119
|
+
<ScreenContext.Provider
|
|
120
|
+
value={{
|
|
121
|
+
...screenInfo,
|
|
122
|
+
componentName: 'InputOTP',
|
|
123
|
+
params,
|
|
124
|
+
state: 'enabled',
|
|
125
|
+
componentLabel: formatComponentName(floatingValue || ''),
|
|
126
|
+
componentId,
|
|
127
|
+
}}>
|
|
128
|
+
<TouchableOpacity
|
|
129
|
+
{...accessibilityID}
|
|
130
|
+
onPress={onPress}
|
|
131
|
+
style={[style, full && styles.wrapper]}>
|
|
132
|
+
{renderInputView()}
|
|
133
|
+
<ErrorView errorMessage={errorMessage} errorSpacing={errorSpacing} />
|
|
134
|
+
</TouchableOpacity>
|
|
135
|
+
</ScreenContext.Provider>
|
|
111
136
|
);
|
|
112
137
|
};
|
|
113
138
|
|
package/Input/InputMoney.tsx
CHANGED
|
@@ -12,12 +12,17 @@ import {
|
|
|
12
12
|
TouchableOpacity,
|
|
13
13
|
View,
|
|
14
14
|
} from 'react-native';
|
|
15
|
-
import {ApplicationContext} from '../Application';
|
|
15
|
+
import {ApplicationContext, MiniAppContext} 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 {formatComponentName, getAccessibilityID} from '../Application/utils';
|
|
22
|
+
|
|
23
|
+
const {
|
|
24
|
+
ScreenContext,
|
|
25
|
+
} = require('react-native/Libraries/Components/ScreenContext');
|
|
21
26
|
|
|
22
27
|
const InputMoney = forwardRef(
|
|
23
28
|
(
|
|
@@ -36,14 +41,18 @@ const InputMoney = forwardRef(
|
|
|
36
41
|
required = false,
|
|
37
42
|
errorSpacing,
|
|
38
43
|
style,
|
|
44
|
+
params,
|
|
39
45
|
defaultValue = '',
|
|
46
|
+
componentId,
|
|
40
47
|
...props
|
|
41
48
|
}: InputMoneyProps,
|
|
42
49
|
ref,
|
|
43
50
|
) => {
|
|
44
51
|
const {theme} = useContext(ApplicationContext);
|
|
52
|
+
const {appId} = useContext(MiniAppContext)
|
|
45
53
|
const [focused, setFocused] = useState(false);
|
|
46
54
|
const inputRef = (ref as React.RefObject<TextInput>) ?? useRef<TextInput>();
|
|
55
|
+
const screenInfo = useContext<any>(ScreenContext);
|
|
47
56
|
|
|
48
57
|
const validateText = (text: string) => {
|
|
49
58
|
const valueFormat = formatMoneyToNumber(text, 'đ');
|
|
@@ -151,11 +160,38 @@ const InputMoney = forwardRef(
|
|
|
151
160
|
);
|
|
152
161
|
};
|
|
153
162
|
|
|
163
|
+
let inputState = 'active';
|
|
164
|
+
|
|
165
|
+
if (value && value?.length > 0) {
|
|
166
|
+
inputState = 'filled';
|
|
167
|
+
}
|
|
168
|
+
if (errorMessage && errorMessage?.length > 0) {
|
|
169
|
+
inputState = 'error';
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (disabled) {
|
|
173
|
+
inputState = 'disabled';
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const accessibilityID = getAccessibilityID(`${appId}|${screenInfo.screenName}|input_${floatingValue}${disabled && "_disabled" }`)
|
|
177
|
+
|
|
154
178
|
return (
|
|
155
|
-
<
|
|
156
|
-
{
|
|
157
|
-
|
|
158
|
-
|
|
179
|
+
<ScreenContext.Provider
|
|
180
|
+
value={{
|
|
181
|
+
...screenInfo,
|
|
182
|
+
componentName: 'InputMoney',
|
|
183
|
+
params,
|
|
184
|
+
componentLabel: formatComponentName(floatingValue || ''),
|
|
185
|
+
state: inputState,
|
|
186
|
+
componentId,
|
|
187
|
+
}}>
|
|
188
|
+
<View
|
|
189
|
+
{...accessibilityID}
|
|
190
|
+
style={[style, styles.wrapper]}>
|
|
191
|
+
{renderInputView()}
|
|
192
|
+
<ErrorView errorMessage={errorMessage} errorSpacing={errorSpacing} />
|
|
193
|
+
</View>
|
|
194
|
+
</ScreenContext.Provider>
|
|
159
195
|
);
|
|
160
196
|
},
|
|
161
197
|
);
|
package/Input/InputOTP.tsx
CHANGED
|
@@ -19,11 +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} from '../Application';
|
|
22
|
+
import {ApplicationContext, MiniAppContext} from '../Application';
|
|
23
23
|
import {Spacing} from '../Consts';
|
|
24
|
+
import {formatComponentName, getAccessibilityID} from '../Application/utils';
|
|
25
|
+
|
|
26
|
+
const {
|
|
27
|
+
ScreenContext,
|
|
28
|
+
} = require('react-native/Libraries/Components/ScreenContext');
|
|
24
29
|
|
|
25
30
|
const OTPCaret: FC<CaretProps> = ({index, length}) => {
|
|
26
31
|
const DURATION = 300;
|
|
32
|
+
const {appId} = useContext(MiniAppContext)
|
|
27
33
|
const {theme} = useContext(ApplicationContext);
|
|
28
34
|
const opacity = useRef(new Animated.Value(0)).current;
|
|
29
35
|
|
|
@@ -78,16 +84,21 @@ const InputOTP = forwardRef(
|
|
|
78
84
|
onFocus,
|
|
79
85
|
onBlur,
|
|
80
86
|
dataType = 'number',
|
|
87
|
+
params,
|
|
81
88
|
style,
|
|
89
|
+
componentId,
|
|
82
90
|
...props
|
|
83
91
|
}: InputOTPProps,
|
|
84
92
|
ref,
|
|
85
93
|
) => {
|
|
86
94
|
const MAX_LENGTH = 10;
|
|
95
|
+
const {appId} = useContext(MiniAppContext)
|
|
96
|
+
|
|
87
97
|
const [value, setValue] = useState('');
|
|
88
98
|
const [focused, setFocused] = useState(false);
|
|
89
99
|
const inputRef = useRef<TextInput>(null);
|
|
90
100
|
const {theme} = useContext(ApplicationContext);
|
|
101
|
+
const screenInfo = useContext<any>(ScreenContext);
|
|
91
102
|
|
|
92
103
|
useImperativeHandle(ref, () => ({
|
|
93
104
|
onChangeText: (text: string) => {
|
|
@@ -219,15 +230,27 @@ const InputOTP = forwardRef(
|
|
|
219
230
|
</View>
|
|
220
231
|
);
|
|
221
232
|
};
|
|
233
|
+
const accessibilityID = getAccessibilityID(`${appId}|${screenInfo.screenName}|input_${floatingValue}${disabled && "_disabled" }`)
|
|
222
234
|
|
|
223
235
|
return (
|
|
224
|
-
<
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
236
|
+
<ScreenContext.Provider
|
|
237
|
+
value={{
|
|
238
|
+
...screenInfo,
|
|
239
|
+
componentName: 'InputOTP',
|
|
240
|
+
params,
|
|
241
|
+
componentLabel: formatComponentName(floatingValue || ''),
|
|
242
|
+
state: 'enabled',
|
|
243
|
+
componentId,
|
|
244
|
+
}}>
|
|
245
|
+
<TouchableOpacity
|
|
246
|
+
{...accessibilityID}
|
|
247
|
+
activeOpacity={1}
|
|
248
|
+
onPress={onFocusInput}
|
|
249
|
+
style={[style, styles.otpWrapper]}>
|
|
250
|
+
{renderInputView()}
|
|
251
|
+
<ErrorView errorMessage={errorMessage} errorSpacing={errorSpacing} />
|
|
252
|
+
</TouchableOpacity>
|
|
253
|
+
</ScreenContext.Provider>
|
|
231
254
|
);
|
|
232
255
|
},
|
|
233
256
|
);
|
package/Input/InputSearch.tsx
CHANGED
|
@@ -7,11 +7,16 @@ import {
|
|
|
7
7
|
View,
|
|
8
8
|
} from 'react-native';
|
|
9
9
|
import {InputSearchProps} from './index';
|
|
10
|
-
import {ApplicationContext} from '../Application';
|
|
10
|
+
import {ApplicationContext, MiniAppContext} 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";
|
|
16
|
+
|
|
17
|
+
const {
|
|
18
|
+
ScreenContext,
|
|
19
|
+
} = require('react-native/Libraries/Components/ScreenContext');
|
|
15
20
|
|
|
16
21
|
const InputSearch = forwardRef(
|
|
17
22
|
(
|
|
@@ -28,15 +33,19 @@ const InputSearch = forwardRef(
|
|
|
28
33
|
style,
|
|
29
34
|
defaultValue,
|
|
30
35
|
onPressButtonText,
|
|
31
|
-
|
|
36
|
+
hasColorBG = true,
|
|
37
|
+
params,
|
|
38
|
+
componentId,
|
|
32
39
|
...props
|
|
33
40
|
}: InputSearchProps,
|
|
34
41
|
ref,
|
|
35
42
|
) => {
|
|
36
43
|
const {theme} = useContext(ApplicationContext);
|
|
44
|
+
const {appId} = useContext(MiniAppContext)
|
|
37
45
|
const [focused, setFocused] = useState(false);
|
|
38
46
|
const [haveValue, setHaveValue] = useState(!!value || !!defaultValue);
|
|
39
47
|
const inputRef = (ref as React.RefObject<TextInput>) ?? useRef<TextInput>();
|
|
48
|
+
const screenInfo = useContext<any>(ScreenContext);
|
|
40
49
|
|
|
41
50
|
const _onFocus = (e: NativeSyntheticEvent<TextInputFocusEventData>) => {
|
|
42
51
|
setFocused(true);
|
|
@@ -117,33 +126,58 @@ const InputSearch = forwardRef(
|
|
|
117
126
|
);
|
|
118
127
|
};
|
|
119
128
|
|
|
120
|
-
|
|
129
|
+
let inputState = 'empty';
|
|
130
|
+
|
|
131
|
+
if (focused) {
|
|
132
|
+
inputState = 'focus';
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (value && value?.length > 0) {
|
|
136
|
+
inputState = 'filled';
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const backgroundColor = hasColorBG
|
|
140
|
+
? theme.colors.background.default
|
|
141
|
+
: theme.colors.background.surface;
|
|
142
|
+
const accessibilityID = getAccessibilityID(`${appId}|${screenInfo.screenName}|input_search`)
|
|
121
143
|
|
|
122
144
|
return (
|
|
123
|
-
<
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
145
|
+
<ScreenContext.Provider
|
|
146
|
+
{...accessibilityID}
|
|
147
|
+
value={{
|
|
148
|
+
...screenInfo,
|
|
149
|
+
componentName: 'InputSearch',
|
|
150
|
+
params,
|
|
151
|
+
state: inputState,
|
|
152
|
+
componentId,
|
|
153
|
+
}}>
|
|
154
|
+
<View style={[style, styles.searchInputContainer]}>
|
|
155
|
+
<View
|
|
156
|
+
style={[
|
|
157
|
+
styles.searchInputWrapper,
|
|
158
|
+
{
|
|
159
|
+
backgroundColor,
|
|
160
|
+
},
|
|
161
|
+
]}>
|
|
162
|
+
<Icon
|
|
163
|
+
source={'navigation_search'}
|
|
164
|
+
size={24}
|
|
165
|
+
color={theme.colors.text.hint}
|
|
166
|
+
/>
|
|
167
|
+
{renderInputView()}
|
|
168
|
+
{renderIconView()}
|
|
169
|
+
</View>
|
|
170
|
+
{showButtonText && (
|
|
171
|
+
<TouchableOpacity onPress={onPressButtonText}>
|
|
172
|
+
<Text
|
|
173
|
+
typography={'action_default_bold'}
|
|
174
|
+
style={styles.textButton}>
|
|
175
|
+
{buttonText}
|
|
176
|
+
</Text>
|
|
177
|
+
</TouchableOpacity>
|
|
178
|
+
)}
|
|
138
179
|
</View>
|
|
139
|
-
|
|
140
|
-
<TouchableOpacity onPress={onPressButtonText}>
|
|
141
|
-
<Text typography={'action_default_bold'} style={styles.textButton}>
|
|
142
|
-
{buttonText}
|
|
143
|
-
</Text>
|
|
144
|
-
</TouchableOpacity>
|
|
145
|
-
)}
|
|
146
|
-
</View>
|
|
180
|
+
</ScreenContext.Provider>
|
|
147
181
|
);
|
|
148
182
|
},
|
|
149
183
|
);
|
package/Input/InputTextArea.tsx
CHANGED
|
@@ -17,7 +17,12 @@ import {
|
|
|
17
17
|
} from './common';
|
|
18
18
|
import {InputTextAreaProps} from './index';
|
|
19
19
|
import {Icon} from '../Icon';
|
|
20
|
-
import {ApplicationContext} from '../Application';
|
|
20
|
+
import {ApplicationContext, MiniAppContext} from '../Application';
|
|
21
|
+
import {getAccessibilityID} from "../Application/utils";
|
|
22
|
+
|
|
23
|
+
const {
|
|
24
|
+
ScreenContext,
|
|
25
|
+
} = require('react-native/Libraries/Components/ScreenContext');
|
|
21
26
|
|
|
22
27
|
const InputTextArea = forwardRef(
|
|
23
28
|
(
|
|
@@ -43,6 +48,8 @@ const InputTextArea = forwardRef(
|
|
|
43
48
|
ref,
|
|
44
49
|
) => {
|
|
45
50
|
const {theme} = useContext(ApplicationContext);
|
|
51
|
+
const screenInfo = useContext<any>(ScreenContext);
|
|
52
|
+
const {appId} = useContext(MiniAppContext)
|
|
46
53
|
const [focused, setFocused] = useState(false);
|
|
47
54
|
const [inputValue, setInputValue] = useState(defaultValue ?? '');
|
|
48
55
|
const inputRef = (ref as React.RefObject<TextInput>) ?? useRef<TextInput>();
|
|
@@ -146,9 +153,12 @@ const InputTextArea = forwardRef(
|
|
|
146
153
|
</View>
|
|
147
154
|
);
|
|
148
155
|
};
|
|
156
|
+
const accessibilityID = getAccessibilityID(`${appId}|${screenInfo.screenName}|input_${floatingValue}${disabled && "_disabled" }`)
|
|
149
157
|
|
|
150
158
|
return (
|
|
151
|
-
<View
|
|
159
|
+
<View
|
|
160
|
+
{...accessibilityID}
|
|
161
|
+
style={[style, styles.wrapper]}>
|
|
152
162
|
{renderInputView()}
|
|
153
163
|
<ErrorView errorMessage={errorMessage} errorSpacing={errorSpacing} />
|
|
154
164
|
</View>
|