UNPKG

9.21 kBJavaScriptView Raw
1!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/api")):"function"==typeof define&&define.amd?define("primeng/paginator",["exports","@angular/core","@angular/common","@angular/forms","primeng/dropdown","primeng/api"],e):e(((t=t||self).primeng=t.primeng||{},t.primeng.paginator={}),t.ng.core,t.ng.common,t.ng.forms,t.primeng.dropdown,t.primeng.api)}(this,(function(t,e,n,a,i,o){"use strict";var r=this&&this.__decorate||function(t,e,n,a){var i,o=arguments.length,r=o<3?e:null===a?a=Object.getOwnPropertyDescriptor(e,n):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,n,a);else for(var s=t.length-1;s>=0;s--)(i=t[s])&&(r=(o<3?i(r):o>3?i(e,n,r):i(e,n))||r);return o>3&&r&&Object.defineProperty(e,n,r),r},s=this&&this.__values||function(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.")},p=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.totalRecords=0,this.rows=0,this._first=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:!0,configurable:!0}),t.prototype.updateRowsPerPageOptions=function(){var t,e;if(this.rowsPerPageOptions){this.rowsPerPageItems=[];try{for(var n=s(this.rowsPerPageOptions),a=n.next();!a.done;a=n.next()){var i=a.value;"object"==typeof i&&i.showAll?this.rowsPerPageItems.unshift({label:i.showAll,value:this.totalRecords}):this.rowsPerPageItems.push({label:String(i),value:i})}}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),i=this.pageLinkSize-(a-n+1);return[n=Math.max(0,n-i),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)},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.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:!0,configurable:!0}),t.ctorParameters=function(){return[{type:e.ChangeDetectorRef}]},r([e.Input()],t.prototype,"pageLinkSize",void 0),r([e.Output()],t.prototype,"onPageChange",void 0),r([e.Input()],t.prototype,"style",void 0),r([e.Input()],t.prototype,"styleClass",void 0),r([e.Input()],t.prototype,"alwaysShow",void 0),r([e.Input()],t.prototype,"templateLeft",void 0),r([e.Input()],t.prototype,"templateRight",void 0),r([e.Input()],t.prototype,"dropdownAppendTo",void 0),r([e.Input()],t.prototype,"dropdownScrollHeight",void 0),r([e.Input()],t.prototype,"currentPageReportTemplate",void 0),r([e.Input()],t.prototype,"showCurrentPageReport",void 0),r([e.Input()],t.prototype,"totalRecords",void 0),r([e.Input()],t.prototype,"rows",void 0),r([e.Input()],t.prototype,"rowsPerPageOptions",void 0),r([e.Input()],t.prototype,"first",null),t=r([e.Component({selector:"p-paginator",template:'\n <div [class]="styleClass" [ngStyle]="style" [ngClass]="\'ui-paginator ui-widget ui-widget-header ui-unselectable-text ui-helper-clearfix\'"\n *ngIf="alwaysShow ? true : (pageLinks && pageLinks.length > 1)">\n <div class="ui-paginator-left-content" *ngIf="templateLeft">\n <ng-container *ngTemplateOutlet="templateLeft; context: {$implicit: paginatorState}"></ng-container>\n </div>\n <span class="ui-paginator-current" *ngIf="showCurrentPageReport">{{currentPageReport}}</span>\n <a [attr.tabindex]="isFirstPage() ? null : \'0\'" class="ui-paginator-first ui-paginator-element ui-state-default ui-corner-all"\n (click)="changePageToFirst($event)" (keydown.enter)="changePageToFirst($event)" [ngClass]="{\'ui-state-disabled\':isFirstPage()}" [tabindex]="isFirstPage() ? -1 : null">\n <span class="ui-paginator-icon pi pi-step-backward"></span>\n </a>\n <a tabindex="0" [attr.tabindex]="isFirstPage() ? null : \'0\'" class="ui-paginator-prev ui-paginator-element ui-state-default ui-corner-all"\n (click)="changePageToPrev($event)" (keydown.enter)="changePageToPrev($event)" [ngClass]="{\'ui-state-disabled\':isFirstPage()}" [tabindex]="isFirstPage() ? -1 : null">\n <span class="ui-paginator-icon pi pi-caret-left"></span>\n </a>\n <span class="ui-paginator-pages">\n <a tabindex="0" *ngFor="let pageLink of pageLinks" class="ui-paginator-page ui-paginator-element ui-state-default ui-corner-all"\n (click)="onPageLinkClick($event, pageLink - 1)" (keydown.enter)="onPageLinkClick($event, pageLink - 1)" [ngClass]="{\'ui-state-active\': (pageLink-1 == getPage())}">{{pageLink}}</a>\n </span>\n <a [attr.tabindex]="isLastPage() ? null : \'0\'" class="ui-paginator-next ui-paginator-element ui-state-default ui-corner-all"\n (click)="changePageToNext($event)" (keydown.enter)="changePageToNext($event)" [ngClass]="{\'ui-state-disabled\':isLastPage()}" [tabindex]="isLastPage() ? -1 : null">\n <span class="ui-paginator-icon pi pi-caret-right"></span>\n </a>\n <a [attr.tabindex]="isLastPage() ? null : \'0\'" class="ui-paginator-last ui-paginator-element ui-state-default ui-corner-all"\n (click)="changePageToLast($event)" (keydown.enter)="changePageToLast($event)" [ngClass]="{\'ui-state-disabled\':isLastPage()}" [tabindex]="isLastPage() ? -1 : null">\n <span class="ui-paginator-icon pi pi-step-forward"></span>\n </a>\n <p-dropdown [options]="rowsPerPageItems" [(ngModel)]="rows" *ngIf="rowsPerPageOptions" \n (onChange)="onRppChange($event)" [appendTo]="dropdownAppendTo" [scrollHeight]="dropdownScrollHeight"></p-dropdown>\n <div class="ui-paginator-right-content" *ngIf="templateRight">\n <ng-container *ngTemplateOutlet="templateRight; context: {$implicit: paginatorState}"></ng-container>\n </div>\n </div>\n ',changeDetection:e.ChangeDetectionStrategy.Default})],t)}(),g=function(){function t(){}return t=r([e.NgModule({imports:[n.CommonModule,i.DropdownModule,a.FormsModule,o.SharedModule],exports:[p,i.DropdownModule,a.FormsModule,o.SharedModule],declarations:[p]})],t)}();t.Paginator=p,t.PaginatorModule=g,Object.defineProperty(t,"__esModule",{value:!0})}));
2//# sourceMappingURL=primeng-paginator.umd.min.js.map
\No newline at end of file