import React from 'react' import PropTypes from 'prop-types' import slugify from 'slugify' import shortid from 'shortid' import Scroll from '../../components/Scroll' import styles from './Entities.module.scss' import { filterByKindOfProperty } from './utils' const Type = ({ type }) => { let isArray = false if (type.type === 'array') { isArray = true type = type.elementType } const { name, type: typeOfType, typeArguments, id } = type const isInternal = typeOfType === 'reference' && id return (
{isInternal && ( {type.name} )} {!isInternal && {type.name}} {typeArguments && ( < {typeArguments.map((typeArgument, i) => ( {i !== 0 && , } ))} > )} {isArray && []}
) } Type.propTypes = { type: PropTypes.object.isRequired } const PropertyDetails = ({ property }) => { const { type } = property return (
) } PropertyDetails.propTypes = { property: PropTypes.object } const MethodDetails = ({ property }) => { const signature = property.signatures[0] const { parameters, type } = signature return ( <> {parameters && parameters.length && (

Parameters

{parameters.map((parameter) => { const { name, type, flags, comment } = parameter const { isOptional } = flags const description = comment && (comment.text || comment.shortText) return (
{name} {isOptional && ( ? )}

{description}

) })}
)} {type && (

Returns

)} ) } MethodDetails.propTypes = { property: PropTypes.object } const PropertyWrapper = ({ property, sourceUrl, parentAnchor }) => { const { name, kindString, flags, signatures, sources, decorators } = property const { isPublic, isStatic } = flags const signature = signatures && signatures[0] const comment = (signature && signature.comment) || property.comment const { fileName, line } = sources[0] const deprecation = (decorators || []).filter( ({ name }) => name === 'deprecated' )[0] // Assuming deprecated annotation let deprecatedUse, deprecatedSlug if (deprecation) { deprecatedUse = deprecation.arguments.alternative.replace(/('|")/g, '') deprecatedSlug = deprecatedUse && slugify(deprecatedUse.replace('.', '-')) } const sourceLink = `${sourceUrl}${fileName}#L${line}` return (

{name}

{kindString}
{isStatic &&
static
} {!isPublic && (
private
)} {comment && !deprecation && (
{comment.text || comment.shortText}
)} {deprecation && (
Deprecated: use{' '} {deprecatedUse} {' '} instead
)} {!deprecation && (() => { switch (kindString) { case 'Method': return case 'Property': return } })()} {fileName && ( {`${fileName}#L${line}`} )}
) } PropertyWrapper.propTypes = { property: PropTypes.object, sourceUrl: PropTypes.string, parentAnchor: PropTypes.string } const Entities = ({ entities, sourceUrl }) => entities.map(({ name, comment, children }) => (

{name}

{comment && (
{comment.text || comment.shortText}
)} {children && children .filter(filterByKindOfProperty) .map((property) => ( ))}
)) Entities.propTypes = { entities: PropTypes.array.isRequired, sourceUrl: PropTypes.string } export default Entities