@@ -12,26 +12,36 @@ import {
1212ToNodeType ,
1313ViewFnTypeForComp ,
1414} from "./multi" ;
15- import { ChildrenToComp , ExposingConfig , withExposingConfigs } from "./withExposing" ;
15+ import {
16+ ChildrenToComp ,
17+ ExposingConfig ,
18+ withExposingConfigs ,
19+ } from "./withExposing" ;
1620import {
1721ExposeMethodCompConstructor ,
1822MethodConfigsType ,
1923withMethodExposing ,
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+ } ) {
2735const { readOnly} = useContext ( ExternalEditorContext ) ;
2836if ( readOnly ) {
2937return < > { props . children } </ > ;
3038} else {
3139return (
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+ > (
4456childrenMap :ToConstructor < ChildrenCompMap >
4557) :ToConstructor < NewChildren < ChildrenCompMap > > {
4658return { ...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+ > {
5569private childrenMap :ToConstructor < ChildrenCompMap > ;
5670private viewFn :ViewFnTypeForComp < ViewReturn , NewChildren < ChildrenCompMap > > ;
57- private propertyViewFn :PropertyViewFnTypeForComp < NewChildren < ChildrenCompMap > > = ( ) => null ;
71+ private propertyViewFn :PropertyViewFnTypeForComp <
72+ NewChildren < ChildrenCompMap >
73+ > = ( ) => null ;
5874private 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>>
6986this . viewFn = viewFn ;
7087}
7188
72- setPropertyViewFn ( propertyViewFn :PropertyViewFnTypeForComp < NewChildren < ChildrenCompMap > > ) {
89+ setPropertyViewFn (
90+ propertyViewFn :PropertyViewFnTypeForComp < NewChildren < ChildrenCompMap > >
91+ ) {
7392this . propertyViewFn = propertyViewFn ;
7493return this ;
7594}
7695
77- setExposeStateConfigs ( configs :ExposingConfig < ChildrenToComp < ChildrenCompMap > > [ ] ) {
96+ setExposeStateConfigs (
97+ configs :ExposingConfig < ChildrenToComp < ChildrenCompMap > > [ ]
98+ ) {
7899this . stateConfigs = configs ;
79100return this ;
80101}
81102
82103setExposeMethodConfigs (
83- configs :MethodConfigsType < ExposeMethodCompConstructor < MultiBaseComp < ChildrenCompMap > > >
104+ configs :MethodConfigsType <
105+ ExposeMethodCompConstructor < MultiBaseComp < ChildrenCompMap > >
106+ >
84107) {
85108this . methodConfigs = configs ;
86109return this ;
@@ -113,14 +136,18 @@ export class UICompBuilder<ChildrenCompMap extends Record<string, Comp<unknown>>
113136}
114137
115138override getPropertyView ( ) :ReactNode {
116- return < PropertyView comp = { this } propertyViewFn = { builder . propertyViewFn } /> ;
139+ return (
140+ < PropertyView comp = { this } propertyViewFn = { builder . propertyViewFn } />
141+ ) ;
117142}
118143}
119144
120145return withExposingConfigs (
121146withMethodExposing (
122147MultiTempComp ,
123- this . methodConfigs as MethodConfigsType < ExposeMethodCompConstructor < MultiTempComp > >
148+ this . methodConfigs as MethodConfigsType <
149+ ExposeMethodCompConstructor < MultiTempComp >
150+ >
124151) as typeof MultiTempComp ,
125152this . stateConfigs
126153) ;
@@ -134,12 +161,26 @@ export const DisabledContext = React.createContext<boolean>(false);
134161 */
135162function UIView ( props :{ comp :any ; viewFn :any } ) {
136163const comp = props . comp ;
164+ console . log ( comp ) ;
165+
166+ console . log ( comp . children ) ;
167+
137168const childrenProps = childrenToProps ( comp . children ) ;
138169const parentDisabled = useContext ( DisabledContext ) ;
139170const disabled = childrenProps [ "disabled" ] ;
140171if ( disabled !== undefined && typeof disabled === "boolean" ) {
141172childrenProps [ "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+
143184return (
144185< HidableView hidden = { childrenProps . hidden as boolean } >
145186{ props . viewFn ( childrenProps , comp . dispatch ) }