kitzo 2.3.21 → 2.3.22

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
@@ -93,11 +93,7 @@ declare type TooltipProps = PropsWithChildren<TooltipCoreProps>;
93
93
 
94
94
  declare type UpdateToastOptions = Omit<ToastOptions, 'id'>;
95
95
 
96
- export declare function useCopy(options?: UseCopyOptions): UseCopyReturn;
97
-
98
- declare type UseCopyOptions = {
99
- resetDelay?: number;
100
- };
96
+ export declare function useCopy(resetDelay?: number): UseCopyReturn;
101
97
 
102
98
  declare type UseCopyReturn = {
103
99
  copy: (doc: string) => Promise<void>;
@@ -1,32 +1,32 @@
1
- import { useState as u, useRef as i, useCallback as p, useEffect as m } from "react";
2
- import d from "../../functions/copy/copy.js";
3
- function g(a = {}) {
4
- const { resetDelay: s = 1500 } = a, [r, e] = u("standby"), [f, c] = u(null), t = i(null), n = i(!1), l = p(
5
- async (y) => {
1
+ import { useState as u, useRef as i, useCallback as y, useEffect as p } from "react";
2
+ import m from "../../functions/copy/copy.js";
3
+ function E(c = 1500) {
4
+ const [r, e] = u("standby"), [a, s] = u(null), t = i(null), n = i(!1), f = y(
5
+ async (l) => {
6
6
  if (!n.current) {
7
7
  t.current && clearTimeout(t.current);
8
8
  try {
9
- n.current = !0, c(null), e("copying"), await d(y), e("copied");
9
+ n.current = !0, s(null), e("copying"), await m(l), e("copied");
10
10
  } catch (o) {
11
- c(o instanceof Error ? o : new Error(String(o))), e("error");
11
+ s(o instanceof Error ? o : new Error(String(o))), e("error");
12
12
  } finally {
13
13
  t.current = setTimeout(
14
14
  () => {
15
15
  n.current = !1, e("standby");
16
16
  },
17
- Math.max(s, 500)
17
+ Math.max(c, 500)
18
18
  );
19
19
  }
20
20
  }
21
21
  },
22
- [s]
22
+ [c]
23
23
  );
24
- return m(() => () => {
24
+ return p(() => () => {
25
25
  t.current && clearTimeout(t.current);
26
26
  }, []), {
27
- copy: l,
27
+ copy: f,
28
28
  status: r,
29
- error: f,
29
+ error: a,
30
30
  isCopying: r === "copying",
31
31
  isCopied: r === "copied",
32
32
  isError: r === "error",
@@ -34,5 +34,5 @@ function g(a = {}) {
34
34
  };
35
35
  }
36
36
  export {
37
- g as default
37
+ E as default
38
38
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kitzo",
3
- "version": "2.3.21",
3
+ "version": "2.3.22",
4
4
  "description": "A lightweight React micro-utility.",
5
5
  "type": "module",
6
6
  "files": [