import ExternalLink from "../ExternalLink"; import docs from "@aws-amplify/ui-components/dist/docs"; import {tableGeneratorMap} from "../TableGenerator"; import {WebComponentProps} from "../../utils/ui-component-props.types"; import {ATTR_HEADER, CSS_HEADER, SLOTS_HEADER} from "../../constants/strings"; export const headerNames: Record = { attr: ATTR_HEADER, css: CSS_HEADER, slots: SLOTS_HEADER, }; export default function UiComponentProps({ tag, useTableHeaders = false, propType = "attr", }) { const component = docs.components.find((component) => component.tag === tag); if (!component || !component.tag || propsAreEmpty({propType, component})) { return null; } const tableGenerator = tableGeneratorMap[propType]; return (
{tableGenerator(component)}
); } function Header({useTableHeaders = false, propType = "attr", component}) { const sectionId = `props-${propType}-${component?.tag}`; return useTableHeaders ? (

{headerNames[propType]}

) : (

{headerNames[propType]}

); } function Content({propType, component}) { if (propType === "attr") { return (

{component?.tag}  provides the following properties to configure the component.

); } else if (propType === "css") { return (

{component?.tag}  provides the following  css properties  to modify the style at component level.

); } else if (propType === "slots") { return (

{component?.tag}  provides the following slots based off of the  Web Components slot  element.

); } } function propsAreEmpty({propType, component}) { return ( (propType === "attr" && component?.props.length === 0) || (propType === "css" && component?.styles.length === 0) || (propType === "slots" && component?.slots.length === 0) ); } export function propsAreEmptyByTag({propType, componentTag}) { const component = docs.components.find( (component) => component.tag === componentTag, ); if (!component || !component.tag || propsAreEmpty({propType, component})) { return true; } return false; }