import { ReactElement } from 'react' ; import { getVectorStyleLabel } from '../components/get_vector_style_label' ; import { RawValue , VECTOR_STYLES } from '../../../../../common/constants' ; export type LegendProps = { isPointsOnly : boolean ; isLinesOnly : boolean ; symbolId ? : string ; } ; export interface IStyleProperty < T > { isDynamic ( ) : boolean ; isComplete ( ) : boolean ; formatField ( value ) : string | number ; getStyleName ( ) : VECTOR_STYLES ; getOptions ( ) : T ; renderLegendDetailRow ( legendProps ) : ReactElement < any > | null ; renderDataMappingPopover ( onChange ) : ReactElement < any > | null ; getDisplayStyleName ( ) : string ; } export class AbstractStyleProperty < T > implements IStyleProperty < T > { protected readonly _options : T ; protected readonly _styleName : VECTOR_STYLES ; constructor ( options , styleName ) { this . _options = options ; this . _styleName = styleName ; } isDynamic ( ) { return false ; } returns { boolean } isComplete ( ) { return true ; } formatField ( value ) { if ( typeof value === 'undefined' || value === null ) { return '' ; } else if ( typeof value === 'boolean' ) { return value . toString ( ) ; } else if ( Array . isArray ( value ) ) { return value . join ( ', ' ) ; } else { return value ; } } getStyleName ( ) { return this . _styleName ; } getOptions ( ) { return this . _options ; } renderLegendDetailRow ( { isPointsOnly , isLinesOnly } ) { return null ; } renderDataMappingPopover ( onChange ) { return null ; } getDisplayStyleName ( ) { return getVectorStyleLabel ( this . getStyleName ( ) ) ; } }