"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _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),_KeyCode=require("./KeyCode"),_KeyCode2=_interopRequireDefault(_KeyCode);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 Options=function(e){function t(e){(0,_classCallCheck3.default)(this,t);var r=(0,_possibleConstructorReturn3.default)(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return r.buildOptionText=function(e){return e+" "+r.props.locale.items_per_page},r.changeSize=function(e){"function"==typeof r.props.changeSize&&r.props.changeSize(Number(e))},r.handleChange=function(e){r.setState({goInputText:e.target.value})},r.go=function(e){var t=r.state.goInputText;""!==t&&(t=isNaN(t)?r.props.current:Number(t),e.keyCode!==_KeyCode2.default.ENTER&&"click"!==e.type||(r.setState({goInputText:""}),"function"==typeof r.props.quickGo&&r.props.quickGo(t)))},r.state={goInputText:""},r}return(0,_inherits3.default)(t,e),(0,_createClass3.default)(t,[{key:"render",value:function(){var e=this.props,t=this.state,r=e.locale,o=e.rootPrefixCls+"-options",n=e.changeSize,i=e.quickGo,p=e.goButton,a=e.buildOptionText||this.buildOptionText,s=e.selectComponentClass,u=null,l=null,c=null;if(!n&&!i)return null;if(n&&s){var f=s.Option,_=e.pageSize||e.pageSizeOptions[0],h=e.pageSizeOptions.map(function(e,t){return React.createElement(f,{key:t,value:e},a(e))});u=React.createElement(s,{prefixCls:e.selectPrefixCls,showSearch:!1,className:o+"-size-changer",optionLabelProp:"children",dropdownMatchSelectWidth:!1,value:_.toString(),onChange:this.changeSize,getPopupContainer:e.getPopupContainer},h)}return i&&(p&&(c="boolean"==typeof p?React.createElement("button",{type:"button",onClick:this.go,onKeyUp:this.go},r.jump_to_confirm):React.createElement("span",{onClick:this.go,onKeyUp:this.go},p)),l=React.createElement("div",{className:o+"-quick-jumper"},r.jump_to,React.createElement("input",{type:"text",value:t.goInputText,onChange:this.handleChange,onKeyUp:this.go}),r.page,c)),React.createElement("li",{className:o},u,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}},exports.default=Options,module.exports=exports.default;