import React, { MouseEvent } from 'react'; import IconButton from '@mui/material/IconButton'; import Tooltip from '@mui/material/Tooltip'; import type { MRT_Row, MRT_TableInstance } from '..'; interface Props = {}> { row: MRT_Row; table: MRT_TableInstance; } export const MRT_ExpandButton = = {}>({ row, table, }: Props) => { const { getState, options: { icons: { ExpandMoreIcon }, localization, muiExpandButtonProps, renderDetailPanel, }, } = table; const { density } = getState(); const iconButtonProps = muiExpandButtonProps instanceof Function ? muiExpandButtonProps({ table, row }) : muiExpandButtonProps; const canExpand = row.getCanExpand(); const isExpanded = row.getIsExpanded(); const handleToggleExpand = (event: MouseEvent) => { event.stopPropagation(); row.toggleExpanded(); iconButtonProps?.onClick?.(event); }; return ( ({ height: density === 'compact' ? '1.75rem' : '2.25rem', width: density === 'compact' ? '1.75rem' : '2.25rem', ...(iconButtonProps?.sx instanceof Function ? iconButtonProps.sx(theme) : (iconButtonProps?.sx as any)), })} title={undefined} > {iconButtonProps?.children ?? ( )} ); };