1 | import _extends from 'babel-runtime/helpers/extends';
|
2 | import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
|
3 | import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
|
4 | import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
|
5 | import _inherits from 'babel-runtime/helpers/inherits';
|
6 |
|
7 | var _fadeStyles;
|
8 |
|
9 | import classNames from 'classnames';
|
10 | import React from 'react';
|
11 | import PropTypes from 'prop-types';
|
12 | import Transition, { ENTERED, ENTERING } from 'react-transition-group/Transition';
|
13 |
|
14 | var propTypes = {
|
15 | |
16 |
|
17 |
|
18 | in: PropTypes.bool,
|
19 |
|
20 | |
21 |
|
22 |
|
23 | mountOnEnter: PropTypes.bool,
|
24 |
|
25 | |
26 |
|
27 |
|
28 | unmountOnExit: PropTypes.bool,
|
29 |
|
30 | |
31 |
|
32 |
|
33 |
|
34 | appear: PropTypes.bool,
|
35 |
|
36 | |
37 |
|
38 |
|
39 |
|
40 |
|
41 | timeout: PropTypes.number,
|
42 |
|
43 | |
44 |
|
45 |
|
46 | onEnter: PropTypes.func,
|
47 | |
48 |
|
49 |
|
50 | onEntering: PropTypes.func,
|
51 | |
52 |
|
53 |
|
54 | onEntered: PropTypes.func,
|
55 | |
56 |
|
57 |
|
58 | onExit: PropTypes.func,
|
59 | |
60 |
|
61 |
|
62 | onExiting: PropTypes.func,
|
63 | |
64 |
|
65 |
|
66 | onExited: PropTypes.func
|
67 | };
|
68 |
|
69 | var defaultProps = {
|
70 | in: false,
|
71 | timeout: 300,
|
72 | mountOnEnter: false,
|
73 | unmountOnExit: false,
|
74 | appear: false
|
75 | };
|
76 |
|
77 | var fadeStyles = (_fadeStyles = {}, _fadeStyles[ENTERING] = 'in', _fadeStyles[ENTERED] = 'in', _fadeStyles);
|
78 |
|
79 | var Fade = function (_React$Component) {
|
80 | _inherits(Fade, _React$Component);
|
81 |
|
82 | function Fade() {
|
83 | _classCallCheck(this, Fade);
|
84 |
|
85 | return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
|
86 | }
|
87 |
|
88 | Fade.prototype.render = function render() {
|
89 | var _props = this.props,
|
90 | className = _props.className,
|
91 | children = _props.children,
|
92 | props = _objectWithoutProperties(_props, ['className', 'children']);
|
93 |
|
94 | return React.createElement(
|
95 | Transition,
|
96 | props,
|
97 | function (status, innerProps) {
|
98 | return React.cloneElement(children, _extends({}, innerProps, {
|
99 | className: classNames('fade', className, children.props.className, fadeStyles[status])
|
100 | }));
|
101 | }
|
102 | );
|
103 | };
|
104 |
|
105 | return Fade;
|
106 | }(React.Component);
|
107 |
|
108 | Fade.propTypes = propTypes;
|
109 | Fade.defaultProps = defaultProps;
|
110 |
|
111 | export default Fade; |
\ | No newline at end of file |