import type { HotInstance } from '../core/types'; /** * Structure returned by createTable(). */ interface GhostTableStruct { fragment: DocumentFragment; table: HTMLTableElement; tHead: HTMLTableSectionElement; tBody: HTMLTableSectionElement; colGroup: HTMLTableColElement; tr: HTMLTableRowElement; th: HTMLTableCellElement; } /** * Structure returned by createContainer(). */ interface GhostContainerStruct { fragment: DocumentFragment; container: HTMLDivElement; } /** * A single string entry within a sample. */ interface SampleString { col?: number; row?: number; value: unknown; } /** * A sample entry in the samples Map. */ interface SampleEntry { strings: SampleString[]; [key: string]: unknown; } /** * @class GhostTable */ declare class GhostTable { /** * Handsontable instance. * * @type {Core} */ hot: HotInstance | null; /** * Container element where every table will be injected. * * @type {HTMLElement|null} */ container: GhostContainerStruct | null; /** * Flag which determine is table was injected to DOM. * * @type {boolean} */ injected: boolean; /** * Added rows collection. * * @type {Array} */ rows: Record[]; /** * Added columns collection. * * @type {Array} */ columns: Record[]; /** * Samples prepared for calculations. * * @type {Map} * @default {null} */ samples: Map | null; /** * Ghost table settings. * * @type {object} * @default {Object} */ settings: Record; /** * Table element. * * @type {unknown} */ table: GhostTableStruct | null; /** * Initializes the ghost table utility with a reference to the Handsontable instance used for DOM context. */ constructor(hotInstance: HotInstance | object); /** * Add row. * * @param {number} row Visual row index. * @param {Map} samples Samples Map object. */ addRow(row: number, samples: Map): void; /** * Add a row consisting of the column headers. * * @param {Map} samples A map with sampled table values. */ addColumnHeadersRow(samples: Map): void; /** * Add column. * * @param {number} column Visual column index. * @param {Map} samples A map with sampled table values. */ addColumn(column: number, samples: Map): void; /** * Get calculated heights. * * @param {Function} callback Callback which will be fired for each calculated row. */ getHeights(callback: Function): void; /** * Get calculated widths. * * @param {Function} callback Callback which will be fired for each calculated column. */ getWidths(callback: Function): void; /** * Set the Ghost Table settings to the provided object. * * @param {object} settings New Ghost Table Settings. */ setSettings(settings: Record): void; /** * Set a single setting of the Ghost Table. * * @param {string} name Setting name. * @param {*} value Setting value. */ setSetting(name: string, value: unknown): void; /** * Get the Ghost Table settings. * * @returns {object|null} */ getSettings(): Record; /** * Get a single Ghost Table setting. * * @param {string} name The setting name to get. * @returns {boolean|null} */ getSetting(name: string): unknown; /** * Create colgroup col elements. * * @param {number} row Visual row index. * @returns {DocumentFragment} */ createColGroupsCol(row?: number): DocumentFragment; /** * Create table row element. * * @param {number} row Visual row index. * @returns {DocumentFragment} Returns created table row elements. */ createRow(row: number): DocumentFragment; /** * Creates DOM elements for headers and appends them to the THEAD element of the table. */ appendColumnHeadersRow(): void; /** * Create table column elements. * * @param {number} column Visual column index. * @returns {DocumentFragment} Returns created column table column elements. */ createCol(column: number): DocumentFragment; /** * Remove table from document and reset internal state. */ clean(): void; /** * Inject generated table into document. * * @param {HTMLElement} [parent=null] The element to which the ghost table is injected. */ injectTable(parent?: HTMLElement | null): void; /** * Remove table from document. */ removeTable(): void; /** * Create col element. * * @param {number} column Visual column index. * @param {number} row Visual row index. * @returns {HTMLElement} */ createColElement(column: number, row: number): HTMLTableColElement; /** * Create table element. * * @param {string} className The CSS classes to add. * @returns {object} */ createTable(className?: string): GhostTableStruct; /** * Create container for tables. * * @param {string} className The CSS classes to add. * @returns {object} */ createContainer(className?: string): GhostContainerStruct; /** * Checks if table is raised vertically (checking rows). * * @returns {boolean} */ isVertical(): boolean; /** * Checks if table is raised horizontally (checking columns). * * @returns {boolean} */ isHorizontal(): boolean; } export default GhostTable;