"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _extends2=require("babel-runtime/helpers/extends"),_extends3=_interopRequireDefault(_extends2),_defineProperty2=require("babel-runtime/helpers/defineProperty"),_defineProperty3=_interopRequireDefault(_defineProperty2),_classCallCheck2=require("babel-runtime/helpers/classCallCheck"),_classCallCheck3=_interopRequireDefault(_classCallCheck2),_createClass2=require("babel-runtime/helpers/createClass"),_createClass3=_interopRequireDefault(_createClass2),_possibleConstructorReturn2=require("babel-runtime/helpers/possibleConstructorReturn"),_possibleConstructorReturn3=_interopRequireDefault(_possibleConstructorReturn2),_inherits2=require("babel-runtime/helpers/inherits"),_inherits3=_interopRequireDefault(_inherits2),_react=require("react"),React=_interopRequireWildcard(_react),_propTypes=require("prop-types"),PropTypes=_interopRequireWildcard(_propTypes),_classnames=require("classnames"),_classnames2=_interopRequireDefault(_classnames),_rcAnimate=require("rc-animate"),_rcAnimate2=_interopRequireDefault(_rcAnimate),_isCssAnimationSupported=require("../_util/isCssAnimationSupported"),_isCssAnimationSupported2=_interopRequireDefault(_isCssAnimationSupported),_omit=require("omit.js"),_omit2=_interopRequireDefault(_omit);function _interopRequireWildcard(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}var __rest=function(e,t){var r={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(r[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(i=Object.getOwnPropertySymbols(e);n<i.length;n++)t.indexOf(i[n])<0&&(r[i[n]]=e[i[n]])}return r},Spin=function(e){function i(e){(0,_classCallCheck3.default)(this,i);var t=(0,_possibleConstructorReturn3.default)(this,(i.__proto__||Object.getPrototypeOf(i)).call(this,e)),r=e.spinning;return t.state={spinning:r},t}return(0,_inherits3.default)(i,e),(0,_createClass3.default)(i,[{key:"isNestedPattern",value:function(){return!(!this.props||!this.props.children)}},{key:"componentDidMount",value:function(){(0,_isCssAnimationSupported2.default)()||this.setState({notCssAnimationSupported:!0})}},{key:"componentWillUnmount",value:function(){this.debounceTimeout&&clearTimeout(this.debounceTimeout),this.delayTimeout&&clearTimeout(this.delayTimeout)}},{key:"componentWillReceiveProps",value:function(e){var t=this,r=this.props.spinning,i=e.spinning,n=this.props.delay;this.debounceTimeout&&clearTimeout(this.debounceTimeout),r&&!i?(this.debounceTimeout=window.setTimeout(function(){return t.setState({spinning:i})},200),this.delayTimeout&&clearTimeout(this.delayTimeout)):i&&n&&!isNaN(Number(n))?(this.delayTimeout&&clearTimeout(this.delayTimeout),this.delayTimeout=window.setTimeout(function(){return t.setState({spinning:i})},n)):this.setState({spinning:i})}},{key:"renderIndicator",value:function(){var e=this.props,t=e.prefixCls,r=e.indicator,i=t+"-dot";return React.isValidElement(r)?React.cloneElement(r,{className:(0,_classnames2.default)(r.props.className,i)}):React.createElement("span",{className:(0,_classnames2.default)(i,t+"-dot-spin")},React.createElement("i",null),React.createElement("i",null),React.createElement("i",null))}},{key:"render",value:function(){var e,t=this.props,r=t.className,i=t.size,n=t.prefixCls,s=t.tip,a=t.wrapperClassName,l=__rest(t,["className","size","prefixCls","tip","wrapperClassName"]),o=this.state,u=o.spinning,p=o.notCssAnimationSupported,c=(0,_classnames2.default)(n,(e={},(0,_defineProperty3.default)(e,n+"-sm","small"===i),(0,_defineProperty3.default)(e,n+"-lg","large"===i),(0,_defineProperty3.default)(e,n+"-spinning",u),(0,_defineProperty3.default)(e,n+"-show-text",!!s||p),e),r),d=(0,_omit2.default)(l,["spinning","delay","indicator"]),m=React.createElement("div",(0,_extends3.default)({},d,{className:c}),this.renderIndicator(),s?React.createElement("div",{className:n+"-text"},s):null);if(this.isNestedPattern()){var _,f=n+"-nested-loading";a&&(f+=" "+a);var h=(0,_classnames2.default)((_={},(0,_defineProperty3.default)(_,n+"-container",!0),(0,_defineProperty3.default)(_,n+"-blur",u),_));return React.createElement(_rcAnimate2.default,(0,_extends3.default)({},d,{component:"div",className:f,style:null,transitionName:"fade"}),u&&React.createElement("div",{key:"loading"},m),React.createElement("div",{className:h,key:"container"},this.props.children))}return m}}]),i}(React.Component);(exports.default=Spin).defaultProps={prefixCls:"dt-spin",spinning:!0,size:"default",wrapperClassName:""},Spin.propTypes={prefixCls:PropTypes.string,className:PropTypes.string,spinning:PropTypes.bool,size:PropTypes.oneOf(["small","default","large"]),wrapperClassName:PropTypes.string,indicator:PropTypes.node},module.exports=exports.default;