-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
66 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { type FC, type ReactNode } from "react" | ||
import { | ||
Table as MuiTable, | ||
type TableProps as MuiTableProps, | ||
TableBody, | ||
type TableBodyProps, | ||
TableCell, | ||
type TableCellProps, | ||
TableContainer, | ||
type TableContainerProps, | ||
TableHead, | ||
type TableHeadProps, | ||
TableRow, | ||
type TableRowProps, | ||
} from "@mui/material" | ||
|
||
export interface TableProps extends MuiTableProps { | ||
headers: ReactNode[] | ||
children: ReactNode | ||
containerProps?: TableContainerProps | ||
headProps?: TableHeadProps | ||
headCellProps?: TableCellProps | ||
headRowProps?: TableRowProps | ||
bodyProps?: TableBodyProps | ||
} | ||
|
||
const Table: FC<TableProps> = ({ | ||
headers, | ||
children, | ||
containerProps, | ||
headProps, | ||
headCellProps, | ||
headRowProps, | ||
bodyProps, | ||
...tableProps | ||
}) => ( | ||
<TableContainer {...containerProps}> | ||
<MuiTable {...tableProps}> | ||
<TableHead {...headProps}> | ||
<TableRow {...headRowProps}> | ||
{headers.map((header, index) => ( | ||
<TableCell {...headCellProps} key={`table-head-cell-${index}`}> | ||
{header} | ||
</TableCell> | ||
))} | ||
</TableRow> | ||
</TableHead> | ||
<TableBody {...bodyProps}>{children}</TableBody> | ||
</MuiTable> | ||
</TableContainer> | ||
) | ||
|
||
export default Table |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export { default as Table } from "./Table" | ||
export * from "./Table" | ||
export { | ||
TableCell as Cell, | ||
type TableCellProps as CellProps, | ||
TableRow as BodyRow, | ||
type TableRowProps as BodyRowProps, | ||
} from "@mui/material" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters