@momo-kits/foundation 0.81.1-optimize.20 → 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.
- package/Application/BottomSheet.tsx +3 -9
- package/Application/BottomTab/BottomTabBar.tsx +1 -1
- package/Application/BottomTab/index.tsx +1 -1
- package/Application/Components.tsx +4 -4
- package/Application/StackScreen.tsx +87 -4
- package/Application/utils.tsx +1 -1
- package/Assets/icon_bank.json +1 -1
- package/Button/index.tsx +7 -7
- package/Icon/index.tsx +1 -1
- package/Icon/types.ts +1 -1
- package/Image/index.tsx +0 -1
- package/Input/InputDropDown.tsx +2 -2
- package/Input/InputOTP.tsx +4 -7
- package/Input/InputTextArea.tsx +0 -1
- package/Input/styles.ts +1 -0
- package/Input/utils.ts +1 -1
- package/Layout/Card.tsx +3 -3
- package/Layout/FloatingButton.tsx +3 -3
- package/Layout/GridSystem.tsx +1 -1
- package/Layout/Section.tsx +3 -3
- package/Layout/utils.ts +2 -2
- package/Popup/PopupNotify.tsx +3 -3
- package/code-scanner.js +141 -124
- package/package.json +2 -2
- package/publish.sh +21 -16
- package/tsconfig.json +1 -1
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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 {
|
|
7
|
-
import {
|
|
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 (
|
|
54
|
-
|
|
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});
|
package/Application/utils.tsx
CHANGED
package/Assets/icon_bank.json
CHANGED
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
|
|
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
|
|
220
|
+
const textColor = getTextColor();
|
|
221
221
|
return (
|
|
222
|
-
<Text typography={typography} color={
|
|
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
|
|
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={
|
|
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
|
|
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={
|
|
280
|
+
<Icon color={textColor} source={iconRight} size={iconSize} />
|
|
281
281
|
</View>
|
|
282
282
|
);
|
|
283
283
|
}
|
package/Icon/index.tsx
CHANGED
package/Icon/types.ts
CHANGED
package/Image/index.tsx
CHANGED
package/Input/InputDropDown.tsx
CHANGED
|
@@ -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,
|
|
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}
|
package/Input/InputOTP.tsx
CHANGED
|
@@ -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 = (
|
|
125
|
+
const renderInputs = (inputLength: number) => {
|
|
129
126
|
const TextInputs: React.ReactNode[] = [];
|
|
130
|
-
for (let i = 0; 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={
|
|
131
|
+
<OTPCaret index={i} length={inputLength} />
|
|
135
132
|
) : (
|
|
136
133
|
<Text
|
|
137
|
-
style={i !==
|
|
134
|
+
style={i !== inputLength - 1 && {marginRight: Spacing.L}}
|
|
138
135
|
color={
|
|
139
136
|
!!value[i]
|
|
140
137
|
? theme.colors.text.default
|
package/Input/InputTextArea.tsx
CHANGED
package/Input/styles.ts
CHANGED
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
126
|
+
height: size === 'small' ? 36 : 48,
|
|
127
127
|
backgroundColor: theme.colors.primary,
|
|
128
128
|
bottom,
|
|
129
129
|
},
|
package/Layout/GridSystem.tsx
CHANGED
|
@@ -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
|
|
56
|
+
{index !== -0 && <View style={{width: grid.gutterSize}} />}
|
|
57
57
|
<View
|
|
58
58
|
key={`Grid${index.toString()}`}
|
|
59
59
|
pointerEvents="none"
|
package/Layout/Section.tsx
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
45
|
+
if (newColumns !== numberOfColumns) {
|
|
46
46
|
setNumberOfColumns(newColumns);
|
|
47
47
|
}
|
|
48
48
|
});
|
package/Popup/PopupNotify.tsx
CHANGED
|
@@ -139,7 +139,7 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
|
|
|
139
139
|
);
|
|
140
140
|
};
|
|
141
141
|
|
|
142
|
-
if (buttonDirection
|
|
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
|
|
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
|
|
207
|
+
if (enableScroll !== scrollContent) {
|
|
208
208
|
setScrollContent(enableScroll);
|
|
209
209
|
}
|
|
210
210
|
}}>
|
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
|
|
6
|
-
|
|
5
|
+
const scan = async config => {
|
|
6
|
+
return await scanner.run(config);
|
|
7
7
|
};
|
|
8
8
|
|
|
9
|
-
const calcSum =
|
|
10
|
-
|
|
9
|
+
const calcSum = array => {
|
|
10
|
+
return array.reduce((a, b) => a + b, 0);
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
const calculateAdoptionRate = async (
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
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.
|
|
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": "
|
|
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
|
-
#
|
|
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"}'
|