|
1
|
import { DataGridCoordinates } from "./types" |
|
2
|
|
|
3
|
export function generateCellId(coords: DataGridCoordinates) { |
|
4
|
return `${coords.row}:${coords.col}` |
|
5
|
} |
|
6
|
|
|
7
|
/** |
|
8
|
* Check if a cell is equal to a set of coords |
|
9
|
* @param cell - The cell to compare |
|
10
|
* @param coords - The coords to compare |
|
11
|
* @returns Whether the cell is equal to the coords |
|
12
|
*/ |
|
13
|
export function isCellMatch( |
|
14
|
cell: DataGridCoordinates, |
|
15
|
coords?: DataGridCoordinates | null |
|
16
|
) { |
|
17
|
if (!coords) { |
|
18
|
return false |
|
19
|
} |
|
20
|
|
|
21
|
return cell.row === coords.row && cell.col === coords.col |
|
22
|
} |
|
23
|
|
|
24
|
const SPECIAL_FOCUS_KEYS = [".", ","] |
|
25
|
|
|
26
|
export function isSpecialFocusKey(event: KeyboardEvent) { |
|
27
|
return SPECIAL_FOCUS_KEYS.includes(event.key) && event.ctrlKey && event.altKey |
|
28
|
} |