import { CellContext, DisplayColumnDef, Row, RowData, TableOptions, AccessorKeyColumnDef, AccessorFnColumnDef } from "@tanstack/react-table"; import React from "react"; import Block from "../Block"; export type TTableVariant = "default" | "inset"; export type DefaultColumns = "expand" | "select"; export type IColumnName = T | DefaultColumns; export type IColumnSizing = Record; export interface IItem { id: number | string; } export type TRow = Row; export type TCellContext = CellContext; export type TEnableRowSelection = TableOptions["enableRowSelection"]; export type TGetRowProps = (row: TRow) => React.HTMLAttributes; export type TSorting = "asc" | "desc" | undefined; export type TSortingState = { [key in TColumnName]?: TSorting; }; export type ITableProps = React.ComponentProps & { columnDefinitions: IColumnDefinition>[]; items: TItem[]; trackName?: string; trackData?: object; emptyState?: React.ReactNode; loading?: boolean; footer?: React.ReactNode; rowHeight?: number | string; /** * Define a fixed height for the table. This does not take the Block header into consideration. * * If value is provided is a number, it will default to `px` unit. */ tableHeight?: number | string; /** * Define a dynamic height for the table based on content. This does not take the Block header into consideration. * * If value is provided is a number, it will default to `px` unit. */ tableMaxHeight?: number | string; renderExtraContent?: (item: TItem) => React.ReactNode; /** * When using this prop make sure to mount in your app, as it is rendered outside of the table * * Also, it is better to use and for actions as they have design system styles */ renderBulkActions?: (selectedItems: TItem[]) => React.ReactNode; getRowLink?: (item: TItem) => string; columnOrder?: IColumnName[]; visibleColumns?: IColumnName[] | Partial, boolean>>; enableRowSelection?: TEnableRowSelection; getRowProps?: TGetRowProps; getRowTrackData?: (row: Row) => object; disableColumnAutoSizing?: boolean; selectedItems?: TItem[]; onRowSelectionChange?: (selectedItems: TItem[]) => void; variant?: TTableVariant; tableHead?: boolean; sorting?: TSortingState; onSortingChange?: (sorting: TSortingState) => void; }; type TSharedColumnIdentifiers = "header" | "cell" | "size" | "minSize" | "maxSize" | "meta" | "enableSorting"; export type IColumnDefinition = (Pick, TSharedColumnIdentifiers> | Pick, TSharedColumnIdentifiers | "accessorKey"> | Pick, TSharedColumnIdentifiers | "accessorFn">) & { id: IColumnName; }; declare module "@tanstack/table-core" { interface ColumnMeta { actions?: boolean; cellClassName?: string; headerClassName?: string; } } export {};