import { DgSearch, SearchOption } from './search'
import { DatagoComponent } from './component'
import type { Button, Dropdown, Pagination, Table } from 'element-ui'

export interface TableAction {
  handler?: (action: TableAction) => void
  label: string
  monitor?: any
  buttonProps?: Button
}

export interface TableTooltipAction extends TableAction {
  tooltip: string
  label?: string
}

export interface TableColumn extends SearchOption {
  slot?: string
  explain?: Record<string, any>
  actions?: (TableTooltipAction | TableAction)[]
}

export interface RowActionProps {
  /** @default 0 */
  grouped?: number
  /** @default true */
  groupDivided?: boolean
  groupDropdownProps?: Dropdown
  /** @default '更多' */
  groupDropdownText?: string
}

export declare class DgTableNew extends DatagoComponent {
  apiCode: string
  queryTerms: string
  /** @default true */
  isInitData: boolean
  title: string
  queries: DgSearch['options']
  searchProps: DgSearch
  actions: TableAction[]
  columns: TableColumn[]
  props: Table
  data: any[]
  rowActionProps: RowActionProps
  pagination: boolean | Pagination
  getDataFn: (form: Record<string, any>, currentPage: number, pageSize: number) => any
}
