UNPKG

ngx-easy-table

Version:
122 lines 13.1 kB
/** * @fileoverview added by tsickle * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ import { ChangeDetectionStrategy, Component, EventEmitter, HostListener, Input, Output, ViewChild, } from '@angular/core'; import { PaginationControlsDirective } from 'ngx-pagination'; /** * @record */ export function PaginationRange() { } if (false) { /** @type {?} */ PaginationRange.prototype.page; /** @type {?} */ PaginationRange.prototype.limit; } export class PaginationComponent { constructor() { this.updateRange = new EventEmitter(); this.ranges = [5, 10, 25, 50, 100]; this.showRange = false; this.screenReaderPaginationLabel = 'Pagination'; this.screenReaderPageLabel = 'page'; this.screenReaderCurrentLabel = 'You are on page'; this.previousLabel = ''; this.nextLabel = ''; this.directionLinks = true; } /** * @param {?} targetElement * @return {?} */ onClick(targetElement) { if (this.paginationRange && !this.paginationRange.nativeElement.contains(targetElement)) { this.showRange = false; } } /** * @param {?} changes * @return {?} */ ngOnChanges(changes) { const { config } = changes; if (config && config.currentValue) { this.selectedLimit = this.config.rows; } } /** * @param {?} page * @return {?} */ onPageChange(page) { this.updateRange.emit({ page, limit: this.selectedLimit, }); } /** * @param {?} limit * @param {?} callFromAPI * @return {?} */ changeLimit(limit, callFromAPI) { if (!callFromAPI) { this.showRange = !this.showRange; } this.selectedLimit = limit; this.updateRange.emit({ page: 1, limit, }); } } PaginationComponent.decorators = [ { type: Component, args: [{ selector: 'pagination', template: "<div class=\"ngx-pagination-wrapper\"\n [style.display]=\"config.paginationEnabled ? '' : 'none'\"\n [class.ngx-table__table--dark-pagination-wrapper]=\"config.tableLayout.theme === 'dark'\">\n <div class=\"ngx-pagination-steps\">\n <pagination-template\n #paginationDirective=\"paginationApi\"\n id=\"pagination-controls\"\n [id]=\"id\"\n [class.ngx-table__table--dark-pagination]=\"config.tableLayout.theme === 'dark'\"\n [maxSize]=\"config.paginationMaxSize || 5\"\n (pageChange)=\"onPageChange($event)\">\n <ul class=\"ngx-pagination\"\n role=\"navigation\"\n [attr.aria-label]=\"screenReaderPaginationLabel\"\n [class.responsive]=\"true\">\n <li class=\"pagination-previous\" [class.disabled]=\"paginationDirective.isFirstPage()\" *ngIf=\"directionLinks\">\n <a tabindex=\"0\" *ngIf=\"1 < paginationDirective.getCurrent()\" (keyup.enter)=\"paginationDirective.previous()\"\n (click)=\"paginationDirective.previous()\"\n [attr.aria-label]=\"previousLabel + ' ' + screenReaderPageLabel\">\n {{ previousLabel }} <span class=\"show-for-sr\">{{ screenReaderPageLabel }}</span>\n </a>\n <span *ngIf=\"paginationDirective.isFirstPage()\">\n {{ previousLabel }} <span class=\"show-for-sr\">{{ screenReaderPageLabel }}</span>\n </span>\n </li>\n <li class=\"small-screen\">\n {{ paginationDirective.getCurrent() }} / {{ paginationDirective.getLastPage() }}\n </li>\n <li [class.current]=\"paginationDirective.getCurrent() === page.value\"\n [class.ellipsis]=\"page.label === '...'\"\n *ngFor=\"let page of paginationDirective.pages\">\n <a tabindex=\"0\" (keyup.enter)=\"paginationDirective.setCurrent(page.value)\"\n (click)=\"paginationDirective.setCurrent(page.value)\"\n *ngIf=\"paginationDirective.getCurrent() !== page.value\">\n <span class=\"show-for-sr\">{{ screenReaderPageLabel }} </span>\n <span>{{ page.label }}</span>\n </a>\n <ng-container *ngIf=\"paginationDirective.getCurrent() === page.value\">\n <span class=\"show-for-sr\">{{ screenReaderCurrentLabel }} </span>\n <span>{{ page.label }}</span>\n </ng-container>\n </li>\n <li class=\"pagination-next\" [class.disabled]=\"paginationDirective.isLastPage()\" *ngIf=\"directionLinks\">\n <a tabindex=\"0\" *ngIf=\"!paginationDirective.isLastPage()\" (keyup.enter)=\"paginationDirective.next()\"\n (click)=\"paginationDirective.next()\"\n [attr.aria-label]=\"nextLabel + ' ' + screenReaderPageLabel\">\n {{ nextLabel }} <span class=\"show-for-sr\">{{ screenReaderPageLabel }}</span>\n </a>\n <span *ngIf=\"paginationDirective.isLastPage()\">\n {{ nextLabel }} <span class=\"show-for-sr\">{{ screenReaderPageLabel }}</span>\n </span>\n </li>\n </ul>\n </pagination-template>\n </div>\n <div class=\"ngx-pagination-range\"\n #paginationRange\n [class.ngx-table__table--dark-pagination-range]=\"config.tableLayout.theme === 'dark'\"\n *ngIf=\"config.paginationRangeEnabled\">\n <div class=\"ngx-dropdown ngx-pagination-range-dropdown\"\n id=\"rowAmount\">\n <div class=\"ngx-btn-group\">\n <div class=\"ngx-pagination-range-dropdown-button\"\n (click)=\"showRange = !showRange\">\n {{selectedLimit}} <i class=\"ngx-icon ngx-icon-arrow-down\"></i>\n </div>\n <ul class=\"ngx-menu\" *ngIf=\"showRange\">\n <li class=\"ngx-pagination-range-dropdown-button-item\"\n [class.ngx-pagination-range--selected]=\"limit === selectedLimit\"\n (click)=\"changeLimit(limit, false)\"\n *ngFor=\"let limit of ranges\">\n <span>{{limit}}</span>\n </li>\n </ul>\n </div>\n </div>\n </div>\n</div>\n", changeDetection: ChangeDetectionStrategy.OnPush }] } ]; PaginationComponent.propDecorators = { paginationDirective: [{ type: ViewChild, args: ['paginationDirective', { static: true },] }], paginationRange: [{ type: ViewChild, args: ['paginationRange', { static: false },] }], pagination: [{ type: Input }], config: [{ type: Input }], id: [{ type: Input }], updateRange: [{ type: Output }], onClick: [{ type: HostListener, args: ['document:click', ['$event.target'],] }] }; if (false) { /** @type {?} */ PaginationComponent.prototype.paginationDirective; /** @type {?} */ PaginationComponent.prototype.paginationRange; /** @type {?} */ PaginationComponent.prototype.pagination; /** @type {?} */ PaginationComponent.prototype.config; /** @type {?} */ PaginationComponent.prototype.id; /** @type {?} */ PaginationComponent.prototype.updateRange; /** @type {?} */ PaginationComponent.prototype.ranges; /** @type {?} */ PaginationComponent.prototype.selectedLimit; /** @type {?} */ PaginationComponent.prototype.showRange; /** @type {?} */ PaginationComponent.prototype.screenReaderPaginationLabel; /** @type {?} */ PaginationComponent.prototype.screenReaderPageLabel; /** @type {?} */ PaginationComponent.prototype.screenReaderCurrentLabel; /** @type {?} */ PaginationComponent.prototype.previousLabel; /** @type {?} */ PaginationComponent.prototype.nextLabel; /** @type {?} */ PaginationComponent.prototype.directionLinks; } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGFnaW5hdGlvbi5jb21wb25lbnQuanMiLCJzb3VyY2VSb290Ijoibmc6Ly9uZ3gtZWFzeS10YWJsZS8iLCJzb3VyY2VzIjpbImxpYi9jb21wb25lbnRzL3BhZ2luYXRpb24vcGFnaW5hdGlvbi5jb21wb25lbnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7OztBQUFBLE9BQU8sRUFDTCx1QkFBdUIsRUFDdkIsU0FBUyxFQUNULFlBQVksRUFDWixZQUFZLEVBQ1osS0FBSyxFQUVMLE1BQU0sRUFFTixTQUFTLEdBQ1YsTUFBTSxlQUFlLENBQUM7QUFFdkIsT0FBTyxFQUFFLDJCQUEyQixFQUFFLE1BQU0sZ0JBQWdCLENBQUM7Ozs7QUFFN0QscUNBR0M7OztJQUZDLCtCQUFhOztJQUNiLGdDQUFjOztBQVFoQixNQUFNLE9BQU8sbUJBQW1CO0lBTGhDO1FBV3FCLGdCQUFXLEdBQWtDLElBQUksWUFBWSxFQUFFLENBQUM7UUFDNUUsV0FBTSxHQUFhLENBQUMsQ0FBQyxFQUFFLEVBQUUsRUFBRSxFQUFFLEVBQUUsRUFBRSxFQUFFLEdBQUcsQ0FBQyxDQUFDO1FBRXhDLGNBQVMsR0FBRyxLQUFLLENBQUM7UUFDbEIsZ0NBQTJCLEdBQUcsWUFBWSxDQUFDO1FBQzNDLDBCQUFxQixHQUFHLE1BQU0sQ0FBQztRQUMvQiw2QkFBd0IsR0FBRyxpQkFBaUIsQ0FBQztRQUM3QyxrQkFBYSxHQUFHLEVBQUUsQ0FBQztRQUNuQixjQUFTLEdBQUcsRUFBRSxDQUFDO1FBQ2YsbUJBQWMsR0FBRyxJQUFJLENBQUM7SUFpQy9CLENBQUM7Ozs7O0lBOUJRLE9B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