import { CSSProperties, ReactNode, useState, createContext } from "react"; import CloseIcon from '@material-ui/icons/Close'; function ToastArea(props: { style?: CSSProperties children?: ReactNode rerender?: boolean; }) { return
{props.children}
} function Toast(props: { text?: string icon?: ReactNode children?: ReactNode type?: "normal"|"confirmation"|"error" style?: CSSProperties }) { var [visible, setVisibility] = useState(true); setTimeout(() => setVisibility(false), 10e3); return visible &&
{ props.children ||
{props.icon}

{props.text}

setVisibility(false)}>
}
} export var ToastContext = createContext<{ toast?: (message: string, type: "confirmation"|"normal"|"error", icon?: ReactNode ) => void }>({}); var toasts: Array = []; export function ToastContextWrapper(props: { children?: ReactNode }) { var [dummyState, rerender] = useState(false); return { toasts.push(); rerender(!dummyState); } }}> { props.children } {toasts} }