2020-06-30 17:41:43 +00:00
|
|
|
import { createContext } from "react";
|
|
|
|
|
|
|
|
export type Status = "success" | "error" | "info" | "warning";
|
2019-06-19 14:40:52 +00:00
|
|
|
export interface IMessage {
|
2020-06-23 16:02:59 +00:00
|
|
|
actionBtn?: {
|
|
|
|
label: string;
|
|
|
|
action: () => void;
|
|
|
|
};
|
2019-11-25 16:53:10 +00:00
|
|
|
autohide?: number;
|
2020-06-23 16:02:59 +00:00
|
|
|
expandText?: string;
|
2019-11-25 16:23:52 +00:00
|
|
|
title?: string;
|
2020-07-30 09:54:16 +00:00
|
|
|
text: React.ReactNode;
|
2019-06-19 14:40:52 +00:00
|
|
|
onUndo?: () => void;
|
2020-06-30 17:41:43 +00:00
|
|
|
status?: Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface INotification {
|
2020-07-02 12:44:03 +00:00
|
|
|
id: number;
|
2020-06-30 17:41:43 +00:00
|
|
|
message: IMessage;
|
2020-06-30 19:32:20 +00:00
|
|
|
timeout: number;
|
2020-06-30 17:41:43 +00:00
|
|
|
close: () => void;
|
2019-06-19 14:40:52 +00:00
|
|
|
}
|
2020-06-24 14:17:56 +00:00
|
|
|
|
2020-06-30 17:41:43 +00:00
|
|
|
export interface ITimer {
|
2020-07-02 12:44:03 +00:00
|
|
|
id: number;
|
2020-06-30 17:41:43 +00:00
|
|
|
notification: INotification;
|
|
|
|
remaining: number;
|
|
|
|
start: number;
|
|
|
|
timeoutId: number;
|
|
|
|
}
|
2020-06-26 09:25:12 +00:00
|
|
|
|
2020-06-30 17:41:43 +00:00
|
|
|
export const types = {
|
|
|
|
ERROR: "error",
|
|
|
|
INFO: "info",
|
|
|
|
SUCCESS: "success",
|
|
|
|
WARNING: "warning"
|
2020-06-24 14:17:56 +00:00
|
|
|
};
|
2020-06-30 17:41:43 +00:00
|
|
|
export interface INotificationContext {
|
2020-07-02 12:44:03 +00:00
|
|
|
show: (message: IMessage, timeout?: number | null) => void;
|
2020-06-30 17:41:43 +00:00
|
|
|
remove: (notification: INotification) => void;
|
|
|
|
}
|
|
|
|
|
|
|
|
export type IMessageContext = (message: IMessage) => void;
|
2020-06-30 19:32:20 +00:00
|
|
|
export const MessageContext = createContext<INotificationContext>(null);
|
2019-06-19 14:40:52 +00:00
|
|
|
|
|
|
|
export * from "./MessageManager";
|
2020-06-30 17:41:43 +00:00
|
|
|
export * from "./MessageManagerProvider";
|
|
|
|
export { default } from "./MessageManagerProvider";
|