import { Column , GroupColumn , IOrderedGroup , IGroup , defaultGroup , IDataRow } from '../model' ; import type { ICellRendererFactory , ICellRenderer , IGroupCellRenderer , ISummaryRenderer } from './interfaces' ; import { noRenderer } from './utils' ; function isDummyGroup ( group ) { return group . parent == null && group . name === defaultGroup . name ; } export default class GroupCellRenderer implements ICellRendererFactory { readonly title : string = 'Default' ; canRender ( col ) { return col instanceof GroupColumn ; } create ( ) { return { template : `<div><div></div></div>` , update ( node , _row , i , group ) { const text = isDummyGroup ( group ) || i > 0 ? '' : `${ group . name } (${ group . order . length })` ; ( node . firstElementChild ! as HTMLElement ) . textContent = text ; node . title = text ; } , render ( _ctx , _row , i ) { return i === 0 ; } , } ; } createGroup ( ) { return { template : `<div><div></div></div>` , update ( node , group ) { const text = isDummyGroup ( group ) ? '' : `${ group . name } (${ group . order . length })` ; ( node . firstElementChild ! as HTMLElement ) . textContent = text ; node . title = text ; } , } ; } createSummary ( ) { return noRenderer ; } }