import { RefObject } from "react"; import { SortColumn } from "../components/table"; /** Paged request parameters */ export type PagedRequest = { /** Offset from the beginning of the list */ offset: number; /** Maximum number of items */ limit: number; /** Search query */ search?: string; /** Column name to sort by */ sortBy?: string; /** Sort order */ sortOrder?: "asc" | "desc"; }; /** Options for the `useComplexTable` hook */ export type UseComplexTableOptions = { /** Total number of available items (known at initialization) */ totalCount: number; /** Number of items per page */ pageSize?: number; /** * Function to load a page of items. * @returns Total number of available items */ loadPage: (params: PagedRequest) => Promise; /** * Callback invoked after a page has successfully loaded (page change, search, or sort). * When provided, replaces the default scroll-to-top behavior. */ afterPageLoad?: () => void; }; /** Result of the `useComplexTable` hook */ export type UseComplexTableResult = { /** Selected item identifiers */ selectedRows: Array; /** Props to spread onto `ComplexTable` */ tableProps: { /** Reference to the table container for scroll management */ containerRef: RefObject; /** Total number of pages */ pagesCount: number; /** Current page */ currentPage: number; /** Whether an active search query is present */ hasActiveSearch: boolean; /** Data loading flag */ loading: boolean; /** Current sort column */ currentSortColumn?: SortColumn; /** Page change handler */ onPageChange: (page: number) => void; /** Search handler */ onSearch: (query: string) => void; /** Sort change handler */ onSortChange: (sortColumn?: SortColumn) => void; /** Selection change handler */ onSelectionChange: (selectedIds: Array) => void; }; }; /** * Hook for managing `ComplexTable` state with server-side pagination, search, sorting, and multi-selection. * * Assumes the first page of data is already loaded and passed to `ComplexTable` as `items`, * and the total number of items is known at initialization (`totalCount`). * * @example * ```tsx * const { tableProps, selectedIds } = useComplexTable({ * totalCount: agents.totalCount, * loadPage: async (params) => { * const result = await api.getItems(params); * dispatch(setItems(result.items)); * return result.total; * }, * }); * * * ``` */ export declare function useComplexTable({ loadPage, totalCount, pageSize, afterPageLoad, }: UseComplexTableOptions): UseComplexTableResult; //# sourceMappingURL=useComplexTable.d.ts.map