import type { ReactNode } from "react";
import type { DataTableVirtualizedOptions } from "./data-table-virtualized.js";
/**
* DataTable — generic, sortable, expandable composite over `
`.
*
* Adds operator-grade entity-list patterns on top of the plain Table
* primitive: sortable headers, sticky header, expandable rows
* (multi-row by default), row action menus (Dropdown), client-side
* pagination, loading skeleton rows, empty state. Both sort and
* pagination support controlled OR uncontrolled mode (consumer
* passes onSortChange / onPageChange to take over state).
*
* `virtualized` mode (M6) renders 10K+ rows over @tanstack/react-virtual.
* It is mutually exclusive with `pagination` and `expandable` at the type
* level — a virtualized list is one continuous scroll of fixed-height rows.
*
* @example
* d.id}
* expandable={(d) => d.status === "pending" ? : null}
* rowActions={(d) => (
* <>
* editDomain(d)}>Edit
* deleteDomain(d)}>Delete
* >
* )}
* />
*/
export interface DataTableColumn {
key: string;
label: ReactNode;
align?: "left" | "center" | "right";
sortable?: boolean;
width?: string;
render?: (row: T) => ReactNode;
className?: string;
}
export interface DataTableSort {
key: string;
direction: "asc" | "desc";
}
export interface DataTableBaseProps {
data: T[];
columns: DataTableColumn[];
rowKey: (row: T) => string;
stickyHeader?: boolean;
rowActions?: (row: T) => ReactNode;
defaultSort?: DataTableSort;
sort?: DataTableSort | null;
onSortChange?: (sort: DataTableSort | null) => void;
loading?: boolean;
emptyState?: ReactNode;
className?: string;
}
/**
* Discriminated union: the default mode keeps pagination/expandable; the
* virtualized mode excludes them at the type level (fixed-height single
* scroll — see DataTableVirtualizedOptions for the documented limitations).
*/
export type DataTableProps = DataTableBaseProps & ({
virtualized?: never;
expandable?: (row: T) => ReactNode | null;
expandMode?: "single" | "multiple";
pagination?: {
pageSize: number;
controlledPage?: number;
onPageChange?: (page: number) => void;
} | null;
} | {
virtualized: DataTableVirtualizedOptions;
expandable?: never;
expandMode?: never;
pagination?: never;
stickyHeader?: never;
});
declare function DataTable(props: DataTableProps): ReactNode;
export { DataTable };