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

56 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;
2019-06-19 14:40:52 +00:00
text: string;
onUndo?: () => void;
status?: Status;
}
export interface IOptions {
timeout: number;
type?: Status;
}
export interface INotification {
id: string;
message: IMessage;
options: IOptions;
close: () => void;
2019-06-19 14:40:52 +00:00
}
2020-06-24 14:17:56 +00:00
export interface ITimer {
id: string;
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 {
show: (message: IMessage, options?: IOptions) => void;
remove: (notification: INotification) => void;
}
export type IMessageContext = (message: IMessage) => void;
export const MessageContext = createContext<
React.MutableRefObject<INotificationContext>
>(null);
2019-06-19 14:40:52 +00:00
export * from "./MessageManager";
export * from "./MessageManagerProvider";
export { default } from "./MessageManagerProvider";