import type { ComponentType, SvelteComponent } from 'svelte'

export type BuiltinRenderer = 'badge' | 'health-dot' | 'relative-time' | 'date' | 'status-badge'

// eslint-disable-next-line @typescript-eslint/no-explicit-any
type CellComponent = ComponentType<SvelteComponent<{ row: any; value: unknown }>>

export interface DataTableColumn<T> {
  key: string
  header: string
  sortable?: boolean
  width?: string | number
  align?: 'left' | 'right' | 'center'
  truncate?: boolean
  class?: string
  headerClass?: string
  render?: BuiltinRenderer | CellComponent
  renderProps?: Record<string, unknown>
  accessor?: (row: T) => unknown
  hidden?: boolean
}

export interface DataTableProps<T> {
  columns: DataTableColumn<T>[]
  data: T[]
  pageSize?: number
  paginated?: boolean
  searchable?: boolean
  loading?: boolean
  emptyMessage?: string
  selected?: string[]
  onRowClick?: (row: T) => void
  class?: string
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
  children?: any
}
