1 | import _extends from "@babel/runtime/helpers/esm/extends";
|
2 | import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
3 | import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
4 | import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
5 | var _excluded = ["visible", "mobile"];
|
6 | import * as React from 'react';
|
7 | import { useState, useEffect } from 'react';
|
8 | import isMobile from "rc-util/es/isMobile";
|
9 | import Mask from "./Mask";
|
10 | import PopupInner from "./PopupInner";
|
11 | import MobilePopupInner from "./MobilePopupInner";
|
12 | var Popup = React.forwardRef(function (_ref, ref) {
|
13 | var visible = _ref.visible,
|
14 | mobile = _ref.mobile,
|
15 | props = _objectWithoutProperties(_ref, _excluded);
|
16 |
|
17 | var _useState = useState(visible),
|
18 | _useState2 = _slicedToArray(_useState, 2),
|
19 | innerVisible = _useState2[0],
|
20 | serInnerVisible = _useState2[1];
|
21 |
|
22 | var _useState3 = useState(false),
|
23 | _useState4 = _slicedToArray(_useState3, 2),
|
24 | inMobile = _useState4[0],
|
25 | setInMobile = _useState4[1];
|
26 |
|
27 | var cloneProps = _objectSpread(_objectSpread({}, props), {}, {
|
28 | visible: innerVisible
|
29 | });
|
30 |
|
31 |
|
32 |
|
33 | useEffect(function () {
|
34 | serInnerVisible(visible);
|
35 |
|
36 | if (visible && mobile) {
|
37 | setInMobile(isMobile());
|
38 | }
|
39 | }, [visible, mobile]);
|
40 | var popupNode = inMobile ? React.createElement(MobilePopupInner, _extends({}, cloneProps, {
|
41 | mobile: mobile,
|
42 | ref: ref
|
43 | })) : React.createElement(PopupInner, _extends({}, cloneProps, {
|
44 | ref: ref
|
45 | }));
|
46 |
|
47 | return React.createElement("div", null, React.createElement(Mask, cloneProps), popupNode);
|
48 | });
|
49 | Popup.displayName = 'Popup';
|
50 | export default Popup; |
\ | No newline at end of file |