@momo-kits/foundation 0.168.1-rn862.1 → 0.169.2

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 (109) hide show
  1. package/Application/BottomSheet.hooks.ts +195 -0
  2. package/Application/BottomSheet.parts.tsx +147 -0
  3. package/Application/BottomSheet.styles.ts +43 -0
  4. package/Application/BottomSheet.tsx +76 -279
  5. package/Application/BottomTab/ActiveIndicator.tsx +90 -0
  6. package/Application/BottomTab/BottomTabBar.styles.ts +65 -0
  7. package/Application/BottomTab/BottomTabBar.tsx +229 -276
  8. package/Application/BottomTab/BottomTabInset.tsx +14 -0
  9. package/Application/BottomTab/CurvedContainer.tsx +153 -0
  10. package/Application/BottomTab/CustomBottomTabItem.tsx +132 -108
  11. package/Application/BottomTab/DuoBarCompression.tsx +4 -12
  12. package/Application/BottomTab/DuoRailTabBar.tsx +227 -0
  13. package/Application/BottomTab/DuoTabBar.styles.ts +81 -0
  14. package/Application/BottomTab/DuoTabBar.tsx +29 -495
  15. package/Application/BottomTab/TabBarIcon.tsx +160 -72
  16. package/Application/BottomTab/TabScreen.tsx +164 -0
  17. package/Application/BottomTab/index.tsx +84 -351
  18. package/Application/BottomTab/metrics.ts +164 -0
  19. package/Application/BottomTab/tabItems.ts +46 -0
  20. package/Application/BottomTab/usePressLift.ts +32 -0
  21. package/Application/Components/DuoGlassBackground.tsx +7 -9
  22. package/Application/Components/HeaderAnimated.tsx +1 -1
  23. package/Application/Components/HeaderBackground.tsx +1 -1
  24. package/Application/Components/HeaderExtendHeader.tsx +17 -11
  25. package/Application/Components/HeaderRight.styles.ts +144 -0
  26. package/Application/Components/HeaderRight.tsx +6 -528
  27. package/Application/Components/HeaderTitle.shared.ts +43 -0
  28. package/Application/Components/HeaderTitle.styles.ts +125 -0
  29. package/Application/Components/HeaderTitle.tsx +12 -576
  30. package/Application/Components/HeaderToolkitAction.tsx +208 -0
  31. package/Application/Components/NavigationButton.tsx +9 -6
  32. package/Application/Components/SearchHeader.tsx +1 -1
  33. package/Application/Components/SwipeBackHaptic.tsx +95 -0
  34. package/Application/Components/TitleJourney.tsx +110 -0
  35. package/Application/Components/TitleLocation.tsx +73 -0
  36. package/Application/Components/TitleUser.tsx +304 -0
  37. package/Application/Components/useToolkitActions.tsx +233 -0
  38. package/Application/ModalIconButton.tsx +66 -0
  39. package/Application/ModalScreen.tsx +39 -18
  40. package/Application/Navigation.ts +1 -1
  41. package/Application/NavigationContainer.tsx +7 -8
  42. package/Application/StackScreen.tracking.ts +158 -0
  43. package/Application/StackScreen.tsx +10 -137
  44. package/Application/WidgetContainer.tsx +10 -3
  45. package/Application/__tests__/modalLayout.test.ts +128 -0
  46. package/Application/hooks.ts +137 -0
  47. package/Application/index.ts +13 -1
  48. package/Application/modalLayout.ts +177 -0
  49. package/Application/navigationOptions.tsx +217 -0
  50. package/Application/types.header.ts +116 -0
  51. package/Application/types.tabs.ts +48 -0
  52. package/Application/types.theme.ts +87 -0
  53. package/Application/types.ts +12 -244
  54. package/Application/utils.ts +107 -0
  55. package/Badge/BadgeRibbon.tsx +3 -3
  56. package/Badge/styles.ts +2 -0
  57. package/Button/index.tsx +16 -136
  58. package/Button/styles.ts +1 -1
  59. package/Button/utils.ts +139 -0
  60. package/CheckBox/index.tsx +1 -6
  61. package/Divider/DashDivider.tsx +10 -11
  62. package/Divider/index.tsx +18 -8
  63. package/Image/index.tsx +1 -46
  64. package/Input/Input.tsx +7 -8
  65. package/Input/InputDropDown.tsx +3 -4
  66. package/Input/InputMoney.tsx +38 -164
  67. package/Input/InputMoneyView.tsx +187 -0
  68. package/Input/InputOTP.tsx +1 -1
  69. package/Input/InputPhoneNumber.tsx +5 -1
  70. package/Input/InputSearch.tsx +2 -108
  71. package/Input/InputTextArea.tsx +1 -5
  72. package/Input/SearchTextTyping.tsx +104 -0
  73. package/Input/common.tsx +4 -4
  74. package/Input/moneyUtils.ts +17 -0
  75. package/Input/styles.ts +26 -2
  76. package/Layout/FloatingButton.tsx +22 -21
  77. package/Layout/ReservedRegions.tsx +21 -4
  78. package/Layout/Screen.tsx +74 -670
  79. package/Layout/Section.tsx +1 -2
  80. package/Layout/index.ts +10 -4
  81. package/Layout/layoutMetrics.ts +58 -0
  82. package/Layout/layoutTypes.ts +86 -0
  83. package/Layout/screenContent.tsx +90 -0
  84. package/Layout/screenFooter.tsx +53 -0
  85. package/Layout/screenHeader.tsx +315 -0
  86. package/Layout/screenQuickReturn.tsx +67 -0
  87. package/Layout/screenScroll.ts +110 -0
  88. package/Layout/screenTypes.ts +134 -0
  89. package/Layout/styles.ts +2 -0
  90. package/Layout/utils.ts +10 -144
  91. package/Loader/DotLoader.tsx +7 -3
  92. package/Loader/ProgressBar.tsx +2 -6
  93. package/Loader/Spinner.tsx +7 -3
  94. package/Loader/styles.ts +4 -0
  95. package/Popup/PopupNotify.tsx +70 -64
  96. package/Popup/PopupPromotion.tsx +5 -4
  97. package/Popup/types.ts +7 -0
  98. package/Popup/utils.ts +46 -24
  99. package/Radio/index.tsx +2 -10
  100. package/Radio/styles.ts +6 -0
  101. package/Skeleton/index.tsx +1 -9
  102. package/Skeleton/styles.ts +1 -0
  103. package/Tag/index.tsx +3 -3
  104. package/Text/index.tsx +11 -2
  105. package/Title/index.tsx +2 -9
  106. package/Title/styles.ts +6 -0
  107. package/package.json +21 -22
  108. package/Application/device.ts +0 -29
  109. package/Application/utils.tsx +0 -497
package/Button/index.tsx CHANGED
@@ -17,9 +17,16 @@ import {
17
17
  SkeletonContext,
18
18
  } from '../Context';
19
19
  import { Text } from '../Text';
20
- import { Typography } from '../Text/types';
21
- import { Colors, Spacing } from '../Consts';
20
+ import { Spacing } from '../Consts';
22
21
  import styles from './styles';
22
+ import {
23
+ getIconSize,
24
+ getIconSpace,
25
+ getTextColor,
26
+ getTypeStyle,
27
+ getTypography,
28
+ shouldShowLoading,
29
+ } from './utils';
23
30
  import { Icon } from '../Icon';
24
31
  import { Skeleton } from '../Skeleton';
25
32
  import LottieView from 'lottie-react-native';
@@ -99,25 +106,6 @@ const Button: FC<ButtonProps> = ({
99
106
  pressAnim.value = withTiming(0, { duration: 100 });
100
107
  };
101
108
 
102
- /**
103
- * determine loading position
104
- * @param left
105
- * @param right
106
- * @param isLeft
107
- */
108
- const shouldShowLoading = (
109
- left?: string,
110
- right?: string,
111
- isLeft?: boolean,
112
- ): boolean => {
113
- const hasLeft = !!left;
114
- const hasRight = !!right;
115
-
116
- const loadingOnLeft = (!hasLeft && !hasRight) || (hasLeft && !hasRight);
117
-
118
- return isLeft === loadingOnLeft;
119
- };
120
-
121
109
  /**
122
110
  * export size style
123
111
  */
@@ -126,120 +114,12 @@ const Button: FC<ButtonProps> = ({
126
114
  return styleSheet[size ?? 'small'];
127
115
  };
128
116
 
129
- /**
130
- * export type style
131
- */
132
- const getTypeStyle = () => {
133
- switch (type) {
134
- case 'disabled':
135
- return {
136
- backgroundColor: theme.colors.background.disable,
137
- };
138
- case 'primary':
139
- return { backgroundColor: theme.colors.primary };
140
- case 'secondary':
141
- return {
142
- backgroundColor: theme.colors.background.surface,
143
- borderWidth: 1,
144
- borderColor: theme.colors.border.default,
145
- };
146
- case 'outline':
147
- return {
148
- backgroundColor: theme.colors.background.surface,
149
- borderWidth: 1,
150
- borderColor: color ?? theme.colors.primary,
151
- };
152
- case 'tonal':
153
- return {
154
- backgroundColor: theme.colors.background.tonal,
155
- };
156
- case 'danger':
157
- return {
158
- backgroundColor: theme.colors.error.primary,
159
- };
160
- case 'text':
161
- return {};
162
- default:
163
- return { backgroundColor: theme.colors.primary };
164
- }
165
- };
166
-
167
- /**
168
- * export icon size
169
- */
170
- const getIconSize = () => {
171
- switch (size) {
172
- case 'large':
173
- return 24;
174
- case 'medium':
175
- case 'small':
176
- return 16;
177
- default:
178
- return 24;
179
- }
180
- };
181
-
182
- /**
183
- * export icon space
184
- */
185
- const getIconSpace = () => {
186
- switch (size) {
187
- case 'large':
188
- case 'medium':
189
- return 8;
190
- case 'small':
191
- return 4;
192
- default:
193
- return 8;
194
- }
195
- };
196
-
197
- /**
198
- * export typography style
199
- */
200
- const getTypography = (): Typography => {
201
- switch (size) {
202
- case 'large':
203
- return 'action_default_bold';
204
- case 'medium':
205
- return 'action_s_bold';
206
- case 'small':
207
- return 'action_xs_bold';
208
- default:
209
- return 'action_default_bold';
210
- }
211
- };
212
-
213
- /**
214
- * export text color
215
- */
216
- const getTextColor = (): string => {
217
- switch (type) {
218
- case 'disabled':
219
- return theme.colors.text.disable;
220
- case 'primary':
221
- return Colors.black_01;
222
- case 'secondary':
223
- return theme.colors.text.default;
224
- case 'outline':
225
- return color ?? theme.colors.primary;
226
- case 'tonal':
227
- return theme.colors.primary;
228
- case 'danger':
229
- return Colors.black_01;
230
- case 'text':
231
- return color ?? theme.colors.primary;
232
- default:
233
- return Colors.black_01;
234
- }
235
- };
236
-
237
117
  /**
238
118
  * render title
239
119
  */
240
120
  const renderTitle = () => {
241
- const typography = getTypography();
242
- const textColor = getTextColor();
121
+ const typography = getTypography(size);
122
+ const textColor = getTextColor(type, theme, color);
243
123
  return (
244
124
  <Text typography={typography} color={textColor} numberOfLines={1}>
245
125
  {title}
@@ -252,9 +132,9 @@ const Button: FC<ButtonProps> = ({
252
132
  * @param position
253
133
  */
254
134
  const renderIcon = (position: 'left' | 'right') => {
255
- const iconSize = getIconSize();
256
- const space = getIconSpace();
257
- const textColor = tintColor ?? getTextColor();
135
+ const iconSize = getIconSize(size);
136
+ const space = getIconSpace(size);
137
+ const textColor = tintColor ?? getTextColor(type, theme, color);
258
138
 
259
139
  const isLeft = position === 'left';
260
140
  const icon = isLeft ? iconLeft : iconRight;
@@ -322,7 +202,7 @@ const Button: FC<ButtonProps> = ({
322
202
  }
323
203
 
324
204
  const sizeStyle = getSizeStyle();
325
- const typeStyle = getTypeStyle();
205
+ const typeStyle = getTypeStyle(type, theme, color);
326
206
  const containerStyle: ViewStyle = StyleSheet.flatten([
327
207
  full && { width: '100%' },
328
208
  loading && { opacity: 0.75 },
@@ -364,7 +244,7 @@ const Button: FC<ButtonProps> = ({
364
244
  onPressOut={animateOut}
365
245
  >
366
246
  <Reanimated.View style={[buttonStyle, animatedStyle]}>
367
- {renderIcon('left')}
247
+ {renderIcon('left')}
368
248
  {renderTitle()}
369
249
  {renderIcon('right')}
370
250
  {gradientPros && (
package/Button/styles.ts CHANGED
@@ -56,7 +56,7 @@ export default StyleSheet.create({
56
56
  right: 2,
57
57
  borderRadius: 6,
58
58
  borderWidth: 0.5,
59
- borderColor: '#FFF9E1',
59
+ borderColor: Colors.yellow_09,
60
60
  },
61
61
  skeleton: {
62
62
  paddingHorizontal: 0,
@@ -0,0 +1,139 @@
1
+ import { Colors } from '../Consts';
2
+ import { Theme } from '../Application/types';
3
+ import { Typography } from '../Text/types';
4
+ import { ButtonProps } from './index';
5
+
6
+ /**
7
+ * determine loading position
8
+ * @param left
9
+ * @param right
10
+ * @param isLeft
11
+ */
12
+ export const shouldShowLoading = (
13
+ left?: string,
14
+ right?: string,
15
+ isLeft?: boolean,
16
+ ): boolean => {
17
+ const hasLeft = !!left;
18
+ const hasRight = !!right;
19
+
20
+ const loadingOnLeft = (!hasLeft && !hasRight) || (hasLeft && !hasRight);
21
+
22
+ return isLeft === loadingOnLeft;
23
+ };
24
+
25
+ /**
26
+ * export type style
27
+ */
28
+ export const getTypeStyle = (
29
+ type: ButtonProps['type'],
30
+ theme: Theme,
31
+ color?: string,
32
+ ) => {
33
+ switch (type) {
34
+ case 'disabled':
35
+ return {
36
+ backgroundColor: theme.colors.background.disable,
37
+ };
38
+ case 'primary':
39
+ return { backgroundColor: theme.colors.primary };
40
+ case 'secondary':
41
+ return {
42
+ backgroundColor: theme.colors.background.surface,
43
+ borderWidth: 1,
44
+ borderColor: theme.colors.border.default,
45
+ };
46
+ case 'outline':
47
+ return {
48
+ backgroundColor: theme.colors.background.surface,
49
+ borderWidth: 1,
50
+ borderColor: color ?? theme.colors.primary,
51
+ };
52
+ case 'tonal':
53
+ return {
54
+ backgroundColor: theme.colors.background.tonal,
55
+ };
56
+ case 'danger':
57
+ return {
58
+ backgroundColor: theme.colors.error.primary,
59
+ };
60
+ case 'text':
61
+ return {};
62
+ default:
63
+ return { backgroundColor: theme.colors.primary };
64
+ }
65
+ };
66
+
67
+ /**
68
+ * export icon size
69
+ */
70
+ export const getIconSize = (size: ButtonProps['size']) => {
71
+ switch (size) {
72
+ case 'large':
73
+ return 24;
74
+ case 'medium':
75
+ case 'small':
76
+ return 16;
77
+ default:
78
+ return 24;
79
+ }
80
+ };
81
+
82
+ /**
83
+ * export icon space
84
+ */
85
+ export const getIconSpace = (size: ButtonProps['size']) => {
86
+ switch (size) {
87
+ case 'large':
88
+ case 'medium':
89
+ return 8;
90
+ case 'small':
91
+ return 4;
92
+ default:
93
+ return 8;
94
+ }
95
+ };
96
+
97
+ /**
98
+ * export typography style
99
+ */
100
+ export const getTypography = (size: ButtonProps['size']): Typography => {
101
+ switch (size) {
102
+ case 'large':
103
+ return 'action_default_bold';
104
+ case 'medium':
105
+ return 'action_s_bold';
106
+ case 'small':
107
+ return 'action_xs_bold';
108
+ default:
109
+ return 'action_default_bold';
110
+ }
111
+ };
112
+
113
+ /**
114
+ * export text color
115
+ */
116
+ export const getTextColor = (
117
+ type: ButtonProps['type'],
118
+ theme: Theme,
119
+ color?: string,
120
+ ): string => {
121
+ switch (type) {
122
+ case 'disabled':
123
+ return theme.colors.text.disable;
124
+ case 'primary':
125
+ return Colors.black_01;
126
+ case 'secondary':
127
+ return theme.colors.text.default;
128
+ case 'outline':
129
+ return color ?? theme.colors.primary;
130
+ case 'tonal':
131
+ return theme.colors.primary;
132
+ case 'danger':
133
+ return Colors.black_01;
134
+ case 'text':
135
+ return color ?? theme.colors.primary;
136
+ default:
137
+ return Colors.black_01;
138
+ }
139
+ };
@@ -77,12 +77,7 @@ const CheckBox: FC<CheckBoxProps> = ({
77
77
  showBaseLineDebug && styles.debugBaseLine,
78
78
  ]}
79
79
  >
80
- <View
81
- style={[
82
- { borderColor, backgroundColor, borderWidth: 1 },
83
- styles.checkbox,
84
- ]}
85
- >
80
+ <View style={[{ borderColor, backgroundColor }, styles.checkbox]}>
86
81
  {haveValue && (
87
82
  <Icon
88
83
  color={theme.colors.background.surface}
@@ -1,5 +1,5 @@
1
1
  import React, { useContext } from 'react';
2
- import { View, ViewStyle } from 'react-native';
2
+ import { StyleSheet, View, ViewStyle } from 'react-native';
3
3
  import { ApplicationContext } from '../Context';
4
4
  import { Spacing } from '../Consts';
5
5
  import Svg, { Line } from 'react-native-svg';
@@ -16,16 +16,7 @@ const DashDivider: React.FC<DashDividerProps> = ({ style }) => {
16
16
  const borderColor = theme.colors.border.default;
17
17
 
18
18
  return (
19
- <View
20
- style={[
21
- {
22
- width: '100%',
23
- height: 1,
24
- marginVertical: Spacing.XS,
25
- },
26
- style,
27
- ]}
28
- >
19
+ <View style={[styles.container, style]}>
29
20
  <Svg height="1" width="100%">
30
21
  <Line
31
22
  x1="0"
@@ -43,4 +34,12 @@ const DashDivider: React.FC<DashDividerProps> = ({ style }) => {
43
34
  );
44
35
  };
45
36
 
37
+ const styles = StyleSheet.create({
38
+ container: {
39
+ width: '100%',
40
+ height: 1,
41
+ marginVertical: Spacing.XS,
42
+ },
43
+ });
44
+
46
45
  export { DashDivider };
package/Divider/index.tsx CHANGED
@@ -1,5 +1,5 @@
1
1
  import React, { useContext } from 'react';
2
- import { StyleProp, View, ViewStyle } from 'react-native';
2
+ import { StyleSheet, View, ViewStyle } from 'react-native';
3
3
  import { ApplicationContext } from '../Context';
4
4
  import { Spacing } from '../Consts';
5
5
  import { DashDivider } from './DashDivider';
@@ -8,7 +8,7 @@ export interface DividerProps {
8
8
  /**
9
9
  * Custom styles for divider
10
10
  */
11
- style?: StyleProp<ViewStyle>;
11
+ style?: ViewStyle;
12
12
 
13
13
  /**
14
14
  * Enable margin vertical 4px
@@ -30,16 +30,26 @@ const Divider: React.FC<DividerProps> = ({
30
30
  return (
31
31
  <View
32
32
  style={[
33
- {
34
- height: 1,
35
- width: '100%',
36
- backgroundColor: theme.colors.border.default,
37
- marginVertical: useMargin ? Spacing.XS : 0,
38
- },
39
33
  style,
34
+ styles.divider,
35
+ useMargin ? styles.margin : styles.noMargin,
36
+ { backgroundColor: theme.colors.border.default },
40
37
  ]}
41
38
  />
42
39
  );
43
40
  };
44
41
 
42
+ const styles = StyleSheet.create({
43
+ divider: {
44
+ height: 1,
45
+ width: '100%',
46
+ },
47
+ margin: {
48
+ marginVertical: Spacing.XS,
49
+ },
50
+ noMargin: {
51
+ marginVertical: 0,
52
+ },
53
+ });
54
+
45
55
  export { Divider };
package/Image/index.tsx CHANGED
@@ -1,5 +1,5 @@
1
1
  import React, { useContext, useRef, useState } from 'react';
2
- import { Image as RNImage, StyleSheet, View } from 'react-native';
2
+ import { StyleSheet, View } from 'react-native';
3
3
  import FastImage from 'react-native-fast-image';
4
4
  import styles from './styles';
5
5
  import {
@@ -23,10 +23,6 @@ export const getImageName = (source: any): string => {
23
23
  return '';
24
24
  };
25
25
 
26
- const isDataUriSource = (source: any): boolean => {
27
- return typeof source?.uri === 'string' && source.uri.startsWith('data:');
28
- };
29
-
30
26
  const Image: React.FC<ImageProps> = ({
31
27
  style,
32
28
  source,
@@ -47,7 +43,6 @@ const Image: React.FC<ImageProps> = ({
47
43
  const [status, setStatus] = useState<Status>('success');
48
44
 
49
45
  const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
50
- const useFastImage = !isDataUriSource(source);
51
46
 
52
47
  let accessibilityLabel: any = `img|${getImageName(source)}`;
53
48
  if (component?.componentId) {
@@ -84,46 +79,6 @@ const Image: React.FC<ImageProps> = ({
84
79
  return children;
85
80
  };
86
81
 
87
- if (!useFastImage) {
88
- return (
89
- <RNImage
90
- {...rest}
91
- {...{
92
- accessibilityLabel: rest.accessibilityLabel ?? accessibilityLabel,
93
- }}
94
- source={source}
95
- style={[
96
- styles.container,
97
- style,
98
- showBaseLineDebug && styles.debugBaseLine,
99
- ]}
100
- onLoadStart={() => {
101
- error.current = false;
102
- if (status !== 'loading' && loading) {
103
- setStatus('loading');
104
- }
105
- }}
106
- onLoad={() => {
107
- error.current = false;
108
- }}
109
- onLoadEnd={() => {
110
- let current: Status = 'success';
111
- if (error.current) {
112
- current = 'error';
113
- }
114
- setStatus(prevState =>
115
- prevState !== current ? current : prevState,
116
- );
117
- }}
118
- onError={() => {
119
- error.current = true;
120
- }}
121
- >
122
- {renderContent()}
123
- </RNImage>
124
- );
125
- }
126
-
127
82
  return (
128
83
  <FastImage
129
84
  {...rest}
package/Input/Input.tsx CHANGED
@@ -14,7 +14,6 @@ import {
14
14
  import { useComponentId } from '../Application';
15
15
  import { Icon } from '../Icon';
16
16
  import { exportFontFamily, useScaleSize } from '../Text';
17
- import { Spacing } from '../Consts';
18
17
  import {
19
18
  ErrorView,
20
19
  FloatingView,
@@ -194,17 +193,17 @@ const Input = forwardRef(
194
193
  ...props.accessibilityState,
195
194
  }}
196
195
  style={[
197
- {
198
- flex: 1,
199
- paddingLeft: Spacing.M,
200
- fontSize: scaledFontSize,
201
- height: '100%',
202
- },
196
+ styles.inputField,
197
+ { fontSize: scaledFontSize },
203
198
  {
204
199
  color: textColor,
205
200
  fontFamily: exportFontFamily(fontWeight ?? 'regular'),
206
201
  },
207
- secure && haveValue && { fontSize: size === 'small' ? 18 : 22 },
202
+ secure &&
203
+ haveValue &&
204
+ (size === 'small'
205
+ ? styles.secureTextSmall
206
+ : styles.secureTextLarge),
208
207
  ]}
209
208
  defaultValue={defaultValue}
210
209
  allowFontScaling={false}
@@ -114,10 +114,9 @@ const InputDropDown = ({
114
114
  <View
115
115
  style={[
116
116
  styles.iconViewDropDown,
117
- {
118
- alignItems: multiline ? 'flex-start' : 'center',
119
- paddingTop: multiline ? Spacing.M : 0,
120
- },
117
+ multiline
118
+ ? styles.iconViewDropDownMultiline
119
+ : styles.iconViewDropDownSingle,
121
120
  ]}
122
121
  >
123
122
  <Icon source={'arrow_chevron_down_small'} />