"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),_typeof2=require("babel-runtime/helpers/typeof"),_typeof3=_interopRequireDefault(_typeof2),_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),_reactDom=require("react-dom"),ReactDOM=_interopRequireWildcard(_reactDom),_rcTabs=require("rc-tabs"),_rcTabs2=_interopRequireDefault(_rcTabs),_ScrollableInkTabBar=require("rc-tabs/lib/ScrollableInkTabBar"),_ScrollableInkTabBar2=_interopRequireDefault(_ScrollableInkTabBar),_TabContent=require("rc-tabs/lib/TabContent"),_TabContent2=_interopRequireDefault(_TabContent),_classnames=require("classnames"),_classnames2=_interopRequireDefault(_classnames),_icon=require("../icon"),_icon2=_interopRequireDefault(_icon),_warning=require("../_util/warning"),_warning2=_interopRequireDefault(_warning),_isFlexSupported=require("../_util/isFlexSupported"),_isFlexSupported2=_interopRequireDefault(_isFlexSupported);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 Tabs=function(e){function t(){(0,_classCallCheck3.default)(this,t);var a=(0,_possibleConstructorReturn3.default)(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments));return a.createNewTab=function(e){var t=a.props.onEdit;t&&t(e,"add")},a.removeTab=function(e,t){if(t.stopPropagation(),e){var r=a.props.onEdit;r&&r(e,"remove")}},a.handleChange=function(e){var t=a.props.onChange;t&&t(e)},a}return(0,_inherits3.default)(t,e),(0,_createClass3.default)(t,[{key:"componentDidMount",value:function(){var e=" no-flex",t=ReactDOM.findDOMNode(this);t&&!(0,_isFlexSupported2.default)()&&-1===t.className.indexOf(e)&&(t.className+=e)}},{key:"render",value:function(){var e,n=this,t=this.props,i=t.prefixCls,r=t.className,a=void 0===r?"":r,l=t.size,o=t.type,s=void 0===o?"line":o,u=t.tabPosition,c=t.children,d=t.tabBarExtraContent,p=t.tabBarStyle,_=t.hideAdd,b=t.onTabClick,f=t.onPrevClick,m=t.onNextClick,h=t.animated,C=void 0===h||h,R=t.tabBarGutter,q="object"===(void 0===C?"undefined":(0,_typeof3.default)(C))?{inkBarAnimated:C.inkBar,tabPaneAnimated:C.tabPane}:{inkBarAnimated:C,tabPaneAnimated:C},y=q.inkBarAnimated,v=q.tabPaneAnimated;"line"!==s&&(v="animated"in this.props&&v),(0,_warning2.default)(!(0<=s.indexOf("card")&&("small"===l||"large"===l)),"Tabs[type=card|editable-card] doesn't have small or large size, it's by designed.");var T=(0,_classnames2.default)(a,(e={},(0,_defineProperty3.default)(e,i+"-vertical","left"===u||"right"===u),(0,_defineProperty3.default)(e,i+"-"+l,!!l),(0,_defineProperty3.default)(e,i+"-card",0<=s.indexOf("card")),(0,_defineProperty3.default)(e,i+"-"+s,!0),(0,_defineProperty3.default)(e,i+"-no-animation",!v),e)),k=[];"editable-card"===s&&(k=[],React.Children.forEach(c,function(t,e){var r=t.props.closable,a=(r=void 0===r||r)?React.createElement(_icon2.default,{type:"close",onClick:function(e){return n.removeTab(t.key,e)}}):null;k.push(React.cloneElement(t,{tab:React.createElement("div",{className:r?void 0:i+"-tab-unclosable"},t.props.tab,a),key:t.key||e}))}),_||(d=React.createElement("span",null,React.createElement(_icon2.default,{type:"plus",className:i+"-new-tab",onClick:this.createNewTab}),d))),d=d?React.createElement("div",{className:i+"-extra-content"},d):null;return React.createElement(_rcTabs2.default,(0,_extends3.default)({},this.props,{className:T,tabBarPosition:u,renderTabBar:function(){return React.createElement(_ScrollableInkTabBar2.default,{inkBarAnimated:y,extraContent:d,onTabClick:b,onPrevClick:f,onNextClick:m,style:p,tabBarGutter:R})},renderTabContent:function(){return React.createElement(_TabContent2.default,{animated:v,animatedWithMargin:!0})},onChange:this.handleChange}),0<k.length?k:c)}}]),t}(React.Component);(exports.default=Tabs).TabPane=_rcTabs.TabPane,Tabs.defaultProps={prefixCls:"dt-tabs",hideAdd:!1},module.exports=exports.default;