1 | import _objectWithoutPropertiesLoose from "@babel/runtime-corejs2/helpers/esm/objectWithoutPropertiesLoose";
|
2 | import _inheritsLoose from "@babel/runtime-corejs2/helpers/esm/inheritsLoose";
|
3 | import _extends from "@babel/runtime-corejs2/helpers/esm/extends";
|
4 | import classNames from 'classnames';
|
5 | import React, { cloneElement } from 'react';
|
6 | import PropTypes from 'prop-types';
|
7 | import BaseOverlay from 'react-overlays/lib/Overlay';
|
8 | import elementType from 'prop-types-extra/lib/elementType';
|
9 | import Fade from './Fade';
|
10 |
|
11 | var propTypes = _extends({}, BaseOverlay.propTypes, {
|
12 | |
13 |
|
14 |
|
15 | show: PropTypes.bool,
|
16 |
|
17 | |
18 |
|
19 |
|
20 | rootClose: PropTypes.bool,
|
21 |
|
22 | |
23 |
|
24 |
|
25 |
|
26 | onHide: PropTypes.func,
|
27 |
|
28 | |
29 |
|
30 |
|
31 | animation: PropTypes.oneOfType([PropTypes.bool, elementType]),
|
32 |
|
33 | |
34 |
|
35 |
|
36 | onEnter: PropTypes.func,
|
37 |
|
38 | |
39 |
|
40 |
|
41 | onEntering: PropTypes.func,
|
42 |
|
43 | |
44 |
|
45 |
|
46 | onEntered: PropTypes.func,
|
47 |
|
48 | |
49 |
|
50 |
|
51 | onExit: PropTypes.func,
|
52 |
|
53 | |
54 |
|
55 |
|
56 | onExiting: PropTypes.func,
|
57 |
|
58 | |
59 |
|
60 |
|
61 | onExited: PropTypes.func,
|
62 |
|
63 | |
64 |
|
65 |
|
66 | placement: PropTypes.oneOf(['top', 'right', 'bottom', 'left'])
|
67 | });
|
68 |
|
69 | var defaultProps = {
|
70 | animation: Fade,
|
71 | rootClose: false,
|
72 | show: false,
|
73 | placement: 'right'
|
74 | };
|
75 |
|
76 | var Overlay =
|
77 |
|
78 | function (_React$Component) {
|
79 | _inheritsLoose(Overlay, _React$Component);
|
80 |
|
81 | function Overlay() {
|
82 | return _React$Component.apply(this, arguments) || this;
|
83 | }
|
84 |
|
85 | var _proto = Overlay.prototype;
|
86 |
|
87 | _proto.render = function render() {
|
88 | var _this$props = this.props,
|
89 | animation = _this$props.animation,
|
90 | children = _this$props.children,
|
91 | props = _objectWithoutPropertiesLoose(_this$props, ["animation", "children"]);
|
92 |
|
93 | var transition = animation === true ? Fade : animation || null;
|
94 | var child;
|
95 |
|
96 | if (!transition) {
|
97 | child = cloneElement(children, {
|
98 | className: classNames(children.props.className, 'in')
|
99 | });
|
100 | } else {
|
101 | child = children;
|
102 | }
|
103 |
|
104 | return React.createElement(BaseOverlay, _extends({}, props, {
|
105 | transition: transition
|
106 | }), child);
|
107 | };
|
108 |
|
109 | return Overlay;
|
110 | }(React.Component);
|
111 |
|
112 | Overlay.propTypes = propTypes;
|
113 | Overlay.defaultProps = defaultProps;
|
114 | export default Overlay; |
\ | No newline at end of file |