import React from 'react'; import { InlineCode } from '~/components/base/code'; import { B, P } from '~/components/base/paragraph'; import { H2, H3Code } from '~/components/plugins/Headings'; import { GeneratedData, PropsDefinitionData } from '~/components/plugins/api/APIDataTypes'; import APISectionProps from '~/components/plugins/api/APISectionProps'; import { CommentTextBlock, resolveTypeName } from '~/components/plugins/api/APISectionUtils'; export type APISectionComponentsProps = { data: GeneratedData[]; componentsProps: PropsDefinitionData[]; }; const renderComponent = ( { name, comment, type, extendedTypes }: GeneratedData, componentsProps?: PropsDefinitionData[] ): JSX.Element => { const finalType = extendedTypes?.length ? extendedTypes[0] : type; return (
{name} {finalType && (

Type: {resolveTypeName(finalType)}

)} {componentsProps && componentsProps.length ? ( ) : null}
); }; const APISectionComponents = ({ data, componentsProps }: APISectionComponentsProps) => data?.length ? ( <>

Components

{data.map(component => renderComponent( component, componentsProps.filter(cp => cp.name.includes(component.name)) ) )} ) : null; export default APISectionComponents;