import _extends from"babel-runtime/helpers/extends";import _defineProperty from"babel-runtime/helpers/defineProperty";import _typeof from"babel-runtime/helpers/typeof";import _classCallCheck from"babel-runtime/helpers/classCallCheck";import _createClass from"babel-runtime/helpers/createClass";import _possibleConstructorReturn from"babel-runtime/helpers/possibleConstructorReturn";import _inherits from"babel-runtime/helpers/inherits";import*as React from"react";import*as ReactDOM from"react-dom";import RcTabs,{TabPane}from"rc-tabs";import ScrollableInkTabBar from"rc-tabs/es/ScrollableInkTabBar";import TabContent from"rc-tabs/es/TabContent";import classNames from"classnames";import Icon from"../icon";import warning from"../_util/warning";import isFlexSupported from"../_util/isFlexSupported";var Tabs=function(e){function t(){_classCallCheck(this,t);var e=_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments));return e.createNewTab=function(t){var a=e.props.onEdit;a&&a(t,"add")},e.removeTab=function(t,a){if(a.stopPropagation(),t){var r=e.props.onEdit;r&&r(t,"remove")}},e.handleChange=function(t){var a=e.props.onChange;a&&a(t)},e}return _inherits(t,e),_createClass(t,[{key:"componentDidMount",value:function(){var e=ReactDOM.findDOMNode(this);e&&!isFlexSupported()&&-1===e.className.indexOf(" no-flex")&&(e.className+=" no-flex")}},{key:"render",value:function(){var e,t=this,a=this.props,r=a.prefixCls,n=a.className,o=void 0===n?"":n,i=a.size,s=a.type,l=void 0===s?"line":s,c=a.tabPosition,m=a.children,p=a.tabBarExtraContent,d=a.tabBarStyle,b=a.hideAdd,f=a.onTabClick,u=a.onPrevClick,h=a.onNextClick,C=a.animated,v=void 0===C||C,k=a.tabBarGutter,y="object"===(void 0===v?"undefined":_typeof(v))?{inkBarAnimated:v.inkBar,tabPaneAnimated:v.tabPane}:{inkBarAnimated:v,tabPaneAnimated:v},T=y.inkBarAnimated,_=y.tabPaneAnimated;"line"!==l&&(_="animated"in this.props&&_),warning(!(l.indexOf("card")>=0&&("small"===i||"large"===i)),"Tabs[type=card|editable-card] doesn't have small or large size, it's by designed.");var P=classNames(o,(_defineProperty(e={},r+"-vertical","left"===c||"right"===c),_defineProperty(e,r+"-"+i,!!i),_defineProperty(e,r+"-card",l.indexOf("card")>=0),_defineProperty(e,r+"-"+l,!0),_defineProperty(e,r+"-no-animation",!_),e)),x=[];"editable-card"===l&&(x=[],React.Children.forEach(m,function(e,a){var n=e.props.closable,o=(n=void 0===n||n)?React.createElement(Icon,{type:"close",onClick:function(a){return t.removeTab(e.key,a)}}):null;x.push(React.cloneElement(e,{tab:React.createElement("div",{className:n?void 0:r+"-tab-unclosable"},e.props.tab,o),key:e.key||a}))}),b||(p=React.createElement("span",null,React.createElement(Icon,{type:"plus",className:r+"-new-tab",onClick:this.createNewTab}),p))),p=p?React.createElement("div",{className:r+"-extra-content"},p):null;return React.createElement(RcTabs,_extends({},this.props,{className:P,tabBarPosition:c,renderTabBar:function(){return React.createElement(ScrollableInkTabBar,{inkBarAnimated:T,extraContent:p,onTabClick:f,onPrevClick:u,onNextClick:h,style:d,tabBarGutter:k})},renderTabContent:function(){return React.createElement(TabContent,{animated:_,animatedWithMargin:!0})},onChange:this.handleChange}),x.length>0?x:m)}}]),t}(React.Component);export default Tabs;Tabs.TabPane=TabPane,Tabs.defaultProps={prefixCls:"dt-tabs",hideAdd:!1};