@siberiacancode/reactuse 0.0.30 → 0.0.31
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-B5ln7UDR.js → _rollupPluginBabelHelpers-XknWBRG7.js} +2 -2
- package/dist/cjs/_rollupPluginBabelHelpers-XknWBRG7.js.map +1 -0
- package/dist/cjs/hooks/index.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/useBoolean/useBoolean.js.map +1 -1
- package/dist/cjs/hooks/useBrowserLanguage/useBrowserLanguage.js +1 -1
- package/dist/cjs/hooks/useClickOutside/useClickOutside.js +1 -1
- package/dist/cjs/hooks/useClickOutside/useClickOutside.js.map +1 -1
- package/dist/cjs/hooks/useCopyToClipboard/useCopyToClipboard.js +2 -2
- package/dist/cjs/hooks/useCopyToClipboard/useCopyToClipboard.js.map +1 -1
- package/dist/cjs/hooks/useCounter/useCounter.js +2 -2
- package/dist/cjs/hooks/useCounter/useCounter.js.map +1 -1
- package/dist/cjs/hooks/useDebouncedValue/useDebouncedValue.js +2 -2
- package/dist/cjs/hooks/useDebouncedValue/useDebouncedValue.js.map +1 -1
- package/dist/cjs/hooks/useDefault/useDefault.js +2 -2
- package/dist/cjs/hooks/useDefault/useDefault.js.map +1 -1
- package/dist/cjs/hooks/useDidUpdate/useDidUpdate.js +1 -1
- package/dist/cjs/hooks/useDidUpdate/useDidUpdate.js.map +1 -1
- package/dist/cjs/hooks/useDocumentEvent/useDocumentEvent.js +1 -1
- package/dist/cjs/hooks/useDocumentTitle/useDocumentTitle.js +2 -2
- package/dist/cjs/hooks/useDocumentTitle/useDocumentTitle.js.map +1 -1
- package/dist/cjs/hooks/useDocumentVisibility/useDocumentVisibility.js +1 -1
- package/dist/cjs/hooks/useDocumentVisibility/useDocumentVisibility.js.map +1 -1
- package/dist/cjs/hooks/useEvent/useEvent.js +1 -1
- package/dist/cjs/hooks/useEvent/useEvent.js.map +1 -1
- package/dist/cjs/hooks/useEventListener/useEventListener.js +1 -1
- 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/useFavicon/useFavicon.js.map +1 -1
- package/dist/cjs/hooks/useField/useField.js +2 -2
- package/dist/cjs/hooks/useField/useField.js.map +1 -1
- package/dist/cjs/hooks/useFps/useFps.js +2 -2
- package/dist/cjs/hooks/useFps/useFps.js.map +1 -1
- package/dist/cjs/hooks/useFullscreen/useFullscreen.js +2 -2
- package/dist/cjs/hooks/useFullscreen/useFullscreen.js.map +1 -1
- package/dist/cjs/hooks/useHash/useHash.js +2 -2
- package/dist/cjs/hooks/useHash/useHash.js.map +1 -1
- 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/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/useInterval/useInterval.js.map +1 -1
- package/dist/cjs/hooks/useIsFirstRender/useIsFirstRender.js +1 -1
- package/dist/cjs/hooks/useIsFirstRender/useIsFirstRender.js.map +1 -1
- package/dist/cjs/hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js +1 -1
- package/dist/cjs/hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js.map +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 +1 -1
- package/dist/cjs/hooks/useKeyboard/useKeyboard.js +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/useList/useList.js.map +1 -1
- package/dist/cjs/hooks/useLocalStorage/useLocalStorage.js +2 -2
- package/dist/cjs/hooks/useLogger/useLogger.js +2 -2
- package/dist/cjs/hooks/useLogger/useLogger.js.map +1 -1
- package/dist/cjs/hooks/useLongPress/useLongPress.js +2 -2
- package/dist/cjs/hooks/useLongPress/useLongPress.js.map +1 -1
- package/dist/cjs/hooks/useMediaQuery/useMediaQuery.js +1 -1
- package/dist/cjs/hooks/useMediaQuery/useMediaQuery.js.map +1 -1
- package/dist/cjs/hooks/useMount/useMount.js +1 -1
- package/dist/cjs/hooks/useMount/useMount.js.map +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/useMutation/useMutation.js.map +1 -1
- package/dist/cjs/hooks/useMutationObserver.js +1 -1
- package/dist/cjs/hooks/useMutationObserver.js.map +1 -1
- package/dist/cjs/hooks/useNetwork/useNetwork.js +2 -2
- package/dist/cjs/hooks/useNetwork/useNetwork.js.map +1 -1
- package/dist/cjs/hooks/useOnline/useOnline.js +1 -1
- package/dist/cjs/hooks/useOnline/useOnline.js.map +1 -1
- package/dist/cjs/hooks/useOperatingSystem/useOperatingSystem.js +1 -1
- package/dist/cjs/hooks/useOperatingSystem/useOperatingSystem.js.map +1 -1
- package/dist/cjs/hooks/useOrientation/useOrientation.js +2 -2
- package/dist/cjs/hooks/useOrientation/useOrientation.js.map +1 -1
- package/dist/cjs/hooks/usePageLeave/usePageLeave.js +2 -2
- package/dist/cjs/hooks/usePageLeave/usePageLeave.js.map +1 -1
- package/dist/cjs/hooks/usePaint/usePaint.js +2 -2
- package/dist/cjs/hooks/usePaint/usePaint.js.map +1 -1
- package/dist/cjs/hooks/usePreferredColorScheme/usePreferredColorScheme.js +1 -1
- package/dist/cjs/hooks/usePreferredLanguages/usePreferredLanguages.js +1 -1
- package/dist/cjs/hooks/usePreferredLanguages/usePreferredLanguages.js.map +1 -1
- package/dist/cjs/hooks/usePrevious/usePrevious.js +1 -1
- package/dist/cjs/hooks/usePrevious/usePrevious.js.map +1 -1
- package/dist/cjs/hooks/useQRCode/useQRCode.js +2 -2
- package/dist/cjs/hooks/useQRCode/useQRCode.js.map +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/useQueue/useQueue.js.map +1 -1
- package/dist/cjs/hooks/useRenderCount/useRenderCount.js +1 -1
- package/dist/cjs/hooks/useRenderCount/useRenderCount.js.map +1 -1
- package/dist/cjs/hooks/useRenderInfo/useRenderInfo.js +1 -1
- package/dist/cjs/hooks/useRenderInfo/useRenderInfo.js.map +1 -1
- package/dist/cjs/hooks/useRerender/useRerender.js +2 -2
- package/dist/cjs/hooks/useRerender/useRerender.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/useSet/useSet.js.map +1 -1
- package/dist/cjs/hooks/useStep/useStep.js +2 -2
- package/dist/cjs/hooks/useStep/useStep.js.map +1 -1
- package/dist/cjs/hooks/useStorage/useStorage.js +2 -2
- package/dist/cjs/hooks/useStorage/useStorage.js.map +1 -1
- package/dist/cjs/hooks/useTextSelection/useTextSelection.js +2 -2
- package/dist/cjs/hooks/useTextSelection/useTextSelection.js.map +1 -1
- package/dist/cjs/hooks/useTime/useTime.js +2 -2
- package/dist/cjs/hooks/useTime/useTime.js.map +1 -1
- package/dist/cjs/hooks/useTimeout/useTimeout.js +2 -2
- package/dist/cjs/hooks/useTimeout/useTimeout.js.map +1 -1
- package/dist/cjs/hooks/useToggle/useToggle.js +2 -2
- package/dist/cjs/hooks/useToggle/useToggle.js.map +1 -1
- package/dist/cjs/hooks/useUnmount/useUnmount.js +1 -1
- package/dist/cjs/hooks/useUnmount/useUnmount.js.map +1 -1
- package/dist/cjs/hooks/useWebSocket/useWebSocket.js +2 -2
- package/dist/cjs/hooks/useWebSocket/useWebSocket.js.map +1 -1
- package/dist/cjs/hooks/useWindowEvent/useWindowEvent.js +1 -1
- package/dist/cjs/hooks/useWindowSize/useWindowSize.js +2 -2
- package/dist/cjs/hooks/useWindowSize/useWindowSize.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/getRetry.js +1 -1
- package/dist/cjs/utils/helpers/index.js +1 -1
- package/dist/cjs/utils/helpers/isClient.js +1 -1
- package/dist/cjs/utils/helpers/throttle.js +1 -1
- package/dist/cjs/utils/helpers/time/getDate.js +1 -1
- package/dist/esm/{_rollupPluginBabelHelpers-BO0nvURb.js → _rollupPluginBabelHelpers-DmI4-Pc6.js} +2 -2
- package/dist/esm/_rollupPluginBabelHelpers-DmI4-Pc6.js.map +1 -0
- package/dist/esm/hooks/index.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/useBoolean/useBoolean.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/useCopyToClipboard/useCopyToClipboard.js +2 -2
- package/dist/esm/hooks/useCopyToClipboard/useCopyToClipboard.js.map +1 -1
- package/dist/esm/hooks/useCounter/useCounter.js +2 -2
- package/dist/esm/hooks/useCounter/useCounter.js.map +1 -1
- package/dist/esm/hooks/useDebouncedValue/useDebouncedValue.js +2 -2
- package/dist/esm/hooks/useDebouncedValue/useDebouncedValue.js.map +1 -1
- package/dist/esm/hooks/useDefault/useDefault.js +2 -2
- package/dist/esm/hooks/useDefault/useDefault.js.map +1 -1
- package/dist/esm/hooks/useDidUpdate/useDidUpdate.js +2 -2
- package/dist/esm/hooks/useDidUpdate/useDidUpdate.js.map +1 -1
- package/dist/esm/hooks/useDocumentEvent/useDocumentEvent.js +1 -1
- package/dist/esm/hooks/useDocumentTitle/useDocumentTitle.js +2 -2
- package/dist/esm/hooks/useDocumentTitle/useDocumentTitle.js.map +1 -1
- package/dist/esm/hooks/useDocumentVisibility/useDocumentVisibility.js +2 -2
- package/dist/esm/hooks/useDocumentVisibility/useDocumentVisibility.js.map +1 -1
- package/dist/esm/hooks/useEvent/useEvent.js +2 -2
- package/dist/esm/hooks/useEvent/useEvent.js.map +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/useFavicon/useFavicon.js.map +1 -1
- package/dist/esm/hooks/useField/useField.js +2 -2
- package/dist/esm/hooks/useField/useField.js.map +1 -1
- package/dist/esm/hooks/useFps/useFps.js +2 -2
- package/dist/esm/hooks/useFps/useFps.js.map +1 -1
- package/dist/esm/hooks/useFullscreen/useFullscreen.js +2 -2
- package/dist/esm/hooks/useFullscreen/useFullscreen.js.map +1 -1
- package/dist/esm/hooks/useHash/useHash.js +2 -2
- package/dist/esm/hooks/useHash/useHash.js.map +1 -1
- 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/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/useInterval/useInterval.js.map +1 -1
- package/dist/esm/hooks/useIsFirstRender/useIsFirstRender.js +2 -2
- package/dist/esm/hooks/useIsFirstRender/useIsFirstRender.js.map +1 -1
- package/dist/esm/hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js +2 -2
- package/dist/esm/hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js.map +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 +1 -1
- package/dist/esm/hooks/useKeyboard/useKeyboard.js +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/useList/useList.js.map +1 -1
- package/dist/esm/hooks/useLocalStorage/useLocalStorage.js +2 -2
- package/dist/esm/hooks/useLogger/useLogger.js +2 -2
- package/dist/esm/hooks/useLogger/useLogger.js.map +1 -1
- package/dist/esm/hooks/useLongPress/useLongPress.js +2 -2
- package/dist/esm/hooks/useLongPress/useLongPress.js.map +1 -1
- package/dist/esm/hooks/useMediaQuery/useMediaQuery.js +2 -2
- package/dist/esm/hooks/useMediaQuery/useMediaQuery.js.map +1 -1
- package/dist/esm/hooks/useMount/useMount.js +2 -2
- package/dist/esm/hooks/useMount/useMount.js.map +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/useMutation/useMutation.js.map +1 -1
- package/dist/esm/hooks/useMutationObserver.js +2 -2
- package/dist/esm/hooks/useMutationObserver.js.map +1 -1
- package/dist/esm/hooks/useNetwork/useNetwork.js +2 -2
- package/dist/esm/hooks/useNetwork/useNetwork.js.map +1 -1
- package/dist/esm/hooks/useOnline/useOnline.js +2 -2
- package/dist/esm/hooks/useOnline/useOnline.js.map +1 -1
- package/dist/esm/hooks/useOperatingSystem/useOperatingSystem.js +2 -2
- package/dist/esm/hooks/useOperatingSystem/useOperatingSystem.js.map +1 -1
- package/dist/esm/hooks/useOrientation/useOrientation.js +2 -2
- package/dist/esm/hooks/useOrientation/useOrientation.js.map +1 -1
- package/dist/esm/hooks/usePageLeave/usePageLeave.js +2 -2
- package/dist/esm/hooks/usePageLeave/usePageLeave.js.map +1 -1
- package/dist/esm/hooks/usePaint/usePaint.js +2 -2
- package/dist/esm/hooks/usePaint/usePaint.js.map +1 -1
- package/dist/esm/hooks/usePreferredColorScheme/usePreferredColorScheme.js +1 -1
- package/dist/esm/hooks/usePreferredLanguages/usePreferredLanguages.js +2 -2
- package/dist/esm/hooks/usePreferredLanguages/usePreferredLanguages.js.map +1 -1
- package/dist/esm/hooks/usePrevious/usePrevious.js +2 -2
- package/dist/esm/hooks/usePrevious/usePrevious.js.map +1 -1
- package/dist/esm/hooks/useQRCode/useQRCode.js +2 -2
- package/dist/esm/hooks/useQRCode/useQRCode.js.map +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/useQueue/useQueue.js.map +1 -1
- package/dist/esm/hooks/useRenderCount/useRenderCount.js +2 -2
- package/dist/esm/hooks/useRenderCount/useRenderCount.js.map +1 -1
- package/dist/esm/hooks/useRenderInfo/useRenderInfo.js +2 -2
- package/dist/esm/hooks/useRenderInfo/useRenderInfo.js.map +1 -1
- package/dist/esm/hooks/useRerender/useRerender.js +2 -2
- package/dist/esm/hooks/useRerender/useRerender.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/useSet/useSet.js.map +1 -1
- package/dist/esm/hooks/useStep/useStep.js +2 -2
- package/dist/esm/hooks/useStep/useStep.js.map +1 -1
- package/dist/esm/hooks/useStorage/useStorage.js +2 -2
- package/dist/esm/hooks/useStorage/useStorage.js.map +1 -1
- package/dist/esm/hooks/useTextSelection/useTextSelection.js +2 -2
- package/dist/esm/hooks/useTextSelection/useTextSelection.js.map +1 -1
- package/dist/esm/hooks/useTime/useTime.js +2 -2
- package/dist/esm/hooks/useTime/useTime.js.map +1 -1
- package/dist/esm/hooks/useTimeout/useTimeout.js +2 -2
- package/dist/esm/hooks/useTimeout/useTimeout.js.map +1 -1
- package/dist/esm/hooks/useToggle/useToggle.js +2 -2
- package/dist/esm/hooks/useToggle/useToggle.js.map +1 -1
- package/dist/esm/hooks/useUnmount/useUnmount.js +2 -2
- package/dist/esm/hooks/useUnmount/useUnmount.js.map +1 -1
- package/dist/esm/hooks/useWebSocket/useWebSocket.js +2 -2
- package/dist/esm/hooks/useWebSocket/useWebSocket.js.map +1 -1
- package/dist/esm/hooks/useWindowEvent/useWindowEvent.js +1 -1
- package/dist/esm/hooks/useWindowSize/useWindowSize.js +2 -2
- package/dist/esm/hooks/useWindowSize/useWindowSize.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/getRetry.js +1 -1
- package/dist/esm/utils/helpers/index.js +1 -1
- package/dist/esm/utils/helpers/isClient.js +1 -1
- package/dist/esm/utils/helpers/throttle.js +1 -1
- package/dist/esm/utils/helpers/time/getDate.js +1 -1
- package/dist/index.d.ts +37 -38
- package/package.json +1 -1
- package/dist/cjs/_rollupPluginBabelHelpers-B5ln7UDR.js.map +0 -1
- package/dist/esm/_rollupPluginBabelHelpers-BO0nvURb.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFullscreen.js","sources":["../../../../src/hooks/useFullscreen/useFullscreen.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"useFullscreen.js","sources":["../../../../src/hooks/useFullscreen/useFullscreen.ts"],"sourcesContent":["import type { RefObject } from 'react';\nimport { useRef, useState } from 'react';\nimport screenfull from 'screenfull';\n\nimport { useUnmount } from '../useUnmount/useUnmount';\n\n/** The use fullscreen target element type */\ntype UseFullScreenTarget = RefObject<Element | null> | (() => Element) | Element;\n\n/** Function to get target element based on its type */\nconst getElement = (target: UseFullScreenTarget) => {\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 fullscreen options type */\nexport interface UseFullScreenOptions {\n /** initial value */\n initialValue?: boolean;\n /** on enter fullscreen */\n onEnter?: () => void;\n /** on exit fullscreen */\n onExit?: () => void;\n}\n\n/** The use click outside return type */\nexport interface UseFullScreenReturn {\n enter: () => void;\n exit: () => void;\n toggle: () => void;\n value: boolean;\n}\n\nexport type UseFullScreen = {\n <Target extends UseFullScreenTarget>(\n target: Target,\n options?: UseFullScreenOptions\n ): UseFullScreenReturn;\n\n <Target extends UseFullScreenTarget>(\n options?: UseFullScreenOptions,\n target?: never\n ): UseFullScreenReturn & { ref: RefObject<Target> };\n};\n\n/**\n * @name useFullscreen\n * @description - Hook to handle fullscreen events\n *\n * @overload\n * @template Target The target element for fullscreen\n * @param {Target} target The target element for fullscreen\n * @param {boolean} [options.initialValue=false] initial value of fullscreen\n * @param {() => void} [options.onEnter] on enter fullscreen\n * @param {() => void} [options.onExit] on exit fullscreen\n * @returns {UseFullScreenReturn} An object with the fullscreen state and methods\n *\n * @example\n * const { enter, exit, toggle, value } = useFullscreen(ref);\n *\n * @overload\n * @template Target The target element for fullscreen\n * @param {boolean} [options.initialValue=false] initial value of fullscreen\n * @param {() => void} [options.onEnter] on enter fullscreen\n * @param {() => void} [options.onExit] on exit fullscreen\n * @returns {UseFullScreenReturn & { ref: RefObject<Target> }} An object with the fullscreen state and methods\n *\n * @example\n * const { ref, enter, exit, toggle, value } = useFullscreen();\n */\nexport const useFullscreen = ((...params: any[]) => {\n const target = (typeof params[1] === 'undefined' ? undefined : params[0]) as\n | UseFullScreenTarget\n | undefined;\n const options = (target ? params[1] : params[0]) as UseFullScreenOptions | undefined;\n\n const internalRef = useRef<Element>(null);\n const [value, setValue] = useState(options?.initialValue ?? false);\n\n const onChange = () => {\n if (!screenfull.isEnabled) return;\n\n if (screenfull.isFullscreen) {\n options?.onEnter?.();\n } else {\n screenfull.off('change', onChange);\n options?.onExit?.();\n }\n\n setValue(screenfull.isFullscreen);\n };\n\n const enter = () => {\n const element = target ? getElement(target) : internalRef.current;\n if (!element) return;\n\n if (screenfull.isEnabled) {\n try {\n screenfull.request(element);\n screenfull.on('change', onChange);\n } catch (error) {\n console.error(error);\n }\n }\n };\n\n const exit = () => {\n if (screenfull.isEnabled) screenfull.exit();\n };\n\n const toggle = () => {\n if (value) return exit();\n enter();\n };\n\n useUnmount(() => {\n if (screenfull.isEnabled) screenfull.off('change', onChange);\n });\n\n return {\n ...(!target && { ref: internalRef }),\n enter,\n exit,\n toggle,\n value\n };\n}) as UseFullScreen;\n"],"names":["useFullscreen","_options$initialValue","target","arguments","length","undefined","options","internalRef","useRef","_useState","useState","initialValue","_useState2","_slicedToArray","value","setValue","onChange","screenfull","isEnabled","_options$onEnter","_options$onExit","isFullscreen","onEnter","call","off","onExit","enter","element","Element","current","getElement","request","on","error","console","exit","useUnmount","_objectSpread","ref","toggle"],"mappings":";uMAUA,IAmEaA,EAAiB,WAAsB,IAAAC,EAC5CC,OAA+B,KAArBC,UAAAC,QAAA,OAAAC,EAAAF,UAAA,KAA4CA,UAAAC,QAAAC,OAATA,EAASF,UAE/C,GACPG,EAAWJ,EAAMC,UAAAC,QAAAC,OAAAA,EAAAF,UAAA,GAAAA,UAAAC,eAAAC,EAAAF,UAA6D,GAE9EI,EAAcC,EAAgB,MACpCC,EAA0BC,EAA8BT,QAAtBA,EAACK,eAAAA,EAASK,wBAAYV,GAAAA,GAAUW,EAAAC,EAAAJ,EAAA,GAA3DK,EAAKF,EAAA,GAAEG,EAAQH,EAAA,GAEhBI,EAAW,SAAXA,IACJ,GAAKC,EAAWC,UAAhB,CAE6B,IAAAC,EAEtBC,EAFP,GAAIH,EAAWI,aACbf,SAAgBa,QAATA,EAAPb,EAASgB,mBAAOH,GAAhBA,EAAAI,KAAAjB,QAEAW,EAAWO,IAAI,SAAUR,GACzBV,SAAec,QAARA,EAAPd,EAASmB,kBAAML,GAAfA,EAAAG,KAAAjB,GAGFS,EAASE,EAAWI,aATO,GAYvBK,EAAQ,WACZ,IAAMC,EAAUzB,EA1FD,SAACA,GAClB,MAAsB,mBAAXA,EACFA,IAGLA,aAAkB0B,QACb1B,EAGFA,EAAO2B,OAChB,CAgF6BC,CAAW5B,GAAUK,EAAYsB,QAC1D,GAAKF,GAEDV,EAAWC,UACb,IACED,EAAWc,QAAQJ,GACnBV,EAAWe,GAAG,SAAUhB,EACzB,CAAC,MAAOiB,GACPC,QAAQD,MAAMA,EAChB,GAIEE,EAAO,WACPlB,EAAWC,WAAWD,EAAWkB,QAYvC,OAJAC,GAAW,WACLnB,EAAWC,WAAWD,EAAWO,IAAI,SAAUR,EACrD,IAEAqB,EAAAA,EACM,CAAA,GAACnC,GAAU,CAAEoC,IAAK/B,IAAa,CAAA,EAAA,CACnCmB,MAAAA,EACAS,KAAAA,EACAI,OAba,WACb,GAAIzB,EAAO,OAAOqB,IAClBT,KAYAZ,MAAAA,GAEJ"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as n}from"../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.31 */
|
|
2
|
+
import{_ as n}from"../../_rollupPluginBabelHelpers-DmI4-Pc6.js";import{useState as o,useEffect as e}from"react";var r=function(){return decodeURIComponent(window.location.hash.replace("#",""))},t=function(){var t=o(window?r():""),i=n(t,2),a=i[0],c=i[1];return e((function(){var n=function(){return c(r())};return window.addEventListener("hashchange",n),function(){window.removeEventListener("hashchange",n)}})),[a,function(n){window.location.hash=n,c(n)}]};export{t as useHash};
|
|
3
3
|
//# sourceMappingURL=useHash.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useHash.js","sources":["../../../../src/hooks/useHash/useHash.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"useHash.js","sources":["../../../../src/hooks/useHash/useHash.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nconst getHash = () => decodeURIComponent(window.location.hash.replace('#', ''));\n\n/** The use hash return type */\ntype UseHashReturn = [string, (value: string) => void];\n\n/**\n * @name useHash\n * @description - Hook that manages the hash value\n *\n * @returns {UseHashReturn} An array containing the hash value and a function to set the hash value\n *\n * @example\n * const [hash, setHash] = useHash();\n */\nexport const useHash = (): UseHashReturn => {\n const [hash, setHash] = useState(window ? getHash() : '');\n\n const set = (value: string) => {\n window.location.hash = value;\n setHash(value);\n };\n\n useEffect(() => {\n const onHashChange = () => setHash(getHash());\n window.addEventListener('hashchange', onHashChange);\n return () => {\n window.removeEventListener('hashchange', onHashChange);\n };\n });\n\n return [hash, set] as const;\n};\n"],"names":["getHash","decodeURIComponent","window","location","hash","replace","useHash","_useState","useState","_useState2","_slicedToArray","setHash","useEffect","onHashChange","addEventListener","removeEventListener","value"],"mappings":";gHAEA,IAAMA,EAAU,WAAH,OAASC,mBAAmBC,OAAOC,SAASC,KAAKC,QAAQ,IAAK,IAAI,EAclEC,EAAU,WACrB,IAAAC,EAAwBC,EAASN,OAASF,IAAY,IAAGS,EAAAC,EAAAH,EAAA,GAAlDH,EAAIK,EAAA,GAAEE,EAAOF,EAAA,GAepB,OARAG,GAAU,WACR,IAAMC,EAAe,WAAH,OAASF,EAAQX,IAAU,EAE7C,OADAE,OAAOY,iBAAiB,aAAcD,GAC/B,WACLX,OAAOa,oBAAoB,aAAcF,GAE7C,IAEO,CAACT,EAbI,SAACY,GACXd,OAAOC,SAASC,KAAOY,EACvBL,EAAQK,IAYZ"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as e,c as o}from"../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.31 */
|
|
2
|
+
import{_ as e,c as o}from"../../_rollupPluginBabelHelpers-DmI4-Pc6.js";import{useState as n}from"react";import{useDidUpdate as t}from"../useDidUpdate/useDidUpdate.js";import{useEventListener as r}from"../useEventListener/useEventListener.js";import"../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js";import"../../utils/helpers/isClient.js";import"../useEvent/useEvent.js";var i=function(e,o){return e.toLowerCase().split(/[+_-]/g).map((function(e){return e.trim()})).every((function(e){return o.find((function(o){return e===o.code.toLocaleLowerCase()||e===o.key.toLocaleLowerCase()||e===o.alias.toLocaleLowerCase()}))}))},u=function(u,l,a){var s,c,d,f,v=null===(s=null==a?void 0:a.enabled)||void 0===s||s,p=null===(c=null==a?void 0:a.preventDefault)||void 0===c||c,m=n([]),y=e(m,2)[1];t((function(){y([])}),[v]),r(null!==(d=null==a?void 0:a.target)&&void 0!==d?d:window,"keydown",(function(e){p&&e.preventDefault(),v&&y((function(n){var t,r,s,c;if(n.some((function(o){return o.code===e.code})))return n;var d=null!==(t=null!==(r=null==a||null===(s=a.aliasMap)||void 0===s?void 0:s[e.key])&&void 0!==r?r:null==a||null===(c=a.aliasMap)||void 0===c?void 0:c[e.key])&&void 0!==t?t:e.code,f=[].concat(o(n),[{key:e.key,code:e.code,alias:d}]);Array.isArray(u)?u.forEach((function(o){i(o,f)&&l(e)})):i(u,f)&&l(e);return f}))})),r(null!==(f=null==a?void 0:a.target)&&void 0!==f?f:window,"keyup",(function(e){v&&y((function(o){return o.filter((function(o){return o.code!==e.code}))}))}))};export{i as isHotkeyMatch,u as useHotkeys};
|
|
3
3
|
//# sourceMappingURL=useHotkeys.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useHotkeys.js","sources":["../../../../src/hooks/useHotkeys/useHotkeys.ts"],"sourcesContent":["import
|
|
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 */\nexport interface UseHotkeysOptions {\n /** The target to attach the event listeners to */\n target?: UseEventListenerTarget;\n\n /** Enable or disable the event listeners */\n enabled?: boolean;\n\n /** Whether to prevent the default behavior of the event */\n preventDefault?: boolean;\n\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 *\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","useHotkeys","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":";4XAqBO,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,EAuBQE,EAAa,SACxBC,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,EAA0B,IAArCC,EAAwCC,EAAAH,EAAA,GAAjC,GA+BhBI,GAAa,WACXF,EAAQ,GACV,GAAG,CAACJ,IAEJO,UAAgBT,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,EAAJ5B,OAAoBqB,EAAMrB,QAAO,OAAOsB,EAC7D,IAAMpB,EAAwE,QAAnEqB,EAAiC,QAAjCC,EAAGlB,SAAiBmB,QAAVA,EAAPnB,EAASuB,gBAATJ,IAAiBA,OAAjBA,EAAAA,EAAoBJ,EAAM1B,YAAI,IAAA6B,EAAAA,EAAIlB,SAAiB,QAAVoB,EAAPpB,EAASuB,gBAAQ,IAAAH,OAAA,EAAjBA,EAAoBL,EAAM1B,YAAI,IAAA4B,EAAAA,EAAIF,EAAMrB,KAClF8B,EAAWC,GAAAA,OAAAC,EAAOV,GAAU,CAAA,CAAE3B,IAAK0B,EAAM1B,IAAKK,KAAMqB,EAAMrB,KAAME,MAAAA,KAElE+B,MAAMC,QAAQ9B,GAChBA,EAAQ+B,SAAQ,SAAC7C,GACCD,EAAcC,EAAQwC,IACzBzB,EAASgB,EACxB,IAEgBhC,EAAce,EAAS0B,IAC1BzB,EAASgB,GAGxB,OAAOS,CACT,OAaFZ,UAAgBR,EAACJ,aAAO,EAAPA,EAASa,cAAM,IAAAT,EAAAA,EAAIU,OAAQ,SAV5B,SAACC,GACVV,GACLI,GAAQ,SAACO,GAAQ,OAAKA,EAASc,QAAO,SAAAC,GAAO,OAAAA,EAAJrC,OAAoBqB,EAAMrB,aASvE"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{a as e,_ as n}from"../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.31 */
|
|
2
|
+
import{a as e,_ as n}from"../../_rollupPluginBabelHelpers-DmI4-Pc6.js";import{useState as t,useRef as o}from"react";import{useEventListener as l}from"../useEventListener/useEventListener.js";import"../useEvent/useEvent.js";import"../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js";import"../../utils/helpers/isClient.js";var i=function(){var i=(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],r=i?"object"===e(arguments.length<=1?void 0:arguments[1])?arguments.length<=1?void 0:arguments[1]:{onEntry:arguments.length<=1?void 0:arguments[1]}:"object"===e(arguments.length<=0?void 0:arguments[0])?arguments.length<=0?void 0:arguments[0]:{onEntry:arguments.length<=0?void 0:arguments[0]},u=t(!1),s=n(u,2),v=s[0],a=s[1],c=o(null);return l(null!=i?i:c,"mouseenter",(function(){var e;null==r||null===(e=r.onEntry)||void 0===e||e.call(r),a(!0)})),l(null!=i?i:c,"mouseleave",(function(){var e;null==r||null===(e=r.onLeave)||void 0===e||e.call(r),a(!1)})),i?v:[c,v]};export{i as useHover};
|
|
3
3
|
//# sourceMappingURL=useHover.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useHover.js","sources":["../../../../src/hooks/useHover/useHover.ts"],"sourcesContent":["import
|
|
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> | Element;\n//* The use hover return type */\nexport type UseHoverReturn<Target extends UseHoverTarget> = [RefObject<Target>, boolean];\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>(callback?: () => void, target?: never): UseHoverReturn<Target>;\n\n <Target extends UseHoverTarget>(\n options?: UseHoverOptions,\n target?: never\n ): UseHoverReturn<Target>;\n};\n\n/**\n * @name useHover\n * @description - Hook that defines the logic when hovering an element\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]) ? undefined : 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>(null);\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":["useHover","target","arguments","length","undefined","Function","options","_typeof","onEntry","_useState","useState","_useState2","_slicedToArray","hovering","setHovering","internalRef","useRef","useEventListener","_options$onEntry","call","_options$onLeave","onLeave"],"mappings":";6UA6EaA,EAAY,WACvB,IAAMC,GACJC,UAAAC,QAAA,OAAAC,EAAAF,UAAqBG,cAAAA,YAAc,YAASH,UAAAC,eAAAC,EAAAF,UAAA,MAA0BA,UAAAC,QAAA,OAATC,EAASF,UACzC,GAEzBI,EACJL,EACyB,WAArBM,EAAAL,UAAAC,QAAAC,OAAAA,EAAAF,UAAA,IAA6BA,UAAAC,QAAAC,OAAAA,EAAAF,UAE3B,GAAA,CAAEM,QAAON,UAAAC,QAAAC,OAAAA,EAAAF,UAAA,IACU,WAArBK,EAAAL,UAAAC,QAAA,OAAAC,EAAAF,cAA6BA,UAAAC,eAAAC,EAAAF,UAE3B,GAAA,CAAEM,QAAON,UAAAC,QAAAC,OAAAA,EAAAF,UAAA,IAGjBO,EAAgCC,GAAS,GAAMC,EAAAC,EAAAH,EAAA,GAAxCI,EAAQF,EAAA,GAAEG,EAAWH,EAAA,GACtBI,EAAcC,EAAgB,MAepC,OAHAC,EAAiBhB,QAAAA,EAAUc,EAAa,cAVnB,WAAM,IAAAG,EACzBZ,SAAgBY,QAATA,EAAPZ,EAASE,mBAAOU,GAAhBA,EAAAC,KAAAb,GACAQ,GAAY,MASdG,EAAiBhB,QAAAA,EAAUc,EAAa,cANnB,WAAM,IAAAK,EACzBd,SAAgBc,QAATA,EAAPd,EAASe,mBAAOD,GAAhBA,EAAAD,KAAAb,GACAQ,GAAY,MAMVb,EAAeY,EACZ,CAACE,EAAaF,EACvB"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as e}from"../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.31 */
|
|
2
|
+
import{_ as e}from"../../_rollupPluginBabelHelpers-DmI4-Pc6.js";import{useState as t,useEffect as n}from"react";import"../../utils/helpers/isClient.js";import{throttle as i}from"../../utils/helpers/throttle.js";var o=["mousemove","mousedown","keydown","touchstart","wheel","resize"],r=function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:6e4,u=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=u.initialValue,l=void 0!==s&&s,a=u.events,c=void 0===a?o:a,d=t(l),m=e(d,2),v=m[0],f=m[1],h=t(Date.now()),p=e(h,2),w=p[0],E=p[1];return n((function(){var e,t=function(){return f(!0)},n=i((function(){f(!1),E(Date.now()),clearTimeout(e),e=setTimeout(t,r)}),500),o=function(){document.hidden||n()};return e=setTimeout(t,r),c.forEach((function(e){return window.addEventListener(e,n)})),document.addEventListener("visibilitychange",o),function(){c.forEach((function(e){return window.addEventListener(e,n)})),document.removeEventListener("visibilitychange",o),clearTimeout(e)}}),[r,c]),{idle:v,lastActive:w}};export{r as useIdle};
|
|
3
3
|
//# sourceMappingURL=useIdle.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIdle.js","sources":["../../../../src/hooks/useIdle/useIdle.ts"],"sourcesContent":["import
|
|
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\ninterface UseIdleOptions {\n initialValue?: boolean;\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 *\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","useIdle","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":";mNASA,IAAMA,EAAc,CAClB,YACA,YACA,UACA,aACA,QACA,UAwBWC,EAAU,WAGH,IAFlBC,EAAYC,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,GAvBK,IAuBQG,EAAAH,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,GACwC,CAAE,EAAAI,EAAAD,EAAjEE,aAAAA,OAAe,IAAHD,GAAQA,EAAAE,EAAAH,EAAEI,OAAAA,OAASV,IAAHS,EAAGT,EAAWS,EAE5CE,EAAwBC,EAASJ,GAAaK,EAAAC,EAAAH,EAAA,GAAvCI,EAAIF,EAAA,GAAEG,EAAOH,EAAA,GACpBI,EAAoCL,EAASM,KAAKC,OAAMC,EAAAN,EAAAG,EAAA,GAAjDI,EAAUD,EAAA,GAAEE,EAAaF,EAAA,GA6BhC,OA3BAG,GAAU,WACR,IAAIC,EACEC,EAAY,WAAH,OAAST,GAAQ,EAAK,EAE/BU,EAAUC,GAAS,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
|
-
import{a as n,_ as e,b as t}from"../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.31 */
|
|
2
|
+
import{a as n,_ as e,b as t}from"../../_rollupPluginBabelHelpers-DmI4-Pc6.js";import{useState as r,useRef as o,useEffect as i}from"react";var l=function(){var l,u="object"!==n(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,c=u?arguments.length<=1?void 0:arguments[1]:arguments.length<=0?void 0:arguments[0],v=null===(l=null==c?void 0:c.enabled)||void 0===l||l,a=r(),d=e(a,2),s=d[0],f=d[1],g=o(null),h=o();return h.current=null==c?void 0:c.onChange,i((function(){if(v){var n,r=u?function(n){return"function"==typeof n?n():n instanceof Element?n:n.current}(u):g.current,o=new IntersectionObserver((function(n){var t,r=e(n,1)[0];f(r),null===(t=h.current)||void 0===t||t.call(h,r)}),t(t({},c),{},{root:(n=null==c?void 0:c.root,n?n instanceof Element||n instanceof Document?n:n.current:document)}));return o.observe(r),function(){o.disconnect()}}}),[u,null==c?void 0:c.rootMargin,null==c?void 0:c.threshold,v]),u?{entry:s,inView:!(null==s||!s.isIntersecting)}:{ref:g,entry:s,inView:!(null==s||!s.isIntersecting)}};export{l as useIntersectionObserver};
|
|
3
3
|
//# sourceMappingURL=useIntersectionObserver.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIntersectionObserver.js","sources":["../../../../src/hooks/useIntersectionObserver/useIntersectionObserver.ts"],"sourcesContent":["import
|
|
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\nexport type UseIntersectionObserverTarget = RefObject<Element | null> | (() => Element) | Element;\n\nexport interface UseIntersectionObserverOptions extends Omit<IntersectionObserverInit, 'root'> {\n enabled?: boolean;\n onChange?: (entry: IntersectionObserverEntry) => void;\n root?: IntersectionObserverInit['root'] | RefObject<Element | null>;\n}\n\nconst getTargetElement = (target: UseIntersectionObserverTarget) => {\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\nconst getRootElement = (root: UseIntersectionObserverOptions['root']) => {\n if (!root) return document;\n\n if (root instanceof Element) {\n return root;\n }\n\n if (root instanceof Document) {\n return root;\n }\n\n return root.current;\n};\n\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: RefObject<Target> };\n};\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 = useRef<Element>(null);\n const onChangeRef = useRef<UseIntersectionObserverOptions['onChange']>();\n onChangeRef.current = options?.onChange;\n\n useEffect(() => {\n if (!enabled) return;\n\n const element = target ? getTargetElement(target) : internalRef.current;\n const observer = new IntersectionObserver(\n ([entry]) => {\n setEntry(entry);\n onChangeRef.current?.(entry);\n },\n {\n ...options,\n root: getRootElement(options?.root)\n }\n );\n\n observer.observe(element!);\n\n return () => {\n observer.disconnect();\n };\n }, [target, options?.rootMargin, options?.threshold, enabled]);\n\n if (target) return { entry, inView: !!entry?.isIntersecting };\n return { ref: internalRef, entry, inView: !!entry?.isIntersecting };\n}) as UseIntersectionObserver;\n"],"names":["useIntersectionObserver","_options$enabled","target","_typeof","arguments","length","undefined","options","enabled","_useState","useState","_useState2","_slicedToArray","entry","setEntry","internalRef","useRef","onChangeRef","current","onChange","useEffect","root","element","Element","getTargetElement","observer","IntersectionObserver","_ref","_onChangeRef$current","call","_objectSpread","Document","document","observe","disconnect","rootMargin","threshold","inView","isIntersecting","ref"],"mappings":";0IAWA,IA2CaA,EAA2B,WAAsB,IAAAC,EACtDC,EACiB,WAArBC,EAAAC,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,IAAqCC,EAAAC,EAAAH,EAAA,GAAxDI,EAAKF,EAAA,GAAEG,EAAQH,EAAA,GAEhBI,EAAcC,EAAgB,MAC9BC,EAAcD,IAyBpB,OAxBAC,EAAYC,QAAUX,aAAO,EAAPA,EAASY,SAE/BC,GAAU,WACR,GAAKZ,EAAL,CAEA,IA/CoBa,EA+CdC,EAAUpB,EA3DK,SAACA,GACxB,MAAsB,mBAAXA,EACFA,IAGLA,aAAkBqB,QACbrB,EAGFA,EAAOgB,OAChB,CAiD6BM,CAAiBtB,GAAUa,EAAYG,QAC1DO,EAAW,IAAIC,sBACnB,SAAAC,GAAa,IAAAC,EAAXf,EAAWD,EAAAe,EAAA,GAAN,GACLb,EAASD,GACUe,QAAnBA,EAAAX,EAAYC,eAAZU,IAAmBA,GAAnBA,EAAAC,KAAAZ,EAAsBJ,EACvB,GAAAiB,EAAAA,KAEIvB,GAAO,CAAA,EAAA,CACVc,MAvDgBA,EAuDKd,aAAO,EAAPA,EAASc,KAtD/BA,EAEDA,aAAgBE,SAIhBF,aAAgBU,SAHXV,EAOFA,EAAKH,QAVMc,aA4DhB,OAFAP,EAASQ,QAAQX,GAEV,WACLG,EAASS,aAjBG,IAmBb,CAAChC,EAAQK,aAAAA,EAAAA,EAAS4B,WAAY5B,aAAAA,EAAAA,EAAS6B,UAAW5B,IAEjDN,EAAe,CAAEW,MAAAA,EAAOwB,SAAUxB,UAAAA,EAAOyB,iBACtC,CAAEC,IAAKxB,EAAaF,MAAAA,EAAOwB,SAAUxB,UAAAA,EAAOyB,gBACrD"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{a as e,_ as r}from"../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.31 */
|
|
2
|
+
import{a as e,_ as r}from"../../_rollupPluginBabelHelpers-DmI4-Pc6.js";import{useState as t,useRef as n,useEffect as u}from"react";import{useEvent as l}from"../useEvent/useEvent.js";import"../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js";import"../../utils/helpers/isClient.js";var o=function(){for(var o,i,a=arguments.length,s=new Array(a),c=0;c<a;c++)s[c]=arguments[c];var f=s[0],v=null!==(o="number"==typeof s[1]?s[1]:s[1].interval)&&void 0!==o?o:1e3,p="object"===e(s[1])?s[1]:s[2],m=null===(i=null==p?void 0:p.enabled)||void 0===i||i,I=t(null==m||m),j=r(I,2),b=j[0],d=j[1],h=n(),y=l(f);u((function(){if(m)return h.current=setInterval(y,v),function(){clearInterval(h.current)}}),[m,v]);return{isActive:b,pause:function(){d(!1),clearInterval(h.current)},resume:function(){v<=0||(d(!0),clearInterval(h.current),h.current=setInterval(y,v))}}};export{o as useInterval};
|
|
3
3
|
//# sourceMappingURL=useInterval.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useInterval.js","sources":["../../../../src/hooks/useInterval/useInterval.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"useInterval.js","sources":["../../../../src/hooks/useInterval/useInterval.ts"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\n\nimport { useEvent } from '../useEvent/useEvent';\n\n/** The use interval options */\nexport interface UseIntervalOptions {\n /** Start the interval immediately */\n enabled?: boolean;\n}\n\n/** The use interval return type */\nexport interface UseIntervalReturn {\n /** Is the interval active */\n isActive: boolean;\n /** Pause the interval */\n pause: () => void;\n /** Resume the interval */\n resume: () => void;\n}\n\ntype UseInterval = {\n (callback: () => void, interval?: number, options?: UseIntervalOptions): UseIntervalReturn;\n (callback: () => void, options?: UseIntervalOptions & { interval?: number }): UseIntervalReturn;\n};\n\n/**\n * @name useInterval\n * @description - Hook that makes and interval and returns controlling functions\n *\n * @overload\n * @param {() => void} callback Any callback function\n * @param {number} [interval=1000] Time in milliseconds\n * @param {boolean} [options.immediate=true] Start the interval immediately\n * @returns {UseIntervalReturn}\n *\n * @example\n * const { isActive, pause, resume } = useInterval(() => console.log('inside interval'), 2500);\n *\n * @overload\n * @param {() => void} callback Any callback function\n * @param {number} [options.interval=1000] Time in milliseconds\n * @param {boolean} [options.immediate=true] Start the interval immediately\n *\n * @example\n * const { isActive, pause, resume } = useInterval(() => console.log('inside interval'), { interval: 2500 });\n */\nexport const useInterval = ((...params: any[]): UseIntervalReturn => {\n const callback = params[0] as () => void;\n const interval =\n ((typeof params[1] === 'number'\n ? params[1]\n : (params[1] as UseIntervalOptions & { interval?: number }).interval) as number) ?? 1000;\n const options =\n typeof params[1] === 'object'\n ? (params[1] as (UseIntervalOptions & { interval?: number }) | undefined)\n : (params[2] as UseIntervalOptions | undefined);\n const enabled = options?.enabled ?? true;\n\n const [isActive, setIsActive] = useState<boolean>(enabled ?? true);\n\n const intervalIdRef = useRef<ReturnType<typeof setInterval>>();\n const internalCallback = useEvent(callback);\n\n useEffect(() => {\n if (!enabled) return;\n\n intervalIdRef.current = setInterval(internalCallback, interval);\n return () => {\n clearInterval(intervalIdRef.current);\n };\n }, [enabled, interval]);\n\n const pause = () => {\n setIsActive(false);\n clearInterval(intervalIdRef.current);\n };\n\n const resume = () => {\n if (interval <= 0) return;\n setIsActive(true);\n clearInterval(intervalIdRef.current);\n intervalIdRef.current = setInterval(internalCallback, interval);\n };\n\n return {\n isActive,\n pause,\n resume\n };\n}) as UseInterval;\n"],"names":["useInterval","_ref","_options$enabled","_len","arguments","length","params","Array","_key","callback","interval","options","_typeof","enabled","_useState","useState","_useState2","_slicedToArray","isActive","setIsActive","intervalIdRef","useRef","internalCallback","useEvent","useEffect","current","setInterval","clearInterval","pause","resume"],"mappings":";oSA8CaA,EAAe,WAAyC,IAAA,IAAAC,EAAAC,EAAAC,EAAAC,UAAAC,OAArCC,EAAMC,IAAAA,MAAAJ,GAAAK,EAAA,EAAAA,EAAAL,EAAAK,IAANF,EAAME,GAAAJ,UAAAI,GACpC,IAAMC,EAAWH,EAAO,GAClBI,EAGkE,QAH1DT,EACW,iBAAdK,EAAO,GACZA,EAAO,GACNA,EAAO,GAAkDI,gBAAQ,IAAAT,EAAAA,EAAgB,IAClFU,EACiB,WAArBC,EAAON,EAAO,IACTA,EAAO,GACPA,EAAO,GACRO,EAA0BX,QAAnBA,EAAGS,aAAO,EAAPA,EAASE,eAAOX,IAAAA,GAAAA,EAEhCY,EAAgCC,EAAkBF,SAAAA,GAAgBG,EAAAC,EAAAH,EAAA,GAA3DI,EAAQF,EAAA,GAAEG,EAAWH,EAAA,GAEtBI,EAAgBC,IAChBC,EAAmBC,EAASd,GAElCe,GAAU,WACR,GAAKX,EAGL,OADAO,EAAcK,QAAUC,YAAYJ,EAAkBZ,GAC/C,WACLiB,cAAcP,EAAcK,SAEhC,GAAG,CAACZ,EAASH,IAcb,MAAO,CACLQ,SAAAA,EACAU,MAdY,WACZT,GAAY,GACZQ,cAAcP,EAAcK,UAa5BI,OAVa,WACTnB,GAAY,IAChBS,GAAY,GACZQ,cAAcP,EAAcK,SAC5BL,EAAcK,QAAUC,YAAYJ,EAAkBZ,KAQ1D"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import r
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.31 */
|
|
2
|
+
import{useRef as r}from"react";var t=function(){var t=r(!0);return!0===t.current?(t.current=!1,!0):t.current};export{t as useIsFirstRender};
|
|
3
3
|
//# sourceMappingURL=useIsFirstRender.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIsFirstRender.js","sources":["../../../../src/hooks/useIsFirstRender/useIsFirstRender.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"useIsFirstRender.js","sources":["../../../../src/hooks/useIsFirstRender/useIsFirstRender.ts"],"sourcesContent":["import { useRef } from 'react';\n\n/**\n * @name useIsFirstRender\n * @description - Hook that returns true if the component is first render\n *\n * @returns {boolean} True if the component is first render\n *\n * @example\n * const isFirstRender = useIsFirstRender();\n */\nexport const useIsFirstRender = () => {\n const renderRef = useRef(true);\n\n if (renderRef.current === true) {\n renderRef.current = false;\n return true;\n }\n\n return renderRef.current;\n};\n"],"names":["useIsFirstRender","renderRef","useRef","current"],"mappings":";mCAWaA,EAAmB,WAC9B,IAAMC,EAAYC,GAAO,GAEzB,OAA0B,IAAtBD,EAAUE,SACZF,EAAUE,SAAU,GACb,GAGFF,EAAUE,OACnB"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.31 */
|
|
2
|
+
import{useLayoutEffect as r,useEffect as t}from"react";import{isClient as e}from"../../utils/helpers/isClient.js";var i=e?r:t;export{i as useIsomorphicLayoutEffect};
|
|
3
3
|
//# sourceMappingURL=useIsomorphicLayoutEffect.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIsomorphicLayoutEffect.js","sources":["../../../../src/hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"useIsomorphicLayoutEffect.js","sources":["../../../../src/hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.ts"],"sourcesContent":["import { useEffect, useLayoutEffect } from 'react';\n\nimport { isClient } from '@/utils/helpers';\n\n/**\n * @name useIsomorphicLayoutEffect\n * @description - Hook conditionally selects either `useLayoutEffect` or `useEffect` based on the environment\n *\n * @example\n * useIsomorphicLayoutEffect(() => console.log('effect'), [])\n */\nexport const useIsomorphicLayoutEffect = isClient ? useLayoutEffect : useEffect;\n"],"names":["useIsomorphicLayoutEffect","isClient","useLayoutEffect","useEffect"],"mappings":";sHAWaA,EAA4BC,EAAWC,EAAkBC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as e}from"../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.31 */
|
|
2
|
+
import{_ as e}from"../../_rollupPluginBabelHelpers-DmI4-Pc6.js";import{useState as r}from"react";import{useEventListener as t}from"../useEventListener/useEventListener.js";import"../useEvent/useEvent.js";import"../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js";import"../../utils/helpers/isClient.js";var i=function(i,o){var n,s,u=r(!1),l=e(u,2),a=l[0],p=l[1];return t(null!==(n=null==o?void 0:o.target)&&void 0!==n?n:window,"keydown",(function(e){(Array.isArray(i)?i.includes(e.key):e.key===i)&&p(!0)})),t(null!==(s=null==o?void 0:o.target)&&void 0!==s?s:window,"keyup",(function(e){(Array.isArray(i)?i.includes(e.key):e.key===i)&&p(!1)})),a};export{i as useKeyPress};
|
|
3
3
|
//# sourceMappingURL=useKeyPress.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useKeyPress.js","sources":["../../../../src/hooks/useKeyPress/useKeyPress.ts"],"sourcesContent":["import
|
|
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 *\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":["useKeyPress","key","options","_options$target","_options$target2","_useState","useState","_useState2","_slicedToArray","pressed","setPressed","useEventListener","target","window","event","Array","isArray","includes"],"mappings":";sTAyBO,IAAMA,EAAc,SAACC,EAAqBC,GAAiC,IAAAC,EAAAC,EAChFC,EAA8BC,GAAS,GAAMC,EAAAC,EAAAH,EAAA,GAAtCI,EAAOF,EAAA,GAAEG,EAAUH,EAAA,GAa1B,OAHAI,UAAgBR,EAACD,aAAO,EAAPA,EAASU,cAAM,IAAAT,EAAAA,EAAIU,OAAQ,WAR1B,SAACC,IACbC,MAAMC,QAAQf,GAAOA,EAAIgB,SAASH,EAAMb,KAAOa,EAAMb,MAAQA,IAAKS,GAAW,MAQnFC,UAAgBP,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.
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.31 */
|
|
2
2
|
import{useEventListener as e}from"../useEventListener/useEventListener.js";import"react";import"../useEvent/useEvent.js";import"../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js";import"../../utils/helpers/isClient.js";var t=function(){var t=Array.isArray(arguments.length<=0?void 0:arguments[0])?arguments.length<=0?void 0:arguments[0]:[arguments.length<=0?void 0:arguments[0]],n=(arguments.length<=1?void 0:arguments[1])instanceof Function?null:arguments.length<=1?void 0:arguments[1],i=n?arguments.length<=2?void 0:arguments[2]:arguments.length<=1?void 0:arguments[1];e(null!=n?n:window,"keydown",(function(e){t.includes(e.key)&&i(e)}),n?arguments.length<=3?void 0:arguments[3]:arguments.length<=2?void 0:arguments[2])};export{t as useKeyPressEvent};
|
|
3
3
|
//# sourceMappingURL=useKeyPressEvent.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.31 */
|
|
2
2
|
import{useEventListener as o}from"../useEventListener/useEventListener.js";import"react";import"../useEvent/useEvent.js";import"../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js";import"../../utils/helpers/isClient.js";var e=function(e){var n,t;o(null!==(n=null==e?void 0:e.target)&&void 0!==n?n:window,"keydown",(function(o){var n;return null==e||null===(n=e.onKeyDown)||void 0===n?void 0:n.call(e,o)})),o(null!==(t=null==e?void 0:e.target)&&void 0!==t?t:window,"keyup",(function(o){var n;return null==e||null===(n=e.onKeyUp)||void 0===n?void 0:n.call(e,o)}))};export{e as useKeyboard};
|
|
3
3
|
//# sourceMappingURL=useKeyboard.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as e,c as o}from"../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.31 */
|
|
2
|
+
import{_ as e,c as o}from"../../_rollupPluginBabelHelpers-DmI4-Pc6.js";import{useState as t}from"react";import{useDidUpdate as n}from"../useDidUpdate/useDidUpdate.js";import{useEventListener as r}from"../useEventListener/useEventListener.js";import"../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js";import"../../utils/helpers/isClient.js";import"../useEvent/useEvent.js";var i=function(i){var u,s,c,l=null===(u=null==i?void 0:i.enabled)||void 0===u||u,d=t([]),f=e(d,2),p=f[0],a=f[1];return n((function(){a([])}),[l]),r(null!==(s=null==i?void 0:i.target)&&void 0!==s?s:window,"keydown",(function(e){l&&a((function(t){return t.some((function(o){return o.code===e.code}))?t:[].concat(o(t),[{key:e.key,code:e.code}])}))})),r(null!==(c=null==i?void 0:i.target)&&void 0!==c?c:window,"keyup",(function(e){l&&a((function(o){return o.filter((function(o){return o.code!==e.code}))}))})),p};export{i as useKeysPressed};
|
|
3
3
|
//# sourceMappingURL=useKeysPressed.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useKeysPressed.js","sources":["../../../../src/hooks/useKeysPressed/useKeysPressed.ts"],"sourcesContent":["import
|
|
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 */\ninterface UseKeysPressedParams {\n /** The target to attach the event listeners to */\n target?: UseEventListenerTarget;\n\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 *\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":["useKeysPressed","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":";gYA0BaA,EAAiB,SAACC,GAAkC,IAAAC,EAAAC,EAAAC,EACzDC,EAAyBH,QAAlBA,EAAGD,aAAM,EAANA,EAAQI,eAAOH,IAAAA,GAAAA,EAC/BI,EAAwBC,EAA0C,IAAGC,EAAAC,EAAAH,EAAA,GAA9DI,EAAIF,EAAA,GAAEG,EAAOH,EAAA,GAsBpB,OAPAI,GAAa,WACXD,EAAQ,GACV,GAAG,CAACN,IAEJQ,UAAgBV,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,EAAWL,GAAU,CAAA,CAAEM,IAAKP,EAAMO,IAAKH,KAAMJ,EAAMI,OACrD,OAaFP,UAAgBT,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
|
-
import{_ as n,c as t}from"../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.31 */
|
|
2
|
+
import{_ as n,c as t}from"../../_rollupPluginBabelHelpers-DmI4-Pc6.js";import{useState as r}from"react";var e=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],u=r(e),c=n(u,2),o=c[0],i=c[1];return{value:o,set:function(n){return i(n)},push:function(n){return i((function(r){return[].concat(t(r),[n])}))},removeAt:function(n){return i((function(r){return[].concat(t(r.slice(0,n)),t(r.slice(n+1)))}))},insertAt:function(n,r){return i((function(e){return[].concat(t(e.slice(0,n)),[r],t(e.slice(n)))}))},updateAt:function(n,t){return i((function(r){return r.map((function(r,e){return e===n?t:r}))}))},clear:function(){return i([])},reset:function(){return i(e)}}};export{e as useList};
|
|
3
3
|
//# sourceMappingURL=useList.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useList.js","sources":["../../../../src/hooks/useList/useList.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"useList.js","sources":["../../../../src/hooks/useList/useList.ts"],"sourcesContent":["import { useState } from 'react';\n\n/** The use list return type */\nexport interface UseListReturn<Item> {\n /** The current list of items */\n value: Item[];\n /** Sets the list of items */\n set: (list: Item[]) => void;\n /** Adds an item to the list */\n push: (item: Item) => void;\n /** Removes an item from the list */\n removeAt: (removeAtIndex: number) => void;\n /** Inserts an item at the specified index */\n insertAt: (insertAtIndex: number, item: Item) => void;\n /** Updates an item at the specified index */\n updateAt: (updateAtIndex: number, item: Item) => void;\n /** Clears the list */\n clear: () => void;\n}\n\n/**\n * @name useList\n * @description - Hook that defines the logic when unmounting a component\n *\n * @template Item - The type of the item\n * @param {Item[] | (() => Item[])} initialList - The initial list of items\n * @returns {UseListReturn} An object containing the current list and functions to interact with the list\n *\n * @example\n * const { value, set, push, removeAt, insertAt, updateAt, clear } = useList();\n */\nexport const useList = <Item>(initialList: Item[] = []) => {\n const [list, setList] = useState(initialList);\n\n const set = (list: Item[]) => setList(list);\n\n const push = (item: Item) => setList((prevList) => [...prevList, item]);\n\n const removeAt = (removeAtIndex: number) =>\n setList((prevList) => [\n ...prevList.slice(0, removeAtIndex),\n ...prevList.slice(removeAtIndex + 1)\n ]);\n\n const insertAt = (insertAtIndex: number, item: Item) =>\n setList((l) => [...l.slice(0, insertAtIndex), item, ...l.slice(insertAtIndex)]);\n\n const updateAt = (updateAtIndex: number, item: Item) =>\n setList((prevList) =>\n prevList.map((element, index) => (index === updateAtIndex ? item : element))\n );\n\n const clear = () => setList([]);\n\n const reset = () => setList(initialList);\n\n return { value: list, set, push, removeAt, insertAt, updateAt, clear, reset };\n};\n"],"names":["useList","initialList","arguments","length","undefined","_useState","useState","_useState2","_slicedToArray","list","setList","value","set","push","item","prevList","concat","_toConsumableArray","removeAt","removeAtIndex","slice","insertAt","insertAtIndex","l","updateAt","updateAtIndex","map","element","index","clear","reset"],"mappings":";4GA+BaA,EAAU,WAAoC,IAA7BC,EAAmBC,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,GAAG,GAClDG,EAAwBC,EAASL,GAAYM,EAAAC,EAAAH,EAAA,GAAtCI,EAAIF,EAAA,GAAEG,EAAOH,EAAA,GAwBpB,MAAO,CAAEI,MAAOF,EAAMG,IAtBV,SAACH,GAAY,OAAKC,EAAQD,EAAK,EAsBhBI,KApBd,SAACC,GAAU,OAAKJ,GAAQ,SAACK,GAAQ,MAAA,GAAAC,OAAAC,EAASF,IAAUD,GAAI,GAAE,EAoBtCI,SAlBhB,SAACC,GAAqB,OACrCT,GAAQ,SAACK,GAAQ,MAAAC,GAAAA,OAAAC,EACZF,EAASK,MAAM,EAAGD,IAAcF,EAChCF,EAASK,MAAMD,EAAgB,IAAE,GACpC,EAcuCE,SAZ1B,SAACC,EAAuBR,GAAU,OACjDJ,GAAQ,SAACa,GAAC,MAAAP,GAAAA,OAAAC,EAASM,EAAEH,MAAM,EAAGE,IAAgBR,CAAAA,GAAIG,EAAKM,EAAEH,MAAME,IAAc,GAAE,EAW5BE,SATpC,SAACC,EAAuBX,GAAU,OACjDJ,GAAQ,SAACK,GAAQ,OACfA,EAASW,KAAI,SAACC,EAASC,GAAK,OAAMA,IAAUH,EAAgBX,EAAOa,CAAO,GAAE,GAC7E,EAM4DE,MAJjD,WAAH,OAASnB,EAAQ,GAAG,EAIuCoB,MAFxD,WAAH,OAASpB,EAAQT,EAAY,EAG1C"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{b as o}from"../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.31 */
|
|
2
|
+
import{b as o}from"../../_rollupPluginBabelHelpers-DmI4-Pc6.js";import{useStorage as r}from"../useStorage/useStorage.js";import"react";import"../../utils/helpers/isClient.js";import"../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js";var e=function(e,t,i){return r(e,o({initialValue:t,storage:window.localStorage},i))};export{e as useLocalStorage};
|
|
3
3
|
//# sourceMappingURL=useLocalStorage.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{c as o}from"../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.31 */
|
|
2
|
+
import{c as o}from"../../_rollupPluginBabelHelpers-DmI4-Pc6.js";import{useEffect as t}from"react";import{useDidUpdate as e}from"../useDidUpdate/useDidUpdate.js";import"../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js";import"../../utils/helpers/isClient.js";var c=function(c,n){t((function(){var t;return(t=console).log.apply(t,["".concat(c," mounted")].concat(o(n))),function(){return console.log("".concat(c," unmounted"))}}),[]),e((function(){var t;(t=console).log.apply(t,["".concat(c," updated")].concat(o(n)))}),n)};export{c as useLogger};
|
|
3
3
|
//# sourceMappingURL=useLogger.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLogger.js","sources":["../../../../src/hooks/useLogger/useLogger.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"useLogger.js","sources":["../../../../src/hooks/useLogger/useLogger.ts"],"sourcesContent":["import { useEffect } from 'react';\n\nimport { useDidUpdate } from '../useDidUpdate/useDidUpdate';\n\n/**\n * @name useLogger\n * @description - Hook for debugging lifecycle\n *\n * @param {string} name The name or identifier for the logger\n * @param {unknown[]} params Additional arguments to be logged\n *\n * @example\n * useLogger('Component', [1, 2, 3]);\n */\nexport const useLogger = (name: string, params: unknown[]) => {\n useEffect(() => {\n console.log(`${name} mounted`, ...params);\n return () => console.log(`${name} unmounted`);\n }, []);\n\n useDidUpdate(() => {\n console.log(`${name} updated`, ...params);\n }, params);\n};\n"],"names":["useLogger","name","params","useEffect","_console","console","log","apply","concat","_toConsumableArray","useDidUpdate","_console2"],"mappings":";2QAcO,IAAMA,EAAY,SAACC,EAAcC,GACtCC,GAAU,WAAM,IAAAC,EAEd,OADAA,EAAAC,SAAQC,IAAGC,MAAAH,MAAAI,OAAIP,EAAIO,aAAAA,OAAAC,EAAeP,KAC3B,WAAA,OAAMG,QAAQC,IAAG,GAAAE,OAAIP,gBAAiB,CAC9C,GAAE,IAEHS,GAAa,WAAM,IAAAC,GACjBA,EAAAN,SAAQC,IAAGC,MAAAI,MAAAH,OAAIP,EAAIO,aAAAA,OAAAC,EAAeP,IACnC,GAAEA,EACL"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.31 */
|
|
2
|
+
import{_ as n}from"../../_rollupPluginBabelHelpers-DmI4-Pc6.js";import{useState as e,useRef as l}from"react";import{useEventListener as t}from"../useEventListener/useEventListener.js";import"../useEvent/useEvent.js";import"../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js";import"../../utils/helpers/isClient.js";var o=function(){var o=(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],u=o?arguments.length<=1?void 0:arguments[1]:arguments.length<=0?void 0:arguments[0],r=o?arguments.length<=2?void 0:arguments[2]:arguments.length<=1?void 0:arguments[1],i=e(!1),s=n(i,2),c=s[0],v=s[1],a=l(null),d=l(),h=l(!1),m=function(n){var e,l;null==r||null===(e=r.onStart)||void 0===e||e.call(r,n),h.current=!0,d.current=setTimeout((function(){u(n),v(!0)}),null!==(l=null==r?void 0:r.threshold)&&void 0!==l?l:400)},f=function(n){var e;if(c)null==r||null===(e=r.onFinish)||void 0===e||e.call(r,n);else if(h.current){var l;null==r||null===(l=r.onCancel)||void 0===l||l.call(r,n)}v(!1),h.current=!1,d.current&&clearTimeout(d.current)};return t(null!=o?o:a,"mousedown",m),t(null!=o?o:a,"touchstart",m),t(null!=o?o:a,"mouseup",f),t(null!=o?o:a,"touchend",f),o?c:[a,c]};export{o as useLongPress};
|
|
3
3
|
//# sourceMappingURL=useLongPress.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLongPress.js","sources":["../../../../src/hooks/useLongPress/useLongPress.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"useLongPress.js","sources":["../../../../src/hooks/useLongPress/useLongPress.ts"],"sourcesContent":["import type { RefObject } from 'react';\nimport { useRef, useState } from 'react';\n\nimport { useEventListener } from '../useEventListener/useEventListener';\n\n// * The use long press target type */\nexport type UseLongPressTarget = RefObject<Element | null> | (() => Element) | Element;\n\n// * The use long press options type */\ninterface UseLongPressOptions {\n // * The threshold time in milliseconds\n threshold?: number;\n // * The callback function to be invoked on long press start\n onStart?: (event: Event) => void;\n // * The callback function to be invoked on long press end\n onFinish?: (event: Event) => void;\n // * The callback function to be invoked on long press cancel\n onCancel?: (event: Event) => void;\n}\n\n// * The use long press return type */\nexport type UseLongPressReturn<Target extends UseLongPressTarget> = [RefObject<Target>, boolean];\n\nexport type UseLongPress = {\n <Target extends UseLongPressTarget>(\n target: Target,\n callback: (event: Event) => void,\n options?: UseLongPressOptions\n ): boolean;\n\n <Target extends UseLongPressTarget>(\n callback: (event: Event) => void,\n options?: UseLongPressOptions,\n target?: never\n ): UseLongPressReturn<Target>;\n};\n\nconst DEFAULT_THRESHOLD_TIME = 400;\n\n/**\n * @name useLongPress\n * @description - Hook that defines the logic when long pressing an element\n *\n * @overload\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 {void}\n *\n * @example\n * const longPressing = useLongPress(ref, () => console.log('callback'));\n *\n * @overload\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 [ref, longPressing] = useLongPress(() => console.log('callback'));\n */\nexport const useLongPress = ((...params: any[]) => {\n const target = (\n params[0] instanceof Function || !('current' in params[0]) ? undefined : params[0]\n ) as UseLongPressTarget | undefined;\n const callback = (target ? params[1] : params[0]) as (event: Event) => void;\n const options = (target ? params[2] : params[1]) as UseLongPressOptions | undefined;\n\n const [isLongPressActive, setIsLongPressActive] = useState(false);\n const internalRef = useRef<Element>(null);\n const timeoutIdRef = useRef<ReturnType<typeof setTimeout>>();\n const isPressed = useRef(false);\n\n const start = (event: Event) => {\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: Event) => {\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 useEventListener(target ?? internalRef, 'mousedown', start);\n useEventListener(target ?? internalRef, 'touchstart', start);\n useEventListener(target ?? internalRef, 'mouseup', cancel);\n useEventListener(target ?? internalRef, 'touchend', cancel);\n\n if (target) return isLongPressActive;\n return [internalRef, isLongPressActive];\n}) as UseLongPress;\n"],"names":["useLongPress","target","arguments","length","undefined","Function","callback","options","_useState","useState","_useState2","_slicedToArray","isLongPressActive","setIsLongPressActive","internalRef","useRef","timeoutIdRef","isPressed","start","event","_options$onStart","_options$threshold","onStart","call","current","setTimeout","threshold","cancel","_options$onFinish","onFinish","_options$onCancel","onCancel","clearTimeout","useEventListener"],"mappings":";kUAqCA,IAgCaA,EAAgB,WAC3B,IAAMC,GACJC,UAAAC,QAAA,OAAAC,EAAAF,UAAqBG,cAAAA,YAAc,YAASH,UAAAC,eAAAC,EAAAF,UAAA,MAA0BA,UAAAC,QAAA,OAATC,EAASF,UACrC,GAC7BI,EAAYL,EAAMC,UAAAC,QAAAC,OAAAA,EAAAF,UAAA,GAAAA,UAAAC,eAAAC,EAAAF,UAAmD,GACrEK,EAAWN,EAAMC,UAAAC,QAAAC,OAAAA,EAAAF,UAAA,GAAAA,UAAAC,eAAAC,EAAAF,UAA4D,GAEnFM,EAAkDC,GAAS,GAAMC,EAAAC,EAAAH,EAAA,GAA1DI,EAAiBF,EAAA,GAAEG,EAAoBH,EAAA,GACxCI,EAAcC,EAAgB,MAC9BC,EAAeD,IACfE,EAAYF,GAAO,GAEnBG,EAAQ,SAACC,GAAiB,IAAAC,EAAAC,EAC9Bd,SAAgB,QAATa,EAAPb,EAASe,eAAO,IAAAF,GAAhBA,EAAAG,KAAAhB,EAAmBY,GAEnBF,EAAUO,SAAU,EACpBR,EAAaQ,QAAUC,YAAW,WAChCnB,EAASa,GACTN,GAAqB,EACvB,WAACQ,EAAEd,aAAAA,EAAAA,EAASmB,iBAAS,IAAAL,EAAAA,EAnDM,MAsDvBM,EAAS,SAACR,GACS,IAAAS,EAAvB,GAAIhB,EACFL,SAAiB,QAAVqB,EAAPrB,EAASsB,gBAAQ,IAAAD,GAAjBA,EAAAL,KAAAhB,EAAoBY,QACf,GAAIF,EAAUO,QAAS,CAAA,IAAAM,EAC5BvB,SAAiB,QAAVuB,EAAPvB,EAASwB,gBAAQ,IAAAD,GAAjBA,EAAAP,KAAAhB,EAAoBY,EACtB,CAEAN,GAAqB,GACrBI,EAAUO,SAAU,EAEhBR,EAAaQ,SAASQ,aAAahB,EAAaQ,UAQtD,OALAS,EAAiBhC,QAAAA,EAAUa,EAAa,YAAaI,GACrDe,EAAiBhC,QAAAA,EAAUa,EAAa,aAAcI,GACtDe,EAAiBhC,QAAAA,EAAUa,EAAa,UAAWa,GACnDM,EAAiBhC,QAAAA,EAAUa,EAAa,WAAYa,GAEhD1B,EAAeW,EACZ,CAACE,EAAaF,EACvB"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import n from"react";var
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.31 */
|
|
2
|
+
import{useCallback as n,useSyncExternalStore as e}from"react";var t=function(){return!1},r=function(r){var a=n((function(n){var e=window.matchMedia(r);return e.addEventListener("change",n),function(){e.removeEventListener("change",n)}}),[r]);return e(a,(function(){return window.matchMedia(r).matches}),t)};export{r as useMediaQuery};
|
|
3
3
|
//# sourceMappingURL=useMediaQuery.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMediaQuery.js","sources":["../../../../src/hooks/useMediaQuery/useMediaQuery.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"useMediaQuery.js","sources":["../../../../src/hooks/useMediaQuery/useMediaQuery.ts"],"sourcesContent":["import { useCallback, useSyncExternalStore } from 'react';\n\nconst getServerSnapshot = () => false;\n\n/**\n * @name useMediaQuery\n * @description - Hook that manages a media query\n *\n * @param {string} query The media query string\n * @returns {boolean} A boolean indicating if the media query matches\n *\n * @example\n * const matches = useMediaQuery('(max-width: 768px)');\n */\nexport const useMediaQuery = (query: string) => {\n const subscribe = useCallback(\n (callback: () => void) => {\n const matchMedia = window.matchMedia(query);\n\n matchMedia.addEventListener('change', callback);\n return () => {\n matchMedia.removeEventListener('change', callback);\n };\n },\n [query]\n );\n\n const getSnapshot = () => window.matchMedia(query).matches;\n\n return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\n};\n"],"names":["getServerSnapshot","useMediaQuery","query","subscribe","useCallback","callback","matchMedia","window","addEventListener","removeEventListener","useSyncExternalStore","matches"],"mappings":";8DAEA,IAAMA,EAAoB,WAAH,OAAS,CAAK,EAYxBC,EAAgB,SAACC,GAC5B,IAAMC,EAAYC,GAChB,SAACC,GACC,IAAMC,EAAaC,OAAOD,WAAWJ,GAGrC,OADAI,EAAWE,iBAAiB,SAAUH,GAC/B,WACLC,EAAWG,oBAAoB,SAAUJ,GAE7C,GACA,CAACH,IAKH,OAAOQ,EAAqBP,GAFR,WAAH,OAASI,OAAOD,WAAWJ,GAAOS,OAAO,GAENX,EACtD"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import r
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.31 */
|
|
2
|
+
import{useEffect as r}from"react";var t=function(t){return r(t,[])};export{t as useMount};
|
|
3
3
|
//# sourceMappingURL=useMount.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMount.js","sources":["../../../../src/hooks/useMount/useMount.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"useMount.js","sources":["../../../../src/hooks/useMount/useMount.ts"],"sourcesContent":["import type { EffectCallback } from 'react';\nimport { useEffect } from 'react';\n\n/**\n * @name useMount\n * @description - Hook that executes a callback when the component mounts\n *\n * @param {EffectCallback} effect The callback to execute\n *\n * @example\n * useMount(() => console.log('This effect runs on the initial render'));\n */\nexport const useMount = (effect: EffectCallback) => useEffect(effect, []);\n"],"names":["useMount","effect","useEffect"],"mappings":";sCAYaA,EAAW,SAACC,GAAsB,OAAKC,EAAUD,EAAQ,GAAG"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as e,b as t}from"../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.31 */
|
|
2
|
+
import{_ as e,b as t}from"../../_rollupPluginBabelHelpers-DmI4-Pc6.js";import{useState as n,useRef as o}from"react";import{useIsomorphicLayoutEffect as r}from"../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js";import"../../utils/helpers/isClient.js";var i=function(){for(var i=arguments.length,l=new Array(i),u=0;u<i;u++)l[u]=arguments[u];var m=l[0],s=n({x:0,y:0,elementX:0,elementY:0,elementPositionX:0,elementPositionY:0}),c=e(s,2),f=c[0],a=c[1],p=o(null);return r((function(){var e=function(e){var n=m?function(e){return"function"==typeof e?e():e instanceof Element?e:e.current}(m):p.current;if(n){var o={x:e.pageX,y:e.pageY},r=n.getBoundingClientRect(),i=r.left,l=r.top,u=i+window.scrollX,s=l+window.scrollY,c=e.pageX-u,f=e.pageY-s;o.elementX=c,o.elementY=f,o.elementPositionX=u,o.elementPositionY=s,a((function(e){return t(t({},e),o)}))}};return document.addEventListener("mousemove",e),function(){document.removeEventListener("mousemove",e)}}),[]),m?f:t(t({},f),{},{ref:p})};export{i as useMouse};
|
|
3
3
|
//# sourceMappingURL=useMouse.js.map
|