import { RequiredKeys } from '@tanstack/react-table'; import type { Column, ColumnDef, InitialTableState, Row, RowData, RowModel, Table, TableFeature, TableMeta, TableOptions, TableOptionsResolved, TableState, Updater } from './types.js'; /** @internal */ export interface CoreOptions { /** * Set this option to override any of the `autoReset...` feature options. */ autoResetAll?: boolean; /** * The array of column defs to use for the table. */ columns: ColumnDef[]; /** * The data for the table to display. This array should match the type you provided to `table.setRowType<...>`. Columns can access this data via string/index or a functional accessor. When the `data` option changes reference, the table will reprocess the data. */ data: TData[]; /** * Set this option to `true` to output all debugging information to the console. */ debugAll?: boolean; /** * Set this option to `true` to output cell debugging information to the console. */ debugCells?: boolean; /** * Set this option to `true` to output column debugging information to the console. */ debugColumns?: boolean; /** * Set this option to `true` to output header debugging information to the console. */ debugHeaders?: boolean; /** * Set this option to `true` to output row debugging information to the console. */ debugRows?: boolean; /** * Set this option to `true` to output table debugging information to the console. */ debugTable?: boolean; /** * Default column options to use for all column defs supplied to the table. */ defaultColumn?: Partial>; /** * This required option is a factory for a function that computes and returns the core row model for the table. */ getCoreRowModel: (table: Table) => () => RowModel; /** * This optional function is used to derive a unique ID for any given row. If not provided the rows index is used (nested rows join together with `.` using their grandparents' index eg. `index.index.index`). If you need to identify individual rows that are originating from any server-side operations, it's suggested you use this function to return an ID that makes sense regardless of network IO/ambiguity eg. a userId, taskId, database ID field, etc. */ getRowId?: (originalRow: TData, index: number, parent?: Row) => string; /** * This optional function is used to access the sub rows for any given row. If you are using nested rows, you will need to use this function to return the sub rows object (or undefined) from the row. */ getSubRows?: (originalRow: TData, index: number) => undefined | TData[]; /** * Use this option to optionally pass initial state to the table. This state will be used when resetting various table states either automatically by the table (eg. `options.autoResetPageIndex`) or via functions like `table.resetRowSelection()`. Most reset function allow you optionally pass a flag to reset to a blank/default state instead of the initial state. * * Table state will not be reset when this object changes, which also means that the initial state object does not need to be stable. * */ initialState?: InitialTableState; /** * This option is used to optionally implement the merging of table options. */ mergeOptions?: (defaultOptions: TableOptions, options: Partial>) => TableOptions; /** * You can pass any object to `options.meta` and access it anywhere the `table` is available via `table.options.meta`. */ meta?: TableMeta; /** * The `onStateChange` option can be used to optionally listen to state changes within the table. */ onStateChange: (updater: Updater) => void; /** * Value used when the desired value is not found in the data. */ renderFallbackValue: any; /** * The `state` option can be used to optionally _control_ part or all of the table state. The state you pass here will merge with and overwrite the internal automatically-managed state to produce the final state for the table. You can also listen to state changes via the `onStateChange` option. * Note: Any state passed in here will override both the internal state and any other `initialState` you provide. */ state: Partial; } /** @internal */ export interface CoreInstance { _features: readonly TableFeature[]; _getAllFlatColumnsById: () => Record>; _getColumnDefs: () => ColumnDef[]; _getCoreRowModel?: () => RowModel; _getDefaultColumnDef: () => Partial>; _getRowId: (_: TData, index: number, parent?: Row) => string; _queue: (cb: () => void) => void; /** * Returns all columns in the table in their normalized and nested hierarchy. */ getAllColumns: () => Column[]; /** * Returns all columns in the table flattened to a single level. */ getAllFlatColumns: () => Column[]; /** * Returns all columns in the table flattened to a single level, excluding builtin columns. */ getAllFlatColumnsWithoutBuiltin: () => Column[]; /** * Returns all column IDs in the table flattened to a single level, excluding builtin columns. */ getAllFlatColumnIdsWithoutBuiltin: () => string[]; /** * Returns the total number of enabled builtin columns in the table. */ getBuiltinColumnsCount: () => number; /** * Returns all leaf-node columns in the table flattened to a single level. This does not include parent columns. */ getAllLeafColumns: () => Column[]; /** * Returns a single column by its ID. */ getColumn: (columnId: string) => Column | undefined; /** * Returns the core row model before any processing has been applied. */ getCoreRowModel: () => RowModel; /** * Returns the row with the given ID. */ getRow: (id: string, searchAll?: boolean) => Row; /** * Returns the final model after all processing from other used features has been applied. This is the row model that is most commonly used for rendering. */ getRowModel: () => RowModel; /** * Call this function to get the table's current state. It's recommended to use this function and its state, especially when managing the table state manually. It is the exact same state used internally by the table for every feature and function it provides. */ getState: () => TableState; /** * This is the resolved initial state of the table. */ initialState: TableState; /** * A read-only reference to the table's current options. */ options: RequiredKeys, 'state'>; /** * Call this function to reset the table state to the initial state. */ reset: () => void; /** * This function can be used to update the table options. */ setOptions: (newOptions: Updater>) => void; /** * Call this function to update the table state. */ setState: (updater: Updater) => void; } /** @internal */ export interface CoreTableState { } /** @internal */ export declare function createTable(options: TableOptionsResolved): Table;