@@ -8,6 +8,7 @@ import { getBuildDirPath } from '../../util/script';
8
8
import { getExpansionRowData } from './TableExpansionRowData' ;
9
9
import { RowDataFields } from '../../context/TableContext' ;
10
10
import { CustomRowBase , CustomRowConstructor } from './CustomRowBase' ;
11
+ import { CustomComponentContextType } from '../../context/CustomComponentContext' ;
11
12
12
13
type CustomControlError = {
13
14
methodName : string ;
@@ -27,6 +28,7 @@ type CustomTableControlProps = {
27
28
fileName : string ;
28
29
type : string ;
29
30
moreInfo : Array < { name : string ; value : string ; mapping ?: Record < string , string > } > ;
31
+ customComponentContext ?: CustomComponentContextType ;
30
32
} ;
31
33
32
34
type CustomTableControlState = {
@@ -38,6 +40,8 @@ type CustomTableControlState = {
38
40
} ;
39
41
40
42
class CustomTableControl extends Component < CustomTableControlProps , CustomTableControlState > {
43
+ customComponentContext ?: CustomComponentContextType ;
44
+
41
45
customControl ?: CustomRowBase ; // Custom control instance
42
46
43
47
el : HTMLSpanElement | null = null ; // Reference to the DOM element for the custom control
@@ -54,6 +58,7 @@ class CustomTableControl extends Component<CustomTableControlProps, CustomTableC
54
58
rowUpdatedByControl : false , // Flag to track if the row was updated by custom control
55
59
} ;
56
60
this . shouldRender = true ; // Flag to control rendering logic
61
+ this . customComponentContext = props . customComponentContext ; // Store custom component context
57
62
}
58
63
59
64
// Lifecycle method that updates the component's state when props change
@@ -101,8 +106,10 @@ class CustomTableControl extends Component<CustomTableControlProps, CustomTableC
101
106
new Promise ( ( resolve , reject ) => {
102
107
const { type, fileName } = this . props ;
103
108
const globalConfig = getUnifiedConfigs ( ) ;
104
-
105
- if ( type === 'external' ) {
109
+ if ( this . customComponentContext ?. [ this . props . fileName ] ) {
110
+ const Control = this . customComponentContext ?. [ this . props . fileName ] ;
111
+ resolve ( Control as CustomRowConstructor ) ;
112
+ } else if ( type === 'external' ) {
106
113
import ( /* @vite -ignore */ `${ getBuildDirPath ( ) } /custom/${ fileName } .js` )
107
114
. then ( ( external ) => resolve ( external . default ) )
108
115
. catch ( ( error ) => reject ( error ) ) ;
@@ -195,12 +202,14 @@ class CustomTableControl extends Component<CustomTableControlProps, CustomTableC
195
202
this . handleNoGetDLRows ( ) ;
196
203
}
197
204
} )
198
- . catch ( ( ) =>
205
+ . catch ( ( e ) => {
199
206
this . setState ( {
200
207
loading : false ,
201
208
methodNotPresentError : 'Error loading custom control' ,
202
- } )
203
- ) ;
209
+ } ) ;
210
+ // eslint-disable-next-line no-console
211
+ console . error ( `[Custom Control] Error loading custom control ${ e } ` ) ;
212
+ } ) ;
204
213
}
205
214
206
215
render ( ) {
0 commit comments