@povio/ui 2.1.2 → 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.
@@ -485,7 +485,7 @@ const button = cva(["group inline-flex items-center justify-center border border
485
485
  }
486
486
  ],
487
487
  defaultVariants: {
488
- width: "fill",
488
+ width: "hug",
489
489
  color: "primary",
490
490
  variant: "contained",
491
491
  inverted: false
@@ -1,12 +1,13 @@
1
- import { ToastPosition } from 'react-toastify';
1
+ import { Id, 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) => 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;
11
13
  };
12
- export {};
@@ -1,10 +1,10 @@
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) => {
7
- toast.success(
6
+ const successToast = useCallback((params, options) => {
7
+ return toast.success(
8
8
  /* @__PURE__ */ jsx(
9
9
  Toast,
10
10
  {
@@ -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,8 +21,8 @@ const useToast = () => {
20
21
  }
21
22
  );
22
23
  }, []);
23
- const errorToast = useCallback((params) => {
24
- toast.error(
24
+ const errorToast = useCallback((params, options) => {
25
+ return toast.error(
25
26
  /* @__PURE__ */ jsx(
26
27
  Toast,
27
28
  {
@@ -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,8 +39,8 @@ const useToast = () => {
37
39
  }
38
40
  );
39
41
  }, []);
40
- const warningToast = useCallback((params) => {
41
- toast.warning(
42
+ const warningToast = useCallback((params, options) => {
43
+ return toast.warning(
42
44
  /* @__PURE__ */ jsx(
43
45
  Toast,
44
46
  {
@@ -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,8 +57,8 @@ const useToast = () => {
54
57
  }
55
58
  );
56
59
  }, []);
57
- const neutralToast = useCallback((params) => {
58
- toast.info(
60
+ const neutralToast = useCallback((params, options) => {
61
+ return toast.info(
59
62
  /* @__PURE__ */ jsx(
60
63
  Toast,
61
64
  {
@@ -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,19 @@ const useToast = () => {
71
75
  }
72
76
  );
73
77
  }, []);
74
- return {
75
- successToast,
76
- errorToast,
77
- warningToast,
78
- neutralToast
79
- };
78
+ const closeToast = useCallback((id) => {
79
+ toast.dismiss(id);
80
+ }, []);
81
+ return useMemo(
82
+ () => ({
83
+ successToast,
84
+ errorToast,
85
+ warningToast,
86
+ neutralToast,
87
+ closeToast
88
+ }),
89
+ [successToast, errorToast, warningToast, neutralToast, closeToast]
90
+ );
80
91
  };
81
92
  export {
82
93
  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.4",
4
4
  "type": "module",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",