"use client" import type { ReactNode } from "react" import { ChevronLeft, ChevronRight } from "lucide-react" import { Button } from "@/components/ui/button" import { Label } from "@/components/ui/label" import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@/components/ui/select" import { cn } from "@/lib/utils" export type AdminListSortOption = { value: string label: string } const DEFAULT_PAGE_SIZE_OPTIONS = [10, 25, 50, 100] as const export function AdminListControls({ page, pageSize, total, totalPages, pageSizeOptions = DEFAULT_PAGE_SIZE_OPTIONS, sort, sortOptions, onPageChange, onPageSizeChange, onSortChange, itemLabel, compact = false, leading, }: { page: number pageSize: number total: number totalPages: number pageSizeOptions?: readonly number[] sort: string sortOptions: readonly AdminListSortOption[] onPageChange: (page: number) => void onPageSizeChange: (pageSize: number) => void onSortChange: (sort: string) => void itemLabel: string /** Barre outils dense : labels dans les selects, pagination icônes. */ compact?: boolean /** Champ ou filtre aligné à gauche (ex. recherche). */ leading?: ReactNode }) { const rangeStart = total === 0 ? 0 : (page - 1) * pageSize + 1 const rangeEnd = Math.min(page * pageSize, total) const rangeLabel = total === 0 ? `0 ${itemLabel}` : `${rangeStart.toLocaleString("fr-FR")}–${rangeEnd.toLocaleString("fr-FR")} sur ${total.toLocaleString("fr-FR")} ${itemLabel}` const pageSizeSelect = ( ) const sortSelect = ( ) const pagination = compact ? (
) : (
) if (compact) { return (
{leading} {pageSizeSelect} {sortSelect}

{rangeLabel}

{pagination}
) } return (
{pageSizeSelect}
{sortSelect}

{rangeLabel}

{pagination}
) }