@@ -44,6 +44,16 @@ const fields = Object.entries(shape).map(([key, zodType]) =>
4444 getComponentForZodType (key , zodType ),
4545)
4646
47+ function parseMeta(zodType : any , key : string ) {
48+ const meta = typeof zodType .meta === ' function' ? zodType .meta () || {} : {}
49+
50+ return {
51+ label: meta .title ?? upperFirst (splitByCase (key ).join (' ' ).toLowerCase ()),
52+ description: meta .description ,
53+ class: meta .autoForm ?.floatRight ? ' flex items-center justify-between text-left' : ' ' ,
54+ }
55+ }
56+
4757function getComponentForZodType(key : string , zodType : any ) {
4858 let component = UInput as any
4959 let componentProps = {}
@@ -67,9 +77,10 @@ function getComponentForZodType(key: string, zodType: any) {
6777 const result = getComponentForZodType (key , zodType .unwrap ()) as any
6878 result .props .multiple = true
6979
70- // todo: method for parsing meta
71- const meta = zodType .meta () || {}
72- result .formField .label = meta .title ?? key
80+ result .formField = {
81+ ... result .formField ,
82+ ... parseMeta (zodType , key ),
83+ }
7384 return result
7485 }
7586 }
@@ -84,14 +95,12 @@ function getComponentForZodType(key: string, zodType: any) {
8495 console .warn (' Unknown zod type' , zodType .constructor .name )
8596 }
8697
87- const meta = zodType . meta () || {}
98+ const meta = parseMeta ( zodType , key )
8899 return {
89100 key ,
90101 formField: {
91102 name: key ,
92- label: meta .title ?? upperFirst (splitByCase (key ).join (' ' ).toLowerCase ()),
93- description: meta .description ,
94- class: meta .autoForm ?.floatRight ? ' flex items-center justify-between text-left' : ' ' ,
103+ ... meta ,
95104 },
96105 component ,
97106 props: componentProps ,
0 commit comments