primeng
Version:
[](https://opensource.org/licenses/MIT) [](https://badge.fury.io/js/primeng) [ • 10.9 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@angular/common"),require("@angular/forms"),require("primeng/dropdown"),require("primeng/ripple"),require("primeng/api")):"function"==typeof define&&define.amd?define("primeng/paginator",["exports","@angular/core","@angular/common","@angular/forms","primeng/dropdown","primeng/ripple","primeng/api"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).primeng=t.primeng||{},t.primeng.paginator={}),t.ng.core,t.ng.common,t.ng.forms,t.primeng.dropdown,t.primeng.ripple,t.primeng.api)}(this,(function(t,e,n,a,o,i,r){"use strict";
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */Object.create;function p(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],a=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&a>=t.length&&(t=void 0),{value:t&&t[a++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}Object.create;var s=function(){function t(t){this.cd=t,this.pageLinkSize=5,this.onPageChange=new e.EventEmitter,this.alwaysShow=!0,this.dropdownScrollHeight="200px",this.currentPageReportTemplate="{currentPage} of {totalPages}",this.showFirstLastIcon=!0,this.totalRecords=0,this.rows=0,this.showPageLinks=!0,this._first=0,this._page=0}return t.prototype.ngOnInit=function(){this.updatePaginatorState()},t.prototype.ngOnChanges=function(t){t.totalRecords&&(this.updatePageLinks(),this.updatePaginatorState(),this.updateFirst(),this.updateRowsPerPageOptions()),t.first&&(this._first=t.first.currentValue,this.updatePageLinks(),this.updatePaginatorState()),t.rows&&(this.updatePageLinks(),this.updatePaginatorState()),t.rowsPerPageOptions&&this.updateRowsPerPageOptions()},Object.defineProperty(t.prototype,"first",{get:function(){return this._first},set:function(t){this._first=t},enumerable:!1,configurable:!0}),t.prototype.updateRowsPerPageOptions=function(){var t,e;if(this.rowsPerPageOptions){this.rowsPerPageItems=[];try{for(var n=p(this.rowsPerPageOptions),a=n.next();!a.done;a=n.next()){var o=a.value;"object"==typeof o&&o.showAll?this.rowsPerPageItems.unshift({label:o.showAll,value:this.totalRecords}):this.rowsPerPageItems.push({label:String(o),value:o})}}catch(e){t={error:e}}finally{try{a&&!a.done&&(e=n.return)&&e.call(n)}finally{if(t)throw t.error}}}},t.prototype.isFirstPage=function(){return 0===this.getPage()},t.prototype.isLastPage=function(){return this.getPage()===this.getPageCount()-1},t.prototype.getPageCount=function(){return Math.ceil(this.totalRecords/this.rows)||1},t.prototype.calculatePageLinkBoundaries=function(){var t=this.getPageCount(),e=Math.min(this.pageLinkSize,t),n=Math.max(0,Math.ceil(this.getPage()-e/2)),a=Math.min(t-1,n+e-1),o=this.pageLinkSize-(a-n+1);return[n=Math.max(0,n-o),a]},t.prototype.updatePageLinks=function(){this.pageLinks=[];for(var t=this.calculatePageLinkBoundaries(),e=t[0],n=t[1],a=e;a<=n;a++)this.pageLinks.push(a+1);if(this.showJumpToPageDropdown){this.pageItems=[];for(a=0;a<this.getPageCount();a++)this.pageItems.push({label:String(a+1),value:a})}},t.prototype.changePage=function(t){var e=this.getPageCount();if(t>=0&&t<e){this._first=this.rows*t;var n={page:t,first:this.first,rows:this.rows,pageCount:e};this.updatePageLinks(),this.onPageChange.emit(n),this.updatePaginatorState()}},t.prototype.updateFirst=function(){var t=this,e=this.getPage();e>0&&this.totalRecords&&this.first>=this.totalRecords&&Promise.resolve(null).then((function(){return t.changePage(e-1)}))},t.prototype.getPage=function(){return Math.floor(this.first/this.rows)},t.prototype.changePageToFirst=function(t){this.isFirstPage()||this.changePage(0),t.preventDefault()},t.prototype.changePageToPrev=function(t){this.changePage(this.getPage()-1),t.preventDefault()},t.prototype.changePageToNext=function(t){this.changePage(this.getPage()+1),t.preventDefault()},t.prototype.changePageToLast=function(t){this.isLastPage()||this.changePage(this.getPageCount()-1),t.preventDefault()},t.prototype.onPageLinkClick=function(t,e){this.changePage(e),t.preventDefault()},t.prototype.onRppChange=function(t){this.changePage(this.getPage())},t.prototype.onPageDropdownChange=function(t){this.changePage(t.value)},t.prototype.updatePaginatorState=function(){this.paginatorState={page:this.getPage(),pageCount:this.getPageCount(),rows:this.rows,first:this.first,totalRecords:this.totalRecords}},Object.defineProperty(t.prototype,"currentPageReport",{get:function(){return this.currentPageReportTemplate.replace("{currentPage}",String(this.getPage()+1)).replace("{totalPages}",String(this.getPageCount())).replace("{first}",String(this._first+1)).replace("{last}",String(Math.min(this._first+this.rows,this.totalRecords))).replace("{rows}",String(this.rows)).replace("{totalRecords}",String(this.totalRecords))},enumerable:!1,configurable:!0}),t}();s.decorators=[{type:e.Component,args:[{selector:"p-paginator",template:'\n <div [class]="styleClass" [ngStyle]="style" [ngClass]="\'p-paginator p-component\'" *ngIf="alwaysShow ? true : (pageLinks && pageLinks.length > 1)">\n <div class="p-paginator-left-content" *ngIf="templateLeft">\n <ng-container *ngTemplateOutlet="templateLeft; context: {$implicit: paginatorState}"></ng-container>\n </div>\n <span class="p-paginator-current" *ngIf="showCurrentPageReport">{{currentPageReport}}</span>\n <button *ngIf="showFirstLastIcon" type="button" [disabled]="isFirstPage()" (click)="changePageToFirst($event)" pRipple\n class="p-paginator-first p-paginator-element p-link" [ngClass]="{\'p-disabled\':isFirstPage()}">\n <span class="p-paginator-icon pi pi-angle-double-left"></span>\n </button>\n <button type="button" [disabled]="isFirstPage()" (click)="changePageToPrev($event)" pRipple\n class="p-paginator-prev p-paginator-element p-link" [ngClass]="{\'p-disabled\':isFirstPage()}">\n <span class="p-paginator-icon pi pi-angle-left"></span>\n </button>\n <span class="p-paginator-pages" *ngIf="showPageLinks">\n <button type="button" *ngFor="let pageLink of pageLinks" class="p-paginator-page p-paginator-element p-link" [ngClass]="{\'p-highlight\': (pageLink-1 == getPage())}"\n (click)="onPageLinkClick($event, pageLink - 1)" pRipple>{{pageLink}}</button>\n </span>\n <p-dropdown [options]="pageItems" [ngModel]="getPage()" *ngIf="showJumpToPageDropdown" styleClass="p-paginator-page-options"\n (onChange)="onPageDropdownChange($event)" [appendTo]="dropdownAppendTo" [scrollHeight]="dropdownScrollHeight">\n <ng-template pTemplate="selectedItem">{{currentPageReport}}</ng-template>\n </p-dropdown>\n <button type="button" [disabled]="isLastPage()" (click)="changePageToNext($event)" pRipple\n class="p-paginator-next p-paginator-element p-link" [ngClass]="{\'p-disabled\':isLastPage()}">\n <span class="p-paginator-icon pi pi-angle-right"></span>\n </button>\n <button *ngIf="showFirstLastIcon" type="button" [disabled]="isLastPage()" (click)="changePageToLast($event)" pRipple\n class="p-paginator-last p-paginator-element p-link" [ngClass]="{\'p-disabled\':isLastPage()}">\n <span class="p-paginator-icon pi pi-angle-double-right"></span>\n </button>\n <p-dropdown [options]="rowsPerPageItems" [(ngModel)]="rows" *ngIf="rowsPerPageOptions" styleClass="p-paginator-rpp-options"\n (onChange)="onRppChange($event)" [appendTo]="dropdownAppendTo" [scrollHeight]="dropdownScrollHeight">\n <ng-container *ngIf="dropdownItemTemplate">\n <ng-template let-item pTemplate="item">\n <ng-container *ngTemplateOutlet="dropdownItemTemplate; context: {$implicit: item}">\n </ng-container>\n </ng-template>\n </ng-container>\n </p-dropdown>\n <div class="p-paginator-right-content" *ngIf="templateRight">\n <ng-container *ngTemplateOutlet="templateRight; context: {$implicit: paginatorState}"></ng-container>\n </div>\n </div>\n ',changeDetection:e.ChangeDetectionStrategy.OnPush,encapsulation:e.ViewEncapsulation.None,styles:[".p-paginator{align-items:center;display:flex;flex-wrap:wrap;justify-content:center}.p-paginator-left-content{margin-right:auto}.p-paginator-right-content{margin-left:auto}.p-paginator-current,.p-paginator-first,.p-paginator-last,.p-paginator-next,.p-paginator-page,.p-paginator-prev{-ms-user-select:none;-webkit-user-select:none;align-items:center;cursor:pointer;display:inline-flex;justify-content:center;line-height:1;overflow:hidden;position:relative;user-select:none}.p-paginator-element:focus{position:relative;z-index:1}"]}]}],s.ctorParameters=function(){return[{type:e.ChangeDetectorRef}]},s.propDecorators={pageLinkSize:[{type:e.Input}],onPageChange:[{type:e.Output}],style:[{type:e.Input}],styleClass:[{type:e.Input}],alwaysShow:[{type:e.Input}],templateLeft:[{type:e.Input}],templateRight:[{type:e.Input}],dropdownAppendTo:[{type:e.Input}],dropdownScrollHeight:[{type:e.Input}],currentPageReportTemplate:[{type:e.Input}],showCurrentPageReport:[{type:e.Input}],showFirstLastIcon:[{type:e.Input}],totalRecords:[{type:e.Input}],rows:[{type:e.Input}],rowsPerPageOptions:[{type:e.Input}],showJumpToPageDropdown:[{type:e.Input}],showPageLinks:[{type:e.Input}],dropdownItemTemplate:[{type:e.Input}],first:[{type:e.Input}]};var g=function(){};g.decorators=[{type:e.NgModule,args:[{imports:[n.CommonModule,o.DropdownModule,a.FormsModule,r.SharedModule,i.RippleModule],exports:[s,o.DropdownModule,a.FormsModule,r.SharedModule],declarations:[s]}]}],t.Paginator=s,t.PaginatorModule=g,Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=primeng-paginator.umd.min.js.map