source: trip-planner-front/node_modules/primeng/fesm2020/primeng-paginator.mjs@ 76712b2

Last change on this file since 76712b2 was 59329aa, checked in by Ema <ema_spirova@…>, 3 years ago

adding photos

  • Property mode set to 100644
File size: 21.0 KB
Line 
1import * as i0 from '@angular/core';
2import { EventEmitter, Component, ChangeDetectionStrategy, ViewEncapsulation, Input, Output, NgModule } from '@angular/core';
3import * as i3 from '@angular/common';
4import { CommonModule } from '@angular/common';
5import * as i5 from '@angular/forms';
6import { FormsModule } from '@angular/forms';
7import * as i1 from 'primeng/dropdown';
8import { DropdownModule } from 'primeng/dropdown';
9import * as i4 from 'primeng/ripple';
10import { RippleModule } from 'primeng/ripple';
11import * as i6 from 'primeng/api';
12import { SharedModule } from 'primeng/api';
13import * as i2 from 'primeng/inputnumber';
14import { InputNumberModule } from 'primeng/inputnumber';
15
16class Paginator {
17 constructor(cd) {
18 this.cd = cd;
19 this.pageLinkSize = 5;
20 this.onPageChange = new EventEmitter();
21 this.alwaysShow = true;
22 this.dropdownScrollHeight = '200px';
23 this.currentPageReportTemplate = '{currentPage} of {totalPages}';
24 this.showFirstLastIcon = true;
25 this.totalRecords = 0;
26 this.rows = 0;
27 this.showPageLinks = true;
28 this._first = 0;
29 this._page = 0;
30 }
31 ngOnInit() {
32 this.updatePaginatorState();
33 }
34 ngOnChanges(simpleChange) {
35 if (simpleChange.totalRecords) {
36 this.updatePageLinks();
37 this.updatePaginatorState();
38 this.updateFirst();
39 this.updateRowsPerPageOptions();
40 }
41 if (simpleChange.first) {
42 this._first = simpleChange.first.currentValue;
43 this.updatePageLinks();
44 this.updatePaginatorState();
45 }
46 if (simpleChange.rows) {
47 this.updatePageLinks();
48 this.updatePaginatorState();
49 }
50 if (simpleChange.rowsPerPageOptions) {
51 this.updateRowsPerPageOptions();
52 }
53 }
54 get first() {
55 return this._first;
56 }
57 set first(val) {
58 this._first = val;
59 }
60 updateRowsPerPageOptions() {
61 if (this.rowsPerPageOptions) {
62 this.rowsPerPageItems = [];
63 for (let opt of this.rowsPerPageOptions) {
64 if (typeof opt == 'object' && opt['showAll']) {
65 this.rowsPerPageItems.unshift({ label: opt['showAll'], value: this.totalRecords });
66 }
67 else {
68 this.rowsPerPageItems.push({ label: String(opt), value: opt });
69 }
70 }
71 }
72 }
73 isFirstPage() {
74 return this.getPage() === 0;
75 }
76 isLastPage() {
77 return this.getPage() === this.getPageCount() - 1;
78 }
79 getPageCount() {
80 return Math.ceil(this.totalRecords / this.rows);
81 }
82 calculatePageLinkBoundaries() {
83 let numberOfPages = this.getPageCount(), visiblePages = Math.min(this.pageLinkSize, numberOfPages);
84 //calculate range, keep current in middle if necessary
85 let start = Math.max(0, Math.ceil(this.getPage() - ((visiblePages) / 2))), end = Math.min(numberOfPages - 1, start + visiblePages - 1);
86 //check when approaching to last page
87 var delta = this.pageLinkSize - (end - start + 1);
88 start = Math.max(0, start - delta);
89 return [start, end];
90 }
91 updatePageLinks() {
92 this.pageLinks = [];
93 let boundaries = this.calculatePageLinkBoundaries(), start = boundaries[0], end = boundaries[1];
94 for (let i = start; i <= end; i++) {
95 this.pageLinks.push(i + 1);
96 }
97 if (this.showJumpToPageDropdown) {
98 this.pageItems = [];
99 for (let i = 0; i < this.getPageCount(); i++) {
100 this.pageItems.push({ label: String(i + 1), value: i });
101 }
102 }
103 }
104 changePage(p) {
105 var pc = this.getPageCount();
106 if (p >= 0 && p < pc) {
107 this._first = this.rows * p;
108 var state = {
109 page: p,
110 first: this.first,
111 rows: this.rows,
112 pageCount: pc
113 };
114 this.updatePageLinks();
115 this.onPageChange.emit(state);
116 this.updatePaginatorState();
117 }
118 }
119 updateFirst() {
120 const page = this.getPage();
121 if (page > 0 && this.totalRecords && (this.first >= this.totalRecords)) {
122 Promise.resolve(null).then(() => this.changePage(page - 1));
123 }
124 }
125 getPage() {
126 return Math.floor(this.first / this.rows);
127 }
128 changePageToFirst(event) {
129 if (!this.isFirstPage()) {
130 this.changePage(0);
131 }
132 event.preventDefault();
133 }
134 changePageToPrev(event) {
135 this.changePage(this.getPage() - 1);
136 event.preventDefault();
137 }
138 changePageToNext(event) {
139 this.changePage(this.getPage() + 1);
140 event.preventDefault();
141 }
142 changePageToLast(event) {
143 if (!this.isLastPage()) {
144 this.changePage(this.getPageCount() - 1);
145 }
146 event.preventDefault();
147 }
148 onPageLinkClick(event, page) {
149 this.changePage(page);
150 event.preventDefault();
151 }
152 onRppChange(event) {
153 this.changePage(this.getPage());
154 }
155 onPageDropdownChange(event) {
156 this.changePage(event.value);
157 }
158 updatePaginatorState() {
159 this.paginatorState = {
160 page: this.getPage(),
161 pageCount: this.getPageCount(),
162 rows: this.rows,
163 first: this.first,
164 totalRecords: this.totalRecords
165 };
166 }
167 empty() {
168 return this.getPageCount() === 0;
169 }
170 currentPage() {
171 return this.getPageCount() > 0 ? this.getPage() + 1 : 0;
172 }
173 get currentPageReport() {
174 return this.currentPageReportTemplate
175 .replace("{currentPage}", String(this.currentPage()))
176 .replace("{totalPages}", String(this.getPageCount()))
177 .replace("{first}", String((this.totalRecords > 0) ? this._first + 1 : 0))
178 .replace("{last}", String(Math.min(this._first + this.rows, this.totalRecords)))
179 .replace("{rows}", String(this.rows))
180 .replace("{totalRecords}", String(this.totalRecords));
181 }
182}
183Paginator.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: Paginator, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
184Paginator.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.0", type: Paginator, selector: "p-paginator", inputs: { pageLinkSize: "pageLinkSize", style: "style", styleClass: "styleClass", alwaysShow: "alwaysShow", templateLeft: "templateLeft", templateRight: "templateRight", dropdownAppendTo: "dropdownAppendTo", dropdownScrollHeight: "dropdownScrollHeight", currentPageReportTemplate: "currentPageReportTemplate", showCurrentPageReport: "showCurrentPageReport", showFirstLastIcon: "showFirstLastIcon", totalRecords: "totalRecords", rows: "rows", rowsPerPageOptions: "rowsPerPageOptions", showJumpToPageDropdown: "showJumpToPageDropdown", showJumpToPageInput: "showJumpToPageInput", showPageLinks: "showPageLinks", dropdownItemTemplate: "dropdownItemTemplate", first: "first" }, outputs: { onPageChange: "onPageChange" }, host: { classAttribute: "p-element" }, usesOnChanges: true, ngImport: i0, template: `
185 <div [class]="styleClass" [ngStyle]="style" [ngClass]="'p-paginator p-component'" *ngIf="alwaysShow ? true : (pageLinks && pageLinks.length > 1)">
186 <div class="p-paginator-left-content" *ngIf="templateLeft">
187 <ng-container *ngTemplateOutlet="templateLeft; context: {$implicit: paginatorState}"></ng-container>
188 </div>
189 <span class="p-paginator-current" *ngIf="showCurrentPageReport">{{currentPageReport}}</span>
190 <button *ngIf="showFirstLastIcon" type="button" [disabled]="isFirstPage() || empty()" (click)="changePageToFirst($event)" pRipple
191 class="p-paginator-first p-paginator-element p-link" [ngClass]="{'p-disabled':isFirstPage() || empty()}">
192 <span class="p-paginator-icon pi pi-angle-double-left"></span>
193 </button>
194 <button type="button" [disabled]="isFirstPage() || empty()" (click)="changePageToPrev($event)" pRipple
195 class="p-paginator-prev p-paginator-element p-link" [ngClass]="{'p-disabled':isFirstPage() || empty()}">
196 <span class="p-paginator-icon pi pi-angle-left"></span>
197 </button>
198 <span class="p-paginator-pages" *ngIf="showPageLinks">
199 <button type="button" *ngFor="let pageLink of pageLinks" class="p-paginator-page p-paginator-element p-link" [ngClass]="{'p-highlight': (pageLink-1 == getPage())}"
200 (click)="onPageLinkClick($event, pageLink - 1)" pRipple>{{pageLink}}</button>
201 </span>
202 <p-dropdown [options]="pageItems" [ngModel]="getPage()" *ngIf="showJumpToPageDropdown" [disabled]="empty()" styleClass="p-paginator-page-options"
203 (onChange)="onPageDropdownChange($event)" [appendTo]="dropdownAppendTo" [scrollHeight]="dropdownScrollHeight">
204 <ng-template pTemplate="selectedItem">{{currentPageReport}}</ng-template>
205 </p-dropdown>
206 <button type="button" [disabled]="isLastPage() || empty()" (click)="changePageToNext($event)" pRipple
207 class="p-paginator-next p-paginator-element p-link" [ngClass]="{'p-disabled':isLastPage() || empty()}">
208 <span class="p-paginator-icon pi pi-angle-right"></span>
209 </button>
210 <button *ngIf="showFirstLastIcon" type="button" [disabled]="isLastPage() || empty()" (click)="changePageToLast($event)" pRipple
211 class="p-paginator-last p-paginator-element p-link" [ngClass]="{'p-disabled':isLastPage() || empty()}">
212 <span class="p-paginator-icon pi pi-angle-double-right"></span>
213 </button>
214 <p-inputNumber *ngIf="showJumpToPageInput" [ngModel]="currentPage()" class="p-paginator-page-input" [disabled]="empty()" (ngModelChange)="changePage($event - 1)"></p-inputNumber>
215 <p-dropdown [options]="rowsPerPageItems" [(ngModel)]="rows" *ngIf="rowsPerPageOptions" styleClass="p-paginator-rpp-options" [disabled]="empty()"
216 (onChange)="onRppChange($event)" [appendTo]="dropdownAppendTo" [scrollHeight]="dropdownScrollHeight">
217 <ng-container *ngIf="dropdownItemTemplate">
218 <ng-template let-item pTemplate="item">
219 <ng-container *ngTemplateOutlet="dropdownItemTemplate; context: {$implicit: item}">
220 </ng-container>
221 </ng-template>
222 </ng-container>
223 </p-dropdown>
224 <div class="p-paginator-right-content" *ngIf="templateRight">
225 <ng-container *ngTemplateOutlet="templateRight; context: {$implicit: paginatorState}"></ng-container>
226 </div>
227 </div>
228 `, isInline: true, styles: [".p-paginator{display:flex;align-items:center;justify-content:center;flex-wrap:wrap}.p-paginator-left-content{margin-right:auto}.p-paginator-right-content{margin-left:auto}.p-paginator-page,.p-paginator-next,.p-paginator-last,.p-paginator-first,.p-paginator-prev,.p-paginator-current{cursor:pointer;display:inline-flex;align-items:center;justify-content:center;line-height:1;-webkit-user-select:none;-ms-user-select:none;user-select:none;overflow:hidden;position:relative}.p-paginator-element:focus{z-index:1;position:relative}\n"], components: [{ type: i1.Dropdown, selector: "p-dropdown", inputs: ["scrollHeight", "filter", "name", "style", "panelStyle", "styleClass", "panelStyleClass", "readonly", "required", "editable", "appendTo", "tabindex", "placeholder", "filterPlaceholder", "filterLocale", "inputId", "selectId", "dataKey", "filterBy", "autofocus", "resetFilterOnHide", "dropdownIcon", "optionLabel", "optionValue", "optionDisabled", "optionGroupLabel", "optionGroupChildren", "autoDisplayFirst", "group", "showClear", "emptyFilterMessage", "emptyMessage", "virtualScroll", "itemSize", "autoZIndex", "baseZIndex", "showTransitionOptions", "hideTransitionOptions", "ariaFilterLabel", "ariaLabelledBy", "filterMatchMode", "maxlength", "tooltip", "tooltipPosition", "tooltipPositionStyle", "tooltipStyleClass", "autofocusFilter", "disabled", "options", "filterValue"], outputs: ["onChange", "onFilter", "onFocus", "onBlur", "onClick", "onShow", "onHide", "onClear"] }, { type: i2.InputNumber, selector: "p-inputNumber", inputs: ["showButtons", "format", "buttonLayout", "inputId", "styleClass", "style", "placeholder", "size", "maxlength", "tabindex", "title", "ariaLabel", "ariaRequired", "name", "required", "autocomplete", "min", "max", "incrementButtonClass", "decrementButtonClass", "incrementButtonIcon", "decrementButtonIcon", "readonly", "step", "allowEmpty", "locale", "localeMatcher", "mode", "currency", "currencyDisplay", "useGrouping", "minFractionDigits", "maxFractionDigits", "prefix", "suffix", "inputStyle", "inputStyleClass", "disabled"], outputs: ["onInput", "onFocus", "onBlur", "onKeyDown"] }], directives: [{ type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i3.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { type: i3.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i3.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }, { type: i4.Ripple, selector: "[pRipple]" }, { type: i3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i5.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i5.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i6.PrimeTemplate, selector: "[pTemplate]", inputs: ["type", "pTemplate"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
229i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: Paginator, decorators: [{
230 type: Component,
231 args: [{ selector: 'p-paginator', template: `
232 <div [class]="styleClass" [ngStyle]="style" [ngClass]="'p-paginator p-component'" *ngIf="alwaysShow ? true : (pageLinks && pageLinks.length > 1)">
233 <div class="p-paginator-left-content" *ngIf="templateLeft">
234 <ng-container *ngTemplateOutlet="templateLeft; context: {$implicit: paginatorState}"></ng-container>
235 </div>
236 <span class="p-paginator-current" *ngIf="showCurrentPageReport">{{currentPageReport}}</span>
237 <button *ngIf="showFirstLastIcon" type="button" [disabled]="isFirstPage() || empty()" (click)="changePageToFirst($event)" pRipple
238 class="p-paginator-first p-paginator-element p-link" [ngClass]="{'p-disabled':isFirstPage() || empty()}">
239 <span class="p-paginator-icon pi pi-angle-double-left"></span>
240 </button>
241 <button type="button" [disabled]="isFirstPage() || empty()" (click)="changePageToPrev($event)" pRipple
242 class="p-paginator-prev p-paginator-element p-link" [ngClass]="{'p-disabled':isFirstPage() || empty()}">
243 <span class="p-paginator-icon pi pi-angle-left"></span>
244 </button>
245 <span class="p-paginator-pages" *ngIf="showPageLinks">
246 <button type="button" *ngFor="let pageLink of pageLinks" class="p-paginator-page p-paginator-element p-link" [ngClass]="{'p-highlight': (pageLink-1 == getPage())}"
247 (click)="onPageLinkClick($event, pageLink - 1)" pRipple>{{pageLink}}</button>
248 </span>
249 <p-dropdown [options]="pageItems" [ngModel]="getPage()" *ngIf="showJumpToPageDropdown" [disabled]="empty()" styleClass="p-paginator-page-options"
250 (onChange)="onPageDropdownChange($event)" [appendTo]="dropdownAppendTo" [scrollHeight]="dropdownScrollHeight">
251 <ng-template pTemplate="selectedItem">{{currentPageReport}}</ng-template>
252 </p-dropdown>
253 <button type="button" [disabled]="isLastPage() || empty()" (click)="changePageToNext($event)" pRipple
254 class="p-paginator-next p-paginator-element p-link" [ngClass]="{'p-disabled':isLastPage() || empty()}">
255 <span class="p-paginator-icon pi pi-angle-right"></span>
256 </button>
257 <button *ngIf="showFirstLastIcon" type="button" [disabled]="isLastPage() || empty()" (click)="changePageToLast($event)" pRipple
258 class="p-paginator-last p-paginator-element p-link" [ngClass]="{'p-disabled':isLastPage() || empty()}">
259 <span class="p-paginator-icon pi pi-angle-double-right"></span>
260 </button>
261 <p-inputNumber *ngIf="showJumpToPageInput" [ngModel]="currentPage()" class="p-paginator-page-input" [disabled]="empty()" (ngModelChange)="changePage($event - 1)"></p-inputNumber>
262 <p-dropdown [options]="rowsPerPageItems" [(ngModel)]="rows" *ngIf="rowsPerPageOptions" styleClass="p-paginator-rpp-options" [disabled]="empty()"
263 (onChange)="onRppChange($event)" [appendTo]="dropdownAppendTo" [scrollHeight]="dropdownScrollHeight">
264 <ng-container *ngIf="dropdownItemTemplate">
265 <ng-template let-item pTemplate="item">
266 <ng-container *ngTemplateOutlet="dropdownItemTemplate; context: {$implicit: item}">
267 </ng-container>
268 </ng-template>
269 </ng-container>
270 </p-dropdown>
271 <div class="p-paginator-right-content" *ngIf="templateRight">
272 <ng-container *ngTemplateOutlet="templateRight; context: {$implicit: paginatorState}"></ng-container>
273 </div>
274 </div>
275 `, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: {
276 'class': 'p-element'
277 }, styles: [".p-paginator{display:flex;align-items:center;justify-content:center;flex-wrap:wrap}.p-paginator-left-content{margin-right:auto}.p-paginator-right-content{margin-left:auto}.p-paginator-page,.p-paginator-next,.p-paginator-last,.p-paginator-first,.p-paginator-prev,.p-paginator-current{cursor:pointer;display:inline-flex;align-items:center;justify-content:center;line-height:1;-webkit-user-select:none;-ms-user-select:none;user-select:none;overflow:hidden;position:relative}.p-paginator-element:focus{z-index:1;position:relative}\n"] }]
278 }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }]; }, propDecorators: { pageLinkSize: [{
279 type: Input
280 }], onPageChange: [{
281 type: Output
282 }], style: [{
283 type: Input
284 }], styleClass: [{
285 type: Input
286 }], alwaysShow: [{
287 type: Input
288 }], templateLeft: [{
289 type: Input
290 }], templateRight: [{
291 type: Input
292 }], dropdownAppendTo: [{
293 type: Input
294 }], dropdownScrollHeight: [{
295 type: Input
296 }], currentPageReportTemplate: [{
297 type: Input
298 }], showCurrentPageReport: [{
299 type: Input
300 }], showFirstLastIcon: [{
301 type: Input
302 }], totalRecords: [{
303 type: Input
304 }], rows: [{
305 type: Input
306 }], rowsPerPageOptions: [{
307 type: Input
308 }], showJumpToPageDropdown: [{
309 type: Input
310 }], showJumpToPageInput: [{
311 type: Input
312 }], showPageLinks: [{
313 type: Input
314 }], dropdownItemTemplate: [{
315 type: Input
316 }], first: [{
317 type: Input
318 }] } });
319class PaginatorModule {
320}
321PaginatorModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: PaginatorModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
322PaginatorModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: PaginatorModule, declarations: [Paginator], imports: [CommonModule, DropdownModule, InputNumberModule, FormsModule, SharedModule, RippleModule], exports: [Paginator, DropdownModule, InputNumberModule, FormsModule, SharedModule] });
323PaginatorModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: PaginatorModule, imports: [[CommonModule, DropdownModule, InputNumberModule, FormsModule, SharedModule, RippleModule], DropdownModule, InputNumberModule, FormsModule, SharedModule] });
324i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: PaginatorModule, decorators: [{
325 type: NgModule,
326 args: [{
327 imports: [CommonModule, DropdownModule, InputNumberModule, FormsModule, SharedModule, RippleModule],
328 exports: [Paginator, DropdownModule, InputNumberModule, FormsModule, SharedModule],
329 declarations: [Paginator]
330 }]
331 }] });
332
333/**
334 * Generated bundle index. Do not edit.
335 */
336
337export { Paginator, PaginatorModule };
Note: See TracBrowser for help on using the repository browser.