1 | "use strict";
|
2 |
|
3 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
4 |
|
5 | var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
6 |
|
7 | Object.defineProperty(exports, "__esModule", {
|
8 | value: true
|
9 | });
|
10 | exports.default = void 0;
|
11 |
|
12 | var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
13 |
|
14 | var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
15 |
|
16 | var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
17 |
|
18 | var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
19 |
|
20 | var React = _interopRequireWildcard(require("react"));
|
21 |
|
22 | var _isMobile = _interopRequireDefault(require("rc-util/lib/isMobile"));
|
23 |
|
24 | var _Mask = _interopRequireDefault(require("./Mask"));
|
25 |
|
26 | var _PopupInner = _interopRequireDefault(require("./PopupInner"));
|
27 |
|
28 | var _MobilePopupInner = _interopRequireDefault(require("./MobilePopupInner"));
|
29 |
|
30 | var _excluded = ["visible", "mobile"];
|
31 | var Popup = React.forwardRef(function (_ref, ref) {
|
32 | var visible = _ref.visible,
|
33 | mobile = _ref.mobile,
|
34 | props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
35 |
|
36 | var _useState = (0, React.useState)(visible),
|
37 | _useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
38 | innerVisible = _useState2[0],
|
39 | serInnerVisible = _useState2[1];
|
40 |
|
41 | var _useState3 = (0, React.useState)(false),
|
42 | _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
43 | inMobile = _useState4[0],
|
44 | setInMobile = _useState4[1];
|
45 |
|
46 | var cloneProps = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, props), {}, {
|
47 | visible: innerVisible
|
48 | });
|
49 |
|
50 |
|
51 | (0, React.useEffect)(function () {
|
52 | serInnerVisible(visible);
|
53 |
|
54 | if (visible && mobile) {
|
55 | setInMobile((0, _isMobile.default)());
|
56 | }
|
57 | }, [visible, mobile]);
|
58 | var popupNode = inMobile ? React.createElement(_MobilePopupInner.default, (0, _extends2.default)({}, cloneProps, {
|
59 | mobile: mobile,
|
60 | ref: ref
|
61 | })) : React.createElement(_PopupInner.default, (0, _extends2.default)({}, cloneProps, {
|
62 | ref: ref
|
63 | }));
|
64 |
|
65 | return React.createElement("div", null, React.createElement(_Mask.default, cloneProps), popupNode);
|
66 | });
|
67 | Popup.displayName = 'Popup';
|
68 | var _default = Popup;
|
69 | exports.default = _default; |
\ | No newline at end of file |