@siberiacancode/reactuse 0.0.11 → 0.0.13

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.
Files changed (142) hide show
  1. package/dist/cjs/{_rollupPluginBabelHelpers-OMepdpg5.js → _rollupPluginBabelHelpers-AbuYd4Pg.js} +2 -2
  2. package/dist/cjs/_rollupPluginBabelHelpers-AbuYd4Pg.js.map +1 -0
  3. package/dist/cjs/hooks/index.js +2 -2
  4. package/dist/cjs/hooks/useBattery/useBattery.js +2 -2
  5. package/dist/cjs/hooks/useBoolean/useBoolean.js +2 -2
  6. package/dist/cjs/hooks/useClickOutside/useClickOutside.js +1 -1
  7. package/dist/cjs/hooks/useClickOutside/useClickOutside.js.map +1 -1
  8. package/dist/cjs/hooks/useCopyToClipboard/useCopyToClipboard.js +2 -2
  9. package/dist/cjs/hooks/useCounter/useCounter.js +2 -2
  10. package/dist/cjs/hooks/useDebouncedValue/useDebouncedValue.js +2 -2
  11. package/dist/cjs/hooks/useDefault/useDefault.js +2 -2
  12. package/dist/cjs/hooks/useDidUpdate/useDidUpdate.js +1 -1
  13. package/dist/cjs/hooks/useDocumentTitle/useDocumentTitle.js +2 -2
  14. package/dist/cjs/hooks/useDocumentVisibility/useDocumentVisibility.js +1 -1
  15. package/dist/cjs/hooks/useEvent/useEvent.js +1 -1
  16. package/dist/cjs/hooks/useEvent/useEvent.js.map +1 -1
  17. package/dist/cjs/hooks/useEventListener/useEventListener.js +1 -1
  18. package/dist/cjs/hooks/useEventListener/useEventListener.js.map +1 -1
  19. package/dist/cjs/hooks/useFavicon/useFavicon.js +2 -2
  20. package/dist/cjs/hooks/useFavicon/useFavicon.js.map +1 -1
  21. package/dist/cjs/hooks/useHash/useHash.js +2 -2
  22. package/dist/cjs/hooks/useHotkeys/useHotkeys.js +2 -2
  23. package/dist/cjs/hooks/useHover/useHover.js +2 -2
  24. package/dist/cjs/hooks/useIdle/useIdle.js +2 -2
  25. package/dist/cjs/hooks/useIntersectionObserver/useIntersectionObserver.js +2 -2
  26. package/dist/cjs/hooks/useIsFirstRender/useIsFirstRender.js +1 -1
  27. package/dist/cjs/hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js +1 -1
  28. package/dist/cjs/hooks/useKeyPress/useKeyPress.js +2 -2
  29. package/dist/cjs/hooks/useKeyPressEvent/useKeyPressEvent.js +1 -1
  30. package/dist/cjs/hooks/useKeysPressed/useKeysPressed.js +2 -2
  31. package/dist/cjs/hooks/useLocalStorage/useLocalStorage.js +2 -2
  32. package/dist/cjs/hooks/useLogger/useLogger.js +2 -2
  33. package/dist/cjs/hooks/useMediaQuery/useMediaQuery.js +1 -1
  34. package/dist/cjs/hooks/useMount/useMount.js +1 -1
  35. package/dist/cjs/hooks/useMutationObserver.js +1 -1
  36. package/dist/cjs/hooks/useNetwork/useNetwork.js +1 -1
  37. package/dist/cjs/hooks/useNetwork/useNetwork.js.map +1 -1
  38. package/dist/cjs/hooks/useOnline/useOnline.js +1 -1
  39. package/dist/cjs/hooks/useOperatingSystem/useOperatingSystem.js +1 -1
  40. package/dist/cjs/hooks/useOrientation/useOrientation.js +2 -2
  41. package/dist/cjs/hooks/useOrientation/useOrientation.js.map +1 -1
  42. package/dist/cjs/hooks/usePageLeave/usePageLeave.js +3 -0
  43. package/dist/cjs/hooks/usePageLeave/usePageLeave.js.map +1 -0
  44. package/dist/cjs/hooks/usePrevious/usePrevious.js +1 -1
  45. package/dist/cjs/hooks/useQueue/useQueue.js +2 -2
  46. package/dist/cjs/hooks/useQueue/useQueue.js.map +1 -1
  47. package/dist/cjs/hooks/useRenderCount/useRenderCount.js +1 -1
  48. package/dist/cjs/hooks/useRerender/useRerender.js +2 -2
  49. package/dist/cjs/hooks/useScript/useScript.js +2 -2
  50. package/dist/cjs/hooks/useSessionStorage/useSessionStorage.js +2 -2
  51. package/dist/cjs/hooks/useSet/useSet.js +2 -2
  52. package/dist/cjs/hooks/useSet/useSet.js.map +1 -1
  53. package/dist/cjs/hooks/useStep/useStep.js +2 -2
  54. package/dist/cjs/hooks/useStorage/useStorage.js +2 -2
  55. package/dist/cjs/hooks/useTimeout/useTimeout.js +2 -2
  56. package/dist/cjs/hooks/useTimeout/useTimeout.js.map +1 -1
  57. package/dist/cjs/hooks/useToggle/useToggle.js +2 -2
  58. package/dist/cjs/hooks/useUnmount/useUnmount.js +1 -1
  59. package/dist/cjs/hooks/useWindowEvent/useWindowEvent.js +1 -1
  60. package/dist/cjs/hooks/useWindowSize/useWindowSize.js +2 -2
  61. package/dist/cjs/hooks/useWindowSize/useWindowSize.js.map +1 -1
  62. package/dist/cjs/index-Bqc-0gKC.js +43 -0
  63. package/dist/cjs/index-Bqc-0gKC.js.map +1 -0
  64. package/dist/cjs/index.js +2 -2
  65. package/dist/cjs/utils/helpers/debounce.js +1 -1
  66. package/dist/cjs/utils/helpers/index.js +1 -1
  67. package/dist/cjs/utils/helpers/isClient.js +1 -1
  68. package/dist/cjs/utils/helpers/isShallowEqual.js +1 -1
  69. package/dist/cjs/utils/helpers/throttle.js +1 -1
  70. package/dist/esm/{_rollupPluginBabelHelpers-TF5Io098.js → _rollupPluginBabelHelpers-CtMKhJ6X.js} +2 -2
  71. package/dist/esm/_rollupPluginBabelHelpers-CtMKhJ6X.js.map +1 -0
  72. package/dist/esm/hooks/index.js +2 -2
  73. package/dist/esm/hooks/useBattery/useBattery.js +2 -2
  74. package/dist/esm/hooks/useBoolean/useBoolean.js +2 -2
  75. package/dist/esm/hooks/useClickOutside/useClickOutside.js +1 -1
  76. package/dist/esm/hooks/useClickOutside/useClickOutside.js.map +1 -1
  77. package/dist/esm/hooks/useCopyToClipboard/useCopyToClipboard.js +2 -2
  78. package/dist/esm/hooks/useCounter/useCounter.js +2 -2
  79. package/dist/esm/hooks/useDebouncedValue/useDebouncedValue.js +2 -2
  80. package/dist/esm/hooks/useDefault/useDefault.js +2 -2
  81. package/dist/esm/hooks/useDidUpdate/useDidUpdate.js +1 -1
  82. package/dist/esm/hooks/useDocumentTitle/useDocumentTitle.js +2 -2
  83. package/dist/esm/hooks/useDocumentVisibility/useDocumentVisibility.js +1 -1
  84. package/dist/esm/hooks/useEvent/useEvent.js +1 -1
  85. package/dist/esm/hooks/useEvent/useEvent.js.map +1 -1
  86. package/dist/esm/hooks/useEventListener/useEventListener.js +1 -1
  87. package/dist/esm/hooks/useEventListener/useEventListener.js.map +1 -1
  88. package/dist/esm/hooks/useFavicon/useFavicon.js +2 -2
  89. package/dist/esm/hooks/useFavicon/useFavicon.js.map +1 -1
  90. package/dist/esm/hooks/useHash/useHash.js +2 -2
  91. package/dist/esm/hooks/useHotkeys/useHotkeys.js +2 -2
  92. package/dist/esm/hooks/useHover/useHover.js +2 -2
  93. package/dist/esm/hooks/useIdle/useIdle.js +2 -2
  94. package/dist/esm/hooks/useIntersectionObserver/useIntersectionObserver.js +2 -2
  95. package/dist/esm/hooks/useIsFirstRender/useIsFirstRender.js +1 -1
  96. package/dist/esm/hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js +1 -1
  97. package/dist/esm/hooks/useKeyPress/useKeyPress.js +2 -2
  98. package/dist/esm/hooks/useKeyPressEvent/useKeyPressEvent.js +1 -1
  99. package/dist/esm/hooks/useKeysPressed/useKeysPressed.js +2 -2
  100. package/dist/esm/hooks/useLocalStorage/useLocalStorage.js +2 -2
  101. package/dist/esm/hooks/useLogger/useLogger.js +2 -2
  102. package/dist/esm/hooks/useMediaQuery/useMediaQuery.js +1 -1
  103. package/dist/esm/hooks/useMount/useMount.js +1 -1
  104. package/dist/esm/hooks/useMutationObserver.js +1 -1
  105. package/dist/esm/hooks/useNetwork/useNetwork.js +1 -1
  106. package/dist/esm/hooks/useNetwork/useNetwork.js.map +1 -1
  107. package/dist/esm/hooks/useOnline/useOnline.js +1 -1
  108. package/dist/esm/hooks/useOperatingSystem/useOperatingSystem.js +1 -1
  109. package/dist/esm/hooks/useOrientation/useOrientation.js +2 -2
  110. package/dist/esm/hooks/useOrientation/useOrientation.js.map +1 -1
  111. package/dist/esm/hooks/usePageLeave/usePageLeave.js +3 -0
  112. package/dist/esm/hooks/usePageLeave/usePageLeave.js.map +1 -0
  113. package/dist/esm/hooks/usePrevious/usePrevious.js +1 -1
  114. package/dist/esm/hooks/useQueue/useQueue.js +2 -2
  115. package/dist/esm/hooks/useQueue/useQueue.js.map +1 -1
  116. package/dist/esm/hooks/useRenderCount/useRenderCount.js +1 -1
  117. package/dist/esm/hooks/useRerender/useRerender.js +2 -2
  118. package/dist/esm/hooks/useScript/useScript.js +2 -2
  119. package/dist/esm/hooks/useSessionStorage/useSessionStorage.js +2 -2
  120. package/dist/esm/hooks/useSet/useSet.js +2 -2
  121. package/dist/esm/hooks/useSet/useSet.js.map +1 -1
  122. package/dist/esm/hooks/useStep/useStep.js +2 -2
  123. package/dist/esm/hooks/useStorage/useStorage.js +2 -2
  124. package/dist/esm/hooks/useTimeout/useTimeout.js +2 -2
  125. package/dist/esm/hooks/useTimeout/useTimeout.js.map +1 -1
  126. package/dist/esm/hooks/useToggle/useToggle.js +2 -2
  127. package/dist/esm/hooks/useUnmount/useUnmount.js +1 -1
  128. package/dist/esm/hooks/useWindowEvent/useWindowEvent.js +1 -1
  129. package/dist/esm/hooks/useWindowSize/useWindowSize.js +2 -2
  130. package/dist/esm/hooks/useWindowSize/useWindowSize.js.map +1 -1
  131. package/dist/esm/index-Dl6lmkQE.js +43 -0
  132. package/dist/esm/index-Dl6lmkQE.js.map +1 -0
  133. package/dist/esm/index.js +2 -2
  134. package/dist/esm/utils/helpers/debounce.js +1 -1
  135. package/dist/esm/utils/helpers/index.js +1 -1
  136. package/dist/esm/utils/helpers/isClient.js +1 -1
  137. package/dist/esm/utils/helpers/isShallowEqual.js +1 -1
  138. package/dist/esm/utils/helpers/throttle.js +1 -1
  139. package/dist/index.d.ts +70 -19
  140. package/package.json +3 -4
  141. package/dist/cjs/_rollupPluginBabelHelpers-OMepdpg5.js.map +0 -1
  142. package/dist/esm/_rollupPluginBabelHelpers-TF5Io098.js.map +0 -1
package/dist/esm/index.js CHANGED
@@ -1,3 +1,3 @@
1
- /* @license @siberiacancode/reactuse v0.0.11 */
2
- export{useBattery}from"./hooks/useBattery/useBattery.js";export{useBoolean}from"./hooks/useBoolean/useBoolean.js";export{useClickOutside}from"./hooks/useClickOutside/useClickOutside.js";export{legacyCopyToClipboard,useCopyToClipboard}from"./hooks/useCopyToClipboard/useCopyToClipboard.js";export{useCounter}from"./hooks/useCounter/useCounter.js";export{useDebouncedValue}from"./hooks/useDebouncedValue/useDebouncedValue.js";export{useDefault}from"./hooks/useDefault/useDefault.js";export{useDidUpdate}from"./hooks/useDidUpdate/useDidUpdate.js";export{useDocumentTitle}from"./hooks/useDocumentTitle/useDocumentTitle.js";export{useDocumentVisibility}from"./hooks/useDocumentVisibility/useDocumentVisibility.js";export{useEvent}from"./hooks/useEvent/useEvent.js";export{useEventListener}from"./hooks/useEventListener/useEventListener.js";export{useFavicon}from"./hooks/useFavicon/useFavicon.js";export{useHash}from"./hooks/useHash/useHash.js";export{isHotkeyMatch,useHotkeys}from"./hooks/useHotkeys/useHotkeys.js";export{useHover}from"./hooks/useHover/useHover.js";export{useIdle}from"./hooks/useIdle/useIdle.js";export{useIntersectionObserver}from"./hooks/useIntersectionObserver/useIntersectionObserver.js";export{useIsomorphicLayoutEffect}from"./hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js";export{useKeyPress}from"./hooks/useKeyPress/useKeyPress.js";export{useKeyPressEvent}from"./hooks/useKeyPressEvent/useKeyPressEvent.js";export{useKeysPressed}from"./hooks/useKeysPressed/useKeysPressed.js";export{useLocalStorage}from"./hooks/useLocalStorage/useLocalStorage.js";export{useLogger}from"./hooks/useLogger/useLogger.js";export{useMediaQuery}from"./hooks/useMediaQuery/useMediaQuery.js";export{useMount}from"./hooks/useMount/useMount.js";export{getConnection,useNetwork}from"./hooks/useNetwork/useNetwork.js";export{useOnline}from"./hooks/useOnline/useOnline.js";export{getOperatingSystem,useOperatingSystem}from"./hooks/useOperatingSystem/useOperatingSystem.js";export{useOrientation}from"./hooks/useOrientation/useOrientation.js";export{usePrevious}from"./hooks/usePrevious/usePrevious.js";export{useQueue}from"./hooks/useQueue/useQueue.js";export{useRenderCount}from"./hooks/useRenderCount/useRenderCount.js";export{useRerender}from"./hooks/useRerender/useRerender.js";export{SCRIPT_STATUS_ATTRIBUTE_NAME,useScript}from"./hooks/useScript/useScript.js";export{useSessionStorage}from"./hooks/useSessionStorage/useSessionStorage.js";export{useSet}from"./hooks/useSet/useSet.js";export{useStep}from"./hooks/useStep/useStep.js";export{dispatchStorageEvent,useStorage}from"./hooks/useStorage/useStorage.js";export{useTimeout}from"./hooks/useTimeout/useTimeout.js";export{useToggle}from"./hooks/useToggle/useToggle.js";export{useUnmount}from"./hooks/useUnmount/useUnmount.js";export{useWindowEvent}from"./hooks/useWindowEvent/useWindowEvent.js";export{useWindowSize}from"./hooks/useWindowSize/useWindowSize.js";import"./_rollupPluginBabelHelpers-TF5Io098.js";import"react";import"./utils/helpers/debounce.js";import"./utils/helpers/isClient.js";import"./hooks/useMutationObserver.js";import"./utils/helpers/throttle.js";import"./utils/helpers/isShallowEqual.js";
1
+ /* @license @siberiacancode/reactuse v0.0.13 */
2
+ export{useBattery}from"./hooks/useBattery/useBattery.js";export{useBoolean}from"./hooks/useBoolean/useBoolean.js";export{useClickOutside}from"./hooks/useClickOutside/useClickOutside.js";export{legacyCopyToClipboard,useCopyToClipboard}from"./hooks/useCopyToClipboard/useCopyToClipboard.js";export{useCounter}from"./hooks/useCounter/useCounter.js";export{useDebouncedValue}from"./hooks/useDebouncedValue/useDebouncedValue.js";export{useDefault}from"./hooks/useDefault/useDefault.js";export{useDidUpdate}from"./hooks/useDidUpdate/useDidUpdate.js";export{useDocumentTitle}from"./hooks/useDocumentTitle/useDocumentTitle.js";export{useDocumentVisibility}from"./hooks/useDocumentVisibility/useDocumentVisibility.js";export{useEvent}from"./hooks/useEvent/useEvent.js";export{useEventListener}from"./hooks/useEventListener/useEventListener.js";export{useFavicon}from"./hooks/useFavicon/useFavicon.js";export{useHash}from"./hooks/useHash/useHash.js";export{isHotkeyMatch,useHotkeys}from"./hooks/useHotkeys/useHotkeys.js";export{useHover}from"./hooks/useHover/useHover.js";export{useIdle}from"./hooks/useIdle/useIdle.js";export{useIntersectionObserver}from"./hooks/useIntersectionObserver/useIntersectionObserver.js";export{useIsFirstRender}from"./hooks/useIsFirstRender/useIsFirstRender.js";export{useIsomorphicLayoutEffect}from"./hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js";export{useKeyPress}from"./hooks/useKeyPress/useKeyPress.js";export{useKeyPressEvent}from"./hooks/useKeyPressEvent/useKeyPressEvent.js";export{useKeysPressed}from"./hooks/useKeysPressed/useKeysPressed.js";export{useLocalStorage}from"./hooks/useLocalStorage/useLocalStorage.js";export{useLogger}from"./hooks/useLogger/useLogger.js";export{useMediaQuery}from"./hooks/useMediaQuery/useMediaQuery.js";export{useMount}from"./hooks/useMount/useMount.js";export{getConnection,useNetwork}from"./hooks/useNetwork/useNetwork.js";export{useOnline}from"./hooks/useOnline/useOnline.js";export{getOperatingSystem,useOperatingSystem}from"./hooks/useOperatingSystem/useOperatingSystem.js";export{useOrientation}from"./hooks/useOrientation/useOrientation.js";export{usePageLeave}from"./hooks/usePageLeave/usePageLeave.js";export{usePrevious}from"./hooks/usePrevious/usePrevious.js";export{useQueue}from"./hooks/useQueue/useQueue.js";export{useRenderCount}from"./hooks/useRenderCount/useRenderCount.js";export{useRerender}from"./hooks/useRerender/useRerender.js";export{SCRIPT_STATUS_ATTRIBUTE_NAME,useScript}from"./hooks/useScript/useScript.js";export{useSessionStorage}from"./hooks/useSessionStorage/useSessionStorage.js";export{useSet}from"./hooks/useSet/useSet.js";export{useStep}from"./hooks/useStep/useStep.js";export{dispatchStorageEvent,useStorage}from"./hooks/useStorage/useStorage.js";export{useTimeout}from"./hooks/useTimeout/useTimeout.js";export{useToggle}from"./hooks/useToggle/useToggle.js";export{useUnmount}from"./hooks/useUnmount/useUnmount.js";export{useWindowEvent}from"./hooks/useWindowEvent/useWindowEvent.js";export{useWindowSize}from"./hooks/useWindowSize/useWindowSize.js";import"./_rollupPluginBabelHelpers-CtMKhJ6X.js";import"react";import"./utils/helpers/debounce.js";import"./utils/helpers/isClient.js";import"./hooks/useMutationObserver.js";import"./utils/helpers/throttle.js";import"./utils/helpers/isShallowEqual.js";import"./index-Dl6lmkQE.js";
3
3
  //# sourceMappingURL=index.js.map
@@ -1,3 +1,3 @@
1
- /* @license @siberiacancode/reactuse v0.0.11 */
1
+ /* @license @siberiacancode/reactuse v0.0.13 */
2
2
  var r=function(r,n){var t;return function(){for(var e=arguments.length,o=new Array(e),u=0;u<e;u++)o[u]=arguments[u];clearTimeout(t),t=setTimeout((function(){return r.apply(void 0,o)}),n)}};export{r as debounce};
3
3
  //# sourceMappingURL=debounce.js.map
@@ -1,3 +1,3 @@
1
- /* @license @siberiacancode/reactuse v0.0.11 */
1
+ /* @license @siberiacancode/reactuse v0.0.13 */
2
2
  export{debounce}from"./debounce.js";export{isClient}from"./isClient.js";export{isShallowEqual}from"./isShallowEqual.js";export{throttle}from"./throttle.js";
3
3
  //# sourceMappingURL=index.js.map
@@ -1,3 +1,3 @@
1
- /* @license @siberiacancode/reactuse v0.0.11 */
1
+ /* @license @siberiacancode/reactuse v0.0.13 */
2
2
  var n,d,e=!("undefined"==typeof window||null===(n=window)||void 0===n||!n.document||null===(d=window)||void 0===d||null===(d=d.document)||void 0===d||!d.createElement);export{e as isClient};
3
3
  //# sourceMappingURL=isClient.js.map
@@ -1,3 +1,3 @@
1
- /* @license @siberiacancode/reactuse v0.0.11 */
1
+ /* @license @siberiacancode/reactuse v0.0.13 */
2
2
  var r=function(r,e){var t=Object.keys(r),n=Object.keys(e);if(t.length!==n.length)return!1;for(var a=0,f=t;a<f.length;a++){var u=f[a];if(r[u]!==e[u])return!1}return!0};export{r as isShallowEqual};
3
3
  //# sourceMappingURL=isShallowEqual.js.map
@@ -1,3 +1,3 @@
1
- /* @license @siberiacancode/reactuse v0.0.11 */
1
+ /* @license @siberiacancode/reactuse v0.0.13 */
2
2
  var n=function(n,t){var o=!1;return function(){o||(n.apply(void 0,arguments),o=!0,setTimeout((function(){o=!1}),t))}};export{n as throttle};
3
3
  //# sourceMappingURL=throttle.js.map
package/dist/index.d.ts CHANGED
@@ -45,12 +45,35 @@ type UseBooleanReturn = [
45
45
  */
46
46
  declare const useBoolean: (initialValue?: boolean) => UseBooleanReturn;
47
47
 
48
+ /** The use click outside target element type */
48
49
  type UseClickOutsideTarget = React.RefObject<Element | null> | (() => Element) | Element;
50
+ /** The use click outside return type */
49
51
  type UseClickOutsideReturn<Target extends UseClickOutsideTarget | UseClickOutsideTarget[]> = React.RefObject<Target>;
50
52
  type UseClickOutside = {
51
53
  <Target extends UseClickOutsideTarget | UseClickOutsideTarget[]>(target: Target, callback: (event: Event) => void): void;
52
54
  <Target extends UseClickOutsideTarget | UseClickOutsideTarget[]>(callback: (event: Event) => void, target?: never): UseClickOutsideReturn<Target>;
53
55
  };
56
+ /**
57
+ * @name useClickOutside
58
+ * @description - Hook to handle click events outside the specified target element(s)
59
+ *
60
+ * @overload
61
+ * @template Target The target element(s) to detect outside clicks for
62
+ * @param {Target} target The target element(s) to detect outside clicks for
63
+ * @param {(event: Event) => void} callback The callback to execute when a click outside the target is detected
64
+ * @returns {void}
65
+ *
66
+ * @overload
67
+ * @template Target The target element(s) to detect outside clicks for
68
+ * @param {(event: Event) => void} callback The callback to execute when a click outside the target is detected
69
+ * @returns {UseClickOutsideReturn<Target>} A React ref to attach to the target element
70
+ *
71
+ * @example
72
+ * const ref = useClickOutside<HMLDiTvElement>(() => console.log('click outside'));
73
+ *
74
+ * @example
75
+ * useClickOutside(ref, () => console.log('click outside'));
76
+ */
54
77
  declare const useClickOutside: UseClickOutside;
55
78
 
56
79
  declare const legacyCopyToClipboard: (value: string) => void;
@@ -197,6 +220,18 @@ declare function useDocumentTitle(value?: string, options?: UseDocumentTitleOpti
197
220
  */
198
221
  declare const useDocumentVisibility: () => DocumentVisibilityState;
199
222
 
223
+ /**
224
+ * @name useEvent
225
+ * @description - Hook that creates an event and returns a stable reference of it
226
+ *
227
+ * @template Params The type of the params
228
+ * @template Return The type of the return
229
+ * @param {(...args: Params) => Return} callback The callback function
230
+ * @returns {(...args: Params) => Return} The callback
231
+ *
232
+ * @example
233
+ * const onClick = useEvent(() => console.log('clicked'));
234
+ */
200
235
  declare const useEvent: <Params extends unknown[], Return>(callback: (...args: Params) => Return) => ((...args: Params) => Return);
201
236
 
202
237
  type UseEventListenerTarget = React.RefObject<Element | null> | (() => Element) | Element | Window | Document;
@@ -211,25 +246,19 @@ type UseEventListener = {
211
246
  };
212
247
  declare const useEventListener: UseEventListener;
213
248
 
214
- /** The use favicon options */
215
- interface UseFaviconOptions {
216
- /** The rel of the favicon */
217
- rel: string;
218
- }
219
249
  /** The use favicon return type */
220
250
  type UseFaviconReturn = [string, React.Dispatch<React.SetStateAction<string>>];
221
251
  /**
222
252
  * @name useFavicon
223
253
  * @description - Hook that manages the favicon
224
254
  *
225
- * @param {string} initialFavicon The initial favicon. If not provided, the current favicon will be used
226
- * @param {string} [options.rel] The rel of the favicon
255
+ * @param {string} [initialFavicon] The initial favicon. If not provided, the current favicon will be used
227
256
  * @returns {UseFaviconReturn} An array containing the current favicon and a function to update the favicon
228
257
  *
229
258
  * @example
230
259
  * const { href, set } = useFavicon('https://www.google.com/favicon.ico');
231
260
  */
232
- declare const useFavicon: (initialHref?: string, options?: UseFaviconOptions) => {
261
+ declare const useFavicon: (initialHref?: string) => {
233
262
  readonly href: string | undefined;
234
263
  readonly set: (favicon: string) => void;
235
264
  };
@@ -364,6 +393,17 @@ type UseIntersectionObserver = {
364
393
  };
365
394
  declare const useIntersectionObserver: UseIntersectionObserver;
366
395
 
396
+ /**
397
+ * @name useIsFirstRender
398
+ * @description - Hook that returns true if the component is first render
399
+ *
400
+ * @returns {boolean} True if the component is first render
401
+ *
402
+ * @example
403
+ * const isFirstRender = useIsFirstRender();
404
+ */
405
+ declare const useIsFirstRender: () => boolean;
406
+
367
407
  /**
368
408
  * @name useIsomorphicLayoutEffect
369
409
  * @description - Hook conditionally selects either `useLayoutEffect` or `useEffect` based on the environment
@@ -511,9 +551,9 @@ interface UseNetworkReturn {
511
551
  declare const getConnection: () => Connection;
512
552
  /**
513
553
  * @name useNetwork
514
- * @description - Hook to track network status.
554
+ * @description - Hook to track network status
515
555
  *
516
- * @returns {UseNetworkReturn} An object containing the network status.
556
+ * @returns {UseNetworkReturn} An object containing the network status
517
557
  *
518
558
  * @example
519
559
  * const { online, downlink, downlinkMax, effectiveType, rtt, saveData, type } = useNetwork();
@@ -562,6 +602,17 @@ interface UseOrientationReturn {
562
602
  */
563
603
  declare const useOrientation: () => UseOrientationReturn;
564
604
 
605
+ /**
606
+ * @name usePageLeave
607
+ * @description - Hook what calls given function when mouse leaves the page
608
+ *
609
+ * @param {() => void} onPageLeave The callback function what calls then mouse leaves the page
610
+ *
611
+ * @example
612
+ * usePageLeave(() => console.log('on leave'))
613
+ */
614
+ declare const usePageLeave: (onPageLeave: () => void) => void;
615
+
565
616
  /**
566
617
  * @name usePrevious
567
618
  * @description - Hook that returns the previous value
@@ -676,13 +727,13 @@ declare const useSessionStorage: <Value>(key: string, initialValue?: UseStorageI
676
727
  * @description - Hook that manages a set structure
677
728
  *
678
729
  * @template Value The type of the value
679
- * @param {Value[]} values The initial array of the set
730
+ * @param {Value[]} [values] The initial array of the set
680
731
  * @returns {Set<Value>} A set structure
681
732
  *
682
733
  * @example
683
734
  * const set = useSet([1, 2, 3]);
684
735
  */
685
- declare const useSet: <Value>(values: Value[]) => Set<Value>;
736
+ declare const useSet: <Value>(values?: Value[]) => Set<Value>;
686
737
 
687
738
  /** The use step params */
688
739
  interface UseStepParams {
@@ -740,14 +791,14 @@ interface UseTimeoutReturn {
740
791
  }
741
792
  /**
742
793
  * @name useTimeout
743
- * @description Hook that executes a callback function after a specified delay.
794
+ * @description Hook that executes a callback function after a specified delay
744
795
  *
745
- * @param {() => void} callback The function to be executed after the timeout.
746
- * @param {number} delay The delay in milliseconds before the timeout executes the callback function.
747
- * @returns {UseTimeoutReturn} An object with a `ready` boolean state value and a `clear` function to clear timeout.
796
+ * @param {() => void} callback The function to be executed after the timeout
797
+ * @param {number} delay The delay in milliseconds before the timeout executes the callback function
798
+ * @returns {UseTimeoutReturn} An object with a `ready` boolean state value and a `clear` function to clear timeout
748
799
  *
749
800
  * @example
750
- * const { clear, ready } = useTimeout(() => {}, 5000)
801
+ * const { clear, ready } = useTimeout(() => {}, 5000);
751
802
  */
752
803
  declare function useTimeout(callback: () => void, delay: number): UseTimeoutReturn;
753
804
 
@@ -818,11 +869,11 @@ interface UseWindowSizeReturn {
818
869
  * @returns {UseWindowSizeReturn} An object containing the current window width and height
819
870
  *
820
871
  * @example
821
- * const { width, height } = useWindowSize()
872
+ * const { width, height } = useWindowSize();
822
873
  */
823
874
  declare const useWindowSize: (params?: UseWindowSizeParams) => {
824
875
  width: number;
825
876
  height: number;
826
877
  };
827
878
 
828
- export { type ConnectionEffectiveType, type ConnectionType, type OperatingSystem, SCRIPT_STATUS_ATTRIBUTE_NAME, type UseClickOutside, type UseClickOutsideReturn, type UseCounter, type UseCounterOptions, type UseCounterParams, type UseCounterReturn, type UseDocumentTitleOptions, type UseDocumentTitleReturn, type UseEventListener, type UseEventListenerOptions, type UseEventListenerReturn, type UseEventListenerTarget, type UseFaviconOptions, type UseFaviconReturn, type UseHover, type UseHoverOptions, type UseHoverReturn, type UseHoverTarget, type UseIdleReturn, type UseIntersectionObserver, type UseIntersectionObserverOptions, type UseIntersectionObserverReturn, type UseIntersectionObserverTarget, type UseKeyPressEvent, type UseKeyPressEventKey, type UseKeyPressKey, type UseKeyPressOptions, type UseNetworkReturn, type UseOrientationReturn, type UseQueueReturn, type UseScriptOptions, type UseScriptStatus, type UseStorageInitialValue, type UseStorageOptions, type UseStorageReturn, type UseToggleReturn, type UseWindowSizeReturn, dispatchStorageEvent, getConnection, getOperatingSystem, isHotkeyMatch, legacyCopyToClipboard, useBattery, useBoolean, useClickOutside, useCopyToClipboard, useCounter, useDebouncedValue, useDefault, useDidUpdate, useDocumentTitle, useDocumentVisibility, useEvent, useEventListener, useFavicon, useHash, useHotkeys, useHover, useIdle, useIntersectionObserver, useIsomorphicLayoutEffect, useKeyPress, useKeyPressEvent, useKeysPressed, useLocalStorage, useLogger, useMediaQuery, useMount, useNetwork, useOnline, useOperatingSystem, useOrientation, usePrevious, useQueue, useRenderCount, useRerender, useScript, useSessionStorage, useSet, useStep, useStorage, useTimeout, useToggle, useUnmount, useWindowEvent, useWindowSize };
879
+ export { type ConnectionEffectiveType, type ConnectionType, type OperatingSystem, SCRIPT_STATUS_ATTRIBUTE_NAME, type UseClickOutside, type UseClickOutsideReturn, type UseCounter, type UseCounterOptions, type UseCounterParams, type UseCounterReturn, type UseDocumentTitleOptions, type UseDocumentTitleReturn, type UseEventListener, type UseEventListenerOptions, type UseEventListenerReturn, type UseEventListenerTarget, type UseFaviconReturn, type UseHover, type UseHoverOptions, type UseHoverReturn, type UseHoverTarget, type UseIdleReturn, type UseIntersectionObserver, type UseIntersectionObserverOptions, type UseIntersectionObserverReturn, type UseIntersectionObserverTarget, type UseKeyPressEvent, type UseKeyPressEventKey, type UseKeyPressKey, type UseKeyPressOptions, type UseNetworkReturn, type UseOrientationReturn, type UseQueueReturn, type UseScriptOptions, type UseScriptStatus, type UseStorageInitialValue, type UseStorageOptions, type UseStorageReturn, type UseToggleReturn, type UseWindowSizeReturn, dispatchStorageEvent, getConnection, getOperatingSystem, isHotkeyMatch, legacyCopyToClipboard, useBattery, useBoolean, useClickOutside, useCopyToClipboard, useCounter, useDebouncedValue, useDefault, useDidUpdate, useDocumentTitle, useDocumentVisibility, useEvent, useEventListener, useFavicon, useHash, useHotkeys, useHover, useIdle, useIntersectionObserver, useIsFirstRender, useIsomorphicLayoutEffect, useKeyPress, useKeyPressEvent, useKeysPressed, useLocalStorage, useLogger, useMediaQuery, useMount, useNetwork, useOnline, useOperatingSystem, useOrientation, usePageLeave, usePrevious, useQueue, useRenderCount, useRerender, useScript, useSessionStorage, useSet, useStep, useStorage, useTimeout, useToggle, useUnmount, useWindowEvent, useWindowSize };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@siberiacancode/reactuse",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "description": "Ultimate tool",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -64,6 +64,7 @@
64
64
  "@siberiacancode/builder": "^1.3.0",
65
65
  "@siberiacancode/eslint": "^1.1.0",
66
66
  "@siberiacancode/prettier": "^1.1.0",
67
+ "@siberiacancode/vitest": "^1.2.3",
67
68
  "@testing-library/jest-dom": "^6.4.5",
68
69
  "@testing-library/react": "^15.0.7",
69
70
  "@types/doctrine": "^0.0.9",
@@ -74,7 +75,6 @@
74
75
  "doctrine": "^3.0.0",
75
76
  "eslint": "^8.56.0",
76
77
  "husky": "^9.0.11",
77
- "jsdom": "^24.1.0",
78
78
  "lint-staged": "^15.2.2",
79
79
  "markdown-table": "^3.0.3",
80
80
  "react": "^18.2.0",
@@ -82,8 +82,7 @@
82
82
  "shx": "^0.3.4",
83
83
  "typescript": "^5.3.3",
84
84
  "vite": "^5.1.3",
85
- "vitepress": "^1.1.4",
86
- "vitest": "^1.6.0"
85
+ "vitepress": "^1.1.4"
87
86
  },
88
87
  "keywords": [
89
88
  "react",
@@ -1 +0,0 @@
1
- {"version":3,"file":"_rollupPluginBabelHelpers-OMepdpg5.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"_rollupPluginBabelHelpers-TF5Io098.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}