@@ -12,26 +12,36 @@ import {
1212 ToNodeType ,
1313 ViewFnTypeForComp ,
1414} from "./multi" ;
15- import { ChildrenToComp , ExposingConfig , withExposingConfigs } from "./withExposing" ;
15+ import {
16+ ChildrenToComp ,
17+ ExposingConfig ,
18+ withExposingConfigs ,
19+ } from "./withExposing" ;
1620import {
1721 ExposeMethodCompConstructor ,
1822 MethodConfigsType ,
1923 withMethodExposing ,
2024} from "./withMethodExposing" ;
2125
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+ } ;
2530
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+ } ) {
2735 const { readOnly } = useContext ( ExternalEditorContext ) ;
2836 if ( readOnly ) {
2937 return < > { props . children } </ > ;
3038 } else {
3139 return (
3240 < >
3341 { 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 >
3545 ) : (
3646 < > { props . children } </ >
3747 ) }
@@ -40,7 +50,9 @@ export function HidableView(props: { children: JSX.Element | React.ReactNode; hi
4050 }
4151}
4252
43- export function uiChildren < ChildrenCompMap extends Record < string , Comp < unknown > > > (
53+ export function uiChildren <
54+ ChildrenCompMap extends Record < string , Comp < unknown > > ,
55+ > (
4456 childrenMap : ToConstructor < ChildrenCompMap >
4557) : ToConstructor < NewChildren < ChildrenCompMap > > {
4658 return { ...childrenMap , hidden : BoolCodeControl } as any ;
@@ -51,12 +63,17 @@ type ViewReturn = ReactNode;
5163/**
5264 * UI components can be constructed with this class, providing the hidden interface
5365 */
54- export class UICompBuilder < ChildrenCompMap extends Record < string , Comp < unknown > > > {
66+ export class UICompBuilder <
67+ ChildrenCompMap extends Record < string , Comp < unknown > > ,
68+ > {
5569 private childrenMap : ToConstructor < ChildrenCompMap > ;
5670 private viewFn : ViewFnTypeForComp < ViewReturn , NewChildren < ChildrenCompMap > > ;
57- private propertyViewFn : PropertyViewFnTypeForComp < NewChildren < ChildrenCompMap > > = ( ) => null ;
71+ private propertyViewFn : PropertyViewFnTypeForComp <
72+ NewChildren < ChildrenCompMap >
73+ > = ( ) => null ;
5874 private stateConfigs : ExposingConfig < ChildrenToComp < ChildrenCompMap > > [ ] = [ ] ;
59- private methodConfigs : MethodConfigsType < ExposeMethodCompConstructor < any > > = [ ] ;
75+ private methodConfigs : MethodConfigsType < ExposeMethodCompConstructor < any > > =
76+ [ ] ;
6077
6178 /**
6279 * 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>>
6986 this . viewFn = viewFn ;
7087 }
7188
72- setPropertyViewFn ( propertyViewFn : PropertyViewFnTypeForComp < NewChildren < ChildrenCompMap > > ) {
89+ setPropertyViewFn (
90+ propertyViewFn : PropertyViewFnTypeForComp < NewChildren < ChildrenCompMap > >
91+ ) {
7392 this . propertyViewFn = propertyViewFn ;
7493 return this ;
7594 }
7695
77- setExposeStateConfigs ( configs : ExposingConfig < ChildrenToComp < ChildrenCompMap > > [ ] ) {
96+ setExposeStateConfigs (
97+ configs : ExposingConfig < ChildrenToComp < ChildrenCompMap > > [ ]
98+ ) {
7899 this . stateConfigs = configs ;
79100 return this ;
80101 }
81102
82103 setExposeMethodConfigs (
83- configs : MethodConfigsType < ExposeMethodCompConstructor < MultiBaseComp < ChildrenCompMap > > >
104+ configs : MethodConfigsType <
105+ ExposeMethodCompConstructor < MultiBaseComp < ChildrenCompMap > >
106+ >
84107 ) {
85108 this . methodConfigs = configs ;
86109 return this ;
@@ -113,14 +136,18 @@ export class UICompBuilder<ChildrenCompMap extends Record<string, Comp<unknown>>
113136 }
114137
115138 override getPropertyView ( ) : ReactNode {
116- return < PropertyView comp = { this } propertyViewFn = { builder . propertyViewFn } /> ;
139+ return (
140+ < PropertyView comp = { this } propertyViewFn = { builder . propertyViewFn } />
141+ ) ;
117142 }
118143 }
119144
120145 return withExposingConfigs (
121146 withMethodExposing (
122147 MultiTempComp ,
123- this . methodConfigs as MethodConfigsType < ExposeMethodCompConstructor < MultiTempComp > >
148+ this . methodConfigs as MethodConfigsType <
149+ ExposeMethodCompConstructor < MultiTempComp >
150+ >
124151 ) as typeof MultiTempComp ,
125152 this . stateConfigs
126153 ) ;
@@ -134,12 +161,26 @@ export const DisabledContext = React.createContext<boolean>(false);
134161 */
135162function UIView ( props : { comp : any ; viewFn : any } ) {
136163 const comp = props . comp ;
164+ console . log ( comp ) ;
165+
166+ console . log ( comp . children ) ;
167+
137168 const childrenProps = childrenToProps ( comp . children ) ;
138169 const parentDisabled = useContext ( DisabledContext ) ;
139170 const disabled = childrenProps [ "disabled" ] ;
140171 if ( disabled !== undefined && typeof disabled === "boolean" ) {
141172 childrenProps [ "disabled" ] = disabled || parentDisabled ;
142173 }
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+
143184 return (
144185 < HidableView hidden = { childrenProps . hidden as boolean } >
145186 { props . viewFn ( childrenProps , comp . dispatch ) }
0 commit comments