@momo-kits/foundation 0.89.5 → 0.92.1-rc.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.
Files changed (41) hide show
  1. package/Application/BottomTab/BottomTabBar.tsx +507 -0
  2. package/Application/BottomTab/CurvedView.tsx +27 -0
  3. package/Application/{BottomTab.tsx → BottomTab/index.tsx} +17 -9
  4. package/Application/BottomTab/path.ts +202 -0
  5. package/Application/Components.tsx +48 -26
  6. package/Application/ModalScreen.tsx +107 -131
  7. package/Application/NavigationContainer.tsx +64 -51
  8. package/Application/Navigator.ts +51 -31
  9. package/Application/StackScreen.tsx +83 -12
  10. package/Application/index.ts +0 -4
  11. package/Application/types.ts +16 -7
  12. package/Application/utils.tsx +65 -10
  13. package/Badge/Badge.tsx +1 -1
  14. package/Button/index.tsx +48 -14
  15. package/CheckBox/index.tsx +47 -20
  16. package/CheckBox/types.ts +4 -0
  17. package/Consts/colors+spacing+radius.ts +13 -0
  18. package/IconButton/index.tsx +30 -7
  19. package/Image/index.tsx +3 -1
  20. package/Input/Input.tsx +60 -5
  21. package/Input/InputDropDown.tsx +38 -4
  22. package/Input/InputMoney.tsx +45 -4
  23. package/Input/InputOTP.tsx +33 -7
  24. package/Input/InputSearch.tsx +61 -25
  25. package/Input/InputTextArea.tsx +21 -0
  26. package/Input/index.tsx +29 -2
  27. package/Input/styles.ts +3 -3
  28. package/Popup/PopupNotify.tsx +13 -2
  29. package/Popup/PopupPromotion.tsx +11 -4
  30. package/Radio/index.tsx +46 -19
  31. package/Radio/types.ts +5 -0
  32. package/Switch/index.tsx +39 -14
  33. package/Switch/types.ts +4 -0
  34. package/Text/index.tsx +3 -5
  35. package/Text/styles.ts +7 -7
  36. package/Title/index.tsx +119 -102
  37. package/Title/styles.ts +26 -6
  38. package/Title/types.ts +11 -48
  39. package/index.ts +2 -1
  40. package/package.json +4 -1
  41. package/verify.js +9 -6
package/Text/styles.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  export default {
2
- headline_default_bold: {fontSize: 24, lineHeight: 32, fontWeight: '700'},
3
- header_m_bold: {fontSize: 18, lineHeight: 28, fontWeight: '700'},
2
+ headline_default_bold: {fontSize: 24, lineHeight: 34, fontWeight: '700'},
3
+ header_m_bold: {fontSize: 18, lineHeight: 26, fontWeight: '700'},
4
4
  header_default_bold: {fontSize: 16, lineHeight: 22, fontWeight: '700'},
5
5
  header_s_semibold: {fontSize: 14, lineHeight: 20, fontWeight: '600'},
6
- header_xs_semibold: {fontSize: 12, lineHeight: 16, fontWeight: '600'},
6
+ header_xs_semibold: {fontSize: 12, lineHeight: 18, fontWeight: '600'},
7
7
  body_default_regular: {fontSize: 14, lineHeight: 20, fontWeight: '400'},
8
8
  body_regularstrikethrought: {
9
9
  fontSize: 14,
@@ -13,12 +13,12 @@ export default {
13
13
  },
14
14
  description_default_regular: {
15
15
  fontSize: 12,
16
- lineHeight: 16,
16
+ lineHeight: 18,
17
17
  fontWeight: '400',
18
18
  },
19
19
  description_default_regularstrikethrought: {
20
20
  fontSize: 12,
21
- lineHeight: 16,
21
+ lineHeight: 18,
22
22
  fontWeight: '400',
23
23
  textDecorationLine: 'line-through',
24
24
  },
@@ -30,11 +30,11 @@ export default {
30
30
  textDecorationLine: 'line-through',
31
31
  },
32
32
  label_default_medium: {fontSize: 14, lineHeight: 20, fontWeight: '500'},
33
- label_s_medium: {fontSize: 12, lineHeight: 16, fontWeight: '500'},
33
+ label_s_medium: {fontSize: 12, lineHeight: 18, fontWeight: '500'},
34
34
  label_xs_medium: {fontSize: 10, lineHeight: 14, fontWeight: '500'},
35
35
  action_default_bold: {fontSize: 16, lineHeight: 22, fontWeight: '700'},
36
36
  action_s_bold: {fontSize: 14, lineHeight: 20, fontWeight: '700'},
37
- action_xs_bold: {fontSize: 12, lineHeight: 16, fontWeight: '700'},
37
+ action_xs_bold: {fontSize: 12, lineHeight: 18, fontWeight: '700'},
38
38
  action_xxs_bold: {fontSize: 10, lineHeight: 14, fontWeight: '700'},
39
39
  /**non-support**/
40
40
  headline_default: {
package/Title/index.tsx CHANGED
@@ -1,129 +1,146 @@
1
- import React, {FC, useContext, useState} from 'react';
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';
4
+ import {Icon} from '../Icon';
5
+ import {scaleSize, Text} from '../Text';
13
6
  import {ApplicationContext} from '../Application';
14
7
  import {Colors, Spacing} from '../Consts';
15
- import {scaleSize, Text} from '../Text';
8
+ import {Badge} from '../Badge';
9
+ import {Typography} from '../Text/types';
10
+ import {TitleProps} from './types';
16
11
 
17
12
  const Title: FC<TitleProps> = ({
18
- size = 'large',
19
- type = 'section',
20
- onPressAction,
21
- actionTitle,
22
13
  title = 'Title',
23
- titleFlex = true,
24
- showAction = true,
14
+ type = 'section',
15
+ size = 'medium',
25
16
  icon,
26
17
  description,
27
- usePadding = true,
18
+ iconColor = null,
19
+ iconAlign = 'top',
20
+ showRightAction = false,
21
+ showLeftAction = false,
22
+ badgeLabel,
23
+ buttonTitle,
24
+ onPressRightAction = () => {},
25
+ buttonSize = 'small',
28
26
  }) => {
29
27
  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;
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
+ const widthStyle =
37
+ !showLeftAction && !showRightAction && !badgeLabel
38
+ ? {width: '100%'}
39
+ : {width: '75%'};
38
40
 
39
- const renderAction = () => {
40
- return !!actionTitle && titleFlex ? (
41
- <TouchableOpacity onPress={onPressAction}>
42
- <Text typography={'action_s_bold'} color={theme.colors.primary}>
43
- {actionTitle}
44
- </Text>
45
- </TouchableOpacity>
46
- ) : (
47
- <TouchableOpacity
48
- style={[
49
- {backgroundColor: theme.colors.primary + '0F'},
50
- styles.actionIcon,
51
- {width: scaleSize(22), height: scaleSize(22)},
52
- ]}
53
- onPress={onPressAction}>
54
- <Icon
55
- size={scaleSize(22)}
56
- color={theme.colors.primary}
57
- source={'arrow_chevron_right_small'}
58
- />
59
- </TouchableOpacity>
41
+ const renderIcon = () => {
42
+ if (!icon) return null;
43
+
44
+ let iconStyle: ViewStyle = {
45
+ justifyContent: 'flex-start',
46
+ };
47
+
48
+ if (iconAlign === 'middle') {
49
+ iconStyle = {justifyContent: 'center'};
50
+ }
51
+
52
+ if (iconAlign === 'bottom') {
53
+ iconStyle = {justifyContent: 'flex-end'};
54
+ }
55
+
56
+ return (
57
+ <View style={[styles.iconView, iconStyle]}>
58
+ <Icon color={iconColor} source={icon} />
59
+ </View>
60
60
  );
61
61
  };
62
62
 
63
- const renderSemiAction = () => {
64
- if (textLines > 1) return null;
63
+ const renderContent = () => {
65
64
  return (
66
- <TouchableOpacity
67
- style={[
68
- {backgroundColor: Colors.black_06},
69
- styles.actionIcon,
70
- {width: scaleSize(18), height: scaleSize(18)},
71
- ]}
72
- onPress={onPressAction}>
73
- <Icon
74
- size={scaleSize(18)}
75
- color={theme.colors.text.default}
76
- source={'arrow_chevron_right_small'}
77
- />
78
- </TouchableOpacity>
65
+ <View style={{flex: 1}}>
66
+ <View style={[styles.iconLeftView, widthStyle]}>
67
+ <RNText
68
+ numberOfLines={numberOfLines}
69
+ style={[
70
+ styleSheet[typography],
71
+ {
72
+ fontWeight: 'bold',
73
+ marginBottom: Spacing.XS,
74
+ },
75
+ ]}>
76
+ {title}
77
+ </RNText>
78
+ <View style={{alignItems: 'center'}}>
79
+ {badgeLabel && (
80
+ <Badge style={{marginLeft: Spacing.XS}} label={badgeLabel} />
81
+ )}
82
+ </View>
83
+ {renderActionLeft()}
84
+ </View>
85
+ <Text
86
+ color={theme.colors.text.secondary}
87
+ typography={'description_default_regular'}>
88
+ {description}
89
+ </Text>
90
+ </View>
79
91
  );
80
92
  };
81
- const onLayout = (e: LayoutChangeEvent) => {
82
- setContainerWidth(e.nativeEvent.layout.width);
83
- };
84
93
 
85
- const onTextLayout = (e: NativeSyntheticEvent<TextLayoutEventData>) => {
86
- setTextLines(e.nativeEvent.lines.length);
94
+ const renderActionLeft = () => {
95
+ return (
96
+ <View style={styles.iconLeftView}>
97
+ {showLeftAction && !showRightAction && (
98
+ <View style={[styles.iconLeft, {backgroundColor: Colors.black_06}]}>
99
+ <Icon
100
+ source={'arrow_chevron_right_small'}
101
+ size={scaleSize(18)}
102
+ color={theme.colors.text.default}
103
+ />
104
+ </View>
105
+ )}
106
+ </View>
107
+ );
87
108
  };
88
109
 
89
- return (
90
- <View onLayout={onLayout} style={[styles.wrapper, marginStyle]}>
91
- {!!icon && type !== 'screen' && (
92
- <Icon style={styles.icon} source={icon} />
93
- )}
94
- <View style={{flex: 1, flexDirection: 'row'}}>
95
- <View style={styles.textContent}>
110
+ const renderActionRight = () => {
111
+ if (!showRightAction || showLeftAction) return false;
112
+
113
+ return (
114
+ <View>
115
+ {!buttonTitle ? (
96
116
  <View
97
- style={{
98
- flexDirection: 'row',
99
- maxWidth: containerWidth - scaleSize(22),
100
- }}>
101
- <RNText
102
- onTextLayout={onTextLayout}
103
- numberOfLines={numberOfLines}
104
- style={[
105
- typeStyle,
106
- {
107
- fontFamily: `${theme.font}-${titleWeight}`,
108
- color: theme.colors.text.default,
109
- marginRight: Spacing.S,
110
- },
111
- ]}>
112
- {title}
113
- </RNText>
114
- {!titleFlex && renderSemiAction()}
117
+ style={[
118
+ styles.iconRight,
119
+ {
120
+ backgroundColor: theme.colors.primary + '0F',
121
+ },
122
+ ]}>
123
+ <Icon
124
+ source={'arrow_chevron_right_small'}
125
+ size={scaleSize(22)}
126
+ color={theme.colors.primary}
127
+ />
115
128
  </View>
116
- {!!description && type !== 'screen' && (
117
- <Text
118
- numberOfLines={1}
119
- typography={'description_default_regular'}
120
- color={theme.colors.text.secondary}>
121
- {description}
129
+ ) : (
130
+ <TouchableOpacity onPress={onPressRightAction}>
131
+ <Text color={theme.colors.primary} typography={buttonTypo}>
132
+ {buttonTitle}
122
133
  </Text>
123
- )}
124
- </View>
125
- {showAction && titleFlex && type !== 'screen' && renderAction()}
134
+ </TouchableOpacity>
135
+ )}
126
136
  </View>
137
+ );
138
+ };
139
+ return (
140
+ <View style={[styles.wrapper, isSection && styles.margin]}>
141
+ {renderIcon()}
142
+ {renderContent()}
143
+ {renderActionRight()}
127
144
  </View>
128
145
  );
129
146
  };
package/Title/styles.ts CHANGED
@@ -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,36 @@ 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
  textContent: {
49
43
  marginRight: Spacing.S,
50
44
  flex: 1,
51
45
  },
46
+ margin: {
47
+ marginTop: Spacing.S,
48
+ },
49
+ iconView: {
50
+ marginRight: Spacing.S,
51
+ },
52
+ iconRight: {
53
+ width: scaleSize(22),
54
+ height: scaleSize(22),
55
+ borderRadius: Radius.M,
56
+ alignItems: 'center',
57
+ justifyContent: 'center',
58
+ marginLeft: Spacing.S,
59
+ },
60
+ iconLeft: {
61
+ width: scaleSize(18),
62
+ height: scaleSize(18),
63
+ borderRadius: Radius.M,
64
+ alignItems: 'center',
65
+ justifyContent: 'center',
66
+ marginHorizontal: Spacing.XS,
67
+ },
68
+ iconLeftView: {
69
+ flexDirection: 'row',
70
+ alignItems: 'center',
71
+ },
52
72
  });
package/Title/types.ts CHANGED
@@ -1,52 +1,15 @@
1
1
  export type TitleProps = {
2
- /**
3
- * Optional. Defines the type of Title component.
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
- * Optional. If `true`, the title will be flexible in its container, adjusting its width dynamically.
34
- */
35
- titleFlex?: boolean;
36
-
37
- /**
38
- * Optional. Text for an action button associated with the title.
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.89.5",
3
+ "version": "0.92.1-rc.1",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {
@@ -14,12 +14,14 @@
14
14
  "react-native-safe-area-context": "3.1.4",
15
15
  "react-native-linear-gradient": "2.8.3",
16
16
  "react-native-gesture-handler": "1.10.3",
17
+ "react-native-modalize": "2.1.1",
17
18
  "react-native-fast-image": "8.1.5",
18
19
  "@react-navigation/bottom-tabs": "git+https://gitlab.com/momo-platform/react-navigation-bottom-tabs.git#main",
19
20
  "@react-navigation/core": "5.16.1",
20
21
  "@react-navigation/native": "5.9.8",
21
22
  "@react-navigation/routers": "5.7.4",
22
23
  "lottie-react-native": "3.3.2",
24
+ "d3-shape": "1.3.7",
23
25
  "@react-navigation/stack": "git+https://gitlab.com/momo-platform/react-navigation-stack.git#main"
24
26
  },
25
27
  "peerDependencies": {
@@ -32,6 +34,7 @@
32
34
  "@types/jest": "26.0.23",
33
35
  "@types/react-native": "0.64.4",
34
36
  "@types/react-test-renderer": "16.9.2",
37
+ "@types/d3-shape": "1.3.7",
35
38
  "babel-jest": "^26.6.3",
36
39
  "eslint": "^7.14.0",
37
40
  "jest": "^26.6.3",
package/verify.js CHANGED
@@ -2,21 +2,24 @@ const fs = require('fs');
2
2
  const path = require('path');
3
3
 
4
4
  try {
5
- const package = path.join(`${__dirname}`, 'package.json');
6
- const packageInfo = JSON.parse(fs.readFileSync(package, 'utf8'));
5
+ const packageInfo = JSON.parse(
6
+ fs.readFileSync(path.join(`${__dirname}`, 'package.json'), 'utf8'),
7
+ );
7
8
  const packageVersion = parseInt(packageInfo?.version.split('.')?.[1]);
8
9
 
9
10
  const app = path.join(`${__dirname}/../../../`, 'app.json');
10
11
  const miniJson = path.join(`${__dirname}/../../../`, 'package.json');
12
+
13
+ if (!fs.existsSync(app) || fs.existsSync(miniJson)) {
14
+ return;
15
+ }
16
+
11
17
  const appInfo = JSON.parse(fs.readFileSync(app, 'utf8'));
12
18
  const miniInfo = JSON.parse(fs.readFileSync(miniJson, 'utf8'));
19
+
13
20
  const iOSAppTarget = appInfo?.client?.ios.deploymentTarget;
14
21
  const androidAppTarget = appInfo?.client?.android.deploymentTarget;
15
22
 
16
- if (appInfo.name === 'MoMoPlatform') {
17
- return;
18
- }
19
-
20
23
  if (packageVersion > iOSAppTarget || packageVersion > androidAppTarget) {
21
24
  console.error(
22
25
  `Package ${packageInfo.name} version: ${packageInfo.version} require deploymentTarget ${packageVersion}`,