saleor-dashboard/src/components/messages/index.ts

49 lines
1.1 KiB
TypeScript
Raw Normal View History

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