import * as React from 'react'; import { ChevronLeftIcon, ChevronRightIcon, MoreHorizontalIcon } from 'lucide-react'; import { cn } from '@/lib/utils'; import { Button } from '@/components/ui/button'; interface DataPaginationProps { /** 1-indexado, compatível com `page`/`limit`/`meta.total` da API (Etapas 1–8 do backend). */ page: number; limit: number; total: number; onPageChange: (page: number) => void; className?: string; } function getPageNumbers(page: number, totalPages: number): (number | 'ellipsis')[] { if (totalPages <= 7) return Array.from({ length: totalPages }, (_, i) => i + 1); const pages = new Set([1, totalPages, page, page - 1, page + 1]); const sorted = [...pages].filter((p) => p >= 1 && p <= totalPages).sort((a, b) => a - b); const result: (number | 'ellipsis')[] = []; sorted.forEach((p, i) => { if (i > 0 && p - sorted[i - 1] > 1) result.push('ellipsis'); result.push(p); }); return result; } /** Controles de página compatíveis com os parâmetros de paginação do backend (Etapa 12). */ function DataPagination({ page, limit, total, onPageChange, className }: DataPaginationProps) { const totalPages = Math.max(1, Math.ceil(total / limit)); const firstItem = total === 0 ? 0 : (page - 1) * limit + 1; const lastItem = Math.min(page * limit, total); return ( ); } export { DataPagination };