import { ReactNode } from "react";
import { RowActionItem } from "../RowActionsDropdown";

export type RowDataType = Record<string, unknown> & { id: string | number };

export interface ColumnType<T extends RowDataType = RowDataType> {
  title: string;
  key: string;
  render?: (item: T) => React.ReactNode;
  width?: string | number;
  align?: "left" | "center" | "right";
  sortable?: boolean;
  className?: string;
}

export interface PaginationConfig {
  currentPage: number;
  totalPages: number;
  onPageChange: (page: number) => void;
}

export interface TableProps<T extends RowDataType = RowDataType> {
  columns: ColumnType<T>[];
  data?: T[];
  isLoading?: boolean;
  onRowClick?: (id: T["id"], item: T) => void;
  className?: string;
  rowClassName?: string | ((item: T, index: number) => string);
  noDataMessage?: React.ReactNode;
  headerClassName?: string;
  emptyRowsCount?: number;
  showHeader?: boolean;
  actions?: ReactNode;
  actionsClassName?: string;
  actionsPosition?: "top" | "header-replace" | "above-header";
  selectable?: boolean;
  selectedActions?: ReactNode;
  onSelectionChange?: (selectedRows: T[]) => void;
  rowActions?: (item: T) => RowActionItem[];
  pagination?: PaginationConfig;
}
