@momo-kits/foundation 0.78.1 → 0.78.2
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/ModalScreen.tsx +33 -6
- package/Application/types.ts +2 -2
- package/Input/Input.tsx +3 -3
- package/Input/InputMoney.tsx +3 -3
- package/Input/InputSearch.tsx +3 -3
- package/Input/InputTextArea.tsx +3 -3
- package/package.json +1 -1
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {
|
|
2
|
+
useCallback,
|
|
3
|
+
useContext,
|
|
4
|
+
useEffect,
|
|
5
|
+
useMemo,
|
|
6
|
+
useRef,
|
|
7
|
+
useState,
|
|
8
|
+
} from 'react';
|
|
2
9
|
import {
|
|
3
|
-
Dimensions,
|
|
4
10
|
KeyboardAvoidingView,
|
|
5
11
|
Platform,
|
|
6
12
|
Pressable,
|
|
@@ -85,11 +91,10 @@ const Modal: React.FC<ModalParams> = props => {
|
|
|
85
91
|
|
|
86
92
|
const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
87
93
|
const {theme, navigator} = useContext(ApplicationContext);
|
|
88
|
-
const {height} = Dimensions.get('window');
|
|
89
94
|
const {
|
|
90
95
|
screen,
|
|
91
96
|
options,
|
|
92
|
-
|
|
97
|
+
useSnap = true,
|
|
93
98
|
}: BottomSheetParams = props.route.params;
|
|
94
99
|
const Component = useRef(screen).current;
|
|
95
100
|
const navigation = new Navigation(props.navigation, theme);
|
|
@@ -100,9 +105,31 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
100
105
|
|
|
101
106
|
delete params.screen;
|
|
102
107
|
|
|
108
|
+
const [contentHeight, setContentHeight] = useState(undefined);
|
|
109
|
+
const snapPoints = useMemo(() => {
|
|
110
|
+
if (useSnap) {
|
|
111
|
+
return ['50%', '90%'];
|
|
112
|
+
}
|
|
113
|
+
return [contentHeight ?? '50%'];
|
|
114
|
+
}, [contentHeight]);
|
|
115
|
+
|
|
103
116
|
const bottomSheetRef = useRef<any>(null);
|
|
104
117
|
const mountedRef = useRef(true);
|
|
105
118
|
|
|
119
|
+
let handleOnLayout;
|
|
120
|
+
if (useSnap) {
|
|
121
|
+
handleOnLayout = useCallback(
|
|
122
|
+
({
|
|
123
|
+
nativeEvent: {
|
|
124
|
+
layout: {height},
|
|
125
|
+
},
|
|
126
|
+
}) => {
|
|
127
|
+
setContentHeight(height);
|
|
128
|
+
},
|
|
129
|
+
[],
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
106
133
|
let backgroundColor = theme.colors.background.default;
|
|
107
134
|
if (options?.surface) {
|
|
108
135
|
backgroundColor = theme.colors.background.surface;
|
|
@@ -127,7 +154,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
127
154
|
<SafeAreaView style={Styles.flex}>
|
|
128
155
|
<BottomSheetModal
|
|
129
156
|
ref={bottomSheetRef}
|
|
130
|
-
snapPoints={snapPoints
|
|
157
|
+
snapPoints={snapPoints}
|
|
131
158
|
onDismiss={() => {
|
|
132
159
|
if (mountedRef.current) {
|
|
133
160
|
navigator?.pop();
|
|
@@ -135,7 +162,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
135
162
|
}}
|
|
136
163
|
handleComponent={null}
|
|
137
164
|
backdropComponent={backdropComponent}>
|
|
138
|
-
<View accessibilityLabel={'BottomSheet'}>
|
|
165
|
+
<View onLayout={handleOnLayout} accessibilityLabel={'BottomSheet'}>
|
|
139
166
|
<View style={[styles.sheetContainer, {backgroundColor}]}>
|
|
140
167
|
<View style={styles.indicatorContainer}>
|
|
141
168
|
<View
|
package/Application/types.ts
CHANGED
|
@@ -83,7 +83,7 @@ export type NavigationContainerProps = {
|
|
|
83
83
|
options?: NavigationOptions;
|
|
84
84
|
theme: Theme;
|
|
85
85
|
maxApi?: any;
|
|
86
|
-
localization
|
|
86
|
+
localization?: LocalizationObject;
|
|
87
87
|
};
|
|
88
88
|
|
|
89
89
|
export type NavigationScreenProps = {
|
|
@@ -107,7 +107,7 @@ export interface ModalParams extends ScreenParams {
|
|
|
107
107
|
export interface BottomSheetParams extends ScreenParams {
|
|
108
108
|
[key: string]: any;
|
|
109
109
|
onDismiss?: () => void;
|
|
110
|
-
|
|
110
|
+
useSnap?: boolean;
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
export type NavigationButtonProps = {
|
package/Input/Input.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {forwardRef, useContext, useRef, useState} from 'react';
|
|
2
2
|
import {
|
|
3
3
|
NativeSyntheticEvent,
|
|
4
4
|
TextInput,
|
|
@@ -14,7 +14,7 @@ import {Icon} from '../Icon';
|
|
|
14
14
|
import {checkTyping} from './utils';
|
|
15
15
|
import {Loader} from '../Loader';
|
|
16
16
|
|
|
17
|
-
const Input
|
|
17
|
+
const Input = forwardRef(
|
|
18
18
|
(
|
|
19
19
|
{
|
|
20
20
|
value,
|
|
@@ -34,7 +34,7 @@ const Input: FC<InputProps> = forwardRef(
|
|
|
34
34
|
errorSpacing,
|
|
35
35
|
loading,
|
|
36
36
|
...props
|
|
37
|
-
},
|
|
37
|
+
}: InputProps,
|
|
38
38
|
ref,
|
|
39
39
|
) => {
|
|
40
40
|
const {theme} = useContext(ApplicationContext);
|
package/Input/InputMoney.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {forwardRef, useContext, useRef, useState} from 'react';
|
|
2
2
|
import {
|
|
3
3
|
NativeSyntheticEvent,
|
|
4
4
|
TextInput,
|
|
@@ -13,7 +13,7 @@ import {InputMoneyProps} from './index';
|
|
|
13
13
|
import {Icon} from '../Icon';
|
|
14
14
|
import {formatMoneyToNumber, formatNumberToMoney} from './utils';
|
|
15
15
|
|
|
16
|
-
const InputMoney
|
|
16
|
+
const InputMoney = forwardRef(
|
|
17
17
|
(
|
|
18
18
|
{
|
|
19
19
|
onChangeText,
|
|
@@ -30,7 +30,7 @@ const InputMoney: FC<InputMoneyProps> = forwardRef(
|
|
|
30
30
|
required,
|
|
31
31
|
errorSpacing,
|
|
32
32
|
...props
|
|
33
|
-
},
|
|
33
|
+
}: InputMoneyProps,
|
|
34
34
|
ref,
|
|
35
35
|
) => {
|
|
36
36
|
const {theme} = useContext(ApplicationContext);
|
package/Input/InputSearch.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {forwardRef, useContext, useRef, useState} from 'react';
|
|
2
2
|
import {
|
|
3
3
|
NativeSyntheticEvent,
|
|
4
4
|
TextInput,
|
|
@@ -13,7 +13,7 @@ import {Icon} from '../Icon';
|
|
|
13
13
|
import {Text} from '../Text';
|
|
14
14
|
import {checkTyping} from './utils';
|
|
15
15
|
|
|
16
|
-
const InputSearch
|
|
16
|
+
const InputSearch = forwardRef(
|
|
17
17
|
(
|
|
18
18
|
{
|
|
19
19
|
placeholder,
|
|
@@ -30,7 +30,7 @@ const InputSearch: FC<InputSearchProps> = forwardRef(
|
|
|
30
30
|
defaultValue,
|
|
31
31
|
onPressButtonText,
|
|
32
32
|
...props
|
|
33
|
-
},
|
|
33
|
+
}: InputSearchProps,
|
|
34
34
|
ref,
|
|
35
35
|
) => {
|
|
36
36
|
const {theme} = useContext(ApplicationContext);
|
package/Input/InputTextArea.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {forwardRef, useContext, useRef, useState} from 'react';
|
|
2
2
|
import {
|
|
3
3
|
NativeSyntheticEvent,
|
|
4
4
|
TextInput,
|
|
@@ -19,7 +19,7 @@ import {InputTextAreaProps} from './index';
|
|
|
19
19
|
import {Icon} from '../Icon';
|
|
20
20
|
import {ApplicationContext} from '../Application';
|
|
21
21
|
|
|
22
|
-
const InputTextArea
|
|
22
|
+
const InputTextArea = forwardRef(
|
|
23
23
|
(
|
|
24
24
|
{
|
|
25
25
|
errorMessage,
|
|
@@ -38,7 +38,7 @@ const InputTextArea: FC<InputTextAreaProps> = forwardRef(
|
|
|
38
38
|
required,
|
|
39
39
|
errorSpacing,
|
|
40
40
|
...props
|
|
41
|
-
},
|
|
41
|
+
}: InputTextAreaProps,
|
|
42
42
|
ref,
|
|
43
43
|
) => {
|
|
44
44
|
const {theme} = useContext(ApplicationContext);
|