summaryrefslogtreecommitdiff
path: root/web/src/types.ts
blob: 9b7a51aa5b024519769cf0fa5dc562f48668dda0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import Ratio from "./math/Ratio";

export interface Cell {
  value?: string;
  widthRatio: Ratio;
}

export interface Row {
  cells: Cell[];
}

export interface Part {
  title?: string;
  rows: Row[];
}

export interface Grid {
  id: string;
  baseCellSize: number;
  baseCellWidthRatio: Ratio;
  parts: Part[];
}

export interface Doc {
  grids: Grid[];
}

export interface RowRef {
  partIndex: number;
  rowIndex: number;
}

export interface CellRef {
  partIndex: number;
  rowIndex: number;
  cellIndex: number;
}

export function cellRefEquals(a: CellRef, b: CellRef): boolean {
  return (
    a.partIndex === b.partIndex &&
    a.rowIndex === b.rowIndex &&
    a.cellIndex === b.cellIndex
  );
}