UNPKG

2.36 kBJavaScriptView Raw
1import _extends from "@babel/runtime/helpers/extends";
2import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3import _createClass from "@babel/runtime/helpers/createClass";
4import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
5import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
6import _inherits from "@babel/runtime/helpers/inherits";
7import React, { Component } from "react";
8import PopLayer from "./PopLayer";
9import CommonMount from "@beisen-platform/common-mount";
10
11var PopLayerWithMask =
12/*#__PURE__*/
13function (_Component) {
14 _inherits(PopLayerWithMask, _Component);
15
16 function PopLayerWithMask(props) {
17 var _this;
18
19 _classCallCheck(this, PopLayerWithMask);
20
21 _this = _possibleConstructorReturn(this, _getPrototypeOf(PopLayerWithMask).call(this, props));
22
23 _this.onClose = function () {
24 var _this$props;
25
26 _this.commonMount.unmountBox();
27
28 _this.props.showHide && (_this$props = _this.props).showHide.apply(_this$props, arguments);
29 };
30
31 _this.popLayerCenterMountContainerId = 'pop-layer__center_mount_container';
32 _this.commonMount = new CommonMount({
33 containerId: _this.popLayerCenterMountContainerId,
34 follow: false,
35 // 是否滚动跟随,默认true
36 fixed: true // 定位:fixed,false时为absolute
37
38 });
39 return _this;
40 }
41
42 _createClass(PopLayerWithMask, [{
43 key: "componentDidMount",
44 value: function componentDidMount() {
45 var popLayer = React.createElement(PopLayer, _extends({}, this.props, {
46 showHide: this.onClose
47 }));
48 this.renderCenterConfirm(popLayer);
49 }
50 }, {
51 key: "componentDidUpdate",
52 value: function componentDidUpdate() {
53 if (!this.props.hidden) {
54 var popLayer = React.createElement(PopLayer, _extends({}, this.props, {
55 showHide: this.onClose
56 }));
57 this.renderCenterConfirm(popLayer);
58 }
59 }
60 }, {
61 key: "renderCenterConfirm",
62 value: function renderCenterConfirm(content) {
63 this.commonMount.renderDom('pop-layer__center-mask', content, null, [document.body, {}]);
64 this.isConfirmPopLayerRendered = true;
65 }
66 }, {
67 key: "render",
68 value: function render() {
69 return null;
70 }
71 }]);
72
73 return PopLayerWithMask;
74}(Component);
75
76export { PopLayerWithMask as default };
\No newline at end of file