packageDocumentation module import * as React from "react" ; import { PrimitiveValue , PropertyDescription , PropertyRecord } from "@itwin/appui-abstract" ; import { EditorContainer , PropertyUpdatedArgs } from "../../../editors/EditorContainer" ; import { TreeModelNode } from "../TreeModel" ; public export interface TreeNodeEditorProps { /** Tree node which is in editing mode. */ node : TreeModelNode ; /** Callback that is called when changes are committed. */ onCommit : ( node : TreeModelNode , newValue : string ) => void ; /** Callback that is called when editing is canceled. */ onCancel : ( ) => void ; /** Editor style. */ style ? : React . CSSProperties ; internal ignoreEditorBlur ? : boolean ; } public export type TreeNodeEditorRenderer = ( props : TreeNodeEditorProps ) => React . ReactNode ; public export function TreeNodeEditor ( props ) { const onCommit = ( args ) => { const newValue = ( args . newValue as PrimitiveValue ) . value as string ; props . onCommit ( props . node , newValue ) ; } ; const propertyRecord = createPropertyRecord ( props . node . item . label ) ; return ( < span style = { props . style } > < EditorContainer propertyRecord = { propertyRecord } title = { propertyRecord . description } onCommit = { onCommit } onCancel = { props . onCancel } ignoreEditorBlur = { props . ignoreEditorBlur } setFocus = { true } / > < /span>); } function createPropertyRecord ( label ) { const property = { name : "tree-node-editor" , displayLabel : "Tree Node Editor" , typename : label . property . typename } ; const record = new PropertyRecord ( label . value , property ) ; record . description = "" ; record . isReadonly = false ; return record ; }