* renamed editable field to inline cell in ui folder * renamed table to table-cell in ui folder
21 lines
659 B
TypeScript
21 lines
659 B
TypeScript
import { useContext, useMemo } from 'react';
|
|
|
|
import { ColumnIndexContext } from '../../contexts/ColumnIndexContext';
|
|
import { RowIndexContext } from '../../contexts/RowIndexContext';
|
|
import { TableCellPosition } from '../../types/TableCellPosition';
|
|
|
|
export const useCurrentTableCellPosition = () => {
|
|
const currentRowNumber = useContext(RowIndexContext);
|
|
const currentColumnNumber = useContext(ColumnIndexContext);
|
|
|
|
const currentTableCellPosition: TableCellPosition = useMemo(
|
|
() => ({
|
|
column: currentColumnNumber,
|
|
row: currentRowNumber,
|
|
}),
|
|
[currentColumnNumber, currentRowNumber],
|
|
);
|
|
|
|
return currentTableCellPosition;
|
|
};
|