@siberiacancode/reactuse 0.3.3 → 0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/hooks/useActiveElement/useActiveElement.cjs +1 -1
- package/dist/cjs/hooks/useActiveElement/useActiveElement.cjs.map +1 -1
- package/dist/cjs/hooks/useAutoScroll/useAutoScroll.cjs +1 -1
- package/dist/cjs/hooks/useAutoScroll/useAutoScroll.cjs.map +1 -1
- package/dist/cjs/hooks/useBreakpoints/useBreakpoints.cjs +1 -1
- package/dist/cjs/hooks/useBreakpoints/useBreakpoints.cjs.map +1 -1
- package/dist/cjs/hooks/useClickOutside/useClickOutside.cjs +1 -1
- package/dist/cjs/hooks/useClickOutside/useClickOutside.cjs.map +1 -1
- package/dist/cjs/hooks/useCookie/useCookie.cjs +1 -1
- package/dist/cjs/hooks/useCookie/useCookie.cjs.map +1 -1
- package/dist/cjs/hooks/useCounter/useCounter.cjs +1 -1
- package/dist/cjs/hooks/useCounter/useCounter.cjs.map +1 -1
- package/dist/cjs/hooks/useCssVar/useCssVar.cjs +1 -1
- package/dist/cjs/hooks/useCssVar/useCssVar.cjs.map +1 -1
- package/dist/cjs/hooks/useDeviceMotion/useDeviceMotion.cjs +1 -1
- package/dist/cjs/hooks/useDeviceMotion/useDeviceMotion.cjs.map +1 -1
- package/dist/cjs/hooks/useDisplayMedia/useDisplayMedia.cjs +1 -1
- package/dist/cjs/hooks/useDisplayMedia/useDisplayMedia.cjs.map +1 -1
- package/dist/cjs/hooks/useDoubleClick/useDoubleClick.cjs +1 -1
- package/dist/cjs/hooks/useDoubleClick/useDoubleClick.cjs.map +1 -1
- package/dist/cjs/hooks/useDropZone/useDropZone.cjs +1 -1
- package/dist/cjs/hooks/useDropZone/useDropZone.cjs.map +1 -1
- package/dist/cjs/hooks/useElementSize/useElementSize.cjs +1 -1
- package/dist/cjs/hooks/useElementSize/useElementSize.cjs.map +1 -1
- package/dist/cjs/hooks/useEventListener/useEventListener.cjs +1 -1
- package/dist/cjs/hooks/useEventListener/useEventListener.cjs.map +1 -1
- package/dist/cjs/hooks/useEventSource/useEventSource.cjs +1 -1
- package/dist/cjs/hooks/useEventSource/useEventSource.cjs.map +1 -1
- package/dist/cjs/hooks/useField/useField.cjs +1 -1
- package/dist/cjs/hooks/useField/useField.cjs.map +1 -1
- package/dist/cjs/hooks/useFileDialog/useFileDialog.cjs +1 -1
- package/dist/cjs/hooks/useFileDialog/useFileDialog.cjs.map +1 -1
- package/dist/cjs/hooks/useFocus/useFocus.cjs +1 -1
- package/dist/cjs/hooks/useFocus/useFocus.cjs.map +1 -1
- package/dist/cjs/hooks/useFocusTrap/useFocusTrap.cjs +1 -1
- package/dist/cjs/hooks/useFocusTrap/useFocusTrap.cjs.map +1 -1
- package/dist/cjs/hooks/useFullscreen/useFullscreen.cjs +1 -1
- package/dist/cjs/hooks/useFullscreen/useFullscreen.cjs.map +1 -1
- package/dist/cjs/hooks/useHash/useHash.cjs +1 -1
- package/dist/cjs/hooks/useHash/useHash.cjs.map +1 -1
- package/dist/cjs/hooks/useHotkeys/useHotkeys.cjs +1 -1
- package/dist/cjs/hooks/useHotkeys/useHotkeys.cjs.map +1 -1
- package/dist/cjs/hooks/useHover/useHover.cjs +1 -1
- package/dist/cjs/hooks/useHover/useHover.cjs.map +1 -1
- package/dist/cjs/hooks/useInfiniteScroll/useInfiniteScroll.cjs +1 -1
- package/dist/cjs/hooks/useInfiniteScroll/useInfiniteScroll.cjs.map +1 -1
- package/dist/cjs/hooks/useIntersectionObserver/useIntersectionObserver.cjs +1 -1
- package/dist/cjs/hooks/useIntersectionObserver/useIntersectionObserver.cjs.map +1 -1
- package/dist/cjs/hooks/useInterval/useInterval.cjs +1 -1
- package/dist/cjs/hooks/useInterval/useInterval.cjs.map +1 -1
- package/dist/cjs/hooks/useKeyPress/useKeyPress.cjs +1 -1
- package/dist/cjs/hooks/useKeyPress/useKeyPress.cjs.map +1 -1
- package/dist/cjs/hooks/useKeyPressEvent/useKeyPressEvent.cjs +1 -1
- package/dist/cjs/hooks/useKeyPressEvent/useKeyPressEvent.cjs.map +1 -1
- package/dist/cjs/hooks/useKeyboard/useKeyboard.cjs +1 -1
- package/dist/cjs/hooks/useKeyboard/useKeyboard.cjs.map +1 -1
- package/dist/cjs/hooks/useKeysPressed/useKeysPressed.cjs +1 -1
- package/dist/cjs/hooks/useKeysPressed/useKeysPressed.cjs.map +1 -1
- package/dist/cjs/hooks/useLockScroll/useLockScroll.cjs +1 -1
- package/dist/cjs/hooks/useLockScroll/useLockScroll.cjs.map +1 -1
- package/dist/cjs/hooks/useLongPress/useLongPress.cjs +1 -1
- package/dist/cjs/hooks/useLongPress/useLongPress.cjs.map +1 -1
- package/dist/cjs/hooks/useMeasure/useMeasure.cjs +1 -1
- package/dist/cjs/hooks/useMeasure/useMeasure.cjs.map +1 -1
- package/dist/cjs/hooks/useMediaControls/useMediaControls.cjs +1 -1
- package/dist/cjs/hooks/useMediaControls/useMediaControls.cjs.map +1 -1
- package/dist/cjs/hooks/useMouse/useMouse.cjs +1 -1
- package/dist/cjs/hooks/useMouse/useMouse.cjs.map +1 -1
- package/dist/cjs/hooks/useMutationObserver/useMutationObserver.cjs +1 -1
- package/dist/cjs/hooks/useMutationObserver/useMutationObserver.cjs.map +1 -1
- package/dist/cjs/hooks/useOtpCredential/useOtpCredential.cjs +1 -1
- package/dist/cjs/hooks/useOtpCredential/useOtpCredential.cjs.map +1 -1
- package/dist/cjs/hooks/usePaint/usePaint.cjs +1 -1
- package/dist/cjs/hooks/usePaint/usePaint.cjs.map +1 -1
- package/dist/cjs/hooks/useParallax/useParallax.cjs +1 -1
- package/dist/cjs/hooks/useParallax/useParallax.cjs.map +1 -1
- package/dist/cjs/hooks/usePictureInPicture/usePictureInPicture.cjs +1 -1
- package/dist/cjs/hooks/usePictureInPicture/usePictureInPicture.cjs.map +1 -1
- package/dist/cjs/hooks/useRefState/useRefState.cjs +1 -1
- package/dist/cjs/hooks/useRefState/useRefState.cjs.map +1 -1
- package/dist/cjs/hooks/useResizeObserver/useResizeObserver.cjs +1 -1
- package/dist/cjs/hooks/useResizeObserver/useResizeObserver.cjs.map +1 -1
- package/dist/cjs/hooks/useRightClick/useRightClick.cjs +1 -1
- package/dist/cjs/hooks/useRightClick/useRightClick.cjs.map +1 -1
- package/dist/cjs/hooks/useScroll/useScroll.cjs +1 -1
- package/dist/cjs/hooks/useScroll/useScroll.cjs.map +1 -1
- package/dist/cjs/hooks/useScrollIntoView/useScrollIntoView.cjs +1 -1
- package/dist/cjs/hooks/useScrollIntoView/useScrollIntoView.cjs.map +1 -1
- package/dist/cjs/hooks/useScrollTo/useScrollTo.cjs +1 -1
- package/dist/cjs/hooks/useScrollTo/useScrollTo.cjs.map +1 -1
- package/dist/cjs/hooks/useSpeechRecognition/useSpeechRecognition.cjs +1 -1
- package/dist/cjs/hooks/useSpeechRecognition/useSpeechRecognition.cjs.map +1 -1
- package/dist/cjs/hooks/useSpeechSynthesis/useSpeechSynthesis.cjs +1 -1
- package/dist/cjs/hooks/useSpeechSynthesis/useSpeechSynthesis.cjs.map +1 -1
- package/dist/cjs/hooks/useSticky/useSticky.cjs +1 -1
- package/dist/cjs/hooks/useSticky/useSticky.cjs.map +1 -1
- package/dist/cjs/hooks/useStopwatch/useStopwatch.cjs +1 -1
- package/dist/cjs/hooks/useStopwatch/useStopwatch.cjs.map +1 -1
- package/dist/cjs/hooks/useStorage/useStorage.cjs +1 -1
- package/dist/cjs/hooks/useStorage/useStorage.cjs.map +1 -1
- package/dist/cjs/hooks/useTextDirection/useTextDirection.cjs +1 -1
- package/dist/cjs/hooks/useTextDirection/useTextDirection.cjs.map +1 -1
- package/dist/cjs/hooks/useTextareaAutosize/useTextareaAutosize.cjs +1 -1
- package/dist/cjs/hooks/useTextareaAutosize/useTextareaAutosize.cjs.map +1 -1
- package/dist/cjs/hooks/useTimer/useTimer.cjs +1 -1
- package/dist/cjs/hooks/useTimer/useTimer.cjs.map +1 -1
- package/dist/cjs/hooks/useUrlSearchParam/useUrlSearchParam.cjs +1 -1
- package/dist/cjs/hooks/useUrlSearchParam/useUrlSearchParam.cjs.map +1 -1
- package/dist/cjs/hooks/useUrlSearchParams/useUrlSearchParams.cjs +1 -1
- package/dist/cjs/hooks/useUrlSearchParams/useUrlSearchParams.cjs.map +1 -1
- package/dist/cjs/hooks/useVisibility/useVisibility.cjs +1 -1
- package/dist/cjs/hooks/useVisibility/useVisibility.cjs.map +1 -1
- package/dist/cjs/hooks/useWindowFocus/useWindowFocus.cjs +1 -1
- package/dist/cjs/hooks/useWindowFocus/useWindowFocus.cjs.map +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/utils/helpers/isTarget.cjs +1 -1
- package/dist/cjs/utils/helpers/isTarget.cjs.map +1 -1
- package/dist/esm/hooks/useActiveElement/useActiveElement.mjs +13 -13
- package/dist/esm/hooks/useActiveElement/useActiveElement.mjs.map +1 -1
- package/dist/esm/hooks/useAutoScroll/useAutoScroll.mjs +24 -24
- package/dist/esm/hooks/useAutoScroll/useAutoScroll.mjs.map +1 -1
- package/dist/esm/hooks/useBreakpoints/useBreakpoints.mjs +30 -35
- package/dist/esm/hooks/useBreakpoints/useBreakpoints.mjs.map +1 -1
- package/dist/esm/hooks/useClickOutside/useClickOutside.mjs +15 -14
- package/dist/esm/hooks/useClickOutside/useClickOutside.mjs.map +1 -1
- package/dist/esm/hooks/useCookie/useCookie.mjs +2 -2
- package/dist/esm/hooks/useCookie/useCookie.mjs.map +1 -1
- package/dist/esm/hooks/useCounter/useCounter.mjs +2 -2
- package/dist/esm/hooks/useCounter/useCounter.mjs.map +1 -1
- package/dist/esm/hooks/useCssVar/useCssVar.mjs +8 -8
- package/dist/esm/hooks/useCssVar/useCssVar.mjs.map +1 -1
- package/dist/esm/hooks/useDeviceMotion/useDeviceMotion.mjs +2 -2
- package/dist/esm/hooks/useDeviceMotion/useDeviceMotion.mjs.map +1 -1
- package/dist/esm/hooks/useDisplayMedia/useDisplayMedia.mjs +17 -17
- package/dist/esm/hooks/useDisplayMedia/useDisplayMedia.mjs.map +1 -1
- package/dist/esm/hooks/useDoubleClick/useDoubleClick.mjs +14 -14
- package/dist/esm/hooks/useDoubleClick/useDoubleClick.mjs.map +1 -1
- package/dist/esm/hooks/useDropZone/useDropZone.mjs +23 -23
- package/dist/esm/hooks/useDropZone/useDropZone.mjs.map +1 -1
- package/dist/esm/hooks/useElementSize/useElementSize.mjs +14 -14
- package/dist/esm/hooks/useElementSize/useElementSize.mjs.map +1 -1
- package/dist/esm/hooks/useEventListener/useEventListener.mjs +14 -14
- package/dist/esm/hooks/useEventListener/useEventListener.mjs.map +1 -1
- package/dist/esm/hooks/useEventSource/useEventSource.mjs +33 -34
- package/dist/esm/hooks/useEventSource/useEventSource.mjs.map +1 -1
- package/dist/esm/hooks/useField/useField.mjs +2 -1
- package/dist/esm/hooks/useField/useField.mjs.map +1 -1
- package/dist/esm/hooks/useFileDialog/useFileDialog.mjs +2 -2
- package/dist/esm/hooks/useFileDialog/useFileDialog.mjs.map +1 -1
- package/dist/esm/hooks/useFocus/useFocus.mjs +20 -20
- package/dist/esm/hooks/useFocus/useFocus.mjs.map +1 -1
- package/dist/esm/hooks/useFocusTrap/useFocusTrap.mjs +21 -21
- package/dist/esm/hooks/useFocusTrap/useFocusTrap.mjs.map +1 -1
- package/dist/esm/hooks/useFullscreen/useFullscreen.mjs +2 -2
- package/dist/esm/hooks/useFullscreen/useFullscreen.mjs.map +1 -1
- package/dist/esm/hooks/useHash/useHash.mjs +2 -2
- package/dist/esm/hooks/useHash/useHash.mjs.map +1 -1
- package/dist/esm/hooks/useHotkeys/useHotkeys.mjs +24 -16
- package/dist/esm/hooks/useHotkeys/useHotkeys.mjs.map +1 -1
- package/dist/esm/hooks/useHover/useHover.mjs +16 -16
- package/dist/esm/hooks/useHover/useHover.mjs.map +1 -1
- package/dist/esm/hooks/useInfiniteScroll/useInfiniteScroll.mjs +16 -16
- package/dist/esm/hooks/useInfiniteScroll/useInfiniteScroll.mjs.map +1 -1
- package/dist/esm/hooks/useIntersectionObserver/useIntersectionObserver.mjs +26 -18
- package/dist/esm/hooks/useIntersectionObserver/useIntersectionObserver.mjs.map +1 -1
- package/dist/esm/hooks/useInterval/useInterval.mjs +2 -2
- package/dist/esm/hooks/useInterval/useInterval.mjs.map +1 -1
- package/dist/esm/hooks/useKeyPress/useKeyPress.mjs +15 -15
- package/dist/esm/hooks/useKeyPress/useKeyPress.mjs.map +1 -1
- package/dist/esm/hooks/useKeyPressEvent/useKeyPressEvent.mjs +22 -15
- package/dist/esm/hooks/useKeyPressEvent/useKeyPressEvent.mjs.map +1 -1
- package/dist/esm/hooks/useKeyboard/useKeyboard.mjs +10 -10
- package/dist/esm/hooks/useKeyboard/useKeyboard.mjs.map +1 -1
- package/dist/esm/hooks/useKeysPressed/useKeysPressed.mjs +12 -12
- package/dist/esm/hooks/useKeysPressed/useKeysPressed.mjs.map +1 -1
- package/dist/esm/hooks/useLockScroll/useLockScroll.mjs +23 -23
- package/dist/esm/hooks/useLockScroll/useLockScroll.mjs.map +1 -1
- package/dist/esm/hooks/useLongPress/useLongPress.mjs +22 -22
- package/dist/esm/hooks/useLongPress/useLongPress.mjs.map +1 -1
- package/dist/esm/hooks/useMeasure/useMeasure.mjs +15 -15
- package/dist/esm/hooks/useMeasure/useMeasure.mjs.map +1 -1
- package/dist/esm/hooks/useMediaControls/useMediaControls.mjs +28 -28
- package/dist/esm/hooks/useMediaControls/useMediaControls.mjs.map +1 -1
- package/dist/esm/hooks/useMouse/useMouse.mjs +17 -17
- package/dist/esm/hooks/useMouse/useMouse.mjs.map +1 -1
- package/dist/esm/hooks/useMutationObserver/useMutationObserver.mjs +17 -16
- package/dist/esm/hooks/useMutationObserver/useMutationObserver.mjs.map +1 -1
- package/dist/esm/hooks/useOtpCredential/useOtpCredential.mjs +2 -2
- package/dist/esm/hooks/useOtpCredential/useOtpCredential.mjs.map +1 -1
- package/dist/esm/hooks/usePaint/usePaint.mjs +31 -31
- package/dist/esm/hooks/usePaint/usePaint.mjs.map +1 -1
- package/dist/esm/hooks/useParallax/useParallax.mjs +24 -23
- package/dist/esm/hooks/useParallax/useParallax.mjs.map +1 -1
- package/dist/esm/hooks/usePictureInPicture/usePictureInPicture.mjs +25 -25
- package/dist/esm/hooks/usePictureInPicture/usePictureInPicture.mjs.map +1 -1
- package/dist/esm/hooks/useRefState/useRefState.mjs +1 -0
- package/dist/esm/hooks/useRefState/useRefState.mjs.map +1 -1
- package/dist/esm/hooks/useResizeObserver/useResizeObserver.mjs +16 -16
- package/dist/esm/hooks/useResizeObserver/useResizeObserver.mjs.map +1 -1
- package/dist/esm/hooks/useRightClick/useRightClick.mjs +14 -14
- package/dist/esm/hooks/useRightClick/useRightClick.mjs.map +1 -1
- package/dist/esm/hooks/useScroll/useScroll.mjs +22 -22
- package/dist/esm/hooks/useScroll/useScroll.mjs.map +1 -1
- package/dist/esm/hooks/useScrollIntoView/useScrollIntoView.mjs +16 -16
- package/dist/esm/hooks/useScrollIntoView/useScrollIntoView.mjs.map +1 -1
- package/dist/esm/hooks/useScrollTo/useScrollTo.mjs +10 -10
- package/dist/esm/hooks/useScrollTo/useScrollTo.mjs.map +1 -1
- package/dist/esm/hooks/useSpeechRecognition/useSpeechRecognition.mjs +20 -21
- package/dist/esm/hooks/useSpeechRecognition/useSpeechRecognition.mjs.map +1 -1
- package/dist/esm/hooks/useSpeechSynthesis/useSpeechSynthesis.mjs +51 -36
- package/dist/esm/hooks/useSpeechSynthesis/useSpeechSynthesis.mjs.map +1 -1
- package/dist/esm/hooks/useSticky/useSticky.mjs +17 -17
- package/dist/esm/hooks/useSticky/useSticky.mjs.map +1 -1
- package/dist/esm/hooks/useStopwatch/useStopwatch.mjs +4 -4
- package/dist/esm/hooks/useStopwatch/useStopwatch.mjs.map +1 -1
- package/dist/esm/hooks/useStorage/useStorage.mjs +40 -37
- package/dist/esm/hooks/useStorage/useStorage.mjs.map +1 -1
- package/dist/esm/hooks/useTextDirection/useTextDirection.mjs +12 -12
- package/dist/esm/hooks/useTextDirection/useTextDirection.mjs.map +1 -1
- package/dist/esm/hooks/useTextareaAutosize/useTextareaAutosize.mjs +20 -20
- package/dist/esm/hooks/useTextareaAutosize/useTextareaAutosize.mjs.map +1 -1
- package/dist/esm/hooks/useTimer/useTimer.mjs +3 -3
- package/dist/esm/hooks/useTimer/useTimer.mjs.map +1 -1
- package/dist/esm/hooks/useUrlSearchParam/useUrlSearchParam.mjs +2 -2
- package/dist/esm/hooks/useUrlSearchParam/useUrlSearchParam.mjs.map +1 -1
- package/dist/esm/hooks/useUrlSearchParams/useUrlSearchParams.mjs +2 -2
- package/dist/esm/hooks/useUrlSearchParams/useUrlSearchParams.mjs.map +1 -1
- package/dist/esm/hooks/useVisibility/useVisibility.mjs +25 -17
- package/dist/esm/hooks/useVisibility/useVisibility.mjs.map +1 -1
- package/dist/esm/hooks/useWindowFocus/useWindowFocus.mjs +1 -1
- package/dist/esm/hooks/useWindowFocus/useWindowFocus.mjs.map +1 -1
- package/dist/esm/index.mjs +98 -96
- package/dist/esm/utils/helpers/isTarget.mjs +10 -8
- package/dist/esm/utils/helpers/isTarget.mjs.map +1 -1
- package/dist/types/hooks/useBreakpoints/useBreakpoints.d.ts +1 -11
- package/dist/types/hooks/useClickOutside/useClickOutside.d.ts +1 -1
- package/dist/types/hooks/useEventSource/useEventSource.d.ts +2 -2
- package/dist/types/hooks/useField/useField.d.ts +3 -0
- package/dist/types/hooks/useHover/useHover.d.ts +6 -6
- package/dist/types/hooks/useRefState/useRefState.d.ts +1 -0
- package/dist/types/hooks/useSpeechSynthesis/useSpeechSynthesis.d.ts +1 -1
- package/dist/types/utils/helpers/isTarget.d.ts +9 -1
- package/package.json +89 -89
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const O=require("./helpers/createContext/createContext.cjs"),k=require("./helpers/createEventEmitter/createEventEmitter.cjs"),v=require("./helpers/createReactiveContext/createReactiveContext.cjs"),A=require("./helpers/createStore/createStore.cjs"),h=require("./hooks/useAsync/useAsync.cjs"),b=require("./hooks/useLockCallback/useLockCallback.cjs"),f=require("./hooks/useMutation/useMutation.cjs"),D=require("./hooks/useOptimistic/useOptimistic.cjs"),L=require("./hooks/useQuery/useQuery.cjs"),M=require("./hooks/useAudio/useAudio.cjs"),_=require("./hooks/useBattery/useBattery.cjs"),N=require("./hooks/useBluetooth/useBluetooth.cjs"),B=require("./hooks/useBroadcastChannel/useBroadcastChannel.cjs"),F=require("./hooks/useClipboard/useClipboard.cjs"),K=require("./hooks/useCopy/useCopy.cjs"),V=require("./hooks/useCssVar/useCssVar.cjs"),U=require("./hooks/useDisplayMedia/useDisplayMedia.cjs"),w=require("./hooks/useDocumentTitle/useDocumentTitle.cjs"),H=require("./hooks/useEventSource/useEventSource.cjs"),x=require("./hooks/useEyeDropper/useEyeDropper.cjs"),W=require("./hooks/useFavicon/useFavicon.cjs"),z=require("./hooks/useFps/useFps.cjs"),Q=require("./hooks/useFullscreen/useFullscreen.cjs"),n=require("./hooks/useGamepad/useGamepad.cjs"),G=require("./hooks/useGeolocation/useGeolocation.cjs"),c=require("./hooks/useMediaControls/useMediaControls.cjs"),X=require("./hooks/useMemory/useMemory.cjs"),a=require("./hooks/useNetwork/useNetwork.cjs"),Z=require("./hooks/useOnline/useOnline.cjs"),j=require("./hooks/useOtpCredential/useOtpCredential.cjs"),J=require("./hooks/usePermission/usePermission.cjs"),Y=require("./hooks/usePictureInPicture/usePictureInPicture.cjs"),$=require("./hooks/usePointerLock/usePointerLock.cjs"),ee=require("./hooks/usePostMessage/usePostMessage.cjs"),se=require("./hooks/useRaf/useRaf.cjs"),ue=require("./hooks/useShare/useShare.cjs"),l=require("./hooks/useSpeechRecognition/useSpeechRecognition.cjs"),re=require("./hooks/useSpeechSynthesis/useSpeechSynthesis.cjs"),te=require("./hooks/useVibrate/useVibrate.cjs"),oe=require("./hooks/useVirtualKeyboard/useVirtualKeyboard.cjs"),ie=require("./hooks/useWakeLock/useWakeLock.cjs"),ne=require("./hooks/useWebSocket/useWebSocket.cjs"),ce=require("./hooks/useLogger/useLogger.cjs"),ae=require("./hooks/useRenderCount/useRenderCount.cjs"),le=require("./hooks/useRenderInfo/useRenderInfo.cjs"),Se=require("./hooks/useRerender/useRerender.cjs"),qe=require("./hooks/useActiveElement/useActiveElement.cjs"),de=require("./hooks/useAutoScroll/useAutoScroll.cjs"),ge=require("./hooks/useClickOutside/useClickOutside.cjs"),S=require("./hooks/useDoubleClick/useDoubleClick.cjs"),Te=require("./hooks/useDropZone/useDropZone.cjs"),Ee=require("./hooks/useFileDialog/useFileDialog.cjs"),Ce=require("./hooks/useFocus/useFocus.cjs"),q=require("./hooks/useFocusTrap/useFocusTrap.cjs"),Pe=require("./hooks/useHover/useHover.cjs"),Re=require("./hooks/useImage/useImage.cjs"),me=require("./hooks/useLongPress/useLongPress.cjs"),r=require("./hooks/usePaint/usePaint.cjs"),ye=require("./hooks/useRightClick/useRightClick.cjs"),d=require("./hooks/useScript/useScript.cjs"),pe=require("./hooks/useSticky/useSticky.cjs"),Ie=require("./hooks/useTextareaAutosize/useTextareaAutosize.cjs"),Oe=require("./hooks/useTextDirection/useTextDirection.cjs"),ke=require("./hooks/useFul/useFul.cjs"),ve=require("./hooks/useLess/useLess.cjs"),Ae=require("./hooks/useOnce/useOnce.cjs"),he=require("./hooks/useAsyncEffect/useAsyncEffect.cjs"),be=require("./hooks/useDidUpdate/useDidUpdate.cjs"),fe=require("./hooks/useIsFirstRender/useIsFirstRender.cjs"),De=require("./hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.cjs"),Le=require("./hooks/useMount/useMount.cjs"),g=require("./hooks/useShallowEffect/useShallowEffect.cjs"),Me=require("./hooks/useUnmount/useUnmount.cjs"),e=require("./hooks/useBreakpoints/useBreakpoints.cjs"),_e=require("./hooks/useDeviceMotion/useDeviceMotion.cjs"),Ne=require("./hooks/useDeviceOrientation/useDeviceOrientation.cjs"),Be=require("./hooks/useDevicePixelRatio/useDevicePixelRatio.cjs"),Fe=require("./hooks/useDocumentEvent/useDocumentEvent.cjs"),Ke=require("./hooks/useDocumentVisibility/useDocumentVisibility.cjs"),Ve=require("./hooks/useElementSize/useElementSize.cjs"),Ue=require("./hooks/useEventListener/useEventListener.cjs"),T=require("./hooks/useHotkeys/useHotkeys.cjs"),we=require("./hooks/useIdle/useIdle.cjs"),He=require("./hooks/useInfiniteScroll/useInfiniteScroll.cjs"),xe=require("./hooks/useIntersectionObserver/useIntersectionObserver.cjs"),We=require("./hooks/useKeyboard/useKeyboard.cjs"),ze=require("./hooks/useKeyPress/useKeyPress.cjs"),Qe=require("./hooks/useKeyPressEvent/useKeyPressEvent.cjs"),Ge=require("./hooks/useKeysPressed/useKeysPressed.cjs"),Xe=require("./hooks/useLockScroll/useLockScroll.cjs"),Ze=require("./hooks/useMeasure/useMeasure.cjs"),je=require("./hooks/useMediaQuery/useMediaQuery.cjs"),Je=require("./hooks/useMouse/useMouse.cjs"),Ye=require("./hooks/useMutationObserver/useMutationObserver.cjs"),$e=require("./hooks/useOrientation/useOrientation.cjs"),es=require("./hooks/usePageLeave/usePageLeave.cjs"),ss=require("./hooks/useParallax/useParallax.cjs"),us=require("./hooks/usePerformanceObserver/usePerformanceObserver.cjs"),rs=require("./hooks/useResizeObserver/useResizeObserver.cjs"),ts=require("./hooks/useScroll/useScroll.cjs"),os=require("./hooks/useScrollIntoView/useScrollIntoView.cjs"),is=require("./hooks/useScrollTo/useScrollTo.cjs"),E=require("./hooks/useTextSelection/useTextSelection.cjs"),ns=require("./hooks/useVisibility/useVisibility.cjs"),cs=require("./hooks/useWindowEvent/useWindowEvent.cjs"),as=require("./hooks/useWindowFocus/useWindowFocus.cjs"),C=require("./hooks/useWindowScroll/useWindowScroll.cjs"),ls=require("./hooks/useWindowSize/useWindowSize.cjs"),Ss=require("./hooks/useBoolean/useBoolean.cjs"),qs=require("./hooks/useControllableState/useControllableState.cjs"),s=require("./hooks/useCookie/useCookie.cjs"),P=require("./hooks/useCookies/useCookies.cjs"),ds=require("./hooks/useCounter/useCounter.cjs"),gs=require("./hooks/useDefault/useDefault.cjs"),Ts=require("./hooks/useDisclosure/useDisclosure.cjs"),Es=require("./hooks/useField/useField.cjs"),R=require("./hooks/useHash/useHash.cjs"),Cs=require("./hooks/useList/useList.cjs"),Ps=require("./hooks/useLocalStorage/useLocalStorage.cjs"),Rs=require("./hooks/useMap/useMap.cjs"),t=require("./hooks/useMergedRef/useMergedRef.cjs"),ms=require("./hooks/useOffsetPagination/useOffsetPagination.cjs"),ys=require("./hooks/useQueue/useQueue.cjs"),ps=require("./hooks/useRafState/useRafState.cjs"),Is=require("./hooks/useRefState/useRefState.cjs"),Os=require("./hooks/useSessionStorage/useSessionStorage.cjs"),ks=require("./hooks/useSet/useSet.cjs"),m=require("./hooks/useStateHistory/useStateHistory.cjs"),vs=require("./hooks/useStep/useStep.cjs"),o=require("./hooks/useStorage/useStorage.cjs"),As=require("./hooks/useToggle/useToggle.cjs"),u=require("./hooks/useUrlSearchParam/useUrlSearchParam.cjs"),hs=require("./hooks/useUrlSearchParams/useUrlSearchParams.cjs"),bs=require("./hooks/useWizard/useWizard.cjs"),fs=require("./hooks/useInterval/useInterval.cjs"),Ds=require("./hooks/useStopwatch/useStopwatch.cjs"),Ls=require("./hooks/useTime/useTime.cjs"),Ms=require("./hooks/useTimeout/useTimeout.cjs"),y=require("./hooks/useTimer/useTimer.cjs"),_s=require("./hooks/useBrowserLanguage/useBrowserLanguage.cjs"),p=require("./hooks/useOperatingSystem/useOperatingSystem.cjs"),Ns=require("./hooks/usePreferredColorScheme/usePreferredColorScheme.cjs"),Bs=require("./hooks/usePreferredContrast/usePreferredContrast.cjs"),Fs=require("./hooks/usePreferredDark/usePreferredDark.cjs"),Ks=require("./hooks/usePreferredLanguages/usePreferredLanguages.cjs"),Vs=require("./hooks/usePreferredReducedMotion/usePreferredReducedMotion.cjs"),Us=require("./hooks/useConst/useConst.cjs"),ws=require("./hooks/useDebounceCallback/useDebounceCallback.cjs"),Hs=require("./hooks/useDebounceState/useDebounceState.cjs"),xs=require("./hooks/useDebounceValue/useDebounceValue.cjs"),Ws=require("./hooks/useEvent/useEvent.cjs"),zs=require("./hooks/useLastChanged/useLastChanged.cjs"),Qs=require("./hooks/useLatest/useLatest.cjs"),Gs=require("./hooks/usePrevious/usePrevious.cjs"),Xs=require("./hooks/useThrottleCallback/useThrottleCallback.cjs"),Zs=require("./hooks/useThrottleState/useThrottleState.cjs"),js=require("./hooks/useThrottleValue/useThrottleValue.cjs"),I=require("./utils/helpers/copy.cjs"),Js=require("./utils/helpers/debounce.cjs"),Ys=require("./utils/helpers/getDate.cjs"),$s=require("./utils/helpers/getRetry.cjs"),i=require("./utils/helpers/isTarget.cjs"),eu=require("./utils/helpers/throttle.cjs");exports.createContext=O.createContext;exports.createEventEmitter=k.createEventEmitter;exports.createReactiveContext=v.createReactiveContext;exports.createStore=A.createStore;exports.useAsync=h.useAsync;exports.useLockCallback=b.useLockCallback;exports.useMutation=f.useMutation;exports.useOptimistic=D.useOptimistic;exports.useQuery=L.useQuery;exports.useAudio=M.useAudio;exports.useBattery=_.useBattery;exports.useBluetooth=N.useBluetooth;exports.useBroadcastChannel=B.useBroadcastChannel;exports.useClipboard=F.useClipboard;exports.useCopy=K.useCopy;exports.useCssVar=V.useCssVar;exports.useDisplayMedia=U.useDisplayMedia;exports.useDocumentTitle=w.useDocumentTitle;exports.useEventSource=H.useEventSource;exports.useEyeDropper=x.useEyeDropper;exports.useFavicon=W.useFavicon;exports.useFps=z.useFps;exports.useFullscreen=Q.useFullscreen;exports.mapGamepadToXbox360Controller=n.mapGamepadToXbox360Controller;exports.useGamepad=n.useGamepad;exports.useGeolocation=G.useGeolocation;exports.timeRangeToArray=c.timeRangeToArray;exports.useMediaControls=c.useMediaControls;exports.useMemory=X.useMemory;exports.getConnection=a.getConnection;exports.useNetwork=a.useNetwork;exports.useOnline=Z.useOnline;exports.useOtpCredential=j.useOtpCredential;exports.usePermission=J.usePermission;exports.usePictureInPicture=Y.usePictureInPicture;exports.usePointerLock=$.usePointerLock;exports.usePostMessage=ee.usePostMessage;exports.useRaf=se.useRaf;exports.useShare=ue.useShare;exports.getSpeechRecognition=l.getSpeechRecognition;exports.useSpeechRecognition=l.useSpeechRecognition;exports.useSpeechSynthesis=re.useSpeechSynthesis;exports.useVibrate=te.useVibrate;exports.useVirtualKeyboard=oe.useVirtualKeyboard;exports.useWakeLock=ie.useWakeLock;exports.useWebSocket=ne.useWebSocket;exports.useLogger=ce.useLogger;exports.useRenderCount=ae.useRenderCount;exports.useRenderInfo=le.useRenderInfo;exports.useRerender=Se.useRerender;exports.useActiveElement=qe.useActiveElement;exports.useAutoScroll=de.useAutoScroll;exports.useClickOutside=ge.useClickOutside;exports.DEFAULT_THRESHOLD_TIME=S.DEFAULT_THRESHOLD_TIME;exports.useDoubleClick=S.useDoubleClick;exports.useDropZone=Te.useDropZone;exports.useFileDialog=Ee.useFileDialog;exports.useFocus=Ce.useFocus;exports.FOCUS_SELECTOR=q.FOCUS_SELECTOR;exports.useFocusTrap=q.useFocusTrap;exports.useHover=Pe.useHover;exports.useImage=Re.useImage;exports.useLongPress=me.useLongPress;exports.Paint=r.Paint;exports.Pointer=r.Pointer;exports.usePaint=r.usePaint;exports.useRightClick=ye.useRightClick;exports.SCRIPT_STATUS_ATTRIBUTE_NAME=d.SCRIPT_STATUS_ATTRIBUTE_NAME;exports.useScript=d.useScript;exports.useSticky=pe.useSticky;exports.useTextareaAutosize=Ie.useTextareaAutosize;exports.useTextDirection=Oe.useTextDirection;exports.useFul=ke.useFul;exports.useLess=ve.useLess;exports.useOnce=Ae.useOnce;exports.useAsyncEffect=he.useAsyncEffect;exports.useDidUpdate=be.useDidUpdate;exports.useIsFirstRender=fe.useIsFirstRender;exports.useIsomorphicLayoutEffect=De.useIsomorphicLayoutEffect;exports.useMount=Le.useMount;exports.deepEqual=g.deepEqual;exports.useShallowEffect=g.useShallowEffect;exports.useUnmount=Me.useUnmount;exports.BREAKPOINTS_ANT_DESIGN=e.BREAKPOINTS_ANT_DESIGN;exports.BREAKPOINTS_BOOTSTRAP_V5=e.BREAKPOINTS_BOOTSTRAP_V5;exports.BREAKPOINTS_MANTINE=e.BREAKPOINTS_MANTINE;exports.BREAKPOINTS_MASTER_CSS=e.BREAKPOINTS_MASTER_CSS;exports.BREAKPOINTS_MATERIAL_UI=e.BREAKPOINTS_MATERIAL_UI;exports.BREAKPOINTS_PRIME_FLEX=e.BREAKPOINTS_PRIME_FLEX;exports.BREAKPOINTS_QUASAR_V2=e.BREAKPOINTS_QUASAR_V2;exports.BREAKPOINTS_SEMANTIC=e.BREAKPOINTS_SEMANTIC;exports.BREAKPOINTS_TAILWIND=e.BREAKPOINTS_TAILWIND;exports.useBreakpoints=e.useBreakpoints;exports.useDeviceMotion=_e.useDeviceMotion;exports.useDeviceOrientation=Ne.useDeviceOrientation;exports.useDevicePixelRatio=Be.useDevicePixelRatio;exports.useDocumentEvent=Fe.useDocumentEvent;exports.useDocumentVisibility=Ke.useDocumentVisibility;exports.useElementSize=Ve.useElementSize;exports.useEventListener=Ue.useEventListener;exports.isHotkeyMatch=T.isHotkeyMatch;exports.useHotkeys=T.useHotkeys;exports.useIdle=we.useIdle;exports.useInfiniteScroll=He.useInfiniteScroll;exports.useIntersectionObserver=xe.useIntersectionObserver;exports.useKeyboard=We.useKeyboard;exports.useKeyPress=ze.useKeyPress;exports.useKeyPressEvent=Qe.useKeyPressEvent;exports.useKeysPressed=Ge.useKeysPressed;exports.useLockScroll=Xe.useLockScroll;exports.useMeasure=Ze.useMeasure;exports.useMediaQuery=je.useMediaQuery;exports.useMouse=Je.useMouse;exports.useMutationObserver=Ye.useMutationObserver;exports.useOrientation=$e.useOrientation;exports.usePageLeave=es.usePageLeave;exports.useParallax=ss.useParallax;exports.usePerformanceObserver=us.usePerformanceObserver;exports.useResizeObserver=rs.useResizeObserver;exports.useScroll=ts.useScroll;exports.useScrollIntoView=os.useScrollIntoView;exports.useScrollTo=is.useScrollTo;exports.getRangesSelection=E.getRangesSelection;exports.useTextSelection=E.useTextSelection;exports.useVisibility=ns.useVisibility;exports.useWindowEvent=cs.useWindowEvent;exports.useWindowFocus=as.useWindowFocus;exports.scrollTo=C.scrollTo;exports.useWindowScroll=C.useWindowScroll;exports.useWindowSize=ls.useWindowSize;exports.useBoolean=Ss.useBoolean;exports.useControllableState=qs.useControllableState;exports.COOKIE_EVENT=s.COOKIE_EVENT;exports.dispatchCookieEvent=s.dispatchCookieEvent;exports.getCookie=s.getCookie;exports.getCookies=s.getCookies;exports.removeCookie=s.removeCookie;exports.removeCookieItem=s.removeCookieItem;exports.setCookie=s.setCookie;exports.setCookieItem=s.setCookieItem;exports.useCookie=s.useCookie;exports.clearCookies=P.clearCookies;exports.useCookies=P.useCookies;exports.useCounter=ds.useCounter;exports.useDefault=gs.useDefault;exports.useDisclosure=Ts.useDisclosure;exports.useField=Es.useField;exports.getHash=R.getHash;exports.useHash=R.useHash;exports.useList=Cs.useList;exports.useLocalStorage=Ps.useLocalStorage;exports.useMap=Rs.useMap;exports.assignRef=t.assignRef;exports.mergeRefs=t.mergeRefs;exports.useMergedRef=t.useMergedRef;exports.useOffsetPagination=ms.useOffsetPagination;exports.useQueue=ys.useQueue;exports.useRafState=ps.useRafState;exports.useRefState=Is.useRefState;exports.useSessionStorage=Os.useSessionStorage;exports.useSet=ks.useSet;exports.stateHistoryReducer=m.stateHistoryReducer;exports.useStateHistory=m.useStateHistory;exports.useStep=vs.useStep;exports.STORAGE_EVENT=o.STORAGE_EVENT;exports.dispatchStorageEvent=o.dispatchStorageEvent;exports.useStorage=o.useStorage;exports.useToggle=As.useToggle;exports.URL_SEARCH_PARAMS_EVENT=u.URL_SEARCH_PARAMS_EVENT;exports.createQueryString=u.createQueryString;exports.dispatchUrlSearchParamsEvent=u.dispatchUrlSearchParamsEvent;exports.getUrlSearchParams=u.getUrlSearchParams;exports.useUrlSearchParam=u.useUrlSearchParam;exports.useUrlSearchParams=hs.useUrlSearchParams;exports.useWizard=bs.useWizard;exports.useInterval=fs.useInterval;exports.useStopwatch=Ds.useStopwatch;exports.useTime=Ls.useTime;exports.useTimeout=Ms.useTimeout;exports.getTimeFromSeconds=y.getTimeFromSeconds;exports.useTimer=y.useTimer;exports.useBrowserLanguage=_s.useBrowserLanguage;exports.getOperatingSystem=p.getOperatingSystem;exports.useOperatingSystem=p.useOperatingSystem;exports.usePreferredColorScheme=Ns.usePreferredColorScheme;exports.usePreferredContrast=Bs.usePreferredContrast;exports.usePreferredDark=Fs.usePreferredDark;exports.usePreferredLanguages=Ks.usePreferredLanguages;exports.usePreferredReducedMotion=Vs.usePreferredReducedMotion;exports.useConst=Us.useConst;exports.useDebounceCallback=ws.useDebounceCallback;exports.useDebounceState=Hs.useDebounceState;exports.useDebounceValue=xs.useDebounceValue;exports.useEvent=Ws.useEvent;exports.useLastChanged=zs.useLastChanged;exports.useLatest=Qs.useLatest;exports.usePrevious=Gs.usePrevious;exports.useThrottleCallback=Xs.useThrottleCallback;exports.useThrottleState=Zs.useThrottleState;exports.useThrottleValue=js.useThrottleValue;exports.copy=I.copy;exports.legacyCopyToClipboard=I.legacyCopyToClipboard;exports.debounce=Js.debounce;exports.getDate=Ys.getDate;exports.getRetry=$s.getRetry;exports.isTarget=i.isTarget;exports.target=i.target;exports.targetSymbol=i.targetSymbol;exports.throttle=eu.throttle;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("./helpers/createContext/createContext.cjs"),v=require("./helpers/createEventEmitter/createEventEmitter.cjs"),A=require("./helpers/createReactiveContext/createReactiveContext.cjs"),h=require("./helpers/createStore/createStore.cjs"),f=require("./hooks/useAsync/useAsync.cjs"),b=require("./hooks/useLockCallback/useLockCallback.cjs"),D=require("./hooks/useMutation/useMutation.cjs"),L=require("./hooks/useOptimistic/useOptimistic.cjs"),M=require("./hooks/useQuery/useQuery.cjs"),_=require("./hooks/useAudio/useAudio.cjs"),N=require("./hooks/useBattery/useBattery.cjs"),B=require("./hooks/useBluetooth/useBluetooth.cjs"),F=require("./hooks/useBroadcastChannel/useBroadcastChannel.cjs"),K=require("./hooks/useClipboard/useClipboard.cjs"),V=require("./hooks/useCopy/useCopy.cjs"),U=require("./hooks/useCssVar/useCssVar.cjs"),w=require("./hooks/useDisplayMedia/useDisplayMedia.cjs"),H=require("./hooks/useDocumentTitle/useDocumentTitle.cjs"),x=require("./hooks/useEventSource/useEventSource.cjs"),W=require("./hooks/useEyeDropper/useEyeDropper.cjs"),z=require("./hooks/useFavicon/useFavicon.cjs"),Q=require("./hooks/useFps/useFps.cjs"),G=require("./hooks/useFullscreen/useFullscreen.cjs"),n=require("./hooks/useGamepad/useGamepad.cjs"),X=require("./hooks/useGeolocation/useGeolocation.cjs"),c=require("./hooks/useMediaControls/useMediaControls.cjs"),Z=require("./hooks/useMemory/useMemory.cjs"),a=require("./hooks/useNetwork/useNetwork.cjs"),j=require("./hooks/useOnline/useOnline.cjs"),J=require("./hooks/useOtpCredential/useOtpCredential.cjs"),Y=require("./hooks/usePermission/usePermission.cjs"),$=require("./hooks/usePictureInPicture/usePictureInPicture.cjs"),ee=require("./hooks/usePointerLock/usePointerLock.cjs"),se=require("./hooks/usePostMessage/usePostMessage.cjs"),ue=require("./hooks/useRaf/useRaf.cjs"),re=require("./hooks/useShare/useShare.cjs"),l=require("./hooks/useSpeechRecognition/useSpeechRecognition.cjs"),te=require("./hooks/useSpeechSynthesis/useSpeechSynthesis.cjs"),oe=require("./hooks/useVibrate/useVibrate.cjs"),ie=require("./hooks/useVirtualKeyboard/useVirtualKeyboard.cjs"),ne=require("./hooks/useWakeLock/useWakeLock.cjs"),ce=require("./hooks/useWebSocket/useWebSocket.cjs"),ae=require("./hooks/useLogger/useLogger.cjs"),le=require("./hooks/useRenderCount/useRenderCount.cjs"),Se=require("./hooks/useRenderInfo/useRenderInfo.cjs"),qe=require("./hooks/useRerender/useRerender.cjs"),de=require("./hooks/useActiveElement/useActiveElement.cjs"),ge=require("./hooks/useAutoScroll/useAutoScroll.cjs"),Te=require("./hooks/useClickOutside/useClickOutside.cjs"),S=require("./hooks/useDoubleClick/useDoubleClick.cjs"),Ee=require("./hooks/useDropZone/useDropZone.cjs"),Ce=require("./hooks/useFileDialog/useFileDialog.cjs"),Re=require("./hooks/useFocus/useFocus.cjs"),q=require("./hooks/useFocusTrap/useFocusTrap.cjs"),Pe=require("./hooks/useHover/useHover.cjs"),me=require("./hooks/useImage/useImage.cjs"),ye=require("./hooks/useLongPress/useLongPress.cjs"),t=require("./hooks/usePaint/usePaint.cjs"),pe=require("./hooks/useRightClick/useRightClick.cjs"),d=require("./hooks/useScript/useScript.cjs"),Ie=require("./hooks/useSticky/useSticky.cjs"),Oe=require("./hooks/useTextareaAutosize/useTextareaAutosize.cjs"),ke=require("./hooks/useTextDirection/useTextDirection.cjs"),ve=require("./hooks/useFul/useFul.cjs"),Ae=require("./hooks/useLess/useLess.cjs"),he=require("./hooks/useOnce/useOnce.cjs"),fe=require("./hooks/useAsyncEffect/useAsyncEffect.cjs"),be=require("./hooks/useDidUpdate/useDidUpdate.cjs"),De=require("./hooks/useIsFirstRender/useIsFirstRender.cjs"),Le=require("./hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.cjs"),Me=require("./hooks/useMount/useMount.cjs"),g=require("./hooks/useShallowEffect/useShallowEffect.cjs"),_e=require("./hooks/useUnmount/useUnmount.cjs"),e=require("./hooks/useBreakpoints/useBreakpoints.cjs"),Ne=require("./hooks/useDeviceMotion/useDeviceMotion.cjs"),Be=require("./hooks/useDeviceOrientation/useDeviceOrientation.cjs"),Fe=require("./hooks/useDevicePixelRatio/useDevicePixelRatio.cjs"),Ke=require("./hooks/useDocumentEvent/useDocumentEvent.cjs"),Ve=require("./hooks/useDocumentVisibility/useDocumentVisibility.cjs"),Ue=require("./hooks/useElementSize/useElementSize.cjs"),we=require("./hooks/useEventListener/useEventListener.cjs"),T=require("./hooks/useHotkeys/useHotkeys.cjs"),He=require("./hooks/useIdle/useIdle.cjs"),xe=require("./hooks/useInfiniteScroll/useInfiniteScroll.cjs"),We=require("./hooks/useIntersectionObserver/useIntersectionObserver.cjs"),ze=require("./hooks/useKeyboard/useKeyboard.cjs"),Qe=require("./hooks/useKeyPress/useKeyPress.cjs"),Ge=require("./hooks/useKeyPressEvent/useKeyPressEvent.cjs"),Xe=require("./hooks/useKeysPressed/useKeysPressed.cjs"),Ze=require("./hooks/useLockScroll/useLockScroll.cjs"),je=require("./hooks/useMeasure/useMeasure.cjs"),Je=require("./hooks/useMediaQuery/useMediaQuery.cjs"),Ye=require("./hooks/useMouse/useMouse.cjs"),$e=require("./hooks/useMutationObserver/useMutationObserver.cjs"),es=require("./hooks/useOrientation/useOrientation.cjs"),ss=require("./hooks/usePageLeave/usePageLeave.cjs"),us=require("./hooks/useParallax/useParallax.cjs"),rs=require("./hooks/usePerformanceObserver/usePerformanceObserver.cjs"),ts=require("./hooks/useResizeObserver/useResizeObserver.cjs"),os=require("./hooks/useScroll/useScroll.cjs"),is=require("./hooks/useScrollIntoView/useScrollIntoView.cjs"),ns=require("./hooks/useScrollTo/useScrollTo.cjs"),E=require("./hooks/useTextSelection/useTextSelection.cjs"),cs=require("./hooks/useVisibility/useVisibility.cjs"),as=require("./hooks/useWindowEvent/useWindowEvent.cjs"),ls=require("./hooks/useWindowFocus/useWindowFocus.cjs"),C=require("./hooks/useWindowScroll/useWindowScroll.cjs"),Ss=require("./hooks/useWindowSize/useWindowSize.cjs"),qs=require("./hooks/useBoolean/useBoolean.cjs"),ds=require("./hooks/useControllableState/useControllableState.cjs"),s=require("./hooks/useCookie/useCookie.cjs"),R=require("./hooks/useCookies/useCookies.cjs"),gs=require("./hooks/useCounter/useCounter.cjs"),Ts=require("./hooks/useDefault/useDefault.cjs"),Es=require("./hooks/useDisclosure/useDisclosure.cjs"),Cs=require("./hooks/useField/useField.cjs"),P=require("./hooks/useHash/useHash.cjs"),Rs=require("./hooks/useList/useList.cjs"),Ps=require("./hooks/useLocalStorage/useLocalStorage.cjs"),ms=require("./hooks/useMap/useMap.cjs"),o=require("./hooks/useMergedRef/useMergedRef.cjs"),ys=require("./hooks/useOffsetPagination/useOffsetPagination.cjs"),ps=require("./hooks/useQueue/useQueue.cjs"),Is=require("./hooks/useRafState/useRafState.cjs"),m=require("./hooks/useRefState/useRefState.cjs"),Os=require("./hooks/useSessionStorage/useSessionStorage.cjs"),ks=require("./hooks/useSet/useSet.cjs"),y=require("./hooks/useStateHistory/useStateHistory.cjs"),vs=require("./hooks/useStep/useStep.cjs"),i=require("./hooks/useStorage/useStorage.cjs"),As=require("./hooks/useToggle/useToggle.cjs"),u=require("./hooks/useUrlSearchParam/useUrlSearchParam.cjs"),hs=require("./hooks/useUrlSearchParams/useUrlSearchParams.cjs"),fs=require("./hooks/useWizard/useWizard.cjs"),bs=require("./hooks/useInterval/useInterval.cjs"),Ds=require("./hooks/useStopwatch/useStopwatch.cjs"),Ls=require("./hooks/useTime/useTime.cjs"),Ms=require("./hooks/useTimeout/useTimeout.cjs"),p=require("./hooks/useTimer/useTimer.cjs"),_s=require("./hooks/useBrowserLanguage/useBrowserLanguage.cjs"),I=require("./hooks/useOperatingSystem/useOperatingSystem.cjs"),Ns=require("./hooks/usePreferredColorScheme/usePreferredColorScheme.cjs"),Bs=require("./hooks/usePreferredContrast/usePreferredContrast.cjs"),Fs=require("./hooks/usePreferredDark/usePreferredDark.cjs"),Ks=require("./hooks/usePreferredLanguages/usePreferredLanguages.cjs"),Vs=require("./hooks/usePreferredReducedMotion/usePreferredReducedMotion.cjs"),Us=require("./hooks/useConst/useConst.cjs"),ws=require("./hooks/useDebounceCallback/useDebounceCallback.cjs"),Hs=require("./hooks/useDebounceState/useDebounceState.cjs"),xs=require("./hooks/useDebounceValue/useDebounceValue.cjs"),Ws=require("./hooks/useEvent/useEvent.cjs"),zs=require("./hooks/useLastChanged/useLastChanged.cjs"),Qs=require("./hooks/useLatest/useLatest.cjs"),Gs=require("./hooks/usePrevious/usePrevious.cjs"),Xs=require("./hooks/useThrottleCallback/useThrottleCallback.cjs"),Zs=require("./hooks/useThrottleState/useThrottleState.cjs"),js=require("./hooks/useThrottleValue/useThrottleValue.cjs"),O=require("./utils/helpers/copy.cjs"),Js=require("./utils/helpers/debounce.cjs"),Ys=require("./utils/helpers/getDate.cjs"),$s=require("./utils/helpers/getRetry.cjs"),r=require("./utils/helpers/isTarget.cjs"),eu=require("./utils/helpers/throttle.cjs");exports.createContext=k.createContext;exports.createEventEmitter=v.createEventEmitter;exports.createReactiveContext=A.createReactiveContext;exports.createStore=h.createStore;exports.useAsync=f.useAsync;exports.useLockCallback=b.useLockCallback;exports.useMutation=D.useMutation;exports.useOptimistic=L.useOptimistic;exports.useQuery=M.useQuery;exports.useAudio=_.useAudio;exports.useBattery=N.useBattery;exports.useBluetooth=B.useBluetooth;exports.useBroadcastChannel=F.useBroadcastChannel;exports.useClipboard=K.useClipboard;exports.useCopy=V.useCopy;exports.useCssVar=U.useCssVar;exports.useDisplayMedia=w.useDisplayMedia;exports.useDocumentTitle=H.useDocumentTitle;exports.useEventSource=x.useEventSource;exports.useEyeDropper=W.useEyeDropper;exports.useFavicon=z.useFavicon;exports.useFps=Q.useFps;exports.useFullscreen=G.useFullscreen;exports.mapGamepadToXbox360Controller=n.mapGamepadToXbox360Controller;exports.useGamepad=n.useGamepad;exports.useGeolocation=X.useGeolocation;exports.timeRangeToArray=c.timeRangeToArray;exports.useMediaControls=c.useMediaControls;exports.useMemory=Z.useMemory;exports.getConnection=a.getConnection;exports.useNetwork=a.useNetwork;exports.useOnline=j.useOnline;exports.useOtpCredential=J.useOtpCredential;exports.usePermission=Y.usePermission;exports.usePictureInPicture=$.usePictureInPicture;exports.usePointerLock=ee.usePointerLock;exports.usePostMessage=se.usePostMessage;exports.useRaf=ue.useRaf;exports.useShare=re.useShare;exports.getSpeechRecognition=l.getSpeechRecognition;exports.useSpeechRecognition=l.useSpeechRecognition;exports.useSpeechSynthesis=te.useSpeechSynthesis;exports.useVibrate=oe.useVibrate;exports.useVirtualKeyboard=ie.useVirtualKeyboard;exports.useWakeLock=ne.useWakeLock;exports.useWebSocket=ce.useWebSocket;exports.useLogger=ae.useLogger;exports.useRenderCount=le.useRenderCount;exports.useRenderInfo=Se.useRenderInfo;exports.useRerender=qe.useRerender;exports.useActiveElement=de.useActiveElement;exports.useAutoScroll=ge.useAutoScroll;exports.useClickOutside=Te.useClickOutside;exports.DEFAULT_THRESHOLD_TIME=S.DEFAULT_THRESHOLD_TIME;exports.useDoubleClick=S.useDoubleClick;exports.useDropZone=Ee.useDropZone;exports.useFileDialog=Ce.useFileDialog;exports.useFocus=Re.useFocus;exports.FOCUS_SELECTOR=q.FOCUS_SELECTOR;exports.useFocusTrap=q.useFocusTrap;exports.useHover=Pe.useHover;exports.useImage=me.useImage;exports.useLongPress=ye.useLongPress;exports.Paint=t.Paint;exports.Pointer=t.Pointer;exports.usePaint=t.usePaint;exports.useRightClick=pe.useRightClick;exports.SCRIPT_STATUS_ATTRIBUTE_NAME=d.SCRIPT_STATUS_ATTRIBUTE_NAME;exports.useScript=d.useScript;exports.useSticky=Ie.useSticky;exports.useTextareaAutosize=Oe.useTextareaAutosize;exports.useTextDirection=ke.useTextDirection;exports.useFul=ve.useFul;exports.useLess=Ae.useLess;exports.useOnce=he.useOnce;exports.useAsyncEffect=fe.useAsyncEffect;exports.useDidUpdate=be.useDidUpdate;exports.useIsFirstRender=De.useIsFirstRender;exports.useIsomorphicLayoutEffect=Le.useIsomorphicLayoutEffect;exports.useMount=Me.useMount;exports.deepEqual=g.deepEqual;exports.useShallowEffect=g.useShallowEffect;exports.useUnmount=_e.useUnmount;exports.BREAKPOINTS_ANT_DESIGN=e.BREAKPOINTS_ANT_DESIGN;exports.BREAKPOINTS_BOOTSTRAP_V5=e.BREAKPOINTS_BOOTSTRAP_V5;exports.BREAKPOINTS_MANTINE=e.BREAKPOINTS_MANTINE;exports.BREAKPOINTS_MASTER_CSS=e.BREAKPOINTS_MASTER_CSS;exports.BREAKPOINTS_MATERIAL_UI=e.BREAKPOINTS_MATERIAL_UI;exports.BREAKPOINTS_PRIME_FLEX=e.BREAKPOINTS_PRIME_FLEX;exports.BREAKPOINTS_QUASAR_V2=e.BREAKPOINTS_QUASAR_V2;exports.BREAKPOINTS_SEMANTIC=e.BREAKPOINTS_SEMANTIC;exports.BREAKPOINTS_TAILWIND=e.BREAKPOINTS_TAILWIND;exports.useBreakpoints=e.useBreakpoints;exports.useDeviceMotion=Ne.useDeviceMotion;exports.useDeviceOrientation=Be.useDeviceOrientation;exports.useDevicePixelRatio=Fe.useDevicePixelRatio;exports.useDocumentEvent=Ke.useDocumentEvent;exports.useDocumentVisibility=Ve.useDocumentVisibility;exports.useElementSize=Ue.useElementSize;exports.useEventListener=we.useEventListener;exports.isHotkeyMatch=T.isHotkeyMatch;exports.useHotkeys=T.useHotkeys;exports.useIdle=He.useIdle;exports.useInfiniteScroll=xe.useInfiniteScroll;exports.useIntersectionObserver=We.useIntersectionObserver;exports.useKeyboard=ze.useKeyboard;exports.useKeyPress=Qe.useKeyPress;exports.useKeyPressEvent=Ge.useKeyPressEvent;exports.useKeysPressed=Xe.useKeysPressed;exports.useLockScroll=Ze.useLockScroll;exports.useMeasure=je.useMeasure;exports.useMediaQuery=Je.useMediaQuery;exports.useMouse=Ye.useMouse;exports.useMutationObserver=$e.useMutationObserver;exports.useOrientation=es.useOrientation;exports.usePageLeave=ss.usePageLeave;exports.useParallax=us.useParallax;exports.usePerformanceObserver=rs.usePerformanceObserver;exports.useResizeObserver=ts.useResizeObserver;exports.useScroll=os.useScroll;exports.useScrollIntoView=is.useScrollIntoView;exports.useScrollTo=ns.useScrollTo;exports.getRangesSelection=E.getRangesSelection;exports.useTextSelection=E.useTextSelection;exports.useVisibility=cs.useVisibility;exports.useWindowEvent=as.useWindowEvent;exports.useWindowFocus=ls.useWindowFocus;exports.scrollTo=C.scrollTo;exports.useWindowScroll=C.useWindowScroll;exports.useWindowSize=Ss.useWindowSize;exports.useBoolean=qs.useBoolean;exports.useControllableState=ds.useControllableState;exports.COOKIE_EVENT=s.COOKIE_EVENT;exports.dispatchCookieEvent=s.dispatchCookieEvent;exports.getCookie=s.getCookie;exports.getCookies=s.getCookies;exports.removeCookie=s.removeCookie;exports.removeCookieItem=s.removeCookieItem;exports.setCookie=s.setCookie;exports.setCookieItem=s.setCookieItem;exports.useCookie=s.useCookie;exports.clearCookies=R.clearCookies;exports.useCookies=R.useCookies;exports.useCounter=gs.useCounter;exports.useDefault=Ts.useDefault;exports.useDisclosure=Es.useDisclosure;exports.useField=Cs.useField;exports.getHash=P.getHash;exports.useHash=P.useHash;exports.useList=Rs.useList;exports.useLocalStorage=Ps.useLocalStorage;exports.useMap=ms.useMap;exports.assignRef=o.assignRef;exports.mergeRefs=o.mergeRefs;exports.useMergedRef=o.useMergedRef;exports.useOffsetPagination=ys.useOffsetPagination;exports.useQueue=ps.useQueue;exports.useRafState=Is.useRafState;exports.createRefState=m.createRefState;exports.useRefState=m.useRefState;exports.useSessionStorage=Os.useSessionStorage;exports.useSet=ks.useSet;exports.stateHistoryReducer=y.stateHistoryReducer;exports.useStateHistory=y.useStateHistory;exports.useStep=vs.useStep;exports.STORAGE_EVENT=i.STORAGE_EVENT;exports.dispatchStorageEvent=i.dispatchStorageEvent;exports.useStorage=i.useStorage;exports.useToggle=As.useToggle;exports.URL_SEARCH_PARAMS_EVENT=u.URL_SEARCH_PARAMS_EVENT;exports.createQueryString=u.createQueryString;exports.dispatchUrlSearchParamsEvent=u.dispatchUrlSearchParamsEvent;exports.getUrlSearchParams=u.getUrlSearchParams;exports.useUrlSearchParam=u.useUrlSearchParam;exports.useUrlSearchParams=hs.useUrlSearchParams;exports.useWizard=fs.useWizard;exports.useInterval=bs.useInterval;exports.useStopwatch=Ds.useStopwatch;exports.useTime=Ls.useTime;exports.useTimeout=Ms.useTimeout;exports.getTimeFromSeconds=p.getTimeFromSeconds;exports.useTimer=p.useTimer;exports.useBrowserLanguage=_s.useBrowserLanguage;exports.getOperatingSystem=I.getOperatingSystem;exports.useOperatingSystem=I.useOperatingSystem;exports.usePreferredColorScheme=Ns.usePreferredColorScheme;exports.usePreferredContrast=Bs.usePreferredContrast;exports.usePreferredDark=Fs.usePreferredDark;exports.usePreferredLanguages=Ks.usePreferredLanguages;exports.usePreferredReducedMotion=Vs.usePreferredReducedMotion;exports.useConst=Us.useConst;exports.useDebounceCallback=ws.useDebounceCallback;exports.useDebounceState=Hs.useDebounceState;exports.useDebounceValue=xs.useDebounceValue;exports.useEvent=Ws.useEvent;exports.useLastChanged=zs.useLastChanged;exports.useLatest=Qs.useLatest;exports.usePrevious=Gs.usePrevious;exports.useThrottleCallback=Xs.useThrottleCallback;exports.useThrottleState=Zs.useThrottleState;exports.useThrottleValue=js.useThrottleValue;exports.copy=O.copy;exports.legacyCopyToClipboard=O.legacyCopyToClipboard;exports.debounce=Js.debounce;exports.getDate=Ys.getDate;exports.getRetry=$s.getRetry;exports.getRefState=r.getRefState;exports.isTarget=r.isTarget;exports.target=r.target;exports.targetSymbol=r.targetSymbol;exports.throttle=eu.throttle;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=Symbol("target"),i=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),t=e=>({value:e,type:u}),n=e=>typeof e=="object"&&("current"in e||e&&e.type===u)||typeof e=="function"&&"state"in e&&"current"in e,o=e=>e&&"state"in e&&e.state;n.wrap=t;n.getElement=i;n.getRefState=o;exports.getRefState=o;exports.isTarget=n;exports.target=t;exports.targetSymbol=u;
|
|
2
2
|
//# sourceMappingURL=isTarget.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isTarget.cjs","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
|
|
1
|
+
{"version":3,"file":"isTarget.cjs","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":"gFAEO,MAAMA,SAAsB,QAAQ,EAiBrCC,EAAcC,GACd,YAAaA,EACRA,EAAO,QAGZ,OAAOA,EAAO,OAAU,WACnBA,EAAO,MAAA,EAGZ,OAAOA,EAAO,OAAU,SACnB,SAAS,cAAcA,EAAO,KAAK,GAGxCA,EAAO,iBAAiB,UAIxBA,EAAO,iBAAiB,QAIxBA,EAAO,iBAAiB,QACnBA,EAAO,OAMLA,EAAUA,IAAoB,CACzC,MAAOA,EACP,KAAMF,CACR,GAEaG,EAAYD,GACtB,OAAOA,GAAW,WAChB,YAAaA,GAAWA,GAAWA,EAAe,OAASF,IAC7D,OAAOE,GAAW,YAAc,UAAWA,GAAU,YAAaA,EAExDE,EAAeF,GAAwBA,GAAU,UAAWA,GAAUA,EAAO,MAE1FC,EAAS,KAAOD,EAChBC,EAAS,WAAaF,EACtBE,EAAS,YAAcC"}
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import { useState as l, useEffect as v } from "react";
|
|
2
2
|
import { useRefState as d } from "../useRefState/useRefState.mjs";
|
|
3
|
-
import { isTarget as
|
|
4
|
-
const L = (...
|
|
5
|
-
const
|
|
3
|
+
import { isTarget as s } from "../../utils/helpers/isTarget.mjs";
|
|
4
|
+
const L = ((...u) => {
|
|
5
|
+
const e = s(u[0]) ? u[0] : void 0, [i, c] = l(null), o = d();
|
|
6
6
|
return v(() => {
|
|
7
|
-
const
|
|
8
|
-
f.filter((
|
|
9
|
-
|
|
7
|
+
const t = (e ? s.getElement(e) : o.current) ?? window, m = new MutationObserver((f) => {
|
|
8
|
+
f.filter((r) => r.removedNodes.length).map((r) => Array.from(r.removedNodes)).flat().forEach((r) => {
|
|
9
|
+
c((a) => r === a ? document.activeElement : a);
|
|
10
10
|
});
|
|
11
11
|
});
|
|
12
|
-
|
|
12
|
+
m.observe(t, {
|
|
13
13
|
childList: !0,
|
|
14
14
|
subtree: !0
|
|
15
15
|
});
|
|
16
|
-
const n = () =>
|
|
17
|
-
return
|
|
18
|
-
|
|
16
|
+
const n = () => c(document?.activeElement);
|
|
17
|
+
return t.addEventListener("focus", n, !0), t.addEventListener("blur", n, !0), () => {
|
|
18
|
+
m.disconnect(), t.removeEventListener("focus", n, !0), t.removeEventListener("blur", n, !0);
|
|
19
19
|
};
|
|
20
|
-
}, [
|
|
20
|
+
}, [e, o.state, s.getRefState(e)]), e ? i : {
|
|
21
21
|
ref: o,
|
|
22
|
-
value:
|
|
22
|
+
value: i
|
|
23
23
|
};
|
|
24
|
-
};
|
|
24
|
+
});
|
|
25
25
|
export {
|
|
26
26
|
L as useActiveElement
|
|
27
27
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useActiveElement.mjs","sources":["../../../../src/hooks/useActiveElement/useActiveElement.ts"],"sourcesContent":["import { useEffect, 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 active element return type */\nexport type UseActiveElementReturn<ActiveElement extends HTMLElement = HTMLElement> =\n ActiveElement | null;\n\nexport interface UseActiveElement {\n (): UseActiveElementReturn;\n\n <Target extends Element, ActiveElement extends HTMLElement = HTMLElement>(\n target?: never\n ): {\n ref: StateRef<Target>;\n value: UseActiveElementReturn<ActiveElement>;\n };\n\n <ActiveElement extends HTMLElement = HTMLElement>(\n target: HookTarget\n ): UseActiveElementReturn<ActiveElement>;\n}\n\n/**\n * @name useActiveElement\n * @description - Hook that returns the active element\n * @category Elements\n * @usage low\n *\n * @overload\n * @param {HookTarget} [target=window] The target element to observe active element changes\n * @returns {ActiveElement | null} The active element\n *\n * @example\n * const activeElement = useActiveElement(ref);\n *\n * @overload\n * @template ActiveElement The active element type\n * @returns {{ ref: StateRef<Element>; activeElement: ActiveElement | null }} An object containing the ref and active element\n *\n * @example\n * const { ref, value } = useActiveElement();\n *\n * @see {@link https://siberiacancode.github.io/reactuse/functions/hooks/useActiveElement.html}\n */\nexport const useActiveElement = ((...params: any[]) => {\n const target = (isTarget(params[0]) ? params[0] : undefined) as HookTarget | undefined;\n\n const [value, setValue] = useState<HTMLElement | null>(null);\n const internalRef = useRefState();\n\n useEffect(() => {\n const element = ((target ? isTarget.getElement(target) : internalRef.current) ??\n window) as Element;\n\n const observer = new MutationObserver((mutations) => {\n mutations\n .filter((mutation) => mutation.removedNodes.length)\n .map((mutation) => Array.from(mutation.removedNodes))\n .flat()\n .forEach((node) => {\n setValue((prevActiveElement) => {\n if (node === prevActiveElement) return document.activeElement as HTMLElement | null;\n return prevActiveElement;\n });\n });\n });\n\n observer.observe(element, {\n childList: true,\n subtree: true\n });\n\n const onActiveElementChange = () => setValue(document?.activeElement as HTMLElement | null);\n\n element.addEventListener('focus', onActiveElementChange, true);\n element.addEventListener('blur', onActiveElementChange, true);\n\n return () => {\n observer.disconnect();\n element.removeEventListener('focus', onActiveElementChange, true);\n element.removeEventListener('blur', onActiveElementChange, true);\n };\n }, [target, internalRef.state]);\n\n if (target) return value;\n return {\n ref: internalRef,\n value\n };\n}) as UseActiveElement;\n"],"names":["useActiveElement","params","target","isTarget","value","setValue","useState","internalRef","useRefState","useEffect","element","observer","mutations","mutation","node","prevActiveElement","onActiveElementChange"],"mappings":";;;AAmDO,MAAMA,
|
|
1
|
+
{"version":3,"file":"useActiveElement.mjs","sources":["../../../../src/hooks/useActiveElement/useActiveElement.ts"],"sourcesContent":["import { useEffect, 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 active element return type */\nexport type UseActiveElementReturn<ActiveElement extends HTMLElement = HTMLElement> =\n ActiveElement | null;\n\nexport interface UseActiveElement {\n (): UseActiveElementReturn;\n\n <Target extends Element, ActiveElement extends HTMLElement = HTMLElement>(\n target?: never\n ): {\n ref: StateRef<Target>;\n value: UseActiveElementReturn<ActiveElement>;\n };\n\n <ActiveElement extends HTMLElement = HTMLElement>(\n target: HookTarget\n ): UseActiveElementReturn<ActiveElement>;\n}\n\n/**\n * @name useActiveElement\n * @description - Hook that returns the active element\n * @category Elements\n * @usage low\n *\n * @overload\n * @param {HookTarget} [target=window] The target element to observe active element changes\n * @returns {ActiveElement | null} The active element\n *\n * @example\n * const activeElement = useActiveElement(ref);\n *\n * @overload\n * @template ActiveElement The active element type\n * @returns {{ ref: StateRef<Element>; activeElement: ActiveElement | null }} An object containing the ref and active element\n *\n * @example\n * const { ref, value } = useActiveElement();\n *\n * @see {@link https://siberiacancode.github.io/reactuse/functions/hooks/useActiveElement.html}\n */\nexport const useActiveElement = ((...params: any[]) => {\n const target = (isTarget(params[0]) ? params[0] : undefined) as HookTarget | undefined;\n\n const [value, setValue] = useState<HTMLElement | null>(null);\n const internalRef = useRefState();\n\n useEffect(() => {\n const element = ((target ? isTarget.getElement(target) : internalRef.current) ??\n window) as Element;\n\n const observer = new MutationObserver((mutations) => {\n mutations\n .filter((mutation) => mutation.removedNodes.length)\n .map((mutation) => Array.from(mutation.removedNodes))\n .flat()\n .forEach((node) => {\n setValue((prevActiveElement) => {\n if (node === prevActiveElement) return document.activeElement as HTMLElement | null;\n return prevActiveElement;\n });\n });\n });\n\n observer.observe(element, {\n childList: true,\n subtree: true\n });\n\n const onActiveElementChange = () => setValue(document?.activeElement as HTMLElement | null);\n\n element.addEventListener('focus', onActiveElementChange, true);\n element.addEventListener('blur', onActiveElementChange, true);\n\n return () => {\n observer.disconnect();\n element.removeEventListener('focus', onActiveElementChange, true);\n element.removeEventListener('blur', onActiveElementChange, true);\n };\n }, [target, internalRef.state, isTarget.getRefState(target)]);\n\n if (target) return value;\n return {\n ref: internalRef,\n value\n };\n}) as UseActiveElement;\n"],"names":["useActiveElement","params","target","isTarget","value","setValue","useState","internalRef","useRefState","useEffect","element","observer","mutations","mutation","node","prevActiveElement","onActiveElementChange"],"mappings":";;;AAmDO,MAAMA,KAAoB,IAAIC,MAAkB;AACrD,QAAMC,IAAUC,EAASF,EAAO,CAAC,CAAC,IAAIA,EAAO,CAAC,IAAI,QAE5C,CAACG,GAAOC,CAAQ,IAAIC,EAA6B,IAAI,GACrDC,IAAcC,EAAA;AAoCpB,SAlCAC,EAAU,MAAM;AACd,UAAMC,KAAYR,IAASC,EAAS,WAAWD,CAAM,IAAIK,EAAY,YACnE,QAEII,IAAW,IAAI,iBAAiB,CAACC,MAAc;AACnD,MAAAA,EACG,OAAO,CAACC,MAAaA,EAAS,aAAa,MAAM,EACjD,IAAI,CAACA,MAAa,MAAM,KAAKA,EAAS,YAAY,CAAC,EACnD,OACA,QAAQ,CAACC,MAAS;AACjB,QAAAT,EAAS,CAACU,MACJD,MAASC,IAA0B,SAAS,gBACzCA,CACR;AAAA,MAAA,CACF;AAAA,IAAA,CACJ;AAED,IAAAJ,EAAS,QAAQD,GAAS;AAAA,MACxB,WAAW;AAAA,MACX,SAAS;AAAA,IAAA,CACV;AAED,UAAMM,IAAwB,MAAMX,EAAS,UAAU,aAAmC;AAE1F,WAAAK,EAAQ,iBAAiB,SAASM,GAAuB,EAAI,GAC7DN,EAAQ,iBAAiB,QAAQM,GAAuB,EAAI,GAErD,MAAM;AACX,MAAAL,EAAS,WAAA,GACTD,EAAQ,oBAAoB,SAASM,GAAuB,EAAI,GAChEN,EAAQ,oBAAoB,QAAQM,GAAuB,EAAI;AAAA,IAAA;AAAA,EACjE,GACC,CAACd,GAAQK,EAAY,OAAOJ,EAAS,YAAYD,CAAM,CAAC,CAAC,GAExDA,IAAeE,IACZ;AAAA,IACL,KAAKG;AAAA,IACL,OAAAH;AAAA,EAAA;AAEJ;"}
|
|
@@ -1,40 +1,40 @@
|
|
|
1
1
|
import { useRef as b, useEffect as p } from "react";
|
|
2
|
-
import { useRefState as
|
|
3
|
-
import { isTarget as
|
|
4
|
-
const x = (...
|
|
5
|
-
const
|
|
6
|
-
if (
|
|
7
|
-
if (!h || !
|
|
8
|
-
const e =
|
|
2
|
+
import { useRefState as R } from "../useRefState/useRefState.mjs";
|
|
3
|
+
import { isTarget as a } from "../../utils/helpers/isTarget.mjs";
|
|
4
|
+
const x = ((...n) => {
|
|
5
|
+
const o = a(n[0]) ? n[0] : void 0, i = n[1] || (typeof n[0] == "object" ? n[0] : {}), { enabled: h = !0 } = i, s = R(), r = b(i);
|
|
6
|
+
if (r.current = i, p(() => {
|
|
7
|
+
if (!h || !o && !s.state) return;
|
|
8
|
+
const e = o ? a.getElement(o) : s.state;
|
|
9
9
|
if (!e) return;
|
|
10
|
-
let c = !0, f = 0,
|
|
11
|
-
const
|
|
12
|
-
if (
|
|
13
|
-
const { scrollHeight: t, clientHeight: l, scrollTop: u } = e,
|
|
14
|
-
u <
|
|
15
|
-
}, v = (t) => {
|
|
16
|
-
o.current.force || (t.deltaY < 0 ? c = !1 : d());
|
|
10
|
+
let c = !0, f = 0, d = 0;
|
|
11
|
+
const v = () => {
|
|
12
|
+
if (r.current.force) return;
|
|
13
|
+
const { scrollHeight: t, clientHeight: l, scrollTop: u } = e, L = t - l, Y = L / 2;
|
|
14
|
+
u < d ? c = !1 : L - u <= Y && (c = !0), d = u;
|
|
17
15
|
}, m = (t) => {
|
|
18
|
-
|
|
16
|
+
r.current.force || (t.deltaY < 0 ? c = !1 : v());
|
|
19
17
|
}, E = (t) => {
|
|
20
|
-
|
|
18
|
+
r.current.force || (f = t.touches[0].clientY);
|
|
19
|
+
}, S = (t) => {
|
|
20
|
+
if (r.current.force) return;
|
|
21
21
|
const l = t.touches[0].clientY;
|
|
22
|
-
f - l < 0 ? c = !1 :
|
|
22
|
+
f - l < 0 ? c = !1 : v(), f = l;
|
|
23
23
|
}, T = () => {
|
|
24
|
-
!c && !
|
|
24
|
+
!c && !r.current.force || e.scrollTo({ top: e.scrollHeight });
|
|
25
25
|
};
|
|
26
|
-
e.addEventListener("wheel",
|
|
27
|
-
const
|
|
28
|
-
return
|
|
26
|
+
e.addEventListener("wheel", m), e.addEventListener("touchstart", E), e.addEventListener("touchmove", S);
|
|
27
|
+
const g = new MutationObserver(T);
|
|
28
|
+
return g.observe(e, {
|
|
29
29
|
childList: !0,
|
|
30
30
|
subtree: !0,
|
|
31
31
|
characterData: !0
|
|
32
32
|
}), () => {
|
|
33
|
-
|
|
33
|
+
g.disconnect(), e.removeEventListener("wheel", m), e.removeEventListener("touchstart", E), e.removeEventListener("touchmove", S);
|
|
34
34
|
};
|
|
35
|
-
}, [h,
|
|
35
|
+
}, [h, o, s.state, a.getRefState(o)]), !o)
|
|
36
36
|
return s;
|
|
37
|
-
};
|
|
37
|
+
});
|
|
38
38
|
export {
|
|
39
39
|
x as useAutoScroll
|
|
40
40
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAutoScroll.mjs","sources":["../../../../src/hooks/useAutoScroll/useAutoScroll.ts"],"sourcesContent":["import { useEffect, useRef } 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 auto scroll options type */\nexport interface UseAutoScrollOptions {\n /** Whether auto-scrolling is enabled */\n enabled?: boolean;\n /** Whether to force auto-scrolling regardless of user interactions */\n force?: boolean;\n}\n\nexport interface UseAutoScroll {\n (target: HookTarget, options?: UseAutoScrollOptions): void;\n\n <Target extends HTMLElement>(options?: UseAutoScrollOptions): StateRef<Target>;\n}\n\n/**\n * @name useAutoScroll\n * @description - Hook that automatically scrolls a list element to the bottom\n * @category Elements\n * @usage low\n *\n * @overload\n * @param {HookTarget} target The target element to auto-scroll\n * @param {boolean} [options.enabled] Whether auto-scrolling is enabled\n * @returns {void}\n *\n * @example\n * useAutoScroll(ref);\n *\n * @overload\n * @template Target\n * @param {boolean} [options.enabled] Whether auto-scrolling is enabled\n * @returns {StateRef<Target>} A React ref to attach to the list element\n *\n * @example\n * const ref = useAutoScroll();\n */\nexport const useAutoScroll = ((...params: any[]) => {\n const target = isTarget(params[0]) ? params[0] : undefined;\n const options = (params[1] ||\n (typeof params[0] === 'object' ? params[0] : {})) as UseAutoScrollOptions;\n const { enabled = true } = options;\n\n const internalRef = useRefState<HTMLElement>();\n const internalOptionsRef = useRef<UseAutoScrollOptions>(options);\n internalOptionsRef.current = options;\n\n useEffect(() => {\n if (!enabled || (!target && !internalRef.state)) return;\n\n const element = (target ? isTarget.getElement(target) : internalRef.state) as HTMLElement;\n\n if (!element) return;\n\n let shouldAutoScroll = true;\n let touchStartY = 0;\n let lastScrollTop = 0;\n\n const onCheckScrollPosition = () => {\n if (internalOptionsRef.current.force) return;\n\n const { scrollHeight, clientHeight, scrollTop } = element;\n const maxScrollHeight = scrollHeight - clientHeight;\n const scrollThreshold = maxScrollHeight / 2;\n\n if (scrollTop < lastScrollTop) shouldAutoScroll = false;\n else if (maxScrollHeight - scrollTop <= scrollThreshold) shouldAutoScroll = true;\n\n lastScrollTop = scrollTop;\n };\n\n const onWheel = (event: WheelEvent) => {\n if (internalOptionsRef.current.force) return;\n\n if (event.deltaY < 0) shouldAutoScroll = false;\n else onCheckScrollPosition();\n };\n\n const onTouchStart = (event: TouchEvent) => {\n if (internalOptionsRef.current.force) return;\n touchStartY = event.touches[0].clientY;\n };\n\n const onTouchMove = (event: TouchEvent) => {\n if (internalOptionsRef.current.force) return;\n\n const touchEndY = event.touches[0].clientY;\n const deltaY = touchStartY - touchEndY;\n\n if (deltaY < 0) shouldAutoScroll = false;\n else onCheckScrollPosition();\n\n touchStartY = touchEndY;\n };\n\n const onMutation = () => {\n if (!shouldAutoScroll && !internalOptionsRef.current.force) return;\n element.scrollTo({ top: element.scrollHeight });\n };\n\n element.addEventListener('wheel', onWheel);\n element.addEventListener('touchstart', onTouchStart);\n element.addEventListener('touchmove', onTouchMove);\n\n const observer = new MutationObserver(onMutation);\n\n observer.observe(element, {\n childList: true,\n subtree: true,\n characterData: true\n });\n\n return () => {\n observer.disconnect();\n element.removeEventListener('wheel', onWheel);\n element.removeEventListener('touchstart', onTouchStart);\n element.removeEventListener('touchmove', onTouchMove);\n };\n }, [enabled, target, internalRef.state]);\n\n if (target) return;\n return internalRef;\n}) as UseAutoScroll;\n"],"names":["useAutoScroll","params","target","isTarget","options","enabled","internalRef","useRefState","internalOptionsRef","useRef","useEffect","element","shouldAutoScroll","touchStartY","lastScrollTop","onCheckScrollPosition","scrollHeight","clientHeight","scrollTop","maxScrollHeight","scrollThreshold","onWheel","event","onTouchStart","onTouchMove","touchEndY","onMutation","observer"],"mappings":";;;AA8CO,MAAMA,
|
|
1
|
+
{"version":3,"file":"useAutoScroll.mjs","sources":["../../../../src/hooks/useAutoScroll/useAutoScroll.ts"],"sourcesContent":["import { useEffect, useRef } 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 auto scroll options type */\nexport interface UseAutoScrollOptions {\n /** Whether auto-scrolling is enabled */\n enabled?: boolean;\n /** Whether to force auto-scrolling regardless of user interactions */\n force?: boolean;\n}\n\nexport interface UseAutoScroll {\n (target: HookTarget, options?: UseAutoScrollOptions): void;\n\n <Target extends HTMLElement>(options?: UseAutoScrollOptions): StateRef<Target>;\n}\n\n/**\n * @name useAutoScroll\n * @description - Hook that automatically scrolls a list element to the bottom\n * @category Elements\n * @usage low\n *\n * @overload\n * @param {HookTarget} target The target element to auto-scroll\n * @param {boolean} [options.enabled] Whether auto-scrolling is enabled\n * @returns {void}\n *\n * @example\n * useAutoScroll(ref);\n *\n * @overload\n * @template Target\n * @param {boolean} [options.enabled] Whether auto-scrolling is enabled\n * @returns {StateRef<Target>} A React ref to attach to the list element\n *\n * @example\n * const ref = useAutoScroll();\n */\nexport const useAutoScroll = ((...params: any[]) => {\n const target = isTarget(params[0]) ? params[0] : undefined;\n const options = (params[1] ||\n (typeof params[0] === 'object' ? params[0] : {})) as UseAutoScrollOptions;\n const { enabled = true } = options;\n\n const internalRef = useRefState<HTMLElement>();\n const internalOptionsRef = useRef<UseAutoScrollOptions>(options);\n internalOptionsRef.current = options;\n\n useEffect(() => {\n if (!enabled || (!target && !internalRef.state)) return;\n\n const element = (target ? isTarget.getElement(target) : internalRef.state) as HTMLElement;\n\n if (!element) return;\n\n let shouldAutoScroll = true;\n let touchStartY = 0;\n let lastScrollTop = 0;\n\n const onCheckScrollPosition = () => {\n if (internalOptionsRef.current.force) return;\n\n const { scrollHeight, clientHeight, scrollTop } = element;\n const maxScrollHeight = scrollHeight - clientHeight;\n const scrollThreshold = maxScrollHeight / 2;\n\n if (scrollTop < lastScrollTop) shouldAutoScroll = false;\n else if (maxScrollHeight - scrollTop <= scrollThreshold) shouldAutoScroll = true;\n\n lastScrollTop = scrollTop;\n };\n\n const onWheel = (event: WheelEvent) => {\n if (internalOptionsRef.current.force) return;\n\n if (event.deltaY < 0) shouldAutoScroll = false;\n else onCheckScrollPosition();\n };\n\n const onTouchStart = (event: TouchEvent) => {\n if (internalOptionsRef.current.force) return;\n touchStartY = event.touches[0].clientY;\n };\n\n const onTouchMove = (event: TouchEvent) => {\n if (internalOptionsRef.current.force) return;\n\n const touchEndY = event.touches[0].clientY;\n const deltaY = touchStartY - touchEndY;\n\n if (deltaY < 0) shouldAutoScroll = false;\n else onCheckScrollPosition();\n\n touchStartY = touchEndY;\n };\n\n const onMutation = () => {\n if (!shouldAutoScroll && !internalOptionsRef.current.force) return;\n element.scrollTo({ top: element.scrollHeight });\n };\n\n element.addEventListener('wheel', onWheel);\n element.addEventListener('touchstart', onTouchStart);\n element.addEventListener('touchmove', onTouchMove);\n\n const observer = new MutationObserver(onMutation);\n\n observer.observe(element, {\n childList: true,\n subtree: true,\n characterData: true\n });\n\n return () => {\n observer.disconnect();\n element.removeEventListener('wheel', onWheel);\n element.removeEventListener('touchstart', onTouchStart);\n element.removeEventListener('touchmove', onTouchMove);\n };\n }, [enabled, target, internalRef.state, isTarget.getRefState(target)]);\n\n if (target) return;\n return internalRef;\n}) as UseAutoScroll;\n"],"names":["useAutoScroll","params","target","isTarget","options","enabled","internalRef","useRefState","internalOptionsRef","useRef","useEffect","element","shouldAutoScroll","touchStartY","lastScrollTop","onCheckScrollPosition","scrollHeight","clientHeight","scrollTop","maxScrollHeight","scrollThreshold","onWheel","event","onTouchStart","onTouchMove","touchEndY","onMutation","observer"],"mappings":";;;AA8CO,MAAMA,KAAiB,IAAIC,MAAkB;AAClD,QAAMC,IAASC,EAASF,EAAO,CAAC,CAAC,IAAIA,EAAO,CAAC,IAAI,QAC3CG,IAAWH,EAAO,CAAC,MACtB,OAAOA,EAAO,CAAC,KAAM,WAAWA,EAAO,CAAC,IAAI,CAAA,IACzC,EAAE,SAAAI,IAAU,GAAA,IAASD,GAErBE,IAAcC,EAAA,GACdC,IAAqBC,EAA6BL,CAAO;AA4E/D,MA3EAI,EAAmB,UAAUJ,GAE7BM,EAAU,MAAM;AACd,QAAI,CAACL,KAAY,CAACH,KAAU,CAACI,EAAY,MAAQ;AAEjD,UAAMK,IAAWT,IAASC,EAAS,WAAWD,CAAM,IAAII,EAAY;AAEpE,QAAI,CAACK,EAAS;AAEd,QAAIC,IAAmB,IACnBC,IAAc,GACdC,IAAgB;AAEpB,UAAMC,IAAwB,MAAM;AAClC,UAAIP,EAAmB,QAAQ,MAAO;AAEtC,YAAM,EAAE,cAAAQ,GAAc,cAAAC,GAAc,WAAAC,EAAA,IAAcP,GAC5CQ,IAAkBH,IAAeC,GACjCG,IAAkBD,IAAkB;AAE1C,MAAID,IAAYJ,IAAeF,IAAmB,KACzCO,IAAkBD,KAAaE,MAAiBR,IAAmB,KAE5EE,IAAgBI;AAAA,IAAA,GAGZG,IAAU,CAACC,MAAsB;AACrC,MAAId,EAAmB,QAAQ,UAE3Bc,EAAM,SAAS,IAAGV,IAAmB,KACpCG,EAAA;AAAA,IAAsB,GAGvBQ,IAAe,CAACD,MAAsB;AAC1C,MAAId,EAAmB,QAAQ,UAC/BK,IAAcS,EAAM,QAAQ,CAAC,EAAE;AAAA,IAAA,GAG3BE,IAAc,CAACF,MAAsB;AACzC,UAAId,EAAmB,QAAQ,MAAO;AAEtC,YAAMiB,IAAYH,EAAM,QAAQ,CAAC,EAAE;AAGnC,MAFeT,IAAcY,IAEhB,IAAGb,IAAmB,KAC9BG,EAAA,GAELF,IAAcY;AAAA,IAAA,GAGVC,IAAa,MAAM;AACvB,MAAI,CAACd,KAAoB,CAACJ,EAAmB,QAAQ,SACrDG,EAAQ,SAAS,EAAE,KAAKA,EAAQ,cAAc;AAAA,IAAA;AAGhD,IAAAA,EAAQ,iBAAiB,SAASU,CAAO,GACzCV,EAAQ,iBAAiB,cAAcY,CAAY,GACnDZ,EAAQ,iBAAiB,aAAaa,CAAW;AAEjD,UAAMG,IAAW,IAAI,iBAAiBD,CAAU;AAEhD,WAAAC,EAAS,QAAQhB,GAAS;AAAA,MACxB,WAAW;AAAA,MACX,SAAS;AAAA,MACT,eAAe;AAAA,IAAA,CAChB,GAEM,MAAM;AACX,MAAAgB,EAAS,WAAA,GACThB,EAAQ,oBAAoB,SAASU,CAAO,GAC5CV,EAAQ,oBAAoB,cAAcY,CAAY,GACtDZ,EAAQ,oBAAoB,aAAaa,CAAW;AAAA,IAAA;AAAA,EACtD,GACC,CAACnB,GAASH,GAAQI,EAAY,OAAOH,EAAS,YAAYD,CAAM,CAAC,CAAC,GAEjE,CAAAA;AACJ,WAAOI;AACT;"}
|
|
@@ -1,51 +1,46 @@
|
|
|
1
|
-
import { useEffect as
|
|
2
|
-
import { useRerender as
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
const e =
|
|
1
|
+
import { useEffect as I } from "react";
|
|
2
|
+
import { useRerender as S } from "../useRerender/useRerender.mjs";
|
|
3
|
+
const o = (s) => typeof window < "u" && window.matchMedia(s).matches, R = (s, c = "mobile-first") => {
|
|
4
|
+
const x = S(), n = (e, t) => t ? `${Number(s[e]) + t}px` : `${s[e]}px`;
|
|
5
|
+
I(() => {
|
|
6
|
+
const e = x;
|
|
7
7
|
return window.addEventListener("resize", e), () => {
|
|
8
8
|
window.removeEventListener("resize", e);
|
|
9
9
|
};
|
|
10
10
|
}, []);
|
|
11
|
-
const
|
|
12
|
-
const e =
|
|
11
|
+
const m = (e) => o(`(min-width: ${n(e)})`), l = (e) => o(`(max-width: ${n(e)})`), r = () => Object.keys(s).map((e) => [e, m(e)]).filter(([, e]) => e).map(([e]) => e), i = () => {
|
|
12
|
+
const e = r();
|
|
13
13
|
return e.length ? e.at(-1) : void 0;
|
|
14
|
-
},
|
|
14
|
+
}, d = (e) => o(`(min-width: ${n(e, 0.1)})`), E = (e) => o(`(max-width: ${n(e, -0.1)})`), A = (e, t) => o(`(min-width: ${n(e)}) and (max-width: ${n(t, -0.1)})`), a = Object.keys(s).reduce(
|
|
15
15
|
(e, t) => {
|
|
16
|
-
const
|
|
17
|
-
return e[t] =
|
|
16
|
+
const u = c === "mobile-first" ? m(t) : l(t);
|
|
17
|
+
return e[t] = u, e;
|
|
18
18
|
},
|
|
19
19
|
{}
|
|
20
20
|
);
|
|
21
21
|
return {
|
|
22
|
-
current:
|
|
23
|
-
greaterOrEqual:
|
|
24
|
-
smallerOrEqual:
|
|
25
|
-
active:
|
|
26
|
-
greater:
|
|
27
|
-
smaller:
|
|
28
|
-
between:
|
|
29
|
-
|
|
30
|
-
isGreaterOrEqual: n,
|
|
31
|
-
isSmaller: c,
|
|
32
|
-
isSmallerOrEqual: m,
|
|
33
|
-
isInBetween: x,
|
|
34
|
-
...A
|
|
22
|
+
current: r,
|
|
23
|
+
greaterOrEqual: m,
|
|
24
|
+
smallerOrEqual: l,
|
|
25
|
+
active: i,
|
|
26
|
+
greater: d,
|
|
27
|
+
smaller: E,
|
|
28
|
+
between: A,
|
|
29
|
+
...a
|
|
35
30
|
};
|
|
36
|
-
},
|
|
31
|
+
}, w = {
|
|
37
32
|
xs: 0,
|
|
38
33
|
sm: 600,
|
|
39
34
|
md: 900,
|
|
40
35
|
lg: 1200,
|
|
41
36
|
xl: 1536
|
|
42
|
-
},
|
|
37
|
+
}, O = {
|
|
43
38
|
xs: 576,
|
|
44
39
|
sm: 768,
|
|
45
40
|
md: 992,
|
|
46
41
|
lg: 1200,
|
|
47
42
|
xl: 1408
|
|
48
|
-
},
|
|
43
|
+
}, _ = {
|
|
49
44
|
sm: 640,
|
|
50
45
|
md: 768,
|
|
51
46
|
lg: 1024,
|
|
@@ -79,7 +74,7 @@ const l = (s) => window.matchMedia(s).matches, N = (s, d = "mobile-first") => {
|
|
|
79
74
|
laptop: 1024,
|
|
80
75
|
laptopL: 1440,
|
|
81
76
|
desktop4K: 2560
|
|
82
|
-
},
|
|
77
|
+
}, f = {
|
|
83
78
|
"3xs": 360,
|
|
84
79
|
"2xs": 480,
|
|
85
80
|
xs: 600,
|
|
@@ -90,7 +85,7 @@ const l = (s) => window.matchMedia(s).matches, N = (s, d = "mobile-first") => {
|
|
|
90
85
|
"2xl": 1600,
|
|
91
86
|
"3xl": 1920,
|
|
92
87
|
"4xl": 2560
|
|
93
|
-
},
|
|
88
|
+
}, h = {
|
|
94
89
|
sm: 576,
|
|
95
90
|
md: 768,
|
|
96
91
|
lg: 992,
|
|
@@ -99,13 +94,13 @@ const l = (s) => window.matchMedia(s).matches, N = (s, d = "mobile-first") => {
|
|
|
99
94
|
export {
|
|
100
95
|
B as BREAKPOINTS_ANT_DESIGN,
|
|
101
96
|
g as BREAKPOINTS_BOOTSTRAP_V5,
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
97
|
+
O as BREAKPOINTS_MANTINE,
|
|
98
|
+
f as BREAKPOINTS_MASTER_CSS,
|
|
99
|
+
w as BREAKPOINTS_MATERIAL_UI,
|
|
100
|
+
h as BREAKPOINTS_PRIME_FLEX,
|
|
106
101
|
K as BREAKPOINTS_QUASAR_V2,
|
|
107
102
|
P as BREAKPOINTS_SEMANTIC,
|
|
108
|
-
|
|
109
|
-
|
|
103
|
+
_ as BREAKPOINTS_TAILWIND,
|
|
104
|
+
R as useBreakpoints
|
|
110
105
|
};
|
|
111
106
|
//# sourceMappingURL=useBreakpoints.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBreakpoints.mjs","sources":["../../../../src/hooks/useBreakpoints/useBreakpoints.ts"],"sourcesContent":["import { useEffect } from 'react';\n\nimport { useRerender } from '../useRerender/useRerender';\n\n/** The breakpoints type */\nexport type Breakpoints<Breakpoint extends string = string> = Record<Breakpoint, number>;\n\n/** The use breakpoints strategy */\nexport type UseBreakpointsStrategy = 'desktop-first' | 'mobile-first';\n\nconst match = (query: string) => window.matchMedia(query).matches;\n\n/** The use breakpoints return type */\nexport type UseBreakpointsReturn<Breakpoint extends string = string> = {\n /** The function that checks if the current breakpoint is greater than to the given breakpoint */\n greater: (breakpoint: Breakpoint) => boolean;\n /** The function that checks if the current breakpoint is greater than or equal to the given breakpoint */\n greaterOrEqual: (breakpoint: Breakpoint) => boolean;\n /** The function that checks if the current breakpoint is smaller than to the given breakpoint */\n smaller: (breakpoint: Breakpoint) => boolean;\n /** The function that checks if the current breakpoint is smaller than or equal to the given breakpoint */\n smallerOrEqual: (breakpoint: Breakpoint) => boolean;\n /** The function that checks if the current breakpoint is between to the given breakpoints */\n between: (a: Breakpoint, b: Breakpoint) => boolean;\n /** The function that
|
|
1
|
+
{"version":3,"file":"useBreakpoints.mjs","sources":["../../../../src/hooks/useBreakpoints/useBreakpoints.ts"],"sourcesContent":["import { useEffect } from 'react';\n\nimport { useRerender } from '../useRerender/useRerender';\n\n/** The breakpoints type */\nexport type Breakpoints<Breakpoint extends string = string> = Record<Breakpoint, number>;\n\n/** The use breakpoints strategy */\nexport type UseBreakpointsStrategy = 'desktop-first' | 'mobile-first';\n\nconst match = (query: string) => typeof window !== 'undefined' && window.matchMedia(query).matches;\n\n/** The use breakpoints return type */\nexport type UseBreakpointsReturn<Breakpoint extends string = string> = {\n /** The function that checks if the current breakpoint is greater than to the given breakpoint */\n greater: (breakpoint: Breakpoint) => boolean;\n /** The function that checks if the current breakpoint is greater than or equal to the given breakpoint */\n greaterOrEqual: (breakpoint: Breakpoint) => boolean;\n /** The function that checks if the current breakpoint is smaller than to the given breakpoint */\n smaller: (breakpoint: Breakpoint) => boolean;\n /** The function that checks if the current breakpoint is smaller than or equal to the given breakpoint */\n smallerOrEqual: (breakpoint: Breakpoint) => boolean;\n /** The function that checks if the current breakpoint is between to the given breakpoints */\n between: (a: Breakpoint, b: Breakpoint) => boolean;\n /** The function that returns the current breakpoints */\n current: () => Breakpoint[];\n /** The function that returns the current active breakpoint */\n active: () => Breakpoint;\n} & Record<Breakpoint, boolean>;\n\n/**\n * @name useBreakpoints\n * @description - Hook that manages breakpoints\n * @category Browser\n * @usage medium\n *\n * @template {string} Breakpoint The name of the breakpoint\n * @param {Breakpoints<Breakpoint>} breakpoints The breakpoints to use\n * @param {UseBreakpointsStrategy} [strategy=min-width] The strategy to use for matching\n * @returns {UseBreakpointsReturn<Breakpoint>} An object containing the current breakpoint\n *\n * @example\n * const { greater, smaller, between, current, active, ...breakpoints } = useBreakpoints({ mobile: 0, tablet: 640, laptop: 1024, desktop: 1280 });\n */\nexport const useBreakpoints = <Breakpoint extends string>(\n breakpoints: Breakpoints<Breakpoint>,\n strategy: UseBreakpointsStrategy = 'mobile-first'\n): UseBreakpointsReturn<Breakpoint> => {\n const rerender = useRerender();\n\n const getValue = (breakpoint: Breakpoint, delta?: number) => {\n if (delta) return `${Number(breakpoints[breakpoint]) + delta}px`;\n return `${breakpoints[breakpoint]}px`;\n };\n\n useEffect(() => {\n const onResize = rerender;\n window.addEventListener('resize', onResize);\n return () => {\n window.removeEventListener('resize', onResize);\n };\n }, []);\n\n const greaterOrEqual = (breakpoint: Breakpoint) => match(`(min-width: ${getValue(breakpoint)})`);\n const smallerOrEqual = (breakpoint: Breakpoint) => match(`(max-width: ${getValue(breakpoint)})`);\n\n const current = () =>\n Object.keys(breakpoints)\n .map((breakpoint) => [breakpoint, greaterOrEqual(breakpoint as Breakpoint)])\n .filter(([, value]) => value)\n .map(([breakpoint]) => breakpoint) as Breakpoint[];\n\n const active = () => {\n const breakpoints = current();\n return (breakpoints.length ? breakpoints.at(-1) : undefined) as Breakpoint;\n };\n\n const greater = (breakpoint: Breakpoint) => match(`(min-width: ${getValue(breakpoint, 0.1)})`);\n const smaller = (breakpoint: Breakpoint) => match(`(max-width: ${getValue(breakpoint, -0.1)})`);\n const between = (a: Breakpoint, b: Breakpoint) =>\n match(`(min-width: ${getValue(a)}) and (max-width: ${getValue(b, -0.1)})`);\n\n const breakpointsKeys = (Object.keys(breakpoints) as Breakpoint[]).reduce(\n (acc, breakpoint) => {\n const value =\n strategy === 'mobile-first' ? greaterOrEqual(breakpoint) : smallerOrEqual(breakpoint);\n acc[breakpoint] = value;\n return acc;\n },\n {} as Record<Breakpoint, boolean>\n );\n\n return {\n current,\n greaterOrEqual,\n smallerOrEqual,\n active,\n greater,\n smaller,\n between,\n ...breakpointsKeys\n };\n};\n\n/** Breakpoints from Material UI */\nexport const BREAKPOINTS_MATERIAL_UI = {\n xs: 0,\n sm: 600,\n md: 900,\n lg: 1200,\n xl: 1536\n};\n\n/** Breakpoints from Mantine */\nexport const BREAKPOINTS_MANTINE = {\n xs: 576,\n sm: 768,\n md: 992,\n lg: 1200,\n xl: 1408\n};\n\n/** Breakpoints from Tailwind */\nexport const BREAKPOINTS_TAILWIND = {\n sm: 640,\n md: 768,\n lg: 1024,\n xl: 1280,\n '2xl': 1536\n};\n\n/** Breakpoints from Bootstrap V5 */\nexport const BREAKPOINTS_BOOTSTRAP_V5 = {\n xs: 0,\n sm: 576,\n md: 768,\n lg: 992,\n xl: 1200,\n xxl: 1400\n};\n\n/** Breakpoints from Ant Design */\nexport const BREAKPOINTS_ANT_DESIGN = {\n xs: 480,\n sm: 576,\n md: 768,\n lg: 992,\n xl: 1200,\n xxl: 1600\n};\n\n/** Breakpoints from Quasar V2 */\nexport const BREAKPOINTS_QUASAR_V2 = {\n xs: 0,\n sm: 600,\n md: 1024,\n lg: 1440,\n xl: 1920\n};\n\n/** Sematic Breakpoints */\nexport const BREAKPOINTS_SEMANTIC = {\n mobileS: 320,\n mobileM: 375,\n mobileL: 425,\n tablet: 768,\n laptop: 1024,\n laptopL: 1440,\n desktop4K: 2560\n};\n\n/** Breakpoints from Master CSS */\nexport const BREAKPOINTS_MASTER_CSS = {\n '3xs': 360,\n '2xs': 480,\n xs: 600,\n sm: 768,\n md: 1024,\n lg: 1280,\n xl: 1440,\n '2xl': 1600,\n '3xl': 1920,\n '4xl': 2560\n};\n\n/** Breakpoints from PrimeFlex */\nexport const BREAKPOINTS_PRIME_FLEX = {\n sm: 576,\n md: 768,\n lg: 992,\n xl: 1200\n};\n"],"names":["match","query","useBreakpoints","breakpoints","strategy","rerender","useRerender","getValue","breakpoint","delta","useEffect","onResize","greaterOrEqual","smallerOrEqual","current","value","active","greater","smaller","between","a","b","breakpointsKeys","acc","BREAKPOINTS_MATERIAL_UI","BREAKPOINTS_MANTINE","BREAKPOINTS_TAILWIND","BREAKPOINTS_BOOTSTRAP_V5","BREAKPOINTS_ANT_DESIGN","BREAKPOINTS_QUASAR_V2","BREAKPOINTS_SEMANTIC","BREAKPOINTS_MASTER_CSS","BREAKPOINTS_PRIME_FLEX"],"mappings":"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"}
|
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import { useRef as
|
|
2
|
-
import { useRefState as
|
|
3
|
-
import { isTarget as
|
|
4
|
-
const g = (...
|
|
5
|
-
const
|
|
6
|
-
if (
|
|
7
|
-
if (!
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { useRef as s, useEffect as l } from "react";
|
|
2
|
+
import { useRefState as a } from "../useRefState/useRefState.mjs";
|
|
3
|
+
import { isTarget as r } from "../../utils/helpers/isTarget.mjs";
|
|
4
|
+
const g = ((...e) => {
|
|
5
|
+
const t = r(e[0]) ? e[0] : void 0, c = e[1] ? e[1] : e[0], n = a(), o = s(c);
|
|
6
|
+
if (o.current = c, l(() => {
|
|
7
|
+
if (!t && !n.state) return;
|
|
8
|
+
const i = t ? r.getElement(t) : n.current;
|
|
9
|
+
if (!i) return;
|
|
10
|
+
const u = (f) => {
|
|
11
|
+
i.contains(f.target) || o.current(f);
|
|
11
12
|
};
|
|
12
|
-
return document.addEventListener("click",
|
|
13
|
-
document.removeEventListener("click",
|
|
13
|
+
return document.addEventListener("click", u), () => {
|
|
14
|
+
document.removeEventListener("click", u);
|
|
14
15
|
};
|
|
15
|
-
}, [
|
|
16
|
+
}, [t, n.state, r.getRefState(t)]), !t)
|
|
16
17
|
return n;
|
|
17
|
-
};
|
|
18
|
+
});
|
|
18
19
|
export {
|
|
19
20
|
g as useClickOutside
|
|
20
21
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useClickOutside.mjs","sources":["../../../../src/hooks/useClickOutside/useClickOutside.ts"],"sourcesContent":["import { useEffect, useRef } 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\nexport interface UseClickOutside {\n (target: HookTarget, callback: (event: Event) => void): void;\n\n <Target extends Element>(callback: (event: Event) => void, target?: never): StateRef<Target>;\n}\n\n/**\n * @name useClickOutside\n * @description - Hook to handle click events outside the specified target element(s)\n * @category Elements \n * @usage necessary\n\n * @overload\n * @param {HookTarget} target The target element(s) to detect outside clicks for\n * @param {(event: Event) => void} callback The callback to execute when a click outside the target is detected\n * @returns {void}\n *\n * @example\n * useClickOutside(ref, () => console.log('click outside'));\n *\n * @overload\n * @template Target The target element(s)\n * @param {(event: Event) => void} callback The callback to execute when a click outside the target is detected\n * @returns {
|
|
1
|
+
{"version":3,"file":"useClickOutside.mjs","sources":["../../../../src/hooks/useClickOutside/useClickOutside.ts"],"sourcesContent":["import { useEffect, useRef } 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\nexport interface UseClickOutside {\n (target: HookTarget, callback: (event: Event) => void): void;\n\n <Target extends Element>(callback: (event: Event) => void, target?: never): StateRef<Target>;\n}\n\n/**\n * @name useClickOutside\n * @description - Hook to handle click events outside the specified target element(s)\n * @category Elements \n * @usage necessary\n\n * @overload\n * @param {HookTarget} target The target element(s) to detect outside clicks for\n * @param {(event: Event) => void} callback The callback to execute when a click outside the target is detected\n * @returns {void}\n *\n * @example\n * useClickOutside(ref, () => console.log('click outside'));\n *\n * @overload\n * @template Target The target element(s)\n * @param {(event: Event) => void} callback The callback to execute when a click outside the target is detected\n * @returns {StateRef<Target>} A ref to attach to the target element\n *\n * @example\n * const ref = useClickOutside<HTMLDivElement>(() => console.log('click outside'));\n *\n * @see {@link https://siberiacancode.github.io/reactuse/functions/hooks/useClickOutside.html}\n */\nexport const useClickOutside = ((...params: any[]) => {\n const target = (isTarget(params[0]) ? params[0] : undefined) as HookTarget | undefined;\n const callback = (params[1] ? params[1] : params[0]) as (event: Event) => void;\n\n const internalRef = useRefState<Element>();\n const internalCallbackRef = useRef(callback);\n internalCallbackRef.current = callback;\n\n useEffect(() => {\n if (!target && !internalRef.state) return;\n\n const element = (target ? isTarget.getElement(target) : internalRef.current) as Element;\n\n if (!element) return;\n\n const onClick = (event: Event) => {\n if (!element.contains(event.target as Node)) {\n internalCallbackRef.current(event);\n }\n };\n\n document.addEventListener('click', onClick);\n\n return () => {\n document.removeEventListener('click', onClick);\n };\n }, [target, internalRef.state, isTarget.getRefState(target)]);\n if (target) return;\n return internalRef;\n}) as UseClickOutside;\n"],"names":["useClickOutside","params","target","isTarget","callback","internalRef","useRefState","internalCallbackRef","useRef","useEffect","element","onClick","event"],"mappings":";;;AAwCO,MAAMA,KAAmB,IAAIC,MAAkB;AACpD,QAAMC,IAAUC,EAASF,EAAO,CAAC,CAAC,IAAIA,EAAO,CAAC,IAAI,QAC5CG,IAAYH,EAAO,CAAC,IAAIA,EAAO,CAAC,IAAIA,EAAO,CAAC,GAE5CI,IAAcC,EAAA,GACdC,IAAsBC,EAAOJ,CAAQ;AAsB3C,MArBAG,EAAoB,UAAUH,GAE9BK,EAAU,MAAM;AACd,QAAI,CAACP,KAAU,CAACG,EAAY,MAAO;AAEnC,UAAMK,IAAWR,IAASC,EAAS,WAAWD,CAAM,IAAIG,EAAY;AAEpE,QAAI,CAACK,EAAS;AAEd,UAAMC,IAAU,CAACC,MAAiB;AAChC,MAAKF,EAAQ,SAASE,EAAM,MAAc,KACxCL,EAAoB,QAAQK,CAAK;AAAA,IACnC;AAGF,oBAAS,iBAAiB,SAASD,CAAO,GAEnC,MAAM;AACX,eAAS,oBAAoB,SAASA,CAAO;AAAA,IAAA;AAAA,EAC/C,GACC,CAACT,GAAQG,EAAY,OAAOF,EAAS,YAAYD,CAAM,CAAC,CAAC,GACxD,CAAAA;AACJ,WAAOG;AACT;"}
|
|
@@ -13,7 +13,7 @@ const p = () => Object.fromEntries(
|
|
|
13
13
|
v(n, e, t), m();
|
|
14
14
|
}, k = (n, e) => {
|
|
15
15
|
C(n, e), m();
|
|
16
|
-
}, d = (n) => p()[n], z = (n, e) => {
|
|
16
|
+
}, d = (n) => p()[n], z = ((n, e) => {
|
|
17
17
|
const t = typeof e == "object" && e && ("serializer" in e || "deserializer" in e || "initialValue" in e) ? e : void 0, o = t ? t?.initialValue : e;
|
|
18
18
|
if (typeof document > "u")
|
|
19
19
|
return {
|
|
@@ -42,7 +42,7 @@ const p = () => Object.fromEntries(
|
|
|
42
42
|
};
|
|
43
43
|
return window.addEventListener(c, i), () => window.removeEventListener(c, i);
|
|
44
44
|
}, [n]), { value: f, set: (i, r) => a(n, s(i), { ...t, ...r }), remove: (i) => k(n, { ...t, ...i }) };
|
|
45
|
-
};
|
|
45
|
+
});
|
|
46
46
|
export {
|
|
47
47
|
c as COOKIE_EVENT,
|
|
48
48
|
m as dispatchCookieEvent,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCookie.mjs","sources":["../../../../src/hooks/useCookie/useCookie.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nexport const getCookies = () =>\n Object.fromEntries(\n document.cookie.split('; ').map((cookie) => {\n const [key, ...value] = cookie.split('=');\n const decodedValue = decodeURIComponent(value.join('='));\n return [key, decodedValue];\n })\n );\n\nexport interface RemoveCookieParams {\n domain?: string;\n expires?: Date;\n maxAge?: number;\n path?: string;\n sameSite?: 'Lax' | 'None' | 'Strict';\n secure?: boolean;\n}\n\nexport const removeCookie = (key: string, options: RemoveCookieParams = {}) => {\n document.cookie = `${encodeURIComponent(key)}=; expires=Thu, 01 Jan 1970 00:00:00 GMT${\n options.path ? `; path=${options.path}` : ''\n }${options.domain ? `; domain=${options.domain}` : ''}${\n options.maxAge ? `; max-age=0` : ''\n }${options.expires ? `; expires=Thu, 01 Jan 1970 00:00:00 GMT` : ''}${\n options.secure ? `; secure` : ''\n }${options.sameSite ? `; samesite=${options.sameSite}` : ''}`;\n};\n\nexport interface SetCookieParams {\n domain?: string;\n expires?: Date;\n httpOnly?: boolean;\n maxAge?: number;\n path?: string;\n sameSite?: 'Lax' | 'None' | 'Strict';\n secure?: boolean;\n}\n\nexport const setCookie = (key: string, value: string, options: SetCookieParams = {}) => {\n const cookie = [`${encodeURIComponent(key)}=${encodeURIComponent(value)}`];\n\n if (options.path) cookie.push(`path=${options.path}`);\n if (options.domain) cookie.push(`domain=${options.domain}`);\n if (typeof options.maxAge === 'number') cookie.push(`max-age=${options.maxAge}`);\n if (options.expires) cookie.push(`expires=${options.expires.toUTCString()}`);\n if (options.secure) cookie.push(`secure`);\n if (options.httpOnly) cookie.push(`httpOnly`);\n if (options.sameSite) cookie.push(`samesite=${options.sameSite}`);\n\n document.cookie = cookie.join('; ');\n};\n\n/* The use cookie initial value type */\nexport type UseCookieInitialValue<Value> = (() => Value) | Value;\n\n/* The use cookie options type */\nexport interface UseCookieOptions<Value> {\n /* The domain of the cookie */\n domain?: string;\n /* The expiration date of the cookie */\n expires?: Date;\n /* Whether the cookie is httpOnly */\n httpOnly?: boolean;\n /* The initial value of the storage */\n initialValue?: UseCookieInitialValue<Value>;\n /* The maximum age of the cookie */\n maxAge?: number;\n /* The path of the cookie */\n path?: string;\n /* The sameSite of the cookie */\n sameSite?: 'Lax' | 'None' | 'Strict';\n /* Whether the cookie is secure */\n secure?: boolean;\n /* The deserializer function to be invoked */\n deserializer?: (value: string) => Value;\n /* The serializer function to be invoked */\n serializer?: (value: Value) => string;\n}\n\n/* The use cookie return type */\nexport interface UseCookieReturn<Value> {\n /* The value of the cookie */\n value: Value;\n /* The remove function */\n remove: (options?: RemoveCookieParams) => void;\n /* The set function */\n set: (value: Value, options?: SetCookieParams) => void;\n}\n\nexport const COOKIE_EVENT = 'reactuse-cookie';\n\nexport const dispatchCookieEvent = () => window.dispatchEvent(new Event(COOKIE_EVENT));\n\nexport const setCookieItem = (key: string, value: string, options?: SetCookieParams) => {\n setCookie(key, value, options);\n dispatchCookieEvent();\n};\n\nexport const removeCookieItem = (key: string, options?: RemoveCookieParams) => {\n removeCookie(key, options);\n dispatchCookieEvent();\n};\n\nexport const getCookie = (key: string): string | undefined => {\n const cookies = getCookies();\n return cookies[key];\n};\n\nexport interface UseCookie {\n <Value>(\n key: string,\n options: UseCookieOptions<Value> & {\n initialValue: UseCookieInitialValue<Value>;\n }\n ): UseCookieReturn<Value>;\n\n <Value>(key: string, options?: UseCookieOptions<Value>): UseCookieReturn<Value | undefined>;\n\n <Value>(key: string, initialValue: UseCookieInitialValue<Value>): UseCookieReturn<Value>;\n\n <Value>(key: string): UseCookieReturn<Value | undefined>;\n}\n\n/**\n * @name useCookie\n * @description - Hook that manages cookie value\n * @category State\n * @usage medium\n\n * @overload\n * @template Value The type of the cookie value\n * @param {string} key The key of the cookie\n * @param {UseCookieInitialValue<Value>} [initialValue] The initial value of the cookie\n * @returns {UseCookieReturn<Value>} The value and the set function\n *\n * @overload\n * @template Value The type of the cookie value\n * @param {string} key The key of the cookie\n * @param {UseCookieOptions<Value>} options The options object\n * @param {UseCookieInitialValue<Value>} [options.initialValue] The initial value of the cookie\n * @param {(value: string) => Value} [options.deserializer] The deserializer function to be invoked\n * @param {(value: Value) => string} [options.serializer] The serializer function to be invoked\n * @returns {UseCookieReturn<Value | undefined>} The value and the set function\n *\n * @example\n * const { value, set, remove } = useCookie('key', 'value');\n */\nexport const useCookie = (<Value>(key: string, params?: any) => {\n const options = (\n typeof params === 'object' &&\n params &&\n ('serializer' in params || 'deserializer' in params || 'initialValue' in params)\n ? params\n : undefined\n ) as UseCookieOptions<Value>;\n const initialValue = (options ? options?.initialValue : params) as UseCookieInitialValue<Value>;\n\n if (typeof document === 'undefined')\n return {\n value: typeof initialValue === 'function' ? (initialValue as () => Value)() : initialValue\n } as UseCookieReturn<Value>;\n\n const serializer = (value: 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;\n\n try {\n return JSON.parse(value) as Value;\n } catch {\n return value as Value;\n }\n };\n\n const [value, setValue] = useState<Value | undefined>(() => {\n const cookieValue = getCookie(key);\n if (cookieValue === undefined && initialValue !== undefined) {\n const value =\n typeof initialValue === 'function' ? (initialValue as () => Value)() : initialValue;\n setCookieItem(key, serializer(value), options);\n return value;\n }\n return cookieValue ? deserializer(cookieValue) : undefined;\n });\n\n useEffect(() => {\n const onChange = () => {\n const cookieValue = getCookie(key);\n setValue(cookieValue ? deserializer(cookieValue) : undefined);\n };\n window.addEventListener(COOKIE_EVENT, onChange);\n return () => window.removeEventListener(COOKIE_EVENT, onChange);\n }, [key]);\n\n const set = (value: Value, params?: SetCookieParams) =>\n setCookieItem(key, serializer(value), { ...options, ...params });\n const remove = (params?: RemoveCookieParams) => removeCookieItem(key, { ...options, ...params });\n\n return { value, set, remove };\n}) as UseCookie;\n"],"names":["getCookies","cookie","key","value","decodedValue","removeCookie","options","setCookie","COOKIE_EVENT","dispatchCookieEvent","setCookieItem","removeCookieItem","getCookie","useCookie","params","initialValue","serializer","deserializer","setValue","useState","cookieValue","useEffect","onChange"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"useCookie.mjs","sources":["../../../../src/hooks/useCookie/useCookie.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nexport const getCookies = () =>\n Object.fromEntries(\n document.cookie.split('; ').map((cookie) => {\n const [key, ...value] = cookie.split('=');\n const decodedValue = decodeURIComponent(value.join('='));\n return [key, decodedValue];\n })\n );\n\nexport interface RemoveCookieParams {\n domain?: string;\n expires?: Date;\n maxAge?: number;\n path?: string;\n sameSite?: 'Lax' | 'None' | 'Strict';\n secure?: boolean;\n}\n\nexport const removeCookie = (key: string, options: RemoveCookieParams = {}) => {\n document.cookie = `${encodeURIComponent(key)}=; expires=Thu, 01 Jan 1970 00:00:00 GMT${\n options.path ? `; path=${options.path}` : ''\n }${options.domain ? `; domain=${options.domain}` : ''}${\n options.maxAge ? `; max-age=0` : ''\n }${options.expires ? `; expires=Thu, 01 Jan 1970 00:00:00 GMT` : ''}${\n options.secure ? `; secure` : ''\n }${options.sameSite ? `; samesite=${options.sameSite}` : ''}`;\n};\n\nexport interface SetCookieParams {\n domain?: string;\n expires?: Date;\n httpOnly?: boolean;\n maxAge?: number;\n path?: string;\n sameSite?: 'Lax' | 'None' | 'Strict';\n secure?: boolean;\n}\n\nexport const setCookie = (key: string, value: string, options: SetCookieParams = {}) => {\n const cookie = [`${encodeURIComponent(key)}=${encodeURIComponent(value)}`];\n\n if (options.path) cookie.push(`path=${options.path}`);\n if (options.domain) cookie.push(`domain=${options.domain}`);\n if (typeof options.maxAge === 'number') cookie.push(`max-age=${options.maxAge}`);\n if (options.expires) cookie.push(`expires=${options.expires.toUTCString()}`);\n if (options.secure) cookie.push(`secure`);\n if (options.httpOnly) cookie.push(`httpOnly`);\n if (options.sameSite) cookie.push(`samesite=${options.sameSite}`);\n\n document.cookie = cookie.join('; ');\n};\n\n/* The use cookie initial value type */\nexport type UseCookieInitialValue<Value> = (() => Value) | Value;\n\n/* The use cookie options type */\nexport interface UseCookieOptions<Value> {\n /* The domain of the cookie */\n domain?: string;\n /* The expiration date of the cookie */\n expires?: Date;\n /* Whether the cookie is httpOnly */\n httpOnly?: boolean;\n /* The initial value of the storage */\n initialValue?: UseCookieInitialValue<Value>;\n /* The maximum age of the cookie */\n maxAge?: number;\n /* The path of the cookie */\n path?: string;\n /* The sameSite of the cookie */\n sameSite?: 'Lax' | 'None' | 'Strict';\n /* Whether the cookie is secure */\n secure?: boolean;\n /* The deserializer function to be invoked */\n deserializer?: (value: string) => Value;\n /* The serializer function to be invoked */\n serializer?: (value: Value) => string;\n}\n\n/* The use cookie return type */\nexport interface UseCookieReturn<Value> {\n /* The value of the cookie */\n value: Value;\n /* The remove function */\n remove: (options?: RemoveCookieParams) => void;\n /* The set function */\n set: (value: Value, options?: SetCookieParams) => void;\n}\n\nexport const COOKIE_EVENT = 'reactuse-cookie';\n\nexport const dispatchCookieEvent = () => window.dispatchEvent(new Event(COOKIE_EVENT));\n\nexport const setCookieItem = (key: string, value: string, options?: SetCookieParams) => {\n setCookie(key, value, options);\n dispatchCookieEvent();\n};\n\nexport const removeCookieItem = (key: string, options?: RemoveCookieParams) => {\n removeCookie(key, options);\n dispatchCookieEvent();\n};\n\nexport const getCookie = (key: string): string | undefined => {\n const cookies = getCookies();\n return cookies[key];\n};\n\nexport interface UseCookie {\n <Value>(\n key: string,\n options: UseCookieOptions<Value> & {\n initialValue: UseCookieInitialValue<Value>;\n }\n ): UseCookieReturn<Value>;\n\n <Value>(key: string, options?: UseCookieOptions<Value>): UseCookieReturn<Value | undefined>;\n\n <Value>(key: string, initialValue: UseCookieInitialValue<Value>): UseCookieReturn<Value>;\n\n <Value>(key: string): UseCookieReturn<Value | undefined>;\n}\n\n/**\n * @name useCookie\n * @description - Hook that manages cookie value\n * @category State\n * @usage medium\n\n * @overload\n * @template Value The type of the cookie value\n * @param {string} key The key of the cookie\n * @param {UseCookieInitialValue<Value>} [initialValue] The initial value of the cookie\n * @returns {UseCookieReturn<Value>} The value and the set function\n *\n * @overload\n * @template Value The type of the cookie value\n * @param {string} key The key of the cookie\n * @param {UseCookieOptions<Value>} options The options object\n * @param {UseCookieInitialValue<Value>} [options.initialValue] The initial value of the cookie\n * @param {(value: string) => Value} [options.deserializer] The deserializer function to be invoked\n * @param {(value: Value) => string} [options.serializer] The serializer function to be invoked\n * @returns {UseCookieReturn<Value | undefined>} The value and the set function\n *\n * @example\n * const { value, set, remove } = useCookie('key', 'value');\n */\nexport const useCookie = (<Value>(key: string, params?: any) => {\n const options = (\n typeof params === 'object' &&\n params &&\n ('serializer' in params || 'deserializer' in params || 'initialValue' in params)\n ? params\n : undefined\n ) as UseCookieOptions<Value>;\n const initialValue = (options ? options?.initialValue : params) as UseCookieInitialValue<Value>;\n\n if (typeof document === 'undefined')\n return {\n value: typeof initialValue === 'function' ? (initialValue as () => Value)() : initialValue\n } as UseCookieReturn<Value>;\n\n const serializer = (value: 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;\n\n try {\n return JSON.parse(value) as Value;\n } catch {\n return value as Value;\n }\n };\n\n const [value, setValue] = useState<Value | undefined>(() => {\n const cookieValue = getCookie(key);\n if (cookieValue === undefined && initialValue !== undefined) {\n const value =\n typeof initialValue === 'function' ? (initialValue as () => Value)() : initialValue;\n setCookieItem(key, serializer(value), options);\n return value;\n }\n return cookieValue ? deserializer(cookieValue) : undefined;\n });\n\n useEffect(() => {\n const onChange = () => {\n const cookieValue = getCookie(key);\n setValue(cookieValue ? deserializer(cookieValue) : undefined);\n };\n window.addEventListener(COOKIE_EVENT, onChange);\n return () => window.removeEventListener(COOKIE_EVENT, onChange);\n }, [key]);\n\n const set = (value: Value, params?: SetCookieParams) =>\n setCookieItem(key, serializer(value), { ...options, ...params });\n const remove = (params?: RemoveCookieParams) => removeCookieItem(key, { ...options, ...params });\n\n return { value, set, remove };\n}) as UseCookie;\n"],"names":["getCookies","cookie","key","value","decodedValue","removeCookie","options","setCookie","COOKIE_EVENT","dispatchCookieEvent","setCookieItem","removeCookieItem","getCookie","useCookie","params","initialValue","serializer","deserializer","setValue","useState","cookieValue","useEffect","onChange"],"mappings":";AAEO,MAAMA,IAAa,MACxB,OAAO;AAAA,EACL,SAAS,OAAO,MAAM,IAAI,EAAE,IAAI,CAACC,MAAW;AAC1C,UAAM,CAACC,GAAK,GAAGC,CAAK,IAAIF,EAAO,MAAM,GAAG,GAClCG,IAAe,mBAAmBD,EAAM,KAAK,GAAG,CAAC;AACvD,WAAO,CAACD,GAAKE,CAAY;AAAA,EAAA,CAC1B;AACH,GAWWC,IAAe,CAACH,GAAaI,IAA8B,OAAO;AAC7E,WAAS,SAAS,GAAG,mBAAmBJ,CAAG,CAAC,2CAC1CI,EAAQ,OAAO,UAAUA,EAAQ,IAAI,KAAK,EAC5C,GAAGA,EAAQ,SAAS,YAAYA,EAAQ,MAAM,KAAK,EAAE,GACnDA,EAAQ,SAAS,gBAAgB,EACnC,GAAGA,EAAQ,UAAU,4CAA4C,EAAE,GACjEA,EAAQ,SAAS,aAAa,EAChC,GAAGA,EAAQ,WAAW,cAAcA,EAAQ,QAAQ,KAAK,EAAE;AAC7D,GAYaC,IAAY,CAACL,GAAaC,GAAeG,IAA2B,CAAA,MAAO;AACtF,QAAML,IAAS,CAAC,GAAG,mBAAmBC,CAAG,CAAC,IAAI,mBAAmBC,CAAK,CAAC,EAAE;AAEzE,EAAIG,EAAQ,QAAML,EAAO,KAAK,QAAQK,EAAQ,IAAI,EAAE,GAChDA,EAAQ,UAAQL,EAAO,KAAK,UAAUK,EAAQ,MAAM,EAAE,GACtD,OAAOA,EAAQ,UAAW,cAAiB,KAAK,WAAWA,EAAQ,MAAM,EAAE,GAC3EA,EAAQ,WAASL,EAAO,KAAK,WAAWK,EAAQ,QAAQ,YAAA,CAAa,EAAE,GACvEA,EAAQ,UAAQL,EAAO,KAAK,QAAQ,GACpCK,EAAQ,YAAUL,EAAO,KAAK,UAAU,GACxCK,EAAQ,YAAUL,EAAO,KAAK,YAAYK,EAAQ,QAAQ,EAAE,GAEhE,SAAS,SAASL,EAAO,KAAK,IAAI;AACpC,GAuCaO,IAAe,mBAEfC,IAAsB,MAAM,OAAO,cAAc,IAAI,MAAMD,CAAY,CAAC,GAExEE,IAAgB,CAACR,GAAaC,GAAeG,MAA8B;AACtF,EAAAC,EAAUL,GAAKC,GAAOG,CAAO,GAC7BG,EAAA;AACF,GAEaE,IAAmB,CAACT,GAAaI,MAAiC;AAC7E,EAAAD,EAAaH,GAAKI,CAAO,GACzBG,EAAA;AACF,GAEaG,IAAY,CAACV,MACRF,EAAA,EACDE,CAAG,GA0CPW,KAAa,CAAQX,GAAaY,MAAiB;AAC9D,QAAMR,IACJ,OAAOQ,KAAW,YAClBA,MACC,gBAAgBA,KAAU,kBAAkBA,KAAU,kBAAkBA,KACrEA,IACA,QAEAC,IAAgBT,IAAUA,GAAS,eAAeQ;AAExD,MAAI,OAAO,WAAa;AACtB,WAAO;AAAA,MACL,OAAO,OAAOC,KAAiB,aAAcA,MAAiCA;AAAA,IAAA;AAGlF,QAAMC,IAAa,CAACb,MACdG,GAAS,aAAmBA,EAAQ,WAAWH,CAAK,IACpD,OAAOA,KAAU,WAAiBA,IAC/B,KAAK,UAAUA,CAAK,GAGvBc,IAAe,CAACd,MAAkB;AACtC,QAAIG,GAAS,aAAc,QAAOA,EAAQ,aAAaH,CAAK;AAC5D,QAAIA,MAAU;AAEd,UAAI;AACF,eAAO,KAAK,MAAMA,CAAK;AAAA,MAAA,QACjB;AACN,eAAOA;AAAAA,MAAA;AAAA,EACT,GAGI,CAACA,GAAOe,CAAQ,IAAIC,EAA4B,MAAM;AAC1D,UAAMC,IAAcR,EAAUV,CAAG;AACjC,QAAIkB,MAAgB,UAAaL,MAAiB,QAAW;AAC3D,YAAMZ,IACJ,OAAOY,KAAiB,aAAcA,MAAiCA;AACzE,aAAAL,EAAcR,GAAKc,EAAWb,CAAK,GAAGG,CAAO,GACtCH;AAAAA,IAAA;AAET,WAAOiB,IAAcH,EAAaG,CAAW,IAAI;AAAA,EAAA,CAClD;AAED,SAAAC,EAAU,MAAM;AACd,UAAMC,IAAW,MAAM;AACrB,YAAMF,IAAcR,EAAUV,CAAG;AACjC,MAAAgB,EAASE,IAAcH,EAAaG,CAAW,IAAI,MAAS;AAAA,IAAA;AAE9D,kBAAO,iBAAiBZ,GAAcc,CAAQ,GACvC,MAAM,OAAO,oBAAoBd,GAAcc,CAAQ;AAAA,EAAA,GAC7D,CAACpB,CAAG,CAAC,GAMD,EAAE,OAAAC,GAAO,KAJJ,CAACA,GAAcW,MACzBJ,EAAcR,GAAKc,EAAWb,CAAK,GAAG,EAAE,GAAGG,GAAS,GAAGQ,GAAQ,GAG5C,QAFN,CAACA,MAAgCH,EAAiBT,GAAK,EAAE,GAAGI,GAAS,GAAGQ,GAAQ,EAE1E;AACvB;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useState as m } from "react";
|
|
2
|
-
const d = (...u) => {
|
|
2
|
+
const d = ((...u) => {
|
|
3
3
|
const i = typeof u[0] == "number" ? u[0] : u[0]?.initialValue, { max: e = Number.POSITIVE_INFINITY, min: o = Number.NEGATIVE_INFINITY } = typeof u[0] == "number" ? u[1] ?? {} : u[0] ?? {}, [c, r] = m(i ?? 0);
|
|
4
4
|
return { value: c, set: (t) => {
|
|
5
5
|
r((n) => Math.max(
|
|
@@ -16,7 +16,7 @@ const d = (...u) => {
|
|
|
16
16
|
if (typeof o == "number" && t < o) return r(o);
|
|
17
17
|
r(t);
|
|
18
18
|
} };
|
|
19
|
-
};
|
|
19
|
+
});
|
|
20
20
|
export {
|
|
21
21
|
d as useCounter
|
|
22
22
|
};
|