@kubed/hooks 0.0.4 → 0.0.8

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/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # @kubed/hooks
2
2
 
3
+ ## 0.0.8
4
+
5
+ ### Patch Changes
6
+
7
+ - [`7f2e134`](https://github.com/kubesphere/kube-design/commit/7f2e134aaff15b0552889f02ca0ae929848877d4) Thanks [@chenz24](https://github.com/chenz24)! - 1. feat: Add usePrevious hook.
8
+
9
+ ## 0.0.7
10
+
11
+ ### Patch Changes
12
+
13
+ - [`f5ed279`](https://github.com/kubesphere/kube-design/commit/f5ed279be5140890fd91e762c02593988576ca46) Thanks [@chenz24](https://github.com/chenz24)! - 1. Add useUnmount hook.
14
+
15
+ ## 0.0.6
16
+
17
+ ### Patch Changes
18
+
19
+ - [`db858ee`](https://github.com/kubesphere/kube-design/commit/db858ee70bc841176d9dd8cf3d52ce6a3927fc2c) Thanks [@chenz24](https://github.com/chenz24)! - 1. add useDidUpdate hook.
20
+
21
+ ## 0.0.5
22
+
23
+ ### Patch Changes
24
+
25
+ - [`f39c7e8`](https://github.com/kubesphere/kube-design/commit/f39c7e8d9550ddd329dc057bf6a737835b738d33) Thanks [@chenz24](https://github.com/chenz24)! - 1. Completely Refactor Empty component.
26
+ 2. Add useDebouncedValue hook.
27
+ 3. Reset default props for LoadingOverlay.
28
+
3
29
  ## 0.0.4
4
30
 
5
31
  ### Patch Changes
package/cjs/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var index$d=require("./utils/index.js"),index=require("./useId/index.js"),index$1=require("./useToggle/index.js"),index$2=require("./useUncontrolled/index.js"),index$3=require("./useMediaQuery/index.js"),index$4=require("./useReducedMotion/index.js"),index$5=require("./useWindowEvent/index.js"),index$6=require("./useLocalStorage/index.js"),index$7=require("./useForceUpdate/index.js"),index$8=require("./useClipboard/index.js"),index$9=require("./useQueue/index.js"),index$a=require("./useClickOutside/index.js"),index$b=require("./useMove/index.js"),index$c=require("./useHotkeys/index.js");exports.clamp=index$d.clamp,exports.randomId=index$d.randomId,exports.useId=index.useId,exports.useBooleanToggle=index$1.useBooleanToggle,exports.useToggle=index$1.useToggle,exports.useUncontrolled=index$2.useUncontrolled,exports.useMediaQuery=index$3.useMediaQuery,exports.useReducedMotion=index$4.useReducedMotion,exports.useWindowEvent=index$5.useWindowEvent,exports.useLocalStorage=index$6.useLocalStorage,exports.useForceUpdate=index$7.useForceUpdate,exports.useClipboard=index$8.useClipboard,exports.useQueue=index$9.useQueue,exports.useClickOutside=index$a.useClickOutside,exports.useMove=index$b.useMove,exports.useHotkeys=index$c.useHotkeys;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var index$i=require("./utils/index.js"),index=require("./useId/index.js"),index$1=require("./useToggle/index.js"),index$2=require("./useUncontrolled/index.js"),index$3=require("./useMediaQuery/index.js"),index$4=require("./useReducedMotion/index.js"),index$5=require("./useWindowEvent/index.js"),index$6=require("./useLocalStorage/index.js"),index$7=require("./useForceUpdate/index.js"),index$8=require("./useClipboard/index.js"),index$9=require("./useQueue/index.js"),index$a=require("./useClickOutside/index.js"),index$b=require("./useMove/index.js"),index$c=require("./useHotkeys/index.js"),index$d=require("./useDebouncedValue/index.js"),index$e=require("./useDidMount/index.js"),index$f=require("./useDidUpdate/index.js"),index$g=require("./useUnmount/index.js"),index$h=require("./usePrevious/index.js");exports.clamp=index$i.clamp,exports.randomId=index$i.randomId,exports.useId=index.useId,exports.useBooleanToggle=index$1.useBooleanToggle,exports.useToggle=index$1.useToggle,exports.useUncontrolled=index$2.useUncontrolled,exports.useMediaQuery=index$3.useMediaQuery,exports.useReducedMotion=index$4.useReducedMotion,exports.useWindowEvent=index$5.useWindowEvent,exports.useLocalStorage=index$6.useLocalStorage,exports.useForceUpdate=index$7.useForceUpdate,exports.useClipboard=index$8.useClipboard,exports.useQueue=index$9.useQueue,exports.useClickOutside=index$a.useClickOutside,exports.useMove=index$b.useMove,exports.useHotkeys=index$c.useHotkeys,exports.useDebouncedValue=index$d.useDebouncedValue,exports.useDidMount=index$e.useDidMount,exports.useDidUpdate=index$f.useDidUpdate,exports.useUnmount=index$g.useUnmount,exports.usePrevious=index$h.usePrevious;
2
2
  //# sourceMappingURL=index.js.map
package/cjs/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var react=require("react");function useDebouncedValue(e,o,r={leading:!1}){const[f,n]=react.useState(e),c=react.useRef(!1),s=react.useRef(null),t=react.useRef(!1),u=()=>window.clearTimeout(s.current);return react.useEffect(()=>{c.current&&(!t.current&&r.leading?(t.current=!0,n(e)):(u(),s.current=window.setTimeout(()=>{t.current=!1,n(e)},o)))},[e,r.leading]),react.useEffect(()=>(c.current=!0,u),[]),[f,u]}exports.useDebouncedValue=useDebouncedValue;
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../src/useDebouncedValue/index.ts"],"sourcesContent":["// https://github.com/mantinedev/mantine/blob/master/src/mantine-hooks/src/use-debounced-value/use-debounced-value.ts\nimport { useEffect, useState, useRef } from 'react';\n\nexport function useDebouncedValue<T = any>(value: T, wait: number, options = { leading: false }) {\n const [_value, setValue] = useState(value);\n const mountedRef = useRef(false);\n const timeoutRef = useRef<number>(null);\n const cooldownRef = useRef(false);\n\n const cancel = () => window.clearTimeout(timeoutRef.current);\n\n useEffect(() => {\n if (mountedRef.current) {\n if (!cooldownRef.current && options.leading) {\n cooldownRef.current = true;\n setValue(value);\n } else {\n cancel();\n timeoutRef.current = window.setTimeout(() => {\n cooldownRef.current = false;\n setValue(value);\n }, wait);\n }\n }\n }, [value, options.leading]);\n\n useEffect(() => {\n mountedRef.current = true;\n return cancel;\n }, []);\n\n return [_value, cancel] as const;\n}\n"],"names":["useState","useRef","useEffect"],"mappings":";;;;;;AACO,SAAS,iBAAiB,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE;AAC7E,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAGA,cAAQ,CAAC,KAAK,CAAC,CAAC;AAC7C,EAAE,MAAM,UAAU,GAAGC,YAAM,CAAC,KAAK,CAAC,CAAC;AACnC,EAAE,MAAM,UAAU,GAAGA,YAAM,CAAC,IAAI,CAAC,CAAC;AAClC,EAAE,MAAM,WAAW,GAAGA,YAAM,CAAC,KAAK,CAAC,CAAC;AACpC,EAAE,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;AAC/D,EAAEC,eAAS,CAAC,MAAM;AAClB,IAAI,IAAI,UAAU,CAAC,OAAO,EAAE;AAC5B,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,IAAI,OAAO,CAAC,OAAO,EAAE;AACnD,QAAQ,WAAW,CAAC,OAAO,GAAG,IAAI,CAAC;AACnC,QAAQ,QAAQ,CAAC,KAAK,CAAC,CAAC;AACxB,OAAO,MAAM;AACb,QAAQ,MAAM,EAAE,CAAC;AACjB,QAAQ,UAAU,CAAC,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,MAAM;AACrD,UAAU,WAAW,CAAC,OAAO,GAAG,KAAK,CAAC;AACtC,UAAU,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC1B,SAAS,EAAE,IAAI,CAAC,CAAC;AACjB,OAAO;AACP,KAAK;AACL,GAAG,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;AAC/B,EAAEA,eAAS,CAAC,MAAM;AAClB,IAAI,UAAU,CAAC,OAAO,GAAG,IAAI,CAAC;AAC9B,IAAI,OAAO,MAAM,CAAC;AAClB,GAAG,EAAE,EAAE,CAAC,CAAC;AACT,EAAE,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAC1B;;;;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var react=require("react");function useDidMount(e){react.useEffect(()=>{typeof e=="function"&&e()},[])}exports.useDidMount=useDidMount;
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../src/useDidMount/index.ts"],"sourcesContent":["import { useEffect } from 'react';\n\nexport function useDidMount(callback: () => any): void {\n useEffect(() => {\n if (typeof callback === 'function') {\n callback();\n }\n }, []);\n}\n"],"names":["useEffect"],"mappings":";;;;;;AACO,SAAS,WAAW,CAAC,QAAQ,EAAE;AACtC,EAAEA,eAAS,CAAC,MAAM;AAClB,IAAI,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE;AACxC,MAAM,QAAQ,EAAE,CAAC;AACjB,KAAK;AACL,GAAG,EAAE,EAAE,CAAC,CAAC;AACT;;;;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var react=require("react");function useDidUpdate(t,r){const e=react.useRef(!1);react.useEffect(()=>{e.current?t():e.current=!0},r)}exports.useDidUpdate=useDidUpdate;
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../src/useDidUpdate/index.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\n\nexport function useDidUpdate(fn: () => void, dependencies?: any[]) {\n const mounted = useRef(false);\n\n useEffect(() => {\n if (mounted.current) {\n fn();\n } else {\n mounted.current = true;\n }\n }, dependencies);\n}\n"],"names":["useRef","useEffect"],"mappings":";;;;;;AACO,SAAS,YAAY,CAAC,EAAE,EAAE,YAAY,EAAE;AAC/C,EAAE,MAAM,OAAO,GAAGA,YAAM,CAAC,KAAK,CAAC,CAAC;AAChC,EAAEC,eAAS,CAAC,MAAM;AAClB,IAAI,IAAI,OAAO,CAAC,OAAO,EAAE;AACzB,MAAM,EAAE,EAAE,CAAC;AACX,KAAK,MAAM;AACX,MAAM,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;AAC7B,KAAK;AACL,GAAG,EAAE,YAAY,CAAC,CAAC;AACnB;;;;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var react=require("react");function usePrevious(e){const r=react.useRef();return react.useEffect(()=>{r.current=e},[e]),r.current}exports.usePrevious=usePrevious;
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../src/usePrevious/index.ts"],"sourcesContent":["import { useRef, useEffect } from 'react';\n\nexport function usePrevious<T>(value: T): T {\n const ref: any = useRef<T>();\n // Store current value in ref\n useEffect(() => {\n ref.current = value;\n }, [value]);\n\n return ref.current;\n}\n"],"names":["useRef","useEffect"],"mappings":";;;;;;AACO,SAAS,WAAW,CAAC,KAAK,EAAE;AACnC,EAAE,MAAM,GAAG,GAAGA,YAAM,EAAE,CAAC;AACvB,EAAEC,eAAS,CAAC,MAAM;AAClB,IAAI,GAAG,CAAC,OAAO,GAAG,KAAK,CAAC;AACxB,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;AACd,EAAE,OAAO,GAAG,CAAC,OAAO,CAAC;AACrB;;;;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var react=require("react");function useUnmount(e){const t=react.useRef(e);t.current=e,react.useEffect(()=>()=>{t.current()},[])}exports.useUnmount=useUnmount;
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../src/useUnmount/index.ts"],"sourcesContent":["import { useRef, useEffect } from 'react';\n\nexport function useUnmount(fn: () => void) {\n const fnRef = useRef(fn);\n fnRef.current = fn;\n\n useEffect(\n () => () => {\n fnRef.current();\n },\n []\n );\n}\n"],"names":["useRef","useEffect"],"mappings":";;;;;;AACO,SAAS,UAAU,CAAC,EAAE,EAAE;AAC/B,EAAE,MAAM,KAAK,GAAGA,YAAM,CAAC,EAAE,CAAC,CAAC;AAC3B,EAAE,KAAK,CAAC,OAAO,GAAG,EAAE,CAAC;AACrB,EAAEC,eAAS,CAAC,MAAM,MAAM;AACxB,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;AACpB,GAAG,EAAE,EAAE,CAAC,CAAC;AACT;;;;"}
package/esm/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export{clamp,randomId}from"./utils/index.js";export{useId}from"./useId/index.js";export{useBooleanToggle,useToggle}from"./useToggle/index.js";export{useUncontrolled}from"./useUncontrolled/index.js";export{useMediaQuery}from"./useMediaQuery/index.js";export{useReducedMotion}from"./useReducedMotion/index.js";export{useWindowEvent}from"./useWindowEvent/index.js";export{useLocalStorage}from"./useLocalStorage/index.js";export{useForceUpdate}from"./useForceUpdate/index.js";export{useClipboard}from"./useClipboard/index.js";export{useQueue}from"./useQueue/index.js";export{useClickOutside}from"./useClickOutside/index.js";export{useMove}from"./useMove/index.js";export{useHotkeys}from"./useHotkeys/index.js";
1
+ export{clamp,randomId}from"./utils/index.js";export{useId}from"./useId/index.js";export{useBooleanToggle,useToggle}from"./useToggle/index.js";export{useUncontrolled}from"./useUncontrolled/index.js";export{useMediaQuery}from"./useMediaQuery/index.js";export{useReducedMotion}from"./useReducedMotion/index.js";export{useWindowEvent}from"./useWindowEvent/index.js";export{useLocalStorage}from"./useLocalStorage/index.js";export{useForceUpdate}from"./useForceUpdate/index.js";export{useClipboard}from"./useClipboard/index.js";export{useQueue}from"./useQueue/index.js";export{useClickOutside}from"./useClickOutside/index.js";export{useMove}from"./useMove/index.js";export{useHotkeys}from"./useHotkeys/index.js";export{useDebouncedValue}from"./useDebouncedValue/index.js";export{useDidMount}from"./useDidMount/index.js";export{useDidUpdate}from"./useDidUpdate/index.js";export{useUnmount}from"./useUnmount/index.js";export{usePrevious}from"./usePrevious/index.js";
2
2
  //# sourceMappingURL=index.js.map
package/esm/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,2 @@
1
+ import{useState as i,useRef as r,useEffect as f}from"react";function d(e,l,u={leading:!1}){const[a,c]=i(e),o=r(!1),s=r(null),t=r(!1),n=()=>window.clearTimeout(s.current);return f(()=>{o.current&&(!t.current&&u.leading?(t.current=!0,c(e)):(n(),s.current=window.setTimeout(()=>{t.current=!1,c(e)},l)))},[e,u.leading]),f(()=>(o.current=!0,n),[]),[a,n]}export{d as useDebouncedValue};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../src/useDebouncedValue/index.ts"],"sourcesContent":["// https://github.com/mantinedev/mantine/blob/master/src/mantine-hooks/src/use-debounced-value/use-debounced-value.ts\nimport { useEffect, useState, useRef } from 'react';\n\nexport function useDebouncedValue<T = any>(value: T, wait: number, options = { leading: false }) {\n const [_value, setValue] = useState(value);\n const mountedRef = useRef(false);\n const timeoutRef = useRef<number>(null);\n const cooldownRef = useRef(false);\n\n const cancel = () => window.clearTimeout(timeoutRef.current);\n\n useEffect(() => {\n if (mountedRef.current) {\n if (!cooldownRef.current && options.leading) {\n cooldownRef.current = true;\n setValue(value);\n } else {\n cancel();\n timeoutRef.current = window.setTimeout(() => {\n cooldownRef.current = false;\n setValue(value);\n }, wait);\n }\n }\n }, [value, options.leading]);\n\n useEffect(() => {\n mountedRef.current = true;\n return cancel;\n }, []);\n\n return [_value, cancel] as const;\n}\n"],"names":[],"mappings":";;AACO,SAAS,iBAAiB,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE;AAC7E,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC7C,EAAE,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;AACnC,EAAE,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;AAClC,EAAE,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;AACpC,EAAE,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;AAC/D,EAAE,SAAS,CAAC,MAAM;AAClB,IAAI,IAAI,UAAU,CAAC,OAAO,EAAE;AAC5B,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,IAAI,OAAO,CAAC,OAAO,EAAE;AACnD,QAAQ,WAAW,CAAC,OAAO,GAAG,IAAI,CAAC;AACnC,QAAQ,QAAQ,CAAC,KAAK,CAAC,CAAC;AACxB,OAAO,MAAM;AACb,QAAQ,MAAM,EAAE,CAAC;AACjB,QAAQ,UAAU,CAAC,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,MAAM;AACrD,UAAU,WAAW,CAAC,OAAO,GAAG,KAAK,CAAC;AACtC,UAAU,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC1B,SAAS,EAAE,IAAI,CAAC,CAAC;AACjB,OAAO;AACP,KAAK;AACL,GAAG,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;AAC/B,EAAE,SAAS,CAAC,MAAM;AAClB,IAAI,UAAU,CAAC,OAAO,GAAG,IAAI,CAAC;AAC9B,IAAI,OAAO,MAAM,CAAC;AAClB,GAAG,EAAE,EAAE,CAAC,CAAC;AACT,EAAE,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAC1B;;;;"}
@@ -0,0 +1,2 @@
1
+ import{useEffect as f}from"react";function o(t){f(()=>{typeof t=="function"&&t()},[])}export{o as useDidMount};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../src/useDidMount/index.ts"],"sourcesContent":["import { useEffect } from 'react';\n\nexport function useDidMount(callback: () => any): void {\n useEffect(() => {\n if (typeof callback === 'function') {\n callback();\n }\n }, []);\n}\n"],"names":[],"mappings":";;AACO,SAAS,WAAW,CAAC,QAAQ,EAAE;AACtC,EAAE,SAAS,CAAC,MAAM;AAClB,IAAI,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE;AACxC,MAAM,QAAQ,EAAE,CAAC;AACjB,KAAK;AACL,GAAG,EAAE,EAAE,CAAC,CAAC;AACT;;;;"}
@@ -0,0 +1,2 @@
1
+ import{useRef as u,useEffect as f}from"react";function c(t,r){const e=u(!1);f(()=>{e.current?t():e.current=!0},r)}export{c as useDidUpdate};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../src/useDidUpdate/index.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\n\nexport function useDidUpdate(fn: () => void, dependencies?: any[]) {\n const mounted = useRef(false);\n\n useEffect(() => {\n if (mounted.current) {\n fn();\n } else {\n mounted.current = true;\n }\n }, dependencies);\n}\n"],"names":[],"mappings":";;AACO,SAAS,YAAY,CAAC,EAAE,EAAE,YAAY,EAAE;AAC/C,EAAE,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;AAChC,EAAE,SAAS,CAAC,MAAM;AAClB,IAAI,IAAI,OAAO,CAAC,OAAO,EAAE;AACzB,MAAM,EAAE,EAAE,CAAC;AACX,KAAK,MAAM;AACX,MAAM,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;AAC7B,KAAK;AACL,GAAG,EAAE,YAAY,CAAC,CAAC;AACnB;;;;"}
@@ -0,0 +1,2 @@
1
+ import{useRef as t,useEffect as u}from"react";function c(r){const e=t();return u(()=>{e.current=r},[r]),e.current}export{c as usePrevious};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../src/usePrevious/index.ts"],"sourcesContent":["import { useRef, useEffect } from 'react';\n\nexport function usePrevious<T>(value: T): T {\n const ref: any = useRef<T>();\n // Store current value in ref\n useEffect(() => {\n ref.current = value;\n }, [value]);\n\n return ref.current;\n}\n"],"names":[],"mappings":";;AACO,SAAS,WAAW,CAAC,KAAK,EAAE;AACnC,EAAE,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC;AACvB,EAAE,SAAS,CAAC,MAAM;AAClB,IAAI,GAAG,CAAC,OAAO,GAAG,KAAK,CAAC;AACxB,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;AACd,EAAE,OAAO,GAAG,CAAC,OAAO,CAAC;AACrB;;;;"}
@@ -0,0 +1,2 @@
1
+ import{useRef as r,useEffect as n}from"react";function u(e){const t=r(e);t.current=e,n(()=>()=>{t.current()},[])}export{u as useUnmount};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../src/useUnmount/index.ts"],"sourcesContent":["import { useRef, useEffect } from 'react';\n\nexport function useUnmount(fn: () => void) {\n const fnRef = useRef(fn);\n fnRef.current = fn;\n\n useEffect(\n () => () => {\n fnRef.current();\n },\n []\n );\n}\n"],"names":[],"mappings":";;AACO,SAAS,UAAU,CAAC,EAAE,EAAE;AAC/B,EAAE,MAAM,KAAK,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC;AAC3B,EAAE,KAAK,CAAC,OAAO,GAAG,EAAE,CAAC;AACrB,EAAE,SAAS,CAAC,MAAM,MAAM;AACxB,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;AACpB,GAAG,EAAE,EAAE,CAAC,CAAC;AACT;;;;"}
package/lib/index.d.ts CHANGED
@@ -12,4 +12,9 @@ export { useQueue } from './useQueue';
12
12
  export { useClickOutside } from './useClickOutside';
13
13
  export { useMove } from './useMove';
14
14
  export { useHotkeys } from './useHotkeys';
15
+ export { useDebouncedValue } from './useDebouncedValue';
16
+ export { useDidMount } from './useDidMount';
17
+ export { useDidUpdate } from './useDidUpdate';
18
+ export { useUnmount } from './useUnmount';
19
+ export { usePrevious } from './usePrevious';
15
20
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,4 @@
1
+ export declare function useDebouncedValue<T = any>(value: T, wait: number, options?: {
2
+ leading: boolean;
3
+ }): readonly [T, () => void];
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useDebouncedValue/index.ts"],"names":[],"mappings":"AAGA,wBAAgB,iBAAiB,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO;;CAAqB,4BA6B9F"}
@@ -0,0 +1,2 @@
1
+ export declare function useDidUpdate(fn: () => void, dependencies?: any[]): void;
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useDidUpdate/index.ts"],"names":[],"mappings":"AAEA,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM,IAAI,EAAE,YAAY,CAAC,EAAE,GAAG,EAAE,QAUhE"}
@@ -0,0 +1,2 @@
1
+ export declare function usePrevious<T>(value: T): T;
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/usePrevious/index.ts"],"names":[],"mappings":"AAEA,wBAAgB,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAQ1C"}
@@ -0,0 +1,2 @@
1
+ export declare function useUnmount(fn: () => void): void;
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useUnmount/index.ts"],"names":[],"mappings":"AAEA,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,IAAI,QAUxC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubed/hooks",
3
- "version": "0.0.4",
3
+ "version": "0.0.8",
4
4
  "main": "cjs/index.js",
5
5
  "module": "esm/index.js",
6
6
  "types": "lib/index.d.ts",