{"dependencies":[{"name":"chain-function","loc":{"line":7,"column":29}},{"name":"react","loc":{"line":11,"column":21}},{"name":"prop-types","loc":{"line":15,"column":25}},{"name":"warning","loc":{"line":19,"column":23}},{"name":"./utils/ChildMapping","loc":{"line":23,"column":28}}],"generated":{"js":"'use strict';\n\nexports.__esModule = true;\n\nvar _extends = Object.assign || function (target) {\n  for (var i = 1; i < arguments.length; i++) {\n    var source = arguments[i];for (var key in source) {\n      if (Object.prototype.hasOwnProperty.call(source, key)) {\n        target[key] = source[key];\n      }\n    }\n  }return target;\n};\n\nvar _chainFunction = require('chain-function');\n\nvar _chainFunction2 = _interopRequireDefault(_chainFunction);\n\nvar _react = require('react');\n\nvar _react2 = _interopRequireDefault(_react);\n\nvar _propTypes = require('prop-types');\n\nvar _propTypes2 = _interopRequireDefault(_propTypes);\n\nvar _warning = require('warning');\n\nvar _warning2 = _interopRequireDefault(_warning);\n\nvar _ChildMapping = require('./utils/ChildMapping');\n\nfunction _interopRequireDefault(obj) {\n  return obj && obj.__esModule ? obj : { default: obj };\n}\n\nfunction _classCallCheck(instance, Constructor) {\n  if (!(instance instanceof Constructor)) {\n    throw new TypeError(\"Cannot call a class as a function\");\n  }\n}\n\nfunction _possibleConstructorReturn(self, call) {\n  if (!self) {\n    throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n  }return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self;\n}\n\nfunction _inherits(subClass, superClass) {\n  if (typeof superClass !== \"function\" && superClass !== null) {\n    throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass);\n  }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;\n}\n\nvar propTypes = {\n  component: _propTypes2.default.any,\n  childFactory: _propTypes2.default.func,\n  children: _propTypes2.default.node\n};\n\nvar defaultProps = {\n  component: 'span',\n  childFactory: function childFactory(child) {\n    return child;\n  }\n};\n\nvar TransitionGroup = function (_React$Component) {\n  _inherits(TransitionGroup, _React$Component);\n\n  function TransitionGroup(props, context) {\n    _classCallCheck(this, TransitionGroup);\n\n    var _this = _possibleConstructorReturn(this, _React$Component.call(this, props, context));\n\n    _this.performAppear = function (key, component) {\n      _this.currentlyTransitioningKeys[key] = true;\n\n      if (component.componentWillAppear) {\n        component.componentWillAppear(_this._handleDoneAppearing.bind(_this, key, component));\n      } else {\n        _this._handleDoneAppearing(key, component);\n      }\n    };\n\n    _this._handleDoneAppearing = function (key, component) {\n      if (component.componentDidAppear) {\n        component.componentDidAppear();\n      }\n\n      delete _this.currentlyTransitioningKeys[key];\n\n      var currentChildMapping = (0, _ChildMapping.getChildMapping)(_this.props.children);\n\n      if (!currentChildMapping || !currentChildMapping.hasOwnProperty(key)) {\n        // This was removed before it had fully appeared. Remove it.\n        _this.performLeave(key, component);\n      }\n    };\n\n    _this.performEnter = function (key, component) {\n      _this.currentlyTransitioningKeys[key] = true;\n\n      if (component.componentWillEnter) {\n        component.componentWillEnter(_this._handleDoneEntering.bind(_this, key, component));\n      } else {\n        _this._handleDoneEntering(key, component);\n      }\n    };\n\n    _this._handleDoneEntering = function (key, component) {\n      if (component.componentDidEnter) {\n        component.componentDidEnter();\n      }\n\n      delete _this.currentlyTransitioningKeys[key];\n\n      var currentChildMapping = (0, _ChildMapping.getChildMapping)(_this.props.children);\n\n      if (!currentChildMapping || !currentChildMapping.hasOwnProperty(key)) {\n        // This was removed before it had fully entered. Remove it.\n        _this.performLeave(key, component);\n      }\n    };\n\n    _this.performLeave = function (key, component) {\n      _this.currentlyTransitioningKeys[key] = true;\n\n      if (component.componentWillLeave) {\n        component.componentWillLeave(_this._handleDoneLeaving.bind(_this, key, component));\n      } else {\n        // Note that this is somewhat dangerous b/c it calls setState()\n        // again, effectively mutating the component before all the work\n        // is done.\n        _this._handleDoneLeaving(key, component);\n      }\n    };\n\n    _this._handleDoneLeaving = function (key, component) {\n      if (component.componentDidLeave) {\n        component.componentDidLeave();\n      }\n\n      delete _this.currentlyTransitioningKeys[key];\n\n      var currentChildMapping = (0, _ChildMapping.getChildMapping)(_this.props.children);\n\n      if (currentChildMapping && currentChildMapping.hasOwnProperty(key)) {\n        // This entered again before it fully left. Add it again.\n        _this.keysToEnter.push(key);\n      } else {\n        _this.setState(function (state) {\n          var newChildren = _extends({}, state.children);\n          delete newChildren[key];\n          return { children: newChildren };\n        });\n      }\n    };\n\n    _this.childRefs = Object.create(null);\n\n    _this.state = {\n      children: (0, _ChildMapping.getChildMapping)(props.children)\n    };\n    return _this;\n  }\n\n  TransitionGroup.prototype.componentWillMount = function componentWillMount() {\n    this.currentlyTransitioningKeys = {};\n    this.keysToEnter = [];\n    this.keysToLeave = [];\n  };\n\n  TransitionGroup.prototype.componentDidMount = function componentDidMount() {\n    var initialChildMapping = this.state.children;\n    for (var key in initialChildMapping) {\n      if (initialChildMapping[key]) {\n        this.performAppear(key, this.childRefs[key]);\n      }\n    }\n  };\n\n  TransitionGroup.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {\n    var nextChildMapping = (0, _ChildMapping.getChildMapping)(nextProps.children);\n    var prevChildMapping = this.state.children;\n\n    this.setState({\n      children: (0, _ChildMapping.mergeChildMappings)(prevChildMapping, nextChildMapping)\n    });\n\n    for (var key in nextChildMapping) {\n      var hasPrev = prevChildMapping && prevChildMapping.hasOwnProperty(key);\n      if (nextChildMapping[key] && !hasPrev && !this.currentlyTransitioningKeys[key]) {\n        this.keysToEnter.push(key);\n      }\n    }\n\n    for (var _key in prevChildMapping) {\n      var hasNext = nextChildMapping && nextChildMapping.hasOwnProperty(_key);\n      if (prevChildMapping[_key] && !hasNext && !this.currentlyTransitioningKeys[_key]) {\n        this.keysToLeave.push(_key);\n      }\n    }\n\n    // If we want to someday check for reordering, we could do it here.\n  };\n\n  TransitionGroup.prototype.componentDidUpdate = function componentDidUpdate() {\n    var _this2 = this;\n\n    var keysToEnter = this.keysToEnter;\n    this.keysToEnter = [];\n    keysToEnter.forEach(function (key) {\n      return _this2.performEnter(key, _this2.childRefs[key]);\n    });\n\n    var keysToLeave = this.keysToLeave;\n    this.keysToLeave = [];\n    keysToLeave.forEach(function (key) {\n      return _this2.performLeave(key, _this2.childRefs[key]);\n    });\n  };\n\n  TransitionGroup.prototype.render = function render() {\n    var _this3 = this;\n\n    // TODO: we could get rid of the need for the wrapper node\n    // by cloning a single child\n    var childrenToRender = [];\n\n    var _loop = function _loop(key) {\n      var child = _this3.state.children[key];\n      if (child) {\n        var isCallbackRef = typeof child.ref !== 'string';\n        var factoryChild = _this3.props.childFactory(child);\n        var ref = function ref(r) {\n          _this3.childRefs[key] = r;\n        };\n\n        \"development\" !== 'production' ? (0, _warning2.default)(isCallbackRef, 'string refs are not supported on children of TransitionGroup and will be ignored. ' + 'Please use a callback ref instead: https://facebook.github.io/react/docs/refs-and-the-dom.html#the-ref-callback-attribute') : void 0;\n\n        // Always chaining the refs leads to problems when the childFactory\n        // wraps the child. The child ref callback gets called twice with the\n        // wrapper and the child. So we only need to chain the ref if the\n        // factoryChild is not different from child.\n        if (factoryChild === child && isCallbackRef) {\n          ref = (0, _chainFunction2.default)(child.ref, ref);\n        }\n\n        // You may need to apply reactive updates to a child as it is leaving.\n        // The normal React way to do it won't work since the child will have\n        // already been removed. In case you need this behavior you can provide\n        // a childFactory function to wrap every child, even the ones that are\n        // leaving.\n        childrenToRender.push(_react2.default.cloneElement(factoryChild, {\n          key: key,\n          ref: ref\n        }));\n      }\n    };\n\n    for (var key in this.state.children) {\n      _loop(key);\n    }\n\n    // Do not forward TransitionGroup props to primitive DOM nodes\n    var props = _extends({}, this.props);\n    delete props.transitionLeave;\n    delete props.transitionName;\n    delete props.transitionAppear;\n    delete props.transitionEnter;\n    delete props.childFactory;\n    delete props.transitionLeaveTimeout;\n    delete props.transitionEnterTimeout;\n    delete props.transitionAppearTimeout;\n    delete props.component;\n\n    return _react2.default.createElement(this.props.component, props, childrenToRender);\n  };\n\n  return TransitionGroup;\n}(_react2.default.Component);\n\nTransitionGroup.displayName = 'TransitionGroup';\n\nTransitionGroup.propTypes = \"development\" !== \"production\" ? propTypes : {};\nTransitionGroup.defaultProps = defaultProps;\n\nexports.default = TransitionGroup;\nmodule.exports = exports['default'];"},"hash":"7f13e963db8195e294ab4502334a170b"}