@momo-kits/foundation 0.89.6 → 0.92.1-rc.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Application/{BottomTab.tsx → BottomTab/index.tsx} +9 -6
- package/Application/Components.tsx +26 -10
- package/Application/NavigationContainer.tsx +15 -3
- package/Application/StackScreen.tsx +73 -14
- package/Application/types.ts +11 -2
- package/Application/utils.tsx +70 -2
- package/Badge/Badge.tsx +1 -1
- package/Button/index.tsx +54 -14
- package/CheckBox/index.tsx +53 -20
- package/CheckBox/types.ts +4 -0
- package/Consts/colors+spacing+radius.ts +13 -0
- package/IconButton/index.tsx +30 -7
- package/Image/index.tsx +3 -1
- package/Input/Input.tsx +66 -5
- package/Input/InputDropDown.tsx +44 -4
- package/Input/InputMoney.tsx +53 -4
- package/Input/InputOTP.tsx +39 -7
- package/Input/InputSearch.tsx +61 -25
- package/Input/InputTextArea.tsx +23 -0
- package/Input/index.tsx +29 -2
- package/Popup/PopupNotify.tsx +13 -2
- package/Popup/PopupPromotion.tsx +11 -4
- package/Radio/index.tsx +52 -19
- package/Radio/types.ts +5 -0
- package/Switch/index.tsx +39 -14
- package/Switch/types.ts +4 -0
- package/Text/index.tsx +1 -0
- package/Text/styles.ts +1 -1
- package/Text/types.ts +1 -1
- package/Title/index.tsx +109 -103
- package/Title/styles.ts +34 -8
- package/Title/types.ts +11 -48
- package/index.ts +2 -1
- package/package.json +3 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import React, {useContext, useEffect} from 'react';
|
|
2
2
|
import {Platform} from 'react-native';
|
|
3
|
-
import {BottomTabProps, NavigationScreenProps} from './types';
|
|
4
3
|
import {createBottomTabNavigator} from '@react-navigation/bottom-tabs';
|
|
5
4
|
import {createStackNavigator} from '@react-navigation/stack';
|
|
6
5
|
import {useSafeAreaInsets} from 'react-native-safe-area-context';
|
|
7
6
|
import {NavigationContainer} from '@react-navigation/native';
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import
|
|
7
|
+
import {BottomTabProps, NavigationScreenProps} from '../types';
|
|
8
|
+
import StackScreen from '../StackScreen';
|
|
9
|
+
import {getAccessibilityID, getStackOptions} from '../utils';
|
|
10
|
+
import {ApplicationContext} from '../index';
|
|
11
|
+
import {Text} from '../../Text';
|
|
12
|
+
import {Icon} from '../../Icon';
|
|
13
13
|
|
|
14
14
|
const Tab = createBottomTabNavigator();
|
|
15
15
|
const Stack = createStackNavigator();
|
|
@@ -40,6 +40,7 @@ const TabScreen: React.FC<NavigationScreenProps> = ({route}) => {
|
|
|
40
40
|
</NavigationContainer>
|
|
41
41
|
);
|
|
42
42
|
};
|
|
43
|
+
|
|
43
44
|
const BottomTab: React.FC<BottomTabProps> = ({
|
|
44
45
|
nested,
|
|
45
46
|
tabs,
|
|
@@ -60,6 +61,7 @@ const BottomTab: React.FC<BottomTabProps> = ({
|
|
|
60
61
|
|
|
61
62
|
return (
|
|
62
63
|
<Tab.Navigator
|
|
64
|
+
{...getAccessibilityID('tbr_main_bottom')}
|
|
63
65
|
initialRouteName={initialRouteName}
|
|
64
66
|
backBehavior={'firstRoute'}
|
|
65
67
|
tabBarOptions={{
|
|
@@ -74,6 +76,7 @@ const BottomTab: React.FC<BottomTabProps> = ({
|
|
|
74
76
|
{tabs.map(item => {
|
|
75
77
|
return (
|
|
76
78
|
<Tab.Screen
|
|
79
|
+
{...getAccessibilityID(`btn_tabbar_${item.name}`)}
|
|
77
80
|
key={item.name}
|
|
78
81
|
name={item.name}
|
|
79
82
|
component={TabScreen}
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
View,
|
|
16
16
|
ViewStyle,
|
|
17
17
|
} from 'react-native';
|
|
18
|
-
import {ApplicationContext
|
|
18
|
+
import {ApplicationContext} from './index';
|
|
19
19
|
import {Colors, Radius, Spacing, Styles} from '../Consts';
|
|
20
20
|
import {Image} from '../Image';
|
|
21
21
|
import {
|
|
@@ -29,6 +29,11 @@ import {scaleSize, Text} from '../Text';
|
|
|
29
29
|
import {Icon} from '../Icon';
|
|
30
30
|
import {PopupNotify} from '../Popup';
|
|
31
31
|
import {Badge, BadgeDot} from '../Badge';
|
|
32
|
+
import {getAccessibilityID} from './utils';
|
|
33
|
+
|
|
34
|
+
const {
|
|
35
|
+
MiniAppContext,
|
|
36
|
+
} = require('react-native/Libraries/Components/ScreenContext');
|
|
32
37
|
|
|
33
38
|
const NavigationButton: React.FC<NavigationButtonProps> = ({
|
|
34
39
|
icon,
|
|
@@ -37,6 +42,7 @@ const NavigationButton: React.FC<NavigationButtonProps> = ({
|
|
|
37
42
|
useBorder = true,
|
|
38
43
|
badgeType,
|
|
39
44
|
badgeValue,
|
|
45
|
+
accessibilityID = '',
|
|
40
46
|
}) => {
|
|
41
47
|
const {theme} = useContext(ApplicationContext);
|
|
42
48
|
let buttonStyle: ViewStyle = {backgroundColor: '#00000066'};
|
|
@@ -64,7 +70,9 @@ const NavigationButton: React.FC<NavigationButtonProps> = ({
|
|
|
64
70
|
}, [badgeType, badgeValue]);
|
|
65
71
|
|
|
66
72
|
return (
|
|
67
|
-
<View
|
|
73
|
+
<View
|
|
74
|
+
{...getAccessibilityID(accessibilityID)}
|
|
75
|
+
style={{width: scaleSize(28)}}>
|
|
68
76
|
<TouchableOpacity
|
|
69
77
|
style={[styles.navigationButton, buttonStyle]}
|
|
70
78
|
onPress={onPress}>
|
|
@@ -90,6 +98,7 @@ const HeaderTitle: React.FC<any> = props => {
|
|
|
90
98
|
return (
|
|
91
99
|
<Animated.Text
|
|
92
100
|
{...props}
|
|
101
|
+
{...getAccessibilityID('title_navigation_header')}
|
|
93
102
|
style={[
|
|
94
103
|
styles.title,
|
|
95
104
|
{fontFamily: `${theme.font}-Bold`, opacity, color: props.tintColor},
|
|
@@ -104,7 +113,7 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
|
|
|
104
113
|
onPressLeftHeader,
|
|
105
114
|
useBorder,
|
|
106
115
|
}) => {
|
|
107
|
-
const context = useContext(MiniAppContext);
|
|
116
|
+
const context = useContext<any>(MiniAppContext);
|
|
108
117
|
const {navigator} = useContext(ApplicationContext);
|
|
109
118
|
|
|
110
119
|
useEffect(() => {
|
|
@@ -128,7 +137,7 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
|
|
|
128
137
|
icon_name: 'back',
|
|
129
138
|
};
|
|
130
139
|
navigator?.maxApi?.showToastDebug?.({
|
|
131
|
-
appId: context.appId
|
|
140
|
+
appId: `auto - ${context.appId}`,
|
|
132
141
|
message: 'service_icon_clicked',
|
|
133
142
|
params,
|
|
134
143
|
});
|
|
@@ -166,10 +175,10 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
|
|
|
166
175
|
}
|
|
167
176
|
return true;
|
|
168
177
|
};
|
|
169
|
-
|
|
170
178
|
return (
|
|
171
179
|
<View style={styles.headerLeft}>
|
|
172
180
|
<NavigationButton
|
|
181
|
+
accessibilityID="btn_navigation_back"
|
|
173
182
|
icon="ic_back"
|
|
174
183
|
tintColor={tintColor}
|
|
175
184
|
onPress={goBackSafe}
|
|
@@ -243,7 +252,10 @@ const HeaderCustom: React.FC<TitleCustomProps> = ({
|
|
|
243
252
|
)}
|
|
244
253
|
</View>
|
|
245
254
|
<View style={[Styles.flex, {paddingHorizontal: 8}]}>
|
|
246
|
-
<Text
|
|
255
|
+
<Text
|
|
256
|
+
{...getAccessibilityID('title_navigation_header')}
|
|
257
|
+
typography="header_default_bold"
|
|
258
|
+
color={tintColor}>
|
|
247
259
|
{title}
|
|
248
260
|
</Text>
|
|
249
261
|
<Text typography="description_default_regular" color={tintColor}>
|
|
@@ -293,7 +305,7 @@ const HeaderToolkitAction: React.FC<any> = ({
|
|
|
293
305
|
preventClose,
|
|
294
306
|
}) => {
|
|
295
307
|
const {theme, navigator} = useContext(ApplicationContext);
|
|
296
|
-
const miniContext = useContext(MiniAppContext);
|
|
308
|
+
const miniContext = useContext<any>(MiniAppContext);
|
|
297
309
|
const [toolConfig, setToolConfig] = useState<any>();
|
|
298
310
|
const {onAction} = toolConfig ?? {};
|
|
299
311
|
|
|
@@ -369,6 +381,7 @@ const HeaderToolkitAction: React.FC<any> = ({
|
|
|
369
381
|
if (pinTool)
|
|
370
382
|
return (
|
|
371
383
|
<NavigationButton
|
|
384
|
+
accessibilityID="btn_navigation_pin"
|
|
372
385
|
icon={pinTool.icon as string}
|
|
373
386
|
tintColor={tintColor}
|
|
374
387
|
badgeValue={badgeValue}
|
|
@@ -386,7 +399,6 @@ const HeaderToolkitAction: React.FC<any> = ({
|
|
|
386
399
|
/>
|
|
387
400
|
);
|
|
388
401
|
};
|
|
389
|
-
|
|
390
402
|
if (toolConfig) {
|
|
391
403
|
return (
|
|
392
404
|
<View style={styles.headerRightButton}>
|
|
@@ -399,11 +411,15 @@ const HeaderToolkitAction: React.FC<any> = ({
|
|
|
399
411
|
borderWidth: backgroundColor ? 0.5 : 0,
|
|
400
412
|
},
|
|
401
413
|
]}>
|
|
402
|
-
<TouchableOpacity
|
|
414
|
+
<TouchableOpacity
|
|
415
|
+
{...getAccessibilityID('btn_navigation_more')}
|
|
416
|
+
onPress={onMore}>
|
|
403
417
|
<Icon color={tintColor} source="navigation_more_horiz" size={20} />
|
|
404
418
|
</TouchableOpacity>
|
|
405
419
|
<View style={[styles.divider, {backgroundColor: tintColor}]} />
|
|
406
|
-
<TouchableOpacity
|
|
420
|
+
<TouchableOpacity
|
|
421
|
+
{...getAccessibilityID('btn_navigation_close')}
|
|
422
|
+
onPress={onClose}>
|
|
407
423
|
<Icon
|
|
408
424
|
color={tintColor}
|
|
409
425
|
source="16_navigation_close_circle"
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
NavigationContainer as ReactNavigationContainer,
|
|
5
5
|
NavigationContainerRef,
|
|
6
6
|
} from '@react-navigation/native';
|
|
7
|
+
import {BottomSheetModalProvider} from '@gorhom/bottom-sheet';
|
|
7
8
|
import {createStackNavigator} from '@react-navigation/stack';
|
|
8
9
|
import {DeviceEventEmitter} from 'react-native';
|
|
9
10
|
import StackScreen from './StackScreen';
|
|
@@ -11,9 +12,19 @@ import ModalScreen from './ModalScreen';
|
|
|
11
12
|
import Navigator from './Navigator';
|
|
12
13
|
import {getDialogOptions, getModalOptions, getStackOptions} from './utils';
|
|
13
14
|
import {LocalizationObject, NavigationContainerProps} from './types';
|
|
14
|
-
import {ApplicationContext
|
|
15
|
+
import {ApplicationContext} from './index';
|
|
15
16
|
import kitLocalization from '../Assets/language.json';
|
|
16
17
|
|
|
18
|
+
const {
|
|
19
|
+
MiniAppContext,
|
|
20
|
+
} = require('react-native/Libraries/Components/ScreenContext');
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* link for deprecated
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
console.log(typeof BottomSheetModalProvider);
|
|
27
|
+
|
|
17
28
|
const Stack = createStackNavigator();
|
|
18
29
|
|
|
19
30
|
const NavigationContainer: React.FC<NavigationContainerProps> = ({
|
|
@@ -22,8 +33,9 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
|
|
|
22
33
|
options,
|
|
23
34
|
maxApi,
|
|
24
35
|
localization,
|
|
36
|
+
initialParams,
|
|
25
37
|
}) => {
|
|
26
|
-
const context = useContext(MiniAppContext);
|
|
38
|
+
const context = useContext<any>(MiniAppContext);
|
|
27
39
|
const navigationRef = useRef<NavigationContainerRef>(null);
|
|
28
40
|
const isReady = useRef(false);
|
|
29
41
|
const navigator = useRef(new Navigator(navigationRef, isReady));
|
|
@@ -96,7 +108,7 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
|
|
|
96
108
|
<Stack.Screen
|
|
97
109
|
name="Stack"
|
|
98
110
|
component={StackScreen}
|
|
99
|
-
initialParams={{screen}}
|
|
111
|
+
initialParams={{screen, initialParams}}
|
|
100
112
|
options={{...getStackOptions(), ...options}}
|
|
101
113
|
/>
|
|
102
114
|
<Stack.Screen
|
|
@@ -1,29 +1,54 @@
|
|
|
1
|
-
import React, {useContext, useEffect, useLayoutEffect} from 'react';
|
|
1
|
+
import React, {useContext, useEffect, useLayoutEffect, useRef} from 'react';
|
|
2
2
|
import {ScreenParams} from './types';
|
|
3
3
|
import Navigation from './Navigation';
|
|
4
|
-
import {ApplicationContext
|
|
4
|
+
import {ApplicationContext} 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
|
+
MiniAppContext,
|
|
12
|
+
} = require('react-native/Libraries/Components/ScreenContext');
|
|
7
13
|
|
|
8
14
|
const StackScreen: React.FC<ScreenParams> = props => {
|
|
9
15
|
const {theme, showGrid, navigator} = useContext(ApplicationContext);
|
|
10
|
-
const
|
|
16
|
+
const startTime = useRef(Date.now());
|
|
17
|
+
const endTime = useRef(Date.now());
|
|
18
|
+
const timeLoad = useRef(0);
|
|
19
|
+
const timeout = useRef<any>();
|
|
20
|
+
|
|
21
|
+
const context = useContext<any>(MiniAppContext);
|
|
11
22
|
|
|
12
|
-
const {screen: Component, options}
|
|
23
|
+
const {screen: Component, options, initialParams} = props.route.params;
|
|
13
24
|
const navigation = new Navigation(props.navigation, theme);
|
|
14
25
|
const heightHeader = useHeaderHeight();
|
|
15
26
|
|
|
16
|
-
const
|
|
27
|
+
const data = {
|
|
17
28
|
...props.route.params,
|
|
29
|
+
...initialParams,
|
|
18
30
|
navigation,
|
|
19
31
|
};
|
|
20
32
|
|
|
21
|
-
delete
|
|
33
|
+
delete data.screen;
|
|
34
|
+
delete data.initialParams;
|
|
35
|
+
|
|
36
|
+
const screenName = Component?.name || Component?.type?.name || '';
|
|
22
37
|
|
|
23
38
|
/**
|
|
24
39
|
* set options for screen
|
|
25
40
|
*/
|
|
26
41
|
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
|
+
});
|
|
27
52
|
if (options) {
|
|
28
53
|
navigation.setOptions(options);
|
|
29
54
|
}
|
|
@@ -33,9 +58,18 @@ const StackScreen: React.FC<ScreenParams> = props => {
|
|
|
33
58
|
* tracking for screen
|
|
34
59
|
*/
|
|
35
60
|
useEffect(() => {
|
|
61
|
+
if (__DEV__) {
|
|
62
|
+
if (!screenName || screenName === 'screen') {
|
|
63
|
+
Alert.alert(
|
|
64
|
+
'Design system',
|
|
65
|
+
`Unvalidated screen name "${screenName}" !`,
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
36
70
|
const tracking = {
|
|
37
71
|
...context,
|
|
38
|
-
screen_name:
|
|
72
|
+
screen_name: screenName,
|
|
39
73
|
};
|
|
40
74
|
|
|
41
75
|
const routes = props.navigation.getState()?.routes || [];
|
|
@@ -52,8 +86,8 @@ const StackScreen: React.FC<ScreenParams> = props => {
|
|
|
52
86
|
};
|
|
53
87
|
navigator?.maxApi?.trackEvent?.('service_frame_displayed', params);
|
|
54
88
|
navigator?.maxApi?.showToastDebug?.({
|
|
55
|
-
appId: context.appId
|
|
56
|
-
message: `${
|
|
89
|
+
appId: `auto - ${context.appId}`,
|
|
90
|
+
message: `${screenName} service_frame_displayed`,
|
|
57
91
|
params,
|
|
58
92
|
});
|
|
59
93
|
|
|
@@ -65,18 +99,43 @@ const StackScreen: React.FC<ScreenParams> = props => {
|
|
|
65
99
|
};
|
|
66
100
|
navigator?.maxApi?.trackEvent?.('service_icon_clicked', params);
|
|
67
101
|
navigator?.maxApi?.showToastDebug?.({
|
|
68
|
-
appId: context.appId
|
|
69
|
-
message: `${
|
|
102
|
+
appId: `auto - ${context.appId}`,
|
|
103
|
+
message: `${screenName} service_icon_clicked`,
|
|
70
104
|
params,
|
|
71
105
|
});
|
|
72
106
|
});
|
|
73
107
|
}, []);
|
|
74
108
|
|
|
75
109
|
return (
|
|
76
|
-
|
|
77
|
-
|
|
110
|
+
<ScreenContext.Provider
|
|
111
|
+
value={{
|
|
112
|
+
appId: context.appId,
|
|
113
|
+
code: context.code,
|
|
114
|
+
screenName,
|
|
115
|
+
autoTracking: (data: any) => {
|
|
116
|
+
navigator?.maxApi?.dispatchFunction?.('autoTracking', data);
|
|
117
|
+
},
|
|
118
|
+
onElementLoad: () => {
|
|
119
|
+
endTime.current = Date.now();
|
|
120
|
+
clearTimeout(timeout.current);
|
|
121
|
+
timeout.current = setTimeout(() => {
|
|
122
|
+
if (timeLoad.current === 0) {
|
|
123
|
+
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
|
+
}
|
|
129
|
+
}, 2000);
|
|
130
|
+
},
|
|
131
|
+
}}>
|
|
132
|
+
<Component
|
|
133
|
+
heightHeader={heightHeader}
|
|
134
|
+
{...data}
|
|
135
|
+
onScreenLoad={() => {}}
|
|
136
|
+
/>
|
|
78
137
|
{showGrid && <GridSystem />}
|
|
79
|
-
|
|
138
|
+
</ScreenContext.Provider>
|
|
80
139
|
);
|
|
81
140
|
};
|
|
82
141
|
|
package/Application/types.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {Animated, FlatListProps, ViewProps} from 'react-native';
|
|
2
1
|
import {StackNavigationOptions} from '@react-navigation/stack';
|
|
3
2
|
import React from 'react';
|
|
4
|
-
import
|
|
3
|
+
import {Animated, FlatListProps, ViewProps} from 'react-native';
|
|
5
4
|
import {PopupNotifyProps} from '../Popup/types';
|
|
6
5
|
import Navigation from './Navigation';
|
|
6
|
+
import Navigator from './Navigator';
|
|
7
7
|
|
|
8
8
|
type Screen = React.ComponentType<NavigationScreenProps>;
|
|
9
9
|
|
|
@@ -95,6 +95,7 @@ export type NavigationContainerProps = {
|
|
|
95
95
|
theme: Theme;
|
|
96
96
|
maxApi: any;
|
|
97
97
|
localization?: LocalizationObject;
|
|
98
|
+
initialParams?: any;
|
|
98
99
|
};
|
|
99
100
|
|
|
100
101
|
export type NavigationScreenProps = {
|
|
@@ -129,6 +130,7 @@ export type NavigationButtonProps = {
|
|
|
129
130
|
onPress: () => void;
|
|
130
131
|
badgeType?: 'dot' | 'number';
|
|
131
132
|
badgeValue?: number;
|
|
133
|
+
accessibilityID?: string;
|
|
132
134
|
};
|
|
133
135
|
|
|
134
136
|
export type PinnedToolType = {
|
|
@@ -208,6 +210,13 @@ export type BottomTabProps = {
|
|
|
208
210
|
tabPress?: any;
|
|
209
211
|
focus?: any;
|
|
210
212
|
};
|
|
213
|
+
floatingButton?: FloatingButtonProps;
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
export type FloatingButtonProps = {
|
|
217
|
+
icon: string | React.ReactNode;
|
|
218
|
+
label: string;
|
|
219
|
+
onPress: () => void;
|
|
211
220
|
};
|
|
212
221
|
|
|
213
222
|
export type AnimatedHeader = {
|
package/Application/utils.tsx
CHANGED
|
@@ -12,7 +12,8 @@ import {
|
|
|
12
12
|
} from './Components';
|
|
13
13
|
import {NavigationOptions, Theme} from './types';
|
|
14
14
|
import {Colors} from '../Consts';
|
|
15
|
-
|
|
15
|
+
import {Platform} from 'react-native';
|
|
16
|
+
const isIOS = Platform.OS === 'ios';
|
|
16
17
|
/**
|
|
17
18
|
* default options for stack screen
|
|
18
19
|
*/
|
|
@@ -141,4 +142,71 @@ const getOptions = (params: NavigationOptions, theme: Theme) => {
|
|
|
141
142
|
};
|
|
142
143
|
};
|
|
143
144
|
|
|
144
|
-
|
|
145
|
+
const getAccessibilityID = (
|
|
146
|
+
key = '',
|
|
147
|
+
override: string | undefined = undefined,
|
|
148
|
+
) => {
|
|
149
|
+
if (isIOS) {
|
|
150
|
+
return {
|
|
151
|
+
accessible: true,
|
|
152
|
+
testID: override || key,
|
|
153
|
+
};
|
|
154
|
+
} else {
|
|
155
|
+
return {
|
|
156
|
+
accessibilityLabel: override || key,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
const cleanNameForTracking = (word = ''): string => {
|
|
162
|
+
return word
|
|
163
|
+
.normalize('NFD')
|
|
164
|
+
.replace(/[\u0300-\u036f |\s]/g, '')
|
|
165
|
+
.toLowerCase();
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
const formatComponentName = (word = '') => {
|
|
169
|
+
const accentsMap = {
|
|
170
|
+
a: 'á|à|ả|ã|ạ|â|ấ|ầ|ẩ|ẫ|ậ|ă|ắ|ằ|ẳ|ẵ|ặ',
|
|
171
|
+
A: 'Á|À|Ả|Ã|Ạ|Â|Ấ|Ầ|Ẩ|Ẫ|Ậ|Ă|Ắ|Ằ|Ẳ|Ẵ|Ặ',
|
|
172
|
+
e: 'é|è|ẻ|ẽ|ẹ|ê|ế|ề|ể|ễ|ệ',
|
|
173
|
+
E: 'É|È|Ẻ|Ẽ|Ẹ|Ê|Ế|Ề|Ể|Ễ|Ệ',
|
|
174
|
+
i: 'í|ì|ỉ|ĩ|ị',
|
|
175
|
+
I: 'Í|Ì|Ỉ|Ĩ|Ị',
|
|
176
|
+
o: 'ó|ò|ỏ|õ|ọ|ô|ố|ồ|ổ|ỗ|ộ|ơ|ớ|ờ|ở|ỡ|ợ',
|
|
177
|
+
O: 'Ó|Ò|Ỏ|Õ|Ọ|Ô|Ố|Ồ|Ổ|Ỗ|Ộ|Ơ|Ớ|Ờ|Ở|Ỡ|Ợ',
|
|
178
|
+
u: 'ú|ù|ủ|ũ|ụ|ư|ứ|ừ|ử|ữ|ự',
|
|
179
|
+
U: 'Ú|Ù|Ủ|Ũ|Ụ|Ư|Ứ|Ừ|Ử|Ữ|Ự',
|
|
180
|
+
y: 'ý|ỳ|ỷ|ỹ|ỵ',
|
|
181
|
+
Y: 'Ý|Ỳ|Ỷ|Ỹ|Ỵ',
|
|
182
|
+
d: 'đ',
|
|
183
|
+
D: 'Đ',
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
for (const [nonAccent, accentGroup] of Object.entries(accentsMap)) {
|
|
187
|
+
const accents = new RegExp(accentGroup, 'g');
|
|
188
|
+
word = word.replace(accents, nonAccent);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
word = word.replace(/\s+/g, '_').toLowerCase();
|
|
192
|
+
|
|
193
|
+
return word;
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
const formatNameLength = (name = '') => {
|
|
197
|
+
let formattedName = name;
|
|
198
|
+
if (formattedName.length > 100) {
|
|
199
|
+
formattedName = formattedName.substring(0, 100);
|
|
200
|
+
}
|
|
201
|
+
return formattedName;
|
|
202
|
+
};
|
|
203
|
+
export {
|
|
204
|
+
getStackOptions,
|
|
205
|
+
getDialogOptions,
|
|
206
|
+
getModalOptions,
|
|
207
|
+
getOptions,
|
|
208
|
+
formatComponentName,
|
|
209
|
+
formatNameLength,
|
|
210
|
+
getAccessibilityID,
|
|
211
|
+
cleanNameForTracking,
|
|
212
|
+
};
|
package/Badge/Badge.tsx
CHANGED
|
@@ -46,7 +46,7 @@ const Badge: FC<BadgeProps> = ({label = 'Label', style, backgroundColor}) => {
|
|
|
46
46
|
|
|
47
47
|
return (
|
|
48
48
|
<View style={[style, styles.badge, {backgroundColor: badgeColor}]}>
|
|
49
|
-
<Text color={Colors.black_01} typography={'
|
|
49
|
+
<Text color={Colors.black_01} typography={'action_xxs_bold'}>
|
|
50
50
|
{formatTitle()}
|
|
51
51
|
</Text>
|
|
52
52
|
</View>
|
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,16 @@ 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 {
|
|
18
|
+
cleanNameForTracking,
|
|
19
|
+
formatComponentName,
|
|
20
|
+
getAccessibilityID,
|
|
21
|
+
} from '../Application/utils';
|
|
22
|
+
|
|
23
|
+
const {
|
|
24
|
+
ScreenContext,
|
|
25
|
+
MiniAppContext,
|
|
26
|
+
} = require('react-native/Libraries/Components/ScreenContext');
|
|
18
27
|
|
|
19
28
|
const AnimationLinear = Animated.createAnimatedComponent(LinearGradient);
|
|
20
29
|
|
|
@@ -70,6 +79,10 @@ export interface ButtonProps extends TouchableOpacityProps {
|
|
|
70
79
|
* A callback function that is called when the button is pressed.
|
|
71
80
|
*/
|
|
72
81
|
onPress: () => void;
|
|
82
|
+
|
|
83
|
+
params?: any;
|
|
84
|
+
|
|
85
|
+
componentId?: string;
|
|
73
86
|
}
|
|
74
87
|
|
|
75
88
|
const Button: FC<ButtonProps> = ({
|
|
@@ -82,9 +95,13 @@ const Button: FC<ButtonProps> = ({
|
|
|
82
95
|
loading = false,
|
|
83
96
|
title = 'Button',
|
|
84
97
|
onPress,
|
|
98
|
+
params,
|
|
99
|
+
componentId,
|
|
100
|
+
accessibilityLabel,
|
|
85
101
|
...rest
|
|
86
102
|
}) => {
|
|
87
103
|
const {theme, config} = useContext(ApplicationContext);
|
|
104
|
+
const {appId, code} = useContext<any>(MiniAppContext);
|
|
88
105
|
const {gradient, color} = config?.navigationBar?.buttonColors ?? {};
|
|
89
106
|
let gradientPros;
|
|
90
107
|
if (gradient?.length > 0 && type == 'primary') {
|
|
@@ -94,6 +111,8 @@ const Button: FC<ButtonProps> = ({
|
|
|
94
111
|
end: {x: 0, y: 0.5},
|
|
95
112
|
};
|
|
96
113
|
}
|
|
114
|
+
|
|
115
|
+
const screenInfo = useContext<any>(ScreenContext);
|
|
97
116
|
const getSizeStyle = () => {
|
|
98
117
|
const styleSheet: {[key: string]: any} = styles;
|
|
99
118
|
return styleSheet[size ?? 'small'];
|
|
@@ -291,19 +310,40 @@ const Button: FC<ButtonProps> = ({
|
|
|
291
310
|
const activeOpacity = type === 'disabled' ? 0.75 : 0.5;
|
|
292
311
|
|
|
293
312
|
return (
|
|
294
|
-
<
|
|
295
|
-
{
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
313
|
+
<ScreenContext.Provider
|
|
314
|
+
value={{
|
|
315
|
+
...screenInfo,
|
|
316
|
+
componentName: 'Button',
|
|
317
|
+
params,
|
|
318
|
+
state: loading
|
|
319
|
+
? 'loading'
|
|
320
|
+
: type === 'disabled'
|
|
321
|
+
? 'disabled'
|
|
322
|
+
: 'enabled',
|
|
323
|
+
componentId,
|
|
324
|
+
componentValue: formatComponentName(title),
|
|
325
|
+
action: 'click',
|
|
326
|
+
}}>
|
|
327
|
+
<TouchableOpacity
|
|
328
|
+
{...rest}
|
|
329
|
+
{...getAccessibilityID(
|
|
330
|
+
`${appId}/${code}/${screenInfo.screenName}/btn_${cleanNameForTracking(
|
|
331
|
+
title,
|
|
332
|
+
)}`,
|
|
333
|
+
accessibilityLabel,
|
|
334
|
+
)}
|
|
335
|
+
activeOpacity={activeOpacity}
|
|
336
|
+
onPress={onPressButton}
|
|
337
|
+
style={buttonStyle}>
|
|
338
|
+
{renderLeading()}
|
|
339
|
+
{renderTitle()}
|
|
340
|
+
{renderTrailing()}
|
|
341
|
+
{gradientPros && (
|
|
342
|
+
<AnimationLinear {...gradientPros} style={styles.gradientView} />
|
|
343
|
+
)}
|
|
344
|
+
{gradientPros && <View style={styles.strokeView} />}
|
|
345
|
+
</TouchableOpacity>
|
|
346
|
+
</ScreenContext.Provider>
|
|
307
347
|
);
|
|
308
348
|
};
|
|
309
349
|
|