import type { HotInstance } from '../../core/types'; import type { default as CellRange } from '../../3rdparty/walkontable/src/cell/range'; import MergedCellCoords from './cellCoords'; import type { MergeCells } from './mergeCells'; /** * Defines a container object for the merged cells. * * @private * @class MergedCellsCollection */ declare class MergedCellsCollection { #private; /** * Reference to the Merge Cells plugin. * * @type {MergeCells} */ plugin: MergeCells; /** * Array of merged cells. * * @type {MergedCellCoords[]} */ mergedCells: MergedCellCoords[]; /** * Matrix of cells (row, col) that points to the instances of the MergedCellCoords objects. * * @type {Array} */ mergedCellsMatrix: Map>; /** * The Handsontable instance. * * @type {Handsontable} */ hot: HotInstance; /** * Initializes the cells collection with references to the MergeCells plugin and the Handsontable instance. */ constructor(mergeCellsPlugin: MergeCells); /** * Get a warning message for when the declared merged cell data overlaps already existing merged cells. * * @param {{ row: number, col: number, rowspan: number, colspan: number }} mergedCell Object containing information * about the merged cells that was about to be added. * @returns {string} */ static IS_OVERLAPPING_WARNING({ row, col }: { row: number; col: number; }): string; /** * Get a merged cell from the container, based on the provided arguments. You can provide either the "starting coordinates" * of a merged cell, or any coordinates from the body of the merged cell. * * @param {number} row Row index. * @param {number} column Column index. * @returns {MergedCellCoords|boolean} Returns a wanted merged cell on success and `false` on failure. */ get(row: number, column: number): false | MergedCellCoords; /** * Get the first-found merged cell containing the provided range. * * @param {CellRange} range The range to search merged cells for. * @returns {MergedCellCoords | false} */ getByRange(range: CellRange): false | MergedCellCoords; /** * Filters merge cells objects provided by users from overlapping cells. * * @param {{ row: number, col: number, rowspan: number, colspan: number }} mergedCellsInfo The merged cell information object. * Has to contain `row`, `col`, `colspan` and `rowspan` properties. * @returns {Array<{ row: number, col: number, rowspan: number, colspan: number }>} */ filterOverlappingMergeCells(mergedCellsInfo: { row: number; col: number; rowspan: number; colspan: number; }[]): { row: number; col: number; rowspan: number; colspan: number; }[]; /** * Get a merged cell contained in the provided range. * * @param {CellRange} range The range to search merged cells in. * @param {boolean} [countPartials=false] If set to `true`, all the merged cells overlapping the range will be taken into calculation. * @returns {MergedCellCoords[]} Array of found merged cells. */ getWithinRange(range: CellRange, countPartials?: boolean): MergedCellCoords[]; /** * Add a merged cell to the container. * * @param {object} mergedCellInfo The merged cell information object. Has to contain `row`, `col`, `colspan` and `rowspan` properties. * @param {boolean} [auto=false] `true` if called internally by the plugin (usually in batch). * @returns {MergedCellCoords|boolean} Returns the new merged cell on success and `false` on failure. */ add(mergedCellInfo: { row: number; col: number; rowspan: number; colspan: number; }, auto?: boolean): false | MergedCellCoords; /** * Remove a merged cell from the container. You can provide either the "starting coordinates" * of a merged cell, or any coordinates from the body of the merged cell. * * @param {number} row Row index. * @param {number} column Column index. * @returns {MergedCellCoords|boolean} Returns the removed merged cell on success and `false` on failure. */ remove(row: number, column: number): false | MergedCellCoords; /** * Clear all the merged cells. */ clear(): void; /** * Check if the provided merged cell overlaps with the others already added. * * @param {MergedCellCoords} mergedCell The merged cell to check against all others in the container. * @returns {boolean} `true` if the provided merged cell overlaps with the others, `false` otherwise. */ isOverlapping(mergedCell: MergedCellCoords): boolean; /** * Check whether the provided row/col coordinates direct to a first not hidden cell within merge area. * * @param {number} row Visual row index. * @param {number} column Visual column index. * @returns {boolean} */ isFirstRenderableMergedCell(row: number, column: number): boolean; /** * Get the first renderable coords of the merged cell at the provided coordinates. * * @param {number} row Visual row index. * @param {number} column Visual column index. * @returns {CellCoords} A `CellCoords` object with the coordinates to the first renderable cell within the * merged cell. */ getFirstRenderableCoords(row: number, column: number): import("../..").CellCoords; /** * Gets the start-most visual column index that do not intersect with other merged cells within the provided range. * * @param {CellRange} range The range to search within. * @param {number} visualColumnIndex The visual column index to start the search from. * @returns {number} */ getStartMostColumnIndex(range: CellRange, visualColumnIndex: number): number; /** * Gets the end-most visual column index that do not intersect with other merged cells within the provided range. * * @param {CellRange} range The range to search within. * @param {number} visualColumnIndex The visual column index to start the search from. * @returns {number} */ getEndMostColumnIndex(range: CellRange, visualColumnIndex: number): number; /** * Gets the top-most visual row index that do not intersect with other merged cells within the provided range. * * @param {CellRange} range The range to search within. * @param {number} visualRowIndex The visual row index to start the search from. * @returns {number} */ getTopMostRowIndex(range: CellRange, visualRowIndex: number): number; /** * Gets the bottom-most visual row index that do not intersect with other merged cells within the provided range. * * @param {CellRange} range The range to search within. * @param {number} visualRowIndex The visual row index to start the search from. * @returns {number} */ getBottomMostRowIndex(range: CellRange, visualRowIndex: number): number; /** * Shift the merged cell in the direction and by an offset defined in the arguments. * * @param {string} direction `right`, `left`, `up` or `down`. * @param {number} index Index where the change, which caused the shifting took place. * @param {number} count Number of rows/columns added/removed in the preceding action. */ shiftCollections(direction: string, index: number, count: number): void; /** * Capture the physical indexes covered by every merged cell along an axis. * * Used by the manual row/column move and column freeze integrations to translate * merges through a reorder: the captured spans pin each merge to the underlying * data so the merge can be repositioned (and split, if a non-contiguous run * results) after the visual sequence changes. * * @param {'column' | 'row'} axis Which axis the upcoming reorder targets. * @returns {Map} Map of merge -> physical indexes along the axis. */ capturePhysicalSpans(axis: 'column' | 'row'): Map; /** * Group an ascending list of integers into contiguous runs. * * @param {number[]} sortedAscending Already-sorted ascending visual indexes. * @returns {Array<{ start: number, length: number }>} */ static detectContiguousRuns(sortedAscending: number[]): Array<{ start: number; length: number; }>; /** * Translate the merged cells collection after a manual row/column reorder, splitting * merges whose physical indexes are no longer contiguous in the new visual order. * * Note: single-cell fragments (`colspan === 1 && rowspan === 1`) are dropped because * they no longer represent a merge. The user-facing behavior (auto-split + silent drop * of singletons) is documented in `docs/content/guides/cell-features/merge-cells/merge-cells.md` * under "Behavior during row/column reorder and column freeze". * * @param {'column' | 'row'} axis Axis that was reordered. * @param {Map} snapshot Snapshot taken before the reorder. */ translateAfterAxisMove(axis: 'column' | 'row', snapshot: Map): void; } export default MergedCellsCollection;