pagination-controls.directive.d.ts 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import { ChangeDetectorRef, EventEmitter } from '@angular/core';
  2. import { PaginationService } from './pagination.service';
  3. export interface Page {
  4. label: string;
  5. value: any;
  6. }
  7. /**
  8. * This directive is what powers all pagination controls components, including the default one.
  9. * It exposes an API which is hooked up to the PaginationService to keep the PaginatePipe in sync
  10. * with the pagination controls.
  11. */
  12. export declare class PaginationControlsDirective {
  13. private service;
  14. private changeDetectorRef;
  15. id: string;
  16. maxSize: number;
  17. pageChange: EventEmitter<number>;
  18. pages: Page[];
  19. private changeSub;
  20. constructor(service: PaginationService, changeDetectorRef: ChangeDetectorRef);
  21. ngOnInit(): void;
  22. ngOnChanges(changes: any): void;
  23. ngOnDestroy(): void;
  24. /**
  25. * Go to the previous page
  26. */
  27. previous(): void;
  28. /**
  29. * Go to the next page
  30. */
  31. next(): void;
  32. /**
  33. * Returns true if current page is first page
  34. */
  35. isFirstPage(): boolean;
  36. /**
  37. * Returns true if current page is last page
  38. */
  39. isLastPage(): boolean;
  40. /**
  41. * Set the current page number.
  42. */
  43. setCurrent(page: number): void;
  44. /**
  45. * Get the current page number.
  46. */
  47. getCurrent(): number;
  48. /**
  49. * Returns the last page number
  50. */
  51. getLastPage(): number;
  52. getTotalItems(): number;
  53. private checkValidId;
  54. /**
  55. * Updates the page links and checks that the current page is valid. Should run whenever the
  56. * PaginationService.change stream emits a value matching the current ID, or when any of the
  57. * input values changes.
  58. */
  59. private updatePageLinks;
  60. /**
  61. * Checks that the instance.currentPage property is within bounds for the current page range.
  62. * If not, return a correct value for currentPage, or the current value if OK.
  63. */
  64. private outOfBoundCorrection;
  65. /**
  66. * Returns an array of Page objects to use in the pagination controls.
  67. */
  68. private createPageArray;
  69. /**
  70. * Given the position in the sequence of pagination links [i],
  71. * figure out what page number corresponds to that position.
  72. */
  73. private calculatePageNumber;
  74. }