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 PropTypes from"prop-types";import KEYCODE from"./KeyCode";var Options=function(e){function t(e){_classCallCheck(this,t);var o=_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return o.buildOptionText=function(e){return e+" "+o.props.locale.items_per_page},o.changeSize=function(e){"function"==typeof o.props.changeSize&&o.props.changeSize(Number(e))},o.handleChange=function(e){o.setState({goInputText:e.target.value})},o.go=function(e){var t=o.state.goInputText;""!==t&&(t=isNaN(t)?o.props.current:Number(t),e.keyCode!==KEYCODE.ENTER&&"click"!==e.type||(o.setState({goInputText:""}),"function"==typeof o.props.quickGo&&o.props.quickGo(t)))},o.state={goInputText:""},o}return _inherits(t,e),_createClass(t,[{key:"render",value:function(){var e=this.props,t=this.state,o=e.locale,n=e.rootPrefixCls+"-options",r=e.changeSize,p=e.quickGo,i=e.goButton,a=e.buildOptionText||this.buildOptionText,s=e.selectComponentClass,c=null,l=null,u=null;if(!r&&!p)return null;if(r&&s){var h=s.Option,m=e.pageSize||e.pageSizeOptions[0],g=e.pageSizeOptions.map(function(e,t){return React.createElement(h,{key:t,value:e},a(e))});c=React.createElement(s,{prefixCls:e.selectPrefixCls,showSearch:!1,className:n+"-size-changer",optionLabelProp:"children",dropdownMatchSelectWidth:!1,value:m.toString(),onChange:this.changeSize,getPopupContainer:e.getPopupContainer},g)}return p&&(i&&(u="boolean"==typeof i?React.createElement("button",{type:"button",onClick:this.go,onKeyUp:this.go},o.jump_to_confirm):React.createElement("span",{onClick:this.go,onKeyUp:this.go},i)),l=React.createElement("div",{className:n+"-quick-jumper"},o.jump_to,React.createElement("input",{type:"text",value:t.goInputText,onChange:this.handleChange,onKeyUp:this.go}),o.page,u)),React.createElement("li",{className:""+n},c,l)}}]),t}(React.Component);Options.propTypes={changeSize:PropTypes.func,quickGo:PropTypes.func,selectComponentClass:PropTypes.func,current:PropTypes.number,pageSizeOptions:PropTypes.arrayOf(PropTypes.string),pageSize:PropTypes.number,buildOptionText:PropTypes.func,locale:PropTypes.object,getPopupContainer:PropTypes.func},Options.defaultProps={pageSizeOptions:["10","20","30","40"],getPopupContainer:function(e){return e.parentNode}};export default Options;