UNPKG

@visa/nova-angular

Version:

Visa Product Design System Nova Angular library

89 lines (88 loc) 3.4 kB
/** * Copyright (c) 2025 Visa, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * **/ import { WritableSignal } from '@angular/core'; import * as i0 from "@angular/core"; /** * Service to create pagination behavior. Intended for use with pagination component. */ export declare class PaginationService { constructor(); /** * Array of page numbers. */ pageItems: number[]; /** * Array of visible page numbers, set by <code>setPages()</code>. */ visiblePages: WritableSignal<number[]>; /** * Current page number, set by <code>changePage()</code>. */ currentPage: number; /** * Number of pages to show in the middle section of the pagination, between ellipses. */ middleLimit: number; /** * Number of pages to show at the start and end of the pagination, before and after ellipses. */ startEndLimit: number; /** * First page number to start pagination with. */ startPage: number; /** * Total number of pages. */ totalPages: number; /** * Last page number, calculated as (this.totalPages + this.startPage - 1). */ lastPage: WritableSignal<number>; /** * Signal to indicate if current page is the first page. */ isFirst: WritableSignal<boolean>; /** * Signal to indicate if current page is the last page. */ isLast: WritableSignal<boolean>; /** * The range method creates an array containing a sequence of numbers within a specified range, typically used for generating page numbers in pagination. * @param start Starting number of range. * @param size Size of array to return. * @returns Array with numbers from start to start + size. */ range(start: number, size: number): number[]; /** * The setPages method sets the visible page block based on the current page, ensuring that the correct sequence of pages is displayed. */ setPages(): void; /** * The changepage method sets the currentPage to the specified page and updates the visible pages, resetting to the starting page if the specified currentPage is out of the valid range. * @param page Number to set as new current page. * @returns New current page. */ changePage(page: number): number; /** * The initializePages method sets variables and visible pages for pagination. It should be called during initialization and will use default values unless values are set beforehand by assigning them directly to <code>PaginationService.variableName</code>. * @param currentPage Current starting page to initialize pagination with. */ initializePages(currentPage: number): void; static ɵfac: i0.ɵɵFactoryDeclaration<PaginationService, never>; static ɵprov: i0.ɵɵInjectableDeclaration<PaginationService>; }