1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { DataTableFilterItem } from "../data-table-filters/data-table-filters";
7 export interface DataColumn<T, F extends DataTableFilterItem = DataTableFilterItem> {
10 configurable?: boolean;
12 sortDirection?: SortDirection;
14 render: (item: T) => React.ReactElement<void>;
15 renderHeader?: () => React.ReactElement<void> | null;
19 export enum SortDirection {
25 export const isColumnConfigurable = <T>(column: DataColumn<T>) => {
26 return column.configurable === undefined || column.configurable;
29 export const toggleSortDirection = <T>(column: DataColumn<T>): DataColumn<T> => {
30 return column.sortDirection
31 ? column.sortDirection === SortDirection.Asc
32 ? { ...column, sortDirection: SortDirection.Desc }
33 : { ...column, sortDirection: SortDirection.Asc }
37 export const resetSortDirection = <T>(column: DataColumn<T>): DataColumn<T> => {
38 return column.sortDirection ? { ...column, sortDirection: SortDirection.None } : column;