import React from 'react'; import { cn } from '../../utils/cn'; import { ColumnAlignment, SortDirection } from '../../types'; export interface TableHeadCellProps extends React.ThHTMLAttributes { /** * Is this header cell sortable */ sortable?: boolean; /** * Current sort direction */ sortDirection?: SortDirection; /** * Whether this cell contains actions */ isAction?: boolean; /** * Whether this cell contains selection controls */ isSelect?: boolean; /** * Width of the column (CSS width value) */ width?: string | number; /** * Text alignment */ align?: ColumnAlignment; /** * Custom class name */ className?: string; } export const TableHeadCell = React.forwardRef< HTMLTableCellElement, TableHeadCellProps >(({ children, sortable, sortDirection, isAction, isSelect, width, align = 'left', className, ...props }, ref) => { return (
{children} {sortable && ( {sortDirection === 'asc' && ( )} {sortDirection === 'desc' && ( )} {!sortDirection && ( )} )}
); }); TableHeadCell.displayName = 'TableHeadCell'; export default TableHeadCell;