@momo-kits/foundation 0.92.2 → 0.92.3-tracking.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/BottomTabBar.tsx +1 -2
- package/Application/BottomTab/index.tsx +2 -2
- package/Application/Components.tsx +27 -34
- package/Application/NavigationContainer.tsx +2 -7
- package/Application/StackScreen.tsx +70 -64
- package/Application/index.ts +8 -8
- package/Application/types.ts +1 -1
- package/Application/utils.tsx +0 -37
- package/Button/index.tsx +11 -32
- package/CheckBox/index.tsx +10 -32
- package/CheckBox/types.ts +4 -6
- package/Icon/index.tsx +8 -8
- package/IconButton/index.tsx +8 -21
- package/Image/index.tsx +53 -38
- package/Image/types.ts +2 -0
- package/Input/Input.tsx +7 -35
- package/Input/InputDropDown.tsx +8 -35
- package/Input/InputMoney.tsx +7 -32
- package/Input/InputOTP.tsx +7 -27
- package/Input/InputSearch.tsx +6 -17
- package/Input/InputTextArea.tsx +1 -23
- package/Input/index.tsx +1 -9
- package/Popup/PopupNotify.tsx +5 -9
- package/Popup/PopupPromotion.tsx +6 -15
- package/Radio/index.tsx +9 -27
- package/Radio/types.ts +4 -7
- package/Switch/index.tsx +15 -26
- package/Switch/types.ts +4 -6
- package/Title/index.tsx +18 -10
- package/Title/styles.ts +4 -1
- package/Title/types.ts +4 -0
- package/code-scanner.js +131 -39
- package/migrate_typo.js +56 -0
- package/package.json +1 -1
package/Input/InputSearch.tsx
CHANGED
|
@@ -7,17 +7,11 @@ import {
|
|
|
7
7
|
View,
|
|
8
8
|
} from 'react-native';
|
|
9
9
|
import {InputSearchProps} from './index';
|
|
10
|
-
import {ApplicationContext} from '../Application';
|
|
10
|
+
import {ApplicationContext, ComponentContext} from '../Application';
|
|
11
11
|
import styles from './styles';
|
|
12
12
|
import {Icon} from '../Icon';
|
|
13
13
|
import {Text} from '../Text';
|
|
14
14
|
import {checkTyping} from './utils';
|
|
15
|
-
import {getAccessibilityID} from '../Application/utils';
|
|
16
|
-
|
|
17
|
-
const {
|
|
18
|
-
ScreenContext,
|
|
19
|
-
MiniAppContext,
|
|
20
|
-
} = require('react-native/Libraries/Components/ScreenContext');
|
|
21
15
|
|
|
22
16
|
const InputSearch = forwardRef(
|
|
23
17
|
(
|
|
@@ -35,18 +29,16 @@ const InputSearch = forwardRef(
|
|
|
35
29
|
defaultValue,
|
|
36
30
|
onPressButtonText,
|
|
37
31
|
params,
|
|
38
|
-
componentId,
|
|
39
32
|
hasColorBG = false,
|
|
33
|
+
accessibilityLabel,
|
|
40
34
|
...props
|
|
41
35
|
}: InputSearchProps,
|
|
42
36
|
ref,
|
|
43
37
|
) => {
|
|
44
38
|
const {theme} = useContext(ApplicationContext);
|
|
45
|
-
const {appId, code} = useContext<any>(MiniAppContext);
|
|
46
39
|
const [focused, setFocused] = useState(false);
|
|
47
40
|
const [haveValue, setHaveValue] = useState(!!value || !!defaultValue);
|
|
48
41
|
const inputRef = (ref as React.RefObject<TextInput>) ?? useRef<TextInput>();
|
|
49
|
-
const screenInfo = useContext<any>(ScreenContext);
|
|
50
42
|
|
|
51
43
|
const _onFocus = (e: NativeSyntheticEvent<TextInputFocusEventData>) => {
|
|
52
44
|
setFocused(true);
|
|
@@ -72,9 +64,7 @@ const InputSearch = forwardRef(
|
|
|
72
64
|
return (
|
|
73
65
|
<TextInput
|
|
74
66
|
{...props}
|
|
75
|
-
{
|
|
76
|
-
`${appId}/${code}/${screenInfo.screenName}/input_search`,
|
|
77
|
-
)}
|
|
67
|
+
accessibilityLabel={accessibilityLabel}
|
|
78
68
|
textAlignVertical="center"
|
|
79
69
|
ref={inputRef}
|
|
80
70
|
style={[
|
|
@@ -145,13 +135,12 @@ const InputSearch = forwardRef(
|
|
|
145
135
|
: theme.colors.background.surface;
|
|
146
136
|
|
|
147
137
|
return (
|
|
148
|
-
<
|
|
138
|
+
<ComponentContext.Provider
|
|
149
139
|
value={{
|
|
150
|
-
...screenInfo,
|
|
151
140
|
componentName: 'InputSearch',
|
|
152
141
|
params,
|
|
153
142
|
state: inputState,
|
|
154
|
-
componentId,
|
|
143
|
+
componentId: accessibilityLabel,
|
|
155
144
|
}}>
|
|
156
145
|
<View style={[style, styles.searchInputContainer]}>
|
|
157
146
|
<View
|
|
@@ -179,7 +168,7 @@ const InputSearch = forwardRef(
|
|
|
179
168
|
</TouchableOpacity>
|
|
180
169
|
)}
|
|
181
170
|
</View>
|
|
182
|
-
</
|
|
171
|
+
</ComponentContext.Provider>
|
|
183
172
|
);
|
|
184
173
|
},
|
|
185
174
|
);
|
package/Input/InputTextArea.tsx
CHANGED
|
@@ -18,12 +18,6 @@ import {
|
|
|
18
18
|
import {InputTextAreaProps} from './index';
|
|
19
19
|
import {Icon} from '../Icon';
|
|
20
20
|
import {ApplicationContext} from '../Application';
|
|
21
|
-
import {cleanNameForTracking, getAccessibilityID} from '../Application/utils';
|
|
22
|
-
|
|
23
|
-
const {
|
|
24
|
-
ScreenContext,
|
|
25
|
-
MiniAppContext,
|
|
26
|
-
} = require('react-native/Libraries/Components/ScreenContext');
|
|
27
21
|
|
|
28
22
|
const InputTextArea = forwardRef(
|
|
29
23
|
(
|
|
@@ -44,13 +38,12 @@ const InputTextArea = forwardRef(
|
|
|
44
38
|
required,
|
|
45
39
|
errorSpacing,
|
|
46
40
|
style,
|
|
41
|
+
accessibilityLabel,
|
|
47
42
|
...props
|
|
48
43
|
}: InputTextAreaProps,
|
|
49
44
|
ref,
|
|
50
45
|
) => {
|
|
51
46
|
const {theme} = useContext(ApplicationContext);
|
|
52
|
-
const screenInfo = useContext<any>(ScreenContext);
|
|
53
|
-
const {appId, code} = useContext<any>(MiniAppContext);
|
|
54
47
|
const [focused, setFocused] = useState(false);
|
|
55
48
|
const [inputValue, setInputValue] = useState(defaultValue ?? '');
|
|
56
49
|
const inputRef = (ref as React.RefObject<TextInput>) ?? useRef<TextInput>();
|
|
@@ -96,20 +89,6 @@ const InputTextArea = forwardRef(
|
|
|
96
89
|
placeholderColor = disabledColor;
|
|
97
90
|
}
|
|
98
91
|
|
|
99
|
-
const accessibilityID = disabled
|
|
100
|
-
? getAccessibilityID(
|
|
101
|
-
`${appId}/${code}/${
|
|
102
|
-
screenInfo.screenName
|
|
103
|
-
}/input_${cleanNameForTracking(
|
|
104
|
-
floatingValue ?? placeholder,
|
|
105
|
-
)}_disabled`,
|
|
106
|
-
)
|
|
107
|
-
: getAccessibilityID(
|
|
108
|
-
`${appId}/${code}/${
|
|
109
|
-
screenInfo.screenName
|
|
110
|
-
}/input_${cleanNameForTracking(floatingValue ?? placeholder)}`,
|
|
111
|
-
);
|
|
112
|
-
|
|
113
92
|
return (
|
|
114
93
|
<View
|
|
115
94
|
style={[
|
|
@@ -131,7 +110,6 @@ const InputTextArea = forwardRef(
|
|
|
131
110
|
<View style={styles.textAreaView}>
|
|
132
111
|
<TextInput
|
|
133
112
|
{...props}
|
|
134
|
-
{...accessibilityID}
|
|
135
113
|
ref={inputRef}
|
|
136
114
|
editable={!disabled}
|
|
137
115
|
textAlignVertical="top"
|
package/Input/index.tsx
CHANGED
|
@@ -82,7 +82,6 @@ export interface InputProps extends TextInputProps {
|
|
|
82
82
|
onPressIcon?: () => void;
|
|
83
83
|
|
|
84
84
|
params?: any;
|
|
85
|
-
componentId?: string;
|
|
86
85
|
}
|
|
87
86
|
|
|
88
87
|
type InputPropsWithoutSizeAndIcon = Omit<
|
|
@@ -130,8 +129,6 @@ export interface InputSearchProps extends TextInputProps {
|
|
|
130
129
|
hasColorBG?: boolean;
|
|
131
130
|
|
|
132
131
|
params?: any;
|
|
133
|
-
|
|
134
|
-
componentId?: string;
|
|
135
132
|
}
|
|
136
133
|
|
|
137
134
|
export interface InputMoneyProps extends InputPropsWithoutPlaceholder {}
|
|
@@ -169,7 +166,7 @@ export type CaretProps = {
|
|
|
169
166
|
length?: number;
|
|
170
167
|
};
|
|
171
168
|
|
|
172
|
-
export interface InputDropDownProps {
|
|
169
|
+
export interface InputDropDownProps extends InputProps {
|
|
173
170
|
/**
|
|
174
171
|
* Optional. Defines the size of the InputDropDown component.
|
|
175
172
|
* 'small' - A smaller, less prominent input.
|
|
@@ -264,11 +261,6 @@ export interface InputDropDownProps {
|
|
|
264
261
|
[key: string]: any;
|
|
265
262
|
};
|
|
266
263
|
|
|
267
|
-
/**
|
|
268
|
-
* component id for element tracking.
|
|
269
|
-
*/
|
|
270
|
-
componentId?: string;
|
|
271
|
-
|
|
272
264
|
/**
|
|
273
265
|
* Optional. Represents the style of the InputDropDown component.
|
|
274
266
|
*/
|
package/Popup/PopupNotify.tsx
CHANGED
|
@@ -4,14 +4,9 @@ import {PopupNotifyProps} from './types';
|
|
|
4
4
|
import {Radius, Spacing, Styles} from '../Consts';
|
|
5
5
|
import {Image} from '../Image';
|
|
6
6
|
import {Text} from '../Text';
|
|
7
|
-
import {ApplicationContext} from '../Application';
|
|
7
|
+
import {ApplicationContext, MiniAppContext} from '../Application';
|
|
8
8
|
import {Button} from '../Button';
|
|
9
9
|
import {Icon} from '../Icon';
|
|
10
|
-
import {getAccessibilityID} from '../Application/utils';
|
|
11
|
-
|
|
12
|
-
const {
|
|
13
|
-
MiniAppContext,
|
|
14
|
-
} = require('react-native/Libraries/Components/ScreenContext');
|
|
15
10
|
|
|
16
11
|
const PopupNotify: React.FC<PopupNotifyProps> = ({
|
|
17
12
|
id,
|
|
@@ -47,7 +42,8 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
|
|
|
47
42
|
screen_name = routes[routesLength - 2]?.params?.screen?.name;
|
|
48
43
|
}
|
|
49
44
|
const tracking = {
|
|
50
|
-
|
|
45
|
+
appId: context.appId,
|
|
46
|
+
code: context.code,
|
|
51
47
|
screen_name,
|
|
52
48
|
component_type: 'popup',
|
|
53
49
|
component_name: id,
|
|
@@ -166,7 +162,7 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
|
|
|
166
162
|
const buildCloseIcon = () => {
|
|
167
163
|
return (
|
|
168
164
|
<TouchableOpacity
|
|
169
|
-
{
|
|
165
|
+
accessibilityLabel={'ic_popup_close'}
|
|
170
166
|
style={styles.iconCloseContainer}
|
|
171
167
|
onPress={() => {
|
|
172
168
|
closeAction.current = 'icon_close';
|
|
@@ -192,7 +188,7 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
|
|
|
192
188
|
|
|
193
189
|
return (
|
|
194
190
|
<View
|
|
195
|
-
{
|
|
191
|
+
accessibilityLabel={'PopupNotify'}
|
|
196
192
|
style={[
|
|
197
193
|
styles.container,
|
|
198
194
|
{backgroundColor: theme.colors.background.surface},
|
package/Popup/PopupPromotion.tsx
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
import React, {useContext, useEffect, useRef} from 'react';
|
|
2
2
|
import {StyleSheet, TouchableOpacity, View} from 'react-native';
|
|
3
3
|
import {PopupPromotionProps} from './types';
|
|
4
|
-
import {ApplicationContext} from '../Application';
|
|
4
|
+
import {ApplicationContext, MiniAppContext} from '../Application';
|
|
5
5
|
import {Image} from '../Image';
|
|
6
6
|
import {Radius, Spacing} from '../Consts';
|
|
7
7
|
import {Icon} from '../Icon';
|
|
8
|
-
import {getAccessibilityID} from '../Application/utils';
|
|
9
|
-
|
|
10
|
-
const {
|
|
11
|
-
MiniAppContext,
|
|
12
|
-
} = require('react-native/Libraries/Components/ScreenContext');
|
|
13
8
|
|
|
14
9
|
const PopupPromotion: React.FC<PopupPromotionProps> = ({
|
|
15
10
|
id,
|
|
@@ -31,7 +26,8 @@ const PopupPromotion: React.FC<PopupPromotionProps> = ({
|
|
|
31
26
|
screen_name = routes[routesLength - 2]?.params?.screen?.name;
|
|
32
27
|
}
|
|
33
28
|
const tracking = {
|
|
34
|
-
|
|
29
|
+
appId: context.appId,
|
|
30
|
+
code: context.code,
|
|
35
31
|
screen_name,
|
|
36
32
|
component_type: 'popup',
|
|
37
33
|
component_name: id,
|
|
@@ -54,10 +50,9 @@ const PopupPromotion: React.FC<PopupPromotionProps> = ({
|
|
|
54
50
|
*/
|
|
55
51
|
const buildCloseIcon = () => {
|
|
56
52
|
return (
|
|
57
|
-
<View
|
|
58
|
-
{...getAccessibilityID?.('ic_popup_close')}
|
|
59
|
-
style={styles.iconCloseContainer}>
|
|
53
|
+
<View style={styles.iconCloseContainer}>
|
|
60
54
|
<TouchableOpacity
|
|
55
|
+
accessibilityLabel={'ic_popup_close'}
|
|
61
56
|
onPress={() => {
|
|
62
57
|
closeAction.current = 'icon_close';
|
|
63
58
|
navigator?.pop();
|
|
@@ -84,7 +79,7 @@ const PopupPromotion: React.FC<PopupPromotionProps> = ({
|
|
|
84
79
|
};
|
|
85
80
|
|
|
86
81
|
return (
|
|
87
|
-
<View {
|
|
82
|
+
<View accessibilityLabel={'PopupPromotion'}>
|
|
88
83
|
<Image
|
|
89
84
|
source={{
|
|
90
85
|
uri: image,
|
|
@@ -120,8 +115,4 @@ const styles = StyleSheet.create({
|
|
|
120
115
|
},
|
|
121
116
|
});
|
|
122
117
|
|
|
123
|
-
PopupPromotion.defaultProps = {
|
|
124
|
-
image: 'https://google.com',
|
|
125
|
-
};
|
|
126
|
-
|
|
127
118
|
export default PopupPromotion;
|
package/Radio/index.tsx
CHANGED
|
@@ -4,18 +4,9 @@ import {TouchableOpacity, View} from 'react-native';
|
|
|
4
4
|
import {RadioProps} from './types';
|
|
5
5
|
import {Text} from '../Text';
|
|
6
6
|
import styles from './styles';
|
|
7
|
-
import {ApplicationContext} from '../Application';
|
|
7
|
+
import {ApplicationContext, ComponentContext} from '../Application';
|
|
8
8
|
import {Spacing} from '../Consts';
|
|
9
|
-
import {
|
|
10
|
-
cleanNameForTracking,
|
|
11
|
-
formatNameLength,
|
|
12
|
-
getAccessibilityID,
|
|
13
|
-
} from '../Application/utils';
|
|
14
|
-
|
|
15
|
-
const {
|
|
16
|
-
ScreenContext,
|
|
17
|
-
MiniAppContext,
|
|
18
|
-
} = require('react-native/Libraries/Components/ScreenContext');
|
|
9
|
+
import {formatNameLength} from '../Application/utils';
|
|
19
10
|
|
|
20
11
|
const Radio: FC<RadioProps> = ({
|
|
21
12
|
value,
|
|
@@ -25,11 +16,9 @@ const Radio: FC<RadioProps> = ({
|
|
|
25
16
|
label,
|
|
26
17
|
style,
|
|
27
18
|
params,
|
|
28
|
-
|
|
19
|
+
accessibilityLabel,
|
|
29
20
|
}) => {
|
|
30
|
-
const {appId, code} = useContext<any>(MiniAppContext);
|
|
31
21
|
const {theme} = useContext(ApplicationContext);
|
|
32
|
-
const screenInfo = useContext<any>(ScreenContext);
|
|
33
22
|
const selected = value === groupValue;
|
|
34
23
|
let disabledStyle = {};
|
|
35
24
|
let checkBoxStyle = {
|
|
@@ -51,26 +40,19 @@ const Radio: FC<RadioProps> = ({
|
|
|
51
40
|
};
|
|
52
41
|
}
|
|
53
42
|
|
|
54
|
-
const accessibilityID = getAccessibilityID?.(
|
|
55
|
-
`${appId}/${code}/${screenInfo.screenName}/rdo_${cleanNameForTracking(
|
|
56
|
-
label,
|
|
57
|
-
)}_${selected}`,
|
|
58
|
-
);
|
|
59
|
-
|
|
60
43
|
return (
|
|
61
|
-
<
|
|
44
|
+
<ComponentContext.Provider
|
|
62
45
|
value={{
|
|
63
|
-
|
|
64
|
-
componentName: 'Button',
|
|
46
|
+
componentName: 'Radio',
|
|
65
47
|
params,
|
|
66
48
|
state: disabled ? 'disabled' : 'enabled',
|
|
67
|
-
componentId,
|
|
49
|
+
componentId: accessibilityLabel,
|
|
68
50
|
componentLabel: formatNameLength(label || ''),
|
|
69
|
-
componentValue:
|
|
51
|
+
componentValue: selected,
|
|
70
52
|
action: 'click',
|
|
71
53
|
}}>
|
|
72
54
|
<TouchableOpacity
|
|
73
|
-
{
|
|
55
|
+
accessibilityLabel={accessibilityLabel}
|
|
74
56
|
onPress={onChange}
|
|
75
57
|
disabled={disabled}
|
|
76
58
|
style={[
|
|
@@ -90,7 +72,7 @@ const Radio: FC<RadioProps> = ({
|
|
|
90
72
|
/>
|
|
91
73
|
{!!label && <Text typography={'body_default_regular'}>{label}</Text>}
|
|
92
74
|
</TouchableOpacity>
|
|
93
|
-
</
|
|
75
|
+
</ComponentContext.Provider>
|
|
94
76
|
);
|
|
95
77
|
};
|
|
96
78
|
|
package/Radio/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 RadioProps extends TouchableOpacityProps {
|
|
4
4
|
/**
|
|
5
5
|
* `value`: Represents the value associated with the Radio component.
|
|
6
6
|
* It is used to determine whether the Radio component is selected or not in comparison with the `groupValue`.
|
|
@@ -36,8 +36,5 @@ export type RadioProps = {
|
|
|
36
36
|
*/
|
|
37
37
|
style?: ViewStyle;
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
componentId?: string
|
|
43
|
-
};
|
|
39
|
+
params?: any;
|
|
40
|
+
}
|
package/Switch/index.tsx
CHANGED
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
import React, {FC
|
|
1
|
+
import React, {FC} from 'react';
|
|
2
2
|
import {TouchableOpacity, View} from 'react-native';
|
|
3
3
|
import {SwitchProps} from './types';
|
|
4
4
|
import styles from './styles';
|
|
5
5
|
import {Colors} from '../Consts';
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
const {
|
|
9
|
-
ScreenContext,
|
|
10
|
-
MiniAppContext,
|
|
11
|
-
} = require('react-native/Libraries/Components/ScreenContext');
|
|
12
|
-
|
|
13
|
-
const Switch: FC<SwitchProps> = props => {
|
|
14
|
-
const {appId, code} = useContext<any>(MiniAppContext);
|
|
15
|
-
const {value, onChange, disabled, style, params, componentId} = props;
|
|
16
|
-
const screenInfo = useContext<any>(ScreenContext);
|
|
6
|
+
import {ComponentContext} from '../Application';
|
|
17
7
|
|
|
8
|
+
const Switch: FC<SwitchProps> = ({
|
|
9
|
+
value = false,
|
|
10
|
+
onChange,
|
|
11
|
+
disabled = false,
|
|
12
|
+
style,
|
|
13
|
+
params,
|
|
14
|
+
accessibilityLabel,
|
|
15
|
+
}) => {
|
|
18
16
|
const circleBackgroundColor = value ? Colors.black_01 : Colors.black_03;
|
|
19
17
|
const circleAlign = value ? 'flex-end' : 'flex-start';
|
|
20
18
|
|
|
@@ -23,24 +21,19 @@ const Switch: FC<SwitchProps> = props => {
|
|
|
23
21
|
backgroundColor = value ? Colors.green_09 : Colors.black_05;
|
|
24
22
|
}
|
|
25
23
|
|
|
26
|
-
const accessibilityID = getAccessibilityID?.(
|
|
27
|
-
`${appId}/${code}/${screenInfo.screenName}/swt_${value}`,
|
|
28
|
-
);
|
|
29
|
-
|
|
30
24
|
return (
|
|
31
|
-
<
|
|
25
|
+
<ComponentContext.Provider
|
|
32
26
|
value={{
|
|
33
|
-
|
|
34
|
-
componentName: 'Button',
|
|
27
|
+
componentName: 'Switch',
|
|
35
28
|
params,
|
|
36
29
|
state: disabled ? 'disabled' : 'enabled',
|
|
37
|
-
componentId,
|
|
30
|
+
componentId: accessibilityLabel,
|
|
38
31
|
componentValue: value,
|
|
39
32
|
action: 'click',
|
|
40
33
|
}}>
|
|
41
34
|
<TouchableOpacity
|
|
42
|
-
{...accessibilityID}
|
|
43
35
|
disabled={disabled}
|
|
36
|
+
accessibilityLabel={accessibilityLabel}
|
|
44
37
|
onPress={() => onChange?.(!value)}
|
|
45
38
|
style={[
|
|
46
39
|
style,
|
|
@@ -51,12 +44,8 @@ const Switch: FC<SwitchProps> = props => {
|
|
|
51
44
|
<View style={[styles.circleSmall, {backgroundColor}]} />
|
|
52
45
|
</View>
|
|
53
46
|
</TouchableOpacity>
|
|
54
|
-
</
|
|
47
|
+
</ComponentContext.Provider>
|
|
55
48
|
);
|
|
56
49
|
};
|
|
57
50
|
|
|
58
|
-
Switch.defaultProps = {
|
|
59
|
-
value: false,
|
|
60
|
-
disabled: false,
|
|
61
|
-
};
|
|
62
51
|
export {Switch};
|
package/Switch/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 SwitchProps extends TouchableOpacityProps {
|
|
4
4
|
/**
|
|
5
5
|
* `value`: Represents whether the Switch component is currently in the 'on' (`true`) or 'off' (`false`) state.
|
|
6
6
|
*/
|
|
@@ -24,7 +24,5 @@ export type SwitchProps = {
|
|
|
24
24
|
*/
|
|
25
25
|
style?: ViewStyle;
|
|
26
26
|
|
|
27
|
-
params?: any
|
|
28
|
-
|
|
29
|
-
componentId?: string
|
|
30
|
-
};
|
|
27
|
+
params?: any;
|
|
28
|
+
}
|
package/Title/index.tsx
CHANGED
|
@@ -22,8 +22,10 @@ const Title: FC<TitleProps> = ({
|
|
|
22
22
|
badgeLabel,
|
|
23
23
|
buttonTitle,
|
|
24
24
|
onPressRightAction = () => {},
|
|
25
|
+
onPressTrailingAction = () => {},
|
|
25
26
|
buttonSize = 'small',
|
|
26
27
|
textOnly = false,
|
|
28
|
+
style,
|
|
27
29
|
}) => {
|
|
28
30
|
const {theme} = useContext(ApplicationContext);
|
|
29
31
|
const [badgeWidth, setBadgeWidth] = useState(0);
|
|
@@ -90,18 +92,23 @@ const Title: FC<TitleProps> = ({
|
|
|
90
92
|
)}
|
|
91
93
|
{renderActionLeft()}
|
|
92
94
|
</View>
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
95
|
+
{description && (
|
|
96
|
+
<Text
|
|
97
|
+
style={styles.description}
|
|
98
|
+
color={theme.colors.text.secondary}
|
|
99
|
+
typography={'description_default_regular'}>
|
|
100
|
+
{description}
|
|
101
|
+
</Text>
|
|
102
|
+
)}
|
|
98
103
|
</View>
|
|
99
104
|
);
|
|
100
105
|
};
|
|
101
106
|
|
|
102
107
|
const renderActionLeft = () => {
|
|
103
108
|
return (
|
|
104
|
-
<
|
|
109
|
+
<TouchableOpacity
|
|
110
|
+
onPress={onPressTrailingAction}
|
|
111
|
+
style={styles.iconLeftView}>
|
|
105
112
|
{showTrailingAction && !showRightAction && (
|
|
106
113
|
<View
|
|
107
114
|
style={[
|
|
@@ -119,7 +126,7 @@ const Title: FC<TitleProps> = ({
|
|
|
119
126
|
/>
|
|
120
127
|
</View>
|
|
121
128
|
)}
|
|
122
|
-
</
|
|
129
|
+
</TouchableOpacity>
|
|
123
130
|
);
|
|
124
131
|
};
|
|
125
132
|
|
|
@@ -129,7 +136,8 @@ const Title: FC<TitleProps> = ({
|
|
|
129
136
|
return (
|
|
130
137
|
<View>
|
|
131
138
|
{!buttonTitle ? (
|
|
132
|
-
<
|
|
139
|
+
<TouchableOpacity
|
|
140
|
+
onPress={onPressRightAction}
|
|
133
141
|
style={[
|
|
134
142
|
styles.iconRight,
|
|
135
143
|
{
|
|
@@ -141,7 +149,7 @@ const Title: FC<TitleProps> = ({
|
|
|
141
149
|
size={scaleSize(22)}
|
|
142
150
|
color={theme.colors.primary}
|
|
143
151
|
/>
|
|
144
|
-
</
|
|
152
|
+
</TouchableOpacity>
|
|
145
153
|
) : (
|
|
146
154
|
<TouchableOpacity onPress={onPressRightAction}>
|
|
147
155
|
<Text color={theme.colors.primary} typography={buttonTypo}>
|
|
@@ -166,7 +174,7 @@ const Title: FC<TitleProps> = ({
|
|
|
166
174
|
}
|
|
167
175
|
|
|
168
176
|
return (
|
|
169
|
-
<View style={[styles.wrapper, isSection && styles.margin]}>
|
|
177
|
+
<View style={[style, styles.wrapper, isSection && styles.margin]}>
|
|
170
178
|
{renderIcon()}
|
|
171
179
|
{renderContent()}
|
|
172
180
|
{renderActionRight()}
|
package/Title/styles.ts
CHANGED
|
@@ -68,9 +68,12 @@ export default StyleSheet.create({
|
|
|
68
68
|
contentView: {marginRight: Spacing.S, flex: 1},
|
|
69
69
|
title: {
|
|
70
70
|
fontWeight: 'bold',
|
|
71
|
-
|
|
71
|
+
color: Colors.black_17,
|
|
72
72
|
},
|
|
73
73
|
badge: {
|
|
74
74
|
marginLeft: Spacing.XS,
|
|
75
75
|
},
|
|
76
|
+
description: {
|
|
77
|
+
marginTop: Spacing.XS,
|
|
78
|
+
},
|
|
76
79
|
});
|
package/Title/types.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import {ViewStyle} from 'react-native';
|
|
2
|
+
|
|
1
3
|
export type TitleProps = {
|
|
2
4
|
type?: 'card' | 'section';
|
|
3
5
|
size?: 'small' | 'medium' | 'large';
|
|
@@ -12,5 +14,7 @@ export type TitleProps = {
|
|
|
12
14
|
buttonTitle?: string;
|
|
13
15
|
buttonSize?: 'small' | 'large';
|
|
14
16
|
onPressRightAction?: () => void;
|
|
17
|
+
onPressTrailingAction?: () => void;
|
|
15
18
|
textOnly?: boolean;
|
|
19
|
+
style?: ViewStyle;
|
|
16
20
|
};
|