Skip to content

Commit fd6704d

Browse files
committed
feat(coretax): add ui handler for table
1 parent edda860 commit fd6704d

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

src/coretax/ui/table.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
export class TableData {
2+
private raw: HTMLTableElement;
3+
4+
constructor(element: HTMLTableElement) {
5+
this.raw = element;
6+
}
7+
8+
headers_element(): HTMLTableHeaderCellElement[] {
9+
const headers_element = Array.from(this.raw.querySelectorAll<
10+
HTMLTableHeaderCellElement
11+
>(
12+
"thead > tr:nth-of-type(1) > th",
13+
));
14+
return headers_element;
15+
}
16+
17+
headers_text(): string[] {
18+
const headers_text = this.headers_element().map((e) => e.innerText);
19+
return headers_text;
20+
}
21+
22+
headers_action_element(): HTMLTableHeaderCellElement[] {
23+
const headers_element = Array.from(this.raw.querySelectorAll<
24+
HTMLTableHeaderCellElement
25+
>(
26+
"thead > tr:nth-of-type(2) > th",
27+
));
28+
return headers_element;
29+
}
30+
31+
cells_element() {
32+
const rows_element = Array.from(this.raw.querySelectorAll("tbody > tr"));
33+
const cells_element = rows_element.map((e) =>
34+
Array.from(e.querySelectorAll("td"))
35+
);
36+
37+
return cells_element;
38+
}
39+
40+
cells_text() {
41+
const cells_element = this.cells_element();
42+
const cells_text = cells_element.map((row) =>
43+
row.map((cell) => cell.innerText)
44+
);
45+
46+
return cells_text;
47+
}
48+
}

0 commit comments

Comments
 (0)