@hero-design/rn 8.41.0 → 8.41.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.
- package/.turbo/turbo-build.log +1 -1
- package/es/index.js +577 -674
- package/lib/index.js +579 -678
- package/package.json +7 -8
- package/rollup.config.js +0 -1
- package/src/components/Error/StyledError.tsx +2 -1
- package/src/components/Error/__tests__/__snapshots__/index.spec.tsx.snap +115 -97
- package/src/components/Error/__tests__/index.spec.tsx +9 -6
- package/src/components/Modal/__tests__/__snapshots__/index.spec.tsx.snap +117 -0
- package/src/components/Modal/__tests__/index.spec.tsx +99 -0
- package/src/components/Modal/index.tsx +178 -82
- package/src/components/Portal/__tests__/__snapshots__/index.spec.tsx.snap +29 -0
- package/src/components/Portal/__tests__/index.spec.tsx +19 -0
- package/src/components/Portal/index.tsx +18 -5
- package/src/components/Success/StyledSuccess.tsx +2 -1
- package/src/components/Success/__tests__/__snapshots__/index.spec.tsx.snap +115 -95
- package/src/components/Success/__tests__/index.spec.tsx +9 -6
- package/src/index.ts +0 -2
- package/testUtils/setup.tsx +0 -18
- package/types/components/Error/StyledError.d.ts +3 -5
- package/types/components/Modal/index.d.ts +12 -8
- package/types/components/Portal/index.d.ts +10 -5
- package/types/components/Success/StyledSuccess.d.ts +3 -5
- package/types/index.d.ts +1 -2
- package/src/components/Modal/ModalContentWrapper.tsx +0 -112
- package/src/components/Modal/ModalPresenter/ModalPresenter.tsx +0 -135
- package/src/components/Modal/ModalPresenter/index.tsx +0 -9
- package/src/components/Modal/ModalProvider.tsx +0 -8
- package/types/components/Modal/ModalContentWrapper.d.ts +0 -16
- package/types/components/Modal/ModalPresenter/ModalPresenter.d.ts +0 -34
- package/types/components/Modal/ModalPresenter/index.d.ts +0 -3
- package/types/components/Modal/ModalProvider.d.ts +0 -5
|
@@ -3,6 +3,7 @@ import { fireEvent } from '@testing-library/react-native';
|
|
|
3
3
|
import renderWithTheme from '../../../testHelpers/renderWithTheme';
|
|
4
4
|
import Success from '..';
|
|
5
5
|
import Image from '../../Image';
|
|
6
|
+
import Portal from '../../Portal';
|
|
6
7
|
|
|
7
8
|
const title = `We’re sorry, something went wrong`;
|
|
8
9
|
const description = 'Please try again later';
|
|
@@ -46,12 +47,14 @@ describe('Success', () => {
|
|
|
46
47
|
});
|
|
47
48
|
it('renders full screen success page correctly', () => {
|
|
48
49
|
const { toJSON, getByText, getByTestId } = renderWithTheme(
|
|
49
|
-
<
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
<Portal.Provider>
|
|
51
|
+
<Success
|
|
52
|
+
variant="full-screen"
|
|
53
|
+
title={title}
|
|
54
|
+
description={description}
|
|
55
|
+
image="path_to_image"
|
|
56
|
+
/>
|
|
57
|
+
</Portal.Provider>
|
|
55
58
|
);
|
|
56
59
|
|
|
57
60
|
expect(getByText(title)).toBeTruthy();
|
package/src/index.ts
CHANGED
|
@@ -38,7 +38,6 @@ import HeroDesignProvider from './components/HeroDesignProvider';
|
|
|
38
38
|
import Icon from './components/Icon';
|
|
39
39
|
import Image from './components/Image';
|
|
40
40
|
import List from './components/List';
|
|
41
|
-
import Modal from './components/Modal';
|
|
42
41
|
import PinInput from './components/PinInput';
|
|
43
42
|
import Progress from './components/Progress';
|
|
44
43
|
import Slider from './components/Slider';
|
|
@@ -103,7 +102,6 @@ export {
|
|
|
103
102
|
Image,
|
|
104
103
|
HeroDesignProvider,
|
|
105
104
|
List,
|
|
106
|
-
Modal,
|
|
107
105
|
PinInput,
|
|
108
106
|
Progress,
|
|
109
107
|
Portal,
|
package/testUtils/setup.tsx
CHANGED
|
@@ -132,22 +132,4 @@ jest.mock('react-native/Libraries/Utilities/BackHandler', () => {
|
|
|
132
132
|
);
|
|
133
133
|
});
|
|
134
134
|
|
|
135
|
-
jest.mock('react-native-root-siblings', () => {
|
|
136
|
-
const React = jest.requireActual('react');
|
|
137
|
-
|
|
138
|
-
class RootSiblingsManager extends React.Component {
|
|
139
|
-
constructor(props) {
|
|
140
|
-
super(props);
|
|
141
|
-
}
|
|
142
|
-
render() {
|
|
143
|
-
return React.createElement('RootSiblingsManager', this.props, this.props.children);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
return {
|
|
148
|
-
__esModule: true,
|
|
149
|
-
default: RootSiblingsManager,
|
|
150
|
-
};
|
|
151
|
-
});
|
|
152
|
-
|
|
153
135
|
export {};
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
2
|
+
import { View } from 'react-native';
|
|
3
3
|
type ErrorVariant = 'full-screen' | 'in-page';
|
|
4
|
-
declare const StyledErrorModal: import("@emotion/native").StyledComponent<import("
|
|
4
|
+
declare const StyledErrorModal: import("@emotion/native").StyledComponent<import("../Modal").ModalProps & {
|
|
5
5
|
theme?: import("@emotion/react").Theme | undefined;
|
|
6
6
|
as?: import("react").ElementType<any> | undefined;
|
|
7
|
-
}, {}, {
|
|
8
|
-
ref?: import("react").Ref<Modal> | undefined;
|
|
9
|
-
}>;
|
|
7
|
+
}, {}, {}>;
|
|
10
8
|
declare const StyledErrorContainer: import("@emotion/native").StyledComponent<import("react-native").ViewProps & {
|
|
11
9
|
theme?: import("@emotion/react").Theme | undefined;
|
|
12
10
|
as?: import("react").ElementType<any> | undefined;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
2
|
export interface ModalProps {
|
|
3
3
|
/**
|
|
4
4
|
* Content of the modal.
|
|
5
5
|
*/
|
|
6
|
-
children:
|
|
6
|
+
children: ReactNode;
|
|
7
7
|
/**
|
|
8
8
|
* Visibility of the modal
|
|
9
9
|
*/
|
|
@@ -24,10 +24,14 @@ export interface ModalProps {
|
|
|
24
24
|
* Animation type of the modal content.
|
|
25
25
|
*/
|
|
26
26
|
animationType?: 'none' | 'slide' | 'fade';
|
|
27
|
+
/**
|
|
28
|
+
* Whether to show the modal backdrop
|
|
29
|
+
*/
|
|
30
|
+
transparent?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Callback when the modal is dismissed. iOS only.
|
|
33
|
+
*/
|
|
34
|
+
onDismiss?: () => void;
|
|
27
35
|
}
|
|
28
|
-
declare const
|
|
29
|
-
|
|
30
|
-
children: React.ReactNode;
|
|
31
|
-
}) => JSX.Element;
|
|
32
|
-
};
|
|
33
|
-
export default _default;
|
|
36
|
+
declare const ModalWrapper: ({ visible, ...props }: ModalProps) => JSX.Element | null;
|
|
37
|
+
export default ModalWrapper;
|
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { Theme } from '../../theme';
|
|
2
3
|
export interface PortalProps {
|
|
3
4
|
name?: string;
|
|
4
5
|
hostName?: string;
|
|
5
6
|
children?: ReactNode | ReactNode[];
|
|
7
|
+
/**
|
|
8
|
+
* Theme for portal children.
|
|
9
|
+
*/
|
|
10
|
+
theme?: Theme;
|
|
6
11
|
}
|
|
7
|
-
declare const _default:
|
|
8
|
-
readonly type: ({ name, hostName, children }: PortalProps) => null;
|
|
12
|
+
declare const _default: React.NamedExoticComponent<PortalProps> & {
|
|
13
|
+
readonly type: ({ name, hostName, children, theme }: PortalProps) => null;
|
|
9
14
|
} & {
|
|
10
|
-
Provider:
|
|
11
|
-
Host:
|
|
15
|
+
Provider: React.MemoExoticComponent<({ rootHostName, children, }: import("./PortalProvider").PortalProviderProps) => JSX.Element>;
|
|
16
|
+
Host: React.MemoExoticComponent<({ name }: import("./PortalHost").PortalHostProps) => JSX.Element>;
|
|
12
17
|
};
|
|
13
18
|
export default _default;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
2
|
+
import { View } from 'react-native';
|
|
3
3
|
type SuccessVariant = 'full-screen' | 'in-page';
|
|
4
4
|
declare const StyledSuccessContainer: import("@emotion/native").StyledComponent<import("react-native").ViewProps & {
|
|
5
5
|
theme?: import("@emotion/react").Theme | undefined;
|
|
@@ -45,10 +45,8 @@ declare const StyledSuccessButtonPrimary: import("@emotion/native").StyledCompon
|
|
|
45
45
|
theme?: import("@emotion/react").Theme | undefined;
|
|
46
46
|
as?: import("react").ElementType<any> | undefined;
|
|
47
47
|
}, {}, {}>;
|
|
48
|
-
declare const StyledSuccessModal: import("@emotion/native").StyledComponent<import("
|
|
48
|
+
declare const StyledSuccessModal: import("@emotion/native").StyledComponent<import("../Modal").ModalProps & {
|
|
49
49
|
theme?: import("@emotion/react").Theme | undefined;
|
|
50
50
|
as?: import("react").ElementType<any> | undefined;
|
|
51
|
-
}, {}, {
|
|
52
|
-
ref?: import("react").Ref<Modal> | undefined;
|
|
53
|
-
}>;
|
|
51
|
+
}, {}, {}>;
|
|
54
52
|
export { SuccessVariant, StyledSuccessImage, StyledSuccessContainer, StyledSuccessContent, StyledSuccessImageContainer, StyledSuccessTitle, StyledSuccessDescription, StyledSuccessButtonContainer, StyledSuccessButtonPrimary, StyledSuccessModal, };
|
package/types/index.d.ts
CHANGED
|
@@ -25,7 +25,6 @@ import HeroDesignProvider from './components/HeroDesignProvider';
|
|
|
25
25
|
import Icon from './components/Icon';
|
|
26
26
|
import Image from './components/Image';
|
|
27
27
|
import List from './components/List';
|
|
28
|
-
import Modal from './components/Modal';
|
|
29
28
|
import PinInput from './components/PinInput';
|
|
30
29
|
import Progress from './components/Progress';
|
|
31
30
|
import Slider from './components/Slider';
|
|
@@ -49,5 +48,5 @@ import RefreshControl from './components/RefreshControl';
|
|
|
49
48
|
import RichTextEditor from './components/RichTextEditor';
|
|
50
49
|
import PageControl from './components/PageControl';
|
|
51
50
|
import Portal from './components/Portal';
|
|
52
|
-
export { theme, getTheme, useTheme, scale, ThemeProvider, ThemeSwitcher, withTheme, swagSystemPalette, swagDarkSystemPalette, workSystemPalette, jobsSystemPalette, walletSystemPalette, eBensSystemPalette, Accordion, Alert, Attachment, Avatar, useAvatarColors, Badge, BottomNavigation, BottomSheet, Box, Button, Calendar, Card, Carousel, Collapse, Checkbox, ContentNavigator, DatePicker, Divider, Drawer, Empty, Error, FAB, Icon, Image, HeroDesignProvider, List,
|
|
51
|
+
export { theme, getTheme, useTheme, scale, ThemeProvider, ThemeSwitcher, withTheme, swagSystemPalette, swagDarkSystemPalette, workSystemPalette, jobsSystemPalette, walletSystemPalette, eBensSystemPalette, Accordion, Alert, Attachment, Avatar, useAvatarColors, Badge, BottomNavigation, BottomSheet, Box, Button, Calendar, Card, Carousel, Collapse, Checkbox, ContentNavigator, DatePicker, Divider, Drawer, Empty, Error, FAB, Icon, Image, HeroDesignProvider, List, PinInput, Progress, Portal, PageControl, Skeleton, Slider, Spinner, Swipeable, Radio, SectionHeading, Select, Success, Switch, Tabs, Tag, TextInput, TimePicker, Toast, Toolbar, Typography, Rate, RefreshControl, RichTextEditor, };
|
|
53
52
|
export * from './types';
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import React, { forwardRef } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
Animated,
|
|
4
|
-
Dimensions,
|
|
5
|
-
Easing,
|
|
6
|
-
Platform,
|
|
7
|
-
StyleProp,
|
|
8
|
-
ViewStyle,
|
|
9
|
-
} from 'react-native';
|
|
10
|
-
|
|
11
|
-
type ModalContentWrapperProps = {
|
|
12
|
-
children: React.ReactElement;
|
|
13
|
-
visible?: boolean;
|
|
14
|
-
onShow?: () => void;
|
|
15
|
-
testID?: string;
|
|
16
|
-
animationType?: 'none' | 'slide' | 'fade';
|
|
17
|
-
style?: StyleProp<ViewStyle>;
|
|
18
|
-
animated?: boolean;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export type ModalContentWrapperHandler = {
|
|
22
|
-
hide: (callback?: () => void) => void;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const windowHeight = Dimensions.get('window').height;
|
|
26
|
-
const defaultAnimationConfig = {
|
|
27
|
-
easing: Easing.inOut(Easing.cubic),
|
|
28
|
-
duration: 400,
|
|
29
|
-
useNativeDriver: Platform.OS !== 'web',
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const ModalContentWrapper = forwardRef<
|
|
33
|
-
ModalContentWrapperHandler,
|
|
34
|
-
ModalContentWrapperProps
|
|
35
|
-
>(
|
|
36
|
-
(
|
|
37
|
-
{
|
|
38
|
-
animationType,
|
|
39
|
-
children,
|
|
40
|
-
testID,
|
|
41
|
-
onShow,
|
|
42
|
-
style,
|
|
43
|
-
visible,
|
|
44
|
-
animated = true,
|
|
45
|
-
},
|
|
46
|
-
ref
|
|
47
|
-
) => {
|
|
48
|
-
const animatedValue = React.useRef(new Animated.Value(0)).current;
|
|
49
|
-
|
|
50
|
-
const modalAnimation = animatedValue.interpolate(
|
|
51
|
-
animationType === 'fade'
|
|
52
|
-
? {
|
|
53
|
-
inputRange: [0, 1],
|
|
54
|
-
outputRange: [0, 1],
|
|
55
|
-
}
|
|
56
|
-
: {
|
|
57
|
-
inputRange: [0, 1],
|
|
58
|
-
outputRange: [windowHeight, 0],
|
|
59
|
-
}
|
|
60
|
-
);
|
|
61
|
-
|
|
62
|
-
React.useImperativeHandle(
|
|
63
|
-
ref,
|
|
64
|
-
() => ({
|
|
65
|
-
hide: (callback) => {
|
|
66
|
-
Animated.timing(animatedValue, {
|
|
67
|
-
toValue: 0,
|
|
68
|
-
...defaultAnimationConfig,
|
|
69
|
-
}).start(callback);
|
|
70
|
-
},
|
|
71
|
-
}),
|
|
72
|
-
[animatedValue]
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
React.useEffect(() => {
|
|
76
|
-
// Hiding animation will be called from the modal component
|
|
77
|
-
if (visible) {
|
|
78
|
-
Animated.timing(animatedValue, {
|
|
79
|
-
toValue: 1,
|
|
80
|
-
...defaultAnimationConfig,
|
|
81
|
-
// Prevent animation when updating the modal content
|
|
82
|
-
duration: animated ? defaultAnimationConfig.duration : 0,
|
|
83
|
-
}).start(() => {
|
|
84
|
-
onShow?.();
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
}, [visible, animatedValue, onShow, animated]);
|
|
88
|
-
|
|
89
|
-
return (
|
|
90
|
-
<Animated.View
|
|
91
|
-
testID={testID}
|
|
92
|
-
style={[
|
|
93
|
-
style,
|
|
94
|
-
{
|
|
95
|
-
...(animationType === 'fade' ? { opacity: modalAnimation } : {}),
|
|
96
|
-
...(animationType === 'slide'
|
|
97
|
-
? {
|
|
98
|
-
transform: [{ translateY: modalAnimation }],
|
|
99
|
-
}
|
|
100
|
-
: {}),
|
|
101
|
-
},
|
|
102
|
-
]}
|
|
103
|
-
>
|
|
104
|
-
{children}
|
|
105
|
-
</Animated.View>
|
|
106
|
-
);
|
|
107
|
-
}
|
|
108
|
-
);
|
|
109
|
-
|
|
110
|
-
ModalContentWrapper.displayName = 'ModalContentWrapper';
|
|
111
|
-
|
|
112
|
-
export default ModalContentWrapper;
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import React, { forwardRef, useRef } from 'react';
|
|
2
|
-
import { Animated, StyleSheet, ViewProps } from 'react-native';
|
|
3
|
-
import RootSiblings from 'react-native-root-siblings';
|
|
4
|
-
import { useTheme } from '../../../theme';
|
|
5
|
-
import Box from '../../Box';
|
|
6
|
-
|
|
7
|
-
export type ModalPresenterHandles = {
|
|
8
|
-
animatedOut: (completion?: () => void) => void;
|
|
9
|
-
};
|
|
10
|
-
export type ModalDismissFunc = (onDismiss?: () => void) => void;
|
|
11
|
-
export type ModalUpdateFunc = (content: React.ReactNode) => void;
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Modal handler is returned by `showModal` function.
|
|
15
|
-
*/
|
|
16
|
-
export type ModalHandler = {
|
|
17
|
-
/**
|
|
18
|
-
* Same `dismiss` function as in `ModalContentProps`.
|
|
19
|
-
*/
|
|
20
|
-
dismiss: ModalDismissFunc;
|
|
21
|
-
/**
|
|
22
|
-
* Same `update` function as in `ModalContentProps`.
|
|
23
|
-
*/
|
|
24
|
-
update: ModalUpdateFunc;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const ModalPresenter = forwardRef<ModalPresenterHandles, ViewProps>(
|
|
28
|
-
({ style, children, ...props }, ref) => {
|
|
29
|
-
const animatedOpacity = useRef(new Animated.Value(0));
|
|
30
|
-
const theme = useTheme();
|
|
31
|
-
|
|
32
|
-
React.useEffect(() => {
|
|
33
|
-
Animated.spring(animatedOpacity.current, {
|
|
34
|
-
toValue: 1,
|
|
35
|
-
useNativeDriver: true,
|
|
36
|
-
}).start();
|
|
37
|
-
}, []);
|
|
38
|
-
|
|
39
|
-
React.useImperativeHandle(ref, () => ({
|
|
40
|
-
animatedOut: (completion?: () => void) => {
|
|
41
|
-
Animated.spring(animatedOpacity.current, {
|
|
42
|
-
toValue: 0,
|
|
43
|
-
useNativeDriver: true,
|
|
44
|
-
}).start(() => {
|
|
45
|
-
completion?.();
|
|
46
|
-
});
|
|
47
|
-
},
|
|
48
|
-
}));
|
|
49
|
-
|
|
50
|
-
return (
|
|
51
|
-
<Box style={StyleSheet.absoluteFill}>
|
|
52
|
-
<Animated.View
|
|
53
|
-
style={[
|
|
54
|
-
{
|
|
55
|
-
width: '100%',
|
|
56
|
-
height: '100%',
|
|
57
|
-
backgroundColor: `${theme.colors.overlayGlobalSurface}66`, // 66 = 40% opacity as suggested by the mobile color guidelines
|
|
58
|
-
justifyContent: 'center',
|
|
59
|
-
alignItems: 'center',
|
|
60
|
-
opacity: animatedOpacity.current,
|
|
61
|
-
},
|
|
62
|
-
style,
|
|
63
|
-
]}
|
|
64
|
-
{...props}
|
|
65
|
-
>
|
|
66
|
-
{children}
|
|
67
|
-
</Animated.View>
|
|
68
|
-
</Box>
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Present a modal on screen immediately.
|
|
75
|
-
*
|
|
76
|
-
* The new presented modal will be on top of existing modals if there are any.
|
|
77
|
-
*
|
|
78
|
-
* @param Content A component to be presented as a modal on screen.
|
|
79
|
-
* This component will be centered horizontally and vertically on screen with
|
|
80
|
-
* a semitransparent black overlay underneath.
|
|
81
|
-
* @param contentProps Props for this modal component.
|
|
82
|
-
* @returns A `ModalHandler` you can use to dismiss the modal.
|
|
83
|
-
*/
|
|
84
|
-
|
|
85
|
-
export const showModal = (content: React.ReactNode): ModalHandler => {
|
|
86
|
-
let ref: ModalPresenterHandles | null = null;
|
|
87
|
-
let rootSiblings: RootSiblings | null = null;
|
|
88
|
-
|
|
89
|
-
const dismiss: ModalDismissFunc = (onDismiss) => {
|
|
90
|
-
if (rootSiblings) {
|
|
91
|
-
const cleanup = () => {
|
|
92
|
-
rootSiblings?.destroy();
|
|
93
|
-
rootSiblings = null;
|
|
94
|
-
ref = null;
|
|
95
|
-
onDismiss?.();
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
if (ref) {
|
|
99
|
-
ref.animatedOut(cleanup);
|
|
100
|
-
} else {
|
|
101
|
-
cleanup();
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
const update: ModalUpdateFunc = (newContent) => {
|
|
107
|
-
rootSiblings?.update(
|
|
108
|
-
<ModalPresenter
|
|
109
|
-
ref={(_ref) => {
|
|
110
|
-
ref = _ref;
|
|
111
|
-
}}
|
|
112
|
-
>
|
|
113
|
-
{newContent}
|
|
114
|
-
</ModalPresenter>
|
|
115
|
-
);
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
rootSiblings = new RootSiblings(
|
|
119
|
-
(
|
|
120
|
-
<ModalPresenter
|
|
121
|
-
ref={(_ref) => {
|
|
122
|
-
ref = _ref;
|
|
123
|
-
}}
|
|
124
|
-
>
|
|
125
|
-
{content}
|
|
126
|
-
</ModalPresenter>
|
|
127
|
-
)
|
|
128
|
-
);
|
|
129
|
-
|
|
130
|
-
return { dismiss, update };
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
ModalPresenter.displayName = 'ModalPresenter';
|
|
134
|
-
|
|
135
|
-
export default ModalPresenter;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import React, { ReactNode } from 'react';
|
|
2
|
-
import { RootSiblingParent } from 'react-native-root-siblings';
|
|
3
|
-
|
|
4
|
-
const ModalProvider = ({ children }: { children: ReactNode }) => {
|
|
5
|
-
return <RootSiblingParent>{children}</RootSiblingParent>;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export default ModalProvider;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { StyleProp, ViewStyle } from 'react-native';
|
|
3
|
-
type ModalContentWrapperProps = {
|
|
4
|
-
children: React.ReactElement;
|
|
5
|
-
visible?: boolean;
|
|
6
|
-
onShow?: () => void;
|
|
7
|
-
testID?: string;
|
|
8
|
-
animationType?: 'none' | 'slide' | 'fade';
|
|
9
|
-
style?: StyleProp<ViewStyle>;
|
|
10
|
-
animated?: boolean;
|
|
11
|
-
};
|
|
12
|
-
export type ModalContentWrapperHandler = {
|
|
13
|
-
hide: (callback?: () => void) => void;
|
|
14
|
-
};
|
|
15
|
-
declare const ModalContentWrapper: React.ForwardRefExoticComponent<ModalContentWrapperProps & React.RefAttributes<ModalContentWrapperHandler>>;
|
|
16
|
-
export default ModalContentWrapper;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { ViewProps } from 'react-native';
|
|
3
|
-
export type ModalPresenterHandles = {
|
|
4
|
-
animatedOut: (completion?: () => void) => void;
|
|
5
|
-
};
|
|
6
|
-
export type ModalDismissFunc = (onDismiss?: () => void) => void;
|
|
7
|
-
export type ModalUpdateFunc = (content: React.ReactNode) => void;
|
|
8
|
-
/**
|
|
9
|
-
* Modal handler is returned by `showModal` function.
|
|
10
|
-
*/
|
|
11
|
-
export type ModalHandler = {
|
|
12
|
-
/**
|
|
13
|
-
* Same `dismiss` function as in `ModalContentProps`.
|
|
14
|
-
*/
|
|
15
|
-
dismiss: ModalDismissFunc;
|
|
16
|
-
/**
|
|
17
|
-
* Same `update` function as in `ModalContentProps`.
|
|
18
|
-
*/
|
|
19
|
-
update: ModalUpdateFunc;
|
|
20
|
-
};
|
|
21
|
-
declare const ModalPresenter: React.ForwardRefExoticComponent<ViewProps & React.RefAttributes<ModalPresenterHandles>>;
|
|
22
|
-
/**
|
|
23
|
-
* Present a modal on screen immediately.
|
|
24
|
-
*
|
|
25
|
-
* The new presented modal will be on top of existing modals if there are any.
|
|
26
|
-
*
|
|
27
|
-
* @param Content A component to be presented as a modal on screen.
|
|
28
|
-
* This component will be centered horizontally and vertically on screen with
|
|
29
|
-
* a semitransparent black overlay underneath.
|
|
30
|
-
* @param contentProps Props for this modal component.
|
|
31
|
-
* @returns A `ModalHandler` you can use to dismiss the modal.
|
|
32
|
-
*/
|
|
33
|
-
export declare const showModal: (content: React.ReactNode) => ModalHandler;
|
|
34
|
-
export default ModalPresenter;
|