import { Documentation } from "react-docgen" import { Suspense } from "react" import { Spinner } from "@medusajs/icons" import { PropTable } from "./props-table" import { Container, clx } from "@medusajs/ui" import { Feedback } from "./feedback" import { MarkdownContent } from "docs-ui" import { components } from "./mdx-components" type ComponentReferenceProps = { mainComponent: string componentsToShow?: string[] specsSrc?: string } const ComponentReference = ({ mainComponent, componentsToShow = [mainComponent], specsSrc, }: ComponentReferenceProps) => { if (!specsSrc) { return <> } const specs = JSON.parse(specsSrc) as Documentation[] return ( <> {componentsToShow.map((component, index) => { const componentSpec = specs?.find( (spec) => spec.displayName === component ) const hasProps = componentSpec?.props && Object.keys(componentSpec.props).length > 0 return ( } key={index} > {componentSpec && ( <> {componentsToShow.length > 1 && (

{componentSpec.displayName || component}

)} {componentSpec.description && ( {componentSpec.description} )} {hasProps && ( <> } > )} )}
) })} ) } export { ComponentReference }