@momo-kits/foundation 0.77.8 → 0.78.1

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.
Files changed (52) hide show
  1. package/Application/BottomTab.tsx +13 -3
  2. package/Application/Components.tsx +51 -4
  3. package/Application/ModalScreen.tsx +17 -16
  4. package/Application/Navigation.ts +4 -2
  5. package/Application/NavigationContainer.tsx +22 -1
  6. package/Application/index.ts +8 -2
  7. package/Application/types.ts +19 -15
  8. package/Application/utils.tsx +13 -0
  9. package/Assets/DotAnimation.json +256 -0
  10. package/Assets/SpinnerAnimation.json +1027 -0
  11. package/Button/index.tsx +25 -14
  12. package/CheckBox/index.tsx +29 -24
  13. package/CheckBox/styles.ts +1 -1
  14. package/CheckBox/types.ts +1 -1
  15. package/Consts/styles.ts +0 -26
  16. package/Divider/index.tsx +2 -0
  17. package/Input/Input.tsx +126 -106
  18. package/Input/InputMoney.tsx +118 -110
  19. package/Input/InputSearch.tsx +129 -134
  20. package/Input/InputTextArea.tsx +126 -118
  21. package/Input/common.tsx +11 -5
  22. package/Input/index.tsx +12 -0
  23. package/Layout/Card.tsx +9 -2
  24. package/Layout/GridSystem.tsx +1 -1
  25. package/Layout/Item.tsx +15 -2
  26. package/Layout/Screen.tsx +76 -8
  27. package/Layout/Section.tsx +36 -3
  28. package/Layout/index.ts +1 -1
  29. package/Layout/types.ts +0 -37
  30. package/Layout/utils.ts +6 -9
  31. package/Loader/DotLoader.tsx +37 -0
  32. package/Loader/Loader.tsx +13 -0
  33. package/Loader/ProgressBar.tsx +44 -0
  34. package/Loader/Spinner.tsx +29 -0
  35. package/Loader/index.tsx +4 -0
  36. package/Loader/styles.ts +10 -0
  37. package/Loader/types.ts +35 -0
  38. package/Loader/utils.ts +25 -0
  39. package/Pagination/PaginationNumber.tsx +1 -2
  40. package/Pagination/PaginationWhiteDot.tsx +1 -3
  41. package/Popup/PopupNotify.tsx +11 -17
  42. package/Popup/PopupPromotion.tsx +19 -13
  43. package/Popup/types.ts +9 -1
  44. package/Radio/index.tsx +1 -1
  45. package/Skeleton/types.ts +3 -0
  46. package/Text/index.tsx +1 -16
  47. package/Text/utils.ts +1 -1
  48. package/code-scanner.js +51 -0
  49. package/index.ts +2 -0
  50. package/package.json +8 -4
  51. package/tsconfig.json +25 -0
  52. package/Application/NavigationButton.tsx +0 -54
@@ -1,4 +1,4 @@
1
- import React, {FC, useContext, useRef, useState} from 'react';
1
+ import React, {FC, forwardRef, useContext, useRef, useState} from 'react';
2
2
  import {
3
3
  NativeSyntheticEvent,
4
4
  TextInput,
@@ -13,123 +13,131 @@ import {InputMoneyProps} from './index';
13
13
  import {Icon} from '../Icon';
14
14
  import {formatMoneyToNumber, formatNumberToMoney} from './utils';
15
15
 
16
- const InputMoney: FC<InputMoneyProps> = ({
17
- onChangeText,
18
- floatingValue,
19
- floatingIcon,
20
- size = 'small',
21
- onBlur,
22
- onFocus,
23
- errorMessage,
24
- icon,
25
- disabled,
26
- floatingIconColor,
27
- iconColor,
28
- required,
29
- ...props
30
- }) => {
31
- const {theme} = useContext(ApplicationContext);
32
- const [focused, setFocused] = useState(false);
33
- const inputRef = useRef<any>(null);
34
- const [value, setValue] = useState('');
35
- const onClearText = () => {
36
- inputRef?.current?.clear();
37
- setValue('');
38
- onChangeText?.('');
39
- };
40
- const _onChangeText = (text: string) => {
41
- if (text.length < value.length && value.indexOf(text) === 0) {
42
- text = value.slice(0, -2) + 'đ';
43
- }
44
- const valueFormat = formatMoneyToNumber(text, 'đ');
45
- setValue(formatNumberToMoney(valueFormat, 'đ'));
46
- onChangeText?.(formatMoneyToNumber(text, 'đ').toString());
47
- };
16
+ const InputMoney: FC<InputMoneyProps> = forwardRef(
17
+ (
18
+ {
19
+ onChangeText,
20
+ floatingValue,
21
+ floatingIcon,
22
+ size = 'small',
23
+ onBlur,
24
+ onFocus,
25
+ errorMessage,
26
+ icon,
27
+ disabled,
28
+ floatingIconColor,
29
+ iconColor,
30
+ required,
31
+ errorSpacing,
32
+ ...props
33
+ },
34
+ ref,
35
+ ) => {
36
+ const {theme} = useContext(ApplicationContext);
37
+ const [focused, setFocused] = useState(false);
38
+ const inputRef = (ref as React.RefObject<TextInput>) ?? useRef<TextInput>();
39
+ const [value, setValue] = useState('');
40
+ const onClearText = () => {
41
+ inputRef?.current?.clear();
42
+ setValue('');
43
+ onChangeText?.('');
44
+ };
45
+ const _onChangeText = (text: string) => {
46
+ if (text.length < value.length && value.indexOf(text) === 0) {
47
+ text = value.slice(0, -2) + 'đ';
48
+ }
49
+ const valueFormat = formatMoneyToNumber(text, 'đ');
50
+ setValue(formatNumberToMoney(valueFormat, 'đ'));
51
+ onChangeText?.(formatMoneyToNumber(text, 'đ').toString());
52
+ };
48
53
 
49
- const _onFocus = (e: NativeSyntheticEvent<TextInputFocusEventData>) => {
50
- setFocused(true);
51
- onFocus?.(e);
52
- };
54
+ const _onFocus = (e: NativeSyntheticEvent<TextInputFocusEventData>) => {
55
+ setFocused(true);
56
+ onFocus?.(e);
57
+ };
53
58
 
54
- const _onBlur = (e: NativeSyntheticEvent<TextInputFocusEventData>) => {
55
- setFocused(false);
56
- onBlur?.(e);
57
- };
59
+ const _onBlur = (e: NativeSyntheticEvent<TextInputFocusEventData>) => {
60
+ setFocused(false);
61
+ onBlur?.(e);
62
+ };
58
63
 
59
- const renderInputView = () => {
60
- const disabledColor = theme.colors.text.disable;
61
- let textColor = theme.colors.text.default;
62
- let placeholderColor = theme.colors.text.hint;
63
- let iconTintColor = iconColor;
64
+ const renderInputView = () => {
65
+ const disabledColor = theme.colors.text.disable;
66
+ let textColor = theme.colors.text.default;
67
+ let placeholderColor = theme.colors.text.hint;
68
+ let iconTintColor = iconColor;
64
69
 
65
- if (disabled) {
66
- textColor = disabledColor;
67
- placeholderColor = disabledColor;
68
- iconTintColor = disabledColor;
69
- }
70
+ if (disabled) {
71
+ textColor = disabledColor;
72
+ placeholderColor = disabledColor;
73
+ iconTintColor = disabledColor;
74
+ }
70
75
 
71
- return (
72
- <View
73
- style={[
74
- getSizeStyle(size),
75
- getBorderColor(focused, errorMessage, disabled),
76
- styles.inputWrapper,
77
- {backgroundColor: theme.colors.background.surface},
78
- ]}>
79
- <FloatingView
80
- floatingValue={floatingValue}
81
- floatingIconColor={floatingIconColor}
82
- disabled={disabled}
83
- required={required}
84
- floatingIcon={floatingIcon}
85
- />
86
- <View style={styles.inputView}>
87
- <TextInput
88
- {...props}
89
- accessibilityLabel={`TextInput`}
90
- editable={!disabled}
91
- textAlignVertical="top"
92
- ref={inputRef}
93
- keyboardType={'number-pad'}
94
- style={[
95
- styles.moneyInput,
96
- {
97
- color: textColor,
98
- },
99
- ]}
100
- value={value}
101
- onChangeText={_onChangeText}
102
- onFocus={_onFocus}
103
- onBlur={_onBlur}
104
- selectionColor={theme.colors.primary}
105
- placeholderTextColor={placeholderColor}
106
- placeholder={'0đ'}
76
+ return (
77
+ <View
78
+ style={[
79
+ styles.inputWrapper,
80
+ {backgroundColor: theme.colors.background.surface},
81
+ getSizeStyle(size),
82
+ getBorderColor(theme, focused, errorMessage, disabled),
83
+ ]}>
84
+ <FloatingView
85
+ floatingValue={floatingValue}
86
+ floatingIconColor={floatingIconColor}
87
+ disabled={disabled}
88
+ required={required}
89
+ floatingIcon={floatingIcon}
107
90
  />
91
+ <View style={styles.inputView}>
92
+ <TextInput
93
+ {...props}
94
+ accessibilityLabel={`TextInput`}
95
+ editable={!disabled}
96
+ textAlignVertical="top"
97
+ ref={inputRef}
98
+ keyboardType={'number-pad'}
99
+ style={[
100
+ styles.moneyInput,
101
+ {
102
+ color: textColor,
103
+ },
104
+ ]}
105
+ value={value}
106
+ onChangeText={_onChangeText}
107
+ onFocus={_onFocus}
108
+ onBlur={_onBlur}
109
+ selectionColor={theme.colors.primary}
110
+ placeholderTextColor={placeholderColor}
111
+ placeholder={'0đ'}
112
+ />
113
+ </View>
114
+ <View style={styles.iconView}>
115
+ {focused && (
116
+ <TouchableOpacity
117
+ style={styles.iconWrapper}
118
+ onPress={onClearText}>
119
+ <Icon
120
+ source="24_navigation_close_circle_full"
121
+ size={16}
122
+ color={theme.colors.text.hint}
123
+ />
124
+ </TouchableOpacity>
125
+ )}
126
+ {!!icon && <Icon color={iconTintColor} source={icon} />}
127
+ </View>
108
128
  </View>
109
- <View style={styles.iconView}>
110
- {focused && (
111
- <TouchableOpacity style={styles.iconWrapper} onPress={onClearText}>
112
- <Icon
113
- source="24_navigation_close_circle_full"
114
- size={16}
115
- color={theme.colors.text.hint}
116
- />
117
- </TouchableOpacity>
118
- )}
119
- {!!icon && <Icon color={iconTintColor} source={icon} />}
120
- </View>
129
+ );
130
+ };
131
+
132
+ return (
133
+ <View
134
+ style={styles.wrapper}
135
+ accessibilityLabel={`InputMoney/${floatingValue}`}>
136
+ {renderInputView()}
137
+ <ErrorView errorMessage={errorMessage} errorSpacing={errorSpacing} />
121
138
  </View>
122
139
  );
123
- };
124
-
125
- return (
126
- <View
127
- style={styles.wrapper}
128
- accessibilityLabel={`InputMoney/${floatingValue}`}>
129
- {renderInputView()}
130
- <ErrorView errorMessage={errorMessage} />
131
- </View>
132
- );
133
- };
140
+ },
141
+ );
134
142
 
135
143
  export default InputMoney;
@@ -1,4 +1,4 @@
1
- import React, {FC, useContext, useRef, useState} from 'react';
1
+ import React, {FC, forwardRef, useContext, useRef, useState} from 'react';
2
2
  import {
3
3
  NativeSyntheticEvent,
4
4
  TextInput,
@@ -13,151 +13,146 @@ import {Icon} from '../Icon';
13
13
  import {Text} from '../Text';
14
14
  import {checkTyping} from './utils';
15
15
 
16
- const InputSearch: FC<InputSearchProps> = ({
17
- placeholder,
18
- onFocus,
19
- onBlur,
20
- iconColor,
21
- value,
22
- onChangeText,
23
- icon,
24
- buttonText = 'Hủy',
25
- showButtonText = true,
26
- showBorder = true,
27
- style,
28
- defaultValue,
29
- onPressButtonText,
30
- ...props
31
- }) => {
32
- const {theme} = useContext(ApplicationContext);
33
- const [focused, setFocused] = useState(false);
34
- const [haveValue, setHaveValue] = useState(!!value || !!defaultValue);
35
- const inputRef = useRef<any>(null);
36
- let iconTintColor = iconColor;
16
+ const InputSearch: FC<InputSearchProps> = forwardRef(
17
+ (
18
+ {
19
+ placeholder,
20
+ onFocus,
21
+ onBlur,
22
+ iconColor,
23
+ value,
24
+ onChangeText,
25
+ icon,
26
+ buttonText = 'Hủy',
27
+ showButtonText = true,
28
+ showBorder = true,
29
+ style,
30
+ defaultValue,
31
+ onPressButtonText,
32
+ ...props
33
+ },
34
+ ref,
35
+ ) => {
36
+ const {theme} = useContext(ApplicationContext);
37
+ const [focused, setFocused] = useState(false);
38
+ const [haveValue, setHaveValue] = useState(!!value || !!defaultValue);
39
+ const inputRef = (ref as React.RefObject<TextInput>) ?? useRef<TextInput>();
40
+ let iconTintColor = iconColor;
37
41
 
38
- const _onFocus = (e: NativeSyntheticEvent<TextInputFocusEventData>) => {
39
- setFocused(true);
40
- onFocus?.(e);
41
- };
42
+ const _onFocus = (e: NativeSyntheticEvent<TextInputFocusEventData>) => {
43
+ setFocused(true);
44
+ onFocus?.(e);
45
+ };
42
46
 
43
- const _onBlur = (e: NativeSyntheticEvent<TextInputFocusEventData>) => {
44
- setFocused(false);
45
- onBlur?.(e);
46
- };
47
+ const _onBlur = (e: NativeSyntheticEvent<TextInputFocusEventData>) => {
48
+ setFocused(false);
49
+ onBlur?.(e);
50
+ };
47
51
 
48
- const onClearText = () => {
49
- inputRef?.current?.clear();
50
- _onChangeText('');
51
- };
52
+ const onClearText = () => {
53
+ inputRef?.current?.clear();
54
+ _onChangeText('');
55
+ };
52
56
 
53
- const _onChangeText = (text: string) => {
54
- checkTyping(text, haveValue, setHaveValue);
55
- onChangeText?.(text);
56
- };
57
+ const _onChangeText = (text: string) => {
58
+ checkTyping(text, haveValue, setHaveValue);
59
+ onChangeText?.(text);
60
+ };
57
61
 
58
- const getBorderColor = () => {
59
- let borderColor = showBorder
60
- ? theme.colors.border.default
61
- : theme.colors.background.surface;
62
+ const renderInputView = () => {
63
+ let textColor = theme.colors.text.default;
64
+ let placeholderColor = theme.colors.text.hint;
62
65
 
63
- if (focused) {
64
- borderColor = theme.colors.primary;
65
- }
66
-
67
- return {borderColor};
68
- };
69
-
70
- const renderInputView = () => {
71
- let textColor = theme.colors.text.default;
72
- let placeholderColor = theme.colors.text.hint;
73
-
74
- return (
75
- <TextInput
76
- {...props}
77
- accessibilityLabel={`TextInput`}
78
- textAlignVertical="top"
79
- ref={inputRef}
80
- style={[
81
- styles.searchInput,
82
- {
83
- color: textColor,
84
- },
85
- ]}
86
- value={value}
87
- onChangeText={_onChangeText}
88
- onFocus={_onFocus}
89
- onBlur={_onBlur}
90
- placeholder={placeholder}
91
- selectionColor={theme.colors.primary}
92
- placeholderTextColor={placeholderColor}
93
- />
94
- );
95
- };
66
+ return (
67
+ <TextInput
68
+ {...props}
69
+ accessibilityLabel={`TextInput`}
70
+ textAlignVertical="top"
71
+ ref={inputRef}
72
+ style={[
73
+ styles.searchInput,
74
+ {
75
+ color: textColor,
76
+ },
77
+ ]}
78
+ value={value}
79
+ onChangeText={_onChangeText}
80
+ onFocus={_onFocus}
81
+ onBlur={_onBlur}
82
+ placeholder={placeholder}
83
+ selectionColor={theme.colors.primary}
84
+ placeholderTextColor={placeholderColor}
85
+ />
86
+ );
87
+ };
96
88
 
97
- const renderIconView = () => {
89
+ const renderIconView = () => {
90
+ return (
91
+ <View
92
+ style={{
93
+ flexDirection: 'row',
94
+ }}>
95
+ {focused && haveValue && (
96
+ <TouchableOpacity style={styles.iconWrapper} onPress={onClearText}>
97
+ <Icon
98
+ source="24_navigation_close_circle_full"
99
+ size={16}
100
+ color={theme.colors.text.hint}
101
+ />
102
+ </TouchableOpacity>
103
+ )}
104
+ {!!icon && (
105
+ <View style={{flexDirection: 'row'}}>
106
+ <View
107
+ style={[
108
+ styles.divider,
109
+ {
110
+ backgroundColor: theme.colors.primary,
111
+ },
112
+ ]}
113
+ />
114
+ <Icon
115
+ color={iconTintColor}
116
+ source={icon}
117
+ style={styles.iconSearchInput}
118
+ />
119
+ </View>
120
+ )}
121
+ </View>
122
+ );
123
+ };
98
124
  return (
99
125
  <View
100
- style={{
101
- flexDirection: 'row',
102
- }}>
103
- {focused && haveValue && (
104
- <TouchableOpacity style={styles.iconWrapper} onPress={onClearText}>
105
- <Icon
106
- source="24_navigation_close_circle_full"
107
- size={16}
108
- color={theme.colors.text.hint}
109
- />
126
+ style={[style, styles.searchInputContainer]}
127
+ accessibilityLabel={`InputSearch/${placeholder}`}>
128
+ <View
129
+ style={[
130
+ styles.searchInputWrapper,
131
+ {
132
+ backgroundColor: theme.colors.background.surface,
133
+ borderColor: theme.colors.background.surface,
134
+ },
135
+ showBorder && {borderColor: theme.colors.border.default},
136
+ focused && {borderColor: theme.colors.primary},
137
+ ]}>
138
+ <Icon
139
+ source={'navigation_search'}
140
+ size={24}
141
+ color={theme.colors.text.hint}
142
+ />
143
+ {renderInputView()}
144
+ {renderIconView()}
145
+ </View>
146
+ {showButtonText && (
147
+ <TouchableOpacity onPress={onPressButtonText}>
148
+ <Text typography={'action_default'} style={styles.textButton}>
149
+ {buttonText}
150
+ </Text>
110
151
  </TouchableOpacity>
111
152
  )}
112
- {!!icon && (
113
- <View style={{flexDirection: 'row'}}>
114
- <View
115
- style={[
116
- styles.divider,
117
- {
118
- backgroundColor: theme.colors.primary,
119
- },
120
- ]}
121
- />
122
- <Icon
123
- color={iconTintColor}
124
- source={icon}
125
- style={styles.iconSearchInput}
126
- />
127
- </View>
128
- )}
129
153
  </View>
130
154
  );
131
- };
132
- return (
133
- <View
134
- style={[style, styles.searchInputContainer]}
135
- accessibilityLabel={`InputSearch/${placeholder}`}>
136
- <View
137
- style={[
138
- getBorderColor(),
139
- styles.searchInputWrapper,
140
- {
141
- backgroundColor: theme.colors.background.surface,
142
- },
143
- ]}>
144
- <Icon
145
- source={'navigation_search'}
146
- size={24}
147
- color={theme.colors.text.hint}
148
- />
149
- {renderInputView()}
150
- {renderIconView()}
151
- </View>
152
- {showButtonText && (
153
- <TouchableOpacity onPress={onPressButtonText}>
154
- <Text typography={'action_default'} style={styles.textButton}>
155
- {buttonText}
156
- </Text>
157
- </TouchableOpacity>
158
- )}
159
- </View>
160
- );
161
- };
155
+ },
156
+ );
162
157
 
163
158
  export default InputSearch;