text: "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _createClass=function(){function r(e,t){for(var a=0;a<t.length;a++){var r=t[a];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(e,t,a){return t&&r(e.prototype,t),a&&r(e,a),e}}(),_templateObject=_taggedTemplateLiteral(["\n    position: relative;\n    background: #fff;\n    min-width: 100px;\n    flex: 1;\n  "],["\n    position: relative;\n    background: #fff;\n    min-width: 100px;\n    flex: 1;\n  "]),_templateObject2=_taggedTemplateLiteral(["\n    overflow: hidden;\n    padding: 10px;\n    width: 100%;\n    height: 0;\n    display: none;\n  "],["\n    overflow: hidden;\n    padding: 10px;\n    width: 100%;\n    height: 0;\n    display: none;\n  "]),_templateObject3=_taggedTemplateLiteral(["\n    -webkit-box-sizing: border-box;\n    box-sizing: border-box;\n    position: relative;\n    overflow: hidden;\n  "],["\n    -webkit-box-sizing: border-box;\n    box-sizing: border-box;\n    position: relative;\n    overflow: hidden;\n  "]),_templateObject4=_taggedTemplateLiteral(["\n    -webkit-box-sizing: border-box;\n    box-sizing: border-box;\n    position: relative;\n    display: flex;\n    flex-direction: column;\n  "],["\n    -webkit-box-sizing: border-box;\n    box-sizing: border-box;\n    position: relative;\n    display: flex;\n    flex-direction: column;\n  "]),_templateObject5=_taggedTemplateLiteral(["\n    -webkit-box-sizing: border-box;\n    box-sizing: border-box;\n    position: relative;\n    display: flex;\n  "],["\n    -webkit-box-sizing: border-box;\n    box-sizing: border-box;\n    position: relative;\n    display: flex;\n  "]);exports.hasTargetInProps=hasTargetInProps,exports.setKeyValue=setKeyValue,exports.getDefaultData=getDefaultData,require("../common/shirm");var _react=require("react"),_react2=_interopRequireDefault(_react),_tabheader=require("./tabheader"),_tabheader2=_interopRequireDefault(_tabheader),_tabcontent=require("./tabcontent"),_tabcontent2=_interopRequireDefault(_tabcontent),_index=require("../consts/index"),_index2=_interopRequireDefault(_index),_tabs=require("../css/tabs"),_utils=require("./utils"),_ObjectUtils=require("../common/ObjectUtils.js"),_themeCssHoc=require("@lugia/theme-css-hoc"),_themeCssHoc2=_interopRequireDefault(_themeCssHoc),_themeHoc=require("@lugia/theme-hoc"),_themeHoc2=_interopRequireDefault(_themeHoc),_objectUtils=require("@lugia/object-utils"),_stateColor=require("../css/stateColor"),_stateColor2=_interopRequireDefault(_stateColor);function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function _toConsumableArray(e){if(Array.isArray(e)){for(var t=0,a=Array(e.length);t<e.length;t++)a[t]=e[t];return a}return Array.from(e)}function _taggedTemplateLiteral(e,t){return Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}var _colorsFunc=(0,_stateColor2.default)(),superLightColor=_colorsFunc.superLightColor,TabContentContainer=(0,_themeCssHoc2.default)({tag:"div",className:"ContentBlock",normal:{selectNames:[["padding"],["width"],["height"],["background"],["boxShadow"],["border"],["borderRadius"],["textAlign"],["font"],["color"]],getCSS:function(e,t){var a=t.propsConfig.tabPosition,r=e.textAlign,n="text-align:"+(void 0===r?"left":r)+";",o="";return(0,_utils.isVertical)(a)&&(o="flex: 1 1 auto;"),n+"\n      "+o}},disabled:{selectNames:[]},css:(0,_themeCssHoc.css)(_templateObject)}),TabContent=(0,_themeCssHoc2.default)({tag:"div",className:"TabContent",normal:{selectNames:[],getCSS:function(e,t){var a=t.propsConfig;return a.active===a.value?"\n        display:block;\n        z-index:10;\n        height:100%;\n        ":""}},disabled:{selectNames:[]},css:(0,_themeCssHoc.css)(_templateObject2)}),WindowContainer=(0,_themeCssHoc2.default)({tag:"div",className:"WindowContainer",normal:{selectNames:[["background"],["padding"],["border"],["borderRadius"],["opacity"],["width"],["height"]],defaultTheme:{background:{color:superLightColor}}},disabled:{selectNames:[]},css:(0,_themeCssHoc.css)(_templateObject3)}),OutContainer=(0,_themeCssHoc2.default)({tag:"div",className:"OutContainer",normal:{selectNames:[["width"],["height"]]},disabled:{selectNames:[]},css:(0,_themeCssHoc.css)(_templateObject4)}),VerticalOutContainer=(0,_themeCssHoc2.default)({tag:"div",className:"VerticalOutContainer",normal:{selectNames:[["width"],["height"]]},disabled:{selectNames:[]},css:(0,_themeCssHoc.css)(_templateObject5)});function hasTargetInProps(e,t){return""+e in t}function setKeyValue(e){return[].concat(_toConsumableArray(e)).map(function(e,t){var a=Object.assign({},e),r=a.value,n=a.key;return r||(a.value=n||"Tab"+(t+1)),a})}function getDefaultData(e){var t=e.defaultData,a=e.data,r=e.children,n=[{title:"Tab1",value:"Tab1"},{title:"Tab2",value:"Tab2"},{title:"Tab3",value:"Tab3"}];return hasTargetInProps("data",e)&&Array.isArray(a)?n=a||[]:r?(n=[],_react2.default.Children.map(r,function(e){if("string"!=typeof e){var t=Object.assign({},e.props);n&&n.push(t)}})):n=t||n,setKeyValue(n)}OutContainer.displayName=_index2.default.TabsContainer;var TabsBox=function(){function o(){var e,t,i;_classCallCheck(this,o);for(var a=arguments.length,r=Array(a),n=0;n<a;n++)r[n]=arguments[n];return(t=i=_possibleConstructorReturn(this,(e=o.__proto__||Object.getPrototypeOf(o)).call.apply(e,[this].concat(r)))).onChange=function(e){var t=i.props.onChange;if(t&&t(e),!hasTargetInProps("activityValue",i.props)){var a=e.activityValue;i.setState({activityValue:a})}},i.onTabClick=function(e){var t=i.props.onTabClick;t&&t(e)},i.onPreClick=function(e){var t=i.props.onPreClick;t&&t(e)},i.onNextClick=function(e){var t=i.props.onNextClick;t&&t(e)},i.onDelete=function(e){var t=i.props.onDelete;if(t&&t(e),!hasTargetInProps("data",i.props)&&!hasTargetInProps("children",i.props)){var a=i.state.data,r=[].concat(_toConsumableArray(a)),n=e.index;r.splice(n,1),i.setState({data:r})}},i.onAddClick=function(e){var t=i.props.onAddClick;if(t&&t(e),!hasTargetInProps("activityValue",i.props)&&!hasTargetInProps("data",i.props)&&!hasTargetInProps("children",i.props)){var a=i.state.data,r=[].concat(_toConsumableArray(a)),n=i.props.getAddItem,o=n&&n()||{title:"Tab"+(a.length+1),content:"Tab"+(a.length+1)+" Content",value:"Tab"+(a.length+1)};r.push(o),i.setState({activityValue:o.value||"Tab"+(a.length+1),data:setKeyValue(r)})}},_possibleConstructorReturn(i,t)}return _inherits(o,_react.Component),_createClass(o,[{key:"render",value:function(){var e=this.props,t=e.themeProps,a=e.tabType,r=e.tabPosition,n="line"===a&&(0,_utils.isVertical)(r)?VerticalOutContainer:OutContainer,o=this.props.getPartOfThemeProps("Container"),i=_react2.default.createElement(n,{themeProps:o},_react2.default.createElement(_tabheader2.default,this.getTabHeaderProps()),this.getChildrenContent());if("line"===a&&("right"!==r&&"bottom"!==r||(i=_react2.default.createElement(n,{themeProps:o},this.getChildrenContent(),_react2.default.createElement(_tabheader2.default,this.getTabHeaderProps())))),"window"===a){var s=(0,_objectUtils.deepMerge)({themeConfig:{normal:{padding:{left:10,right:10,top:10,bottom:10},background:{color:superLightColor}}}},o,this.props.getPartOfThemeProps("WindowContainer"));i=_react2.default.createElement(WindowContainer,{themeProps:s},_react2.default.createElement(OutContainer,{themeProps:t},_react2.default.createElement(_tabheader2.default,this.getTabHeaderProps()),this.getChildrenContent()))}return i}},{key:"getTabHeaderProps",value:function(){var e=this.state,t=e.activityValue,a=e.data,r=this.props,n=r.tabType,o=r.showAddBtn,i=r.pagedType,s=r.getTabpane,l=r.showDeleteBtn,c=r.themeProps,u=r.getPartOfThemeHocProps,p=r.getPartOfThemeProps,d=r.showDividerLine,b=r.addIcon,h=r.deleteIcon,f=r.pageArrowIcon,g=this.props.tabPosition;return{activityValue:t,data:a,tabPosition:g="line"===n?g:"top",tabType:n,showAddBtn:o,pagedType:i,showDeleteBtn:l,getTabpane:s,onChange:this.onChange,onTabClick:this.onTabClick,onPreClick:this.onPreClick,onNextClick:this.onNextClick,onAddClick:this.onAddClick,onDelete:this.onDelete,themeProps:c,getPartOfThemeHocProps:u,getPartOfThemeProps:p,showDividerLine:d,addIcon:b,deleteIcon:h,pageArrowIcon:f}}},{key:"getChildrenContent",value:function(){var s=this,e=this.state,l=e.activityValue,t=e.data,a=this.props,r=a.tabPosition,n=a.themeProps,o=a.hideContent;if(t){n.propsConfig={tabPosition:r};var c=this.props.getPartOfThemeProps("ContentBlock",{props:{tabPosition:r}});if(o)return;return _react2.default.createElement(TabContentContainer,{themeProps:c},t.map(function(e,t){var a=(0,_ObjectUtils.getAttributeFromObject)(e,"content",(0,_ObjectUtils.getAttributeFromObject)(e.props,"content",(0,_ObjectUtils.getAttributeFromObject)(e,"children",void 0))),r=(0,_ObjectUtils.getAttributeFromObject)(e,"value",(0,_ObjectUtils.getAttributeFromObject)(e.props,"value",(0,_ObjectUtils.getAttributeFromObject)(e,"children",void 0))),n={active:l,value:r},o=s.props.getPartOfThemeProps("ContentBlock",{props:n}),i=s.props.forceRender;return a?i?l===r&&_react2.default.createElement(TabContent,{themeProps:o},_react2.default.createElement(_tabcontent2.default,Object.assign({},s.props,{themeProps:c,content:a,forceRender:i&&r===l}))):_react2.default.createElement(TabContent,{themeProps:o},_react2.default.createElement(_tabcontent2.default,Object.assign({},s.props,{themeProps:c,content:a,forceRender:i&&r===l}))):null}))}}}],[{key:"getDerivedStateFromProps",value:function(e,t){var a=e.activityValue,r=e.defaultActivityValue,n=getDefaultData(e),o=a||r||(0!==n.length?n[0].value:null);t&&(o=hasTargetInProps("activityValue",e)?o:t.activityValue,n=hasTargetInProps("data",e)||hasTargetInProps("children",e)?n:t.data);var i={data:n,activityValue:o};return Object.assign({},i)}}]),o}();TabsBox.defaultProps={tabType:"line",tabPosition:"top",pagedType:"single",forceRender:!1,showAddBtn:!1,showDeleteBtn:!1,addIcon:"lugia-icon-reminder_plus",deleteIcon:"lugia-icon-reminder_close"},TabsBox.displayName=_index2.default.Tabs,exports.default=(0,_themeHoc2.default)(TabsBox,_index2.default.Tabs,{hover:!0,active:!1});