@momo-kits/foundation 0.80.9 → 0.81.1-beta.0

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 (87) hide show
  1. package/Application/BottomSheet.tsx +212 -0
  2. package/Application/BottomTab/BottomTabBar.tsx +278 -0
  3. package/Application/BottomTab/index.tsx +143 -0
  4. package/Application/Components.tsx +379 -209
  5. package/Application/ModalScreen.tsx +14 -178
  6. package/Application/Navigation.ts +15 -19
  7. package/Application/NavigationContainer.tsx +66 -63
  8. package/Application/Navigator.ts +106 -53
  9. package/Application/StackScreen.tsx +123 -9
  10. package/Application/index.ts +19 -6
  11. package/Application/types.ts +83 -26
  12. package/Application/utils.tsx +38 -49
  13. package/Assets/icon.json +83 -5
  14. package/Assets/icon_bank.json +506 -0
  15. package/Assets/language.json +3 -1
  16. package/Badge/Badge.tsx +56 -0
  17. package/Badge/BadgeDot.tsx +11 -0
  18. package/Badge/BadgeRibbon.tsx +125 -0
  19. package/Badge/Shape.tsx +29 -0
  20. package/Badge/index.tsx +7 -0
  21. package/Badge/styles.ts +58 -0
  22. package/Badge/types.ts +63 -0
  23. package/Button/index.tsx +64 -28
  24. package/Button/styles.ts +19 -0
  25. package/CheckBox/index.tsx +37 -27
  26. package/CheckBox/types.ts +5 -3
  27. package/Consts/colors+spacing+radius.ts +18 -0
  28. package/Icon/index.tsx +14 -9
  29. package/Icon/types.ts +4 -3
  30. package/IconButton/index.tsx +24 -15
  31. package/Image/index.tsx +62 -47
  32. package/Image/styles.ts +1 -9
  33. package/Image/types.ts +5 -1
  34. package/Input/Input.tsx +104 -25
  35. package/Input/InputDropDown.tsx +35 -23
  36. package/Input/InputMoney.tsx +79 -18
  37. package/Input/InputOTP.tsx +190 -149
  38. package/Input/InputSearch.tsx +96 -44
  39. package/Input/InputTextArea.tsx +33 -17
  40. package/Input/common.tsx +26 -17
  41. package/Input/index.tsx +69 -24
  42. package/Input/styles.ts +5 -7
  43. package/Input/utils.ts +1 -1
  44. package/Layout/AnimatedInputSearch.tsx +44 -0
  45. package/Layout/Card.tsx +37 -13
  46. package/Layout/FloatingButton.tsx +168 -0
  47. package/Layout/GridSystem.tsx +2 -3
  48. package/Layout/Item.tsx +1 -2
  49. package/Layout/ItemList.tsx +55 -0
  50. package/Layout/ItemSectionList.tsx +39 -0
  51. package/Layout/Screen.tsx +404 -181
  52. package/Layout/Section.tsx +22 -22
  53. package/Layout/TextTyping.tsx +114 -0
  54. package/Layout/index.ts +12 -2
  55. package/Layout/styles.ts +46 -13
  56. package/Layout/types.ts +13 -5
  57. package/Layout/utils.ts +7 -12
  58. package/Loader/index.tsx +2 -0
  59. package/Pagination/PaginationDot.tsx +6 -1
  60. package/Pagination/PaginationNumber.tsx +7 -4
  61. package/Pagination/PaginationScroll.tsx +0 -1
  62. package/Pagination/PaginationWhiteDot.tsx +6 -1
  63. package/Pagination/styles.ts +3 -0
  64. package/Pagination/types.ts +2 -0
  65. package/Popup/PopupNotify.tsx +108 -40
  66. package/Popup/PopupPromotion.tsx +45 -10
  67. package/Popup/types.ts +13 -10
  68. package/Radio/index.tsx +35 -21
  69. package/Radio/types.ts +7 -5
  70. package/Skeleton/index.tsx +1 -1
  71. package/Switch/index.tsx +32 -19
  72. package/Switch/types.ts +5 -3
  73. package/Tag/index.tsx +2 -4
  74. package/Text/index.tsx +26 -6
  75. package/Text/styles.ts +38 -0
  76. package/Text/types.ts +25 -13
  77. package/Title/index.tsx +177 -63
  78. package/Title/styles.ts +48 -15
  79. package/Title/types.ts +16 -47
  80. package/code-scanner.js +125 -16
  81. package/index.ts +9 -0
  82. package/migrate_typo.js +56 -0
  83. package/package.json +9 -8
  84. package/publish.sh +21 -16
  85. package/tsconfig.json +1 -2
  86. package/verify.js +24 -6
  87. package/Application/BottomTab.tsx +0 -65
package/Text/styles.ts CHANGED
@@ -1,4 +1,42 @@
1
1
  export default {
2
+ headline_default_bold: {fontSize: 24, lineHeight: 34, fontWeight: '700'},
3
+ header_m_bold: {fontSize: 18, lineHeight: 26, fontWeight: '700'},
4
+ header_default_bold: {fontSize: 16, lineHeight: 22, fontWeight: '700'},
5
+ header_s_semibold: {fontSize: 14, lineHeight: 20, fontWeight: '600'},
6
+ header_xs_semibold: {fontSize: 12, lineHeight: 18, fontWeight: '600'},
7
+ body_default_regular: {fontSize: 14, lineHeight: 20, fontWeight: '400'},
8
+ body_default_regularstrikethrought: {
9
+ fontSize: 14,
10
+ lineHeight: 20,
11
+ fontWeight: '400',
12
+ textDecorationLine: 'line-through',
13
+ },
14
+ description_default_regular: {
15
+ fontSize: 12,
16
+ lineHeight: 18,
17
+ fontWeight: '400',
18
+ },
19
+ description_default_regularstrikethrought: {
20
+ fontSize: 12,
21
+ lineHeight: 18,
22
+ fontWeight: '400',
23
+ textDecorationLine: 'line-through',
24
+ },
25
+ description_xs_regular: {fontSize: 10, lineHeight: 14, fontWeight: '400'},
26
+ description_xs_regularstrikethrought: {
27
+ fontSize: 10,
28
+ lineHeight: 14,
29
+ fontWeight: '400',
30
+ textDecorationLine: 'line-through',
31
+ },
32
+ label_default_medium: {fontSize: 14, lineHeight: 20, fontWeight: '500'},
33
+ label_s_medium: {fontSize: 12, lineHeight: 18, fontWeight: '500'},
34
+ label_xs_medium: {fontSize: 10, lineHeight: 14, fontWeight: '500'},
35
+ action_default_bold: {fontSize: 16, lineHeight: 22, fontWeight: '700'},
36
+ action_s_bold: {fontSize: 14, lineHeight: 20, fontWeight: '700'},
37
+ action_xs_bold: {fontSize: 12, lineHeight: 18, fontWeight: '700'},
38
+ action_xxs_bold: {fontSize: 10, lineHeight: 14, fontWeight: '700'},
39
+ /**non-support**/
2
40
  headline_default: {
3
41
  fontSize: 28,
4
42
  lineHeight: 34,
package/Text/types.ts CHANGED
@@ -14,27 +14,39 @@ export type TypographyWeight = {
14
14
  };
15
15
 
16
16
  export type Typography =
17
+ /**
18
+ * @deprecated
19
+ **/
17
20
  | 'headline_default'
18
- | 'headline_s'
19
21
  | 'headline_l'
20
22
  | 'headline_xl'
21
23
  | 'title_default'
22
24
  | 'title_xs'
23
25
  | 'title_s'
24
26
  | 'header_default'
25
- | 'header_xs'
26
- | 'header_s'
27
27
  | 'paragraph_default'
28
28
  | 'paragraph_bold'
29
29
  | 'paragraph_italic'
30
- | 'description_default'
31
- | 'description_xs'
32
- | 'description_s'
33
- | 'label_default'
34
30
  | 'label_xxs'
35
- | 'label_xs'
36
- | 'label_s'
37
- | 'action_default'
38
- | 'action_xxs'
39
- | 'action_xs'
40
- | 'action_s';
31
+ | 'action_s'
32
+ /**
33
+ * end
34
+ **/
35
+ | 'headline_default_bold'
36
+ | 'header_m_bold'
37
+ | 'header_default_bold'
38
+ | 'header_s_semibold'
39
+ | 'header_xs_semibold'
40
+ | 'body_default_regular'
41
+ | 'body_default_regularstrikethrought'
42
+ | 'description_default_regular'
43
+ | 'description_default_regularstrikethrought'
44
+ | 'description_xs_regular'
45
+ | 'description_xs_regularstrikethrought'
46
+ | 'label_default_medium'
47
+ | 'label_s_medium'
48
+ | 'label_xs_medium'
49
+ | 'action_default_bold'
50
+ | 'action_s_bold'
51
+ | 'action_xs_bold'
52
+ | 'action_xxs_bold';
package/Title/index.tsx CHANGED
@@ -1,85 +1,199 @@
1
- import React, {FC, useContext} from 'react';
2
- import {Text as RNText, TouchableOpacity, View} from 'react-native';
3
- import {TitleProps} from './types';
4
- import {Icon} from '../Icon';
1
+ import React, {FC, useContext, useState} from 'react';
2
+ import {Text as RNText, TouchableOpacity, View, ViewStyle} from 'react-native';
3
+ import {
4
+ Typography,
5
+ Colors,
6
+ Icon,
7
+ Badge,
8
+ ApplicationContext,
9
+ scaleSize,
10
+ Text,
11
+ } from '@momo-kits/foundation';
5
12
  import styles from './styles';
6
- import {ApplicationContext} from '../Application';
7
- import {Colors, Spacing} from '../Consts';
8
- import {scaleSize, Text} from '../Text';
13
+ import {TitleProps} from './types';
9
14
 
10
15
  const Title: FC<TitleProps> = ({
11
- size = 'large',
12
- type = 'section',
13
- onPressAction,
14
- actionTitle,
15
16
  title = 'Title',
16
- titleFlex = true,
17
- showAction = true,
17
+ type = 'section',
18
+ size = 'medium',
18
19
  icon,
19
20
  description,
21
+ iconColor = null,
22
+ iconAlign = 'top',
23
+ showRightAction = false,
24
+ showTrailingAction = false,
25
+ badgeLabel,
26
+ buttonTitle,
27
+ onPressRightAction = () => {},
28
+ onPressTrailingAction = () => {},
29
+ buttonSize = 'small',
30
+ textOnly = false,
31
+ style,
20
32
  }) => {
21
33
  const {theme} = useContext(ApplicationContext);
22
- const flexStyle = titleFlex ? {flex: 1} : {};
23
- const typeStyle =
24
- 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
- const titleWeight = type === 'screen' ? 'Semibold' : 'Bold';
33
- const marginStyle = type === 'section' ? {marginTop: Spacing.M} : {};
34
+ const [badgeWidth, setBadgeWidth] = useState(0);
35
+ const [contentWidth, setContentWidth] = useState(0);
36
+ const styleSheet: {
37
+ [key: string]: any;
38
+ } = styles;
39
+ const typography = `${type}_${size}`;
40
+ const isSection = type === 'section';
41
+ const numberOfLines = showTrailingAction || !!badgeLabel ? 1 : 2;
42
+ const buttonTypo: Typography =
43
+ buttonSize === 'small' ? 'action_xs_bold' : 'action_s_bold';
44
+ const flexStyle = showTrailingAction && {maxWidth: '70%'};
34
45
 
35
- const renderAction = () => {
36
- return !!actionTitle && titleFlex ? (
37
- <TouchableOpacity onPress={onPressAction}>
38
- <Text typography={'action_s'} color={theme.colors.primary}>
39
- {actionTitle}
40
- </Text>
41
- </TouchableOpacity>
42
- ) : (
46
+ const renderIcon = () => {
47
+ if (!icon) return null;
48
+
49
+ let iconStyle: ViewStyle = {
50
+ justifyContent: 'flex-start',
51
+ };
52
+
53
+ if (iconAlign === 'middle') {
54
+ iconStyle = {justifyContent: 'center'};
55
+ }
56
+
57
+ if (iconAlign === 'bottom') {
58
+ iconStyle = {justifyContent: 'flex-end'};
59
+ }
60
+
61
+ return (
62
+ <View style={[styles.iconView, iconStyle]}>
63
+ <Icon color={iconColor} source={icon} />
64
+ </View>
65
+ );
66
+ };
67
+
68
+ const renderContent = () => {
69
+ return (
70
+ <View style={styles.contentView}>
71
+ <View
72
+ onLayout={e => {
73
+ if (e.nativeEvent.layout.width !== contentWidth) {
74
+ setContentWidth(e.nativeEvent.layout.width);
75
+ }
76
+ }}
77
+ style={[styles.iconLeftView, flexStyle]}>
78
+ <RNText
79
+ numberOfLines={numberOfLines}
80
+ style={[
81
+ styleSheet[typography],
82
+ styles.title,
83
+ {
84
+ maxWidth:
85
+ contentWidth > 0 ? contentWidth - badgeWidth : undefined,
86
+ },
87
+ ]}>
88
+ {title}
89
+ </RNText>
90
+ {badgeLabel && (
91
+ <View
92
+ onLayout={e => {
93
+ if (e.nativeEvent.layout.width !== badgeWidth) {
94
+ setBadgeWidth(e.nativeEvent.layout.width);
95
+ }
96
+ }}
97
+ style={{
98
+ alignItems: 'center',
99
+ }}>
100
+ <Badge style={styles.badge} label={badgeLabel} />
101
+ </View>
102
+ )}
103
+ {renderActionLeft()}
104
+ </View>
105
+ {description && (
106
+ <Text
107
+ style={styles.description}
108
+ color={theme.colors.text.secondary}
109
+ typography={'description_default_regular'}>
110
+ {description}
111
+ </Text>
112
+ )}
113
+ </View>
114
+ );
115
+ };
116
+
117
+ const renderActionLeft = () => {
118
+ return (
43
119
  <TouchableOpacity
44
- style={[
45
- {backgroundColor: actionBackground},
46
- styles.actionIcon,
47
- {width: actionSize, height: actionSize},
48
- ]}
49
- onPress={onPressAction}>
50
- <Icon
51
- size={actionSize}
52
- color={actionColor}
53
- source={'arrow_chevron_right_small'}
54
- />
120
+ onPress={onPressTrailingAction}
121
+ style={styles.iconLeftView}>
122
+ {showTrailingAction && !showRightAction && (
123
+ <View
124
+ style={[
125
+ styles.iconLeft,
126
+ {
127
+ backgroundColor: isSection
128
+ ? Colors.black_06 + '99'
129
+ : Colors.black_06 + '4D',
130
+ },
131
+ ]}>
132
+ <Icon
133
+ source={'arrow_chevron_right_small'}
134
+ size={scaleSize(18)}
135
+ color={theme.colors.text.default}
136
+ />
137
+ </View>
138
+ )}
55
139
  </TouchableOpacity>
56
140
  );
57
141
  };
58
142
 
59
- return (
60
- <View style={styles.wrapper}>
61
- <View style={[styles.container, marginStyle]}>
62
- {!!icon && type !== 'screen' && (
63
- <Icon style={styles.icon} source={icon} />
143
+ const renderActionRight = () => {
144
+ if (!showRightAction || showTrailingAction) return false;
145
+
146
+ const lineHeight = styleSheet[typography].lineHeight;
147
+
148
+ return (
149
+ <View
150
+ style={{
151
+ height: lineHeight,
152
+ justifyContent: 'center',
153
+ }}>
154
+ {!buttonTitle ? (
155
+ <TouchableOpacity
156
+ onPress={onPressRightAction}
157
+ style={[
158
+ styles.iconRight,
159
+ {
160
+ backgroundColor: theme.colors.primary + '0F',
161
+ },
162
+ ]}>
163
+ <Icon
164
+ source={'arrow_chevron_right_small'}
165
+ size={scaleSize(22)}
166
+ color={theme.colors.primary}
167
+ />
168
+ </TouchableOpacity>
169
+ ) : (
170
+ <TouchableOpacity onPress={onPressRightAction}>
171
+ <Text color={theme.colors.primary} typography={buttonTypo}>
172
+ {buttonTitle}
173
+ </Text>
174
+ </TouchableOpacity>
64
175
  )}
176
+ </View>
177
+ );
178
+ };
179
+
180
+ if (textOnly) {
181
+ return (
182
+ <View style={isSection && styles.margin}>
65
183
  <RNText
66
- style={[
67
- typeStyle,
68
- flexStyle,
69
- styles.title,
70
- {
71
- fontFamily: `${theme.font}-${titleWeight}`,
72
- },
73
- ]}>
184
+ numberOfLines={numberOfLines}
185
+ style={[styleSheet[typography], styles.title]}>
74
186
  {title}
75
187
  </RNText>
76
- {showAction && type !== 'screen' && renderAction()}
77
188
  </View>
78
- {!!description && type !== 'screen' && (
79
- <Text typography={'description_s'} color={theme.colors.text.secondary}>
80
- {description}
81
- </Text>
82
- )}
189
+ );
190
+ }
191
+
192
+ return (
193
+ <View style={[style, styles.wrapper, isSection && styles.margin]}>
194
+ {renderIcon()}
195
+ {renderContent()}
196
+ {renderActionRight()}
83
197
  </View>
84
198
  );
85
199
  };
package/Title/styles.ts CHANGED
@@ -1,9 +1,13 @@
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: {
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,36 +15,65 @@ 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),
21
29
  },
22
- screen: {
23
- fontSize: scaleSize(36),
24
- lineHeight: scaleSize(44),
30
+ actionIcon: {
31
+ borderRadius: Radius.M,
32
+ alignItems: 'center',
33
+ justifyContent: 'center',
25
34
  },
26
- title: {
27
- marginRight: Spacing.XS,
35
+ icon: {
36
+ marginRight: Spacing.S,
37
+ borderRadius: Radius.XS,
28
38
  },
29
- container: {
39
+ wrapper: {
30
40
  flexDirection: 'row',
41
+ },
42
+ margin: {
43
+ marginTop: Spacing.S,
44
+ },
45
+ iconView: {
46
+ marginRight: Spacing.S,
47
+ },
48
+ iconRight: {
49
+ width: scaleSize(22),
50
+ height: scaleSize(22),
51
+ borderRadius: Radius.M,
31
52
  alignItems: 'center',
32
- width: '100%',
53
+ justifyContent: 'center',
54
+ marginLeft: Spacing.S,
33
55
  },
34
- actionIcon: {
56
+ iconLeft: {
57
+ width: scaleSize(18),
58
+ height: scaleSize(18),
35
59
  borderRadius: Radius.M,
36
60
  alignItems: 'center',
37
61
  justifyContent: 'center',
62
+ marginHorizontal: Spacing.XS,
38
63
  },
39
- icon: {
40
- marginRight: Spacing.XS,
41
- borderRadius: Radius.XS,
64
+ iconLeftView: {
65
+ flexDirection: 'row',
66
+ alignItems: 'center',
42
67
  },
43
- wrapper: {
44
- width: '100%',
68
+ contentView: {marginRight: Spacing.S, flex: 1},
69
+ title: {
70
+ fontWeight: 'bold',
71
+ color: Colors.black_17,
72
+ },
73
+ badge: {
74
+ marginLeft: Spacing.XS,
75
+ },
76
+ description: {
77
+ marginTop: Spacing.XS,
45
78
  },
46
79
  });
package/Title/types.ts CHANGED
@@ -1,51 +1,20 @@
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';
1
+ import {ViewStyle} from 'react-native';
9
2
 
10
- /**
11
- * Required. The text of the title.
12
- */
3
+ export type TitleProps = {
4
+ type?: 'card' | 'section';
5
+ size?: 'small' | 'medium' | 'large';
13
6
  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' | 'small';
26
-
27
- /**
28
- * Optional. Represents the name or key of the icon to be displayed alongside the title.
29
- */
30
7
  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;
8
+ description?: string;
9
+ iconColor?: string;
10
+ iconAlign?: 'top' | 'middle' | 'bottom';
11
+ showRightAction?: boolean;
12
+ showTrailingAction?: boolean;
13
+ badgeLabel?: string;
14
+ buttonTitle?: string;
15
+ buttonSize?: 'small' | 'large';
16
+ onPressRightAction?: () => void;
17
+ onPressTrailingAction?: () => void;
18
+ textOnly?: boolean;
19
+ style?: ViewStyle;
51
20
  };