@momo-kits/foundation 0.92.2 → 0.92.3-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/Components.tsx +18 -23
- package/Application/NavigationContainer.tsx +3 -8
- package/Application/StackScreen.tsx +70 -64
- package/Application/index.ts +8 -8
- package/Button/index.tsx +11 -31
- package/CheckBox/index.tsx +9 -31
- package/CheckBox/types.ts +4 -6
- package/Icon/index.tsx +8 -8
- package/IconButton/index.tsx +7 -19
- package/Image/index.tsx +15 -8
- package/Image/types.ts +1 -0
- package/Input/Input.tsx +7 -34
- package/Input/InputDropDown.tsx +7 -32
- package/Input/InputMoney.tsx +7 -30
- package/Input/InputOTP.tsx +7 -26
- package/Input/InputSearch.tsx +6 -17
- package/Input/InputTextArea.tsx +1 -23
- package/Input/index.tsx +1 -9
- package/Popup/PopupNotify.tsx +3 -6
- package/Popup/PopupPromotion.tsx +3 -10
- package/Radio/index.tsx +7 -25
- package/Radio/types.ts +4 -7
- package/Switch/index.tsx +14 -25
- package/Switch/types.ts +4 -6
- package/package.json +1 -1
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
View,
|
|
16
16
|
ViewStyle,
|
|
17
17
|
} from 'react-native';
|
|
18
|
-
import {ApplicationContext} from './index';
|
|
18
|
+
import {ApplicationContext, MiniAppContext} from './index';
|
|
19
19
|
import {Colors, Radius, Spacing, Styles} from '../Consts';
|
|
20
20
|
import {Image} from '../Image';
|
|
21
21
|
import {
|
|
@@ -31,10 +31,6 @@ import {PopupNotify} from '../Popup';
|
|
|
31
31
|
import {Badge, BadgeDot} from '../Badge';
|
|
32
32
|
import {getAccessibilityID} from './utils';
|
|
33
33
|
|
|
34
|
-
const {
|
|
35
|
-
MiniAppContext,
|
|
36
|
-
} = require('react-native/Libraries/Components/ScreenContext');
|
|
37
|
-
|
|
38
34
|
const NavigationButton: React.FC<NavigationButtonProps> = ({
|
|
39
35
|
icon,
|
|
40
36
|
tintColor,
|
|
@@ -127,26 +123,25 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
|
|
|
127
123
|
|
|
128
124
|
const goBackSafe = () => {
|
|
129
125
|
const goBack = () => {
|
|
130
|
-
const canGoBack = navigator?.ref
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}
|
|
126
|
+
const canGoBack = navigator?.ref?.current?.canGoBack?.();
|
|
127
|
+
const currentRoute = navigator?.ref?.current?.getCurrentRoute?.();
|
|
128
|
+
const params = {
|
|
129
|
+
appId: context.appId,
|
|
130
|
+
code: context.code,
|
|
131
|
+
screen_name: currentRoute?.params?.screen?.name ?? currentRoute?.name,
|
|
132
|
+
trigger_id: '111154000000000000',
|
|
133
|
+
icon_name: 'back',
|
|
134
|
+
};
|
|
135
|
+
navigator?.maxApi?.showToastDebug?.({
|
|
136
|
+
appId: `auto - ${context.appId}`,
|
|
137
|
+
message: 'service_icon_clicked',
|
|
138
|
+
params,
|
|
139
|
+
});
|
|
140
|
+
navigator?.maxApi?.trackEvent?.('service_icon_clicked', params);
|
|
146
141
|
if (canGoBack) {
|
|
147
|
-
navigator?.ref
|
|
142
|
+
navigator?.ref?.current?.goBack?.();
|
|
148
143
|
} else if (navigator?.maxApi) {
|
|
149
|
-
navigator?.maxApi?.dismiss(navigator
|
|
144
|
+
navigator?.maxApi?.dismiss?.(navigator?.dismissData);
|
|
150
145
|
} else {
|
|
151
146
|
const currentTime = new Date().getTime();
|
|
152
147
|
const requestId = `navigationBackPress#${currentTime}`;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {useEffect, useRef, useState} from 'react';
|
|
2
2
|
import {SafeAreaProvider} from 'react-native-safe-area-context';
|
|
3
3
|
import {
|
|
4
4
|
NavigationContainer as ReactNavigationContainer,
|
|
@@ -15,10 +15,6 @@ import {LocalizationObject, NavigationContainerProps} from './types';
|
|
|
15
15
|
import {ApplicationContext} from './index';
|
|
16
16
|
import kitLocalization from '../Assets/language.json';
|
|
17
17
|
|
|
18
|
-
const {
|
|
19
|
-
MiniAppContext,
|
|
20
|
-
} = require('react-native/Libraries/Components/ScreenContext');
|
|
21
|
-
|
|
22
18
|
/**
|
|
23
19
|
* link for deprecated
|
|
24
20
|
*/
|
|
@@ -35,11 +31,10 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
|
|
|
35
31
|
localization,
|
|
36
32
|
initialParams,
|
|
37
33
|
}) => {
|
|
38
|
-
const context = useContext<any>(MiniAppContext);
|
|
39
34
|
const navigationRef = useRef<NavigationContainerRef>(null);
|
|
40
35
|
const isReady = useRef(false);
|
|
41
36
|
const navigator = useRef(new Navigator(navigationRef, isReady));
|
|
42
|
-
const [showGrid, setShowGrid] = useState(
|
|
37
|
+
const [showGrid, setShowGrid] = useState(true);
|
|
43
38
|
const config = useRef<any>();
|
|
44
39
|
|
|
45
40
|
/**
|
|
@@ -69,7 +64,7 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
|
|
|
69
64
|
* @param key
|
|
70
65
|
*/
|
|
71
66
|
const translate = (key: string) => {
|
|
72
|
-
const language: 'vi' | 'en' =
|
|
67
|
+
const language: 'vi' | 'en' = 'vi';
|
|
73
68
|
const mergedLocalization: LocalizationObject = {
|
|
74
69
|
vi: {...localization?.vi, ...kitLocalization.vi},
|
|
75
70
|
en: {...localization?.en, ...kitLocalization.en},
|
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
import React, {useContext, useEffect, useLayoutEffect, useRef} from 'react';
|
|
2
2
|
import {ScreenParams} from './types';
|
|
3
3
|
import Navigation from './Navigation';
|
|
4
|
-
import {ApplicationContext} from './index';
|
|
4
|
+
import {ApplicationContext, MiniAppContext, ScreenContext} from './index';
|
|
5
5
|
import {GridSystem} from '../Layout';
|
|
6
6
|
import {useHeaderHeight} from '@react-navigation/stack';
|
|
7
7
|
import {Alert, InteractionManager} from 'react-native';
|
|
8
8
|
|
|
9
|
-
const {
|
|
10
|
-
ScreenContext,
|
|
11
|
-
MiniAppContext,
|
|
12
|
-
} = require('react-native/Libraries/Components/ScreenContext');
|
|
13
|
-
|
|
14
9
|
const StackScreen: React.FC<ScreenParams> = props => {
|
|
15
10
|
const {theme, showGrid, navigator} = useContext(ApplicationContext);
|
|
16
11
|
const startTime = useRef(Date.now());
|
|
17
12
|
const endTime = useRef(Date.now());
|
|
18
13
|
const timeLoad = useRef(0);
|
|
19
|
-
const
|
|
20
|
-
|
|
14
|
+
const timeInteraction = useRef(0);
|
|
15
|
+
const timeoutLoad = useRef<any>();
|
|
16
|
+
const tracked = useRef<any>({
|
|
17
|
+
releaseLoad: undefined,
|
|
18
|
+
releaseInteraction: undefined,
|
|
19
|
+
timeoutLoad: undefined,
|
|
20
|
+
timeoutInteraction: undefined,
|
|
21
|
+
});
|
|
22
|
+
const interaction = useRef<any>();
|
|
21
23
|
const context = useContext<any>(MiniAppContext);
|
|
22
24
|
|
|
23
25
|
const {screen: Component, options, initialParams} = props.route.params;
|
|
@@ -39,16 +41,6 @@ const StackScreen: React.FC<ScreenParams> = props => {
|
|
|
39
41
|
* set options for screen
|
|
40
42
|
*/
|
|
41
43
|
useLayoutEffect(() => {
|
|
42
|
-
const host = (global as any).miniAppApi?.currentHost || {};
|
|
43
|
-
host.screenName = screenName;
|
|
44
|
-
InteractionManager.runAfterInteractions(() => {
|
|
45
|
-
navigator?.maxApi?.showToastDebug?.({
|
|
46
|
-
appId: `auto - ${context.appId}`,
|
|
47
|
-
message: `${screenName} screen_interaction_time ${
|
|
48
|
-
Date.now() - startTime.current
|
|
49
|
-
}`,
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
44
|
if (options) {
|
|
53
45
|
navigation.setOptions(options);
|
|
54
46
|
}
|
|
@@ -58,73 +50,86 @@ const StackScreen: React.FC<ScreenParams> = props => {
|
|
|
58
50
|
* tracking for screen
|
|
59
51
|
*/
|
|
60
52
|
useEffect(() => {
|
|
61
|
-
if (__DEV__) {
|
|
62
|
-
|
|
63
|
-
Alert.alert(
|
|
64
|
-
'Design system',
|
|
65
|
-
`Unvalidated screen name "${screenName}" !`,
|
|
66
|
-
);
|
|
67
|
-
}
|
|
53
|
+
if (__DEV__ && (!screenName || screenName == 'Invalid')) {
|
|
54
|
+
Alert.alert('Design system', `Unvalidated screen name "${screenName}" !`);
|
|
68
55
|
}
|
|
69
56
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
57
|
+
navigator?.maxApi?.of?.({screenName});
|
|
58
|
+
|
|
59
|
+
tracked.current.timeoutLoad = setTimeout(() => {
|
|
60
|
+
onScreenLoad();
|
|
61
|
+
}, 5000);
|
|
62
|
+
tracked.current.timeoutInteraction = setTimeout(() => {
|
|
63
|
+
onScreenInteraction();
|
|
64
|
+
}, 5000);
|
|
65
|
+
return () => {
|
|
66
|
+
onScreenLoad();
|
|
67
|
+
onScreenInteraction();
|
|
73
68
|
};
|
|
69
|
+
}, []);
|
|
74
70
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
71
|
+
/**
|
|
72
|
+
* tracking for screen load
|
|
73
|
+
*/
|
|
74
|
+
const onScreenLoad = () => {
|
|
75
|
+
clearTimeout(tracked.current.timeoutLoad);
|
|
76
|
+
if (!tracked.current?.releaseLoad) {
|
|
77
|
+
navigator?.maxApi?.dispatchFunction?.('autoTracking', {
|
|
78
|
+
appId: context.appId,
|
|
79
|
+
code: context.code,
|
|
80
|
+
screenName,
|
|
81
|
+
componentName: 'Screen',
|
|
82
|
+
state: 'load',
|
|
83
|
+
time: timeLoad.current,
|
|
84
|
+
});
|
|
85
|
+
navigator?.maxApi?.showToastDebug?.({
|
|
86
|
+
appId: `auto - ${context.appId}`,
|
|
87
|
+
message: `${screenName} screen_load_time ${timeLoad.current}`,
|
|
88
|
+
});
|
|
89
|
+
tracked.current.releaseLoad = true;
|
|
80
90
|
}
|
|
91
|
+
};
|
|
81
92
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
+
/**
|
|
94
|
+
* tracking for screen load
|
|
95
|
+
*/
|
|
96
|
+
const onScreenInteraction = () => {
|
|
97
|
+
clearTimeout(tracked.current.timeoutInteraction);
|
|
98
|
+
if (!tracked.current?.releaseInteraction) {
|
|
99
|
+
navigator?.maxApi?.dispatchFunction?.('autoTracking', {
|
|
100
|
+
appId: context.appId,
|
|
101
|
+
code: context.code,
|
|
102
|
+
screenName,
|
|
103
|
+
componentName: 'Screen',
|
|
104
|
+
state: 'interaction',
|
|
105
|
+
time: timeInteraction.current,
|
|
106
|
+
});
|
|
93
107
|
|
|
94
|
-
return props.navigation.addListener('beforeRemove', () => {
|
|
95
|
-
const params = {
|
|
96
|
-
...tracking,
|
|
97
|
-
trigger_id: '111154000000000000',
|
|
98
|
-
icon_name: 'back',
|
|
99
|
-
};
|
|
100
|
-
navigator?.maxApi?.trackEvent?.('service_icon_clicked', params);
|
|
101
108
|
navigator?.maxApi?.showToastDebug?.({
|
|
102
109
|
appId: `auto - ${context.appId}`,
|
|
103
|
-
message: `${screenName}
|
|
104
|
-
params,
|
|
110
|
+
message: `${screenName} screen_interaction_time ${timeInteraction.current}`,
|
|
105
111
|
});
|
|
106
|
-
|
|
107
|
-
|
|
112
|
+
tracked.current.releaseInteraction = true;
|
|
113
|
+
}
|
|
114
|
+
};
|
|
108
115
|
|
|
109
116
|
return (
|
|
110
117
|
<ScreenContext.Provider
|
|
111
118
|
value={{
|
|
112
|
-
appId: context.appId,
|
|
113
|
-
code: context.code,
|
|
114
119
|
screenName,
|
|
115
120
|
autoTracking: (data: any) => {
|
|
116
121
|
navigator?.maxApi?.dispatchFunction?.('autoTracking', data);
|
|
117
122
|
},
|
|
118
123
|
onElementLoad: () => {
|
|
119
124
|
endTime.current = Date.now();
|
|
120
|
-
|
|
121
|
-
|
|
125
|
+
interaction.current?.cancel?.();
|
|
126
|
+
interaction.current = InteractionManager.runAfterInteractions(() => {
|
|
127
|
+
timeInteraction.current = Date.now() - startTime.current;
|
|
128
|
+
});
|
|
129
|
+
clearTimeout(timeoutLoad.current);
|
|
130
|
+
timeoutLoad.current = setTimeout(() => {
|
|
122
131
|
if (timeLoad.current === 0) {
|
|
123
132
|
timeLoad.current = endTime.current - startTime.current;
|
|
124
|
-
navigator?.maxApi?.showToastDebug?.({
|
|
125
|
-
appId: `auto - ${context.appId}`,
|
|
126
|
-
message: `${screenName} screen_load_time ${timeLoad.current}`,
|
|
127
|
-
});
|
|
128
133
|
}
|
|
129
134
|
}, 2000);
|
|
130
135
|
},
|
|
@@ -132,7 +137,8 @@ const StackScreen: React.FC<ScreenParams> = props => {
|
|
|
132
137
|
<Component
|
|
133
138
|
heightHeader={heightHeader}
|
|
134
139
|
{...data}
|
|
135
|
-
onScreenLoad={
|
|
140
|
+
onScreenLoad={onScreenLoad}
|
|
141
|
+
onScreenInteraction={onScreenInteraction}
|
|
136
142
|
/>
|
|
137
143
|
{showGrid && <GridSystem />}
|
|
138
144
|
</ScreenContext.Provider>
|
package/Application/index.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {Platform} from 'react-native';
|
|
1
2
|
import {NavigationContainer} from './NavigationContainer';
|
|
2
3
|
import Screen from '../Layout/Screen';
|
|
3
4
|
import {
|
|
@@ -11,20 +12,19 @@ import {
|
|
|
11
12
|
import BottomTab from './BottomTab';
|
|
12
13
|
import {createContext} from 'react';
|
|
13
14
|
import {defaultContext} from '../Consts';
|
|
14
|
-
import {MiniAppInfo} from './types';
|
|
15
15
|
|
|
16
|
+
const Context = createContext({});
|
|
16
17
|
const ApplicationContext = createContext(defaultContext);
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
toolkitConfig: {},
|
|
22
|
-
fromCode: '',
|
|
23
|
-
});
|
|
18
|
+
|
|
19
|
+
const MiniAppContext = (Platform as any).MiniAppContext ?? Context;
|
|
20
|
+
const ScreenContext = (Platform as any).ScreenContext ?? Context;
|
|
21
|
+
const ComponentContext = (Platform as any).ComponentContext ?? Context;
|
|
24
22
|
|
|
25
23
|
export {
|
|
26
24
|
ApplicationContext,
|
|
27
25
|
MiniAppContext,
|
|
26
|
+
ScreenContext,
|
|
27
|
+
ComponentContext,
|
|
28
28
|
NavigationContainer,
|
|
29
29
|
Screen,
|
|
30
30
|
BottomTab,
|
package/Button/index.tsx
CHANGED
|
@@ -7,23 +7,14 @@ import {
|
|
|
7
7
|
View,
|
|
8
8
|
} from 'react-native';
|
|
9
9
|
import LinearGradient from 'react-native-linear-gradient';
|
|
10
|
-
import {ApplicationContext} from '../Application';
|
|
10
|
+
import {ApplicationContext, ComponentContext} from '../Application';
|
|
11
11
|
import {Text} from '../Text';
|
|
12
12
|
import {Typography} from '../Text/types';
|
|
13
13
|
import {Colors, Spacing} from '../Consts';
|
|
14
14
|
import styles from './styles';
|
|
15
15
|
import {Icon} from '../Icon';
|
|
16
16
|
import {Loader} from '../Loader';
|
|
17
|
-
import {
|
|
18
|
-
cleanNameForTracking,
|
|
19
|
-
formatComponentName,
|
|
20
|
-
getAccessibilityID,
|
|
21
|
-
} from '../Application/utils';
|
|
22
|
-
|
|
23
|
-
const {
|
|
24
|
-
ScreenContext,
|
|
25
|
-
MiniAppContext,
|
|
26
|
-
} = require('react-native/Libraries/Components/ScreenContext');
|
|
17
|
+
import {formatComponentName} from '../Application/utils';
|
|
27
18
|
|
|
28
19
|
const AnimationLinear = Animated.createAnimatedComponent(LinearGradient);
|
|
29
20
|
|
|
@@ -81,8 +72,6 @@ export interface ButtonProps extends TouchableOpacityProps {
|
|
|
81
72
|
onPress: () => void;
|
|
82
73
|
|
|
83
74
|
params?: any;
|
|
84
|
-
|
|
85
|
-
componentId?: string;
|
|
86
75
|
}
|
|
87
76
|
|
|
88
77
|
const Button: FC<ButtonProps> = ({
|
|
@@ -96,14 +85,16 @@ const Button: FC<ButtonProps> = ({
|
|
|
96
85
|
title = 'Button',
|
|
97
86
|
onPress,
|
|
98
87
|
params,
|
|
99
|
-
componentId,
|
|
100
88
|
accessibilityLabel,
|
|
101
89
|
...rest
|
|
102
90
|
}) => {
|
|
103
91
|
const {theme, config} = useContext(ApplicationContext);
|
|
104
|
-
const {appId, code} = useContext<any>(MiniAppContext);
|
|
105
92
|
const {gradient, color} = config?.navigationBar?.buttonColors ?? {};
|
|
106
93
|
let gradientPros;
|
|
94
|
+
let state = 'enabled';
|
|
95
|
+
if (loading) {
|
|
96
|
+
state = 'loading';
|
|
97
|
+
}
|
|
107
98
|
if (gradient?.length > 0 && type == 'primary') {
|
|
108
99
|
gradientPros = {
|
|
109
100
|
colors: gradient,
|
|
@@ -112,7 +103,6 @@ const Button: FC<ButtonProps> = ({
|
|
|
112
103
|
};
|
|
113
104
|
}
|
|
114
105
|
|
|
115
|
-
const screenInfo = useContext<any>(ScreenContext);
|
|
116
106
|
const getSizeStyle = () => {
|
|
117
107
|
const styleSheet: {[key: string]: any} = styles;
|
|
118
108
|
return styleSheet[size ?? 'small'];
|
|
@@ -310,28 +300,18 @@ const Button: FC<ButtonProps> = ({
|
|
|
310
300
|
const activeOpacity = type === 'disabled' ? 0.75 : 0.5;
|
|
311
301
|
|
|
312
302
|
return (
|
|
313
|
-
<
|
|
303
|
+
<ComponentContext.Provider
|
|
314
304
|
value={{
|
|
315
|
-
...screenInfo,
|
|
316
305
|
componentName: 'Button',
|
|
317
306
|
params,
|
|
318
|
-
state:
|
|
319
|
-
|
|
320
|
-
: type === 'disabled'
|
|
321
|
-
? 'disabled'
|
|
322
|
-
: 'enabled',
|
|
323
|
-
componentId,
|
|
307
|
+
state: state,
|
|
308
|
+
componentId: accessibilityLabel,
|
|
324
309
|
componentValue: formatComponentName(title),
|
|
325
310
|
action: 'click',
|
|
326
311
|
}}>
|
|
327
312
|
<TouchableOpacity
|
|
328
313
|
{...rest}
|
|
329
|
-
{
|
|
330
|
-
`${appId}/${code}/${screenInfo.screenName}/btn_${cleanNameForTracking(
|
|
331
|
-
title,
|
|
332
|
-
)}`,
|
|
333
|
-
accessibilityLabel,
|
|
334
|
-
)}
|
|
314
|
+
accessibilityLabel={accessibilityLabel}
|
|
335
315
|
activeOpacity={activeOpacity}
|
|
336
316
|
onPress={onPressButton}
|
|
337
317
|
style={buttonStyle}>
|
|
@@ -343,7 +323,7 @@ const Button: FC<ButtonProps> = ({
|
|
|
343
323
|
)}
|
|
344
324
|
{gradientPros && <View style={styles.strokeView} />}
|
|
345
325
|
</TouchableOpacity>
|
|
346
|
-
</
|
|
326
|
+
</ComponentContext.Provider>
|
|
347
327
|
);
|
|
348
328
|
};
|
|
349
329
|
|
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
49
|
componentValue: indeterminate ? 'indetermine' : 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,16 +5,12 @@ 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
12
|
import {formatComponentName} from '../Application/utils';
|
|
13
13
|
|
|
14
|
-
const {
|
|
15
|
-
ScreenContext,
|
|
16
|
-
} = require('react-native/Libraries/Components/ScreenContext');
|
|
17
|
-
|
|
18
14
|
export interface IconButtonProps extends TouchableOpacityProps {
|
|
19
15
|
/**
|
|
20
16
|
* Represents the name or key of the icon to be displayed on the IconButton.
|
|
@@ -33,21 +29,18 @@ export interface IconButtonProps extends TouchableOpacityProps {
|
|
|
33
29
|
size?: 'large' | 'small';
|
|
34
30
|
|
|
35
31
|
params?: any;
|
|
36
|
-
|
|
37
|
-
componentId?: string;
|
|
38
32
|
}
|
|
39
33
|
|
|
40
34
|
const IconButton: React.FC<IconButtonProps> = ({
|
|
41
|
-
type,
|
|
35
|
+
type = 'primary',
|
|
42
36
|
icon,
|
|
43
37
|
size,
|
|
44
38
|
onPress,
|
|
45
39
|
params,
|
|
46
|
-
|
|
40
|
+
accessibilityLabel,
|
|
47
41
|
...rest
|
|
48
42
|
}) => {
|
|
49
43
|
const {theme} = useContext(ApplicationContext);
|
|
50
|
-
const screenInfo = useContext<any>(ScreenContext);
|
|
51
44
|
|
|
52
45
|
/**
|
|
53
46
|
* get size icon button
|
|
@@ -133,30 +126,25 @@ const IconButton: React.FC<IconButtonProps> = ({
|
|
|
133
126
|
const iconSize = size === 'small' ? 16 : 24;
|
|
134
127
|
|
|
135
128
|
return (
|
|
136
|
-
<
|
|
129
|
+
<ComponentContext.Provider
|
|
137
130
|
value={{
|
|
138
|
-
...screenInfo,
|
|
139
131
|
componentName: 'IconButton',
|
|
140
132
|
params,
|
|
141
133
|
state: type === 'disabled' ? 'disabled' : 'enabled',
|
|
142
|
-
componentId,
|
|
134
|
+
componentId: accessibilityLabel,
|
|
143
135
|
componentValue: formatComponentName(icon),
|
|
144
136
|
action: 'click',
|
|
145
137
|
}}>
|
|
146
138
|
<TouchableOpacity
|
|
147
139
|
{...rest}
|
|
140
|
+
accessibilityLabel={accessibilityLabel}
|
|
148
141
|
activeOpacity={activeOpacity}
|
|
149
142
|
onPress={onPressButton}
|
|
150
143
|
style={buttonStyle}>
|
|
151
144
|
<Icon size={iconSize} source={icon} color={getIconColor()} />
|
|
152
145
|
</TouchableOpacity>
|
|
153
|
-
</
|
|
146
|
+
</ComponentContext.Provider>
|
|
154
147
|
);
|
|
155
148
|
};
|
|
156
149
|
|
|
157
|
-
IconButton.defaultProps = {
|
|
158
|
-
type: 'primary',
|
|
159
|
-
disabled: false,
|
|
160
|
-
};
|
|
161
|
-
|
|
162
150
|
export {IconButton};
|