// @flow strict import * as React from 'react'; import classify from '../../utils/classify'; import { ForbiddenImage, NotFoundImage, ServerErrorImage, UnauthorizedImage, } from './ErrorImages'; import css from './ErrorMessage.module.css'; type ClassNames = $ReadOnly<{ wrapper?: string, image?: string, heading?: string, title?: string, description?: string, children?: string, }>; export type ErrorMessageProps = { classNames?: ClassNames, children?: React.Node, imageVariant?: 'unauthorized' | 'forbidden' | 'notFound' | 'serverError', title?: React.Node, description?: React.Node, heading?: React.Node, customImageUrl?: string, ... }; export const ErrorMessage: React$AbstractComponent< ErrorMessageProps, HTMLDivElement, > = React.forwardRef( ( { classNames, children, imageVariant, title, description, customImageUrl, heading, ...props }: ErrorMessageProps, ref, ): React.Node => (
{!!imageVariant && !customImageUrl && (
{imageVariant === 'unauthorized' && } {imageVariant === 'forbidden' && } {imageVariant === 'notFound' && } {imageVariant === 'serverError' && }
)} {customImageUrl && ( Empty State )} {!!heading && (
{heading}
)} {!!title && (
{title}
)} {!!description && (
{description}
)} {!!children && (
{children}
)}
), );