import { BodyRow, DataBodyRow } from './bodyRows.js'; import { FlatColumn, type Column } from './columns.js'; import type { Table } from './createTable.js'; import { HeaderRow } from './headerRows.js'; import type { AnyPlugins, PluginStates } from './types/TablePlugin.js'; import { type Readable, type Writable } from 'svelte/store'; /** * HTML attributes for the table element. * * @template Item - The type of data items in the table. * @template Plugins - The plugins used by the table. */ export type TableAttributes = Record & { role: 'table'; }; /** * HTML attributes for the table head element. * * @template Item - The type of data items in the table. * @template Plugins - The plugins used by the table. */ export type TableHeadAttributes = Record; /** * HTML attributes for the table body element. * * @template Item - The type of data items in the table. * @template Plugins - The plugins used by the table. */ export type TableBodyAttributes = Record & { role: 'rowgroup'; }; /** * Debug information for performance analysis of the table view model. * Provides metrics about derivation chains and call counts. */ export interface ViewModelDebug { /** Number of plugins active */ pluginCount: number; /** Names of active plugins */ pluginNames: string[]; /** Number of derived stores in each chain */ derivedStoreCount: { tableAttrs: number; tableHeadAttrs: number; tableBodyAttrs: number; visibleColumns: number; rows: number; pageRows: number; }; /** Counters that increment on each derivation execution */ derivationCalls: { tableAttrs: number; tableHeadAttrs: number; tableBodyAttrs: number; visibleColumns: number; columnedRows: number; rows: number; injectedRows: number; pageRows: number; injectedPageRows: number; headerRows: number; }; /** Reset all derivation call counters to 0 */ resetCounters: () => void; /** Get total derivation calls since last reset */ getTotalCalls: () => number; } /** * The view model for a table, containing all reactive stores and state. * Created by `createViewModel` and used to render the table. * * @template Item - The type of data items in the table. * @template Plugins - The plugins used by the table. */ export interface TableViewModel { flatColumns: FlatColumn[]; tableAttrs: Readable>; tableHeadAttrs: Readable>; tableBodyAttrs: Readable>; visibleColumns: Readable[]>; headerRows: Readable[]>; originalRows: Readable[]>; rows: Readable[]>; pageRows: Readable[]>; pluginStates: PluginStates; /** Debug information for performance analysis (always available) */ _debug: ViewModelDebug; } /** * A type that can be either Readable or Writable. * * @template T - The type of the store value. */ export type ReadOrWritable = Readable | Writable; /** * The table state passed to plugins during initialization. * Contains references to all table stores before plugin states are available. * * @template Item - The type of data items in the table. * @template Plugins - The plugins used by the table. */ export interface PluginInitTableState extends Omit, 'pluginStates' | '_debug'> { /** The data source for the table. */ data: ReadOrWritable; /** The column definitions. */ columns: Column[]; } /** * The complete table state including plugin states. * Available to plugins and components after initialization. * * @template Item - The type of data items in the table. * @template Plugins - The plugins used by the table. */ export interface TableState extends Omit, '_debug'> { /** The data source for the table. */ data: ReadOrWritable; /** The column definitions. */ columns: Column[]; } /** * Options for creating a table view model. * * @template Item - The type of data items in the table. */ export interface CreateViewModelOptions { /** Optional function to generate a unique ID for each data item. */ rowDataId?: (item: Item, index: number) => string; } /** * Creates a view model for rendering a table. * The view model contains all reactive stores for the table, headers, and rows. * * @template Item - The type of data items in the table. * @template Plugins - The plugins used by the table. * @param table - The table instance created by `createTable`. * @param columns - The column definitions. * @param options - Optional configuration options. * @returns A TableViewModel containing all reactive stores for rendering. */ export declare const createViewModel: (table: Table, columns: Column[], { rowDataId }?: CreateViewModelOptions) => TableViewModel;