pagination.d.ts 5.2 KB

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