import { type ReactNode } from 'react'

interface ITableColumn<T> {
  id: string
  label: string | ReactNode
  textOnlyLabel?: string
  accessor?: (row: T) => ReactNode
  textOnlyAccessor?: (row: T) => string
  sortable?: boolean
  headerClassName?: string
  cellClassName?: string
}

interface ITableRow {
  fullSpanContent?: ReactNode
  fullSpanClassName?: string
}

interface ITableOptions {
  paged?: boolean
  scrollable?: boolean
  defaultClassName?: string
  defaultHeaderClassName?: string
  defaultCellClassName?: string
  className?: string
}

export type IDefaultTableRow = Record<string, any> & ITableRow

interface ITableProps<TRowType extends IDefaultTableRow = IDefaultTableRow> {
  className?: string
  tbodyClassName?: string
  theadClassName?: string
  rowClassName?: string
  columns: Array<ITableColumn<TRowType>>
  data: TRowType[]
  options?: ITableOptions
  defaultFullSpanClassName?: string
  fullSpanClassName?: string
}

export type {
  ITableColumn,
  ITableRow,
  ITableProps,
  ITableOptions
}
