import * as React from "react" ; import { TreeElement } from "../../classes/TreeElement" ; import { lazyInject } from "../../inversify.config" ; import SceneStore from "../../stores/SceneStore" ; interface ElementInfoProps { element : TreeElement ; } /**
 * Currently used for an example use of selected scene object store.
 */ export default class FolderContentElement extends React . Component < ElementInfoProps , any > { @ lazyInject ( "SceneStore" ) private readonly sceneStore ! : SceneStore ; public render ( ) { const { element } = this . props ; const classes = [ ] ; classes . push ( element . isFile ( ) ? "leaf" : "node" ) ; const isSelected = element . key === this . sceneStore . selectedObjectKey ; if ( isSelected ) { classes . push ( "current-selected" ) ; } return ( < li key = { element . key } className = { classes . join ( " " ) } onClick = { ( ) => isSelected || this . selectElement ( ) } > { this . props . element . name } < /li>); } private selectElement ( ) { this . sceneStore . selectedObjectKey = this . props . element . key ; } }