import { memo } from 'react'; import { useRovingTabIndex } from './hooks'; import { getCellClassname, getCellStyle } from './utils'; import type { CalculatedColumn, GroupRow } from './types'; interface GroupCellProps { column: CalculatedColumn; row: GroupRow; isCellActive: boolean; isGroupByColumn: boolean; // Only the group-by column of the row's level renders the group cell and is clickable isLevelMatching: boolean; toggleGroup: (expandedGroupId: string) => void; } function GroupCell({ column, row, isCellActive, isGroupByColumn, isLevelMatching, toggleGroup: toggleGroupWrapper }: GroupCellProps) { const { tabIndex, childTabIndex, onFocus } = useRovingTabIndex(isCellActive); function toggleGroup() { toggleGroupWrapper(row.id); } return (
{(!isGroupByColumn || isLevelMatching) && column.renderGroupCell?.({ column, row, tabIndex: childTabIndex, toggleGroup })}
); } export default memo(GroupCell) as (props: GroupCellProps) => React.JSX.Element;