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