// frontend\src\components\ui\Pagination.tsx 'use client' import { type ReactNode } from 'react' import clsx from 'clsx' import { ChevronLeftIcon, ChevronRightIcon, ChevronDoubleLeftIcon, ChevronDoubleRightIcon, ChevronDownIcon, } from '@heroicons/react/20/solid' export type PaginationProps = { page: number // 1-based pageSize: number totalItems: number onPageChange: (page: number) => void showSummary?: boolean className?: string ariaLabel?: string prevLabel?: string nextLabel?: string firstLabel?: string lastLabel?: string } function clamp(n: number, min: number, max: number) { return Math.max(min, Math.min(max, n)) } function PageButton({ disabled, rounded, onClick, children, title, }: { disabled?: boolean rounded?: 'l' | 'r' | 'none' onClick?: () => void children: ReactNode title?: string }) { const roundedCls = rounded === 'l' ? 'rounded-l-md' : rounded === 'r' ? 'rounded-r-md' : '' return ( ) } export default function Pagination({ page, pageSize, totalItems, onPageChange, showSummary = false, className, ariaLabel = 'Pagination', prevLabel = 'Vorherige Seite', nextLabel = 'Nächste Seite', firstLabel = 'Erste Seite', lastLabel = 'Letzte Seite', }: PaginationProps) { const totalPages = Math.max( 1, Math.ceil((totalItems || 0) / Math.max(1, pageSize || 1)) ) const current = clamp(page || 1, 1, totalPages) if (totalPages <= 1) return null const from = totalItems === 0 ? 0 : (current - 1) * pageSize + 1 const to = Math.min(current * pageSize, totalItems) const go = (p: number) => onPageChange(clamp(p, 1, totalPages)) return (
{showSummary ? (

Showing {from} to{' '} {to} of{' '} {totalItems} results

) : null}
) }