@povio/ui 2.1.3 → 2.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { ToastPosition, ToastOptions as ToastifyToastOptions } from 'react-toastify';
|
|
1
|
+
import { Id, ToastPosition, ToastOptions as ToastifyToastOptions } from 'react-toastify';
|
|
2
2
|
import { ToastProps } from './Toast';
|
|
3
3
|
export interface ToastParams extends Omit<ToastProps, "color"> {
|
|
4
4
|
position?: ToastPosition;
|
|
5
5
|
}
|
|
6
6
|
export type ToastOptions = Omit<ToastifyToastOptions, "position" | "data">;
|
|
7
7
|
export declare const useToast: () => {
|
|
8
|
-
successToast: (params: ToastParams, options?: ToastOptions) =>
|
|
9
|
-
errorToast: (params: ToastParams, options?: ToastOptions) =>
|
|
10
|
-
warningToast: (params: ToastParams, options?: ToastOptions) =>
|
|
11
|
-
neutralToast: (params: ToastParams, options?: ToastOptions) =>
|
|
8
|
+
successToast: (params: ToastParams, options?: ToastOptions) => Id;
|
|
9
|
+
errorToast: (params: ToastParams, options?: ToastOptions) => Id;
|
|
10
|
+
warningToast: (params: ToastParams, options?: ToastOptions) => Id;
|
|
11
|
+
neutralToast: (params: ToastParams, options?: ToastOptions) => Id;
|
|
12
|
+
closeToast: (id: Id) => void;
|
|
12
13
|
};
|
|
@@ -4,7 +4,7 @@ import { toast } from "react-toastify";
|
|
|
4
4
|
import { Toast } from "./Toast.js";
|
|
5
5
|
const useToast = () => {
|
|
6
6
|
const successToast = useCallback((params, options) => {
|
|
7
|
-
toast.success(
|
|
7
|
+
return toast.success(
|
|
8
8
|
/* @__PURE__ */ jsx(
|
|
9
9
|
Toast,
|
|
10
10
|
{
|
|
@@ -22,7 +22,7 @@ const useToast = () => {
|
|
|
22
22
|
);
|
|
23
23
|
}, []);
|
|
24
24
|
const errorToast = useCallback((params, options) => {
|
|
25
|
-
toast.error(
|
|
25
|
+
return toast.error(
|
|
26
26
|
/* @__PURE__ */ jsx(
|
|
27
27
|
Toast,
|
|
28
28
|
{
|
|
@@ -40,7 +40,7 @@ const useToast = () => {
|
|
|
40
40
|
);
|
|
41
41
|
}, []);
|
|
42
42
|
const warningToast = useCallback((params, options) => {
|
|
43
|
-
toast.warning(
|
|
43
|
+
return toast.warning(
|
|
44
44
|
/* @__PURE__ */ jsx(
|
|
45
45
|
Toast,
|
|
46
46
|
{
|
|
@@ -58,7 +58,7 @@ const useToast = () => {
|
|
|
58
58
|
);
|
|
59
59
|
}, []);
|
|
60
60
|
const neutralToast = useCallback((params, options) => {
|
|
61
|
-
toast.info(
|
|
61
|
+
return toast.info(
|
|
62
62
|
/* @__PURE__ */ jsx(
|
|
63
63
|
Toast,
|
|
64
64
|
{
|
|
@@ -75,14 +75,18 @@ const useToast = () => {
|
|
|
75
75
|
}
|
|
76
76
|
);
|
|
77
77
|
}, []);
|
|
78
|
+
const closeToast = useCallback((id) => {
|
|
79
|
+
toast.dismiss(id);
|
|
80
|
+
}, []);
|
|
78
81
|
return useMemo(
|
|
79
82
|
() => ({
|
|
80
83
|
successToast,
|
|
81
84
|
errorToast,
|
|
82
85
|
warningToast,
|
|
83
|
-
neutralToast
|
|
86
|
+
neutralToast,
|
|
87
|
+
closeToast
|
|
84
88
|
}),
|
|
85
|
-
[successToast, errorToast, warningToast, neutralToast]
|
|
89
|
+
[successToast, errorToast, warningToast, neutralToast, closeToast]
|
|
86
90
|
);
|
|
87
91
|
};
|
|
88
92
|
export {
|