import React from "react"; import { Definitions as IntentStates, IntentTypes } from "../../common/Intent"; import SimpleDialog, { SimpleDialogProps } from "./SimpleDialog"; export interface AlertDialogProps extends Omit { /** * set to true if alert dialog displays a success message */ success?: boolean; /** * set to true if alert dialog displays a warning */ warning?: boolean; /** * set to true if alert dialog displays a strong message about errors or disruptive actions */ danger?: boolean; } /** * Special element to display alert notification in modal dialogs. * Inherits all properties from `SimpleDialog`, except `intent` and `role`. * If `title`, `aria-label` nor a `aria-labelledby` is given then the alert level automatically used as fallback for `aria-label`. */ export const AlertDialog = ({ children, success = false, warning = false, danger = false, ...otherProps }: AlertDialogProps) => { let intentLevel: IntentTypes = IntentStates.INFO; if (success) { intentLevel = IntentStates.SUCCESS; } if (warning) { intentLevel = IntentStates.WARNING; } if (danger) { intentLevel = IntentStates.DANGER; } return ( {children} ); }; export default AlertDialog;