import { type RowModel, type Table, type TableFeature, type TableOptions } from '../../hooks/useTable/types.js'; import type { DataTableV2RowData } from '../../public.api.js'; /** * Extension interface to extend the types of the columnDefinition from the tanstack table. * @public */ export interface DataTableV2SortingColumnDef { /** * Setting to true disables sorting for this column even * if sorting is enabled globally. */ disableSorting?: boolean; /** * Used to compare two rows of data and order them correctly. * If a function is passed, it must be memoized. * @defaultValue 'text' */ sortType?: 'text' | 'number' | 'textCaseSensitive' | 'datetime' | DataTableV2CustomSortingFn; /** * Setting to true means the first sorting direction for * this column will be descending instead of ascending. */ sortDescFirst?: boolean; /** * Setting this to true means the underlying sorting * direction will be inverted but the UI will not. This * could be useful for example where a lower score is better. */ sortInverted?: boolean; /** * Optional - to be used for providing the value used for sorting. * This enables the value used for sorting to be different than * the value returned by the accessor. For example, if the accessor * returns an object, the sortAccessor may return a number or string * field within the object. */ sortAccessor?: string | ((row: TData) => TValue); } /** * Rule for sorting a column. * @public */ export interface DataTableV2ColumnSort { /** * Column ID. */ id: string; /** * Descending sorting direction. */ desc: boolean; } /** * @public */ export interface DataTableV2SortingBaseProps { /** * Enables sorting for all columns which do not have it explicitly * disabled with the `disableSorting` prop on the column entry. * * @defaultValue false */ sortable?: boolean | { /** * When set to true, the table will assume that the data provided by the consumer is already sorted, * and will not apply any sorting to it. */ manualSort?: boolean; }; /** * Callback triggered when sorting of the column is changed. */ onSortByChange?: (columnSorting: DataTableV2ColumnSort[]) => void; } /** * @public */ export interface DataTableV2SortingControlledProps extends DataTableV2SortingBaseProps { /** * Controlled property to define the columns the DataTableV2 is sorted by. **/ sortBy?: DataTableV2ColumnSort[]; /** * Uncontrolled property to define the columns the DataTableV2 is sorted by. **/ defaultSortBy?: never; } /** * @public */ export interface DataTableV2SortingUncontrolledProps extends DataTableV2SortingBaseProps { /** * Controlled property to define the columns the DataTableV2 is sorted by. **/ sortBy?: never; /** * Uncontrolled property to define the columns the DataTableV2 is sorted by. **/ defaultSortBy?: DataTableV2ColumnSort[]; } /** * Options for DataTableV2 sorting * @public */ export type DataTableV2SortingProps = DataTableV2SortingControlledProps | DataTableV2SortingUncontrolledProps; /** * Extension interface to extend the tanstack table state with the sortable state. * @internal */ export interface DataTableV2SortingOptions { getSortedRowModel?: (table: Table) => () => RowModel; } /** * Extension interface to extend the tanstack table header instance. * @internal */ export interface DataTableV2SortingHeader { getAriaSortAttribute: () => 'none' | 'ascending' | 'descending' | 'other' | undefined; getCanSortByHeaderClick: () => boolean; } /** * Extension interface to extend the types of the `Row` from the tanstack table. * @internal */ export interface DataTableV2SortingRow { _sortingValuesCache: Record; getSortingValue: (columnId: string) => unknown; } /** * Compares two values from a given column for sorting. * * @param valueA - First value for comparison. * @param valueB - Second value for comparison. * * @returns the function is expected to return `-1`, `0`, or `1` in ascending order. `0` indicates that both values are equal, * `-1` indicates that `valueA` should come before `valueB`, `1` indicates that `valueA` should come after `valueB`. * @public */ export interface DataTableV2CustomSortingFn { (valueA: TValue, valueB: TValue): number; } /** * Configuration hook for the DataTableV2 sorting feature. * @internal */ export declare function useSorting(props: DataTableV2SortingProps, options: TableOptions): void; /** * @internal */ export declare const Sorting: TableFeature;