@siberiacancode/reactuse 0.3.3 → 0.3.4

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 (220) 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/useFileDialog/useFileDialog.cjs +1 -1
  28. package/dist/cjs/hooks/useFileDialog/useFileDialog.cjs.map +1 -1
  29. package/dist/cjs/hooks/useFocus/useFocus.cjs +1 -1
  30. package/dist/cjs/hooks/useFocus/useFocus.cjs.map +1 -1
  31. package/dist/cjs/hooks/useFocusTrap/useFocusTrap.cjs +1 -1
  32. package/dist/cjs/hooks/useFocusTrap/useFocusTrap.cjs.map +1 -1
  33. package/dist/cjs/hooks/useFullscreen/useFullscreen.cjs +1 -1
  34. package/dist/cjs/hooks/useFullscreen/useFullscreen.cjs.map +1 -1
  35. package/dist/cjs/hooks/useHash/useHash.cjs +1 -1
  36. package/dist/cjs/hooks/useHash/useHash.cjs.map +1 -1
  37. package/dist/cjs/hooks/useHotkeys/useHotkeys.cjs +1 -1
  38. package/dist/cjs/hooks/useHotkeys/useHotkeys.cjs.map +1 -1
  39. package/dist/cjs/hooks/useHover/useHover.cjs +1 -1
  40. package/dist/cjs/hooks/useHover/useHover.cjs.map +1 -1
  41. package/dist/cjs/hooks/useInfiniteScroll/useInfiniteScroll.cjs +1 -1
  42. package/dist/cjs/hooks/useInfiniteScroll/useInfiniteScroll.cjs.map +1 -1
  43. package/dist/cjs/hooks/useIntersectionObserver/useIntersectionObserver.cjs +1 -1
  44. package/dist/cjs/hooks/useIntersectionObserver/useIntersectionObserver.cjs.map +1 -1
  45. package/dist/cjs/hooks/useInterval/useInterval.cjs +1 -1
  46. package/dist/cjs/hooks/useInterval/useInterval.cjs.map +1 -1
  47. package/dist/cjs/hooks/useKeyPress/useKeyPress.cjs +1 -1
  48. package/dist/cjs/hooks/useKeyPress/useKeyPress.cjs.map +1 -1
  49. package/dist/cjs/hooks/useKeyPressEvent/useKeyPressEvent.cjs +1 -1
  50. package/dist/cjs/hooks/useKeyPressEvent/useKeyPressEvent.cjs.map +1 -1
  51. package/dist/cjs/hooks/useKeyboard/useKeyboard.cjs +1 -1
  52. package/dist/cjs/hooks/useKeyboard/useKeyboard.cjs.map +1 -1
  53. package/dist/cjs/hooks/useKeysPressed/useKeysPressed.cjs +1 -1
  54. package/dist/cjs/hooks/useKeysPressed/useKeysPressed.cjs.map +1 -1
  55. package/dist/cjs/hooks/useLockScroll/useLockScroll.cjs +1 -1
  56. package/dist/cjs/hooks/useLockScroll/useLockScroll.cjs.map +1 -1
  57. package/dist/cjs/hooks/useLongPress/useLongPress.cjs +1 -1
  58. package/dist/cjs/hooks/useLongPress/useLongPress.cjs.map +1 -1
  59. package/dist/cjs/hooks/useMeasure/useMeasure.cjs +1 -1
  60. package/dist/cjs/hooks/useMeasure/useMeasure.cjs.map +1 -1
  61. package/dist/cjs/hooks/useMediaControls/useMediaControls.cjs +1 -1
  62. package/dist/cjs/hooks/useMediaControls/useMediaControls.cjs.map +1 -1
  63. package/dist/cjs/hooks/useMouse/useMouse.cjs +1 -1
  64. package/dist/cjs/hooks/useMouse/useMouse.cjs.map +1 -1
  65. package/dist/cjs/hooks/useMutationObserver/useMutationObserver.cjs +1 -1
  66. package/dist/cjs/hooks/useMutationObserver/useMutationObserver.cjs.map +1 -1
  67. package/dist/cjs/hooks/useOtpCredential/useOtpCredential.cjs +1 -1
  68. package/dist/cjs/hooks/useOtpCredential/useOtpCredential.cjs.map +1 -1
  69. package/dist/cjs/hooks/usePaint/usePaint.cjs +1 -1
  70. package/dist/cjs/hooks/usePaint/usePaint.cjs.map +1 -1
  71. package/dist/cjs/hooks/useParallax/useParallax.cjs +1 -1
  72. package/dist/cjs/hooks/useParallax/useParallax.cjs.map +1 -1
  73. package/dist/cjs/hooks/usePictureInPicture/usePictureInPicture.cjs +1 -1
  74. package/dist/cjs/hooks/usePictureInPicture/usePictureInPicture.cjs.map +1 -1
  75. package/dist/cjs/hooks/useRefState/useRefState.cjs +1 -1
  76. package/dist/cjs/hooks/useRefState/useRefState.cjs.map +1 -1
  77. package/dist/cjs/hooks/useResizeObserver/useResizeObserver.cjs +1 -1
  78. package/dist/cjs/hooks/useResizeObserver/useResizeObserver.cjs.map +1 -1
  79. package/dist/cjs/hooks/useRightClick/useRightClick.cjs +1 -1
  80. package/dist/cjs/hooks/useRightClick/useRightClick.cjs.map +1 -1
  81. package/dist/cjs/hooks/useScroll/useScroll.cjs +1 -1
  82. package/dist/cjs/hooks/useScroll/useScroll.cjs.map +1 -1
  83. package/dist/cjs/hooks/useScrollIntoView/useScrollIntoView.cjs +1 -1
  84. package/dist/cjs/hooks/useScrollIntoView/useScrollIntoView.cjs.map +1 -1
  85. package/dist/cjs/hooks/useScrollTo/useScrollTo.cjs +1 -1
  86. package/dist/cjs/hooks/useScrollTo/useScrollTo.cjs.map +1 -1
  87. package/dist/cjs/hooks/useSticky/useSticky.cjs +1 -1
  88. package/dist/cjs/hooks/useSticky/useSticky.cjs.map +1 -1
  89. package/dist/cjs/hooks/useStopwatch/useStopwatch.cjs +1 -1
  90. package/dist/cjs/hooks/useStopwatch/useStopwatch.cjs.map +1 -1
  91. package/dist/cjs/hooks/useStorage/useStorage.cjs +1 -1
  92. package/dist/cjs/hooks/useStorage/useStorage.cjs.map +1 -1
  93. package/dist/cjs/hooks/useTextDirection/useTextDirection.cjs +1 -1
  94. package/dist/cjs/hooks/useTextDirection/useTextDirection.cjs.map +1 -1
  95. package/dist/cjs/hooks/useTextareaAutosize/useTextareaAutosize.cjs +1 -1
  96. package/dist/cjs/hooks/useTextareaAutosize/useTextareaAutosize.cjs.map +1 -1
  97. package/dist/cjs/hooks/useTimer/useTimer.cjs +1 -1
  98. package/dist/cjs/hooks/useTimer/useTimer.cjs.map +1 -1
  99. package/dist/cjs/hooks/useUrlSearchParam/useUrlSearchParam.cjs +1 -1
  100. package/dist/cjs/hooks/useUrlSearchParam/useUrlSearchParam.cjs.map +1 -1
  101. package/dist/cjs/hooks/useUrlSearchParams/useUrlSearchParams.cjs +1 -1
  102. package/dist/cjs/hooks/useUrlSearchParams/useUrlSearchParams.cjs.map +1 -1
  103. package/dist/cjs/hooks/useVisibility/useVisibility.cjs +1 -1
  104. package/dist/cjs/hooks/useVisibility/useVisibility.cjs.map +1 -1
  105. package/dist/cjs/index.cjs +1 -1
  106. package/dist/cjs/utils/helpers/isTarget.cjs +1 -1
  107. package/dist/cjs/utils/helpers/isTarget.cjs.map +1 -1
  108. package/dist/esm/hooks/useActiveElement/useActiveElement.mjs +13 -13
  109. package/dist/esm/hooks/useActiveElement/useActiveElement.mjs.map +1 -1
  110. package/dist/esm/hooks/useAutoScroll/useAutoScroll.mjs +24 -24
  111. package/dist/esm/hooks/useAutoScroll/useAutoScroll.mjs.map +1 -1
  112. package/dist/esm/hooks/useBreakpoints/useBreakpoints.mjs +30 -35
  113. package/dist/esm/hooks/useBreakpoints/useBreakpoints.mjs.map +1 -1
  114. package/dist/esm/hooks/useClickOutside/useClickOutside.mjs +15 -14
  115. package/dist/esm/hooks/useClickOutside/useClickOutside.mjs.map +1 -1
  116. package/dist/esm/hooks/useCookie/useCookie.mjs +2 -2
  117. package/dist/esm/hooks/useCookie/useCookie.mjs.map +1 -1
  118. package/dist/esm/hooks/useCounter/useCounter.mjs +2 -2
  119. package/dist/esm/hooks/useCounter/useCounter.mjs.map +1 -1
  120. package/dist/esm/hooks/useCssVar/useCssVar.mjs +8 -8
  121. package/dist/esm/hooks/useCssVar/useCssVar.mjs.map +1 -1
  122. package/dist/esm/hooks/useDeviceMotion/useDeviceMotion.mjs +2 -2
  123. package/dist/esm/hooks/useDeviceMotion/useDeviceMotion.mjs.map +1 -1
  124. package/dist/esm/hooks/useDisplayMedia/useDisplayMedia.mjs +17 -17
  125. package/dist/esm/hooks/useDisplayMedia/useDisplayMedia.mjs.map +1 -1
  126. package/dist/esm/hooks/useDoubleClick/useDoubleClick.mjs +14 -14
  127. package/dist/esm/hooks/useDoubleClick/useDoubleClick.mjs.map +1 -1
  128. package/dist/esm/hooks/useDropZone/useDropZone.mjs +23 -23
  129. package/dist/esm/hooks/useDropZone/useDropZone.mjs.map +1 -1
  130. package/dist/esm/hooks/useElementSize/useElementSize.mjs +14 -14
  131. package/dist/esm/hooks/useElementSize/useElementSize.mjs.map +1 -1
  132. package/dist/esm/hooks/useEventListener/useEventListener.mjs +14 -14
  133. package/dist/esm/hooks/useEventListener/useEventListener.mjs.map +1 -1
  134. package/dist/esm/hooks/useFileDialog/useFileDialog.mjs +2 -2
  135. package/dist/esm/hooks/useFileDialog/useFileDialog.mjs.map +1 -1
  136. package/dist/esm/hooks/useFocus/useFocus.mjs +20 -20
  137. package/dist/esm/hooks/useFocus/useFocus.mjs.map +1 -1
  138. package/dist/esm/hooks/useFocusTrap/useFocusTrap.mjs +21 -21
  139. package/dist/esm/hooks/useFocusTrap/useFocusTrap.mjs.map +1 -1
  140. package/dist/esm/hooks/useFullscreen/useFullscreen.mjs +2 -2
  141. package/dist/esm/hooks/useFullscreen/useFullscreen.mjs.map +1 -1
  142. package/dist/esm/hooks/useHash/useHash.mjs +2 -2
  143. package/dist/esm/hooks/useHash/useHash.mjs.map +1 -1
  144. package/dist/esm/hooks/useHotkeys/useHotkeys.mjs +24 -16
  145. package/dist/esm/hooks/useHotkeys/useHotkeys.mjs.map +1 -1
  146. package/dist/esm/hooks/useHover/useHover.mjs +16 -16
  147. package/dist/esm/hooks/useHover/useHover.mjs.map +1 -1
  148. package/dist/esm/hooks/useInfiniteScroll/useInfiniteScroll.mjs +16 -16
  149. package/dist/esm/hooks/useInfiniteScroll/useInfiniteScroll.mjs.map +1 -1
  150. package/dist/esm/hooks/useIntersectionObserver/useIntersectionObserver.mjs +26 -18
  151. package/dist/esm/hooks/useIntersectionObserver/useIntersectionObserver.mjs.map +1 -1
  152. package/dist/esm/hooks/useInterval/useInterval.mjs +2 -2
  153. package/dist/esm/hooks/useInterval/useInterval.mjs.map +1 -1
  154. package/dist/esm/hooks/useKeyPress/useKeyPress.mjs +15 -15
  155. package/dist/esm/hooks/useKeyPress/useKeyPress.mjs.map +1 -1
  156. package/dist/esm/hooks/useKeyPressEvent/useKeyPressEvent.mjs +22 -15
  157. package/dist/esm/hooks/useKeyPressEvent/useKeyPressEvent.mjs.map +1 -1
  158. package/dist/esm/hooks/useKeyboard/useKeyboard.mjs +10 -10
  159. package/dist/esm/hooks/useKeyboard/useKeyboard.mjs.map +1 -1
  160. package/dist/esm/hooks/useKeysPressed/useKeysPressed.mjs +12 -12
  161. package/dist/esm/hooks/useKeysPressed/useKeysPressed.mjs.map +1 -1
  162. package/dist/esm/hooks/useLockScroll/useLockScroll.mjs +23 -23
  163. package/dist/esm/hooks/useLockScroll/useLockScroll.mjs.map +1 -1
  164. package/dist/esm/hooks/useLongPress/useLongPress.mjs +16 -16
  165. package/dist/esm/hooks/useLongPress/useLongPress.mjs.map +1 -1
  166. package/dist/esm/hooks/useMeasure/useMeasure.mjs +15 -15
  167. package/dist/esm/hooks/useMeasure/useMeasure.mjs.map +1 -1
  168. package/dist/esm/hooks/useMediaControls/useMediaControls.mjs +28 -28
  169. package/dist/esm/hooks/useMediaControls/useMediaControls.mjs.map +1 -1
  170. package/dist/esm/hooks/useMouse/useMouse.mjs +17 -17
  171. package/dist/esm/hooks/useMouse/useMouse.mjs.map +1 -1
  172. package/dist/esm/hooks/useMutationObserver/useMutationObserver.mjs +17 -16
  173. package/dist/esm/hooks/useMutationObserver/useMutationObserver.mjs.map +1 -1
  174. package/dist/esm/hooks/useOtpCredential/useOtpCredential.mjs +2 -2
  175. package/dist/esm/hooks/useOtpCredential/useOtpCredential.mjs.map +1 -1
  176. package/dist/esm/hooks/usePaint/usePaint.mjs +31 -31
  177. package/dist/esm/hooks/usePaint/usePaint.mjs.map +1 -1
  178. package/dist/esm/hooks/useParallax/useParallax.mjs +24 -23
  179. package/dist/esm/hooks/useParallax/useParallax.mjs.map +1 -1
  180. package/dist/esm/hooks/usePictureInPicture/usePictureInPicture.mjs +25 -25
  181. package/dist/esm/hooks/usePictureInPicture/usePictureInPicture.mjs.map +1 -1
  182. package/dist/esm/hooks/useRefState/useRefState.mjs +1 -0
  183. package/dist/esm/hooks/useRefState/useRefState.mjs.map +1 -1
  184. package/dist/esm/hooks/useResizeObserver/useResizeObserver.mjs +16 -16
  185. package/dist/esm/hooks/useResizeObserver/useResizeObserver.mjs.map +1 -1
  186. package/dist/esm/hooks/useRightClick/useRightClick.mjs +14 -14
  187. package/dist/esm/hooks/useRightClick/useRightClick.mjs.map +1 -1
  188. package/dist/esm/hooks/useScroll/useScroll.mjs +22 -22
  189. package/dist/esm/hooks/useScroll/useScroll.mjs.map +1 -1
  190. package/dist/esm/hooks/useScrollIntoView/useScrollIntoView.mjs +16 -16
  191. package/dist/esm/hooks/useScrollIntoView/useScrollIntoView.mjs.map +1 -1
  192. package/dist/esm/hooks/useScrollTo/useScrollTo.mjs +10 -10
  193. package/dist/esm/hooks/useScrollTo/useScrollTo.mjs.map +1 -1
  194. package/dist/esm/hooks/useSticky/useSticky.mjs +17 -17
  195. package/dist/esm/hooks/useSticky/useSticky.mjs.map +1 -1
  196. package/dist/esm/hooks/useStopwatch/useStopwatch.mjs +4 -4
  197. package/dist/esm/hooks/useStopwatch/useStopwatch.mjs.map +1 -1
  198. package/dist/esm/hooks/useStorage/useStorage.mjs +2 -2
  199. package/dist/esm/hooks/useStorage/useStorage.mjs.map +1 -1
  200. package/dist/esm/hooks/useTextDirection/useTextDirection.mjs +12 -12
  201. package/dist/esm/hooks/useTextDirection/useTextDirection.mjs.map +1 -1
  202. package/dist/esm/hooks/useTextareaAutosize/useTextareaAutosize.mjs +20 -20
  203. package/dist/esm/hooks/useTextareaAutosize/useTextareaAutosize.mjs.map +1 -1
  204. package/dist/esm/hooks/useTimer/useTimer.mjs +3 -3
  205. package/dist/esm/hooks/useTimer/useTimer.mjs.map +1 -1
  206. package/dist/esm/hooks/useUrlSearchParam/useUrlSearchParam.mjs +2 -2
  207. package/dist/esm/hooks/useUrlSearchParam/useUrlSearchParam.mjs.map +1 -1
  208. package/dist/esm/hooks/useUrlSearchParams/useUrlSearchParams.mjs +2 -2
  209. package/dist/esm/hooks/useUrlSearchParams/useUrlSearchParams.mjs.map +1 -1
  210. package/dist/esm/hooks/useVisibility/useVisibility.mjs +25 -17
  211. package/dist/esm/hooks/useVisibility/useVisibility.mjs.map +1 -1
  212. package/dist/esm/index.mjs +98 -96
  213. package/dist/esm/utils/helpers/isTarget.mjs +10 -8
  214. package/dist/esm/utils/helpers/isTarget.mjs.map +1 -1
  215. package/dist/types/hooks/useBreakpoints/useBreakpoints.d.ts +1 -11
  216. package/dist/types/hooks/useClickOutside/useClickOutside.d.ts +1 -1
  217. package/dist/types/hooks/useHover/useHover.d.ts +6 -6
  218. package/dist/types/hooks/useRefState/useRefState.d.ts +1 -0
  219. package/dist/types/utils/helpers/isTarget.d.ts +9 -1
  220. package/package.json +89 -89
@@ -1 +1 @@
1
- {"version":3,"file":"useUrlSearchParams.mjs","sources":["../../../../src/hooks/useUrlSearchParams/useUrlSearchParams.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nimport {\n createQueryString,\n dispatchUrlSearchParamsEvent,\n getUrlSearchParams,\n URL_SEARCH_PARAMS_EVENT\n} from '../useUrlSearchParam/useUrlSearchParam';\n\n/** The url params type */\nexport type UrlParams = Record<string, any>;\n\n/** The url search params mod */\nexport type UrlSearchParamsMode = 'hash-params' | 'hash' | 'history';\n\n/** The use url search params set options type */\nexport interface UseUrlSearchParamsSetOptions {\n /** The mode to use for writing to the URL */\n write?: 'push' | 'replace';\n}\n\n/* The use search params initial value type */\nexport type UseUrlSearchParamsInitialValue<Value> = (() => Value) | Value;\n\n/** The use url search params options type */\nexport interface UseUrlSearchParamsOptions<Value> {\n /* The initial value of the url search params */\n initialValue?: UseUrlSearchParamsInitialValue<string | URLSearchParams | Value>;\n /** The mode to use for writing to the URL */\n mode?: UrlSearchParamsMode;\n /** The mode to use for writing to the URL */\n write?: 'push' | 'replace';\n /* The deserializer function to be invoked */\n deserializer?: (value: string) => Value[keyof Value];\n /* The serializer function to be invoked */\n serializer?: (value: Value[keyof Value]) => string;\n}\n\n/** The use url search params return type */\nexport interface UseUrlSearchParamsReturn<Value> {\n /** The value of the url search params */\n value: Value;\n /** The set function */\n set: (value: Partial<Value>, options?: UseUrlSearchParamsSetOptions) => void;\n}\n\nexport interface UseUrlSearchParams {\n <Value>(\n key: string,\n options: UseUrlSearchParamsOptions<Value> & {\n initialValue: UseUrlSearchParamsInitialValue<Value>;\n }\n ): UseUrlSearchParamsReturn<Value>;\n\n <Value>(options?: UseUrlSearchParamsOptions<Value>): UseUrlSearchParamsReturn<Value | undefined>;\n\n <Value>(initialValue: UseUrlSearchParamsInitialValue<Value>): UseUrlSearchParamsReturn<Value>;\n\n <Value>(key: string): UseUrlSearchParamsReturn<Value | undefined>;\n}\n\n/**\n * @name useUrlSearchParams\n * @description - Hook that provides reactive URLSearchParams\n * @category State\n * @usage high\n *\n * @overload\n * @template Value The type of the url param values\n * @param {UseUrlSearchParamsOptions<Value> & { initialValue: UseUrlSearchParamsInitialValue<Value> }} options The options object with required initialValue\n * @param {UseUrlSearchParamsInitialValue<Value>} [options.initialValue] The initial value for the url params\n * @param {UrlSearchParamsMode} [options.mode='history'] The mode to use for the URL ('history' | 'hash-params' | 'hash')\n * @param {'push' | 'replace'} [options.write='replace'] The mode to use for writing to the URL\n * @param {(value: Value[keyof Value]) => string} [options.serializer] Custom serializer function to convert value to string\n * @param {(value: string) => Value[keyof Value]} [options.deserializer] Custom deserializer function to convert string to value\n * @returns {UseUrlSearchParamsReturn<Value>} The object with value and function for change value\n *\n * @example\n * const { value, set } = useUrlSearchParams({ initialValue: { page: 1 } });\n *\n * @overload\n * @template Value The type of the url param values\n * @param {UseUrlSearchParamsInitialValue<Value>} [initialValue] The initial value for the url params\n * @returns {UseUrlSearchParamsReturn<Value>} The object with value and function for change value\n *\n * @example\n * const { value, set } = useUrlSearchParams({ page: 1 });\n */\nexport const useUrlSearchParams = (<Value extends UrlParams>(\n params: any\n): UseUrlSearchParamsReturn<Value> => {\n const options = (\n typeof params === 'object' &&\n params &&\n ('serializer' in params ||\n 'deserializer' in params ||\n 'initialValue' in params ||\n 'mode' in params ||\n 'write' in params)\n ? params\n : {}\n ) as UseUrlSearchParamsOptions<Value>;\n const initialValue = (\n options ? options?.initialValue : params\n ) as UseUrlSearchParamsInitialValue<Value>;\n\n const { mode = 'history', write: writeMode = 'replace' } = options;\n\n const serializer = (value: Value[keyof Value]) => {\n if (options?.serializer) return options.serializer(value);\n if (typeof value === 'string') return value;\n return JSON.stringify(value);\n };\n\n const deserializer = (value: string) => {\n if (options?.deserializer) return options.deserializer(value);\n if (value === 'undefined') return undefined as unknown as Value[keyof Value];\n\n try {\n return JSON.parse(value) as Value;\n } catch {\n return value as Value[keyof Value];\n }\n };\n\n const setUrlSearchParams = <Value extends UrlParams>(\n mode: UrlSearchParamsMode,\n value: Partial<Value>,\n write: 'push' | 'replace' = 'replace'\n ) => {\n const urlSearchParams = getUrlSearchParams(mode);\n\n Object.entries(value).forEach(([key, param]) => {\n if (param === undefined) {\n urlSearchParams.delete(key);\n } else {\n const serializedValue = serializer ? serializer(param) : String(param);\n urlSearchParams.set(key, serializedValue);\n }\n });\n\n const query = createQueryString(urlSearchParams, mode);\n if (write === 'replace') window.history.replaceState({}, '', query);\n if (write === 'push') window.history.pushState({}, '', query);\n dispatchUrlSearchParamsEvent();\n\n return urlSearchParams;\n };\n\n const getParsedUrlSearchParams = (searchParams: string | UrlParams | URLSearchParams) => {\n if (typeof searchParams === 'string') {\n return getParsedUrlSearchParams(new URLSearchParams(searchParams));\n }\n\n if (searchParams instanceof URLSearchParams) {\n return Array.from(searchParams.entries()).reduce(\n (acc, [key, value]) => {\n acc[key] = deserializer(value);\n return acc;\n },\n {} as Record<string, any>\n );\n }\n\n return searchParams;\n };\n\n const [value, setValue] = useState<Value>(() => {\n if (typeof window === 'undefined') return (initialValue ?? {}) as Value;\n\n const urlSearchParams = getUrlSearchParams(mode);\n const value = {\n ...(initialValue && getParsedUrlSearchParams(initialValue)),\n ...getParsedUrlSearchParams(urlSearchParams)\n } as Value;\n\n setUrlSearchParams(mode, value, writeMode);\n\n return value;\n });\n\n const set = (params: Partial<Value>, options?: UseUrlSearchParamsSetOptions) => {\n const searchParams = setUrlSearchParams(\n mode,\n { ...value, ...params },\n options?.write ?? writeMode\n );\n setValue(getParsedUrlSearchParams(searchParams) as Value);\n };\n\n useEffect(() => {\n const onParamsChange = () => {\n const searchParams = getUrlSearchParams(mode);\n setValue(getParsedUrlSearchParams(searchParams) as Value);\n };\n\n window.addEventListener(URL_SEARCH_PARAMS_EVENT, onParamsChange);\n window.addEventListener('popstate', onParamsChange);\n if (mode !== 'history') window.addEventListener('hashchange', onParamsChange);\n\n return () => {\n window.removeEventListener(URL_SEARCH_PARAMS_EVENT, onParamsChange);\n window.removeEventListener('popstate', onParamsChange);\n if (mode !== 'history') window.removeEventListener('hashchange', onParamsChange);\n };\n }, [mode]);\n\n return {\n value,\n set\n };\n}) as UseUrlSearchParams;\n\nexport { createQueryString, dispatchUrlSearchParamsEvent, getUrlSearchParams };\n"],"names":["useUrlSearchParams","params","options","initialValue","mode","writeMode","serializer","value","deserializer","setUrlSearchParams","write","urlSearchParams","getUrlSearchParams","key","param","serializedValue","query","createQueryString","dispatchUrlSearchParamsEvent","getParsedUrlSearchParams","searchParams","acc","setValue","useState","set","useEffect","onParamsChange","URL_SEARCH_PARAMS_EVENT"],"mappings":"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"}
1
+ {"version":3,"file":"useUrlSearchParams.mjs","sources":["../../../../src/hooks/useUrlSearchParams/useUrlSearchParams.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nimport {\n createQueryString,\n dispatchUrlSearchParamsEvent,\n getUrlSearchParams,\n URL_SEARCH_PARAMS_EVENT\n} from '../useUrlSearchParam/useUrlSearchParam';\n\n/** The url params type */\nexport type UrlParams = Record<string, any>;\n\n/** The url search params mod */\nexport type UrlSearchParamsMode = 'hash-params' | 'hash' | 'history';\n\n/** The use url search params set options type */\nexport interface UseUrlSearchParamsSetOptions {\n /** The mode to use for writing to the URL */\n write?: 'push' | 'replace';\n}\n\n/* The use search params initial value type */\nexport type UseUrlSearchParamsInitialValue<Value> = (() => Value) | Value;\n\n/** The use url search params options type */\nexport interface UseUrlSearchParamsOptions<Value> {\n /* The initial value of the url search params */\n initialValue?: UseUrlSearchParamsInitialValue<string | URLSearchParams | Value>;\n /** The mode to use for writing to the URL */\n mode?: UrlSearchParamsMode;\n /** The mode to use for writing to the URL */\n write?: 'push' | 'replace';\n /* The deserializer function to be invoked */\n deserializer?: (value: string) => Value[keyof Value];\n /* The serializer function to be invoked */\n serializer?: (value: Value[keyof Value]) => string;\n}\n\n/** The use url search params return type */\nexport interface UseUrlSearchParamsReturn<Value> {\n /** The value of the url search params */\n value: Value;\n /** The set function */\n set: (value: Partial<Value>, options?: UseUrlSearchParamsSetOptions) => void;\n}\n\nexport interface UseUrlSearchParams {\n <Value>(\n key: string,\n options: UseUrlSearchParamsOptions<Value> & {\n initialValue: UseUrlSearchParamsInitialValue<Value>;\n }\n ): UseUrlSearchParamsReturn<Value>;\n\n <Value>(options?: UseUrlSearchParamsOptions<Value>): UseUrlSearchParamsReturn<Value | undefined>;\n\n <Value>(initialValue: UseUrlSearchParamsInitialValue<Value>): UseUrlSearchParamsReturn<Value>;\n\n <Value>(key: string): UseUrlSearchParamsReturn<Value | undefined>;\n}\n\n/**\n * @name useUrlSearchParams\n * @description - Hook that provides reactive URLSearchParams\n * @category State\n * @usage high\n *\n * @overload\n * @template Value The type of the url param values\n * @param {UseUrlSearchParamsOptions<Value> & { initialValue: UseUrlSearchParamsInitialValue<Value> }} options The options object with required initialValue\n * @param {UseUrlSearchParamsInitialValue<Value>} [options.initialValue] The initial value for the url params\n * @param {UrlSearchParamsMode} [options.mode='history'] The mode to use for the URL ('history' | 'hash-params' | 'hash')\n * @param {'push' | 'replace'} [options.write='replace'] The mode to use for writing to the URL\n * @param {(value: Value[keyof Value]) => string} [options.serializer] Custom serializer function to convert value to string\n * @param {(value: string) => Value[keyof Value]} [options.deserializer] Custom deserializer function to convert string to value\n * @returns {UseUrlSearchParamsReturn<Value>} The object with value and function for change value\n *\n * @example\n * const { value, set } = useUrlSearchParams({ initialValue: { page: 1 } });\n *\n * @overload\n * @template Value The type of the url param values\n * @param {UseUrlSearchParamsInitialValue<Value>} [initialValue] The initial value for the url params\n * @returns {UseUrlSearchParamsReturn<Value>} The object with value and function for change value\n *\n * @example\n * const { value, set } = useUrlSearchParams({ page: 1 });\n */\nexport const useUrlSearchParams = (<Value extends UrlParams>(\n params: any\n): UseUrlSearchParamsReturn<Value> => {\n const options = (\n typeof params === 'object' &&\n params &&\n ('serializer' in params ||\n 'deserializer' in params ||\n 'initialValue' in params ||\n 'mode' in params ||\n 'write' in params)\n ? params\n : {}\n ) as UseUrlSearchParamsOptions<Value>;\n const initialValue = (\n options ? options?.initialValue : params\n ) as UseUrlSearchParamsInitialValue<Value>;\n\n const { mode = 'history', write: writeMode = 'replace' } = options;\n\n const serializer = (value: Value[keyof Value]) => {\n if (options?.serializer) return options.serializer(value);\n if (typeof value === 'string') return value;\n return JSON.stringify(value);\n };\n\n const deserializer = (value: string) => {\n if (options?.deserializer) return options.deserializer(value);\n if (value === 'undefined') return undefined as unknown as Value[keyof Value];\n\n try {\n return JSON.parse(value) as Value;\n } catch {\n return value as Value[keyof Value];\n }\n };\n\n const setUrlSearchParams = <Value extends UrlParams>(\n mode: UrlSearchParamsMode,\n value: Partial<Value>,\n write: 'push' | 'replace' = 'replace'\n ) => {\n const urlSearchParams = getUrlSearchParams(mode);\n\n Object.entries(value).forEach(([key, param]) => {\n if (param === undefined) {\n urlSearchParams.delete(key);\n } else {\n const serializedValue = serializer ? serializer(param) : String(param);\n urlSearchParams.set(key, serializedValue);\n }\n });\n\n const query = createQueryString(urlSearchParams, mode);\n if (write === 'replace') window.history.replaceState({}, '', query);\n if (write === 'push') window.history.pushState({}, '', query);\n dispatchUrlSearchParamsEvent();\n\n return urlSearchParams;\n };\n\n const getParsedUrlSearchParams = (searchParams: string | UrlParams | URLSearchParams) => {\n if (typeof searchParams === 'string') {\n return getParsedUrlSearchParams(new URLSearchParams(searchParams));\n }\n\n if (searchParams instanceof URLSearchParams) {\n return Array.from(searchParams.entries()).reduce(\n (acc, [key, value]) => {\n acc[key] = deserializer(value);\n return acc;\n },\n {} as Record<string, any>\n );\n }\n\n return searchParams;\n };\n\n const [value, setValue] = useState<Value>(() => {\n if (typeof window === 'undefined') return (initialValue ?? {}) as Value;\n\n const urlSearchParams = getUrlSearchParams(mode);\n const value = {\n ...(initialValue && getParsedUrlSearchParams(initialValue)),\n ...getParsedUrlSearchParams(urlSearchParams)\n } as Value;\n\n setUrlSearchParams(mode, value, writeMode);\n\n return value;\n });\n\n const set = (params: Partial<Value>, options?: UseUrlSearchParamsSetOptions) => {\n const searchParams = setUrlSearchParams(\n mode,\n { ...value, ...params },\n options?.write ?? writeMode\n );\n setValue(getParsedUrlSearchParams(searchParams) as Value);\n };\n\n useEffect(() => {\n const onParamsChange = () => {\n const searchParams = getUrlSearchParams(mode);\n setValue(getParsedUrlSearchParams(searchParams) as Value);\n };\n\n window.addEventListener(URL_SEARCH_PARAMS_EVENT, onParamsChange);\n window.addEventListener('popstate', onParamsChange);\n if (mode !== 'history') window.addEventListener('hashchange', onParamsChange);\n\n return () => {\n window.removeEventListener(URL_SEARCH_PARAMS_EVENT, onParamsChange);\n window.removeEventListener('popstate', onParamsChange);\n if (mode !== 'history') window.removeEventListener('hashchange', onParamsChange);\n };\n }, [mode]);\n\n return {\n value,\n set\n };\n}) as UseUrlSearchParams;\n\nexport { createQueryString, dispatchUrlSearchParamsEvent, getUrlSearchParams };\n"],"names":["useUrlSearchParams","params","options","initialValue","mode","writeMode","serializer","value","deserializer","setUrlSearchParams","write","urlSearchParams","getUrlSearchParams","key","param","serializedValue","query","createQueryString","dispatchUrlSearchParamsEvent","getParsedUrlSearchParams","searchParams","acc","setValue","useState","set","useEffect","onParamsChange","URL_SEARCH_PARAMS_EVENT"],"mappings":"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"}
@@ -1,33 +1,41 @@
1
- import { useState as d, useRef as C, useEffect as E } from "react";
2
- import { useRefState as R } from "../useRefState/useRefState.mjs";
3
- import { isTarget as c } from "../../utils/helpers/isTarget.mjs";
4
- const V = (...e) => {
5
- const n = c(e[0]) ? e[0] : void 0, t = n ? typeof e[1] == "object" ? e[1] : { onChange: e[1] } : typeof e[0] == "object" ? e[0] : { onChange: e[0] }, i = t?.onChange, f = t?.enabled ?? !0, [u, v] = d(), [o, y] = d(), r = R(), l = C(i);
6
- return l.current = i, E(() => {
1
+ import { useState as d, useRef as R, useEffect as C } from "react";
2
+ import { useRefState as E } from "../useRefState/useRefState.mjs";
3
+ import { isTarget as s } from "../../utils/helpers/isTarget.mjs";
4
+ const S = ((...e) => {
5
+ const n = s(e[0]) ? e[0] : void 0, t = n ? typeof e[1] == "object" ? e[1] : { onChange: e[1] } : typeof e[0] == "object" ? e[0] : { onChange: e[0] }, i = t?.onChange, f = t?.enabled ?? !0, [u, v] = d(), [o, y] = d(), r = E(), l = R(i);
6
+ return l.current = i, C(() => {
7
7
  if (!f || !n && !r.state) return;
8
- const b = n ? c.getElement(n) : r.current;
8
+ const b = n ? s.getElement(n) : r.current;
9
9
  if (!b) return;
10
- const s = new IntersectionObserver(
11
- (h, a) => {
12
- const g = h.pop();
13
- y(g), l.current?.(g, a);
10
+ const c = new IntersectionObserver(
11
+ (a, h) => {
12
+ const g = a.pop();
13
+ y(g), l.current?.(g, h);
14
14
  },
15
15
  {
16
16
  ...t,
17
- root: t?.root ? c.getElement(t.root) : document
17
+ root: t?.root ? s.getElement(t.root) : document
18
18
  }
19
19
  );
20
- return v(s), s.observe(b), () => {
21
- s.disconnect();
20
+ return v(c), c.observe(b), () => {
21
+ c.disconnect();
22
22
  };
23
- }, [n, r.state, t?.rootMargin, t?.threshold, t?.root, f]), n ? { observer: u, entry: o, inView: !!o?.isIntersecting } : {
23
+ }, [
24
+ n,
25
+ r.state,
26
+ s.getRefState(n),
27
+ t?.rootMargin,
28
+ t?.threshold,
29
+ t?.root,
30
+ f
31
+ ]), n ? { observer: u, entry: o, inView: !!o?.isIntersecting } : {
24
32
  observer: u,
25
33
  ref: r,
26
34
  entry: o,
27
35
  inView: !!o?.isIntersecting
28
36
  };
29
- };
37
+ });
30
38
  export {
31
- V as useVisibility
39
+ S as useVisibility
32
40
  };
33
41
  //# sourceMappingURL=useVisibility.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useVisibility.mjs","sources":["../../../../src/hooks/useVisibility/useVisibility.ts"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\n\nimport type { HookTarget } from '@/utils/helpers';\n\nimport { isTarget } from '@/utils/helpers';\n\nimport type { StateRef } from '../useRefState/useRefState';\n\nimport { useRefState } from '../useRefState/useRefState';\n\n/** The visibility callback type */\nexport type UseVisibilityCallback = (\n entry: IntersectionObserverEntry,\n observer: IntersectionObserver\n) => void;\n\n/** The visibility options type */\nexport interface UseVisibilityOptions extends Omit<IntersectionObserverInit, 'root'> {\n /** The enabled state of the intersection */\n enabled?: boolean;\n /** The callback to execute when intersection is detected */\n onChange?: UseVisibilityCallback;\n /** The root element to observe */\n root?: HookTarget;\n}\n\n/** The intersection observer return type */\nexport interface UseVisibilityReturn {\n /** The intersection observer entry */\n entry?: IntersectionObserverEntry;\n /** The intersection observer in view */\n inView?: boolean;\n\n /** The intersection observer instance */\n observer?: IntersectionObserver;\n}\n\nexport interface UseVisibility {\n <Target extends Element>(\n options?: UseVisibilityOptions,\n target?: never\n ): UseVisibilityReturn & { ref: StateRef<Target> };\n\n (target: HookTarget, options?: UseVisibilityOptions): UseVisibilityReturn;\n\n <Target extends Element>(\n callback: UseVisibilityCallback,\n target?: never\n ): UseVisibilityReturn & { ref: StateRef<Target> };\n\n (target: HookTarget, callback: UseVisibilityCallback): UseVisibilityReturn;\n}\n\n/**\n * @name useVisibility\n * @description - Hook that gives you visibility observer state\n * @category Sensors\n * @usage medium\n *\n * @browserapi IntersectionObserver https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver\n *\n * @overload\n * @param {HookTarget} target The target element to detect intersection\n * @param {boolean} [options.enabled=true] The Intersection options\n * @param {((entries: IntersectionEntry[], observer: Intersection) => void) | undefined} [options.onChange] The callback to execute when intersection is detected\n * @param {HookTarget} [options.root=document] The root element to observe\n * @returns {UseVisibilityReturn} An object containing the state\n *\n * @example\n * const { ref, entries, observer } = useVisibility();\n *\n * @overload\n * @template Target The target element\n * @param {boolean} [options.enabled=true] The Intersection options\n * @param {((entries: IntersectionEntry[], observer: Intersection) => void) | undefined} [options.onChange] The callback to execute when intersection is detected\n * @param {HookTarget} [options.root=document] The root element to observe\n * @returns {UseVisibilityReturn & { ref: StateRef<Target> }} A React ref to attach to the target element\n *\n * @example\n * const { entries, observer } = useVisibility(ref);\n *\n * @overload\n * @template Target The target element\n * @param {UseVisibilityCallback} callback The callback to execute when intersection is detected\n * @returns {UseVisibilityReturn & { ref: StateRef<Target> }} A React ref to attach to the target element\n *\n * @example\n * const { ref, entries, observer } = useVisibility(() => console.log('callback'));\n *\n * @overload\n * @param {UseVisibilityCallback} callback The callback to execute when intersection is detected\n * @param {HookTarget} target The target element to detect intersection\n * @returns {UseVisibilityReturn} An object containing the state\n *\n * @example\n * const { entries, observer } = useVisibility(ref, () => console.log('callback'));\n */\nexport const useVisibility = ((...params: any[]) => {\n const target = (isTarget(params[0]) ? params[0] : undefined) as HookTarget | undefined;\n\n const options = (\n target\n ? typeof params[1] === 'object'\n ? params[1]\n : { onChange: params[1] }\n : typeof params[0] === 'object'\n ? params[0]\n : { onChange: params[0] }\n ) as UseVisibilityOptions | undefined;\n\n const callback = options?.onChange;\n const enabled = options?.enabled ?? true;\n\n const [observer, setObserver] = useState<IntersectionObserver>();\n const [entry, setEntry] = useState<IntersectionObserverEntry>();\n\n const internalRef = useRefState<Element>();\n const internalCallbackRef = useRef(callback);\n internalCallbackRef.current = callback;\n\n useEffect(() => {\n if (!enabled || (!target && !internalRef.state)) return;\n\n const element = target ? isTarget.getElement(target) : internalRef.current;\n if (!element) return;\n\n const observer = new IntersectionObserver(\n (entries: IntersectionObserverEntry[], observer: IntersectionObserver) => {\n const entry = entries.pop()!;\n setEntry(entry);\n internalCallbackRef.current?.(entry, observer);\n },\n {\n ...options,\n root: options?.root ? (isTarget.getElement(options.root) as Document | Element) : document\n }\n );\n\n setObserver(observer);\n observer.observe(element as Element);\n\n return () => {\n observer.disconnect();\n };\n }, [target, internalRef.state, options?.rootMargin, options?.threshold, options?.root, enabled]);\n\n if (target) return { observer, entry, inView: !!entry?.isIntersecting };\n return {\n observer,\n ref: internalRef,\n entry,\n inView: !!entry?.isIntersecting\n };\n}) as UseVisibility;\n"],"names":["useVisibility","params","target","isTarget","options","callback","enabled","observer","setObserver","useState","entry","setEntry","internalRef","useRefState","internalCallbackRef","useRef","useEffect","element","entries"],"mappings":";;;AAiGO,MAAMA,IAAiB,IAAIC,MAAkB;AAClD,QAAMC,IAAUC,EAASF,EAAO,CAAC,CAAC,IAAIA,EAAO,CAAC,IAAI,QAE5CG,IACJF,IACI,OAAOD,EAAO,CAAC,KAAM,WACnBA,EAAO,CAAC,IACR,EAAE,UAAUA,EAAO,CAAC,EAAA,IACtB,OAAOA,EAAO,CAAC,KAAM,WACnBA,EAAO,CAAC,IACR,EAAE,UAAUA,EAAO,CAAC,EAAA,GAGtBI,IAAWD,GAAS,UACpBE,IAAUF,GAAS,WAAW,IAE9B,CAACG,GAAUC,CAAW,IAAIC,EAAA,GAC1B,CAACC,GAAOC,CAAQ,IAAIF,EAAA,GAEpBG,IAAcC,EAAA,GACdC,IAAsBC,EAAOV,CAAQ;AA6B3C,SA5BAS,EAAoB,UAAUT,GAE9BW,EAAU,MAAM;AACd,QAAI,CAACV,KAAY,CAACJ,KAAU,CAACU,EAAY,MAAQ;AAEjD,UAAMK,IAAUf,IAASC,EAAS,WAAWD,CAAM,IAAIU,EAAY;AACnE,QAAI,CAACK,EAAS;AAEd,UAAMV,IAAW,IAAI;AAAA,MACnB,CAACW,GAAsCX,MAAmC;AACxE,cAAMG,IAAQQ,EAAQ,IAAA;AACtB,QAAAP,EAASD,CAAK,GACdI,EAAoB,UAAUJ,GAAOH,CAAQ;AAAA,MAAA;AAAA,MAE/C;AAAA,QACE,GAAGH;AAAA,QACH,MAAMA,GAAS,OAAQD,EAAS,WAAWC,EAAQ,IAAI,IAA2B;AAAA,MAAA;AAAA,IACpF;AAGF,WAAAI,EAAYD,CAAQ,GACpBA,EAAS,QAAQU,CAAkB,GAE5B,MAAM;AACXV,MAAAA,EAAS,WAAA;AAAA,IAAW;AAAA,EACtB,GACC,CAACL,GAAQU,EAAY,OAAOR,GAAS,YAAYA,GAAS,WAAWA,GAAS,MAAME,CAAO,CAAC,GAE3FJ,IAAe,EAAE,UAAAK,GAAU,OAAAG,GAAO,QAAQ,CAAC,CAACA,GAAO,eAAA,IAChD;AAAA,IACL,UAAAH;AAAA,IACA,KAAKK;AAAA,IACL,OAAAF;AAAA,IACA,QAAQ,CAAC,CAACA,GAAO;AAAA,EAAA;AAErB;"}
1
+ {"version":3,"file":"useVisibility.mjs","sources":["../../../../src/hooks/useVisibility/useVisibility.ts"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\n\nimport type { HookTarget } from '@/utils/helpers';\n\nimport { isTarget } from '@/utils/helpers';\n\nimport type { StateRef } from '../useRefState/useRefState';\n\nimport { useRefState } from '../useRefState/useRefState';\n\n/** The visibility callback type */\nexport type UseVisibilityCallback = (\n entry: IntersectionObserverEntry,\n observer: IntersectionObserver\n) => void;\n\n/** The visibility options type */\nexport interface UseVisibilityOptions extends Omit<IntersectionObserverInit, 'root'> {\n /** The enabled state of the intersection */\n enabled?: boolean;\n /** The callback to execute when intersection is detected */\n onChange?: UseVisibilityCallback;\n /** The root element to observe */\n root?: HookTarget;\n}\n\n/** The intersection observer return type */\nexport interface UseVisibilityReturn {\n /** The intersection observer entry */\n entry?: IntersectionObserverEntry;\n /** The intersection observer in view */\n inView?: boolean;\n\n /** The intersection observer instance */\n observer?: IntersectionObserver;\n}\n\nexport interface UseVisibility {\n <Target extends Element>(\n options?: UseVisibilityOptions,\n target?: never\n ): UseVisibilityReturn & { ref: StateRef<Target> };\n\n (target: HookTarget, options?: UseVisibilityOptions): UseVisibilityReturn;\n\n <Target extends Element>(\n callback: UseVisibilityCallback,\n target?: never\n ): UseVisibilityReturn & { ref: StateRef<Target> };\n\n (target: HookTarget, callback: UseVisibilityCallback): UseVisibilityReturn;\n}\n\n/**\n * @name useVisibility\n * @description - Hook that gives you visibility observer state\n * @category Sensors\n * @usage medium\n *\n * @browserapi IntersectionObserver https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver\n *\n * @overload\n * @param {HookTarget} target The target element to detect intersection\n * @param {boolean} [options.enabled=true] The Intersection options\n * @param {((entries: IntersectionEntry[], observer: Intersection) => void) | undefined} [options.onChange] The callback to execute when intersection is detected\n * @param {HookTarget} [options.root=document] The root element to observe\n * @returns {UseVisibilityReturn} An object containing the state\n *\n * @example\n * const { ref, entries, observer } = useVisibility();\n *\n * @overload\n * @template Target The target element\n * @param {boolean} [options.enabled=true] The Intersection options\n * @param {((entries: IntersectionEntry[], observer: Intersection) => void) | undefined} [options.onChange] The callback to execute when intersection is detected\n * @param {HookTarget} [options.root=document] The root element to observe\n * @returns {UseVisibilityReturn & { ref: StateRef<Target> }} A React ref to attach to the target element\n *\n * @example\n * const { entries, observer } = useVisibility(ref);\n *\n * @overload\n * @template Target The target element\n * @param {UseVisibilityCallback} callback The callback to execute when intersection is detected\n * @returns {UseVisibilityReturn & { ref: StateRef<Target> }} A React ref to attach to the target element\n *\n * @example\n * const { ref, entries, observer } = useVisibility(() => console.log('callback'));\n *\n * @overload\n * @param {UseVisibilityCallback} callback The callback to execute when intersection is detected\n * @param {HookTarget} target The target element to detect intersection\n * @returns {UseVisibilityReturn} An object containing the state\n *\n * @example\n * const { entries, observer } = useVisibility(ref, () => console.log('callback'));\n */\nexport const useVisibility = ((...params: any[]) => {\n const target = (isTarget(params[0]) ? params[0] : undefined) as HookTarget | undefined;\n\n const options = (\n target\n ? typeof params[1] === 'object'\n ? params[1]\n : { onChange: params[1] }\n : typeof params[0] === 'object'\n ? params[0]\n : { onChange: params[0] }\n ) as UseVisibilityOptions | undefined;\n\n const callback = options?.onChange;\n const enabled = options?.enabled ?? true;\n\n const [observer, setObserver] = useState<IntersectionObserver>();\n const [entry, setEntry] = useState<IntersectionObserverEntry>();\n\n const internalRef = useRefState<Element>();\n const internalCallbackRef = useRef(callback);\n internalCallbackRef.current = callback;\n\n useEffect(() => {\n if (!enabled || (!target && !internalRef.state)) return;\n\n const element = target ? isTarget.getElement(target) : internalRef.current;\n if (!element) return;\n\n const observer = new IntersectionObserver(\n (entries: IntersectionObserverEntry[], observer: IntersectionObserver) => {\n const entry = entries.pop()!;\n setEntry(entry);\n internalCallbackRef.current?.(entry, observer);\n },\n {\n ...options,\n root: options?.root ? (isTarget.getElement(options.root) as Document | Element) : document\n }\n );\n\n setObserver(observer);\n observer.observe(element as Element);\n\n return () => {\n observer.disconnect();\n };\n }, [\n target,\n internalRef.state,\n isTarget.getRefState(target),\n options?.rootMargin,\n options?.threshold,\n options?.root,\n enabled\n ]);\n\n if (target) return { observer, entry, inView: !!entry?.isIntersecting };\n return {\n observer,\n ref: internalRef,\n entry,\n inView: !!entry?.isIntersecting\n };\n}) as UseVisibility;\n"],"names":["useVisibility","params","target","isTarget","options","callback","enabled","observer","setObserver","useState","entry","setEntry","internalRef","useRefState","internalCallbackRef","useRef","useEffect","element","entries"],"mappings":";;;AAiGO,MAAMA,KAAiB,IAAIC,MAAkB;AAClD,QAAMC,IAAUC,EAASF,EAAO,CAAC,CAAC,IAAIA,EAAO,CAAC,IAAI,QAE5CG,IACJF,IACI,OAAOD,EAAO,CAAC,KAAM,WACnBA,EAAO,CAAC,IACR,EAAE,UAAUA,EAAO,CAAC,EAAA,IACtB,OAAOA,EAAO,CAAC,KAAM,WACnBA,EAAO,CAAC,IACR,EAAE,UAAUA,EAAO,CAAC,EAAA,GAGtBI,IAAWD,GAAS,UACpBE,IAAUF,GAAS,WAAW,IAE9B,CAACG,GAAUC,CAAW,IAAIC,EAAA,GAC1B,CAACC,GAAOC,CAAQ,IAAIF,EAAA,GAEpBG,IAAcC,EAAA,GACdC,IAAsBC,EAAOV,CAAQ;AAqC3C,SApCAS,EAAoB,UAAUT,GAE9BW,EAAU,MAAM;AACd,QAAI,CAACV,KAAY,CAACJ,KAAU,CAACU,EAAY,MAAQ;AAEjD,UAAMK,IAAUf,IAASC,EAAS,WAAWD,CAAM,IAAIU,EAAY;AACnE,QAAI,CAACK,EAAS;AAEd,UAAMV,IAAW,IAAI;AAAA,MACnB,CAACW,GAAsCX,MAAmC;AACxE,cAAMG,IAAQQ,EAAQ,IAAA;AACtB,QAAAP,EAASD,CAAK,GACdI,EAAoB,UAAUJ,GAAOH,CAAQ;AAAA,MAAA;AAAA,MAE/C;AAAA,QACE,GAAGH;AAAA,QACH,MAAMA,GAAS,OAAQD,EAAS,WAAWC,EAAQ,IAAI,IAA2B;AAAA,MAAA;AAAA,IACpF;AAGF,WAAAI,EAAYD,CAAQ,GACpBA,EAAS,QAAQU,CAAkB,GAE5B,MAAM;AACXV,MAAAA,EAAS,WAAA;AAAA,IAAW;AAAA,EACtB,GACC;AAAA,IACDL;AAAA,IACAU,EAAY;AAAA,IACZT,EAAS,YAAYD,CAAM;AAAA,IAC3BE,GAAS;AAAA,IACTA,GAAS;AAAA,IACTA,GAAS;AAAA,IACTE;AAAA,EAAA,CACD,GAEGJ,IAAe,EAAE,UAAAK,GAAU,OAAAG,GAAO,QAAQ,CAAC,CAACA,GAAO,eAAA,IAChD;AAAA,IACL,UAAAH;AAAA,IACA,KAAKK;AAAA,IACL,OAAAF;AAAA,IACA,QAAQ,CAAC,CAACA,GAAO;AAAA,EAAA;AAErB;"}
@@ -7,7 +7,7 @@ import { useLockCallback as n } from "./hooks/useLockCallback/useLockCallback.mj
7
7
  import { useMutation as l } from "./hooks/useMutation/useMutation.mjs";
8
8
  import { useOptimistic as E } from "./hooks/useOptimistic/useOptimistic.mjs";
9
9
  import { useQuery as g } from "./hooks/useQuery/useQuery.mjs";
10
- import { useAudio as R } from "./hooks/useAudio/useAudio.mjs";
10
+ import { useAudio as d } from "./hooks/useAudio/useAudio.mjs";
11
11
  import { useBattery as P } from "./hooks/useBattery/useBattery.mjs";
12
12
  import { useBluetooth as I } from "./hooks/useBluetooth/useBluetooth.mjs";
13
13
  import { useBroadcastChannel as O } from "./hooks/useBroadcastChannel/useBroadcastChannel.mjs";
@@ -32,7 +32,7 @@ import { usePermission as ie } from "./hooks/usePermission/usePermission.mjs";
32
32
  import { usePictureInPicture as ce } from "./hooks/usePictureInPicture/usePictureInPicture.mjs";
33
33
  import { usePointerLock as Se } from "./hooks/usePointerLock/usePointerLock.mjs";
34
34
  import { usePostMessage as Te } from "./hooks/usePostMessage/usePostMessage.mjs";
35
- import { useRaf as de } from "./hooks/useRaf/useRaf.mjs";
35
+ import { useRaf as Re } from "./hooks/useRaf/useRaf.mjs";
36
36
  import { useShare as Ce } from "./hooks/useShare/useShare.mjs";
37
37
  import { getSpeechRecognition as Ae, useSpeechRecognition as Ie } from "./hooks/useSpeechRecognition/useSpeechRecognition.mjs";
38
38
  import { useSpeechSynthesis as Oe } from "./hooks/useSpeechSynthesis/useSpeechSynthesis.mjs";
@@ -78,7 +78,7 @@ import { useDevicePixelRatio as nr } from "./hooks/useDevicePixelRatio/useDevice
78
78
  import { useDocumentEvent as lr } from "./hooks/useDocumentEvent/useDocumentEvent.mjs";
79
79
  import { useDocumentVisibility as Er } from "./hooks/useDocumentVisibility/useDocumentVisibility.mjs";
80
80
  import { useElementSize as gr } from "./hooks/useElementSize/useElementSize.mjs";
81
- import { useEventListener as Rr } from "./hooks/useEventListener/useEventListener.mjs";
81
+ import { useEventListener as dr } from "./hooks/useEventListener/useEventListener.mjs";
82
82
  import { isHotkeyMatch as Pr, useHotkeys as Ar } from "./hooks/useHotkeys/useHotkeys.mjs";
83
83
  import { useIdle as yr } from "./hooks/useIdle/useIdle.mjs";
84
84
  import { useInfiniteScroll as kr } from "./hooks/useInfiniteScroll/useInfiniteScroll.mjs";
@@ -104,7 +104,7 @@ import { getRangesSelection as it, useTextSelection as nt } from "./hooks/useTex
104
104
  import { useVisibility as lt } from "./hooks/useVisibility/useVisibility.mjs";
105
105
  import { useWindowEvent as Et } from "./hooks/useWindowEvent/useWindowEvent.mjs";
106
106
  import { useWindowFocus as gt } from "./hooks/useWindowFocus/useWindowFocus.mjs";
107
- import { scrollTo as Rt, useWindowScroll as Ct } from "./hooks/useWindowScroll/useWindowScroll.mjs";
107
+ import { scrollTo as dt, useWindowScroll as Ct } from "./hooks/useWindowScroll/useWindowScroll.mjs";
108
108
  import { useWindowSize as At } from "./hooks/useWindowSize/useWindowSize.mjs";
109
109
  import { useBoolean as yt } from "./hooks/useBoolean/useBoolean.mjs";
110
110
  import { useControllableState as kt } from "./hooks/useControllableState/useControllableState.mjs";
@@ -122,45 +122,45 @@ import { assignRef as us, mergeRefs as ms, useMergedRef as ps } from "./hooks/us
122
122
  import { useOffsetPagination as xs } from "./hooks/useOffsetPagination/useOffsetPagination.mjs";
123
123
  import { useQueue as is } from "./hooks/useQueue/useQueue.mjs";
124
124
  import { useRafState as cs } from "./hooks/useRafState/useRafState.mjs";
125
- import { useRefState as Ss } from "./hooks/useRefState/useRefState.mjs";
126
- import { useSessionStorage as Ts } from "./hooks/useSessionStorage/useSessionStorage.mjs";
125
+ import { createRefState as Ss, useRefState as Es } from "./hooks/useRefState/useRefState.mjs";
126
+ import { useSessionStorage as gs } from "./hooks/useSessionStorage/useSessionStorage.mjs";
127
127
  import { useSet as ds } from "./hooks/useSet/useSet.mjs";
128
- import { stateHistoryReducer as Cs, useStateHistory as Ps } from "./hooks/useStateHistory/useStateHistory.mjs";
129
- import { useStep as Is } from "./hooks/useStep/useStep.mjs";
130
- import { STORAGE_EVENT as Os, dispatchStorageEvent as ks, useStorage as hs } from "./hooks/useStorage/useStorage.mjs";
131
- import { useToggle as _s } from "./hooks/useToggle/useToggle.mjs";
132
- import { URL_SEARCH_PARAMS_EVENT as bs, createQueryString as Ls, dispatchUrlSearchParamsEvent as Ms, getUrlSearchParams as Ns, useUrlSearchParam as Bs } from "./hooks/useUrlSearchParam/useUrlSearchParam.mjs";
133
- import { useUrlSearchParams as Fs } from "./hooks/useUrlSearchParams/useUrlSearchParams.mjs";
134
- import { useWizard as Vs } from "./hooks/useWizard/useWizard.mjs";
135
- import { useInterval as ws } from "./hooks/useInterval/useInterval.mjs";
136
- import { useStopwatch as zs } from "./hooks/useStopwatch/useStopwatch.mjs";
137
- import { useTime as Qs } from "./hooks/useTime/useTime.mjs";
138
- import { useTimeout as qs } from "./hooks/useTimeout/useTimeout.mjs";
139
- import { getTimeFromSeconds as js, useTimer as Js } from "./hooks/useTimer/useTimer.mjs";
140
- import { useBrowserLanguage as $s } from "./hooks/useBrowserLanguage/useBrowserLanguage.mjs";
141
- import { getOperatingSystem as ou, useOperatingSystem as ru } from "./hooks/useOperatingSystem/useOperatingSystem.mjs";
142
- import { usePreferredColorScheme as su } from "./hooks/usePreferredColorScheme/usePreferredColorScheme.mjs";
143
- import { usePreferredContrast as mu } from "./hooks/usePreferredContrast/usePreferredContrast.mjs";
144
- import { usePreferredDark as fu } from "./hooks/usePreferredDark/usePreferredDark.mjs";
145
- import { usePreferredLanguages as au } from "./hooks/usePreferredLanguages/usePreferredLanguages.mjs";
146
- import { usePreferredReducedMotion as nu } from "./hooks/usePreferredReducedMotion/usePreferredReducedMotion.mjs";
147
- import { useConst as lu } from "./hooks/useConst/useConst.mjs";
148
- import { useDebounceCallback as Eu } from "./hooks/useDebounceCallback/useDebounceCallback.mjs";
149
- import { useDebounceState as gu } from "./hooks/useDebounceState/useDebounceState.mjs";
150
- import { useDebounceValue as Ru } from "./hooks/useDebounceValue/useDebounceValue.mjs";
151
- import { useEvent as Pu } from "./hooks/useEvent/useEvent.mjs";
152
- import { useLastChanged as Iu } from "./hooks/useLastChanged/useLastChanged.mjs";
153
- import { useLatest as Ou } from "./hooks/useLatest/useLatest.mjs";
154
- import { usePrevious as hu } from "./hooks/usePrevious/usePrevious.mjs";
155
- import { useThrottleCallback as _u } from "./hooks/useThrottleCallback/useThrottleCallback.mjs";
156
- import { useThrottleState as bu } from "./hooks/useThrottleState/useThrottleState.mjs";
157
- import { useThrottleValue as Mu } from "./hooks/useThrottleValue/useThrottleValue.mjs";
158
- import { copy as Bu, legacyCopyToClipboard as Ku } from "./utils/helpers/copy.mjs";
159
- import { debounce as Uu } from "./utils/helpers/debounce.mjs";
160
- import { getDate as Hu } from "./utils/helpers/getDate.mjs";
161
- import { getRetry as Wu } from "./utils/helpers/getRetry.mjs";
162
- import { isTarget as Gu, target as Qu, targetSymbol as Xu } from "./utils/helpers/isTarget.mjs";
163
- import { throttle as Zu } from "./utils/helpers/throttle.mjs";
128
+ import { stateHistoryReducer as Ps, useStateHistory as As } from "./hooks/useStateHistory/useStateHistory.mjs";
129
+ import { useStep as ys } from "./hooks/useStep/useStep.mjs";
130
+ import { STORAGE_EVENT as ks, dispatchStorageEvent as hs, useStorage as vs } from "./hooks/useStorage/useStorage.mjs";
131
+ import { useToggle as Ds } from "./hooks/useToggle/useToggle.mjs";
132
+ import { URL_SEARCH_PARAMS_EVENT as Ls, createQueryString as Ms, dispatchUrlSearchParamsEvent as Ns, getUrlSearchParams as Bs, useUrlSearchParam as Ks } from "./hooks/useUrlSearchParam/useUrlSearchParam.mjs";
133
+ import { useUrlSearchParams as Us } from "./hooks/useUrlSearchParams/useUrlSearchParams.mjs";
134
+ import { useWizard as Hs } from "./hooks/useWizard/useWizard.mjs";
135
+ import { useInterval as Ws } from "./hooks/useInterval/useInterval.mjs";
136
+ import { useStopwatch as Gs } from "./hooks/useStopwatch/useStopwatch.mjs";
137
+ import { useTime as Xs } from "./hooks/useTime/useTime.mjs";
138
+ import { useTimeout as Zs } from "./hooks/useTimeout/useTimeout.mjs";
139
+ import { getTimeFromSeconds as Js, useTimer as Ys } from "./hooks/useTimer/useTimer.mjs";
140
+ import { useBrowserLanguage as eu } from "./hooks/useBrowserLanguage/useBrowserLanguage.mjs";
141
+ import { getOperatingSystem as ru, useOperatingSystem as tu } from "./hooks/useOperatingSystem/useOperatingSystem.mjs";
142
+ import { usePreferredColorScheme as uu } from "./hooks/usePreferredColorScheme/usePreferredColorScheme.mjs";
143
+ import { usePreferredContrast as pu } from "./hooks/usePreferredContrast/usePreferredContrast.mjs";
144
+ import { usePreferredDark as xu } from "./hooks/usePreferredDark/usePreferredDark.mjs";
145
+ import { usePreferredLanguages as iu } from "./hooks/usePreferredLanguages/usePreferredLanguages.mjs";
146
+ import { usePreferredReducedMotion as cu } from "./hooks/usePreferredReducedMotion/usePreferredReducedMotion.mjs";
147
+ import { useConst as Su } from "./hooks/useConst/useConst.mjs";
148
+ import { useDebounceCallback as Tu } from "./hooks/useDebounceCallback/useDebounceCallback.mjs";
149
+ import { useDebounceState as Ru } from "./hooks/useDebounceState/useDebounceState.mjs";
150
+ import { useDebounceValue as Cu } from "./hooks/useDebounceValue/useDebounceValue.mjs";
151
+ import { useEvent as Au } from "./hooks/useEvent/useEvent.mjs";
152
+ import { useLastChanged as yu } from "./hooks/useLastChanged/useLastChanged.mjs";
153
+ import { useLatest as ku } from "./hooks/useLatest/useLatest.mjs";
154
+ import { usePrevious as vu } from "./hooks/usePrevious/usePrevious.mjs";
155
+ import { useThrottleCallback as Du } from "./hooks/useThrottleCallback/useThrottleCallback.mjs";
156
+ import { useThrottleState as Lu } from "./hooks/useThrottleState/useThrottleState.mjs";
157
+ import { useThrottleValue as Nu } from "./hooks/useThrottleValue/useThrottleValue.mjs";
158
+ import { copy as Ku, legacyCopyToClipboard as Fu } from "./utils/helpers/copy.mjs";
159
+ import { debounce as Vu } from "./utils/helpers/debounce.mjs";
160
+ import { getDate as wu } from "./utils/helpers/getDate.mjs";
161
+ import { getRetry as zu } from "./utils/helpers/getRetry.mjs";
162
+ import { getRefState as Qu, isTarget as Xu, target as qu, targetSymbol as Zu } from "./utils/helpers/isTarget.mjs";
163
+ import { throttle as Ju } from "./utils/helpers/throttle.mjs";
164
164
  export {
165
165
  Jo as BREAKPOINTS_ANT_DESIGN,
166
166
  Yo as BREAKPOINTS_BOOTSTRAP_V5,
@@ -177,70 +177,72 @@ export {
177
177
  lo as Paint,
178
178
  So as Pointer,
179
179
  Co as SCRIPT_STATUS_ATTRIBUTE_NAME,
180
- Os as STORAGE_EVENT,
181
- bs as URL_SEARCH_PARAMS_EVENT,
180
+ ks as STORAGE_EVENT,
181
+ Ls as URL_SEARCH_PARAMS_EVENT,
182
182
  us as assignRef,
183
183
  Ut as clearCookies,
184
- Bu as copy,
184
+ Ku as copy,
185
185
  r as createContext,
186
186
  s as createEventEmitter,
187
- Ls as createQueryString,
187
+ Ms as createQueryString,
188
188
  m as createReactiveContext,
189
+ Ss as createRefState,
189
190
  f as createStore,
190
- Uu as debounce,
191
+ Vu as debounce,
191
192
  Qo as deepEqual,
192
193
  _t as dispatchCookieEvent,
193
- ks as dispatchStorageEvent,
194
- Ms as dispatchUrlSearchParamsEvent,
194
+ hs as dispatchStorageEvent,
195
+ Ns as dispatchUrlSearchParamsEvent,
195
196
  se as getConnection,
196
197
  Dt as getCookie,
197
198
  bt as getCookies,
198
- Hu as getDate,
199
+ wu as getDate,
199
200
  jt as getHash,
200
- ou as getOperatingSystem,
201
+ ru as getOperatingSystem,
201
202
  it as getRangesSelection,
202
- Wu as getRetry,
203
+ Qu as getRefState,
204
+ zu as getRetry,
203
205
  Ae as getSpeechRecognition,
204
- js as getTimeFromSeconds,
205
- Ns as getUrlSearchParams,
206
+ Js as getTimeFromSeconds,
207
+ Bs as getUrlSearchParams,
206
208
  Pr as isHotkeyMatch,
207
- Gu as isTarget,
208
- Ku as legacyCopyToClipboard,
209
+ Xu as isTarget,
210
+ Fu as legacyCopyToClipboard,
209
211
  q as mapGamepadToXbox360Controller,
210
212
  ms as mergeRefs,
211
213
  Lt as removeCookie,
212
214
  Mt as removeCookieItem,
213
- Rt as scrollTo,
215
+ dt as scrollTo,
214
216
  Nt as setCookie,
215
217
  Bt as setCookieItem,
216
- Cs as stateHistoryReducer,
217
- Qu as target,
218
- Xu as targetSymbol,
219
- Zu as throttle,
218
+ Ps as stateHistoryReducer,
219
+ qu as target,
220
+ Zu as targetSymbol,
221
+ Ju as throttle,
220
222
  $ as timeRangeToArray,
221
223
  ze as useActiveElement,
222
224
  a as useAsync,
223
225
  Bo as useAsyncEffect,
224
- R as useAudio,
226
+ d as useAudio,
225
227
  Qe as useAutoScroll,
226
228
  P as useBattery,
227
229
  I as useBluetooth,
228
230
  yt as useBoolean,
229
231
  mr as useBreakpoints,
230
232
  O as useBroadcastChannel,
231
- $s as useBrowserLanguage,
233
+ eu as useBrowserLanguage,
232
234
  qe as useClickOutside,
233
235
  h as useClipboard,
234
- lu as useConst,
236
+ Su as useConst,
235
237
  kt as useControllableState,
236
238
  Kt as useCookie,
237
239
  Vt as useCookies,
238
240
  _ as useCopy,
239
241
  wt as useCounter,
240
242
  b as useCssVar,
241
- Eu as useDebounceCallback,
242
- gu as useDebounceState,
243
- Ru as useDebounceValue,
243
+ Tu as useDebounceCallback,
244
+ Ru as useDebounceState,
245
+ Cu as useDebounceValue,
244
246
  zt as useDefault,
245
247
  fr as useDeviceMotion,
246
248
  ar as useDeviceOrientation,
@@ -254,8 +256,8 @@ export {
254
256
  Je as useDoubleClick,
255
257
  $e as useDropZone,
256
258
  gr as useElementSize,
257
- Pu as useEvent,
258
- Rr as useEventListener,
259
+ Au as useEvent,
260
+ dr as useEventListener,
259
261
  F as useEventSource,
260
262
  V as useEyeDropper,
261
263
  w as useFavicon,
@@ -275,15 +277,15 @@ export {
275
277
  ao as useImage,
276
278
  kr as useInfiniteScroll,
277
279
  vr as useIntersectionObserver,
278
- ws as useInterval,
280
+ Ws as useInterval,
279
281
  Vo as useIsFirstRender,
280
282
  wo as useIsomorphicLayoutEffect,
281
283
  Lr as useKeyPress,
282
284
  Nr as useKeyPressEvent,
283
285
  Dr as useKeyboard,
284
286
  Kr as useKeysPressed,
285
- Iu as useLastChanged,
286
- Ou as useLatest,
287
+ yu as useLastChanged,
288
+ ku as useLatest,
287
289
  bo as useLess,
288
290
  $t as useList,
289
291
  os as useLocalStorage,
@@ -305,7 +307,7 @@ export {
305
307
  xs as useOffsetPagination,
306
308
  Mo as useOnce,
307
309
  pe as useOnline,
308
- ru as useOperatingSystem,
310
+ tu as useOperatingSystem,
309
311
  E as useOptimistic,
310
312
  Zr as useOrientation,
311
313
  xe as useOtpCredential,
@@ -317,17 +319,17 @@ export {
317
319
  ce as usePictureInPicture,
318
320
  Se as usePointerLock,
319
321
  Te as usePostMessage,
320
- su as usePreferredColorScheme,
321
- mu as usePreferredContrast,
322
- fu as usePreferredDark,
323
- au as usePreferredLanguages,
324
- nu as usePreferredReducedMotion,
325
- hu as usePrevious,
322
+ uu as usePreferredColorScheme,
323
+ pu as usePreferredContrast,
324
+ xu as usePreferredDark,
325
+ iu as usePreferredLanguages,
326
+ cu as usePreferredReducedMotion,
327
+ vu as usePrevious,
326
328
  g as useQuery,
327
329
  is as useQueue,
328
- de as useRaf,
330
+ Re as useRaf,
329
331
  cs as useRafState,
330
- Ss as useRefState,
332
+ Es as useRefState,
331
333
  Fe as useRenderCount,
332
334
  Ve as useRenderInfo,
333
335
  we as useRerender,
@@ -337,30 +339,30 @@ export {
337
339
  ut as useScroll,
338
340
  pt as useScrollIntoView,
339
341
  xt as useScrollTo,
340
- Ts as useSessionStorage,
342
+ gs as useSessionStorage,
341
343
  ds as useSet,
342
344
  Xo as useShallowEffect,
343
345
  Ce as useShare,
344
346
  Ie as useSpeechRecognition,
345
347
  Oe as useSpeechSynthesis,
346
- Ps as useStateHistory,
347
- Is as useStep,
348
+ As as useStateHistory,
349
+ ys as useStep,
348
350
  Io as useSticky,
349
- zs as useStopwatch,
350
- hs as useStorage,
351
+ Gs as useStopwatch,
352
+ vs as useStorage,
351
353
  ho as useTextDirection,
352
354
  nt as useTextSelection,
353
355
  Oo as useTextareaAutosize,
354
- _u as useThrottleCallback,
355
- bu as useThrottleState,
356
- Mu as useThrottleValue,
357
- Qs as useTime,
358
- qs as useTimeout,
359
- Js as useTimer,
360
- _s as useToggle,
356
+ Du as useThrottleCallback,
357
+ Lu as useThrottleState,
358
+ Nu as useThrottleValue,
359
+ Xs as useTime,
360
+ Zs as useTimeout,
361
+ Ys as useTimer,
362
+ Ds as useToggle,
361
363
  Zo as useUnmount,
362
- Bs as useUrlSearchParam,
363
- Fs as useUrlSearchParams,
364
+ Ks as useUrlSearchParam,
365
+ Us as useUrlSearchParams,
364
366
  he as useVibrate,
365
367
  _e as useVirtualKeyboard,
366
368
  lt as useVisibility,
@@ -370,6 +372,6 @@ export {
370
372
  gt as useWindowFocus,
371
373
  Ct as useWindowScroll,
372
374
  At as useWindowSize,
373
- Vs as useWizard
375
+ Hs as useWizard
374
376
  };
375
377
  //# sourceMappingURL=index.mjs.map
@@ -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'));
@@ -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