import { css } from '@emotion/react'; import React from 'react'; import { InlineCode } from '~/components/base/code'; import { UL, LI } from '~/components/base/list'; import { B, P } from '~/components/base/paragraph'; import { H2, H4, H3Code } from '~/components/plugins/Headings'; import { ClassDefinitionData, CommentData, GeneratedData, MethodSignatureData, PropData, } from '~/components/plugins/api/APIDataTypes'; import { CommentTextBlock, listParams, mdInlineComponents, renderParam, renderTypeOrSignatureType, resolveTypeName, STYLES_OPTIONAL, TypeDocKind, } from '~/components/plugins/api/APISectionUtils'; export type APISectionClassesProps = { data: GeneratedData[]; }; const renderPropertyComment = (comment?: CommentData, signatures?: MethodSignatureData[]) => { if (signatures && signatures.length) { const { type, parameters, comment: signatureComment } = signatures[0]; return ( <> {signatureComment && ( )} ); } else { return comment ? : null; } }; const renderProperty = ({ name, signatures, flags, type, comment }: PropData) => (
  • {name} {signatures && signatures.length ? `(${listParams(signatures[0].parameters)})` : null} {!signatures ? <> {renderTypeOrSignatureType(type, signatures)} : null} {flags?.isOptional ?  • optional : null} {!signatures ?
    : null} {renderPropertyComment(comment, signatures)}
  • ); const renderClass = ({ name, comment, type, extendedTypes, children, }: ClassDefinitionData): JSX.Element => { const properties = children?.filter( child => child.kind === TypeDocKind.Property && !child.overwrites ); const methods = children?.filter(child => child.kind === TypeDocKind.Method && !child.overwrites); return (
    {name} {extendedTypes?.length && (

    Type: {type ? {resolveTypeName(type)} : 'Class'} extends {resolveTypeName(extendedTypes[0])}

    )} {properties?.length ? ( <>

    Properties:

      {properties.map(child => renderProperty(child))}
    ) : null} {methods?.length ? ( <>

    Methods:

      {methods.map(child => renderProperty(child))}
    ) : null}
    ); }; const APISectionClasses = ({ data }: APISectionClassesProps) => data?.length ? ( <>

    Classes

    {data.map(cls => renderClass(cls))} ) : null; export default APISectionClasses;