import { Category , SupportType , toolbar , dialogAddons } from './annotations' ; import Column , { widthChanged , labelChanged , metaDataChanged , dirty , dirtyHeader , dirtyValues , rendererTypeChanged , groupRendererChanged , summaryRendererChanged , visibilityChanged , dirtyCaches , } from './Column' ; import { IDataRow , IGroup , ECompareValueType } from './interfaces' ; import { missingGroup } from './missing' ; import type { IEventListener , ISequence } from '../internal' ; export function createGroupDesc ( label = 'Group Name' ) { return { type : 'group' , label } ; } export enum EGroupSortMethod { name = 'name' , count = 'count' } asMemberOf event export declare function sortMethodChanged ( previous , current ) ; @ SupportType ( ) @ toolbar ( 'rename' , 'sortGroupBy' ) @ dialogAddons ( 'sortGroup' , 'sortGroups' ) @ Category ( 'support' ) export default class GroupColumn extends Column { static readonly EVENT_SORTMETHOD_CHANGED = 'sortMethodChanged' ; private groupSortMethod : EGroupSortMethod = EGroupSortMethod . name ; get frozen ( ) { return this . desc . frozen !== false ; } protected createEventList ( ) { return super . createEventList ( ) . concat ( [ GroupColumn . EVENT_SORTMETHOD_CHANGED ] ) ; } 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 ) ; } getLabel ( ) { return '' ; } getValue ( ) { return '' ; } getSortMethod ( ) { return this . groupSortMethod ; } setSortMethod ( sortMethod ) { if ( this . groupSortMethod === sortMethod ) { return ; } this . fire ( GroupColumn . EVENT_SORTMETHOD_CHANGED , this . groupSortMethod , ( this . groupSortMethod = sortMethod ) ) ; if ( ! this . isGroupSortedByMe ( ) . asc ) { this . toggleMyGroupSorting ( ) ; } } toCompareGroupValue ( rows , group ) { if ( this . groupSortMethod === 'count' ) { return rows . length ; } return group . name === missingGroup . name ? null : group . name . toLowerCase ( ) ; } toCompareGroupValueType ( ) { return this . groupSortMethod === 'count' ? ECompareValueType . COUNT : ECompareValueType . STRING ; } }