@momo-kits/foundation 0.103.2-beta.11 → 0.103.2-beta.19

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.
@@ -19,7 +19,7 @@ import {Icon} from '../Icon';
19
19
 
20
20
  const BottomSheet: React.FC<BottomSheetParams> = props => {
21
21
  const {theme, navigator} = useContext(ApplicationContext);
22
- const heightDevice = Dimensions.get('screen').height; // lấy chiều cao thiết bị
22
+ const heightDevice = Dimensions.get('screen').height;
23
23
  const insets = useSafeAreaInsets();
24
24
  const {
25
25
  screen: Screen,
@@ -18,7 +18,6 @@ const Stack = createStackNavigator();
18
18
 
19
19
  const TabScreen: React.FC<NavigationScreenProps> = ({route}) => {
20
20
  let options = {};
21
-
22
21
  if (route.params?.options) {
23
22
  options = getOptions(route.params?.options);
24
23
  }
@@ -81,7 +80,11 @@ const BottomTab: React.FC<BottomTabProps> = ({
81
80
  initialRouteName={initialRouteName}
82
81
  backBehavior={'firstRoute'}
83
82
  tabBar={props => (
84
- <BottomTabBar {...props} floatingButton={floatingButton} />
83
+ <BottomTabBar
84
+ {...props}
85
+ floatingButton={floatingButton}
86
+ inactiveTintColor={theme.colors.text.secondary}
87
+ />
85
88
  )}
86
89
  tabBarOptions={{
87
90
  style: {
@@ -378,7 +378,7 @@ const HeaderToolkitAction: React.FC<any> = ({
378
378
  {runtimeTools},
379
379
  (res: {item: {action?: string; key: string}}) => {
380
380
  const {item} = res;
381
- navigator?.toolkitCallback?.(item.key);
381
+ navigator?.toolkitCallback?.(item?.key);
382
382
  getToolkitConfig();
383
383
  }
384
384
  );
@@ -430,7 +430,7 @@ const HeaderToolkitAction: React.FC<any> = ({
430
430
  getToolkitConfig();
431
431
  }
432
432
  );
433
- navigator?.toolkitCallback?.(pinTool.key);
433
+ navigator?.toolkitCallback?.(pinTool?.key);
434
434
  }}
435
435
  />
436
436
  );
@@ -13,12 +13,13 @@ import {getDialogOptions, getModalOptions, getStackOptions} from './utils';
13
13
  import {NavigationContainerProps} from './types';
14
14
  import {ApplicationContext} from './index';
15
15
  import Localize from './Localize';
16
+ import {defaultTheme} from '../Consts';
16
17
 
17
18
  const Stack = createStackNavigator();
18
19
 
19
- const NavigationContainer: React.FC<NavigationContainerProps> = ({ // screen: Screen; options?: NavigationOptions; theme: Theme; maxApi: any; initialParams?: any; localize: Localize;
20
+ const NavigationContainer: React.FC<NavigationContainerProps> = ({
20
21
  screen,
21
- theme,
22
+ theme = defaultTheme,
22
23
  options,
23
24
  maxApi,
24
25
  initialParams,
@@ -38,6 +38,7 @@ class Navigator {
38
38
  this.ref.current?.dispatch?.(StackActions.replace('Stack', params));
39
39
  }
40
40
  };
41
+
41
42
  /**
42
43
  * pop to dismiss a screen
43
44
  * @param count
@@ -61,26 +62,42 @@ class Navigator {
61
62
  /**
62
63
  * show a modal popup
63
64
  * @param params
65
+ * @param onError
64
66
  */
65
- showModal = (params: ModalParams) => {
66
- console.log(this);
67
- if (this.isReady.current) {
68
- this.ref.current?.dispatch?.(StackActions.push('Modal', params));
67
+ showModal = (params: ModalParams, onError?: (error: string) => void) => {
68
+ try {
69
+ if (this.isReady.current) {
70
+ this.ref.current?.dispatch?.(StackActions.push('Modal', params));
71
+ } else {
72
+ onError?.('NavigationContainer not ready');
73
+ }
74
+ } catch (error) {
75
+ onError?.(`${error}`);
69
76
  }
70
77
  };
71
78
 
72
79
  /**
73
80
  * show a bottom sheet
74
81
  * @param params
82
+ * @param onError
75
83
  */
76
- showBottomSheet = (params: BottomSheetParams) => {
77
- if (this.isReady.current) {
78
- this.ref.current?.dispatch?.(
79
- StackActions.push('Modal', {
80
- ...params,
81
- isBottomSheet: true,
82
- })
83
- );
84
+ showBottomSheet = (
85
+ params: BottomSheetParams,
86
+ onError?: (error: string) => void
87
+ ) => {
88
+ try {
89
+ if (this.isReady.current) {
90
+ this.ref.current?.dispatch?.(
91
+ StackActions.push('Modal', {
92
+ ...params,
93
+ isBottomSheet: true,
94
+ })
95
+ );
96
+ } else {
97
+ onError?.('NavigationContainer not ready');
98
+ }
99
+ } catch (error) {
100
+ onError?.(`${error}`);
84
101
  }
85
102
  };
86
103
 
@@ -14,7 +14,7 @@ import {Colors, Radius, Spacing} from '../Consts';
14
14
  * @constructor
15
15
  */
16
16
  const StackScreen: React.FC<ScreenParams> = props => {
17
- const {showGrid, navigator} = useContext(ApplicationContext); //showGrid: false, navigator: undefined,
17
+ const {showGrid, navigator} = useContext(ApplicationContext);
18
18
  const tracking = useRef<any>({
19
19
  timeoutLoad: undefined,
20
20
  timeoutInteraction: undefined,
@@ -31,7 +31,6 @@ const StackScreen: React.FC<ScreenParams> = props => {
31
31
 
32
32
  const context = useContext<any>(MiniAppContext);
33
33
  const {screen: Component, options, initialParams} = props.route.params;
34
- console.log(props.route.params);
35
34
  const navigation = new Navigation(props.navigation);
36
35
  const heightHeader = useHeaderHeight();
37
36
 
package/Assets/icon.json CHANGED
@@ -239,6 +239,9 @@
239
239
  "basic_suport_24": {
240
240
  "uri": "https://img.mservice.com.vn/app/img/kits/basic_suport_24.png"
241
241
  },
242
+ "basic_support_24h": {
243
+ "uri": "https://img.mservice.com.vn/app/img/kits/basic_suport_24.png"
244
+ },
242
245
  "basic_ticket": {
243
246
  "uri": "https://img.mservice.com.vn/app/img/kits/basic_ticket.png"
244
247
  },
package/Button/index.tsx CHANGED
@@ -289,14 +289,6 @@ const Button: FC<ButtonProps> = ({
289
289
  full && {width: '100%'},
290
290
  ]);
291
291
 
292
- const onPressButton = () => {
293
- if (type === 'disabled') {
294
- return () => {};
295
- }
296
- onPress?.();
297
- };
298
-
299
- const activeOpacity = type === 'disabled' ? 0.75 : 0.5;
300
292
  return (
301
293
  <ComponentContext.Provider
302
294
  value={{
@@ -309,9 +301,10 @@ const Button: FC<ButtonProps> = ({
309
301
  }}>
310
302
  <TouchableOpacity
311
303
  {...rest}
304
+ disabled={type === 'disabled'}
312
305
  accessibilityLabel={accessibilityLabel}
313
- activeOpacity={activeOpacity}
314
- onPress={onPressButton}
306
+ activeOpacity={0.5}
307
+ onPress={onPress}
315
308
  style={buttonStyle}>
316
309
  {renderLeading()}
317
310
  {renderTitle()}
package/Icon/index.tsx CHANGED
@@ -10,6 +10,7 @@ const Icon: React.FC<IconProps> = ({
10
10
  size = 24,
11
11
  color,
12
12
  style = {},
13
+ accessibilityLabel,
13
14
  }) => {
14
15
  const {theme} = useContext(ApplicationContext);
15
16
 
@@ -34,6 +35,7 @@ const Icon: React.FC<IconProps> = ({
34
35
  source={getIconSource()}
35
36
  style={[style, {width: size, height: size}]}
36
37
  resizeMode="contain"
38
+ accessibilityLabel={accessibilityLabel}
37
39
  {...tintColorProps}
38
40
  />
39
41
  );
package/Icon/types.ts CHANGED
@@ -24,4 +24,9 @@ export type IconProps = {
24
24
  * Accepts an object of style properties.
25
25
  */
26
26
  style?: StyleProp<ImageStyle>;
27
+
28
+ /**
29
+ * Optional. Represents the accessibility label for the icon.
30
+ */
31
+ accessibilityLabel?: string;
27
32
  };
@@ -1,6 +1,5 @@
1
1
  import React, {useContext} from 'react';
2
2
  import {
3
- GestureResponderEvent,
4
3
  StyleSheet,
5
4
  TouchableOpacity,
6
5
  TouchableOpacityProps,
@@ -109,17 +108,6 @@ const IconButton: React.FC<IconButtonProps> = ({
109
108
  }
110
109
  };
111
110
 
112
- /**
113
- * handle press
114
- * @param e
115
- */
116
- const onPressButton = (e: GestureResponderEvent) => {
117
- if (type === 'disabled') {
118
- return () => {};
119
- }
120
- onPress?.(e);
121
- };
122
-
123
111
  const activeOpacity = type === 'disabled' ? 0.75 : 0.5;
124
112
  const buttonStyle = StyleSheet.flatten([getTypeStyle(), getSizeStyle()]);
125
113
  const iconSize = size === 'small' ? 16 : 24;
@@ -136,9 +124,10 @@ const IconButton: React.FC<IconButtonProps> = ({
136
124
  }}>
137
125
  <TouchableOpacity
138
126
  {...rest}
127
+ disabled={type === 'disabled'}
139
128
  accessibilityLabel={accessibilityLabel}
140
129
  activeOpacity={activeOpacity}
141
- onPress={onPressButton}
130
+ onPress={onPress}
142
131
  style={buttonStyle}>
143
132
  <Icon size={iconSize} source={icon} color={getIconColor()} />
144
133
  </TouchableOpacity>
package/Image/index.tsx CHANGED
@@ -1,12 +1,8 @@
1
- import React, {useContext, useEffect, useRef, useState} from 'react';
1
+ import React, {useContext, useRef, useState} from 'react';
2
2
  import {StyleSheet, View} from 'react-native';
3
3
  import FastImage, {Source} from 'react-native-fast-image';
4
4
  import styles from './styles';
5
- import {
6
- ApplicationContext,
7
- ComponentContext,
8
- MiniAppContext,
9
- } from '../Application';
5
+ import {ApplicationContext} from '../Application';
10
6
  import {Skeleton} from '../Skeleton';
11
7
  import {Icon} from '../Icon';
12
8
  import {Styles} from '../Consts';
@@ -23,8 +19,6 @@ const Image: React.FC<ImageProps> = ({
23
19
  ...rest
24
20
  }) => {
25
21
  const {theme} = useContext(ApplicationContext);
26
- const app = useContext<any>(MiniAppContext);
27
- const component = useContext<any>(ComponentContext);
28
22
  const error = useRef(false);
29
23
  const [status, setStatus] = useState<Status>('success');
30
24
 
@@ -32,13 +26,6 @@ const Image: React.FC<ImageProps> = ({
32
26
  accessibilityLabel: accessibilityLabel || `img|${(source as Source).uri}`,
33
27
  };
34
28
 
35
- useEffect(() => {
36
- if (app.enableAutoId) {
37
- component?.addChildren?.(test.accessibilityLabel, 'add');
38
- return () => component?.addChildren?.(test.accessibilityLabel, 'remove');
39
- }
40
- }, []);
41
-
42
29
  /**
43
30
  * render content loading | fail | rendered
44
31
  */
@@ -1,6 +1,5 @@
1
1
  import React, {
2
2
  forwardRef,
3
- ReactNode,
4
3
  useContext,
5
4
  useEffect,
6
5
  useImperativeHandle,
@@ -16,12 +15,19 @@ import {
16
15
  } from 'react-native';
17
16
  import {ApplicationContext, ComponentContext} from '../Application';
18
17
  import {Icon} from '../Icon';
19
- import {ErrorView, FloatingView, getBorderColor, getSizeStyle} from './common';
18
+ import {
19
+ ErrorView,
20
+ FloatingView,
21
+ getBorderColor,
22
+ getSizeStyle,
23
+ RenderTrailing,
24
+ } from './common';
20
25
  import {InputMoneyProps} from './index';
21
26
  import styles from './styles';
22
27
  import {formatMoneyToNumber, formatNumberToMoney} from './utils';
23
- import {Text} from '../Text';
24
- import {Loader} from '../Loader';
28
+ // import {Text} from '../Text';
29
+ // import {Loader} from '../Loader';
30
+ // import icons from '../Assets/icon.json';
25
31
 
26
32
  const InputMoney = forwardRef(
27
33
  (
@@ -108,46 +114,6 @@ const InputMoney = forwardRef(
108
114
  onBlur?.(e);
109
115
  };
110
116
 
111
- /**
112
- * Render trailing icon or text
113
- * @param color
114
- */
115
- const renderTrailing = (color?: string) => {
116
- if (loading) {
117
- return <Loader type={'spinner'} color={color} style={styles.icon} />;
118
- }
119
-
120
- if (icon || trailing) {
121
- const renderIconTouchable = (icon: ReactNode) => {
122
- return (
123
- <TouchableOpacity
124
- onPress={onPressTrailing ?? onPressIcon}
125
- style={styles.icon}>
126
- {icon}
127
- </TouchableOpacity>
128
- );
129
- };
130
- const trailingValue = icon || trailing;
131
- if (trailingValue?.includes('_') || trailingValue?.includes('http')) {
132
- return renderIconTouchable(
133
- <Icon
134
- color={color}
135
- source={(icon || trailing) as string}
136
- size={24}
137
- />
138
- );
139
- }
140
- return renderIconTouchable(
141
- <Text
142
- typography="action_xs_bold"
143
- color={color ?? theme.colors.primary}
144
- numberOfLines={1}>
145
- {trailingValue!.substring(0, 15)}
146
- </Text>
147
- );
148
- }
149
- };
150
-
151
117
  const renderInputView = () => {
152
118
  const disabledColor = theme.colors.text.disable;
153
119
  let textColor = theme.colors.text.default;
@@ -210,7 +176,14 @@ const InputMoney = forwardRef(
210
176
  />
211
177
  </TouchableOpacity>
212
178
  )}
213
- {renderTrailing(iconTintColor)}
179
+ <RenderTrailing
180
+ color={iconTintColor}
181
+ icon={icon}
182
+ trailing={trailing}
183
+ onPressTrailing={onPressTrailing}
184
+ onPressIcon={onPressIcon}
185
+ loading={loading}
186
+ />
214
187
  </View>
215
188
  </View>
216
189
  );
package/Input/common.tsx CHANGED
@@ -1,4 +1,4 @@
1
- import React, {FC, useContext} from 'react';
1
+ import React, {FC, ReactNode, useContext} from 'react';
2
2
  import {
3
3
  GestureResponderEvent,
4
4
  TouchableOpacity,
@@ -11,6 +11,8 @@ import {Styles} from '../Consts';
11
11
  import {Icon} from '../Icon';
12
12
  import {scaleSize, Text} from '../Text';
13
13
  import styles from './styles';
14
+ import {Loader} from '../Loader';
15
+ import iconSource from '../Assets/icon.json';
14
16
 
15
17
  type FloatingViewProps = {
16
18
  floatingValue?: string;
@@ -22,6 +24,15 @@ type FloatingViewProps = {
22
24
  onPress?: (e: GestureResponderEvent) => void;
23
25
  };
24
26
 
27
+ type TrailingProps = {
28
+ loading?: boolean;
29
+ color?: string;
30
+ icon?: string;
31
+ trailing?: string;
32
+ onPressTrailing?: () => void;
33
+ onPressIcon?: () => void;
34
+ };
35
+
25
36
  export const DEFAULT_HEIGHT = scaleSize(104);
26
37
  export const MAX_LENGTH = 300;
27
38
 
@@ -153,3 +164,47 @@ export const FloatingView: FC<FloatingViewProps> = ({
153
164
  }
154
165
  return null;
155
166
  };
167
+
168
+ export const RenderTrailing: FC<TrailingProps> = ({
169
+ loading,
170
+ color,
171
+ icon,
172
+ trailing,
173
+ onPressTrailing,
174
+ onPressIcon,
175
+ }) => {
176
+ const {theme} = useContext(ApplicationContext);
177
+ if (loading) {
178
+ return <Loader type={'spinner'} color={color} style={styles.icon} />;
179
+ }
180
+
181
+ if (icon || trailing) {
182
+ const renderIconTouchable = (icon: ReactNode) => {
183
+ return (
184
+ <TouchableOpacity
185
+ onPress={onPressTrailing ?? onPressIcon}
186
+ style={styles.icon}>
187
+ {icon}
188
+ </TouchableOpacity>
189
+ );
190
+ };
191
+ const trailingValue = icon || trailing;
192
+ if (
193
+ (iconSource as any)?.[trailingValue as string]?.uri ||
194
+ trailingValue?.includes('http')
195
+ ) {
196
+ return renderIconTouchable(
197
+ <Icon color={color} source={(icon || trailing) as string} size={24} />
198
+ );
199
+ }
200
+ return renderIconTouchable(
201
+ <Text
202
+ typography="action_xs_bold"
203
+ color={color ?? theme.colors.primary}
204
+ numberOfLines={1}>
205
+ {trailingValue!.substring(0, 15)}
206
+ </Text>
207
+ );
208
+ }
209
+ return null;
210
+ };
package/Layout/Item.tsx CHANGED
@@ -41,7 +41,7 @@ const Item: React.FC<ItemProps> = ({
41
41
  style,
42
42
  styles.item,
43
43
  {
44
- width: grid.getSizeSpan(widthSpan ?? grid.numberOfColumns), //grid.numberOfColumns=12
44
+ width: grid.getSizeSpan(widthSpan ?? grid.numberOfColumns),
45
45
  height: heightSpan ? grid.getSizeSpan(heightSpan) : undefined,
46
46
  },
47
47
  ]}>
package/Layout/styles.ts CHANGED
@@ -42,7 +42,6 @@ export default StyleSheet.create({
42
42
  padding: 12,
43
43
  },
44
44
  item: {
45
- overflow: 'hidden',
46
45
  margin: undefined,
47
46
  marginTop: undefined,
48
47
  marginBottom: undefined,
@@ -5,7 +5,7 @@ import {ApplicationContext} from '../Application';
5
5
  import {hexToRGBA} from './utils';
6
6
  import {LoaderProps} from './types';
7
7
 
8
- const DotLoader: FC<LoaderProps> = ({color}) => {
8
+ const DotLoader: FC<LoaderProps> = ({color, style}) => {
9
9
  const {theme} = useContext(ApplicationContext);
10
10
 
11
11
  const arrayColor = [
@@ -28,7 +28,7 @@ const DotLoader: FC<LoaderProps> = ({color}) => {
28
28
  return (
29
29
  <AnimatedLottieView
30
30
  source={source}
31
- style={{width: 52, height: 18}}
31
+ style={[{width: 52, height: 18}, style]}
32
32
  autoPlay
33
33
  />
34
34
  );
@@ -5,7 +5,7 @@ import {hexToRGBA} from './utils';
5
5
  import {ApplicationContext} from '../Application';
6
6
  import {LoaderProps} from './types';
7
7
 
8
- const Spinner: FC<LoaderProps> = ({color}) => {
8
+ const Spinner: FC<LoaderProps> = ({color, style}) => {
9
9
  const {theme} = useContext(ApplicationContext);
10
10
 
11
11
  let source: any = animation;
@@ -20,7 +20,7 @@ const Spinner: FC<LoaderProps> = ({color}) => {
20
20
  return (
21
21
  <AnimatedLottieView
22
22
  source={source}
23
- style={{width: 24, height: 24}}
23
+ style={[{width: 24, height: 24}, style]}
24
24
  autoPlay
25
25
  />
26
26
  );
@@ -27,7 +27,7 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
27
27
  let Description: any = View;
28
28
  if (scrollContent) {
29
29
  Description = ScrollView;
30
- descriptionStyle = {maxHeight: scaleSize(172)}; //maxHeight=175
30
+ descriptionStyle = {maxHeight: scaleSize(172)};
31
31
  }
32
32
  /**
33
33
  * tracking
package/Text/index.tsx CHANGED
@@ -109,18 +109,19 @@ const Text: React.FC<TextProps> = ({
109
109
  };
110
110
  };
111
111
 
112
+
112
113
  const textStyle = getTypoStyle(typography);
113
114
 
114
115
  if (deprecatedValues.includes(typography)) {
115
116
  console.warn(
116
- `Warning: The typography value "${typography}" is deprecated.`
117
+ `Warning: The typography value "${typography}" is deprecated.`,
117
118
  );
118
119
  }
119
120
 
120
121
  return (
121
122
  <RNText
122
123
  {...rest}
123
- {...getAccessibilityID(rest.accessibilityLabel)}
124
+ {...getAccessibilityID((rest.accessibilityLabel))}
124
125
  style={[style, textStyle, {color: color ?? theme.colors.text.default}]}>
125
126
  {children ?? ''}
126
127
  </RNText>
package/Text/utils.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import {Dimensions, Platform} from 'react-native';
2
2
 
3
3
  const deviceWidth = Dimensions.get('window').width;
4
- console.log(deviceWidth);
5
4
  const DEFAULT_SCREEN_SIZE = 375;
6
5
  const scaleSize = (size: number) => {
7
6
  const scaleRate = deviceWidth / DEFAULT_SCREEN_SIZE;
7
+
8
8
  if (scaleRate > 1) {
9
9
  return Math.min(Math.round(size * scaleRate), size + 3);
10
10
  }
@@ -16,6 +16,7 @@ const getAccessibilityID = (accessibilityLabel = '') => {
16
16
  return {
17
17
  accessible: true,
18
18
  testID: accessibilityLabel,
19
+ accessibilityLabel: undefined,
19
20
  };
20
21
  } else {
21
22
  return {
package/index.ts CHANGED
@@ -49,3 +49,10 @@ export * from './Title';
49
49
  export * from './Title/types';
50
50
  export * from './Badge';
51
51
  export * from './Badge/types';
52
+
53
+ /**
54
+ * export trick for keep old mini app working
55
+ * @deprecated
56
+ */
57
+ export * from 'react-native-modalize';
58
+ export * from '@gorhom/bottom-sheet';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.103.2-beta.11",
3
+ "version": "0.103.2-beta.19",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {},
@@ -8,9 +8,11 @@
8
8
  "@momo-kits/foundation"
9
9
  ],
10
10
  "dependencies": {
11
+ "@gorhom/bottom-sheet": "2.4.1",
11
12
  "react-native-safe-area-context": "3.1.4",
12
13
  "react-native-linear-gradient": "2.8.3",
13
14
  "react-native-gesture-handler": "1.10.3",
15
+ "react-native-modalize": "2.1.1",
14
16
  "react-native-fast-image": "8.1.5",
15
17
  "@react-navigation/bottom-tabs": "https://gitlab.mservice.com.vn/momo-platform/react-native-bottom-tabs.git",
16
18
  "@react-navigation/core": "5.16.1",