/** * ColumnType which applied in antd: https://ant.design/components/table-cn/#column * - defaultSortOrder * - filterDropdown * - filterDropdownOpen * - filtered * - filteredValue * - filterIcon * - filterMultiple * - filters * - sorter * - sortOrder * - sortDirections * - onFilter * - onFilterDropdownOpenChange */ import type { CSSProperties, Ref, TdHTMLAttributes } from 'vue'; export type Key = number | string; export type FixedType = 'left' | 'right' | boolean; export type DefaultRecordType = any; export type TableLayout = 'auto' | 'fixed'; // ==================== Row ===================== export type RowClassName = ( record: RecordType, index: number, indent: number, ) => string; export type TransformCellText = (opt: { text: any; column: ColumnType; record: any; index: number; }) => any; // =================== Column =================== export interface CellType { key?: Key; class?: string; style?: CSSProperties; // children?: any; column?: ColumnsType[number]; colSpan?: number; rowSpan?: number; /** Only used for table header */ hasSubColumns?: boolean; colStart?: number; colEnd?: number; } export interface RenderedCell { props?: CellType; children?: any; } export type DataIndex = string | number | readonly (string | number)[]; export type CellEllipsisType = { showTitle?: boolean } | boolean; interface ColumnSharedType { title?: any; key?: Key; class?: string; className?: string; fixed?: FixedType; customHeaderCell?: GetComponentProps[number]>; ellipsis?: CellEllipsisType; align?: AlignType; customFilterDropdown?: boolean; /** @deprecated Please use `v-slot:filterIcon` `v-slot:bodyCell` `v-slot:headerCell` instead */ slots?: { filterIcon?: string; filterDropdown?: string; customRender?: string; title?: string; }; /** * @private Internal usage. * * !!! DO NOT USE IN PRODUCTION ENVIRONMENT !!! */ __originColumn__?: any; } export interface ColumnGroupType extends ColumnSharedType { children: ColumnsType; } export type AlignType = 'left' | 'center' | 'right'; export interface ColumnType extends ColumnSharedType { colSpan?: number; dataIndex?: DataIndex; customRender?: (opt: { value: any; text: any; // 兼容 V2 record: RecordType; index: number; renderIndex: number; column: ColumnType; }) => any | RenderedCell; rowSpan?: number; width?: number | string; minWidth?: number; maxWidth?: number; resizable?: boolean; customCell?: GetComponentProps; /** @deprecated Please use `customCell` instead */ onCellClick?: (record: RecordType, e: MouseEvent) => void; } export type ColumnsType = readonly ( | ColumnGroupType | ColumnType )[]; export type GetRowKey = (record: RecordType, index?: number) => Key; // ================= Fix Column ================= export interface StickyOffsets { left: readonly number[]; right: readonly number[]; isSticky?: boolean; } export type AdditionalProps = TdHTMLAttributes & { colSpan?: number; rowSpan?: number; }; // ================= Customized ================= export type GetComponentProps = ( data: DataType, index?: number, column?: ColumnType, ) => AdditionalProps; // type Component

= DefineComponent

| FunctionalComponent

| string; export type CustomizeComponent = any; export type CustomizeScrollBody = ( data: readonly RecordType[], info: { scrollbarSize: number; ref: Ref<{ scrollLeft: number }>; onScroll: (info: { currentTarget?: HTMLElement; scrollLeft?: number }) => void; }, ) => any; export interface TableComponents { table?: CustomizeComponent; header?: { wrapper?: CustomizeComponent; row?: CustomizeComponent; cell?: CustomizeComponent; }; body?: | CustomizeScrollBody | { wrapper?: CustomizeComponent; row?: CustomizeComponent; cell?: CustomizeComponent; }; } export type GetComponent = ( path: readonly string[], defaultComponent?: CustomizeComponent, ) => CustomizeComponent; // =================== Expand =================== export type ExpandableType = false | 'row' | 'nest'; export interface LegacyExpandableProps { expandedRowKeys?: Key[]; defaultExpandedRowKeys?: Key[]; expandedRowRender?: ExpandedRowRender; expandRowByClick?: boolean; expandIcon?: RenderExpandIcon; onExpand?: (expanded: boolean, record: RecordType) => void; onExpandedRowsChange?: (expandedKeys: Key[]) => void; defaultExpandAllRows?: boolean; indentSize?: number; /** @deprecated Please use `EXPAND_COLUMN` in `columns` directly */ expandIconColumnIndex?: number; showExpandColumn?: boolean; expandedRowClassName?: RowClassName; childrenColumnName?: string; rowExpandable?: (record: RecordType) => boolean; } export type ExpandedRowRender = (opt: { record: ValueType; index: number; indent: number; expanded: boolean; }) => any; export interface RenderExpandIconProps { prefixCls: string; expanded: boolean; record: RecordType; expandable: boolean; onExpand: TriggerEventHandler; } export type RenderExpandIcon = (props: RenderExpandIconProps) => any; export interface ExpandableConfig { expandedRowKeys?: readonly Key[]; defaultExpandedRowKeys?: readonly Key[]; expandedRowRender?: ExpandedRowRender; expandRowByClick?: boolean; expandIcon?: RenderExpandIcon; onExpand?: (expanded: boolean, record: RecordType) => void; onExpandedRowsChange?: (expandedKeys: readonly Key[]) => void; defaultExpandAllRows?: boolean; indentSize?: number; /** @deprecated Please use `EXPAND_COLUMN` in `columns` directly */ expandIconColumnIndex?: number; showExpandColumn?: boolean; expandedRowClassName?: RowClassName; childrenColumnName?: string; rowExpandable?: (record: RecordType) => boolean; columnWidth?: number | string; fixed?: FixedType; } // =================== Render =================== export type PanelRender = (data: readonly RecordType[]) => any; // =================== Events =================== export type TriggerEventHandler = (record: RecordType, event: MouseEvent) => void; // =================== Sticky =================== export interface TableSticky { offsetHeader?: number; offsetSummary?: number; offsetScroll?: number; getContainer?: () => Window | HTMLElement; }