import type { ReactElement } from 'react'; import React from 'react'; import type { ImageProps as RNImageProps, StyleProp, ViewStyle, } from 'react-native'; import type { ImageProps } from '../../Image'; import type { IllustrationName } from '../../Illustration'; import Illustration from '../../Illustration'; import { StyledDescription, StyledEmptyImageContainer, StyledTitle, StyledWrapper, } from './StyledEmpty'; interface EmptyProps { /** * Image to be displayed. * @deprecated The `image` prop is deprecated and will be removed in the next major version. Use the `icon` prop instead. */ image?: ReactElement; /** * Empty's title. */ title: string | ReactElement; /** * Empty's description. */ description?: string; /** * Empty's variant. * @deprecated The `variant` prop is deprecated and will be removed in the next major version. Only light mode will be supported. */ variant?: 'light' | 'dark'; /** * Additional style. */ style?: StyleProp; /** * Testing id of the component. */ testID?: string; /** * Status icon to be displayed, this will replace the deprecated image prop. */ icon?: IllustrationName; } const renderImageOrIcon = ({ image, icon, }: { image?: ReactElement; icon?: IllustrationName; }) => { if (icon) { return ( ); } if (image) { return ( {image} ); } return null; }; const Empty = ({ image, title, description, style, testID, variant = 'light', icon, }: EmptyProps): ReactElement => ( {renderImageOrIcon({ image, icon })} {typeof title === 'string' ? ( {title} ) : ( title )} {!!description && ( {description} )} ); export default Empty;