import IconButton, { type IconButtonProps } from '@mui/material/IconButton'; import Tooltip from '@mui/material/Tooltip'; import { type MRT_RowData, type MRT_TableInstance } from '../../types'; import { getCommonTooltipProps } from '../../utils/style.utils'; import { parseFromValuesOrFunc } from '../../utils/utils'; export interface MRT_ExpandAllButtonProps extends IconButtonProps { table: MRT_TableInstance; } export const MRT_ExpandAllButton = ({ table, ...rest }: MRT_ExpandAllButtonProps) => { const { getCanSomeRowsExpand, getIsAllRowsExpanded, getIsSomeRowsExpanded, getState, options: { icons: { KeyboardDoubleArrowDownIcon }, localization, muiExpandAllButtonProps, renderDetailPanel, }, toggleAllRowsExpanded, } = table; const { density, isLoading } = getState(); const iconButtonProps = { ...parseFromValuesOrFunc(muiExpandAllButtonProps, { table, }), ...rest, }; const isAllRowsExpanded = getIsAllRowsExpanded(); return ( toggleAllRowsExpanded(!isAllRowsExpanded)} {...iconButtonProps} sx={(theme) => ({ height: density === 'compact' ? '1.75rem' : '2.25rem', mt: density !== 'compact' ? '-0.25rem' : undefined, width: density === 'compact' ? '1.75rem' : '2.25rem', ...(parseFromValuesOrFunc(iconButtonProps?.sx, theme) as any), })} title={undefined} > {iconButtonProps?.children ?? ( )} ); };