@@ -46,27 +46,30 @@ const appConfig = computed<AutoFormConfig>(() => {
4646 return defu (props .config , useAppConfig ().autoForm , defaults )
4747})
4848
49- const fields = Object .entries (shape ).map (([key , zodType ]: [string , any ]) => {
50- const result = mapZodTypeToComponent (key , zodType , appConfig .value , state )
51- if (! result )
52- return null
53-
54- const meta = typeof zodType .meta === ' function' ? zodType .meta () || {} : {}
55-
56- const defaultProps = {
57- class: appConfig .value ?.theme ?.wFull ? ' w-full' : ' ' ,
58- }
59- return {
60- key ,
61- formField: {
62- name: key ,
63- slots: findSlots (key ),
64- ... parseMeta (meta , key ),
65- },
66- component: meta ?.input ?.component ?? result .component ,
67- props: defu (defaultProps , meta ?.input ?.props , result .componentProps ?? {}),
68- }
69- }).filter ((field ): field is NonNullable <typeof field > => field != null )
49+ const fields = computed (() => {
50+ return Object .entries (shape ).map (([key , zodType ]: [string , any ]) => {
51+ const result = mapZodTypeToComponent (key , zodType , appConfig .value , state )
52+ if (! result )
53+ return null
54+
55+ const meta = typeof zodType .meta === ' function' ? zodType .meta () || {} : {}
56+
57+ const defaultProps = {
58+ class: appConfig .value ?.theme ?.wFull ? ' w-full' : ' ' ,
59+ }
60+
61+ return {
62+ key ,
63+ formField: {
64+ name: key ,
65+ slots: findSlots (key ),
66+ ... parseMeta (meta , key ),
67+ },
68+ component: meta ?.input ?.component ?? result .component ,
69+ props: defu (defaultProps , meta ?.input ?.props , result .componentProps ?? {}),
70+ }
71+ }).filter ((field ): field is NonNullable <typeof field > => field != null )
72+ })
7073
7174function findSlots(key : string ): string [] {
7275 return Object .keys (slots )
@@ -102,7 +105,7 @@ function submit() {
102105
103106const submitButton = computed (() => {
104107 if (appConfig .value ?.submit !== false )
105- return appConfig .value .submit
108+ return appConfig .value ? .submit
106109 return undefined
107110})
108111
@@ -152,7 +155,7 @@ const submitButtonProps = computed(() => {
152155 <slot name =" after-fields" />
153156
154157 <slot name =" submit" :disabled =" isButtonDisabled" >
155- <div v-if =" submitButton " >
158+ <div v-if =" appConfig?.submit !== false " >
156159 <template v-if =" submitButton ?.component " >
157160 <component :is =" toRaw(submitButton?.component)" v-bind =" submitButtonProps" />
158161 </template >
0 commit comments