Skip to content

Commit fd0d6e4

Browse files
committed
Finish update table component
1 parent 62aac25 commit fd0d6e4

File tree

3 files changed

+8
-39
lines changed

3 files changed

+8
-39
lines changed

chartlets.js/packages/lib/src/plugins/mui/Table.test.tsx

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import { createChangeHandler } from "@/plugins/mui/common.test";
66

77
describe("Table", () => {
88
const rows = [
9-
{ id: 1, data: { firstName: "John", lastName: "Doe" } },
10-
{ id: 2, data: { firstName: "Johnie", lastName: "Undoe" } },
9+
["John", "Doe"],
10+
["Johnie", "Undoe"],
1111
];
1212
const columns = [
1313
{ id: "firstName", label: "First Name" },
@@ -30,9 +30,8 @@ describe("Table", () => {
3030
columns.forEach((column) => {
3131
expect(screen.getByText(column.label)).toBeInTheDocument();
3232
});
33-
rows.forEach((row) => {
34-
expect(screen.getByText(row.data.firstName)).toBeInTheDocument();
35-
expect(screen.getByText(row.data.lastName)).toBeInTheDocument();
33+
rows.forEach((row, index) => {
34+
expect(screen.getByText(row[index])).toBeInTheDocument();
3635
});
3736
});
3837

@@ -69,11 +68,8 @@ describe("Table", () => {
6968
id: "table",
7069
property: "value",
7170
value: {
72-
id: 1,
73-
data: {
74-
firstName: "John",
75-
lastName: "Doe",
76-
},
71+
firstName: "John",
72+
lastName: "Doe",
7773
},
7874
});
7975
});

chartlets.js/packages/lib/src/plugins/mui/Table.tsx

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ interface TableCellProps {
1414
id: string | number;
1515
size?: "medium" | "small";
1616
align?: "inherit" | "left" | "center" | "right" | "justify";
17-
padding?: "checkbox" | "none" | "normal";
1817
sx?: SxProps;
1918
}
2019

@@ -70,30 +69,6 @@ export const Table = ({
7069
}
7170
};
7271

73-
// function descendingComparator<T>(a: T, b: T, orderBy: keyof T) {
74-
// if (b[orderBy] < a[orderBy]) {
75-
// return -1;
76-
// }
77-
// if (b[orderBy] > a[orderBy]) {
78-
// return 1;
79-
// }
80-
// return 0;
81-
// }
82-
//
83-
// type Order = "asc" | "desc";
84-
//
85-
// function getComparator<Key extends keyof any>(
86-
// order: Order,
87-
// orderBy: Key,
88-
// ): (
89-
// a: { [key in Key]: number | string },
90-
// b: { [key in Key]: number | string },
91-
// ) => number {
92-
// return order === "desc"
93-
// ? (a, b) => descendingComparator(a, b, orderBy)
94-
// : (a, b) => -descendingComparator(a, b, orderBy);
95-
// }
96-
9772
return (
9873
<TableContainer component={Paper} sx={style} id={id}>
9974
<MuiTable stickyHeader={stickyHeader}>
@@ -104,7 +79,6 @@ export const Table = ({
10479
key={column.id}
10580
align={column.align || "inherit"}
10681
size={column.size || "medium"}
107-
padding={column.padding}
10882
>
10983
{column.label}
11084
</TableCell>
@@ -123,7 +97,6 @@ export const Table = ({
12397
key={item_index}
12498
align={columns[item_index].align || "inherit"}
12599
size={columns[item_index].size || "medium"}
126-
padding={columns[item_index].padding}
127100
>
128101
{item}
129102
</TableCell>

chartlets.py/chartlets/components/table.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@ class TableCellProps(TypedDict, total=False):
1515
align: Literal["inherit", "left", "center", "right", "justify"] | None
1616
"""The alignment of the cell content."""
1717

18-
# sortDirection:
19-
2018

2119
class TableColumn(TableCellProps):
2220
"""Defines a column in the table."""
2321

2422
label: str
2523
"""The display label for the column header."""
2624

25+
2726
type TableRow = list[list[str | int | float | bool | None]]
2827

28+
2929
@dataclass(frozen=True)
3030
class Table(Component):
3131
"""A basic Table with configurable rows and columns."""

0 commit comments

Comments
 (0)