import type { DisplayBodyCell } from './bodyCells.js'; import type { TableState } from './createViewModel.js'; import type { DataLabel, DisplayLabel, HeaderLabel } from './types/Label.js'; import type { AnyPlugins, PluginColumnConfigs } from './types/TablePlugin.js'; /** * Initialization options for a Column. * * @template Item - The type of data items in the table. * @template Plugins - The plugins configuration type. */ export interface ColumnInit { /** The header label or render function. */ header: HeaderLabel; /** Optional footer label or render function. */ footer?: HeaderLabel; /** The height of the column in header rows (for grouping). */ height: number; /** Plugin-specific column configuration. */ plugins?: PluginColumnConfigs; } /** * Base class for all column types in the table. * Provides type guards for determining the specific column type. * * @template Item - The type of data items in the table. * @template Plugins - The plugins configuration type. */ export declare class Column { /** The header label or render function. */ header: HeaderLabel; /** Optional footer label or render function. */ footer?: HeaderLabel; /** The height of the column in header rows. */ height: number; /** Plugin-specific column configuration. */ plugins?: PluginColumnConfigs; /** * Creates a new Column instance. * * @param init - The column initialization options. */ constructor({ header, footer, height, plugins }: ColumnInit); /** * Type guard to check if this column is a FlatColumn (DataColumn or DisplayColumn). * * @returns True if this is a FlatColumn. */ isFlat(): this is FlatColumn; /** * Type guard to check if this column is a DataColumn. * * @returns True if this is a DataColumn. */ isData(): this is DataColumn; /** * Type guard to check if this column is a DisplayColumn. * * @returns True if this is a DisplayColumn. */ isDisplay(): this is DisplayColumn; /** * Type guard to check if this column is a GroupColumn. * * @returns True if this is a GroupColumn. */ isGroup(): this is GroupColumn; } /** * Initialization options for a FlatColumn. * Height is always 1 for flat columns. * * @template Item - The type of data items in the table. * @template Plugins - The plugins configuration type. * @template Id - The column ID type. */ export type FlatColumnInit = Omit, 'height'> & { /** Optional unique identifier for the column. Defaults to the header string. */ id?: Id; }; /** * A column that occupies a single row in the header (not a group). * Base class for DataColumn and DisplayColumn. * * @template Item - The type of data items in the table. * @template Plugins - The plugins configuration type. * @template Id - The column ID type. */ export declare class FlatColumn extends Column { __flat: boolean; /** The unique identifier for this column. */ id: Id; /** * Creates a new FlatColumn instance. * * @param init - The column initialization options. */ constructor({ header, footer, plugins, id }: FlatColumnInit); } /** * Full initialization type for a DataColumn. * Supports three accessor patterns: key only, key with ID, or function with ID. * * @template Item - The type of data items in the table. * @template Plugins - The plugins configuration type. * @template Id - The column ID type. * @template Value - The type of the cell value. */ export type DataColumnInit = DataColumnInitBase & ((Id extends keyof Item ? DataColumnInitKey : never) | DataColumnInitIdAndKey | DataColumnInitFnAndId); /** * Base initialization options for a DataColumn. * * @template Item - The type of data items in the table. * @template Plugins - The plugins configuration type. * @template Value - The type of the cell value. */ export type DataColumnInitBase = Omit, 'height'> & { /** Optional custom cell renderer. */ cell?: DataLabel; }; /** * DataColumn init when using an accessor key that matches Item property. * * @template Item - The type of data items. * @template Id - The key of Item to access. */ export type DataColumnInitKey = { /** The property key to access on each item. */ accessor: Id; /** Optional ID override. Defaults to accessor key. */ id?: Id; }; /** * DataColumn init when using an accessor key with a custom ID. * * @template Item - The type of data items. * @template Id - The column ID type. * @template Key - The key of Item to access. */ export type DataColumnInitIdAndKey = { /** The property key to access on each item. */ accessor: Key; /** Optional custom ID for the column. */ id?: Id; }; /** * DataColumn init when using an accessor function. * * @template Item - The type of data items. * @template Id - The column ID type. * @template Value - The return type of the accessor function. */ export type DataColumnInitFnAndId = { /** Function to extract the value from each item, or a property key. */ accessor: keyof Item | ((item: Item) => Value); /** Optional custom ID for the column. */ id?: Id; }; /** * A column that displays data from the table items. * Uses an accessor (key or function) to extract values from each row. * * @template Item - The type of data items in the table. * @template Plugins - The plugins configuration type. * @template Id - The column ID type. * @template Value - The type of the cell value. */ export declare class DataColumn extends FlatColumn { __data: boolean; /** Optional custom cell renderer. */ cell?: DataLabel; /** The property key used to access values (if using key accessor). */ accessorKey?: keyof Item; /** The function used to extract values (if using function accessor). */ accessorFn?: (item: Item) => Value; /** * Creates a new DataColumn instance. * * @param init - The column initialization options. * @throws Error if no id, accessor key, or header is provided. */ constructor({ header, footer, plugins, cell, accessor, id }: DataColumnInit); /** * Extracts the value from a data item using the configured accessor. * * @param item - The data item to extract the value from. * @returns The extracted value, or undefined if no accessor is configured. */ getValue(item: Item): any; } /** * Function type for getting custom data from a DisplayColumn cell. * * @template Item - The type of data items in the table. * @template Plugins - The plugins configuration type. */ export type DisplayColumnDataGetter = (cell: DisplayBodyCell, state?: TableState) => unknown; /** * Initialization options for a DisplayColumn. * * @template Item - The type of data items in the table. * @template Plugins - The plugins configuration type. * @template Id - The column ID type. */ export type DisplayColumnInit = FlatColumnInit & { /** The cell renderer function. */ cell: DisplayLabel; /** Optional function to provide custom data to the cell. */ data?: DisplayColumnDataGetter; }; /** * A column for displaying non-data content like actions, checkboxes, or custom UI. * Unlike DataColumn, it doesn't extract values from the data items automatically. * * @template Item - The type of data items in the table. * @template Plugins - The plugins configuration type. * @template Id - The column ID type. */ export declare class DisplayColumn extends FlatColumn { __display: boolean; /** The cell renderer function. */ cell: DisplayLabel; /** Optional function to provide custom data to the cell. */ data?: DisplayColumnDataGetter; /** * Creates a new DisplayColumn instance. * * @param init - The column initialization options. */ constructor({ header, footer, plugins, id, cell, data }: DisplayColumnInit); } /** * Initialization options for a GroupColumn. * * @template Item - The type of data items in the table. * @template Plugins - The plugins configuration type. */ export type GroupColumnInit = Omit, 'height'> & { /** The child columns contained within this group. */ columns: Column[]; }; /** * A column that groups other columns under a shared header. * Creates a hierarchical header structure. * * @template Item - The type of data items in the table. * @template Plugins - The plugins configuration type. */ export declare class GroupColumn extends Column { __group: boolean; /** The child columns contained within this group. */ columns: Column[]; /** The IDs of all flat columns within this group (recursively). */ ids: string[]; /** * Creates a new GroupColumn instance. * Height is calculated as max child height + 1. * * @param init - The column initialization options. */ constructor({ header, footer, columns, plugins }: GroupColumnInit); } /** * Extracts all flat column IDs from an array of columns (including nested groups). * * @template Item - The type of data items in the table. * @template Plugins - The plugins configuration type. * @param columns - The array of columns to extract IDs from. * @returns An array of column ID strings. */ export declare const getFlatColumnIds: (columns: Column[]) => string[]; /** * Extracts all FlatColumns from an array of columns (including nested groups). * * @template Item - The type of data items in the table. * @template Plugins - The plugins configuration type. * @param columns - The array of columns to flatten. * @returns An array of FlatColumn instances. */ export declare const getFlatColumns: (columns: Column[]) => FlatColumn[];