/*! Strand UI | MIT License | dillingerstaffing.com */ import type { ComponentChildren, JSX } from "preact"; import { forwardRef } from "preact/compat"; import { cx } from "../../internal/index.js"; export interface AlertProps extends Omit, "status" | "title"> { /** Severity; error and warning announce assertively. */ status?: "info" | "success" | "warning" | "error"; /** Show the dismiss control. */ dismissible?: boolean; /** Called when the dismiss control is pressed. */ onDismiss?: () => void; /** Accessible name of the dismiss control. */ dismissLabel?: string; /** Heading set above the message. */ title?: ComponentChildren; /** A control set after the message, such as an undo button. */ action?: ComponentChildren; children?: ComponentChildren; } /** * Contextual feedback banner. * * @example * Saved. */ export const Alert = forwardRef( ({ status = "info", dismissible = false, onDismiss, dismissLabel = "Dismiss", title, action, className = "", children, ...rest }, ref) => { const role = status === "error" || status === "warning" ? "alert" : "status"; const statusLabel = status === "success" ? "COMPLETE" : status.toUpperCase(); return (
{statusLabel}
{title &&
{title}
} {children}
{action &&
{action}
} {dismissible && ( )}
); }, ); Alert.displayName = "Alert";