import React from 'react'; import { InlineCode } from '~/components/base/code'; import { B } from '~/components/base/paragraph'; import { H2, H3Code } from '~/components/plugins/Headings'; import { CommentData, InterfaceDefinitionData, InterfaceValueData, MethodSignatureData, } from '~/components/plugins/api/APIDataTypes'; import { CommentTextBlock, mdInlineRenderers, renderFlags, renderParam, renderTypeOrSignatureType, resolveTypeName, } from '~/components/plugins/api/APISectionUtils'; export type APISectionInterfacesProps = { data: InterfaceDefinitionData[]; }; const renderInterfaceComment = (comment?: CommentData, signatures?: MethodSignatureData[]) => { if (signatures && signatures.length) { const { type, parameters, comment: signatureComment } = signatures[0]; return ( <> {parameters.map(param => renderParam(param))} Returns: {resolveTypeName(type)} {signatureComment && ( )} ); } else { return comment ? : '-'; } }; const renderInterfacePropertyRow = ({ name, flags, type, comment, signatures, }: InterfaceValueData): JSX.Element => ( {name} {signatures && signatures.length ? '()' : ''} {renderFlags(flags)} {renderTypeOrSignatureType(type, signatures)} {renderInterfaceComment(comment, signatures)} ); const renderInterface = ({ name, children, comment, }: InterfaceDefinitionData): JSX.Element | null => children ? (
{name} {children.map(renderInterfacePropertyRow)}
Name Type Description
) : null; const APISectionInterfaces: React.FC = ({ data }) => data?.length ? ( <>

Interfaces

{data.map(renderInterface)} ) : null; export default APISectionInterfaces;