UNPKG

@progress/kendo-angular-pager

Version:
114 lines (113 loc) 4.42 kB
/**----------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the project root for more information *-------------------------------------------------------------------------------------------*/ import { Component, ChangeDetectorRef } from '@angular/core'; import { PagerContextService } from "./pager-context.service"; import { LocalizationService } from '@progress/kendo-angular-l10n'; import { caretAltLeftIcon, caretAltRightIcon, caretAltToLeftIcon, caretAltToRightIcon } from '@progress/kendo-svg-icons'; import * as i0 from "@angular/core"; import * as i1 from "@progress/kendo-angular-l10n"; import * as i2 from "./pager-context.service"; /** * @hidden */ export class PagerElementComponent { localization; pagerContext; cd; total; skip; pageSize; caretAltLeftIcon = caretAltLeftIcon; caretAltToLeftIcon = caretAltToLeftIcon; caretAltRightIcon = caretAltRightIcon; caretAltToRightIcon = caretAltToRightIcon; /** * @hidden * * @readonly * @type {number} * @memberOf PagerElementComponent */ get currentPage() { return Math.floor((this.skip || 0) / this.pageSize) + 1; } /** * @hidden * * @readonly * @type {number} * @memberOf PagerElementComponent */ get totalPages() { return Math.ceil((this.total || 0) / this.pageSize); } subscriptions; constructor(localization, pagerContext, cd) { this.localization = localization; this.pagerContext = pagerContext; this.cd = cd; this.total = pagerContext.total; this.skip = pagerContext.skip; this.pageSize = pagerContext.pageSize; } /** * @hidden * * @param {string} key * @returns {string} * * @memberOf PagerElementComponent */ textFor(key) { const isPagerLocalization = this.localization.prefix === 'kendo.pager'; return this.localization.get(isPagerLocalization ? key : `pager${key[0].toLocaleUpperCase()}${key.slice(1)}`); } /** * @hidden * * @param {number} page * * @memberOf PagerElementComponent */ changePage(page) { this.pagerContext.changePage(page); return false; } /** * @hidden * * @memberOf PagerElementComponent */ ngOnInit() { this.subscriptions = this.pagerContext.changes.subscribe(this.onChanges.bind(this)); this.subscriptions.add(this.localization.changes.subscribe(() => this.cd.markForCheck())); } ngOnDestroy() { if (this.subscriptions) { this.subscriptions.unsubscribe(); } } get prevArrowIcons() { return !this.localization.rtl ? ['caret-alt-to-left', 'caret-alt-left'] : ['caret-alt-to-right', 'caret-alt-right']; } get prevArrowSVGIcons() { return !this.localization.rtl ? [this.caretAltToLeftIcon, this.caretAltLeftIcon] : [this.caretAltToRightIcon, this.caretAltRightIcon]; } get nextArrowIcons() { return !this.localization.rtl ? ['caret-alt-right', 'caret-alt-to-right'] : ['caret-alt-left', 'caret-alt-to-left']; } get nextArrowSVGIcons() { return !this.localization.rtl ? [this.caretAltRightIcon, this.caretAltToRightIcon] : [this.caretAltLeftIcon, this.caretAltToLeftIcon]; } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: PagerElementComponent, deps: [{ token: i1.LocalizationService }, { token: i2.PagerContextService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: PagerElementComponent, selector: "kendo-pager-element", ngImport: i0, template: ``, isInline: true }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: PagerElementComponent, decorators: [{ type: Component, args: [{ selector: 'kendo-pager-element', template: `` }] }], ctorParameters: function () { return [{ type: i1.LocalizationService }, { type: i2.PagerContextService }, { type: i0.ChangeDetectorRef }]; } });