diff --git a/Front/src/Componentes/PaginacionStepper.svelte b/Front/src/Componentes/PaginacionStepper.svelte index e62e219..f2ee2f4 100644 --- a/Front/src/Componentes/PaginacionStepper.svelte +++ b/Front/src/Componentes/PaginacionStepper.svelte @@ -3,25 +3,45 @@ let {currentPag, cantpag, - queryPag + queryPag, + centrado = false }:{ currentPag: number, cantpag: number, - queryPag: (a:number) => void} = $props(); + queryPag: (a:number) => void, + centrado:boolean + } = $props(); + + function getVisiblePages() { + if (!centrado || cantpag <= 5) { + return Array.from({ length: cantpag }, (_, i) => i + 1); + } + + if (currentPag <= 3) { + return [1, 2, 3, 4, 5]; + } else if (currentPag >= cantpag - 2) { + return [cantpag - 4, cantpag - 3, cantpag - 2, cantpag - 1, cantpag]; + } else { + return [currentPag - 2, currentPag - 1, currentPag, currentPag + 1, currentPag + 2]; + } + } + let visiblePages = $derived.by(getVisiblePages); + - let array = $derived.by(()=> Array.from({ length: cantpag }, (_, i) => i + 1)); -{#if cantpag>0} -