2 lines
19 KiB
JavaScript
2 lines
19 KiB
JavaScript
this.primereact=this.primereact||{},this.primereact.paginator=function(e,t,n,r,o,a){"use strict";function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=s(t);function l(e){if(Array.isArray(e))return e}function p(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,a=[],s=!0,i=!1;try{for(n=n.call(e);!(s=(r=n.next()).done)&&(a.push(r.value),!t||a.length!==t);s=!0);}catch(e){i=!0,o=e}finally{try{s||null==n.return||n.return()}finally{if(i)throw o}}return a}}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function c(e,t){if(e){if("string"==typeof e)return u(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?u(e,t):void 0}}function f(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function h(e){return h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},h(e)}function g(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function d(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)}}function m(e,t,n){return t&&d(e.prototype,t),n&&d(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function y(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function v(e,t){return v=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},v(e,t)}function P(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}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&v(e,t)}function b(e,t){if(t&&("object"===h(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return y(e)}function k(e){return k=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},k(e)}function C(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function R(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}var w=function(e){P(s,e);var t,o,a=(t=s,o=R(),function(){var e,n=k(t);if(o){var r=k(this).constructor;e=Reflect.construct(n,arguments,r)}else e=n.apply(this,arguments);return b(this,e)});function s(){return g(this,s),a.apply(this,arguments)}return m(s,[{key:"render",value:function(){var e=n.classNames("p-paginator-first p-paginator-element p-link",{"p-disabled":this.props.disabled}),t="p-paginator-icon pi pi-angle-double-left",o=i.default.createElement("button",{type:"button",className:e,onClick:this.props.onClick,disabled:this.props.disabled},i.default.createElement("span",{className:t}),i.default.createElement(r.Ripple,null));return this.props.template?n.ObjectUtils.getJSXElement(this.props.template,{onClick:this.props.onClick,className:e,iconClassName:t,disabled:this.props.disabled,element:o,props:this.props}):o}}]),s}(t.Component);function O(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}C(w,"defaultProps",{disabled:!1,onClick:null,template:null});var E=function(e){P(s,e);var t,o,a=(t=s,o=O(),function(){var e,n=k(t);if(o){var r=k(this).constructor;e=Reflect.construct(n,arguments,r)}else e=n.apply(this,arguments);return b(this,e)});function s(){return g(this,s),a.apply(this,arguments)}return m(s,[{key:"render",value:function(){var e=n.classNames("p-paginator-next p-paginator-element p-link",{"p-disabled":this.props.disabled}),t="p-paginator-icon pi pi-angle-right",o=i.default.createElement("button",{type:"button",className:e,onClick:this.props.onClick,disabled:this.props.disabled},i.default.createElement("span",{className:t}),i.default.createElement(r.Ripple,null));return this.props.template?n.ObjectUtils.getJSXElement(this.props.template,{onClick:this.props.onClick,className:e,iconClassName:t,disabled:this.props.disabled,element:o,props:this.props}):o}}]),s}(t.Component);function N(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}C(E,"defaultProps",{disabled:!1,onClick:null,template:null});var j=function(e){P(s,e);var t,o,a=(t=s,o=N(),function(){var e,n=k(t);if(o){var r=k(this).constructor;e=Reflect.construct(n,arguments,r)}else e=n.apply(this,arguments);return b(this,e)});function s(){return g(this,s),a.apply(this,arguments)}return m(s,[{key:"render",value:function(){var e=n.classNames("p-paginator-prev p-paginator-element p-link",{"p-disabled":this.props.disabled}),t="p-paginator-icon pi pi-angle-left",o=i.default.createElement("button",{type:"button",className:e,onClick:this.props.onClick,disabled:this.props.disabled},i.default.createElement("span",{className:t}),i.default.createElement(r.Ripple,null));return this.props.template?n.ObjectUtils.getJSXElement(this.props.template,{onClick:this.props.onClick,className:e,iconClassName:t,disabled:this.props.disabled,element:o,props:this.props}):o}}]),s}(t.Component);function T(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}C(j,"defaultProps",{disabled:!1,onClick:null,template:null});var L=function(e){P(s,e);var t,o,a=(t=s,o=T(),function(){var e,n=k(t);if(o){var r=k(this).constructor;e=Reflect.construct(n,arguments,r)}else e=n.apply(this,arguments);return b(this,e)});function s(){return g(this,s),a.apply(this,arguments)}return m(s,[{key:"render",value:function(){var e=n.classNames("p-paginator-last p-paginator-element p-link",{"p-disabled":this.props.disabled}),t="p-paginator-icon pi pi-angle-double-right",o=i.default.createElement("button",{type:"button",className:e,onClick:this.props.onClick,disabled:this.props.disabled},i.default.createElement("span",{className:t}),i.default.createElement(r.Ripple,null));return this.props.template?n.ObjectUtils.getJSXElement(this.props.template,{onClick:this.props.onClick,className:e,iconClassName:t,disabled:this.props.disabled,element:o,props:this.props}):o}}]),s}(t.Component);function S(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}C(L,"defaultProps",{disabled:!1,onClick:null,template:null});var x=function(e){P(s,e);var t,o,a=(t=s,o=S(),function(){var e,n=k(t);if(o){var r=k(this).constructor;e=Reflect.construct(n,arguments,r)}else e=n.apply(this,arguments);return b(this,e)});function s(){return g(this,s),a.apply(this,arguments)}return m(s,[{key:"onPageLinkClick",value:function(e,t){this.props.onClick&&this.props.onClick({originalEvent:e,value:t}),e.preventDefault()}},{key:"render",value:function(){var e,t=this;if(this.props.value){var o=this.props.value[0],a=this.props.value[this.props.value.length-1];e=this.props.value.map((function(e,s){var l=n.classNames("p-paginator-page p-paginator-element p-link",{"p-paginator-page-start":e===o,"p-paginator-page-end":e===a,"p-highlight":e-1===t.props.page}),p=i.default.createElement("button",{type:"button",className:l,onClick:function(n){return t.onPageLinkClick(n,e)}},e,i.default.createElement(r.Ripple,null));if(t.props.template){var u={onClick:function(n){return t.onPageLinkClick(n,e)},className:l,view:{startPage:o-1,endPage:a-1},page:e-1,currentPage:t.props.page,totalPages:t.props.pageCount,element:p,props:t.props};p=n.ObjectUtils.getJSXElement(t.props.template,u)}return i.default.createElement(i.default.Fragment,{key:e},p)}))}return i.default.createElement("span",{className:"p-paginator-pages"},e)}}]),s}(t.Component);function B(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}C(x,"defaultProps",{value:null,page:null,rows:null,pageCount:null,links:null,template:null});var D=function(e){P(s,e);var t,r,a=(t=s,r=B(),function(){var e,n=k(t);if(r){var o=k(this).constructor;e=Reflect.construct(n,arguments,o)}else e=n.apply(this,arguments);return b(this,e)});function s(){return g(this,s),a.apply(this,arguments)}return m(s,[{key:"hasOptions",value:function(){return this.props.options&&this.props.options.length>0}},{key:"render",value:function(){var e=this.hasOptions(),t=e?this.props.options.map((function(e){return{label:String(e),value:e}})):[],r=e?i.default.createElement(o.Dropdown,{value:this.props.value,options:t,onChange:this.props.onChange,appendTo:this.props.appendTo,disabled:this.props.disabled}):null;return this.props.template?n.ObjectUtils.getJSXElement(this.props.template,{value:this.props.value,options:t,onChange:this.props.onChange,appendTo:this.props.appendTo,currentPage:this.props.page,totalPages:this.props.pageCount,totalRecords:this.props.totalRecords,disabled:this.props.disabled,element:r,props:this.props}):r}}]),s}(t.Component);function M(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function U(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?M(Object(n),!0).forEach((function(t){C(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):M(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function J(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}C(D,"defaultProps",{options:null,value:null,page:null,pageCount:null,totalRecords:0,appendTo:null,onChange:null,template:null,disabled:!1});var F=function(e){P(a,e);var t,r,o=(t=a,r=J(),function(){var e,n=k(t);if(r){var o=k(this).constructor;e=Reflect.construct(n,arguments,o)}else e=n.apply(this,arguments);return b(this,e)});function a(){return g(this,a),o.apply(this,arguments)}return m(a,[{key:"render",value:function(){var e={currentPage:this.props.page+1,totalPages:this.props.pageCount,first:Math.min(this.props.first+1,this.props.totalRecords),last:Math.min(this.props.first+this.props.rows,this.props.totalRecords),rows:this.props.rows,totalRecords:this.props.totalRecords},t=this.props.reportTemplate.replace("{currentPage}",e.currentPage).replace("{totalPages}",e.totalPages).replace("{first}",e.first).replace("{last}",e.last).replace("{rows}",e.rows).replace("{totalRecords}",e.totalRecords),r=i.default.createElement("span",{className:"p-paginator-current"},t);if(this.props.template){var o=U(U({},e),{className:"p-paginator-current",element:r,props:this.props});return n.ObjectUtils.getJSXElement(this.props.template,o)}return r}}]),a}(t.Component);function X(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}C(F,"defaultProps",{pageCount:null,page:null,first:null,rows:null,totalRecords:null,reportTemplate:"({currentPage} of {totalPages})",template:null});var _=function(e){P(s,e);var t,r,o=(t=s,r=X(),function(){var e,n=k(t);if(r){var o=k(this).constructor;e=Reflect.construct(n,arguments,o)}else e=n.apply(this,arguments);return b(this,e)});function s(e){var t;return g(this,s),(t=o.call(this,e)).onChange=t.onChange.bind(y(t)),t}return m(s,[{key:"onChange",value:function(e){this.props.onChange&&this.props.onChange(this.props.rows*(e.value-1),this.props.rows)}},{key:"render",value:function(){var e=this.props.pageCount>0?this.props.page+1:0,t=i.default.createElement(a.InputNumber,{value:e,onChange:this.onChange,className:"p-paginator-page-input",disabled:this.props.disabled});return this.props.template?n.ObjectUtils.getJSXElement(this.props.template,{value:e,onChange:this.onChange,disabled:this.props.disabled,className:"p-paginator-page-input",element:t,props:this.props}):t}}]),s}(t.Component);function A(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}C(_,"defaultProps",{page:null,rows:null,pageCount:null,disabled:!1,template:null,onChange:null});var I=function(e){P(a,e);var t,r,o=(t=a,r=A(),function(){var e,n=k(t);if(r){var o=k(this).constructor;e=Reflect.construct(n,arguments,o)}else e=n.apply(this,arguments);return b(this,e)});function a(e){var t;return g(this,a),(t=o.call(this,e)).changePageToFirst=t.changePageToFirst.bind(y(t)),t.changePageToPrev=t.changePageToPrev.bind(y(t)),t.changePageToNext=t.changePageToNext.bind(y(t)),t.changePageToLast=t.changePageToLast.bind(y(t)),t.onRowsChange=t.onRowsChange.bind(y(t)),t.changePage=t.changePage.bind(y(t)),t.onPageLinkClick=t.onPageLinkClick.bind(y(t)),t}return m(a,[{key:"isFirstPage",value:function(){return 0===this.getPage()}},{key:"isLastPage",value:function(){return this.getPage()===this.getPageCount()-1}},{key:"getPageCount",value:function(){return Math.ceil(this.props.totalRecords/this.props.rows)}},{key:"calculatePageLinkBoundaries",value:function(){var e=this.getPageCount(),t=Math.min(this.props.pageLinkSize,e),n=Math.max(0,Math.ceil(this.getPage()-t/2)),r=Math.min(e-1,n+t-1);return[n=Math.max(0,n-(this.props.pageLinkSize-(r-n+1))),r]}},{key:"updatePageLinks",value:function(){for(var e=[],t=this.calculatePageLinkBoundaries(),n=t[1],r=t[0];r<=n;r++)e.push(r+1);return e}},{key:"changePage",value:function(e,t){var n=this.getPageCount(),r=Math.floor(e/t);r>=0&&r<n&&(this.props.onPageChange&&this.props.onPageChange({first:e,rows:t,page:r,pageCount:n}))}},{key:"getPage",value:function(){return Math.floor(this.props.first/this.props.rows)}},{key:"empty",value:function(){return 0===this.getPageCount()}},{key:"changePageToFirst",value:function(e){this.changePage(0,this.props.rows),e.preventDefault()}},{key:"changePageToPrev",value:function(e){this.changePage(this.props.first-this.props.rows,this.props.rows),e.preventDefault()}},{key:"onPageLinkClick",value:function(e){this.changePage((e.value-1)*this.props.rows,this.props.rows)}},{key:"changePageToNext",value:function(e){this.changePage(this.props.first+this.props.rows,this.props.rows),e.preventDefault()}},{key:"changePageToLast",value:function(e){this.changePage((this.getPageCount()-1)*this.props.rows,this.props.rows),e.preventDefault()}},{key:"onRowsChange",value:function(e){var t=e.value;this.isRowChanged=t!==this.props.rows,this.changePage(0,t)}},{key:"componentDidUpdate",value:function(e,t){this.props.rows===e.rows||this.isRowChanged?this.getPage()>0&&e.totalRecords!==this.props.totalRecords&&this.props.first>=this.props.totalRecords&&this.changePage((this.getPageCount()-1)*this.props.rows,this.props.rows):this.changePage(0,this.props.rows),this.isRowChanged=!1}},{key:"renderElement",value:function(e,t){var n;switch(e){case"FirstPageLink":n=i.default.createElement(w,{key:e,onClick:this.changePageToFirst,disabled:this.isFirstPage()||this.empty(),template:t});break;case"PrevPageLink":n=i.default.createElement(j,{key:e,onClick:this.changePageToPrev,disabled:this.isFirstPage()||this.empty(),template:t});break;case"NextPageLink":n=i.default.createElement(E,{key:e,onClick:this.changePageToNext,disabled:this.isLastPage()||this.empty(),template:t});break;case"LastPageLink":n=i.default.createElement(L,{key:e,onClick:this.changePageToLast,disabled:this.isLastPage()||this.empty(),template:t});break;case"PageLinks":n=i.default.createElement(x,{key:e,value:this.updatePageLinks(),page:this.getPage(),rows:this.props.rows,pageCount:this.getPageCount(),onClick:this.onPageLinkClick,template:t});break;case"RowsPerPageDropdown":n=i.default.createElement(D,{key:e,value:this.props.rows,page:this.getPage(),pageCount:this.getPageCount(),totalRecords:this.props.totalRecords,options:this.props.rowsPerPageOptions,onChange:this.onRowsChange,appendTo:this.props.dropdownAppendTo,template:t,disabled:this.empty()});break;case"CurrentPageReport":n=i.default.createElement(F,{reportTemplate:this.props.currentPageReportTemplate,key:e,page:this.getPage(),pageCount:this.getPageCount(),first:this.props.first,rows:this.props.rows,totalRecords:this.props.totalRecords,template:t});break;case"JumpToPageInput":n=i.default.createElement(_,{key:e,rows:this.props.rows,page:this.getPage(),pageCount:this.getPageCount(),onChange:this.changePage,disabled:this.empty(),template:t});break;default:n=null}return n}},{key:"renderElements",value:function(){var e=this,t=this.props.template;return t?"object"===h(t)?t.layout?t.layout.split(" ").map((function(n){var r=n.trim();return e.renderElement(r,t[r])})):Object.entries(t).map((function(t){var n,r,o=(r=2,l(n=t)||p(n,r)||c(n,r)||f());return e.renderElement(o[0],o[1])})):t.split(" ").map((function(t){return e.renderElement(t.trim())})):null}},{key:"render",value:function(){if(this.props.alwaysShow||1!==this.getPageCount()){var e=n.classNames("p-paginator p-component",this.props.className),t=n.ObjectUtils.getJSXElement(this.props.leftContent,this.props),r=n.ObjectUtils.getJSXElement(this.props.rightContent,this.props),o=this.renderElements();return i.default.createElement("div",{className:e,style:this.props.style},t&&i.default.createElement("div",{className:"p-paginator-left-content"},t),o,r&&i.default.createElement("div",{className:"p-paginator-right-content"},r))}return null}}]),a}(t.Component);return C(I,"defaultProps",{totalRecords:0,rows:0,first:0,pageLinkSize:5,rowsPerPageOptions:null,alwaysShow:!0,style:null,className:null,template:"FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink RowsPerPageDropdown",onPageChange:null,leftContent:null,rightContent:null,dropdownAppendTo:null,currentPageReportTemplate:"({currentPage} of {totalPages})"}),e.Paginator=I,Object.defineProperty(e,"__esModule",{value:!0}),e}({},React,primereact.utils,primereact.ripple,primereact.dropdown,primereact.inputnumber);
|