Refactor
Some changes to simplify and harmonize the code structure:
Cell.tsx
-
Cell.onChange, Grid.setErrorCell : define regExp as a static variable to compile only once -
ICellProps: modifiable field is redundant with onChange → modifiable = onChange ≠ null ? -
add readOnly attribute on non-modifiable cells
Grid:
-
cells IDs are differents in memory and database - memory : cells[XX]
- DB : mvmap[cellXX]
-
setMVMap: rename to initFrom and take a string instead of an array -
checkArray: delete, replace with array.every((c) => c <= 1); -
firstCellOfBlock(): used in blockIndex() only -
hashSetToString: generalize in
function* jsiter(ktIterator){
while (ktIterator.hasNext()) {
yield ktIterator.next();
}
}
-
merge GridUtils to Grid -
IGridState.cells: { value: string, modifiable: boolean, error: boolean}[] -
checkGrid/setErrorCell: errorIndexList → Set -
validateLine/Column → checkLine/Column
checkLine/Column → checkLines/Columns
validateBlock → checkBlock
checkCells → checkBlocks -
setErrorCell: rename to updateState and reverse call to checkGrid
Edited by Yannick Li