import { BodyCell } from './bodyCells.js'; import type { FlatColumn } from './columns.js'; import { TableComponent } from './tableComponent.js'; import type { AnyPlugins } from './types/TablePlugin.js'; import { type Readable } from 'svelte/store'; /** * Initialization options for creating a BodyRow. * * @template Item - The type of data items in the table. * @template Plugins - The plugins used by the table. */ export type BodyRowInit = { id: string; cells: BodyCell[]; cellForId: Record>; depth?: number; parentRow?: BodyRow; }; /** * HTML attributes for a body row element. * * @template Item - The type of data items in the table. * @template Plugins - The plugins used by the table. */ export type BodyRowAttributes = { role: 'row'; }; /** * Abstract base class representing a row in the table body. * Extended by DataBodyRow for data rows and DisplayBodyRow for display-only rows. * * @template Item - The type of data items in the table. * @template Plugins - The plugins used by the table. */ export declare abstract class BodyRow extends TableComponent { cells: BodyCell[]; /** * Get the cell with a given column id. * * **This includes hidden cells.** */ cellForId: Record>; depth: number; parentRow?: BodyRow; subRows?: BodyRow[]; constructor({ id, cells, cellForId, depth, parentRow }: BodyRowInit); attrs(): Readable>; abstract clone(props?: BodyRowCloneProps): BodyRow; /** * Type guard to check if this row is a data row. * * @returns True if this is a DataBodyRow. */ isData(): this is DataBodyRow; /** * Type guard to check if this row is a display row. * * @returns True if this is a DisplayBodyRow. */ isDisplay(): this is DisplayBodyRow; } /** * Options for cloning a BodyRow. */ type BodyRowCloneProps = { /** Whether to clone the cells as well. */ includeCells?: boolean; /** Whether to recursively clone sub-rows. */ includeSubRows?: boolean; }; /** * Initialization options for creating a DataBodyRow. * * @template Item - The type of data items in the table. * @template Plugins - The plugins used by the table. */ export type DataBodyRowInit = BodyRowInit & { /** Unique identifier for the data item. */ dataId: string; /** The original data item. */ original: Item; }; /** * A body row that contains actual data from the data source. * Provides access to the original data item and a unique data ID. * * @template Item - The type of data items in the table. * @template Plugins - The plugins used by the table. */ export declare class DataBodyRow extends BodyRow { __data: boolean; /** Unique identifier for the data item. */ dataId: string; /** The original data item from the data source. */ original: Item; /** * Creates a new DataBodyRow. * * @param init - Initialization options. */ constructor({ id, dataId, original, cells, cellForId, depth, parentRow }: DataBodyRowInit); /** * Creates a copy of this row with optional deep cloning of cells and sub-rows. * * @param props - Cloning options. * @returns A cloned DataBodyRow. */ clone({ includeCells, includeSubRows }?: BodyRowCloneProps): DataBodyRow; } /** * Initialization options for creating a DisplayBodyRow. * * @template Item - The type of data items in the table. * @template Plugins - The plugins used by the table. */ export type DisplayBodyRowInit = BodyRowInit; /** * A body row used for display purposes only (e.g., grouped rows, aggregate rows). * Does not contain direct data from the data source. * * @template Item - The type of data items in the table. * @template Plugins - The plugins used by the table. */ export declare class DisplayBodyRow extends BodyRow { __display: boolean; /** * Creates a new DisplayBodyRow. * * @param init - Initialization options. */ constructor({ id, cells, cellForId, depth, parentRow }: DisplayBodyRowInit); /** * Creates a copy of this row with optional deep cloning of cells and sub-rows. * * @param props - Cloning options. * @returns A cloned DisplayBodyRow. */ clone({ includeCells, includeSubRows }?: BodyRowCloneProps): DisplayBodyRow; } /** * Options for creating body rows from data. * * @template Item - The type of data items. */ export interface BodyRowsOptions { /** Optional function to generate a unique ID for each data item. */ rowDataId?: (item: Item, index: number) => string; } /** * Converts an array of items into an array of table `BodyRow`s based on the column structure. * @param data The data to display. * @param flatColumns The column structure. * @returns An array of `BodyRow`s representing the table structure. */ export declare const getBodyRows: (data: Item[], /** * Flat columns before column transformations. */ flatColumns: FlatColumn[], { rowDataId }?: BodyRowsOptions) => DataBodyRow[]; /** * Arranges and hides columns in an array of `BodyRow`s based on * `columnIdOrder` by transforming the `cells` property of each row. * * `cellForId` should remain unaffected. * * @param rows The rows to transform. * @param columnIdOrder The column order to transform to. * @returns A new array of `BodyRow`s with corrected row references. */ export declare const getColumnedBodyRows: (rows: DataBodyRow[], columnIdOrder: string[]) => DataBodyRow[]; /** * Converts an array of items into an array of table `BodyRow`s based on a parent row. * @param subItems The sub data to display. * @param parentRow The parent row. * @returns An array of `BodyRow`s representing the child rows of `parentRow`. */ export declare const getSubRows: (subItems: Item[], parentRow: BodyRow, { rowDataId }?: BodyRowsOptions) => BodyRow[]; export {};