import React, { ReactNode } from 'react'; import { IResponsiveTableColumnDefinition } from '../Data/IResponsiveTableColumnDefinition'; import { IResponsiveTablePlugin } from '../Plugins/IResponsiveTablePlugin'; export type ColumnDefinition = IResponsiveTableColumnDefinition | ((data: TData, rowIndex?: number) => IResponsiveTableColumnDefinition); /** * Parameters passed to the dataSource function. */ export interface IDataSourceParams { /** The 1-based page number to fetch. */ page: number; /** The number of items to fetch per page. */ pageSize: number; /** The active sort configuration, if any. */ sort?: { columnId: string; direction: 'asc' | 'desc'; }; /** The active filter string, if any. */ filter?: string; } /** * The result of a dataSource fetch. * Can be a simple array of items (hasMore will be auto-detected) * or an object containing items and an optional totalCount. */ export type DataSourceResult = TData[] | { items: TData[]; totalCount?: number; }; /** * A function that fetches data from an external source (e.g., an API). */ export type DataSource = (params: IDataSourceParams) => Promise>; interface TableContextValue { /** The raw data provided to the table (or the combined data from dataSource). */ data: TData[]; /** The data after being processed by plugins (sort, filter, etc.). */ processedData: TData[]; /** Alias for processedData, used for backward compatibility. */ currentData: TData[]; /** The list of columns that are currently visible. */ visibleColumns: ColumnDefinition[]; /** The full list of column definitions provided to the table. */ originalColumnDefinitions: ColumnDefinition[]; /** The list of plugins currently active on the table. */ activePlugins: IResponsiveTablePlugin[]; /** Callback for when a row is clicked. */ onRowClick?: (item: TData) => void; /** Configuration for row selection. */ selectionProps?: { onSelectionChange: (selectedItems: TData[]) => void; rowIdKey: keyof TData; mode?: 'single' | 'multiple'; selectedItems?: TData[]; selectedRowClassName?: string; }; /** Configuration for table animations and loading states. */ animationProps?: { isLoading?: boolean; animateOnLoad?: boolean; }; /** The smart data source used for server-side operations and infinite scroll. */ dataSource?: DataSource; /** The current state of pagination and async loading. */ pagination?: { currentPage: number; pageSize: number; hasMore: boolean; totalCount?: number; isLoading: boolean; isFetchingMore: boolean; loadNextPage: () => void; error?: Error; }; /** Custom CSS class to apply to each card in mobile view. */ mobileCardClassName?: string; /** Return a ReactNode for expandable content below a row, or null/undefined for no toggle on that row. */ expandRowRenderer?: (row: TData, rowIndex: number) => React.ReactNode; /** Custom CSS class applied to the chevron icon span. */ expandChevronClassName?: string; getRawColumnDefinition: (colDef: ColumnDefinition) => IResponsiveTableColumnDefinition; getColumnDefinition: (colDef: ColumnDefinition, rowIndex: number) => IResponsiveTableColumnDefinition; onHeaderClickCallback: (colDef: ColumnDefinition) => ((id: string) => void) | undefined; getClickableHeaderClassName: (onHeaderClick: ((id: string) => void) | undefined, colDef: ColumnDefinition) => string; getHeaderProps: (colDef: ColumnDefinition) => React.HTMLAttributes & { className?: string; }; getRowProps: (row: TData) => React.HTMLAttributes; getRowId: (row: TData, index: number) => string | number; renderCell: (content: React.ReactNode, row: TData, colDef: IResponsiveTableColumnDefinition) => React.ReactNode; } export declare const useTableContext: () => TableContextValue; interface TableProviderProps { children: ReactNode; value: Omit, 'currentData' | 'getRawColumnDefinition' | 'getColumnDefinition' | 'onHeaderClickCallback' | 'getClickableHeaderClassName' | 'getHeaderProps' | 'getRowProps' | 'getRowId' | 'renderCell'>; } export declare function TableProvider({ children, value }: TableProviderProps): React.JSX.Element; export {};