@momo-kits/foundation 0.92.29-optimize.4 → 0.92.29-optimize.6

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.
@@ -338,7 +338,7 @@ const HeaderToolkitAction: React.FC<any> = ({
338
338
  {runtimeTools},
339
339
  (res: {item: {action?: string; key: string}}) => {
340
340
  const {item} = res;
341
- navigator?.toolkitCallback?.(item);
341
+ navigator?.toolkitCallback?.(item.key);
342
342
  getToolkitConfig();
343
343
  }
344
344
  );
@@ -12,7 +12,7 @@ class Navigator {
12
12
  toolkitConfig?: HeaderToolkitProps;
13
13
  maxApi?: any;
14
14
  dismissData?: any;
15
- toolkitCallback?: (item: any) => void;
15
+ toolkitCallback?: (key: string) => void;
16
16
 
17
17
  constructor(navigation: any, isReady: any) {
18
18
  this.ref = navigation;
@@ -78,7 +78,7 @@ class Navigator {
78
78
  StackActions.push('Modal', {
79
79
  ...params,
80
80
  isBottomSheet: true,
81
- }),
81
+ })
82
82
  );
83
83
  }
84
84
  };
@@ -103,7 +103,7 @@ class Navigator {
103
103
  CommonActions.navigate({
104
104
  name,
105
105
  params,
106
- }),
106
+ })
107
107
  );
108
108
  }
109
109
  };
@@ -124,7 +124,7 @@ class Navigator {
124
124
  params,
125
125
  },
126
126
  ],
127
- }),
127
+ })
128
128
  );
129
129
  }
130
130
  };
@@ -141,9 +141,7 @@ class Navigator {
141
141
  * set callback function for toolkit
142
142
  * @param callback
143
143
  */
144
- setToolkitCallback = (
145
- callback: (item: {key: string; action: string}) => void,
146
- ) => {
144
+ setToolkitCallback = (callback: (key: string) => void) => {
147
145
  this.toolkitCallback = callback;
148
146
  };
149
147
  }
package/Input/Input.tsx CHANGED
@@ -59,6 +59,7 @@ const Input = forwardRef(
59
59
  hintText,
60
60
  accessibilityLabel,
61
61
  editable = true,
62
+ onPressFloatingIcon,
62
63
  ...props
63
64
  }: InputProps,
64
65
  ref
@@ -189,6 +190,7 @@ const Input = forwardRef(
189
190
  disabled={disabled}
190
191
  required={required}
191
192
  floatingIcon={floatingIcon}
193
+ onPress={onPressFloatingIcon}
192
194
  />
193
195
  <View style={styles.inputView}>
194
196
  {!!leadingIcon && (
@@ -1,77 +1,36 @@
1
- import React, {ReactNode, useContext} from 'react';
2
- import {TextInput, TouchableOpacity, View} from 'react-native';
1
+ import React, {useContext} from 'react';
2
+ import {TouchableOpacity, View} from 'react-native';
3
3
  import {ApplicationContext, ComponentContext} from '../Application';
4
4
  import {Icon} from '../Icon';
5
- import {Loader} from '../Loader';
6
5
  import {ErrorView, FloatingView, getBorderColor, getSizeStyle} from './common';
7
6
  import {InputDropDownProps} from './index';
8
7
  import {Text} from '../Text';
9
8
  import styles from './styles';
9
+ import {Spacing} from '../Consts';
10
10
 
11
11
  const InputDropDown = ({
12
12
  value,
13
13
  floatingValue,
14
14
  floatingIcon,
15
+ onPressFloatingIcon,
15
16
  size = 'small',
16
17
  onPress,
17
18
  placeholder,
18
19
  errorMessage,
19
- icon = 'arrow_chevron_down_small',
20
- iconColor,
21
- onPressIcon,
22
- trailing = 'arrow_chevron_down_small',
23
- trailingColor,
24
- onPressTrailing,
25
20
  disabled = false,
26
21
  floatingIconColor,
27
22
  required = false,
28
23
  errorSpacing,
29
- loading = false,
30
24
  leadingIcon,
31
25
  leadingIconColor,
32
26
  style,
33
27
  params,
34
28
  accessibilityLabel,
35
29
  hintText,
36
- ...props
30
+ multiline,
37
31
  }: InputDropDownProps) => {
38
32
  const {theme} = useContext(ApplicationContext);
39
33
 
40
- /**
41
- * Render trailing icon or text
42
- * @param color
43
- */
44
- const renderTrailing = (color?: string) => {
45
- if (loading) {
46
- return <Loader type={'spinner'} color={color} style={styles.icon} />;
47
- }
48
- if (icon || trailing) {
49
- const renderIconTouchable = (icon: ReactNode) => {
50
- return (
51
- <TouchableOpacity
52
- onPress={onPressTrailing ?? onPressIcon}
53
- style={styles.icon}>
54
- {icon}
55
- </TouchableOpacity>
56
- );
57
- };
58
- const trailingValue = icon || trailing;
59
- if (trailingValue?.includes('_') || trailingValue?.includes('http')) {
60
- return renderIconTouchable(
61
- <Icon color={color} source={(icon || trailing) as string} size={24} />
62
- );
63
- }
64
- return renderIconTouchable(
65
- <Text
66
- typography="action_xs_bold"
67
- color={color ?? theme.colors.primary}
68
- numberOfLines={1}>
69
- {trailingValue!.substring(0, 15)}
70
- </Text>
71
- );
72
- }
73
- };
74
-
75
34
  /**
76
35
  * Render the input view
77
36
  */
@@ -79,20 +38,18 @@ const InputDropDown = ({
79
38
  const disabledColor = theme.colors.text.disable;
80
39
  let textColor = theme.colors.text.default;
81
40
  let placeholderColor = theme.colors.text.hint;
82
- let iconTintColor = trailingColor ?? iconColor;
83
41
 
84
42
  if (disabled) {
85
43
  textColor = disabledColor;
86
44
  placeholderColor = disabledColor;
87
- iconTintColor = disabledColor;
88
45
  }
89
46
 
90
47
  return (
91
48
  <View
92
49
  style={[
93
- styles.inputWrapper,
50
+ styles.inputDropDownWrapper,
94
51
  {backgroundColor: theme.colors.background.surface},
95
- getSizeStyle(size),
52
+ getSizeStyle(size, multiline),
96
53
  getBorderColor(theme, false, errorMessage, disabled),
97
54
  ]}>
98
55
  <FloatingView
@@ -101,10 +58,18 @@ const InputDropDown = ({
101
58
  disabled={disabled}
102
59
  required={required}
103
60
  floatingIcon={floatingIcon}
61
+ onPress={onPressFloatingIcon}
104
62
  />
105
- <View style={styles.inputView}>
63
+ <View style={styles.inputDropDownView}>
106
64
  {!!leadingIcon && (
107
- <View style={styles.leadingIconContainer}>
65
+ <View
66
+ style={[
67
+ styles.leadingIconContainerDropDown,
68
+ {
69
+ marginTop: Spacing.M,
70
+ marginRight: Spacing.S,
71
+ },
72
+ ]}>
108
73
  <Icon
109
74
  color={leadingIconColor}
110
75
  source={leadingIcon}
@@ -112,26 +77,27 @@ const InputDropDown = ({
112
77
  />
113
78
  </View>
114
79
  )}
115
- <TextInput
116
- {...props}
80
+ <View
117
81
  accessibilityLabel={accessibilityLabel}
118
- onPressOut={onPress}
119
- editable={false}
120
- style={[
121
- styles.input,
122
- {
123
- color: textColor,
124
- fontFamily: `${theme.font}-Regular`,
125
- },
126
- ]}
127
- textBreakStrategy="highQuality"
128
- value={value}
129
- placeholder={placeholder}
130
- selectionColor={theme.colors.primary}
131
- placeholderTextColor={placeholderColor}
132
- />
82
+ style={styles.textViewDropDown}>
83
+ <Text
84
+ numberOfLines={multiline ? undefined : 1}
85
+ typography={'body_default_regular'}
86
+ color={value ? textColor : placeholderColor}>
87
+ {value || placeholder}
88
+ </Text>
89
+ </View>
90
+ </View>
91
+ <View
92
+ style={[
93
+ styles.iconViewDropDown,
94
+ {
95
+ alignItems: multiline ? 'flex-start' : 'center',
96
+ paddingTop: multiline ? Spacing.M : 0,
97
+ },
98
+ ]}>
99
+ <Icon source={'arrow_chevron_down_small'} />
133
100
  </View>
134
- <View style={styles.iconView}>{renderTrailing(iconTintColor)}</View>
135
101
  </View>
136
102
  );
137
103
  };
@@ -145,7 +111,10 @@ const InputDropDown = ({
145
111
  componentLabel: floatingValue,
146
112
  componentId: accessibilityLabel,
147
113
  }}>
148
- <TouchableOpacity onPress={onPress} style={[style, styles.wrapper]}>
114
+ <TouchableOpacity
115
+ activeOpacity={0.6}
116
+ onPress={onPress}
117
+ style={[style, styles.wrapper]}>
149
118
  {renderInputView()}
150
119
  <ErrorView
151
120
  errorMessage={errorMessage}
@@ -50,6 +50,7 @@ const InputMoney = forwardRef(
50
50
  accessibilityLabel,
51
51
  hintText,
52
52
  value: _value,
53
+ onPressFloatingIcon,
53
54
  ...props
54
55
  }: InputMoneyProps,
55
56
  ref
@@ -173,6 +174,7 @@ const InputMoney = forwardRef(
173
174
  disabled={disabled}
174
175
  required={required}
175
176
  floatingIcon={floatingIcon}
177
+ onPress={onPressFloatingIcon}
176
178
  />
177
179
  <View style={styles.inputView}>
178
180
  <TextInput
package/Input/common.tsx CHANGED
@@ -1,5 +1,10 @@
1
1
  import React, {FC, useContext} from 'react';
2
- import {View, ViewStyle} from 'react-native';
2
+ import {
3
+ GestureResponderEvent,
4
+ TouchableOpacity,
5
+ View,
6
+ ViewStyle,
7
+ } from 'react-native';
3
8
  import {ApplicationContext} from '../Application';
4
9
  import {Theme} from '../Application/types';
5
10
  import {Styles} from '../Consts';
@@ -14,6 +19,7 @@ type FloatingViewProps = {
14
19
  floatingIcon?: string;
15
20
  required?: boolean;
16
21
  style?: ViewStyle;
22
+ onPress?: (e: GestureResponderEvent) => void;
17
23
  };
18
24
 
19
25
  export const DEFAULT_HEIGHT = scaleSize(104);
@@ -23,7 +29,7 @@ export const getBorderColor = (
23
29
  theme: Theme,
24
30
  focused: boolean,
25
31
  errorMessage?: string,
26
- disabled?: boolean,
32
+ disabled?: boolean
27
33
  ) => {
28
34
  let borderColor = theme.colors.border.default;
29
35
 
@@ -42,7 +48,18 @@ export const getBorderColor = (
42
48
  return {borderColor};
43
49
  };
44
50
 
45
- export const getSizeStyle = (size?: 'small' | 'large') => {
51
+ export const getSizeStyle = (
52
+ size?: 'small' | 'large',
53
+ multiline: boolean = false
54
+ ) => {
55
+ if (multiline)
56
+ return [
57
+ styles.multilineContainer,
58
+ {
59
+ minHeight: size === 'small' ? 48 : 56,
60
+ },
61
+ ];
62
+
46
63
  if (size === 'small') {
47
64
  return styles.smallContainer;
48
65
  }
@@ -70,7 +87,6 @@ export const ErrorView: FC<{
70
87
  <Text
71
88
  style={Styles.flex}
72
89
  color={errorMessage ? errorColor : hintColor}
73
- numberOfLines={2}
74
90
  typography={'description_default_regular'}>
75
91
  {errorMessage ?? hintTextDefault}
76
92
  </Text>
@@ -90,6 +106,7 @@ export const FloatingView: FC<FloatingViewProps> = ({
90
106
  floatingIcon,
91
107
  required,
92
108
  style,
109
+ onPress,
93
110
  }) => {
94
111
  const {theme} = useContext(ApplicationContext);
95
112
 
@@ -122,12 +139,14 @@ export const FloatingView: FC<FloatingViewProps> = ({
122
139
  )}
123
140
  </Text>
124
141
  {!!floatingIcon && (
125
- <Icon
126
- color={floatingIconTintColor}
127
- source={floatingIcon}
128
- size={16}
129
- style={styles.floatingIcon}
130
- />
142
+ <TouchableOpacity activeOpacity={onPress ? 0.6 : 1} onPress={onPress}>
143
+ <Icon
144
+ color={floatingIconTintColor}
145
+ source={floatingIcon}
146
+ size={16}
147
+ style={styles.floatingIcon}
148
+ />
149
+ </TouchableOpacity>
131
150
  )}
132
151
  </View>
133
152
  );
package/Input/index.tsx CHANGED
@@ -1,4 +1,4 @@
1
- import {TextInputProps, ViewStyle} from 'react-native';
1
+ import {GestureResponderEvent, TextInputProps, ViewStyle} from 'react-native';
2
2
  import Input from './Input';
3
3
  import InputDropDown from './InputDropDown';
4
4
  import InputMoney from './InputMoney';
@@ -116,6 +116,8 @@ export interface InputProps extends TextInputProps {
116
116
  * Optional. Represents text below the Input component.
117
117
  */
118
118
  hintText?: string;
119
+
120
+ onPressFloatingIcon?: (e: GestureResponderEvent) => void;
119
121
  }
120
122
 
121
123
  export interface InputTextAreaProps extends Omit<InputProps, 'size'> {
@@ -221,7 +223,8 @@ export type CaretProps = {
221
223
  length?: number;
222
224
  };
223
225
 
224
- export interface InputDropDownProps extends InputProps {
226
+ export interface InputDropDownProps
227
+ extends Omit<InputProps, 'trailing' | 'trailingColor' | 'onPressTrailing'> {
225
228
  /**
226
229
  * Optional. Defines the size of the InputDropDown component.
227
230
  * 'small' - A smaller, less prominent input.
@@ -258,6 +261,8 @@ export interface InputDropDownProps extends InputProps {
258
261
  * Optional. Represents the style of the InputDropDown component.
259
262
  */
260
263
  style?: ViewStyle | ViewStyle[];
264
+
265
+ multiline?: boolean;
261
266
  }
262
267
 
263
268
  export {Input, InputDropDown, InputMoney, InputOTP, InputSearch, InputTextArea};
package/Input/styles.ts CHANGED
@@ -157,4 +157,33 @@ export default StyleSheet.create({
157
157
  alignItems: 'center',
158
158
  justifyContent: 'center',
159
159
  },
160
+
161
+ //DropDown
162
+ inputDropDownWrapper: {
163
+ flexDirection: 'row',
164
+ marginTop: Spacing.S,
165
+ },
166
+ inputDropDownView: {
167
+ flex: 1,
168
+ flexDirection: 'row',
169
+ paddingLeft: Spacing.M,
170
+ },
171
+ iconViewDropDown: {
172
+ flexDirection: 'row',
173
+ marginRight: Spacing.M,
174
+ },
175
+ textViewDropDown: {
176
+ flex: 1,
177
+ marginVertical: Spacing.M,
178
+ marginRight: Spacing.S,
179
+ justifyContent: 'center',
180
+ },
181
+ multilineContainer: {
182
+ borderWidth: 1,
183
+ borderRadius: Radius.S,
184
+ },
185
+ leadingIconContainerDropDown: {
186
+ borderRadius: Radius.XS,
187
+ overflow: 'hidden',
188
+ },
160
189
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.92.29-optimize.4",
3
+ "version": "0.92.29-optimize.6",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {},
@@ -14,12 +14,12 @@
14
14
  "react-native-gesture-handler": "1.10.3",
15
15
  "react-native-modalize": "2.1.1",
16
16
  "react-native-fast-image": "8.1.5",
17
- "@react-navigation/bottom-tabs": "git+https://gitlab.com/momo-platform/react-navigation-bottom-tabs.git#main",
17
+ "@react-navigation/bottom-tabs": "https://oauth2:5WXQLHPMxxCyvGt_Py4D@gitlab.mservice.com.vn/momo-platform/react-native-bottom-tabs.git",
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
21
  "lottie-react-native": "git+https://gitlab.mservice.com.vn/momo-platform/momo-lottie-react-native.git",
22
- "@react-navigation/stack": "git+https://gitlab.com/momo-platform/react-navigation-stack.git#main"
22
+ "@react-navigation/stack": "https://oauth2:eX-jVhzQdLc343AjD3Sc@gitlab.mservice.com.vn/momo-platform/react-navigation-stack.git"
23
23
  },
24
24
  "peerDependencies": {
25
25
  "react-native": "*"