import { type Readable, type Updater, type Writable } from 'svelte/store'; import type { NewTablePropSet, TablePlugin } from '../types/TablePlugin.js'; /** * Configuration options for the addPagination plugin. * Supports both client-side and server-side pagination modes. */ export type PaginationConfig = { /** Initial page index (0-based). Defaults to 0. */ initialPageIndex?: number; /** Initial page size. Defaults to 10. */ initialPageSize?: number; } & ({ /** Client-side pagination mode. */ serverSide?: false | undefined; serverItemCount?: undefined; } | { /** Server-side pagination mode. */ serverSide: true; /** A readable store containing the total item count from the server. */ serverItemCount: Readable; }); /** * State exposed by the addPagination plugin. */ export interface PaginationState { /** Writable store for the current page size. */ pageSize: Writable; /** Writable store for the current page index (0-based). */ pageIndex: Writable; /** Readable store for the total number of pages. */ pageCount: Readable; /** Readable store indicating if there's a previous page. */ hasPreviousPage: Readable; /** Readable store indicating if there's a next page. */ hasNextPage: Readable; } /** * Creates a page store with pagination state and navigation helpers. * * @param config - Configuration for the page store. * @returns An object containing pagination state stores. */ export declare const createPageStore: ({ items, initialPageSize, initialPageIndex, serverSide, serverItemCount }: PageStoreConfig) => { pageSize: { subscribe: (this: void, run: import("svelte/store").Subscriber, invalidate?: () => void) => import("svelte/store").Unsubscriber; update: (fn: Updater) => void; set: (newPageSize: number) => void; }; pageIndex: Writable; pageCount: Readable; serverItemCount: Readable | undefined; hasPreviousPage: Readable; hasNextPage: Readable; }; /** * Configuration for createPageStore. */ export interface PageStoreConfig { /** Readable store of items to paginate. */ items: Readable; /** Initial page size. */ initialPageSize?: number; /** Initial page index (0-based). */ initialPageIndex?: number; /** Whether pagination is server-side. */ serverSide?: boolean; /** Total item count from server (for server-side pagination). */ serverItemCount?: Readable; } /** * Creates a pagination plugin that enables paged navigation through table rows. * Supports both client-side and server-side pagination. * * @template Item - The type of data items in the table. * @param config - Configuration options for pagination. * @returns A TablePlugin that provides pagination functionality. * @example * ```typescript * const table = createTable(data, { * page: addPagination({ * initialPageSize: 20, * initialPageIndex: 0 * }) * }) * * // Navigate pages * const { pageIndex, pageCount, hasNextPage } = table.pluginStates.page * if ($hasNextPage) { * pageIndex.update(n => n + 1) * } * ``` */ export declare const addPagination: ({ initialPageIndex, initialPageSize, serverSide, serverItemCount }?: PaginationConfig) => TablePlugin, NewTablePropSet>;