import Handsontable from 'handsontable' // Handsontable physical/visual row helper functions for hiddenColumns support // Problem: Custom renderers cause dirty rendering after hiding columns due to DOM reuse // Solution: Use physical row index for data lookup export const getPhysicalRowIndex = (instance: Handsontable.Core, visualRow: number): number => { const physicalRow = instance.toPhysicalRow(visualRow) return physicalRow >= 0 ? physicalRow : visualRow } export const getRowData = (instance: Handsontable.Core, visualRow: number): any | null => { const physicalRow = getPhysicalRowIndex(instance, visualRow) return (instance.getSourceDataAtRow(physicalRow) as any | null) ?? null } export const getCellValueByProp = ( instance: Handsontable.Core, visualRow: number, visualColumn: number, ): { cellProp: string | number; cellValue: any; rowData: any | null } => { const cellProp = instance.colToProp(visualColumn) const rowData = getRowData(instance, visualRow) if (typeof cellProp === 'string' && rowData) { return { cellProp, cellValue: rowData[cellProp], rowData } } return { cellProp, cellValue: instance.getDataAtCell(visualRow, visualColumn), rowData, } }