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