import clsx from 'clsx'; import commonClasses from './common.styles.module.css'; import classes from './MRT_TopToolbar.module.css'; import { Box, type BoxProps, Flex } from '@mantine/core'; import { useMediaQuery } from '@mantine/hooks'; import { MRT_ProgressBar } from './MRT_ProgressBar'; import { MRT_TablePagination } from './MRT_TablePagination'; import { MRT_ToolbarAlertBanner } from './MRT_ToolbarAlertBanner'; import { MRT_ToolbarDropZone } from './MRT_ToolbarDropZone'; import { MRT_ToolbarInternalButtons } from './MRT_ToolbarInternalButtons'; import { type MRT_RowData, type MRT_TableInstance } from '../../types'; import { parseFromValuesOrFunc } from '../../utils/utils'; import { MRT_GlobalFilterTextInput } from '../inputs/MRT_GlobalFilterTextInput'; interface Props extends BoxProps { table: MRT_TableInstance; } export const MRT_TopToolbar = ({ table, ...rest }: Props) => { 'use no memo'; const { getState, options: { enableGlobalFilter, enablePagination, enableToolbarInternalActions, mantineTopToolbarProps, positionGlobalFilter, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, renderTopToolbarCustomActions, }, refs: { topToolbarRef }, } = table; const { isFullScreen, showGlobalFilter } = getState(); const isMobile = useMediaQuery('(max-width:720px)'); const isTablet = useMediaQuery('(max-width:1024px)'); const toolbarProps = { ...parseFromValuesOrFunc(mantineTopToolbarProps, { table }), ...rest, }; const stackAlertBanner = isMobile || !!renderTopToolbarCustomActions || (showGlobalFilter && isTablet); const globalFilterProps = { style: !isTablet ? { zIndex: 3, } : undefined, table, }; return ( { if (node) { topToolbarRef.current = node; if (toolbarProps?.ref) { toolbarProps.ref.current = node; } } }} > {positionToolbarAlertBanner === 'top' && ( )} {['both', 'top'].includes(positionToolbarDropZone ?? '') && ( )} {enableGlobalFilter && positionGlobalFilter === 'left' && ( )} {renderTopToolbarCustomActions?.({ table }) ?? } {enableToolbarInternalActions ? ( {enableGlobalFilter && positionGlobalFilter === 'right' && ( )} ) : ( enableGlobalFilter && positionGlobalFilter === 'right' && ( ) )} {enablePagination && ['both', 'top'].includes(positionPagination ?? '') && ( )} ); };