@momo-kits/foundation 0.92.30 → 0.92.32

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.
@@ -18,6 +18,7 @@ import {Text} from '../Text';
18
18
  import {InputSearchProps} from './index';
19
19
  import styles from './styles';
20
20
  import {checkTyping} from './utils';
21
+ import {Styles} from '../Consts';
21
22
 
22
23
  const InputSearch = forwardRef(
23
24
  (
@@ -25,10 +26,14 @@ const InputSearch = forwardRef(
25
26
  placeholder,
26
27
  onFocus,
27
28
  onBlur,
28
- iconColor,
29
29
  value,
30
- onChangeText,
31
30
  icon,
31
+ iconColor,
32
+ onPressIcon,
33
+ trailing,
34
+ trailingColor,
35
+ onPressTrailing,
36
+ onChangeText,
32
37
  buttonText = 'Hủy',
33
38
  showButtonText = true,
34
39
  style,
@@ -39,7 +44,7 @@ const InputSearch = forwardRef(
39
44
  accessibilityLabel,
40
45
  ...props
41
46
  }: InputSearchProps,
42
- ref,
47
+ ref
43
48
  ) => {
44
49
  const {theme} = useContext(ApplicationContext);
45
50
  const [focused, setFocused] = useState(false);
@@ -75,6 +80,9 @@ const InputSearch = forwardRef(
75
80
  };
76
81
  });
77
82
 
83
+ /**
84
+ * Render the input view
85
+ */
78
86
  const renderInputView = () => {
79
87
  return (
80
88
  <TextInput
@@ -99,12 +107,12 @@ const InputSearch = forwardRef(
99
107
  );
100
108
  };
101
109
 
102
- const renderIconView = () => {
110
+ /**
111
+ * Render trailing icon or text
112
+ */
113
+ const renderTrailing = () => {
103
114
  return (
104
- <View
105
- style={{
106
- flexDirection: 'row',
107
- }}>
115
+ <View style={Styles.row}>
108
116
  {focused && haveValue && (
109
117
  <TouchableOpacity style={styles.iconWrapper} onPress={onClearText}>
110
118
  <Icon
@@ -114,8 +122,10 @@ const InputSearch = forwardRef(
114
122
  />
115
123
  </TouchableOpacity>
116
124
  )}
117
- {!!icon && (
118
- <View style={{flexDirection: 'row'}}>
125
+ {!!(icon || trailing) && (
126
+ <TouchableOpacity
127
+ style={Styles.row}
128
+ onPress={onPressTrailing ?? onPressIcon}>
119
129
  <View
120
130
  style={[
121
131
  styles.divider,
@@ -125,22 +135,20 @@ const InputSearch = forwardRef(
125
135
  ]}
126
136
  />
127
137
  <Icon
128
- color={iconColor}
129
- source={icon}
138
+ color={iconColor || trailingColor}
139
+ source={(icon || trailing) as string}
130
140
  style={styles.iconSearchInput}
131
141
  />
132
- </View>
142
+ </TouchableOpacity>
133
143
  )}
134
144
  </View>
135
145
  );
136
146
  };
137
147
 
138
148
  let inputState = 'empty';
139
-
140
149
  if (focused) {
141
150
  inputState = 'focus';
142
151
  }
143
-
144
152
  if (value && value?.length > 0) {
145
153
  inputState = 'filled';
146
154
  }
@@ -171,7 +179,7 @@ const InputSearch = forwardRef(
171
179
  color={theme.colors.text.hint}
172
180
  />
173
181
  {renderInputView()}
174
- {renderIconView()}
182
+ {renderTrailing()}
175
183
  </View>
176
184
  {showButtonText && (
177
185
  <TouchableOpacity onPress={onPressButtonText}>
@@ -185,7 +193,7 @@ const InputSearch = forwardRef(
185
193
  </View>
186
194
  </ComponentContext.Provider>
187
195
  );
188
- },
196
+ }
189
197
  );
190
198
 
191
199
  export default InputSearch;
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';
@@ -6,6 +6,8 @@ import InputOTP from './InputOTP';
6
6
  import InputSearch from './InputSearch';
7
7
  import InputTextArea from './InputTextArea';
8
8
 
9
+ export type OTPInputLength = 2 | 4 | 6 | 8 | 10;
10
+
9
11
  export interface InputProps extends TextInputProps {
10
12
  /**
11
13
  * Optional. Defines the size of the Input component.
@@ -28,15 +30,38 @@ export interface InputProps extends TextInputProps {
28
30
  errorMessage?: string;
29
31
 
30
32
  /**
33
+ * @deprecated Use `trailing` instead.
31
34
  * Optional. Represents the name or key of the icon to be displayed in the Input component.
32
35
  */
33
36
  icon?: string;
34
37
 
35
38
  /**
39
+ * @deprecated Use `trailingColor` instead.
36
40
  * Optional. Represents the color of the icon in the Input component.
37
41
  */
38
42
  iconColor?: string;
39
43
 
44
+ /**
45
+ * @deprecated Use `onPressTrailing` instead.
46
+ * Optional. callback function to be called when the icon is pressed.
47
+ */
48
+ onPressIcon?: () => void;
49
+
50
+ /**
51
+ * Optional. Represents the name or key of the icon to be displayed in the Input component.
52
+ */
53
+ trailing?: string;
54
+
55
+ /**
56
+ * Optional. Represents the color of the icon in the Input component.
57
+ */
58
+ trailingColor?: string;
59
+
60
+ /**
61
+ * Optional. callback function to be called when the icon is pressed.
62
+ */
63
+ onPressTrailing?: () => void;
64
+
40
65
  /**
41
66
  * Optional. If `true`, the user won't be able to interact with the Input component.
42
67
  * Defaults to `false` if not provided.
@@ -82,11 +107,6 @@ export interface InputProps extends TextInputProps {
82
107
  */
83
108
  fontWeight?: 'Regular' | 'Bold';
84
109
 
85
- /**
86
- * Optional. callback function to be called when the icon is pressed.
87
- */
88
- onPressIcon?: () => void;
89
-
90
110
  /**
91
111
  * Optional. params for element tracking.
92
112
  */
@@ -96,10 +116,11 @@ export interface InputProps extends TextInputProps {
96
116
  * Optional. Represents text below the Input component.
97
117
  */
98
118
  hintText?: string;
119
+
120
+ onPressFloatingIcon?: (e: GestureResponderEvent) => void;
99
121
  }
100
122
 
101
- export interface InputTextAreaProps
102
- extends Omit<InputProps, 'size' | 'icon' | 'iconColor'> {
123
+ export interface InputTextAreaProps extends Omit<InputProps, 'size'> {
103
124
  /**
104
125
  * Optional. Defines the height of the InputTextArea component.
105
126
  * It can be used to set a specific height for the text area.
@@ -125,14 +146,37 @@ export interface InputSearchProps extends TextInputProps {
125
146
  onPressButtonText?: () => void;
126
147
 
127
148
  /**
149
+ * @deprecated Use `trailing` instead.
150
+ * Optional. Represents the name or key of the icon to be displayed in the Input component.
151
+ */
152
+ icon?: string;
153
+
154
+ /**
155
+ * @deprecated Use `trailingColor` instead.
128
156
  * Optional. Represents the color of the icon in the Input component.
129
157
  */
130
158
  iconColor?: string;
131
159
 
160
+ /**
161
+ * @deprecated Use `onPressTrailing` instead.
162
+ * Optional. callback function to be called when the icon is pressed.
163
+ */
164
+ onPressIcon?: () => void;
165
+
132
166
  /**
133
167
  * Optional. Represents the name or key of the icon to be displayed in the Input component.
134
168
  */
135
- icon?: string;
169
+ trailing?: string;
170
+
171
+ /**
172
+ * Optional. Represents the color of the icon in the Input component.
173
+ */
174
+ trailingColor?: string;
175
+
176
+ /**
177
+ * Optional. callback function to be called when the icon is pressed.
178
+ */
179
+ onPressTrailing?: () => void;
136
180
 
137
181
  /**
138
182
  * Optional. If `true`, the user won't be able to interact with the Input component.
@@ -147,8 +191,6 @@ export interface InputSearchProps extends TextInputProps {
147
191
 
148
192
  export interface InputMoneyProps extends Omit<InputProps, 'placeholder'> {}
149
193
 
150
- export type OTPInputLength = 2 | 4 | 6 | 8 | 10;
151
-
152
194
  export interface InputOTPProps
153
195
  extends Omit<InputProps, 'size' | 'icon' | 'iconColor'> {
154
196
  /**
@@ -181,7 +223,8 @@ export type CaretProps = {
181
223
  length?: number;
182
224
  };
183
225
 
184
- export interface InputDropDownProps extends InputProps {
226
+ export interface InputDropDownProps
227
+ extends Omit<InputProps, 'trailing' | 'trailingColor' | 'onPressTrailing'> {
185
228
  /**
186
229
  * Optional. Defines the size of the InputDropDown component.
187
230
  * 'small' - A smaller, less prominent input.
@@ -189,57 +232,17 @@ export interface InputDropDownProps extends InputProps {
189
232
  */
190
233
  size?: 'small' | 'large';
191
234
 
192
- /**
193
- * Optional. The current value of the InputDropDown.
194
- */
195
- value?: string;
196
-
197
- /**
198
- * Optional. Text that is displayed when there is no value set in the InputDropDown.
199
- */
200
- placeholder?: string;
201
-
202
235
  /**
203
236
  * Optional. Function to be called when the InputDropDown is pressed.
204
237
  */
205
238
  onPress?: () => void;
206
239
 
207
- /**
208
- * Optional. Represents the value for the floating title in the InputDropDown component.
209
- */
210
- floatingValue?: string;
211
-
212
- /**
213
- * Optional. Represents the name or key of the floating icon to be displayed in the InputDropDown component.
214
- */
215
- floatingIcon?: string;
216
-
217
- /**
218
- * Optional. Represents the error message to be displayed below the InputDropDown component when there is an error.
219
- */
220
- errorMessage?: string;
221
-
222
- /**
223
- * Optional. Represents the name or key of the icon to be displayed in the InputDropDown component.
224
- */
225
- icon?: string;
226
-
227
- /**
228
- * Optional. Represents the color of the icon in the InputDropDown component.
229
- */
230
- iconColor?: string;
231
-
232
240
  /**
233
241
  * Optional. If `true`, the user won't be able to interact with the InputDropDown component.
234
242
  * Defaults to `false` if not provided.
235
243
  */
236
244
  disabled?: boolean;
237
245
 
238
- /**
239
- * Optional. Represents the color of the floating icon in the InputDropDown component.
240
- */
241
- floatingIconColor?: string;
242
-
243
246
  /**
244
247
  * Optional. If `true`, the InputDropDown component is marked as required,
245
248
  * indicating that the user must provide a value before submitting a form.
@@ -247,28 +250,6 @@ export interface InputDropDownProps extends InputProps {
247
250
  */
248
251
  required?: boolean;
249
252
 
250
- /**
251
- * Optional. If `true`,
252
- * includes spacing when InputDropDown does not have an error message.
253
- * Defaults to `false` if not provided.
254
- */
255
- errorSpacing?: boolean;
256
-
257
- /**
258
- * If `true`, the icon of the input will show an indicator for loading.
259
- */
260
- loading?: boolean;
261
-
262
- /**
263
- * Optional. Represents the leading icon in the InputDropDown component.
264
- */
265
- leadingIcon?: string;
266
-
267
- /**
268
- * Optional. Represents the color of the leading icon in the InputDropDown component.
269
- */
270
- leadingIconColor?: string;
271
-
272
253
  /**
273
254
  * Optional. params for element tracking.
274
255
  */
@@ -280,6 +261,8 @@ export interface InputDropDownProps extends InputProps {
280
261
  * Optional. Represents the style of the InputDropDown component.
281
262
  */
282
263
  style?: ViewStyle | ViewStyle[];
264
+
265
+ multiline?: boolean;
283
266
  }
284
267
 
285
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/Layout/Screen.tsx CHANGED
@@ -121,25 +121,25 @@ const Screen = forwardRef(
121
121
  useGridLayout = true,
122
122
  keyboardVerticalOffset,
123
123
  }: ScreenProps,
124
- ref,
124
+ ref
125
125
  ) => {
126
126
  const animatedValue = useRef<Animated.Value>(new Animated.Value(0));
127
127
  const {theme} = useContext(ApplicationContext);
128
128
  const insets = useSafeAreaInsets();
129
129
  const heightHeader = useHeaderHeight();
130
130
  const currentTint = useRef(Colors.black_01);
131
- const isTab = navigation?.instance?.getState?.()?.type == 'tab';
131
+ const isTab = navigation?.instance?.getState?.()?.type === 'tab';
132
132
 
133
133
  let styleAnimatedHeader: NavigationOptions;
134
134
  let handleScroll;
135
135
  let headerBackground: string | undefined = undefined;
136
136
  let Component: any = View;
137
137
  let keyboardOffset = heightHeader - 20;
138
- if (headerType == 'extended' || animatedHeader) {
138
+ if (headerType === 'extended' || animatedHeader) {
139
139
  keyboardOffset = -20;
140
140
  }
141
141
 
142
- if (headerType == 'extended') {
142
+ if (headerType === 'extended') {
143
143
  headerBackground = theme.assets?.headerBackground;
144
144
  }
145
145
 
@@ -157,7 +157,7 @@ const Screen = forwardRef(
157
157
  <HeaderTitle {...props} animatedValue={animatedValue.current} />
158
158
  ),
159
159
  };
160
- if (animatedHeader.type == 'surface') {
160
+ if (animatedHeader.type === 'surface') {
161
161
  styleAnimatedHeader = {
162
162
  ...styleAnimatedHeader,
163
163
  headerBackground: (props: any) => (
@@ -249,13 +249,13 @@ const Screen = forwardRef(
249
249
  useNativeDriver: true,
250
250
  listener: (e: NativeSyntheticEvent<NativeScrollEvent>) => {
251
251
  scrollViewProps?.onScroll?.(e);
252
- if (animatedHeader?.type == 'surface') {
252
+ if (animatedHeader?.type === 'surface') {
253
253
  const offsetY = e.nativeEvent.contentOffset.y;
254
254
  let color = Colors.black_01;
255
255
  if (offsetY > 50) {
256
256
  color = theme.colors.text.default;
257
257
  }
258
- if (color != currentTint.current) {
258
+ if (color !== currentTint.current) {
259
259
  currentTint.current = color;
260
260
  navigation?.setOptions({
261
261
  headerTintColor: color,
@@ -263,7 +263,7 @@ const Screen = forwardRef(
263
263
  }
264
264
  }
265
265
  },
266
- },
266
+ }
267
267
  );
268
268
  }
269
269
  }
@@ -287,7 +287,7 @@ const Screen = forwardRef(
287
287
  if (Array.isArray(results)) {
288
288
  return results.map((item, index) => {
289
289
  const space = item?.props?.useMargin === false ? 0 : Spacing.M;
290
- if (item?.type == Fragment) {
290
+ if (item?.type === Fragment) {
291
291
  return renderContent(item?.props?.children);
292
292
  }
293
293
  if (item) {
@@ -307,7 +307,7 @@ const Screen = forwardRef(
307
307
  } else {
308
308
  const item: any = children;
309
309
  const space = item?.props?.useMargin === false ? 0 : Spacing.M;
310
- if (item?.type == Fragment) {
310
+ if (item?.type === Fragment) {
311
311
  return renderContent(item?.props?.children);
312
312
  }
313
313
  return (
@@ -387,7 +387,7 @@ const Screen = forwardRef(
387
387
  </KeyboardAvoidingView>
388
388
  </View>
389
389
  );
390
- },
390
+ }
391
391
  );
392
392
 
393
393
  export default Screen;
@@ -5,7 +5,7 @@ import {Button} from '../Button';
5
5
  import {Radius, Spacing, Styles} from '../Consts';
6
6
  import {Icon} from '../Icon';
7
7
  import {Image} from '../Image';
8
- import {Text} from '../Text';
8
+ import {scaleSize, Text} from '../Text';
9
9
  import {PopupNotifyProps} from './types';
10
10
 
11
11
  const PopupNotify: React.FC<PopupNotifyProps> = ({
@@ -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 = {height: 80};
30
+ descriptionStyle = {maxHeight: scaleSize(172)};
31
31
  }
32
32
  /**
33
33
  * tracking
package/Title/styles.ts CHANGED
@@ -46,16 +46,16 @@ export default StyleSheet.create({
46
46
  marginRight: Spacing.S,
47
47
  },
48
48
  iconRight: {
49
- width: scaleSize(22),
50
- height: scaleSize(22),
49
+ width: 22,
50
+ height: 22,
51
51
  borderRadius: Radius.M,
52
52
  alignItems: 'center',
53
53
  justifyContent: 'center',
54
54
  marginLeft: Spacing.S,
55
55
  },
56
56
  iconLeft: {
57
- width: scaleSize(18),
58
- height: scaleSize(18),
57
+ width: 18,
58
+ height: 18,
59
59
  borderRadius: Radius.M,
60
60
  alignItems: 'center',
61
61
  justifyContent: 'center',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.92.30",
3
+ "version": "0.92.32",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {},
package/publish.sh CHANGED
@@ -1,11 +1,5 @@
1
1
  #!/bin/bash
2
2
 
3
- # Prepare dist files
4
- rm -rf dist
5
- mkdir dist
6
- rsync -r --exclude=/dist ./* dist
7
- cd dist
8
-
9
3
  if [ "$1" == "stable" ]; then
10
4
  npm version $(npm view @momo-kits/foundation@stable version)
11
5
  npm version patch
@@ -22,7 +16,3 @@ fi
22
16
 
23
17
  PACKAGE_NAME=$(npm pkg get name)
24
18
  NEW_PACKAGE_VERSION=$(npm pkg get version)
25
-
26
- # Clean up
27
- cd ..
28
- rm -rf dist