@@ -39,14 +39,16 @@ export const SchemaObject: React.FunctionComponent<SchemaObjectProps> = (
39
39
localState . isAdvancedOpen . set ( false ) ;
40
40
} ;
41
41
42
- const showadvanced = ( item : State < JSONSchema7 > ) : void => {
42
+ const showadvanced = ( item : string ) : void => {
43
43
localState . isAdvancedOpen . set ( true ) ;
44
+ localState . item . set ( item ) ;
44
45
} ;
45
46
46
47
const focusRef = React . createRef < HTMLElement > ( ) ;
47
48
48
49
const localState = useState ( {
49
50
isAdvancedOpen : false ,
51
+ item : "" ,
50
52
} ) ;
51
53
52
54
if ( ! propertiesOrNull ) {
@@ -56,55 +58,53 @@ export const SchemaObject: React.FunctionComponent<SchemaObjectProps> = (
56
58
< div className = "object-style" >
57
59
{ propertiesOrNull ?. keys ?. map ( ( name ) => {
58
60
return (
59
- < >
60
- < SchemaItem
61
- key = { String ( name ) }
61
+ < SchemaItem
62
+ key = { String ( name ) }
63
+ itemStateProp = {
64
+ propertiesOrNull . nested ( name as string ) as State < JSONSchema7 >
65
+ }
66
+ parentStateProp = { schema }
67
+ name = { name as string }
68
+ showadvanced = { showadvanced }
69
+ required = { schema . required . value as string [ ] }
70
+ isReadOnly = { isReadOnlyState }
71
+ />
72
+ ) ;
73
+ } ) }
74
+ < Modal
75
+ isOpen = { localState . isAdvancedOpen . get ( ) }
76
+ finalFocusRef = { focusRef }
77
+ size = "lg"
78
+ onClose = { onCloseAdvanced }
79
+ >
80
+ < ModalOverlay />
81
+ < ModalContent >
82
+ < ModalHeader textAlign = "center" >
83
+ Advanced Schema Settings
84
+ </ ModalHeader >
85
+
86
+ < ModalBody >
87
+ < AdvancedSettings
62
88
itemStateProp = {
63
- propertiesOrNull . nested ( name as string ) as State < JSONSchema7 >
89
+ propertiesOrNull . nested (
90
+ localState . item . value as string
91
+ ) as State < JSONSchema7 >
64
92
}
65
- parentStateProp = { schema }
66
- name = { name as string }
67
- showadvanced = { showadvanced }
68
- required = { schema . required . value as string [ ] }
69
- isReadOnly = { isReadOnlyState }
70
93
/>
71
- < Modal
72
- isOpen = { localState . isAdvancedOpen . get ( ) }
73
- finalFocusRef = { focusRef }
74
- size = "lg"
75
- onClose = { onCloseAdvanced }
76
- >
77
- < ModalOverlay />
78
- < ModalContent >
79
- < ModalHeader textAlign = "center" >
80
- Advanced Schema Settings
81
- </ ModalHeader >
94
+ </ ModalBody >
82
95
83
- < ModalBody >
84
- < AdvancedSettings
85
- itemStateProp = {
86
- propertiesOrNull . nested (
87
- name as string
88
- ) as State < JSONSchema7 >
89
- }
90
- />
91
- </ ModalBody >
92
-
93
- < ModalFooter >
94
- < Button
95
- colorScheme = "blue"
96
- variant = "ghost"
97
- mr = { 3 }
98
- onClick = { onCloseAdvanced }
99
- >
100
- Close
101
- </ Button >
102
- </ ModalFooter >
103
- </ ModalContent >
104
- </ Modal >
105
- </ >
106
- ) ;
107
- } ) }
96
+ < ModalFooter >
97
+ < Button
98
+ colorScheme = "blue"
99
+ variant = "ghost"
100
+ mr = { 3 }
101
+ onClick = { onCloseAdvanced }
102
+ >
103
+ Close
104
+ </ Button >
105
+ </ ModalFooter >
106
+ </ ModalContent >
107
+ </ Modal >
108
108
</ div >
109
109
) ;
110
110
}
0 commit comments