Files
CollabTable/frontend/src/lib/components/ui/paginator.svelte
T
Gabriel20xx 6c1ea2da47
Docker / Docker Build & Push (push) Failing after 28s
Lint / Lint (push) Failing after 6s
Tests / Go backend (push) Failing after 4s
Tests / Dashboard checks (push) Failing after 6s
feat: add user credentials management and health monitoring features
- Implemented CredentialsDialog for updating user credentials.
- Created auth store with functions for managing authentication state.
- Added HealthWidget to display server health status.
- Introduced health monitoring functionality with polling.
- Developed AppShell layout to manage authentication and loading states.
- Added SettingsDialog for user preferences including theme and language.
- Created utility functions for list management and data fetching.
- Implemented dashboard view mode preferences.
- Integrated search functionality for filtering lists.
- Established theme management with local storage support.
- Added utility functions for class name management.
- Configured SvelteKit for static site generation with fallback.
- Set up Vite for development with proxy support for API calls.
- Created About and List detail pages with data fetching and display.
- Added favicon and updated project configuration files.
2026-08-03 22:38:45 +02:00

94 lines
3.1 KiB
Svelte
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script>
import { ChevronFirst, ChevronLast, ChevronLeft, ChevronRight } from '@lucide/svelte';
import Button from './button.svelte';
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from './select';
import { SimpleTooltip } from './tooltip';
let { page, pageSize, pageSizes = [12, 24, 48, 96], pageLength = 0, totalLength = 0, onPaging } = $props();
const hasPreviousPage = $derived(page > 1);
const firstItemIndex = $derived((page - 1) * pageSize + 1);
const lastItemIndex = $derived((page - 1) * pageSize + pageLength);
const hasNextPage = $derived(page * pageSize < totalLength);
// Passed as `Select`'s `items` prop so the trigger shows the right label immediately, even
// before the dropdown has ever been opened - bits-ui can't rely on `Select.Item` having
// mounted to the DOM yet to read its label back off of it.
const pageSizeItems = $derived(pageSizes.map((size) => ({ value: String(size), label: String(size) })));
</script>
<div class="flex flex-wrap items-center justify-end gap-4 px-2 py-3 text-sm">
<Select
type="single"
value={String(pageSize)}
items={pageSizeItems}
onValueChange={(value) => onPaging({ page: 1, pageSize: Number(value) })}
>
<SelectTrigger class="w-24">
<SelectValue />
</SelectTrigger>
<SelectContent>
{#each pageSizeItems as item (item.value)}
<SelectItem value={item.value} label={item.label}>{item.label}</SelectItem>
{/each}
</SelectContent>
</Select>
<p class="text-muted-fg">
{firstItemIndex.toLocaleString()}–{lastItemIndex.toLocaleString()} of {totalLength.toLocaleString()}
</p>
<div class="flex items-center gap-1">
<SimpleTooltip label="First page">
{#snippet children({ props })}
<Button
{...props}
variant="ghost"
size="icon"
disabled={!hasPreviousPage}
onclick={() => onPaging({ page: 1, pageSize })}
>
<ChevronFirst class="size-4" />
</Button>
{/snippet}
</SimpleTooltip>
<SimpleTooltip label="Previous page">
{#snippet children({ props })}
<Button
{...props}
variant="ghost"
size="icon"
disabled={!hasPreviousPage}
onclick={() => onPaging({ page: page - 1, pageSize })}
>
<ChevronLeft class="size-4" />
</Button>
{/snippet}
</SimpleTooltip>
<SimpleTooltip label="Next page">
{#snippet children({ props })}
<Button
{...props}
variant="ghost"
size="icon"
disabled={!hasNextPage}
onclick={() => onPaging({ page: page + 1, pageSize })}
>
<ChevronRight class="size-4" />
</Button>
{/snippet}
</SimpleTooltip>
<SimpleTooltip label="Last page">
{#snippet children({ props })}
<Button
{...props}
variant="ghost"
size="icon"
disabled={!hasNextPage}
onclick={() => onPaging({ page: Math.max(1, Math.ceil(totalLength / pageSize)), pageSize })}
>
<ChevronLast class="size-4" />
</Button>
{/snippet}
</SimpleTooltip>
</div>
</div>