kitzo 2.3.20 → 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>;
@@ -113,13 +109,9 @@ export declare function useDebounce<T>(value: T, delay?: number): T;
113
109
 
114
110
  export declare function useThrottle<T>(value: T, delay?: number): T;
115
111
 
116
- export declare function useWindowSize(options?: UseWindowSizeOptions): {
112
+ export declare function useWindowSize(updateDelay?: number): {
117
113
  screenWidth: number;
118
114
  screenHeight: number;
119
115
  };
120
116
 
121
- declare type UseWindowSizeOptions = {
122
- updateDelay?: number;
123
- };
124
-
125
117
  export { }
@@ -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
  };
@@ -1,14 +1,14 @@
1
- import { useState as u, useRef as c, useEffect as d } from "react";
2
- function w(i = {}) {
3
- const { updateDelay: n = 30 } = i, [r, o] = u({
1
+ import { useState as o, useRef as u, useEffect as c } from "react";
2
+ function d(n = 30) {
3
+ const [t, r] = o({
4
4
  screenWidth: window.innerWidth,
5
5
  screenHeight: window.innerHeight
6
- }), e = c(null);
7
- return d(() => {
8
- function t() {
6
+ }), e = u(null);
7
+ return c(() => {
8
+ function i() {
9
9
  e.current && clearTimeout(e.current), e.current = setTimeout(
10
10
  () => {
11
- o({
11
+ r({
12
12
  screenWidth: window.innerWidth,
13
13
  screenHeight: window.innerHeight
14
14
  });
@@ -16,11 +16,11 @@ function w(i = {}) {
16
16
  Math.max(0, +n)
17
17
  );
18
18
  }
19
- return typeof window < "u" && window.addEventListener("resize", t), () => {
20
- e.current && clearTimeout(e.current), window.removeEventListener("resize", t);
19
+ return typeof window < "u" && window.addEventListener("resize", i), () => {
20
+ e.current && clearTimeout(e.current), window.removeEventListener("resize", i);
21
21
  };
22
- }, [n]), r;
22
+ }, [n]), t;
23
23
  }
24
24
  export {
25
- w as default
25
+ d as default
26
26
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kitzo",
3
- "version": "2.3.20",
3
+ "version": "2.3.22",
4
4
  "description": "A lightweight React micro-utility.",
5
5
  "type": "module",
6
6
  "files": [