ng-zorro-antd
Version:
An enterprise-class UI components based on Ant Design and Angular
2 lines • 12.2 kB
JavaScript
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("@angular/core"),require("rxjs"),require("rxjs/operators"),require("ng-zorro-antd/core"),require("ng-zorro-antd/i18n"),require("@angular/common"),require("@angular/forms"),require("ng-zorro-antd/icon"),require("ng-zorro-antd/select")):"function"==typeof define&&define.amd?define("ng-zorro-antd/pagination",["exports","@angular/core","rxjs","rxjs/operators","ng-zorro-antd/core","ng-zorro-antd/i18n","@angular/common","@angular/forms","ng-zorro-antd/icon","ng-zorro-antd/select"],n):n(((e=e||self)["ng-zorro-antd"]=e["ng-zorro-antd"]||{},e["ng-zorro-antd"].pagination={}),e.ng.core,e.rxjs,e.rxjs.operators,e["ng-zorro-antd"].core,e["ng-zorro-antd"].i18n,e.ng.common,e.ng.forms,e["ng-zorro-antd"].icon,e["ng-zorro-antd"].select)}(this,function(e,n,t,a,i,o,l,p,s,r){"use strict";function g(e,n,t,a){var i,o=arguments.length,l=o<3?n:null===a?a=Object.getOwnPropertyDescriptor(n,t):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(e,n,t,a);else for(var p=e.length-1;p>=0;p--)(i=e[p])&&(l=(o<3?i(l):o>3?i(n,t,l):i(n,t))||l);return o>3&&l&&Object.defineProperty(n,t,l),l}function d(e,n){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,n)}var c=function(){function e(e,a){this.i18n=e,this.cdr=a,this.locale={},this.firstIndex=1,this.pages=[],this.$destroy=new t.Subject,this.nzPageSizeChange=new n.EventEmitter,this.nzPageIndexChange=new n.EventEmitter,this.nzInTable=!1,this.nzSize="default",this.nzPageSizeOptions=[10,20,30,40],this.nzDisabled=!1,this.nzShowSizeChanger=!1,this.nzHideOnSinglePage=!1,this.nzShowQuickJumper=!1,this.nzSimple=!1,this.nzTotal=0,this.nzPageIndex=1,this.nzPageSize=10}return Object.defineProperty(e.prototype,"itemRender",{get:function(){return this.nzItemRender||this.nzItemRenderChild},enumerable:!0,configurable:!0}),e.prototype.validatePageIndex=function(e){return e>this.lastIndex?this.lastIndex:e<this.firstIndex?this.firstIndex:e},e.prototype.updatePageIndexValue=function(e){this.nzPageIndex=e,this.nzPageIndexChange.emit(this.nzPageIndex),this.buildIndexes()},e.prototype.isPageIndexValid=function(e){return this.validatePageIndex(e)===e},e.prototype.jumpPage=function(e){if(e!==this.nzPageIndex&&!this.nzDisabled){var n=this.validatePageIndex(e);n!==this.nzPageIndex&&this.updatePageIndexValue(n)}},e.prototype.jumpDiff=function(e){this.jumpPage(this.nzPageIndex+e)},e.prototype.onPageSizeChange=function(e){this.nzPageSize=e,this.nzPageSizeChange.emit(e),this.buildIndexes(),this.nzPageIndex>this.lastIndex&&this.updatePageIndexValue(this.lastIndex)},e.prototype.handleKeyDown=function(e,n,t){var a=n,o=i.toNumber(a.value,this.nzPageIndex);i.isInteger(o)&&this.isPageIndexValid(o)&&o!==this.nzPageIndex&&this.updatePageIndexValue(o),a.value=t?"":""+this.nzPageIndex},e.prototype.buildIndexes=function(){var e=[];if(this.lastIndex<=9)for(var n=2;n<=this.lastIndex-1;n++)e.push(n);else{var t=+this.nzPageIndex,a=Math.max(2,t-2),i=Math.min(t+2,this.lastIndex-1);t-1<=2&&(i=5),this.lastIndex-t<=2&&(a=this.lastIndex-4);for(n=a;n<=i;n++)e.push(n)}this.pages=e,this.cdr.markForCheck()},Object.defineProperty(e.prototype,"lastIndex",{get:function(){return Math.ceil(this.nzTotal/this.nzPageSize)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isLastIndex",{get:function(){return this.nzPageIndex===this.lastIndex},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isFirstIndex",{get:function(){return this.nzPageIndex===this.firstIndex},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"ranges",{get:function(){return[(this.nzPageIndex-1)*this.nzPageSize+1,Math.min(this.nzPageIndex*this.nzPageSize,this.nzTotal)]},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"showAddOption",{get:function(){return-1===this.nzPageSizeOptions.indexOf(this.nzPageSize)},enumerable:!0,configurable:!0}),e.prototype.ngOnInit=function(){var e=this;this.i18n.localeChange.pipe(a.takeUntil(this.$destroy)).subscribe(function(){e.locale=e.i18n.getLocaleData("Pagination"),e.cdr.markForCheck()})},e.prototype.ngOnDestroy=function(){this.$destroy.next(),this.$destroy.complete()},e.prototype.ngOnChanges=function(e){(e.nzTotal||e.nzPageSize||e.nzPageIndex)&&this.buildIndexes()},e.decorators=[{type:n.Component,args:[{selector:"nz-pagination",exportAs:"nzPagination",preserveWhitespaces:!1,encapsulation:n.ViewEncapsulation.None,changeDetection:n.ChangeDetectionStrategy.OnPush,template:'<ng-template #renderItemTemplate let-type let-page="page">\n <a class="ant-pagination-item-link" *ngIf="type===\'pre\'">\n <i nz-icon nzType="left"></i>\n </a>\n <a class="ant-pagination-item-link" *ngIf="type===\'next\'">\n <i nz-icon nzType="right"></i>\n </a>\n <a *ngIf="type==\'page\'">{{ page }}</a>\n</ng-template>\n<ng-container *ngIf="(nzHideOnSinglePage && (nzTotal > nzPageSize)) || (nzTotal && !nzHideOnSinglePage)">\n <ul class="ant-pagination"\n [class.ant-table-pagination]="nzInTable"\n [class.ant-pagination-simple]="nzSimple"\n [class.ant-pagination-disabled]="nzDisabled"\n [class.mini]="(nzSize === \'small\') && !nzSimple">\n <ng-container *ngIf="nzSimple; else normalTemplate">\n <li class="ant-pagination-prev"\n [attr.title]="locale.prev_page"\n [class.ant-pagination-disabled]="isFirstIndex"\n (click)="jumpDiff(-1)">\n <ng-template [ngTemplateOutlet]="itemRender" [ngTemplateOutletContext]="{ $implicit: \'pre\'}"></ng-template>\n </li>\n <li [attr.title]="nzPageIndex+\'/\'+lastIndex" class="ant-pagination-simple-pager">\n <input #simplePagerInput\n [disabled]="nzDisabled"\n [value]="nzPageIndex"\n (keydown.enter)="handleKeyDown($event,simplePagerInput,false)"\n size="3">\n <span class="ant-pagination-slash">/</span>\n {{ lastIndex }}\n </li>\n <li class="ant-pagination-next"\n [attr.title]="locale.next_page"\n [class.ant-pagination-disabled]="isLastIndex"\n (click)="jumpDiff(1)">\n <ng-template [ngTemplateOutlet]="itemRender" [ngTemplateOutletContext]="{ $implicit: \'next\'}"></ng-template>\n </li>\n </ng-container>\n <ng-template #normalTemplate>\n <li class="ant-pagination-total-text" *ngIf="nzShowTotal">\n <ng-template [ngTemplateOutlet]="nzShowTotal"\n [ngTemplateOutletContext]="{ $implicit: nzTotal,range:ranges }"></ng-template>\n </li>\n <li class="ant-pagination-prev"\n [attr.title]="locale.prev_page"\n [class.ant-pagination-disabled]="isFirstIndex"\n (click)="jumpDiff(-1)">\n <ng-template [ngTemplateOutlet]="itemRender" [ngTemplateOutletContext]="{ $implicit: \'pre\'}"></ng-template>\n </li>\n <li class="ant-pagination-item"\n [attr.title]="firstIndex"\n [class.ant-pagination-item-active]="isFirstIndex"\n (click)="jumpPage(firstIndex)">\n <ng-template [ngTemplateOutlet]="itemRender"\n [ngTemplateOutletContext]="{ $implicit: \'page\',page: firstIndex }"></ng-template>\n </li>\n <li class="ant-pagination-jump-prev"\n *ngIf="(lastIndex > 9) && (nzPageIndex - 3 > firstIndex)"\n [attr.title]="locale.prev_5"\n (click)="jumpDiff(-5)">\n <a class="ant-pagination-item-link">\n <div class="ant-pagination-item-container">\n <i nz-icon nzType="double-left" class="ant-pagination-item-link-icon"></i>\n <span class="ant-pagination-item-ellipsis">•••</span>\n </div>\n </a>\n </li>\n <li class="ant-pagination-item"\n *ngFor="let page of pages"\n [attr.title]="page"\n [class.ant-pagination-item-active]="nzPageIndex === page"\n (click)="jumpPage(page)">\n <ng-template [ngTemplateOutlet]="itemRender"\n [ngTemplateOutletContext]="{ $implicit: \'page\',page: page }"></ng-template>\n </li>\n <li class="ant-pagination-jump-next ant-pagination-item-link-icon"\n [attr.title]="locale.next_5"\n (click)="jumpDiff(5)"\n *ngIf="(lastIndex > 9) && (nzPageIndex + 3 < lastIndex)">\n <a class="ant-pagination-item-link">\n <div class="ant-pagination-item-container">\n <i nz-icon nzType="double-right" class="ant-pagination-item-link-icon"></i>\n <span class="ant-pagination-item-ellipsis">•••</span>\n </div>\n </a>\n </li>\n <li class="ant-pagination-item"\n [attr.title]="lastIndex"\n (click)="jumpPage(lastIndex)"\n *ngIf="(lastIndex > 0) && (lastIndex !== firstIndex)"\n [class.ant-pagination-item-active]="isLastIndex">\n <ng-template [ngTemplateOutlet]="itemRender"\n [ngTemplateOutletContext]="{ $implicit: \'page\',page: lastIndex }"></ng-template>\n </li>\n <li class="ant-pagination-next"\n [title]="locale.next_page"\n [class.ant-pagination-disabled]="isLastIndex"\n (click)="jumpDiff(1)">\n <ng-template [ngTemplateOutlet]="itemRender" [ngTemplateOutletContext]="{ $implicit: \'next\'}"></ng-template>\n </li>\n <div class="ant-pagination-options" *ngIf="nzShowQuickJumper || nzShowSizeChanger">\n <nz-select class="ant-pagination-options-size-changer"\n *ngIf="nzShowSizeChanger"\n [nzDisabled]="nzDisabled"\n [nzSize]="nzSize"\n [ngModel]="nzPageSize"\n (ngModelChange)="onPageSizeChange($event)">\n <nz-option *ngFor="let option of nzPageSizeOptions"\n [nzLabel]="option + \' \' + locale.items_per_page"\n [nzValue]="option">\n </nz-option>\n <nz-option *ngIf="showAddOption"\n [nzLabel]="nzPageSize + \' \' + locale.items_per_page"\n [nzValue]="nzPageSize">\n </nz-option>\n </nz-select>\n <div class="ant-pagination-options-quick-jumper" *ngIf="nzShowQuickJumper">\n {{ locale.jump_to }}\n <input #quickJumperInput\n [disabled]="nzDisabled"\n (keydown.enter)="handleKeyDown($event,quickJumperInput,true)">\n {{ locale.page }}\n </div>\n </div>\n </ng-template>\n </ul>\n</ng-container>\n'}]}],e.ctorParameters=function(){return[{type:o.NzI18nService},{type:n.ChangeDetectorRef}]},e.propDecorators={nzPageSizeChange:[{type:n.Output}],nzPageIndexChange:[{type:n.Output}],nzShowTotal:[{type:n.Input}],nzInTable:[{type:n.Input}],nzSize:[{type:n.Input}],nzPageSizeOptions:[{type:n.Input}],nzItemRender:[{type:n.Input}],nzItemRenderChild:[{type:n.ViewChild,args:["renderItemTemplate",{static:!0}]}],nzDisabled:[{type:n.Input}],nzShowSizeChanger:[{type:n.Input}],nzHideOnSinglePage:[{type:n.Input}],nzShowQuickJumper:[{type:n.Input}],nzSimple:[{type:n.Input}],nzTotal:[{type:n.Input}],nzPageIndex:[{type:n.Input}],nzPageSize:[{type:n.Input}]},g([i.InputBoolean(),d("design:type",Object)],e.prototype,"nzDisabled",void 0),g([i.InputBoolean(),d("design:type",Object)],e.prototype,"nzShowSizeChanger",void 0),g([i.InputBoolean(),d("design:type",Object)],e.prototype,"nzHideOnSinglePage",void 0),g([i.InputBoolean(),d("design:type",Object)],e.prototype,"nzShowQuickJumper",void 0),g([i.InputBoolean(),d("design:type",Object)],e.prototype,"nzSimple",void 0),g([i.InputNumber(),d("design:type",Object)],e.prototype,"nzTotal",void 0),g([i.InputNumber(),d("design:type",Object)],e.prototype,"nzPageIndex",void 0),g([i.InputNumber(),d("design:type",Object)],e.prototype,"nzPageSize",void 0),e}();var u=function(){function e(){}return e.decorators=[{type:n.NgModule,args:[{declarations:[c],exports:[c],imports:[l.CommonModule,p.FormsModule,r.NzSelectModule,o.NzI18nModule,s.NzIconModule]}]}],e}();e.NzPaginationComponent=c,e.NzPaginationModule=u,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=ng-zorro-antd-pagination.umd.min.js.map