@siberiacancode/reactuse 0.3.7 → 0.3.9

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 (179) 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/useClickOutside/useClickOutside.cjs +1 -1
  6. package/dist/cjs/hooks/useClickOutside/useClickOutside.cjs.map +1 -1
  7. package/dist/cjs/hooks/useCssVar/useCssVar.cjs +1 -1
  8. package/dist/cjs/hooks/useCssVar/useCssVar.cjs.map +1 -1
  9. package/dist/cjs/hooks/useDebounceEffect/useDebounceEffect.cjs +2 -0
  10. package/dist/cjs/hooks/useDebounceEffect/useDebounceEffect.cjs.map +1 -0
  11. package/dist/cjs/hooks/useDidUpdate/useDidUpdate.cjs.map +1 -1
  12. package/dist/cjs/hooks/useDisplayMedia/useDisplayMedia.cjs +1 -1
  13. package/dist/cjs/hooks/useDisplayMedia/useDisplayMedia.cjs.map +1 -1
  14. package/dist/cjs/hooks/useDoubleClick/useDoubleClick.cjs +1 -1
  15. package/dist/cjs/hooks/useDoubleClick/useDoubleClick.cjs.map +1 -1
  16. package/dist/cjs/hooks/useDropZone/useDropZone.cjs +1 -1
  17. package/dist/cjs/hooks/useDropZone/useDropZone.cjs.map +1 -1
  18. package/dist/cjs/hooks/useEventListener/useEventListener.cjs +1 -1
  19. package/dist/cjs/hooks/useEventListener/useEventListener.cjs.map +1 -1
  20. package/dist/cjs/hooks/useFocus/useFocus.cjs +1 -1
  21. package/dist/cjs/hooks/useFocus/useFocus.cjs.map +1 -1
  22. package/dist/cjs/hooks/useFocusTrap/useFocusTrap.cjs +1 -1
  23. package/dist/cjs/hooks/useFocusTrap/useFocusTrap.cjs.map +1 -1
  24. package/dist/cjs/hooks/useHotkeys/useHotkeys.cjs +1 -1
  25. package/dist/cjs/hooks/useHotkeys/useHotkeys.cjs.map +1 -1
  26. package/dist/cjs/hooks/useHover/useHover.cjs +1 -1
  27. package/dist/cjs/hooks/useHover/useHover.cjs.map +1 -1
  28. package/dist/cjs/hooks/useInfiniteScroll/useInfiniteScroll.cjs +1 -1
  29. package/dist/cjs/hooks/useInfiniteScroll/useInfiniteScroll.cjs.map +1 -1
  30. package/dist/cjs/hooks/useIntersectionObserver/useIntersectionObserver.cjs +1 -1
  31. package/dist/cjs/hooks/useIntersectionObserver/useIntersectionObserver.cjs.map +1 -1
  32. package/dist/cjs/hooks/useKeyPress/useKeyPress.cjs +1 -1
  33. package/dist/cjs/hooks/useKeyPress/useKeyPress.cjs.map +1 -1
  34. package/dist/cjs/hooks/useKeyPressEvent/useKeyPressEvent.cjs +1 -1
  35. package/dist/cjs/hooks/useKeyPressEvent/useKeyPressEvent.cjs.map +1 -1
  36. package/dist/cjs/hooks/useKeyboard/useKeyboard.cjs +1 -1
  37. package/dist/cjs/hooks/useKeyboard/useKeyboard.cjs.map +1 -1
  38. package/dist/cjs/hooks/useKeysPressed/useKeysPressed.cjs +1 -1
  39. package/dist/cjs/hooks/useKeysPressed/useKeysPressed.cjs.map +1 -1
  40. package/dist/cjs/hooks/useLockScroll/useLockScroll.cjs +1 -1
  41. package/dist/cjs/hooks/useLockScroll/useLockScroll.cjs.map +1 -1
  42. package/dist/cjs/hooks/useLongPress/useLongPress.cjs +1 -1
  43. package/dist/cjs/hooks/useLongPress/useLongPress.cjs.map +1 -1
  44. package/dist/cjs/hooks/useMeasure/useMeasure.cjs +1 -1
  45. package/dist/cjs/hooks/useMeasure/useMeasure.cjs.map +1 -1
  46. package/dist/cjs/hooks/useMediaControls/useMediaControls.cjs +1 -1
  47. package/dist/cjs/hooks/useMediaControls/useMediaControls.cjs.map +1 -1
  48. package/dist/cjs/hooks/useMouse/useMouse.cjs +1 -1
  49. package/dist/cjs/hooks/useMouse/useMouse.cjs.map +1 -1
  50. package/dist/cjs/hooks/useMutationObserver/useMutationObserver.cjs +1 -1
  51. package/dist/cjs/hooks/useMutationObserver/useMutationObserver.cjs.map +1 -1
  52. package/dist/cjs/hooks/usePaint/usePaint.cjs +1 -1
  53. package/dist/cjs/hooks/usePaint/usePaint.cjs.map +1 -1
  54. package/dist/cjs/hooks/useParallax/useParallax.cjs +1 -1
  55. package/dist/cjs/hooks/useParallax/useParallax.cjs.map +1 -1
  56. package/dist/cjs/hooks/usePictureInPicture/usePictureInPicture.cjs +1 -1
  57. package/dist/cjs/hooks/usePictureInPicture/usePictureInPicture.cjs.map +1 -1
  58. package/dist/cjs/hooks/useResizeObserver/useResizeObserver.cjs +1 -1
  59. package/dist/cjs/hooks/useResizeObserver/useResizeObserver.cjs.map +1 -1
  60. package/dist/cjs/hooks/useRightClick/useRightClick.cjs +1 -1
  61. package/dist/cjs/hooks/useRightClick/useRightClick.cjs.map +1 -1
  62. package/dist/cjs/hooks/useScroll/useScroll.cjs +1 -1
  63. package/dist/cjs/hooks/useScroll/useScroll.cjs.map +1 -1
  64. package/dist/cjs/hooks/useScrollIntoView/useScrollIntoView.cjs +1 -1
  65. package/dist/cjs/hooks/useScrollIntoView/useScrollIntoView.cjs.map +1 -1
  66. package/dist/cjs/hooks/useScrollTo/useScrollTo.cjs +1 -1
  67. package/dist/cjs/hooks/useScrollTo/useScrollTo.cjs.map +1 -1
  68. package/dist/cjs/hooks/useSize/useSize.cjs +2 -0
  69. package/dist/cjs/hooks/useSize/useSize.cjs.map +1 -0
  70. package/dist/cjs/hooks/useSticky/useSticky.cjs +1 -1
  71. package/dist/cjs/hooks/useSticky/useSticky.cjs.map +1 -1
  72. package/dist/cjs/hooks/useTextDirection/useTextDirection.cjs +1 -1
  73. package/dist/cjs/hooks/useTextDirection/useTextDirection.cjs.map +1 -1
  74. package/dist/cjs/hooks/useTextareaAutosize/useTextareaAutosize.cjs +1 -1
  75. package/dist/cjs/hooks/useTextareaAutosize/useTextareaAutosize.cjs.map +1 -1
  76. package/dist/cjs/hooks/useThrottleEffect/useThrottleEffect.cjs +2 -0
  77. package/dist/cjs/hooks/useThrottleEffect/useThrottleEffect.cjs.map +1 -0
  78. package/dist/cjs/hooks/useVisibility/useVisibility.cjs +1 -1
  79. package/dist/cjs/hooks/useVisibility/useVisibility.cjs.map +1 -1
  80. package/dist/cjs/index.cjs +1 -1
  81. package/dist/cjs/utils/helpers/isTarget.cjs +1 -1
  82. package/dist/cjs/utils/helpers/isTarget.cjs.map +1 -1
  83. package/dist/esm/hooks/useActiveElement/useActiveElement.mjs +5 -5
  84. package/dist/esm/hooks/useActiveElement/useActiveElement.mjs.map +1 -1
  85. package/dist/esm/hooks/useAutoScroll/useAutoScroll.mjs +6 -6
  86. package/dist/esm/hooks/useAutoScroll/useAutoScroll.mjs.map +1 -1
  87. package/dist/esm/hooks/useClickOutside/useClickOutside.mjs +6 -6
  88. package/dist/esm/hooks/useClickOutside/useClickOutside.mjs.map +1 -1
  89. package/dist/esm/hooks/useCssVar/useCssVar.mjs +5 -5
  90. package/dist/esm/hooks/useCssVar/useCssVar.mjs.map +1 -1
  91. package/dist/esm/hooks/useDebounceEffect/useDebounceEffect.mjs +19 -0
  92. package/dist/esm/hooks/useDebounceEffect/useDebounceEffect.mjs.map +1 -0
  93. package/dist/esm/hooks/useDidUpdate/useDidUpdate.mjs +7 -7
  94. package/dist/esm/hooks/useDidUpdate/useDidUpdate.mjs.map +1 -1
  95. package/dist/esm/hooks/useDisplayMedia/useDisplayMedia.mjs +6 -6
  96. package/dist/esm/hooks/useDisplayMedia/useDisplayMedia.mjs.map +1 -1
  97. package/dist/esm/hooks/useDoubleClick/useDoubleClick.mjs +12 -12
  98. package/dist/esm/hooks/useDoubleClick/useDoubleClick.mjs.map +1 -1
  99. package/dist/esm/hooks/useDropZone/useDropZone.mjs +3 -3
  100. package/dist/esm/hooks/useDropZone/useDropZone.mjs.map +1 -1
  101. package/dist/esm/hooks/useEventListener/useEventListener.mjs +10 -10
  102. package/dist/esm/hooks/useEventListener/useEventListener.mjs.map +1 -1
  103. package/dist/esm/hooks/useFocus/useFocus.mjs +10 -10
  104. package/dist/esm/hooks/useFocus/useFocus.mjs.map +1 -1
  105. package/dist/esm/hooks/useFocusTrap/useFocusTrap.mjs +5 -5
  106. package/dist/esm/hooks/useFocusTrap/useFocusTrap.mjs.map +1 -1
  107. package/dist/esm/hooks/useHotkeys/useHotkeys.mjs +7 -8
  108. package/dist/esm/hooks/useHotkeys/useHotkeys.mjs.map +1 -1
  109. package/dist/esm/hooks/useHover/useHover.mjs +7 -7
  110. package/dist/esm/hooks/useHover/useHover.mjs.map +1 -1
  111. package/dist/esm/hooks/useInfiniteScroll/useInfiniteScroll.mjs +6 -6
  112. package/dist/esm/hooks/useInfiniteScroll/useInfiniteScroll.mjs.map +1 -1
  113. package/dist/esm/hooks/useIntersectionObserver/useIntersectionObserver.mjs +17 -18
  114. package/dist/esm/hooks/useIntersectionObserver/useIntersectionObserver.mjs.map +1 -1
  115. package/dist/esm/hooks/useKeyPress/useKeyPress.mjs +5 -5
  116. package/dist/esm/hooks/useKeyPress/useKeyPress.mjs.map +1 -1
  117. package/dist/esm/hooks/useKeyPressEvent/useKeyPressEvent.mjs +3 -4
  118. package/dist/esm/hooks/useKeyPressEvent/useKeyPressEvent.mjs.map +1 -1
  119. package/dist/esm/hooks/useKeyboard/useKeyboard.mjs +8 -8
  120. package/dist/esm/hooks/useKeyboard/useKeyboard.mjs.map +1 -1
  121. package/dist/esm/hooks/useKeysPressed/useKeysPressed.mjs +8 -8
  122. package/dist/esm/hooks/useKeysPressed/useKeysPressed.mjs.map +1 -1
  123. package/dist/esm/hooks/useLockScroll/useLockScroll.mjs +13 -13
  124. package/dist/esm/hooks/useLockScroll/useLockScroll.mjs.map +1 -1
  125. package/dist/esm/hooks/useLongPress/useLongPress.mjs +7 -7
  126. package/dist/esm/hooks/useLongPress/useLongPress.mjs.map +1 -1
  127. package/dist/esm/hooks/useMeasure/useMeasure.mjs +3 -3
  128. package/dist/esm/hooks/useMeasure/useMeasure.mjs.map +1 -1
  129. package/dist/esm/hooks/useMediaControls/useMediaControls.mjs +4 -4
  130. package/dist/esm/hooks/useMediaControls/useMediaControls.mjs.map +1 -1
  131. package/dist/esm/hooks/useMouse/useMouse.mjs +10 -10
  132. package/dist/esm/hooks/useMouse/useMouse.mjs.map +1 -1
  133. package/dist/esm/hooks/useMutationObserver/useMutationObserver.mjs +7 -8
  134. package/dist/esm/hooks/useMutationObserver/useMutationObserver.mjs.map +1 -1
  135. package/dist/esm/hooks/usePaint/usePaint.mjs +15 -15
  136. package/dist/esm/hooks/usePaint/usePaint.mjs.map +1 -1
  137. package/dist/esm/hooks/useParallax/useParallax.mjs +24 -25
  138. package/dist/esm/hooks/useParallax/useParallax.mjs.map +1 -1
  139. package/dist/esm/hooks/usePictureInPicture/usePictureInPicture.mjs +6 -6
  140. package/dist/esm/hooks/usePictureInPicture/usePictureInPicture.mjs.map +1 -1
  141. package/dist/esm/hooks/useResizeObserver/useResizeObserver.mjs +7 -7
  142. package/dist/esm/hooks/useResizeObserver/useResizeObserver.mjs.map +1 -1
  143. package/dist/esm/hooks/useRightClick/useRightClick.mjs +5 -5
  144. package/dist/esm/hooks/useRightClick/useRightClick.mjs.map +1 -1
  145. package/dist/esm/hooks/useScroll/useScroll.mjs +13 -13
  146. package/dist/esm/hooks/useScroll/useScroll.mjs.map +1 -1
  147. package/dist/esm/hooks/useScrollIntoView/useScrollIntoView.mjs +9 -9
  148. package/dist/esm/hooks/useScrollIntoView/useScrollIntoView.mjs.map +1 -1
  149. package/dist/esm/hooks/useScrollTo/useScrollTo.mjs +1 -1
  150. package/dist/esm/hooks/useScrollTo/useScrollTo.mjs.map +1 -1
  151. package/dist/esm/hooks/useSize/useSize.mjs +31 -0
  152. package/dist/esm/hooks/useSize/useSize.mjs.map +1 -0
  153. package/dist/esm/hooks/useSticky/useSticky.mjs +10 -10
  154. package/dist/esm/hooks/useSticky/useSticky.mjs.map +1 -1
  155. package/dist/esm/hooks/useTextDirection/useTextDirection.mjs +3 -3
  156. package/dist/esm/hooks/useTextDirection/useTextDirection.mjs.map +1 -1
  157. package/dist/esm/hooks/useTextareaAutosize/useTextareaAutosize.mjs +13 -13
  158. package/dist/esm/hooks/useTextareaAutosize/useTextareaAutosize.mjs.map +1 -1
  159. package/dist/esm/hooks/useThrottleEffect/useThrottleEffect.mjs +22 -0
  160. package/dist/esm/hooks/useThrottleEffect/useThrottleEffect.mjs.map +1 -0
  161. package/dist/esm/hooks/useVisibility/useVisibility.mjs +22 -23
  162. package/dist/esm/hooks/useVisibility/useVisibility.mjs.map +1 -1
  163. package/dist/esm/index.mjs +110 -102
  164. package/dist/esm/index.mjs.map +1 -1
  165. package/dist/esm/utils/helpers/isTarget.mjs +12 -7
  166. package/dist/esm/utils/helpers/isTarget.mjs.map +1 -1
  167. package/dist/types/hooks/sensors.d.ts +1 -1
  168. package/dist/types/hooks/useDebounceEffect/useDebounceEffect.d.ts +15 -0
  169. package/dist/types/hooks/useSize/useSize.d.ts +43 -0
  170. package/dist/types/hooks/useThrottleEffect/useThrottleEffect.d.ts +15 -0
  171. package/dist/types/hooks/useVisibility/useVisibility.d.ts +1 -1
  172. package/dist/types/hooks/utilities.d.ts +2 -0
  173. package/dist/types/utils/helpers/isTarget.d.ts +10 -4
  174. package/package.json +1 -1
  175. package/dist/cjs/hooks/useElementSize/useElementSize.cjs +0 -2
  176. package/dist/cjs/hooks/useElementSize/useElementSize.cjs.map +0 -1
  177. package/dist/esm/hooks/useElementSize/useElementSize.mjs +0 -30
  178. package/dist/esm/hooks/useElementSize/useElementSize.mjs.map +0 -1
  179. package/dist/types/hooks/useElementSize/useElementSize.d.ts +0 -39
@@ -1 +1 @@
1
- {"version":3,"file":"useTextareaAutosize.mjs","sources":["../../../../src/hooks/useTextareaAutosize/useTextareaAutosize.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 use textarea autosize options */\nexport interface UseTextareaAutosizeOptions {\n /** The initial value for the textarea */\n initialValue?: string;\n /** Callback function called when the textarea size changes */\n onResize?: () => void;\n}\n\n/** The use textarea autosize return type */\nexport interface UseTextareaAutosizeReturn {\n /** The current value of the textarea */\n value: string;\n /** Function to clear the textarea value */\n clear: () => void;\n /** Function to set the textarea value */\n set: (value: string) => void;\n}\n\nexport interface UseTextareaAutosize {\n (target: HookTarget, options?: UseTextareaAutosizeOptions): UseTextareaAutosizeReturn;\n\n (target: HookTarget, initialValue: string): UseTextareaAutosizeReturn;\n\n <Target extends HTMLTextAreaElement = HTMLTextAreaElement>(\n initialValue: string,\n target?: never\n ): UseTextareaAutosizeReturn & {\n ref: StateRef<Target>;\n };\n\n <Target extends HTMLTextAreaElement = HTMLTextAreaElement>(\n options?: UseTextareaAutosizeOptions,\n target?: never\n ): UseTextareaAutosizeReturn & {\n ref: StateRef<Target>;\n };\n}\n\n/**\n * @name useTextareaAutosize\n * @description - Hook that automatically adjusts textarea height based on content\n * @category Elements\n * @usage medium\n *\n * @overload\n * @param {HookTarget} target The target textarea element\n * @param {string} [options.initialValue] The initial value for the textarea\n * @param {Function} [options.onResize] Callback function called when the textarea size changes\n * @returns {UseTextareaAutosizeReturn} An object containing value, setValue and clear\n *\n * @example\n * const { value, setValue, clear } = useTextareaAutosize(ref);\n *\n * @overload\n * @param {HookTarget} target The target textarea element\n * @param {string} initialValue The initial value for the textarea\n * @returns {UseTextareaAutosizeReturn} An object containing value, setValue and clear\n *\n * @example\n * const { value, setValue, clear } = useTextareaAutosize(ref, 'initial');\n *\n * @overload\n * @template Target The textarea element type\n * @param {string} initialValue The initial value for the textarea\n * @returns {UseTextareaAutosizeReturn & { ref: StateRef<Target> }} An object containing ref, value, setValue and clear\n *\n * @example\n * const { ref, value, setValue, clear } = useTextareaAutosize('initial');\n *\n * @overload\n * @template Target The textarea element type\n * @param {string} [options.initialValue] The initial value for the textarea\n * @param {Function} [options.onResize] Callback function called when the textarea size changes\n * @returns {UseTextareaAutosizeReturn & { ref: StateRef<Target> }} An object containing ref, value, setValue and clear\n *\n * @example\n * const { ref, value, setValue, clear } = useTextareaAutosize();\n */\nexport const useTextareaAutosize = ((...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 : { initialValue: params[1] }\n : typeof params[0] === 'object'\n ? params[0]\n : { initialValue: params[0] }\n ) as UseTextareaAutosizeOptions | undefined;\n\n const [value, setValue] = useState(options?.initialValue ?? '');\n const internalRef = useRefState<HTMLTextAreaElement>();\n const textareaRef = useRef<HTMLTextAreaElement | null>(null);\n const scrollHeightRef = useRef(0);\n\n const onTextareaResize = () => {\n const textarea = textareaRef.current;\n if (!textarea) return;\n\n const originalMinHeight = textarea.style.minHeight;\n const originalMaxHeight = textarea.style.maxHeight;\n\n textarea.style.height = 'auto';\n textarea.style.minHeight = 'auto';\n textarea.style.maxHeight = 'none';\n\n const scrollHeight = textarea.scrollHeight;\n\n textarea.style.height = `${scrollHeight}px`;\n textarea.style.minHeight = originalMinHeight;\n textarea.style.maxHeight = originalMaxHeight;\n\n if (scrollHeight !== scrollHeightRef.current) options?.onResize?.();\n scrollHeightRef.current = scrollHeight;\n };\n\n const setTextareaValue = (newValue: string) => {\n setValue(newValue);\n const textarea = textareaRef.current;\n if (!textarea) return;\n textarea.value = newValue;\n requestAnimationFrame(() => {\n onTextareaResize();\n });\n };\n\n useEffect(() => {\n if (!target && !internalRef.state) return;\n\n const element = (\n target ? isTarget.getElement(target) : internalRef.current\n ) as HTMLTextAreaElement;\n if (!element) return;\n\n textareaRef.current = element;\n if (options?.initialValue) element.value = options.initialValue;\n\n onTextareaResize();\n\n const onInput = (event: InputEvent) => {\n const newValue = (event.target as HTMLTextAreaElement).value;\n setTextareaValue(newValue);\n\n requestAnimationFrame(() => {\n onTextareaResize();\n });\n };\n\n const onResize = () => {\n requestAnimationFrame(() => {\n onTextareaResize();\n });\n };\n\n element.addEventListener('input', onInput as EventListener);\n element.addEventListener('resize', onResize as EventListener);\n\n return () => {\n element.removeEventListener('input', onInput as EventListener);\n element.removeEventListener('resize', onResize as EventListener);\n };\n }, [target, internalRef.state, isTarget.getRefState(target)]);\n\n const clear = () => setValue('');\n\n if (target)\n return {\n value,\n set: setTextareaValue,\n clear\n };\n return {\n ref: internalRef,\n value,\n set: setTextareaValue,\n clear\n };\n}) as UseTextareaAutosize;\n"],"names":["useTextareaAutosize","params","target","isTarget","options","value","setValue","useState","internalRef","useRefState","textareaRef","useRef","scrollHeightRef","onTextareaResize","textarea","originalMinHeight","originalMaxHeight","scrollHeight","setTextareaValue","newValue","useEffect","element","onInput","event","onResize","clear"],"mappings":";;;AAwFO,MAAMA,KAAuB,IAAIC,MAAkB;AACxD,QAAMC,IAAUC,EAASF,EAAO,CAAC,CAAC,IAAIA,EAAO,CAAC,IAAI,QAE5CG,IACJF,IACI,OAAOD,EAAO,CAAC,KAAM,WACnBA,EAAO,CAAC,IACR,EAAE,cAAcA,EAAO,CAAC,EAAA,IAC1B,OAAOA,EAAO,CAAC,KAAM,WACnBA,EAAO,CAAC,IACR,EAAE,cAAcA,EAAO,CAAC,EAAA,GAG1B,CAACI,GAAOC,CAAQ,IAAIC,EAASH,GAAS,gBAAgB,EAAE,GACxDI,IAAcC,EAAA,GACdC,IAAcC,EAAmC,IAAI,GACrDC,IAAkBD,EAAO,CAAC,GAE1BE,IAAmB,MAAM;AAC7B,UAAMC,IAAWJ,EAAY;AAC7B,QAAI,CAACI,EAAU;AAEf,UAAMC,IAAoBD,EAAS,MAAM,WACnCE,IAAoBF,EAAS,MAAM;AAEzC,IAAAA,EAAS,MAAM,SAAS,QACxBA,EAAS,MAAM,YAAY,QAC3BA,EAAS,MAAM,YAAY;AAE3B,UAAMG,IAAeH,EAAS;AAE9B,IAAAA,EAAS,MAAM,SAAS,GAAGG,CAAY,MACvCH,EAAS,MAAM,YAAYC,GAC3BD,EAAS,MAAM,YAAYE,GAEvBC,MAAiBL,EAAgB,WAASR,GAAS,WAAA,GACvDQ,EAAgB,UAAUK;AAAA,EAAA,GAGtBC,IAAmB,CAACC,MAAqB;AAC7C,IAAAb,EAASa,CAAQ;AACjB,UAAML,IAAWJ,EAAY;AAC7B,IAAKI,MACLA,EAAS,QAAQK,GACjB,sBAAsB,MAAM;AAC1B,MAAAN,EAAA;AAAA,IAAiB,CAClB;AAAA,EAAA;AAGH,EAAAO,EAAU,MAAM;AACd,QAAI,CAAClB,KAAU,CAACM,EAAY,MAAO;AAEnC,UAAMa,IACJnB,IAASC,EAAS,WAAWD,CAAM,IAAIM,EAAY;AAErD,QAAI,CAACa,EAAS;AAEd,IAAAX,EAAY,UAAUW,GAClBjB,GAAS,iBAAciB,EAAQ,QAAQjB,EAAQ,eAEnDS,EAAA;AAEA,UAAMS,IAAU,CAACC,MAAsB;AACrC,YAAMJ,IAAYI,EAAM,OAA+B;AACvD,MAAAL,EAAiBC,CAAQ,GAEzB,sBAAsB,MAAM;AAC1B,QAAAN,EAAA;AAAA,MAAiB,CAClB;AAAA,IAAA,GAGGW,IAAW,MAAM;AACrB,4BAAsB,MAAM;AAC1B,QAAAX,EAAA;AAAA,MAAiB,CAClB;AAAA,IAAA;AAGH,WAAAQ,EAAQ,iBAAiB,SAASC,CAAwB,GAC1DD,EAAQ,iBAAiB,UAAUG,CAAyB,GAErD,MAAM;AACX,MAAAH,EAAQ,oBAAoB,SAASC,CAAwB,GAC7DD,EAAQ,oBAAoB,UAAUG,CAAyB;AAAA,IAAA;AAAA,EACjE,GACC,CAACtB,GAAQM,EAAY,OAAOL,EAAS,YAAYD,CAAM,CAAC,CAAC;AAE5D,QAAMuB,IAAQ,MAAMnB,EAAS,EAAE;AAE/B,SAAIJ,IACK;AAAA,IACL,OAAAG;AAAA,IACA,KAAKa;AAAA,IACL,OAAAO;AAAA,EAAA,IAEG;AAAA,IACL,KAAKjB;AAAA,IACL,OAAAH;AAAA,IACA,KAAKa;AAAA,IACL,OAAAO;AAAA,EAAA;AAEJ;"}
1
+ {"version":3,"file":"useTextareaAutosize.mjs","sources":["../../../../src/hooks/useTextareaAutosize/useTextareaAutosize.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 use textarea autosize options */\nexport interface UseTextareaAutosizeOptions {\n /** The initial value for the textarea */\n initialValue?: string;\n /** Callback function called when the textarea size changes */\n onResize?: () => void;\n}\n\n/** The use textarea autosize return type */\nexport interface UseTextareaAutosizeReturn {\n /** The current value of the textarea */\n value: string;\n /** Function to clear the textarea value */\n clear: () => void;\n /** Function to set the textarea value */\n set: (value: string) => void;\n}\n\nexport interface UseTextareaAutosize {\n (target: HookTarget, options?: UseTextareaAutosizeOptions): UseTextareaAutosizeReturn;\n\n (target: HookTarget, initialValue: string): UseTextareaAutosizeReturn;\n\n <Target extends HTMLTextAreaElement = HTMLTextAreaElement>(\n initialValue: string,\n target?: never\n ): UseTextareaAutosizeReturn & {\n ref: StateRef<Target>;\n };\n\n <Target extends HTMLTextAreaElement = HTMLTextAreaElement>(\n options?: UseTextareaAutosizeOptions,\n target?: never\n ): UseTextareaAutosizeReturn & {\n ref: StateRef<Target>;\n };\n}\n\n/**\n * @name useTextareaAutosize\n * @description - Hook that automatically adjusts textarea height based on content\n * @category Elements\n * @usage medium\n *\n * @overload\n * @param {HookTarget} target The target textarea element\n * @param {string} [options.initialValue] The initial value for the textarea\n * @param {Function} [options.onResize] Callback function called when the textarea size changes\n * @returns {UseTextareaAutosizeReturn} An object containing value, setValue and clear\n *\n * @example\n * const { value, setValue, clear } = useTextareaAutosize(ref);\n *\n * @overload\n * @param {HookTarget} target The target textarea element\n * @param {string} initialValue The initial value for the textarea\n * @returns {UseTextareaAutosizeReturn} An object containing value, setValue and clear\n *\n * @example\n * const { value, setValue, clear } = useTextareaAutosize(ref, 'initial');\n *\n * @overload\n * @template Target The textarea element type\n * @param {string} initialValue The initial value for the textarea\n * @returns {UseTextareaAutosizeReturn & { ref: StateRef<Target> }} An object containing ref, value, setValue and clear\n *\n * @example\n * const { ref, value, setValue, clear } = useTextareaAutosize('initial');\n *\n * @overload\n * @template Target The textarea element type\n * @param {string} [options.initialValue] The initial value for the textarea\n * @param {Function} [options.onResize] Callback function called when the textarea size changes\n * @returns {UseTextareaAutosizeReturn & { ref: StateRef<Target> }} An object containing ref, value, setValue and clear\n *\n * @example\n * const { ref, value, setValue, clear } = useTextareaAutosize();\n */\nexport const useTextareaAutosize = ((...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 : { initialValue: params[1] }\n : typeof params[0] === 'object'\n ? params[0]\n : { initialValue: params[0] }\n ) as UseTextareaAutosizeOptions | undefined;\n\n const [value, setValue] = useState(options?.initialValue ?? '');\n const internalRef = useRefState<HTMLTextAreaElement>();\n const textareaRef = useRef<HTMLTextAreaElement | null>(null);\n const scrollHeightRef = useRef(0);\n\n const onTextareaResize = () => {\n const textarea = textareaRef.current;\n if (!textarea) return;\n\n const originalMinHeight = textarea.style.minHeight;\n const originalMaxHeight = textarea.style.maxHeight;\n\n textarea.style.height = 'auto';\n textarea.style.minHeight = 'auto';\n textarea.style.maxHeight = 'none';\n\n const scrollHeight = textarea.scrollHeight;\n\n textarea.style.height = `${scrollHeight}px`;\n textarea.style.minHeight = originalMinHeight;\n textarea.style.maxHeight = originalMaxHeight;\n\n if (scrollHeight !== scrollHeightRef.current) options?.onResize?.();\n scrollHeightRef.current = scrollHeight;\n };\n\n const setTextareaValue = (newValue: string) => {\n setValue(newValue);\n const textarea = textareaRef.current;\n if (!textarea) return;\n textarea.value = newValue;\n requestAnimationFrame(() => {\n onTextareaResize();\n });\n };\n\n useEffect(() => {\n if (!target && !internalRef.state) return;\n\n const element = (\n target ? isTarget.getElement(target) : internalRef.current\n ) as HTMLTextAreaElement;\n if (!element) return;\n\n textareaRef.current = element;\n if (options?.initialValue) element.value = options.initialValue;\n\n onTextareaResize();\n\n const onInput = (event: InputEvent) => {\n const newValue = (event.target as HTMLTextAreaElement).value;\n setTextareaValue(newValue);\n\n requestAnimationFrame(() => {\n onTextareaResize();\n });\n };\n\n const onResize = () => {\n requestAnimationFrame(() => {\n onTextareaResize();\n });\n };\n\n element.addEventListener('input', onInput as EventListener);\n element.addEventListener('resize', onResize as EventListener);\n\n return () => {\n element.removeEventListener('input', onInput as EventListener);\n element.removeEventListener('resize', onResize as EventListener);\n };\n }, [target && isTarget.getRawElement(target), internalRef.state]);\n\n const clear = () => setValue('');\n\n if (target)\n return {\n value,\n set: setTextareaValue,\n clear\n };\n return {\n ref: internalRef,\n value,\n set: setTextareaValue,\n clear\n };\n}) as UseTextareaAutosize;\n"],"names":["useTextareaAutosize","params","target","isTarget","options","value","setValue","useState","internalRef","useRefState","textareaRef","useRef","scrollHeightRef","onTextareaResize","textarea","originalMinHeight","originalMaxHeight","scrollHeight","setTextareaValue","newValue","useEffect","element","onInput","event","onResize","clear"],"mappings":";;;AAwFO,MAAMA,KAAuB,IAAIC,MAAkB;AACxD,QAAMC,IAAUC,EAASF,EAAO,CAAC,CAAC,IAAIA,EAAO,CAAC,IAAI,QAE5CG,IACJF,IACI,OAAOD,EAAO,CAAC,KAAM,WACnBA,EAAO,CAAC,IACR,EAAE,cAAcA,EAAO,CAAC,EAAA,IAC1B,OAAOA,EAAO,CAAC,KAAM,WACnBA,EAAO,CAAC,IACR,EAAE,cAAcA,EAAO,CAAC,EAAA,GAG1B,CAACI,GAAOC,CAAQ,IAAIC,EAASH,GAAS,gBAAgB,EAAE,GACxDI,IAAcC,EAAA,GACdC,IAAcC,EAAmC,IAAI,GACrDC,IAAkBD,EAAO,CAAC,GAE1BE,IAAmB,MAAM;AAC7B,UAAMC,IAAWJ,EAAY;AAC7B,QAAI,CAACI,EAAU;AAEf,UAAMC,IAAoBD,EAAS,MAAM,WACnCE,IAAoBF,EAAS,MAAM;AAEzC,IAAAA,EAAS,MAAM,SAAS,QACxBA,EAAS,MAAM,YAAY,QAC3BA,EAAS,MAAM,YAAY;AAE3B,UAAMG,IAAeH,EAAS;AAE9B,IAAAA,EAAS,MAAM,SAAS,GAAGG,CAAY,MACvCH,EAAS,MAAM,YAAYC,GAC3BD,EAAS,MAAM,YAAYE,GAEvBC,MAAiBL,EAAgB,WAASR,GAAS,WAAA,GACvDQ,EAAgB,UAAUK;AAAA,EAAA,GAGtBC,IAAmB,CAACC,MAAqB;AAC7C,IAAAb,EAASa,CAAQ;AACjB,UAAML,IAAWJ,EAAY;AAC7B,IAAKI,MACLA,EAAS,QAAQK,GACjB,sBAAsB,MAAM;AAC1B,MAAAN,EAAA;AAAA,IAAiB,CAClB;AAAA,EAAA;AAGH,EAAAO,EAAU,MAAM;AACd,QAAI,CAAClB,KAAU,CAACM,EAAY,MAAO;AAEnC,UAAMa,IACJnB,IAASC,EAAS,WAAWD,CAAM,IAAIM,EAAY;AAErD,QAAI,CAACa,EAAS;AAEd,IAAAX,EAAY,UAAUW,GAClBjB,GAAS,iBAAciB,EAAQ,QAAQjB,EAAQ,eAEnDS,EAAA;AAEA,UAAMS,IAAU,CAACC,MAAsB;AACrC,YAAMJ,IAAYI,EAAM,OAA+B;AACvD,MAAAL,EAAiBC,CAAQ,GAEzB,sBAAsB,MAAM;AAC1B,QAAAN,EAAA;AAAA,MAAiB,CAClB;AAAA,IAAA,GAGGW,IAAW,MAAM;AACrB,4BAAsB,MAAM;AAC1B,QAAAX,EAAA;AAAA,MAAiB,CAClB;AAAA,IAAA;AAGH,WAAAQ,EAAQ,iBAAiB,SAASC,CAAwB,GAC1DD,EAAQ,iBAAiB,UAAUG,CAAyB,GAErD,MAAM;AACX,MAAAH,EAAQ,oBAAoB,SAASC,CAAwB,GAC7DD,EAAQ,oBAAoB,UAAUG,CAAyB;AAAA,IAAA;AAAA,EACjE,GACC,CAACtB,KAAUC,EAAS,cAAcD,CAAM,GAAGM,EAAY,KAAK,CAAC;AAEhE,QAAMiB,IAAQ,MAAMnB,EAAS,EAAE;AAE/B,SAAIJ,IACK;AAAA,IACL,OAAAG;AAAA,IACA,KAAKa;AAAA,IACL,OAAAO;AAAA,EAAA,IAEG;AAAA,IACL,KAAKjB;AAAA,IACL,OAAAH;AAAA,IACA,KAAKa;AAAA,IACL,OAAAO;AAAA,EAAA;AAEJ;"}
@@ -0,0 +1,22 @@
1
+ import { useRef as e, useEffect as l } from "react";
2
+ const R = (f, o, i) => {
3
+ const s = e(!0), r = e(void 0), t = e(null), u = e(!1), n = e(f), c = e(o);
4
+ n.current = f, c.current = o, l(() => {
5
+ if (s.current) {
6
+ s.current = !1;
7
+ return;
8
+ }
9
+ if (!u.current)
10
+ return r.current = n.current(), u.current = !0, setTimeout(() => {
11
+ u.current = !1, t.current = setTimeout(() => {
12
+ r.current = n.current();
13
+ }, c.current);
14
+ }, c.current), () => {
15
+ t.current && clearTimeout(t.current), t.current = null, typeof r.current == "function" && r.current();
16
+ };
17
+ }, i);
18
+ };
19
+ export {
20
+ R as useThrottleEffect
21
+ };
22
+ //# sourceMappingURL=useThrottleEffect.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useThrottleEffect.mjs","sources":["../../../../src/hooks/useThrottleEffect/useThrottleEffect.ts"],"sourcesContent":["import type { DependencyList, EffectCallback } from 'react';\n\nimport { useEffect, useRef } from 'react';\n\n/**\n * @name useThrottleEffect\n * @description – Hook that runs an effect at most once per delay period when dependencies change\n * @category Utilities\n * @usage medium\n *\n * @param {EffectCallback} effect The effect callback to run\n * @param {number} delay The delay in milliseconds\n * @param {DependencyList} deps The dependencies list for the effect\n *\n * @example\n * useThrottleEffect(() => console.log('effect'), 500, [value]);\n */\nexport const useThrottleEffect = (effect: EffectCallback, delay: number, deps?: DependencyList) => {\n const mountedRef = useRef(true);\n const cleanupRef = useRef<ReturnType<EffectCallback>>(undefined);\n const timeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const isCalledRef = useRef(false);\n\n const effectRef = useRef(effect);\n const delayRef = useRef(delay);\n\n effectRef.current = effect;\n delayRef.current = delay;\n\n useEffect(() => {\n if (mountedRef.current) {\n mountedRef.current = false;\n return;\n }\n\n if (isCalledRef.current) return;\n\n cleanupRef.current = effectRef.current();\n isCalledRef.current = true;\n\n setTimeout(() => {\n isCalledRef.current = false;\n\n timeoutRef.current = setTimeout(() => {\n cleanupRef.current = effectRef.current();\n }, delayRef.current);\n }, delayRef.current);\n\n return () => {\n if (timeoutRef.current) clearTimeout(timeoutRef.current);\n timeoutRef.current = null;\n if (typeof cleanupRef.current === 'function') cleanupRef.current();\n };\n }, deps);\n};\n"],"names":["useThrottleEffect","effect","delay","deps","mountedRef","useRef","cleanupRef","timeoutRef","isCalledRef","effectRef","delayRef","useEffect"],"mappings":";AAiBO,MAAMA,IAAoB,CAACC,GAAwBC,GAAeC,MAA0B;AACjG,QAAMC,IAAaC,EAAO,EAAI,GACxBC,IAAaD,EAAmC,MAAS,GACzDE,IAAaF,EAA6C,IAAI,GAC9DG,IAAcH,EAAO,EAAK,GAE1BI,IAAYJ,EAAOJ,CAAM,GACzBS,IAAWL,EAAOH,CAAK;AAE7B,EAAAO,EAAU,UAAUR,GACpBS,EAAS,UAAUR,GAEnBS,EAAU,MAAM;AACd,QAAIP,EAAW,SAAS;AACtB,MAAAA,EAAW,UAAU;AACrB;AAAA,IAAA;AAGF,QAAI,CAAAI,EAAY;AAEhB,aAAAF,EAAW,UAAUG,EAAU,QAAA,GAC/BD,EAAY,UAAU,IAEtB,WAAW,MAAM;AACf,QAAAA,EAAY,UAAU,IAEtBD,EAAW,UAAU,WAAW,MAAM;AACpC,UAAAD,EAAW,UAAUG,EAAU,QAAA;AAAA,QAAQ,GACtCC,EAAS,OAAO;AAAA,MAAA,GAClBA,EAAS,OAAO,GAEZ,MAAM;AACX,QAAIH,EAAW,WAAS,aAAaA,EAAW,OAAO,GACvDA,EAAW,UAAU,MACjB,OAAOD,EAAW,WAAY,gBAAuB,QAAA;AAAA,MAAQ;AAAA,EACnE,GACCH,CAAI;AACT;"}
@@ -1,41 +1,40 @@
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
- if (!f || !n && !r.state) return;
8
- const b = n ? s.getElement(n) : r.current;
9
- if (!b) return;
1
+ import { useState as d, useRef as R, useEffect as m } from "react";
2
+ import { useRefState as C } from "../useRefState/useRefState.mjs";
3
+ import { isTarget as r } from "../../utils/helpers/isTarget.mjs";
4
+ const I = ((...e) => {
5
+ const n = r(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] }, f = t?.onChange, l = t?.enabled ?? !0, [u, v] = d(), [s, y] = d(), b = s?.isIntersecting ?? !1, o = C(), g = R(f);
6
+ return g.current = f, m(() => {
7
+ if (!l || !n && !o.state) return;
8
+ const a = n ? r.getElement(n) : o.current;
9
+ if (!a) return;
10
10
  const c = new IntersectionObserver(
11
- (a, h) => {
12
- const g = a.pop();
13
- y(g), l.current?.(g, h);
11
+ (E, h) => {
12
+ const i = E[0];
13
+ i && (y(i), g.current?.(i, h));
14
14
  },
15
15
  {
16
16
  ...t,
17
- root: t?.root ? s.getElement(t.root) : document
17
+ root: t?.root ? r.getElement(t.root) : document
18
18
  }
19
19
  );
20
- return v(c), c.observe(b), () => {
20
+ return v(c), c.observe(a), () => {
21
21
  c.disconnect();
22
22
  };
23
23
  }, [
24
- n,
25
- r.state,
26
- s.getRefState(n),
24
+ n && r.getRawElement(n),
25
+ o.state,
27
26
  t?.rootMargin,
28
27
  t?.threshold,
29
28
  t?.root,
30
- f
31
- ]), n ? { observer: u, entry: o, inView: !!o?.isIntersecting } : {
29
+ l
30
+ ]), n ? { observer: u, entry: s, inView: b } : {
32
31
  observer: u,
33
- ref: r,
34
- entry: o,
35
- inView: !!o?.isIntersecting
32
+ ref: o,
33
+ entry: s,
34
+ inView: b
36
35
  };
37
36
  });
38
37
  export {
39
- S as useVisibility
38
+ I as useVisibility
40
39
  };
41
40
  //# 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 }, [\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;"}
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 /** 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 const inView = entry?.isIntersecting ?? false;\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 firstEntry = entries[0];\n if (firstEntry) {\n setEntry(firstEntry);\n internalCallbackRef.current?.(firstEntry, observer);\n }\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 && isTarget.getRawElement(target),\n internalRef.state,\n options?.rootMargin,\n options?.threshold,\n options?.root,\n enabled\n ]);\n\n if (target) return { observer, entry, inView };\n return {\n observer,\n ref: internalRef,\n entry,\n inView\n };\n}) as UseVisibility;\n"],"names":["useVisibility","params","target","isTarget","options","callback","enabled","observer","setObserver","useState","entry","setEntry","inView","internalRef","useRefState","internalCallbackRef","useRef","useEffect","element","entries","firstEntry"],"mappings":";;;AAgGO,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,GACpBG,IAASF,GAAO,kBAAkB,IAElCG,IAAcC,EAAA,GACdC,IAAsBC,EAAOX,CAAQ;AAsC3C,SArCAU,EAAoB,UAAUV,GAE9BY,EAAU,MAAM;AACd,QAAI,CAACX,KAAY,CAACJ,KAAU,CAACW,EAAY,MAAQ;AAEjD,UAAMK,IAAUhB,IAASC,EAAS,WAAWD,CAAM,IAAIW,EAAY;AACnE,QAAI,CAACK,EAAS;AAEd,UAAMX,IAAW,IAAI;AAAA,MACnB,CAACY,GAAsCZ,MAAmC;AACxE,cAAMa,IAAaD,EAAQ,CAAC;AAC5B,QAAIC,MACFT,EAASS,CAAU,GACnBL,EAAoB,UAAUK,GAAYb,CAAQ;AAAA,MACpD;AAAA,MAEF;AAAA,QACE,GAAGH;AAAA,QACH,MAAMA,GAAS,OAAQD,EAAS,WAAWC,EAAQ,IAAI,IAA2B;AAAA,MAAA;AAAA,IACpF;AAGF,WAAAI,EAAYD,CAAQ,GACpBA,EAAS,QAAQW,CAAkB,GAE5B,MAAM;AACXX,MAAAA,EAAS,WAAA;AAAA,IAAW;AAAA,EACtB,GACC;AAAA,IACDL,KAAUC,EAAS,cAAcD,CAAM;AAAA,IACvCW,EAAY;AAAA,IACZT,GAAS;AAAA,IACTA,GAAS;AAAA,IACTA,GAAS;AAAA,IACTE;AAAA,EAAA,CACD,GAEGJ,IAAe,EAAE,UAAAK,GAAU,OAAAG,GAAO,QAAAE,EAAA,IAC/B;AAAA,IACL,UAAAL;AAAA,IACA,KAAKM;AAAA,IACL,OAAAH;AAAA,IACA,QAAAE;AAAA,EAAA;AAEJ;"}
@@ -11,14 +11,14 @@ 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";
14
- import { useClipboard as h } from "./hooks/useClipboard/useClipboard.mjs";
14
+ import { useClipboard as k } from "./hooks/useClipboard/useClipboard.mjs";
15
15
  import { useCopy as _ } from "./hooks/useCopy/useCopy.mjs";
16
16
  import { useCssVar as D } from "./hooks/useCssVar/useCssVar.mjs";
17
17
  import { useDisplayMedia as M } from "./hooks/useDisplayMedia/useDisplayMedia.mjs";
18
18
  import { useDocumentTitle as B } from "./hooks/useDocumentTitle/useDocumentTitle.mjs";
19
19
  import { useEventSource as F } from "./hooks/useEventSource/useEventSource.mjs";
20
20
  import { useEyeDropper as V } from "./hooks/useEyeDropper/useEyeDropper.mjs";
21
- import { useFavicon as w } from "./hooks/useFavicon/useFavicon.mjs";
21
+ import { useFavicon as H } from "./hooks/useFavicon/useFavicon.mjs";
22
22
  import { useFps as z } from "./hooks/useFps/useFps.mjs";
23
23
  import { useFullscreen as Q } from "./hooks/useFullscreen/useFullscreen.mjs";
24
24
  import { mapGamepadToXbox360Controller as q, useGamepad as Z } from "./hooks/useGamepad/useGamepad.mjs";
@@ -36,14 +36,14 @@ 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";
39
- import { useVibrate as he } from "./hooks/useVibrate/useVibrate.mjs";
39
+ import { useVibrate as ke } from "./hooks/useVibrate/useVibrate.mjs";
40
40
  import { useVirtualKeyboard as _e } from "./hooks/useVirtualKeyboard/useVirtualKeyboard.mjs";
41
41
  import { useWakeLock as De } from "./hooks/useWakeLock/useWakeLock.mjs";
42
42
  import { useWebSocket as Me } from "./hooks/useWebSocket/useWebSocket.mjs";
43
43
  import { useLogger as Be } from "./hooks/useLogger/useLogger.mjs";
44
44
  import { useRenderCount as Fe } from "./hooks/useRenderCount/useRenderCount.mjs";
45
45
  import { useRenderInfo as Ve } from "./hooks/useRenderInfo/useRenderInfo.mjs";
46
- import { useRerender as we } from "./hooks/useRerender/useRerender.mjs";
46
+ import { useRerender as He } from "./hooks/useRerender/useRerender.mjs";
47
47
  import { useActiveElement as ze } from "./hooks/useActiveElement/useActiveElement.mjs";
48
48
  import { useAutoScroll as Qe } from "./hooks/useAutoScroll/useAutoScroll.mjs";
49
49
  import { useClickOutside as qe } from "./hooks/useClickOutside/useClickOutside.mjs";
@@ -60,14 +60,14 @@ import { useRightClick as go } from "./hooks/useRightClick/useRightClick.mjs";
60
60
  import { SCRIPT_STATUS_ATTRIBUTE_NAME as Co, useScript as Po } from "./hooks/useScript/useScript.mjs";
61
61
  import { useSticky as Io } from "./hooks/useSticky/useSticky.mjs";
62
62
  import { useTextareaAutosize as Oo } from "./hooks/useTextareaAutosize/useTextareaAutosize.mjs";
63
- import { useTextDirection as ho } from "./hooks/useTextDirection/useTextDirection.mjs";
63
+ import { useTextDirection as ko } from "./hooks/useTextDirection/useTextDirection.mjs";
64
64
  import { useFul as _o } from "./hooks/useFul/useFul.mjs";
65
65
  import { useLess as Do } from "./hooks/useLess/useLess.mjs";
66
66
  import { useOnce as Mo } from "./hooks/useOnce/useOnce.mjs";
67
67
  import { useAsyncEffect as Bo } from "./hooks/useAsyncEffect/useAsyncEffect.mjs";
68
68
  import { useDidUpdate as Fo } from "./hooks/useDidUpdate/useDidUpdate.mjs";
69
69
  import { useIsFirstRender as Vo } from "./hooks/useIsFirstRender/useIsFirstRender.mjs";
70
- import { useIsomorphicLayoutEffect as wo } from "./hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.mjs";
70
+ import { useIsomorphicLayoutEffect as Ho } from "./hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.mjs";
71
71
  import { useMount as zo } from "./hooks/useMount/useMount.mjs";
72
72
  import { deepEqual as Qo, useShallowEffect as Xo } from "./hooks/useShallowEffect/useShallowEffect.mjs";
73
73
  import { useUnmount as Zo } from "./hooks/useUnmount/useUnmount.mjs";
@@ -77,29 +77,29 @@ import { useDeviceOrientation as ar } from "./hooks/useDeviceOrientation/useDevi
77
77
  import { useDevicePixelRatio as nr } from "./hooks/useDevicePixelRatio/useDevicePixelRatio.mjs";
78
78
  import { useDocumentEvent as lr } from "./hooks/useDocumentEvent/useDocumentEvent.mjs";
79
79
  import { useDocumentVisibility as Er } from "./hooks/useDocumentVisibility/useDocumentVisibility.mjs";
80
- import { useElementSize as gr } from "./hooks/useElementSize/useElementSize.mjs";
81
- import { useEventListener as dr } from "./hooks/useEventListener/useEventListener.mjs";
82
- import { isHotkeyMatch as Pr, useHotkeys as Ar } from "./hooks/useHotkeys/useHotkeys.mjs";
83
- import { useIdle as yr } from "./hooks/useIdle/useIdle.mjs";
84
- import { useInfiniteScroll as kr } from "./hooks/useInfiniteScroll/useInfiniteScroll.mjs";
85
- import { useIntersectionObserver as vr } from "./hooks/useIntersectionObserver/useIntersectionObserver.mjs";
86
- import { useKeyboard as br } from "./hooks/useKeyboard/useKeyboard.mjs";
87
- import { useKeyPress as Lr } from "./hooks/useKeyPress/useKeyPress.mjs";
88
- import { useKeyPressEvent as Nr } from "./hooks/useKeyPressEvent/useKeyPressEvent.mjs";
89
- import { useKeysPressed as Kr } from "./hooks/useKeysPressed/useKeysPressed.mjs";
90
- import { useLockScroll as Ur } from "./hooks/useLockScroll/useLockScroll.mjs";
91
- import { useMeasure as Hr } from "./hooks/useMeasure/useMeasure.mjs";
92
- import { useMediaQuery as Wr } from "./hooks/useMediaQuery/useMediaQuery.mjs";
93
- import { useMouse as Gr } from "./hooks/useMouse/useMouse.mjs";
94
- import { useMutationObserver as Xr } from "./hooks/useMutationObserver/useMutationObserver.mjs";
95
- import { useOrientation as Zr } from "./hooks/useOrientation/useOrientation.mjs";
96
- import { usePageLeave as Jr } from "./hooks/usePageLeave/usePageLeave.mjs";
97
- import { useParallax as $r } from "./hooks/useParallax/useParallax.mjs";
98
- import { usePerformanceObserver as ot } from "./hooks/usePerformanceObserver/usePerformanceObserver.mjs";
99
- import { useResizeObserver as tt } from "./hooks/useResizeObserver/useResizeObserver.mjs";
100
- import { useScroll as ut } from "./hooks/useScroll/useScroll.mjs";
101
- import { useScrollIntoView as pt } from "./hooks/useScrollIntoView/useScrollIntoView.mjs";
102
- import { useScrollTo as xt } from "./hooks/useScrollTo/useScrollTo.mjs";
80
+ import { useEventListener as gr } from "./hooks/useEventListener/useEventListener.mjs";
81
+ import { isHotkeyMatch as dr, useHotkeys as Cr } from "./hooks/useHotkeys/useHotkeys.mjs";
82
+ import { useIdle as Ar } from "./hooks/useIdle/useIdle.mjs";
83
+ import { useInfiniteScroll as yr } from "./hooks/useInfiniteScroll/useInfiniteScroll.mjs";
84
+ import { useIntersectionObserver as hr } from "./hooks/useIntersectionObserver/useIntersectionObserver.mjs";
85
+ import { useKeyboard as vr } from "./hooks/useKeyboard/useKeyboard.mjs";
86
+ import { useKeyPress as br } from "./hooks/useKeyPress/useKeyPress.mjs";
87
+ import { useKeyPressEvent as Lr } from "./hooks/useKeyPressEvent/useKeyPressEvent.mjs";
88
+ import { useKeysPressed as Nr } from "./hooks/useKeysPressed/useKeysPressed.mjs";
89
+ import { useLockScroll as Kr } from "./hooks/useLockScroll/useLockScroll.mjs";
90
+ import { useMeasure as Ur } from "./hooks/useMeasure/useMeasure.mjs";
91
+ import { useMediaQuery as wr } from "./hooks/useMediaQuery/useMediaQuery.mjs";
92
+ import { useMouse as Wr } from "./hooks/useMouse/useMouse.mjs";
93
+ import { useMutationObserver as Gr } from "./hooks/useMutationObserver/useMutationObserver.mjs";
94
+ import { useOrientation as Xr } from "./hooks/useOrientation/useOrientation.mjs";
95
+ import { usePageLeave as Zr } from "./hooks/usePageLeave/usePageLeave.mjs";
96
+ import { useParallax as Jr } from "./hooks/useParallax/useParallax.mjs";
97
+ import { usePerformanceObserver as $r } from "./hooks/usePerformanceObserver/usePerformanceObserver.mjs";
98
+ import { useResizeObserver as ot } from "./hooks/useResizeObserver/useResizeObserver.mjs";
99
+ import { useScroll as tt } from "./hooks/useScroll/useScroll.mjs";
100
+ import { useScrollIntoView as ut } from "./hooks/useScrollIntoView/useScrollIntoView.mjs";
101
+ import { useScrollTo as pt } from "./hooks/useScrollTo/useScrollTo.mjs";
102
+ import { useSize as xt } from "./hooks/useSize/useSize.mjs";
103
103
  import { getRangesSelection as it, useTextSelection as nt } from "./hooks/useTextSelection/useTextSelection.mjs";
104
104
  import { useVisibility as lt } from "./hooks/useVisibility/useVisibility.mjs";
105
105
  import { useWindowEvent as Et } from "./hooks/useWindowEvent/useWindowEvent.mjs";
@@ -107,10 +107,10 @@ import { useWindowFocus as gt } from "./hooks/useWindowFocus/useWindowFocus.mjs"
107
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
- import { useControllableState as kt } from "./hooks/useControllableState/useControllableState.mjs";
110
+ import { useControllableState as ht } from "./hooks/useControllableState/useControllableState.mjs";
111
111
  import { COOKIE_EVENT as vt, dispatchCookieEvent as _t, getCookie as bt, getCookies as Dt, removeCookie as Lt, removeCookieItem as Mt, setCookie as Nt, setCookieItem as Bt, useCookie as Kt } from "./hooks/useCookie/useCookie.mjs";
112
112
  import { clearCookies as Ut, useCookies as Vt } from "./hooks/useCookies/useCookies.mjs";
113
- import { useCounter as wt } from "./hooks/useCounter/useCounter.mjs";
113
+ import { useCounter as Ht } from "./hooks/useCounter/useCounter.mjs";
114
114
  import { useDefault as zt } from "./hooks/useDefault/useDefault.mjs";
115
115
  import { useDisclosure as Qt } from "./hooks/useDisclosure/useDisclosure.mjs";
116
116
  import { useField as qt } from "./hooks/useField/useField.mjs";
@@ -127,11 +127,11 @@ import { useSessionStorage as gs } from "./hooks/useSessionStorage/useSessionSto
127
127
  import { useSet as ds } from "./hooks/useSet/useSet.mjs";
128
128
  import { stateHistoryReducer as Ps, useStateHistory as As } from "./hooks/useStateHistory/useStateHistory.mjs";
129
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";
130
+ import { STORAGE_EVENT as hs, dispatchStorageEvent as ks, useStorage as vs } from "./hooks/useStorage/useStorage.mjs";
131
131
  import { useToggle as bs } from "./hooks/useToggle/useToggle.mjs";
132
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
133
  import { useUrlSearchParams as Us } from "./hooks/useUrlSearchParams/useUrlSearchParams.mjs";
134
- import { useWizard as Hs } from "./hooks/useWizard/useWizard.mjs";
134
+ import { useWizard as ws } from "./hooks/useWizard/useWizard.mjs";
135
135
  import { useInterval as Ws } from "./hooks/useInterval/useInterval.mjs";
136
136
  import { useStopwatch as Gs } from "./hooks/useStopwatch/useStopwatch.mjs";
137
137
  import { useTime as Xs } from "./hooks/useTime/useTime.mjs";
@@ -147,21 +147,23 @@ import { usePreferredReducedMotion as cu } from "./hooks/usePreferredReducedMoti
147
147
  import { useBatchedCallback as Su } from "./hooks/useBatchedCallback/useBatchedCallback.mjs";
148
148
  import { useConst as Tu } from "./hooks/useConst/useConst.mjs";
149
149
  import { useDebounceCallback as Ru } from "./hooks/useDebounceCallback/useDebounceCallback.mjs";
150
- import { useDebounceState as Cu } from "./hooks/useDebounceState/useDebounceState.mjs";
151
- import { useDebounceValue as Au } from "./hooks/useDebounceValue/useDebounceValue.mjs";
152
- import { useEvent as yu } from "./hooks/useEvent/useEvent.mjs";
153
- import { useLastChanged as ku } from "./hooks/useLastChanged/useLastChanged.mjs";
154
- import { useLatest as vu } from "./hooks/useLatest/useLatest.mjs";
155
- import { usePrevious as bu } from "./hooks/usePrevious/usePrevious.mjs";
156
- import { useThrottleCallback as Lu } from "./hooks/useThrottleCallback/useThrottleCallback.mjs";
157
- import { useThrottleState as Nu } from "./hooks/useThrottleState/useThrottleState.mjs";
158
- import { useThrottleValue as Ku } from "./hooks/useThrottleValue/useThrottleValue.mjs";
159
- import { copy as Uu, legacyCopyToClipboard as Vu } from "./utils/helpers/copy.mjs";
160
- import { debounce as wu } from "./utils/helpers/debounce.mjs";
161
- import { getDate as zu } from "./utils/helpers/getDate.mjs";
162
- import { getRetry as Qu } from "./utils/helpers/getRetry.mjs";
163
- import { getRefState as qu, isTarget as Zu, target as ju, targetSymbol as Ju } from "./utils/helpers/isTarget.mjs";
164
- import { throttle as $u } from "./utils/helpers/throttle.mjs";
150
+ import { useDebounceEffect as Cu } from "./hooks/useDebounceEffect/useDebounceEffect.mjs";
151
+ import { useDebounceState as Au } from "./hooks/useDebounceState/useDebounceState.mjs";
152
+ import { useDebounceValue as yu } from "./hooks/useDebounceValue/useDebounceValue.mjs";
153
+ import { useEvent as hu } from "./hooks/useEvent/useEvent.mjs";
154
+ import { useLastChanged as vu } from "./hooks/useLastChanged/useLastChanged.mjs";
155
+ import { useLatest as bu } from "./hooks/useLatest/useLatest.mjs";
156
+ import { usePrevious as Lu } from "./hooks/usePrevious/usePrevious.mjs";
157
+ import { useThrottleCallback as Nu } from "./hooks/useThrottleCallback/useThrottleCallback.mjs";
158
+ import { useThrottleEffect as Ku } from "./hooks/useThrottleEffect/useThrottleEffect.mjs";
159
+ import { useThrottleState as Uu } from "./hooks/useThrottleState/useThrottleState.mjs";
160
+ import { useThrottleValue as wu } from "./hooks/useThrottleValue/useThrottleValue.mjs";
161
+ import { copy as Wu, legacyCopyToClipboard as zu } from "./utils/helpers/copy.mjs";
162
+ import { debounce as Qu } from "./utils/helpers/debounce.mjs";
163
+ import { getDate as qu } from "./utils/helpers/getDate.mjs";
164
+ import { getRetry as ju } from "./utils/helpers/getRetry.mjs";
165
+ import { getRawElement as Yu, getRefState as $u, isBrowserTarget as em, isRef as om, isRefState as rm, isTarget as tm, target as sm, targetSymbol as um } from "./utils/helpers/isTarget.mjs";
166
+ import { throttle as pm } from "./utils/helpers/throttle.mjs";
165
167
  export {
166
168
  Jo as BREAKPOINTS_ANT_DESIGN,
167
169
  Yo as BREAKPOINTS_BOOTSTRAP_V5,
@@ -178,37 +180,41 @@ export {
178
180
  lo as Paint,
179
181
  So as Pointer,
180
182
  Co as SCRIPT_STATUS_ATTRIBUTE_NAME,
181
- ks as STORAGE_EVENT,
183
+ hs as STORAGE_EVENT,
182
184
  Ls as URL_SEARCH_PARAMS_EVENT,
183
185
  us as assignRef,
184
186
  Ut as clearCookies,
185
- Uu as copy,
187
+ Wu as copy,
186
188
  r as createContext,
187
189
  s as createEventEmitter,
188
190
  Ms as createQueryString,
189
191
  m as createReactiveContext,
190
192
  Ss as createRefState,
191
193
  f as createStore,
192
- wu as debounce,
194
+ Qu as debounce,
193
195
  Qo as deepEqual,
194
196
  _t as dispatchCookieEvent,
195
- hs as dispatchStorageEvent,
197
+ ks as dispatchStorageEvent,
196
198
  Ns as dispatchUrlSearchParamsEvent,
197
199
  se as getConnection,
198
200
  bt as getCookie,
199
201
  Dt as getCookies,
200
- zu as getDate,
202
+ qu as getDate,
201
203
  jt as getHash,
202
204
  ru as getOperatingSystem,
203
205
  it as getRangesSelection,
204
- qu as getRefState,
205
- Qu as getRetry,
206
+ Yu as getRawElement,
207
+ $u as getRefState,
208
+ ju as getRetry,
206
209
  Ae as getSpeechRecognition,
207
210
  Js as getTimeFromSeconds,
208
211
  Bs as getUrlSearchParams,
209
- Pr as isHotkeyMatch,
210
- Zu as isTarget,
211
- Vu as legacyCopyToClipboard,
212
+ em as isBrowserTarget,
213
+ dr as isHotkeyMatch,
214
+ om as isRef,
215
+ rm as isRefState,
216
+ tm as isTarget,
217
+ zu as legacyCopyToClipboard,
212
218
  q as mapGamepadToXbox360Controller,
213
219
  ms as mergeRefs,
214
220
  Lt as removeCookie,
@@ -217,9 +223,9 @@ export {
217
223
  Nt as setCookie,
218
224
  Bt as setCookieItem,
219
225
  Ps as stateHistoryReducer,
220
- ju as target,
221
- Ju as targetSymbol,
222
- $u as throttle,
226
+ sm as target,
227
+ um as targetSymbol,
228
+ pm as throttle,
223
229
  $ as timeRangeToArray,
224
230
  ze as useActiveElement,
225
231
  a as useAsync,
@@ -234,17 +240,18 @@ export {
234
240
  O as useBroadcastChannel,
235
241
  eu as useBrowserLanguage,
236
242
  qe as useClickOutside,
237
- h as useClipboard,
243
+ k as useClipboard,
238
244
  Tu as useConst,
239
- kt as useControllableState,
245
+ ht as useControllableState,
240
246
  Kt as useCookie,
241
247
  Vt as useCookies,
242
248
  _ as useCopy,
243
- wt as useCounter,
249
+ Ht as useCounter,
244
250
  D as useCssVar,
245
251
  Ru as useDebounceCallback,
246
- Cu as useDebounceState,
247
- Au as useDebounceValue,
252
+ Cu as useDebounceEffect,
253
+ Au as useDebounceState,
254
+ yu as useDebounceValue,
248
255
  zt as useDefault,
249
256
  fr as useDeviceMotion,
250
257
  ar as useDeviceOrientation,
@@ -257,12 +264,11 @@ export {
257
264
  Er as useDocumentVisibility,
258
265
  Je as useDoubleClick,
259
266
  $e as useDropZone,
260
- gr as useElementSize,
261
- yu as useEvent,
262
- dr as useEventListener,
267
+ hu as useEvent,
268
+ gr as useEventListener,
263
269
  F as useEventSource,
264
270
  V as useEyeDropper,
265
- w as useFavicon,
271
+ H as useFavicon,
266
272
  qt as useField,
267
273
  oo as useFileDialog,
268
274
  to as useFocus,
@@ -273,50 +279,50 @@ export {
273
279
  Z as useGamepad,
274
280
  J as useGeolocation,
275
281
  Jt as useHash,
276
- Ar as useHotkeys,
282
+ Cr as useHotkeys,
277
283
  fo as useHover,
278
- yr as useIdle,
284
+ Ar as useIdle,
279
285
  ao as useImage,
280
- kr as useInfiniteScroll,
281
- vr as useIntersectionObserver,
286
+ yr as useInfiniteScroll,
287
+ hr as useIntersectionObserver,
282
288
  Ws as useInterval,
283
289
  Vo as useIsFirstRender,
284
- wo as useIsomorphicLayoutEffect,
285
- Lr as useKeyPress,
286
- Nr as useKeyPressEvent,
287
- br as useKeyboard,
288
- Kr as useKeysPressed,
289
- ku as useLastChanged,
290
- vu as useLatest,
290
+ Ho as useIsomorphicLayoutEffect,
291
+ br as useKeyPress,
292
+ Lr as useKeyPressEvent,
293
+ vr as useKeyboard,
294
+ Nr as useKeysPressed,
295
+ vu as useLastChanged,
296
+ bu as useLatest,
291
297
  Do as useLess,
292
298
  $t as useList,
293
299
  os as useLocalStorage,
294
300
  n as useLockCallback,
295
- Ur as useLockScroll,
301
+ Kr as useLockScroll,
296
302
  Be as useLogger,
297
303
  no as useLongPress,
298
304
  ts as useMap,
299
- Hr as useMeasure,
305
+ Ur as useMeasure,
300
306
  ee as useMediaControls,
301
- Wr as useMediaQuery,
307
+ wr as useMediaQuery,
302
308
  re as useMemory,
303
309
  ps as useMergedRef,
304
310
  zo as useMount,
305
- Gr as useMouse,
311
+ Wr as useMouse,
306
312
  l as useMutation,
307
- Xr as useMutationObserver,
313
+ Gr as useMutationObserver,
308
314
  ue as useNetwork,
309
315
  xs as useOffsetPagination,
310
316
  Mo as useOnce,
311
317
  pe as useOnline,
312
318
  tu as useOperatingSystem,
313
319
  E as useOptimistic,
314
- Zr as useOrientation,
320
+ Xr as useOrientation,
315
321
  xe as useOtpCredential,
316
- Jr as usePageLeave,
322
+ Zr as usePageLeave,
317
323
  Eo as usePaint,
318
- $r as useParallax,
319
- ot as usePerformanceObserver,
324
+ Jr as useParallax,
325
+ $r as usePerformanceObserver,
320
326
  ie as usePermission,
321
327
  ce as usePictureInPicture,
322
328
  Se as usePointerLock,
@@ -326,7 +332,7 @@ export {
326
332
  xu as usePreferredDark,
327
333
  iu as usePreferredLanguages,
328
334
  cu as usePreferredReducedMotion,
329
- bu as usePrevious,
335
+ Lu as usePrevious,
330
336
  g as useQuery,
331
337
  is as useQueue,
332
338
  Re as useRaf,
@@ -334,17 +340,18 @@ export {
334
340
  Es as useRefState,
335
341
  Fe as useRenderCount,
336
342
  Ve as useRenderInfo,
337
- we as useRerender,
338
- tt as useResizeObserver,
343
+ He as useRerender,
344
+ ot as useResizeObserver,
339
345
  go as useRightClick,
340
346
  Po as useScript,
341
- ut as useScroll,
342
- pt as useScrollIntoView,
343
- xt as useScrollTo,
347
+ tt as useScroll,
348
+ ut as useScrollIntoView,
349
+ pt as useScrollTo,
344
350
  gs as useSessionStorage,
345
351
  ds as useSet,
346
352
  Xo as useShallowEffect,
347
353
  Ce as useShare,
354
+ xt as useSize,
348
355
  Ie as useSpeechRecognition,
349
356
  Oe as useSpeechSynthesis,
350
357
  As as useStateHistory,
@@ -352,12 +359,13 @@ export {
352
359
  Io as useSticky,
353
360
  Gs as useStopwatch,
354
361
  vs as useStorage,
355
- ho as useTextDirection,
362
+ ko as useTextDirection,
356
363
  nt as useTextSelection,
357
364
  Oo as useTextareaAutosize,
358
- Lu as useThrottleCallback,
359
- Nu as useThrottleState,
360
- Ku as useThrottleValue,
365
+ Nu as useThrottleCallback,
366
+ Ku as useThrottleEffect,
367
+ Uu as useThrottleState,
368
+ wu as useThrottleValue,
361
369
  Xs as useTime,
362
370
  Zs as useTimeout,
363
371
  Ys as useTimer,
@@ -365,7 +373,7 @@ export {
365
373
  Zo as useUnmount,
366
374
  Ks as useUrlSearchParam,
367
375
  Us as useUrlSearchParams,
368
- he as useVibrate,
376
+ ke as useVibrate,
369
377
  _e as useVirtualKeyboard,
370
378
  lt as useVisibility,
371
379
  De as useWakeLock,
@@ -374,6 +382,6 @@ export {
374
382
  gt as useWindowFocus,
375
383
  Ct as useWindowScroll,
376
384
  At as useWindowSize,
377
- Hs as useWizard
385
+ ws as useWizard
378
386
  };
379
387
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,14 +1,19 @@
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) => ({
1
+ const u = /* @__PURE__ */ Symbol("target"), c = (e) => ({
2
2
  value: e,
3
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;
4
+ }), f = (e) => typeof e == "object" && "current" in e, o = (e) => typeof e == "function" && "state" in e && "current" in e, i = (e) => typeof e == "object" && e && "type" in e && e.type === u && "value" in e, n = (e) => f(e) || o(e) || i(e), l = (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), s = (e) => e && "state" in e && e.state, t = (e) => o(e) ? e.state : i(e) ? e.value : e;
5
+ n.wrap = c;
6
+ n.getElement = l;
7
+ n.getRefState = s;
8
+ n.getRawElement = t;
8
9
  export {
9
- c as getRefState,
10
+ t as getRawElement,
11
+ s as getRefState,
12
+ i as isBrowserTarget,
13
+ f as isRef,
14
+ o as isRefState,
10
15
  n as isTarget,
11
- i as target,
16
+ c as target,
12
17
  u as targetSymbol
13
18
  };
14
19
  //# sourceMappingURL=isTarget.mjs.map