import { Checkbox, type CheckboxProps, Tooltip } from '@mantine/core'; import { type MRT_Column, type MRT_TableInstance } from '../types'; interface Props = {}> { column: MRT_Column; table: MRT_TableInstance; } export const MRT_FilterCheckbox = = {}>({ column, table, }: Props) => { const { getState, options: { localization, mantineFilterCheckboxProps }, } = table; const { density } = getState(); const { columnDef } = column; const mTableHeadCellFilterCheckboxProps = mantineFilterCheckboxProps instanceof Function ? mantineFilterCheckboxProps({ column, table, }) : mantineFilterCheckboxProps; const mcTableHeadCellFilterCheckboxProps = columnDef.mantineFilterCheckboxProps instanceof Function ? columnDef.mantineFilterCheckboxProps({ column, table, }) : columnDef.mantineFilterCheckboxProps; const checkboxProps = { ...mTableHeadCellFilterCheckboxProps, ...mcTableHeadCellFilterCheckboxProps, } as CheckboxProps; const filterLabel = localization.filterByColumn?.replace( '{column}', columnDef.header, ); return ( { e.stopPropagation(); checkboxProps?.onClick?.(e); }} onChange={(e) => { column.setFilterValue( column.getFilterValue() === undefined ? 'true' : column.getFilterValue() === 'true' ? 'false' : undefined, ); checkboxProps?.onChange?.(e); }} sx={(theme) => ({ fontWeight: 'normal', ...(checkboxProps?.sx instanceof Function ? checkboxProps.sx(theme) : (checkboxProps?.sx as any)), height: "2rem", })} styles={{ label: { alignItems: 'center', } }} title={undefined} /> ); };