import React, { FC } from 'react'; import classNames from 'classnames'; import { TextProps } from './Text'; /** * */ export type PageHeaderDetailBodyProps = TextProps; export const PageHeaderDetailBody: FC = ({ children, ...props }) => typeof children === 'string' ? (
{children}
) : ( <>{children} ); /** * */ export type PageHeaderDetailLabelProps = TextProps; export const PageHeaderDetailLabel: FC = ({ children, ...props }) => typeof children === 'string' ? (
{children}
) : ( <>{children} ); /** * */ export type PageHeaderDetailItemProps = { label?: string; } & React.LiHTMLAttributes; export const PageHeaderDetailItem: FC = (props) => { const { children, label, ...pprops } = props; const manuallyAssembled = !label; return (
  • {!manuallyAssembled ? [ {label}, {children}, ] : [children]}
  • ); }; /** * */ export type PageHeaderDetailProps = React.HTMLAttributes; export const PageHeaderDetail: FC = ({ children, ...props }) => (
      {children}
    ); /** * */ export type PageHeaderHeadingTitleProps = { className?: string; } & React.HTMLAttributes; export const PageHeaderHeadingTitle: FC = ( props ) => { const { className, children } = props; const titleClassNames = classNames( className, 'slds-page-header__title slds-truncate slds-align-middle' ); return (

    {children}

    ); }; /** * */ export type PageHeaderHeadingProps = { info?: string; legend?: string; title?: string | JSX.Element; breadCrumbs?: Array; leftActions?: JSX.Element; figure?: JSX.Element; rightActions?: JSX.Element | Array; }; /** * */ export const PageHeaderHeading: FC = (props) => { const { leftActions, rightActions, title, info, breadCrumbs, figure, legend, } = props; const infoPart = info ? (

    {info}

    ) : null; const titlePart = typeof title === 'string' ? (

    {legend && {legend}} {title}

    ) : (

    {title}

    ); let breadCrumbsPart = null; if (breadCrumbs) { breadCrumbsPart = ( ); } const mediaContent = (
    {titlePart} {leftActions && (
    {leftActions}
    )}
    {!breadCrumbs && infoPart}
    ); const mediaObject = figure ? (
    {React.cloneElement(figure, { className: classNames( (() => { const props: unknown = figure.props; const isPropsObject = typeof props === 'object' && props !== null; if ( isPropsObject && 'className' in props && typeof props.className === 'string' ) { return props.className; } else { return null; } })(), 'slds-page-header__icon' ), 'aria-hidden': 'true', })}
    {mediaContent}
    ) : (
    {mediaContent}
    ); return (
    {breadCrumbsPart} {mediaObject}
    {rightActions && (
    {Array.isArray(rightActions) ? ( rightActions.map((action, index) => (
    {action}
    )) ) : (
    {rightActions}
    )}
    )}
    ); }; /** * */ export type PageHeaderMetaProps = { info?: string; rightActions?: JSX.Element | Array; } & React.HTMLAttributes; export const PageHeaderMeta: FC = ({ info, rightActions, ...props }) => (
    {info &&

    {info}

    }
    {rightActions && (
    {Array.isArray(rightActions) ? ( rightActions.map((action, index) => (
    {action}
    )) ) : (
    {rightActions}
    )}
    )}
    ); /** * */ export type PageHeaderProps = { variant?: 'record-home' | 'related-list'; } & React.HTMLAttributes; export const PageHeader: FC = ({ variant, className, ...props }) => { const pageHeaderClassNames = classNames( 'slds-page-header', variant ? `slds-page-header_${variant}` : null, className ); return (
    {props.children}
    ); };