import React, { ReactNode } from 'react'; import { SortDirection } from '../Data/IResponsiveTableColumnDefinition'; import IFooterRowDefinition from '../Data/IFooterRowDefinition'; import { IResponsiveTablePlugin } from '../Plugins/IResponsiveTablePlugin'; import { ColumnDefinition, DataSource } from '../Context/TableContext'; import { DataSourceState } from '../Hooks/useTableDataSource'; export { ColumnDefinition }; export interface ResponsiveTableHandle { loadNextPage: () => Promise; resetAndFetch: () => Promise; getState: () => DataSourceState; expandRows(...ids: (string | number)[]): void; collapseRows(...ids: (string | number)[]): void; toggleRows(...ids: (string | number)[]): void; /** Scroll the table container (or the page, if no maxHeight) to the given pixel offset. */ scrollTo(position: number): void; } interface ISortProps { initialSortColumn?: string; initialSortDirection?: SortDirection; } interface IProps { /** The definitions for each column in the table. */ columnDefinitions: ColumnDefinition[]; /** The initial data to display. If using dataSource, this acts as the starting set. */ data: TData[]; /** * A smart data source function for server-side pagination, sorting, and filtering. * If provided, the table automatically handles infinite scroll and re-fetching on sort/filter. */ dataSource?: DataSource; /** The number of items to fetch per page when using dataSource. Defaults to 20. */ pageSize?: number; /** A component to display when there is no data. */ noDataComponent?: ReactNode; /** The maximum height of the table container (enables internal scrolling). */ maxHeight?: string; /** * Callback for when a row is clicked. * * @note To prevent this event from triggering when clicking interactive elements * (buttons, links, custom components) inside a cell, add the `data-rt-ignore-row-click` * attribute to those elements. * * @example * (row) => ( * * ) */ onRowClick?: (item: TData) => void; /** Custom definitions for footer rows. */ footerRows?: IFooterRowDefinition[]; /** The pixel width at which the table switches to mobile card view. Defaults to 600. */ mobileBreakpoint?: number; /** An array of plugins to extend table functionality. */ plugins?: IResponsiveTablePlugin[]; /** If true, the header will stick to the top of the page when scrolling. */ enablePageLevelStickyHeader?: boolean; /** Configuration for the built-in filter plugin. */ filterProps?: { showFilter?: boolean; filterPlaceholder?: string; className?: string; /** Default: 'server' when dataSource is present, 'client' otherwise. Pass 'client' to force in-memory filtering even with a dataSource. */ mode?: 'client' | 'server'; }; /** Configuration for row selection. */ selectionProps?: { onSelectionChange: (selectedItems: TData[]) => void; rowIdKey: keyof TData; mode?: 'single' | 'multiple'; selectedItems?: TData[]; selectedRowClassName?: string; }; /** Configuration for loading states and entrance animations. */ animationProps?: { isLoading?: boolean; animateOnLoad?: boolean; }; /** Initial sort state for the table. */ sortProps?: ISortProps; /** Custom CSS class to apply to each card in mobile view. */ mobileCardClassName?: string; /** Callback fired whenever the dataSource state changes (data, page, loading, error). */ onDataSourceStateChange?: (state: DataSourceState) => void; /** Callback fired when the current page changes. */ onPageChange?: (page: number) => void; /** Callback fired when a dataSource fetch fails. */ onDataSourceError?: (error: Error) => void; /** Return a ReactNode to render expandable content below a row, or null/undefined for no expand toggle on that row. */ expandRowRenderer?: (row: TData, rowIndex: number) => React.ReactNode; /** Custom CSS class applied to the expand/collapse chevron icon span. Use to override color, size, or add custom styling. */ expandChevronClassName?: string; /** Row IDs to expand on initial render. Passed once at mount; does not sync after mount. */ defaultExpandedIds?: (string | number)[]; /** * Fired on scroll with the current vertical pixel offset of the table's scroll container. * When `maxHeight` is set this reflects the internal container's `scrollTop`; otherwise it * reflects `window.scrollY`. Use with `ref.scrollTo()` to save and restore position. */ onScrollPositionChange?: (scrollTop: number) => void; } declare const ResponsiveTable: (props: IProps & { ref?: React.Ref>; }) => React.ReactElement; export default ResponsiveTable;