material-ui-arrowy-pagination
Version:
An easy to use and customizable pagination component for Material-UI.
6 lines • 19.6 kB
JavaScript
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("material-ui/Button"),require("material-ui/IconButton"),require("material-ui/Icon")):"function"==typeof define&&define.amd?define(["react","material-ui/Button","material-ui/IconButton","material-ui/Icon"],t):"object"==typeof exports?exports["react-component-dev"]=t(require("react"),require("material-ui/Button"),require("material-ui/IconButton"),require("material-ui/Icon")):e["react-component-dev"]=t(e.React,e["material-ui/Button"],e["material-ui/IconButton"],e["material-ui/Icon"])}(this,function(e,t,n,r){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){e.exports=n(1)},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(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 i(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)}Object.defineProperty(t,"__esModule",{value:!0});var u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},l=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),s=n(2),c=r(s),f=n(3),p=r(f),d=n(13),y=(r(d),n(14)),v=r(y),h=n(15),b=r(h),m={width:"36px",height:"36px"},g={fontSize:"16px",cursor:"pointer"},P=function(e){var t=e.total,n=e.current,r=e.display,o=t,a=1;if(r<o){var i=Math.floor(r/2),u=i;r%2===0&&(i-=1),n<=i+1?o=r:n>=t-u?a=t-r+1:(a=n-i,o=n+u)}return{end:o,start:a}},w=function(e){var t=e.total,n=e.current,r=e.display;return t=t>0?t:1,n=n>0?n:1,r=r>0?r:1,n=n<t?n:t,r=r<t?r:t,{current:n,display:r,total:t}},E=function(e){var t=e.pageNumber,n=e.isActive,r=e.onClick,o=e.styleButton,a=e.stylePrimary;return o?c.default.createElement("div",{style:n?a:o,onClick:r},c.default.createElement("label",{style:g},t)):c.default.createElement(v.default,{style:m,onClick:r,"aria-label":"page-"+t,color:n?"primary":"default"},c.default.createElement("label",{style:g},t))};E.propTypes={value:p.default.number,isActive:p.default.bool,onClick:p.default.func,styleButton:p.default.object,stylePrimary:p.default.object};var O=function(e){var t=e.onClick,n=e.styleFirstPageButton,r=e.disabled;return n?c.default.createElement("div",{style:n,onClick:t,disabled:r}):c.default.createElement(v.default,{style:m,onClick:t,disabled:r,"aria-label":"FirstPage"},c.default.createElement(b.default,null,"first_page"))};O.propTypes={onClick:p.default.func,styleFirstPageButton:p.default.object,disabled:p.default.bool};var x=function(e){var t=e.onClick,n=e.stylePreviousPageButton,r=e.disabled;return n?c.default.createElement("div",{style:n,onClick:t,disabled:r}):c.default.createElement(v.default,{style:m,onClick:t,disabled:r,"aria-label":"FirstPage"},c.default.createElement(b.default,null,"navigate_before"))};x.propTypes={onClick:p.default.func,styleFirstPageButton:p.default.object,disabled:p.default.bool};var k=function(e){var t=e.onClick,n=e.styleNextPageButton,r=e.disabled;return n?c.default.createElement("div",{style:n,onClick:t,disabled:r}):c.default.createElement(v.default,{style:m,onClick:t,disabled:r,"aria-label":"NextPage"},c.default.createElement(b.default,null,"navigate_next"))};k.propTypes={onClick:p.default.func,styleFirstPageButton:p.default.object,disabled:p.default.bool};var j=function(e){var t=e.onClick,n=e.styleLastPageButton,r=e.disabled;return n?c.default.createElement("div",{style:n,onClick:t,disabled:r}):c.default.createElement(v.default,{style:m,onClick:t,disabled:r,"aria-label":"LastPage"},c.default.createElement(b.default,null,"last_page"))};j.propTypes={onClick:p.default.func,styleLastPageButton:p.default.object,disabled:p.default.bool};var T=function(e){function t(e){o(this,t);var n=a(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e)),r=w(e);return n.setCurrent=n.setCurrent.bind(n),n.handleClickPreviousPage=n.handleClickPreviousPage.bind(n),n.handleClickNextPage=n.handleClickNextPage.bind(n),n.state=u({},r,P(r)),n}return i(t,e),l(t,[{key:"componentWillReceiveProps",value:function(e){var t=w(e);this.setState(u({},t,P(t)))}},{key:"setCurrent",value:function(e){var t=u({},this.state,{current:e});this.props.onChange(e,this.state.current),this.setState(u({},t,P(t)))}},{key:"handleClickPreviousPage",value:function(){this.state.current>1&&this.setCurrent(this.state.current-1)}},{key:"handleClickNextPage",value:function(){this.state.current<this.state.total&&this.setCurrent(this.state.current+1)}},{key:"render",value:function(){for(var e=this,t=[],n=this.state.start;n<=this.state.end;n+=1)t.push(n);return c.default.createElement("div",{className:this.props.className,style:u({},this.props.styleRoot,this.props.style)},this.props.showFirstPageButton&&c.default.createElement(O,{onClick:function(){return e.setCurrent(1)},styleFirstPageButton:this.props.styleFirstPageButton,disabled:1===this.state.current}),this.props.showPreviousPageButton&&c.default.createElement(x,{onClick:this.handleClickPreviousPage,stylePreviousPageButton:this.props.styleFirstPageButton,disabled:1===this.state.current}),this.props.showPageNumberButton&&t.map(function(t,n){return c.default.createElement(E,{key:n,pageNumber:t,isActive:e.state.current===t,onClick:function(){return e.setCurrent(t)},styleButton:e.props.styleButton,stylePrimary:e.props.stylePrimary})}),this.props.showNextPageButton&&c.default.createElement(k,{onClick:this.handleClickNextPage,styleNextPageButton:this.props.styleFirstPageButton,disabled:this.state.current===this.state.total}),this.props.showLastPageButton&&c.default.createElement(j,{onClick:function(){return e.setCurrent(e.state.total)},styleLastPageButton:this.props.styleLastPageButton,disabled:this.state.current===this.state.total}))}}]),t}(c.default.Component);T.propTypes={total:p.default.number,current:p.default.number,display:p.default.number,onChange:p.default.func.isRequired,className:p.default.string,style:p.default.object,styleRoot:p.default.object,styleFirstPageButton:p.default.object,stylePreviousPageButton:p.default.object,styleNextPageButton:p.default.object,styleLastPageButton:p.default.object,styleButton:p.default.object,stylePrimary:p.default.object,showFirstPageButton:p.default.bool,showPreviousPageButton:p.default.bool,showPageNumberButton:p.default.bool,showNextPageButton:p.default.bool,showLastPageButton:p.default.bool},T.defaultProps={styleRoot:null,styleFirstPageButton:null,stylePreviousPageButton:null,styleNextPageButton:null,styleLastPageButton:null,styleButton:null,stylePrimary:null,showFirstPageButton:!1,showPreviousPageButton:!1,showPageNumberButton:!0,showNextPageButton:!1,showLastPageButton:!1},T.displayName="Pagination",t.default=T},function(t,n){t.exports=e},function(e,t,n){(function(t){if("production"!==t.env.NODE_ENV){var r="function"==typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,o=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===r},a=!0;e.exports=n(5)(o,a)}else e.exports=n(12)()}).call(t,n(4))},function(e,t){function n(){throw new Error("setTimeout has not been defined")}function r(){throw new Error("clearTimeout has not been defined")}function o(e){if(c===setTimeout)return setTimeout(e,0);if((c===n||!c)&&setTimeout)return c=setTimeout,setTimeout(e,0);try{return c(e,0)}catch(t){try{return c.call(null,e,0)}catch(t){return c.call(this,e,0)}}}function a(e){if(f===clearTimeout)return clearTimeout(e);if((f===r||!f)&&clearTimeout)return f=clearTimeout,clearTimeout(e);try{return f(e)}catch(t){try{return f.call(null,e)}catch(t){return f.call(this,e)}}}function i(){v&&d&&(v=!1,d.length?y=d.concat(y):h=-1,y.length&&u())}function u(){if(!v){var e=o(i);v=!0;for(var t=y.length;t;){for(d=y,y=[];++h<t;)d&&d[h].run();h=-1,t=y.length}d=null,v=!1,a(e)}}function l(e,t){this.fun=e,this.array=t}function s(){}var c,f,p=e.exports={};!function(){try{c="function"==typeof setTimeout?setTimeout:n}catch(e){c=n}try{f="function"==typeof clearTimeout?clearTimeout:r}catch(e){f=r}}();var d,y=[],v=!1,h=-1;p.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];y.push(new l(e,t)),1!==y.length||v||o(u)},l.prototype.run=function(){this.fun.apply(null,this.array)},p.title="browser",p.browser=!0,p.env={},p.argv=[],p.version="",p.versions={},p.on=s,p.addListener=s,p.once=s,p.off=s,p.removeListener=s,p.removeAllListeners=s,p.emit=s,p.prependListener=s,p.prependOnceListener=s,p.listeners=function(e){return[]},p.binding=function(e){throw new Error("process.binding is not supported")},p.cwd=function(){return"/"},p.chdir=function(e){throw new Error("process.chdir is not supported")},p.umask=function(){return 0}},function(e,t,n){(function(t){"use strict";var r=n(6),o=n(7),a=n(8),i=n(9),u=n(10),l=n(11);e.exports=function(e,n){function s(e){var t=e&&(N&&e[N]||e[_]);if("function"==typeof t)return t}function c(e,t){return e===t?0!==e||1/e===1/t:e!==e&&t!==t}function f(e){this.message=e,this.stack=""}function p(e){function r(r,s,c,p,d,y,v){if(p=p||R,y=y||c,v!==u)if(n)o(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");else if("production"!==t.env.NODE_ENV&&"undefined"!=typeof console){var h=p+":"+c;!i[h]&&l<3&&(a(!1,"You are manually calling a React.PropTypes validation function for the `%s` prop on `%s`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details.",y,p),i[h]=!0,l++)}return null==s[c]?r?new f(null===s[c]?"The "+d+" `"+y+"` is marked as required "+("in `"+p+"`, but its value is `null`."):"The "+d+" `"+y+"` is marked as required in "+("`"+p+"`, but its value is `undefined`.")):null:e(s,c,p,d,y)}if("production"!==t.env.NODE_ENV)var i={},l=0;var s=r.bind(null,!1);return s.isRequired=r.bind(null,!0),s}function d(e){function t(t,n,r,o,a,i){var u=t[n],l=j(u);if(l!==e){var s=T(u);return new f("Invalid "+o+" `"+a+"` of type "+("`"+s+"` supplied to `"+r+"`, expected ")+("`"+e+"`."))}return null}return p(t)}function y(){return p(r.thatReturnsNull)}function v(e){function t(t,n,r,o,a){if("function"!=typeof e)return new f("Property `"+a+"` of component `"+r+"` has invalid PropType notation inside arrayOf.");var i=t[n];if(!Array.isArray(i)){var l=j(i);return new f("Invalid "+o+" `"+a+"` of type "+("`"+l+"` supplied to `"+r+"`, expected an array."))}for(var s=0;s<i.length;s++){var c=e(i,s,r,o,a+"["+s+"]",u);if(c instanceof Error)return c}return null}return p(t)}function h(){function t(t,n,r,o,a){var i=t[n];if(!e(i)){var u=j(i);return new f("Invalid "+o+" `"+a+"` of type "+("`"+u+"` supplied to `"+r+"`, expected a single ReactElement."))}return null}return p(t)}function b(e){function t(t,n,r,o,a){if(!(t[n]instanceof e)){var i=e.name||R,u=C(t[n]);return new f("Invalid "+o+" `"+a+"` of type "+("`"+u+"` supplied to `"+r+"`, expected ")+("instance of `"+i+"`."))}return null}return p(t)}function m(e){function n(t,n,r,o,a){for(var i=t[n],u=0;u<e.length;u++)if(c(i,e[u]))return null;var l=JSON.stringify(e);return new f("Invalid "+o+" `"+a+"` of value `"+i+"` "+("supplied to `"+r+"`, expected one of "+l+"."))}return Array.isArray(e)?p(n):("production"!==t.env.NODE_ENV?a(!1,"Invalid argument supplied to oneOf, expected an instance of array."):void 0,r.thatReturnsNull)}function g(e){function t(t,n,r,o,a){if("function"!=typeof e)return new f("Property `"+a+"` of component `"+r+"` has invalid PropType notation inside objectOf.");var i=t[n],l=j(i);if("object"!==l)return new f("Invalid "+o+" `"+a+"` of type "+("`"+l+"` supplied to `"+r+"`, expected an object."));for(var s in i)if(i.hasOwnProperty(s)){var c=e(i,s,r,o,a+"."+s,u);if(c instanceof Error)return c}return null}return p(t)}function P(e){function n(t,n,r,o,a){for(var i=0;i<e.length;i++){var l=e[i];if(null==l(t,n,r,o,a,u))return null}return new f("Invalid "+o+" `"+a+"` supplied to "+("`"+r+"`."))}if(!Array.isArray(e))return"production"!==t.env.NODE_ENV?a(!1,"Invalid argument supplied to oneOfType, expected an instance of array."):void 0,r.thatReturnsNull;for(var o=0;o<e.length;o++){var i=e[o];if("function"!=typeof i)return a(!1,"Invalid argument supplied to oneOfType. Expected an array of check functions, but received %s at index %s.",B(i),o),r.thatReturnsNull}return p(n)}function w(){function e(e,t,n,r,o){return x(e[t])?null:new f("Invalid "+r+" `"+o+"` supplied to "+("`"+n+"`, expected a ReactNode."))}return p(e)}function E(e){function t(t,n,r,o,a){var i=t[n],l=j(i);if("object"!==l)return new f("Invalid "+o+" `"+a+"` of type `"+l+"` "+("supplied to `"+r+"`, expected `object`."));for(var s in e){var c=e[s];if(c){var p=c(i,s,r,o,a+"."+s,u);if(p)return p}}return null}return p(t)}function O(e){function t(t,n,r,o,a){var l=t[n],s=j(l);if("object"!==s)return new f("Invalid "+o+" `"+a+"` of type `"+s+"` "+("supplied to `"+r+"`, expected `object`."));var c=i({},t[n],e);for(var p in c){var d=e[p];if(!d)return new f("Invalid "+o+" `"+a+"` key `"+p+"` supplied to `"+r+"`.\nBad object: "+JSON.stringify(t[n],null," ")+"\nValid keys: "+JSON.stringify(Object.keys(e),null," "));var y=d(l,p,r,o,a+"."+p,u);if(y)return y}return null}return p(t)}function x(t){switch(typeof t){case"number":case"string":case"undefined":return!0;case"boolean":return!t;case"object":if(Array.isArray(t))return t.every(x);if(null===t||e(t))return!0;var n=s(t);if(!n)return!1;var r,o=n.call(t);if(n!==t.entries){for(;!(r=o.next()).done;)if(!x(r.value))return!1}else for(;!(r=o.next()).done;){var a=r.value;if(a&&!x(a[1]))return!1}return!0;default:return!1}}function k(e,t){return"symbol"===e||("Symbol"===t["@@toStringTag"]||"function"==typeof Symbol&&t instanceof Symbol)}function j(e){var t=typeof e;return Array.isArray(e)?"array":e instanceof RegExp?"object":k(t,e)?"symbol":t}function T(e){if("undefined"==typeof e||null===e)return""+e;var t=j(e);if("object"===t){if(e instanceof Date)return"date";if(e instanceof RegExp)return"regexp"}return t}function B(e){var t=T(e);switch(t){case"array":case"object":return"an "+t;case"boolean":case"date":case"regexp":return"a "+t;default:return t}}function C(e){return e.constructor&&e.constructor.name?e.constructor.name:R}var N="function"==typeof Symbol&&Symbol.iterator,_="@@iterator",R="<<anonymous>>",I={array:d("array"),bool:d("boolean"),func:d("function"),number:d("number"),object:d("object"),string:d("string"),symbol:d("symbol"),any:y(),arrayOf:v,element:h(),instanceOf:b,node:w(),objectOf:g,oneOf:m,oneOfType:P,shape:E,exact:O};return f.prototype=Error.prototype,I.checkPropTypes=l,I.PropTypes=I,I}}).call(t,n(4))},function(e,t){"use strict";function n(e){return function(){return e}}var r=function(){};r.thatReturns=n,r.thatReturnsFalse=n(!1),r.thatReturnsTrue=n(!0),r.thatReturnsNull=n(null),r.thatReturnsThis=function(){return this},r.thatReturnsArgument=function(e){return e},e.exports=r},function(e,t,n){(function(t){"use strict";function n(e,t,n,o,a,i,u,l){if(r(t),!e){var s;if(void 0===t)s=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var c=[n,o,a,i,u,l],f=0;s=new Error(t.replace(/%s/g,function(){return c[f++]})),s.name="Invariant Violation"}throw s.framesToPop=1,s}}var r=function(e){};"production"!==t.env.NODE_ENV&&(r=function(e){if(void 0===e)throw new Error("invariant requires an error message argument")}),e.exports=n}).call(t,n(4))},function(e,t,n){(function(t){"use strict";var r=n(6),o=r;if("production"!==t.env.NODE_ENV){var a=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];var o=0,a="Warning: "+e.replace(/%s/g,function(){return n[o++]});"undefined"!=typeof console&&console.error(a);try{throw new Error(a)}catch(e){}};o=function(e,t){if(void 0===t)throw new Error("`warning(condition, format, ...args)` requires a warning message argument");if(0!==t.indexOf("Failed Composite propType: ")&&!e){for(var n=arguments.length,r=Array(n>2?n-2:0),o=2;o<n;o++)r[o-2]=arguments[o];a.apply(void 0,[t].concat(r))}}}e.exports=o}).call(t,n(4))},function(e,t){/*
object-assign
(c) Sindre Sorhus
@license MIT
*/
;function n(e){if(null===e||void 0===e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}function r(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;var r=Object.getOwnPropertyNames(t).map(function(e){return t[e]});if("0123456789"!==r.join(""))return!1;var o={};return"abcdefghijklmnopqrst".split("").forEach(function(e){o[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},o)).join("")}catch(e){return!1}}var o=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable;e.exports=r()?Object.assign:function(e,t){for(var r,u,l=n(e),s=1;s<arguments.length;s++){r=Object(arguments[s]);for(var c in r)a.call(r,c)&&(l[c]=r[c]);if(o){u=o(r);for(var f=0;f<u.length;f++)i.call(r,u[f])&&(l[u[f]]=r[u[f]])}}return l}},function(e,t){"use strict";var n="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";e.exports=n},function(e,t,n){(function(t){"use strict";function r(e,n,r,l,s){if("production"!==t.env.NODE_ENV)for(var c in e)if(e.hasOwnProperty(c)){var f;try{o("function"==typeof e[c],"%s: %s type `%s` is invalid; it must be a function, usually from the `prop-types` package, but received `%s`.",l||"React class",r,c,typeof e[c]),f=e[c](n,c,l,r,null,i)}catch(e){f=e}if(a(!f||f instanceof Error,"%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",l||"React class",r,c,typeof f),f instanceof Error&&!(f.message in u)){u[f.message]=!0;var p=s?s():"";a(!1,"Failed %s type: %s%s",r,f.message,null!=p?p:"")}}}if("production"!==t.env.NODE_ENV)var o=n(7),a=n(8),i=n(10),u={};e.exports=r}).call(t,n(4))},function(e,t,n){"use strict";var r=n(6),o=n(7),a=n(10);e.exports=function(){function e(e,t,n,r,i,u){u!==a&&o(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types")}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t};return n.checkPropTypes=r,n.PropTypes=n,n}},function(e,n){e.exports=t},function(e,t){e.exports=n},function(e,t){e.exports=r}])});