From c3347e3e1de5c538ae9082041fc60355941d187d Mon Sep 17 00:00:00 2001 From: Patrick Nwakwoke Date: Tue, 21 Jan 2020 14:08:37 +0100 Subject: [PATCH] Chore: Reduce bundle size --- .gitignore | 4 +++- dist/index.js | 2 +- package-lock.json | 46 +++++++++++++++++++++++++++++++++++++++++++- package.json | 6 ++++-- src/lib/paginator.js | 32 +++++++++++++++--------------- webpack.config.js | 11 +++++++++-- 6 files changed, 78 insertions(+), 23 deletions(-) diff --git a/.gitignore b/.gitignore index dc0db97..e09d1b1 100644 --- a/.gitignore +++ b/.gitignore @@ -28,4 +28,6 @@ yarn-error.log* #all src files except lib src/* !src/lib -!src/__tests__ \ No newline at end of file +!src/__tests__ + +stats.json \ No newline at end of file diff --git a/dist/index.js b/dist/index.js index add70df..4ca68a3 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1 +1 @@ -module.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="/dist/",r(r.s=9)}([function(e,t,r){e.exports=r(2)()},function(e,t){e.exports=require("react")},function(e,t,r){"use strict";var n=r(3);function o(){}function a(){}a.resetWarningCache=o,e.exports=function(){function e(e,t,r,o,a,i){if(i!==n){var s=new Error("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");throw s.name="Invariant Violation",s}}function t(){return e}e.isRequired=e;var r={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:a,resetWarningCache:o};return r.PropTypes=r,r}},function(e,t,r){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},function(e,t,r){var n=r(5);"string"==typeof n&&(n=[[e.i,n,""]]);var o={hmr:!0,transform:void 0,insertInto:void 0};r(7)(n,o);n.locals&&(e.exports=n.locals)},function(e,t,r){(e.exports=r(6)(!1)).push([e.i,".react-hooks-paginator{align-items:center;display:flex;justify-content:center;margin:1rem 0}.react-hooks-paginator .page-item{list-style:none}.react-hooks-paginator .page-item:first-child .page-link{margin-left:0;border-top-left-radius:3px;border-bottom-left-radius:3px}.react-hooks-paginator .page-item:last-child .page-link{border-top-right-radius:3px;border-bottom-right-radius:3px}.react-hooks-paginator .page-item:hover .page-link,.react-hooks-paginator .page-item.active .page-link{background-color:#3895d3;border-color:#3895d3;color:#fff}.react-hooks-paginator .page-link{border:1px solid #dee2e6;color:#4a4a4a;margin-left:-1px;outline:none;padding:0.5rem 0.75rem;text-decoration:none;transition:all 0.2s}\n",""])},function(e,t,r){"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map(function(t){var r=function(e,t){var r=e[1]||"",n=e[3];if(!n)return r;if(t&&"function"==typeof btoa){var o=(i=n,"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(i))))+" */"),a=n.sources.map(function(e){return"/*# sourceURL="+n.sourceRoot+e+" */"});return[r].concat(a).concat([o]).join("\n")}var i;return[r].join("\n")}(t,e);return t[2]?"@media "+t[2]+"{"+r+"}":r}).join("")},t.i=function(e,r){"string"==typeof e&&(e=[[null,e,""]]);for(var n={},o=0;o=0&&l.splice(t,1)}function m(e){var t=document.createElement("style");if(void 0===e.attrs.type&&(e.attrs.type="text/css"),void 0===e.attrs.nonce){var n=function(){0;return r.nc}();n&&(e.attrs.nonce=n)}return v(t,e.attrs),d(e,t),t}function v(e,t){Object.keys(t).forEach(function(r){e.setAttribute(r,t[r])})}function h(e,t){var r,n,o,a;if(t.transform&&e.css){if(!(a="function"==typeof t.transform?t.transform(e.css):t.transform.default(e.css)))return function(){};e.css=a}if(t.singleton){var i=u++;r=c||(c=m(t)),n=x.bind(null,r,i,!1),o=x.bind(null,r,i,!0)}else e.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(r=function(e){var t=document.createElement("link");return void 0===e.attrs.type&&(e.attrs.type="text/css"),e.attrs.rel="stylesheet",v(t,e.attrs),d(e,t),t}(t),n=function(e,t,r){var n=r.css,o=r.sourceMap,a=void 0===t.convertToAbsoluteUrls&&o;(t.convertToAbsoluteUrls||a)&&(n=f(n));o&&(n+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(o))))+" */");var i=new Blob([n],{type:"text/css"}),s=e.href;e.href=URL.createObjectURL(i),s&&URL.revokeObjectURL(s)}.bind(null,r,t),o=function(){b(r),r.href&&URL.revokeObjectURL(r.href)}):(r=m(t),n=function(e,t){var r=t.css,n=t.media;n&&e.setAttribute("media",n);if(e.styleSheet)e.styleSheet.cssText=r;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(r))}}.bind(null,r),o=function(){b(r)});return n(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;n(e=t)}else o()}}e.exports=function(e,t){if("undefined"!=typeof DEBUG&&DEBUG&&"object"!=typeof document)throw new Error("The style-loader cannot be used in a non-browser environment");(t=t||{}).attrs="object"==typeof t.attrs?t.attrs:{},t.singleton||"boolean"==typeof t.singleton||(t.singleton=i()),t.insertInto||(t.insertInto="head"),t.insertAt||(t.insertAt="bottom");var r=g(e,t);return p(r,t),function(e){for(var n=[],o=0;o2&&void 0!==arguments[2]?arguments[2]:1,n=e,o=[];n<=t;)o.push(n),n+=r;return o};function d(e){var t=l(Object(n.useState)(function(){return t=e.totalRecords,r=void 0===t?null:t,n=e.pageLimit,o=void 0===n?20:n,a=e.pageNeighbours,{pageLimit:o="number"==typeof o?o:20,totalRecords:r="number"==typeof r?r:0,pageNeighbours:i="number"==typeof(i=void 0===a?0:a)?Math.max(0,Math.min(i,2)):0,totalPages:Math.ceil(r/o)};var t,r,n,o,a,i}),2),r=t[0],a=t[1],i=Object(n.useRef)(!0),d=Object(n.useCallback)(function(t){var n=Math.max(1,Math.min(t,r.totalPages));e.setCurrentPage(n)},[r.totalPages,e.pageLimit]);Object(n.useEffect)(function(){d(1)},[d]),Object(n.useEffect)(function(){e.setOffset((e.currentPage-1)*e.pageLimit)},[e.currentPage]),Object(n.useEffect)(function(){if(i.current)i.current=!1;else{var t=e.totalRecords,n=Math.ceil(t/r.pageLimit);a(function(e){for(var t=1;ta+2){var i=[],c=n-o,u=n+o,l=t-1,d=c>2?c:2,b=u2,h=b=0&&l.splice(t,1)}function m(e){var t=document.createElement("style");if(void 0===e.attrs.type&&(e.attrs.type="text/css"),void 0===e.attrs.nonce){var n=function(){0;return r.nc}();n&&(e.attrs.nonce=n)}return v(t,e.attrs),d(e,t),t}function v(e,t){Object.keys(t).forEach(function(r){e.setAttribute(r,t[r])})}function h(e,t){var r,n,o,a;if(t.transform&&e.css){if(!(a="function"==typeof t.transform?t.transform(e.css):t.transform.default(e.css)))return function(){};e.css=a}if(t.singleton){var i=u++;r=c||(c=m(t)),n=j.bind(null,r,i,!1),o=j.bind(null,r,i,!0)}else e.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(r=function(e){var t=document.createElement("link");return void 0===e.attrs.type&&(e.attrs.type="text/css"),e.attrs.rel="stylesheet",v(t,e.attrs),d(e,t),t}(t),n=function(e,t,r){var n=r.css,o=r.sourceMap,a=void 0===t.convertToAbsoluteUrls&&o;(t.convertToAbsoluteUrls||a)&&(n=f(n));o&&(n+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(o))))+" */");var i=new Blob([n],{type:"text/css"}),s=e.href;e.href=URL.createObjectURL(i),s&&URL.revokeObjectURL(s)}.bind(null,r,t),o=function(){b(r),r.href&&URL.revokeObjectURL(r.href)}):(r=m(t),n=function(e,t){var r=t.css,n=t.media;n&&e.setAttribute("media",n);if(e.styleSheet)e.styleSheet.cssText=r;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(r))}}.bind(null,r),o=function(){b(r)});return n(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;n(e=t)}else o()}}e.exports=function(e,t){if("undefined"!=typeof DEBUG&&DEBUG&&"object"!=typeof document)throw new Error("The style-loader cannot be used in a non-browser environment");(t=t||{}).attrs="object"==typeof t.attrs?t.attrs:{},t.singleton||"boolean"==typeof t.singleton||(t.singleton=i()),t.insertInto||(t.insertInto="head"),t.insertAt||(t.insertAt="bottom");var r=g(e,t);return p(r,t),function(e){for(var n=[],o=0;o2&&void 0!==arguments[2]?arguments[2]:1,n=e,o=[];n<=t;)o.push(n),n+=r;return o};function g(e){var t=u(Object(n.useState)(function(){return t=e.totalRecords,r=void 0===t?null:t,n=e.pageLimit,o=void 0===n?20:n,a=e.pageNeighbours,{pageLimit:o="number"==typeof o?o:20,totalRecords:r="number"==typeof r?r:0,pageNeighbours:i="number"==typeof(i=void 0===a?0:a)?Math.max(0,Math.min(i,2)):0,totalPages:Math.ceil(r/o)};var t,r,n,o,a,i}),2),r=t[0],a=t[1],g=Object(n.useRef)(!0),d=Object(n.useCallback)(function(t){var n=Math.max(1,Math.min(t,r.totalPages));e.setCurrentPage(n)},[r.totalPages,e.pageLimit]);Object(n.useEffect)(function(){d(1)},[d]),Object(n.useEffect)(function(){e.setOffset((e.currentPage-1)*e.pageLimit)},[e.currentPage]),Object(n.useEffect)(function(){if(g.current)g.current=!1;else{var t=e.totalRecords,n=Math.ceil(t/r.pageLimit);a(function(e){for(var t=1;ta+2){var s=[],c=n-o,u=n+o,g=t-1,d=c>2?c:2,b=u2,h=b