import { Card, CardContent, CardHeader, Divider, Typography } from '@mui/material'; import { SxProps, lighten, useTheme } from '@mui/material/styles'; import { forwardRef } from 'react'; const headerSX = { p: 2.5, '& .MuiCardHeader-action': { m: '0px auto', alignSelf: 'center' } }; type MainCardProps = { /** * Indicates if the card must be rendered with a border. */ border?: boolean; /** * Indicates if the card must be rendered with a box shadow. */ boxShadow?: boolean; /** * The content of the card. */ children?: React.ReactNode | React.ReactNode[]; /** * The subheader of the card. */ subheader?: React.ReactNode | string; /** * Indicates if the card must be rendered with a content. */ content?: boolean; /** * The class name of the content. */ contentClass?: string; /** * The style of the content. */ contentSX?: SxProps | any; /** * Indicates if the title of the card must be rendered with a dark color. */ darkTitle?: boolean; /** * Indicates if the card must be rendered with a divider. */ divider?: boolean; /** * The elevation of the card. */ elevation?: number; /** * The secondary content of the card. */ secondary?: React.ReactNode | string | object; /** * The shadow of the card. * @example '0px 0px 0px 0px rgba(0,0,0,0.2)' */ shadow?: string; /** * The style of the card. */ sx?: SxProps | any; /** * The title of the card. */ title?: React.ReactNode | string | object; /** * Indicates if the card must be rendered as a modal. */ modal?: boolean; /** * The color of the card. */ color?: 'default' | 'primary' | 'secondary'; }; const MainCard = forwardRef( ( { border = true, boxShadow, children, subheader, content = true, contentSX = {}, darkTitle, divider = true, elevation, secondary, shadow, sx = {}, title, modal = false, color = 'default', ...others }: MainCardProps, ref ) => { const theme = useTheme() as any; boxShadow = theme.palette.mode === 'dark' ? boxShadow || true : boxShadow; return ( /** @ts-ignore */ {!darkTitle && title ? ( // @ts-ignore ) : null} {darkTitle && title ? ( {title as any}} action={secondary as any} /> ) : null} {title && divider ? : null} {content ? {children} : null} {!content && children} ); } ); export { MainCard }; export type { MainCardProps };