@@ -25,7 +25,10 @@ export function ActionInputSection() {
2525 const [ placeholderText , setPlaceholderText ] = useState < string > ( "" ) ;
2626 const [ selectedComponent , setSelectedComponent ] = useState < string | null > ( null ) ;
2727 const [ showComponentDropdown , setShowComponentDropdown ] = useState < boolean > ( false ) ;
28+ const [ isNestedComponent , setIsNestedComponent ] = useState < boolean > ( false ) ;
29+ const [ selectedNestComponent , setSelectedNestComponent ] = useState < string | null > ( null ) ;
2830 const [ showEditorComponentsDropdown , setShowEditorComponentsDropdown ] = useState < boolean > ( false ) ;
31+ const [ showStylingInput , setShowStylingInput ] = useState < boolean > ( false ) ;
2932 const [ selectedEditorComponent , setSelectedEditorComponent ] = useState < string | null > ( null ) ;
3033 const [ validationError , setValidationError ] = useState < string | null > ( null ) ;
3134 const inputRef = useRef < InputRef > ( null ) ;
@@ -73,44 +76,55 @@ export function ActionInputSection() {
7376
7477 setShowComponentDropdown ( false ) ;
7578 setShowEditorComponentsDropdown ( false ) ;
79+ setShowStylingInput ( false ) ;
7680 setSelectedComponent ( null ) ;
7781 setSelectedEditorComponent ( null ) ;
82+ setIsNestedComponent ( false ) ;
83+ setSelectedNestComponent ( null ) ;
7884 setActionValue ( "" ) ;
7985
8086 if ( action . requiresComponentSelection ) {
8187 setShowComponentDropdown ( true ) ;
8288 setPlaceholderText ( "Select a component to add" ) ;
83- } else if ( action . requiresEditorComponentSelection ) {
89+ }
90+ if ( action . requiresEditorComponentSelection ) {
8491 setShowEditorComponentsDropdown ( true ) ;
8592 setPlaceholderText ( `Select a component to ${ action . label . toLowerCase ( ) } ` ) ;
86- } else if ( action . requiresInput ) {
93+ }
94+ if ( action . requiresInput ) {
8795 setPlaceholderText ( action . inputPlaceholder || `Enter ${ action . label . toLowerCase ( ) } value` ) ;
8896 } else {
8997 setPlaceholderText ( `Execute ${ action . label . toLowerCase ( ) } ` ) ;
9098 }
99+ if ( action . requiresStyle ) {
100+ setShowStylingInput ( true ) ;
101+ setPlaceholderText ( `Select a component to style` ) ;
102+ }
103+ if ( action . isNested ) {
104+ setIsNestedComponent ( true ) ;
105+ }
91106 } , [ ] ) ;
92107
93108 const handleComponentSelection = useCallback ( ( key : string ) => {
94109 if ( key . startsWith ( 'comp-' ) ) {
95110 const compName = key . replace ( 'comp-' , '' ) ;
96- setSelectedComponent ( compName ) ;
111+ isNestedComponent ? setSelectedNestComponent ( compName ) : setSelectedComponent ( compName ) ;
97112 setPlaceholderText ( `Configure ${ compName } component` ) ;
98113 }
99- } , [ ] ) ;
114+ } , [ isNestedComponent ] ) ;
100115
101116 const handleEditorComponentSelection = useCallback ( ( key : string ) => {
102117 setSelectedEditorComponent ( key ) ;
103- if ( currentAction ) {
104- setPlaceholderText ( `${ currentAction . label } ` ) ;
105- }
118+ setPlaceholderText ( `${ currentAction ?. label } ` ) ;
106119 } , [ currentAction ] ) ;
107120
121+
108122 const validateInput = useCallback ( ( value : string ) : string | null => {
109123 if ( ! currentAction ?. validation ) return null ;
110124 return currentAction . validation ( value ) ;
111125 } , [ currentAction ] ) ;
112126
113- const handleInputChange = useCallback ( ( e : React . ChangeEvent < HTMLInputElement > ) => {
127+ const handleInputChange = useCallback ( ( e : React . ChangeEvent < HTMLTextAreaElement | HTMLInputElement > ) => {
114128 const value = e . target . value ;
115129 setActionValue ( value ) ;
116130
@@ -149,12 +163,18 @@ export function ActionInputSection() {
149163 return ;
150164 }
151165
166+ if ( currentAction . isNested && ! selectedNestComponent ) {
167+ message . error ( 'Please select a component to nest' ) ;
168+ return ;
169+ }
170+
152171 try {
153172 await currentAction . execute ( {
154173 actionKey : selectedActionKey ,
155174 actionValue,
156175 selectedComponent,
157176 selectedEditorComponent,
177+ selectedNestComponent,
158178 editorState
159179 } ) ;
160180
@@ -167,6 +187,8 @@ export function ActionInputSection() {
167187 setSelectedEditorComponent ( null ) ;
168188 setPlaceholderText ( "" ) ;
169189 setValidationError ( null ) ;
190+ setIsNestedComponent ( false ) ;
191+ setSelectedNestComponent ( null ) ;
170192
171193 } catch ( error ) {
172194 console . error ( 'Error executing action:' , error ) ;
@@ -177,6 +199,7 @@ export function ActionInputSection() {
177199 actionValue ,
178200 selectedComponent ,
179201 selectedEditorComponent ,
202+ selectedNestComponent ,
180203 editorState ,
181204 currentAction ,
182205 validateInput
@@ -235,7 +258,7 @@ export function ActionInputSection() {
235258 </ Button >
236259 </ CustomDropdown >
237260
238- { showComponentDropdown && (
261+ { ( showComponentDropdown || isNestedComponent ) && (
239262 < CustomDropdown
240263 overlayStyle = { {
241264 maxHeight : '400px' ,
@@ -253,7 +276,13 @@ export function ActionInputSection() {
253276 >
254277 < Button size = { "small" } >
255278 < Space >
256- { selectedComponent ? selectedComponent : 'Select Component' }
279+ {
280+ selectedComponent
281+ ? selectedComponent
282+ : selectedNestComponent
283+ ? selectedNestComponent
284+ : 'New Component'
285+ }
257286 < DownOutlined />
258287 </ Space >
259288 </ Button >
@@ -278,23 +307,34 @@ export function ActionInputSection() {
278307 >
279308 < Button size = { "small" } >
280309 < Space >
281- { selectedEditorComponent ? selectedEditorComponent : 'Select Component' }
310+ { selectedEditorComponent ? selectedEditorComponent : 'Editor Component' }
282311 < DownOutlined />
283312 </ Space >
284313 </ Button >
285314 </ CustomDropdown >
286315 ) }
287-
316+
288317 { shouldShowInput && (
289- < Input
290- ref = { inputRef }
291- value = { actionValue }
292- onChange = { handleInputChange }
293- placeholder = { placeholderText }
294- status = { validationError ? 'error' : undefined }
295- />
318+ showStylingInput ? (
319+ < Input . TextArea
320+ ref = { inputRef }
321+ value = { actionValue }
322+ onChange = { handleInputChange }
323+ placeholder = { placeholderText }
324+ status = { validationError ? 'error' : undefined }
325+ autoSize = { { minRows : 1 } }
326+ />
327+ ) : (
328+ < Input
329+ ref = { inputRef }
330+ value = { actionValue }
331+ onChange = { handleInputChange }
332+ placeholder = { placeholderText }
333+ status = { validationError ? 'error' : undefined }
334+ />
335+ )
296336 ) }
297-
337+
298338 { validationError && (
299339 < div style = { { color : '#ff4d4f' , fontSize : '12px' , marginTop : '-8px' } } >
300340 { validationError }
0 commit comments