import { css } from '@emotion/react'; import React from 'react'; import { InlineCode } from '~/components/base/code'; import { H4 } from '~/components/base/headings'; import { LI, UL } from '~/components/base/list'; import { P } from '~/components/base/paragraph'; import { H2, H3, H3Code } from '~/components/plugins/Headings'; import { CommentTagData, DefaultPropsDefinitionData, PropData, PropsDefinitionData, TypeDefinitionData, } from '~/components/plugins/api/APIDataTypes'; import { CommentTextBlock, getCommentOrSignatureComment, renderTypeOrSignatureType, resolveTypeName, STYLES_SECONDARY, } from '~/components/plugins/api/APISectionUtils'; export type APISectionPropsProps = { data: PropsDefinitionData[]; defaultProps?: DefaultPropsDefinitionData; header?: string; }; const UNKNOWN_VALUE = '...'; const PROP_LIST_ELEMENT_STYLE = css` padding: 0; `; const extractDefaultPropValue = ( { comment, name }: PropData, defaultProps?: DefaultPropsDefinitionData ): string | undefined => { const annotationDefault = comment?.tags?.filter((tag: CommentTagData) => tag.tag === 'default'); if (annotationDefault?.length) { return annotationDefault[0].text; } return defaultProps?.type?.declaration?.children?.filter( (defaultProp: PropData) => defaultProp.name === name )[0]?.defaultValue; }; const renderInheritedProp = (ip: TypeDefinitionData) => { return (
{flags?.isOptional && Optional • }
Type: {renderTypeOrSignatureType(type, signatures, true)}
{defaultValue && defaultValue !== UNKNOWN_VALUE ? (
• Default:{' '}