import * as React from 'react'; import clsx from 'clsx'; /** * Derived HTML element of the {@link KeyValueTable} component. */ export type KeyValueTableDerivedElement = HTMLDListElement; /** * Individual property of the {@link KeyValueTable} component. */ export interface KeyValueTableProperty { /** * Key of the property. */ key: string; /** * Class name of the property. */ className?: string; /** * Value of the property. */ valueProps?: React.HTMLProps; } /** * Props of the {@link KeyValueTable} component. */ export interface KeyValueTableProps extends Omit, 'children'> { /** * Should the keys be hidden? */ hiddenKeys?: boolean; /** * Properties displayed on the component. */ properties?: (KeyValueTableProperty | boolean | null | undefined)[]; } /** * Component for displaying key-value pairs. */ export const KeyValueTable = React.forwardRef(( { hiddenKeys = false, properties = [], className, style, ...etcProps }, forwardedRef, ) => (
{properties.map((property) => typeof property === 'object' && property && (
{property.key}
{property.valueProps?.children}
))}
)); KeyValueTable.displayName = 'KeyValueTable'; KeyValueTable.defaultProps = { hiddenKeys: false, properties: [], };