@momo-kits/foundation 0.154.2-beta.1 → 0.155.1-beta.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 (52) hide show
  1. package/Application/BottomSheet.tsx +15 -10
  2. package/Application/BottomTab/BottomTabBar.tsx +7 -2
  3. package/Application/BottomTab/CustomBottomTabItem.tsx +8 -1
  4. package/Application/Components/HeaderAnimated.tsx +2 -12
  5. package/Application/Components/HeaderBackground.tsx +7 -3
  6. package/Application/Components/HeaderExtendHeader.tsx +6 -12
  7. package/Application/Components/HeaderRight.tsx +0 -9
  8. package/Application/Components/HeaderTitle.tsx +13 -17
  9. package/Application/Components/NavigationButton.tsx +0 -9
  10. package/Application/Components/SearchHeader.tsx +7 -2
  11. package/Application/Localize.ts +2 -2
  12. package/Badge/Badge.tsx +9 -2
  13. package/Badge/BadgeDot.tsx +15 -5
  14. package/Badge/BadgeRibbon.tsx +10 -2
  15. package/Badge/styles.ts +1 -0
  16. package/Button/index.tsx +7 -8
  17. package/Button/styles.ts +2 -0
  18. package/CheckBox/index.tsx +13 -2
  19. package/CheckBox/styles.ts +5 -4
  20. package/Icon/index.tsx +15 -2
  21. package/IconButton/index.tsx +9 -2
  22. package/IconButton/styles.ts +3 -2
  23. package/Image/index.tsx +12 -2
  24. package/Image/styles.ts +3 -1
  25. package/Input/Input.tsx +15 -2
  26. package/Input/InputDropDown.tsx +13 -2
  27. package/Input/InputMoney.tsx +15 -2
  28. package/Input/InputOTP.tsx +20 -3
  29. package/Input/InputPhoneNumber.tsx +15 -2
  30. package/Input/InputSearch.tsx +15 -2
  31. package/Input/InputTextArea.tsx +12 -10
  32. package/Input/styles.ts +1 -0
  33. package/Layout/Card.tsx +5 -1
  34. package/Layout/Item.tsx +5 -1
  35. package/Layout/Section.tsx +5 -1
  36. package/Layout/styles.ts +3 -2
  37. package/Pagination/PaginationDot.tsx +8 -2
  38. package/Pagination/PaginationNumber.tsx +13 -6
  39. package/Pagination/PaginationScroll.tsx +11 -2
  40. package/Pagination/PaginationWhiteDot.tsx +14 -7
  41. package/Pagination/styles.ts +4 -3
  42. package/Popup/PopupNotify.tsx +4 -1
  43. package/Popup/PopupPromotion.tsx +8 -2
  44. package/Radio/index.tsx +9 -1
  45. package/Radio/styles.ts +5 -4
  46. package/Switch/index.tsx +6 -2
  47. package/Switch/styles.ts +3 -1
  48. package/Tag/index.tsx +28 -16
  49. package/Title/index.tsx +10 -2
  50. package/Title/styles.ts +4 -3
  51. package/package.json +1 -1
  52. package/Tag/styles.ts +0 -25
@@ -1,17 +1,24 @@
1
- import React, {FC} from 'react';
2
- import {View} from 'react-native';
3
- import {ChildPaginationProps} from './types';
1
+ import React, { FC, useContext } from 'react';
2
+ import { View } from 'react-native';
3
+ import { ChildPaginationProps } from './types';
4
4
  import styles from './styles';
5
- import {Text} from '../Text';
6
- import {Colors} from '../Consts';
5
+ import { Text } from '../Text';
6
+ import { Colors } from '../Consts';
7
+ import { MiniAppContext } from '../Context';
7
8
 
8
9
  const PaginationNumber: FC<ChildPaginationProps> = ({
9
10
  activeIndex = 0,
10
11
  dataLength = 2,
11
12
  style,
12
13
  }) => {
14
+ const context = useContext<any>(MiniAppContext);
15
+
16
+ const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
17
+
13
18
  return (
14
- <View style={[style, styles.row]}>
19
+ <View
20
+ style={[style, styles.row, showBaseLineDebug && styles.debugBaseLine]}
21
+ >
15
22
  <View style={styles.paginationNumberContainer}>
16
23
  <Text color={Colors.black_01} typography={'label_default_medium'}>{`${
17
24
  activeIndex + 1
@@ -2,7 +2,7 @@ import React, { FC, useContext, useRef, useState } from 'react';
2
2
  import { Animated, View } from 'react-native';
3
3
  import { ScrollIndicatorProps } from './types';
4
4
  import styles from './styles';
5
- import { ApplicationContext } from '../Context';
5
+ import { ApplicationContext, MiniAppContext } from '../Context';
6
6
 
7
7
  const INDICATOR_WIDTH = 24;
8
8
  const INDICATOR_CONTAINER_WIDTH = 72;
@@ -12,10 +12,13 @@ const PaginationScroll: FC<ScrollIndicatorProps> = ({
12
12
  scrollViewRef,
13
13
  }) => {
14
14
  const { theme } = useContext(ApplicationContext);
15
+ const context = useContext<any>(MiniAppContext);
15
16
  const left = useRef(new Animated.Value(0)).current;
16
17
  const [scrollViewWidth, setScrollViewWidth] = useState(0);
17
18
  const [scrollContentWidth, setScrollContentWidth] = useState(0);
18
19
 
20
+ const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
21
+
19
22
  const translateX = () => {
20
23
  if (scrollViewWidth && scrollContentWidth) {
21
24
  const value = left.interpolate({
@@ -80,7 +83,13 @@ const PaginationScroll: FC<ScrollIndicatorProps> = ({
80
83
  );
81
84
  };
82
85
  return (
83
- <View style={[style, styles.scrollContainer]}>
86
+ <View
87
+ style={[
88
+ style,
89
+ styles.scrollContainer,
90
+ showBaseLineDebug && styles.debugBaseLine,
91
+ ]}
92
+ >
84
93
  {renderScrollView()}
85
94
  {scrollContentWidth > scrollViewWidth && renderIndicator()}
86
95
  </View>
@@ -1,15 +1,20 @@
1
- import React, {FC} from 'react';
2
- import {View} from 'react-native';
3
- import {ChildPaginationProps} from './types';
1
+ import React, { FC, useContext } from 'react';
2
+ import { View } from 'react-native';
3
+ import { ChildPaginationProps } from './types';
4
4
  import styles from './styles';
5
5
  import Dot from './Dot';
6
- import {Colors, Spacing} from '../Consts';
6
+ import { Colors, Spacing } from '../Consts';
7
+ import { MiniAppContext } from '../Context';
7
8
 
8
9
  const PaginationWhiteDot: FC<ChildPaginationProps> = ({
9
10
  dataLength = 2,
10
11
  activeIndex = 0,
11
12
  style,
12
13
  }) => {
14
+ const context = useContext<any>(MiniAppContext);
15
+
16
+ const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
17
+
13
18
  const renderDots = () => {
14
19
  const dots: React.ReactElement[] = [];
15
20
  for (let i = 0; i < dataLength; i++) {
@@ -17,8 +22,8 @@ const PaginationWhiteDot: FC<ChildPaginationProps> = ({
17
22
  <Dot
18
23
  key={`Dot${i}`}
19
24
  style={[
20
- i !== dataLength - 1 ? {marginRight: Spacing.XS} : {},
21
- {backgroundColor: Colors.black_01},
25
+ i !== dataLength - 1 ? { marginRight: Spacing.XS } : {},
26
+ { backgroundColor: Colors.black_01 },
22
27
  ]}
23
28
  active={activeIndex === i}
24
29
  />,
@@ -27,7 +32,9 @@ const PaginationWhiteDot: FC<ChildPaginationProps> = ({
27
32
  return dots;
28
33
  };
29
34
  return (
30
- <View style={[style, styles.row]}>
35
+ <View
36
+ style={[style, styles.row, showBaseLineDebug && styles.debugBaseLine]}
37
+ >
31
38
  <View style={styles.paginationWhiteContainer}>{renderDots()}</View>
32
39
  </View>
33
40
  );
@@ -1,5 +1,5 @@
1
- import {StyleSheet} from 'react-native';
2
- import {Colors, Radius, Spacing} from '../Consts';
1
+ import { StyleSheet } from 'react-native';
2
+ import { Colors, Radius, Spacing } from '../Consts';
3
3
 
4
4
  export default StyleSheet.create({
5
5
  activeDot: {
@@ -46,5 +46,6 @@ export default StyleSheet.create({
46
46
  height: 4,
47
47
  borderRadius: Radius.XS,
48
48
  },
49
- row: {flexDirection: 'row'},
49
+ row: { flexDirection: 'row' },
50
+ debugBaseLine: { borderWidth: 1, borderColor: Colors.green_06 },
50
51
  });
@@ -8,7 +8,7 @@ import {
8
8
  } from 'react-native';
9
9
  import { ApplicationContext, MiniAppContext } from '../Context';
10
10
  import { Button } from '../Button';
11
- import { Radius, Spacing, Styles } from '../Consts';
11
+ import { Colors, Radius, Spacing, Styles } from '../Consts';
12
12
  import { Icon } from '../Icon';
13
13
  import { Image } from '../Image';
14
14
  import { useScaleSize, Text } from '../Text';
@@ -33,6 +33,7 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
33
33
  const { width: widthDevice } = Dimensions.get('window');
34
34
  const scaledMaxHeight = useScaleSize(172);
35
35
 
36
+ const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
36
37
  const closeAction = useRef('touch_outside');
37
38
  let descriptionStyle = {};
38
39
  let Description: any = View;
@@ -211,6 +212,7 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
211
212
  backgroundColor: theme.colors.background.surface,
212
213
  width: widthDevice - Spacing.XL * 2,
213
214
  },
215
+ showBaseLineDebug && styles.debugBaseLine,
214
216
  ]}
215
217
  >
216
218
  {!!image && <Image source={{ uri: image }} style={styles.image} />}
@@ -264,6 +266,7 @@ const styles = StyleSheet.create({
264
266
  container: {
265
267
  borderRadius: Radius.L,
266
268
  },
269
+ debugBaseLine: { borderWidth: 1, borderColor: Colors.green_06 },
267
270
  image: {
268
271
  borderTopLeftRadius: Radius.L,
269
272
  borderTopRightRadius: Radius.L,
@@ -3,7 +3,7 @@ import { Dimensions, StyleSheet, TouchableOpacity, View } from 'react-native';
3
3
  import { PopupPromotionProps } from './types';
4
4
  import { ApplicationContext, MiniAppContext } from '../Context';
5
5
  import { Image } from '../Image';
6
- import { Radius, Spacing } from '../Consts';
6
+ import { Colors, Radius, Spacing } from '../Consts';
7
7
  import { Icon } from '../Icon';
8
8
 
9
9
  const PopupPromotion: React.FC<PopupPromotionProps> = ({
@@ -18,6 +18,8 @@ const PopupPromotion: React.FC<PopupPromotionProps> = ({
18
18
  const { width: widthDevice } = Dimensions.get('window');
19
19
  const closeAction = useRef('touch_outside');
20
20
 
21
+ const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
22
+
21
23
  /**
22
24
  * tracking
23
25
  */
@@ -95,7 +97,10 @@ const PopupPromotion: React.FC<PopupPromotionProps> = ({
95
97
  };
96
98
 
97
99
  return (
98
- <View accessibilityLabel={'popup_promotion'}>
100
+ <View
101
+ accessibilityLabel={'popup_promotion'}
102
+ style={showBaseLineDebug && styles.debugBaseLine}
103
+ >
99
104
  <TouchableOpacity onPress={() => onAction(onActionClick)}>
100
105
  <Image
101
106
  source={{
@@ -119,6 +124,7 @@ const styles = StyleSheet.create({
119
124
  aspectRatio: 0.72,
120
125
  width: '100%',
121
126
  },
127
+ debugBaseLine: { borderWidth: 1, borderColor: Colors.green_06 },
122
128
  iconCloseContainer: {
123
129
  width: '100%',
124
130
  flexDirection: 'row',
package/Radio/index.tsx CHANGED
@@ -5,7 +5,11 @@ import { RadioProps } from './types';
5
5
  import { Text } from '../Text';
6
6
  import styles from './styles';
7
7
  import { useComponentId } from '../Application';
8
- import { ApplicationContext, ComponentContext } from '../Context';
8
+ import {
9
+ ApplicationContext,
10
+ ComponentContext,
11
+ MiniAppContext,
12
+ } from '../Context';
9
13
  import { Spacing } from '../Consts';
10
14
 
11
15
  const Radio: FC<RadioProps> = ({
@@ -21,12 +25,15 @@ const Radio: FC<RadioProps> = ({
21
25
  ...props
22
26
  }) => {
23
27
  const { theme } = useContext(ApplicationContext);
28
+ const context = useContext<any>(MiniAppContext);
24
29
  const selected = value === groupValue;
25
30
  const componentName = 'Radio';
26
31
  const { componentId } = useComponentId(
27
32
  `${componentName}${label ? `/${label}` : ''}`,
28
33
  accessibilityLabel,
29
34
  );
35
+
36
+ const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
30
37
  let disabledStyle = {};
31
38
  let checkBoxStyle = {
32
39
  borderWidth: 2,
@@ -67,6 +74,7 @@ const Radio: FC<RadioProps> = ({
67
74
  flexDirection: 'row',
68
75
  alignItems: 'center',
69
76
  },
77
+ showBaseLineDebug && styles.debugBaseLine,
70
78
  ]}
71
79
  accessibilityState={{
72
80
  checked: selected,
package/Radio/styles.ts CHANGED
@@ -1,5 +1,5 @@
1
- import {StyleSheet} from 'react-native';
2
- import {Radius, Spacing} from '../Consts';
1
+ import { StyleSheet } from 'react-native';
2
+ import { Radius, Spacing, Colors } from '../Consts';
3
3
 
4
4
  export default StyleSheet.create({
5
5
  radio: {
@@ -7,8 +7,9 @@ export default StyleSheet.create({
7
7
  width: 20,
8
8
  borderRadius: Radius.M,
9
9
  },
10
- container: {flex: 1},
10
+ container: { flex: 1 },
11
11
  radioText: {
12
12
  marginRight: Spacing.M,
13
- }
13
+ },
14
+ debugBaseLine: { borderWidth: 1, borderColor: Colors.green_06 },
14
15
  });
package/Switch/index.tsx CHANGED
@@ -1,10 +1,10 @@
1
- import React, { FC } from 'react';
1
+ import React, { FC, useContext } from 'react';
2
2
  import { TouchableOpacity, View } from 'react-native';
3
3
  import { SwitchProps } from './types';
4
4
  import styles from './styles';
5
5
  import { Colors } from '../Consts';
6
6
  import { useComponentId } from '../Application';
7
- import { ComponentContext } from '../Context';
7
+ import { ComponentContext, MiniAppContext } from '../Context';
8
8
 
9
9
  const Switch: FC<SwitchProps> = ({
10
10
  value = false,
@@ -15,12 +15,15 @@ const Switch: FC<SwitchProps> = ({
15
15
  accessibilityLabel,
16
16
  ...props
17
17
  }) => {
18
+ const context = useContext<any>(MiniAppContext);
18
19
  const circleBackgroundColor = value ? Colors.black_01 : Colors.black_03;
19
20
  const circleAlign = value ? 'flex-end' : 'flex-start';
20
21
  const componentName = 'Switch';
21
22
 
22
23
  const { componentId } = useComponentId(componentName, accessibilityLabel);
23
24
 
25
+ const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
26
+
24
27
  let backgroundColor = value ? Colors.green_03 : Colors.black_07;
25
28
  if (disabled) {
26
29
  backgroundColor = value ? Colors.green_09 : Colors.black_05;
@@ -49,6 +52,7 @@ const Switch: FC<SwitchProps> = ({
49
52
  style,
50
53
  styles.container,
51
54
  { backgroundColor, alignItems: circleAlign },
55
+ showBaseLineDebug && styles.debugBaseLine,
52
56
  ]}
53
57
  >
54
58
  <View
package/Switch/styles.ts CHANGED
@@ -1,4 +1,5 @@
1
- import {StyleSheet} from 'react-native';
1
+ import { StyleSheet } from 'react-native';
2
+ import { Colors } from '../Consts';
2
3
 
3
4
  export default StyleSheet.create({
4
5
  container: {
@@ -20,4 +21,5 @@ export default StyleSheet.create({
20
21
  height: 6,
21
22
  borderRadius: 4,
22
23
  },
24
+ debugBaseLine: { borderWidth: 1, borderColor: Colors.green_06 },
23
25
  });
package/Tag/index.tsx CHANGED
@@ -1,10 +1,11 @@
1
- import React, {FC} from 'react';
2
- import {View, StyleSheet} from 'react-native';
3
- import {TagProps} from './types';
4
- import {Colors, Radius, Spacing} from '../Consts';
5
- import {Icon} from '../Icon';
6
- import {Text, useScaleSize} from '../Text';
7
- import {useComponentId} from '../Application';
1
+ import React, { FC, useContext } from 'react';
2
+ import { View, StyleSheet } from 'react-native';
3
+ import { TagProps } from './types';
4
+ import { Colors, Radius, Spacing } from '../Consts';
5
+ import { Icon } from '../Icon';
6
+ import { Text, useScaleSize } from '../Text';
7
+ import { useComponentId } from '../Application';
8
+ import { MiniAppContext } from '../Context';
8
9
 
9
10
  const backgroundColor = {
10
11
  default: Colors.black_04,
@@ -33,9 +34,12 @@ const Tag: FC<TagProps> = ({
33
34
  customColor,
34
35
  accessibilityLabel,
35
36
  }) => {
37
+ const context = useContext<any>(MiniAppContext);
36
38
  const scaledHeight24 = useScaleSize(24);
37
39
  const scaledHeight18 = useScaleSize(18);
38
-
40
+
41
+ const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
42
+
39
43
  const styles = StyleSheet.create({
40
44
  container: {
41
45
  paddingHorizontal: Spacing.S,
@@ -56,21 +60,22 @@ const Tag: FC<TagProps> = ({
56
60
  icon: {
57
61
  marginRight: Spacing.XS,
58
62
  },
63
+ debugBaseLine: { borderWidth: 1, borderColor: Colors.green_06 },
59
64
  });
60
-
65
+
61
66
  let labelColor = textColor[color];
62
67
  let tagColor = backgroundColor[color];
63
68
  let sizeStyle = styles.mediumContainer;
64
69
  const componentName = 'Tag';
65
70
 
66
- const {componentId} = useComponentId(
71
+ const { componentId } = useComponentId(
67
72
  `${componentName}/${label}`,
68
- accessibilityLabel
73
+ accessibilityLabel,
69
74
  );
70
75
  //Check if custom color is [color]_03 (only check in dev mode)
71
76
  const validateCustomColor = (color: string) => {
72
77
  if (__DEV__) {
73
- const colorCore: {[key: string]: string} = Colors;
78
+ const colorCore: { [key: string]: string } = Colors;
74
79
  const primaryColors = Object.keys(Colors)
75
80
  .map(i => {
76
81
  if (i.includes('_03')) {
@@ -93,8 +98,14 @@ const Tag: FC<TagProps> = ({
93
98
 
94
99
  return (
95
100
  <View
96
- style={[style, sizeStyle, {backgroundColor: tagColor}]}
97
- accessibilityLabel={componentId}>
101
+ style={[
102
+ style,
103
+ sizeStyle,
104
+ { backgroundColor: tagColor },
105
+ showBaseLineDebug && styles.debugBaseLine,
106
+ ]}
107
+ accessibilityLabel={componentId}
108
+ >
98
109
  {!!icon && (
99
110
  <Icon
100
111
  style={styles.icon}
@@ -106,11 +117,12 @@ const Tag: FC<TagProps> = ({
106
117
  <Text
107
118
  color={labelColor}
108
119
  typography={'label_s_medium'}
109
- accessibilityLabel={`${componentId}|text`}>
120
+ accessibilityLabel={`${componentId}|text`}
121
+ >
110
122
  {label}
111
123
  </Text>
112
124
  </View>
113
125
  );
114
126
  };
115
127
 
116
- export {Tag};
128
+ export { Tag };
package/Title/index.tsx CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  import { Icon } from '../Icon';
9
9
  import { useScaleSize, Text } from '../Text';
10
10
  import { useComponentId } from '../Application';
11
- import { ApplicationContext } from '../Context';
11
+ import { ApplicationContext, MiniAppContext } from '../Context';
12
12
  import { Badge } from '../Badge';
13
13
  import { Colors } from '../Consts';
14
14
  import styles from './styles';
@@ -35,9 +35,12 @@ const Title: FC<TitleProps> = ({
35
35
  style,
36
36
  }) => {
37
37
  const { theme } = useContext(ApplicationContext);
38
+ const context = useContext<any>(MiniAppContext);
38
39
  const [badgeWidth, setBadgeWidth] = useState(0);
39
40
  const [contentWidth, setContentWidth] = useState(0);
40
41
 
42
+ const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
43
+
41
44
  const size18 = useScaleSize(18);
42
45
  const size22 = useScaleSize(22);
43
46
  // Dynamic styles using useScaleSize hook
@@ -263,7 +266,12 @@ const Title: FC<TitleProps> = ({
263
266
 
264
267
  return (
265
268
  <View
266
- style={[style, styles.wrapper, isSection && styles.margin]}
269
+ style={[
270
+ style,
271
+ styles.wrapper,
272
+ isSection && styles.margin,
273
+ showBaseLineDebug && styles.debugBaseLine,
274
+ ]}
267
275
  accessibilityLabel={componentId}
268
276
  >
269
277
  {renderIcon()}
package/Title/styles.ts CHANGED
@@ -1,5 +1,5 @@
1
- import {StyleSheet} from 'react-native';
2
- import {Colors, Radius, Spacing} from '../Consts';
1
+ import { StyleSheet } from 'react-native';
2
+ import { Colors, Radius, Spacing } from '../Consts';
3
3
 
4
4
  export default StyleSheet.create({
5
5
  actionIcon: {
@@ -40,7 +40,7 @@ export default StyleSheet.create({
40
40
  flexDirection: 'row',
41
41
  alignItems: 'center',
42
42
  },
43
- contentView: {marginRight: Spacing.S, flex: 1},
43
+ contentView: { marginRight: Spacing.S, flex: 1 },
44
44
  title: {
45
45
  fontWeight: 'bold',
46
46
  color: Colors.black_17,
@@ -51,4 +51,5 @@ export default StyleSheet.create({
51
51
  description: {
52
52
  marginTop: Spacing.XS,
53
53
  },
54
+ debugBaseLine: { borderWidth: 1, borderColor: Colors.green_06 },
54
55
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.154.2-beta.1",
3
+ "version": "0.155.1-beta.1",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {},
package/Tag/styles.ts DELETED
@@ -1,25 +0,0 @@
1
- import {StyleSheet} from 'react-native';
2
- import {Radius, Spacing} from '../Consts';
3
- import {scaleSize} from '../Text';
4
-
5
- export default StyleSheet.create({
6
- container: {
7
- paddingHorizontal: Spacing.S,
8
- borderRadius: Radius.S,
9
- flexDirection: 'row',
10
- height: scaleSize(24),
11
- alignItems: 'center',
12
- justifyContent: 'center',
13
- },
14
- mediumContainer: {
15
- paddingHorizontal: Spacing.S,
16
- borderRadius: Radius.S,
17
- height: scaleSize(18),
18
- alignItems: 'center',
19
- flexDirection: 'row',
20
- justifyContent: 'center',
21
- },
22
- icon: {
23
- marginRight: Spacing.XS,
24
- },
25
- });