import { type ColumnOrderState, type TableOptions, useReactTable, type VisibilityState } from "@tanstack/react-table"; import * as React from "react"; import { DataTableColumnDef, DataTableColumnFilter, DataTableCommand, DataTableDateComparisonOperator, DataTableEmptyState, DataTableFilter, DataTableFilteringState, DataTableFilterOption, DataTablePaginationState, DataTableRow, DataTableRowSelectionState, DataTableSortingState } from "./types"; interface DataTableOptions extends Pick, "data" | "getRowId"> { /** * The columns to use for the table. */ columns: DataTableColumnDef[]; /** * The filters which the user can apply to the table. */ filters?: DataTableFilter[]; /** * The commands which the user can apply to selected rows. */ commands?: DataTableCommand[]; /** * Whether the data for the table is currently being loaded. */ isLoading?: boolean; /** * The state and callback for the filtering. */ filtering?: { state: DataTableFilteringState; onFilteringChange: (state: DataTableFilteringState) => void; }; /** * The state and callback for the row selection. */ rowSelection?: { state: DataTableRowSelectionState; onRowSelectionChange: (state: DataTableRowSelectionState) => void; enableRowSelection?: boolean | ((row: DataTableRow) => boolean) | undefined; }; /** * The state and callback for the sorting. */ sorting?: { state: DataTableSortingState | null; onSortingChange: (state: DataTableSortingState) => void; }; /** * The state and callback for the search, with optional debounce. */ search?: { state: string; onSearchChange: (state: string) => void; /** * Debounce time in milliseconds for the search callback. * @default 300 */ debounce?: number; }; /** * The state and callback for the pagination. */ pagination?: { state: DataTablePaginationState; onPaginationChange: (state: DataTablePaginationState) => void; }; /** * The function to execute when a row is clicked. */ onRowClick?: (event: React.MouseEvent, row: TData) => void; /** * The total count of rows. When working with pagination, this will be the total * number of rows available, not the number of rows currently being displayed. */ rowCount?: number; /** * Whether the page index should be reset the filtering, sorting, or pagination changes. * * @default true */ autoResetPageIndex?: boolean; /** * The state and callback for the column visibility. */ columnVisibility?: { state: VisibilityState; onColumnVisibilityChange: (state: VisibilityState) => void; }; /** * The state and callback for the column order. */ columnOrder?: { state: ColumnOrderState; onColumnOrderChange: (state: ColumnOrderState) => void; }; } interface UseDataTableReturn extends Pick>, "getHeaderGroups" | "getRowModel" | "getCanNextPage" | "getCanPreviousPage" | "nextPage" | "previousPage" | "getPageCount" | "getAllColumns" | "setColumnVisibility" | "setColumnOrder"> { getSorting: () => DataTableSortingState | null; setSorting: (sortingOrUpdater: DataTableSortingState | ((prev: DataTableSortingState | null) => DataTableSortingState)) => void; getFilters: () => DataTableFilter[]; getFilterOptions: (id: string) => DataTableFilterOption[] | null; getFilterMeta: (id: string) => DataTableFilter | null; getFiltering: () => DataTableFilteringState; addFilter: (filter: DataTableColumnFilter) => void; removeFilter: (id: string) => void; clearFilters: () => void; updateFilter: (filter: DataTableColumnFilter) => void; getSearch: () => string; onSearchChange: (search: string) => void; getCommands: () => DataTableCommand[]; getRowSelection: () => DataTableRowSelectionState; onRowClick?: (event: React.MouseEvent, row: TData) => void; emptyState: DataTableEmptyState; isLoading: boolean; showSkeleton: boolean; pageIndex: number; pageSize: number; rowCount: number; enablePagination: boolean; enableFiltering: boolean; enableSorting: boolean; enableSearch: boolean; enableColumnVisibility: boolean; enableColumnOrder: boolean; columnOrder: ColumnOrderState; setColumnOrderFromArray: (order: string[]) => void; } declare const useDataTable: ({ rowCount, filters, commands, rowSelection, sorting, filtering, pagination, search, onRowClick, autoResetPageIndex, isLoading, columnVisibility, columnOrder, ...options }: DataTableOptions) => UseDataTableReturn; export { useDataTable }; export type { DataTableOptions, UseDataTableReturn }; //# sourceMappingURL=use-data-table.d.ts.map