@momo-kits/foundation 0.89.4-tracking.18 → 0.89.5-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/Components.tsx +2 -8
- package/Application/NavigationContainer.tsx +2 -6
- package/Application/Navigator.ts +31 -51
- package/Application/StackScreen.tsx +5 -63
- package/Application/utils.tsx +1 -36
- package/Button/index.tsx +14 -42
- package/CheckBox/index.tsx +20 -40
- package/CheckBox/types.ts +0 -4
- package/IconButton/index.tsx +7 -30
- package/Input/Input.tsx +4 -35
- package/Input/InputDropDown.tsx +4 -24
- package/Input/InputMoney.tsx +4 -35
- package/Input/InputOTP.tsx +7 -25
- package/Input/InputSearch.tsx +25 -55
- package/Input/index.tsx +2 -27
- package/Radio/index.tsx +19 -39
- package/Radio/types.ts +0 -5
- package/Switch/index.tsx +14 -31
- package/Switch/types.ts +0 -4
- package/code-scanner.js +126 -39
- package/package.json +2 -2
|
@@ -120,19 +120,13 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
|
|
|
120
120
|
const goBack = () => {
|
|
121
121
|
const canGoBack = navigator?.ref.current?.canGoBack();
|
|
122
122
|
if (!canGoBack) {
|
|
123
|
-
const currentRoute = navigator?.ref?.current
|
|
124
|
-
|
|
123
|
+
const currentRoute = navigator?.ref?.current.getCurrentRoute();
|
|
124
|
+
navigator?.maxApi?.trackEvent?.('service_icon_clicked', {
|
|
125
125
|
...context,
|
|
126
126
|
screen_name: currentRoute?.params?.screen?.name ?? currentRoute?.name,
|
|
127
127
|
trigger_id: '111154000000000000',
|
|
128
128
|
icon_name: 'back',
|
|
129
|
-
};
|
|
130
|
-
navigator?.maxApi?.showToastDebug?.({
|
|
131
|
-
appId: context.appId,
|
|
132
|
-
message: 'service_icon_clicked',
|
|
133
|
-
params,
|
|
134
129
|
});
|
|
135
|
-
navigator?.maxApi?.trackEvent?.('service_icon_clicked', params);
|
|
136
130
|
}
|
|
137
131
|
if (canGoBack) {
|
|
138
132
|
navigator?.ref.current?.goBack();
|
|
@@ -25,9 +25,8 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
|
|
|
25
25
|
localization,
|
|
26
26
|
}) => {
|
|
27
27
|
const context = useContext(MiniAppContext);
|
|
28
|
-
const navigationRef = useRef<NavigationContainerRef>(null);
|
|
29
|
-
const
|
|
30
|
-
const navigator = useRef(new Navigator(navigationRef, isReady));
|
|
28
|
+
const navigationRef = React.useRef<NavigationContainerRef>(null);
|
|
29
|
+
const navigator = useRef(new Navigator(navigationRef));
|
|
31
30
|
const [showGrid, setShowGrid] = useState(false);
|
|
32
31
|
const config = useRef<any>();
|
|
33
32
|
|
|
@@ -90,9 +89,6 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
|
|
|
90
89
|
},
|
|
91
90
|
}}
|
|
92
91
|
ref={navigator.current?.ref}
|
|
93
|
-
onReady={() => {
|
|
94
|
-
isReady.current = true;
|
|
95
|
-
}}
|
|
96
92
|
independent={true}>
|
|
97
93
|
<Stack.Navigator initialRouteName="Stack" headerMode="screen">
|
|
98
94
|
<Stack.Screen
|
package/Application/Navigator.ts
CHANGED
|
@@ -8,15 +8,13 @@ import {
|
|
|
8
8
|
|
|
9
9
|
class Navigator {
|
|
10
10
|
ref?: any;
|
|
11
|
-
isReady?: any;
|
|
12
11
|
toolkitConfig?: HeaderToolkitProps;
|
|
13
12
|
maxApi?: any;
|
|
14
13
|
dismissData?: any;
|
|
15
14
|
toolkitCallback?: (item: any) => void;
|
|
16
15
|
|
|
17
|
-
constructor(navigation: any
|
|
16
|
+
constructor(navigation: any) {
|
|
18
17
|
this.ref = navigation;
|
|
19
|
-
this.isReady = isReady;
|
|
20
18
|
}
|
|
21
19
|
|
|
22
20
|
/**
|
|
@@ -24,9 +22,7 @@ class Navigator {
|
|
|
24
22
|
* @param params
|
|
25
23
|
*/
|
|
26
24
|
push = (params: ScreenParams) => {
|
|
27
|
-
|
|
28
|
-
this.ref.current.dispatch(StackActions.push('Stack', params));
|
|
29
|
-
}
|
|
25
|
+
this.ref.current.dispatch(StackActions.push('Stack', params));
|
|
30
26
|
};
|
|
31
27
|
|
|
32
28
|
/**
|
|
@@ -34,18 +30,14 @@ class Navigator {
|
|
|
34
30
|
* @param params
|
|
35
31
|
*/
|
|
36
32
|
replace = (params: ScreenParams) => {
|
|
37
|
-
|
|
38
|
-
this.ref.current.dispatch(StackActions.replace('Stack', params));
|
|
39
|
-
}
|
|
33
|
+
this.ref.current.dispatch(StackActions.replace('Stack', params));
|
|
40
34
|
};
|
|
41
35
|
/**
|
|
42
36
|
* pop to dismiss a screen
|
|
43
37
|
* @param count
|
|
44
38
|
*/
|
|
45
39
|
pop = (count?: number) => {
|
|
46
|
-
|
|
47
|
-
this.ref.current.dispatch(StackActions.pop(count ?? 1));
|
|
48
|
-
}
|
|
40
|
+
this.ref.current.dispatch(StackActions.pop(count ?? 1));
|
|
49
41
|
};
|
|
50
42
|
|
|
51
43
|
/**
|
|
@@ -53,9 +45,7 @@ class Navigator {
|
|
|
53
45
|
* @param params
|
|
54
46
|
*/
|
|
55
47
|
present = (params: ScreenParams) => {
|
|
56
|
-
|
|
57
|
-
this.ref.current.dispatch(StackActions.push('Dialog', params));
|
|
58
|
-
}
|
|
48
|
+
this.ref.current.dispatch(StackActions.push('Dialog', params));
|
|
59
49
|
};
|
|
60
50
|
|
|
61
51
|
/**
|
|
@@ -63,9 +53,7 @@ class Navigator {
|
|
|
63
53
|
* @param params
|
|
64
54
|
*/
|
|
65
55
|
showModal = (params: ModalParams) => {
|
|
66
|
-
|
|
67
|
-
this.ref.current.dispatch(StackActions.push('Modal', params));
|
|
68
|
-
}
|
|
56
|
+
this.ref.current.dispatch(StackActions.push('Modal', params));
|
|
69
57
|
};
|
|
70
58
|
|
|
71
59
|
/**
|
|
@@ -73,23 +61,19 @@ class Navigator {
|
|
|
73
61
|
* @param params
|
|
74
62
|
*/
|
|
75
63
|
showBottomSheet = (params: BottomSheetParams) => {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
);
|
|
83
|
-
}
|
|
64
|
+
this.ref.current.dispatch(
|
|
65
|
+
StackActions.push('Modal', {
|
|
66
|
+
...params,
|
|
67
|
+
isBottomSheet: true,
|
|
68
|
+
}),
|
|
69
|
+
);
|
|
84
70
|
};
|
|
85
71
|
|
|
86
72
|
/**
|
|
87
73
|
* pop all screen route
|
|
88
74
|
*/
|
|
89
75
|
popToTop = () => {
|
|
90
|
-
|
|
91
|
-
this.ref.current.dispatch(StackActions.popToTop());
|
|
92
|
-
}
|
|
76
|
+
this.ref.current.dispatch(StackActions.popToTop());
|
|
93
77
|
};
|
|
94
78
|
|
|
95
79
|
/**
|
|
@@ -98,14 +82,12 @@ class Navigator {
|
|
|
98
82
|
* @param params
|
|
99
83
|
*/
|
|
100
84
|
navigate = (name: string, params: any) => {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
);
|
|
108
|
-
}
|
|
85
|
+
this.ref.current.dispatch(
|
|
86
|
+
CommonActions.navigate({
|
|
87
|
+
name,
|
|
88
|
+
params,
|
|
89
|
+
}),
|
|
90
|
+
);
|
|
109
91
|
};
|
|
110
92
|
|
|
111
93
|
/**
|
|
@@ -113,20 +95,18 @@ class Navigator {
|
|
|
113
95
|
* @param params
|
|
114
96
|
*/
|
|
115
97
|
reset = (params: ScreenParams) => {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
);
|
|
129
|
-
}
|
|
98
|
+
this.ref.current.dispatch(
|
|
99
|
+
CommonActions.reset({
|
|
100
|
+
index: 0,
|
|
101
|
+
routes: [
|
|
102
|
+
{
|
|
103
|
+
name: 'Stack',
|
|
104
|
+
key: `Stack_${new Date().getTime()}`,
|
|
105
|
+
params,
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
}),
|
|
109
|
+
);
|
|
130
110
|
};
|
|
131
111
|
|
|
132
112
|
/**
|
|
@@ -1,22 +1,12 @@
|
|
|
1
|
-
import React, {useContext, useEffect, useLayoutEffect
|
|
1
|
+
import React, {useContext, useEffect, useLayoutEffect} from 'react';
|
|
2
2
|
import {ScreenParams} from './types';
|
|
3
3
|
import Navigation from './Navigation';
|
|
4
4
|
import {ApplicationContext, MiniAppContext} from './index';
|
|
5
5
|
import {GridSystem} from '../Layout';
|
|
6
6
|
import {useHeaderHeight} from '@react-navigation/stack';
|
|
7
|
-
import {Alert, InteractionManager} from 'react-native';
|
|
8
|
-
|
|
9
|
-
const {
|
|
10
|
-
ScreenContext,
|
|
11
|
-
} = require('react-native/Libraries/Components/ScreenContext');
|
|
12
7
|
|
|
13
8
|
const StackScreen: React.FC<ScreenParams> = props => {
|
|
14
9
|
const {theme, showGrid, navigator} = useContext(ApplicationContext);
|
|
15
|
-
const startTime = useRef(Date.now());
|
|
16
|
-
const endTime = useRef(Date.now());
|
|
17
|
-
const timeLoad = useRef(0);
|
|
18
|
-
const timeout = useRef<any>();
|
|
19
|
-
|
|
20
10
|
const context = useContext(MiniAppContext);
|
|
21
11
|
|
|
22
12
|
const {screen: Component, options}: ScreenParams = props.route.params;
|
|
@@ -37,29 +27,12 @@ const StackScreen: React.FC<ScreenParams> = props => {
|
|
|
37
27
|
if (options) {
|
|
38
28
|
navigation.setOptions(options);
|
|
39
29
|
}
|
|
40
|
-
InteractionManager.runAfterInteractions(() => {
|
|
41
|
-
navigator?.maxApi?.showToastDebug?.({
|
|
42
|
-
appId: context.appId,
|
|
43
|
-
message: `${Component.name} screen_interaction_time ${
|
|
44
|
-
Date.now() - startTime.current
|
|
45
|
-
}`,
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
30
|
}, [options]);
|
|
49
31
|
|
|
50
32
|
/**
|
|
51
33
|
* tracking for screen
|
|
52
34
|
*/
|
|
53
35
|
useEffect(() => {
|
|
54
|
-
if (__DEV__) {
|
|
55
|
-
if (!Component.name || Component.name === 'screen') {
|
|
56
|
-
Alert.alert(
|
|
57
|
-
'Design system',
|
|
58
|
-
`Unvalidated screen name "${Component.name}" !`,
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
36
|
const tracking = {
|
|
64
37
|
...context,
|
|
65
38
|
screen_name: Component.name,
|
|
@@ -72,57 +45,26 @@ const StackScreen: React.FC<ScreenParams> = props => {
|
|
|
72
45
|
pre_screen_name = routes[routesLength - 2]?.params?.screen?.name;
|
|
73
46
|
}
|
|
74
47
|
|
|
75
|
-
|
|
48
|
+
navigator?.maxApi?.trackEvent?.('service_frame_displayed', {
|
|
76
49
|
...tracking,
|
|
77
50
|
pre_screen_name,
|
|
78
51
|
trigger_id: '111378000000000000',
|
|
79
|
-
};
|
|
80
|
-
navigator?.maxApi?.trackEvent?.('service_frame_displayed', params);
|
|
81
|
-
navigator?.maxApi?.showToastDebug?.({
|
|
82
|
-
appId: context.appId,
|
|
83
|
-
message: `${Component.name} service_frame_displayed`,
|
|
84
|
-
params,
|
|
85
52
|
});
|
|
86
53
|
|
|
87
54
|
return props.navigation.addListener('beforeRemove', () => {
|
|
88
|
-
|
|
55
|
+
navigator?.maxApi?.trackEvent?.('service_icon_clicked', {
|
|
89
56
|
...tracking,
|
|
90
57
|
trigger_id: '111154000000000000',
|
|
91
58
|
icon_name: 'back',
|
|
92
|
-
};
|
|
93
|
-
navigator?.maxApi?.trackEvent?.('service_icon_clicked', params);
|
|
94
|
-
navigator?.maxApi?.showToastDebug?.({
|
|
95
|
-
appId: context.appId,
|
|
96
|
-
message: `${Component.name} service_icon_clicked`,
|
|
97
|
-
params,
|
|
98
59
|
});
|
|
99
60
|
});
|
|
100
61
|
}, []);
|
|
101
62
|
|
|
102
63
|
return (
|
|
103
|
-
|
|
104
|
-
value={{
|
|
105
|
-
appId: context.appId,
|
|
106
|
-
code: context.code,
|
|
107
|
-
screenName: Component.name,
|
|
108
|
-
autoTracking: (data: any) => {
|
|
109
|
-
navigator?.maxApi?.dispatchFunction?.('autoTracking', data);
|
|
110
|
-
},
|
|
111
|
-
onElementLoad: () => {
|
|
112
|
-
endTime.current = Date.now();
|
|
113
|
-
clearTimeout(timeout.current);
|
|
114
|
-
timeout.current = setTimeout(() => {
|
|
115
|
-
timeLoad.current = endTime.current - startTime.current;
|
|
116
|
-
navigator?.maxApi?.showToastDebug?.({
|
|
117
|
-
appId: context.appId,
|
|
118
|
-
message: `${Component.name} screen_load_time ${timeLoad.current}`,
|
|
119
|
-
});
|
|
120
|
-
}, 1000);
|
|
121
|
-
},
|
|
122
|
-
}}>
|
|
64
|
+
<>
|
|
123
65
|
<Component heightHeader={heightHeader} {...params} />
|
|
124
66
|
{showGrid && <GridSystem />}
|
|
125
|
-
|
|
67
|
+
</>
|
|
126
68
|
);
|
|
127
69
|
};
|
|
128
70
|
|
package/Application/utils.tsx
CHANGED
|
@@ -146,39 +146,4 @@ const getOptions = (params: NavigationOptions, theme: Theme) => {
|
|
|
146
146
|
};
|
|
147
147
|
};
|
|
148
148
|
|
|
149
|
-
|
|
150
|
-
const accentsMap = {
|
|
151
|
-
'a': 'á|à|ả|ã|ạ|â|ấ|ầ|ẩ|ẫ|ậ|ă|ắ|ằ|ẳ|ẵ|ặ',
|
|
152
|
-
'A': 'Á|À|Ả|Ã|Ạ|Â|Ấ|Ầ|Ẩ|Ẫ|Ậ|Ă|Ắ|Ằ|Ẳ|Ẵ|Ặ',
|
|
153
|
-
'e': 'é|è|ẻ|ẽ|ẹ|ê|ế|ề|ể|ễ|ệ',
|
|
154
|
-
'E': 'É|È|Ẻ|Ẽ|Ẹ|Ê|Ế|Ề|Ể|Ễ|Ệ',
|
|
155
|
-
'i': 'í|ì|ỉ|ĩ|ị',
|
|
156
|
-
'I': 'Í|Ì|Ỉ|Ĩ|Ị',
|
|
157
|
-
'o': 'ó|ò|ỏ|õ|ọ|ô|ố|ồ|ổ|ỗ|ộ|ơ|ớ|ờ|ở|ỡ|ợ',
|
|
158
|
-
'O': 'Ó|Ò|Ỏ|Õ|Ọ|Ô|Ố|Ồ|Ổ|Ỗ|Ộ|Ơ|Ớ|Ờ|Ở|Ỡ|Ợ',
|
|
159
|
-
'u': 'ú|ù|ủ|ũ|ụ|ư|ứ|ừ|ử|ữ|ự',
|
|
160
|
-
'U': 'Ú|Ù|Ủ|Ũ|Ụ|Ư|Ứ|Ừ|Ử|Ữ|Ự',
|
|
161
|
-
'y': 'ý|ỳ|ỷ|ỹ|ỵ',
|
|
162
|
-
'Y': 'Ý|Ỳ|Ỷ|Ỹ|Ỵ',
|
|
163
|
-
'd': 'đ',
|
|
164
|
-
'D': 'Đ'
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
for (const [nonAccent, accentGroup] of Object.entries(accentsMap)) {
|
|
168
|
-
const accents = new RegExp(accentGroup, 'g');
|
|
169
|
-
word = word.replace(accents, nonAccent);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
word = word.replace(/\s+/g, '_').toLowerCase();
|
|
173
|
-
|
|
174
|
-
return word;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
const formatNameLength = (name: string) =>{
|
|
178
|
-
let formattedName = name
|
|
179
|
-
if (formattedName.length > 100) {
|
|
180
|
-
formattedName = formattedName.substring(0, 100);
|
|
181
|
-
}
|
|
182
|
-
return formattedName
|
|
183
|
-
}
|
|
184
|
-
export {getStackOptions, getDialogOptions, getModalOptions, getOptions, formatComponentName, formatNameLength};
|
|
149
|
+
export {getStackOptions, getDialogOptions, getModalOptions, getOptions};
|
package/Button/index.tsx
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
TouchableOpacityProps,
|
|
7
7
|
View,
|
|
8
8
|
} from 'react-native';
|
|
9
|
+
|
|
9
10
|
import LinearGradient from 'react-native-linear-gradient';
|
|
10
11
|
import {ApplicationContext} from '../Application';
|
|
11
12
|
import {Text} from '../Text';
|
|
@@ -14,11 +15,6 @@ import {Colors, Spacing} from '../Consts';
|
|
|
14
15
|
import styles from './styles';
|
|
15
16
|
import {Icon} from '../Icon';
|
|
16
17
|
import {Loader} from '../Loader';
|
|
17
|
-
import {formatComponentName} from '../Application/utils';
|
|
18
|
-
|
|
19
|
-
const {
|
|
20
|
-
ScreenContext,
|
|
21
|
-
} = require('react-native/Libraries/Components/ScreenContext');
|
|
22
18
|
|
|
23
19
|
const AnimationLinear = Animated.createAnimatedComponent(LinearGradient);
|
|
24
20
|
|
|
@@ -74,10 +70,6 @@ export interface ButtonProps extends TouchableOpacityProps {
|
|
|
74
70
|
* A callback function that is called when the button is pressed.
|
|
75
71
|
*/
|
|
76
72
|
onPress: () => void;
|
|
77
|
-
|
|
78
|
-
params?: any;
|
|
79
|
-
|
|
80
|
-
componentId?: string;
|
|
81
73
|
}
|
|
82
74
|
|
|
83
75
|
const Button: FC<ButtonProps> = ({
|
|
@@ -90,9 +82,6 @@ const Button: FC<ButtonProps> = ({
|
|
|
90
82
|
loading = false,
|
|
91
83
|
title = 'Button',
|
|
92
84
|
onPress,
|
|
93
|
-
params,
|
|
94
|
-
componentId,
|
|
95
|
-
accessibilityLabel,
|
|
96
85
|
...rest
|
|
97
86
|
}) => {
|
|
98
87
|
const {theme, config} = useContext(ApplicationContext);
|
|
@@ -105,8 +94,6 @@ const Button: FC<ButtonProps> = ({
|
|
|
105
94
|
end: {x: 0, y: 0.5},
|
|
106
95
|
};
|
|
107
96
|
}
|
|
108
|
-
|
|
109
|
-
const screenInfo = useContext<any>(ScreenContext);
|
|
110
97
|
const getSizeStyle = () => {
|
|
111
98
|
const styleSheet: {[key: string]: any} = styles;
|
|
112
99
|
return styleSheet[size ?? 'small'];
|
|
@@ -304,34 +291,19 @@ const Button: FC<ButtonProps> = ({
|
|
|
304
291
|
const activeOpacity = type === 'disabled' ? 0.75 : 0.5;
|
|
305
292
|
|
|
306
293
|
return (
|
|
307
|
-
<
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
}}>
|
|
321
|
-
<TouchableOpacity
|
|
322
|
-
{...rest}
|
|
323
|
-
activeOpacity={activeOpacity}
|
|
324
|
-
onPress={onPressButton}
|
|
325
|
-
style={buttonStyle}>
|
|
326
|
-
{renderLeading()}
|
|
327
|
-
{renderTitle()}
|
|
328
|
-
{renderTrailing()}
|
|
329
|
-
{gradientPros && (
|
|
330
|
-
<AnimationLinear {...gradientPros} style={styles.gradientView} />
|
|
331
|
-
)}
|
|
332
|
-
{gradientPros && <View style={styles.strokeView} />}
|
|
333
|
-
</TouchableOpacity>
|
|
334
|
-
</ScreenContext.Provider>
|
|
294
|
+
<TouchableOpacity
|
|
295
|
+
{...rest}
|
|
296
|
+
activeOpacity={activeOpacity}
|
|
297
|
+
onPress={onPressButton}
|
|
298
|
+
style={buttonStyle}>
|
|
299
|
+
{renderLeading()}
|
|
300
|
+
{renderTitle()}
|
|
301
|
+
{renderTrailing()}
|
|
302
|
+
{gradientPros && (
|
|
303
|
+
<AnimationLinear {...gradientPros} style={styles.gradientView} />
|
|
304
|
+
)}
|
|
305
|
+
{gradientPros && <View style={styles.strokeView} />}
|
|
306
|
+
</TouchableOpacity>
|
|
335
307
|
);
|
|
336
308
|
};
|
|
337
309
|
|
package/CheckBox/index.tsx
CHANGED
|
@@ -5,11 +5,6 @@ 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');
|
|
13
8
|
|
|
14
9
|
const CheckBox: FC<CheckBoxProps> = ({
|
|
15
10
|
value,
|
|
@@ -18,11 +13,8 @@ const CheckBox: FC<CheckBoxProps> = ({
|
|
|
18
13
|
style,
|
|
19
14
|
label,
|
|
20
15
|
indeterminate,
|
|
21
|
-
params,
|
|
22
|
-
componentId,
|
|
23
16
|
}) => {
|
|
24
17
|
const {theme} = useContext(ApplicationContext);
|
|
25
|
-
const screenInfo = useContext<any>(ScreenContext);
|
|
26
18
|
const haveValue = value || indeterminate;
|
|
27
19
|
const iconSource = indeterminate ? 'ic_minus' : 'ic_checked';
|
|
28
20
|
let borderColor = theme.colors.text.default;
|
|
@@ -43,38 +35,26 @@ const CheckBox: FC<CheckBoxProps> = ({
|
|
|
43
35
|
}
|
|
44
36
|
|
|
45
37
|
return (
|
|
46
|
-
<
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
]}>
|
|
67
|
-
{haveValue && (
|
|
68
|
-
<Icon
|
|
69
|
-
color={theme.colors.background.surface}
|
|
70
|
-
size={20}
|
|
71
|
-
source={iconSource}
|
|
72
|
-
/>
|
|
73
|
-
)}
|
|
74
|
-
</View>
|
|
75
|
-
{!!label && <Text typography={'body_default_regular'}>{label}</Text>}
|
|
76
|
-
</TouchableOpacity>
|
|
77
|
-
</ScreenContext.Provider>
|
|
38
|
+
<TouchableOpacity
|
|
39
|
+
activeOpacity={0.8}
|
|
40
|
+
onPress={() => onChange?.(!value)}
|
|
41
|
+
disabled={disabled}
|
|
42
|
+
style={[style, styles.container]}>
|
|
43
|
+
<View
|
|
44
|
+
style={[
|
|
45
|
+
{borderColor, backgroundColor, borderWidth: 1},
|
|
46
|
+
styles.checkbox,
|
|
47
|
+
]}>
|
|
48
|
+
{haveValue && (
|
|
49
|
+
<Icon
|
|
50
|
+
color={theme.colors.background.surface}
|
|
51
|
+
size={20}
|
|
52
|
+
source={iconSource}
|
|
53
|
+
/>
|
|
54
|
+
)}
|
|
55
|
+
</View>
|
|
56
|
+
{!!label && <Text typography={'body_default_regular'}>{label}</Text>}
|
|
57
|
+
</TouchableOpacity>
|
|
78
58
|
);
|
|
79
59
|
};
|
|
80
60
|
|
package/CheckBox/types.ts
CHANGED
package/IconButton/index.tsx
CHANGED
|
@@ -9,11 +9,6 @@ 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');
|
|
17
12
|
|
|
18
13
|
export interface IconButtonProps extends TouchableOpacityProps {
|
|
19
14
|
/**
|
|
@@ -31,10 +26,6 @@ export interface IconButtonProps extends TouchableOpacityProps {
|
|
|
31
26
|
* Optional. Defines the size of the IconButton.
|
|
32
27
|
*/
|
|
33
28
|
size?: 'large' | 'small';
|
|
34
|
-
|
|
35
|
-
params?: any;
|
|
36
|
-
|
|
37
|
-
componentId?: string;
|
|
38
29
|
}
|
|
39
30
|
|
|
40
31
|
const IconButton: React.FC<IconButtonProps> = ({
|
|
@@ -42,12 +33,9 @@ const IconButton: React.FC<IconButtonProps> = ({
|
|
|
42
33
|
icon,
|
|
43
34
|
size,
|
|
44
35
|
onPress,
|
|
45
|
-
params,
|
|
46
|
-
componentId,
|
|
47
36
|
...rest
|
|
48
37
|
}) => {
|
|
49
38
|
const {theme} = useContext(ApplicationContext);
|
|
50
|
-
const screenInfo = useContext<any>(ScreenContext);
|
|
51
39
|
|
|
52
40
|
/**
|
|
53
41
|
* get size icon button
|
|
@@ -133,24 +121,13 @@ const IconButton: React.FC<IconButtonProps> = ({
|
|
|
133
121
|
const iconSize = size === 'small' ? 16 : 24;
|
|
134
122
|
|
|
135
123
|
return (
|
|
136
|
-
<
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
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>
|
|
124
|
+
<TouchableOpacity
|
|
125
|
+
{...rest}
|
|
126
|
+
activeOpacity={activeOpacity}
|
|
127
|
+
onPress={onPressButton}
|
|
128
|
+
style={buttonStyle}>
|
|
129
|
+
<Icon size={iconSize} source={icon} color={getIconColor()} />
|
|
130
|
+
</TouchableOpacity>
|
|
154
131
|
);
|
|
155
132
|
};
|
|
156
133
|
|
package/Input/Input.tsx
CHANGED
|
@@ -13,11 +13,6 @@ 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');
|
|
21
16
|
|
|
22
17
|
const Input = forwardRef(
|
|
23
18
|
(
|
|
@@ -44,8 +39,6 @@ const Input = forwardRef(
|
|
|
44
39
|
onPressIcon,
|
|
45
40
|
secureTextEntry,
|
|
46
41
|
style,
|
|
47
|
-
params,
|
|
48
|
-
componentId,
|
|
49
42
|
...props
|
|
50
43
|
}: InputProps,
|
|
51
44
|
ref,
|
|
@@ -55,7 +48,6 @@ const Input = forwardRef(
|
|
|
55
48
|
const [haveValue, setHaveValue] = useState(!!value || !!props.defaultValue);
|
|
56
49
|
const [secureTextInput, setSecureTextInput] = useState(secureTextEntry);
|
|
57
50
|
const inputRef = (ref as React.RefObject<TextInput>) ?? useRef<TextInput>();
|
|
58
|
-
const screenInfo = useContext<any>(ScreenContext);
|
|
59
51
|
|
|
60
52
|
const onClearText = () => {
|
|
61
53
|
inputRef?.current?.clear();
|
|
@@ -188,34 +180,11 @@ const Input = forwardRef(
|
|
|
188
180
|
);
|
|
189
181
|
};
|
|
190
182
|
|
|
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
183
|
return (
|
|
205
|
-
<
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
params,
|
|
210
|
-
componentLabel: formatComponentName(floatingValue || ''),
|
|
211
|
-
state: inputState,
|
|
212
|
-
componentId,
|
|
213
|
-
}}>
|
|
214
|
-
<View style={[style, styles.wrapper]}>
|
|
215
|
-
{renderInputView()}
|
|
216
|
-
<ErrorView errorMessage={errorMessage} errorSpacing={errorSpacing} />
|
|
217
|
-
</View>
|
|
218
|
-
</ScreenContext.Provider>
|
|
184
|
+
<View style={[style, styles.wrapper]}>
|
|
185
|
+
{renderInputView()}
|
|
186
|
+
<ErrorView errorMessage={errorMessage} errorSpacing={errorSpacing} />
|
|
187
|
+
</View>
|
|
219
188
|
);
|
|
220
189
|
},
|
|
221
190
|
);
|