You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
1.5KB

  1. import {
  2. Button,
  3. Stack,
  4. SxProps,
  5. Table,
  6. TableBody,
  7. TableCell,
  8. TableRow,
  9. Typography,
  10. useTheme,
  11. } from "@mui/material";
  12. import TextFieldEx from "components/form/TextFieldEx";
  13. import { ReactNode, useEffect, useMemo } from "react";
  14. export { default as TableHeadCustom } from "./TableHeadCustom";
  15. export type SimpleData = {
  16. title: string;
  17. value?: string;
  18. end?: ReactNode;
  19. };
  20. export type SimpleDataListProps = {
  21. data: SimpleData[];
  22. tableSx?: SxProps;
  23. };
  24. export const SimpleDataList = ({ data, tableSx }: SimpleDataListProps) => {
  25. const { typography } = useTheme();
  26. const fontSize = useMemo(() => {
  27. return typography.body2.fontSize;
  28. }, [typography]);
  29. return (
  30. <Table sx={tableSx}>
  31. <TableBody>
  32. {data.map(({ title, value, end }, index) => {
  33. return (
  34. <TableRow key={index}>
  35. <TableCell
  36. sx={{ borderRight: "1px solid rgba(224, 224, 224, 1)" }}
  37. >
  38. <Typography variant="body2">{title}</Typography>
  39. </TableCell>
  40. <TableCell>
  41. <Stack direction="row" spacing={1}>
  42. <TextFieldEx
  43. value={value ?? ""}
  44. readOnly
  45. multiline
  46. fullWidth
  47. inputProps={{ style: { fontSize } }}
  48. />
  49. {end}
  50. </Stack>
  51. </TableCell>
  52. </TableRow>
  53. );
  54. })}
  55. </TableBody>
  56. </Table>
  57. );
  58. };