import { ComponentType, SyntheticEvent, FC, MouseEvent } from 'react'; import { TableCellProps, TableHeaderCellProps, Checkbox, CheckboxProps, } from '@servicetitan/design-system'; import classNames from 'classnames'; import * as Styles from './select-cell.module.css'; import { useTdProps } from '../utils/use-td-props'; export type SelectionControlType = ComponentType>; interface SelectColumnCellProps extends TableCellProps { isRowSelectable?: boolean; control?: SelectionControlType; } interface SelectHeaderCellProps extends TableHeaderCellProps { isSomeRowsSelected?: boolean; control?: SelectionControlType; } interface SelectCellProps { checked: boolean; disabled?: boolean; indeterminate?: boolean; selectionChange?: (event: { syntheticEvent: SyntheticEvent }) => void; control?: SelectionControlType; } export const SelectCell: FC = ({ selectionChange, control: Control = Checkbox, ...props }: SelectCellProps) => { const onChange = (_0: never, _1: boolean, event: SyntheticEvent) => { if (!selectionChange) { return; } selectionChange({ syntheticEvent: event }); }; return ; }; const stopPropagation = (e: MouseEvent) => e.stopPropagation(); export const SelectColumnCell: FC = (props: SelectColumnCellProps) => { const tdProps = useTdProps(props); if (props.rowType === 'groupHeader') { return null; } if (props.rowType === 'groupFooter') { return ; } return ( ); }; export const SelectHeaderCell: FC = (props: SelectHeaderCellProps) => ( );