import { EventTarget, type Event } from 'event-target-shim'; import type { IColumnHeaderGroup } from './ColumnHeaderGroup'; import { type ModelIndex } from './GridMetrics'; import { type GridColor, type GridTheme, type NullableGridColor } from './GridTheme'; import { type Token } from './GridUtils'; import { type CellRenderType } from './CellRenderer'; /** * Model for a Grid * All of these methods should return very quickly, as they will be called many times in the render cycle. * If data needs to be loaded asynchronously, return something immediately, then trigger an event for the table to refresh (Not yet implemented). */ declare abstract class GridModel> = Record>, TMode extends 'standard' | 'strict' = 'standard'> extends EventTarget { /** Count of rows in the grid */ abstract get rowCount(): number; /** Count of columns in the grid */ abstract get columnCount(): number; /** Count of rows that are frozen (or 'floating') at the top */ get floatingTopRowCount(): number; /** Count of rows that are frozen at the bottom */ get floatingBottomRowCount(): number; /** Count of columns that are frozen (or 'floating') at the left */ get floatingLeftColumnCount(): number; /** Count of columns that are frozen (or 'floating') at the right */ get floatingRightColumnCount(): number; /** * How many columns header levels are in the grid * Used for column grouping where columns at depth 0 are the base columns * * A grid with 1-level grouping would have a columnHeaderDepth of 2 * and column headers at depths 0 and 1 */ get columnHeaderMaxDepth(): number; /** * Get the text for the specified cell * @param column Column to get the text for * @param row Row to get the text for * @returns Text for the specified cell */ abstract textForCell(column: ModelIndex, row: ModelIndex): string; /** * Get the character to replace text when truncated for a specific cell. * Leave undefined to show text truncated with ellipsis * @param column Column to get the truncation character for * @param row Row to get the truncation character for * @returns Truncation character for the specified cell */ truncationCharForCell(column: ModelIndex, row: ModelIndex): string | undefined; /** * Get the text alignment for the specified cell * @param column Column to get the alignment for * @param row Row to get the alignment for * @returns Text alignment for the specified cell */ textAlignForCell(column: ModelIndex, row: ModelIndex): CanvasTextAlign; /** * Get the color for the text in the specified cell * @param column Column to get the color for * @param row Row to get the color for * @param theme Theme applied to the grid * @returns Color for the text in the cell */ colorForCell(column: ModelIndex, row: ModelIndex, theme: GridTheme): GridColor; /** * Get the background color for the cell * @param column Column to get the background color for * @param row Row to get the background color for * @param theme Theme applied to the grid * @returns Background color for the cell */ backgroundColorForCell(column: ModelIndex, row: ModelIndex, theme: GridTheme): NullableGridColor; /** * Text for the column header * @param column Column to get the header for * @param depth Depth to get the header text for. 0 is base columns * @returns Text to put in the column header */ abstract textForColumnHeader(column: ModelIndex, depth?: number): string | undefined; /** Color for column header * @param column Column to get the color for * @param depth Header depth to get the color for * @returns Color for the header at the depth or null */ colorForColumnHeader(column: ModelIndex, depth?: number): string | null; /** * Text for the row header * @param row Row to get the header for * @returns Text to put in the row header */ textForRowHeader(row: ModelIndex): string; /** * Text for the row footer * @param row Row to get the footer for * @returns Text to put in the row footer */ textForRowFooter(row: ModelIndex): string; /** * @param column Column to check * @returns True if the column is movable */ isColumnMovable(column: ModelIndex, depth?: number): boolean; /** * @param row Row to check * @returns True if the row is movable */ isRowMovable(row: ModelIndex): boolean; getColumnHeaderGroup(modelIndex: ModelIndex, depth: number): IColumnHeaderGroup | undefined; getColumnHeaderParentGroup(modelIndex: ModelIndex, depth: number): IColumnHeaderGroup | undefined; /** * Gets the tokens in the cell at column and row, based on the visible text * @param column The model column * @param row The model row * @param visibleLength The length of the visible text * @returns An array of Tokens in the cell */ tokensForCell(column: ModelIndex, row: ModelIndex, visibleLength?: number): Token[]; getCachedTokensInText: ((text: string, visibleLength: number) => Token[]) & import("@types/memoizee").Memoized<(text: string, visibleLength: number) => Token[]>; renderTypeForCell(column: ModelIndex, row: ModelIndex): CellRenderType; /** * Get the column restrictions for a column, which can be used to determine * what type of input component to render for cells in that column. * @param column The model index of the column * @returns The column restrictions, or an empty array if there are none */ getColumnRestrictions(column: ModelIndex): ColumnRestriction[]; } /** * Base type for a column restriction. Carries a `type` discriminator that * can be used to narrow to a more specific restriction shape. */ export type ColumnRestriction = { type: string; }; export default GridModel; //# sourceMappingURL=GridModel.d.ts.map