1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | 'use strict';
|
10 |
|
11 | var _assign = require('object-assign');
|
12 |
|
13 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
14 |
|
15 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
16 |
|
17 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
18 |
|
19 | var React = require('./React');
|
20 | var propTypesFactory = require('prop-types/factory');
|
21 | var PropTypes = propTypesFactory(React.isValidElement);
|
22 |
|
23 | var ReactTransitionGroup = require('./ReactTransitionGroup');
|
24 | var ReactCSSTransitionGroupChild = require('./ReactCSSTransitionGroupChild');
|
25 |
|
26 | function createTransitionTimeoutPropValidator(transitionType) {
|
27 | var timeoutPropName = 'transition' + transitionType + 'Timeout';
|
28 | var enabledPropName = 'transition' + transitionType;
|
29 |
|
30 | return function (props) {
|
31 |
|
32 | if (props[enabledPropName]) {
|
33 |
|
34 | if (props[timeoutPropName] == null) {
|
35 | return new Error(timeoutPropName + " wasn't supplied to ReactCSSTransitionGroup: " + "this can cause unreliable animations and won't be supported in " + 'a future version of React. See ' + 'https://fb.me/react-animation-transition-group-timeout for more ' + 'information.');
|
36 |
|
37 |
|
38 | } else if (typeof props[timeoutPropName] !== 'number') {
|
39 | return new Error(timeoutPropName + ' must be a number (in milliseconds)');
|
40 | }
|
41 | }
|
42 | };
|
43 | }
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 | var ReactCSSTransitionGroup = function (_React$Component) {
|
52 | _inherits(ReactCSSTransitionGroup, _React$Component);
|
53 |
|
54 | function ReactCSSTransitionGroup() {
|
55 | var _temp, _this, _ret;
|
56 |
|
57 | _classCallCheck(this, ReactCSSTransitionGroup);
|
58 |
|
59 | for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
60 | args[_key] = arguments[_key];
|
61 | }
|
62 |
|
63 | return _ret = (_temp = (_this = _possibleConstructorReturn(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this._wrapChild = function (child) {
|
64 |
|
65 |
|
66 |
|
67 | return React.createElement(ReactCSSTransitionGroupChild, {
|
68 | name: _this.props.transitionName,
|
69 | appear: _this.props.transitionAppear,
|
70 | enter: _this.props.transitionEnter,
|
71 | leave: _this.props.transitionLeave,
|
72 | appearTimeout: _this.props.transitionAppearTimeout,
|
73 | enterTimeout: _this.props.transitionEnterTimeout,
|
74 | leaveTimeout: _this.props.transitionLeaveTimeout
|
75 | }, child);
|
76 | }, _temp), _possibleConstructorReturn(_this, _ret);
|
77 | }
|
78 |
|
79 | ReactCSSTransitionGroup.prototype.render = function render() {
|
80 | return React.createElement(ReactTransitionGroup, _assign({}, this.props, { childFactory: this._wrapChild }));
|
81 | };
|
82 |
|
83 | return ReactCSSTransitionGroup;
|
84 | }(React.Component);
|
85 |
|
86 | ReactCSSTransitionGroup.displayName = 'ReactCSSTransitionGroup';
|
87 | ReactCSSTransitionGroup.propTypes = {
|
88 | transitionName: ReactCSSTransitionGroupChild.propTypes.name,
|
89 |
|
90 | transitionAppear: PropTypes.bool,
|
91 | transitionEnter: PropTypes.bool,
|
92 | transitionLeave: PropTypes.bool,
|
93 | transitionAppearTimeout: createTransitionTimeoutPropValidator('Appear'),
|
94 | transitionEnterTimeout: createTransitionTimeoutPropValidator('Enter'),
|
95 | transitionLeaveTimeout: createTransitionTimeoutPropValidator('Leave')
|
96 | };
|
97 | ReactCSSTransitionGroup.defaultProps = {
|
98 | transitionAppear: false,
|
99 | transitionEnter: true,
|
100 | transitionLeave: true
|
101 | };
|
102 |
|
103 |
|
104 | module.exports = ReactCSSTransitionGroup; |
\ | No newline at end of file |