import TableCell, { type TableCellProps } from '@mui/material/TableCell'; import { useTheme } from '@mui/material/styles'; import { type MRT_Header, type MRT_RowData, type MRT_TableInstance, } from '../../types'; import { getCommonMRTCellStyles } from '../../utils/style.utils'; import { parseFromValuesOrFunc } from '../../utils/utils'; import { cellKeyboardShortcuts } from '../../utils/cell.utils'; export interface MRT_TableFooterCellProps extends TableCellProps { footer: MRT_Header; staticColumnIndex?: number; table: MRT_TableInstance; } export const MRT_TableFooterCell = ({ footer, staticColumnIndex, table, ...rest }: MRT_TableFooterCellProps) => { const theme = useTheme(); const { getState, options: { enableColumnPinning, muiTableFooterCellProps, enableKeyboardShortcuts, }, } = table; const { density } = getState(); const { column } = footer; const { columnDef } = column; const { columnDefType } = columnDef; const isColumnPinned = enableColumnPinning && columnDef.columnDefType !== 'group' && column.getIsPinned(); const args = { column, table }; const tableCellProps = { ...parseFromValuesOrFunc(muiTableFooterCellProps, args), ...parseFromValuesOrFunc(columnDef.muiTableFooterCellProps, args), ...rest, }; const handleKeyDown = (event: React.KeyboardEvent) => { tableCellProps?.onKeyDown?.(event); cellKeyboardShortcuts({ event, cellValue: footer.column.columnDef.footer, table, }); }; return ( ({ fontWeight: 'bold', p: density === 'compact' ? '0.5rem' : density === 'comfortable' ? '1rem' : '1.5rem', verticalAlign: 'top', ...getCommonMRTCellStyles({ column, header: footer, table, tableCellProps, theme, }), ...(parseFromValuesOrFunc(tableCellProps?.sx, theme) as any), })} > {tableCellProps.children ?? (footer.isPlaceholder ? null : (parseFromValuesOrFunc(columnDef.Footer, { column, footer, table, }) ?? columnDef.footer ?? null))} ); };