@momo-kits/foundation 0.115.2-beta.12 → 0.115.2-beta.13
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/Application/BottomSheet.tsx +2 -30
- package/Input/InputMoney.tsx +2 -3
- package/Input/InputOTP.tsx +11 -0
- package/Input/styles.ts +6 -0
- package/package.json +1 -1
|
@@ -18,9 +18,6 @@ import {Text} from '../Text';
|
|
|
18
18
|
import {Icon} from '../Icon';
|
|
19
19
|
import {useHeaderHeight} from '@react-navigation/stack';
|
|
20
20
|
import Animated, {Easing, Extrapolate} from 'react-native-reanimated';
|
|
21
|
-
import {Keyboard, LayoutAnimation} from 'react-native';
|
|
22
|
-
import {useState} from 'react';
|
|
23
|
-
import {ScrollView} from 'react-native-gesture-handler';
|
|
24
21
|
|
|
25
22
|
const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
26
23
|
const {theme, navigator} = useContext(ApplicationContext);
|
|
@@ -29,26 +26,6 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
29
26
|
const insets = useSafeAreaInsets();
|
|
30
27
|
const heightHeader = useHeaderHeight();
|
|
31
28
|
const keyboardOffset = heightHeader - Math.min(insets.bottom, 21);
|
|
32
|
-
const [keyboardHeight, setKeyboardHeight] = useState(0);
|
|
33
|
-
|
|
34
|
-
useEffect(() => {
|
|
35
|
-
const onKeyboardShow = (e: any) => {
|
|
36
|
-
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
|
|
37
|
-
setKeyboardHeight(e.endCoordinates.height);
|
|
38
|
-
};
|
|
39
|
-
const onKeyboardHide = () => {
|
|
40
|
-
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
|
|
41
|
-
setKeyboardHeight(0);
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const showSub = Keyboard.addListener('keyboardDidShow', onKeyboardShow);
|
|
45
|
-
const hideSub = Keyboard.addListener('keyboardDidHide', onKeyboardHide);
|
|
46
|
-
|
|
47
|
-
return () => {
|
|
48
|
-
showSub.remove();
|
|
49
|
-
hideSub.remove();
|
|
50
|
-
};
|
|
51
|
-
}, []);
|
|
52
29
|
|
|
53
30
|
const {
|
|
54
31
|
screen: Screen,
|
|
@@ -239,14 +216,9 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
239
216
|
<Animated.View
|
|
240
217
|
style={{
|
|
241
218
|
transform: [{translateY}],
|
|
242
|
-
maxHeight: keyboardHeight > 0 ? heightDevice / 2 : undefined,
|
|
243
219
|
}}>
|
|
244
220
|
{renderHeader()}
|
|
245
|
-
<
|
|
246
|
-
scrollEnabled={keyboardHeight > 0 ? true : false}
|
|
247
|
-
keyboardShouldPersistTaps="handled"
|
|
248
|
-
contentContainerStyle={{flexGrow: 1}}
|
|
249
|
-
style={{backgroundColor: backgroundColor}}>
|
|
221
|
+
<View style={{backgroundColor: backgroundColor}}>
|
|
250
222
|
<Screen
|
|
251
223
|
{...props}
|
|
252
224
|
{...props.route.params}
|
|
@@ -255,7 +227,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
255
227
|
{useBottomInset && (
|
|
256
228
|
<View style={{height: Math.min(insets.bottom, 21)}} />
|
|
257
229
|
)}
|
|
258
|
-
</
|
|
230
|
+
</View>
|
|
259
231
|
</Animated.View>
|
|
260
232
|
</KeyboardAvoidingView>
|
|
261
233
|
</Container>
|
package/Input/InputMoney.tsx
CHANGED
|
@@ -97,10 +97,10 @@ const InputMoney = forwardRef(
|
|
|
97
97
|
};
|
|
98
98
|
|
|
99
99
|
const onClearText = () => {
|
|
100
|
-
inputRef?.current?.clear();
|
|
101
100
|
setDisplayValue('');
|
|
102
101
|
setNumericValue('');
|
|
103
102
|
onChangeText?.('');
|
|
103
|
+
inputRef?.current?.focus();
|
|
104
104
|
};
|
|
105
105
|
|
|
106
106
|
const _onChangeText = (text: string) => {
|
|
@@ -113,8 +113,7 @@ const InputMoney = forwardRef(
|
|
|
113
113
|
|
|
114
114
|
if (text.length < lastDisplayValue.length) {
|
|
115
115
|
const lastChar = lastDisplayValue.charAt(lastDisplayValue.length - 1);
|
|
116
|
-
const isRemovingCurrency =
|
|
117
|
-
lastDisplayValue.endsWith(currency) || lastChar === ' ';
|
|
116
|
+
const isRemovingCurrency = lastDisplayValue.endsWith(currency) || lastChar === ' ';
|
|
118
117
|
const isRemovingDot = lastChar === '.';
|
|
119
118
|
|
|
120
119
|
if (isRemovingCurrency || isRemovingDot) {
|
package/Input/InputOTP.tsx
CHANGED
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
NativeSyntheticEvent,
|
|
13
13
|
TextInput,
|
|
14
14
|
TextInputFocusEventData,
|
|
15
|
+
TouchableOpacity,
|
|
15
16
|
View,
|
|
16
17
|
} from 'react-native';
|
|
17
18
|
import {
|
|
@@ -24,6 +25,7 @@ import {scaleSize, Text} from '../Text';
|
|
|
24
25
|
import {ErrorView, getBorderColor} from './common';
|
|
25
26
|
import {CaretProps, InputOTPProps} from './index';
|
|
26
27
|
import styles from './styles';
|
|
28
|
+
import {Icon} from "../Icon";
|
|
27
29
|
|
|
28
30
|
const OTPCaret: FC<CaretProps> = ({index, length}) => {
|
|
29
31
|
const DURATION = 300;
|
|
@@ -132,6 +134,10 @@ const InputOTP = forwardRef(
|
|
|
132
134
|
onChangeText?.(text);
|
|
133
135
|
};
|
|
134
136
|
|
|
137
|
+
const onClearText = () => {
|
|
138
|
+
_onChangeText('');
|
|
139
|
+
};
|
|
140
|
+
|
|
135
141
|
const renderInputs = (inputLength: number) => {
|
|
136
142
|
const TextInputs: React.ReactNode[] = [];
|
|
137
143
|
for (let i = 0; i < inputLength; i++) {
|
|
@@ -215,6 +221,11 @@ const InputOTP = forwardRef(
|
|
|
215
221
|
</Text>
|
|
216
222
|
</View>
|
|
217
223
|
)}
|
|
224
|
+
{value.length > 0 && focused && (
|
|
225
|
+
<TouchableOpacity onPress={onClearText} style={styles.clearIcon}>
|
|
226
|
+
<Icon source={'24_navigation_close_circle_full'} size={12} />
|
|
227
|
+
</TouchableOpacity>
|
|
228
|
+
)}
|
|
218
229
|
<View style={styles.otpInputsView}>
|
|
219
230
|
{length ? renderInputs(length) : renderUnidentifiedInputs()}
|
|
220
231
|
</View>
|
package/Input/styles.ts
CHANGED
|
@@ -150,8 +150,14 @@ export default StyleSheet.create({
|
|
|
150
150
|
otpInput: {
|
|
151
151
|
height: 56,
|
|
152
152
|
borderRadius: Radius.S,
|
|
153
|
+
justifyContent: 'center',
|
|
153
154
|
borderWidth: 1,
|
|
154
155
|
},
|
|
156
|
+
clearIcon: {
|
|
157
|
+
position: 'absolute',
|
|
158
|
+
right: Spacing.M,
|
|
159
|
+
zIndex: 4,
|
|
160
|
+
},
|
|
155
161
|
otpFloatingView: {
|
|
156
162
|
position: 'absolute',
|
|
157
163
|
top: -Spacing.M + 2,
|