import { defineComponent } from 'vue'; import Cell from '../Cell'; import { useInjectTable } from '../context/TableContext'; import type { CellType, StickyOffsets, ColumnType, CustomizeComponent, GetComponentProps, DefaultRecordType, } from '../interface'; import { getCellFixedInfo } from '../utils/fixUtil'; import { getColumnsKey } from '../utils/valueUtil'; import DragHandleVue from './DragHandle'; export interface RowProps { cells: readonly CellType[]; stickyOffsets: StickyOffsets; flattenColumns: readonly ColumnType[]; rowComponent: CustomizeComponent; cellComponent: CustomizeComponent; customHeaderRow: GetComponentProps[]>; index: number; } export default defineComponent({ name: 'HeaderRow', props: [ 'cells', 'stickyOffsets', 'flattenColumns', 'rowComponent', 'cellComponent', 'index', 'customHeaderRow', ] as any, setup(props: RowProps) { const tableContext = useInjectTable(); return () => { const { prefixCls, direction } = tableContext; const { cells, stickyOffsets, flattenColumns, rowComponent: RowComponent, cellComponent: CellComponent, customHeaderRow, index, } = props; let rowProps; if (customHeaderRow) { rowProps = customHeaderRow( cells.map(cell => cell.column), index, ); } const columnsKey = getColumnsKey(cells.map(cell => cell.column)); return ( {cells.map((cell: CellType, cellIndex) => { const { column } = cell; const fixedInfo = getCellFixedInfo( cell.colStart, cell.colEnd, flattenColumns, stickyOffsets, direction, ); let additionalProps; if (column && column.customHeaderCell) { additionalProps = cell.column.customHeaderCell(column); } const col: ColumnType = column; return ( column.title, dragHandle: () => col.resizable ? ( ) : null, }} /> ); })} ); }; }, });