@momo-kits/foundation 0.81.1-beta.6 → 0.81.1-optimize.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 (67) hide show
  1. package/Application/BottomTab.tsx +76 -23
  2. package/Application/Components.tsx +243 -198
  3. package/Application/ModalScreen.tsx +20 -65
  4. package/Application/Navigation.ts +15 -4
  5. package/Application/NavigationContainer.tsx +20 -20
  6. package/Application/Navigator.ts +61 -28
  7. package/Application/StackScreen.tsx +41 -23
  8. package/Application/index.ts +16 -6
  9. package/Application/types.ts +34 -19
  10. package/Application/utils.tsx +26 -0
  11. package/Assets/icon.json +83 -5
  12. package/Assets/icon_bank.json +506 -0
  13. package/Assets/language.json +3 -1
  14. package/Badge/Badge.tsx +56 -0
  15. package/Badge/BadgeDot.tsx +11 -0
  16. package/Badge/BadgeRibbon.tsx +125 -0
  17. package/Badge/Shape.tsx +29 -0
  18. package/Badge/index.tsx +7 -0
  19. package/Badge/styles.ts +58 -0
  20. package/Badge/types.ts +63 -0
  21. package/Button/index.tsx +26 -9
  22. package/Button/styles.ts +19 -0
  23. package/CheckBox/index.tsx +1 -2
  24. package/Consts/colors+spacing+radius.ts +3 -3
  25. package/Icon/index.tsx +7 -3
  26. package/Icon/types.ts +3 -3
  27. package/IconButton/index.tsx +0 -1
  28. package/Image/index.tsx +39 -49
  29. package/Image/styles.ts +1 -9
  30. package/Image/types.ts +3 -1
  31. package/Input/Input.tsx +37 -16
  32. package/Input/InputDropDown.tsx +5 -14
  33. package/Input/InputMoney.tsx +28 -11
  34. package/Input/InputOTP.tsx +169 -145
  35. package/Input/InputSearch.tsx +9 -13
  36. package/Input/InputTextArea.tsx +6 -12
  37. package/Input/common.tsx +5 -3
  38. package/Input/index.tsx +15 -9
  39. package/Input/styles.ts +1 -4
  40. package/Layout/Card.tsx +20 -11
  41. package/Layout/GridSystem.tsx +1 -2
  42. package/Layout/Item.tsx +0 -1
  43. package/Layout/ItemList.tsx +39 -40
  44. package/Layout/ItemSectionList.tsx +39 -0
  45. package/Layout/Screen.tsx +96 -45
  46. package/Layout/Section.tsx +17 -19
  47. package/Layout/index.ts +2 -1
  48. package/Layout/styles.ts +16 -15
  49. package/Layout/types.ts +2 -5
  50. package/Pagination/PaginationNumber.tsx +1 -1
  51. package/Pagination/PaginationScroll.tsx +0 -1
  52. package/Popup/PopupNotify.tsx +71 -14
  53. package/Popup/PopupPromotion.tsx +43 -6
  54. package/Popup/types.ts +12 -3
  55. package/Radio/index.tsx +1 -2
  56. package/Skeleton/index.tsx +1 -1
  57. package/Switch/index.tsx +0 -1
  58. package/Tag/index.tsx +2 -4
  59. package/Text/index.tsx +3 -2
  60. package/Text/styles.ts +38 -0
  61. package/Text/types.ts +25 -13
  62. package/Title/index.tsx +82 -38
  63. package/Title/styles.ts +16 -10
  64. package/Title/types.ts +2 -1
  65. package/index.ts +2 -0
  66. package/package.json +6 -6
  67. package/verify.js +15 -0
package/Title/index.tsx CHANGED
@@ -1,5 +1,12 @@
1
- import React, {FC, useContext} from 'react';
2
- import {Text as RNText, TouchableOpacity, View} from 'react-native';
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';
3
10
  import {TitleProps} from './types';
4
11
  import {Icon} from '../Icon';
5
12
  import styles from './styles';
@@ -17,69 +24,106 @@ const Title: FC<TitleProps> = ({
17
24
  showAction = true,
18
25
  icon,
19
26
  description,
27
+ usePadding = true,
20
28
  }) => {
21
29
  const {theme} = useContext(ApplicationContext);
22
- const flexStyle = titleFlex ? {flex: 1} : {};
30
+ const [containerWidth, setContainerWidth] = useState(0);
31
+ const [textLines, setTextLines] = useState(0);
23
32
  const typeStyle =
24
33
  type === 'screen' ? styles.screen : styles[`${type}_${size}`];
25
- const actionColor = titleFlex
26
- ? theme.colors.primary
27
- : theme.colors.text.default;
28
- const actionBackground = titleFlex
29
- ? theme.colors.primary + '0F'
30
- : Colors.black_06;
31
- const actionSize = titleFlex ? scaleSize(22) : scaleSize(18);
32
34
  const titleWeight = type === 'screen' ? 'Semibold' : 'Bold';
33
- const marginStyle = type === 'section' ? {marginTop: Spacing.M} : {};
35
+ const marginStyle =
36
+ type === 'section' && usePadding ? {marginTop: Spacing.S} : {};
37
+ const numberOfLines = type === 'section' ? 1 : 2;
34
38
 
35
39
  const renderAction = () => {
36
40
  return !!actionTitle && titleFlex ? (
37
41
  <TouchableOpacity onPress={onPressAction}>
38
- <Text typography={'action_s'} color={theme.colors.primary}>
42
+ <Text typography={'action_s_bold'} color={theme.colors.primary}>
39
43
  {actionTitle}
40
44
  </Text>
41
45
  </TouchableOpacity>
42
46
  ) : (
43
47
  <TouchableOpacity
44
48
  style={[
45
- {backgroundColor: actionBackground},
49
+ {backgroundColor: theme.colors.primary + '0F'},
46
50
  styles.actionIcon,
47
- {width: actionSize, height: actionSize},
51
+ {width: scaleSize(22), height: scaleSize(22)},
48
52
  ]}
49
53
  onPress={onPressAction}>
50
54
  <Icon
51
- size={actionSize}
52
- color={actionColor}
55
+ size={scaleSize(22)}
56
+ color={theme.colors.primary}
53
57
  source={'arrow_chevron_right_small'}
54
58
  />
55
59
  </TouchableOpacity>
56
60
  );
57
61
  };
58
62
 
63
+ const renderSemiAction = () => {
64
+ if (textLines > 1) return null;
65
+ 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>
79
+ );
80
+ };
81
+ const onLayout = (e: LayoutChangeEvent) => {
82
+ setContainerWidth(e.nativeEvent.layout.width);
83
+ };
84
+
85
+ const onTextLayout = (e: NativeSyntheticEvent<TextLayoutEventData>) => {
86
+ setTextLines(e.nativeEvent.lines.length);
87
+ };
88
+
59
89
  return (
60
- <View style={styles.wrapper}>
61
- <View style={[styles.container, marginStyle]}>
62
- {!!icon && type !== 'screen' && (
63
- <Icon style={styles.icon} source={icon} />
64
- )}
65
- <RNText
66
- style={[
67
- typeStyle,
68
- flexStyle,
69
- styles.title,
70
- {
71
- fontFamily: `${theme.font}-${titleWeight}`,
72
- },
73
- ]}>
74
- {title}
75
- </RNText>
76
- {showAction && type !== 'screen' && renderAction()}
77
- </View>
78
- {!!description && type !== 'screen' && (
79
- <Text typography={'description_s'} color={theme.colors.text.secondary}>
80
- {description}
81
- </Text>
90
+ <View onLayout={onLayout} style={[styles.wrapper, marginStyle]}>
91
+ {!!icon && type !== 'screen' && (
92
+ <Icon style={styles.icon} source={icon} />
82
93
  )}
94
+ <View style={{flex: 1, flexDirection: 'row'}}>
95
+ <View style={styles.textContent}>
96
+ <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()}
115
+ </View>
116
+ {!!description && type !== 'screen' && (
117
+ <Text
118
+ numberOfLines={1}
119
+ typography={'description_default_regular'}
120
+ color={theme.colors.text.secondary}>
121
+ {description}
122
+ </Text>
123
+ )}
124
+ </View>
125
+ {showAction && titleFlex && type !== 'screen' && renderAction()}
126
+ </View>
83
127
  </View>
84
128
  );
85
129
  };
package/Title/styles.ts CHANGED
@@ -4,6 +4,10 @@ import {Radius, Spacing} from '../Consts';
4
4
 
5
5
  export default StyleSheet.create({
6
6
  card_small: {
7
+ fontSize: scaleSize(14),
8
+ lineHeight: scaleSize(20),
9
+ },
10
+ card_medium: {
7
11
  fontSize: scaleSize(16),
8
12
  lineHeight: scaleSize(22),
9
13
  },
@@ -11,10 +15,14 @@ export default StyleSheet.create({
11
15
  fontSize: scaleSize(18),
12
16
  lineHeight: scaleSize(26),
13
17
  },
14
- section_small: {
18
+ section_medium: {
15
19
  fontSize: scaleSize(20),
16
20
  lineHeight: scaleSize(28),
17
21
  },
22
+ section_small: {
23
+ fontSize: scaleSize(16),
24
+ lineHeight: scaleSize(22),
25
+ },
18
26
  section_large: {
19
27
  fontSize: scaleSize(24),
20
28
  lineHeight: scaleSize(34),
@@ -23,24 +31,22 @@ export default StyleSheet.create({
23
31
  fontSize: scaleSize(36),
24
32
  lineHeight: scaleSize(44),
25
33
  },
26
- title: {
27
- marginRight: Spacing.XS,
28
- },
29
- container: {
30
- flexDirection: 'row',
31
- alignItems: 'center',
32
- width: '100%',
33
- },
34
34
  actionIcon: {
35
35
  borderRadius: Radius.M,
36
36
  alignItems: 'center',
37
37
  justifyContent: 'center',
38
38
  },
39
39
  icon: {
40
- marginRight: Spacing.XS,
40
+ marginRight: Spacing.S,
41
41
  borderRadius: Radius.XS,
42
42
  },
43
43
  wrapper: {
44
44
  width: '100%',
45
+ flexDirection: 'row',
46
+ alignItems: 'center',
47
+ },
48
+ textContent: {
49
+ marginRight: Spacing.S,
50
+ flex: 1,
45
51
  },
46
52
  });
package/Title/types.ts CHANGED
@@ -22,7 +22,7 @@ export type TitleProps = {
22
22
  * 'large' - A larger, more prominent title.
23
23
  * 'small' - A smaller, less prominent title.
24
24
  */
25
- size?: 'large' | 'small';
25
+ size?: 'large' | 'medium' | 'small';
26
26
 
27
27
  /**
28
28
  * Optional. Represents the name or key of the icon to be displayed alongside the title.
@@ -48,4 +48,5 @@ export type TitleProps = {
48
48
  * Optional. If `true`, an action button or icon is displayed alongside the title.
49
49
  */
50
50
  showAction?: boolean;
51
+ usePadding?: boolean;
51
52
  };
package/index.ts CHANGED
@@ -47,3 +47,5 @@ export * from './Loader';
47
47
  export * from './Loader/types';
48
48
  export * from './Title';
49
49
  export * from './Title/types';
50
+ export * from './Badge';
51
+ export * from './Badge/types';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.81.1-beta.6",
3
+ "version": "0.81.1-optimize.1",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {
@@ -10,17 +10,17 @@
10
10
  "@momo-kits/foundation"
11
11
  ],
12
12
  "dependencies": {
13
- "@gorhom/bottom-sheet": "git+https://gitlab.com/dung.huynh1/bottom-sheet.git#main",
13
+ "@gorhom/bottom-sheet": "git+https://gitlab.com/momo-platform/bottom-sheet.git#main",
14
14
  "react-native-safe-area-context": "3.1.4",
15
- "react-native-linear-gradient": "2.5.6",
15
+ "react-native-linear-gradient": "2.8.3",
16
16
  "react-native-gesture-handler": "1.10.3",
17
17
  "react-native-fast-image": "8.1.5",
18
- "@react-navigation/bottom-tabs": "git+https://gitlab.com/dung.huynh1/react-navigation-bottom-tabs.git#main",
18
+ "@react-navigation/bottom-tabs": "git+https://gitlab.com/momo-platform/react-navigation-bottom-tabs.git#main",
19
19
  "@react-navigation/core": "5.16.1",
20
20
  "@react-navigation/native": "5.9.8",
21
21
  "@react-navigation/routers": "5.7.4",
22
22
  "lottie-react-native": "3.3.2",
23
- "@react-navigation/stack": "git+https://gitlab.com/dung.huynh1/react-navigation-stack.git#main"
23
+ "@react-navigation/stack": "git+https://gitlab.com/momo-platform/react-navigation-stack.git#main"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "react-native": "*"
@@ -43,4 +43,4 @@
43
43
  },
44
44
  "author": "@momo-kits/foundation",
45
45
  "license": "ISC"
46
- }
46
+ }
package/verify.js CHANGED
@@ -7,7 +7,9 @@ try {
7
7
  const packageVersion = parseInt(packageInfo?.version.split('.')?.[1]);
8
8
 
9
9
  const app = path.join(`${__dirname}/../../../`, 'app.json');
10
+ const miniJson = path.join(`${__dirname}/../../../`, 'package.json');
10
11
  const appInfo = JSON.parse(fs.readFileSync(app, 'utf8'));
12
+ const miniInfo = JSON.parse(fs.readFileSync(miniJson, 'utf8'));
11
13
  const iOSAppTarget = appInfo?.client?.ios.deploymentTarget;
12
14
  const androidAppTarget = appInfo?.client?.android.deploymentTarget;
13
15
 
@@ -23,6 +25,19 @@ try {
23
25
  `Package ${packageInfo.name} version: ${packageInfo.version} require deploymentTarget ${packageVersion}`,
24
26
  );
25
27
  }
28
+
29
+ if (
30
+ miniInfo?.dependencies?.['@momo-platform/momo-core'] &&
31
+ miniInfo?.dependencies?.['@momo-platform/momo-core'] !==
32
+ packageInfo?.version
33
+ ) {
34
+ console.error(
35
+ `Package ${packageInfo.name} version: ${packageInfo.version} require install resolutions @momo-platform/momo-core ${packageInfo.version}`,
36
+ );
37
+ throw new Error(
38
+ `Package ${packageInfo.name} version: ${packageInfo.version} require install resolutions @momo-platform/momo-core ${packageInfo.version}`,
39
+ );
40
+ }
26
41
  } catch (error) {
27
42
  console.error(`Installation failed: ${error.message}`);
28
43
  process.exit(1);