1 | this["react-paginating"]=this["react-paginating"]||{},this["react-paginating"].umd=this["react-paginating"].umd||{},this["react-paginating"].umd.min=function(e,t){"use strict";var r="default"in e?e.default:e;function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function a(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function o(e){return(o=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function i(e,t){return(i=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function u(e,t){if(null==e)return{};var r,n,a=function(e,t){if(null==e)return{};var r,n,a={},o=Object.keys(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||(a[r]=e[r]);return a}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}function c(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function s(e){return function(e){if(Array.isArray(e)){for(var t=0,r=new Array(e.length);t<e.length;t++)r[t]=e[t];return r}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}t=t&&t.hasOwnProperty("default")?t.default:t;var l=function(t){function l(){var e,t,r;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,l),t=this,r=o(l).call(this),e=!r||"object"!=typeof r&&"function"!=typeof r?c(t):r,a(c(c(e)),"_getPageItemProps",function(t){var r=t.pageValue,n=t.onPageChange;return function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){a(e,t,r[t])})}return e}({onClick:function(t){"function"==typeof n&&n(r,t),e.setState({currentPage:r})}},u(t,["pageValue","onPageChange"]))}),e.state={currentPage:0},e}var p,g,f;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&i(e,t)}(l,e.Component),p=l,(g=[{key:"componentWillMount",value:function(){this.props.currentPage&&this.setState({currentPage:parseInt(this.props.currentPage,10)})}},{key:"componentWillReceiveProps",value:function(e){e.currentPage!==this.props.currentPage&&this.setState({currentPage:parseInt(e.currentPage,10)})}},{key:"render",value:function(){var e,t=this.props,n=t.total,a=t.limit,o=t.pageCount,i=this.state.currentPage,u=function(e){var t=e.limit,r=e.pageCount,n=e.total,a=e.page,o=Math.ceil(n/t),i=parseInt(n,10),u=parseInt(a,10);u<1&&(u=1),u>o&&(u=o);var c=Math.max(1,u-Math.floor(r/2)),s=Math.min(o,u+Math.floor(r/2));s-c+1<r&&(u<o/2?s=Math.min(o,s+(r-(s-c))):c=Math.max(1,c-(r-(s-c)))),s-c+1>r&&(u>o/2?c++:s--);var l=t*(u-1),p=t*u-1;return{totalPages:o,pages:Math.min(s-c+1,o),currentPage:u,firstPage:c,lastPage:s,previousPage:u-1,nextPage:u+1,hasPreviousPage:u>1,hasNextPage:u<o,totalResults:i,results:Math.min(p-l+1,i),firstResult:l,lastResult:p}}({limit:a,pageCount:o,total:n,page:i}),c=u.firstPage,l=u.lastPage,p=u.hasNextPage,g=u.hasPreviousPage,f=u.previousPage,P=u.nextPage,h=u.totalPages,b=n?(e=c,s(Array(l-e+1)).map(function(t,r){return e+r})):[];return r.createElement("div",null,this.props.children({pages:b,previousPage:f,nextPage:P,totalPages:h,currentPage:i,hasNextPage:p,hasPreviousPage:g,getPageItemProps:this._getPageItemProps}))}}])&&n(p.prototype,g),f&&n(p,f),l}();return l.propTypes={total:t.number.isRequired,limit:t.number,pageCount:t.number,currentPage:t.number,pageValue:t.number,children:t.func.isRequired,onPageChange:t.func},l.defaultProps={limit:10,pageCount:5,currentPage:0,pageValue:0},l}(React,PropTypes);
|