import type { HTMLAttributes } from 'react' import React, { forwardRef, useCallback } from 'react' import { Icon, IconButton, Link, type LinkProps } from '../../' import type { MouseEvent, ReactNode } from 'react' export interface AlertProps extends Omit, 'role'> { /** * ID to find this component in testing tools (e.g.: cypress, * testing-library, and jest). */ testId?: string /** * Icon component for additional customization. */ icon?: ReactNode /** * Enables dismissible feature. */ dismissible?: boolean /** * Extends all Link Props. */ link?: LinkProps /** * Function called when dismiss button is clicked. */ onClose?: (event: MouseEvent) => void } const Alert = forwardRef(function Alert( { testId = 'fs-alert', children, icon, dismissible, link, onClose, ...otherProps }, ref ) { const handleClose = useCallback( (event: MouseEvent) => { if (event.defaultPrevented) { return } onClose?.(event) }, [onClose] ) return (
{!!icon && icon}

{children}

{link && } {dismissible && ( } onClick={handleClose} /> )}
) }) export default Alert