import { ComponentStEntry , ComponentSymbolTable } from '../../symbolTable' ; import * as _ from 'lodash' ; export const DV_COMPONENT = 'dv.component' ; export const DV_TX_COMPONENT = 'dv.tx-component' ; export const DV_COMPONENT_NAME_ATTR = 'name' ; export const NAV_SPLIT_REGEX = /(?:\.|\?\.)/ ; export function isInput ( name ) { return _ . startsWith ( name , '$' ) ; } export function inputToNgField ( input ) { return input . substr ( 1 ) ; } export function attributeNameToInput ( attributeName ) { return attributeName ; } export function isComponent ( name ) { return _ . includes ( name , '-' ) && ! name . startsWith ( 'mat-' ) ; } export function classNameToNgField ( name ) { return `__componentInput__${ _ . camelCase ( name ) }` ; } export function getStEntryForNgComponent ( ngComponentName , symbolTable , alias ? ) { const [ conceptName , componentName ] = _ . split ( ngComponentName , /-(.+)/ ) ; const stPath = ( alias === undefined ) ? `${ conceptName }.symbolTable.${ componentName }` : alias ; return < ComponentStEntry | undefined > _ . get ( symbolTable , stPath ) ; } export function outputToNgField ( conceptName , componentName , output , alias ? ) { const aliasStr = ( alias === undefined ) ? '' : `__${ alias . replace ( /-/g , '_' ) }` ; const componentNameNoHyphens = componentName . replace ( /-/g , '_' ) ; return `__ngOutput__${ conceptName }__` + `${ componentNameNoHyphens }__${ output }${ aliasStr }` ; }