@momo-kits/foundation 0.103.2 → 0.103.4

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.
@@ -80,7 +80,11 @@ const BottomTab: React.FC<BottomTabProps> = ({
80
80
  initialRouteName={initialRouteName}
81
81
  backBehavior={'firstRoute'}
82
82
  tabBar={props => (
83
- <BottomTabBar {...props} floatingButton={floatingButton} />
83
+ <BottomTabBar
84
+ {...props}
85
+ floatingButton={floatingButton}
86
+ inactiveTintColor={theme.colors.text.secondary}
87
+ />
84
88
  )}
85
89
  tabBarOptions={{
86
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
  );
@@ -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,25 +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
- if (this.isReady.current) {
67
- 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}`);
68
76
  }
69
77
  };
70
78
 
71
79
  /**
72
80
  * show a bottom sheet
73
81
  * @param params
82
+ * @param onError
74
83
  */
75
- showBottomSheet = (params: BottomSheetParams) => {
76
- if (this.isReady.current) {
77
- this.ref.current?.dispatch?.(
78
- StackActions.push('Modal', {
79
- ...params,
80
- isBottomSheet: true,
81
- })
82
- );
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}`);
83
101
  }
84
102
  };
85
103
 
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,16 @@ 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';
25
28
 
26
29
  const InputMoney = forwardRef(
27
30
  (
@@ -108,46 +111,6 @@ const InputMoney = forwardRef(
108
111
  onBlur?.(e);
109
112
  };
110
113
 
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
114
  const renderInputView = () => {
152
115
  const disabledColor = theme.colors.text.disable;
153
116
  let textColor = theme.colors.text.default;
@@ -210,7 +173,14 @@ const InputMoney = forwardRef(
210
173
  />
211
174
  </TouchableOpacity>
212
175
  )}
213
- {renderTrailing(iconTintColor)}
176
+ <RenderTrailing
177
+ color={iconTintColor}
178
+ icon={icon}
179
+ trailing={trailing}
180
+ onPressTrailing={onPressTrailing}
181
+ onPressIcon={onPressIcon}
182
+ loading={loading}
183
+ />
214
184
  </View>
215
185
  </View>
216
186
  );
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 IconSources 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
+ (IconSources 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
+ };
@@ -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
  );
package/Text/utils.ts CHANGED
@@ -12,10 +12,11 @@ const scaleSize = (size: number) => {
12
12
  return size;
13
13
  };
14
14
  const getAccessibilityID = (accessibilityLabel = '') => {
15
- if (Platform.OS ==='ios') {
15
+ if (Platform.OS === 'ios') {
16
16
  return {
17
17
  accessible: true,
18
18
  testID: accessibilityLabel,
19
+ accessibilityLabel: undefined,
19
20
  };
20
21
  } else {
21
22
  return {
@@ -23,4 +24,4 @@ const getAccessibilityID = (accessibilityLabel = '') => {
23
24
  };
24
25
  }
25
26
  };
26
- export {scaleSize,getAccessibilityID};
27
+ export {scaleSize, getAccessibilityID};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.103.2",
3
+ "version": "0.103.4",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {},