diff --git a/packages/core-components/api-report.md b/packages/core-components/api-report.md index 495150e54b..7df74ee892 100644 --- a/packages/core-components/api-report.md +++ b/packages/core-components/api-report.md @@ -120,10 +120,10 @@ export type BottomLinkProps = { onClick?: (event: React_2.MouseEvent) => void; }; -// Warning: (ae-forgotten-export) The symbol "Props_19" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "Props_18" needs to be exported by the entry point index.d.ts // // @public -export function Breadcrumbs(props: Props_19): React_2.JSX.Element; +export function Breadcrumbs(props: Props_18): React_2.JSX.Element; // @public (undocumented) export type BreadcrumbsClickableTextClassKey = 'root'; @@ -177,11 +177,11 @@ export interface CodeSnippetProps { text: string; } -// Warning: (ae-forgotten-export) The symbol "Props_13" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "Props_12" needs to be exported by the entry point index.d.ts // // @public export function Content( - props: PropsWithChildren, + props: PropsWithChildren, ): React_2.JSX.Element; // Warning: (ae-forgotten-export) The symbol "ContentHeaderProps" needs to be exported by the entry point index.d.ts @@ -454,10 +454,10 @@ export function GitHubIcon(props: IconComponentProps): React_2.JSX.Element; // @public (undocumented) export function GroupIcon(props: IconComponentProps): React_2.JSX.Element; -// Warning: (ae-forgotten-export) The symbol "Props_14" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "Props_13" needs to be exported by the entry point index.d.ts // // @public -export function Header(props: PropsWithChildren): React_2.JSX.Element; +export function Header(props: PropsWithChildren): React_2.JSX.Element; // @public (undocumented) export function HeaderActionMenu( @@ -564,10 +564,10 @@ export type IconLinkVerticalProps = { // @public (undocumented) export type IdentityProviders = ('guest' | 'custom' | SignInProviderConfig)[]; -// Warning: (ae-forgotten-export) The symbol "Props_15" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "Props_14" needs to be exported by the entry point index.d.ts // // @public -export function InfoCard(props: Props_15): JSX.Element; +export function InfoCard(props: Props_14): JSX.Element; // @public (undocumented) export type InfoCardClassKey = @@ -795,11 +795,11 @@ export function OverflowTooltip(props: Props_9): React_2.JSX.Element; // @public (undocumented) export type OverflowTooltipClassKey = 'container'; -// Warning: (ae-forgotten-export) The symbol "Props_16" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "Props_15" needs to be exported by the entry point index.d.ts // Warning: (ae-missing-release-tag) "Page" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export function Page(props: Props_16): React_2.JSX.Element; +export function Page(props: Props_15): React_2.JSX.Element; // Warning: (ae-missing-release-tag) "PageClassKey" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) // @@ -1125,11 +1125,11 @@ export type SidebarSubmenuProps = { children: ReactNode; }; -// Warning: (ae-forgotten-export) The symbol "Props_17" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "Props_16" needs to be exported by the entry point index.d.ts // Warning: (ae-missing-release-tag) "SignInPage" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) -export function SignInPage(props: Props_17): React_2.JSX.Element; +export function SignInPage(props: Props_16): React_2.JSX.Element; // Warning: (ae-missing-release-tag) "SignInPageClassKey" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) // @@ -1222,11 +1222,10 @@ export function StatusWarning( props: PropsWithChildren<{}>, ): React_2.JSX.Element; -// Warning: (ae-forgotten-export) The symbol "Props_12" needs to be exported by the entry point index.d.ts -// Warning: (ae-missing-release-tag) "StructuredMetadataTable" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) -// // @public (undocumented) -export function StructuredMetadataTable(props: Props_12): React_2.JSX.Element; +export function StructuredMetadataTable( + props: StructuredMetadataTableProps, +): React_2.JSX.Element; // Warning: (ae-missing-release-tag) "StructuredMetadataTableListClassKey" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) // @@ -1238,6 +1237,20 @@ export type StructuredMetadataTableListClassKey = 'root'; // @public (undocumented) export type StructuredMetadataTableNestedListClassKey = 'root'; +// @public (undocumented) +export interface StructuredMetadataTableProps { + // (undocumented) + dense?: boolean; + // (undocumented) + metadata: { + [key: string]: any; + }; + // (undocumented) + options?: { + titleFormat?: (key: string) => string; + }; +} + // @public (undocumented) export type SubmenuOptions = { drawerWidthClosed?: number; @@ -1305,12 +1318,12 @@ export type Tab = { >; }; -// Warning: (ae-forgotten-export) The symbol "Props_18" needs to be exported by the entry point index.d.ts +// Warning: (ae-forgotten-export) The symbol "Props_17" needs to be exported by the entry point index.d.ts // Warning: (ae-missing-release-tag) "TabbedCard" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) export function TabbedCard( - props: PropsWithChildren, + props: PropsWithChildren, ): React_2.JSX.Element; // Warning: (ae-missing-release-tag) "TabbedCardClassKey" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) diff --git a/packages/core-components/src/components/StructuredMetadataTable/StructuredMetadataTable.tsx b/packages/core-components/src/components/StructuredMetadataTable/StructuredMetadataTable.tsx index 08c00da772..3099edf9d8 100644 --- a/packages/core-components/src/components/StructuredMetadataTable/StructuredMetadataTable.tsx +++ b/packages/core-components/src/components/StructuredMetadataTable/StructuredMetadataTable.tsx @@ -85,11 +85,10 @@ function renderMap( ) { const values = Object.keys(map).map(key => { const value = toValue(map[key], options, true); - const fmtKey = options.titleFormat?.(key) ?? startCase(key); return ( - {`${fmtKey}: `} + {`${options.titleFormat(key)}: `} {value} @@ -144,7 +143,7 @@ const TableItem = ({ options: Options; }) => { return ( - + ); @@ -156,25 +155,29 @@ function mapToItems(info: { [key: string]: string }, options: Options) { )); } -interface Options { - /** - * Function to format the keys from the `metadata` object. Defaults to - * startCase from the lodash library. - * @param key A key within the `metadata` - * @returns Formatted key - * @see {@link startCase} - */ - titleFormat?: (key: string) => string; -} - -type Props = { +/** @public */ +export interface StructuredMetadataTableProps { metadata: { [key: string]: any }; dense?: boolean; - options?: Options; -}; + options?: { + /** + * Function to format the keys from the `metadata` object. Defaults to + * startCase from the lodash library. + * @param key - A key within the `metadata` + * @returns Formatted key + */ + titleFormat?: (key: string) => string; + }; +} -export function StructuredMetadataTable(props: Props) { - const { metadata, dense = true, options } = props; - const metadataItems = mapToItems(metadata, options || {}); +type Options = Required>; + +/** @public */ +export function StructuredMetadataTable(props: StructuredMetadataTableProps) { + const { metadata, dense = true, options = {} } = props; + const metadataItems = mapToItems(metadata, { + titleFormat: startCase, + ...options, + }); return {metadataItems}; } diff --git a/packages/core-components/src/components/StructuredMetadataTable/index.tsx b/packages/core-components/src/components/StructuredMetadataTable/index.tsx index 855df31e2f..e45b4a862f 100644 --- a/packages/core-components/src/components/StructuredMetadataTable/index.tsx +++ b/packages/core-components/src/components/StructuredMetadataTable/index.tsx @@ -20,7 +20,10 @@ export type { MetadataTableListClassKey, MetadataTableListItemClassKey, } from './MetadataTable'; -export { StructuredMetadataTable } from './StructuredMetadataTable'; +export { + StructuredMetadataTable, + type StructuredMetadataTableProps, +} from './StructuredMetadataTable'; export type { StructuredMetadataTableListClassKey, StructuredMetadataTableNestedListClassKey,