import type { InjectionKey } from 'vue'

export type SortOrder = 'asc' | 'desc'

export interface SortField {
  field: string
  order: SortOrder
}

export interface FilterPayload {
  prop: string
  value: any
}

export interface TableContext<T = any> {
  onQuery: (payload?: FilterPayload) => void
  onSort: (prop: string, order: SortOrder | null) => void
  data: Ref<T[]>
  sortingFields: Ref<SortField[]>
  loading: Ref<boolean>
}

export const TableContextKey: InjectionKey<TableContext> = Symbol('zm-table')
