UNPKG

6.15 kBTypeScriptView Raw
1import { EventEmitter, OnChanges, SimpleChanges, TemplateRef } from '@angular/core';
2import { NgbPaginationConfig } from './pagination-config';
3/**
4 * A context for the
5 * * `NgbPaginationFirst`
6 * * `NgbPaginationPrevious`
7 * * `NgbPaginationNext`
8 * * `NgbPaginationLast`
9 * * `NgbPaginationEllipsis`
10 * * `NgbPaginationPages`
11 *
12 * link templates in case you want to override one.
13 *
14 * @since 4.1.0
15 */
16export interface NgbPaginationLinkContext {
17 /**
18 * Page number displayed by the current link.
19 */
20 currentPage: number;
21 /**
22 * If `true`, the current link is disabled.
23 */
24 disabled: boolean;
25}
26/**
27 * A context for the `NgbPaginationNumber` link template in case you want to override one.
28 *
29 * Extends `NgbPaginationLinkContext`.
30 *
31 * @since 4.1.0
32 */
33export interface NgbPaginationNumberContext extends NgbPaginationLinkContext {
34 /**
35 * The page number, displayed by the current page link.
36 */
37 $implicit: number;
38}
39/**
40 * A context for the `NgbPaginationPages` pages template in case you want to override
41 * the way all pages are displayed.
42 *
43 * @since 9.1.0
44 */
45export interface NgbPaginationPagesContext {
46 /**
47 * The currently selected page number.
48 */
49 $implicit: number;
50 /**
51 * If `true`, pagination is disabled.
52 */
53 disabled: boolean;
54 /**
55 * Pages numbers that should be rendered starting with 1.
56 */
57 pages: number[];
58}
59/**
60 * A directive to match the 'ellipsis' link template
61 *
62 * @since 4.1.0
63 */
64export declare class NgbPaginationEllipsis {
65 templateRef: TemplateRef<NgbPaginationLinkContext>;
66 constructor(templateRef: TemplateRef<NgbPaginationLinkContext>);
67}
68/**
69 * A directive to match the 'first' link template
70 *
71 * @since 4.1.0
72 */
73export declare class NgbPaginationFirst {
74 templateRef: TemplateRef<NgbPaginationLinkContext>;
75 constructor(templateRef: TemplateRef<NgbPaginationLinkContext>);
76}
77/**
78 * A directive to match the 'last' link template
79 *
80 * @since 4.1.0
81 */
82export declare class NgbPaginationLast {
83 templateRef: TemplateRef<NgbPaginationLinkContext>;
84 constructor(templateRef: TemplateRef<NgbPaginationLinkContext>);
85}
86/**
87 * A directive to match the 'next' link template
88 *
89 * @since 4.1.0
90 */
91export declare class NgbPaginationNext {
92 templateRef: TemplateRef<NgbPaginationLinkContext>;
93 constructor(templateRef: TemplateRef<NgbPaginationLinkContext>);
94}
95/**
96 * A directive to match the page 'number' link template
97 *
98 * @since 4.1.0
99 */
100export declare class NgbPaginationNumber {
101 templateRef: TemplateRef<NgbPaginationNumberContext>;
102 constructor(templateRef: TemplateRef<NgbPaginationNumberContext>);
103}
104/**
105 * A directive to match the 'previous' link template
106 *
107 * @since 4.1.0
108 */
109export declare class NgbPaginationPrevious {
110 templateRef: TemplateRef<NgbPaginationLinkContext>;
111 constructor(templateRef: TemplateRef<NgbPaginationLinkContext>);
112}
113/**
114 * A directive to match the 'pages' whole content
115 *
116 * @since 9.1.0
117 */
118export declare class NgbPaginationPages {
119 templateRef: TemplateRef<NgbPaginationPagesContext>;
120 constructor(templateRef: TemplateRef<NgbPaginationPagesContext>);
121}
122/**
123 * A component that displays page numbers and allows to customize them in several ways.
124 */
125export declare class NgbPagination implements OnChanges {
126 pageCount: number;
127 pages: number[];
128 tplEllipsis: NgbPaginationEllipsis;
129 tplFirst: NgbPaginationFirst;
130 tplLast: NgbPaginationLast;
131 tplNext: NgbPaginationNext;
132 tplNumber: NgbPaginationNumber;
133 tplPrevious: NgbPaginationPrevious;
134 tplPages: NgbPaginationPages;
135 /**
136 * If `true`, pagination links will be disabled.
137 */
138 disabled: boolean;
139 /**
140 * If `true`, the "First" and "Last" page links are shown.
141 */
142 boundaryLinks: boolean;
143 /**
144 * If `true`, the "Next" and "Previous" page links are shown.
145 */
146 directionLinks: boolean;
147 /**
148 * If `true`, the ellipsis symbols and first/last page numbers will be shown when `maxSize` > number of pages.
149 */
150 ellipses: boolean;
151 /**
152 * Whether to rotate pages when `maxSize` > number of pages.
153 *
154 * The current page always stays in the middle if `true`.
155 */
156 rotate: boolean;
157 /**
158 * The number of items in your paginated collection.
159 *
160 * Note, that this is not the number of pages. Page numbers are calculated dynamically based on
161 * `collectionSize` and `pageSize`. Ex. if you have 100 items in your collection and displaying 20 items per page,
162 * you'll end up with 5 pages.
163 */
164 collectionSize: number;
165 /**
166 * The maximum number of pages to display.
167 */
168 maxSize: number;
169 /**
170 * The current page.
171 *
172 * Page numbers start with `1`.
173 */
174 page: number;
175 /**
176 * The number of items per page.
177 */
178 pageSize: number;
179 /**
180 * An event fired when the page is changed. Will fire only if collection size is set and all values are valid.
181 *
182 * Event payload is the number of the newly selected page.
183 *
184 * Page numbers start with `1`.
185 */
186 pageChange: EventEmitter<number>;
187 /**
188 * The pagination display size.
189 *
190 * Bootstrap currently supports small and large sizes.
191 */
192 size: 'sm' | 'lg';
193 constructor(config: NgbPaginationConfig);
194 hasPrevious(): boolean;
195 hasNext(): boolean;
196 nextDisabled(): boolean;
197 previousDisabled(): boolean;
198 selectPage(pageNumber: number): void;
199 ngOnChanges(changes: SimpleChanges): void;
200 isEllipsis(pageNumber: any): boolean;
201 /**
202 * Appends ellipses and first/last page number to the displayed pages
203 */
204 private _applyEllipses;
205 /**
206 * Rotates page numbers based on maxSize items visible.
207 * Currently selected page stays in the middle:
208 *
209 * Ex. for selected page = 6:
210 * [5,*6*,7] for maxSize = 3
211 * [4,5,*6*,7] for maxSize = 4
212 */
213 private _applyRotation;
214 /**
215 * Paginates page numbers based on maxSize items per page.
216 */
217 private _applyPagination;
218 private _setPageInRange;
219 private _updatePages;
220}