index.blade.php 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. @props([
  2. 'currentPageOptionProperty' => 'tableRecordsPerPage',
  3. 'extremeLinks' => false,
  4. 'paginator',
  5. 'pageOptions' => [],
  6. ])
  7. @php
  8. use Illuminate\Contracts\Pagination\CursorPaginator;
  9. $isRtl = __('filament-panels::layout.direction') === 'rtl';
  10. $isSimple = ! $paginator instanceof \Illuminate\Pagination\LengthAwarePaginator;
  11. @endphp
  12. <nav
  13. aria-label="{{ __('filament::components/pagination.label') }}"
  14. role="navigation"
  15. {{
  16. $attributes->class([
  17. 'fi-pagination',
  18. 'fi-simple' => $isSimple,
  19. ])
  20. }}
  21. >
  22. @if (! $paginator->onFirstPage())
  23. @php
  24. if ($paginator instanceof CursorPaginator) {
  25. $wireClickAction = "setPage('{$paginator->previousCursor()->encode()}', '{$paginator->getCursorName()}')";
  26. } else {
  27. $wireClickAction = "previousPage('{$paginator->getPageName()}')";
  28. }
  29. @endphp
  30. <x-filament::button
  31. color="gray"
  32. rel="prev"
  33. :wire:click="$wireClickAction"
  34. :wire:key="$this->getId() . '.pagination.previous'"
  35. class="fi-pagination-previous-btn"
  36. >
  37. {{ __('filament::components/pagination.actions.previous.label') }}
  38. </x-filament::button>
  39. @endif
  40. @if (! $isSimple)
  41. <span class="fi-pagination-overview">
  42. {{
  43. trans_choice(
  44. 'filament::components/pagination.overview',
  45. $paginator->total(),
  46. [
  47. 'first' => \Illuminate\Support\Number::format($paginator->firstItem() ?? 0),
  48. 'last' => \Illuminate\Support\Number::format($paginator->lastItem() ?? 0),
  49. 'total' => \Illuminate\Support\Number::format($paginator->total()),
  50. ],
  51. )
  52. }}
  53. </span>
  54. @endif
  55. @if (count($pageOptions) > 1)
  56. <div class="fi-pagination-records-per-page-select-ctn">
  57. <label class="fi-pagination-records-per-page-select fi-compact">
  58. <x-filament::input.wrapper>
  59. <x-filament::input.select
  60. :wire:model.live="$currentPageOptionProperty"
  61. >
  62. @foreach ($pageOptions as $option)
  63. <option value="{{ $option }}">
  64. {{ $option === 'all' ? __('filament::components/pagination.fields.records_per_page.options.all') : $option }}
  65. </option>
  66. @endforeach
  67. </x-filament::input.select>
  68. </x-filament::input.wrapper>
  69. <span class="fi-sr-only">
  70. {{ __('filament::components/pagination.fields.records_per_page.label') }}
  71. </span>
  72. </label>
  73. <label class="fi-pagination-records-per-page-select">
  74. <x-filament::input.wrapper
  75. :prefix="__('filament::components/pagination.fields.records_per_page.label')"
  76. >
  77. <x-filament::input.select
  78. :wire:model.live="$currentPageOptionProperty"
  79. >
  80. @foreach ($pageOptions as $option)
  81. <option value="{{ $option }}">
  82. {{ $option === 'all' ? __('filament::components/pagination.fields.records_per_page.options.all') : $option }}
  83. </option>
  84. @endforeach
  85. </x-filament::input.select>
  86. </x-filament::input.wrapper>
  87. </label>
  88. </div>
  89. @endif
  90. @if ($paginator->hasMorePages())
  91. @php
  92. if ($paginator instanceof CursorPaginator) {
  93. $wireClickAction = "setPage('{$paginator->nextCursor()->encode()}', '{$paginator->getCursorName()}')";
  94. } else {
  95. $wireClickAction = "nextPage('{$paginator->getPageName()}')";
  96. }
  97. @endphp
  98. <x-filament::button
  99. color="gray"
  100. rel="next"
  101. :wire:click="$wireClickAction"
  102. :wire:key="$this->getId() . '.pagination.next'"
  103. class="fi-pagination-next-btn"
  104. >
  105. {{ __('filament::components/pagination.actions.next.label') }}
  106. </x-filament::button>
  107. @endif
  108. @if ((! $isSimple) && $paginator->hasPages())
  109. <ol class="fi-pagination-items">
  110. @if (! $paginator->onFirstPage())
  111. @if ($extremeLinks)
  112. <x-filament::pagination.item
  113. :aria-label="__('filament::components/pagination.actions.first.label')"
  114. :icon="$isRtl ? \Filament\Support\Icons\Heroicon::ChevronDoubleRight : \Filament\Support\Icons\Heroicon::ChevronDoubleLeft"
  115. :icon-alias="
  116. $isRtl
  117. ? \Filament\Support\View\SupportIconAlias::PAGINATION_FIRST_BUTTON_RTL
  118. : \Filament\Support\View\SupportIconAlias::PAGINATION_FIRST_BUTTON
  119. "
  120. rel="first"
  121. :wire:click="'gotoPage(1, \'' . $paginator->getPageName() . '\')'"
  122. :wire:key="$this->getId() . '.pagination.first'"
  123. />
  124. @endif
  125. <x-filament::pagination.item
  126. :aria-label="__('filament::components/pagination.actions.previous.label')"
  127. :icon="$isRtl ? \Filament\Support\Icons\Heroicon::ChevronRight : \Filament\Support\Icons\Heroicon::ChevronLeft"
  128. {{-- @deprecated Use `SupportIconAlias::PAGINATION_PREVIOUS_BUTTON_RTL` instead of `SupportIconAlias::PAGINATION_PREVIOUS_BUTTON` for RTL. --}}
  129. :icon-alias="
  130. $isRtl
  131. ? [
  132. \Filament\Support\View\SupportIconAlias::PAGINATION_PREVIOUS_BUTTON_RTL,
  133. \Filament\Support\View\SupportIconAlias::PAGINATION_PREVIOUS_BUTTON,
  134. ]
  135. : \Filament\Support\View\SupportIconAlias::PAGINATION_PREVIOUS_BUTTON
  136. "
  137. rel="prev"
  138. :wire:click="'previousPage(\'' . $paginator->getPageName() . '\')'"
  139. :wire:key="$this->getId() . '.pagination.previous'"
  140. />
  141. @endif
  142. @foreach ($paginator->render()->offsetGet('elements') as $element)
  143. @if (is_string($element))
  144. <x-filament::pagination.item disabled :label="$element" />
  145. @endif
  146. @if (is_array($element))
  147. @foreach ($element as $page => $url)
  148. <x-filament::pagination.item
  149. :active="$page === $paginator->currentPage()"
  150. :aria-label="trans_choice('filament::components/pagination.actions.go_to_page.label', $page, ['page' => \Illuminate\Support\Number::format($page)])"
  151. :label="\Illuminate\Support\Number::format($page)"
  152. :wire:click="'gotoPage(' . $page . ', \'' . $paginator->getPageName() . '\')'"
  153. :wire:key="$this->getId() . '.pagination.' . $paginator->getPageName() . '.' . $page"
  154. />
  155. @endforeach
  156. @endif
  157. @endforeach
  158. @if ($paginator->hasMorePages())
  159. <x-filament::pagination.item
  160. :aria-label="__('filament::components/pagination.actions.next.label')"
  161. :icon="$isRtl ? \Filament\Support\Icons\Heroicon::ChevronLeft : \Filament\Support\Icons\Heroicon::ChevronRight"
  162. {{-- @deprecated Use `SupportIconAlias::PAGINATION_NEXT_BUTTON_RTL` instead of `SupportIconAlias::PAGINATION_NEXT_BUTTON` for RTL. --}}
  163. :icon-alias="
  164. $isRtl
  165. ? [
  166. \Filament\Support\View\SupportIconAlias::PAGINATION_NEXT_BUTTON_RTL,
  167. \Filament\Support\View\SupportIconAlias::PAGINATION_NEXT_BUTTON,
  168. ]
  169. : \Filament\Support\View\SupportIconAlias::PAGINATION_NEXT_BUTTON
  170. "
  171. rel="next"
  172. :wire:click="'nextPage(\'' . $paginator->getPageName() . '\')'"
  173. :wire:key="$this->getId() . '.pagination.next'"
  174. />
  175. @if ($extremeLinks)
  176. <x-filament::pagination.item
  177. :aria-label="__('filament::components/pagination.actions.last.label')"
  178. :icon="$isRtl ? \Filament\Support\Icons\Heroicon::ChevronDoubleLeft : \Filament\Support\Icons\Heroicon::ChevronDoubleRight"
  179. :icon-alias="
  180. $isRtl
  181. ? \Filament\Support\View\SupportIconAlias::PAGINATION_LAST_BUTTON_RTL
  182. : \Filament\Support\View\SupportIconAlias::PAGINATION_LAST_BUTTON
  183. "
  184. rel="last"
  185. :wire:click="'gotoPage(' . $paginator->lastPage() . ', \'' . $paginator->getPageName() . '\')'"
  186. :wire:key="$this->getId() . '.pagination.last'"
  187. />
  188. @endif
  189. @endif
  190. </ol>
  191. @endif
  192. </nav>