@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
package/Title/index.tsx
CHANGED
|
@@ -1,129 +1,135 @@
|
|
|
1
|
-
import React, {FC, useContext
|
|
2
|
-
import {
|
|
3
|
-
LayoutChangeEvent,
|
|
4
|
-
NativeSyntheticEvent,
|
|
5
|
-
Text as RNText,
|
|
6
|
-
TextLayoutEventData,
|
|
7
|
-
TouchableOpacity,
|
|
8
|
-
View,
|
|
9
|
-
} from 'react-native';
|
|
10
|
-
import {TitleProps} from './types';
|
|
11
|
-
import {Icon} from '../Icon';
|
|
1
|
+
import React, {FC, useContext} from 'react';
|
|
2
|
+
import {Text as RNText, TouchableOpacity, View, ViewStyle} from 'react-native';
|
|
12
3
|
import styles from './styles';
|
|
13
|
-
import {
|
|
14
|
-
import {Colors, Spacing} from '../Consts';
|
|
4
|
+
import {Icon} from '../Icon';
|
|
15
5
|
import {scaleSize, Text} from '../Text';
|
|
6
|
+
import {ApplicationContext} from '../Application';
|
|
7
|
+
import {Badge} from '../Badge';
|
|
8
|
+
import {Typography} from '../Text/types';
|
|
9
|
+
import {TitleProps} from './types';
|
|
16
10
|
|
|
17
11
|
const Title: FC<TitleProps> = ({
|
|
18
|
-
size = 'large',
|
|
19
|
-
type = 'section',
|
|
20
|
-
onPressAction,
|
|
21
|
-
actionTitle,
|
|
22
12
|
title = 'Title',
|
|
23
|
-
|
|
24
|
-
|
|
13
|
+
type = 'section',
|
|
14
|
+
size = 'medium',
|
|
25
15
|
icon,
|
|
26
16
|
description,
|
|
27
|
-
|
|
17
|
+
iconColor = null,
|
|
18
|
+
iconAlign = 'top',
|
|
19
|
+
showRightAction = false,
|
|
20
|
+
showLeftAction = false,
|
|
21
|
+
badgeLabel,
|
|
22
|
+
buttonTitle,
|
|
23
|
+
onPressRightAction = () => {},
|
|
24
|
+
buttonSize = 'small',
|
|
28
25
|
}) => {
|
|
29
26
|
const {theme} = useContext(ApplicationContext);
|
|
30
|
-
const [containerWidth, setContainerWidth] = useState(0);
|
|
31
|
-
const [textLines, setTextLines] = useState(0);
|
|
32
|
-
const typeStyle =
|
|
33
|
-
type === 'screen' ? styles.screen : styles[`${type}_${size}`];
|
|
34
|
-
const titleWeight = type === 'screen' ? 'Semibold' : 'Bold';
|
|
35
|
-
const marginStyle =
|
|
36
|
-
type === 'section' && usePadding ? {marginTop: Spacing.S} : {};
|
|
37
|
-
const numberOfLines = type === 'section' ? 1 : 2;
|
|
38
27
|
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
28
|
+
const styleSheet: {
|
|
29
|
+
[key: string]: any;
|
|
30
|
+
} = styles;
|
|
31
|
+
const typography = `${type}_${size}`;
|
|
32
|
+
const isSection = type === 'section';
|
|
33
|
+
const numberOfLines = showLeftAction || !!badgeLabel ? 1 : 2;
|
|
34
|
+
const buttonTypo: Typography =
|
|
35
|
+
buttonSize === 'small' ? 'action_xs_bold' : 'action_s_bold';
|
|
36
|
+
|
|
37
|
+
const renderIcon = () => {
|
|
38
|
+
if (!icon) return null;
|
|
39
|
+
|
|
40
|
+
let iconStyle: ViewStyle = {
|
|
41
|
+
justifyContent: 'flex-start',
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
if (iconAlign === 'middle') {
|
|
45
|
+
iconStyle = {justifyContent: 'center'};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (iconAlign === 'bottom') {
|
|
49
|
+
iconStyle = {justifyContent: 'flex-end'};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<View style={[styles.iconView, iconStyle]}>
|
|
54
|
+
<Icon color={iconColor} source={icon} />
|
|
55
|
+
</View>
|
|
60
56
|
);
|
|
61
57
|
};
|
|
62
58
|
|
|
63
|
-
const
|
|
64
|
-
if (textLines > 1) return null;
|
|
59
|
+
const renderContent = () => {
|
|
65
60
|
return (
|
|
66
|
-
<
|
|
67
|
-
style={[
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
61
|
+
<View style={styles.contentView}>
|
|
62
|
+
<View style={[styles.iconLeftView]}>
|
|
63
|
+
<RNText
|
|
64
|
+
numberOfLines={numberOfLines}
|
|
65
|
+
style={[styleSheet[typography], styles.title]}>
|
|
66
|
+
{title}
|
|
67
|
+
</RNText>
|
|
68
|
+
|
|
69
|
+
<View style={{alignItems: 'center'}}>
|
|
70
|
+
{badgeLabel && <Badge style={styles.badge} label={badgeLabel} />}
|
|
71
|
+
</View>
|
|
72
|
+
{renderActionLeft()}
|
|
73
|
+
</View>
|
|
74
|
+
<Text
|
|
75
|
+
color={theme.colors.text.secondary}
|
|
76
|
+
typography={'description_default_regular'}>
|
|
77
|
+
{description}
|
|
78
|
+
</Text>
|
|
79
|
+
</View>
|
|
79
80
|
);
|
|
80
81
|
};
|
|
81
|
-
const onLayout = (e: LayoutChangeEvent) => {
|
|
82
|
-
setContainerWidth(e.nativeEvent.layout.width);
|
|
83
|
-
};
|
|
84
82
|
|
|
85
|
-
const
|
|
86
|
-
|
|
83
|
+
const renderActionLeft = () => {
|
|
84
|
+
return (
|
|
85
|
+
<View style={styles.iconLeftView}>
|
|
86
|
+
{showLeftAction && !showRightAction && (
|
|
87
|
+
<View style={styles.iconLeft}>
|
|
88
|
+
<Icon
|
|
89
|
+
source={'arrow_chevron_right_small'}
|
|
90
|
+
size={scaleSize(18)}
|
|
91
|
+
color={theme.colors.text.default}
|
|
92
|
+
/>
|
|
93
|
+
</View>
|
|
94
|
+
)}
|
|
95
|
+
</View>
|
|
96
|
+
);
|
|
87
97
|
};
|
|
88
98
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
<View style={styles.textContent}>
|
|
99
|
+
const renderActionRight = () => {
|
|
100
|
+
if (!showRightAction || showLeftAction) return false;
|
|
101
|
+
|
|
102
|
+
return (
|
|
103
|
+
<View>
|
|
104
|
+
{!buttonTitle ? (
|
|
96
105
|
<View
|
|
97
|
-
style={
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
color: theme.colors.text.default,
|
|
109
|
-
marginRight: Spacing.S,
|
|
110
|
-
},
|
|
111
|
-
]}>
|
|
112
|
-
{title}
|
|
113
|
-
</RNText>
|
|
114
|
-
{!titleFlex && renderSemiAction()}
|
|
106
|
+
style={[
|
|
107
|
+
styles.iconRight,
|
|
108
|
+
{
|
|
109
|
+
backgroundColor: theme.colors.primary + '0F',
|
|
110
|
+
},
|
|
111
|
+
]}>
|
|
112
|
+
<Icon
|
|
113
|
+
source={'arrow_chevron_right_small'}
|
|
114
|
+
size={scaleSize(22)}
|
|
115
|
+
color={theme.colors.primary}
|
|
116
|
+
/>
|
|
115
117
|
</View>
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
color={theme.colors.text.secondary}>
|
|
121
|
-
{description}
|
|
118
|
+
) : (
|
|
119
|
+
<TouchableOpacity onPress={onPressRightAction}>
|
|
120
|
+
<Text color={theme.colors.primary} typography={buttonTypo}>
|
|
121
|
+
{buttonTitle}
|
|
122
122
|
</Text>
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
{showAction && titleFlex && type !== 'screen' && renderAction()}
|
|
123
|
+
</TouchableOpacity>
|
|
124
|
+
)}
|
|
126
125
|
</View>
|
|
126
|
+
);
|
|
127
|
+
};
|
|
128
|
+
return (
|
|
129
|
+
<View style={[styles.wrapper, isSection && styles.margin]}>
|
|
130
|
+
{renderIcon()}
|
|
131
|
+
{renderContent()}
|
|
132
|
+
{renderActionRight()}
|
|
127
133
|
</View>
|
|
128
134
|
);
|
|
129
135
|
};
|
package/Title/styles.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {StyleSheet} from 'react-native';
|
|
2
2
|
import {scaleSize} from '../Text';
|
|
3
|
-
import {Radius, Spacing} from '../Consts';
|
|
3
|
+
import {Colors, Radius, Spacing} from '../Consts';
|
|
4
4
|
|
|
5
5
|
export default StyleSheet.create({
|
|
6
6
|
card_small: {
|
|
@@ -27,10 +27,6 @@ export default StyleSheet.create({
|
|
|
27
27
|
fontSize: scaleSize(24),
|
|
28
28
|
lineHeight: scaleSize(34),
|
|
29
29
|
},
|
|
30
|
-
screen: {
|
|
31
|
-
fontSize: scaleSize(36),
|
|
32
|
-
lineHeight: scaleSize(44),
|
|
33
|
-
},
|
|
34
30
|
actionIcon: {
|
|
35
31
|
borderRadius: Radius.M,
|
|
36
32
|
alignItems: 'center',
|
|
@@ -41,12 +37,42 @@ export default StyleSheet.create({
|
|
|
41
37
|
borderRadius: Radius.XS,
|
|
42
38
|
},
|
|
43
39
|
wrapper: {
|
|
44
|
-
width: '100%',
|
|
45
40
|
flexDirection: 'row',
|
|
46
|
-
alignItems: 'center',
|
|
47
41
|
},
|
|
48
|
-
|
|
42
|
+
margin: {
|
|
43
|
+
marginTop: Spacing.S,
|
|
44
|
+
},
|
|
45
|
+
iconView: {
|
|
49
46
|
marginRight: Spacing.S,
|
|
47
|
+
},
|
|
48
|
+
iconRight: {
|
|
49
|
+
width: scaleSize(22),
|
|
50
|
+
height: scaleSize(22),
|
|
51
|
+
borderRadius: Radius.M,
|
|
52
|
+
alignItems: 'center',
|
|
53
|
+
justifyContent: 'center',
|
|
54
|
+
marginLeft: Spacing.S,
|
|
55
|
+
},
|
|
56
|
+
iconLeft: {
|
|
57
|
+
width: scaleSize(18),
|
|
58
|
+
height: scaleSize(18),
|
|
59
|
+
borderRadius: Radius.M,
|
|
60
|
+
alignItems: 'center',
|
|
61
|
+
justifyContent: 'center',
|
|
62
|
+
marginHorizontal: Spacing.XS,
|
|
63
|
+
backgroundColor: Colors.black_06,
|
|
64
|
+
},
|
|
65
|
+
iconLeftView: {
|
|
66
|
+
flexDirection: 'row',
|
|
67
|
+
alignItems: 'center',
|
|
68
|
+
},
|
|
69
|
+
contentView: {marginRight: Spacing.S, flex: 1},
|
|
70
|
+
title: {
|
|
71
|
+
fontWeight: 'bold',
|
|
72
|
+
marginBottom: Spacing.XS,
|
|
50
73
|
flex: 1,
|
|
51
74
|
},
|
|
75
|
+
badge: {
|
|
76
|
+
marginLeft: Spacing.XS,
|
|
77
|
+
},
|
|
52
78
|
});
|
package/Title/types.ts
CHANGED
|
@@ -1,52 +1,15 @@
|
|
|
1
1
|
export type TitleProps = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* 'screen' - Used for screen titles.
|
|
5
|
-
* 'section' - Used for section titles within a screen.
|
|
6
|
-
* 'card' - Used for titles within a card component.
|
|
7
|
-
*/
|
|
8
|
-
type?: 'screen' | 'section' | 'card';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Required. The text of the title.
|
|
12
|
-
*/
|
|
2
|
+
type?: 'card' | 'section';
|
|
3
|
+
size?: 'small' | 'medium' | 'large';
|
|
13
4
|
title: string;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Optional. A description or subtitle that appears below the title.
|
|
17
|
-
*/
|
|
18
|
-
description?: string;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Optional. Defines the size of the Title component.
|
|
22
|
-
* 'large' - A larger, more prominent title.
|
|
23
|
-
* 'small' - A smaller, less prominent title.
|
|
24
|
-
*/
|
|
25
|
-
size?: 'large' | 'medium' | 'small';
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Optional. Represents the name or key of the icon to be displayed alongside the title.
|
|
29
|
-
*/
|
|
30
5
|
icon?: string;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
actionTitle?: string;
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Optional. Function to be called when the action associated with the title is pressed.
|
|
44
|
-
*/
|
|
45
|
-
onPressAction?: () => void;
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Optional. If `true`, an action button or icon is displayed alongside the title.
|
|
49
|
-
*/
|
|
50
|
-
showAction?: boolean;
|
|
51
|
-
usePadding?: boolean;
|
|
6
|
+
description?: string;
|
|
7
|
+
iconColor?: string;
|
|
8
|
+
iconAlign?: 'top' | 'middle' | 'bottom';
|
|
9
|
+
showRightAction?: boolean;
|
|
10
|
+
showLeftAction?: boolean;
|
|
11
|
+
badgeLabel?: string;
|
|
12
|
+
buttonTitle?: string;
|
|
13
|
+
buttonSize?: 'small' | 'large';
|
|
14
|
+
onPressRightAction?: () => void;
|
|
52
15
|
};
|
package/index.ts
CHANGED
|
@@ -4,11 +4,12 @@ import {
|
|
|
4
4
|
useSafeAreaInsets,
|
|
5
5
|
} from 'react-native-safe-area-context';
|
|
6
6
|
import LinearGradient from 'react-native-linear-gradient';
|
|
7
|
+
import {getAccessibilityID} from "./Application/utils";
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* native export
|
|
10
11
|
*/
|
|
11
|
-
export {SafeAreaView, useSafeAreaInsets, SafeAreaProvider, LinearGradient};
|
|
12
|
+
export {SafeAreaView, useSafeAreaInsets, SafeAreaProvider, LinearGradient, getAccessibilityID};
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* foundation component
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@momo-kits/foundation",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.92.1-rc.10",
|
|
4
4
|
"description": "React Native Component Kits",
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"@momo-kits/foundation"
|
|
11
11
|
],
|
|
12
12
|
"dependencies": {
|
|
13
|
+
"@gorhom/bottom-sheet": "git+https://gitlab.com/momo-platform/bottom-sheet.git#main",
|
|
13
14
|
"react-native-safe-area-context": "3.1.4",
|
|
14
15
|
"react-native-linear-gradient": "2.8.3",
|
|
15
16
|
"react-native-gesture-handler": "1.10.3",
|
|
@@ -32,6 +33,7 @@
|
|
|
32
33
|
"@types/jest": "26.0.23",
|
|
33
34
|
"@types/react-native": "0.64.4",
|
|
34
35
|
"@types/react-test-renderer": "16.9.2",
|
|
36
|
+
"@types/d3-shape": "1.3.7",
|
|
35
37
|
"babel-jest": "^26.6.3",
|
|
36
38
|
"eslint": "^7.14.0",
|
|
37
39
|
"jest": "^26.6.3",
|