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