@siberiacancode/reactuse 0.0.58 → 0.0.60
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/{_rollupPluginBabelHelpers-DirJM657.js → _rollupPluginBabelHelpers-DaULt_UR.js} +2 -2
- package/dist/cjs/_rollupPluginBabelHelpers-DaULt_UR.js.map +1 -0
- package/dist/cjs/hooks/index.js +2 -2
- package/dist/cjs/hooks/useAsync/useAsync.js +2 -2
- package/dist/cjs/hooks/useBattery/useBattery.js +2 -2
- package/dist/cjs/hooks/useBattery/useBattery.js.map +1 -1
- package/dist/cjs/hooks/useBoolean/useBoolean.js +2 -2
- package/dist/cjs/hooks/useBreakpoints/constants/breakpoints.js +1 -1
- package/dist/cjs/hooks/useBreakpoints/useBreakpoints.js +2 -2
- package/dist/cjs/hooks/useBreakpoints/useBreakpoints.js.map +1 -1
- package/dist/cjs/hooks/useBrowserLanguage/useBrowserLanguage.js +1 -1
- package/dist/cjs/hooks/useClickOutside/useClickOutside.js +2 -2
- package/dist/cjs/hooks/useClickOutside/useClickOutside.js.map +1 -1
- package/dist/cjs/hooks/useClipboard/useClipboard.js +2 -2
- package/dist/cjs/hooks/useClipboard/useClipboard.js.map +1 -1
- package/dist/cjs/hooks/useCounter/useCounter.js +2 -2
- package/dist/cjs/hooks/useDebounceCallback/useDebounceCallback.js +1 -1
- package/dist/cjs/hooks/useDebounceValue/useDebounceValue.js +2 -2
- package/dist/cjs/hooks/useDefault/useDefault.js +2 -2
- package/dist/cjs/hooks/useDidUpdate/useDidUpdate.js +1 -1
- package/dist/cjs/hooks/useDisclosure/useDisclosure.js +2 -2
- package/dist/cjs/hooks/useDisclosure/useDisclosure.js.map +1 -1
- package/dist/cjs/hooks/useDocumentEvent/useDocumentEvent.js +2 -2
- package/dist/cjs/hooks/useDocumentEvent/useDocumentEvent.js.map +1 -1
- package/dist/cjs/hooks/useDocumentTitle/useDocumentTitle.js +2 -2
- package/dist/cjs/hooks/useDocumentVisibility/useDocumentVisibility.js +1 -1
- package/dist/cjs/hooks/useEvent/useEvent.js +1 -1
- package/dist/cjs/hooks/useEventListener/useEventListener.js +2 -2
- package/dist/cjs/hooks/useEventListener/useEventListener.js.map +1 -1
- package/dist/cjs/hooks/useEyeDropper/useEyeDropper.js +2 -2
- package/dist/cjs/hooks/useEyeDropper/useEyeDropper.js.map +1 -1
- package/dist/cjs/hooks/useFavicon/useFavicon.js +2 -2
- package/dist/cjs/hooks/useField/useField.js +2 -2
- package/dist/cjs/hooks/useFileDialog/useFileDialog.js +2 -2
- package/dist/cjs/hooks/useFps/useFps.js +2 -2
- package/dist/cjs/hooks/useFullscreen/useFullscreen.js +2 -2
- package/dist/cjs/hooks/useGamepad/helpers/mapGamepadToXbox360Controller.js +3 -0
- package/dist/cjs/hooks/useGamepad/helpers/mapGamepadToXbox360Controller.js.map +1 -0
- package/dist/cjs/hooks/useGamepad/useGamepad.js +3 -0
- package/dist/cjs/hooks/useGamepad/useGamepad.js.map +1 -0
- package/dist/cjs/hooks/useGeolocation/useGeolocation.js +2 -2
- package/dist/cjs/hooks/useHash/useHash.js +2 -2
- package/dist/cjs/hooks/useHotkeys/useHotkeys.js +2 -2
- package/dist/cjs/hooks/useHotkeys/useHotkeys.js.map +1 -1
- package/dist/cjs/hooks/useHover/useHover.js +2 -2
- package/dist/cjs/hooks/useHover/useHover.js.map +1 -1
- package/dist/cjs/hooks/useIdle/useIdle.js +2 -2
- package/dist/cjs/hooks/useIdle/useIdle.js.map +1 -1
- package/dist/cjs/hooks/useImage/useImage.js +2 -2
- package/dist/cjs/hooks/useInfiniteScroll/useInfiniteScroll.js +2 -2
- package/dist/cjs/hooks/useInfiniteScroll/useInfiniteScroll.js.map +1 -1
- package/dist/cjs/hooks/useIntersectionObserver/useIntersectionObserver.js +2 -2
- package/dist/cjs/hooks/useIntersectionObserver/useIntersectionObserver.js.map +1 -1
- package/dist/cjs/hooks/useInterval/useInterval.js +2 -2
- package/dist/cjs/hooks/useIsFirstRender/useIsFirstRender.js +1 -1
- package/dist/cjs/hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js +1 -1
- package/dist/cjs/hooks/useKeyPress/useKeyPress.js +2 -2
- package/dist/cjs/hooks/useKeyPress/useKeyPress.js.map +1 -1
- package/dist/cjs/hooks/useKeyPressEvent/useKeyPressEvent.js +2 -2
- package/dist/cjs/hooks/useKeyPressEvent/useKeyPressEvent.js.map +1 -1
- package/dist/cjs/hooks/useKeyboard/useKeyboard.js +2 -2
- package/dist/cjs/hooks/useKeyboard/useKeyboard.js.map +1 -1
- package/dist/cjs/hooks/useKeysPressed/useKeysPressed.js +2 -2
- package/dist/cjs/hooks/useKeysPressed/useKeysPressed.js.map +1 -1
- package/dist/cjs/hooks/useList/useList.js +2 -2
- package/dist/cjs/hooks/useLocalStorage/useLocalStorage.js +2 -2
- package/dist/cjs/hooks/useLogger/useLogger.js +2 -2
- package/dist/cjs/hooks/useLongPress/useLongPress.js +2 -2
- package/dist/cjs/hooks/useLongPress/useLongPress.js.map +1 -1
- package/dist/cjs/hooks/useMap/useMap.js +2 -2
- package/dist/cjs/hooks/useMap/useMap.js.map +1 -1
- package/dist/cjs/hooks/useMeasure/useMeasure.js +2 -2
- package/dist/cjs/hooks/useMeasure/useMeasure.js.map +1 -1
- package/dist/cjs/hooks/useMediaQuery/useMediaQuery.js +1 -1
- package/dist/cjs/hooks/useMemory/useMemory.js +2 -2
- package/dist/cjs/hooks/useMemory/useMemory.js.map +1 -1
- package/dist/cjs/hooks/useMount/useMount.js +1 -1
- package/dist/cjs/hooks/useMouse/useMouse.js +2 -2
- package/dist/cjs/hooks/useMouse/useMouse.js.map +1 -1
- package/dist/cjs/hooks/useMutation/useMutation.js +2 -2
- package/dist/cjs/hooks/useMutationObserver.js +1 -1
- package/dist/cjs/hooks/useNetwork/useNetwork.js +2 -2
- package/dist/cjs/hooks/useOffsetPagination/useOffsetPagination.js +3 -0
- package/dist/cjs/hooks/useOffsetPagination/useOffsetPagination.js.map +1 -0
- package/dist/cjs/hooks/useOnline/useOnline.js +1 -1
- package/dist/cjs/hooks/useOperatingSystem/useOperatingSystem.js +1 -1
- package/dist/cjs/hooks/useOrientation/useOrientation.js +2 -2
- package/dist/cjs/hooks/usePageLeave/usePageLeave.js +2 -2
- package/dist/cjs/hooks/usePaint/helpers/Paint.js +2 -2
- package/dist/cjs/hooks/usePaint/helpers/Pointer.js +2 -2
- package/dist/cjs/hooks/usePaint/usePaint.js +2 -2
- package/dist/cjs/hooks/usePermission/usePermission.js +2 -2
- package/dist/cjs/hooks/usePermission/usePermission.js.map +1 -1
- package/dist/cjs/hooks/usePreferredColorScheme/usePreferredColorScheme.js +1 -1
- package/dist/cjs/hooks/usePreferredContrast/usePreferredContrast.js +1 -1
- package/dist/cjs/hooks/usePreferredDark/usePreferredDark.js +1 -1
- package/dist/cjs/hooks/usePreferredLanguages/usePreferredLanguages.js +1 -1
- package/dist/cjs/hooks/usePreferredReducedMotion/usePreferredReducedMotion.js +1 -1
- package/dist/cjs/hooks/usePrevious/usePrevious.js +1 -1
- package/dist/cjs/hooks/useQuery/useQuery.js +2 -2
- package/dist/cjs/hooks/useQuery/useQuery.js.map +1 -1
- package/dist/cjs/hooks/useQueue/useQueue.js +2 -2
- package/dist/cjs/hooks/useRaf/useRaf.js +2 -2
- package/dist/cjs/hooks/useRafValue/useRafValue.js +2 -2
- package/dist/cjs/hooks/useRenderCount/useRenderCount.js +1 -1
- package/dist/cjs/hooks/useRenderInfo/useRenderInfo.js +1 -1
- package/dist/cjs/hooks/useRerender/useRerender.js +2 -2
- package/dist/cjs/hooks/useResizeObserver/useResizeObserver.js +2 -2
- package/dist/cjs/hooks/useResizeObserver/useResizeObserver.js.map +1 -1
- package/dist/cjs/hooks/useScript/useScript.js +2 -2
- package/dist/cjs/hooks/useScript/useScript.js.map +1 -1
- package/dist/cjs/hooks/useSessionStorage/useSessionStorage.js +2 -2
- package/dist/cjs/hooks/useSet/useSet.js +2 -2
- package/dist/cjs/hooks/useShare/useShare.js +2 -2
- package/dist/cjs/hooks/useStep/useStep.js +2 -2
- package/dist/cjs/hooks/useStopwatch/useStopwatch.js +2 -2
- package/dist/cjs/hooks/useStorage/useStorage.js +2 -2
- package/dist/cjs/hooks/useTextSelection/useTextSelection.js +2 -2
- package/dist/cjs/hooks/useTime/useTime.js +2 -2
- package/dist/cjs/hooks/useTimeout/useTimeout.js +2 -2
- package/dist/cjs/hooks/useToggle/useToggle.js +2 -2
- package/dist/cjs/hooks/useUnmount/useUnmount.js +1 -1
- package/dist/cjs/hooks/useWebSocket/useWebSocket.js +2 -2
- package/dist/cjs/hooks/useWindowEvent/useWindowEvent.js +2 -2
- package/dist/cjs/hooks/useWindowEvent/useWindowEvent.js.map +1 -1
- package/dist/cjs/hooks/useWindowScroll/useWindowScroll.js +2 -2
- package/dist/cjs/hooks/useWindowSize/useWindowSize.js +2 -2
- package/dist/cjs/hooks/useWizard/useWizard.js +2 -2
- package/dist/cjs/{index-YChVM8hc.js → index-BNXI2awt.js} +2 -2
- package/dist/cjs/{index-YChVM8hc.js.map → index-BNXI2awt.js.map} +1 -1
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/utils/helpers/debounce.js +1 -1
- package/dist/cjs/utils/helpers/getElement.js +3 -0
- package/dist/cjs/utils/helpers/getElement.js.map +1 -0
- package/dist/cjs/utils/helpers/getRetry.js +1 -1
- package/dist/cjs/utils/helpers/index.js +2 -2
- package/dist/cjs/utils/helpers/isClient.js +1 -1
- package/dist/cjs/utils/helpers/isPermissionAllowed.js +1 -1
- package/dist/cjs/utils/helpers/throttle.js +1 -1
- package/dist/cjs/utils/helpers/time/getDate.js +1 -1
- package/dist/cjs/utils/types/index.js +1 -1
- package/dist/esm/{_rollupPluginBabelHelpers-Bu6kaSqT.js → _rollupPluginBabelHelpers-BdfjLHhW.js} +3 -3
- package/dist/esm/_rollupPluginBabelHelpers-BdfjLHhW.js.map +1 -0
- package/dist/esm/hooks/index.js +2 -2
- package/dist/esm/hooks/useAsync/useAsync.js +2 -2
- package/dist/esm/hooks/useBattery/useBattery.js +2 -2
- package/dist/esm/hooks/useBattery/useBattery.js.map +1 -1
- package/dist/esm/hooks/useBoolean/useBoolean.js +2 -2
- package/dist/esm/hooks/useBreakpoints/constants/breakpoints.js +1 -1
- package/dist/esm/hooks/useBreakpoints/useBreakpoints.js +2 -2
- package/dist/esm/hooks/useBreakpoints/useBreakpoints.js.map +1 -1
- package/dist/esm/hooks/useBrowserLanguage/useBrowserLanguage.js +1 -1
- package/dist/esm/hooks/useClickOutside/useClickOutside.js +2 -2
- package/dist/esm/hooks/useClickOutside/useClickOutside.js.map +1 -1
- package/dist/esm/hooks/useClipboard/useClipboard.js +2 -2
- package/dist/esm/hooks/useClipboard/useClipboard.js.map +1 -1
- package/dist/esm/hooks/useCounter/useCounter.js +2 -2
- package/dist/esm/hooks/useDebounceCallback/useDebounceCallback.js +1 -1
- package/dist/esm/hooks/useDebounceValue/useDebounceValue.js +2 -2
- package/dist/esm/hooks/useDefault/useDefault.js +2 -2
- package/dist/esm/hooks/useDidUpdate/useDidUpdate.js +1 -1
- package/dist/esm/hooks/useDisclosure/useDisclosure.js +2 -2
- package/dist/esm/hooks/useDisclosure/useDisclosure.js.map +1 -1
- package/dist/esm/hooks/useDocumentEvent/useDocumentEvent.js +2 -2
- package/dist/esm/hooks/useDocumentEvent/useDocumentEvent.js.map +1 -1
- package/dist/esm/hooks/useDocumentTitle/useDocumentTitle.js +2 -2
- package/dist/esm/hooks/useDocumentVisibility/useDocumentVisibility.js +1 -1
- package/dist/esm/hooks/useEvent/useEvent.js +1 -1
- package/dist/esm/hooks/useEventListener/useEventListener.js +2 -2
- package/dist/esm/hooks/useEventListener/useEventListener.js.map +1 -1
- package/dist/esm/hooks/useEyeDropper/useEyeDropper.js +2 -2
- package/dist/esm/hooks/useEyeDropper/useEyeDropper.js.map +1 -1
- package/dist/esm/hooks/useFavicon/useFavicon.js +2 -2
- package/dist/esm/hooks/useField/useField.js +2 -2
- package/dist/esm/hooks/useFileDialog/useFileDialog.js +2 -2
- package/dist/esm/hooks/useFps/useFps.js +2 -2
- package/dist/esm/hooks/useFullscreen/useFullscreen.js +2 -2
- package/dist/esm/hooks/useGamepad/helpers/mapGamepadToXbox360Controller.js +3 -0
- package/dist/esm/hooks/useGamepad/helpers/mapGamepadToXbox360Controller.js.map +1 -0
- package/dist/esm/hooks/useGamepad/useGamepad.js +3 -0
- package/dist/esm/hooks/useGamepad/useGamepad.js.map +1 -0
- package/dist/esm/hooks/useGeolocation/useGeolocation.js +2 -2
- package/dist/esm/hooks/useHash/useHash.js +2 -2
- package/dist/esm/hooks/useHotkeys/useHotkeys.js +2 -2
- package/dist/esm/hooks/useHotkeys/useHotkeys.js.map +1 -1
- package/dist/esm/hooks/useHover/useHover.js +2 -2
- package/dist/esm/hooks/useHover/useHover.js.map +1 -1
- package/dist/esm/hooks/useIdle/useIdle.js +2 -2
- package/dist/esm/hooks/useIdle/useIdle.js.map +1 -1
- package/dist/esm/hooks/useImage/useImage.js +2 -2
- package/dist/esm/hooks/useInfiniteScroll/useInfiniteScroll.js +2 -2
- package/dist/esm/hooks/useInfiniteScroll/useInfiniteScroll.js.map +1 -1
- package/dist/esm/hooks/useIntersectionObserver/useIntersectionObserver.js +2 -2
- package/dist/esm/hooks/useIntersectionObserver/useIntersectionObserver.js.map +1 -1
- package/dist/esm/hooks/useInterval/useInterval.js +2 -2
- package/dist/esm/hooks/useIsFirstRender/useIsFirstRender.js +1 -1
- package/dist/esm/hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js +1 -1
- package/dist/esm/hooks/useKeyPress/useKeyPress.js +2 -2
- package/dist/esm/hooks/useKeyPress/useKeyPress.js.map +1 -1
- package/dist/esm/hooks/useKeyPressEvent/useKeyPressEvent.js +2 -2
- package/dist/esm/hooks/useKeyPressEvent/useKeyPressEvent.js.map +1 -1
- package/dist/esm/hooks/useKeyboard/useKeyboard.js +2 -2
- package/dist/esm/hooks/useKeyboard/useKeyboard.js.map +1 -1
- package/dist/esm/hooks/useKeysPressed/useKeysPressed.js +2 -2
- package/dist/esm/hooks/useKeysPressed/useKeysPressed.js.map +1 -1
- package/dist/esm/hooks/useList/useList.js +2 -2
- package/dist/esm/hooks/useLocalStorage/useLocalStorage.js +2 -2
- package/dist/esm/hooks/useLogger/useLogger.js +2 -2
- package/dist/esm/hooks/useLongPress/useLongPress.js +2 -2
- package/dist/esm/hooks/useLongPress/useLongPress.js.map +1 -1
- package/dist/esm/hooks/useMap/useMap.js +2 -2
- package/dist/esm/hooks/useMap/useMap.js.map +1 -1
- package/dist/esm/hooks/useMeasure/useMeasure.js +2 -2
- package/dist/esm/hooks/useMeasure/useMeasure.js.map +1 -1
- package/dist/esm/hooks/useMediaQuery/useMediaQuery.js +1 -1
- package/dist/esm/hooks/useMemory/useMemory.js +2 -2
- package/dist/esm/hooks/useMemory/useMemory.js.map +1 -1
- package/dist/esm/hooks/useMount/useMount.js +1 -1
- package/dist/esm/hooks/useMouse/useMouse.js +2 -2
- package/dist/esm/hooks/useMouse/useMouse.js.map +1 -1
- package/dist/esm/hooks/useMutation/useMutation.js +2 -2
- package/dist/esm/hooks/useMutationObserver.js +1 -1
- package/dist/esm/hooks/useNetwork/useNetwork.js +2 -2
- package/dist/esm/hooks/useOffsetPagination/useOffsetPagination.js +3 -0
- package/dist/esm/hooks/useOffsetPagination/useOffsetPagination.js.map +1 -0
- package/dist/esm/hooks/useOnline/useOnline.js +1 -1
- package/dist/esm/hooks/useOperatingSystem/useOperatingSystem.js +1 -1
- package/dist/esm/hooks/useOrientation/useOrientation.js +2 -2
- package/dist/esm/hooks/usePageLeave/usePageLeave.js +2 -2
- package/dist/esm/hooks/usePaint/helpers/Paint.js +2 -2
- package/dist/esm/hooks/usePaint/helpers/Paint.js.map +1 -1
- package/dist/esm/hooks/usePaint/helpers/Pointer.js +2 -2
- package/dist/esm/hooks/usePaint/usePaint.js +2 -2
- package/dist/esm/hooks/usePermission/usePermission.js +2 -2
- package/dist/esm/hooks/usePermission/usePermission.js.map +1 -1
- package/dist/esm/hooks/usePreferredColorScheme/usePreferredColorScheme.js +1 -1
- package/dist/esm/hooks/usePreferredContrast/usePreferredContrast.js +1 -1
- package/dist/esm/hooks/usePreferredDark/usePreferredDark.js +1 -1
- package/dist/esm/hooks/usePreferredLanguages/usePreferredLanguages.js +1 -1
- package/dist/esm/hooks/usePreferredReducedMotion/usePreferredReducedMotion.js +1 -1
- package/dist/esm/hooks/usePrevious/usePrevious.js +1 -1
- package/dist/esm/hooks/useQuery/useQuery.js +2 -2
- package/dist/esm/hooks/useQuery/useQuery.js.map +1 -1
- package/dist/esm/hooks/useQueue/useQueue.js +2 -2
- package/dist/esm/hooks/useRaf/useRaf.js +2 -2
- package/dist/esm/hooks/useRafValue/useRafValue.js +2 -2
- package/dist/esm/hooks/useRenderCount/useRenderCount.js +1 -1
- package/dist/esm/hooks/useRenderInfo/useRenderInfo.js +1 -1
- package/dist/esm/hooks/useRerender/useRerender.js +2 -2
- package/dist/esm/hooks/useResizeObserver/useResizeObserver.js +2 -2
- package/dist/esm/hooks/useResizeObserver/useResizeObserver.js.map +1 -1
- package/dist/esm/hooks/useScript/useScript.js +2 -2
- package/dist/esm/hooks/useScript/useScript.js.map +1 -1
- package/dist/esm/hooks/useSessionStorage/useSessionStorage.js +2 -2
- package/dist/esm/hooks/useSet/useSet.js +2 -2
- package/dist/esm/hooks/useShare/useShare.js +2 -2
- package/dist/esm/hooks/useStep/useStep.js +2 -2
- package/dist/esm/hooks/useStopwatch/useStopwatch.js +2 -2
- package/dist/esm/hooks/useStorage/useStorage.js +2 -2
- package/dist/esm/hooks/useTextSelection/useTextSelection.js +2 -2
- package/dist/esm/hooks/useTime/useTime.js +2 -2
- package/dist/esm/hooks/useTimeout/useTimeout.js +2 -2
- package/dist/esm/hooks/useToggle/useToggle.js +2 -2
- package/dist/esm/hooks/useUnmount/useUnmount.js +1 -1
- package/dist/esm/hooks/useWebSocket/useWebSocket.js +2 -2
- package/dist/esm/hooks/useWindowEvent/useWindowEvent.js +2 -2
- package/dist/esm/hooks/useWindowEvent/useWindowEvent.js.map +1 -1
- package/dist/esm/hooks/useWindowScroll/useWindowScroll.js +2 -2
- package/dist/esm/hooks/useWindowSize/useWindowSize.js +2 -2
- package/dist/esm/hooks/useWizard/useWizard.js +2 -2
- package/dist/esm/{index-BXUPAyJA.js → index-Iv79yzFW.js} +2 -2
- package/dist/esm/{index-BXUPAyJA.js.map → index-Iv79yzFW.js.map} +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/utils/helpers/debounce.js +1 -1
- package/dist/esm/utils/helpers/getElement.js +3 -0
- package/dist/esm/utils/helpers/getElement.js.map +1 -0
- package/dist/esm/utils/helpers/getRetry.js +1 -1
- package/dist/esm/utils/helpers/index.js +2 -2
- package/dist/esm/utils/helpers/isClient.js +1 -1
- package/dist/esm/utils/helpers/isPermissionAllowed.js +1 -1
- package/dist/esm/utils/helpers/throttle.js +1 -1
- package/dist/esm/utils/helpers/time/getDate.js +1 -1
- package/dist/esm/utils/types/index.js +1 -1
- package/dist/index.d.ts +136 -29
- package/package.json +1 -1
- package/dist/cjs/_rollupPluginBabelHelpers-DirJM657.js.map +0 -1
- package/dist/esm/_rollupPluginBabelHelpers-Bu6kaSqT.js.map +0 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
"use strict";var e=require("../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.60 */
|
|
2
|
+
"use strict";var e=require("../../_rollupPluginBabelHelpers-DaULt_UR.js"),n=require("react"),l=require("../../index-BNXI2awt.js"),r=require("../useUnmount/useUnmount.js");exports.useFullscreen=function(){var u,i=void 0===(arguments.length<=1?void 0:arguments[1])||arguments.length<=0?void 0:arguments[0],t=i?arguments.length<=1?void 0:arguments[1]:arguments.length<=0?void 0:arguments[0],c=n.useRef(null),s=n.useState(null!==(u=null==t?void 0:t.initialValue)&&void 0!==u&&u),o=e._slicedToArray(s,2),f=o[0],a=o[1],d=function e(){if(l.screenfull.isEnabled){var n,r;if(l.screenfull.isFullscreen)null==t||null===(n=t.onEnter)||void 0===n||n.call(t);else l.screenfull.off("change",e),null==t||null===(r=t.onExit)||void 0===r||r.call(t);a(l.screenfull.isFullscreen)}},v=function(){var e=i?function(e){return"function"==typeof e?e():e instanceof Element?e:e.current}(i):c.current;if(e&&l.screenfull.isEnabled)try{l.screenfull.request(e),l.screenfull.on("change",d)}catch(e){console.error(e)}},g=function(){l.screenfull.isEnabled&&l.screenfull.exit()};return r.useUnmount((function(){l.screenfull.isEnabled&&l.screenfull.off("change",d)})),e._objectSpread2(e._objectSpread2({},!i&&{ref:c}),{},{enter:v,exit:g,toggle:function(){if(f)return g();v()},value:f})};
|
|
3
3
|
//# sourceMappingURL=useFullscreen.js.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.60 */
|
|
2
|
+
"use strict";exports.mapGamepadToXbox360Controller=function(t){return{buttons:{a:t.buttons[0],b:t.buttons[1],x:t.buttons[2],y:t.buttons[3]},bumper:{left:t.buttons[4],right:t.buttons[5]},triggers:{left:t.buttons[6],right:t.buttons[7]},stick:{left:{horizontal:t.axes[0],vertical:t.axes[1],button:t.buttons[10]},right:{horizontal:t.axes[2],vertical:t.axes[3],button:t.buttons[11]}},dpad:{up:t.buttons[12],down:t.buttons[13],left:t.buttons[14],right:t.buttons[15]},back:t.buttons[8],start:t.buttons[9]}};
|
|
3
|
+
//# sourceMappingURL=mapGamepadToXbox360Controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapGamepadToXbox360Controller.js","sources":["../../../../../src/hooks/useGamepad/helpers/mapGamepadToXbox360Controller.ts"],"sourcesContent":["export const mapGamepadToXbox360Controller = (gamepad: Gamepad) => ({\n buttons: {\n a: gamepad.buttons[0],\n b: gamepad.buttons[1],\n x: gamepad.buttons[2],\n y: gamepad.buttons[3]\n },\n bumper: {\n left: gamepad.buttons[4],\n right: gamepad.buttons[5]\n },\n triggers: {\n left: gamepad.buttons[6],\n right: gamepad.buttons[7]\n },\n stick: {\n left: {\n horizontal: gamepad.axes[0],\n vertical: gamepad.axes[1],\n button: gamepad.buttons[10]\n },\n right: {\n horizontal: gamepad.axes[2],\n vertical: gamepad.axes[3],\n button: gamepad.buttons[11]\n }\n },\n dpad: {\n up: gamepad.buttons[12],\n down: gamepad.buttons[13],\n left: gamepad.buttons[14],\n right: gamepad.buttons[15]\n },\n back: gamepad.buttons[8],\n start: gamepad.buttons[9]\n});\n"],"names":["gamepad","buttons","a","b","x","y","bumper","left","right","triggers","stick","horizontal","axes","vertical","button","dpad","up","down","back","start"],"mappings":";mDAA6C,SAACA,GAAgB,MAAM,CAClEC,QAAS,CACPC,EAAGF,EAAQC,QAAQ,GACnBE,EAAGH,EAAQC,QAAQ,GACnBG,EAAGJ,EAAQC,QAAQ,GACnBI,EAAGL,EAAQC,QAAQ,IAErBK,OAAQ,CACNC,KAAMP,EAAQC,QAAQ,GACtBO,MAAOR,EAAQC,QAAQ,IAEzBQ,SAAU,CACRF,KAAMP,EAAQC,QAAQ,GACtBO,MAAOR,EAAQC,QAAQ,IAEzBS,MAAO,CACLH,KAAM,CACJI,WAAYX,EAAQY,KAAK,GACzBC,SAAUb,EAAQY,KAAK,GACvBE,OAAQd,EAAQC,QAAQ,KAE1BO,MAAO,CACLG,WAAYX,EAAQY,KAAK,GACzBC,SAAUb,EAAQY,KAAK,GACvBE,OAAQd,EAAQC,QAAQ,MAG5Bc,KAAM,CACJC,GAAIhB,EAAQC,QAAQ,IACpBgB,KAAMjB,EAAQC,QAAQ,IACtBM,KAAMP,EAAQC,QAAQ,IACtBO,MAAOR,EAAQC,QAAQ,KAEzBiB,KAAMlB,EAAQC,QAAQ,GACtBkB,MAAOnB,EAAQC,QAAQ,GACxB"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.60 */
|
|
2
|
+
"use strict";var e=require("../../_rollupPluginBabelHelpers-DaULt_UR.js"),t=require("react"),a=require("../useEvent/useEvent.js"),r=require("../useRaf/useRaf.js"),n=require("./helpers/mapGamepadToXbox360Controller.js");exports.mapGamepadToXbox360Controller=n.mapGamepadToXbox360Controller,exports.useGamepad=function(){var n=navigator&&"getGamepads"in navigator,o=t.useState({}),u=e._slicedToArray(o,2),c=u[0],d=u[1],i=r.useRaf((function(){}),{enabled:!!Object.keys(c).length}).active,s=function(t){var a=[],r="vibrationActuator"in t?t.vibrationActuator:null;return r&&a.push(r),t.hapticActuators&&a.push.apply(a,e._toConsumableArray(t.hapticActuators)),e._objectSpread2(e._objectSpread2({},t),{},{hapticActuators:a})};t.useEffect((function(){if(n){var t=navigator.getGamepads();d(t.reduce((function(t,a){return e._objectSpread2(e._objectSpread2({},t),a&&e._defineProperty({},a.index,s(a)))}),{}))}}),[]);var p=a.useEvent((function(t){var a=t.gamepad;d(e._objectSpread2(e._objectSpread2({},c),{},e._defineProperty({},a.index,s(a))))})),v=a.useEvent((function(t){var a=t.gamepad,r=e._objectSpread2({},c);delete r[a.index],d(r)}));return t.useEffect((function(){return document.addEventListener("gamepadconnected",p),document.addEventListener("gamepaddisconnected",v),function(){document.removeEventListener("gamepadconnected",p),document.removeEventListener("gamepaddisconnected",v)}}),[]),{active:i,supported:n,gamepads:Object.values(c)}};
|
|
3
|
+
//# sourceMappingURL=useGamepad.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGamepad.js","sources":["../../../../src/hooks/useGamepad/useGamepad.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nimport { useEvent } from '../useEvent/useEvent';\nimport { useRaf } from '../useRaf/useRaf';\n\ndeclare global {\n interface Gamepad {\n hapticActuators?: GamepadHapticActuator[];\n }\n}\n\n/** The use gamepad return type */\nexport interface UseGamepadStateReturn {\n /** The gamepad supported status */\n supported: boolean;\n /** The gamepad state */\n gamepads: Gamepad[];\n /** The gamepad active status */\n active: boolean;\n}\n\n/**\n * @name useGamepad\n * @description - Hook for getting information about gamepad\n * @category Browser\n *\n * @returns {UseGamepadStateReturn} An object containing the gamepad information\n *\n * @example\n * const { supported, gamepads, active } = useGamepad();\n */\nexport const useGamepad = () => {\n const supported = navigator && 'getGamepads' in navigator;\n const [gamepads, setGamepads] = useState<Record<number, Gamepad>>({});\n\n const { active } = useRaf(() => {}, { enabled: !!Object.keys(gamepads).length });\n\n const createGamepad = (gamepad: Gamepad) => {\n const hapticActuators = [];\n const vibrationActuator = 'vibrationActuator' in gamepad ? gamepad.vibrationActuator : null;\n\n if (vibrationActuator) hapticActuators.push(vibrationActuator);\n if (gamepad.hapticActuators) hapticActuators.push(...gamepad.hapticActuators);\n\n return {\n ...gamepad,\n hapticActuators\n } as Gamepad;\n };\n\n useEffect(() => {\n if (!supported) return;\n const gamepads = navigator.getGamepads();\n setGamepads(\n gamepads.reduce(\n (acc, gamepad) => ({ ...acc, ...(gamepad && { [gamepad.index]: createGamepad(gamepad) }) }),\n {}\n )\n );\n }, []);\n\n const onConnected = useEvent((event: Event) => {\n const { gamepad } = event as GamepadEvent;\n setGamepads({ ...gamepads, [gamepad.index]: createGamepad(gamepad) });\n });\n\n const onDisconnected = useEvent((event: Event) => {\n const { gamepad } = event as GamepadEvent;\n const updatedGamepads = { ...gamepads };\n delete updatedGamepads[gamepad.index];\n setGamepads(updatedGamepads);\n });\n\n useEffect(() => {\n document.addEventListener('gamepadconnected', onConnected);\n document.addEventListener('gamepaddisconnected', onDisconnected);\n\n return () => {\n document.removeEventListener('gamepadconnected', onConnected);\n document.removeEventListener('gamepaddisconnected', onDisconnected);\n };\n }, []);\n\n return {\n active,\n supported,\n gamepads: Object.values(gamepads)\n };\n};\n\nexport * from './helpers/mapGamepadToXbox360Controller';\n"],"names":["supported","navigator","_useState","useState","_useState2","_slicedToArray","gamepads","setGamepads","active","useRaf","enabled","Object","keys","length","createGamepad","gamepad","hapticActuators","vibrationActuator","push","apply","_toConsumableArray","_objectSpread","_objectSpread2","useEffect","getGamepads","reduce","acc","_defineProperty","index","onConnected","useEvent","event","onDisconnected","updatedGamepads","document","addEventListener","removeEventListener","values"],"mappings":";oTA+B0B,WACxB,IAAMA,EAAYC,WAAa,gBAAiBA,UAChDC,EAAgCC,EAAQA,SAA0B,IAAGC,EAAAC,EAAAA,eAAAH,EAAA,GAA9DI,EAAQF,EAAA,GAAEG,EAAWH,EAAA,GAEpBI,EAAWC,UAAO,cAAU,CAAEC,UAAWC,OAAOC,KAAKN,GAAUO,SAA/DL,OAEFM,EAAgB,SAACC,GACrB,IAAMC,EAAkB,GAClBC,EAAoB,sBAAuBF,EAAUA,EAAQE,kBAAoB,KAKvF,OAHIA,GAAmBD,EAAgBE,KAAKD,GACxCF,EAAQC,iBAAiBA,EAAgBE,KAAIC,MAApBH,EAAeI,qBAASL,EAAQC,kBAE7DK,EAAAC,eAAAD,EAAAC,eAAA,CAAA,EACKP,GAAO,CAAA,EAAA,CACVC,gBAAAA,KAIJO,EAAAA,WAAU,WACR,GAAKvB,EAAL,CACA,IAAMM,EAAWL,UAAUuB,cAC3BjB,EACED,EAASmB,QACP,SAACC,EAAKX,GAAO,OAAAM,EAAAC,eAAAD,EAAAC,kBAAWI,GAASX,GAAOY,EAAAA,gBAAOZ,CAAAA,EAAAA,EAAQa,MAAQd,EAAcC,IAAU,GACvF,CAAA,GALY,CAQjB,GAAE,IAEH,IAAMc,EAAcC,YAAS,SAACC,GAC5B,IAAQhB,EAAYgB,EAAZhB,QACRR,EAAWc,EAAAC,eAAAD,EAAAC,eAAMhB,CAAAA,EAAAA,MAAQqB,EAAAA,gBAAA,CAAA,EAAGZ,EAAQa,MAAQd,EAAcC,KAC5D,IAEMiB,EAAiBF,YAAS,SAACC,GAC/B,IAAQhB,EAAYgB,EAAZhB,QACFkB,EAAeZ,EAAAA,eAAA,CAAA,EAAQf,UACtB2B,EAAgBlB,EAAQa,OAC/BrB,EAAY0B,EACd,IAYA,OAVAV,EAAAA,WAAU,WAIR,OAHAW,SAASC,iBAAiB,mBAAoBN,GAC9CK,SAASC,iBAAiB,sBAAuBH,GAE1C,WACLE,SAASE,oBAAoB,mBAAoBP,GACjDK,SAASE,oBAAoB,sBAAuBJ,GAEvD,GAAE,IAEI,CACLxB,OAAAA,EACAR,UAAAA,EACAM,SAAUK,OAAO0B,OAAO/B,GAE5B"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
"use strict";var e=require("../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.60 */
|
|
2
|
+
"use strict";var e=require("../../_rollupPluginBabelHelpers-DaULt_UR.js"),t=require("react");exports.useGeolocation=function(a){var i=t.useState({loading:!0,error:null,timestamp:Date.now(),accuracy:0,latitude:Number.POSITIVE_INFINITY,longitude:Number.POSITIVE_INFINITY,altitude:null,altitudeAccuracy:null,heading:null,speed:null}),u=e._slicedToArray(i,2),o=u[0],r=u[1];return t.useEffect((function(){var t=function(t){var a=t.coords,i=t.timestamp;r(e._objectSpread2(e._objectSpread2({},o),{},{loading:!1,timestamp:i,latitude:a.latitude,longitude:a.longitude,altitude:a.altitude,accuracy:a.accuracy,altitudeAccuracy:a.altitudeAccuracy,heading:a.heading,speed:a.speed}))},i=function(t){r(e._objectSpread2(e._objectSpread2({},o),{},{loading:!1,error:t}))};navigator.geolocation.getCurrentPosition(t,i,a);var u=navigator.geolocation.watchPosition(t,i,a);return function(){navigator.geolocation.clearWatch(u)}}),[null==a?void 0:a.enableHighAccuracy,null==a?void 0:a.maximumAge,null==a?void 0:a.timeout]),o};
|
|
3
3
|
//# sourceMappingURL=useGeolocation.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
"use strict";var e=require("../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.60 */
|
|
2
|
+
"use strict";var e=require("../../_rollupPluginBabelHelpers-DaULt_UR.js"),n=require("react"),r=function(){return decodeURIComponent(window.location.hash.replace("#",""))};exports.useHash=function(){var t=n.useState(window?r():""),o=e._slicedToArray(t,2),i=o[0],a=o[1];return n.useEffect((function(){var e=function(){return a(r())};return window.addEventListener("hashchange",e),function(){window.removeEventListener("hashchange",e)}})),[i,function(e){window.location.hash=e,a(e)}]};
|
|
3
3
|
//# sourceMappingURL=useHash.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
"use strict";var e=require("../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.60 */
|
|
2
|
+
"use strict";var e=require("../../_rollupPluginBabelHelpers-DaULt_UR.js"),r=require("react"),n=require("../useDidUpdate/useDidUpdate.js"),t=require("../useEventListener/useEventListener.js");require("../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js"),require("../../utils/helpers/isClient.js"),require("../../utils/helpers/getElement.js"),require("../useEvent/useEvent.js");var u=function(e,r){return e.toLowerCase().split(/[+_-]/g).map((function(e){return e.trim()})).every((function(e){return r.find((function(r){return e===r.code.toLocaleLowerCase()||e===r.key.toLocaleLowerCase()||e===r.alias.toLocaleLowerCase()}))}))};exports.isHotkeyMatch=u,exports.useHotkeys=function(o,i,l){var s,a,c,d,v=null===(s=null==l?void 0:l.enabled)||void 0===s||s,f=null===(a=null==l?void 0:l.preventDefault)||void 0===a||a,p=r.useState([]),y=e._slicedToArray(p,2)[1];n.useDidUpdate((function(){y([])}),[v]),t.useEventListener(null!==(c=null==l?void 0:l.target)&&void 0!==c?c:window,"keydown",(function(r){f&&r.preventDefault(),v&&y((function(n){var t,s,a,c;if(n.some((function(e){return e.code===r.code})))return n;var d=null!==(t=null!==(s=null==l||null===(a=l.aliasMap)||void 0===a?void 0:a[r.key])&&void 0!==s?s:null==l||null===(c=l.aliasMap)||void 0===c?void 0:c[r.key])&&void 0!==t?t:r.code,v=[].concat(e._toConsumableArray(n),[{key:r.key,code:r.code,alias:d}]);Array.isArray(o)?o.forEach((function(e){u(e,v)&&i(r)})):u(o,v)&&i(r);return v}))})),t.useEventListener(null!==(d=null==l?void 0:l.target)&&void 0!==d?d:window,"keyup",(function(e){v&&y((function(r){return r.filter((function(r){return r.code!==e.code}))}))}))};
|
|
3
3
|
//# sourceMappingURL=useHotkeys.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useHotkeys.js","sources":["../../../../src/hooks/useHotkeys/useHotkeys.ts"],"sourcesContent":["import { useState } from 'react';\n\nimport { useDidUpdate } from '../useDidUpdate/useDidUpdate';\nimport type { UseEventListenerTarget } from '../useEventListener/useEventListener';\nimport { useEventListener } from '../useEventListener/useEventListener';\n\n/** The use hotkeys params type */\nexport interface UseHotkeysOptions {\n /** The target to attach the event listeners to */\n target?: UseEventListenerTarget;\n /** Enable or disable the event listeners */\n enabled?: boolean;\n /** Whether to prevent the default behavior of the event */\n preventDefault?: boolean;\n /** Alias map for hotkeys */\n aliasMap?: Record<string, string>;\n}\n\nexport const isHotkeyMatch = (hotkey: string, keys: UseHotkeysKey[]) =>\n hotkey\n .toLowerCase()\n .split(/[+_-]/g)\n .map((key) => key.trim())\n .every((key) =>\n keys.find(\n (updatedKey) =>\n key === updatedKey.code.toLocaleLowerCase() ||\n key === updatedKey.key.toLocaleLowerCase() ||\n key === updatedKey.alias.toLocaleLowerCase()\n )\n );\n\nexport type UseHotkeysHotkeys = string[] | string;\nexport type UseHotkeysKey = { key: string; code: string; alias: string };\n\n/**\n * @name useHotkeys\n * @description - Hook that listens for hotkeys\n * @category Sensors\n *\n * @param {UseHotkeysHotkeys} hotkeys The key or keys to listen for\n * @param {(event: KeyboardEvent) => void} callback The callback function to be called when the hotkey is pressed\n * @param {UseEventListenerTarget} [options.target=window] The target to attach the event listeners to\n * @param {boolean} [options.enabled=true] Enable or disable the event listeners\n * @param {boolean} [options.preventDefault=true] Whether to prevent the default behavior of the event\n * @param {Record<string, string>} [options.aliasMap] Alias map for hotkeys\n * @returns {useKeysPressedReturns} Array of strings with keys that were press\n *\n * @example\n * useHotkeys('control+a', () => console.log('hotkey pressed'));\n *\n * @example\n * useHotkeys('ControlLeft+KeyA', () => console.log('hotkey pressed'));\n */\nexport const useHotkeys = (\n hotkeys: UseHotkeysHotkeys,\n callback: (event: KeyboardEvent) => void,\n options?: UseHotkeysOptions\n) => {\n const enabled = options?.enabled ?? true;\n const preventDefault = options?.preventDefault ?? true;\n const [, setKeys] = useState<UseHotkeysKey[]>([]);\n\n const onKeyDown = (event: KeyboardEvent) => {\n if (preventDefault) event.preventDefault();\n\n if (!enabled) return;\n\n setKeys((prevKeys) => {\n if (prevKeys.some(({ code }) => code === event.code)) return prevKeys;\n const alias = options?.aliasMap?.[event.key] ?? options?.aliasMap?.[event.key] ?? event.code;\n const updatedKeys = [...prevKeys, { key: event.key, code: event.code, alias }];\n\n if (Array.isArray(hotkeys)) {\n hotkeys.forEach((hotkey) => {\n const isMatch = isHotkeyMatch(hotkey, updatedKeys);\n if (isMatch) callback(event);\n });\n } else {\n const isMatch = isHotkeyMatch(hotkeys, updatedKeys);\n if (isMatch) callback(event);\n }\n\n return updatedKeys;\n });\n };\n\n const onKeyUp = (event: KeyboardEvent) => {\n if (!enabled) return;\n setKeys((prevKeys) => prevKeys.filter(({ code }) => code !== event.code));\n };\n\n useDidUpdate(() => {\n setKeys([]);\n }, [enabled]);\n\n useEventListener(options?.target ?? window, 'keydown', onKeyDown);\n useEventListener(options?.target ?? window, 'keyup', onKeyUp);\n};\n"],"names":["isHotkeyMatch","hotkey","keys","toLowerCase","split","map","key","trim","every","find","updatedKey","code","toLocaleLowerCase","alias","hotkeys","callback","options","_options$enabled","_options$preventDefau","_options$target","_options$target2","enabled","preventDefault","_useState","useState","setKeys","_slicedToArray","useDidUpdate","useEventListener","target","window","event","prevKeys","_ref2","_options$aliasMap$eve","_options$aliasMap","_options$aliasMap2","some","_ref","aliasMap","updatedKeys","concat","_toConsumableArray","Array","isArray","forEach","filter","_ref3"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useHotkeys.js","sources":["../../../../src/hooks/useHotkeys/useHotkeys.ts"],"sourcesContent":["import { useState } from 'react';\n\nimport { useDidUpdate } from '../useDidUpdate/useDidUpdate';\nimport type { UseEventListenerTarget } from '../useEventListener/useEventListener';\nimport { useEventListener } from '../useEventListener/useEventListener';\n\n/** The use hotkeys params type */\nexport interface UseHotkeysOptions {\n /** The target to attach the event listeners to */\n target?: UseEventListenerTarget;\n /** Enable or disable the event listeners */\n enabled?: boolean;\n /** Whether to prevent the default behavior of the event */\n preventDefault?: boolean;\n /** Alias map for hotkeys */\n aliasMap?: Record<string, string>;\n}\n\nexport const isHotkeyMatch = (hotkey: string, keys: UseHotkeysKey[]) =>\n hotkey\n .toLowerCase()\n .split(/[+_-]/g)\n .map((key) => key.trim())\n .every((key) =>\n keys.find(\n (updatedKey) =>\n key === updatedKey.code.toLocaleLowerCase() ||\n key === updatedKey.key.toLocaleLowerCase() ||\n key === updatedKey.alias.toLocaleLowerCase()\n )\n );\n\nexport type UseHotkeysHotkeys = string[] | string;\nexport type UseHotkeysKey = { key: string; code: string; alias: string };\n\n/**\n * @name useHotkeys\n * @description - Hook that listens for hotkeys\n * @category Sensors\n *\n * @param {UseHotkeysHotkeys} hotkeys The key or keys to listen for\n * @param {(event: KeyboardEvent) => void} callback The callback function to be called when the hotkey is pressed\n * @param {UseEventListenerTarget} [options.target=window] The target to attach the event listeners to\n * @param {boolean} [options.enabled=true] Enable or disable the event listeners\n * @param {boolean} [options.preventDefault=true] Whether to prevent the default behavior of the event\n * @param {Record<string, string>} [options.aliasMap] Alias map for hotkeys\n * @returns {useKeysPressedReturns} Array of strings with keys that were press\n *\n * @example\n * useHotkeys('control+a', () => console.log('hotkey pressed'));\n *\n * @example\n * useHotkeys('ControlLeft+KeyA', () => console.log('hotkey pressed'));\n */\nexport const useHotkeys = (\n hotkeys: UseHotkeysHotkeys,\n callback: (event: KeyboardEvent) => void,\n options?: UseHotkeysOptions\n) => {\n const enabled = options?.enabled ?? true;\n const preventDefault = options?.preventDefault ?? true;\n const [, setKeys] = useState<UseHotkeysKey[]>([]);\n\n const onKeyDown = (event: KeyboardEvent) => {\n if (preventDefault) event.preventDefault();\n\n if (!enabled) return;\n\n setKeys((prevKeys) => {\n if (prevKeys.some(({ code }) => code === event.code)) return prevKeys;\n const alias = options?.aliasMap?.[event.key] ?? options?.aliasMap?.[event.key] ?? event.code;\n const updatedKeys = [...prevKeys, { key: event.key, code: event.code, alias }];\n\n if (Array.isArray(hotkeys)) {\n hotkeys.forEach((hotkey) => {\n const isMatch = isHotkeyMatch(hotkey, updatedKeys);\n if (isMatch) callback(event);\n });\n } else {\n const isMatch = isHotkeyMatch(hotkeys, updatedKeys);\n if (isMatch) callback(event);\n }\n\n return updatedKeys;\n });\n };\n\n const onKeyUp = (event: KeyboardEvent) => {\n if (!enabled) return;\n setKeys((prevKeys) => prevKeys.filter(({ code }) => code !== event.code));\n };\n\n useDidUpdate(() => {\n setKeys([]);\n }, [enabled]);\n\n useEventListener(options?.target ?? window, 'keydown', onKeyDown);\n useEventListener(options?.target ?? window, 'keyup', onKeyUp);\n};\n"],"names":["isHotkeyMatch","hotkey","keys","toLowerCase","split","map","key","trim","every","find","updatedKey","code","toLocaleLowerCase","alias","hotkeys","callback","options","_options$enabled","_options$preventDefau","_options$target","_options$target2","enabled","preventDefault","_useState","useState","setKeys","_slicedToArray","useDidUpdate","useEventListener","target","window","event","prevKeys","_ref2","_options$aliasMap$eve","_options$aliasMap","_options$aliasMap2","some","_ref","aliasMap","updatedKeys","concat","_toConsumableArray","Array","isArray","forEach","filter","_ref3"],"mappings":";+XAkBO,IAAMA,EAAgB,SAACC,EAAgBC,GAAqB,OACjED,EACGE,cACAC,MAAM,UACNC,KAAI,SAACC,GAAG,OAAKA,EAAIC,MAAM,IACvBC,OAAM,SAACF,GAAG,OACTJ,EAAKO,MACH,SAACC,GAAU,OACTJ,IAAQI,EAAWC,KAAKC,qBACxBN,IAAQI,EAAWJ,IAAIM,qBACvBN,IAAQI,EAAWG,MAAMD,mBAAmB,GAC/C,GACF,6CAwBqB,SACxBE,EACAC,EACAC,GACG,IAAAC,EAAAC,EAAAC,EAAAC,EACGC,EAA0BJ,QAAnBA,EAAGD,aAAO,EAAPA,EAASK,eAAOJ,IAAAA,GAAAA,EAC1BK,EAAwCJ,QAA1BA,EAAGF,aAAO,EAAPA,EAASM,sBAAcJ,IAAAA,GAAAA,EAC9CK,EAAoBC,EAAQA,SAAkB,IAArCC,EAAwCC,EAAAA,eAAAH,EAAA,GAAjC,GA+BhBI,EAAAA,cAAa,WACXF,EAAQ,GACV,GAAG,CAACJ,IAEJO,2BAAgBT,EAACH,aAAO,EAAPA,EAASa,cAAM,IAAAV,EAAAA,EAAIW,OAAQ,WAjC1B,SAACC,GACbT,GAAgBS,EAAMT,iBAErBD,GAELI,GAAQ,SAACO,GAAa,IAAAC,EAAAC,EAAAC,EAAAC,EACpB,GAAIJ,EAASK,MAAK,SAAAC,GAAO,OAAAA,EAAJ3B,OAAoBoB,EAAMpB,QAAO,OAAOqB,EAC7D,IAAMnB,EAAwE,QAAnEoB,EAAiC,QAAjCC,EAAGlB,SAAiBmB,QAAVA,EAAPnB,EAASuB,gBAATJ,IAAiBA,OAAjBA,EAAAA,EAAoBJ,EAAMzB,YAAI,IAAA4B,EAAAA,EAAIlB,SAAiB,QAAVoB,EAAPpB,EAASuB,gBAAQ,IAAAH,OAAA,EAAjBA,EAAoBL,EAAMzB,YAAI,IAAA2B,EAAAA,EAAIF,EAAMpB,KAClF6B,EAAWC,GAAAA,OAAAC,EAAAA,mBAAOV,GAAU,CAAA,CAAE1B,IAAKyB,EAAMzB,IAAKK,KAAMoB,EAAMpB,KAAME,MAAAA,KAElE8B,MAAMC,QAAQ9B,GAChBA,EAAQ+B,SAAQ,SAAC5C,GACCD,EAAcC,EAAQuC,IACzBzB,EAASgB,EACxB,IAEgB/B,EAAcc,EAAS0B,IAC1BzB,EAASgB,GAGxB,OAAOS,CACT,OAaFZ,2BAAgBR,EAACJ,aAAO,EAAPA,EAASa,cAAM,IAAAT,EAAAA,EAAIU,OAAQ,SAV5B,SAACC,GACVV,GACLI,GAAQ,SAACO,GAAQ,OAAKA,EAASc,QAAO,SAAAC,GAAO,OAAAA,EAAJpC,OAAoBoB,EAAMpB,aASvE"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
"use strict";var e=require("../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.60 */
|
|
2
|
+
"use strict";var e=require("../../_rollupPluginBabelHelpers-DaULt_UR.js"),n=require("react"),t=require("../useEventListener/useEventListener.js");require("../../utils/helpers/getElement.js"),require("../../utils/helpers/isClient.js"),require("../useEvent/useEvent.js");exports.useHover=function(){var l=(arguments.length<=0?void 0:arguments[0])instanceof Function||!("current"in(arguments.length<=0?void 0:arguments[0])||(arguments.length<=0?void 0:arguments[0])instanceof Element)||arguments.length<=0?void 0:arguments[0],r=l?"object"===e._typeof(arguments.length<=1?void 0:arguments[1])?arguments.length<=1?void 0:arguments[1]:{onEntry:arguments.length<=1?void 0:arguments[1]}:"object"===e._typeof(arguments.length<=0?void 0:arguments[0])?arguments.length<=0?void 0:arguments[0]:{onEntry:arguments.length<=0?void 0:arguments[0]},i=n.useState(!1),u=e._slicedToArray(i,2),o=u[0],s=u[1],v=n.useRef();return t.useEventListener(null!=l?l:v,"mouseenter",(function(){var e;null==r||null===(e=r.onEntry)||void 0===e||e.call(r),s(!0)})),t.useEventListener(null!=l?l:v,"mouseleave",(function(){var e;null==r||null===(e=r.onLeave)||void 0===e||e.call(r),s(!1)})),l?o:[v,o]};
|
|
3
3
|
//# sourceMappingURL=useHover.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useHover.js","sources":["../../../../src/hooks/useHover/useHover.ts"],"sourcesContent":["import type { RefObject } from 'react';\nimport { useRef, useState } from 'react';\n\nimport { useEventListener } from '../useEventListener/useEventListener';\n\n//* The use hover options type */\nexport interface UseHoverOptions {\n //* The on entry callback */\n onEntry?: () => void;\n //* The on leave callback */\n onLeave?: () => void;\n}\n\n//* The use hover target type */\nexport type UseHoverTarget = RefObject<Element | null | undefined> | Element;\n\nexport type UseHover = {\n <Target extends UseHoverTarget>(target: Target, callback?: () => void): boolean;\n\n <Target extends UseHoverTarget>(target: Target, options?: UseHoverOptions): boolean;\n\n <Target extends UseHoverTarget>(\n callback?: () => void,\n target?: never\n ): [RefObject<Target>, boolean];\n\n <Target extends UseHoverTarget>(\n options?: UseHoverOptions,\n target?: never\n ): [RefObject<Target>, boolean];\n};\n\n/**\n * @name useHover\n * @description - Hook that defines the logic when hovering an element\n * @category Sensors\n *\n * @overload\n * @template Target The target element\n * @param {Target} target The target element to be hovered\n * @param {() => void} [callback] The callback function to be invoked on mouse enter\n * @returns {boolean} The state of the hover\n *\n * @example\n * const hovering = useHover(ref, () => console.log('callback'));\n *\n * @overload\n * @template Target The target element\n * @param {Target} target The target element to be hovered\n * @param {() => void} [options.onEntry] The callback function to be invoked on mouse enter\n * @param {() => void} [options.onLeave] The callback function to be invoked on mouse leave\n * @returns {boolean} The state of the hover\n *\n * @example\n * const hovering = useHover(ref, {\n * onEntry: () => console.log('onEntry'),\n * onLeave: () => console.log('onLeave'),\n * });\n *\n * @overload\n * @template Target The target element\n * @param {() => void} [callback] The callback function to be invoked on mouse enter\n * @returns {UseHoverReturn<Target>} The state of the hover\n *\n * @example\n * const [ref, hovering] = useHover(() => console.log('callback'));\n *\n * @overload\n * @template Target The target element\n * @param {() => void} [options.onEntry] The callback function to be invoked on mouse enter\n * @param {() => void} [options.onLeave] The callback function to be invoked on mouse leave\n * @returns {UseHoverReturn<Target>} The state of the hover\n *\n * @example\n * const [ref, hovering] = useHover({\n * onEntry: () => console.log('onEntry'),\n * onLeave: () => console.log('onLeave'),\n * });\n */\nexport const useHover = ((...params: any[]) => {\n const target = (\n params[0] instanceof Function || !('current' in params[0] || params[0] instanceof Element)\n ? undefined\n : params[0]\n ) as UseHoverTarget | undefined;\n\n const options = (\n target\n ? typeof params[1] === 'object'\n ? params[1]\n : { onEntry: params[1] }\n : typeof params[0] === 'object'\n ? params[0]\n : { onEntry: params[0] }\n ) as UseHoverOptions | undefined;\n\n const [hovering, setHovering] = useState(false);\n const internalRef = useRef<Element>();\n\n const onMouseEnter = () => {\n options?.onEntry?.();\n setHovering(true);\n };\n\n const onMouseLeave = () => {\n options?.onLeave?.();\n setHovering(false);\n };\n\n useEventListener(target ?? internalRef, 'mouseenter', onMouseEnter);\n useEventListener(target ?? internalRef, 'mouseleave', onMouseLeave);\n\n if (target) return hovering;\n return [internalRef, hovering] as const;\n}) as UseHover;\n"],"names":["target","arguments","length","undefined","Function","Element","options","_typeof","onEntry","_useState","useState","_useState2","_slicedToArray","hovering","setHovering","internalRef","useRef","useEventListener","_options$onEntry","call","_options$onLeave","onLeave"],"mappings":";
|
|
1
|
+
{"version":3,"file":"useHover.js","sources":["../../../../src/hooks/useHover/useHover.ts"],"sourcesContent":["import type { RefObject } from 'react';\nimport { useRef, useState } from 'react';\n\nimport { useEventListener } from '../useEventListener/useEventListener';\n\n//* The use hover options type */\nexport interface UseHoverOptions {\n //* The on entry callback */\n onEntry?: () => void;\n //* The on leave callback */\n onLeave?: () => void;\n}\n\n//* The use hover target type */\nexport type UseHoverTarget = RefObject<Element | null | undefined> | Element;\n\nexport type UseHover = {\n <Target extends UseHoverTarget>(target: Target, callback?: () => void): boolean;\n\n <Target extends UseHoverTarget>(target: Target, options?: UseHoverOptions): boolean;\n\n <Target extends UseHoverTarget>(\n callback?: () => void,\n target?: never\n ): [RefObject<Target>, boolean];\n\n <Target extends UseHoverTarget>(\n options?: UseHoverOptions,\n target?: never\n ): [RefObject<Target>, boolean];\n};\n\n/**\n * @name useHover\n * @description - Hook that defines the logic when hovering an element\n * @category Sensors\n *\n * @overload\n * @template Target The target element\n * @param {Target} target The target element to be hovered\n * @param {() => void} [callback] The callback function to be invoked on mouse enter\n * @returns {boolean} The state of the hover\n *\n * @example\n * const hovering = useHover(ref, () => console.log('callback'));\n *\n * @overload\n * @template Target The target element\n * @param {Target} target The target element to be hovered\n * @param {() => void} [options.onEntry] The callback function to be invoked on mouse enter\n * @param {() => void} [options.onLeave] The callback function to be invoked on mouse leave\n * @returns {boolean} The state of the hover\n *\n * @example\n * const hovering = useHover(ref, {\n * onEntry: () => console.log('onEntry'),\n * onLeave: () => console.log('onLeave'),\n * });\n *\n * @overload\n * @template Target The target element\n * @param {() => void} [callback] The callback function to be invoked on mouse enter\n * @returns {UseHoverReturn<Target>} The state of the hover\n *\n * @example\n * const [ref, hovering] = useHover(() => console.log('callback'));\n *\n * @overload\n * @template Target The target element\n * @param {() => void} [options.onEntry] The callback function to be invoked on mouse enter\n * @param {() => void} [options.onLeave] The callback function to be invoked on mouse leave\n * @returns {UseHoverReturn<Target>} The state of the hover\n *\n * @example\n * const [ref, hovering] = useHover({\n * onEntry: () => console.log('onEntry'),\n * onLeave: () => console.log('onLeave'),\n * });\n */\nexport const useHover = ((...params: any[]) => {\n const target = (\n params[0] instanceof Function || !('current' in params[0] || params[0] instanceof Element)\n ? undefined\n : params[0]\n ) as UseHoverTarget | undefined;\n\n const options = (\n target\n ? typeof params[1] === 'object'\n ? params[1]\n : { onEntry: params[1] }\n : typeof params[0] === 'object'\n ? params[0]\n : { onEntry: params[0] }\n ) as UseHoverOptions | undefined;\n\n const [hovering, setHovering] = useState(false);\n const internalRef = useRef<Element>();\n\n const onMouseEnter = () => {\n options?.onEntry?.();\n setHovering(true);\n };\n\n const onMouseLeave = () => {\n options?.onLeave?.();\n setHovering(false);\n };\n\n useEventListener(target ?? internalRef, 'mouseenter', onMouseEnter);\n useEventListener(target ?? internalRef, 'mouseleave', onMouseLeave);\n\n if (target) return hovering;\n return [internalRef, hovering] as const;\n}) as UseHover;\n"],"names":["target","arguments","length","undefined","Function","Element","options","_typeof","onEntry","_useState","useState","_useState2","_slicedToArray","hovering","setHovering","internalRef","useRef","useEventListener","_options$onEntry","call","_options$onLeave","onLeave"],"mappings":";8RA+EyB,WACvB,IAAMA,GACJC,UAAAC,QAAA,OAAAC,EAAAF,wBAAqBG,YAAc,YAASH,UAAAC,QAAAC,OAAAA,EAAAF,gBAAiBA,UAAAC,eAAAC,EAAAF,UAAqBI,cAAAA,UACrEJ,UAAAC,QAAAC,OAATA,EAASF,UAEgB,GAEzBK,EACJN,EACyB,WAArBO,EAAAA,QAAAN,UAAAC,QAAAC,OAAAA,EAAAF,UAAA,IAA6BA,UAAAC,QAAAC,OAAAA,EAAAF,UAE3B,GAAA,CAAEO,QAAOP,UAAAC,QAAAC,OAAAA,EAAAF,UAAA,IACU,WAArBM,EAAAA,QAAAN,UAAAC,QAAA,OAAAC,EAAAF,cAA6BA,UAAAC,eAAAC,EAAAF,UAE3B,GAAA,CAAEO,QAAOP,UAAAC,QAAAC,OAAAA,EAAAF,UAAA,IAGjBQ,EAAgCC,EAAQA,UAAC,GAAMC,EAAAC,EAAAA,eAAAH,EAAA,GAAxCI,EAAQF,EAAA,GAAEG,EAAWH,EAAA,GACtBI,EAAcC,EAAAA,SAepB,OAHAC,mBAAiBjB,QAAAA,EAAUe,EAAa,cAVnB,WAAM,IAAAG,EACzBZ,SAAgBY,QAATA,EAAPZ,EAASE,mBAAOU,GAAhBA,EAAAC,KAAAb,GACAQ,GAAY,MASdG,mBAAiBjB,QAAAA,EAAUe,EAAa,cANnB,WAAM,IAAAK,EACzBd,SAAgBc,QAATA,EAAPd,EAASe,mBAAOD,GAAhBA,EAAAD,KAAAb,GACAQ,GAAY,MAMVd,EAAea,EACZ,CAACE,EAAaF,EACvB"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
"use strict";var e=require("../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.60 */
|
|
2
|
+
"use strict";var e=require("../../_rollupPluginBabelHelpers-DaULt_UR.js"),t=require("react");require("../../utils/helpers/isClient.js");var i=require("../../utils/helpers/throttle.js"),n=["mousemove","mousedown","keydown","touchstart","wheel","resize"];exports.useIdle=function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:6e4,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},u=o.initialValue,s=void 0!==u&&u,l=o.events,a=void 0===l?n:l,c=t.useState(s),d=e._slicedToArray(c,2),v=d[0],h=d[1],f=t.useState(Date.now()),m=e._slicedToArray(f,2),w=m[0],E=m[1];return t.useEffect((function(){var e,t=function(){return h(!0)},n=i.throttle((function(){h(!1),E(Date.now()),clearTimeout(e),e=setTimeout(t,r)}),500),o=function(){document.hidden||n()};return e=setTimeout(t,r),a.forEach((function(e){return window.addEventListener(e,n)})),document.addEventListener("visibilitychange",o),function(){a.forEach((function(e){return window.addEventListener(e,n)})),document.removeEventListener("visibilitychange",o),clearTimeout(e)}}),[r,a]),{idle:v,lastActive:w}};
|
|
3
3
|
//# sourceMappingURL=useIdle.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIdle.js","sources":["../../../../src/hooks/useIdle/useIdle.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nimport { throttle } from '@/utils/helpers';\n\
|
|
1
|
+
{"version":3,"file":"useIdle.js","sources":["../../../../src/hooks/useIdle/useIdle.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nimport { throttle } from '@/utils/helpers';\n\n//* The use idle options type */\nexport interface UseIdleOptions {\n //* The idle state */\n initialValue?: boolean;\n //* The idle events */\n events?: Array<keyof DocumentEventMap>;\n}\n\nconst IDLE_EVENTS = [\n 'mousemove',\n 'mousedown',\n 'keydown',\n 'touchstart',\n 'wheel',\n 'resize'\n] satisfies Array<keyof DocumentEventMap>;\nconst ONE_MINUTE = 60e3;\n\n//* The use idle return type */\nexport interface UseIdleReturn {\n //* The idle state */\n idle: boolean;\n //* The last active time */\n lastActive: number;\n}\n\n/**\n * @name useIdle\n * @description - Hook that defines the logic when the user is idle\n * @category Sensors\n *\n * @param {number} [milliseconds=ONE_MINUTE] The idle time in milliseconds\n * @param {boolean} [options.initialState=false] The options for the hook\n * @param {Array<keyof WindowEventMap>} [options.events=IDLE_EVENTS]\n * @returns {UseIdleReturn} An object containing the idle state and the last active time\n *\n * @example\n * const { idle, lastActive } = useIdle();\n */\nexport const useIdle = (\n milliseconds = ONE_MINUTE,\n { initialValue = false, events = IDLE_EVENTS }: UseIdleOptions = {}\n): UseIdleReturn => {\n const [idle, setIdle] = useState(initialValue);\n const [lastActive, setLastActive] = useState(Date.now());\n\n useEffect(() => {\n let timeoutId: ReturnType<typeof setTimeout>;\n const onTimeout = () => setIdle(true);\n\n const onEvent = throttle(() => {\n setIdle(false);\n setLastActive(Date.now());\n clearTimeout(timeoutId);\n timeoutId = setTimeout(onTimeout, milliseconds);\n }, 500);\n\n const onVisibilitychange = () => {\n if (!document.hidden) onEvent();\n };\n\n timeoutId = setTimeout(onTimeout, milliseconds);\n\n events.forEach((event) => window.addEventListener(event, onEvent));\n document.addEventListener('visibilitychange', onVisibilitychange);\n\n return () => {\n events.forEach((event) => window.addEventListener(event, onEvent));\n document.removeEventListener('visibilitychange', onVisibilitychange);\n clearTimeout(timeoutId);\n };\n }, [milliseconds, events]);\n\n return { idle, lastActive };\n};\n"],"names":["IDLE_EVENTS","milliseconds","arguments","length","undefined","_ref","_ref$initialValue","initialValue","_ref$events","events","_useState","useState","_useState2","_slicedToArray","idle","setIdle","_useState3","Date","now","_useState4","lastActive","setLastActive","useEffect","timeoutId","onTimeout","onEvent","throttle","clearTimeout","setTimeout","onVisibilitychange","document","hidden","forEach","event","window","addEventListener","removeEventListener"],"mappings":";yLAYMA,EAAc,CAClB,YACA,YACA,UACA,aACA,QACA,0BAyBqB,WAGH,IAFlBC,EAAYC,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,GAxBK,IAwBQG,EAAAH,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,GACwC,CAAE,EAAAI,EAAAD,EAAjEE,aAAAA,OAAe,IAAHD,GAAQA,EAAAE,EAAAH,EAAEI,OAAAA,OAAST,IAAHQ,EAAGR,EAAWQ,EAE5CE,EAAwBC,EAAQA,SAACJ,GAAaK,EAAAC,EAAAA,eAAAH,EAAA,GAAvCI,EAAIF,EAAA,GAAEG,EAAOH,EAAA,GACpBI,EAAoCL,EAAAA,SAASM,KAAKC,OAAMC,EAAAN,EAAAA,eAAAG,EAAA,GAAjDI,EAAUD,EAAA,GAAEE,EAAaF,EAAA,GA6BhC,OA3BAG,EAAAA,WAAU,WACR,IAAIC,EACEC,EAAY,WAAH,OAAST,GAAQ,EAAK,EAE/BU,EAAUC,EAAAA,UAAS,WACvBX,GAAQ,GACRM,EAAcJ,KAAKC,OACnBS,aAAaJ,GACbA,EAAYK,WAAWJ,EAAWvB,EACnC,GAAE,KAEG4B,EAAqB,WACpBC,SAASC,QAAQN,KAQxB,OALAF,EAAYK,WAAWJ,EAAWvB,GAElCQ,EAAOuB,SAAQ,SAACC,GAAK,OAAKC,OAAOC,iBAAiBF,EAAOR,MACzDK,SAASK,iBAAiB,mBAAoBN,GAEvC,WACLpB,EAAOuB,SAAQ,SAACC,GAAK,OAAKC,OAAOC,iBAAiBF,EAAOR,MACzDK,SAASM,oBAAoB,mBAAoBP,GACjDF,aAAaJ,GAEjB,GAAG,CAACtB,EAAcQ,IAEX,CAAEK,KAAAA,EAAMM,WAAAA,EACjB"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
"use strict";var e=require("../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.60 */
|
|
2
|
+
"use strict";var e=require("../../_rollupPluginBabelHelpers-DaULt_UR.js"),r=require("../useQuery/useQuery.js");require("react"),require("../../utils/helpers/getRetry.js"),require("../../utils/helpers/isClient.js"),require("../useDidUpdate/useDidUpdate.js"),require("../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js"),require("../useMount/useMount.js");var s=function(){var r=e._asyncToGenerator(e._regeneratorRuntime().mark((function r(s){var u,t=arguments;return e._regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return u=t.length>1&&void 0!==t[1]?t[1]:{},e.abrupt("return",new Promise((function(e,r){var t=new Image,n=u.srcset,i=u.sizes,o=u.class,a=u.loading,c=u.crossorigin,l=u.referrerPolicy;t.src=s,n&&(t.srcset=n),i&&(t.sizes=i),o&&(t.className=o),a&&(t.loading=a),c&&(t.crossOrigin=c),l&&(t.referrerPolicy=l),t.onload=function(){return e(t)},t.onerror=r})));case 2:case"end":return e.stop()}}),r)})));return function(e){return r.apply(this,arguments)}}();exports.useImage=function(u,t){var n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return r.useQuery((function(){return s(u,t)}),e._objectSpread2({keys:[u].concat(e._toConsumableArray(null!==(n=i.keys)&&void 0!==n?n:[]))},i))};
|
|
3
3
|
//# sourceMappingURL=useImage.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
"use strict";var e=require("../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.60 */
|
|
2
|
+
"use strict";var e=require("../../_rollupPluginBabelHelpers-DaULt_UR.js"),r=require("react"),t=require("../useEvent/useEvent.js");exports.useInfiniteScroll=function(){for(var n,i,o=arguments.length,u=new Array(o),c=0;c<o;c++)u[c]=arguments[c];var s=u[1]instanceof Function?u[0]:void 0,a=u[1]instanceof Function?u[1]:u[0],l=u[1]instanceof Function?u[2]:u[1],f=null!==(n=null==l?void 0:l.direction)&&void 0!==n?n:"bottom",v=null!==(i=null==l?void 0:l.distance)&&void 0!==i?i:10,d=r.useState(!1),p=e._slicedToArray(d,2),g=p[0],h=p[1],m=r.useState(),E=e._slicedToArray(m,2),b=E[0],y=E[1],_=r.useRef(a);_.current=a;var x=t.useEvent(function(){var r=e._asyncToGenerator(e._regeneratorRuntime().mark((function r(t){var n,i,o,u,c,s,a;return e._regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!g){e.next=2;break}return e.abrupt("return");case 2:if(n=t.target,i=n.clientHeight,o=n.scrollHeight,u=n.scrollTop,c=n.clientWidth,s=n.scrollWidth,a=n.scrollLeft,!({bottom:o-(u+i),top:u,right:s-(a+c),left:a}[f]<=v)){e.next=11;break}return h(!0),e.next=10,_.current(t);case 10:h(!1);case 11:case"end":return e.stop()}}),r)})));return function(e){return r.apply(this,arguments)}}());return r.useEffect((function(){if(s||b){var e=s?function(e){return"function"==typeof e?e():e instanceof Element?e:e.current}(s):b;if(e)return e.addEventListener("scroll",x),function(){e.removeEventListener("scroll",x)}}}),[b,s,f,v]),s?g:{ref:y,isLoading:g}};
|
|
3
3
|
//# sourceMappingURL=useInfiniteScroll.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useInfiniteScroll.js","sources":["../../../../src/hooks/useInfiniteScroll/useInfiniteScroll.ts"],"sourcesContent":["import type { RefObject } from 'react';\nimport { useEffect, useRef, useState } from 'react';\n\nimport { useEvent } from '../useEvent/useEvent';\
|
|
1
|
+
{"version":3,"file":"useInfiniteScroll.js","sources":["../../../../src/hooks/useInfiniteScroll/useInfiniteScroll.ts"],"sourcesContent":["import type { RefObject } from 'react';\nimport { useEffect, useRef, useState } from 'react';\n\nimport { useEvent } from '../useEvent/useEvent';\n\n/** The use infinite scroll target element type */\nexport type UseInfiniteScrollTarget = RefObject<Element | null> | (() => Element) | Element;\n\nconst getElement = (target: UseInfiniteScrollTarget) => {\n if (typeof target === 'function') {\n return target();\n }\n\n if (target instanceof Element) {\n return target;\n }\n\n return target.current;\n};\n\n/** The use infinite scroll options type */\nexport interface UseInfiniteScrollOptions {\n /** The distance in pixels to trigger the callback */\n distance?: number;\n /** The direction to trigger the callback */\n direction?: 'top' | 'bottom' | 'left' | 'right';\n}\n\nexport type UseInfiniteScroll = {\n <Target extends UseInfiniteScrollTarget>(\n target: Target,\n callback: (event: Event) => void,\n options?: UseInfiniteScrollOptions\n ): boolean;\n\n <Target extends UseInfiniteScrollTarget>(\n callback: (event: Event) => void,\n options?: UseInfiniteScrollOptions,\n target?: never\n ): {\n ref: (node: Target) => void;\n isLoading: boolean;\n };\n};\n\n/**\n * @name useInfiniteScroll\n * @description - Hook that defines the logic for infinite scroll\n * @category Sensors\n *\n * @overload\n * @template Target The target element\n * @param {(event: Event) => void} callback The callback to execute when a click outside the target is detected\n * @param {number} [options.distance=10] The distance in pixels to trigger the callback\n * @param {string} [options.direction='bottom'] The direction to trigger the callback\n * @returns {{ ref: (node: Target) => void; isLoading: boolean }} An object containing the ref and isLoading\n *\n * @example\n * const { ref, isLoading } = useInfiniteScroll(() => console.log('infinite scroll'));\n *\n * @overload\n * @template Target The target element\n * @param {Target} target The target element to detect infinite scroll for\n * @param {(event: Event) => void} callback The callback to execute when a click outside the target is detected\n * @param {number} [options.distance=10] The distance in pixels to trigger the callback\n * @param {string} [options.direction='bottom'] The direction to trigger the callback\n * @returns {boolean} A loading indicator of the infinite scroll\n *\n * @example\n * const isLoading = useInfiniteScroll(ref, () => console.log('infinite scroll'));\n */\nexport const useInfiniteScroll = ((...params) => {\n const target = params[1] instanceof Function ? (params[0] as UseInfiniteScrollTarget) : undefined;\n const callback = params[1] instanceof Function ? params[1] : (params[0] as () => void);\n const options = (\n params[1] instanceof Function ? params[2] : params[1]\n ) as UseInfiniteScrollOptions;\n\n const direction = options?.direction ?? 'bottom';\n const distance = options?.distance ?? 10;\n\n const [isLoading, setIsLoading] = useState(false);\n const [internalRef, setInternalRef] = useState<Element>();\n const internalCallbackRef = useRef(callback);\n internalCallbackRef.current = callback;\n\n const onLoadMore = useEvent(async (event: Event) => {\n if (isLoading) return;\n const { clientHeight, scrollHeight, scrollTop, clientWidth, scrollWidth, scrollLeft } =\n event.target as Element;\n const scrollBottom = scrollHeight - (scrollTop + clientHeight);\n const scrollRight = scrollWidth - (scrollLeft + clientWidth);\n\n const distances = {\n bottom: scrollBottom,\n top: scrollTop,\n right: scrollRight,\n left: scrollLeft\n };\n\n if (distances[direction] <= distance) {\n setIsLoading(true);\n await internalCallbackRef.current(event);\n setIsLoading(false);\n }\n });\n\n useEffect(() => {\n if (!target && !internalRef) return;\n const element = target ? getElement(target) : internalRef;\n if (!element) return;\n\n element.addEventListener('scroll', onLoadMore);\n\n return () => {\n element.removeEventListener('scroll', onLoadMore);\n };\n }, [internalRef, target, direction, distance]);\n\n if (target) return isLoading;\n return {\n ref: setInternalRef,\n isLoading\n };\n}) as UseInfiniteScroll;\n"],"names":["_options$direction","_options$distance","_len","arguments","length","params","Array","_key","target","Function","undefined","callback","options","direction","distance","_useState","useState","_useState2","_slicedToArray","isLoading","setIsLoading","_useState3","_useState4","internalRef","setInternalRef","internalCallbackRef","useRef","current","onLoadMore","useEvent","_ref","_asyncToGenerator","_regeneratorRuntime","mark","_callee","event","_ref2","clientHeight","scrollHeight","scrollTop","clientWidth","scrollWidth","scrollLeft","wrap","_context","prev","next","abrupt","bottom","top","right","left","stop","_x","apply","this","useEffect","element","Element","getElement","addEventListener","removeEventListener","ref"],"mappings":";4JAuEkC,WAAe,IAAA,IAAAA,EAAAC,EAAAC,EAAAC,UAAAC,OAAXC,EAAMC,IAAAA,MAAAJ,GAAAK,EAAA,EAAAA,EAAAL,EAAAK,IAANF,EAAME,GAAAJ,UAAAI,GAC1C,IAAMC,EAASH,EAAO,aAAcI,SAAYJ,EAAO,QAAiCK,EAClFC,EAAWN,EAAO,aAAcI,SAAWJ,EAAO,GAAMA,EAAO,GAC/DO,EACJP,EAAO,aAAcI,SAAWJ,EAAO,GAAKA,EAAO,GAG/CQ,EAA8Bb,QAArBA,EAAGY,aAAO,EAAPA,EAASC,iBAASb,IAAAA,EAAAA,EAAI,SAClCc,EAA4Bb,QAApBA,EAAGW,aAAO,EAAPA,EAASE,gBAAQb,IAAAA,EAAAA,EAAI,GAEtCc,EAAkCC,EAAQA,UAAC,GAAMC,EAAAC,EAAAA,eAAAH,EAAA,GAA1CI,EAASF,EAAA,GAAEG,EAAYH,EAAA,GAC9BI,EAAsCL,EAAAA,WAAmBM,EAAAJ,EAAAA,eAAAG,EAAA,GAAlDE,EAAWD,EAAA,GAAEE,EAAcF,EAAA,GAC5BG,EAAsBC,SAAOf,GACnCc,EAAoBE,QAAUhB,EAE9B,IAAMiB,EAAaC,EAAAA,SAAQ,WAAA,IAAAC,EAAAC,EAAAA,kBAAAC,EAAAA,sBAAAC,MAAC,SAAAC,EAAOC,GAAY,IAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAA,OAAAV,EAAAA,sBAAAW,MAAA,SAAAC,GAAA,cAAAA,EAAAC,KAAAD,EAAAE,MAAA,KAAA,EAAA,IACzC3B,EAAS,CAAAyB,EAAAE,KAAA,EAAA,KAAA,CAAA,OAAAF,EAAAG,OAAA,UAAA,KAAA,EAWZ,GAXYX,EAEXD,EAAM3B,OADA6B,EAAYD,EAAZC,aAAcC,EAAYF,EAAZE,aAAcC,EAASH,EAATG,UAAWC,EAAWJ,EAAXI,YAAaC,EAAWL,EAAXK,YAAaC,EAAUN,EAAVM,aAKvD,CAChBM,OAJmBV,GAAgBC,EAAYF,GAK/CY,IAAKV,EACLW,MALkBT,GAAeC,EAAaF,GAM9CW,KAAMT,GAGM7B,IAAcC,GAAQ,CAAA8B,EAAAE,KAAA,GAAA,KAAA,CACf,OAAnB1B,GAAa,GAAMwB,EAAAE,KAAA,GACbrB,EAAoBE,QAAQQ,GAAM,KAAA,GACxCf,GAAa,GAAO,KAAA,GAAA,IAAA,MAAA,OAAAwB,EAAAQ,OAAA,GAAAlB,EAEvB,KAAA,OAAA,SAAAmB,GAAA,OAAAvB,EAAAwB,MAAAC,KAAApD,UAAA,CAAC,CAnByB,IAiC3B,OAZAqD,EAAAA,WAAU,WACR,GAAKhD,GAAWe,EAAhB,CACA,IAAMkC,EAAUjD,EArGD,SAACA,GAClB,MAAsB,mBAAXA,EACFA,IAGLA,aAAkBkD,QACblD,EAGFA,EAAOmB,OAChB,CA2F6BgC,CAAWnD,GAAUe,EAC9C,GAAKkC,EAIL,OAFAA,EAAQG,iBAAiB,SAAUhC,GAE5B,WACL6B,EAAQI,oBAAoB,SAAUjC,GAPX,CAS9B,GAAE,CAACL,EAAaf,EAAQK,EAAWC,IAEhCN,EAAeW,EACZ,CACL2C,IAAKtC,EACLL,UAAAA,EAEJ"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
"use strict";var e=require("../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.60 */
|
|
2
|
+
"use strict";var e=require("../../_rollupPluginBabelHelpers-DaULt_UR.js"),r=require("react"),n=require("../../utils/helpers/getElement.js");require("../../utils/helpers/isClient.js");exports.useIntersectionObserver=function(){var t,l="object"!==e._typeof(arguments.length<=0?void 0:arguments[0])||"current"in(arguments.length<=0?void 0:arguments[0])?arguments.length<=0?void 0:arguments[0]:void 0,i=l?arguments.length<=1?void 0:arguments[1]:arguments.length<=0?void 0:arguments[0],o=null===(t=null==i?void 0:i.enabled)||void 0===t||t,u=r.useState(),s=e._slicedToArray(u,2),c=s[0],d=s[1],v=r.useState(),a=e._slicedToArray(v,2),g=a[0],f=a[1],h=r.useRef();return h.current=null==i?void 0:i.onChange,r.useEffect((function(){if(o&&g){var r=l?n.getElement(l):g;if(r){var t=new IntersectionObserver((function(r){var n,t=e._slicedToArray(r,1)[0];d(t),null===(n=h.current)||void 0===n||n.call(h,t)}),e._objectSpread2(e._objectSpread2({},i),{},{root:null!=i&&i.root?n.getElement(null==i?void 0:i.root):document}));return t.observe(r),function(){t.disconnect()}}}}),[l,g,null==i?void 0:i.rootMargin,null==i?void 0:i.threshold,null==i?void 0:i.root,o]),l?{entry:c,inView:!(null==c||!c.isIntersecting)}:{ref:f,entry:c,inView:!(null==c||!c.isIntersecting)}};
|
|
3
3
|
//# sourceMappingURL=useIntersectionObserver.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIntersectionObserver.js","sources":["../../../../src/hooks/useIntersectionObserver/useIntersectionObserver.ts"],"sourcesContent":["import type { RefObject } from 'react';\nimport { useEffect, useRef, useState } from 'react';\n\nimport {
|
|
1
|
+
{"version":3,"file":"useIntersectionObserver.js","sources":["../../../../src/hooks/useIntersectionObserver/useIntersectionObserver.ts"],"sourcesContent":["import type { RefObject } from 'react';\nimport { useEffect, useRef, useState } from 'react';\n\nimport { getElement } from '@/utils/helpers';\n\n/** The intersection observer target element type */\nexport type UseIntersectionObserverTarget =\n | RefObject<Element | null | undefined>\n | (() => Element)\n | Element;\n\n/** The intersection observer options type */\nexport interface UseIntersectionObserverOptions extends Omit<IntersectionObserverInit, 'root'> {\n enabled?: boolean;\n onChange?: (entry: IntersectionObserverEntry) => void;\n root?: IntersectionObserverInit['root'] | RefObject<Element | null | undefined>;\n}\n\n/** The intersection observer return type */\nexport interface UseIntersectionObserverReturn {\n inView: boolean;\n entry?: IntersectionObserverEntry;\n}\n\nexport type UseIntersectionObserver = {\n <Target extends UseIntersectionObserverTarget>(\n target: Target,\n options?: UseIntersectionObserverOptions\n ): UseIntersectionObserverReturn;\n\n <Target extends UseIntersectionObserverTarget>(\n options?: UseIntersectionObserverOptions,\n target?: never\n ): UseIntersectionObserverReturn & { ref: (node: Target) => void };\n};\n\n/**\n * @name useIntersectionObserver\n * @description - Hook that gives you intersection observer state\n * @category Browser\n *\n * @overload\n * @template Target The target element\n * @param {Target} target The target element to detect intersection\n * @param {boolean} [options.enabled=true] The IntersectionObserver options\n * @param {((entries: IntersectionObserverEntry[], observer: IntersectionObserver) => void) | undefined} [options.onChange] The callback to execute when intersection is detected\n * @param {IntersectionObserverInit['root'] | RefObject<Element | null | undefined>} [options.root] The root element to observe\n * @returns {UseIntersectionObserverReturn} An object containing the state and the supported status\n *\n * @example\n * const { ref, entry, inView } = useIntersectionObserver();\n *\n * @overload\n * @template Target The target element\n * @param {boolean} [options.enabled=true] The IntersectionObserver options\n * @param {((entries: IntersectionObserverEntry[], observer: IntersectionObserver) => void) | undefined} [options.onChange] The callback to execute when intersection is detected\n * @param {IntersectionObserverInit['root'] | RefObject<Element | null | undefined>} [options.root] The root element to observe\n * @returns {UseIntersectionObserverReturn & { ref: (node: Target) => void }} A React ref to attach to the target element\n *\n * @example\n * const { entry, inView } = useIntersectionObserver(ref);\n */\nexport const useIntersectionObserver = ((...params: any[]) => {\n const target = (\n typeof params[0] === 'object' && !('current' in params[0]) ? undefined : params[0]\n ) as UseIntersectionObserverTarget | undefined;\n const options = (target ? params[1] : params[0]) as UseIntersectionObserverOptions | undefined;\n const enabled = options?.enabled ?? true;\n\n const [entry, setEntry] = useState<IntersectionObserverEntry>();\n\n const [internalRef, setInternalRef] = useState<Element>();\n const internalOnChangeRef = useRef<UseIntersectionObserverOptions['onChange']>();\n internalOnChangeRef.current = options?.onChange;\n\n useEffect(() => {\n if (!enabled || !internalRef) return;\n const element = target ? getElement(target) : internalRef;\n if (!element) return;\n\n const observer = new IntersectionObserver(\n ([entry]) => {\n setEntry(entry);\n internalOnChangeRef.current?.(entry);\n },\n {\n ...options,\n root: options?.root ? (getElement(options?.root) as Element | Document) : document\n }\n );\n\n observer.observe(element as Element);\n\n return () => {\n observer.disconnect();\n };\n }, [target, internalRef, options?.rootMargin, options?.threshold, options?.root, enabled]);\n\n if (target) return { entry, inView: !!entry?.isIntersecting };\n return {\n ref: setInternalRef,\n entry,\n inView: !!entry?.isIntersecting\n };\n}) as UseIntersectionObserver;\n"],"names":["_options$enabled","target","_typeof","arguments","length","undefined","options","enabled","_useState","useState","_useState2","_slicedToArray","entry","setEntry","_useState3","_useState4","internalRef","setInternalRef","internalOnChangeRef","useRef","current","onChange","useEffect","element","getElement","observer","IntersectionObserver","_ref","_internalOnChangeRef$","call","_objectSpread","_objectSpread2","root","document","observe","disconnect","rootMargin","threshold","inView","isIntersecting","ref"],"mappings":";uNA8DwC,WAAsB,IAAAA,EACtDC,EACiB,WAArBC,EAAAA,QAAAC,UAAAC,QAAA,OAAAC,EAAAF,UAAqB,KAAc,YAASA,UAAAC,eAAAC,EAAAF,UAAA,IAA0BA,UAAAC,QAAA,OAAAC,EAAAF,UAC1B,QADiBE,EAEzDC,EAAWL,EAAME,UAAAC,QAAAC,OAAAA,EAAAF,UAAA,GAAAA,UAAAC,eAAAC,EAAAF,UAAuE,GACxFI,EAA0BP,QAAnBA,EAAGM,aAAO,EAAPA,EAASC,eAAOP,IAAAA,GAAAA,EAEhCQ,EAA0BC,EAAAA,WAAqCC,EAAAC,EAAAA,eAAAH,EAAA,GAAxDI,EAAKF,EAAA,GAAEG,EAAQH,EAAA,GAEtBI,EAAsCL,EAAAA,WAAmBM,EAAAJ,EAAAA,eAAAG,EAAA,GAAlDE,EAAWD,EAAA,GAAEE,EAAcF,EAAA,GAC5BG,EAAsBC,EAAAA,SA0B5B,OAzBAD,EAAoBE,QAAUd,aAAO,EAAPA,EAASe,SAEvCC,EAAAA,WAAU,WACR,GAAKf,GAAYS,EAAjB,CACA,IAAMO,EAAUtB,EAASuB,EAAUA,WAACvB,GAAUe,EAC9C,GAAKO,EAAL,CAEA,IAAME,EAAW,IAAIC,sBACnB,SAAAC,GAAa,IAAAC,EAAXhB,EAAWD,EAAAA,eAAAgB,EAAA,GAAN,GACLd,EAASD,GACkBgB,QAA3BA,EAAAV,EAAoBE,eAApBQ,IAA2BA,GAA3BA,EAAAC,KAAAX,EAA8BN,EAC/B,GAAAkB,EAAAC,eAAAD,EAAAC,kBAEIzB,GAAO,CAAA,EAAA,CACV0B,KAAM1B,SAAAA,EAAS0B,KAAQR,EAAUA,WAAClB,aAAO,EAAPA,EAAS0B,MAA+BC,YAM9E,OAFAR,EAASS,QAAQX,GAEV,WACLE,EAASU,aAhBG,CAFgB,CAoB/B,GAAE,CAAClC,EAAQe,EAAaV,aAAAA,EAAAA,EAAS8B,WAAY9B,aAAO,EAAPA,EAAS+B,UAAW/B,aAAAA,EAAAA,EAAS0B,KAAMzB,IAE7EN,EAAe,CAAEW,MAAAA,EAAO0B,SAAU1B,UAAAA,EAAO2B,iBACtC,CACLC,IAAKvB,EACLL,MAAAA,EACA0B,SAAU1B,UAAAA,EAAO2B,gBAErB"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
"use strict";var e=require("../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.60 */
|
|
2
|
+
"use strict";var e=require("../../_rollupPluginBabelHelpers-DaULt_UR.js"),r=require("react"),n=require("../useEvent/useEvent.js");exports.useInterval=function(){for(var t,u,l=arguments.length,a=new Array(l),c=0;c<l;c++)a[c]=arguments[c];var s=a[0],i=null!==(t="number"==typeof a[1]?a[1]:a[1].interval)&&void 0!==t?t:1e3,v="object"===e._typeof(a[1])?a[1]:a[2],o=null===(u=null==v?void 0:v.enabled)||void 0===u||u,f=r.useState(null==o||o),p=e._slicedToArray(f,2),I=p[0],d=p[1],b=r.useRef(),y=n.useEvent(s);r.useEffect((function(){if(o)return b.current=setInterval(y,i),function(){clearInterval(b.current)}}),[o,i]);return{active:I,pause:function(){d(!1),clearInterval(b.current)},resume:function(){i<=0||(d(!0),clearInterval(b.current),b.current=setInterval(y,i))}}};
|
|
3
3
|
//# sourceMappingURL=useInterval.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.60 */
|
|
2
2
|
"use strict";var r=require("react");exports.useIsFirstRender=function(){var e=r.useRef(!0);return!0===e.current?(e.current=!1,!0):e.current};
|
|
3
3
|
//# sourceMappingURL=useIsFirstRender.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.60 */
|
|
2
2
|
"use strict";var e=require("react"),s=require("../../utils/helpers/isClient.js").isClient?e.useLayoutEffect:e.useEffect;exports.useIsomorphicLayoutEffect=s;
|
|
3
3
|
//# sourceMappingURL=useIsomorphicLayoutEffect.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
"use strict";var e=require("../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.60 */
|
|
2
|
+
"use strict";var e=require("../../_rollupPluginBabelHelpers-DaULt_UR.js"),r=require("react"),s=require("../useEventListener/useEventListener.js");require("../../utils/helpers/getElement.js"),require("../../utils/helpers/isClient.js"),require("../useEvent/useEvent.js");exports.useKeyPress=function(i,u){var n,t,l=r.useState(!1),o=e._slicedToArray(l,2),a=o[0],v=o[1];return s.useEventListener(null!==(n=null==u?void 0:u.target)&&void 0!==n?n:window,"keydown",(function(e){(Array.isArray(i)?i.includes(e.key):e.key===i)&&v(!0)})),s.useEventListener(null!==(t=null==u?void 0:u.target)&&void 0!==t?t:window,"keyup",(function(e){(Array.isArray(i)?i.includes(e.key):e.key===i)&&v(!1)})),a};
|
|
3
3
|
//# sourceMappingURL=useKeyPress.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useKeyPress.js","sources":["../../../../src/hooks/useKeyPress/useKeyPress.ts"],"sourcesContent":["import { useState } from 'react';\n\nimport type { UseEventListenerTarget } from '../useEventListener/useEventListener';\nimport { useEventListener } from '../useEventListener/useEventListener';\n\n/** The key or keys to listen for */\nexport type UseKeyPressKey = string | string[];\n\n/** The use key press options type */\nexport type UseKeyPressOptions = {\n /** The target to attach the event listeners to */\n target?: UseEventListenerTarget;\n};\n\n/**\n * @name useKeyPress\n * @description - Hook that listens for key press events\n * @category Sensors\n *\n * @param {UseKeyPressKey} key The key or keys to listen for\n * @param {UseEventListenerTarget} [options.target=window] The target to attach the event listeners to\n * @returns {useKeyPressReturns} Return boolean type (`true` if the specified keys are currently pressed)\n *\n * @example\n * const isKeyPressed = useKeyPress('a');\n */\nexport const useKeyPress = (key: UseKeyPressKey, options?: UseKeyPressOptions) => {\n const [pressed, setPressed] = useState(false);\n\n const onKeyDown = (event: KeyboardEvent) => {\n if (Array.isArray(key) ? key.includes(event.key) : event.key === key) setPressed(true);\n };\n\n const onKeyUp = (event: KeyboardEvent) => {\n if (Array.isArray(key) ? key.includes(event.key) : event.key === key) setPressed(false);\n };\n\n useEventListener(options?.target ?? window, 'keydown', onKeyDown);\n useEventListener(options?.target ?? window, 'keyup', onKeyUp);\n\n return pressed;\n};\n"],"names":["key","options","_options$target","_options$target2","_useState","useState","_useState2","_slicedToArray","pressed","setPressed","useEventListener","target","window","event","Array","isArray","includes"],"mappings":";
|
|
1
|
+
{"version":3,"file":"useKeyPress.js","sources":["../../../../src/hooks/useKeyPress/useKeyPress.ts"],"sourcesContent":["import { useState } from 'react';\n\nimport type { UseEventListenerTarget } from '../useEventListener/useEventListener';\nimport { useEventListener } from '../useEventListener/useEventListener';\n\n/** The key or keys to listen for */\nexport type UseKeyPressKey = string | string[];\n\n/** The use key press options type */\nexport type UseKeyPressOptions = {\n /** The target to attach the event listeners to */\n target?: UseEventListenerTarget;\n};\n\n/**\n * @name useKeyPress\n * @description - Hook that listens for key press events\n * @category Sensors\n *\n * @param {UseKeyPressKey} key The key or keys to listen for\n * @param {UseEventListenerTarget} [options.target=window] The target to attach the event listeners to\n * @returns {useKeyPressReturns} Return boolean type (`true` if the specified keys are currently pressed)\n *\n * @example\n * const isKeyPressed = useKeyPress('a');\n */\nexport const useKeyPress = (key: UseKeyPressKey, options?: UseKeyPressOptions) => {\n const [pressed, setPressed] = useState(false);\n\n const onKeyDown = (event: KeyboardEvent) => {\n if (Array.isArray(key) ? key.includes(event.key) : event.key === key) setPressed(true);\n };\n\n const onKeyUp = (event: KeyboardEvent) => {\n if (Array.isArray(key) ? key.includes(event.key) : event.key === key) setPressed(false);\n };\n\n useEventListener(options?.target ?? window, 'keydown', onKeyDown);\n useEventListener(options?.target ?? window, 'keyup', onKeyUp);\n\n return pressed;\n};\n"],"names":["key","options","_options$target","_options$target2","_useState","useState","_useState2","_slicedToArray","pressed","setPressed","useEventListener","target","window","event","Array","isArray","includes"],"mappings":";iSA0B2B,SAACA,EAAqBC,GAAiC,IAAAC,EAAAC,EAChFC,EAA8BC,EAAQA,UAAC,GAAMC,EAAAC,EAAAA,eAAAH,EAAA,GAAtCI,EAAOF,EAAA,GAAEG,EAAUH,EAAA,GAa1B,OAHAI,2BAAgBR,EAACD,aAAO,EAAPA,EAASU,cAAM,IAAAT,EAAAA,EAAIU,OAAQ,WAR1B,SAACC,IACbC,MAAMC,QAAQf,GAAOA,EAAIgB,SAASH,EAAMb,KAAOa,EAAMb,MAAQA,IAAKS,GAAW,MAQnFC,2BAAgBP,EAACF,aAAO,EAAPA,EAASU,cAAM,IAAAR,EAAAA,EAAIS,OAAQ,SAL5B,SAACC,IACXC,MAAMC,QAAQf,GAAOA,EAAIgB,SAASH,EAAMb,KAAOa,EAAMb,MAAQA,IAAKS,GAAW,MAM5ED,CACT"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
"use strict";var e=require("../useEventListener/useEventListener.js");require("react"),require("../useEvent/useEvent.js");exports.useKeyPressEvent=function(){var n=Array.isArray(arguments.length<=0?void 0:arguments[0])?arguments.length<=0?void 0:arguments[0]:[arguments.length<=0?void 0:arguments[0]],
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.60 */
|
|
2
|
+
"use strict";var e=require("../useEventListener/useEventListener.js");require("../../_rollupPluginBabelHelpers-DaULt_UR.js"),require("react"),require("../../utils/helpers/getElement.js"),require("../../utils/helpers/isClient.js"),require("../useEvent/useEvent.js");exports.useKeyPressEvent=function(){var n=Array.isArray(arguments.length<=0?void 0:arguments[0])?arguments.length<=0?void 0:arguments[0]:[arguments.length<=0?void 0:arguments[0]],i=(arguments.length<=1?void 0:arguments[1])instanceof Function?null:arguments.length<=1?void 0:arguments[1],t=i?arguments.length<=2?void 0:arguments[2]:arguments.length<=1?void 0:arguments[1],r=i?arguments.length<=3?void 0:arguments[3]:arguments.length<=2?void 0:arguments[2];e.useEventListener(null!=i?i:window,"keydown",(function(e){n.includes(e.key)&&t(e)}),r)};
|
|
3
3
|
//# sourceMappingURL=useKeyPressEvent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useKeyPressEvent.js","sources":["../../../../src/hooks/useKeyPressEvent/useKeyPressEvent.ts"],"sourcesContent":["import type {\n UseEventListenerOptions,\n UseEventListenerTarget\n} from '../useEventListener/useEventListener';\nimport { useEventListener } from '../useEventListener/useEventListener';\n\nexport type UseKeyPressEventKey = string | string[];\n\nexport type UseKeyPressEvent = {\n (\n key: UseKeyPressEventKey,\n target: Window,\n listener: (this: Window, event: WindowEventMap['keydown']) => void,\n options?: UseEventListenerOptions\n ): void;\n\n (\n key: UseKeyPressEventKey,\n target: Document,\n listener: (this: Document, event: DocumentEventMap['keydown']) => void,\n options?: UseEventListenerOptions\n ): void;\n\n <Target extends UseEventListenerTarget>(\n key: UseKeyPressEventKey,\n target: Target,\n listener: (this: Target, event: HTMLElementEventMap['keydown']) => void,\n options?: UseEventListenerOptions\n ): void;\n\n <Target extends Element>(\n key: UseKeyPressEventKey,\n listener: (this: Target, event: HTMLElementEventMap['keydown']) => void,\n options?: UseEventListenerOptions,\n target?: never\n ): void;\n};\n\nexport const useKeyPressEvent = ((...params: any[]) => {\n const keys = (Array.isArray(params[0]) ? params[0] : [params[0]]) as UseKeyPressEventKey;\n const target = (params[1] instanceof Function ? null : params[1]) as\n | UseEventListenerTarget\n | undefined;\n const callback = (target ? params[2] : params[1]) as (...arg: any[]) => void;\n const options: UseEventListenerOptions | undefined = target ? params[3] : params[2];\n\n const onKeyDown = (event: KeyboardEvent) => {\n if (keys.includes(event.key)) callback(event);\n };\n\n useEventListener(target ?? window, 'keydown', onKeyDown, options);\n}) as UseKeyPressEvent;\n"],"names":["keys","Array","isArray","arguments","length","undefined","target","Function","callback","options","useEventListener","window","event","includes","key"],"mappings":";
|
|
1
|
+
{"version":3,"file":"useKeyPressEvent.js","sources":["../../../../src/hooks/useKeyPressEvent/useKeyPressEvent.ts"],"sourcesContent":["import type {\n UseEventListenerOptions,\n UseEventListenerTarget\n} from '../useEventListener/useEventListener';\nimport { useEventListener } from '../useEventListener/useEventListener';\n\nexport type UseKeyPressEventKey = string | string[];\n\nexport type UseKeyPressEvent = {\n (\n key: UseKeyPressEventKey,\n target: Window,\n listener: (this: Window, event: WindowEventMap['keydown']) => void,\n options?: UseEventListenerOptions\n ): void;\n\n (\n key: UseKeyPressEventKey,\n target: Document,\n listener: (this: Document, event: DocumentEventMap['keydown']) => void,\n options?: UseEventListenerOptions\n ): void;\n\n <Target extends UseEventListenerTarget>(\n key: UseKeyPressEventKey,\n target: Target,\n listener: (this: Target, event: HTMLElementEventMap['keydown']) => void,\n options?: UseEventListenerOptions\n ): void;\n\n <Target extends Element>(\n key: UseKeyPressEventKey,\n listener: (this: Target, event: HTMLElementEventMap['keydown']) => void,\n options?: UseEventListenerOptions,\n target?: never\n ): void;\n};\n\nexport const useKeyPressEvent = ((...params: any[]) => {\n const keys = (Array.isArray(params[0]) ? params[0] : [params[0]]) as UseKeyPressEventKey;\n const target = (params[1] instanceof Function ? null : params[1]) as\n | UseEventListenerTarget\n | undefined;\n const callback = (target ? params[2] : params[1]) as (...arg: any[]) => void;\n const options: UseEventListenerOptions | undefined = target ? params[3] : params[2];\n\n const onKeyDown = (event: KeyboardEvent) => {\n if (keys.includes(event.key)) callback(event);\n };\n\n useEventListener(target ?? window, 'keydown', onKeyDown, options);\n}) as UseKeyPressEvent;\n"],"names":["keys","Array","isArray","arguments","length","undefined","target","Function","callback","options","useEventListener","window","event","includes","key"],"mappings":";kSAsCiC,WAC/B,IAAMA,EAAQC,MAAMC,QAAOC,UAAAC,QAAAC,OAAAA,EAAAF,cAAWA,UAAAC,QAAA,OAAAC,EAAAF,UAAe,GAAA,CAAAA,UAAAC,QAAA,OAAAC,EAAAF,UAAmC,IAClFG,GAAUH,UAAAC,QAAA,OAAAC,EAAAF,UAAA,cAAqBI,SAAW,KAAIJ,UAAAC,QAAAC,OAAAA,EAAAF,UAEvC,GACPK,EAAYF,EAAMH,UAAAC,QAAAC,OAAAA,EAAAF,UAAA,GAAAA,UAAAC,eAAAC,EAAAF,UAAoD,GACtEM,EAA+CH,EAAMH,UAAAC,QAAAC,OAAAA,EAAAF,UAAA,GAAAA,UAAAC,eAAAC,EAAAF,UAAwB,GAMnFO,EAAAA,iBAAiBJ,QAAAA,EAAUK,OAAQ,WAJjB,SAACC,GACbZ,EAAKa,SAASD,EAAME,MAAMN,EAASI,KAGgBH,EAC3D"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
"use strict";var e=require("../useEventListener/useEventListener.js");require("react"),require("../useEvent/useEvent.js");exports.useKeyboard=function(n){var u
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.60 */
|
|
2
|
+
"use strict";var e=require("../useEventListener/useEventListener.js");require("../../_rollupPluginBabelHelpers-DaULt_UR.js"),require("react"),require("../../utils/helpers/getElement.js"),require("../../utils/helpers/isClient.js"),require("../useEvent/useEvent.js");exports.useKeyboard=function(n){var r,u;e.useEventListener(null!==(r=null==n?void 0:n.target)&&void 0!==r?r:window,"keydown",(function(e){var r;return null==n||null===(r=n.onKeyDown)||void 0===r?void 0:r.call(n,e)})),e.useEventListener(null!==(u=null==n?void 0:n.target)&&void 0!==u?u:window,"keyup",(function(e){var r;return null==n||null===(r=n.onKeyUp)||void 0===r?void 0:r.call(n,e)}))};
|
|
3
3
|
//# sourceMappingURL=useKeyboard.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useKeyboard.js","sources":["../../../../src/hooks/useKeyboard/useKeyboard.ts"],"sourcesContent":["import type { UseEventListenerTarget } from '../useEventListener/useEventListener';\nimport { useEventListener } from '../useEventListener/useEventListener';\n\n/** The use key press options type */\nexport type UseKeyboardParams = {\n /** The target to attach the event listeners to */\n target?: UseEventListenerTarget;\n /** The callback function to be invoked on key down */\n onKeyDown?: (event: KeyboardEvent) => void;\n /** The callback function to be invoked on key up */\n onKeyUp?: (event: KeyboardEvent) => void;\n};\n\n/**\n * @name useKeyboard\n * @description - Hook that help to listen for keyboard events\n * @category Sensors\n *\n * @param {UseEventListenerTarget} [target=window] The target to attach the event listeners to\n * @param {(event: KeyboardEvent) => void} [onKeyDown] The callback function to be invoked on key down\n * @param {(event: KeyboardEvent) => void} [onKeyUp] The callback function to be invoked on key up\n *\n * @example\n * useKeyboard({ onKeyDown: () => console.log('key down'), onKeyUp: () => console.log('key up') })\n */\nexport const useKeyboard = (params?: UseKeyboardParams) => {\n const onKeyDown = (event: KeyboardEvent) => params?.onKeyDown?.(event);\n const onKeyUp = (event: KeyboardEvent) => params?.onKeyUp?.(event);\n\n useEventListener(params?.target ?? window, 'keydown', onKeyDown);\n useEventListener(params?.target ?? window, 'keyup', onKeyUp);\n};\n"],"names":["params","_params$target","_params$target2","useEventListener","target","window","event","_params$onKeyDown","onKeyDown","call","_params$onKeyUp","onKeyUp"],"mappings":";
|
|
1
|
+
{"version":3,"file":"useKeyboard.js","sources":["../../../../src/hooks/useKeyboard/useKeyboard.ts"],"sourcesContent":["import type { UseEventListenerTarget } from '../useEventListener/useEventListener';\nimport { useEventListener } from '../useEventListener/useEventListener';\n\n/** The use key press options type */\nexport type UseKeyboardParams = {\n /** The target to attach the event listeners to */\n target?: UseEventListenerTarget;\n /** The callback function to be invoked on key down */\n onKeyDown?: (event: KeyboardEvent) => void;\n /** The callback function to be invoked on key up */\n onKeyUp?: (event: KeyboardEvent) => void;\n};\n\n/**\n * @name useKeyboard\n * @description - Hook that help to listen for keyboard events\n * @category Sensors\n *\n * @param {UseEventListenerTarget} [target=window] The target to attach the event listeners to\n * @param {(event: KeyboardEvent) => void} [onKeyDown] The callback function to be invoked on key down\n * @param {(event: KeyboardEvent) => void} [onKeyUp] The callback function to be invoked on key up\n *\n * @example\n * useKeyboard({ onKeyDown: () => console.log('key down'), onKeyUp: () => console.log('key up') })\n */\nexport const useKeyboard = (params?: UseKeyboardParams) => {\n const onKeyDown = (event: KeyboardEvent) => params?.onKeyDown?.(event);\n const onKeyUp = (event: KeyboardEvent) => params?.onKeyUp?.(event);\n\n useEventListener(params?.target ?? window, 'keydown', onKeyDown);\n useEventListener(params?.target ?? window, 'keyup', onKeyUp);\n};\n"],"names":["params","_params$target","_params$target2","useEventListener","target","window","event","_params$onKeyDown","onKeyDown","call","_params$onKeyUp","onKeyUp"],"mappings":";6RAyB2B,SAACA,GAA+B,IAAAC,EAAAC,EAIzDC,2BAAgBF,EAACD,aAAM,EAANA,EAAQI,cAAM,IAAAH,EAAAA,EAAII,OAAQ,WAHzB,SAACC,GAAoB,IAAAC,EAAA,OAAKP,iBAAMO,EAANP,EAAQQ,iBAAS,IAAAD,OAAA,EAAjBA,EAAAE,KAAAT,EAAoBM,EAAM,IAItEH,2BAAgBD,EAACF,aAAM,EAANA,EAAQI,cAAM,IAAAF,EAAAA,EAAIG,OAAQ,SAH3B,SAACC,GAAoB,IAAAI,EAAA,OAAKV,iBAAMU,EAANV,EAAQW,eAAO,IAAAD,OAAA,EAAfA,EAAAD,KAAAT,EAAkBM,EAAM,GAIpE"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
"use strict";var e=require("../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.60 */
|
|
2
|
+
"use strict";var e=require("../../_rollupPluginBabelHelpers-DaULt_UR.js"),r=require("react"),u=require("../useDidUpdate/useDidUpdate.js"),t=require("../useEventListener/useEventListener.js");require("../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js"),require("../../utils/helpers/isClient.js"),require("../../utils/helpers/getElement.js"),require("../useEvent/useEvent.js");exports.useKeysPressed=function(n){var i,s,o,l=null===(i=null==n?void 0:n.enabled)||void 0===i||i,d=r.useState([]),c=e._slicedToArray(d,2),a=c[0],v=c[1];return u.useDidUpdate((function(){v([])}),[l]),t.useEventListener(null!==(s=null==n?void 0:n.target)&&void 0!==s?s:window,"keydown",(function(r){l&&v((function(u){return u.some((function(e){return e.code===r.code}))?u:[].concat(e._toConsumableArray(u),[{key:r.key,code:r.code}])}))})),t.useEventListener(null!==(o=null==n?void 0:n.target)&&void 0!==o?o:window,"keyup",(function(e){l&&v((function(r){return r.filter((function(r){return r.code!==e.code}))}))})),a};
|
|
3
3
|
//# sourceMappingURL=useKeysPressed.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useKeysPressed.js","sources":["../../../../src/hooks/useKeysPressed/useKeysPressed.ts"],"sourcesContent":["import { useState } from 'react';\n\nimport { useDidUpdate } from '../useDidUpdate/useDidUpdate';\nimport type { UseEventListenerTarget } from '../useEventListener/useEventListener';\nimport { useEventListener } from '../useEventListener/useEventListener';\n\n/** The use keys pressed params type */\
|
|
1
|
+
{"version":3,"file":"useKeysPressed.js","sources":["../../../../src/hooks/useKeysPressed/useKeysPressed.ts"],"sourcesContent":["import { useState } from 'react';\n\nimport { useDidUpdate } from '../useDidUpdate/useDidUpdate';\nimport type { UseEventListenerTarget } from '../useEventListener/useEventListener';\nimport { useEventListener } from '../useEventListener/useEventListener';\n\n/** The use keys pressed params type */\nexport interface UseKeysPressedParams {\n /** The target to attach the event listeners to */\n target?: UseEventListenerTarget;\n /** Enable or disable the event listeners */\n enabled?: boolean;\n}\n\n/**\n * @name useKeysPressed\n * @description - Hook for get keys that were pressed\n * @category Sensors\n *\n * @param {UseEventListenerTarget} [params.target=window] The target to attach the event listeners to\n * @param {boolean} [params.enabled=bollean] Enable or disable the event listeners\n * @returns {useKeysPressedReturns} Array of strings with keys that were press\n *\n * @example\n * const pressedKeys = useKeysPressed();\n */\nexport const useKeysPressed = (params?: UseKeysPressedParams) => {\n const enabled = params?.enabled ?? true;\n const [keys, setKeys] = useState<{ key: string; code: string }[]>([]);\n\n const onKeyDown = (event: KeyboardEvent) => {\n if (!enabled) return;\n setKeys((prevKeys) => {\n if (prevKeys.some(({ code }) => code === event.code)) return prevKeys;\n return [...prevKeys, { key: event.key, code: event.code }];\n });\n };\n\n const onKeyUp = (event: KeyboardEvent) => {\n if (!enabled) return;\n setKeys((prevKeys) => prevKeys.filter(({ code }) => code !== event.code));\n };\n\n useDidUpdate(() => {\n setKeys([]);\n }, [enabled]);\n\n useEventListener(params?.target ?? window, 'keydown', onKeyDown);\n useEventListener(params?.target ?? window, 'keyup', onKeyUp);\n\n return keys;\n};\n"],"names":["params","_params$enabled","_params$target","_params$target2","enabled","_useState","useState","_useState2","_slicedToArray","keys","setKeys","useDidUpdate","useEventListener","target","window","event","prevKeys","some","_ref","code","concat","_toConsumableArray","key","filter","_ref2"],"mappings":";sZA0B8B,SAACA,GAAkC,IAAAC,EAAAC,EAAAC,EACzDC,EAAyBH,QAAlBA,EAAGD,aAAM,EAANA,EAAQI,eAAOH,IAAAA,GAAAA,EAC/BI,EAAwBC,EAAQA,SAAkC,IAAGC,EAAAC,EAAAA,eAAAH,EAAA,GAA9DI,EAAIF,EAAA,GAAEG,EAAOH,EAAA,GAsBpB,OAPAI,EAAAA,cAAa,WACXD,EAAQ,GACV,GAAG,CAACN,IAEJQ,2BAAgBV,EAACF,aAAM,EAANA,EAAQa,cAAM,IAAAX,EAAAA,EAAIY,OAAQ,WAjBzB,SAACC,GACZX,GACLM,GAAQ,SAACM,GACP,OAAIA,EAASC,MAAK,SAAAC,GAAO,OAAAA,EAAJC,OAAoBJ,EAAMI,QAAcH,EAC7D,GAAAI,OAAAC,qBAAWL,GAAU,CAAA,CAAEM,IAAKP,EAAMO,IAAKH,KAAMJ,EAAMI,OACrD,OAaFP,2BAAgBT,EAACH,aAAM,EAANA,EAAQa,cAAM,IAAAV,EAAAA,EAAIW,OAAQ,SAV3B,SAACC,GACVX,GACLM,GAAQ,SAACM,GAAQ,OAAKA,EAASO,QAAO,SAAAC,GAAO,OAAAA,EAAJL,OAAoBJ,EAAMI,cAU9DV,CACT"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
"use strict";var r=require("../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.60 */
|
|
2
|
+
"use strict";var r=require("../../_rollupPluginBabelHelpers-DaULt_UR.js"),n=require("react");exports.useList=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=n.useState(t),u=r._slicedToArray(e,2),o=u[0],c=u[1];return{value:o,set:c,push:function(n){return c((function(t){return[].concat(r._toConsumableArray(t),[n])}))},removeAt:function(n){return c((function(t){return[].concat(r._toConsumableArray(t.slice(0,n)),r._toConsumableArray(t.slice(n+1)))}))},insertAt:function(n,t){return c((function(e){return[].concat(r._toConsumableArray(e.slice(0,n)),[t],r._toConsumableArray(e.slice(n)))}))},updateAt:function(r,n){return c((function(t){return t.map((function(t,e){return e===r?n:t}))}))},clear:function(){return c([])},reset:function(){return c(t)}}};
|
|
3
3
|
//# sourceMappingURL=useList.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
"use strict";var e=require("../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.60 */
|
|
2
|
+
"use strict";var e=require("../../_rollupPluginBabelHelpers-DaULt_UR.js"),r=require("../useStorage/useStorage.js");require("react"),require("../../utils/helpers/isClient.js"),require("../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js");exports.useLocalStorage=function(s,t,u){return r.useStorage(s,e._objectSpread2({initialValue:t,storage:window.localStorage},u))};
|
|
3
3
|
//# sourceMappingURL=useLocalStorage.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
"use strict";var e=require("../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.60 */
|
|
2
|
+
"use strict";var e=require("../../_rollupPluginBabelHelpers-DaULt_UR.js"),o=require("react"),r=require("../useDidUpdate/useDidUpdate.js");require("../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js"),require("../../utils/helpers/isClient.js");exports.useLogger=function(t,u){o.useEffect((function(){var o;return(o=console).log.apply(o,["".concat(t," mounted")].concat(e._toConsumableArray(u))),function(){return console.log("".concat(t," unmounted"))}}),[]),r.useDidUpdate((function(){var o;(o=console).log.apply(o,["".concat(t," updated")].concat(e._toConsumableArray(u)))}),u)};
|
|
3
3
|
//# sourceMappingURL=useLogger.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
"use strict";var e=require("../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.60 */
|
|
2
|
+
"use strict";var e=require("../../_rollupPluginBabelHelpers-DaULt_UR.js"),n=require("react");exports.useLongPress=function(r,u){var l=n.useState(!1),o=e._slicedToArray(l,2),t=o[0],c=o[1],i=n.useRef(),s=n.useRef(!1),a=function(e){var n,l;null==u||null===(n=u.onStart)||void 0===n||n.call(u,e),s.current=!0,i.current=setTimeout((function(){r(e),c(!0)}),null!==(l=null==u?void 0:u.threshold)&&void 0!==l?l:400)},v=function(e){var n;if(t)null==u||null===(n=u.onFinish)||void 0===n||n.call(u,e);else if(s.current){var r;null==u||null===(r=u.onCancel)||void 0===r||r.call(u,e)}c(!1),s.current=!1,i.current&&clearTimeout(i.current)};return[{onMouseDown:a,onTouchStart:a,onMouseUp:v,onTouchEnd:v},t]};
|
|
3
3
|
//# sourceMappingURL=useLongPress.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLongPress.js","sources":["../../../../src/hooks/useLongPress/useLongPress.ts"],"sourcesContent":["import type { RefObject } from 'react';\nimport { useRef, useState } from 'react';\n\
|
|
1
|
+
{"version":3,"file":"useLongPress.js","sources":["../../../../src/hooks/useLongPress/useLongPress.ts"],"sourcesContent":["import type { MouseEventHandler, RefObject, TouchEventHandler } from 'react';\nimport { useRef, useState } from 'react';\n\n// * The use long press target type */\nexport type UseLongPressTarget = RefObject<Element | null | undefined> | (() => Element) | Element;\n\nexport type LongPressReactEvents<Target extends Element = Element> =\n | MouseEventHandler<Target>\n | TouchEventHandler<Target>;\n\n// * The use long press options type */\nexport interface UseLongPressOptions {\n // * The threshold time in milliseconds\n threshold?: number;\n // * The callback function to be invoked on long press start\n onStart?: (event: LongPressReactEvents) => void;\n // * The callback function to be invoked on long press end\n onFinish?: (event: LongPressReactEvents) => void;\n // * The callback function to be invoked on long press cancel\n onCancel?: (event: LongPressReactEvents) => void;\n}\n\n// * The use long press bind type */\nexport interface UseLongPressBind {\n /** The callback function to be invoked on mouse down */\n onMouseDown: MouseEventHandler<Element>;\n /** The callback function to be invoked on touch start */\n onTouchStart: TouchEventHandler<Element>;\n /** The callback function to be invoked on mouse up */\n onMouseUp: MouseEventHandler<Element>;\n /** The callback function to be invoked on touch end */\n onTouchEnd: TouchEventHandler<Element>;\n}\n\n// * The use long press return type */\nexport type UseLongPressReturn = [UseLongPressBind, boolean];\n\nconst DEFAULT_THRESHOLD_TIME = 400;\n\n/**\n * @name useLongPress\n * @description - Hook that defines the logic when long pressing an element\n * @category Sensors\n *\n * @template Target The target element\n * @param {Target} target The target element to be long pressed\n * @param {(event: Event) => void} callback The callback function to be invoked on long press\n * @param {number} [options.threshold=400] The threshold time in milliseconds\n * @param {(event: Event) => void} [options.onStart] The callback function to be invoked on long press start\n * @param {(event: Event) => void} [options.onFinish] The callback function to be invoked on long press finish\n * @param {(event: Event) => void} [options.onCancel] The callback function to be invoked on long press cancel\n * @returns {UseLongPressReturn<Target>} The ref of the target element\n *\n * @example\n * const [bind, longPressing] = useLongPress(() => console.log('callback'));\n */\nexport const useLongPress = (\n callback: (event: LongPressReactEvents) => void,\n options?: UseLongPressOptions\n): UseLongPressReturn => {\n const [isLongPressActive, setIsLongPressActive] = useState(false);\n const timeoutIdRef = useRef<ReturnType<typeof setTimeout>>();\n const isPressed = useRef(false);\n\n const start = (event: LongPressReactEvents) => {\n options?.onStart?.(event);\n\n isPressed.current = true;\n timeoutIdRef.current = setTimeout(() => {\n callback(event);\n setIsLongPressActive(true);\n }, options?.threshold ?? DEFAULT_THRESHOLD_TIME);\n };\n\n const cancel = (event: LongPressReactEvents) => {\n if (isLongPressActive) {\n options?.onFinish?.(event);\n } else if (isPressed.current) {\n options?.onCancel?.(event);\n }\n\n setIsLongPressActive(false);\n isPressed.current = false;\n\n if (timeoutIdRef.current) clearTimeout(timeoutIdRef.current);\n };\n\n const bind = {\n onMouseDown: start,\n onTouchStart: start,\n onMouseUp: cancel,\n onTouchEnd: cancel\n } as unknown as UseLongPressBind;\n\n return [bind, isLongPressActive];\n};\n"],"names":["callback","options","_useState","useState","_useState2","_slicedToArray","isLongPressActive","setIsLongPressActive","timeoutIdRef","useRef","isPressed","start","event","_options$onStart","_options$threshold","onStart","call","current","setTimeout","threshold","cancel","_options$onFinish","onFinish","_options$onCancel","onCancel","clearTimeout","onMouseDown","onTouchStart","onMouseUp","onTouchEnd"],"mappings":";kHAwD4B,SAC1BA,EACAC,GAEA,IAAAC,EAAkDC,EAAQA,UAAC,GAAMC,EAAAC,EAAAA,eAAAH,EAAA,GAA1DI,EAAiBF,EAAA,GAAEG,EAAoBH,EAAA,GACxCI,EAAeC,EAAAA,SACfC,EAAYD,UAAO,GAEnBE,EAAQ,SAACC,GAAgC,IAAAC,EAAAC,EAC7Cb,SAAgB,QAATY,EAAPZ,EAASc,eAAO,IAAAF,GAAhBA,EAAAG,KAAAf,EAAmBW,GAEnBF,EAAUO,SAAU,EACpBT,EAAaS,QAAUC,YAAW,WAChClB,EAASY,GACTL,GAAqB,EACvB,WAACO,EAAEb,aAAAA,EAAAA,EAASkB,iBAAS,IAAAL,EAAAA,EAlCM,MAqCvBM,EAAS,SAACR,GACS,IAAAS,EAAvB,GAAIf,EACFL,SAAiB,QAAVoB,EAAPpB,EAASqB,gBAAQ,IAAAD,GAAjBA,EAAAL,KAAAf,EAAoBW,QACf,GAAIF,EAAUO,QAAS,CAAA,IAAAM,EAC5BtB,SAAiB,QAAVsB,EAAPtB,EAASuB,gBAAQ,IAAAD,GAAjBA,EAAAP,KAAAf,EAAoBW,EACtB,CAEAL,GAAqB,GACrBG,EAAUO,SAAU,EAEhBT,EAAaS,SAASQ,aAAajB,EAAaS,UAUtD,MAAO,CAPM,CACXS,YAAaf,EACbgB,aAAchB,EACdiB,UAAWR,EACXS,WAAYT,GAGAd,EAChB"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
"use strict";var e=require("../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.60 */
|
|
2
|
+
"use strict";var e=require("../../_rollupPluginBabelHelpers-DaULt_UR.js"),r=require("react");exports.useMap=function(n){var t=r.useState(new Map(n)),u=e._slicedToArray(t,2),a=u[0],i=u[1];return{value:a,size:a.size,set:function(e,r){return i((function(n){return new Map(n).set(e,r)}))},has:function(e){return a.has(e)},remove:function(e){return i((function(r){if(!r.has(e))return r;var n=new Map(r);return n.delete(e),n}))},clear:function(){return i(new Map)},reset:function(){return i(new Map(n))}}};
|
|
3
3
|
//# sourceMappingURL=useMap.js.map
|