import type { BglFormSchemaT } from '@bagelink/vue'
import type { MaybeRefOrGetter, ComputedRef } from '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?: MaybeRefOrGetter<BglFormSchemaT<T>>
	columns?: MaybeRefOrGetter<string[]>
	useServerSort?: boolean
	selectable?: boolean
	onLastItemVisible?: () => void
}

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

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

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

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