source: trip-planner-front/node_modules/@angular/material/fesm2015/paginator.js@ ceaed42

Last change on this file since ceaed42 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 18.5 KB
Line 
1import { CommonModule } from '@angular/common';
2import * as i0 from '@angular/core';
3import { Injectable, Optional, SkipSelf, InjectionToken, EventEmitter, Directive, ChangeDetectorRef, Input, Output, Component, ChangeDetectionStrategy, ViewEncapsulation, Inject, NgModule } from '@angular/core';
4import { mixinDisabled, mixinInitialized, MatCommonModule } from '@angular/material/core';
5import { MatButtonModule } from '@angular/material/button';
6import { MatSelectModule } from '@angular/material/select';
7import { MatTooltipModule } from '@angular/material/tooltip';
8import { coerceNumberProperty, coerceBooleanProperty } from '@angular/cdk/coercion';
9import { Subject } from 'rxjs';
10
11/**
12 * @license
13 * Copyright Google LLC All Rights Reserved.
14 *
15 * Use of this source code is governed by an MIT-style license that can be
16 * found in the LICENSE file at https://angular.io/license
17 */
18/**
19 * To modify the labels and text displayed, create a new instance of MatPaginatorIntl and
20 * include it in a custom provider
21 */
22class MatPaginatorIntl {
23 constructor() {
24 /**
25 * Stream to emit from when labels are changed. Use this to notify components when the labels have
26 * changed after initialization.
27 */
28 this.changes = new Subject();
29 /** A label for the page size selector. */
30 this.itemsPerPageLabel = 'Items per page:';
31 /** A label for the button that increments the current page. */
32 this.nextPageLabel = 'Next page';
33 /** A label for the button that decrements the current page. */
34 this.previousPageLabel = 'Previous page';
35 /** A label for the button that moves to the first page. */
36 this.firstPageLabel = 'First page';
37 /** A label for the button that moves to the last page. */
38 this.lastPageLabel = 'Last page';
39 /** A label for the range of items within the current page and the length of the whole list. */
40 this.getRangeLabel = (page, pageSize, length) => {
41 if (length == 0 || pageSize == 0) {
42 return `0 of ${length}`;
43 }
44 length = Math.max(length, 0);
45 const startIndex = page * pageSize;
46 // If the start index exceeds the list length, do not try and fix the end index to the end.
47 const endIndex = startIndex < length ?
48 Math.min(startIndex + pageSize, length) :
49 startIndex + pageSize;
50 return `${startIndex + 1} – ${endIndex} of ${length}`;
51 };
52 }
53}
54MatPaginatorIntl.ɵprov = i0.ɵɵdefineInjectable({ factory: function MatPaginatorIntl_Factory() { return new MatPaginatorIntl(); }, token: MatPaginatorIntl, providedIn: "root" });
55MatPaginatorIntl.decorators = [
56 { type: Injectable, args: [{ providedIn: 'root' },] }
57];
58/** @docs-private */
59function MAT_PAGINATOR_INTL_PROVIDER_FACTORY(parentIntl) {
60 return parentIntl || new MatPaginatorIntl();
61}
62/** @docs-private */
63const MAT_PAGINATOR_INTL_PROVIDER = {
64 // If there is already an MatPaginatorIntl available, use that. Otherwise, provide a new one.
65 provide: MatPaginatorIntl,
66 deps: [[new Optional(), new SkipSelf(), MatPaginatorIntl]],
67 useFactory: MAT_PAGINATOR_INTL_PROVIDER_FACTORY
68};
69
70/**
71 * @license
72 * Copyright Google LLC All Rights Reserved.
73 *
74 * Use of this source code is governed by an MIT-style license that can be
75 * found in the LICENSE file at https://angular.io/license
76 */
77/** The default page size if there is no page size and there are no provided page size options. */
78const DEFAULT_PAGE_SIZE = 50;
79/**
80 * Change event object that is emitted when the user selects a
81 * different page size or navigates to another page.
82 */
83class PageEvent {
84}
85/** Injection token that can be used to provide the default options for the paginator module. */
86const MAT_PAGINATOR_DEFAULT_OPTIONS = new InjectionToken('MAT_PAGINATOR_DEFAULT_OPTIONS');
87// Boilerplate for applying mixins to _MatPaginatorBase.
88/** @docs-private */
89const _MatPaginatorMixinBase = mixinDisabled(mixinInitialized(class {
90}));
91/**
92 * Base class with all of the `MatPaginator` functionality.
93 * @docs-private
94 */
95class _MatPaginatorBase extends _MatPaginatorMixinBase {
96 constructor(_intl, _changeDetectorRef, defaults) {
97 super();
98 this._intl = _intl;
99 this._changeDetectorRef = _changeDetectorRef;
100 this._pageIndex = 0;
101 this._length = 0;
102 this._pageSizeOptions = [];
103 this._hidePageSize = false;
104 this._showFirstLastButtons = false;
105 /** Event emitted when the paginator changes the page size or page index. */
106 this.page = new EventEmitter();
107 this._intlChanges = _intl.changes.subscribe(() => this._changeDetectorRef.markForCheck());
108 if (defaults) {
109 const { pageSize, pageSizeOptions, hidePageSize, showFirstLastButtons, } = defaults;
110 if (pageSize != null) {
111 this._pageSize = pageSize;
112 }
113 if (pageSizeOptions != null) {
114 this._pageSizeOptions = pageSizeOptions;
115 }
116 if (hidePageSize != null) {
117 this._hidePageSize = hidePageSize;
118 }
119 if (showFirstLastButtons != null) {
120 this._showFirstLastButtons = showFirstLastButtons;
121 }
122 }
123 }
124 /** The zero-based page index of the displayed list of items. Defaulted to 0. */
125 get pageIndex() { return this._pageIndex; }
126 set pageIndex(value) {
127 this._pageIndex = Math.max(coerceNumberProperty(value), 0);
128 this._changeDetectorRef.markForCheck();
129 }
130 /** The length of the total number of items that are being paginated. Defaulted to 0. */
131 get length() { return this._length; }
132 set length(value) {
133 this._length = coerceNumberProperty(value);
134 this._changeDetectorRef.markForCheck();
135 }
136 /** Number of items to display on a page. By default set to 50. */
137 get pageSize() { return this._pageSize; }
138 set pageSize(value) {
139 this._pageSize = Math.max(coerceNumberProperty(value), 0);
140 this._updateDisplayedPageSizeOptions();
141 }
142 /** The set of provided page size options to display to the user. */
143 get pageSizeOptions() { return this._pageSizeOptions; }
144 set pageSizeOptions(value) {
145 this._pageSizeOptions = (value || []).map(p => coerceNumberProperty(p));
146 this._updateDisplayedPageSizeOptions();
147 }
148 /** Whether to hide the page size selection UI from the user. */
149 get hidePageSize() { return this._hidePageSize; }
150 set hidePageSize(value) {
151 this._hidePageSize = coerceBooleanProperty(value);
152 }
153 /** Whether to show the first/last buttons UI to the user. */
154 get showFirstLastButtons() { return this._showFirstLastButtons; }
155 set showFirstLastButtons(value) {
156 this._showFirstLastButtons = coerceBooleanProperty(value);
157 }
158 ngOnInit() {
159 this._initialized = true;
160 this._updateDisplayedPageSizeOptions();
161 this._markInitialized();
162 }
163 ngOnDestroy() {
164 this._intlChanges.unsubscribe();
165 }
166 /** Advances to the next page if it exists. */
167 nextPage() {
168 if (!this.hasNextPage()) {
169 return;
170 }
171 const previousPageIndex = this.pageIndex;
172 this.pageIndex++;
173 this._emitPageEvent(previousPageIndex);
174 }
175 /** Move back to the previous page if it exists. */
176 previousPage() {
177 if (!this.hasPreviousPage()) {
178 return;
179 }
180 const previousPageIndex = this.pageIndex;
181 this.pageIndex--;
182 this._emitPageEvent(previousPageIndex);
183 }
184 /** Move to the first page if not already there. */
185 firstPage() {
186 // hasPreviousPage being false implies at the start
187 if (!this.hasPreviousPage()) {
188 return;
189 }
190 const previousPageIndex = this.pageIndex;
191 this.pageIndex = 0;
192 this._emitPageEvent(previousPageIndex);
193 }
194 /** Move to the last page if not already there. */
195 lastPage() {
196 // hasNextPage being false implies at the end
197 if (!this.hasNextPage()) {
198 return;
199 }
200 const previousPageIndex = this.pageIndex;
201 this.pageIndex = this.getNumberOfPages() - 1;
202 this._emitPageEvent(previousPageIndex);
203 }
204 /** Whether there is a previous page. */
205 hasPreviousPage() {
206 return this.pageIndex >= 1 && this.pageSize != 0;
207 }
208 /** Whether there is a next page. */
209 hasNextPage() {
210 const maxPageIndex = this.getNumberOfPages() - 1;
211 return this.pageIndex < maxPageIndex && this.pageSize != 0;
212 }
213 /** Calculate the number of pages */
214 getNumberOfPages() {
215 if (!this.pageSize) {
216 return 0;
217 }
218 return Math.ceil(this.length / this.pageSize);
219 }
220 /**
221 * Changes the page size so that the first item displayed on the page will still be
222 * displayed using the new page size.
223 *
224 * For example, if the page size is 10 and on the second page (items indexed 10-19) then
225 * switching so that the page size is 5 will set the third page as the current page so
226 * that the 10th item will still be displayed.
227 */
228 _changePageSize(pageSize) {
229 // Current page needs to be updated to reflect the new page size. Navigate to the page
230 // containing the previous page's first item.
231 const startIndex = this.pageIndex * this.pageSize;
232 const previousPageIndex = this.pageIndex;
233 this.pageIndex = Math.floor(startIndex / pageSize) || 0;
234 this.pageSize = pageSize;
235 this._emitPageEvent(previousPageIndex);
236 }
237 /** Checks whether the buttons for going forwards should be disabled. */
238 _nextButtonsDisabled() {
239 return this.disabled || !this.hasNextPage();
240 }
241 /** Checks whether the buttons for going backwards should be disabled. */
242 _previousButtonsDisabled() {
243 return this.disabled || !this.hasPreviousPage();
244 }
245 /**
246 * Updates the list of page size options to display to the user. Includes making sure that
247 * the page size is an option and that the list is sorted.
248 */
249 _updateDisplayedPageSizeOptions() {
250 if (!this._initialized) {
251 return;
252 }
253 // If no page size is provided, use the first page size option or the default page size.
254 if (!this.pageSize) {
255 this._pageSize = this.pageSizeOptions.length != 0 ?
256 this.pageSizeOptions[0] :
257 DEFAULT_PAGE_SIZE;
258 }
259 this._displayedPageSizeOptions = this.pageSizeOptions.slice();
260 if (this._displayedPageSizeOptions.indexOf(this.pageSize) === -1) {
261 this._displayedPageSizeOptions.push(this.pageSize);
262 }
263 // Sort the numbers using a number-specific sort function.
264 this._displayedPageSizeOptions.sort((a, b) => a - b);
265 this._changeDetectorRef.markForCheck();
266 }
267 /** Emits an event notifying that a change of the paginator's properties has been triggered. */
268 _emitPageEvent(previousPageIndex) {
269 this.page.emit({
270 previousPageIndex,
271 pageIndex: this.pageIndex,
272 pageSize: this.pageSize,
273 length: this.length
274 });
275 }
276}
277_MatPaginatorBase.decorators = [
278 { type: Directive }
279];
280_MatPaginatorBase.ctorParameters = () => [
281 { type: MatPaginatorIntl },
282 { type: ChangeDetectorRef },
283 { type: undefined }
284];
285_MatPaginatorBase.propDecorators = {
286 color: [{ type: Input }],
287 pageIndex: [{ type: Input }],
288 length: [{ type: Input }],
289 pageSize: [{ type: Input }],
290 pageSizeOptions: [{ type: Input }],
291 hidePageSize: [{ type: Input }],
292 showFirstLastButtons: [{ type: Input }],
293 page: [{ type: Output }]
294};
295/**
296 * Component to provide navigation between paged information. Displays the size of the current
297 * page, user-selectable options to change that size, what items are being shown, and
298 * navigational button to go to the previous or next page.
299 */
300class MatPaginator extends _MatPaginatorBase {
301 constructor(intl, changeDetectorRef, defaults) {
302 super(intl, changeDetectorRef, defaults);
303 if (defaults && defaults.formFieldAppearance != null) {
304 this._formFieldAppearance = defaults.formFieldAppearance;
305 }
306 }
307}
308MatPaginator.decorators = [
309 { type: Component, args: [{
310 selector: 'mat-paginator',
311 exportAs: 'matPaginator',
312 template: "<div class=\"mat-paginator-outer-container\">\n <div class=\"mat-paginator-container\">\n <div class=\"mat-paginator-page-size\" *ngIf=\"!hidePageSize\">\n <div class=\"mat-paginator-page-size-label\">\n {{_intl.itemsPerPageLabel}}\n </div>\n\n <mat-form-field\n *ngIf=\"_displayedPageSizeOptions.length > 1\"\n [appearance]=\"_formFieldAppearance!\"\n [color]=\"color\"\n class=\"mat-paginator-page-size-select\">\n <mat-select\n [value]=\"pageSize\"\n [disabled]=\"disabled\"\n [aria-label]=\"_intl.itemsPerPageLabel\"\n (selectionChange)=\"_changePageSize($event.value)\">\n <mat-option *ngFor=\"let pageSizeOption of _displayedPageSizeOptions\" [value]=\"pageSizeOption\">\n {{pageSizeOption}}\n </mat-option>\n </mat-select>\n </mat-form-field>\n\n <div\n class=\"mat-paginator-page-size-value\"\n *ngIf=\"_displayedPageSizeOptions.length <= 1\">{{pageSize}}</div>\n </div>\n\n <div class=\"mat-paginator-range-actions\">\n <div class=\"mat-paginator-range-label\">\n {{_intl.getRangeLabel(pageIndex, pageSize, length)}}\n </div>\n\n <button mat-icon-button type=\"button\"\n class=\"mat-paginator-navigation-first\"\n (click)=\"firstPage()\"\n [attr.aria-label]=\"_intl.firstPageLabel\"\n [matTooltip]=\"_intl.firstPageLabel\"\n [matTooltipDisabled]=\"_previousButtonsDisabled()\"\n [matTooltipPosition]=\"'above'\"\n [disabled]=\"_previousButtonsDisabled()\"\n *ngIf=\"showFirstLastButtons\">\n <svg class=\"mat-paginator-icon\" viewBox=\"0 0 24 24\" focusable=\"false\">\n <path d=\"M18.41 16.59L13.82 12l4.59-4.59L17 6l-6 6 6 6zM6 6h2v12H6z\"/>\n </svg>\n </button>\n <button mat-icon-button type=\"button\"\n class=\"mat-paginator-navigation-previous\"\n (click)=\"previousPage()\"\n [attr.aria-label]=\"_intl.previousPageLabel\"\n [matTooltip]=\"_intl.previousPageLabel\"\n [matTooltipDisabled]=\"_previousButtonsDisabled()\"\n [matTooltipPosition]=\"'above'\"\n [disabled]=\"_previousButtonsDisabled()\">\n <svg class=\"mat-paginator-icon\" viewBox=\"0 0 24 24\" focusable=\"false\">\n <path d=\"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z\"/>\n </svg>\n </button>\n <button mat-icon-button type=\"button\"\n class=\"mat-paginator-navigation-next\"\n (click)=\"nextPage()\"\n [attr.aria-label]=\"_intl.nextPageLabel\"\n [matTooltip]=\"_intl.nextPageLabel\"\n [matTooltipDisabled]=\"_nextButtonsDisabled()\"\n [matTooltipPosition]=\"'above'\"\n [disabled]=\"_nextButtonsDisabled()\">\n <svg class=\"mat-paginator-icon\" viewBox=\"0 0 24 24\" focusable=\"false\">\n <path d=\"M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z\"/>\n </svg>\n </button>\n <button mat-icon-button type=\"button\"\n class=\"mat-paginator-navigation-last\"\n (click)=\"lastPage()\"\n [attr.aria-label]=\"_intl.lastPageLabel\"\n [matTooltip]=\"_intl.lastPageLabel\"\n [matTooltipDisabled]=\"_nextButtonsDisabled()\"\n [matTooltipPosition]=\"'above'\"\n [disabled]=\"_nextButtonsDisabled()\"\n *ngIf=\"showFirstLastButtons\">\n <svg class=\"mat-paginator-icon\" viewBox=\"0 0 24 24\" focusable=\"false\">\n <path d=\"M5.59 7.41L10.18 12l-4.59 4.59L7 18l6-6-6-6zM16 6h2v12h-2z\"/>\n </svg>\n </button>\n </div>\n </div>\n</div>\n",
313 inputs: ['disabled'],
314 host: {
315 'class': 'mat-paginator',
316 'role': 'group',
317 },
318 changeDetection: ChangeDetectionStrategy.OnPush,
319 encapsulation: ViewEncapsulation.None,
320 styles: [".mat-paginator{display:block}.mat-paginator-outer-container{display:flex}.mat-paginator-container{display:flex;align-items:center;justify-content:flex-end;padding:0 8px;flex-wrap:wrap-reverse;width:100%}.mat-paginator-page-size{display:flex;align-items:baseline;margin-right:8px}[dir=rtl] .mat-paginator-page-size{margin-right:0;margin-left:8px}.mat-paginator-page-size-label{margin:0 4px}.mat-paginator-page-size-select{margin:6px 4px 0 4px;width:56px}.mat-paginator-page-size-select.mat-form-field-appearance-outline{width:64px}.mat-paginator-page-size-select.mat-form-field-appearance-fill{width:64px}.mat-paginator-range-label{margin:0 32px 0 24px}.mat-paginator-range-actions{display:flex;align-items:center}.mat-paginator-icon{width:28px;fill:currentColor}[dir=rtl] .mat-paginator-icon{transform:rotate(180deg)}.cdk-high-contrast-active .mat-paginator-icon{fill:CanvasText}\n"]
321 },] }
322];
323MatPaginator.ctorParameters = () => [
324 { type: MatPaginatorIntl },
325 { type: ChangeDetectorRef },
326 { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [MAT_PAGINATOR_DEFAULT_OPTIONS,] }] }
327];
328
329/**
330 * @license
331 * Copyright Google LLC All Rights Reserved.
332 *
333 * Use of this source code is governed by an MIT-style license that can be
334 * found in the LICENSE file at https://angular.io/license
335 */
336class MatPaginatorModule {
337}
338MatPaginatorModule.decorators = [
339 { type: NgModule, args: [{
340 imports: [
341 CommonModule,
342 MatButtonModule,
343 MatSelectModule,
344 MatTooltipModule,
345 MatCommonModule,
346 ],
347 exports: [MatPaginator],
348 declarations: [MatPaginator],
349 providers: [MAT_PAGINATOR_INTL_PROVIDER],
350 },] }
351];
352
353/**
354 * @license
355 * Copyright Google LLC All Rights Reserved.
356 *
357 * Use of this source code is governed by an MIT-style license that can be
358 * found in the LICENSE file at https://angular.io/license
359 */
360
361/**
362 * Generated bundle index. Do not edit.
363 */
364
365export { MAT_PAGINATOR_DEFAULT_OPTIONS, MAT_PAGINATOR_INTL_PROVIDER, MAT_PAGINATOR_INTL_PROVIDER_FACTORY, MatPaginator, MatPaginatorIntl, MatPaginatorModule, PageEvent, _MatPaginatorBase };
366//# sourceMappingURL=paginator.js.map
Note: See TracBrowser for help on using the repository browser.