docs(ComponentProps): handle ignore in schema

This commit is contained in:
Benjamin Canac
2024-08-06 11:20:18 +02:00
parent 24f24e9d8e
commit 68afba8f3c
2 changed files with 3 additions and 2 deletions

View File

@@ -77,7 +77,7 @@ const metaProps: ComputedRef<ComponentMeta['props']> = computed(() => {
<MDC v-if="prop.description" :value="prop.description" class="text-gray-600 dark:text-gray-300 mt-1" /> <MDC v-if="prop.description" :value="prop.description" class="text-gray-600 dark:text-gray-300 mt-1" />
<ComponentPropsSchema v-if="prop.schema" :prop="prop" /> <ComponentPropsSchema v-if="prop.schema" :prop="prop" :ignore="ignore" />
</ProseTd> </ProseTd>
</ProseTr> </ProseTr>
</ProseTbody> </ProseTbody>

View File

@@ -3,6 +3,7 @@ import type { PropertyMeta } from 'vue-component-meta'
const props = defineProps<{ const props = defineProps<{
prop: PropertyMeta prop: PropertyMeta
ignore?: string[]
}>() }>()
function getSchemaProps(schema: PropertyMeta['schema']) { function getSchemaProps(schema: PropertyMeta['schema']) {
@@ -11,7 +12,7 @@ function getSchemaProps(schema: PropertyMeta['schema']) {
} }
if (schema.kind === 'object') { if (schema.kind === 'object') {
return Object.values(schema.schema) return Object.values(schema.schema).filter(prop => !props.ignore?.includes(prop.name))
} }
return (Array.isArray(schema.schema) ? schema.schema : Object.values(schema.schema)).flatMap(getSchemaProps) return (Array.isArray(schema.schema) ? schema.schema : Object.values(schema.schema)).flatMap(getSchemaProps)