@momo-kits/foundation 0.81.1-optimize.19 → 0.81.1-optimize.20
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.
- package/Input/InputMoney.tsx +9 -0
- package/Input/index.tsx +12 -18
- package/Title/index.tsx +7 -2
- package/package.json +1 -1
package/Input/InputMoney.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, {
|
|
2
2
|
forwardRef,
|
|
3
3
|
useContext,
|
|
4
|
+
useEffect,
|
|
4
5
|
useImperativeHandle,
|
|
5
6
|
useRef,
|
|
6
7
|
useState,
|
|
@@ -40,6 +41,7 @@ const InputMoney = forwardRef(
|
|
|
40
41
|
defaultValue = '',
|
|
41
42
|
accessibilityLabel,
|
|
42
43
|
hintText,
|
|
44
|
+
value: _value,
|
|
43
45
|
...props
|
|
44
46
|
}: InputMoneyProps,
|
|
45
47
|
ref,
|
|
@@ -48,6 +50,13 @@ const InputMoney = forwardRef(
|
|
|
48
50
|
const [focused, setFocused] = useState(false);
|
|
49
51
|
const inputRef = useRef<TextInput>(null);
|
|
50
52
|
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
if (_value) {
|
|
55
|
+
setValue(validateText(_value));
|
|
56
|
+
onChangeText?.(formatMoneyToNumber(_value, 'đ').toString());
|
|
57
|
+
}
|
|
58
|
+
}, [_value]);
|
|
59
|
+
|
|
51
60
|
const validateText = (text: string) => {
|
|
52
61
|
const valueFormat = formatMoneyToNumber(text, 'đ');
|
|
53
62
|
return formatNumberToMoney(valueFormat, 'đ');
|
package/Input/index.tsx
CHANGED
|
@@ -6,13 +6,6 @@ import InputOTP from './InputOTP';
|
|
|
6
6
|
import InputSearch from './InputSearch';
|
|
7
7
|
import InputTextArea from './InputTextArea';
|
|
8
8
|
|
|
9
|
-
export interface InputRef {
|
|
10
|
-
focus: () => void;
|
|
11
|
-
blur: () => void;
|
|
12
|
-
clear: () => void;
|
|
13
|
-
setText: (text: string) => void;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
9
|
export interface InputProps extends TextInputProps {
|
|
17
10
|
/**
|
|
18
11
|
* Optional. Defines the size of the Input component.
|
|
@@ -105,14 +98,8 @@ export interface InputProps extends TextInputProps {
|
|
|
105
98
|
hintText?: string;
|
|
106
99
|
}
|
|
107
100
|
|
|
108
|
-
|
|
109
|
-
InputProps,
|
|
110
|
-
'size' | 'icon' | 'iconColor'
|
|
111
|
-
>;
|
|
112
|
-
|
|
113
|
-
type InputPropsWithoutPlaceholder = Omit<InputProps, 'placeholder'>;
|
|
114
|
-
|
|
115
|
-
export interface InputTextAreaProps extends InputPropsWithoutSizeAndIcon {
|
|
101
|
+
export interface InputTextAreaProps
|
|
102
|
+
extends Omit<InputProps, 'size' | 'icon' | 'iconColor'> {
|
|
116
103
|
/**
|
|
117
104
|
* Optional. Defines the height of the InputTextArea component.
|
|
118
105
|
* It can be used to set a specific height for the text area.
|
|
@@ -132,6 +119,9 @@ export interface InputSearchProps extends TextInputProps {
|
|
|
132
119
|
*/
|
|
133
120
|
showButtonText?: boolean;
|
|
134
121
|
|
|
122
|
+
/**
|
|
123
|
+
* Optional. Represents the value for the floating title in the InputSearch component.
|
|
124
|
+
*/
|
|
135
125
|
onPressButtonText?: () => void;
|
|
136
126
|
|
|
137
127
|
/**
|
|
@@ -145,18 +135,22 @@ export interface InputSearchProps extends TextInputProps {
|
|
|
145
135
|
icon?: string;
|
|
146
136
|
|
|
147
137
|
/**
|
|
148
|
-
*
|
|
138
|
+
* Optional. If `true`, the user won't be able to interact with the Input component.
|
|
149
139
|
*/
|
|
150
140
|
hasColorBG?: boolean;
|
|
151
141
|
|
|
142
|
+
/**
|
|
143
|
+
* Optional. Represents the style of the InputSearch component.
|
|
144
|
+
*/
|
|
152
145
|
params?: any;
|
|
153
146
|
}
|
|
154
147
|
|
|
155
|
-
export interface InputMoneyProps extends
|
|
148
|
+
export interface InputMoneyProps extends Omit<InputProps, 'placeholder'> {}
|
|
156
149
|
|
|
157
150
|
export type OTPInputLength = 2 | 4 | 6 | 8 | 10;
|
|
158
151
|
|
|
159
|
-
export interface InputOTPProps
|
|
152
|
+
export interface InputOTPProps
|
|
153
|
+
extends Omit<InputProps, 'size' | 'icon' | 'iconColor'> {
|
|
160
154
|
/**
|
|
161
155
|
* Optional. Defines the length of the OTP (One Time Password) input.
|
|
162
156
|
* Can be 2, 4, 6, 8, or 10.
|
package/Title/index.tsx
CHANGED
|
@@ -143,8 +143,14 @@ const Title: FC<TitleProps> = ({
|
|
|
143
143
|
const renderActionRight = () => {
|
|
144
144
|
if (!showRightAction || showTrailingAction) return false;
|
|
145
145
|
|
|
146
|
+
const lineHeight = styleSheet[typography].lineHeight;
|
|
147
|
+
|
|
146
148
|
return (
|
|
147
|
-
<View
|
|
149
|
+
<View
|
|
150
|
+
style={{
|
|
151
|
+
height: lineHeight,
|
|
152
|
+
justifyContent: 'center',
|
|
153
|
+
}}>
|
|
148
154
|
{!buttonTitle ? (
|
|
149
155
|
<TouchableOpacity
|
|
150
156
|
onPress={onPressRightAction}
|
|
@@ -174,7 +180,6 @@ const Title: FC<TitleProps> = ({
|
|
|
174
180
|
if (textOnly) {
|
|
175
181
|
return (
|
|
176
182
|
<View style={isSection && styles.margin}>
|
|
177
|
-
zZ
|
|
178
183
|
<RNText
|
|
179
184
|
numberOfLines={numberOfLines}
|
|
180
185
|
style={[styleSheet[typography], styles.title]}>
|