import clsx from 'clsx'; import classes from './MRT_ExpandButton.module.css'; import { type MouseEvent } from 'react'; import { ActionIcon, type ActionIconProps, Tooltip, useDirection, } from '@mantine/core'; import { type MRT_Row, type MRT_RowData, type MRT_TableInstance, } from '../../types'; import { parseFromValuesOrFunc } from '../../utils/utils'; import { MRT_EditCellTextInput } from '../inputs/MRT_EditCellTextInput'; interface Props extends ActionIconProps { row: MRT_Row; table: MRT_TableInstance; } export const MRT_ExpandButton = ({ row, table, ...rest }: Props) => { 'use no memo'; const direction = useDirection(); const { options: { icons: { IconChevronDown }, localization, mantineExpandButtonProps, positionExpandColumn, renderDetailPanel, }, } = table; const actionIconProps = { ...parseFromValuesOrFunc(mantineExpandButtonProps, { row, table, }), ...rest, }; const internalEditComponents = row .getAllCells() .filter((cell) => cell.column.columnDef.columnDefType === 'data') .map((cell) => ( )); const canExpand = row.getCanExpand(); const isExpanded = row.getIsExpanded(); const DetailPanel = !!renderDetailPanel?.({ internalEditComponents, row, table, }); const handleToggleExpand = (event: MouseEvent) => { event.stopPropagation(); row.toggleExpanded(); actionIconProps?.onClick?.(event); }; const rtl = direction.dir === 'rtl' || positionExpandColumn === 'last'; return ( {actionIconProps?.children ?? ( )} ); };