@@ -28,7 +28,7 @@ export abstract class CompositeNode<O, M extends NodeSchema> extends Node<NodeS,
28
28
abstract getCompositeOutput ( output : NodeO ) : NodeOutputValue < O > ;
29
29
30
30
renderComposite ( context : FormContext , children : ChildrenMap < React . ReactNode > ) : React . ReactNode {
31
- return Object . values ( children ) ;
31
+ return Object . keys ( children ) . map ( key => children [ key ] ) ;
32
32
}
33
33
34
34
resolveInitialState ( ) {
@@ -39,10 +39,29 @@ export abstract class CompositeNode<O, M extends NodeSchema> extends Node<NodeS,
39
39
return initialState ;
40
40
}
41
41
42
- getRawOutput ( ) {
42
+ getValueMapFromValue ( value : NodeOutputValue < O > ) : NodeOutputValue < O > {
43
+ return { ...value } ;
44
+ }
45
+
46
+ setValue ( value : NodeOutputValue < O > ) {
47
+ if ( this . getSchema ( ) . formatInput ) {
48
+ value = this . getSchema ( ) . formatInput ( value ) ;
49
+ }
50
+ value = this . getValueMapFromValue ( value ) ;
51
+
52
+ Object . keys ( this . getChildrenMapFromSchema ( ) ) . forEach ( key => {
53
+ if ( this . findChild ( key ) ) {
54
+ this . findChild ( key ) . setValue ( value [ key ] ) ;
55
+ }
56
+ } ) ;
57
+ }
58
+
59
+ getRawOutput ( options ) {
43
60
const output = { } ;
44
61
Object . keys ( this . getChildrenMapFromSchema ( ) ) . forEach ( key => {
45
- output [ key ] = this . findChild ( key ) . getOutput ( ) ;
62
+ if ( this . findChild ( key ) && this . findChild ( key ) . isOutputAvailable ( ) ) {
63
+ output [ key ] = this . findChild ( key ) . getOutput ( options ) ;
64
+ }
46
65
} ) ;
47
66
return this . getCompositeOutput ( output ) ;
48
67
}
@@ -67,7 +86,9 @@ export abstract class CompositeNode<O, M extends NodeSchema> extends Node<NodeS,
67
86
const childrenMap : ChildrenMap < React . ReactNode > = { } ;
68
87
69
88
Object . keys ( this . getChildrenMapFromSchema ( ) ) . forEach ( ( key : string , index : number ) => {
70
- childrenMap [ key ] = this . findChild ( key ) . render ( context ) ;
89
+ if ( this . findChild ( key ) ) {
90
+ childrenMap [ key ] = this . findChild ( key ) . render ( context ) ;
91
+ }
71
92
} ) ;
72
93
73
94
return this . renderComposite ( context , childrenMap ) ;
0 commit comments