@@ -330,174 +330,184 @@ export const DataTablePagination = <TData = unknown,>({
330330 </ div >
331331 ) }
332332
333- { /* Center: Navigation controls */ }
334- { config . showNavigation && pageCount > 1 && (
335- < div className = "flex items-center gap-2" >
336- < Pagination >
337- < PaginationContent >
338- { /* First page */ }
339- < PaginationItem >
340- < PaginationLink
341- onClick = { ( ) => table . setPageIndex ( 0 ) }
342- className = { cn (
343- "cursor-pointer" ,
344- ! canPreviousPage && "pointer-events-none opacity-50" ,
345- ) }
346- aria-disabled = { ! canPreviousPage }
347- title = {
348- enableKeyboardShortcuts ? "First page (Home)" : "First page"
349- }
350- >
351- First
352- </ PaginationLink >
353- </ PaginationItem >
354-
355- { /* Fast previous (if enabled) */ }
356- { config . enableFastNavigation && currentPage > 5 && (
333+ { /* Center and Right side: Navigation controls and info */ }
334+ < div className = "flex flex-col gap-4 sm:flex-row sm:items-center sm:gap-8" >
335+ { /* Center: Navigation controls */ }
336+ { config . showNavigation && pageCount > 1 && (
337+ < div className = "flex items-center justify-center" >
338+ < Pagination >
339+ < PaginationContent >
340+ { /* First page */ }
357341 < PaginationItem >
358342 < PaginationLink
359- onClick = { handleFastPrevious }
360- className = "cursor-pointer"
361- aria-label = "Go back 5 pages"
343+ onClick = { ( ) => table . setPageIndex ( 0 ) }
344+ className = { cn (
345+ "cursor-pointer" ,
346+ ! canPreviousPage && "pointer-events-none opacity-50" ,
347+ ) }
348+ aria-disabled = { ! canPreviousPage }
362349 title = {
363350 enableKeyboardShortcuts
364- ? "Go back 5 pages (PageUp )"
365- : "Go back 5 pages "
351+ ? "First page (Home )"
352+ : "First page "
366353 }
367354 >
368- «
355+ First
369356 </ PaginationLink >
370357 </ PaginationItem >
371- ) }
372-
373- { /* Previous */ }
374- < PaginationItem >
375- < PaginationPrevious
376- onClick = { ( ) => table . previousPage ( ) }
377- className = { cn (
378- "cursor-pointer" ,
379- ! canPreviousPage && "pointer-events-none opacity-50" ,
380- ) }
381- aria-disabled = { ! canPreviousPage }
382- title = {
383- enableKeyboardShortcuts
384- ? "Previous page (←)"
385- : "Previous page"
386- }
387- />
388- </ PaginationItem >
389-
390- { /* Page numbers */ }
391- { visiblePageNumbers . map ( ( page , index ) => (
392- < PaginationItem key = { index } >
393- { page === "ellipsis" ? (
394- < PaginationEllipsis />
395- ) : (
358+
359+ { /* Fast previous (if enabled) */ }
360+ { config . enableFastNavigation && currentPage > 5 && (
361+ < PaginationItem >
396362 < PaginationLink
397- onClick = { ( ) => table . setPageIndex ( page - 1 ) }
398- isActive = { page === currentPage }
363+ onClick = { handleFastPrevious }
399364 className = "cursor-pointer"
365+ aria-label = "Go back 5 pages"
366+ title = {
367+ enableKeyboardShortcuts
368+ ? "Go back 5 pages (PageUp)"
369+ : "Go back 5 pages"
370+ }
400371 >
401- { page }
372+ «
402373 </ PaginationLink >
403- ) }
374+ </ PaginationItem >
375+ ) }
376+
377+ { /* Previous */ }
378+ < PaginationItem >
379+ < PaginationPrevious
380+ onClick = { ( ) => table . previousPage ( ) }
381+ className = { cn (
382+ "cursor-pointer" ,
383+ ! canPreviousPage && "pointer-events-none opacity-50" ,
384+ ) }
385+ aria-disabled = { ! canPreviousPage }
386+ title = {
387+ enableKeyboardShortcuts
388+ ? "Previous page (←)"
389+ : "Previous page"
390+ }
391+ />
392+ </ PaginationItem >
393+
394+ { /* Page numbers */ }
395+ { visiblePageNumbers . map ( ( page , index ) => (
396+ < PaginationItem key = { index } >
397+ { page === "ellipsis" ? (
398+ < PaginationEllipsis />
399+ ) : (
400+ < PaginationLink
401+ onClick = { ( ) => table . setPageIndex ( page - 1 ) }
402+ isActive = { page === currentPage }
403+ className = "cursor-pointer"
404+ >
405+ { page }
406+ </ PaginationLink >
407+ ) }
408+ </ PaginationItem >
409+ ) ) }
410+
411+ { /* Next */ }
412+ < PaginationItem >
413+ < PaginationNext
414+ onClick = { ( ) => table . nextPage ( ) }
415+ className = { cn (
416+ "cursor-pointer" ,
417+ ! canNextPage && "pointer-events-none opacity-50" ,
418+ ) }
419+ aria-disabled = { ! canNextPage }
420+ title = {
421+ enableKeyboardShortcuts ? "Next page (→)" : "Next page"
422+ }
423+ />
404424 </ PaginationItem >
405- ) ) }
406-
407- { /* Next */ }
408- < PaginationItem >
409- < PaginationNext
410- onClick = { ( ) => table . nextPage ( ) }
411- className = { cn (
412- "cursor-pointer" ,
413- ! canNextPage && "pointer-events-none opacity-50" ,
425+
426+ { /* Fast next (if enabled) */ }
427+ { config . enableFastNavigation &&
428+ currentPage <= pageCount - 5 && (
429+ < PaginationItem >
430+ < PaginationLink
431+ onClick = { handleFastNext }
432+ className = "cursor-pointer"
433+ aria-label = "Go forward 5 pages"
434+ title = {
435+ enableKeyboardShortcuts
436+ ? "Go forward 5 pages (PageDown)"
437+ : "Go forward 5 pages"
438+ }
439+ >
440+ »
441+ </ PaginationLink >
442+ </ PaginationItem >
414443 ) }
415- aria-disabled = { ! canNextPage }
416- title = {
417- enableKeyboardShortcuts ? "Next page (→)" : "Next page"
418- }
419- />
420- </ PaginationItem >
421-
422- { /* Fast next (if enabled) */ }
423- { config . enableFastNavigation && currentPage <= pageCount - 5 && (
444+
445+ { /* Last page */ }
424446 < PaginationItem >
425447 < PaginationLink
426- onClick = { handleFastNext }
427- className = "cursor-pointer"
428- aria-label = "Go forward 5 pages"
448+ onClick = { ( ) => table . setPageIndex ( pageCount - 1 ) }
449+ className = { cn (
450+ "cursor-pointer" ,
451+ ! canNextPage && "pointer-events-none opacity-50" ,
452+ ) }
453+ aria-disabled = { ! canNextPage }
429454 title = {
430- enableKeyboardShortcuts
431- ? "Go forward 5 pages (PageDown)"
432- : "Go forward 5 pages"
455+ enableKeyboardShortcuts ? "Last page (End)" : "Last page"
433456 }
434457 >
435- »
458+ Last
436459 </ PaginationLink >
437460 </ PaginationItem >
438- ) }
439-
440- { /* Last page */ }
441- < PaginationItem >
442- < PaginationLink
443- onClick = { ( ) => table . setPageIndex ( pageCount - 1 ) }
444- className = { cn (
445- "cursor-pointer" ,
446- ! canNextPage && "pointer-events-none opacity-50" ,
447- ) }
448- aria-disabled = { ! canNextPage }
449- title = {
450- enableKeyboardShortcuts ? "Last page (End)" : "Last page"
451- }
452- >
453- Last
454- </ PaginationLink >
455- </ PaginationItem >
456- </ PaginationContent >
457- </ Pagination >
458- </ div >
459- ) }
460-
461- { /* Right side: Page info and jump-to-page */ }
462- < div className = "flex items-center gap-4" >
463- { /* Page info */ }
464- { config . showPageInfo && (
465- < div className = "text-sm text-foreground" >
466- Showing { paginationInfo . totalRows > 0 ? paginationInfo . startRow : 0 }
467- -{ paginationInfo . endRow } of { paginationInfo . totalRows } entries
461+ </ PaginationContent >
462+ </ Pagination >
468463 </ div >
469464 ) }
470465
471- { /* Jump to page */ }
472- { config . enableJumpToPage && pageCount > 10 && (
473- < form onSubmit = { handleJumpToPage } className = "flex items-center gap-2" >
474- < span className = "text-sm" > Go to:</ span >
475- < input
476- ref = { jumpInputRef }
477- type = "number"
478- min = "1"
479- max = { pageCount }
480- value = { jumpToPage }
481- onChange = { ( e ) => setJumpToPage ( e . target . value ) }
482- className = "h-8 w-16 rounded-md border bg-background px-2 text-sm text-center"
483- placeholder = { currentPage . toString ( ) }
484- disabled = { loading }
485- title = {
486- enableKeyboardShortcuts
487- ? "Jump to page (Ctrl+G to focus)"
488- : "Jump to page"
489- }
490- aria-label = "Jump to page number"
491- />
492- < button
493- type = "submit"
494- className = "h-8 px-3 rounded-md border bg-background text-sm hover:bg-muted disabled:opacity-50"
495- disabled = { loading || ! jumpToPage }
466+ { /* Right side: Page info and jump-to-page */ }
467+ < div className = "flex items-center gap-4" >
468+ { /* Page info */ }
469+ { config . showPageInfo && (
470+ < div className = "text-sm text-foreground" >
471+ Showing{ " " }
472+ { paginationInfo . totalRows > 0 ? paginationInfo . startRow : 0 } -
473+ { paginationInfo . endRow } of { paginationInfo . totalRows } entries
474+ </ div >
475+ ) }
476+
477+ { /* Jump to page */ }
478+ { config . enableJumpToPage && pageCount > 10 && (
479+ < form
480+ onSubmit = { handleJumpToPage }
481+ className = "flex items-center gap-2"
496482 >
497- Go
498- </ button >
499- </ form >
500- ) }
483+ < span className = "text-sm" > Go to:</ span >
484+ < input
485+ ref = { jumpInputRef }
486+ type = "number"
487+ min = "1"
488+ max = { pageCount }
489+ value = { jumpToPage }
490+ onChange = { ( e ) => setJumpToPage ( e . target . value ) }
491+ className = "h-8 w-16 rounded-md border bg-background px-2 text-sm text-center"
492+ placeholder = { currentPage . toString ( ) }
493+ disabled = { loading }
494+ title = {
495+ enableKeyboardShortcuts
496+ ? "Jump to page (Ctrl+G to focus)"
497+ : "Jump to page"
498+ }
499+ aria-label = "Jump to page number"
500+ />
501+ < button
502+ type = "submit"
503+ className = "h-8 px-3 rounded-md border bg-background text-sm hover:bg-muted disabled:opacity-50"
504+ disabled = { loading || ! jumpToPage }
505+ >
506+ Go
507+ </ button >
508+ </ form >
509+ ) }
510+ </ div >
501511 </ div >
502512 </ div >
503513 ) ;
0 commit comments