kitzo 2.3.19 → 2.3.21

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
@@ -111,13 +111,11 @@ declare type UseCopyReturn = {
111
111
 
112
112
  export declare function useDebounce<T>(value: T, delay?: number): T;
113
113
 
114
- export declare function useWindowSize(options?: UseWindowSizeOptions): {
114
+ export declare function useThrottle<T>(value: T, delay?: number): T;
115
+
116
+ export declare function useWindowSize(updateDelay?: number): {
115
117
  screenWidth: number;
116
118
  screenHeight: number;
117
119
  };
118
120
 
119
- declare type UseWindowSizeOptions = {
120
- updateDelay?: number;
121
- };
122
-
123
121
  export { }
package/dist/index.js CHANGED
@@ -1,14 +1,16 @@
1
1
  import { default as t } from "./react/hooks/useWindowSize.js";
2
2
  import { default as r } from "./react/hooks/useDebounce.js";
3
3
  import { default as s } from "./react/hooks/useCopy.js";
4
- import { default as p } from "./react/components/tooltip/Tooltip.js";
5
- import { default as l } from "./react/components/toast/Toaster.js";
6
- import { default as x } from "./react/components/toast/helpers/triggerToasts.js";
4
+ import { default as l } from "./react/hooks/useThrottle.js";
5
+ import { default as d } from "./react/components/tooltip/Tooltip.js";
6
+ import { default as x } from "./react/components/toast/Toaster.js";
7
+ import { default as T } from "./react/components/toast/helpers/triggerToasts.js";
7
8
  export {
8
- l as Toaster,
9
- p as Tooltip,
10
- x as toast,
9
+ x as Toaster,
10
+ d as Tooltip,
11
+ T as toast,
11
12
  s as useCopy,
12
13
  r as useDebounce,
14
+ l as useThrottle,
13
15
  t as useWindowSize
14
16
  };
@@ -0,0 +1,14 @@
1
+ import { useState as c, useRef as f, useEffect as i } from "react";
2
+ function a(t, e = 500) {
3
+ const [n, u] = c(t), r = f(0);
4
+ return i(() => {
5
+ function s() {
6
+ const o = Date.now();
7
+ o - r.current >= e && (u(t), r.current = o);
8
+ }
9
+ return s;
10
+ }, [t, e]), n;
11
+ }
12
+ export {
13
+ a as default
14
+ };
@@ -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.19",
3
+ "version": "2.3.21",
4
4
  "description": "A lightweight React micro-utility.",
5
5
  "type": "module",
6
6
  "files": [