import cn from "classnames"; import React, { forwardRef, useContext } from "react"; import PropTypes from "prop-types"; import closeIcon from "!!svg-sprite-loader!@cloudbees/honeyui-icons/svg/clear.svg"; import collapseIcon from "!!svg-sprite-loader!@cloudbees/honeyui-icons/svg/fullscreen_exit.svg"; import expandIcon from "!!svg-sprite-loader!@cloudbees/honeyui-icons/svg/fullscreen.svg"; import questionIcon from "!!svg-sprite-loader!@cloudbees/honeyui-icons/svg/info.svg"; import { Icon, Popover, PopoverBody } from "../"; import DialogContext from "./dialog-context"; export interface IDialogHeaderProps { ["data-testid"]?: string; className?: string; expandable?: boolean; help?: string; subTitle?: string; title: string; } const DialogHeader: React.FC = forwardRef( (props, ref: React.Ref) => { const { children, className, expandable, help, subTitle, title } = props; const dataTestId = props["data-testid"] || "honey-ui-dialog-header"; const { onClose, changeDialogExpanded, dialogExpanded } = useContext(DialogContext); const isExtraHeader = children || subTitle; return ( <>

{title}

{expandable && ( changeDialogExpanded(!dialogExpanded)} size="md" // TODO: use i18n text title={dialogExpanded ? "Collapse" : "Expand"} viewBox={dialogExpanded ? collapseIcon.viewBox : expandIcon.viewBox} /> )} {help && ( } className="w-100" placement="bottom-end" > {help} )}
{(children || subTitle) && (subTitle ? (
{subTitle}
{children}
) : ( children ))} ); } ); DialogHeader.displayName = "DialogHeader"; DialogHeader.propTypes = { className: PropTypes.string, expandable: PropTypes.bool, help: PropTypes.string, subTitle: PropTypes.string, title: PropTypes.string.isRequired }; export default DialogHeader;