diff --git a/packages/docz/src/components/PropsTable.tsx b/packages/docz/src/components/PropsTable.tsx index 91745e3b7..5e7e082d1 100644 --- a/packages/docz/src/components/PropsTable.tsx +++ b/packages/docz/src/components/PropsTable.tsx @@ -26,6 +26,7 @@ export interface PropType { name: string value?: any raw?: any + computed?: boolean } export interface FlowType extends PropType { @@ -33,6 +34,7 @@ export interface FlowType extends PropType { name: string raw: string type?: string + computed?: boolean signature?: { arguments: FlowTypeArgs[] return: { @@ -73,12 +75,13 @@ export type TooltipComponent = React.ComponentType<{ const getPropType = (prop: Prop, Tooltip?: TooltipComponent) => { const propName = prop.flowType ? prop.flowType.name : prop.type.name - const isEnum = propName.startsWith('"') + const isEnum = propName.startsWith('"') || propName === 'enum' const name = capitalize(isEnum ? 'enum' : propName) const value = prop.type && prop.type.value if (!name) return null if (!Tooltip) return name + if (isEnum && typeof value === 'string') return name if (!prop.flowType && !isEnum && !value) return name if (prop.flowType && !prop.flowType.elements) return name diff --git a/packages/docz/src/utils/humanize-prop.ts b/packages/docz/src/utils/humanize-prop.ts index ed42fd9ea..ef624927a 100644 --- a/packages/docz/src/utils/humanize-prop.ts +++ b/packages/docz/src/utils/humanize-prop.ts @@ -9,6 +9,7 @@ const getTypeStr = (type: PropType | FlowType): any => { case 'instanceof': return `Class(${type.value})` case 'enum': + if (type.computed) return type.value return type.value ? type.value.map((v: any) => `${v.value}`).join(' │ ') : type.raw