diff --git a/src/lib/Pagination.svelte b/src/lib/Pagination.svelte index b07eeae..ea3aa9f 100644 --- a/src/lib/Pagination.svelte +++ b/src/lib/Pagination.svelte @@ -2,10 +2,15 @@ let { items, itemsPerPage, - pageItems = $bindable() - }: { items: Array; itemsPerPage: number; pageItems: Array } = $props(); + pageItems = $bindable(), + currentPage = 0 + }: { + items: Array; + itemsPerPage: number; + pageItems: Array; + currentPage?: number; + } = $props(); - let currentPage = $state(0); let pageIndexStart = $derived(currentPage * itemsPerPage); let pageIndexEnd = $derived(Math.min(itemsPerPage * (currentPage + 1), items.length)); @@ -20,21 +25,23 @@ showing {pageIndexStart + 1} to {pageIndexEnd} of {items.length} - entires + entires ()

- currentPage--}>prev - currentPage++}>next
- - diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 15a4025..8ae14fb 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -1,4 +1,5 @@