UNPKG

3.74 kBJavaScriptView Raw
1import _extends from 'babel-runtime/helpers/extends';
2import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
3import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
4import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
5import _inherits from 'babel-runtime/helpers/inherits';
6import React from 'react';
7import ConfigProvider from '../config-provider';
8
9import Overlay1 from './overlay';
10import Overlay2 from './overlay-v2';
11
12import Gateway from './gateway';
13import Position from './position';
14
15import Popup1 from './popup';
16import Popup2 from './popup-v2';
17import { log } from '../util';
18
19var Overlay = function (_React$Component) {
20 _inherits(Overlay, _React$Component);
21
22 function Overlay(props) {
23 _classCallCheck(this, Overlay);
24
25 var _this = _possibleConstructorReturn(this, _React$Component.call(this, props));
26
27 _this.overlayRef = null;
28 _this.saveRef = _this.saveRef.bind(_this);
29 return _this;
30 }
31
32 Overlay.prototype.saveRef = function saveRef(ref) {
33 this.overlayRef = ref;
34 };
35 /**
36 * 兼容 1.x API, will be removed in 2.1.0
37 */
38
39
40 Overlay.prototype.getContent = function getContent() {
41 if (this.overlayRef) {
42 return this.overlayRef.getContent();
43 }
44 return null;
45 };
46 /**
47 * 兼容 1.x API, will be removed in 2.1.0
48 */
49
50
51 Overlay.prototype.getContentNode = function getContentNode() {
52 if (this.overlayRef) {
53 return this.overlayRef.getContentNode();
54 }
55 return null;
56 };
57
58 Overlay.prototype.render = function render() {
59 var _props = this.props,
60 v2 = _props.v2,
61 others = _objectWithoutProperties(_props, ['v2']);
62
63 if (v2) {
64 if ('needAdjust' in others) {
65 log.deprecated('needAdjust', 'needAdjust', 'Overlay v2');
66 others.autoAdjust = others.needAdjust;
67 delete others.needAdjust;
68 }
69 return React.createElement(Overlay2, others);
70 } else {
71 return React.createElement(Overlay1, _extends({}, others, { ref: this.saveRef }));
72 }
73 };
74
75 return Overlay;
76}(React.Component);
77// eslint-disable-next-line
78
79
80Overlay.displayName = 'Overlay';
81
82var Popup = function (_React$Component2) {
83 _inherits(Popup, _React$Component2);
84
85 function Popup(props) {
86 _classCallCheck(this, Popup);
87
88 var _this2 = _possibleConstructorReturn(this, _React$Component2.call(this, props));
89
90 _this2.overlay = null;
91 _this2.saveRef = _this2.saveRef.bind(_this2);
92 return _this2;
93 }
94
95 Popup.prototype.saveRef = function saveRef(ref) {
96 if (ref) {
97 this.overlay = ref.overlay;
98 }
99 };
100
101 Popup.prototype.render = function render() {
102 var _props2 = this.props,
103 v2 = _props2.v2,
104 others = _objectWithoutProperties(_props2, ['v2']);
105
106 if (v2) {
107 if ('needAdjust' in others) {
108 log.deprecated('needAdjust', 'needAdjust', 'Popup v2');
109 others.autoAdjust = others.needAdjust;
110 delete others.needAdjust;
111 }
112
113 return React.createElement(Popup2, others);
114 } else {
115 return React.createElement(Popup1, _extends({}, others, { ref: this.saveRef }));
116 }
117 };
118
119 return Popup;
120}(React.Component);
121
122Popup.displayName = 'Popup';
123
124
125Overlay.Gateway = Gateway;
126Overlay.Position = Position;
127Overlay.Popup = ConfigProvider.config(Popup, {
128 exportNames: ['overlay']
129});
130
131export default ConfigProvider.config(Overlay, {
132 exportNames: ['getContent', 'getContentNode']
133});
\No newline at end of file