pagination.html 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <div class="flex flex-wrap items-center gap-4">
  2. @if (showTotal()) {
  3. <span class="text-sm text-muted">共 {{ total() }} 条</span>
  4. }
  5. @if (simple()) {
  6. <div class="flex items-center gap-1.5">
  7. <button
  8. type="button"
  9. [class]="navClasses()"
  10. (click)="prev()"
  11. [disabled]="currentPage() <= 1"
  12. aria-label="上一页"
  13. >
  14. <i class="fa-solid fa-angle-left" aria-hidden="true"></i>
  15. </button>
  16. <span class="min-w-20 px-2 text-center text-sm text-ink-2">{{ currentPage() }} / {{ totalPages() }}</span>
  17. <button
  18. type="button"
  19. [class]="navClasses()"
  20. (click)="next()"
  21. [disabled]="currentPage() >= totalPages()"
  22. aria-label="下一页"
  23. >
  24. <i class="fa-solid fa-angle-right" aria-hidden="true"></i>
  25. </button>
  26. </div>
  27. } @else {
  28. <div class="flex items-center gap-1.5">
  29. <button
  30. type="button"
  31. [class]="navClasses()"
  32. (click)="prev()"
  33. [disabled]="currentPage() <= 1"
  34. aria-label="上一页"
  35. >
  36. <i class="fa-solid fa-angle-left" aria-hidden="true"></i>
  37. </button>
  38. @for (p of pageItems(); track $index) {
  39. @if (p === '…') {
  40. <span class="select-none px-1 text-sm text-muted" aria-hidden="true">…</span>
  41. } @else {
  42. <button
  43. type="button"
  44. [class]="pageClasses(p === currentPage())"
  45. (click)="go(p)"
  46. [attr.aria-current]="p === currentPage() ? 'page' : null"
  47. >
  48. {{ p }}
  49. </button>
  50. }
  51. }
  52. <button
  53. type="button"
  54. [class]="navClasses()"
  55. (click)="next()"
  56. [disabled]="currentPage() >= totalPages()"
  57. aria-label="下一页"
  58. >
  59. <i class="fa-solid fa-angle-right" aria-hidden="true"></i>
  60. </button>
  61. </div>
  62. <div class="flex items-center gap-2">
  63. <input
  64. type="number"
  65. min="1"
  66. [attr.max]="totalPages()"
  67. [value]="jumpValue()"
  68. (input)="onJumpInput($event)"
  69. (keydown)="onJumpKeydown($event)"
  70. class="h-8 w-16 rounded-lg border border-edge bg-surface px-2 text-center text-sm text-ink outline-none transition-colors focus:border-primary"
  71. placeholder="页码"
  72. aria-label="跳转到页码"
  73. />
  74. <button type="button" [class]="jumpBtnClasses" (click)="jump()">跳转</button>
  75. </div>
  76. }
  77. </div>