@siberiacancode/reactuse 0.3.3 → 0.3.5

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 (243) hide show
  1. package/dist/cjs/hooks/useActiveElement/useActiveElement.cjs +1 -1
  2. package/dist/cjs/hooks/useActiveElement/useActiveElement.cjs.map +1 -1
  3. package/dist/cjs/hooks/useAutoScroll/useAutoScroll.cjs +1 -1
  4. package/dist/cjs/hooks/useAutoScroll/useAutoScroll.cjs.map +1 -1
  5. package/dist/cjs/hooks/useBreakpoints/useBreakpoints.cjs +1 -1
  6. package/dist/cjs/hooks/useBreakpoints/useBreakpoints.cjs.map +1 -1
  7. package/dist/cjs/hooks/useClickOutside/useClickOutside.cjs +1 -1
  8. package/dist/cjs/hooks/useClickOutside/useClickOutside.cjs.map +1 -1
  9. package/dist/cjs/hooks/useCookie/useCookie.cjs +1 -1
  10. package/dist/cjs/hooks/useCookie/useCookie.cjs.map +1 -1
  11. package/dist/cjs/hooks/useCounter/useCounter.cjs +1 -1
  12. package/dist/cjs/hooks/useCounter/useCounter.cjs.map +1 -1
  13. package/dist/cjs/hooks/useCssVar/useCssVar.cjs +1 -1
  14. package/dist/cjs/hooks/useCssVar/useCssVar.cjs.map +1 -1
  15. package/dist/cjs/hooks/useDeviceMotion/useDeviceMotion.cjs +1 -1
  16. package/dist/cjs/hooks/useDeviceMotion/useDeviceMotion.cjs.map +1 -1
  17. package/dist/cjs/hooks/useDisplayMedia/useDisplayMedia.cjs +1 -1
  18. package/dist/cjs/hooks/useDisplayMedia/useDisplayMedia.cjs.map +1 -1
  19. package/dist/cjs/hooks/useDoubleClick/useDoubleClick.cjs +1 -1
  20. package/dist/cjs/hooks/useDoubleClick/useDoubleClick.cjs.map +1 -1
  21. package/dist/cjs/hooks/useDropZone/useDropZone.cjs +1 -1
  22. package/dist/cjs/hooks/useDropZone/useDropZone.cjs.map +1 -1
  23. package/dist/cjs/hooks/useElementSize/useElementSize.cjs +1 -1
  24. package/dist/cjs/hooks/useElementSize/useElementSize.cjs.map +1 -1
  25. package/dist/cjs/hooks/useEventListener/useEventListener.cjs +1 -1
  26. package/dist/cjs/hooks/useEventListener/useEventListener.cjs.map +1 -1
  27. package/dist/cjs/hooks/useEventSource/useEventSource.cjs +1 -1
  28. package/dist/cjs/hooks/useEventSource/useEventSource.cjs.map +1 -1
  29. package/dist/cjs/hooks/useField/useField.cjs +1 -1
  30. package/dist/cjs/hooks/useField/useField.cjs.map +1 -1
  31. package/dist/cjs/hooks/useFileDialog/useFileDialog.cjs +1 -1
  32. package/dist/cjs/hooks/useFileDialog/useFileDialog.cjs.map +1 -1
  33. package/dist/cjs/hooks/useFocus/useFocus.cjs +1 -1
  34. package/dist/cjs/hooks/useFocus/useFocus.cjs.map +1 -1
  35. package/dist/cjs/hooks/useFocusTrap/useFocusTrap.cjs +1 -1
  36. package/dist/cjs/hooks/useFocusTrap/useFocusTrap.cjs.map +1 -1
  37. package/dist/cjs/hooks/useFullscreen/useFullscreen.cjs +1 -1
  38. package/dist/cjs/hooks/useFullscreen/useFullscreen.cjs.map +1 -1
  39. package/dist/cjs/hooks/useHash/useHash.cjs +1 -1
  40. package/dist/cjs/hooks/useHash/useHash.cjs.map +1 -1
  41. package/dist/cjs/hooks/useHotkeys/useHotkeys.cjs +1 -1
  42. package/dist/cjs/hooks/useHotkeys/useHotkeys.cjs.map +1 -1
  43. package/dist/cjs/hooks/useHover/useHover.cjs +1 -1
  44. package/dist/cjs/hooks/useHover/useHover.cjs.map +1 -1
  45. package/dist/cjs/hooks/useInfiniteScroll/useInfiniteScroll.cjs +1 -1
  46. package/dist/cjs/hooks/useInfiniteScroll/useInfiniteScroll.cjs.map +1 -1
  47. package/dist/cjs/hooks/useIntersectionObserver/useIntersectionObserver.cjs +1 -1
  48. package/dist/cjs/hooks/useIntersectionObserver/useIntersectionObserver.cjs.map +1 -1
  49. package/dist/cjs/hooks/useInterval/useInterval.cjs +1 -1
  50. package/dist/cjs/hooks/useInterval/useInterval.cjs.map +1 -1
  51. package/dist/cjs/hooks/useKeyPress/useKeyPress.cjs +1 -1
  52. package/dist/cjs/hooks/useKeyPress/useKeyPress.cjs.map +1 -1
  53. package/dist/cjs/hooks/useKeyPressEvent/useKeyPressEvent.cjs +1 -1
  54. package/dist/cjs/hooks/useKeyPressEvent/useKeyPressEvent.cjs.map +1 -1
  55. package/dist/cjs/hooks/useKeyboard/useKeyboard.cjs +1 -1
  56. package/dist/cjs/hooks/useKeyboard/useKeyboard.cjs.map +1 -1
  57. package/dist/cjs/hooks/useKeysPressed/useKeysPressed.cjs +1 -1
  58. package/dist/cjs/hooks/useKeysPressed/useKeysPressed.cjs.map +1 -1
  59. package/dist/cjs/hooks/useLockScroll/useLockScroll.cjs +1 -1
  60. package/dist/cjs/hooks/useLockScroll/useLockScroll.cjs.map +1 -1
  61. package/dist/cjs/hooks/useLongPress/useLongPress.cjs +1 -1
  62. package/dist/cjs/hooks/useLongPress/useLongPress.cjs.map +1 -1
  63. package/dist/cjs/hooks/useMeasure/useMeasure.cjs +1 -1
  64. package/dist/cjs/hooks/useMeasure/useMeasure.cjs.map +1 -1
  65. package/dist/cjs/hooks/useMediaControls/useMediaControls.cjs +1 -1
  66. package/dist/cjs/hooks/useMediaControls/useMediaControls.cjs.map +1 -1
  67. package/dist/cjs/hooks/useMouse/useMouse.cjs +1 -1
  68. package/dist/cjs/hooks/useMouse/useMouse.cjs.map +1 -1
  69. package/dist/cjs/hooks/useMutationObserver/useMutationObserver.cjs +1 -1
  70. package/dist/cjs/hooks/useMutationObserver/useMutationObserver.cjs.map +1 -1
  71. package/dist/cjs/hooks/useOtpCredential/useOtpCredential.cjs +1 -1
  72. package/dist/cjs/hooks/useOtpCredential/useOtpCredential.cjs.map +1 -1
  73. package/dist/cjs/hooks/usePaint/usePaint.cjs +1 -1
  74. package/dist/cjs/hooks/usePaint/usePaint.cjs.map +1 -1
  75. package/dist/cjs/hooks/useParallax/useParallax.cjs +1 -1
  76. package/dist/cjs/hooks/useParallax/useParallax.cjs.map +1 -1
  77. package/dist/cjs/hooks/usePictureInPicture/usePictureInPicture.cjs +1 -1
  78. package/dist/cjs/hooks/usePictureInPicture/usePictureInPicture.cjs.map +1 -1
  79. package/dist/cjs/hooks/useRefState/useRefState.cjs +1 -1
  80. package/dist/cjs/hooks/useRefState/useRefState.cjs.map +1 -1
  81. package/dist/cjs/hooks/useResizeObserver/useResizeObserver.cjs +1 -1
  82. package/dist/cjs/hooks/useResizeObserver/useResizeObserver.cjs.map +1 -1
  83. package/dist/cjs/hooks/useRightClick/useRightClick.cjs +1 -1
  84. package/dist/cjs/hooks/useRightClick/useRightClick.cjs.map +1 -1
  85. package/dist/cjs/hooks/useScroll/useScroll.cjs +1 -1
  86. package/dist/cjs/hooks/useScroll/useScroll.cjs.map +1 -1
  87. package/dist/cjs/hooks/useScrollIntoView/useScrollIntoView.cjs +1 -1
  88. package/dist/cjs/hooks/useScrollIntoView/useScrollIntoView.cjs.map +1 -1
  89. package/dist/cjs/hooks/useScrollTo/useScrollTo.cjs +1 -1
  90. package/dist/cjs/hooks/useScrollTo/useScrollTo.cjs.map +1 -1
  91. package/dist/cjs/hooks/useSpeechRecognition/useSpeechRecognition.cjs +1 -1
  92. package/dist/cjs/hooks/useSpeechRecognition/useSpeechRecognition.cjs.map +1 -1
  93. package/dist/cjs/hooks/useSpeechSynthesis/useSpeechSynthesis.cjs +1 -1
  94. package/dist/cjs/hooks/useSpeechSynthesis/useSpeechSynthesis.cjs.map +1 -1
  95. package/dist/cjs/hooks/useSticky/useSticky.cjs +1 -1
  96. package/dist/cjs/hooks/useSticky/useSticky.cjs.map +1 -1
  97. package/dist/cjs/hooks/useStopwatch/useStopwatch.cjs +1 -1
  98. package/dist/cjs/hooks/useStopwatch/useStopwatch.cjs.map +1 -1
  99. package/dist/cjs/hooks/useStorage/useStorage.cjs +1 -1
  100. package/dist/cjs/hooks/useStorage/useStorage.cjs.map +1 -1
  101. package/dist/cjs/hooks/useTextDirection/useTextDirection.cjs +1 -1
  102. package/dist/cjs/hooks/useTextDirection/useTextDirection.cjs.map +1 -1
  103. package/dist/cjs/hooks/useTextareaAutosize/useTextareaAutosize.cjs +1 -1
  104. package/dist/cjs/hooks/useTextareaAutosize/useTextareaAutosize.cjs.map +1 -1
  105. package/dist/cjs/hooks/useTimer/useTimer.cjs +1 -1
  106. package/dist/cjs/hooks/useTimer/useTimer.cjs.map +1 -1
  107. package/dist/cjs/hooks/useUrlSearchParam/useUrlSearchParam.cjs +1 -1
  108. package/dist/cjs/hooks/useUrlSearchParam/useUrlSearchParam.cjs.map +1 -1
  109. package/dist/cjs/hooks/useUrlSearchParams/useUrlSearchParams.cjs +1 -1
  110. package/dist/cjs/hooks/useUrlSearchParams/useUrlSearchParams.cjs.map +1 -1
  111. package/dist/cjs/hooks/useVisibility/useVisibility.cjs +1 -1
  112. package/dist/cjs/hooks/useVisibility/useVisibility.cjs.map +1 -1
  113. package/dist/cjs/hooks/useWindowFocus/useWindowFocus.cjs +1 -1
  114. package/dist/cjs/hooks/useWindowFocus/useWindowFocus.cjs.map +1 -1
  115. package/dist/cjs/index.cjs +1 -1
  116. package/dist/cjs/utils/helpers/isTarget.cjs +1 -1
  117. package/dist/cjs/utils/helpers/isTarget.cjs.map +1 -1
  118. package/dist/esm/hooks/useActiveElement/useActiveElement.mjs +13 -13
  119. package/dist/esm/hooks/useActiveElement/useActiveElement.mjs.map +1 -1
  120. package/dist/esm/hooks/useAutoScroll/useAutoScroll.mjs +24 -24
  121. package/dist/esm/hooks/useAutoScroll/useAutoScroll.mjs.map +1 -1
  122. package/dist/esm/hooks/useBreakpoints/useBreakpoints.mjs +30 -35
  123. package/dist/esm/hooks/useBreakpoints/useBreakpoints.mjs.map +1 -1
  124. package/dist/esm/hooks/useClickOutside/useClickOutside.mjs +15 -14
  125. package/dist/esm/hooks/useClickOutside/useClickOutside.mjs.map +1 -1
  126. package/dist/esm/hooks/useCookie/useCookie.mjs +2 -2
  127. package/dist/esm/hooks/useCookie/useCookie.mjs.map +1 -1
  128. package/dist/esm/hooks/useCounter/useCounter.mjs +2 -2
  129. package/dist/esm/hooks/useCounter/useCounter.mjs.map +1 -1
  130. package/dist/esm/hooks/useCssVar/useCssVar.mjs +8 -8
  131. package/dist/esm/hooks/useCssVar/useCssVar.mjs.map +1 -1
  132. package/dist/esm/hooks/useDeviceMotion/useDeviceMotion.mjs +2 -2
  133. package/dist/esm/hooks/useDeviceMotion/useDeviceMotion.mjs.map +1 -1
  134. package/dist/esm/hooks/useDisplayMedia/useDisplayMedia.mjs +17 -17
  135. package/dist/esm/hooks/useDisplayMedia/useDisplayMedia.mjs.map +1 -1
  136. package/dist/esm/hooks/useDoubleClick/useDoubleClick.mjs +14 -14
  137. package/dist/esm/hooks/useDoubleClick/useDoubleClick.mjs.map +1 -1
  138. package/dist/esm/hooks/useDropZone/useDropZone.mjs +23 -23
  139. package/dist/esm/hooks/useDropZone/useDropZone.mjs.map +1 -1
  140. package/dist/esm/hooks/useElementSize/useElementSize.mjs +14 -14
  141. package/dist/esm/hooks/useElementSize/useElementSize.mjs.map +1 -1
  142. package/dist/esm/hooks/useEventListener/useEventListener.mjs +14 -14
  143. package/dist/esm/hooks/useEventListener/useEventListener.mjs.map +1 -1
  144. package/dist/esm/hooks/useEventSource/useEventSource.mjs +33 -34
  145. package/dist/esm/hooks/useEventSource/useEventSource.mjs.map +1 -1
  146. package/dist/esm/hooks/useField/useField.mjs +2 -1
  147. package/dist/esm/hooks/useField/useField.mjs.map +1 -1
  148. package/dist/esm/hooks/useFileDialog/useFileDialog.mjs +2 -2
  149. package/dist/esm/hooks/useFileDialog/useFileDialog.mjs.map +1 -1
  150. package/dist/esm/hooks/useFocus/useFocus.mjs +20 -20
  151. package/dist/esm/hooks/useFocus/useFocus.mjs.map +1 -1
  152. package/dist/esm/hooks/useFocusTrap/useFocusTrap.mjs +21 -21
  153. package/dist/esm/hooks/useFocusTrap/useFocusTrap.mjs.map +1 -1
  154. package/dist/esm/hooks/useFullscreen/useFullscreen.mjs +2 -2
  155. package/dist/esm/hooks/useFullscreen/useFullscreen.mjs.map +1 -1
  156. package/dist/esm/hooks/useHash/useHash.mjs +2 -2
  157. package/dist/esm/hooks/useHash/useHash.mjs.map +1 -1
  158. package/dist/esm/hooks/useHotkeys/useHotkeys.mjs +24 -16
  159. package/dist/esm/hooks/useHotkeys/useHotkeys.mjs.map +1 -1
  160. package/dist/esm/hooks/useHover/useHover.mjs +16 -16
  161. package/dist/esm/hooks/useHover/useHover.mjs.map +1 -1
  162. package/dist/esm/hooks/useInfiniteScroll/useInfiniteScroll.mjs +16 -16
  163. package/dist/esm/hooks/useInfiniteScroll/useInfiniteScroll.mjs.map +1 -1
  164. package/dist/esm/hooks/useIntersectionObserver/useIntersectionObserver.mjs +26 -18
  165. package/dist/esm/hooks/useIntersectionObserver/useIntersectionObserver.mjs.map +1 -1
  166. package/dist/esm/hooks/useInterval/useInterval.mjs +2 -2
  167. package/dist/esm/hooks/useInterval/useInterval.mjs.map +1 -1
  168. package/dist/esm/hooks/useKeyPress/useKeyPress.mjs +15 -15
  169. package/dist/esm/hooks/useKeyPress/useKeyPress.mjs.map +1 -1
  170. package/dist/esm/hooks/useKeyPressEvent/useKeyPressEvent.mjs +22 -15
  171. package/dist/esm/hooks/useKeyPressEvent/useKeyPressEvent.mjs.map +1 -1
  172. package/dist/esm/hooks/useKeyboard/useKeyboard.mjs +10 -10
  173. package/dist/esm/hooks/useKeyboard/useKeyboard.mjs.map +1 -1
  174. package/dist/esm/hooks/useKeysPressed/useKeysPressed.mjs +12 -12
  175. package/dist/esm/hooks/useKeysPressed/useKeysPressed.mjs.map +1 -1
  176. package/dist/esm/hooks/useLockScroll/useLockScroll.mjs +23 -23
  177. package/dist/esm/hooks/useLockScroll/useLockScroll.mjs.map +1 -1
  178. package/dist/esm/hooks/useLongPress/useLongPress.mjs +22 -22
  179. package/dist/esm/hooks/useLongPress/useLongPress.mjs.map +1 -1
  180. package/dist/esm/hooks/useMeasure/useMeasure.mjs +15 -15
  181. package/dist/esm/hooks/useMeasure/useMeasure.mjs.map +1 -1
  182. package/dist/esm/hooks/useMediaControls/useMediaControls.mjs +28 -28
  183. package/dist/esm/hooks/useMediaControls/useMediaControls.mjs.map +1 -1
  184. package/dist/esm/hooks/useMouse/useMouse.mjs +17 -17
  185. package/dist/esm/hooks/useMouse/useMouse.mjs.map +1 -1
  186. package/dist/esm/hooks/useMutationObserver/useMutationObserver.mjs +17 -16
  187. package/dist/esm/hooks/useMutationObserver/useMutationObserver.mjs.map +1 -1
  188. package/dist/esm/hooks/useOtpCredential/useOtpCredential.mjs +2 -2
  189. package/dist/esm/hooks/useOtpCredential/useOtpCredential.mjs.map +1 -1
  190. package/dist/esm/hooks/usePaint/usePaint.mjs +31 -31
  191. package/dist/esm/hooks/usePaint/usePaint.mjs.map +1 -1
  192. package/dist/esm/hooks/useParallax/useParallax.mjs +24 -23
  193. package/dist/esm/hooks/useParallax/useParallax.mjs.map +1 -1
  194. package/dist/esm/hooks/usePictureInPicture/usePictureInPicture.mjs +25 -25
  195. package/dist/esm/hooks/usePictureInPicture/usePictureInPicture.mjs.map +1 -1
  196. package/dist/esm/hooks/useRefState/useRefState.mjs +1 -0
  197. package/dist/esm/hooks/useRefState/useRefState.mjs.map +1 -1
  198. package/dist/esm/hooks/useResizeObserver/useResizeObserver.mjs +16 -16
  199. package/dist/esm/hooks/useResizeObserver/useResizeObserver.mjs.map +1 -1
  200. package/dist/esm/hooks/useRightClick/useRightClick.mjs +14 -14
  201. package/dist/esm/hooks/useRightClick/useRightClick.mjs.map +1 -1
  202. package/dist/esm/hooks/useScroll/useScroll.mjs +22 -22
  203. package/dist/esm/hooks/useScroll/useScroll.mjs.map +1 -1
  204. package/dist/esm/hooks/useScrollIntoView/useScrollIntoView.mjs +16 -16
  205. package/dist/esm/hooks/useScrollIntoView/useScrollIntoView.mjs.map +1 -1
  206. package/dist/esm/hooks/useScrollTo/useScrollTo.mjs +10 -10
  207. package/dist/esm/hooks/useScrollTo/useScrollTo.mjs.map +1 -1
  208. package/dist/esm/hooks/useSpeechRecognition/useSpeechRecognition.mjs +20 -21
  209. package/dist/esm/hooks/useSpeechRecognition/useSpeechRecognition.mjs.map +1 -1
  210. package/dist/esm/hooks/useSpeechSynthesis/useSpeechSynthesis.mjs +51 -36
  211. package/dist/esm/hooks/useSpeechSynthesis/useSpeechSynthesis.mjs.map +1 -1
  212. package/dist/esm/hooks/useSticky/useSticky.mjs +17 -17
  213. package/dist/esm/hooks/useSticky/useSticky.mjs.map +1 -1
  214. package/dist/esm/hooks/useStopwatch/useStopwatch.mjs +4 -4
  215. package/dist/esm/hooks/useStopwatch/useStopwatch.mjs.map +1 -1
  216. package/dist/esm/hooks/useStorage/useStorage.mjs +40 -37
  217. package/dist/esm/hooks/useStorage/useStorage.mjs.map +1 -1
  218. package/dist/esm/hooks/useTextDirection/useTextDirection.mjs +12 -12
  219. package/dist/esm/hooks/useTextDirection/useTextDirection.mjs.map +1 -1
  220. package/dist/esm/hooks/useTextareaAutosize/useTextareaAutosize.mjs +20 -20
  221. package/dist/esm/hooks/useTextareaAutosize/useTextareaAutosize.mjs.map +1 -1
  222. package/dist/esm/hooks/useTimer/useTimer.mjs +3 -3
  223. package/dist/esm/hooks/useTimer/useTimer.mjs.map +1 -1
  224. package/dist/esm/hooks/useUrlSearchParam/useUrlSearchParam.mjs +2 -2
  225. package/dist/esm/hooks/useUrlSearchParam/useUrlSearchParam.mjs.map +1 -1
  226. package/dist/esm/hooks/useUrlSearchParams/useUrlSearchParams.mjs +2 -2
  227. package/dist/esm/hooks/useUrlSearchParams/useUrlSearchParams.mjs.map +1 -1
  228. package/dist/esm/hooks/useVisibility/useVisibility.mjs +25 -17
  229. package/dist/esm/hooks/useVisibility/useVisibility.mjs.map +1 -1
  230. package/dist/esm/hooks/useWindowFocus/useWindowFocus.mjs +1 -1
  231. package/dist/esm/hooks/useWindowFocus/useWindowFocus.mjs.map +1 -1
  232. package/dist/esm/index.mjs +98 -96
  233. package/dist/esm/utils/helpers/isTarget.mjs +10 -8
  234. package/dist/esm/utils/helpers/isTarget.mjs.map +1 -1
  235. package/dist/types/hooks/useBreakpoints/useBreakpoints.d.ts +1 -11
  236. package/dist/types/hooks/useClickOutside/useClickOutside.d.ts +1 -1
  237. package/dist/types/hooks/useEventSource/useEventSource.d.ts +2 -2
  238. package/dist/types/hooks/useField/useField.d.ts +3 -0
  239. package/dist/types/hooks/useHover/useHover.d.ts +6 -6
  240. package/dist/types/hooks/useRefState/useRefState.d.ts +1 -0
  241. package/dist/types/hooks/useSpeechSynthesis/useSpeechSynthesis.d.ts +1 -1
  242. package/dist/types/utils/helpers/isTarget.d.ts +9 -1
  243. package/package.json +89 -89
@@ -1,12 +1,14 @@
1
- const n = Symbol("target"), o = (e) => "current" in e ? e.current : typeof e.value == "function" ? e.value() : typeof e.value == "string" ? document.querySelector(e.value) : (e.value instanceof Document || e.value instanceof Window || e.value instanceof Element, e.value), l = (e) => ({
1
+ const u = /* @__PURE__ */ Symbol("target"), o = (e) => "current" in e ? e.current : typeof e.value == "function" ? e.value() : typeof e.value == "string" ? document.querySelector(e.value) : (e.value instanceof Document || e.value instanceof Window || e.value instanceof Element, e.value), i = (e) => ({
2
2
  value: e,
3
- type: n
4
- }), u = (e) => typeof e == "object" && ("current" in e || e && e.type === n);
5
- u.wrap = l;
6
- u.getElement = o;
3
+ type: u
4
+ }), n = (e) => typeof e == "object" && ("current" in e || e && e.type === u) || typeof e == "function" && "state" in e && "current" in e, c = (e) => e && "state" in e && e.state;
5
+ n.wrap = i;
6
+ n.getElement = o;
7
+ n.getRefState = c;
7
8
  export {
8
- u as isTarget,
9
- l as target,
10
- n as targetSymbol
9
+ c as getRefState,
10
+ n as isTarget,
11
+ i as target,
12
+ u as targetSymbol
11
13
  };
12
14
  //# sourceMappingURL=isTarget.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"isTarget.mjs","sources":["../../../../src/utils/helpers/isTarget.ts"],"sourcesContent":["import type { RefObject } from 'react';\n\nexport const targetSymbol = Symbol('target');\n\nexport type Target = (() => Element) | string | Document | Element | Window;\n\nexport type HookTarget =\n | RefObject<Element | null | undefined>\n | {\n value: Target;\n type: symbol;\n };\n\nconst getElement = (target: HookTarget) => {\n if ('current' in target) {\n return target.current;\n }\n\n if (typeof target.value === 'function') {\n return target.value();\n }\n\n if (typeof target.value === 'string') {\n return document.querySelector(target.value);\n }\n\n if (target.value instanceof Document) {\n return target.value;\n }\n\n if (target.value instanceof Window) {\n return target.value;\n }\n\n if (target.value instanceof Element) {\n return target.value;\n }\n\n return target.value;\n};\n\nexport const target = (target: Target) => ({\n value: target,\n type: targetSymbol\n});\n\nexport const isTarget = (target: HookTarget) =>\n typeof target === 'object' &&\n ('current' in target || (target && (target as any).type === targetSymbol));\n\nisTarget.wrap = target;\nisTarget.getElement = getElement;\n"],"names":["targetSymbol","getElement","target","isTarget"],"mappings":"AAEO,MAAMA,IAAe,OAAO,QAAQ,GAWrCC,IAAa,CAACC,MACd,aAAaA,IACRA,EAAO,UAGZ,OAAOA,EAAO,SAAU,aACnBA,EAAO,MAAA,IAGZ,OAAOA,EAAO,SAAU,WACnB,SAAS,cAAcA,EAAO,KAAK,KAGxCA,EAAO,iBAAiB,YAIxBA,EAAO,iBAAiB,UAIxBA,EAAO,iBAAiB,SACnBA,EAAO,QAMLA,IAAS,CAACA,OAAoB;AAAA,EACzC,OAAOA;AAAAA,EACP,MAAMF;AACR,IAEaG,IAAW,CAACD,MACvB,OAAOA,KAAW,aACjB,aAAaA,KAAWA,KAAWA,EAAe,SAASF;AAE9DG,EAAS,OAAOD;AAChBC,EAAS,aAAaF;"}
1
+ {"version":3,"file":"isTarget.mjs","sources":["../../../../src/utils/helpers/isTarget.ts"],"sourcesContent":["import type { RefObject } from 'react';\n\nexport const targetSymbol = Symbol('target');\n\nexport type Target = (() => Element) | string | Document | Element | Window;\ninterface StateRef<Value> {\n (node: Value): void;\n current: Value;\n state: Value;\n}\n\nexport type HookTarget =\n | RefObject<Element | null | undefined>\n | StateRef<Element | null | undefined>\n | {\n value: Target;\n type: symbol;\n };\n\nconst getElement = (target: HookTarget) => {\n if ('current' in target) {\n return target.current;\n }\n\n if (typeof target.value === 'function') {\n return target.value();\n }\n\n if (typeof target.value === 'string') {\n return document.querySelector(target.value);\n }\n\n if (target.value instanceof Document) {\n return target.value;\n }\n\n if (target.value instanceof Window) {\n return target.value;\n }\n\n if (target.value instanceof Element) {\n return target.value;\n }\n\n return target.value;\n};\n\nexport const target = (target: Target) => ({\n value: target,\n type: targetSymbol\n});\n\nexport const isTarget = (target: HookTarget) =>\n (typeof target === 'object' &&\n ('current' in target || (target && (target as any).type === targetSymbol))) ||\n (typeof target === 'function' && 'state' in target && 'current' in target);\n\nexport const getRefState = (target?: HookTarget) => target && 'state' in target && target.state;\n\nisTarget.wrap = target;\nisTarget.getElement = getElement;\nisTarget.getRefState = getRefState;\n"],"names":["targetSymbol","getElement","target","isTarget","getRefState"],"mappings":"AAEO,MAAMA,2BAAsB,QAAQ,GAiBrCC,IAAa,CAACC,MACd,aAAaA,IACRA,EAAO,UAGZ,OAAOA,EAAO,SAAU,aACnBA,EAAO,MAAA,IAGZ,OAAOA,EAAO,SAAU,WACnB,SAAS,cAAcA,EAAO,KAAK,KAGxCA,EAAO,iBAAiB,YAIxBA,EAAO,iBAAiB,UAIxBA,EAAO,iBAAiB,SACnBA,EAAO,QAMLA,IAAS,CAACA,OAAoB;AAAA,EACzC,OAAOA;AAAAA,EACP,MAAMF;AACR,IAEaG,IAAW,CAACD,MACtB,OAAOA,KAAW,aAChB,aAAaA,KAAWA,KAAWA,EAAe,SAASF,MAC7D,OAAOE,KAAW,cAAc,WAAWA,KAAU,aAAaA,GAExDE,IAAc,CAACF,MAAwBA,KAAU,WAAWA,KAAUA,EAAO;AAE1FC,EAAS,OAAOD;AAChBC,EAAS,aAAaF;AACtBE,EAAS,cAAcC;"}
@@ -14,16 +14,6 @@ export type UseBreakpointsReturn<Breakpoint extends string = string> = {
14
14
  smallerOrEqual: (breakpoint: Breakpoint) => boolean;
15
15
  /** The function that checks if the current breakpoint is between to the given breakpoints */
16
16
  between: (a: Breakpoint, b: Breakpoint) => boolean;
17
- /** The function that checks if the current breakpoint is greater than to the given breakpoint */
18
- isGreater: (breakpoint: Breakpoint) => boolean;
19
- /** The function that checks if the current breakpoint is greater than or equal to the given breakpoint */
20
- isGreaterOrEqual: (breakpoint: Breakpoint) => boolean;
21
- /** The function that checks if the current breakpoint is smaller than to the given breakpoint */
22
- isSmaller: (breakpoint: Breakpoint) => boolean;
23
- /** The function that checks if the current breakpoint is smaller than or equal to the given breakpoint */
24
- isSmallerOrEqual: (breakpoint: Breakpoint) => boolean;
25
- /** The function that checks if the current breakpoint is between to the given breakpoints */
26
- isInBetween: (a: Breakpoint, b: Breakpoint) => boolean;
27
17
  /** The function that returns the current breakpoints */
28
18
  current: () => Breakpoint[];
29
19
  /** The function that returns the current active breakpoint */
@@ -41,7 +31,7 @@ export type UseBreakpointsReturn<Breakpoint extends string = string> = {
41
31
  * @returns {UseBreakpointsReturn<Breakpoint>} An object containing the current breakpoint
42
32
  *
43
33
  * @example
44
- * const { greaterOrEqual, smallerOrEqual, current } = useBreakpoints({ mobile: 0, tablet: 640, laptop: 1024, desktop: 1280 });
34
+ * const { greater, smaller, between, current, active, ...breakpoints } = useBreakpoints({ mobile: 0, tablet: 640, laptop: 1024, desktop: 1280 });
45
35
  */
46
36
  export declare const useBreakpoints: <Breakpoint extends string>(breakpoints: Breakpoints<Breakpoint>, strategy?: UseBreakpointsStrategy) => UseBreakpointsReturn<Breakpoint>;
47
37
  /** Breakpoints from Material UI */
@@ -21,7 +21,7 @@ export interface UseClickOutside {
21
21
  * @overload
22
22
  * @template Target The target element(s)
23
23
  * @param {(event: Event) => void} callback The callback to execute when a click outside the target is detected
24
- * @returns {(node: Target) => void} A React ref to attach to the target element
24
+ * @returns {StateRef<Target>} A ref to attach to the target element
25
25
  *
26
26
  * @example
27
27
  * const ref = useClickOutside<HTMLDivElement>(() => console.log('click outside'));
@@ -22,7 +22,7 @@ interface UseEventSourceReturn<Data = any> {
22
22
  instance?: EventSource;
23
23
  isConnecting: boolean;
24
24
  isError: boolean;
25
- isOpen: boolean;
25
+ opened: boolean;
26
26
  /** Closes the EventSource connection gracefully */
27
27
  close: () => void;
28
28
  /** Reopen the EventSource connection */
@@ -42,7 +42,7 @@ interface UseEventSourceReturn<Data = any> {
42
42
  * @returns {UseEventSourceReturn<Data>} The EventSource state and controls
43
43
  *
44
44
  * @example
45
- * const { instance, data, isConnecting, isOpen, isError, close, open } = useEventSource('url', ['message']);
45
+ * const { instance, data, connecting, opened, isError, close, open } = useEventSource('url', ['message']);
46
46
  */
47
47
  export declare const useEventSource: <QueryData = any, Data = QueryData>(url: string | URL, events?: string[], options?: UseEventSourceOptions<QueryData, Data>) => UseEventSourceReturn<Data>;
48
48
  export {};
@@ -1,3 +1,4 @@
1
+ import { RefObject } from 'react';
1
2
  /** The use field params type */
2
3
  export interface UseFieldParams<Value> {
3
4
  /** The auto focus */
@@ -51,6 +52,8 @@ export interface UseFieldReturn<Value> {
51
52
  dirty: boolean;
52
53
  /** The error state */
53
54
  error?: string;
55
+ /** The input ref */
56
+ ref: RefObject<HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement | null>;
54
57
  /** The set error function */
55
58
  touched: boolean;
56
59
  /** The set error function */
@@ -31,7 +31,7 @@ export interface UseHover {
31
31
  * @overload
32
32
  * @param {HookTarget} target The target element to be hovered
33
33
  * @param {(event: Event) => void} [callback] The callback function to be invoked on mouse enter
34
- * @returns {boolean} The state of the hover
34
+ * @returns {boolean} The value of the hover
35
35
  *
36
36
  * @example
37
37
  * const hovering = useHover(ref, () => console.log('callback'));
@@ -40,7 +40,7 @@ export interface UseHover {
40
40
  * @param {HookTarget} target The target element to be hovered
41
41
  * @param {(event: Event) => void} [options.onEntry] The callback function to be invoked on mouse enter
42
42
  * @param {(event: Event) => void} [options.onLeave] The callback function to be invoked on mouse leave
43
- * @returns {boolean} The state of the hover
43
+ * @returns {boolean} The value of the hover
44
44
  *
45
45
  * @example
46
46
  * const hovering = useHover(ref, options);
@@ -48,18 +48,18 @@ export interface UseHover {
48
48
  * @overload
49
49
  * @template Target The target element
50
50
  * @param {(event: Event) => void} [callback] The callback function to be invoked on mouse enter
51
- * @returns {{ ref: StateRef<Target> } & UseHoverReturn} The state of the hover
51
+ * @returns {{ ref: StateRef<Target> } & UseHoverReturn} The object with the ref and the value of the hover
52
52
  *
53
53
  * @example
54
- * const [ref, hovering] = useHover(() => console.log('callback'));
54
+ * const { ref, value } = useHover(() => console.log('callback'));
55
55
  *
56
56
  * @overload
57
57
  * @template Target The target element
58
58
  * @param {(event: Event) => void} [options.onEntry] The callback function to be invoked on mouse enter
59
59
  * @param {(event: Event) => void} [options.onLeave] The callback function to be invoked on mouse leave
60
- * @returns {{ ref: StateRef<Target> } & UseHoverReturn} The state of the hover
60
+ * @returns {{ ref: StateRef<Target> } & UseHoverReturn} The object with the ref and the value of the hover
61
61
  *
62
62
  * @example
63
- * const [ref, hovering] = useHover(options);
63
+ * const { ref, value } = useHover(options);
64
64
  */
65
65
  export declare const useHover: UseHover;
@@ -3,6 +3,7 @@ export interface StateRef<Value> {
3
3
  current: Value;
4
4
  state?: Value;
5
5
  }
6
+ export declare const createRefState: <Value>(initialValue: Value | undefined, setState: (value: Value) => void) => StateRef<Value>;
6
7
  /**
7
8
  * @name useRefState
8
9
  * @description - Hook that returns the state reference of the value
@@ -26,7 +26,7 @@ export interface UseSpeechSynthesisReturn {
26
26
  /** Indicates if the SpeechSynthesis API is supported in the current environment. */
27
27
  supported: boolean;
28
28
  /** The SpeechSynthesisUtterance instance. */
29
- utterance: SpeechSynthesisUtterance | null;
29
+ utterance: SpeechSynthesisUtterance | undefined;
30
30
  /** Function to pause speech synthesis. */
31
31
  pause: () => void;
32
32
  /** Function to resume speech synthesis. */
@@ -1,7 +1,12 @@
1
1
  import { RefObject } from 'react';
2
2
  export declare const targetSymbol: unique symbol;
3
3
  export type Target = (() => Element) | string | Document | Element | Window;
4
- export type HookTarget = RefObject<Element | null | undefined> | {
4
+ interface StateRef<Value> {
5
+ (node: Value): void;
6
+ current: Value;
7
+ state: Value;
8
+ }
9
+ export type HookTarget = RefObject<Element | null | undefined> | StateRef<Element | null | undefined> | {
5
10
  value: Target;
6
11
  type: symbol;
7
12
  };
@@ -16,4 +21,7 @@ export declare const isTarget: {
16
21
  type: symbol;
17
22
  };
18
23
  getElement: (target: HookTarget) => Window | Document | Element | null | undefined;
24
+ getRefState: (target?: HookTarget) => false | Element | null | undefined;
19
25
  };
26
+ export declare const getRefState: (target?: HookTarget) => false | Element | null | undefined;
27
+ export {};
package/package.json CHANGED
@@ -1,89 +1,89 @@
1
- {
2
- "name": "@siberiacancode/reactuse",
3
- "version": "0.3.3",
4
- "description": "The ultimate collection of react hooks",
5
- "author": {
6
- "name": "SIBERIA CAN CODE 🧊",
7
- "url": "https://github.com/siberiacancode"
8
- },
9
- "license": "MIT",
10
- "homepage": "https://siberiacancode.github.io/reactuse/",
11
- "repository": {
12
- "type": "git",
13
- "url": "git+https://github.com/siberiacancode/reactuse.git",
14
- "directory": "packages/core"
15
- },
16
- "bugs": "https://github.com/siberiacancode/reactuse/issues",
17
- "keywords": [
18
- "react",
19
- "react hooks",
20
- "react use",
21
- "use",
22
- "hooks"
23
- ],
24
- "sideEffects": false,
25
- "exports": {
26
- "types": "./dist/types/index.d.ts",
27
- "import": "./dist/esm/index.mjs",
28
- "require": "./dist/cjs/index.cjs"
29
- },
30
- "main": "dist/cjs/index.cjs",
31
- "module": "dist/esm/index.mjs",
32
- "types": "dist/types/index.d.ts",
33
- "files": [
34
- "dist"
35
- ],
36
- "engines": {
37
- "node": ">=14"
38
- },
39
- "publishConfig": {
40
- "access": "public"
41
- },
42
- "scripts": {
43
- "prepublishOnly": "pnpm unit-test run && pnpm build",
44
- "build": "shx rm -rf dist && vite build",
45
- "build:js": "tsc --project tsconfig.build.json && prettier --write src/bundle",
46
- "lint": "eslint . --fix",
47
- "lint-inspector": "npx @eslint/config-inspector@latest",
48
- "format": "prettier --write .",
49
- "pretty": "pnpm lint && pnpm format",
50
- "unit-test": "vitest",
51
- "lint-staged": "lint-staged"
52
- },
53
- "peerDependencies": {
54
- "@types/react": "^18 || ^19",
55
- "react": "^18 || ^19",
56
- "react-dom": "^18 || ^19"
57
- },
58
- "peerDependenciesMeta": {
59
- "@types/react": {
60
- "optional": true
61
- }
62
- },
63
- "dependencies": {
64
- "screenfull": "^6.0.2"
65
- },
66
- "devDependencies": {
67
- "@siberiacancode/vitest": "^2.2.0",
68
- "@testing-library/dom": "^10.4.1",
69
- "@testing-library/react": "^16.3.0",
70
- "@types/dom-speech-recognition": "^0.0.7",
71
- "@types/react": "^19.2.2",
72
- "@types/react-dom": "^19.2.2",
73
- "@types/web-bluetooth": "^0.0.21",
74
- "@vitejs/plugin-react": "^5.1.0",
75
- "core-js": "^3.46.0",
76
- "react": "^19.2.0",
77
- "react-dom": "^19.2.0",
78
- "shx": "^0.4.0",
79
- "vite": "^7.2.2",
80
- "vite-plugin-dts": "^4.5.4",
81
- "vitest": "^4.0.8"
82
- },
83
- "lint-staged": {
84
- "*.{js,ts,tsx}": [
85
- "eslint --fix",
86
- "prettier --write"
87
- ]
88
- }
89
- }
1
+ {
2
+ "name": "@siberiacancode/reactuse",
3
+ "version": "0.3.5",
4
+ "description": "The ultimate collection of react hooks",
5
+ "author": {
6
+ "name": "SIBERIA CAN CODE 🧊",
7
+ "url": "https://github.com/siberiacancode"
8
+ },
9
+ "license": "MIT",
10
+ "homepage": "https://siberiacancode.github.io/reactuse/",
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/siberiacancode/reactuse.git",
14
+ "directory": "packages/core"
15
+ },
16
+ "bugs": "https://github.com/siberiacancode/reactuse/issues",
17
+ "keywords": [
18
+ "react",
19
+ "react hooks",
20
+ "react use",
21
+ "use",
22
+ "hooks"
23
+ ],
24
+ "sideEffects": false,
25
+ "exports": {
26
+ "types": "./dist/types/index.d.ts",
27
+ "import": "./dist/esm/index.mjs",
28
+ "require": "./dist/cjs/index.cjs"
29
+ },
30
+ "main": "dist/cjs/index.cjs",
31
+ "module": "dist/esm/index.mjs",
32
+ "types": "dist/types/index.d.ts",
33
+ "files": [
34
+ "dist"
35
+ ],
36
+ "engines": {
37
+ "node": ">=14"
38
+ },
39
+ "publishConfig": {
40
+ "access": "public"
41
+ },
42
+ "scripts": {
43
+ "prepublishOnly": "pnpm unit-test run && pnpm build",
44
+ "build": "shx rm -rf dist && vite build",
45
+ "build:js": "tsc --project tsconfig.build.json && prettier --write src/bundle",
46
+ "lint": "eslint . --fix",
47
+ "lint-inspector": "npx @eslint/config-inspector@latest",
48
+ "format": "prettier --write .",
49
+ "pretty": "pnpm lint && pnpm format",
50
+ "unit-test": "vitest",
51
+ "lint-staged": "lint-staged"
52
+ },
53
+ "peerDependencies": {
54
+ "@types/react": "^18 || ^19",
55
+ "react": "^18 || ^19",
56
+ "react-dom": "^18 || ^19"
57
+ },
58
+ "peerDependenciesMeta": {
59
+ "@types/react": {
60
+ "optional": true
61
+ }
62
+ },
63
+ "dependencies": {
64
+ "screenfull": "^6.0.2"
65
+ },
66
+ "devDependencies": {
67
+ "@siberiacancode/vitest": "^2.3.0",
68
+ "@testing-library/dom": "^10.4.1",
69
+ "@testing-library/react": "^16.3.1",
70
+ "@types/dom-speech-recognition": "^0.0.7",
71
+ "@types/react": "^19.2.7",
72
+ "@types/react-dom": "^19.2.3",
73
+ "@types/web-bluetooth": "^0.0.21",
74
+ "@vitejs/plugin-react": "^5.1.2",
75
+ "core-js": "^3.47.0",
76
+ "react": "^19.2.3",
77
+ "react-dom": "^19.2.3",
78
+ "shx": "^0.4.0",
79
+ "vite": "^7.3.0",
80
+ "vite-plugin-dts": "^4.5.4",
81
+ "vitest": "^4.0.16"
82
+ },
83
+ "lint-staged": {
84
+ "*.{js,ts,tsx}": [
85
+ "eslint --fix",
86
+ "prettier --write"
87
+ ]
88
+ }
89
+ }