@@ -12,26 +12,36 @@ import {
12
12
ToNodeType ,
13
13
ViewFnTypeForComp ,
14
14
} from "./multi" ;
15
- import { ChildrenToComp , ExposingConfig , withExposingConfigs } from "./withExposing" ;
15
+ import {
16
+ ChildrenToComp ,
17
+ ExposingConfig ,
18
+ withExposingConfigs ,
19
+ } from "./withExposing" ;
16
20
import {
17
21
ExposeMethodCompConstructor ,
18
22
MethodConfigsType ,
19
23
withMethodExposing ,
20
24
} from "./withMethodExposing" ;
21
25
22
- export type NewChildren < ChildrenCompMap extends Record < string , Comp < unknown > > > = ChildrenCompMap & {
23
- hidden : InstanceType < typeof BoolCodeControl > ;
24
- } ;
26
+ export type NewChildren < ChildrenCompMap extends Record < string , Comp < unknown > > > =
27
+ ChildrenCompMap & {
28
+ hidden : InstanceType < typeof BoolCodeControl > ;
29
+ } ;
25
30
26
- export function HidableView ( props : { children : JSX . Element | React . ReactNode ; hidden : boolean } ) {
31
+ export function HidableView ( props : {
32
+ children : JSX . Element | React . ReactNode ;
33
+ hidden : boolean ;
34
+ } ) {
27
35
const { readOnly } = useContext ( ExternalEditorContext ) ;
28
36
if ( readOnly ) {
29
37
return < > { props . children } </ > ;
30
38
} else {
31
39
return (
32
40
< >
33
41
{ props . hidden ? (
34
- < div style = { { opacity : "50%" , width : "100%" , height : "100%" } } > { props . children } </ div >
42
+ < div style = { { opacity : "50%" , width : "100%" , height : "100%" } } >
43
+ { props . children }
44
+ </ div >
35
45
) : (
36
46
< > { props . children } </ >
37
47
) }
@@ -40,7 +50,9 @@ export function HidableView(props: { children: JSX.Element | React.ReactNode; hi
40
50
}
41
51
}
42
52
43
- export function uiChildren < ChildrenCompMap extends Record < string , Comp < unknown > > > (
53
+ export function uiChildren <
54
+ ChildrenCompMap extends Record < string , Comp < unknown > > ,
55
+ > (
44
56
childrenMap : ToConstructor < ChildrenCompMap >
45
57
) : ToConstructor < NewChildren < ChildrenCompMap > > {
46
58
return { ...childrenMap , hidden : BoolCodeControl } as any ;
@@ -51,12 +63,17 @@ type ViewReturn = ReactNode;
51
63
/**
52
64
* UI components can be constructed with this class, providing the hidden interface
53
65
*/
54
- export class UICompBuilder < ChildrenCompMap extends Record < string , Comp < unknown > > > {
66
+ export class UICompBuilder <
67
+ ChildrenCompMap extends Record < string , Comp < unknown > > ,
68
+ > {
55
69
private childrenMap : ToConstructor < ChildrenCompMap > ;
56
70
private viewFn : ViewFnTypeForComp < ViewReturn , NewChildren < ChildrenCompMap > > ;
57
- private propertyViewFn : PropertyViewFnTypeForComp < NewChildren < ChildrenCompMap > > = ( ) => null ;
71
+ private propertyViewFn : PropertyViewFnTypeForComp <
72
+ NewChildren < ChildrenCompMap >
73
+ > = ( ) => null ;
58
74
private stateConfigs : ExposingConfig < ChildrenToComp < ChildrenCompMap > > [ ] = [ ] ;
59
- private methodConfigs : MethodConfigsType < ExposeMethodCompConstructor < any > > = [ ] ;
75
+ private methodConfigs : MethodConfigsType < ExposeMethodCompConstructor < any > > =
76
+ [ ] ;
60
77
61
78
/**
62
79
* If viewFn is not placed in the constructor, the type of ViewReturn cannot be inferred
@@ -69,18 +86,24 @@ export class UICompBuilder<ChildrenCompMap extends Record<string, Comp<unknown>>
69
86
this . viewFn = viewFn ;
70
87
}
71
88
72
- setPropertyViewFn ( propertyViewFn : PropertyViewFnTypeForComp < NewChildren < ChildrenCompMap > > ) {
89
+ setPropertyViewFn (
90
+ propertyViewFn : PropertyViewFnTypeForComp < NewChildren < ChildrenCompMap > >
91
+ ) {
73
92
this . propertyViewFn = propertyViewFn ;
74
93
return this ;
75
94
}
76
95
77
- setExposeStateConfigs ( configs : ExposingConfig < ChildrenToComp < ChildrenCompMap > > [ ] ) {
96
+ setExposeStateConfigs (
97
+ configs : ExposingConfig < ChildrenToComp < ChildrenCompMap > > [ ]
98
+ ) {
78
99
this . stateConfigs = configs ;
79
100
return this ;
80
101
}
81
102
82
103
setExposeMethodConfigs (
83
- configs : MethodConfigsType < ExposeMethodCompConstructor < MultiBaseComp < ChildrenCompMap > > >
104
+ configs : MethodConfigsType <
105
+ ExposeMethodCompConstructor < MultiBaseComp < ChildrenCompMap > >
106
+ >
84
107
) {
85
108
this . methodConfigs = configs ;
86
109
return this ;
@@ -113,14 +136,18 @@ export class UICompBuilder<ChildrenCompMap extends Record<string, Comp<unknown>>
113
136
}
114
137
115
138
override getPropertyView ( ) : ReactNode {
116
- return < PropertyView comp = { this } propertyViewFn = { builder . propertyViewFn } /> ;
139
+ return (
140
+ < PropertyView comp = { this } propertyViewFn = { builder . propertyViewFn } />
141
+ ) ;
117
142
}
118
143
}
119
144
120
145
return withExposingConfigs (
121
146
withMethodExposing (
122
147
MultiTempComp ,
123
- this . methodConfigs as MethodConfigsType < ExposeMethodCompConstructor < MultiTempComp > >
148
+ this . methodConfigs as MethodConfigsType <
149
+ ExposeMethodCompConstructor < MultiTempComp >
150
+ >
124
151
) as typeof MultiTempComp ,
125
152
this . stateConfigs
126
153
) ;
@@ -134,12 +161,26 @@ export const DisabledContext = React.createContext<boolean>(false);
134
161
*/
135
162
function UIView ( props : { comp : any ; viewFn : any } ) {
136
163
const comp = props . comp ;
164
+ console . log ( comp ) ;
165
+
166
+ console . log ( comp . children ) ;
167
+
137
168
const childrenProps = childrenToProps ( comp . children ) ;
138
169
const parentDisabled = useContext ( DisabledContext ) ;
139
170
const disabled = childrenProps [ "disabled" ] ;
140
171
if ( disabled !== undefined && typeof disabled === "boolean" ) {
141
172
childrenProps [ "disabled" ] = disabled || parentDisabled ;
142
173
}
174
+
175
+ //ADDED BY FRED
176
+ if ( childrenProps . events ) {
177
+ const events = childrenProps . events as { value ?: any [ ] } ;
178
+ if ( ! events . value || events . value . length === 0 ) {
179
+ events . value = [ ] ;
180
+ }
181
+ }
182
+ //END ADD BY FRED
183
+
143
184
return (
144
185
< HidableView hidden = { childrenProps . hidden as boolean } >
145
186
{ props . viewFn ( childrenProps , comp . dispatch ) }
0 commit comments