From 9769d10209e4dbce395bcfee78a31d78b5db6072 Mon Sep 17 00:00:00 2001 From: zernonia Date: Sat, 20 Apr 2024 11:00:54 +0800 Subject: [PATCH] feat: expose custom auto form slot --- .../new-york/ui/auto-form/AutoForm.vue | 42 +++++++++++++------ 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/apps/www/src/lib/registry/new-york/ui/auto-form/AutoForm.vue b/apps/www/src/lib/registry/new-york/ui/auto-form/AutoForm.vue index 98296928..e883328e 100644 --- a/apps/www/src/lib/registry/new-york/ui/auto-form/AutoForm.vue +++ b/apps/www/src/lib/registry/new-york/ui/auto-form/AutoForm.vue @@ -45,6 +45,20 @@ const shapes = computed(() => { return val }) +const fields = computed(() => { + // @ts-expect-error ignore {} not assignable to object + const val: { [key in keyof z.infer]: { shape: Shape, fieldName: string, config: ConfigItem } } = {} + for (const key in shapes.value) { + const shape = shapes.value[key] + val[key as keyof z.infer] = { + shape, + config: props.fieldConfig?.[key] as ConfigItem, + fieldName: key, + } + } + return val +}) + const formComponent = computed(() => props.form ? 'form' : Form) const formComponentProps = computed(() => { if (props.form) { @@ -68,20 +82,22 @@ const formComponentProps = computed(() => { :is="formComponent" v-bind="formComponentProps" > - +