Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | 12x 12x | import type {ReactElement, ReactNode} from 'react';
import {Box, Link as MuiLink} from '@mui/material';
import {Link as RouterLink} from 'react-router-dom';
interface LinkedCellProps {
to?: string;
children: ReactNode;
title?: string;
}
/**
* DataGrid cell wrapper that renders its content as a navigation link. When
* `to` is omitted, renders as plain text — useful when the same column is
* conditionally actionable across rows.
*/
export default function LinkedCell({to, children, title}: LinkedCellProps): ReactElement {
Eif (to !== undefined) {
return (
<MuiLink
component={RouterLink}
to={to}
underline="hover"
color="primary"
title={title}
sx={{cursor: 'pointer'}}
>
{children}
</MuiLink>
);
}
return <Box component="span" title={title}>{children}</Box>;
}
|