import React, { forwardRef } from 'react';
import { TableCell as MuiTableCell, type TableCellProps } from '@mui/material';

type Props = {
  noWrap?: boolean;
  autoWidth?: boolean;
} & TableCellProps;

const TableCell = forwardRef<HTMLTableCellElement, Props>(({ noWrap, autoWidth, sx, ...rest }, ref) => (
  <MuiTableCell
    ref={ref}
    {...rest}
    sx={{
      ...(noWrap && {
        whiteSpace: 'nowrap',
      }),
      ...(autoWidth && {
        minWidth: 0,
        width: 'auto',
      }),
      ...sx,
    }}
  />
));

TableCell.displayName = 'TableCell';

export default TableCell;
