import type { ColumnDef } from '@tanstack/react-table';
import type * as React from 'react';

/** Row density — drives vertical padding + font size. */
export type DataTableDensity = 'compact' | 'comfortable';

export interface DataTableProps<T> {
  /** TanStack column definitions. Use an `id` on each for reorder/pin to work. */
  columns: ColumnDef<T, unknown>[];
  /** Row data. */
  data: T[];

  // ── Behaviour toggles ──
  /** Click a header to sort (default true). */
  enableSorting?: boolean;
  /** Show a global filter input above the table (default true). */
  enableFilter?: boolean;
  /** Placeholder for the global filter input. */
  filterPlaceholder?: string;
  /** Paginate the rows (default true). Ignored when `virtualized`. */
  enablePagination?: boolean;
  /** Rows per page (default 10). */
  pageSize?: number;
  /** Add a selection checkbox column + expose selection (default false). */
  enableRowSelection?: boolean;
  /** Render a bulk-action bar when ≥1 row is selected. */
  renderBulkActions?: (selectedRows: T[], clearSelection: () => void) => React.ReactNode;
  /** Allow drag-resizing of column widths (default false). */
  enableColumnResizing?: boolean;
  /** Allow drag-reordering of columns by their header (default false). */
  enableColumnReorder?: boolean;
  /** Show a pin toggle in each header to pin a column to the left (default false). */
  enableColumnPinning?: boolean;

  // ── Presentation ──
  /** Row density (default 'comfortable'). */
  density?: DataTableDensity;
  /** Stable row id resolver — required for predictable selection. */
  getRowId?: (row: T, index: number) => string;
  /** Rendered when `data` is empty. */
  emptyState?: React.ReactNode;
  /** Accessible label for the table element. */
  ariaLabel?: string;
  className?: string;

  // ── Virtualisation (9.C.5/9.C.8) ──
  /** Virtualise rows for large datasets. Disables built-in pagination. */
  virtualized?: boolean;
  /** Fixed row height in px when virtualising (default 40). */
  rowHeight?: number;
  /** Scroll container height in px when virtualising (default 480). */
  maxBodyHeight?: number;
}
