Skip to content

Commit 93a8de4

Browse files
committed
feat: enhance email field handling in AutoForm component
1 parent 9b41993 commit 93a8de4

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/runtime/components/AutoForm.vue

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ const COMPONENTS_MAP: ComponentsMap = {
5454
},
5555
}),
5656
array: (key, zodType) => {
57-
const sub_element = zodType.def.element
58-
if (sub_element instanceof z.ZodEnum) {
57+
const innerType = zodType.def.element
58+
if (innerType instanceof z.ZodEnum) {
5959
const result = mapZodTypeToComponent(key, zodType.unwrap()) as any
6060
result.componentProps.multiple = true
6161
return result
@@ -65,7 +65,15 @@ const COMPONENTS_MAP: ComponentsMap = {
6565
(state as any)[key] = zodType.def.defaultValue
6666
return mapZodTypeToComponent(key, zodType.unwrap())
6767
},
68-
email: () => ({ component: UInput, componentProps: { type: 'email' } }),
68+
email: (key, _) => {
69+
const stringComponent = mapZodTypeToComponent(key, 'string')!
70+
71+
return defu({
72+
componentProps: {
73+
type: 'email',
74+
},
75+
}, stringComponent)
76+
},
6977
}
7078
7179
const defaults: Partial<AutoFormConfig> = {

0 commit comments

Comments
 (0)