import type { default as CellCoords } from '../../../3rdparty/walkontable/src/cell/coords'; import type { HotInstance } from '../../../core/types'; import type { NestedRows } from '../nestedRows'; import BaseUI from './_base'; import type DataManager from '../data/dataManager'; import type { RowObject } from '../data/dataManager'; /** * Class responsible for the UI for collapsing and expanding groups. * * @private * @class * @augments BaseUI */ declare class CollapsingUI extends BaseUI { /** * Reference to the DataManager instance. * * @type {object} */ dataManager: DataManager; /** * Array of currently collapsed rows. * * @type {Array} */ collapsedRows: number[]; /** * Object for stashing and restoring collapsed rows state. * * @type {object} */ collapsedRowsStash: { stash: (forceRender?: boolean) => void; shiftStash: (baseIndex: number, targetIndex?: number | null, delta?: number) => void; applyStash: (forceRender?: boolean) => void; trimStash: (realElementIndex: number, amount: number) => void; }; /** * Stashed copy of collapsed rows from the last stash operation. * * @type {Array|undefined} */ lastCollapsedRows: number[] | undefined; /** * Initializes the collapsing UI component and sets up the stash mechanism for preserving collapsed row state across operations. */ constructor(nestedRowsPlugin: NestedRows, hotInstance: HotInstance); /** * Collapse the children of the row passed as an argument. * * @param {number|object} row The parent row. * @param {boolean} [forceRender=true] Whether to render the table after the function ends. * @param {boolean} [doTrimming=true] I determine whether collapsing should envolve trimming rows. * @returns {Array} */ collapseChildren(row: number, forceRender?: boolean, doTrimming?: boolean): number[]; /** * Collapse multiple children. * * @param {Array} rows Rows to collapse (including their children). * @param {boolean} [forceRender=true] `true` if the table should be rendered after finishing the function. * @param {boolean} [doTrimming=true] I determine whether collapsing should envolve trimming rows. */ collapseMultipleChildren(rows: number[] | RowObject[], forceRender?: boolean, doTrimming?: boolean): void; /** * Collapse a single row. * * @param {number} rowIndex Index of the row to collapse. * @param {boolean} [recursive=true] `true` if it should collapse the row's children. */ collapseRow(rowIndex: number, recursive?: boolean): void; /** * Collapse multiple rows. * * @param {Array} rowIndexes Array of row indexes to collapse. * @param {boolean} [recursive=true] `true` if it should collapse the rows' children. * @param {boolean} [doTrimming=true] I determine whether collapsing should envolve trimming rows. * @returns {Array} Rows prepared for trimming (or trimmed, if doTrimming == true). */ collapseRows(rowIndexes: number[], recursive?: boolean, doTrimming?: boolean): number[]; /** * Collapse child rows of the row at the provided index. * * @param {number} parentIndex Index of the parent node. * @param {Array} [rowsToTrim=[]] Array of rows to trim. Defaults to an empty array. * @param {boolean} [recursive] `true` if the collapsing process should be recursive. * @param {boolean} [doTrimming=true] I determine whether collapsing should envolve trimming rows. */ collapseChildRows(parentIndex: number, rowsToTrim?: number[], recursive?: boolean, doTrimming?: boolean): void; /** * Expand a single row. * * @param {number} rowIndex Index of the row to expand. * @param {boolean} [recursive=true] `true` if it should expand the row's children recursively. */ expandRow(rowIndex: number, recursive?: boolean): void; /** * Expand multiple rows. * * @param {Array} rowIndexes Array of indexes of the rows to expand. * @param {boolean} [recursive=true] `true` if it should expand the rows' children recursively. * @param {boolean} [doTrimming=true] I determine whether collapsing should envolve trimming rows. * @returns {Array} Array of row indexes to be untrimmed. */ expandRows(rowIndexes: number[], recursive?: boolean, doTrimming?: boolean): number[]; /** * Expand child rows of the provided index. * * @param {number} parentIndex Index of the parent row. * @param {Array} [rowsToUntrim=[]] Array of the rows to be untrimmed. * @param {boolean} [recursive] `true` if it should expand the rows' children recursively. * @param {boolean} [doTrimming=false] I determine whether collapsing should envolve trimming rows. */ expandChildRows(parentIndex: number, rowsToUntrim?: number[], recursive?: boolean, doTrimming?: boolean): void; /** * Expand the children of the row passed as an argument. * * @param {number|object} row Parent row. * @param {boolean} [forceRender=true] Whether to render the table after the function ends. * @param {boolean} [doTrimming=true] If set to `true`, the trimming will be applied when the function finishes. * @returns {number[]} */ expandChildren(row: number, forceRender?: boolean, doTrimming?: boolean): number[]; /** * Expand multiple rows' children. * * @param {Array} rows Array of rows which children are about to be expanded. * @param {boolean} [forceRender=true] `true` if the table should render after finishing the function. * @param {boolean} [doTrimming=true] `true` if the rows should be untrimmed after finishing the function. */ expandMultipleChildren(rows: number[] | RowObject[], forceRender?: boolean, doTrimming?: boolean): void; /** * Collapse all collapsable rows. */ collapseAll(): void; /** * Expand all collapsable rows. */ expandAll(): void; /** * Trim rows. * * @param {Array} rows Physical row indexes. */ trimRows(rows: number[]): void; /** * Untrim rows. * * @param {Array} rows Physical row indexes. */ untrimRows(rows: number[]): void; /** * Check if all child rows are collapsed. * * @private * @param {number|object|null} row The parent row. `null` for the top level. * @returns {boolean} */ areChildrenCollapsed(row: number): boolean; /** * Check if any of the row object parents are collapsed. * * @private * @param {object} rowObj Row object. * @returns {boolean} */ isAnyParentCollapsed(rowObj: RowObject | null): boolean; /** * Toggle collapsed state. Callback for the `beforeOnCellMousedown` hook. * * @private * @param {MouseEvent} event `mousedown` event. * @param {object} coords Coordinates of the clicked cell/header. */ toggleState(event: Event, coords: CellCoords, _TD?: HTMLTableCellElement): void; /** * Translate visual row after trimming to physical base row index. * * @private * @param {number} row Row index. * @returns {number} Base row index. */ translateTrimmedRow(row: number): number; /** * Translate physical row after trimming to visual base row index. * * @private * @param {number} row Row index. * @returns {number} Base row index. */ untranslateTrimmedRow(row: number): number; /** * Helper function to render the table and call the `adjustElementsSize` method. * * @private */ renderAndAdjust(): void; } export default CollapsingUI;