import React from "react"; import { CLASSPREFIX as eccgui } from "../../configuration/constants"; import { PropertyValuePair } from "./PropertyValuePair"; export interface PropertyValueListProps extends React.HTMLAttributes { /** * Only use one single column and put property label and value below each other. * This property is forward to direct `PropertyValuePair` children. */ singleColumn?: boolean; } /** * Need to be used to wrap one or more `PropertyValuePair` elements. */ export const PropertyValueList = ({ className = "", children, singleColumn = false, ...otherProps }: PropertyValueListProps) => { const alteredChildren = singleColumn ? React.Children.map(children, (child) => { const originalChild = child as React.ReactElement; if (originalChild && originalChild.type && originalChild.type === PropertyValuePair) { return React.cloneElement(originalChild, { singleColumn: true }); } return child; }) : children; return (
{alteredChildren}
); }; export default PropertyValueList;