import type { HotInstance } from '../../../core/types'; interface CollapsedRowsStash { stash(): void; applyStash(flag: boolean): void; shiftStash(from: number, to: number, count: number): void; } interface CollapsingUI { areChildrenCollapsed(parent: Record | null): boolean; collapsedRowsStash: CollapsedRowsStash; } interface DataManager { translateTrimmedRow(rowIndex: number): number; isParent(physicalRowIndex: number): boolean; isRowHighestLevel(physicalRowIndex: number): boolean; getRowParent(index: number): Record | null; getRowIndex(object: Record | null): number; countChildren(object: Record | null): number; moveRow(fromPhysicalIndex: number, toPhysicalIndex: number, movedToCollapsed: boolean, moveToLastChild: boolean): void; rewriteCache(): void; untranslateTrimmedRow(index: number): number; } interface NestedRowsPlugin { hot: HotInstance; dataManager: DataManager; collapsingUI: CollapsingUI; } /** * Helper class for the row-move-related operations. * * @private * @class RowMoveController */ export default class RowMoveController { /** * Reference to the Nested Rows plugin instance. * * @type {NestedRows} */ plugin: NestedRowsPlugin; /** * Reference to the Handsontable instance. * * @type {Handsontable.Core} */ hot: HotInstance; /** * Reference to the Data Manager class instance. * * @type {DataManager} */ dataManager: DataManager; /** * Reference to the Collapsing UI class instance. * * @type {CollapsingUI} */ collapsingUI: CollapsingUI; /** * Flag indicating if the rows were moved to a collapsed parent. * * @type {boolean} */ movedToCollapsed: boolean; /** * Initializes the row move controller with references to the NestedRows plugin, the Handsontable instance, the data manager, and the collapsing UI. */ constructor(plugin: NestedRowsPlugin); /** * `beforeRowMove` hook callback. * * @param {Array} rows Array of visual row indexes to be moved. * @param {number} finalIndex Visual row index, being a start index for the moved rows. Points to where the elements * will be placed after the moving action. To check the visualization of the final index, please take a look at * [documentation](@/guides/rows/row-moving/row-moving.md). * @param {undefined|number} dropIndex Visual row index, being a drop index for the moved rows. Points to where we * are going to drop the moved elements. To check visualization of drop index please take a look at * [documentation](@/guides/rows/row-moving/row-moving.md). * @param {boolean} movePossible Indicates if it's possible to move rows to the desired position. * @fires Hooks#afterRowMove * @returns {boolean} */ onBeforeRowMove(rows: number[], finalIndex: number, dropIndex: number | undefined, movePossible: boolean): false | undefined; /** * Display a `dragRows`/`moveRows` method compatibility warning if needed. * * @param {object} beforeMoveRowHookArgs A set of arguments from the `beforeMoveRow` hook. * @returns {boolean} `true` if is a result of an improper usage of the moving API. */ displayAPICompatibilityWarning(beforeMoveRowHookArgs: Record): boolean; /** * Check if the moving action should be allowed. * * @param {number} physicalRowIndex Physical start row index. * @param {number} physicalDropIndex Physical drop index. * @returns {boolean} `true` if it should continue with the moving action. */ shouldAllowMoving(physicalRowIndex: number, physicalDropIndex: number): boolean; /** * Get the base row parent. * * @param {number} physicalStartIndexes Physical start row index. * @returns {object|null} The base row parent. */ getBaseParent(physicalStartIndexes: number[]): Record | null; /** * Get the target row parent. * * @param {boolean} dropToLastRow `true` if the row is moved to the last row of the table. * @param {number} physicalDropIndex Physical drop row index. * @returns {object|null} The target row parent. */ getTargetParent(dropToLastRow: boolean, physicalDropIndex: number): Record | null; /** * Shift the cached collapsible rows position according to the move action. * * @param {number[]} physicalStartIndexes Physical start row indexes. * @param {number} physicalDropIndex Physical drop index. * @param {boolean} sameParent `true` if the row's being moved between siblings of the same parent. */ shiftCollapsibleParentsLocations(physicalStartIndexes: number[], physicalDropIndex: number, sameParent: boolean): void; /** * Move the rows at the provided coordinates. * * @param {number[]} physicalStartIndexes Physical indexes of the rows about to be moved. * @param {number} physicalDropIndex Physical drop index. * @param {object} targetParent Parent of the destination row. */ moveRows(physicalStartIndexes: number[], physicalDropIndex: number, targetParent: Record | null): void; /** * Move the cell meta for multiple rows. * * @param {number[]} baseIndexes Array of indexes for the rows being moved. * @param {number} targetIndex Index of the destination of the move. */ moveCellsMeta(baseIndexes: number[], targetIndex: number): void; /** * Select cells after the move. * * @param {Array} rows Array of visual row indexes to be moved. * @param {undefined|number} dropIndex Visual row index, being a drop index for the moved rows. Points to where we * are going to drop the moved elements. To check visualization of drop index please take a look at * [documentation](@/guides/rows/row-moving/row-moving.md). */ selectCells(rows: number[], dropIndex: number | undefined): void; /** * Indicates if order of rows was changed. * * @param {Array} movedRows Array of visual row indexes to be moved. * @param {number} finalIndex Visual row index, being a start index for the moved rows. Points to where the elements * will be placed after the moving action. To check the visualization of the final index, please take a look at * [documentation](@/guides/rows/row-moving/row-moving.md). * @returns {boolean} */ isRowOrderChanged(movedRows: number[], finalIndex: number): boolean; } export {};