import { toolbar } from './annotations' ; import type Column from './Column' ; import type { widthChanged , labelChanged , metaDataChanged , dirty , dirtyHeader , dirtyValues , rendererTypeChanged , groupRendererChanged , summaryRendererChanged , visibilityChanged , dirtyCaches , } from './Column' ; import type { dataLoaded } from './ValueColumn' ; import type ValueColumn from './ValueColumn' ; import type { IDataRow , ITypeFactory } from './interfaces' ; import { patternFunction , integrateDefaults } from './internal' ; import MapColumn , { IMapColumnDesc } from './MapColumn' ; import LinkColumn , { ILinkDesc } from './LinkColumn' ; import type { IEventListener } from '../internal' ; import { EAlignment } from './StringColumn' ; import type { IKeyValue } from './IArrayColumn' ; import type { ILink } from './LinkColumn' ; export declare type ILinkMapColumnDesc = ILinkDesc & IMapColumnDesc < string > ; asMemberOf event export declare function patternChanged_LMC ( previous , current ) ; /**
 * a string column with optional alignment
 */ @ toolbar ( 'rename' , 'search' , 'editPattern' ) export default class LinkMapColumn extends MapColumn < string > { static readonly EVENT_PATTERN_CHANGED = LinkColumn . EVENT_PATTERN_CHANGED ; readonly alignment : EAlignment ; readonly escape : boolean ; private pattern : string ; private patternFunction : ( value : string , raw : any , key : string ) => string | null = null ; readonly patternTemplates : string [ ] ; constructor ( id , desc ) { super ( id , integrateDefaults ( desc , { width : 200 , renderer : 'map' , } ) ) ; this . alignment = desc . alignment ?? EAlignment . left ; this . escape = desc . escape !== false ; this . pattern = desc . pattern ?? '' ; this . patternTemplates = desc . patternTemplates ?? [ ] ; } setPattern ( pattern ) { LinkColumn . prototype . setPattern . call ( this , pattern ) ; } getPattern ( ) { return this . pattern ; } protected createEventList ( ) { return super . createEventList ( ) . concat ( [ LinkColumn . EVENT_PATTERN_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 ) ; on ( type , listener ) { return super . on ( type as any , listener ) ; } getValue ( row ) { const r = this . getLinkMap ( row ) ; return r . every ( ( d ) => d . value == null ) ? null : r . map ( ( { key , value } ) => ( { key , value : value ? value . href : '' , } ) ) ; } getLabels ( row ) { return this . getLinkMap ( row ) . map ( ( { key , value } ) => ( { key , value : value ? value . alt : '' , } ) ) ; } getLinkMap ( row ) { return super . getMap ( row ) . map ( ( { key , value } ) => ( { key , value : this . transformValue ( value , row , key ) , } ) ) ; } private transformValue ( v , row , key ) { if ( v == null || v === '' ) { return null ; } if ( typeof v === 'string' ) { if ( ! this . pattern ) { return { alt : v , href : v , } ; } if ( ! this . patternFunction ) { this . patternFunction = patternFunction ( this . pattern , 'item' , 'key' ) ; } return { alt : v , href : this . patternFunction . call ( this , v , row . v , key ) , } ; } return v ; } dump ( toDescRef ) { const r = super . dump ( toDescRef ) ; if ( this . pattern !== ( this . desc as any ) . pattern ) { r . pattern = this . pattern ; } return r ; } restore ( dump , factory ) { if ( dump . pattern ) { this . pattern = dump . pattern ; } super . restore ( dump , factory ) ; } }