import { Category , SupportType , toolbar } from './annotations' ; import Column , { widthChanged , labelChanged , metaDataChanged , dirty , dirtyHeader , dirtyValues , rendererTypeChanged , groupRendererChanged , summaryRendererChanged , visibilityChanged , dirtyCaches , } from './Column' ; import type { IGroup , IColumnDesc } from './interfaces' ; import type Ranking from './Ranking' ; import type { IEventListener } from '../internal' ; import { integrateDefaults } from './internal' ; import { AGGREGATION_LEVEL_WIDTH } from '../styles' ; export enum EAggregationState { COLLAPSE = 'collapse' , EXPAND = 'expand' , EXPAND_TOP_N = 'expand_top' } param label returns { { type : string , label : string } } export function createAggregateDesc ( label = 'Aggregate Groups' ) { return { type : 'aggregate' , label , fixed : true } ; } export interface IAggregateGroupColumnDesc extends IColumnDesc { isAggregated ( ranking , group ) : EAggregationState ; setAggregated ( ranking , group , value ) : void ; } param value asMemberOf event export declare function aggregate ( ranking , group , value , state ) ; /**
 * a checkbox column for selections
 */ @ toolbar ( 'setShowTopN' , 'rename' ) @ SupportType ( ) @ Category ( 'support' ) export default class AggregateGroupColumn extends Column { static readonly EVENT_AGGREGATE = 'aggregate' ; constructor ( id , desc ) { super ( id , integrateDefaults ( desc , { width : AGGREGATION_LEVEL_WIDTH * 2 , } ) ) ; } get frozen ( ) { return this . desc . frozen !== false ; } protected createEventList ( ) { return super . createEventList ( ) . concat ( [ AggregateGroupColumn . EVENT_AGGREGATE ] ) ; } on ( type , listener ) ; on ( type , listener ) ; on ( type , listener ) ; on ( type , listener ) ; on ( type , listener ) ; on ( type , listener ) ; on ( type , listener ) ; on ( type , listener ) ; on ( type , listener ) ; on ( type , listener ) ; on ( type , listener ) ; on ( type , listener ) ; on ( type , listener ) ; on ( type , listener ) { return super . on ( type as any , listener ) ; } isAggregated ( group ) { const ranking = this . findMyRanker ( ) ! ; if ( ( this . desc as IAggregateGroupColumnDesc ) . isAggregated ) { return ( this . desc as IAggregateGroupColumnDesc ) . isAggregated ( ranking , group ) ; } return false ; } setAggregated ( group , value ) { const n = typeof value === 'boolean' ? ( value ? EAggregationState . EXPAND : EAggregationState . COLLAPSE ) : value ; const ranking = this . findMyRanker ( ) ! ; const current = ( this . desc as IAggregateGroupColumnDesc ) . isAggregated && ( this . desc as IAggregateGroupColumnDesc ) . isAggregated ( ranking , group ) ; if ( current === n ) { return true ; } if ( ( this . desc as IAggregateGroupColumnDesc ) . setAggregated ) { ( this . desc as IAggregateGroupColumnDesc ) . setAggregated ( ranking , group , n ) ; } this . fire ( AggregateGroupColumn . EVENT_AGGREGATE , ranking , group , n !== EAggregationState . COLLAPSE , n ) ; return false ; } }