/* * SPDX-License-Identifier: Apache-2.0 * * The OpenSearch Contributors require contributions made to * this file be licensed under the Apache-2.0 license or a * compatible open source license. * * Modifications Copyright OpenSearch Contributors. See * GitHub history for details. */ import React from 'react'; import { //@ts-ignore EuiTitleSize, EuiFlexGroup, EuiFlexItem, EuiHorizontalRule, EuiPanel, EuiTitle, EuiSpacer, } from '@elastic/eui'; import { isEmpty, get } from 'lodash'; type ContentPanelProps = { // keep title string part for backwards compatibility // might need to refactor code and // deprecate support for 'string' in the near future title: string | React.ReactNode | React.ReactNode[]; titleSize?: EuiTitleSize; subTitle?: React.ReactNode | React.ReactNode[]; badgeLabel?: string; bodyStyles?: React.CSSProperties; panelStyles?: React.CSSProperties; horizontalRuleClassName?: string; titleClassName?: string; titleContainerStyles?: React.CSSProperties; actions?: React.ReactNode | React.ReactNode[]; children: React.ReactNode | React.ReactNode[]; contentPanelClassName?: string; hideBody?: boolean; titleDataTestSubj?: string; }; const ContentPanel = (props: ContentPanelProps) => { const titleDataTestSubj = get( props, 'titleDataTestSubj', 'contentPanelTitle' ); return ( {typeof props.title === 'string' ? (

{props.title}

) : ( {Array.isArray(props.title) ? ( props.title.map( (titleComponent: React.ReactNode, idx: number) => ( {titleComponent} ) ) ) : ( {props.title} )} )} {Array.isArray(props.subTitle) ? ( props.subTitle.map( (subTitleComponent: React.ReactNode, idx: number) => ( {subTitleComponent} ) ) ) : ( {props.subTitle} )}
{Array.isArray(props.actions) ? ( props.actions.map((action: React.ReactNode, idx: number) => ( {action} )) ) : ( {props.actions} )}
{!isEmpty(props.actions) ? : null} {props.title != '' && props.hideBody !== true ? (
{props.children}
) : null}
); }; export default ContentPanel;