ui/table_state.svelte.ts

Reactive state for database table pagination and data fetching.

Extends Loadable to manage paginated table data with column metadata, row deletion, and derived pagination controls.

@example

const table = new TableState(); await table.fetch('accounts', 0, 50); // pagination if (table.has_next) table.go_next(); await table.fetch(table.table_name, table.offset, table.limit); // deletion const deleted = await table.delete_row(table.rows[0]);

@example

<script lang="ts"> import {TableState} from '@fuzdev/fuz_app/ui/table_state.svelte.js'; const table = new TableState(); table.fetch('accounts'); </script> {#if table.loading} <p>loading…</p> {:else if table.error} <p>{table.error}</p> {:else} <p>showing {table.showing_start}{table.showing_end} of {table.total}</p> {/if}

Declarations
#

2 declarations

view source

TABLE_LIMIT_MAX
#

TableState
#

ui/table_state.svelte.ts view source

inheritance

extends:

table_name

type string

columns

type Array<ColumnInfo>

rows

type Array<Record<string, unknown>>

total

offset

limit

primary_key

type string | null

deleting

type string | null

delete_error

type string | null

showing_start

readonly

showing_end

readonly

has_prev

readonly

has_next

readonly

fetch

type (table_name: string, offset?: number, limit?: number): Promise<void>

table_name
type string
offset
type number
default 0
limit
type number
default 100
returns Promise<void>

go_prev

type (): void

returns void

go_next

type (): void

returns void

delete_row

type (row: Record<string, unknown>): Promise<boolean>

row
type Record<string, unknown>
returns Promise<boolean>

Depends on
#