@momo-kits/foundation 0.89.3 → 0.89.4-rc.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/Application/Components.tsx +3 -13
- package/Application/ModalScreen.tsx +4 -16
- package/Application/Navigator.ts +12 -0
- package/Application/StackScreen.tsx +13 -2
- package/Application/types.ts +0 -2
- package/Application/utils.tsx +36 -1
- package/Button/index.tsx +40 -15
- package/CheckBox/index.tsx +44 -21
- package/CheckBox/types.ts +4 -0
- package/IconButton/index.tsx +33 -8
- package/Input/Input.tsx +64 -10
- package/Input/InputDropDown.tsx +28 -9
- package/Input/InputMoney.tsx +38 -8
- package/Input/InputOTP.tsx +28 -10
- package/Input/InputSearch.tsx +55 -30
- package/Input/InputTextArea.tsx +1 -5
- package/Input/index.tsx +11 -0
- package/Input/styles.ts +1 -2
- package/Layout/Card.tsx +0 -1
- package/Layout/Item.tsx +0 -1
- package/Layout/Screen.tsx +1 -3
- package/Layout/Section.tsx +0 -1
- package/Pagination/PaginationScroll.tsx +0 -1
- package/Popup/PopupNotify.tsx +0 -1
- package/Popup/PopupPromotion.tsx +1 -1
- package/Radio/index.tsx +41 -19
- package/Radio/types.ts +5 -0
- package/Skeleton/index.tsx +1 -1
- package/Switch/index.tsx +31 -15
- package/Switch/types.ts +4 -0
- package/Tag/index.tsx +1 -3
- package/Text/index.tsx +0 -1
- package/package.json +1 -1
|
@@ -35,7 +35,6 @@ const NavigationButton: React.FC<NavigationButtonProps> = ({
|
|
|
35
35
|
tintColor,
|
|
36
36
|
onPress,
|
|
37
37
|
useBorder = true,
|
|
38
|
-
accessibilityLabel,
|
|
39
38
|
badgeType,
|
|
40
39
|
badgeValue,
|
|
41
40
|
}) => {
|
|
@@ -67,7 +66,6 @@ const NavigationButton: React.FC<NavigationButtonProps> = ({
|
|
|
67
66
|
return (
|
|
68
67
|
<View style={{width: scaleSize(28)}}>
|
|
69
68
|
<TouchableOpacity
|
|
70
|
-
accessibilityLabel={`NavigationButton/${accessibilityLabel}`}
|
|
71
69
|
style={[styles.navigationButton, buttonStyle]}
|
|
72
70
|
onPress={onPress}>
|
|
73
71
|
<Icon
|
|
@@ -81,7 +79,7 @@ const NavigationButton: React.FC<NavigationButtonProps> = ({
|
|
|
81
79
|
);
|
|
82
80
|
};
|
|
83
81
|
|
|
84
|
-
const HeaderTitle: React.FC<any> =
|
|
82
|
+
const HeaderTitle: React.FC<any> = props => {
|
|
85
83
|
const {theme} = useContext(ApplicationContext);
|
|
86
84
|
const opacity = props.animatedValue?.interpolate({
|
|
87
85
|
inputRange: [0, 200],
|
|
@@ -92,7 +90,6 @@ const HeaderTitle: React.FC<any> = ({accessibilityLabel = '', ...props}) => {
|
|
|
92
90
|
return (
|
|
93
91
|
<Animated.Text
|
|
94
92
|
{...props}
|
|
95
|
-
accessibilityLabel={`HeaderTitle/${accessibilityLabel}${props.children}`}
|
|
96
93
|
style={[
|
|
97
94
|
styles.title,
|
|
98
95
|
{fontFamily: `${theme.font}-Bold`, opacity, color: props.tintColor},
|
|
@@ -106,7 +103,6 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
|
|
|
106
103
|
preventBack,
|
|
107
104
|
onPressLeftHeader,
|
|
108
105
|
useBorder,
|
|
109
|
-
accessibilityLabel = '',
|
|
110
106
|
}) => {
|
|
111
107
|
const context = useContext(MiniAppContext);
|
|
112
108
|
const {navigator} = useContext(ApplicationContext);
|
|
@@ -171,7 +167,6 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
|
|
|
171
167
|
icon="ic_back"
|
|
172
168
|
tintColor={tintColor}
|
|
173
169
|
onPress={goBackSafe}
|
|
174
|
-
accessibilityLabel={`${accessibilityLabel}Back`}
|
|
175
170
|
useBorder={useBorder}
|
|
176
171
|
/>
|
|
177
172
|
</View>
|
|
@@ -368,7 +363,6 @@ const HeaderToolkitAction: React.FC<any> = ({
|
|
|
368
363
|
if (pinTool)
|
|
369
364
|
return (
|
|
370
365
|
<NavigationButton
|
|
371
|
-
accessibilityLabel={'UtilityTool'}
|
|
372
366
|
icon={pinTool.icon as string}
|
|
373
367
|
tintColor={tintColor}
|
|
374
368
|
badgeValue={badgeValue}
|
|
@@ -399,15 +393,11 @@ const HeaderToolkitAction: React.FC<any> = ({
|
|
|
399
393
|
borderWidth: backgroundColor ? 0.5 : 0,
|
|
400
394
|
},
|
|
401
395
|
]}>
|
|
402
|
-
<TouchableOpacity
|
|
403
|
-
accessibilityLabel={'Toolkit/More'}
|
|
404
|
-
onPress={onMore}>
|
|
396
|
+
<TouchableOpacity onPress={onMore}>
|
|
405
397
|
<Icon color={tintColor} source="navigation_more_horiz" size={20} />
|
|
406
398
|
</TouchableOpacity>
|
|
407
399
|
<View style={[styles.divider, {backgroundColor: tintColor}]} />
|
|
408
|
-
<TouchableOpacity
|
|
409
|
-
accessibilityLabel={`Toolkit/Close`}
|
|
410
|
-
onPress={onClose}>
|
|
400
|
+
<TouchableOpacity onPress={onClose}>
|
|
411
401
|
<Icon
|
|
412
402
|
color={tintColor}
|
|
413
403
|
source="16_navigation_close_circle"
|
|
@@ -74,7 +74,7 @@ const Modal: React.FC<ModalParams> = props => {
|
|
|
74
74
|
style={styles.modalSpaceVertical}
|
|
75
75
|
onPress={() => onDismiss()}
|
|
76
76
|
/>
|
|
77
|
-
<View style={styles.modalContent}
|
|
77
|
+
<View style={styles.modalContent}>
|
|
78
78
|
<Component {...params} />
|
|
79
79
|
</View>
|
|
80
80
|
<Pressable
|
|
@@ -167,7 +167,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
167
167
|
bottomInset={Platform.OS === 'ios' ? bottomInset : 0}
|
|
168
168
|
handleComponent={null}
|
|
169
169
|
backdropComponent={backdropComponent}>
|
|
170
|
-
<BottomSheetView
|
|
170
|
+
<BottomSheetView>
|
|
171
171
|
<View style={[styles.sheetContainer, {backgroundColor}]}>
|
|
172
172
|
<View style={styles.indicatorContainer}>
|
|
173
173
|
<View
|
|
@@ -189,22 +189,11 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
189
189
|
...{
|
|
190
190
|
headerLeft: (props: any) => {
|
|
191
191
|
if (props.canGoBack) {
|
|
192
|
-
return
|
|
193
|
-
<HeaderLeft
|
|
194
|
-
{...props}
|
|
195
|
-
useBorder={false}
|
|
196
|
-
accessibilityLabel={'BottomSheet/'}
|
|
197
|
-
/>
|
|
198
|
-
);
|
|
192
|
+
return <HeaderLeft {...props} useBorder={false} />;
|
|
199
193
|
}
|
|
200
194
|
},
|
|
201
195
|
headerTitle: (props: any) => {
|
|
202
|
-
return
|
|
203
|
-
<HeaderTitle
|
|
204
|
-
{...props}
|
|
205
|
-
accessibilityLabel={'BottomSheet/'}
|
|
206
|
-
/>
|
|
207
|
-
);
|
|
196
|
+
return <HeaderTitle {...props} />;
|
|
208
197
|
},
|
|
209
198
|
headerTintColor: theme.colors.text.default,
|
|
210
199
|
headerBackground: () => (
|
|
@@ -220,7 +209,6 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
220
209
|
icon="24_navigation_close"
|
|
221
210
|
useBorder={false}
|
|
222
211
|
onPress={() => bottomSheetRef.current?.dismiss()}
|
|
223
|
-
accessibilityLabel={'BottomSheet/Close'}
|
|
224
212
|
/>
|
|
225
213
|
</HeaderRightAction>
|
|
226
214
|
),
|
package/Application/Navigator.ts
CHANGED
|
@@ -109,6 +109,18 @@ class Navigator {
|
|
|
109
109
|
);
|
|
110
110
|
};
|
|
111
111
|
|
|
112
|
+
/**
|
|
113
|
+
* dismiss a feature data
|
|
114
|
+
* @param data
|
|
115
|
+
*/
|
|
116
|
+
setDismissData = (data: any) => {
|
|
117
|
+
this.dismissData = data;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* set callback function for toolkit
|
|
122
|
+
* @param callback
|
|
123
|
+
*/
|
|
112
124
|
setToolkitCallback = (
|
|
113
125
|
callback: (item: {key: string; action: string}) => void,
|
|
114
126
|
) => {
|
|
@@ -5,6 +5,10 @@ import {ApplicationContext, MiniAppContext} from './index';
|
|
|
5
5
|
import {GridSystem} from '../Layout';
|
|
6
6
|
import {useHeaderHeight} from '@react-navigation/stack';
|
|
7
7
|
|
|
8
|
+
const {
|
|
9
|
+
ScreenContext,
|
|
10
|
+
} = require('react-native/Libraries/Components/ScreenContext');
|
|
11
|
+
|
|
8
12
|
const StackScreen: React.FC<ScreenParams> = props => {
|
|
9
13
|
const {theme, showGrid, navigator} = useContext(ApplicationContext);
|
|
10
14
|
const context = useContext(MiniAppContext);
|
|
@@ -61,10 +65,17 @@ const StackScreen: React.FC<ScreenParams> = props => {
|
|
|
61
65
|
}, []);
|
|
62
66
|
|
|
63
67
|
return (
|
|
64
|
-
|
|
68
|
+
<ScreenContext.Provider
|
|
69
|
+
value={{
|
|
70
|
+
...context,
|
|
71
|
+
screenName: Component.name,
|
|
72
|
+
autoTracking: (data: any) => {
|
|
73
|
+
navigator?.maxApi?.dispatchFunction?.('autoTracking', data);
|
|
74
|
+
},
|
|
75
|
+
}}>
|
|
65
76
|
<Component heightHeader={heightHeader} {...params} />
|
|
66
77
|
{showGrid && <GridSystem />}
|
|
67
|
-
|
|
78
|
+
</ScreenContext.Provider>
|
|
68
79
|
);
|
|
69
80
|
};
|
|
70
81
|
|
package/Application/types.ts
CHANGED
|
@@ -127,7 +127,6 @@ export type NavigationButtonProps = {
|
|
|
127
127
|
tintColor?: string;
|
|
128
128
|
useBorder?: boolean;
|
|
129
129
|
onPress: () => void;
|
|
130
|
-
accessibilityLabel?: string;
|
|
131
130
|
badgeType?: 'dot' | 'number';
|
|
132
131
|
badgeValue?: number;
|
|
133
132
|
};
|
|
@@ -159,7 +158,6 @@ export interface NavigationOptions extends StackNavigationOptions {
|
|
|
159
158
|
export interface HeaderBackProps extends NavigationButtonProps {
|
|
160
159
|
preventBack?: PopupNotifyProps;
|
|
161
160
|
onPressLeftHeader?: () => void;
|
|
162
|
-
accessibilityLabel?: string;
|
|
163
161
|
}
|
|
164
162
|
|
|
165
163
|
export type HeaderBackgroundProps = {
|
package/Application/utils.tsx
CHANGED
|
@@ -148,4 +148,39 @@ const getOptions = (params: NavigationOptions, theme: Theme) => {
|
|
|
148
148
|
};
|
|
149
149
|
};
|
|
150
150
|
|
|
151
|
-
|
|
151
|
+
const formatComponentName= (word: string) =>{
|
|
152
|
+
const accentsMap = {
|
|
153
|
+
'a': 'á|à|ả|ã|ạ|â|ấ|ầ|ẩ|ẫ|ậ|ă|ắ|ằ|ẳ|ẵ|ặ',
|
|
154
|
+
'A': 'Á|À|Ả|Ã|Ạ|Â|Ấ|Ầ|Ẩ|Ẫ|Ậ|Ă|Ắ|Ằ|Ẳ|Ẵ|Ặ',
|
|
155
|
+
'e': 'é|è|ẻ|ẽ|ẹ|ê|ế|ề|ể|ễ|ệ',
|
|
156
|
+
'E': 'É|È|Ẻ|Ẽ|Ẹ|Ê|Ế|Ề|Ể|Ễ|Ệ',
|
|
157
|
+
'i': 'í|ì|ỉ|ĩ|ị',
|
|
158
|
+
'I': 'Í|Ì|Ỉ|Ĩ|Ị',
|
|
159
|
+
'o': 'ó|ò|ỏ|õ|ọ|ô|ố|ồ|ổ|ỗ|ộ|ơ|ớ|ờ|ở|ỡ|ợ',
|
|
160
|
+
'O': 'Ó|Ò|Ỏ|Õ|Ọ|Ô|Ố|Ồ|Ổ|Ỗ|Ộ|Ơ|Ớ|Ờ|Ở|Ỡ|Ợ',
|
|
161
|
+
'u': 'ú|ù|ủ|ũ|ụ|ư|ứ|ừ|ử|ữ|ự',
|
|
162
|
+
'U': 'Ú|Ù|Ủ|Ũ|Ụ|Ư|Ứ|Ừ|Ử|Ữ|Ự',
|
|
163
|
+
'y': 'ý|ỳ|ỷ|ỹ|ỵ',
|
|
164
|
+
'Y': 'Ý|Ỳ|Ỷ|Ỹ|Ỵ',
|
|
165
|
+
'd': 'đ',
|
|
166
|
+
'D': 'Đ'
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
for (const [nonAccent, accentGroup] of Object.entries(accentsMap)) {
|
|
170
|
+
const accents = new RegExp(accentGroup, 'g');
|
|
171
|
+
word = word.replace(accents, nonAccent);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
word = word.replace(/\s+/g, '_').toLowerCase();
|
|
175
|
+
|
|
176
|
+
return word;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const formatNameLength = (name: string) =>{
|
|
180
|
+
let formattedName = name
|
|
181
|
+
if (formattedName.length > 100) {
|
|
182
|
+
formattedName = formattedName.substring(0, 100);
|
|
183
|
+
}
|
|
184
|
+
return formattedName
|
|
185
|
+
}
|
|
186
|
+
export {getStackOptions, getDialogOptions, getModalOptions, getOptions, formatComponentName, formatNameLength};
|
package/Button/index.tsx
CHANGED
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
TouchableOpacityProps,
|
|
7
7
|
View,
|
|
8
8
|
} from 'react-native';
|
|
9
|
-
|
|
10
9
|
import LinearGradient from 'react-native-linear-gradient';
|
|
11
10
|
import {ApplicationContext} from '../Application';
|
|
12
11
|
import {Text} from '../Text';
|
|
@@ -15,6 +14,11 @@ import {Colors, Spacing} from '../Consts';
|
|
|
15
14
|
import styles from './styles';
|
|
16
15
|
import {Icon} from '../Icon';
|
|
17
16
|
import {Loader} from '../Loader';
|
|
17
|
+
import {formatComponentName} from "../Application/utils";
|
|
18
|
+
|
|
19
|
+
const {
|
|
20
|
+
ScreenContext,
|
|
21
|
+
} = require('react-native/Libraries/Components/ScreenContext');
|
|
18
22
|
|
|
19
23
|
const AnimationLinear = Animated.createAnimatedComponent(LinearGradient);
|
|
20
24
|
|
|
@@ -70,6 +74,10 @@ export interface ButtonProps extends TouchableOpacityProps {
|
|
|
70
74
|
* A callback function that is called when the button is pressed.
|
|
71
75
|
*/
|
|
72
76
|
onPress: () => void;
|
|
77
|
+
|
|
78
|
+
params?: any;
|
|
79
|
+
|
|
80
|
+
componentId?: string;
|
|
73
81
|
}
|
|
74
82
|
|
|
75
83
|
const Button: FC<ButtonProps> = ({
|
|
@@ -82,6 +90,8 @@ const Button: FC<ButtonProps> = ({
|
|
|
82
90
|
loading = false,
|
|
83
91
|
title = 'Button',
|
|
84
92
|
onPress,
|
|
93
|
+
params,
|
|
94
|
+
componentId,
|
|
85
95
|
...rest
|
|
86
96
|
}) => {
|
|
87
97
|
const {theme, config} = useContext(ApplicationContext);
|
|
@@ -94,6 +104,8 @@ const Button: FC<ButtonProps> = ({
|
|
|
94
104
|
end: {x: 0, y: 0.5},
|
|
95
105
|
};
|
|
96
106
|
}
|
|
107
|
+
|
|
108
|
+
const screenInfo = useContext<any>(ScreenContext);
|
|
97
109
|
const getSizeStyle = () => {
|
|
98
110
|
const styleSheet: {[key: string]: any} = styles;
|
|
99
111
|
return styleSheet[size ?? 'small'];
|
|
@@ -289,22 +301,35 @@ const Button: FC<ButtonProps> = ({
|
|
|
289
301
|
};
|
|
290
302
|
|
|
291
303
|
const activeOpacity = type === 'disabled' ? 0.75 : 0.5;
|
|
304
|
+
const button_name = formatComponentName(title)
|
|
292
305
|
|
|
293
306
|
return (
|
|
294
|
-
<
|
|
295
|
-
{
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
307
|
+
<ScreenContext.Provider
|
|
308
|
+
value={{
|
|
309
|
+
...screenInfo,
|
|
310
|
+
componentName: 'Button',
|
|
311
|
+
params: {
|
|
312
|
+
...params,
|
|
313
|
+
button_name
|
|
314
|
+
},
|
|
315
|
+
state: loading ? "loading" : type === 'disabled' ? 'disabled' : 'enabled',
|
|
316
|
+
componentId,
|
|
317
|
+
action: 'click',
|
|
318
|
+
}}>
|
|
319
|
+
<TouchableOpacity
|
|
320
|
+
{...rest}
|
|
321
|
+
activeOpacity={activeOpacity}
|
|
322
|
+
onPress={onPressButton}
|
|
323
|
+
style={buttonStyle}>
|
|
324
|
+
{renderLeading()}
|
|
325
|
+
{renderTitle()}
|
|
326
|
+
{renderTrailing()}
|
|
327
|
+
{gradientPros && (
|
|
328
|
+
<AnimationLinear {...gradientPros} style={styles.gradientView} />
|
|
329
|
+
)}
|
|
330
|
+
{gradientPros && <View style={styles.strokeView} />}
|
|
331
|
+
</TouchableOpacity>
|
|
332
|
+
</ScreenContext.Provider>
|
|
308
333
|
);
|
|
309
334
|
};
|
|
310
335
|
|
package/CheckBox/index.tsx
CHANGED
|
@@ -5,6 +5,11 @@ import styles from './styles';
|
|
|
5
5
|
import {ApplicationContext} from '../Application';
|
|
6
6
|
import {Text} from '../Text';
|
|
7
7
|
import {Icon} from '../Icon';
|
|
8
|
+
import {formatNameLength} 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,11 @@ const CheckBox: FC<CheckBoxProps> = ({
|
|
|
13
18
|
style,
|
|
14
19
|
label,
|
|
15
20
|
indeterminate,
|
|
21
|
+
params,
|
|
22
|
+
componentId,
|
|
16
23
|
}) => {
|
|
17
24
|
const {theme} = useContext(ApplicationContext);
|
|
25
|
+
const screenInfo = useContext<any>(ScreenContext);
|
|
18
26
|
const haveValue = value || indeterminate;
|
|
19
27
|
const iconSource = indeterminate ? 'ic_minus' : 'ic_checked';
|
|
20
28
|
let borderColor = theme.colors.text.default;
|
|
@@ -34,28 +42,43 @@ const CheckBox: FC<CheckBoxProps> = ({
|
|
|
34
42
|
}
|
|
35
43
|
}
|
|
36
44
|
|
|
45
|
+
const component_name = formatNameLength(label || '');
|
|
46
|
+
|
|
37
47
|
return (
|
|
38
|
-
<
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
48
|
+
<ScreenContext.Provider
|
|
49
|
+
value={{
|
|
50
|
+
...screenInfo,
|
|
51
|
+
componentName: 'Button',
|
|
52
|
+
params: {
|
|
53
|
+
...params,
|
|
54
|
+
component_name,
|
|
55
|
+
},
|
|
56
|
+
state: disabled ? 'disabled' : 'filled',
|
|
57
|
+
componentId,
|
|
58
|
+
componentValue: indeterminate ? 'indetermine' : value,
|
|
59
|
+
action: 'click',
|
|
60
|
+
}}>
|
|
61
|
+
<TouchableOpacity
|
|
62
|
+
activeOpacity={0.8}
|
|
63
|
+
onPress={() => onChange?.(!value)}
|
|
64
|
+
disabled={disabled}
|
|
65
|
+
style={[style, styles.container]}>
|
|
66
|
+
<View
|
|
67
|
+
style={[
|
|
68
|
+
{borderColor, backgroundColor, borderWidth: 1},
|
|
69
|
+
styles.checkbox,
|
|
70
|
+
]}>
|
|
71
|
+
{haveValue && (
|
|
72
|
+
<Icon
|
|
73
|
+
color={theme.colors.background.surface}
|
|
74
|
+
size={20}
|
|
75
|
+
source={iconSource}
|
|
76
|
+
/>
|
|
77
|
+
)}
|
|
78
|
+
</View>
|
|
79
|
+
{!!label && <Text typography={'body_default_regular'}>{label}</Text>}
|
|
80
|
+
</TouchableOpacity>
|
|
81
|
+
</ScreenContext.Provider>
|
|
59
82
|
);
|
|
60
83
|
};
|
|
61
84
|
|
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
|
|
@@ -119,16 +131,29 @@ const IconButton: React.FC<IconButtonProps> = ({
|
|
|
119
131
|
const activeOpacity = type === 'disabled' ? 0.75 : 0.5;
|
|
120
132
|
const buttonStyle = StyleSheet.flatten([getTypeStyle(), getSizeStyle()]);
|
|
121
133
|
const iconSize = size === 'small' ? 16 : 24;
|
|
134
|
+
const icon_name = formatComponentName(icon)
|
|
122
135
|
|
|
123
136
|
return (
|
|
124
|
-
<
|
|
125
|
-
{
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
137
|
+
<ScreenContext.Provider
|
|
138
|
+
value={{
|
|
139
|
+
...screenInfo,
|
|
140
|
+
componentName: 'IconButton',
|
|
141
|
+
params: {
|
|
142
|
+
...params,
|
|
143
|
+
icon_name
|
|
144
|
+
},
|
|
145
|
+
state: type === 'disabled' ? 'disabled' : 'enabled',
|
|
146
|
+
componentId,
|
|
147
|
+
action: 'click',
|
|
148
|
+
}}>
|
|
149
|
+
<TouchableOpacity
|
|
150
|
+
{...rest}
|
|
151
|
+
activeOpacity={activeOpacity}
|
|
152
|
+
onPress={onPressButton}
|
|
153
|
+
style={buttonStyle}>
|
|
154
|
+
<Icon size={iconSize} source={icon} color={getIconColor()} />
|
|
155
|
+
</TouchableOpacity>
|
|
156
|
+
</ScreenContext.Provider>
|
|
132
157
|
);
|
|
133
158
|
};
|
|
134
159
|
|
package/Input/Input.tsx
CHANGED
|
@@ -13,6 +13,11 @@ 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} from '../Application/utils';
|
|
17
|
+
|
|
18
|
+
const {
|
|
19
|
+
ScreenContext,
|
|
20
|
+
} = require('react-native/Libraries/Components/ScreenContext');
|
|
16
21
|
|
|
17
22
|
const Input = forwardRef(
|
|
18
23
|
(
|
|
@@ -37,7 +42,10 @@ const Input = forwardRef(
|
|
|
37
42
|
leadingIconColor,
|
|
38
43
|
fontWeight = 'Regular',
|
|
39
44
|
onPressIcon,
|
|
45
|
+
secureTextEntry,
|
|
40
46
|
style,
|
|
47
|
+
params,
|
|
48
|
+
componentId,
|
|
41
49
|
...props
|
|
42
50
|
}: InputProps,
|
|
43
51
|
ref,
|
|
@@ -45,8 +53,9 @@ const Input = forwardRef(
|
|
|
45
53
|
const {theme} = useContext(ApplicationContext);
|
|
46
54
|
const [focused, setFocused] = useState(false);
|
|
47
55
|
const [haveValue, setHaveValue] = useState(!!value || !!props.defaultValue);
|
|
56
|
+
const [secureTextInput, setSecureTextInput] = useState(secureTextEntry);
|
|
48
57
|
const inputRef = (ref as React.RefObject<TextInput>) ?? useRef<TextInput>();
|
|
49
|
-
const
|
|
58
|
+
const screenInfo = useContext<any>(ScreenContext);
|
|
50
59
|
|
|
51
60
|
const onClearText = () => {
|
|
52
61
|
inputRef?.current?.clear();
|
|
@@ -70,11 +79,29 @@ const Input = forwardRef(
|
|
|
70
79
|
|
|
71
80
|
const renderIcon = (color: string | undefined) => {
|
|
72
81
|
if (loading) {
|
|
73
|
-
return <Loader type={'spinner'} color={color} />;
|
|
82
|
+
return <Loader type={'spinner'} color={color} style={styles.icon} />;
|
|
83
|
+
}
|
|
84
|
+
if (secureTextEntry) {
|
|
85
|
+
return (
|
|
86
|
+
<TouchableOpacity
|
|
87
|
+
onPress={() => setSecureTextInput(!secureTextInput)}
|
|
88
|
+
style={styles.icon}>
|
|
89
|
+
<Icon
|
|
90
|
+
color={color}
|
|
91
|
+
size={24}
|
|
92
|
+
source={
|
|
93
|
+
secureTextInput ? '24_security_eye_off' : '24_security_eye_open'
|
|
94
|
+
}
|
|
95
|
+
/>
|
|
96
|
+
</TouchableOpacity>
|
|
97
|
+
);
|
|
74
98
|
}
|
|
75
99
|
if (icon) {
|
|
76
100
|
return (
|
|
77
|
-
<TouchableOpacity
|
|
101
|
+
<TouchableOpacity
|
|
102
|
+
onPress={onPressIcon}
|
|
103
|
+
disabled={!onPressIcon}
|
|
104
|
+
style={styles.icon}>
|
|
78
105
|
<Icon color={color} source={icon} size={24} />
|
|
79
106
|
</TouchableOpacity>
|
|
80
107
|
);
|
|
@@ -83,6 +110,7 @@ const Input = forwardRef(
|
|
|
83
110
|
|
|
84
111
|
const renderInputView = () => {
|
|
85
112
|
const disabledColor = theme.colors.text.disable;
|
|
113
|
+
const secure = secureTextInput && secureTextEntry;
|
|
86
114
|
let textColor = theme.colors.text.default;
|
|
87
115
|
let placeholderColor = theme.colors.text.hint;
|
|
88
116
|
let iconTintColor = iconColor;
|
|
@@ -120,8 +148,8 @@ const Input = forwardRef(
|
|
|
120
148
|
)}
|
|
121
149
|
<TextInput
|
|
122
150
|
{...props}
|
|
123
|
-
accessibilityLabel={accessibilityLabel}
|
|
124
151
|
editable={!disabled}
|
|
152
|
+
secureTextEntry={secure}
|
|
125
153
|
textAlignVertical="center"
|
|
126
154
|
ref={inputRef}
|
|
127
155
|
style={[
|
|
@@ -130,6 +158,7 @@ const Input = forwardRef(
|
|
|
130
158
|
color: textColor,
|
|
131
159
|
fontFamily: `${theme.font}-${fontWeight}`,
|
|
132
160
|
},
|
|
161
|
+
secure && haveValue && {fontSize: size === 'small' ? 18 : 22},
|
|
133
162
|
]}
|
|
134
163
|
textBreakStrategy="highQuality"
|
|
135
164
|
value={value}
|
|
@@ -159,13 +188,38 @@ const Input = forwardRef(
|
|
|
159
188
|
);
|
|
160
189
|
};
|
|
161
190
|
|
|
191
|
+
let inputState = 'active';
|
|
192
|
+
|
|
193
|
+
if (value && value?.length > 0) {
|
|
194
|
+
inputState = 'filled';
|
|
195
|
+
}
|
|
196
|
+
if (errorMessage && errorMessage?.length > 0) {
|
|
197
|
+
inputState = 'error';
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
if (disabled) {
|
|
201
|
+
inputState = 'disabled';
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const component_name = formatComponentName(floatingValue || '');
|
|
205
|
+
|
|
162
206
|
return (
|
|
163
|
-
<
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
207
|
+
<ScreenContext.Provider
|
|
208
|
+
value={{
|
|
209
|
+
...screenInfo,
|
|
210
|
+
componentName: 'Input',
|
|
211
|
+
params: {
|
|
212
|
+
...params,
|
|
213
|
+
component_name,
|
|
214
|
+
},
|
|
215
|
+
state: inputState,
|
|
216
|
+
componentId,
|
|
217
|
+
}}>
|
|
218
|
+
<View style={[style, styles.wrapper]}>
|
|
219
|
+
{renderInputView()}
|
|
220
|
+
<ErrorView errorMessage={errorMessage} errorSpacing={errorSpacing} />
|
|
221
|
+
</View>
|
|
222
|
+
</ScreenContext.Provider>
|
|
169
223
|
);
|
|
170
224
|
},
|
|
171
225
|
);
|