@povio/ui 2.1.2 → 2.1.3

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,12 @@
1
- import { ToastPosition } from 'react-toastify';
1
+ import { ToastPosition, ToastOptions as ToastifyToastOptions } from 'react-toastify';
2
2
  import { ToastProps } from './Toast';
3
- type IShowToast = Omit<ToastProps, "color"> & {
3
+ export interface ToastParams extends Omit<ToastProps, "color"> {
4
4
  position?: ToastPosition;
5
- };
5
+ }
6
+ export type ToastOptions = Omit<ToastifyToastOptions, "position" | "data">;
6
7
  export declare const useToast: () => {
7
- successToast: (params: IShowToast) => void;
8
- errorToast: (params: IShowToast) => void;
9
- warningToast: (params: IShowToast) => void;
10
- neutralToast: (params: IShowToast) => void;
8
+ successToast: (params: ToastParams, options?: ToastOptions) => void;
9
+ errorToast: (params: ToastParams, options?: ToastOptions) => void;
10
+ warningToast: (params: ToastParams, options?: ToastOptions) => void;
11
+ neutralToast: (params: ToastParams, options?: ToastOptions) => void;
11
12
  };
12
- export {};
@@ -1,9 +1,9 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import { useCallback } from "react";
2
+ import { useCallback, useMemo } from "react";
3
3
  import { toast } from "react-toastify";
4
4
  import { Toast } from "./Toast.js";
5
5
  const useToast = () => {
6
- const successToast = useCallback((params) => {
6
+ const successToast = useCallback((params, options) => {
7
7
  toast.success(
8
8
  /* @__PURE__ */ jsx(
9
9
  Toast,
@@ -13,6 +13,7 @@ const useToast = () => {
13
13
  }
14
14
  ),
15
15
  {
16
+ ...options,
16
17
  position: params.position,
17
18
  data: {
18
19
  variant: params.variant
@@ -20,7 +21,7 @@ const useToast = () => {
20
21
  }
21
22
  );
22
23
  }, []);
23
- const errorToast = useCallback((params) => {
24
+ const errorToast = useCallback((params, options) => {
24
25
  toast.error(
25
26
  /* @__PURE__ */ jsx(
26
27
  Toast,
@@ -30,6 +31,7 @@ const useToast = () => {
30
31
  }
31
32
  ),
32
33
  {
34
+ ...options,
33
35
  position: params.position,
34
36
  data: {
35
37
  variant: params.variant
@@ -37,7 +39,7 @@ const useToast = () => {
37
39
  }
38
40
  );
39
41
  }, []);
40
- const warningToast = useCallback((params) => {
42
+ const warningToast = useCallback((params, options) => {
41
43
  toast.warning(
42
44
  /* @__PURE__ */ jsx(
43
45
  Toast,
@@ -47,6 +49,7 @@ const useToast = () => {
47
49
  }
48
50
  ),
49
51
  {
52
+ ...options,
50
53
  position: params.position,
51
54
  data: {
52
55
  variant: params.variant
@@ -54,7 +57,7 @@ const useToast = () => {
54
57
  }
55
58
  );
56
59
  }, []);
57
- const neutralToast = useCallback((params) => {
60
+ const neutralToast = useCallback((params, options) => {
58
61
  toast.info(
59
62
  /* @__PURE__ */ jsx(
60
63
  Toast,
@@ -64,6 +67,7 @@ const useToast = () => {
64
67
  }
65
68
  ),
66
69
  {
70
+ ...options,
67
71
  position: params.position,
68
72
  data: {
69
73
  variant: params.variant
@@ -71,12 +75,15 @@ const useToast = () => {
71
75
  }
72
76
  );
73
77
  }, []);
74
- return {
75
- successToast,
76
- errorToast,
77
- warningToast,
78
- neutralToast
79
- };
78
+ return useMemo(
79
+ () => ({
80
+ successToast,
81
+ errorToast,
82
+ warningToast,
83
+ neutralToast
84
+ }),
85
+ [successToast, errorToast, warningToast, neutralToast]
86
+ );
80
87
  };
81
88
  export {
82
89
  useToast
package/dist/index.d.ts CHANGED
@@ -128,6 +128,7 @@ export { Loader } from './components/status/Loader/Loader';
128
128
  export type { ToastAction, ToastProps } from './components/status/Toast/Toast';
129
129
  export { Toast, ToastContainer } from './components/status/Toast/Toast';
130
130
  export type { ToastVariantProps } from './components/status/Toast/toast.cva';
131
+ export type { ToastOptions, ToastParams } from './components/status/Toast/useToast';
131
132
  export { useToast } from './components/status/Toast/useToast';
132
133
  export type { CellTextProps } from './components/table/CellText';
133
134
  export { CellText } from './components/table/CellText';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@povio/ui",
3
- "version": "2.1.2",
3
+ "version": "2.1.3",
4
4
  "type": "module",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",