kitzo 2.3.15 → 2.3.17

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.
package/dist/index.d.ts CHANGED
@@ -13,6 +13,8 @@ declare type AnimationOptions = {
13
13
 
14
14
  declare type CopyStatus = 'standby' | 'copying' | 'copied' | 'error';
15
15
 
16
+ declare type Options = ToastOptionsWithoutType;
17
+
16
18
  declare type Position = 'top' | 'top-start' | 'top-end' | 'right' | 'right-start' | 'right-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'left-start' | 'left-end';
17
19
 
18
20
  declare type Positions = 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right';
@@ -44,15 +46,15 @@ declare type ToasterProps = {
44
46
 
45
47
  declare type ToastFn = {
46
48
  (content: ToastContent, options?: ToastOptions): void;
47
- info: (content: ToastContent, options?: ToastOptions) => void;
48
- success: (content: ToastContent, options?: ToastOptions) => void;
49
- warning: (content: ToastContent, options?: ToastOptions) => void;
50
- error: (content: ToastContent, options?: ToastOptions) => void;
49
+ info: (content: ToastContent, options?: Options) => void;
50
+ success: (content: ToastContent, options?: Options) => void;
51
+ warning: (content: ToastContent, options?: Options) => void;
52
+ error: (content: ToastContent, options?: Options) => void;
51
53
  promise: PromiseToastFn;
52
- loading: (content: ToastContent, options?: ToastOptions) => void;
53
- custom: (content: ToastContent, options?: ToastOptions) => void;
54
+ loading: (content: ToastContent, options?: Options) => void;
55
+ custom: (content: ToastContent, options?: Options) => void;
54
56
  dismiss: (id?: string | number) => void;
55
- update: (id: string | number, content: ToastContent, options?: ToastUpdateOptions) => void;
57
+ update: (id: string | number, content: ToastContent, options?: UpdateToastOptions) => void;
56
58
  };
57
59
 
58
60
  declare type ToastOptions = {
@@ -65,9 +67,9 @@ declare type ToastOptions = {
65
67
  type?: ToastType;
66
68
  };
67
69
 
68
- declare type ToastType = 'default' | 'success' | 'warning' | 'error' | 'info' | 'custom' | 'loading';
70
+ declare type ToastOptionsWithoutType = Omit<ToastOptions, 'type'>;
69
71
 
70
- declare type ToastUpdateOptions = Omit<ToastOptions, 'id'>;
72
+ declare type ToastType = 'default' | 'success' | 'warning' | 'error' | 'info' | 'custom' | 'loading';
71
73
 
72
74
  export declare function Tooltip(props: TooltipProps): ReactNode;
73
75
 
@@ -89,6 +91,8 @@ declare type TooltipCoreProps = {
89
91
 
90
92
  declare type TooltipProps = PropsWithChildren<TooltipCoreProps>;
91
93
 
94
+ declare type UpdateToastOptions = Omit<ToastOptions, 'id'>;
95
+
92
96
  export declare function useCopy(options?: UseCopyOptions): UseCopyReturn;
93
97
 
94
98
  declare type UseCopyOptions = {
@@ -1,44 +1,44 @@
1
- const a = {
1
+ const i = {
2
2
  duration: 2800,
3
3
  showIcon: !0,
4
4
  animateTransformOrigin: void 0
5
5
  };
6
- let e = 0;
7
- const s = () => crypto.randomUUID?.() ?? `kitzo_toast_id_${++e}`;
8
- let d = 1;
6
+ let r = 0;
7
+ const d = () => crypto.randomUUID?.() ?? `kitzo_toast_id_${++r}`;
8
+ let s = 1;
9
9
  function c({
10
- type: i,
11
- action: r,
10
+ type: a,
11
+ action: e,
12
12
  content: o,
13
13
  options: n
14
14
  }) {
15
15
  const t = typeof n == "object" && n !== null ? n : {};
16
16
  return {
17
- id: t.id ?? s(),
18
- duration: t.duration ?? a.duration,
19
- showIcon: t.showIcon ?? a.showIcon,
20
- animateTransformOrigin: t.animateTransformOrigin ?? a.animateTransformOrigin,
17
+ id: t.id ?? d(),
18
+ duration: t.duration ?? i.duration,
19
+ showIcon: t.showIcon ?? i.showIcon,
20
+ animateTransformOrigin: t.animateTransformOrigin ?? i.animateTransformOrigin,
21
21
  position: t.position,
22
22
  icon: t.icon,
23
- type: i,
23
+ type: a === "default" ? t.type ?? "default" : a,
24
24
  status: "entering",
25
- zIndex: ++d,
25
+ zIndex: ++s,
26
26
  content: o,
27
- action: r
27
+ action: e
28
28
  };
29
29
  }
30
- function T({ id: i, content: r, options: o }) {
30
+ function T({ id: a, content: e, options: o }) {
31
31
  const n = typeof o == "object" && o !== null ? o : {};
32
32
  return {
33
33
  ...n,
34
- id: i,
35
- content: r,
34
+ id: a,
35
+ content: e,
36
36
  action: "update",
37
- duration: n.duration ?? a.duration
37
+ duration: n.duration ?? i.duration
38
38
  };
39
39
  }
40
40
  export {
41
41
  c as createToast,
42
- s as genId,
42
+ d as genId,
43
43
  T as updateToast
44
44
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kitzo",
3
- "version": "2.3.15",
3
+ "version": "2.3.17",
4
4
  "description": "A lightweight React micro-utility.",
5
5
  "type": "module",
6
6
  "files": [