import type { ColumnType } from './interface'; import { INTERNAL_COL_DEFINE } from './utils/legacyUtil'; export interface ColGroupProps { colWidths: readonly (number | string)[]; columns?: readonly ColumnType[]; columCount?: number; } function ColGroup({ colWidths, columns, columCount }: ColGroupProps) { const cols = []; const len = columCount || columns.length; // Only insert col with width & additional props // Skip if rest col do not have any useful info let mustInsert = false; for (let i = len - 1; i >= 0; i -= 1) { const width = colWidths[i]; const column = columns && columns[i]; const additionalProps = column && column[INTERNAL_COL_DEFINE]; if (width || additionalProps || mustInsert) { const { columnType, ...restAdditionalProps } = additionalProps || {}; cols.unshift( , ); mustInsert = true; } } return {cols}; } export default ColGroup;