@momo-kits/foundation 0.81.18-beta.1 → 0.81.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.
@@ -7,6 +7,7 @@ import {
7
7
  StyleSheet,
8
8
  TouchableOpacity,
9
9
  View,
10
+ ViewStyle,
10
11
  } from 'react-native';
11
12
  import {ApplicationContext} from './index';
12
13
  import {Colors, Radius, Spacing, Styles} from '../Consts';
@@ -28,7 +29,6 @@ const styles = StyleSheet.create({
28
29
  height: 28,
29
30
  width: 28,
30
31
  borderRadius: 14,
31
- borderColor: '#00000066',
32
32
  justifyContent: 'center',
33
33
  alignItems: 'center',
34
34
  },
@@ -92,25 +92,23 @@ const NavigationButton: React.FC<NavigationButtonProps> = ({
92
92
  icon,
93
93
  tintColor,
94
94
  onPress,
95
- backgroundColor,
96
95
  useBorder = true,
97
96
  accessibilityLabel,
98
97
  }) => {
99
98
  const {theme} = useContext(ApplicationContext);
100
- if (!backgroundColor && tintColor != Colors.black_01) {
101
- backgroundColor = theme.colors.background.surface;
99
+ let buttonStyle: ViewStyle = {backgroundColor: '#00000066'};
100
+ if (tintColor != Colors.black_01) {
101
+ buttonStyle = {
102
+ backgroundColor: 'transparent',
103
+ borderColor: '#00000066',
104
+ borderWidth: useBorder ? 0.5 : 0,
105
+ };
102
106
  }
103
107
 
104
108
  return (
105
109
  <TouchableOpacity
106
110
  accessibilityLabel={`NavigationButton/${accessibilityLabel}`}
107
- style={[
108
- styles.navigationButton,
109
- {
110
- backgroundColor: backgroundColor ?? '#00000066',
111
- borderWidth: useBorder && backgroundColor ? 0.5 : 0,
112
- },
113
- ]}
111
+ style={[styles.navigationButton, buttonStyle]}
114
112
  onPress={onPress}>
115
113
  <Icon
116
114
  source={icon}
@@ -214,7 +212,6 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
214
212
  onPress={goBack}
215
213
  accessibilityLabel={`${accessibilityLabel}Back`}
216
214
  useBorder={useBorder}
217
- backgroundColor={backgroundColor}
218
215
  />
219
216
  </View>
220
217
  );
@@ -226,7 +226,6 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
226
226
  <NavigationButton
227
227
  {...props}
228
228
  icon="24_navigation_close"
229
- backgroundColor="transparent"
230
229
  useBorder={false}
231
230
  onPress={() => bottomSheetRef.current?.dismiss()}
232
231
  accessibilityLabel={'BottomSheet/Close'}
package/Input/Input.tsx CHANGED
@@ -21,18 +21,18 @@ const Input = forwardRef(
21
21
  onChangeText,
22
22
  floatingValue,
23
23
  floatingIcon,
24
- size,
24
+ size = 'small',
25
25
  placeholder,
26
26
  onBlur,
27
27
  onFocus,
28
28
  errorMessage,
29
29
  icon,
30
- disabled,
30
+ disabled = false,
31
31
  floatingIconColor,
32
32
  iconColor,
33
- required,
33
+ required = false,
34
34
  errorSpacing,
35
- loading,
35
+ loading = false,
36
36
  leadingIcon,
37
37
  leadingIconColor,
38
38
  fontWeight = 'Regular',
@@ -165,8 +165,4 @@ const Input = forwardRef(
165
165
  },
166
166
  );
167
167
 
168
- Input.defaultProps = {
169
- size: 'small',
170
- };
171
-
172
168
  export default Input;
@@ -12,17 +12,17 @@ const InputDropDown = ({
12
12
  value,
13
13
  floatingValue,
14
14
  floatingIcon,
15
- size,
15
+ size = 'small',
16
16
  onPress,
17
17
  placeholder,
18
18
  errorMessage,
19
19
  icon = 'arrow_chevron_down_small',
20
- disabled,
20
+ disabled = false,
21
21
  floatingIconColor,
22
22
  iconColor,
23
- required,
23
+ required = false,
24
24
  errorSpacing,
25
- loading,
25
+ loading = false,
26
26
  leadingIcon,
27
27
  leadingIconColor,
28
28
  style,
@@ -116,8 +116,4 @@ const InputDropDown = ({
116
116
  );
117
117
  };
118
118
 
119
- InputDropDown.defaultProps = {
120
- size: 'small',
121
- };
122
-
123
119
  export default InputDropDown;
@@ -24,12 +24,13 @@ const InputMoney = forwardRef(
24
24
  onFocus,
25
25
  errorMessage,
26
26
  icon,
27
- disabled,
27
+ disabled = false,
28
28
  floatingIconColor,
29
29
  iconColor,
30
- required,
30
+ required = false,
31
31
  errorSpacing,
32
32
  style,
33
+ defaultValue = '',
33
34
  ...props
34
35
  }: InputMoneyProps,
35
36
  ref,
@@ -37,20 +38,26 @@ const InputMoney = forwardRef(
37
38
  const {theme} = useContext(ApplicationContext);
38
39
  const [focused, setFocused] = useState(false);
39
40
  const inputRef = (ref as React.RefObject<TextInput>) ?? useRef<TextInput>();
40
- const [value, setValue] = useState('');
41
41
  const accessibilityLabel = `InputMoney/${floatingValue}`;
42
42
 
43
+ const validateText = (text: string) => {
44
+ const valueFormat = formatMoneyToNumber(text, 'đ');
45
+ return formatNumberToMoney(valueFormat, 'đ');
46
+ };
47
+
48
+ const [value, setValue] = useState(validateText(defaultValue));
49
+
43
50
  const onClearText = () => {
44
51
  inputRef?.current?.clear();
45
52
  setValue('');
46
53
  onChangeText?.('');
47
54
  };
55
+
48
56
  const _onChangeText = (text: string) => {
49
57
  if (text.length < value.length && value.indexOf(text) === 0) {
50
58
  text = value.slice(0, -2) + 'đ';
51
59
  }
52
- const valueFormat = formatMoneyToNumber(text, 'đ');
53
- setValue(formatNumberToMoney(valueFormat, 'đ'));
60
+ setValue(validateText(text));
54
61
  onChangeText?.(formatMoneyToNumber(text, 'đ').toString());
55
62
  };
56
63
 
@@ -29,12 +29,12 @@ const InputTextArea = forwardRef(
29
29
  floatingValue,
30
30
  onFocus,
31
31
  onBlur,
32
- disabled,
32
+ disabled = false,
33
33
  value,
34
34
  defaultValue,
35
35
  height,
36
36
  placeholder,
37
- maxLength,
37
+ maxLength = MAX_LENGTH,
38
38
  required,
39
39
  errorSpacing,
40
40
  style,
@@ -158,8 +158,4 @@ const InputTextArea = forwardRef(
158
158
  },
159
159
  );
160
160
 
161
- InputTextArea.defaultProps = {
162
- maxLength: MAX_LENGTH,
163
- };
164
-
165
161
  export default InputTextArea;
package/Input/index.tsx CHANGED
@@ -85,10 +85,6 @@ type InputPropsWithoutSizeAndIcon = Omit<
85
85
  'size' | 'icon' | 'iconColor'
86
86
  >;
87
87
 
88
- type InputPropsOmitForSearch = Omit<
89
- InputProps,
90
- 'required' | 'size' | 'errorMessage' | 'disabled'
91
- >;
92
88
  type InputPropsWithoutPlaceholder = Omit<InputProps, 'placeholder'>;
93
89
 
94
90
  export interface InputTextAreaProps extends InputPropsWithoutSizeAndIcon {
@@ -99,7 +95,7 @@ export interface InputTextAreaProps extends InputPropsWithoutSizeAndIcon {
99
95
  height?: number;
100
96
  }
101
97
 
102
- export interface InputSearchProps extends InputPropsOmitForSearch {
98
+ export interface InputSearchProps extends TextInputProps {
103
99
  /**
104
100
  * Optional. Represents the text to be displayed on the search button within the InputSearch component.
105
101
  */
@@ -118,6 +114,16 @@ export interface InputSearchProps extends InputPropsOmitForSearch {
118
114
  showBorder?: boolean;
119
115
 
120
116
  onPressButtonText?: () => void;
117
+
118
+ /**
119
+ * Optional. Represents the color of the icon in the Input component.
120
+ */
121
+ iconColor?: string;
122
+
123
+ /**
124
+ * Optional. Represents the name or key of the icon to be displayed in the Input component.
125
+ */
126
+ icon?: string;
121
127
  }
122
128
 
123
129
  export interface InputMoneyProps extends InputPropsWithoutPlaceholder {}
package/Layout/Screen.tsx CHANGED
@@ -267,6 +267,7 @@ const Screen = forwardRef(
267
267
  <KeyboardAvoidingView
268
268
  style={Styles.flex}
269
269
  enabled={enableKeyboardAvoidingView}
270
+ keyboardVerticalOffset={heightHeader - 20}
270
271
  behavior={Platform.select({
271
272
  ios: 'padding',
272
273
  android: undefined,
package/Title/index.tsx CHANGED
@@ -1,7 +1,9 @@
1
1
  import React, {FC, useContext, useState} from 'react';
2
2
  import {
3
3
  LayoutChangeEvent,
4
+ NativeSyntheticEvent,
4
5
  Text as RNText,
6
+ TextLayoutEventData,
5
7
  TouchableOpacity,
6
8
  View,
7
9
  } from 'react-native';
@@ -25,6 +27,7 @@ const Title: FC<TitleProps> = ({
25
27
  }) => {
26
28
  const {theme} = useContext(ApplicationContext);
27
29
  const [containerWidth, setContainerWidth] = useState(0);
30
+ const [textLines, setTextLines] = useState(0);
28
31
  const flexStyle = titleFlex ? {flex: 1} : {};
29
32
  const typeStyle =
30
33
  type === 'screen' ? styles.screen : styles[`${type}_${size}`];
@@ -38,7 +41,10 @@ const Title: FC<TitleProps> = ({
38
41
  const titleWeight = type === 'screen' ? 'Semibold' : 'Bold';
39
42
  const marginStyle = type === 'section' ? {marginTop: Spacing.M} : {};
40
43
  const numberOfLines = type === 'section' ? 1 : 2;
44
+
41
45
  const renderAction = () => {
46
+ if (!actionTitle && !titleFlex && textLines > 1) return null;
47
+
42
48
  return !!actionTitle && titleFlex ? (
43
49
  <TouchableOpacity onPress={onPressAction}>
44
50
  <Text typography={'action_s'} color={theme.colors.primary}>
@@ -66,6 +72,10 @@ const Title: FC<TitleProps> = ({
66
72
  setContainerWidth(e.nativeEvent.layout.width);
67
73
  };
68
74
 
75
+ const onTextLayout = (e: NativeSyntheticEvent<TextLayoutEventData>) => {
76
+ setTextLines(e.nativeEvent.lines.length);
77
+ };
78
+
69
79
  return (
70
80
  <View onLayout={onLayout} style={styles.wrapper}>
71
81
  <View style={[styles.container, marginStyle]}>
@@ -73,6 +83,7 @@ const Title: FC<TitleProps> = ({
73
83
  <Icon style={styles.icon} source={icon} />
74
84
  )}
75
85
  <RNText
86
+ onTextLayout={onTextLayout}
76
87
  numberOfLines={numberOfLines}
77
88
  style={[
78
89
  typeStyle,
package/Title/styles.ts CHANGED
@@ -32,11 +32,10 @@ export default StyleSheet.create({
32
32
  lineHeight: scaleSize(44),
33
33
  },
34
34
  title: {
35
- marginRight: Spacing.XS,
35
+ marginRight: Spacing.S,
36
36
  },
37
37
  container: {
38
38
  flexDirection: 'row',
39
- alignItems: 'baseline',
40
39
  width: '100%',
41
40
  },
42
41
  actionIcon: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.81.18-beta.1",
3
+ "version": "0.81.19",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {