import type { HotInstance } from '../core/types'; type DataAccessorFn = (dataRow: unknown) => unknown; /** * @class DataSource * @private */ declare class DataSource { /** * Instance of Handsontable. * * @type {Handsontable} */ hot: HotInstance | null; /** * Data source. * * @type {Array} */ data: (Record | unknown[])[] | null; /** * Type of data source. * * @type {string} * @default 'array' */ dataType: string; /** * Translates a visual column index to the corresponding data property key. May be overridden by DataMap when object data is used. */ colToProp: (column: unknown) => unknown; /** * Translates a data property key to the corresponding visual column index. May be overridden by DataMap when object data is used. */ propToCol: (prop: unknown) => unknown; /** * Returns the number of columns derived from the data source cache; injected externally when object-based data is used. */ countCachedColumns?: () => number; /** * Initializes the data source with a reference to the Handsontable instance and the raw data array. */ constructor(hotInstance: HotInstance, dataSource?: unknown[][] | object[][]); /** * Run the `modifyRowData` hook and return either the modified or the source data for the provided row. * * @private * @param {number} rowIndex Row index. * @returns {Array|object} Source or modified row of data. */ modifyRowData(rowIndex: number): {} | null; /** * Get all data. * * Each call returns a fresh shallow clone of the source data so consumers can * safely mutate the returned array without affecting subsequent calls or the * underlying data. The fast path skips the per-cell hook lookups in * `getByRange()` and is taken when no `modifySourceData` / `modifyRowData` * hooks are registered and the caller does not request array-of-arrays * coercion (which needs the `colToProp` mapping `getByRange()` supplies). * * @param {boolean} [toArray=false] If `true` return source data as an array of arrays even when source data was provided * in another format. * @returns {Array} */ getData(toArray?: boolean): unknown[] | null; /** * Set new data source. * * @param {Array} data The new data. */ setData(data: unknown[]): void; /** * Returns array of column values from the data source. `column` is the index of the row in the data source. * * @param {number} column Visual column index. * @returns {Array} */ getAtColumn(column: number): unknown[]; /** * Returns a single row of the data or a subset of its columns. If a column range or `toArray` arguments are provided, it * operates only on the columns declared by the `columns` setting or the data schema. * * @param {number} row Physical row index. * @param {number} [startColumn] Starting index for the column range (optional). * @param {number} [endColumn] Ending index for the column range (optional). * @param {boolean} [toArray=false] `true` if the returned value should be forced to be presented as an array. * @returns {Array|object} */ getAtRow(row: number, startColumn?: number, endColumn?: number, toArray?: boolean): Record | null; /** * Set the provided value in the source data set at the provided coordinates. * * @param {number|string} row Physical row index. * @param {number|string} column Property name / physical column index. * @param {*} value The value to be set at the provided coordinates. */ setAtCell(row: number | string, column: string | number, value: unknown): void; /** * Get data from the source data set using the physical indexes. * * @private * @param {number} row Physical row index. * @param {string|number|Function} column Physical column index / property / function. * @param {Array|object} dataRow A representation of a data row. * @returns {*} Value at the provided coordinates. */ getAtPhysicalCell(row: number, column: number | string | DataAccessorFn, dataRow: unknown): unknown; /** * Returns a single value from the data. * * @param {number} row Physical row index. * @param {number} columnOrProp Visual column index or property. * @returns {*} */ getAtCell(row: number, columnOrProp: number | string): unknown; /** * Returns source data by passed range. * * @param {object} [start] Object with physical `row` and `col` keys (or visual column index, if data type is an array of objects). * @param {object} [end] Object with physical `row` and `col` keys (or visual column index, if data type is an array of objects). * @param {boolean} [toArray=false] If `true` return source data as an array of arrays even when source data was provided * in another format. * @returns {Array} */ getByRange(start?: { row?: number; col?: number; } | null, end?: { row?: number; col?: number; } | null, toArray?: boolean): unknown[]; /** * Returns single value from the data array (intended for clipboard copy to an external application). * * @param {number} row Visual row index. * @param {number} prop The column property. * @since 16.1.0 * @returns {string} */ getCopyable(row: number, prop: string | number): unknown; /** * Count number of rows. * * @returns {number} */ countRows(): number; /** * Count number of columns. * * @returns {number} */ countFirstRowKeys(): number; /** * Destroy instance. */ destroy(): void; } export default DataSource;