mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-22 16:00:39 +01:00
docs(ComponentProps): display schema default in description
This commit is contained in:
@@ -18,7 +18,20 @@ function getSchemaProps(schema: PropertyMeta['schema']) {
|
||||
return (Array.isArray(schema.schema) ? schema.schema : Object.values(schema.schema)).flatMap(getSchemaProps)
|
||||
}
|
||||
|
||||
const schemaProps = computed(() => getSchemaProps(props.prop.schema))
|
||||
const schemaProps = computed(() => {
|
||||
return getSchemaProps(props.prop.schema).map((prop) => {
|
||||
const defaultValue = prop.default ?? prop.tags?.find(tag => tag.name === 'defaultValue')?.text
|
||||
let description = prop.description
|
||||
if (defaultValue) {
|
||||
description = description ? `${description} Defaults to \`${defaultValue}\`{lang="ts-type"}.` : `Defaults to \`${defaultValue}\`{lang="ts-type"}.`
|
||||
}
|
||||
|
||||
return {
|
||||
...prop,
|
||||
description
|
||||
}
|
||||
})
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
Reference in New Issue
Block a user