chore: prevent schema props showing on attribute
This commit is contained in:
parent
b07b4d4d96
commit
c986fed5ef
|
|
@ -1,9 +1,10 @@
|
||||||
<script setup lang="ts" generic="U extends ZodAny">
|
<script setup lang="ts" generic="U extends ZodAny">
|
||||||
import type { ZodAny } from 'zod'
|
import type { ZodAny } from 'zod'
|
||||||
|
import { computed } from 'vue'
|
||||||
import type { Config, ConfigItem, Shape } from './interface'
|
import type { Config, ConfigItem, Shape } from './interface'
|
||||||
import { DEFAULT_ZOD_HANDLERS, INPUT_COMPONENTS } from './constant'
|
import { DEFAULT_ZOD_HANDLERS, INPUT_COMPONENTS } from './constant'
|
||||||
|
|
||||||
defineProps<{
|
const props = defineProps<{
|
||||||
name: string
|
name: string
|
||||||
shape: Shape
|
shape: Shape
|
||||||
label?: string
|
label?: string
|
||||||
|
|
@ -13,6 +14,12 @@ defineProps<{
|
||||||
function isValidConfig(config: any): config is ConfigItem {
|
function isValidConfig(config: any): config is ConfigItem {
|
||||||
return !!config?.component
|
return !!config?.component
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const delegatedProps = computed(() => {
|
||||||
|
if (['ZodObject', 'ZodArray'].includes(props.shape?.type))
|
||||||
|
return { schema: props.shape?.schema }
|
||||||
|
return undefined
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
@ -22,8 +29,8 @@ function isValidConfig(config: any): config is ConfigItem {
|
||||||
:label="label"
|
:label="label"
|
||||||
:required="shape.required"
|
:required="shape.required"
|
||||||
:options="shape.options"
|
:options="shape.options"
|
||||||
:schema="shape.schema"
|
|
||||||
:config="config"
|
:config="config"
|
||||||
|
v-bind="delegatedProps"
|
||||||
>
|
>
|
||||||
<slot />
|
<slot />
|
||||||
</component>
|
</component>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user