import * as React from "react"; import type { CardHeaderOwnProps, PolymorphicWithRef } from "../types"; import CardHeaderWrapper from "./CardHeaderWrapper"; import { CardHeaderAvatar } from "../CardHeaderAvatar"; import { CardHeaderAction } from "../CardHeaderAction"; import { BodyTypography } from "../BodyTypography"; import { TitleTypography } from "../TitleTypography"; type CardHeaderProps = PolymorphicWithRef< T, CardHeaderOwnProps & { renderHeadline: ( Headline: typeof TitleTypography & { Headline: typeof TitleTypography; Subhead: typeof BodyTypography; }, headlineProps: React.ComponentProps, subheadProps: React.ComponentProps ) => React.ReactElement; renderSubhead?: ( Subhead: typeof BodyTypography, props: React.ComponentProps ) => React.ReactElement; renderAction?: ( Action: typeof CardHeaderAction, props: React.ComponentProps ) => React.ReactElement; renderAvatar?: ( Avatar: typeof CardHeaderAvatar, props: React.ComponentProps ) => React.ReactElement; } >; type CardHeaderElement = ( props: CardHeaderProps ) => React.ReactElement>; const CardHeader: CardHeaderElement = React.forwardRef( ( props: CardHeaderProps, innerRef: typeof props.ref ) => { const { component, children, renderHeadline, renderSubhead, renderAction, renderAvatar, ...rest } = props; return ( {renderAvatar && renderAvatar(CardHeaderAvatar, {})} {renderHeadline && renderHeadline( Object.assign(TitleTypography, { Headline: TitleTypography, Subhead: BodyTypography, }), { size: "medium", }, { size: "medium", } )} {renderAction && renderAction(CardHeaderAction, {})} ); } ); export default CardHeader;