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 { CommentData, CommentTagData, InterfaceDefinitionData, MethodSignatureData, PropData, } from '~/components/plugins/api/APIDataTypes'; import { CommentTextBlock, getTagData, mdInlineComponents, renderFlags, renderParam, renderTypeOrSignatureType, resolveTypeName, } from '~/components/plugins/api/APISectionUtils'; import { Cell, HeaderCell, Row, Table, TableHead } from '~/ui/components/Table'; export type APISectionInterfacesProps = { data: InterfaceDefinitionData[]; }; const renderDefaultValue = (defaultValue?: CommentTagData) => defaultValue ? ( <>

Default: {defaultValue.text} ) : null; const renderInterfaceComment = (comment?: CommentData, signatures?: MethodSignatureData[]) => { if (signatures && signatures.length) { const { type, parameters, comment: signatureComment } = signatures[0]; const defaultValue = getTagData('default', signatureComment); return ( <> {parameters?.length ? parameters.map(param => renderParam(param)) : null} Returns: {resolveTypeName(type)} {signatureComment && ( <>
)} ); } else { const defaultValue = getTagData('default', comment); return comment ? ( ) : ( '-' ); } }; const renderInterfacePropertyRow = ({ name, flags, type, comment, signatures, }: PropData): JSX.Element => ( {name} {signatures && signatures.length ? '()' : ''} {renderFlags(flags)} {renderTypeOrSignatureType(type, signatures)} {renderInterfaceComment(comment, signatures)} ); const renderInterface = ({ name, children, comment, extendedTypes, }: InterfaceDefinitionData): JSX.Element | null => children ? (
{name} {extendedTypes?.length && (

Extends: {extendedTypes.map(extendedType => ( {resolveTypeName(extendedType)} ))}

)} Name Type Description {children.filter(child => !child?.inheritedFrom).map(renderInterfacePropertyRow)}
) : null; const APISectionInterfaces = ({ data }: APISectionInterfacesProps) => data?.length ? ( <>

Interfaces

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