"use strict";var _interopRequireWildcard=require("@babel/runtime/helpers/interopRequireWildcard"),_interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=void 0;var _classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")),_createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass")),_assertThisInitialized2=_interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized")),_inherits2=_interopRequireDefault(require("@babel/runtime/helpers/inherits")),_possibleConstructorReturn2=_interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")),_getPrototypeOf2=_interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")),_defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty")),React=_interopRequireWildcard(require("react")),_classnames=_interopRequireDefault(require("classnames")),_propTypes=_interopRequireDefault(require("prop-types")),_rcPagination=_interopRequireDefault(require("rc-pagination")),_en_US=_interopRequireDefault(require("rc-pagination/lib/locale/en_US")),_withStyles=_interopRequireDefault(require("../../hoc/withStyles")),_ErrorBoundary=_interopRequireDefault(require("../../hoc/ErrorBoundary")),_styles=_interopRequireDefault(require("./styles"));function _createSuper(Derived){var hasNativeReflectConstruct=_isNativeReflectConstruct();return function(){var result,Super=(0,_getPrototypeOf2["default"])(Derived);if(hasNativeReflectConstruct){var NewTarget=(0,_getPrototypeOf2["default"])(this).constructor;result=Reflect.construct(Super,arguments,NewTarget)}else result=Super.apply(this,arguments);return(0,_possibleConstructorReturn2["default"])(this,result)}}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(e){return!1}}var Pagination=/*#__PURE__*/function(_React$Component){function Pagination(props){var _this;return(0,_classCallCheck2["default"])(this,Pagination),_this=_super.call(this,props),(0,_defineProperty2["default"])((0,_assertThisInitialized2["default"])(_this),"onChange",function(page){_this.setState({current:page}),_this.props.onPageChange&&_this.props.onPageChange(page)}),(0,_defineProperty2["default"])((0,_assertThisInitialized2["default"])(_this),"itemRender",function(current,type,element){var classes=_this.props.classes;return"page"===type?/*#__PURE__*/React.createElement("div",{className:(0,_classnames["default"])(classes.page,current===_this.state.current&&"active")},current):"jump-prev"===type?/*#__PURE__*/React.createElement("div",{className:classes.page},"..."):"jump-next"===type?/*#__PURE__*/React.createElement("div",{className:classes.page},"..."):"prev"===type?/*#__PURE__*/React.createElement("div",{className:(0,_classnames["default"])(classes.page,classes.prevBtn)},"Prev"):"next"===type?/*#__PURE__*/React.createElement("div",{className:(0,_classnames["default"])(classes.page,classes.nextBtn)},"Next"):element}),_this.state={current:props.current||1},_this}(0,_inherits2["default"])(Pagination,_React$Component);var _super=_createSuper(Pagination);return(0,_createClass2["default"])(Pagination,[{key:"componentDidUpdate",value:function componentDidUpdate(prevProps){this.props.current!==prevProps.current&&this.setState({current:this.props.current})}},{key:"render",value:function render(){var _this$props=this.props,classes=_this$props.classes,total=_this$props.total,pageSize=_this$props.pageSize,current=this.state.current,startItem=(current-1)*pageSize,endItem=startItem+pageSize;return/*#__PURE__*/React.createElement(_ErrorBoundary["default"],null,/*#__PURE__*/React.createElement("div",{className:classes.component},/*#__PURE__*/React.createElement(_rcPagination["default"],{locale:_en_US["default"],onChange:this.onChange,current:this.state.current,total:total,pageSize:pageSize,itemRender:this.itemRender,showLessItems:!0}),/*#__PURE__*/React.createElement("div",{className:classes.numberWrapper},startItem+1,"-",endItem>total?total:endItem," 0f ",total)))}}]),Pagination}(React.Component);(0,_defineProperty2["default"])(Pagination,"propTypes",{current:_propTypes["default"].number,pageSize:_propTypes["default"].number,total:_propTypes["default"].number.isRequired,onPageChange:_propTypes["default"].func,classes:_propTypes["default"].object// will come from withStyles HOC
}),(0,_defineProperty2["default"])(Pagination,"defaultProps",{pageSize:10,onPageChange:function onPageChange(){},current:1});var _default=(0,_withStyles["default"])(_styles["default"])(Pagination);exports["default"]=_default;