import type { BglFormSchemaT } from '@bagelink/vue'

export type SortDirectionsT = 'ASC' | 'DESC'
export type EmitOrderT = `${string} ${SortDirectionsT}`

export interface TableSchemaProps<T extends { [key: string]: any } = { [key: string]: any }> {
	data: T[]
	schema?: BglFormSchemaT<T> | (() => BglFormSchemaT<T>)
	columns?: string[]
	useServerSort?: boolean
	selectable?: boolean
	onLastItemVisible?: () => void
}

export interface TableDataOptions<T> {
	data: T[]
	schema?: BglFormSchemaT<T> | (() => BglFormSchemaT<T>)
	columns?: string[]
	sortField: string
	sortDirection: SortDirectionsT
	useServerSort?: boolean
}

export interface SortingOptions<T> {
	onSort: (field: string, direction: SortDirectionsT) => void
}

export interface TableSelectionOptions<T> {
	selectable: boolean | undefined
	selectedItems: { value: string[] }
	onSelect: (item: T) => void
}

export interface TableVirtualizationOptions<T> {
	data: T[]
	itemHeight: number
	onLastItemVisible?: () => void
}
