11import { Fields , ISailsFuncArg } from '@gear-js/sails-payload-form' ;
22import { InputProps , InputWrapper , Select } from '@gear-js/ui' ;
3+ import { ComponentProps } from 'react' ;
34import { Sails } from 'sails-js' ;
45
56import { Checkbox , Fieldset , Input , Textarea } from '@/shared/ui' ;
@@ -24,21 +25,35 @@ type ServiceProps = BaseProps & {
2425
2526type Props = ConstructorProps | ServiceProps ;
2627
28+ function PayloadSelect ( props : Omit < ComponentProps < typeof Select > , 'direction' | 'gap' > ) {
29+ // eslint-disable-next-line react/no-children-prop
30+ return < Select { ...props } direction = "y" children = "" /> ;
31+ }
32+
33+ function PayloadInput ( props : Omit < ComponentProps < typeof Input > , 'direction' | 'gap' > ) {
34+ return < Input { ...props } direction = "y" /> ;
35+ }
36+
37+ function PayloadTextarea ( props : Omit < ComponentProps < typeof Textarea > , 'direction' | 'gap' > ) {
38+ return < Textarea { ...props } direction = "y" /> ;
39+ }
40+
2741function PayloadForm ( { sails, select, args, gap, direction = 'x' , ...props } : Props ) {
2842 const isFunction = 'functionSelect' in props ;
2943
3044 return (
3145 < InputWrapper id = "payload" label = "Payload" size = "normal" gap = { gap } direction = { direction } className = { styles . form } >
32- < Select direction = "y" { ...select } />
33- { isFunction && < Select direction = "y" { ...props . functionSelect } /> }
46+ < PayloadSelect { ...select } />
47+ { isFunction && < PayloadSelect { ...props . functionSelect } /> }
3448
3549 < Fields
3650 sails = { sails }
3751 args = { args }
3852 render = { {
39- ui : { fieldset : Fieldset , select : Select } ,
40- rhf : { input : Input , textarea : Textarea , checkbox : Checkbox } ,
53+ ui : { fieldset : Fieldset , select : PayloadSelect } ,
54+ rhf : { input : PayloadInput , textarea : PayloadTextarea , checkbox : Checkbox } ,
4155 } }
56+ renderContainer = { Fieldset }
4257 />
4358 </ InputWrapper >
4459 ) ;
0 commit comments