import type { ValueOf } from 'type-fest'
import type { formatterTypes } from './const'

export type Format = (value: Value, locale?: string) => string

export type FormatterType = ValueOf<typeof formatterTypes>

export interface Formatter {
  type: FormatterType
  format: Format
}

export type Formatters = Record<FormatterType, Formatter>

export type FieldFormatter = FormatterType | Format

export type Value = string | number

export interface ObjectToHtmlOptions<T extends Record<string, Value>> {
  properties: T
  formatters?: Record<string, FieldFormatter>
  includeColumns?: string[]
  locale?: string
  showColumnName?: boolean
  title?: string
  getColumnName?: (name: string) => string
  getFieldHtml?: (column: string, value: Value) => string
  getTitle?: (title: string) => string
  getValue?: (value: Value, locale: string, formatter: FieldFormatter) => string
}
