import type { DataAccessObject, WalkontableInstance, DomBindings } from './types'; import type Settings from './settings'; import ColumnFilter from './filter/column'; import RowFilter from './filter/row'; import { Renderer } from './renderer'; import ColumnUtils from './utils/column'; import RowUtils from './utils/row'; /** * @todo These mixes are never added to the class Table, however their members are used here. * @todo Continue: Potentially it works only, because some of these mixes are added to every inherited class. * @todo Refactoring, move code from `if(this.isMaster)` into MasterTable, and others like that. * @mixes stickyColumnsStart * @mixes stickyRowsBottom * @mixes stickyRowsTop * @mixes calculatedRows * @mixes calculatedColumns * @abstract */ declare class Table { /** * The walkontable settings. * * @protected * @type {Settings} */ wtSettings: Settings; /** * The DOM bindings for the table. * * @type {DomBindings} */ domBindings: DomBindings; /** * The table body element (TBODY). * * @type {HTMLTableSectionElement | null} */ TBODY: HTMLTableSectionElement | null; /** * The table head element (THEAD). * * @type {HTMLTableSectionElement | null} */ THEAD: HTMLTableSectionElement | null; /** * The column group element (COLGROUP). * * @type {HTMLTableColElement | null} */ COLGROUP: HTMLTableColElement | null; /** * Indicates if the table has height bigger than 0px. * * @type {boolean} */ hasTableHeight: boolean; /** * Indicates if the table has width bigger than 0px. * * @type {boolean} */ hasTableWidth: boolean; /** * Indicates if the table is visible. By visible, it means that the holder * element has CSS 'display' property different than 'none'. * * @type {boolean} */ isTableVisible: boolean; /** * The offset of the table element. * * @type {number | { top: number; left: number }} */ tableOffset: number | { top: number; left: number; }; /** * The offset of the holder element. * * @type {number | { top: number; left: number }} */ holderOffset: number | { top: number; left: number; }; /** * The borders holder element. * * @type {HTMLElement} */ bordersHolder?: HTMLElement; /** * Indicates if this instance is of type MasterTable (i.e. it is NOT an overlay). * * @type {boolean} */ isMaster: boolean; /** * The name of the table (overlay name or 'master'). * * @type {string} */ name: string; /** * The data access object. * * @type {DataAccessObject} */ dataAccessObject: DataAccessObject; /** * Function which returns the proper facade. * * @type {Function} */ facadeGetter: Function; /** * The Walkontable instance. * * @type {WalkontableInstance} */ instance: WalkontableInstance; /** * The Walkontable instance (legacy alias for instance). * * @type {WalkontableInstance} */ wot: WalkontableInstance; /** * The table element. * * @type {HTMLTableElement} */ TABLE: HTMLTableElement; /** * The spreader element. * * @type {HTMLElement} */ spreader: HTMLElement; /** * The hider element. * * @type {HTMLElement} */ hider: HTMLElement; /** * The holder element. * * @type {HTMLElement} */ holder: HTMLElement; /** * The root element. * * @type {HTMLElement} */ wtRootElement: HTMLElement; /** * The row filter. * * @type {RowFilter | null} */ rowFilter: RowFilter | null; /** * The column filter. * * @type {ColumnFilter | null} */ columnFilter: ColumnFilter | null; /** * Indicates if the header width should be corrected. * * @type {boolean} */ correctHeaderWidth: boolean; /** * The row utilities. * * @type {RowUtils} */ rowUtils: RowUtils; /** * The column utilities. * * @type {ColumnUtils} */ columnUtils: ColumnUtils; /** * The table renderer. * * @type {Renderer} */ tableRenderer: Renderer; /** * Gets the index of the first rendered row. * * @type {() => number} */ getFirstRenderedRow: () => number; /** * Gets the index of the first visible row. * * @type {() => number} */ getFirstVisibleRow: () => number; /** * Gets the index of the first partially visible row. * * @type {() => number} */ getFirstPartiallyVisibleRow: () => number; /** * Gets the index of the last rendered row. * * @type {() => number} */ getLastRenderedRow: () => number; /** * Gets the index of the last visible row. * * @type {() => number} */ getLastVisibleRow: () => number; /** * Gets the index of the last partially visible row. * * @type {() => number} */ getLastPartiallyVisibleRow: () => number; /** * Gets the count of rendered rows. * * @type {() => number} */ getRenderedRowsCount: () => number; /** * Gets the count of visible rows. * * @type {() => number} */ getVisibleRowsCount: () => number; /** * Gets the count of column headers. * * @type {() => number} */ getColumnHeadersCount: () => number; /** * Gets the index of the first rendered column. * * @type {() => number} */ getFirstRenderedColumn: () => number; /** * Gets the index of the first visible column. * * @type {() => number} */ getFirstVisibleColumn: () => number; /** * Gets the index of the first partially visible column. * * @type {() => number} */ getFirstPartiallyVisibleColumn: () => number; /** * Gets the index of the last rendered column. * * @type {() => number} */ getLastRenderedColumn: () => number; /** * Gets the index of the last visible column. * * @type {() => number} */ getLastVisibleColumn: () => number; /** * Gets the index of the last partially visible column. * * @type {() => number} */ getLastPartiallyVisibleColumn: () => number; /** * Gets the count of rendered columns. * * @type {() => number} */ getRenderedColumnsCount: () => number; /** * Gets the count of visible columns. * * @type {() => number} */ getVisibleColumnsCount: () => number; /** * Gets the count of row headers. * * @type {() => number} */ getRowHeadersCount: () => number; /** * Aligns overlays with the trimming container. * * @returns {void} */ alignOverlaysWithTrimmingContainer(): void; /** * Marks oversized column headers. * * @returns {void} */ markOversizedColumnHeaders(): void; /** * * @abstract * @param {TableDao} dataAccessObject The data access object. * @param {FacadeGetter} facadeGetter Function which return proper facade. * @param {DomBindings} domBindings Bindings into DOM. * @param {Settings} wtSettings The Walkontable settings. * @param {'master'|CLONE_TYPES_ENUM} name Overlay name. */ constructor(dataAccessObject: DataAccessObject, facadeGetter: Function, domBindings: DomBindings, wtSettings: Settings, name: string); /** * Returns a boolean that is true if this Table represents a specific overlay, identified by the overlay name. * For MasterTable, it returns false. * * @param {string} overlayTypeName The overlay type. * @returns {boolean} */ is(overlayTypeName: string): boolean; /** * */ fixTableDomTree(): void; /** * @param {HTMLTableElement} table An element to process. * @returns {HTMLElement} */ createSpreader(table: HTMLTableElement): HTMLDivElement | undefined; /** * @param {HTMLElement} spreader An element to the hider element is injected. * @returns {HTMLElement} */ createHider(spreader: HTMLElement): HTMLDivElement | undefined; /** * * @param {HTMLElement} hider An element to the holder element is injected. * @returns {HTMLElement} */ createHolder(hider: HTMLElement): HTMLDivElement | undefined; /** * Redraws the table. * * @param {boolean} [fastDraw=false] If TRUE, will try to avoid full redraw and only update the border positions. * If FALSE or UNDEFINED, will perform a full redraw. * @returns {Table} */ draw(fastDraw?: boolean): this; /** * @param {number} col The visual column index. */ markIfOversizedColumnHeader(col: number): void; /** * */ adjustColumnHeaderHeights(): void; /** * After the master table applies `oversizedColumnHeaders` via `adjustColumnHeaderHeights`, * the actual THEAD row heights may exceed the stored values when header content (e.g., * wrapping text) pushes cells taller than the configured `columnHeaderHeight`. This method * re-reads the rendered THEAD row heights and updates `oversizedColumnHeaders` so that * overlay tables receive the correct values during their own `adjustColumnHeaderHeights`. */ syncOversizedColumnHeadersWithDOM(): void; /** * Frozen column headers (e.g., with `white-space: normal`) are rendered only in the frozen * overlays, never in the master table's THEAD. When such a header is taller than the headers * of the scrollable columns, the master and top overlay THEADs render shorter than the corner * and inline-start overlays, so the frozen overlay body rows sit shifted against the master. * The gap can be sub-pixel: under browser zoom the frozen header content is a fraction of a * pixel taller than the applied height, and that fraction accumulates into a visible 1px shift. * * This method runs after the frozen overlays have rendered. It reads the corner overlay's * content-driven THEAD row heights with sub-pixel precision and forces the matching master and * top overlay header cells to the same height so every overlay THEAD ends up the same height * and the body rows stay pixel-aligned. * * It deliberately does NOT write to `wtViewport.oversizedColumnHeaders`. That cache is applied * back to the corner overlay on the next render; growing it here would inflate the corner cell, * which would then be re-measured taller, ratcheting the height up every render. Reading the * corner's natural (content-driven) height and only adjusting the master/top side keeps the * synchronization stable and lets the header shrink again when the content allows. */ syncOversizedColumnHeadersWithFrozenOverlays(): void; /** * Resets cache of row heights. The cache should be cached for each render cycle in a case * when new cell values have content which increases/decreases cell height. */ resetOversizedRows(): void; /** * Get cell element at coords. * Negative coords.row or coords.col are used to retrieve header cells. If there are multiple header levels, the * negative value corresponds to the distance from the working area. For example, when there are 3 levels of column * headers, coords.col=-1 corresponds to the most inner header element, while coords.col=-3 corresponds to the * outmost header element. * * In case an element for the coords is not rendered, the method returns an error code. * To produce the error code, the input parameters are validated in the order in which they * are given. Thus, if both the row and the column coords are out of the rendered bounds, * the method returns the error code for the row. * * @param {CellCoords} coords The cell coordinates. * @returns {HTMLElement|number} HTMLElement on success or Number one of the exit codes on error: * -1 row before viewport * -2 row after viewport * -3 column before viewport * -4 column after viewport. */ getCell(coords: { row: number | null; col: number | null; }): -1 | HTMLElement | -5 | -2 | -3 | -4; /** * Get the DOM element of the row with the provided index. * * @param {number} rowIndex Row index. * @returns {HTMLTableRowElement|boolean} Return the row's DOM element or `false` if the row with the provided * index doesn't exist. */ getRow(rowIndex: number): HTMLTableRowElement | false; /** * GetColumnHeader. * * @param {number} col Column index. * @param {number} [level=0] Header level (0 = most distant to the table). * @returns {object} HTMLElement on success or undefined on error. */ getColumnHeader(col: number, level?: number): HTMLElement | undefined; /** * Gets all columns headers (TH elements) from the table. * * @param {number} column A source column index. * @returns {HTMLTableCellElement[]} */ getColumnHeaders(column: number): HTMLTableCellElement[]; /** * GetRowHeader. * * @param {number} row Row index. * @param {number} [level=0] Header level (0 = most distant to the table). * @returns {HTMLElement} HTMLElement on success or Number one of the exit codes on error: `null table doesn't have * row headers`. */ getRowHeader(row: number, level?: number): HTMLElement | undefined; /** * Gets all rows headers (TH elements) from the table. * * @param {number} row A source row index. * @returns {HTMLTableCellElement[]} */ getRowHeaders(row: number): ChildNode[]; /** * Returns cell coords object for a given TD (or a child element of a TD element). * * @param {HTMLTableCellElement} TD A cell DOM element (or a child of one). * @returns {CellCoords|null} The coordinates of the provided TD element (or the closest TD element) or null, if the * provided element is not applicable. */ getCoords(TD: HTMLTableCellElement | HTMLElement): import(".").CellCoords | null; /** * Check if any of the rendered rows is higher than expected, and if so, cache them. */ markOversizedRows(): void; /** * @param {number} row The visual row index. * @returns {HTMLTableRowElement} */ getTrForRow(row: number): HTMLTableRowElement; /** * Checks if the column index (negative value from -1 to N) is rendered. * * @param {number} column The column index (negative value from -1 to N). * @returns {boolean} */ isColumnHeaderRendered(column: number): boolean; /** * Checks if the row index (negative value from -1 to N) is rendered. * * @param {number} row The row index (negative value from -1 to N). * @returns {boolean} */ isRowHeaderRendered(row: number): boolean; /** * Check if the given row index is lower than the index of the first row that * is currently rendered and return TRUE in that case, or FALSE otherwise. * * Negative row index is used to check the columns' headers. * * Headers * +--------------+ │ * -3 │ │ │ │ │ * +--------------+ │ * -2 │ │ │ │ │ TRUE * +--------------+ │ * -1 │ │ │ │ │ * Cells +==================+ │ * 0 ┇ ┇ ┇ ┇ <--- For fixedRowsTop: 1 │ * +--------------+ the master overlay do ---+ first rendered row (index 1) * 1 │ A2 │ B2 │ C2 │ not render the first row. │ * +--------------+ │ FALSE * 2 │ A3 │ B3 │ C3 │ │ * +--------------+ ---+ last rendered row * │ * │ FALSE * * @param {number} row The visual row index. * @memberof Table# * @function isRowBeforeRenderedRows * @returns {boolean} */ isRowBeforeRenderedRows(row: number): boolean; /** * Check if the given column index is greater than the index of the last column that * is currently rendered and return TRUE in that case, or FALSE otherwise. * * The negative row index is used to check the columns' headers. However, * keep in mind that for negative indexes, the method always returns FALSE as * it is not possible to render headers partially. The "after" index can not be * lower than -1. * * Headers * +--------------+ │ * -3 │ │ │ │ │ * +--------------+ │ * -2 │ │ │ │ │ FALSE * +--------------+ │ * -1 │ │ │ │ │ * Cells +==================+ │ * 0 ┇ ┇ ┇ ┇ <--- For fixedRowsTop: 1 │ * +--------------+ the master overlay do ---+ first rendered row (index 1) * 1 │ A2 │ B2 │ C2 │ not render the first rows │ * +--------------+ │ FALSE * 2 │ A3 │ B3 │ C3 │ │ * +--------------+ ---+ last rendered row * │ * │ TRUE * * @param {number} row The visual row index. * @memberof Table# * @function isRowAfterRenderedRows * @returns {boolean} */ isRowAfterRenderedRows(row: number): boolean; /** * Check if the given column index is lower than the index of the first column that * is currently rendered and return TRUE in that case, or FALSE otherwise. * * Negative column index is used to check the rows' headers. * * For fixedColumnsStart: 1 the master overlay * do not render this first columns. * Headers -3 -2 -1 | * +----+----+----║┄ ┄ +------+------+ * │ │ │ ║ │ B1 │ C1 │ * +--------------║┄ ┄ --------------│ * │ │ │ ║ │ B2 │ C2 │ * +--------------║┄ ┄ --------------│ * │ │ │ ║ │ B3 │ C3 │ * +----+----+----║┄ ┄ +------+------+ * ╷ ╷ * -------------------------+-------------+----------------> * TRUE first FALSE last FALSE * rendered rendered * column column * * @param {number} column The visual column index. * @memberof Table# * @function isColumnBeforeRenderedColumns * @returns {boolean} */ isColumnBeforeRenderedColumns(column: number): boolean; /** * Check if the given column index is greater than the index of the last column that * is currently rendered and return TRUE in that case, or FALSE otherwise. * * The negative column index is used to check the rows' headers. However, * keep in mind that for negative indexes, the method always returns FALSE as * it is not possible to render headers partially. The "after" index can not be * lower than -1. * * For fixedColumnsStart: 1 the master overlay * do not render this first columns. * Headers -3 -2 -1 | * +----+----+----║┄ ┄ +------+------+ * │ │ │ ║ │ B1 │ C1 │ * +--------------║┄ ┄ --------------│ * │ │ │ ║ │ B2 │ C2 │ * +--------------║┄ ┄ --------------│ * │ │ │ ║ │ B3 │ C3 │ * +----+----+----║┄ ┄ +------+------+ * ╷ ╷ * -------------------------+-------------+----------------> * FALSE first FALSE last TRUE * rendered rendered * column column * * @param {number} column The visual column index. * @memberof Table# * @function isColumnAfterRenderedColumns * @returns {boolean} */ isColumnAfterRenderedColumns(column: number): boolean | null; /** * Checks if the column is after the last visible column. * * @param {number} column The visual column index. * @returns {boolean} */ isColumnAfterViewport(column: number): boolean | null; /** * Checks if the row is after the last visible row. * * @param {number} row The visual row index. * @returns {boolean} */ isRowAfterViewport(row: number): boolean | null; /** * Checks if the column is before the first visible column. * * @param {number} column The visual column index. * @returns {boolean} */ isColumnBeforeViewport(column: number): boolean | null; /** * Checks if the last row is fully visible. * * @returns {boolean} */ isLastRowFullyVisible(): boolean; /** * Checks if the last column is fully visible. * * @returns {boolean} */ isLastColumnFullyVisible(): boolean; /** * Checks if all rows fit in the viewport. * * @returns {boolean} */ allRowsInViewport(): boolean; /** * Checks if all columns fit in the viewport. * * @returns {boolean} */ allColumnsInViewport(): boolean; /** * Checks if any of the row's cells content exceeds its initial height, and if so, returns the oversized height. * * @param {number} sourceRow The physical row index. * @returns {number} */ getRowHeight(sourceRow: number): number | undefined; /** * @param {number} level The column level. * @returns {number} */ getColumnHeaderHeight(level: number): number; /** * @param {number} sourceColumn The physical column index. * @returns {number} */ getColumnWidth(sourceColumn: number): number; /** * Checks if the table has defined size. It returns `true` when the table has width and height * set bigger than `0px`. * * @returns {boolean} */ hasDefinedSize(): boolean; /** * Gets table's width. The returned width is the width of the rendered cells that fit in the * current viewport. The value may change depends on the viewport position (scroll position). * * @returns {number} */ getWidth(): number; /** * Gets table's height. The returned height is the height of the rendered cells that fit in the * current viewport. The value may change depends on the viewport position (scroll position). * * @returns {number} */ getHeight(): number; /** * Gets table's total width. The returned width is the width of all rendered cells (including headers) * that can be displayed in the table. * * @returns {number} */ getTotalWidth(): number; /** * Gets table's total height. The returned height is the height of all rendered cells (including headers) * that can be displayed in the table. * * @returns {number} */ getTotalHeight(): number; /** * Checks if the table is visible. It returns `true` when the holder element (or its parents) * has CSS 'display' property different than 'none'. * * @returns {boolean} */ isVisible(): boolean; /** * Modify row header widths provided by user in class contructor. * * @private * @param {Function | number | null} rowHeaderWidthFactory The function which can provide default width values for rows.. * @returns {number} */ _modifyRowHeaderWidth(rowHeaderWidthFactory: ((...args: unknown[]) => number | number[]) | number | null): number | number[]; /** * Correct row header width if necessary. * * @private * @param {number | null} width The width to process. * @returns {number} */ _correctRowHeaderWidth(width: number | null): number; /** * Destroys the table instance. Overridden by MasterTable to release DOM resources. */ destroy(): void; } export default Table;