11export function useFormKitSchema ( ) {
2- const addComponent = ( component : string = 'Button' , props : object = { } , render : string = ' true' , formKitAttrs : object = { } ) : object => {
2+ const addComponent = ( component : string = 'Button' , props : object = { } , render : string | boolean = true , formKitAttrs : object = { } ) : object => {
33 return {
44 $cmp : component ,
5- if : render ,
5+ if : render . toString ( ) ,
66 props,
77 ...formKitAttrs ,
88 }
99 }
1010
11- const addElement = ( element : string = 'div' , children : any [ ] | string = [ ] , attrs : object = { } , render : string = ' true' , formKitAttrs : object = { } ) => {
11+ const addElement = ( element : string = 'div' , children : any [ ] | string = [ ] , attrs : object = { } , render : string | boolean = true , formKitAttrs : object = { } ) => {
1212 return {
1313 $el : element ,
14- if : render ,
14+ if : render . toString ( ) ,
1515 attrs,
1616 children,
1717 ...formKitAttrs ,
1818 }
1919 }
2020
21- const addGroup = ( name : string , children : object [ ] = [ ] , render : string = ' true' , formKitAttrs : object = { } ) => {
21+ const addGroup = ( name : string , children : object [ ] = [ ] , render : string | boolean = true , formKitAttrs : object = { } ) => {
2222 return {
2323 $formkit : 'group' ,
24- if : render ,
24+ if : render . toString ( ) ,
2525 name,
2626 children,
2727 ...formKitAttrs ,
2828 }
2929 }
3030
31- const addList = ( name : string , children : object [ ] , dynamic : boolean = true , render : string = ' true' , formKitAttrs : object = { } ) => {
31+ const addList = ( name : string , children : object [ ] = [ ] , dynamic : boolean = true , render : string | boolean = true , formKitAttrs : object = { } ) => {
3232 return {
3333 $formkit : 'list' ,
34- if : render ,
34+ if : render . toString ( ) ,
3535 name,
3636 dynamic,
3737 children,
3838 ...formKitAttrs ,
3939 }
4040 }
4141
42- const addListGroup = ( children : object [ ] = [ ] , render : string = ' true' , formKitAttrs : object = { } ) => {
42+ const addListGroup = ( children : object [ ] = [ ] , render : string | boolean = true , formKitAttrs : object = { } ) => {
4343 return {
4444 $formkit : 'group' ,
45- if : render ,
45+ if : render . toString ( ) ,
4646 for : [ 'item' , 'index' , '$items' ] , // 👈 $items is in the slot’s scope
4747 key : '$item' ,
4848 index : '$index' ,
@@ -51,7 +51,7 @@ export function useFormKitSchema() {
5151 }
5252 }
5353
54- const addElementsInOuterDiv = ( children : object [ ] = [ ] , innerClass : string = '' , outerClass : string = '' , label : string = '' , help : string = '' , render : string = ' true' ) => {
54+ const addElementsInOuterDiv = ( children : object [ ] = [ ] , innerClass : string = '' , outerClass : string = '' , label : string = '' , help : string = '' , render : string | boolean = true ) => {
5555 const inner = addElement ( 'div' , children , { class : `formkit-inner ${ innerClass } ` , style : 'position: relative;' } )
5656 const labelDiv = addElement ( 'label' , [ label ] , { class : 'formkit-label' } )
5757 const wrapperDiv = addElement ( 'div' , [ labelDiv , inner ] , { class : 'formkit-wrapper' } )
0 commit comments