@@ -12,6 +12,7 @@ import type {
1212 GraphMissingRefsMetadata ,
1313 GraphRefMetadataItem ,
1414} from '../../../../plus/graph/protocol' ;
15+ import type { GraphWrapperInitProps , GraphWrapperProps , GraphWrapperSubscriberProps } from './graph-wrapper.react' ;
1516import { GraphWrapperReact } from './graph-wrapper.react' ;
1617
1718// @customElement ('gl-graph-wrapper-element')
@@ -38,8 +39,8 @@ export class WebGraph extends LitElement {
3839 private graphRef : GraphContainer | null = null ;
3940
4041 // State updater function provided by the React component
41- @state ( )
42- private stateUpdater : ( ( props : any ) => void ) | null = null ;
42+ // @state ()
43+ private stateUpdater : ( ( props : Partial < GraphWrapperSubscriberProps > ) => void ) | null = null ;
4344
4445 // Properties that match GraphWrapperProps
4546 @property ( { type : String } )
@@ -79,7 +80,7 @@ export class WebGraph extends LitElement {
7980 loading ?: boolean ;
8081
8182 @property ( { type : Object } )
82- selectedRows ?: Record < string , boolean > ;
83+ selectedRows ?: GraphWrapperProps [ 'selectedRows' ] ;
8384
8485 @property ( { type : Boolean } )
8586 windowFocused ?: boolean ;
@@ -124,10 +125,10 @@ export class WebGraph extends LitElement {
124125 }
125126
126127 // Update the React component's state when properties change
127- override updated ( _changedProperties : Map < string , any > ) : void {
128+ override updated ( changedProperties : Map < string , unknown > ) : void {
128129 if ( this . stateUpdater ) {
129130 // Only update if we have a state updater and properties have changed
130- const props = this . getProps ( ) ;
131+ const props = this . getProps ( changedProperties ) ;
131132 this . stateUpdater ( props ) ;
132133 }
133134 }
@@ -145,15 +146,13 @@ export class WebGraph extends LitElement {
145146 // Get the initial props
146147 const props = this . getProps ( ) ;
147148
148- // Add the subscriber function to allow the React component to provide a state updater
149- props . subscriber = ( updater : ( props : any ) => void ) => {
150- this . stateUpdater = updater ;
151- } ;
152-
153149 // Mount the React component
154150 this . reactRoot . render (
155151 createElement ( GraphWrapperReact , {
156152 ...props ,
153+ subscriber : ( updater : ( props : Partial < GraphWrapperSubscriberProps > ) => void ) => {
154+ this . stateUpdater = updater ;
155+ } ,
157156 onChangeColumns : this . handleChangeColumns . bind ( this ) ,
158157 onGraphMouseLeave : this . handleGraphMouseLeave . bind ( this ) ,
159158 onChangeRefsVisibility : this . handleChangeRefsVisibility . bind ( this ) ,
@@ -167,17 +166,22 @@ export class WebGraph extends LitElement {
167166 onGraphRowHovered : this . handleGraphRowHovered . bind ( this ) ,
168167 onGraphRowUnhovered : this . handleGraphRowUnhovered . bind ( this ) ,
169168 onRowContextMenu : this . handleRowContextMenu . bind ( this ) ,
170- } ) ,
169+ } as GraphWrapperInitProps ) ,
171170 ) ;
172171 }
173172
174173 // Collect all props to pass to the React component
175- private getProps ( ) : any {
174+ private getProps ( _changedProperties ?: Map < string , unknown > ) : Partial < GraphWrapperSubscriberProps > {
175+ // TODO: look at only sending changed properties
176+ // if (changedProperties != null) {
177+ // return Object.fromEntries(changedProperties.entries());
178+ // }
179+
176180 return {
177181 activeRow : this . activeRow ,
178182 avatars : this . avatars ,
179183 columns : this . columns ,
180- context : this . context ,
184+ context : this . context as GraphWrapperSubscriberProps [ 'context' ] ,
181185 config : this . config ,
182186 downstreams : this . downstreams ,
183187 rows : this . rows ,
0 commit comments