add optional tooltip

This commit is contained in:
Alex Holliday committed 2025-08-28 12:21:23 -07:00
1 parent 0ad759a384
commit bda48e07f1
1 file changed
+33 -1
+33 -1
View File
@@ -7,6 +7,7 @@ import {
TableHead, TableHead,
TableRow, TableRow,
} from "@mui/material"; } from "@mui/material";
import Tooltip from "@mui/material/Tooltip";
import SkeletonLayout from "./skeleton"; import SkeletonLayout from "./skeleton";
import PropTypes from "prop-types"; import PropTypes from "prop-types";
import { useTheme } from "@emotion/react"; import { useTheme } from "@emotion/react";
@@ -41,6 +42,7 @@ const DataTable = ({
data = [], data = [],
config = { config = {
emptyView: "No data", emptyView: "No data",
tooltipContent: null,
onRowClick: () => {}, onRowClick: () => {},
}, },
}) => { }) => {
@@ -101,8 +103,37 @@ const DataTable = ({
data.map((row) => { data.map((row) => {
const key = row.id || row._id || Math.random(); const key = row.id || row._id || Math.random();
return ( return (
<TableRow <Tooltip
key={key} key={key}
followCursor
enterDelay={500}
enterNextDelay={500}
title={
typeof config.tooltipContent === "function"
? config.tooltipContent(row)
: config.tooltipContent
}
slotProps={{
tooltip: {
sx: {
background: "unset",
},
},
popper: {
modifiers: [
{
name: "offset",
options: {
offset: ({ popper }) => {
return [popper.width / 2 + 20, -popper.height / 8];
},
},
},
],
},
}}
>
<TableRow
sx={config?.rowSX ?? {}} sx={config?.rowSX ?? {}}
onClick={config?.onRowClick ? () => config.onRowClick(row) : null} onClick={config?.onRowClick ? () => config.onRowClick(row) : null}
> >
@@ -119,6 +150,7 @@ const DataTable = ({
); );
})} })}
</TableRow> </TableRow>
</Tooltip>
); );
}) })
)} )}