import { ColDef , ColDefUtil } from 'ag-grid-community' ; export class AgGridColumn { public static hasChildColumns ( slots ) { return slots && slots . default && slots . default . length > 0 ; } public static mapChildColumnDefs ( slots ) { return slots . default . map ( ( column ) => { return AgGridColumn . toColDef ( column ) ; } ) ; } public static toColDef ( column ) { const colDef = AgGridColumn . createColDefFromGridColumn ( column ) ; if ( column . children && column . children . length > 0 ) { ( colDef as any ) . children = AgGridColumn . getChildColDefs ( column . children ) ; } return colDef ; } private static getChildColDefs ( columnChildren ) { return columnChildren . map ( ( column ) => { return AgGridColumn . createColDefFromGridColumn ( column ) ; } ) ; } private static createColDefFromGridColumn ( column ) { const colDef = { } ; Object . assign ( colDef , column . data . attrs ) ; delete ( colDef as any ) . children ; ColDefUtil . BOOLEAN_PROPERTIES . forEach ( ( property ) => { const colDefAsAny = colDef as any ; if ( colDefAsAny [ property ] === '' ) { colDefAsAny [ property ] = true ; } } ) ; return colDef ; } }