import clsx from 'clsx'; import classes from './MRT_TableHeadCellSortLabel.module.css'; import { ActionIcon, type ActionIconProps, Indicator, Tooltip, } from '@mantine/core'; import type { MRT_Header, MRT_RowData, MRT_TableInstance } from '../../types'; import { dataVariable } from '../../utils/style.utils'; interface Props extends ActionIconProps { header: MRT_Header; table: MRT_TableInstance; } export const MRT_TableHeadCellSortLabel = ({ header, table, ...rest }: Props) => { 'use no memo'; const { getState, options: { icons: { IconArrowsSort, IconSortAscending, IconSortDescending }, localization, }, } = table; const column = header.column; const { columnDef } = column; const { sorting } = getState(); const sorted = column.getIsSorted(); const sortIndex = column.getSortIndex(); const sortTooltip = sorted ? sorted === 'desc' ? localization.sortedByColumnDesc.replace('{column}', columnDef.header) : localization.sortedByColumnAsc.replace('{column}', columnDef.header) : column.getNextSortingOrder() === 'desc' ? localization.sortByColumnDesc.replace('{column}', columnDef.header) : localization.sortByColumnAsc.replace('{column}', columnDef.header); const SortActionButton = ( {sorted === 'desc' ? ( ) : sorted === 'asc' ? ( ) : ( )} ); return ( {sorting.length < 2 || sortIndex === -1 ? ( SortActionButton ) : ( {SortActionButton} )} ); };