import type { CellData, ColumnDef, Header, HeaderGroup, ReactTable, Row, RowData, } from '@tanstack/react-table'; import type { CSSProperties, MouseEvent } from 'react'; import type { HighlightEventSourceExtra, HighlightEventSourceType, } from '../../highlight/index.tsx'; import type { BaseContextMenuProps } from '../ContextMenuBluePrint.tsx'; import type { TanStackTableFeatures } from './features.ts'; type TanStackCellData = CellData; export type TanStackRowData = RowData; export type TanStackReactTable = ReactTable< TanStackTableFeatures, TData >; export type TanStackTableRow = Row< TanStackTableFeatures, TData >; export type TanStackTableColumn< TData extends TanStackRowData, TValue extends TanStackCellData = TanStackCellData, > = ColumnDef; export type TanStackTableHeader< TData extends TanStackRowData, TValue extends TanStackCellData = TanStackCellData, > = Header; export type TanStackTableHeaderGroup = HeaderGroup; export type TanStackTableHighlightSourceProps = { [K in HighlightEventSourceType]: HighlightEventSourceExtra extends never ? { highlightedSource?: K; getHighlightExtra?: never } : { highlightedSource: K; getHighlightExtra: (row: TData) => HighlightEventSourceExtra; }; }[HighlightEventSourceType]; export interface TanStackTableRowStyle { active?: CSSProperties; activated?: CSSProperties; hover?: CSSProperties; base?: CSSProperties; } export interface TanStackTableContextMenuProps { contextMenu?: BaseContextMenuProps['options']; onContextMenuSelect?: ( selected: Parameters[0], data: TData, ) => void; } export interface TanStackTableClickEvent { onClick?: (event: MouseEvent, row: TanStackTableRow) => void; } export interface TanStackTableSortEvent { onSortEnd?: (data: TData[], isTableSorted?: boolean) => void; } export interface TanStackTableReorderEvent { onReorder?: ( sourceIndex: number, targetIndex: number, source: TData, target: TData, ) => void; } interface VirtualBoundary { start: number; end: number; } export interface TanStackTableVirtualBoundary { rows: VirtualBoundary; columns: VirtualBoundary; }