import { ComponentInternalInstance, CSSProperties, Ref, VNode, PropType } from 'vue' import { Store } from '../store/index' import { TableColumnCtx } from '../table-column/defaults' import type TableLayout from '../table-layout' export type DefaultRow = any export type Nullable = null | T interface TableRefs { headerWrapper: HTMLElement footerWrapper: HTMLElement fixedBodyWrapper: HTMLElement rightFixedBodyWrapper: HTMLElement bodyWrapper: HTMLElement [key: string]: any } interface TableState { isGroup: Ref resizeState: Ref<{ width: any height: any }> doLayout: () => void debouncedUpdateLayout: () => void } type HoverState = Nullable<{ cell: HTMLElement column: TableColumnCtx row: T }> type RIS = { row: T; $index: number; store: Store; } type RenderExpanded = ({ row, $index, store }: RIS) => VNode type SummaryMethod = (data: { columns: TableColumnCtx data: T[] }) => string[] interface Table extends ComponentInternalInstance { $ready: boolean hoverState?: HoverState renderExpanded: RenderExpanded store: Store layout: TableLayout refs: TableRefs tableId: string state: TableState } type ColumnCls = string | ((data: { row: T; rowIndex: number; }) => string) type ColumnStyle = | CSSProperties | ((data: { row: T; rowIndex: number; }) => CSSProperties) type CellCls = | string | ((data: { row: T rowIndex: number column: TableColumnCtx columnIndex: number }) => string) type CellStyle = | CSSProperties | ((data: { row: T rowIndex: number column: TableColumnCtx columnIndex: number }) => CSSProperties) interface TableProps { data: T[] size?: string width?: string | number height?: string | number maxHeight?: string | number fit?: boolean stripe?: boolean border?: boolean rowKey?: string | ((row: T) => string) context?: Table showHeader?: boolean showSummary?: boolean sumText?: string summaryMethod?: SummaryMethod rowClassName?: ColumnCls rowStyle?: ColumnStyle cellClassName?: CellCls cellStyle?: CellStyle headerRowClassName?: ColumnCls headerRowStyle?: ColumnStyle headerCellClassName?: CellCls headerCellStyle?: CellStyle highlightCurrentRow?: boolean currentRowKey?: string | number emptyText?: string expandRowKeys?: any[] defaultExpandAll?: boolean defaultSort?: Sort tooltipEffect?: string spanMethod?: (data: { row: T rowIndex: number column: TableColumnCtx columnIndex: number }) => | number[] | { rowspan: number colspan: number } selectOnIndeterminate?: boolean indent?: number treeProps?: { hasChildren?: string children?: string } lazy?: boolean load?: (row: T, treeNode: TreeNode, resolve: (data: T[]) => void) => void className?: string style?: CSSProperties } interface Sort { prop: string order: 'ascending' | 'descending' init?: any silent?: any } interface Filter { column: TableColumnCtx values: string[] silent: any } interface TreeNode { expanded?: boolean loading?: boolean noLazyChildren?: boolean indent?: number level?: number display?: boolean } interface RenderRowData { store: Store _self: Table column: TableColumnCtx row: T $index: number treeNode?: TreeNode } export default { data: { type: Array as PropType, default: () => { return [] }, }, size: String, width: [String, Number], height: [String, Number], maxHeight: [String, Number], fit: { type: Boolean, default: true, }, stripe: Boolean, border: Boolean, rowKey: [String, Function] as PropType['rowKey']>, showHeader: { type: Boolean, default: true, }, showSummary: Boolean, sumText: String, summaryMethod: Function as PropType['summaryMethod']>, rowClassName: [String, Function] as PropType< TableProps['rowClassName'] >, rowStyle: [Object, Function] as PropType['rowStyle']>, cellClassName: [String, Function] as PropType< TableProps['cellClassName'] >, cellStyle: [Object, Function] as PropType< TableProps['cellStyle'] >, headerRowClassName: [String, Function] as PropType< TableProps['headerRowClassName'] >, headerRowStyle: [Object, Function] as PropType< TableProps['headerRowStyle'] >, headerCellClassName: [String, Function] as PropType< TableProps['headerCellClassName'] >, headerCellStyle: [Object, Function] as PropType< TableProps['headerCellStyle'] >, highlightCurrentRow: Boolean, currentRowKey: [String, Number], emptyText: String, expandRowKeys: Array as PropType['expandRowKeys']>, defaultExpandAll: Boolean, defaultSort: Object as PropType['defaultSort']>, tooltipEffect: String, spanMethod: Function as PropType['spanMethod']>, selectOnIndeterminate: { type: Boolean, default: true, }, indent: { type: Number, default: 16, }, treeProps: { type: Object as PropType['treeProps']>, default: () => { return { hasChildren: 'hasChildren', children: 'children', } }, }, lazy: Boolean, load: Function as PropType['load']>, style: { type: Object as PropType, default: () => ({}), }, className: { type: String, default: '', }, } export type { SummaryMethod, Table, TableProps, TableRefs, ColumnCls, ColumnStyle, TreeNode, RenderRowData, Sort, Filter }