1 | import _extends from "@babel/runtime/helpers/esm/extends";
|
2 | import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
3 | import * as React from 'react';
|
4 | import Portal from "rc-util/es/PortalWrapper";
|
5 | import Dialog from './Dialog';
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | var DialogWrap = function DialogWrap(props) {
|
16 | var visible = props.visible,
|
17 | getContainer = props.getContainer,
|
18 | forceRender = props.forceRender,
|
19 | _props$destroyOnClose = props.destroyOnClose,
|
20 | destroyOnClose = _props$destroyOnClose === void 0 ? false : _props$destroyOnClose,
|
21 | _afterClose = props.afterClose;
|
22 |
|
23 | var _React$useState = React.useState(visible),
|
24 | _React$useState2 = _slicedToArray(_React$useState, 2),
|
25 | animatedVisible = _React$useState2[0],
|
26 | setAnimatedVisible = _React$useState2[1];
|
27 |
|
28 | React.useEffect(function () {
|
29 | if (visible) {
|
30 | setAnimatedVisible(true);
|
31 | }
|
32 | }, [visible]);
|
33 |
|
34 | if (getContainer === false) {
|
35 | return React.createElement(Dialog, _extends({}, props, {
|
36 | getOpenCount: function getOpenCount() {
|
37 | return 2;
|
38 | }
|
39 |
|
40 | }));
|
41 | }
|
42 |
|
43 |
|
44 | if (!forceRender && destroyOnClose && !animatedVisible) {
|
45 | return null;
|
46 | }
|
47 |
|
48 | return React.createElement(Portal, {
|
49 | visible: visible,
|
50 | forceRender: forceRender,
|
51 | getContainer: getContainer
|
52 | }, function (childProps) {
|
53 | return React.createElement(Dialog, _extends({}, props, {
|
54 | destroyOnClose: destroyOnClose,
|
55 | afterClose: function afterClose() {
|
56 | _afterClose === null || _afterClose === void 0 ? void 0 : _afterClose();
|
57 | setAnimatedVisible(false);
|
58 | }
|
59 | }, childProps));
|
60 | });
|
61 | };
|
62 |
|
63 | DialogWrap.displayName = 'Dialog';
|
64 | export default DialogWrap; |
\ | No newline at end of file |