@momo-kits/foundation 0.92.8-rc.6 → 0.92.8-rc.8
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 +20 -3
- package/Application/StackScreen.tsx +3 -2
- package/Application/types.ts +1 -0
- package/Input/InputMoney.tsx +9 -0
- package/Input/index.tsx +5 -10
- package/Layout/Screen.tsx +11 -10
- package/Title/index.tsx +7 -2
- package/package.json +1 -1
|
@@ -28,6 +28,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
28
28
|
barrierDismissible = false,
|
|
29
29
|
draggable = true,
|
|
30
30
|
useBottomInset = true,
|
|
31
|
+
keyboardVerticalOffset,
|
|
31
32
|
}: BottomSheetParams = props.route.params;
|
|
32
33
|
const pan = useRef(
|
|
33
34
|
new Animated.ValueXY({
|
|
@@ -83,7 +84,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
83
84
|
/**
|
|
84
85
|
* handler dismiss
|
|
85
86
|
*/
|
|
86
|
-
const onDismiss = (force = false) => {
|
|
87
|
+
const onDismiss = (force = false, callback?: () => void) => {
|
|
87
88
|
if (barrierDismissible && !force) {
|
|
88
89
|
return;
|
|
89
90
|
}
|
|
@@ -93,9 +94,20 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
93
94
|
duration: 100,
|
|
94
95
|
}).start(() => {
|
|
95
96
|
navigator?.pop();
|
|
97
|
+
callback?.();
|
|
96
98
|
});
|
|
97
99
|
};
|
|
98
100
|
|
|
101
|
+
/**
|
|
102
|
+
* manual close
|
|
103
|
+
*/
|
|
104
|
+
const requestClose = useCallback((callback?: () => void) => {
|
|
105
|
+
onDismiss(true, callback);
|
|
106
|
+
}, []);
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* render header
|
|
110
|
+
*/
|
|
99
111
|
const renderHeader = useCallback(() => {
|
|
100
112
|
return (
|
|
101
113
|
<View
|
|
@@ -137,7 +149,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
137
149
|
<Modal transparent visible={true} onRequestClose={() => onDismiss()}>
|
|
138
150
|
<KeyboardAvoidingView
|
|
139
151
|
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
|
|
140
|
-
keyboardVerticalOffset={-20}
|
|
152
|
+
keyboardVerticalOffset={keyboardVerticalOffset ?? -20}
|
|
141
153
|
style={[Styles.flex, {justifyContent: 'flex-end'}]}>
|
|
142
154
|
<TouchableOpacity
|
|
143
155
|
style={Styles.flex}
|
|
@@ -147,7 +159,11 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
147
159
|
<Animated.View style={{transform: pan.getTranslateTransform()}}>
|
|
148
160
|
{renderHeader()}
|
|
149
161
|
<View style={{backgroundColor: backgroundColor}}>
|
|
150
|
-
<Screen
|
|
162
|
+
<Screen
|
|
163
|
+
{...props}
|
|
164
|
+
{...props.route.params}
|
|
165
|
+
requestClose={requestClose}
|
|
166
|
+
/>
|
|
151
167
|
{useBottomInset && (
|
|
152
168
|
<View style={{height: Math.min(insets.bottom, 21)}} />
|
|
153
169
|
)}
|
|
@@ -157,6 +173,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
157
173
|
</Modal>
|
|
158
174
|
);
|
|
159
175
|
};
|
|
176
|
+
|
|
160
177
|
export default BottomSheet;
|
|
161
178
|
|
|
162
179
|
const styles = StyleSheet.create({
|
|
@@ -50,10 +50,11 @@ const StackScreen: React.FC<ScreenParams> = props => {
|
|
|
50
50
|
* tracking for screen
|
|
51
51
|
*/
|
|
52
52
|
useEffect(() => {
|
|
53
|
-
|
|
53
|
+
if (__DEV__ && (!screenName || screenName == 'Invalid')) {
|
|
54
|
+
Alert.alert('Design system', `Unvalidated screen name "${screenName}" !`);
|
|
55
|
+
}
|
|
54
56
|
|
|
55
57
|
navigator?.maxApi?.of?.({screenName});
|
|
56
|
-
|
|
57
58
|
tracked.current.timeoutLoad = setTimeout(() => {
|
|
58
59
|
onScreenLoad();
|
|
59
60
|
}, 5000);
|
package/Application/types.ts
CHANGED
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
|
@@ -105,14 +105,8 @@ export interface InputProps extends TextInputProps {
|
|
|
105
105
|
hintText?: string;
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
|
|
109
|
-
InputProps,
|
|
110
|
-
'size' | 'icon' | 'iconColor'
|
|
111
|
-
>;
|
|
112
|
-
|
|
113
|
-
type InputPropsWithoutPlaceholder = Omit<InputProps, 'placeholder'>;
|
|
114
|
-
|
|
115
|
-
export interface InputTextAreaProps extends InputPropsWithoutSizeAndIcon {
|
|
108
|
+
export interface InputTextAreaProps
|
|
109
|
+
extends Omit<InputProps, 'size' | 'icon' | 'iconColor'> {
|
|
116
110
|
/**
|
|
117
111
|
* Optional. Defines the height of the InputTextArea component.
|
|
118
112
|
* It can be used to set a specific height for the text area.
|
|
@@ -152,11 +146,12 @@ export interface InputSearchProps extends TextInputProps {
|
|
|
152
146
|
params?: any;
|
|
153
147
|
}
|
|
154
148
|
|
|
155
|
-
export interface InputMoneyProps extends
|
|
149
|
+
export interface InputMoneyProps extends Omit<InputProps, 'placeholder'> {}
|
|
156
150
|
|
|
157
151
|
export type OTPInputLength = 2 | 4 | 6 | 8 | 10;
|
|
158
152
|
|
|
159
|
-
export interface InputOTPProps
|
|
153
|
+
export interface InputOTPProps
|
|
154
|
+
extends Omit<InputProps, 'size' | 'icon' | 'iconColor'> {
|
|
160
155
|
/**
|
|
161
156
|
* Optional. Defines the length of the OTP (One Time Password) input.
|
|
162
157
|
* Can be 2, 4, 6, 8, or 10.
|
package/Layout/Screen.tsx
CHANGED
|
@@ -33,6 +33,9 @@ import styles from './styles';
|
|
|
33
33
|
import {HeaderType} from './types';
|
|
34
34
|
|
|
35
35
|
export interface ScreenProps extends ViewProps {
|
|
36
|
+
/**
|
|
37
|
+
* ReactNode representing the content of the screen.
|
|
38
|
+
*/
|
|
36
39
|
children: React.ReactNode;
|
|
37
40
|
/**
|
|
38
41
|
* Optional. Navigation object for handling navigation actions.
|
|
@@ -90,9 +93,10 @@ export interface ScreenProps extends ViewProps {
|
|
|
90
93
|
floatingButtonProps?: Omit<FloatingButtonProps, 'animatedValue' | 'bottom'>;
|
|
91
94
|
|
|
92
95
|
/**
|
|
93
|
-
*
|
|
96
|
+
* Optional. Keyboard vertical offset.
|
|
94
97
|
*/
|
|
95
|
-
|
|
98
|
+
keyboardVerticalOffset?: number;
|
|
99
|
+
|
|
96
100
|
/**
|
|
97
101
|
* Optional. If `true`, the screen content is using grid layout by span.
|
|
98
102
|
*/
|
|
@@ -115,13 +119,11 @@ const Screen = forwardRef(
|
|
|
115
119
|
headerType = 'default',
|
|
116
120
|
floatingButtonProps,
|
|
117
121
|
useGridLayout = true,
|
|
118
|
-
|
|
122
|
+
keyboardVerticalOffset,
|
|
119
123
|
}: ScreenProps,
|
|
120
124
|
ref,
|
|
121
125
|
) => {
|
|
122
|
-
const animatedValue = useRef<Animated.Value>(
|
|
123
|
-
animated ?? new Animated.Value(0),
|
|
124
|
-
);
|
|
126
|
+
const animatedValue = useRef<Animated.Value>(new Animated.Value(0));
|
|
125
127
|
const {theme} = useContext(ApplicationContext);
|
|
126
128
|
const insets = useSafeAreaInsets();
|
|
127
129
|
const heightHeader = useHeaderHeight();
|
|
@@ -132,10 +134,9 @@ const Screen = forwardRef(
|
|
|
132
134
|
let handleScroll;
|
|
133
135
|
let headerBackground: string | undefined = undefined;
|
|
134
136
|
let Component: any = View;
|
|
135
|
-
let
|
|
136
|
-
|
|
137
|
+
let keyboardOffset = heightHeader - 20;
|
|
137
138
|
if (headerType == 'extended' || animatedHeader) {
|
|
138
|
-
|
|
139
|
+
keyboardOffset = -20;
|
|
139
140
|
}
|
|
140
141
|
|
|
141
142
|
if (headerType == 'extended') {
|
|
@@ -339,7 +340,7 @@ const Screen = forwardRef(
|
|
|
339
340
|
<KeyboardAvoidingView
|
|
340
341
|
style={Styles.flex}
|
|
341
342
|
enabled={enableKeyboardAvoidingView}
|
|
342
|
-
keyboardVerticalOffset={keyboardVerticalOffset}
|
|
343
|
+
keyboardVerticalOffset={keyboardVerticalOffset ?? keyboardOffset}
|
|
343
344
|
behavior={Platform.select({
|
|
344
345
|
ios: 'padding',
|
|
345
346
|
android: undefined,
|
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]}>
|