kitzo 2.3.21 → 2.3.23
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/fns.d.ts +1 -1
- package/dist/functions/copy/copy.js +5 -6
- package/dist/index.d.ts +1 -5
- package/dist/react/hooks/useCopy.js +13 -13
- package/package.json +1 -1
package/dist/fns.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ function o(e) {
|
|
|
2
2
|
const t = document.createElement("textarea");
|
|
3
3
|
t.value = e, document.body.appendChild(t), t.select(), document.execCommand("copy"), document.body.removeChild(t);
|
|
4
4
|
}
|
|
5
|
-
async function
|
|
5
|
+
async function a(e) {
|
|
6
6
|
if (!navigator.clipboard?.writeText) {
|
|
7
7
|
o(e);
|
|
8
8
|
return;
|
|
@@ -13,11 +13,10 @@ async function n(e) {
|
|
|
13
13
|
o(e), console.error(t);
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
-
async function
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
await n(t);
|
|
16
|
+
async function n(e) {
|
|
17
|
+
const t = typeof e == "string" || typeof e == "number" || typeof e == "boolean" ? String(e) : JSON.stringify(e);
|
|
18
|
+
await a(t);
|
|
20
19
|
}
|
|
21
20
|
export {
|
|
22
|
-
|
|
21
|
+
n as default
|
|
23
22
|
};
|
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(
|
|
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
|
|
2
|
-
import
|
|
3
|
-
function
|
|
4
|
-
const
|
|
5
|
-
async (
|
|
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,
|
|
9
|
+
n.current = !0, s(null), e("copying"), await m(l), e("copied");
|
|
10
10
|
} catch (o) {
|
|
11
|
-
|
|
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(
|
|
17
|
+
Math.max(c, 500)
|
|
18
18
|
);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
|
-
[
|
|
22
|
+
[c]
|
|
23
23
|
);
|
|
24
|
-
return
|
|
24
|
+
return p(() => () => {
|
|
25
25
|
t.current && clearTimeout(t.current);
|
|
26
26
|
}, []), {
|
|
27
|
-
copy:
|
|
27
|
+
copy: f,
|
|
28
28
|
status: r,
|
|
29
|
-
error:
|
|
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
|
-
|
|
37
|
+
E as default
|
|
38
38
|
};
|