-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathRow.ts
More file actions
40 lines (40 loc) · 1.01 KB
/
Row.ts
File metadata and controls
40 lines (40 loc) · 1.01 KB
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
import Colors from './enum/colors';
import { ICell, IRow } from './types';
import Cell from './Cell';
export default class Row {
isHeader: boolean;
rowHeight: number;
columns: Cell[];
rowSpan?: number;
constructor(row?: string[] | IRow) {
this.isHeader = false;
this.rowHeight = 15;
this.columns = [];
if (!row) {
return;
}
if (Array.isArray(row)) {
row.forEach((col) => {
this.addColumn(col);
});
return;
}
this.isHeader = row.isHeader;
this.rowHeight = row.rowHeight;
this.columns = row.columns;
this.rowSpan = row.rowSpan;
}
/**
* Adds single column to the Row
*
* @param {(string | ICell)} column
* @memberof Row
*/
addColumn(column: string | ICell): void {
if (column instanceof Cell) {
this.columns.push(column);
} else {
this.columns.push(new Cell(column));
}
}
}