@momo-kits/foundation 0.81.1-optimize.19 → 0.81.1-optimize.21

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.
@@ -34,7 +34,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
34
34
  new Animated.ValueXY({
35
35
  y: heightDevice,
36
36
  x: 0,
37
- }),
37
+ })
38
38
  ).current;
39
39
  const panResponder = useRef(
40
40
  PanResponder.create({
@@ -46,7 +46,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
46
46
  gestureState.dy > 0 &&
47
47
  Animated.event([null, {dy: pan.y}], {useNativeDriver: false})(
48
48
  e,
49
- gestureState,
49
+ gestureState
50
50
  );
51
51
  },
52
52
  onPanResponderRelease: (_, gestureState) => {
@@ -59,7 +59,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
59
59
  }).start();
60
60
  }
61
61
  },
62
- }),
62
+ })
63
63
  ).current;
64
64
 
65
65
  let backgroundColor = theme.colors.background.default;
@@ -209,10 +209,4 @@ const styles = StyleSheet.create({
209
209
  justifyContent: 'center',
210
210
  marginHorizontal: Spacing.M,
211
211
  },
212
- estimate: {
213
- position: 'absolute',
214
- top: -9999,
215
- left: -9999,
216
- opacity: 0,
217
- },
218
212
  });
@@ -133,7 +133,7 @@ export default function BottomTabBar({
133
133
  */
134
134
  const renderFloatingButton = useCallback(() => {
135
135
  const renderFloatingButton = () => {
136
- if (typeof floatingButton?.icon == 'string') {
136
+ if (typeof floatingButton?.icon === 'string') {
137
137
  return <Icon source={floatingButton?.icon} size={32} color={'white'} />;
138
138
  }
139
139
  return floatingButton?.icon;
@@ -94,7 +94,7 @@ const BottomTab: React.FC<BottomTabProps> = ({
94
94
  }}>
95
95
  {tabs.map(item => {
96
96
  const isNum = !isNaN(parseInt(`${item?.badgeLabel}`));
97
- const isDot = typeof item?.badgeLabel == 'string' && !item?.badgeLabel;
97
+ const isDot = typeof item?.badgeLabel === 'string' && !item?.badgeLabel;
98
98
  return (
99
99
  <Tab.Screen
100
100
  key={item.name}
@@ -41,7 +41,7 @@ const NavigationButton: React.FC<NavigationButtonProps> = ({
41
41
  }) => {
42
42
  const {theme} = useContext(ApplicationContext);
43
43
  let buttonStyle: ViewStyle = {backgroundColor: '#00000066'};
44
- if (tintColor != Colors.black_01) {
44
+ if (tintColor !== Colors.black_01) {
45
45
  buttonStyle = {
46
46
  backgroundColor: 'transparent',
47
47
  borderColor: '#00000066',
@@ -238,7 +238,7 @@ const HeaderCustom: React.FC<TitleCustomProps> = ({
238
238
  tintColor,
239
239
  dotColor,
240
240
  }) => {
241
- const avatarStyle = imageShape == 'circle' ? styles.circle : styles.square;
241
+ const avatarStyle = imageShape === 'circle' ? styles.circle : styles.square;
242
242
  const header = (
243
243
  <View style={Styles.row}>
244
244
  <View>
@@ -265,7 +265,7 @@ const HeaderCustom: React.FC<TitleCustomProps> = ({
265
265
 
266
266
  const HeaderRightAction: React.FC<any> = ({children, ...restProps}) => {
267
267
  const validateType = (child: React.ReactElement) => {
268
- const valid = child?.type === NavigationButton || child?.type == Fragment;
268
+ const valid = child?.type === NavigationButton || child?.type === Fragment;
269
269
  if (__DEV__ && !valid) {
270
270
  console.warn(
271
271
  'HeaderRightAction contains element type of NavigationButton, Please check again.',
@@ -306,7 +306,7 @@ const HeaderToolkitAction: React.FC<any> = ({
306
306
  const {onAction} = toolConfig ?? {};
307
307
 
308
308
  let backgroundColor;
309
- if (tintColor != Colors.black_01) {
309
+ if (tintColor !== Colors.black_01) {
310
310
  backgroundColor = 'transparent';
311
311
  }
312
312
 
@@ -1,11 +1,92 @@
1
1
  import React, {useContext, useEffect, useLayoutEffect, useRef} from 'react';
2
+ import {useHeaderHeight} from '@react-navigation/stack';
3
+ import {InteractionManager, Linking, View} from 'react-native';
2
4
  import {ScreenParams} from './types';
3
5
  import Navigation from './Navigation';
4
6
  import {ApplicationContext, MiniAppContext, ScreenContext} from './index';
5
7
  import {GridSystem} from '../Layout';
6
- import {useHeaderHeight} from '@react-navigation/stack';
7
- import {Alert, InteractionManager} from 'react-native';
8
+ import {Text} from '../Text';
9
+ import {Colors, Radius, Spacing} from '../Consts';
10
+
11
+ /**
12
+ * Empty screen for unvalidated screen name
13
+ * @constructor
14
+ */
15
+ const EmptyScreen: React.FC = () => {
16
+ return (
17
+ <View
18
+ style={{
19
+ backgroundColor: Colors.black_01,
20
+ padding: Spacing.M,
21
+ borderRadius: Radius.M,
22
+ }}>
23
+ <Text typography={'header_m_bold'}>Unvalidated screen name</Text>
24
+ <Text
25
+ typography={'description_default_regular'}
26
+ style={{paddingVertical: Spacing.S}}>
27
+ Your screen has not been rendered because Platform has not detected the
28
+ screen name. Please migrate to support this feature.
29
+ </Text>
30
+ <Text typography={'header_default'} style={{width: '100%'}}>
31
+ Possible fixes:
32
+ </Text>
33
+ <View style={{marginLeft: Spacing.S}}>
34
+ <Text typography={'body_default_regular'}>1. Off webpack config</Text>
35
+ <Text typography={'body_default_regular'}>
36
+ 2. Screen name refactoring
37
+ </Text>
38
+ <View style={{marginLeft: Spacing.S}}>
39
+ <Text
40
+ typography={'description_default_regular'}
41
+ style={{marginBottom: Spacing.S}}>
42
+ - Với các screen push/import dạng arrow function ={'>'} đổi thành
43
+ named function
44
+ </Text>
45
+ <Text
46
+ typography={'description_default_regular'}
47
+ style={{marginBottom: Spacing.S}}>
48
+ - Với các screen import dạng High Order Component ={'>'} rename
49
+ generic function thành named function
50
+ </Text>
51
+ <Text
52
+ typography={'description_default_regular'}
53
+ style={{marginBottom: Spacing.S}}>
54
+ - Với Tab Navigator, Platform sẽ lấy Tab Container làm screen name.
55
+ Trong trường hợp miniapp muốn track riêng action cho từng tab, tham
56
+ khảo theo docs
57
+ </Text>
58
+ </View>
59
+ </View>
60
+ <Text typography={'header_s_semibold'}>More information: </Text>
61
+ <Text
62
+ typography={'body_default_regular'}
63
+ color={Colors.blue_01}
64
+ onPress={() => {
65
+ Linking.openURL(
66
+ 'https://gitlab.mservice.com.vn/momo-platform/mini-app/-/tree/vn.momo.uikits/dev/app'
67
+ );
68
+ }}>
69
+ Mini App: vn.momo.uikits/dev
70
+ </Text>
71
+ <Text
72
+ typography={'body_default_regular'}
73
+ color={Colors.blue_01}
74
+ onPress={() => {
75
+ Linking.openURL(
76
+ 'https://docs.google.com/presentation/d/1bIFoh8gRXb6hsnGJz4O1Kxg4_oNikB1KuuEt2wULCDM/edit?usp=sharing'
77
+ );
78
+ }}>
79
+ https://docs.google.com/presentation/d/1bIFoh8gRXb6hsnGJz4O1Kxg4_oNikB1KuuEt2wULCDM/edit?usp=sharing
80
+ </Text>
81
+ </View>
82
+ );
83
+ };
8
84
 
85
+ /**
86
+ * container for stack screen
87
+ * @param props
88
+ * @constructor
89
+ */
9
90
  const StackScreen: React.FC<ScreenParams> = props => {
10
91
  const {theme, showGrid, navigator} = useContext(ApplicationContext);
11
92
  const startTime = useRef(Date.now());
@@ -50,8 +131,10 @@ const StackScreen: React.FC<ScreenParams> = props => {
50
131
  * tracking for screen
51
132
  */
52
133
  useEffect(() => {
53
- if (__DEV__ && (!screenName || screenName == 'Invalid')) {
54
- Alert.alert('Design system', `Unvalidated screen name "${screenName}" !`);
134
+ if (['Invalid', 'screen'].includes(screenName) && context.enableAutoId) {
135
+ setTimeout(() => {
136
+ navigator?.showModal({screen: EmptyScreen});
137
+ }, 300);
55
138
  }
56
139
 
57
140
  navigator?.maxApi?.of?.({screenName});
@@ -94,7 +94,7 @@ const getOptions = (params: NavigationOptions, theme: Theme) => {
94
94
  };
95
95
  }
96
96
 
97
- if (typeof params.surface == 'boolean') {
97
+ if (typeof params.surface === 'boolean') {
98
98
  if (params.surface) {
99
99
  options = {
100
100
  ...options,
@@ -503,4 +503,4 @@
503
503
  "zalopay_icon": {
504
504
  "uri": "https://static.momocdn.net/app/img/kits/icon_bank/zalopay_icon.png"
505
505
  }
506
- }
506
+ }
package/Button/index.tsx CHANGED
@@ -94,7 +94,7 @@ const Button: FC<ButtonProps> = ({
94
94
  if (loading) {
95
95
  state = 'loading';
96
96
  }
97
- if (gradient?.length > 0 && type == 'primary') {
97
+ if (gradient?.length > 0 && type === 'primary') {
98
98
  gradientPros = {
99
99
  colors: gradient,
100
100
  start: {x: 1, y: 0.5},
@@ -217,9 +217,9 @@ const Button: FC<ButtonProps> = ({
217
217
  */
218
218
  const renderTitle = () => {
219
219
  const typography = getTypography();
220
- const color = getTextColor();
220
+ const textColor = getTextColor();
221
221
  return (
222
- <Text typography={typography} color={color} numberOfLines={1}>
222
+ <Text typography={typography} color={textColor} numberOfLines={1}>
223
223
  {title}
224
224
  </Text>
225
225
  );
@@ -231,7 +231,7 @@ const Button: FC<ButtonProps> = ({
231
231
  const renderLeading = () => {
232
232
  const iconSize = getIconSize();
233
233
  const marginRight = getIconSpace();
234
- const color = tintColor ?? getTextColor();
234
+ const textColor = tintColor ?? getTextColor();
235
235
 
236
236
  if (loading) {
237
237
  return (
@@ -256,7 +256,7 @@ const Button: FC<ButtonProps> = ({
256
256
  styles.leading,
257
257
  {width: iconSize, height: iconSize, marginRight},
258
258
  ]}>
259
- <Icon color={color} source={iconLeft} size={iconSize} />
259
+ <Icon color={textColor} source={iconLeft} size={iconSize} />
260
260
  </View>
261
261
  );
262
262
  }
@@ -266,7 +266,7 @@ const Button: FC<ButtonProps> = ({
266
266
  * render trailing
267
267
  */
268
268
  const renderTrailing = () => {
269
- const color = tintColor ?? getTextColor();
269
+ const textColor = tintColor ?? getTextColor();
270
270
  const marginLeft = getIconSpace();
271
271
 
272
272
  if (iconRight) {
@@ -277,7 +277,7 @@ const Button: FC<ButtonProps> = ({
277
277
  styles.trailing,
278
278
  {width: iconSize, height: iconSize, marginLeft},
279
279
  ]}>
280
- <Icon color={color} source={iconRight} size={iconSize} />
280
+ <Icon color={textColor} source={iconRight} size={iconSize} />
281
281
  </View>
282
282
  );
283
283
  }
package/Icon/index.tsx CHANGED
@@ -33,7 +33,7 @@ const Icon: React.FC<IconProps> = ({
33
33
  loading={false}
34
34
  source={getIconSource()}
35
35
  style={[style, {width: size, height: size}]}
36
- resizeMode='contain'
36
+ resizeMode="contain"
37
37
  {...tintColorProps}
38
38
  />
39
39
  );
package/Icon/types.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import {ImageStyle} from 'react-native-fast-image';
2
- import {StyleProp} from "react-native";
2
+ import {StyleProp} from 'react-native';
3
3
 
4
4
  export type IconProps = {
5
5
  /**
package/Image/index.tsx CHANGED
@@ -19,7 +19,6 @@ const Image: React.FC<ImageProps> = ({
19
19
  source,
20
20
  loading = true,
21
21
  children,
22
- params,
23
22
  accessibilityLabel,
24
23
  ...rest
25
24
  }) => {
@@ -4,7 +4,7 @@ import {ApplicationContext, ComponentContext} from '../Application';
4
4
  import {Styles} from '../Consts';
5
5
  import {Icon} from '../Icon';
6
6
  import {Loader} from '../Loader';
7
- import {ErrorView, FloatingView, getBorderColor, getSizeStyle} from './common';
7
+ import {ErrorView, FloatingView, getSizeStyle} from './common';
8
8
  import {InputDropDownProps} from './index';
9
9
  import styles from './styles';
10
10
 
@@ -61,7 +61,7 @@ const InputDropDown = ({
61
61
  styles.inputWrapper,
62
62
  {backgroundColor: theme.colors.background.surface},
63
63
  getSizeStyle(size),
64
- getBorderColor(theme, false, errorMessage, disabled),
64
+ // getBorderColor(theme, false, errorMessage, disabled),
65
65
  ]}>
66
66
  <FloatingView
67
67
  floatingValue={floatingValue}
@@ -1,6 +1,7 @@
1
1
  import React, {
2
2
  forwardRef,
3
3
  useContext,
4
+ useEffect,
4
5
  useImperativeHandle,
5
6
  useRef,
6
7
  useState,
@@ -40,6 +41,7 @@ const InputMoney = forwardRef(
40
41
  defaultValue = '',
41
42
  accessibilityLabel,
42
43
  hintText,
44
+ value: _value,
43
45
  ...props
44
46
  }: InputMoneyProps,
45
47
  ref,
@@ -48,6 +50,13 @@ const InputMoney = forwardRef(
48
50
  const [focused, setFocused] = useState(false);
49
51
  const inputRef = useRef<TextInput>(null);
50
52
 
53
+ useEffect(() => {
54
+ if (_value) {
55
+ setValue(validateText(_value));
56
+ onChangeText?.(formatMoneyToNumber(_value, 'đ').toString());
57
+ }
58
+ }, [_value]);
59
+
51
60
  const validateText = (text: string) => {
52
61
  const valueFormat = formatMoneyToNumber(text, 'đ');
53
62
  return formatNumberToMoney(valueFormat, 'đ');
@@ -71,11 +71,8 @@ const InputOTP = forwardRef(
71
71
  errorMessage,
72
72
  errorSpacing,
73
73
  floatingValue = 'Label',
74
- floatingIconColor,
75
- floatingIcon,
76
74
  placeholder,
77
75
  onChangeText,
78
- onFocus,
79
76
  onBlur,
80
77
  dataType = 'number',
81
78
  params,
@@ -125,16 +122,16 @@ const InputOTP = forwardRef(
125
122
  onChangeText?.(text);
126
123
  };
127
124
 
128
- const renderInputs = (length: number) => {
125
+ const renderInputs = (inputLength: number) => {
129
126
  const TextInputs: React.ReactNode[] = [];
130
- for (let i = 0; i < length; i++) {
127
+ for (let i = 0; i < inputLength; i++) {
131
128
  TextInputs.push(
132
129
  <View>
133
130
  {focused && value.length === i ? (
134
- <OTPCaret index={i} length={length} />
131
+ <OTPCaret index={i} length={inputLength} />
135
132
  ) : (
136
133
  <Text
137
- style={i !== length - 1 && {marginRight: Spacing.L}}
134
+ style={i !== inputLength - 1 && {marginRight: Spacing.L}}
138
135
  color={
139
136
  !!value[i]
140
137
  ? theme.colors.text.default
@@ -44,7 +44,6 @@ const InputTextArea = forwardRef(
44
44
  required,
45
45
  errorSpacing,
46
46
  style,
47
- accessibilityLabel,
48
47
  hintText,
49
48
  ...props
50
49
  }: InputTextAreaProps,
package/Input/index.tsx CHANGED
@@ -6,13 +6,6 @@ import InputOTP from './InputOTP';
6
6
  import InputSearch from './InputSearch';
7
7
  import InputTextArea from './InputTextArea';
8
8
 
9
- export interface InputRef {
10
- focus: () => void;
11
- blur: () => void;
12
- clear: () => void;
13
- setText: (text: string) => void;
14
- }
15
-
16
9
  export interface InputProps extends TextInputProps {
17
10
  /**
18
11
  * Optional. Defines the size of the Input component.
@@ -105,14 +98,8 @@ export interface InputProps extends TextInputProps {
105
98
  hintText?: string;
106
99
  }
107
100
 
108
- type InputPropsWithoutSizeAndIcon = Omit<
109
- InputProps,
110
- 'size' | 'icon' | 'iconColor'
111
- >;
112
-
113
- type InputPropsWithoutPlaceholder = Omit<InputProps, 'placeholder'>;
114
-
115
- export interface InputTextAreaProps extends InputPropsWithoutSizeAndIcon {
101
+ export interface InputTextAreaProps
102
+ extends Omit<InputProps, 'size' | 'icon' | 'iconColor'> {
116
103
  /**
117
104
  * Optional. Defines the height of the InputTextArea component.
118
105
  * It can be used to set a specific height for the text area.
@@ -132,6 +119,9 @@ export interface InputSearchProps extends TextInputProps {
132
119
  */
133
120
  showButtonText?: boolean;
134
121
 
122
+ /**
123
+ * Optional. Represents the value for the floating title in the InputSearch component.
124
+ */
135
125
  onPressButtonText?: () => void;
136
126
 
137
127
  /**
@@ -145,18 +135,22 @@ export interface InputSearchProps extends TextInputProps {
145
135
  icon?: string;
146
136
 
147
137
  /**
148
- *
138
+ * Optional. If `true`, the user won't be able to interact with the Input component.
149
139
  */
150
140
  hasColorBG?: boolean;
151
141
 
142
+ /**
143
+ * Optional. Represents the style of the InputSearch component.
144
+ */
152
145
  params?: any;
153
146
  }
154
147
 
155
- export interface InputMoneyProps extends InputPropsWithoutPlaceholder {}
148
+ export interface InputMoneyProps extends Omit<InputProps, 'placeholder'> {}
156
149
 
157
150
  export type OTPInputLength = 2 | 4 | 6 | 8 | 10;
158
151
 
159
- export interface InputOTPProps extends InputPropsWithoutSizeAndIcon {
152
+ export interface InputOTPProps
153
+ extends Omit<InputProps, 'size' | 'icon' | 'iconColor'> {
160
154
  /**
161
155
  * Optional. Defines the length of the OTP (One Time Password) input.
162
156
  * Can be 2, 4, 6, 8, or 10.
package/Input/styles.ts CHANGED
@@ -8,6 +8,7 @@ export default StyleSheet.create({
8
8
  flex: 1,
9
9
  paddingLeft: Spacing.M,
10
10
  fontSize: scaleSize(14),
11
+ height: '100%',
11
12
  },
12
13
  wrapper: {
13
14
  width: '100%',
package/Input/utils.ts CHANGED
@@ -61,7 +61,7 @@ const formatMoneyToNumber = (money: string, currencyUnit: string) => {
61
61
  };
62
62
  const checkTyping = (text: string, value: boolean, setValue: any) => {
63
63
  let typing = text?.length > 0;
64
- if (typing != value) {
64
+ if (typing !== value) {
65
65
  setValue(typing);
66
66
  }
67
67
  };
package/Layout/Card.tsx CHANGED
@@ -86,7 +86,7 @@ const Card: React.FC<CardProps> = ({
86
86
  {rows.map((i: React.ReactElement, index: number) => {
87
87
  return (
88
88
  <View key={`Item${cursor}${index}`} style={{flexDirection: 'row'}}>
89
- {index != 0 && (
89
+ {index !== 0 && (
90
90
  <View style={{width: gridContext.gutterSize}}></View>
91
91
  )}
92
92
  {i}
@@ -126,14 +126,14 @@ const Card: React.FC<CardProps> = ({
126
126
  rows = [item];
127
127
  }
128
128
 
129
- if (i == arrayChild.length - 1) {
129
+ if (i === arrayChild.length - 1) {
130
130
  cursor += 1;
131
131
  element.push(addRowView(rows, cursor, true));
132
132
  }
133
133
  }
134
134
  } else {
135
135
  element.push(children);
136
- if (children?.type == Fragment) {
136
+ if (children?.type === Fragment) {
137
137
  return renderView(children?.props.children);
138
138
  }
139
139
  }
@@ -34,7 +34,7 @@ export const FloatingButton: React.FC<FloatingButtonProps> = ({
34
34
  }: FloatingButtonProps) => {
35
35
  const {theme} = useContext(ApplicationContext);
36
36
  const maxWidth = useRef(0);
37
- const minWidth = size == 'small' ? 36 : 48;
37
+ const minWidth = size === 'small' ? 36 : 48;
38
38
  const [opacityAnimated] = useState(new Animated.Value(0)); // Initial opacity set to 0
39
39
  const [widthAnimated, setWidthAnimated] = useState<Animated.Value>();
40
40
  const lastOffset = useRef(0);
@@ -84,7 +84,7 @@ export const FloatingButton: React.FC<FloatingButtonProps> = ({
84
84
  });
85
85
 
86
86
  return () => {
87
- if (listener != null) {
87
+ if (listener !== null) {
88
88
  animatedValue?.removeListener(listener);
89
89
  }
90
90
  };
@@ -123,7 +123,7 @@ export const FloatingButton: React.FC<FloatingButtonProps> = ({
123
123
  right: position === 'right' ? 12 : undefined,
124
124
  alignSelf: position === 'center' ? 'center' : 'flex-end',
125
125
  width: widthAnimated,
126
- height: size == 'small' ? 36 : 48,
126
+ height: size === 'small' ? 36 : 48,
127
127
  backgroundColor: theme.colors.primary,
128
128
  bottom,
129
129
  },
@@ -53,7 +53,7 @@ const GridSystem: React.FC<any> = ({
53
53
  {list.map((_, index) => {
54
54
  return (
55
55
  <View style={{flexDirection: 'row'}} key={index.toString()}>
56
- {index != -0 && <View style={{width: grid.gutterSize}} />}
56
+ {index !== -0 && <View style={{width: grid.gutterSize}} />}
57
57
  <View
58
58
  key={`Grid${index.toString()}`}
59
59
  pointerEvents="none"
@@ -85,7 +85,7 @@ const Section: React.FC<SectionProps> = ({
85
85
  {rows.map((i: React.ReactElement, index: number) => {
86
86
  return (
87
87
  <View key={`Card${cursor}${index}`} style={{flexDirection: 'row'}}>
88
- {index != 0 && (
88
+ {index !== 0 && (
89
89
  <View style={{width: gridContext.gutterSize}}></View>
90
90
  )}
91
91
  {i}
@@ -125,14 +125,14 @@ const Section: React.FC<SectionProps> = ({
125
125
  rows = [item];
126
126
  }
127
127
 
128
- if (i == arrayChild.length - 1) {
128
+ if (i === arrayChild.length - 1) {
129
129
  cursor += 1;
130
130
  element.push(addRowView(rows, cursor, true));
131
131
  }
132
132
  }
133
133
  } else {
134
134
  element.push(children);
135
- if (children?.type == Fragment) {
135
+ if (children?.type === Fragment) {
136
136
  return renderView(children?.props.children);
137
137
  }
138
138
  }
package/Layout/utils.ts CHANGED
@@ -12,7 +12,7 @@ const validateChildren = (
12
12
  ) => {
13
13
  const validateType = (child: React.ReactElement) => {
14
14
  const valid = childrenTypes.some(
15
- childrenType => child?.type === childrenType || child?.type == Fragment,
15
+ childrenType => child?.type === childrenType || child?.type === Fragment,
16
16
  );
17
17
  if (!valid) {
18
18
  console.warn(
@@ -42,7 +42,7 @@ const useGridSystem = () => {
42
42
  useEffect(() => {
43
43
  const subscription: any = Dimensions.addEventListener('change', () => {
44
44
  const newColumns = Dimensions.get('window').width > 600 ? 24 : 12;
45
- if (newColumns != numberOfColumns) {
45
+ if (newColumns !== numberOfColumns) {
46
46
  setNumberOfColumns(newColumns);
47
47
  }
48
48
  });
@@ -139,7 +139,7 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
139
139
  );
140
140
  };
141
141
 
142
- if (buttonDirection == 'auto') {
142
+ if (buttonDirection === 'auto') {
143
143
  if (
144
144
  secondary?.title &&
145
145
  (secondary.title.length > 12 || primary.title.length > 12)
@@ -148,7 +148,7 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
148
148
  }
149
149
  return renderRow();
150
150
  }
151
- if (buttonDirection == 'row') {
151
+ if (buttonDirection === 'row') {
152
152
  return renderRow();
153
153
  }
154
154
  return renderColumn();
@@ -204,7 +204,7 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
204
204
  typography={'body_default_regular'}
205
205
  onTextLayout={({nativeEvent: {lines}}) => {
206
206
  const enableScroll = lines.length > 3;
207
- if (enableScroll != scrollContent) {
207
+ if (enableScroll !== scrollContent) {
208
208
  setScrollContent(enableScroll);
209
209
  }
210
210
  }}>
package/Title/index.tsx CHANGED
@@ -143,8 +143,14 @@ const Title: FC<TitleProps> = ({
143
143
  const renderActionRight = () => {
144
144
  if (!showRightAction || showTrailingAction) return false;
145
145
 
146
+ const lineHeight = styleSheet[typography].lineHeight;
147
+
146
148
  return (
147
- <View>
149
+ <View
150
+ style={{
151
+ height: lineHeight,
152
+ justifyContent: 'center',
153
+ }}>
148
154
  {!buttonTitle ? (
149
155
  <TouchableOpacity
150
156
  onPress={onPressRightAction}
@@ -174,7 +180,6 @@ const Title: FC<TitleProps> = ({
174
180
  if (textOnly) {
175
181
  return (
176
182
  <View style={isSection && styles.margin}>
177
- zZ
178
183
  <RNText
179
184
  numberOfLines={numberOfLines}
180
185
  style={[styleSheet[typography], styles.title]}>
package/code-scanner.js CHANGED
@@ -2,142 +2,159 @@ const scanner = require('react-scanner');
2
2
  const fs = require('fs');
3
3
  const path = require('path');
4
4
 
5
- const scan = async (config) => {
6
- return await scanner.run(config);
5
+ const scan = async config => {
6
+ return await scanner.run(config);
7
7
  };
8
8
 
9
- const calcSum = (array) => {
10
- return array.reduce((a, b) => a + b, 0);
9
+ const calcSum = array => {
10
+ return array.reduce((a, b) => a + b, 0);
11
11
  };
12
12
 
13
- const calculateAdoptionRate = async (branchName , kitJsonPath , miniappJsonPath , reactNativeJsonPath , fsJsonPath ) => {
14
- const kitJson = require(kitJsonPath);
15
- const miniAppJson = require(miniappJsonPath);
16
- const reactNativeJson = require(reactNativeJsonPath);
17
- const fsJson = require(fsJsonPath);
18
-
19
- const numOfKitComponents = calcSum(Object.values(kitJson));
20
- const numOfMiniAppComponents = calcSum(Object.values(miniAppJson));
21
- const numOfReactNativeComponents = calcSum(Object.values(reactNativeJson));
22
- const numOfFSComponents = calcSum(Object.values(fsJson));
23
-
24
- const adoptionRate = ((numOfKitComponents + numOfReactNativeComponents + numOfFSComponents) / numOfMiniAppComponents) * 100;
25
-
26
- return {
27
- miniAppName: branchName,
28
- numOfKitComponents: numOfKitComponents,
29
- numOfMiniAppComponents: numOfMiniAppComponents,
30
- numOfReactNativeComponents: numOfReactNativeComponents,
31
- numOfFSComponents: numOfFSComponents,
32
- adoptionRate: adoptionRate.toFixed(2) + '%'
33
- }
13
+ const calculateAdoptionRate = async (
14
+ branchName,
15
+ kitJsonPath,
16
+ miniappJsonPath,
17
+ reactNativeJsonPath,
18
+ fsJsonPath,
19
+ ) => {
20
+ const kitJson = require(kitJsonPath);
21
+ const miniAppJson = require(miniappJsonPath);
22
+ const reactNativeJson = require(reactNativeJsonPath);
23
+ const fsJson = require(fsJsonPath);
24
+
25
+ const numOfKitComponents = calcSum(Object.values(kitJson));
26
+ const numOfMiniAppComponents = calcSum(Object.values(miniAppJson));
27
+ const numOfReactNativeComponents = calcSum(Object.values(reactNativeJson));
28
+ const numOfFSComponents = calcSum(Object.values(fsJson));
29
+
30
+ const adoptionRate =
31
+ ((numOfKitComponents + numOfReactNativeComponents + numOfFSComponents) /
32
+ numOfMiniAppComponents) *
33
+ 100;
34
+
35
+ return {
36
+ miniAppName: branchName,
37
+ numOfKitComponents: numOfKitComponents,
38
+ numOfMiniAppComponents: numOfMiniAppComponents,
39
+ numOfReactNativeComponents: numOfReactNativeComponents,
40
+ numOfFSComponents: numOfFSComponents,
41
+ adoptionRate: adoptionRate.toFixed(2) + '%',
42
+ };
34
43
  };
35
44
 
36
- function ensureFileExists(filePath , defaultContent = {}) {
37
- if (!fs.existsSync(filePath)) {
38
- fs.mkdirSync(path.dirname(filePath), { recursive: true });
39
- fs.writeFileSync(filePath, JSON.stringify(defaultContent, null, 2));
40
- }
45
+ function ensureFileExists(filePath, defaultContent = {}) {
46
+ if (!fs.existsSync(filePath)) {
47
+ fs.mkdirSync(path.dirname(filePath), {recursive: true});
48
+ fs.writeFileSync(filePath, JSON.stringify(defaultContent, null, 2));
49
+ }
41
50
  }
42
51
 
43
52
  const sendMessage = ({
44
- numOfKitComponents,
45
- numOfMiniAppComponents,
46
- numOfFSComponents,
47
- numOfReactNativeComponents,
48
- adoptionRate,
49
- miniAppName = ''
50
- }) => {
51
- const url = 'https://chat.googleapis.com/v1/spaces/AAAAL9P6G8M/messages?key=AIzaSyDdI0hCZtE6vySjMm-WEfRq3CPzqKqqsHI&token=fnwfYuH_u0KicBnKTSSm9S0qV6azJH5v6URm8HR7V2g';
52
-
53
- const data = {
54
- text: `MiniApp: ${miniAppName}\nNumber of kit's components: ${numOfKitComponents}\nNumber of miniapp's components: ${numOfMiniAppComponents}\nNumber of FS's components: ${numOfFSComponents}\nNumber of React Native's components: ${numOfReactNativeComponents}\nAdoption rate: ${adoptionRate}`
55
- };
56
-
57
- fetch(url, {
58
- method: 'POST',
59
- headers: {
60
- 'Content-Type': 'application/json'
61
- },
62
- body: JSON.stringify(data)
53
+ numOfKitComponents,
54
+ numOfMiniAppComponents,
55
+ numOfFSComponents,
56
+ numOfReactNativeComponents,
57
+ adoptionRate,
58
+ miniAppName = '',
59
+ }) => {
60
+ const url =
61
+ 'https://chat.googleapis.com/v1/spaces/AAAAL9P6G8M/messages?key=AIzaSyDdI0hCZtE6vySjMm-WEfRq3CPzqKqqsHI&token=fnwfYuH_u0KicBnKTSSm9S0qV6azJH5v6URm8HR7V2g';
62
+
63
+ const data = {
64
+ text: `MiniApp: ${miniAppName}\nNumber of kit's components: ${numOfKitComponents}\nNumber of miniapp's components: ${numOfMiniAppComponents}\nNumber of FS's components: ${numOfFSComponents}\nNumber of React Native's components: ${numOfReactNativeComponents}\nAdoption rate: ${adoptionRate}`,
65
+ };
66
+
67
+ fetch(url, {
68
+ method: 'POST',
69
+ headers: {
70
+ 'Content-Type': 'application/json',
71
+ },
72
+ body: JSON.stringify(data),
73
+ })
74
+ .then(response => response.json())
75
+ .then(data => {
76
+ console.log('Success:', data);
63
77
  })
64
- .then(response => response.json())
65
- .then(data => {
66
- console.log('Success:', data);
67
- })
68
- .catch((error) => {
69
- console.error('Error:', error);
70
- });
71
- }
78
+ .catch(error => {
79
+ console.error('Error:', error);
80
+ });
81
+ };
72
82
 
73
83
  const main = async () => {
74
- const rootPath = `${__dirname}/../../../`
75
- const app = path.join(`${__dirname}/../../../`, 'app.json');
76
- const appJson = require(app)
77
- const branchName = appJson.appId
78
-
79
- if (!branchName || !branchName.includes("vn.momo")){
80
- return
81
- }
82
-
83
- const scanPath = path.join(rootPath, 'src')
84
- const kitJsonPath = path.join(rootPath, './scan/kit.json')
85
- const miniappJsonPath = path.join(rootPath, './scan/miniapp.json')
86
- const reactNativeJsonPath = path.join(rootPath, './scan/RN.json')
87
- const fsJsonPath = path.join(rootPath, './scan/verLib.json')
88
-
89
- const allKitsReg = /@momo-kits/;
90
- const fsReg = /^(?:@fs-mobile-platform\/(components|investment|screens)|@miniapp-platform\/(components|foundation))$/;
91
- const RNReg = 'react-native'
92
-
93
- const config1 = {
94
- crawlFrom: scanPath,
95
- includeSubComponents: true,
96
- importedFrom: allKitsReg,
97
- processors: [['count-components', { outputTo: kitJsonPath }]],
98
- rootDir: process.cwd(),
99
- };
100
-
101
- const config2 = {
102
- crawlFrom: scanPath,
103
- includeSubComponents: true,
104
- processors: [['count-components', { outputTo: miniappJsonPath }]],
105
- rootDir: process.cwd(),
106
- };
107
-
108
- const config3 = {
109
- crawlFrom: scanPath,
110
- includeSubComponents: true,
111
- importedFrom: RNReg,
112
- processors: [['count-components', { outputTo: reactNativeJsonPath }]],
113
- rootDir: process.cwd(),
114
- };
115
-
116
- const config4 = {
117
- crawlFrom: scanPath,
118
- includeSubComponents: true,
119
- importedFrom: fsReg,
120
- processors: [['count-components', { outputTo: fsJsonPath }]],
121
- rootDir: process.cwd(),
122
- };
123
-
124
- try {
125
- ensureFileExists(kitJsonPath, {});
126
- ensureFileExists(miniappJsonPath, {});
127
- ensureFileExists(reactNativeJsonPath, {});
128
- ensureFileExists(fsJsonPath, {});
129
-
130
- await scan(config1);
131
- await scan(config2);
132
- await scan(config3);
133
- await scan(config4);
134
-
135
- const result = await calculateAdoptionRate(branchName,kitJsonPath, miniappJsonPath, reactNativeJsonPath, fsJsonPath);
136
- sendMessage(result)
137
- console.log(result)
138
- } catch (error) {
139
- console.error("Error during scan or calculation:", error);
140
- }
84
+ const rootPath = `${__dirname}/../../../`;
85
+ const app = path.join(`${__dirname}/../../../`, 'app.json');
86
+ const appJson = require(app);
87
+ const branchName = appJson.appId;
88
+
89
+ if (!branchName || !branchName.includes('vn.momo')) {
90
+ return;
91
+ }
92
+
93
+ const scanPath = path.join(rootPath, 'src');
94
+ const kitJsonPath = path.join(rootPath, './scan/kit.json');
95
+ const miniappJsonPath = path.join(rootPath, './scan/miniapp.json');
96
+ const reactNativeJsonPath = path.join(rootPath, './scan/RN.json');
97
+ const fsJsonPath = path.join(rootPath, './scan/verLib.json');
98
+
99
+ const allKitsReg = /@momo-kits/;
100
+ const fsReg =
101
+ /^(?:@fs-mobile-platform\/(components|investment|screens)|@miniapp-platform\/(components|foundation))$/;
102
+ const RNReg = 'react-native';
103
+
104
+ const config1 = {
105
+ crawlFrom: scanPath,
106
+ includeSubComponents: true,
107
+ importedFrom: allKitsReg,
108
+ processors: [['count-components', {outputTo: kitJsonPath}]],
109
+ rootDir: process.cwd(),
110
+ };
111
+
112
+ const config2 = {
113
+ crawlFrom: scanPath,
114
+ includeSubComponents: true,
115
+ processors: [['count-components', {outputTo: miniappJsonPath}]],
116
+ rootDir: process.cwd(),
117
+ };
118
+
119
+ const config3 = {
120
+ crawlFrom: scanPath,
121
+ includeSubComponents: true,
122
+ importedFrom: RNReg,
123
+ processors: [['count-components', {outputTo: reactNativeJsonPath}]],
124
+ rootDir: process.cwd(),
125
+ };
126
+
127
+ const config4 = {
128
+ crawlFrom: scanPath,
129
+ includeSubComponents: true,
130
+ importedFrom: fsReg,
131
+ processors: [['count-components', {outputTo: fsJsonPath}]],
132
+ rootDir: process.cwd(),
133
+ };
134
+
135
+ try {
136
+ ensureFileExists(kitJsonPath, {});
137
+ ensureFileExists(miniappJsonPath, {});
138
+ ensureFileExists(reactNativeJsonPath, {});
139
+ ensureFileExists(fsJsonPath, {});
140
+
141
+ await scan(config1);
142
+ await scan(config2);
143
+ await scan(config3);
144
+ await scan(config4);
145
+
146
+ const result = await calculateAdoptionRate(
147
+ branchName,
148
+ kitJsonPath,
149
+ miniappJsonPath,
150
+ reactNativeJsonPath,
151
+ fsJsonPath,
152
+ );
153
+ sendMessage(result);
154
+ console.log(result);
155
+ } catch (error) {
156
+ console.error('Error during scan or calculation:', error);
157
+ }
141
158
  };
142
159
 
143
160
  main();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.81.1-optimize.19",
3
+ "version": "0.81.1-optimize.21",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {},
@@ -18,7 +18,7 @@
18
18
  "@react-navigation/core": "5.16.1",
19
19
  "@react-navigation/native": "5.9.8",
20
20
  "@react-navigation/routers": "5.7.4",
21
- "lottie-react-native": "3.3.2",
21
+ "lottie-react-native": "git+https://gitlab.mservice.com.vn/momo-platform/momo-lottie-react-native.git",
22
22
  "@react-navigation/stack": "https://oauth2:eX-jVhzQdLc343AjD3Sc@gitlab.mservice.com.vn/momo-platform/react-navigation-stack.git"
23
23
  },
24
24
  "peerDependencies": {
package/publish.sh CHANGED
@@ -1,23 +1,28 @@
1
1
  #!/bin/bash
2
+
3
+ # Prepare dist files
2
4
  rm -rf dist
3
5
  mkdir dist
4
-
5
- cp . ./dist
6
-
7
-
8
- # GET VERSION from mck_package.json
9
- VERSIONSTRING=( v$(jq .version package.json) )
10
- VERSION=(${VERSIONSTRING//[\"]/})
11
- echo VERSION: $VERSION
12
-
13
- rsync -r --verbose --exclude '*.mdx' --exclude '*Demo.js' --exclude 'props-type.js' --exclude 'prop-types.js' ./* dist
14
-
6
+ rsync -r --exclude=/dist ./* dist
15
7
  cd dist
16
- npm publish --tag latest --access=public
17
8
 
18
- #clear dist and package json
9
+ #if [ "$1" == "stable" ]; then
10
+ # npm version $(npm view @momo-kits/foundation@stable version)
11
+ # npm version patch
12
+ # npm publish --tag stable --access=public
13
+ #elif [ "$1" == "latest" ]; then
14
+ # npm version $(npm view @momo-kits/foundation@latest version)
15
+ # npm version prerelease --preid=rc
16
+ # npm publish --tag latest --access=public
17
+ #else
18
+ # npm version $(npm view @momo-kits/foundation@beta version)
19
+ # npm version prerelease --preid=beta
20
+ npm publish --tag beta --access=public
21
+ #fi
22
+
23
+ PACKAGE_NAME=$(npm pkg get name)
24
+ NEW_PACKAGE_VERSION=$(npm pkg get version)
25
+
26
+ # Clean up
19
27
  cd ..
20
28
  rm -rf dist
21
-
22
-
23
- #curl -X POST -H 'Content-Type: application/json' 'https://chat.googleapis.com/v1/spaces/AAAAbP8987c/messages?key=AIzaSyDdI0hCZtE6vySjMm-WEfRq3CPzqKqqsHI&token=UGSFRvk_oYb9uGsAgs31bVvMm6jDkmD8zihGm3eyaQA%3D&threadKey=JoaXTEYaNNkl' -d '{"text": "@momo-kits/core new version release: '*"$VERSION"*' https://www.npmjs.com/package/@momo-kits/foundation"}'
package/tsconfig.json CHANGED
@@ -19,6 +19,6 @@
19
19
  "resolveJsonModule": true,
20
20
  "skipLibCheck": true,
21
21
  "strict": true,
22
- "target": "esnext",
22
+ "target": "esnext"
23
23
  }
24
24
  }