import clsx from 'clsx'; import classes from './MRT_TableFooterRow.module.css'; import { Box, TableTr, type TableTrProps } from '@mantine/core'; import { MRT_TableFooterCell } from './MRT_TableFooterCell'; import { type MRT_ColumnVirtualizer, type MRT_Header, type MRT_HeaderGroup, type MRT_RowData, type MRT_TableInstance, type MRT_VirtualItem, } from '../../types'; import { parseFromValuesOrFunc } from '../../utils/utils'; interface Props extends TableTrProps { columnVirtualizer?: MRT_ColumnVirtualizer; footerGroup: MRT_HeaderGroup; table: MRT_TableInstance; } export const MRT_TableFooterRow = ({ columnVirtualizer, footerGroup, table, ...rest }: Props) => { 'use no memo'; const { options: { layoutMode, mantineTableFooterRowProps }, } = table; const { virtualColumns, virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer ?? {}; // if no content in row, skip row if ( !footerGroup.headers?.some( (header) => (typeof header.column.columnDef.footer === 'string' && !!header.column.columnDef.footer) || header.column.columnDef.Footer, ) ) { return null; } const tableRowProps = { ...parseFromValuesOrFunc(mantineTableFooterRowProps, { footerGroup, table, }), ...rest, }; return ( {virtualPaddingLeft ? ( ) : null} {(virtualColumns ?? footerGroup.headers).map( (footerOrVirtualFooter, renderedColumnIndex) => { let footer = footerOrVirtualFooter as MRT_Header; if (columnVirtualizer) { renderedColumnIndex = (footerOrVirtualFooter as MRT_VirtualItem) .index; footer = footerGroup.headers[renderedColumnIndex]; } return ( ); }, )} {virtualPaddingRight ? ( ) : null} ); };