@siberiacancode/reactuse 0.0.91 → 0.0.94
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/README.md +1 -1
- package/dist/cjs/_rollupPluginBabelHelpers-EWRwz6fS.js +3 -0
- package/dist/cjs/_rollupPluginBabelHelpers-EWRwz6fS.js.map +1 -0
- package/dist/cjs/hooks/index.js +2 -2
- package/dist/cjs/hooks/useActiveElement/useActiveElement.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/useBluetooth/useBluetooth.js +2 -2
- package/dist/cjs/hooks/useBoolean/useBoolean.js +2 -2
- package/dist/cjs/hooks/useBreakpoints/{constants → helpers}/breakpoints.js +1 -1
- package/dist/cjs/hooks/useBreakpoints/helpers/breakpoints.js.map +1 -0
- package/dist/cjs/hooks/useBreakpoints/helpers/index.js +3 -0
- package/dist/cjs/hooks/useBreakpoints/helpers/index.js.map +1 -0
- 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/useConst/useConst.js +1 -1
- package/dist/cjs/hooks/useCounter/useCounter.js +2 -2
- package/dist/cjs/hooks/useCssVar/useCssVar.js +2 -2
- package/dist/cjs/hooks/useCssVar/useCssVar.js.map +1 -1
- 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/useDeviceMotion/useDeviceMotion.js +2 -2
- package/dist/cjs/hooks/useDeviceMotion/useDeviceMotion.js.map +1 -1
- package/dist/cjs/hooks/useDeviceOrientation/useDeviceOrientation.js +2 -2
- package/dist/cjs/hooks/useDevicePixelRatio/useDevicePixelRatio.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/useDisplayMedia/useDisplayMedia.js +3 -0
- package/dist/cjs/hooks/useDisplayMedia/useDisplayMedia.js.map +1 -0
- 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/useElementSize/useElementSize.js +2 -2
- package/dist/cjs/hooks/useElementSize/useElementSize.js.map +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/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/useFileDialog/useFileDialog.js.map +1 -1
- package/dist/cjs/hooks/useFocus/useFocus.js +2 -2
- package/dist/cjs/hooks/useFocus/useFocus.js.map +1 -1
- package/dist/cjs/hooks/useFps/useFps.js +2 -2
- package/dist/cjs/hooks/useFullscreen/useFullscreen.js +2 -2
- package/dist/cjs/hooks/useFullscreen/useFullscreen.js.map +1 -1
- package/dist/cjs/hooks/useGamepad/helpers/index.js +3 -0
- package/dist/cjs/hooks/useGamepad/helpers/index.js.map +1 -0
- package/dist/cjs/hooks/useGamepad/helpers/mapGamepadToXbox360Controller.js +1 -1
- package/dist/cjs/hooks/useGamepad/useGamepad.js +2 -2
- package/dist/cjs/hooks/useGamepad/useGamepad.js.map +1 -1
- 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/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/useInterval/useInterval.js.map +1 -1
- 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/useLastChanged/useLastChanged.js +2 -2
- package/dist/cjs/hooks/useLatest/useLatest.js +1 -1
- package/dist/cjs/hooks/useList/useList.js +2 -2
- package/dist/cjs/hooks/useLocalStorage/useLocalStorage.js +2 -2
- package/dist/cjs/hooks/useLocalStorage/useLocalStorage.js.map +1 -1
- 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/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/useMutationObserver.js +2 -2
- package/dist/cjs/hooks/useMutationObserver/useMutationObserver.js.map +1 -1
- package/dist/cjs/hooks/useNetwork/useNetwork.js +2 -2
- package/dist/cjs/hooks/useOffsetPagination/useOffsetPagination.js +2 -2
- package/dist/cjs/hooks/useOnline/useOnline.js +1 -1
- package/dist/cjs/hooks/useOperatingSystem/useOperatingSystem.js +1 -1
- package/dist/cjs/hooks/useOptimistic/useOptimistic.js +2 -2
- package/dist/cjs/hooks/useOrientation/useOrientation.js +2 -2
- package/dist/cjs/hooks/useOrientation/useOrientation.js.map +1 -1
- package/dist/cjs/hooks/useOtpCredential/useOtpCredential.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/useParallax/useParallax.js +2 -2
- package/dist/cjs/hooks/useParallax/useParallax.js.map +1 -1
- package/dist/cjs/hooks/usePermission/usePermission.js +2 -2
- package/dist/cjs/hooks/usePointerLock/usePointerLock.js +2 -2
- package/dist/cjs/hooks/usePostMessage/usePostMessage.js +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/useRaf/useRaf.js.map +1 -1
- package/dist/cjs/hooks/useRafValue/useRafValue.js +2 -2
- package/dist/cjs/hooks/useRefState/useRefState.js +2 -2
- package/dist/cjs/hooks/useRefState/useRefState.js.map +1 -1
- 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 +1 -1
- package/dist/cjs/hooks/useResizeObserver/useResizeObserver.js +2 -2
- package/dist/cjs/hooks/useResizeObserver/useResizeObserver.js.map +1 -1
- package/dist/cjs/hooks/useScreenOrientation/useScreenOrientation.js +2 -2
- package/dist/cjs/hooks/useScript/useScript.js +2 -2
- package/dist/cjs/hooks/useScroll/useScroll.js +2 -2
- package/dist/cjs/hooks/useScroll/useScroll.js.map +1 -1
- package/dist/cjs/hooks/useScrollIntoView/useScrollIntoView.js +3 -0
- package/dist/cjs/hooks/useScrollIntoView/useScrollIntoView.js.map +1 -0
- package/dist/cjs/hooks/useScrollTo/useScrollTo.js +2 -2
- package/dist/cjs/hooks/useScrollTo/useScrollTo.js.map +1 -1
- package/dist/cjs/hooks/useSessionStorage/useSessionStorage.js +2 -2
- package/dist/cjs/hooks/useSessionStorage/useSessionStorage.js.map +1 -1
- package/dist/cjs/hooks/useSet/useSet.js +2 -2
- package/dist/cjs/hooks/useShare/useShare.js +2 -2
- package/dist/cjs/hooks/useShare/useShare.js.map +1 -1
- package/dist/cjs/hooks/useStateHistory/useStateHistory.js +3 -0
- package/dist/cjs/hooks/useStateHistory/useStateHistory.js.map +1 -0
- 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/useStorage/useStorage.js.map +1 -1
- package/dist/cjs/hooks/useTextDirection/useTextDirection.js +2 -2
- package/dist/cjs/hooks/useTextDirection/useTextDirection.js.map +1 -1
- package/dist/cjs/hooks/useTextSelection/useTextSelection.js +2 -2
- package/dist/cjs/hooks/useThrottleCallback/useThrottleCallback.js +1 -1
- package/dist/cjs/hooks/useThrottleCallback/useThrottleCallback.js.map +1 -1
- package/dist/cjs/hooks/useThrottleValue/useThrottleValue.js +2 -2
- package/dist/cjs/hooks/useThrottleValue/useThrottleValue.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/useTimer/useTimer.js +2 -2
- package/dist/cjs/hooks/useTimer/useTimer.js.map +1 -1
- package/dist/cjs/hooks/useToggle/useToggle.js +2 -2
- package/dist/cjs/hooks/useUnmount/useUnmount.js +1 -1
- package/dist/cjs/hooks/useVibrate/useVibrate.js +2 -2
- package/dist/cjs/hooks/useVibrate/useVibrate.js.map +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/useWindowFocus/useWindowFocus.js +2 -2
- 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/hooks/useWizard/useWizard.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/{time/getDate.js → getDate.js} +1 -1
- package/dist/cjs/utils/helpers/getDate.js.map +1 -0
- package/dist/cjs/utils/helpers/getElement.js +1 -1
- package/dist/cjs/utils/helpers/getRetry.js +1 -1
- package/dist/cjs/utils/helpers/index.js +2 -2
- package/dist/cjs/utils/helpers/isTarget.js +2 -2
- package/dist/cjs/utils/helpers/isTarget.js.map +1 -1
- package/dist/cjs/utils/helpers/throttle.js +1 -1
- package/dist/cjs/utils/helpers/throttle.js.map +1 -1
- package/dist/esm/_rollupPluginBabelHelpers-Dp_7XWBJ.js +3 -0
- package/dist/esm/_rollupPluginBabelHelpers-Dp_7XWBJ.js.map +1 -0
- package/dist/esm/hooks/index.js +2 -2
- package/dist/esm/hooks/useActiveElement/useActiveElement.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/useBluetooth/useBluetooth.js +2 -2
- package/dist/esm/hooks/useBoolean/useBoolean.js +2 -2
- package/dist/esm/hooks/useBreakpoints/{constants → helpers}/breakpoints.js +1 -1
- package/dist/esm/hooks/useBreakpoints/helpers/breakpoints.js.map +1 -0
- package/dist/esm/hooks/useBreakpoints/helpers/index.js +3 -0
- package/dist/esm/hooks/useBreakpoints/helpers/index.js.map +1 -0
- 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/useConst/useConst.js +1 -1
- package/dist/esm/hooks/useCounter/useCounter.js +2 -2
- package/dist/esm/hooks/useCssVar/useCssVar.js +2 -2
- package/dist/esm/hooks/useCssVar/useCssVar.js.map +1 -1
- 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/useDeviceMotion/useDeviceMotion.js +2 -2
- package/dist/esm/hooks/useDeviceOrientation/useDeviceOrientation.js +2 -2
- package/dist/esm/hooks/useDevicePixelRatio/useDevicePixelRatio.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/useDisplayMedia/useDisplayMedia.js +3 -0
- package/dist/esm/hooks/useDisplayMedia/useDisplayMedia.js.map +1 -0
- 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/useElementSize/useElementSize.js +2 -2
- package/dist/esm/hooks/useElementSize/useElementSize.js.map +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/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/useFileDialog/useFileDialog.js.map +1 -1
- package/dist/esm/hooks/useFocus/useFocus.js +2 -2
- package/dist/esm/hooks/useFocus/useFocus.js.map +1 -1
- package/dist/esm/hooks/useFps/useFps.js +2 -2
- package/dist/esm/hooks/useFullscreen/useFullscreen.js +2 -2
- package/dist/esm/hooks/useFullscreen/useFullscreen.js.map +1 -1
- package/dist/esm/hooks/useGamepad/helpers/index.js +3 -0
- package/dist/esm/hooks/useGamepad/helpers/index.js.map +1 -0
- package/dist/esm/hooks/useGamepad/helpers/mapGamepadToXbox360Controller.js +1 -1
- package/dist/esm/hooks/useGamepad/useGamepad.js +2 -2
- package/dist/esm/hooks/useGamepad/useGamepad.js.map +1 -1
- 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/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/useInterval/useInterval.js.map +1 -1
- 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/useLastChanged/useLastChanged.js +2 -2
- package/dist/esm/hooks/useLatest/useLatest.js +1 -1
- package/dist/esm/hooks/useList/useList.js +2 -2
- package/dist/esm/hooks/useLocalStorage/useLocalStorage.js +2 -2
- package/dist/esm/hooks/useLocalStorage/useLocalStorage.js.map +1 -1
- 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/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/useMutationObserver.js +2 -2
- package/dist/esm/hooks/useMutationObserver/useMutationObserver.js.map +1 -1
- package/dist/esm/hooks/useNetwork/useNetwork.js +2 -2
- package/dist/esm/hooks/useOffsetPagination/useOffsetPagination.js +2 -2
- package/dist/esm/hooks/useOnline/useOnline.js +1 -1
- package/dist/esm/hooks/useOperatingSystem/useOperatingSystem.js +1 -1
- package/dist/esm/hooks/useOptimistic/useOptimistic.js +2 -2
- package/dist/esm/hooks/useOrientation/useOrientation.js +2 -2
- package/dist/esm/hooks/useOrientation/useOrientation.js.map +1 -1
- package/dist/esm/hooks/useOtpCredential/useOtpCredential.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/Pointer.js +2 -2
- package/dist/esm/hooks/usePaint/usePaint.js +2 -2
- package/dist/esm/hooks/useParallax/useParallax.js +2 -2
- package/dist/esm/hooks/useParallax/useParallax.js.map +1 -1
- package/dist/esm/hooks/usePermission/usePermission.js +2 -2
- package/dist/esm/hooks/usePointerLock/usePointerLock.js +2 -2
- package/dist/esm/hooks/usePostMessage/usePostMessage.js +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/useRaf/useRaf.js.map +1 -1
- package/dist/esm/hooks/useRafValue/useRafValue.js +2 -2
- package/dist/esm/hooks/useRefState/useRefState.js +2 -2
- package/dist/esm/hooks/useRefState/useRefState.js.map +1 -1
- 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 +1 -1
- package/dist/esm/hooks/useResizeObserver/useResizeObserver.js +2 -2
- package/dist/esm/hooks/useResizeObserver/useResizeObserver.js.map +1 -1
- package/dist/esm/hooks/useScreenOrientation/useScreenOrientation.js +2 -2
- package/dist/esm/hooks/useScript/useScript.js +2 -2
- package/dist/esm/hooks/useScroll/useScroll.js +2 -2
- package/dist/esm/hooks/useScroll/useScroll.js.map +1 -1
- package/dist/esm/hooks/useScrollIntoView/useScrollIntoView.js +3 -0
- package/dist/esm/hooks/useScrollIntoView/useScrollIntoView.js.map +1 -0
- package/dist/esm/hooks/useScrollTo/useScrollTo.js +2 -2
- package/dist/esm/hooks/useScrollTo/useScrollTo.js.map +1 -1
- package/dist/esm/hooks/useSessionStorage/useSessionStorage.js +2 -2
- package/dist/esm/hooks/useSessionStorage/useSessionStorage.js.map +1 -1
- package/dist/esm/hooks/useSet/useSet.js +2 -2
- package/dist/esm/hooks/useShare/useShare.js +2 -2
- package/dist/esm/hooks/useShare/useShare.js.map +1 -1
- package/dist/esm/hooks/useStateHistory/useStateHistory.js +3 -0
- package/dist/esm/hooks/useStateHistory/useStateHistory.js.map +1 -0
- 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/useStorage/useStorage.js.map +1 -1
- package/dist/esm/hooks/useTextDirection/useTextDirection.js +2 -2
- package/dist/esm/hooks/useTextDirection/useTextDirection.js.map +1 -1
- package/dist/esm/hooks/useTextSelection/useTextSelection.js +2 -2
- package/dist/esm/hooks/useThrottleCallback/useThrottleCallback.js +1 -1
- package/dist/esm/hooks/useThrottleCallback/useThrottleCallback.js.map +1 -1
- package/dist/esm/hooks/useThrottleValue/useThrottleValue.js +2 -2
- package/dist/esm/hooks/useThrottleValue/useThrottleValue.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/useTimer/useTimer.js +2 -2
- package/dist/esm/hooks/useTimer/useTimer.js.map +1 -1
- package/dist/esm/hooks/useToggle/useToggle.js +2 -2
- package/dist/esm/hooks/useUnmount/useUnmount.js +1 -1
- package/dist/esm/hooks/useVibrate/useVibrate.js +2 -2
- package/dist/esm/hooks/useVibrate/useVibrate.js.map +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/useWindowFocus/useWindowFocus.js +2 -2
- 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/hooks/useWizard/useWizard.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/{time/getDate.js → getDate.js} +1 -1
- package/dist/esm/utils/helpers/getDate.js.map +1 -0
- package/dist/esm/utils/helpers/getElement.js +1 -1
- package/dist/esm/utils/helpers/getRetry.js +1 -1
- package/dist/esm/utils/helpers/index.js +2 -2
- package/dist/esm/utils/helpers/isTarget.js +2 -2
- package/dist/esm/utils/helpers/isTarget.js.map +1 -1
- package/dist/esm/utils/helpers/throttle.js +1 -1
- package/dist/esm/utils/helpers/throttle.js.map +1 -1
- package/dist/types/index.d.ts +202 -38
- package/package.json +91 -114
- package/LICENSE +0 -21
- package/dist/cjs/_rollupPluginBabelHelpers-Cyl0H0H0.js +0 -3
- package/dist/cjs/_rollupPluginBabelHelpers-Cyl0H0H0.js.map +0 -1
- package/dist/cjs/hooks/useBreakpoints/constants/breakpoints.js.map +0 -1
- package/dist/cjs/utils/helpers/time/getDate.js.map +0 -1
- package/dist/esm/_rollupPluginBabelHelpers-USgtHx7z.js +0 -3
- package/dist/esm/_rollupPluginBabelHelpers-USgtHx7z.js.map +0 -1
- package/dist/esm/hooks/useBreakpoints/constants/breakpoints.js.map +0 -1
- package/dist/esm/utils/helpers/time/getDate.js.map +0 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.94 */
|
|
2
2
|
import{useRef as r,useEffect as t}from"react";var n=function(){var n=r(0);return t((function(){n.current+=1})),n.current};export{n as useRenderCount};
|
|
3
3
|
//# sourceMappingURL=useRenderCount.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.94 */
|
|
2
2
|
import{useRef as e}from"react";var n=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Unknown",r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],t=e({component:n,renders:0,timestamp:Date.now(),sinceLast:0}),c=Date.now();return t.current.renders+=1,t.current.sinceLast=t.current.timestamp?c-t.current.timestamp:0,t.current.timestamp=c,r&&(console.group("".concat(n," info, render number: ").concat(t.current.renders)),console.log("Timestamp: ".concat(t.current.timestamp)),console.log("Since last render: ".concat(t.current.sinceLast)),console.log("Renders: ".concat(t.current.renders)),console.dir(t.current),console.groupEnd()),t.current};export{n as useRenderInfo};
|
|
3
3
|
//# sourceMappingURL=useRenderInfo.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{b as e,_ as r}from"../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.94 */
|
|
2
|
+
import{b as e,_ as r}from"../../_rollupPluginBabelHelpers-Dp_7XWBJ.js";import{useState as t,useRef as n,useEffect as o}from"react";import{getElement as i}from"../../utils/helpers/getElement.js";import{useRefState as l}from"../useRefState/useRefState.js";var u=function(){var u,s="object"!==e(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,v=s?arguments.length<=1?void 0:arguments[1]:arguments.length<=0?void 0:arguments[0],a=null===(u=null==v?void 0:v.enabled)||void 0===u||u,c=t([]),d=r(c,2),f=d[0],m=d[1],g=l(),p=n();return p.current=null==v?void 0:v.onChange,o((function(){if(a||s||g.state){var e=s?i(s):g.current;if(e){var r=new ResizeObserver((function(e){var t;m(e),null===(t=p.current)||void 0===t||t.call(p,e,r)}));return r.observe(e,v),function(){r.disconnect()}}}}),[s,g.state,null==v?void 0:v.box,a]),s?{entries:f}:{ref:g,entries:f}};export{u as useResizeObserver};
|
|
3
3
|
//# sourceMappingURL=useResizeObserver.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useResizeObserver.js","sources":["../../../../src/hooks/useResizeObserver/useResizeObserver.ts"],"sourcesContent":["import type { RefObject } from 'react';\n\nimport { useEffect, useRef, useState } from 'react';\n\nimport { getElement } from '@/utils/helpers';\n\nimport type { StateRef } from '../useRefState/useRefState';\n\nimport { useRefState } from '../useRefState/useRefState';\n\n/** The resize observer target element type */\nexport type UseResizeObserverTarget = string | Element | RefObject<Element | null | undefined>;\n\n/** The resize observer options type */\nexport interface UseResizeObserverOptions extends ResizeObserverOptions {\n /** The enabled state */\n enabled?: boolean;\n /** The resize observer callback */\n onChange?: (entries: ResizeObserverEntry[], observer: ResizeObserver) => void;\n}\n\n/** The resize observer return type */\nexport interface UseResizeObserverReturn {\n /** The resize observer entries */\n entries: ResizeObserverEntry[];\n}\n\nexport interface UseResizeObserver {\n <Target extends UseResizeObserverTarget
|
|
1
|
+
{"version":3,"file":"useResizeObserver.js","sources":["../../../../src/hooks/useResizeObserver/useResizeObserver.ts"],"sourcesContent":["import type { RefObject } from 'react';\n\nimport { useEffect, useRef, useState } from 'react';\n\nimport { getElement } from '@/utils/helpers';\n\nimport type { StateRef } from '../useRefState/useRefState';\n\nimport { useRefState } from '../useRefState/useRefState';\n\n/** The resize observer target element type */\nexport type UseResizeObserverTarget = string | Element | RefObject<Element | null | undefined>;\n\n/** The resize observer options type */\nexport interface UseResizeObserverOptions extends ResizeObserverOptions {\n /** The enabled state */\n enabled?: boolean;\n /** The resize observer callback */\n onChange?: (entries: ResizeObserverEntry[], observer: ResizeObserver) => void;\n}\n\n/** The resize observer return type */\nexport interface UseResizeObserverReturn {\n /** The resize observer entries */\n entries: ResizeObserverEntry[];\n}\n\nexport interface UseResizeObserver {\n <Target extends UseResizeObserverTarget>(\n target: Target,\n options?: UseResizeObserverOptions\n ): UseResizeObserverReturn;\n\n <Target extends UseResizeObserverTarget>(\n options?: UseResizeObserverOptions,\n target?: never\n ): UseResizeObserverReturn & { ref: StateRef<Target> };\n}\n\n/**\n * @name useResizeObserver\n * @description - Hook that gives you resize observer state\n * @category Browser\n *\n * @overload\n * @template Target The target element\n * @param {boolean} [options.enabled=true] The IntersectionObserver options\n * @param {boolean} [options.box] The IntersectionObserver options\n * @param {(entries: ResizeObserverEntry[], observer: ResizeObserver) => void} [options.onChange] The callback to execute when resize is detected\n * @returns {UseResizeObserverReturn & { ref: (node: Target) => void }} An object containing the resize observer state\n *\n * @example\n * const { ref, entries } = useResizeObserver();\n *\n * @overload\n * @template Target The target element\n * @param {Target} target The target element to observe\n * @param {boolean} [options.enabled=true] The IntersectionObserver options\n * @param {boolean} [options.box] The IntersectionObserver options\n * @param {(entries: ResizeObserverEntry[], observer: ResizeObserver) => void} [options.onChange] The callback to execute when resize is detected\n * @returns {UseResizeObserverReturn} An object containing the resize observer state\n *\n * @example\n * const { entries } = useResizeObserver(ref);\n */\nexport const useResizeObserver = ((...params: any[]) => {\n const target = (\n typeof params[0] === 'object' && !('current' in params[0]) ? undefined : params[0]\n ) as UseResizeObserverTarget | undefined;\n const options = (target ? params[1] : params[0]) as UseResizeObserverOptions | undefined;\n const enabled = options?.enabled ?? true;\n\n const [entries, setEntries] = useState<ResizeObserverEntry[]>([]);\n\n const internalRef = useRefState<Element>();\n const internalOnChangeRef = useRef<UseResizeObserverOptions['onChange']>();\n internalOnChangeRef.current = options?.onChange;\n\n useEffect(() => {\n if (!enabled && !target && !internalRef.state) return;\n\n const element = target ? getElement(target) : internalRef.current;\n if (!element) return;\n\n const observer = new ResizeObserver((entries) => {\n setEntries(entries);\n internalOnChangeRef.current?.(entries, observer);\n });\n observer.observe(element as Element, options);\n\n return () => {\n observer.disconnect();\n };\n }, [target, internalRef.state, options?.box, enabled]);\n\n if (target) return { entries };\n return {\n ref: internalRef,\n entries\n };\n}) as UseResizeObserver;\n"],"names":["useResizeObserver","_options$enabled","target","_typeof","arguments","length","undefined","options","enabled","_useState","useState","_useState2","_slicedToArray","entries","setEntries","internalRef","useRefState","internalOnChangeRef","useRef","current","onChange","useEffect","state","element","getElement","observer","ResizeObserver","_internalOnChangeRef$","call","observe","disconnect","box","ref"],"mappings":";kQAiEaA,EAAqB,WAAsB,IAAAC,EAChDC,EACiB,WAArBC,EAAAC,UAAAC,QAAA,OAAAC,EAAAF,UAAqB,KAAc,YAASA,UAAAC,eAAAC,EAAAF,UAAA,IAA0BA,UAAAC,QAAA,OAAAC,EAAAF,UAChC,QADuBE,EAEzDC,EAAWL,EAAME,UAAAC,QAAAC,OAAAA,EAAAF,UAAA,GAAAA,UAAAC,eAAAC,EAAAF,UAAiE,GAClFI,EAA0BP,QAAnBA,EAAGM,aAAO,EAAPA,EAASC,eAAOP,IAAAA,GAAAA,EAEhCQ,EAA8BC,EAAgC,IAAGC,EAAAC,EAAAH,EAAA,GAA1DI,EAAOF,EAAA,GAAEG,EAAUH,EAAA,GAEpBI,EAAcC,IACdC,EAAsBC,IAoB5B,OAnBAD,EAAoBE,QAAUZ,aAAO,EAAPA,EAASa,SAEvCC,GAAU,WACR,GAAKb,GAAYN,GAAWa,EAAYO,MAAxC,CAEA,IAAMC,EAAUrB,EAASsB,EAAWtB,GAAUa,EAAYI,QAC1D,GAAKI,EAAL,CAEA,IAAME,EAAW,IAAIC,gBAAe,SAACb,GAAY,IAAAc,EAC/Cb,EAAWD,WACXc,EAAAV,EAAoBE,eAAO,IAAAQ,GAA3BA,EAAAC,KAAAX,EAA8BJ,EAASY,EACzC,IAGA,OAFAA,EAASI,QAAQN,EAAoBhB,GAE9B,WACLkB,EAASK,YACV,CAVa,CAHiC,CAchD,GAAE,CAAC5B,EAAQa,EAAYO,MAAOf,eAAAA,EAASwB,IAAKvB,IAEzCN,EAAe,CAAEW,QAAAA,GACd,CACLmB,IAAKjB,EACLF,QAAAA,EAEJ"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as n}from"../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.94 */
|
|
2
|
+
import{_ as n}from"../../_rollupPluginBabelHelpers-Dp_7XWBJ.js";import{useState as e,useEffect as o}from"react";var i=function(){var i="undefined"!=typeof window&&"screen"in window&&"orientation"in window.screen,t=i?window.screen.orientation:{},r=e((function(){var n;return{angle:null!==(n=null==t?void 0:t.angle)&&void 0!==n?n:0,orientationType:null==t?void 0:t.type}})),u=n(r,2),l=u[0],a=u[1];o((function(){if(i){var n=function(){return a({angle:t.angle,orientationType:t.type})};return window.addEventListener("orientationchange",n),function(){window.removeEventListener("orientationchange",n)}}}));return{supported:i,value:l,lock:function(n){if(i&&"function"==typeof t.lock)return t.lock(n)},unlock:function(){i&&"function"==typeof t.unlock&&t.unlock()}}};export{i as useScreenOrientation};
|
|
3
3
|
//# sourceMappingURL=useScreenOrientation.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as r}from"../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.94 */
|
|
2
|
+
import{_ as r}from"../../_rollupPluginBabelHelpers-Dp_7XWBJ.js";import{useState as t,useEffect as e}from"react";var n="script-status",o=function(o){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},u=t((function(){var r=document.querySelector('script[src="'.concat(o,'"]')),t=null==r?void 0:r.getAttribute(n);return t||(r?"unknown":"loading")})),c=r(u,2),a=c[0],s=c[1],d=i.removeOnUnmount,v=void 0===d||d,l=i.async,m=void 0===l||l;return e((function(){var t=document.querySelector('script[src="'.concat(o,'"]')),e=null==t?void 0:t.getAttribute(n);if(e)return s(e);if(t)return s("unknown");var u=document.createElement("script");u.src=o,u.async=m;for(var c=0,a=Object.entries(i);c<a.length;c++){var d=r(a[c],2),l=d[0],f=d[1];u.setAttribute(l,String(f))}u.setAttribute(n,"loading"),document.body.appendChild(u);var p=function(){u.setAttribute(n,"ready"),s("ready")},b=function(){u.setAttribute(n,"error"),s("error")};return u.addEventListener("load",p),u.addEventListener("error",b),function(){v&&u.remove(),u.removeEventListener("load",p),u.removeEventListener("error",b)}}),[o,v]),a};export{n as SCRIPT_STATUS_ATTRIBUTE_NAME,o as useScript};
|
|
3
3
|
//# sourceMappingURL=useScript.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{b as
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.94 */
|
|
2
|
+
import{b as t,_ as e}from"../../_rollupPluginBabelHelpers-Dp_7XWBJ.js";import{useRef as l,useState as o,useEffect as r}from"react";import{getElement as n}from"../../utils/helpers/getElement.js";import{isTarget as i}from"../../utils/helpers/isTarget.js";import{useRefState as c}from"../useRefState/useRefState.js";var u=function(){var u=i(arguments.length<=0?void 0:arguments[0])?arguments.length<=0?void 0:arguments[0]:void 0,v=u?"object"===t(arguments.length<=1?void 0:arguments[1])?arguments.length<=1?void 0:arguments[1]:{onScroll:arguments.length<=1?void 0:arguments[1]}:"object"===t(arguments.length<=0?void 0:arguments[0])?arguments.length<=0?void 0:arguments[0]:{onScroll:arguments.length<=0?void 0:arguments[0]},d=c(),s=l(v);s.current=v;var a=o(!1),f=e(a,2),m=f[0],g=f[1],h=l({x:0,y:0});return r((function(){if(u||d.state){var t=u?n(u):d.current;if(t){var e=function(t){var e;g(!1),null==v||null===(e=v.onStop)||void 0===e||e.call(v,t)},l=function(t){var e,l,o,r,n,i,c;g(!0);var u=t.target===document?t.target.documentElement:t.target,v=u.style,d=v.display,a=v.flexDirection,f="rtl"===v.direction?-1:1,m=u.scrollLeft,p=u.scrollTop;u instanceof Document&&!p&&(p=window.document.body.scrollTop);var x=null===(e=s.current)||void 0===e?void 0:e.offset,b=m*f<=(null!==(l=null==x?void 0:x.left)&&void 0!==l?l:0),y=m*f+u.clientWidth>=u.scrollWidth-(null!==(o=null==x?void 0:x.right)&&void 0!==o?o:0)-1,j=p<=(null!==(r=null==x?void 0:x.top)&&void 0!==r?r:0),E=p+u.clientHeight>=u.scrollHeight-(null!==(n=null==x?void 0:x.bottom)&&void 0!==n?n:0)-1,S="flex"===d&&"column-reverse"===a,L="flex"===d&&"column-reverse"===a,H={x:m,y:p,directions:{left:m<h.current.x,right:m>h.current.x,top:p<h.current.y,bottom:p>h.current.y},arrived:{left:L?y:b,right:L?b:y,top:S?E:j,bottom:S?j:E}};h.current={x:m,y:p},null===(i=s.current)||void 0===i||null===(c=i.onScroll)||void 0===c||c.call(i,H,t)};return t.addEventListener("scroll",l),t.addEventListener("scrollend",e),function(){t.removeEventListener("scroll",l),t.removeEventListener("scrollend",e)}}}}),[u,d.state]),u?m:[d,m]};export{u as useScroll};
|
|
3
3
|
//# sourceMappingURL=useScroll.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useScroll.js","sources":["../../../../src/hooks/useScroll/useScroll.ts"],"sourcesContent":["import type { RefObject } from 'react';\n\nimport { useEffect, useRef, useState } from 'react';\n\nimport { getElement, isTarget } from '@/utils/helpers';\n\nimport type { StateRef } from '../useRefState/useRefState';\n\nimport { useRefState } from '../useRefState/useRefState';\n\nconst ARRIVED_STATE_THRESHOLD_PIXELS = 1;\n\n/** The use scroll target element type */\nexport type UseScrollTarget =\n | string\n | Document\n | Element\n | RefObject<Element | null | undefined>\n | Window;\n\nexport interface UseScrollOptions {\n /** The on scroll callback */\n onScroll?: (params: UseScrollCallbackParams, event: Event) => void;\n\n /** The on end scroll callback */\n onStop?: (event: Event) => void;\n\n /** Offset arrived states by x pixels. */\n offset?: {\n left?: number;\n right?: number;\n top?: number;\n bottom?: number;\n };\n}\n\nexport interface UseScrollCallbackParams {\n /** The element x position */\n x: number;\n /** The element y position */\n y: number;\n /** State of scroll arrived */\n arrived: {\n left: boolean;\n right: boolean;\n top: boolean;\n bottom: boolean;\n };\n /** State of scroll direction */\n directions: {\n left: boolean;\n right: boolean;\n top: boolean;\n bottom: boolean;\n };\n}\n\nexport interface UseScroll {\n <Target extends UseScrollTarget>(\n target: Target,\n callback?: (params: UseScrollCallbackParams, event: Event) => void\n ): boolean;\n\n <Target extends UseScrollTarget>(target: Target, options?: UseScrollOptions): boolean;\n\n <Target extends UseScrollTarget>(\n callback?: (params: UseScrollCallbackParams, event: Event) => void,\n target?: never\n ): [StateRef<Target>, boolean];\n\n <Target extends UseScrollTarget>(\n options?: UseScrollOptions,\n target?: never\n ): [StateRef<Target>, boolean];\n}\n\n/**\n * @name useScroll\n * @description - Hook that allows you to control scroll a element\n * @category Sensors\n *\n * @overload\n * @template Target The target element\n * @param {ScrollBehavior} [options.behavior=auto] The behavior of scrolling\n * @param {number} [options.offset.left=0] The left offset for arrived states\n * @param {number} [options.offset.right=0] The right offset for arrived states\n * @param {number} [options.offset.top=0] The top offset for arrived states\n * @param {number} [options.offset.bottom=0] The bottom offset for arrived states\n * @param {(params: UseScrollCallbackParams, event: Event) => void} [options.onScroll] The callback function to be invoked on scroll\n * @param {(event: Event) => void} [options.onStop] The callback function to be invoked on scroll end\n * @returns {boolean} The state of scrolling\n *\n * @example\n * const scrolling = useScroll(ref, options);\n *\n * @overload\n * @template Target The target element\n * @param {(params: UseScrollCallbackParams, event: Event) => void} [callback] The callback function to be invoked on scroll\n * @returns {boolean} The state of scrolling\n *\n * @example\n * const scrolling = useScroll(ref, () => console.log('callback'));\n *\n * @overload\n * @template Target The target element\n * @param {Target} target The target element to scroll\n * @param {ScrollBehavior} [options.behavior=auto] The behavior of scrolling\n * @param {number} [options.offset.left=0] The left offset for arrived states\n * @param {number} [options.offset.right=0] The right offset for arrived states\n * @param {number} [options.offset.top=0] The top offset for arrived states\n * @param {number} [options.offset.bottom=0] The bottom offset for arrived states\n * @param {(params: UseScrollCallbackParams, event: Event) => void} [options.onScroll] The callback function to be invoked on scroll\n * @param {(event: Event) => void} [options.onStop] The callback function to be invoked on scroll end\n * @returns {[StateRef<Target>, boolean]} The state of scrolling\n *\n * @example\n * const [ref, scrolling] = useScroll(options);\n *\n * @overload\n * @template Target The target element\n * @param {Target} target The target element to scroll\n * @param {(params: UseScrollCallbackParams, event: Event) => void} [callback] The callback function to be invoked on scroll\n * @returns {[StateRef<Target>, boolean]} The state of scrolling\n *\n * @example\n * const [ref, scrolling] = useScroll(() => console.log('callback'));\n */\nexport const useScroll = ((...params: any[]) => {\n const target = (isTarget(params[0]) ? params[0] : undefined) as UseScrollTarget | undefined;\n const options = (\n target\n ? typeof params[1] === 'object'\n ? params[1]\n : { onScroll: params[1] }\n : typeof params[0] === 'object'\n ? params[0]\n : { onScroll: params[0] }\n ) as UseScrollOptions | undefined;\n\n const internalRef = useRefState<Element>();\n const internalOptionsRef = useRef(options);\n internalOptionsRef.current = options;\n\n const [scrolling, setScrolling] = useState(false);\n const scrollPositionRef = useRef({ x: 0, y: 0 });\n\n useEffect(() => {\n if (!target && !internalRef.current) return;\n const element = (target ? getElement(target) : internalRef.current) as Element;\n\n if (!element) return;\n\n const onScrollEnd = (event: Event) => {\n setScrolling(false);\n options?.onStop?.(event);\n };\n\n const onScroll = (event: Event) => {\n setScrolling(true);\n const target = (\n event.target === document ? (event.target as Document).documentElement : event.target\n ) as HTMLElement;\n\n const { display, flexDirection, direction } = target.style;\n const directionMultiplier = direction === 'rtl' ? -1 : 1;\n\n const scrollLeft = target.scrollLeft;\n let scrollTop = target.scrollTop;\n if (target instanceof Document && !scrollTop) scrollTop = window.document.body.scrollTop;\n\n const offset = internalOptionsRef.current?.offset;\n const left = scrollLeft * directionMultiplier <= (offset?.left ?? 0);\n const right =\n scrollLeft * directionMultiplier + target.clientWidth >=\n target.scrollWidth - (offset?.right ?? 0) - ARRIVED_STATE_THRESHOLD_PIXELS;\n const top = scrollTop <= (offset?.top ?? 0);\n const bottom =\n scrollTop + target.clientHeight >=\n target.scrollHeight - (offset?.bottom ?? 0) - ARRIVED_STATE_THRESHOLD_PIXELS;\n\n const isColumnReverse = display === 'flex' && flexDirection === 'column-reverse';\n const isRowReverse = display === 'flex' && flexDirection === 'column-reverse';\n\n const params = {\n x: scrollLeft,\n y: scrollTop,\n directions: {\n left: scrollLeft < scrollPositionRef.current.x,\n right: scrollLeft > scrollPositionRef.current.x,\n top: scrollTop < scrollPositionRef.current.y,\n bottom: scrollTop > scrollPositionRef.current.y\n },\n arrived: {\n left: isRowReverse ? right : left,\n right: isRowReverse ? left : right,\n top: isColumnReverse ? bottom : top,\n bottom: isColumnReverse ? top : bottom\n }\n };\n\n scrollPositionRef.current = { x: scrollLeft, y: scrollTop };\n internalOptionsRef.current?.onScroll?.(params, event);\n };\n\n element.addEventListener('scroll', onScroll);\n element.addEventListener('scrollend', onScrollEnd);\n\n return () => {\n element.removeEventListener('scroll', onScroll);\n element.removeEventListener('scrollend', onScrollEnd);\n };\n }, [target, internalRef.current]);\n\n if (target) return scrolling;\n return [internalRef, scrolling];\n}) as UseScroll;\n"],"names":["useScroll","target","isTarget","arguments","length","undefined","options","_typeof","onScroll","internalRef","useRefState","internalOptionsRef","useRef","current","_useState","useState","_useState2","_slicedToArray","scrolling","setScrolling","scrollPositionRef","x","y","useEffect","element","getElement","onScrollEnd","event","_options$onStop","onStop","call","_internalOptionsRef$c","_offset$left","_offset$right","_offset$top","_offset$bottom","_internalOptionsRef$c2","_internalOptionsRef$c3","document","documentElement","_target$style","style","display","flexDirection","directionMultiplier","direction","scrollLeft","scrollTop","Document","window","body","offset","left","right","clientWidth","scrollWidth","top","bottom","clientHeight","scrollHeight","isColumnReverse","isRowReverse","params","directions","arrived","addEventListener","removeEventListener"],"mappings":";+VAUA,IAqHaA,EAAa,WACxB,IAAMC,EAAUC,EAAQC,UAAAC,QAAAC,OAAAA,EAAAF,cAAWA,UAAAC,eAAAC,EAAAF,UAAA,QAAeE,EAC5CC,EACJL,EACyB,WAArBM,EAAAJ,UAAAC,QAAAC,OAAAA,EAAAF,UAAA,IAA6BA,UAAAC,QAAAC,OAAAA,EAAAF,UAE3B,GAAA,CAAEK,SAAQL,UAAAC,QAAAC,OAAAA,EAAAF,UAAA,IACS,WAArBI,EAAAJ,UAAAC,QAAA,OAAAC,EAAAF,cAA6BA,UAAAC,eAAAC,EAAAF,UAE3B,GAAA,CAAEK,SAAQL,UAAAC,QAAAC,OAAAA,EAAAF,UAAA,IAGZM,EAAcC,IACdC,EAAqBC,EAAON,GAClCK,EAAmBE,QAAUP,EAE7B,IAAAQ,EAAkCC,GAAS,GAAMC,EAAAC,EAAAH,EAAA,GAA1CI,EAASF,EAAA,GAAEG,EAAYH,EAAA,GACxBI,EAAoBR,EAAO,CAAES,EAAG,EAAGC,EAAG,IAqE5C,OAnEAC,GAAU,WACR,GAAKtB,GAAWQ,EAAYI,QAA5B,CACA,IAAMW,EAAWvB,EAASwB,EAAWxB,GAAUQ,EAAYI,QAE3D,GAAKW,EAAL,CAEA,IAAME,EAAc,SAACC,GAAiB,IAAAC,EACpCT,GAAa,GACbb,SAAe,QAARsB,EAAPtB,EAASuB,cAAM,IAAAD,GAAfA,EAAAE,KAAAxB,EAAkBqB,EACnB,EAEKnB,EAAW,SAACmB,GAAiB,IAAAI,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EACjClB,GAAa,GACb,IAAMlB,EACJ0B,EAAM1B,SAAWqC,SAAYX,EAAM1B,OAAoBsC,gBAAkBZ,EAAM1B,OAGjFuC,EAA8CvC,EAAOwC,MAA7CC,EAAOF,EAAPE,QAASC,EAAaH,EAAbG,cACXC,EAAoC,QADDJ,EAATK,WACmB,EAAI,EAEjDC,EAAa7C,EAAO6C,WACtBC,EAAY9C,EAAO8C,UACnB9C,aAAkB+C,WAAaD,IAAWA,EAAYE,OAAOX,SAASY,KAAKH,WAE/E,IAAMI,EAAmC,QAA7BpB,EAAGpB,EAAmBE,eAAO,IAAAkB,OAAA,EAA1BA,EAA4BoB,OACrCC,EAAON,EAAaF,IAAoC,QAAjBZ,EAAKmB,aAAAA,EAAAA,EAAQC,YAAIpB,IAAAA,EAAAA,EAAI,GAC5DqB,EACJP,EAAaF,EAAsB3C,EAAOqD,aAC1CrD,EAAOsD,aAA4B,QAAjBtB,EAAIkB,aAAAA,EAAAA,EAAQE,aAAK,IAAApB,EAAAA,EAAI,GApKR,EAqK3BuB,EAAMT,IAAyBb,QAAhBA,EAAKiB,eAAAA,EAAQK,eAAGtB,EAAAA,EAAI,GACnCuB,EACJV,EAAY9C,EAAOyD,cACnBzD,EAAO0D,cAA8B,QAAlBxB,EAAIgB,aAAM,EAANA,EAAQM,cAAM,IAAAtB,EAAAA,EAAI,GAxKV,EA0K3ByB,EAA8B,SAAZlB,GAAwC,mBAAlBC,EACxCkB,EAA2B,SAAZnB,GAAwC,mBAAlBC,EAErCmB,EAAS,CACbzC,EAAGyB,EACHxB,EAAGyB,EACHgB,WAAY,CACVX,KAAMN,EAAa1B,EAAkBP,QAAQQ,EAC7CgC,MAAOP,EAAa1B,EAAkBP,QAAQQ,EAC9CmC,IAAKT,EAAY3B,EAAkBP,QAAQS,EAC3CmC,OAAQV,EAAY3B,EAAkBP,QAAQS,GAEhD0C,QAAS,CACPZ,KAAMS,EAAeR,EAAQD,EAC7BC,MAAOQ,EAAeT,EAAOC,EAC7BG,IAAKI,EAAkBH,EAASD,EAChCC,OAAQG,EAAkBJ,EAAMC,IAIpCrC,EAAkBP,QAAU,CAAEQ,EAAGyB,EAAYxB,EAAGyB,WAChDX,EAAAzB,EAAmBE,eAAO,IAAAuB,GAAUC,QAAVA,EAA1BD,EAA4B5B,gBAA5B6B,IAAoCA,GAApCA,EAAAP,KAAAM,EAAuC0B,EAAQnC,EAChD,EAKD,OAHAH,EAAQyC,iBAAiB,SAAUzD,GACnCgB,EAAQyC,iBAAiB,YAAavC,GAE/B,WACLF,EAAQ0C,oBAAoB,SAAU1D,GACtCgB,EAAQ0C,oBAAoB,YAAaxC,EAC1C,CA5Da,CAHuB,CAgEtC,GAAE,CAACzB,EAAQQ,EAAYI,UAEpBZ,EAAeiB,EACZ,CAACT,EAAaS,EACvB"}
|
|
1
|
+
{"version":3,"file":"useScroll.js","sources":["../../../../src/hooks/useScroll/useScroll.ts"],"sourcesContent":["import type { RefObject } from 'react';\n\nimport { useEffect, useRef, useState } from 'react';\n\nimport { getElement, isTarget } from '@/utils/helpers';\n\nimport type { StateRef } from '../useRefState/useRefState';\n\nimport { useRefState } from '../useRefState/useRefState';\n\nconst ARRIVED_STATE_THRESHOLD_PIXELS = 1;\n\n/** The use scroll target element type */\nexport type UseScrollTarget =\n | string\n | Document\n | Element\n | RefObject<Element | null | undefined>\n | Window;\n\nexport interface UseScrollOptions {\n /** The on scroll callback */\n onScroll?: (params: UseScrollCallbackParams, event: Event) => void;\n\n /** The on end scroll callback */\n onStop?: (event: Event) => void;\n\n /** Offset arrived states by x pixels. */\n offset?: {\n left?: number;\n right?: number;\n top?: number;\n bottom?: number;\n };\n}\n\nexport interface UseScrollCallbackParams {\n /** The element x position */\n x: number;\n /** The element y position */\n y: number;\n /** State of scroll arrived */\n arrived: {\n left: boolean;\n right: boolean;\n top: boolean;\n bottom: boolean;\n };\n /** State of scroll direction */\n directions: {\n left: boolean;\n right: boolean;\n top: boolean;\n bottom: boolean;\n };\n}\n\nexport interface UseScroll {\n <Target extends UseScrollTarget>(\n target: Target,\n callback?: (params: UseScrollCallbackParams, event: Event) => void\n ): boolean;\n\n <Target extends UseScrollTarget>(target: Target, options?: UseScrollOptions): boolean;\n\n <Target extends UseScrollTarget>(\n callback?: (params: UseScrollCallbackParams, event: Event) => void,\n target?: never\n ): [StateRef<Target>, boolean];\n\n <Target extends UseScrollTarget>(\n options?: UseScrollOptions,\n target?: never\n ): [StateRef<Target>, boolean];\n}\n\n/**\n * @name useScroll\n * @description - Hook that allows you to control scroll a element\n * @category Sensors\n *\n * @overload\n * @template Target The target element\n * @param {ScrollBehavior} [options.behavior=auto] The behavior of scrolling\n * @param {number} [options.offset.left=0] The left offset for arrived states\n * @param {number} [options.offset.right=0] The right offset for arrived states\n * @param {number} [options.offset.top=0] The top offset for arrived states\n * @param {number} [options.offset.bottom=0] The bottom offset for arrived states\n * @param {(params: UseScrollCallbackParams, event: Event) => void} [options.onScroll] The callback function to be invoked on scroll\n * @param {(event: Event) => void} [options.onStop] The callback function to be invoked on scroll end\n * @returns {boolean} The state of scrolling\n *\n * @example\n * const scrolling = useScroll(ref, options);\n *\n * @overload\n * @template Target The target element\n * @param {(params: UseScrollCallbackParams, event: Event) => void} [callback] The callback function to be invoked on scroll\n * @returns {boolean} The state of scrolling\n *\n * @example\n * const scrolling = useScroll(ref, () => console.log('callback'));\n *\n * @overload\n * @template Target The target element\n * @param {Target} target The target element to scroll\n * @param {ScrollBehavior} [options.behavior=auto] The behavior of scrolling\n * @param {number} [options.offset.left=0] The left offset for arrived states\n * @param {number} [options.offset.right=0] The right offset for arrived states\n * @param {number} [options.offset.top=0] The top offset for arrived states\n * @param {number} [options.offset.bottom=0] The bottom offset for arrived states\n * @param {(params: UseScrollCallbackParams, event: Event) => void} [options.onScroll] The callback function to be invoked on scroll\n * @param {(event: Event) => void} [options.onStop] The callback function to be invoked on scroll end\n * @returns {[StateRef<Target>, boolean]} The state of scrolling\n *\n * @example\n * const [ref, scrolling] = useScroll(options);\n *\n * @overload\n * @template Target The target element\n * @param {Target} target The target element to scroll\n * @param {(params: UseScrollCallbackParams, event: Event) => void} [callback] The callback function to be invoked on scroll\n * @returns {[StateRef<Target>, boolean]} The state of scrolling\n *\n * @example\n * const [ref, scrolling] = useScroll(() => console.log('callback'));\n */\nexport const useScroll = ((...params: any[]) => {\n const target = (isTarget(params[0]) ? params[0] : undefined) as UseScrollTarget | undefined;\n const options = (\n target\n ? typeof params[1] === 'object'\n ? params[1]\n : { onScroll: params[1] }\n : typeof params[0] === 'object'\n ? params[0]\n : { onScroll: params[0] }\n ) as UseScrollOptions | undefined;\n\n const internalRef = useRefState<Element>();\n const internalOptionsRef = useRef(options);\n internalOptionsRef.current = options;\n\n const [scrolling, setScrolling] = useState(false);\n const scrollPositionRef = useRef({ x: 0, y: 0 });\n\n useEffect(() => {\n if (!target && !internalRef.state) return;\n const element = (target ? getElement(target) : internalRef.current) as Element;\n\n if (!element) return;\n\n const onScrollEnd = (event: Event) => {\n setScrolling(false);\n options?.onStop?.(event);\n };\n\n const onScroll = (event: Event) => {\n setScrolling(true);\n const target = (\n event.target === document ? (event.target as Document).documentElement : event.target\n ) as HTMLElement;\n\n const { display, flexDirection, direction } = target.style;\n const directionMultiplier = direction === 'rtl' ? -1 : 1;\n\n const scrollLeft = target.scrollLeft;\n let scrollTop = target.scrollTop;\n if (target instanceof Document && !scrollTop) scrollTop = window.document.body.scrollTop;\n\n const offset = internalOptionsRef.current?.offset;\n const left = scrollLeft * directionMultiplier <= (offset?.left ?? 0);\n const right =\n scrollLeft * directionMultiplier + target.clientWidth >=\n target.scrollWidth - (offset?.right ?? 0) - ARRIVED_STATE_THRESHOLD_PIXELS;\n const top = scrollTop <= (offset?.top ?? 0);\n const bottom =\n scrollTop + target.clientHeight >=\n target.scrollHeight - (offset?.bottom ?? 0) - ARRIVED_STATE_THRESHOLD_PIXELS;\n\n const isColumnReverse = display === 'flex' && flexDirection === 'column-reverse';\n const isRowReverse = display === 'flex' && flexDirection === 'column-reverse';\n\n const params = {\n x: scrollLeft,\n y: scrollTop,\n directions: {\n left: scrollLeft < scrollPositionRef.current.x,\n right: scrollLeft > scrollPositionRef.current.x,\n top: scrollTop < scrollPositionRef.current.y,\n bottom: scrollTop > scrollPositionRef.current.y\n },\n arrived: {\n left: isRowReverse ? right : left,\n right: isRowReverse ? left : right,\n top: isColumnReverse ? bottom : top,\n bottom: isColumnReverse ? top : bottom\n }\n };\n\n scrollPositionRef.current = { x: scrollLeft, y: scrollTop };\n internalOptionsRef.current?.onScroll?.(params, event);\n };\n\n element.addEventListener('scroll', onScroll);\n element.addEventListener('scrollend', onScrollEnd);\n\n return () => {\n element.removeEventListener('scroll', onScroll);\n element.removeEventListener('scrollend', onScrollEnd);\n };\n }, [target, internalRef.state]);\n\n if (target) return scrolling;\n return [internalRef, scrolling];\n}) as UseScroll;\n"],"names":["useScroll","target","isTarget","arguments","length","undefined","options","_typeof","onScroll","internalRef","useRefState","internalOptionsRef","useRef","current","_useState","useState","_useState2","_slicedToArray","scrolling","setScrolling","scrollPositionRef","x","y","useEffect","state","element","getElement","onScrollEnd","event","_options$onStop","onStop","call","_internalOptionsRef$c","_offset$left","_offset$right","_offset$top","_offset$bottom","_internalOptionsRef$c2","_internalOptionsRef$c3","document","documentElement","_target$style","style","display","flexDirection","directionMultiplier","direction","scrollLeft","scrollTop","Document","window","body","offset","left","right","clientWidth","scrollWidth","top","bottom","clientHeight","scrollHeight","isColumnReverse","isRowReverse","params","directions","arrived","addEventListener","removeEventListener"],"mappings":";yTAUA,IAqHaA,EAAa,WACxB,IAAMC,EAAUC,EAAQC,UAAAC,QAAAC,OAAAA,EAAAF,cAAWA,UAAAC,eAAAC,EAAAF,UAAA,QAAeE,EAC5CC,EACJL,EACyB,WAArBM,EAAAJ,UAAAC,QAAAC,OAAAA,EAAAF,UAAA,IAA6BA,UAAAC,QAAAC,OAAAA,EAAAF,UAE3B,GAAA,CAAEK,SAAQL,UAAAC,QAAAC,OAAAA,EAAAF,UAAA,IACS,WAArBI,EAAAJ,UAAAC,QAAA,OAAAC,EAAAF,cAA6BA,UAAAC,eAAAC,EAAAF,UAE3B,GAAA,CAAEK,SAAQL,UAAAC,QAAAC,OAAAA,EAAAF,UAAA,IAGZM,EAAcC,IACdC,EAAqBC,EAAON,GAClCK,EAAmBE,QAAUP,EAE7B,IAAAQ,EAAkCC,GAAS,GAAMC,EAAAC,EAAAH,EAAA,GAA1CI,EAASF,EAAA,GAAEG,EAAYH,EAAA,GACxBI,EAAoBR,EAAO,CAAES,EAAG,EAAGC,EAAG,IAqE5C,OAnEAC,GAAU,WACR,GAAKtB,GAAWQ,EAAYe,MAA5B,CACA,IAAMC,EAAWxB,EAASyB,EAAWzB,GAAUQ,EAAYI,QAE3D,GAAKY,EAAL,CAEA,IAAME,EAAc,SAACC,GAAiB,IAAAC,EACpCV,GAAa,GACbb,SAAe,QAARuB,EAAPvB,EAASwB,cAAM,IAAAD,GAAfA,EAAAE,KAAAzB,EAAkBsB,EACnB,EAEKpB,EAAW,SAACoB,GAAiB,IAAAI,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EAAAC,EACjCnB,GAAa,GACb,IAAMlB,EACJ2B,EAAM3B,SAAWsC,SAAYX,EAAM3B,OAAoBuC,gBAAkBZ,EAAM3B,OAGjFwC,EAA8CxC,EAAOyC,MAA7CC,EAAOF,EAAPE,QAASC,EAAaH,EAAbG,cACXC,EAAoC,QADDJ,EAATK,WACoB,EAAG,EAEjDC,EAAa9C,EAAO8C,WACtBC,EAAY/C,EAAO+C,UACnB/C,aAAkBgD,WAAaD,IAAWA,EAAYE,OAAOX,SAASY,KAAKH,WAE/E,IAAMI,EAAmC,QAA7BpB,EAAGrB,EAAmBE,eAAO,IAAAmB,OAAA,EAA1BA,EAA4BoB,OACrCC,EAAON,EAAaF,IAAoC,QAAjBZ,EAAKmB,aAAAA,EAAAA,EAAQC,YAAIpB,IAAAA,EAAAA,EAAI,GAC5DqB,EACJP,EAAaF,EAAsB5C,EAAOsD,aAC1CtD,EAAOuD,aAA4B,QAAjBtB,EAAIkB,aAAAA,EAAAA,EAAQE,aAAK,IAAApB,EAAAA,EAAI,GApKR,EAqK3BuB,EAAMT,IAAyBb,QAAhBA,EAAKiB,eAAAA,EAAQK,eAAGtB,EAAAA,EAAI,GACnCuB,EACJV,EAAY/C,EAAO0D,cACnB1D,EAAO2D,cAA8B,QAAlBxB,EAAIgB,aAAM,EAANA,EAAQM,cAAM,IAAAtB,EAAAA,EAAI,GAxKV,EA0K3ByB,EAA8B,SAAZlB,GAAwC,mBAAlBC,EACxCkB,EAA2B,SAAZnB,GAAwC,mBAAlBC,EAErCmB,EAAS,CACb1C,EAAG0B,EACHzB,EAAG0B,EACHgB,WAAY,CACVX,KAAMN,EAAa3B,EAAkBP,QAAQQ,EAC7CiC,MAAOP,EAAa3B,EAAkBP,QAAQQ,EAC9CoC,IAAKT,EAAY5B,EAAkBP,QAAQS,EAC3CoC,OAAQV,EAAY5B,EAAkBP,QAAQS,GAEhD2C,QAAS,CACPZ,KAAMS,EAAeR,EAAQD,EAC7BC,MAAOQ,EAAeT,EAAOC,EAC7BG,IAAKI,EAAkBH,EAASD,EAChCC,OAAQG,EAAkBJ,EAAMC,IAIpCtC,EAAkBP,QAAU,CAAEQ,EAAG0B,EAAYzB,EAAG0B,WAChDX,EAAA1B,EAAmBE,eAAO,IAAAwB,GAAUC,QAAVA,EAA1BD,EAA4B7B,gBAA5B8B,IAAoCA,GAApCA,EAAAP,KAAAM,EAAuC0B,EAAQnC,EAChD,EAKD,OAHAH,EAAQyC,iBAAiB,SAAU1D,GACnCiB,EAAQyC,iBAAiB,YAAavC,GAE/B,WACLF,EAAQ0C,oBAAoB,SAAU3D,GACtCiB,EAAQ0C,oBAAoB,YAAaxC,EAC1C,CA5Da,CAHqB,CAgEpC,GAAE,CAAC1B,EAAQQ,EAAYe,QAEpBvB,EAAeiB,EACZ,CAACT,EAAaS,EACvB"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.94 */
|
|
2
|
+
import{b as e}from"../../_rollupPluginBabelHelpers-Dp_7XWBJ.js";import{useEffect as t}from"react";import{getElement as i}from"../../utils/helpers/getElement.js";import{useRefState as o}from"../useRefState/useRefState.js";var r=function(){var r="object"!==e(arguments.length<=0?void 0:arguments[0])||"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]:void 0,n=r?arguments.length<=1?void 0:arguments[1]:arguments.length<=0?void 0:arguments[0],l=o(),a=null!=n?n:{},v=a.behavior,s=void 0===v?"smooth":v,c=a.block,u=void 0===c?"start":c,f=a.inline,b=void 0===f?"nearest":f,d=a.enabled,g=void 0===d||d;t((function(){if(g&&(r||l.state)){var e=r?i(r):l.current;e&&e.scrollIntoView({behavior:s,block:u,inline:b})}}),[r,l.state,g]);var h=function(e){var t=r?i(r):l.current;if(t){var o=null!=e?e:{},n=o.behavior,a=o.block,v=o.inline;t.scrollIntoView({behavior:n,block:a,inline:v})}};return r?{trigger:h}:{ref:l,trigger:h}};export{r as useScrollIntoView};
|
|
3
|
+
//# sourceMappingURL=useScrollIntoView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useScrollIntoView.js","sources":["../../../../src/hooks/useScrollIntoView/useScrollIntoView.ts"],"sourcesContent":["import type { RefObject } from 'react';\n\nimport { useEffect } from 'react';\n\nimport { getElement } from '@/utils/helpers';\n\nimport type { StateRef } from '../useRefState/useRefState';\n\nimport { useRefState } from '../useRefState/useRefState';\n\n/** The scroll into view options type */\nexport interface UseScrollIntoViewOptions extends ScrollIntoViewOptions {\n /** Whether to enable the scroll into view */\n enabled?: boolean;\n}\n\n/** The scroll into view target type */\nexport type UseScrollIntoViewTarget = string | Element | RefObject<Element | null | undefined>;\n\n/** The scroll into view return type */\nexport interface UseScrollIntoViewReturn {\n /** Function to scroll element into view */\n trigger: (params?: {\n behavior?: ScrollBehavior;\n block?: ScrollLogicalPosition;\n inline?: ScrollLogicalPosition;\n }) => void;\n}\n\nexport interface UseScrollIntoViewOverload {\n <Target extends UseScrollIntoViewTarget>(\n target: Target,\n options?: UseScrollIntoViewOptions\n ): UseScrollIntoViewReturn;\n\n <Target extends UseScrollIntoViewTarget>(\n options?: UseScrollIntoViewOptions,\n target?: never\n ): { ref: StateRef<Target> } & UseScrollIntoViewReturn;\n}\n\n/**\n * @name useScrollIntoView\n * @description - Hook that provides functionality to scroll an element into view\n * @category Sensors\n *\n * @overload\n * @template Target The target element\n * @param {Target} target The target element to scroll into view\n * @param {ScrollBehavior} [options.behavior='smooth'] The scrolling behavior\n * @param {ScrollLogicalPosition} [options.block='start'] The vertical alignment\n * @param {ScrollLogicalPosition} [options.inline='nearest'] The horizontal alignment\n * @returns {UseScrollIntoViewReturn} Object containing scroll function\n *\n * @example\n * const { trigger } = useScrollIntoView(ref);\n *\n * @overload\n * @template Target The target element\n * @param {ScrollBehavior} [options.behavior='smooth'] The scrolling behavior\n * @param {ScrollLogicalPosition} [options.block='start'] The vertical alignment\n * @param {ScrollLogicalPosition} [options.inline='nearest'] The horizontal alignment\n * @returns {UseScrollIntoViewReturn & { ref: StateRef<Target> }} Object containing scroll function and ref\n *\n * @example\n * const { ref, trigger } = useScrollIntoView<HTMLDivElement>();\n */\nexport const useScrollIntoView = ((...params: any[]) => {\n const target = (\n typeof params[0] !== 'object' || 'current' in params[0] || params[0] instanceof Element\n ? params[0]\n : undefined\n ) as UseScrollIntoViewTarget | undefined;\n const options = (target ? params[1] : params[0]) as UseScrollIntoViewOptions | undefined;\n\n const internalRef = useRefState<Element>();\n const {\n behavior = 'smooth',\n block = 'start',\n inline = 'nearest',\n enabled = true\n } = options ?? {};\n\n useEffect(() => {\n if (!enabled) return;\n if (!target && !internalRef.state) return;\n\n const element = (target ? getElement(target) : internalRef.current) as Element;\n if (!element) return;\n\n element.scrollIntoView({\n behavior,\n block,\n inline\n });\n }, [target, internalRef.state, enabled]);\n\n const trigger = (params?: {\n behavior?: ScrollBehavior;\n block?: ScrollLogicalPosition;\n inline?: ScrollLogicalPosition;\n }) => {\n const element = (target ? getElement(target) : internalRef.current) as Element;\n if (!element) return;\n\n const { behavior, block, inline } = params ?? {};\n\n element.scrollIntoView({\n behavior,\n block,\n inline\n });\n };\n\n if (target) return { trigger };\n return { ref: internalRef, trigger };\n}) as UseScrollIntoViewOverload;\n"],"names":["useScrollIntoView","target","_typeof","arguments","length","undefined","Element","options","internalRef","useRefState","_ref","_ref$behavior","behavior","_ref$block","block","_ref$inline","inline","_ref$enabled","enabled","useEffect","state","element","getElement","current","scrollIntoView","trigger","params","_ref2","ref"],"mappings":";iOAmEaA,EAAqB,WAChC,IAAMC,EACiB,WAArBC,EAAAC,UAAAC,eAAAC,EAAAF,UAAqB,KAAY,YAASA,UAAAC,eAAAC,EAAAF,UAAa,MAAIA,UAAAC,QAAAC,OAAAA,EAAAF,UAAA,cAAqBG,QAAOH,UAAAC,QAAA,OAAAC,EAAAF,kBAEnFE,EAEAE,EAAWN,EAAME,UAAAC,QAAAC,OAAAA,EAAAF,UAAA,GAAAA,UAAAC,eAAAC,EAAAF,UAAiE,GAElFK,EAAcC,IACpBC,EAKIH,QAAAA,EAAW,CAAE,EAAAI,EAAAD,EAJfE,SAAAA,OAAW,IAAHD,EAAG,SAAQA,EAAAE,EAAAH,EACnBI,MAAAA,OAAQ,IAAHD,EAAG,QAAOA,EAAAE,EAAAL,EACfM,OAAAA,OAAS,IAAHD,EAAG,UAASA,EAAAE,EAAAP,EAClBQ,QAAAA,OAAU,IAAHD,GAAOA,EAGhBE,GAAU,WACR,GAAKD,IACAjB,GAAWO,EAAYY,OAA5B,CAEA,IAAMC,EAAWpB,EAASqB,EAAWrB,GAAUO,EAAYe,QACtDF,GAELA,EAAQG,eAAe,CACrBZ,SAAAA,EACAE,MAAAA,EACAE,OAAAA,GARiC,CAUpC,GAAE,CAACf,EAAQO,EAAYY,MAAOF,IAE/B,IAAMO,EAAU,SAACC,GAKf,IAAML,EAAWpB,EAASqB,EAAWrB,GAAUO,EAAYe,QAC3D,GAAKF,EAAL,CAEA,IAAAM,EAAoCD,QAAAA,EAAU,CAAE,EAAxCd,EAAQe,EAARf,SAAUE,EAAKa,EAALb,MAAOE,EAAMW,EAANX,OAEzBK,EAAQG,eAAe,CACrBZ,SAAAA,EACAE,MAAAA,EACAE,OAAAA,GAPY,CASf,EAED,OAAIf,EAAe,CAAEwB,QAAAA,GACd,CAAEG,IAAKpB,EAAaiB,QAAAA,EAC7B"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{useLayoutEffect as
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.94 */
|
|
2
|
+
import{useLayoutEffect as e}from"react";import{getElement as r}from"../../utils/helpers/getElement.js";import{isTarget as t}from"../../utils/helpers/isTarget.js";import{useRefState as o}from"../useRefState/useRefState.js";import"../../_rollupPluginBabelHelpers-Dp_7XWBJ.js";var i=function(){var i,l=t(arguments.length<=0?void 0:arguments[0])?arguments.length<=0?void 0:arguments[0]:void 0,a=null!==(i=l?arguments.length<=1?void 0:arguments[1]:arguments.length<=0?void 0:arguments[0])&&void 0!==i?i:{},n=a.x,v=a.y,s=a.behavior,u=void 0===s?"auto":s,f=a.enabled,p=void 0===f||f,h=o();e((function(){if(p&&(l||h.state)){var e=l?r(l):h.current;e&&e.scrollTo({top:v,left:n,behavior:u})}}),[l,h.state]);var m=function(e){var t=l?r(l):h.current;if(t){var o=null!=e?e:{},i=o.x,a=o.y,n=o.behavior;t.scrollTo({left:i,top:a,behavior:n})}};return l?m:{ref:h,trigger:m}};export{i as useScrollTo};
|
|
3
3
|
//# sourceMappingURL=useScrollTo.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useScrollTo.js","sources":["../../../../src/hooks/useScrollTo/useScrollTo.ts"],"sourcesContent":["import type { RefObject } from 'react';\n\nimport { useLayoutEffect } from 'react';\n\nimport { getElement, isTarget } from '@/utils/helpers';\n\nimport type { StateRef } from '../useRefState/useRefState';\n\nimport { useRefState } from '../useRefState/useRefState';\n\n/** The use scroll target element type */\nexport type UseScrollToTarget =\n | string\n | Document\n | Element\n | RefObject<Element | null | undefined>\n | Window;\n\n/** The use scroll to options type */\nexport interface UseScrollToOptions {\n /** The scrolling behavior */\n behavior?: ScrollBehavior;\n /** The horizontal position to scroll to */\n x: number;\n /** The vertical position to scroll to */\n y: number;\n}\n\n/** The use scroll to return type */\nexport interface UseScrollToReturn {\n /** The state of scrolling */\n trigger: (params
|
|
1
|
+
{"version":3,"file":"useScrollTo.js","sources":["../../../../src/hooks/useScrollTo/useScrollTo.ts"],"sourcesContent":["import type { RefObject } from 'react';\n\nimport { useLayoutEffect } from 'react';\n\nimport { getElement, isTarget } from '@/utils/helpers';\n\nimport type { StateRef } from '../useRefState/useRefState';\n\nimport { useRefState } from '../useRefState/useRefState';\n\n/** The use scroll target element type */\nexport type UseScrollToTarget =\n | string\n | Document\n | Element\n | RefObject<Element | null | undefined>\n | Window;\n\n/** The use scroll to options type */\nexport interface UseScrollToOptions {\n /** The scrolling behavior */\n behavior?: ScrollBehavior;\n /** Whether to enable the scroll to */\n enabled?: boolean;\n /** The horizontal position to scroll to */\n x: number;\n /** The vertical position to scroll to */\n y: number;\n}\n\n/** The use scroll to return type */\nexport interface UseScrollToReturn {\n /** The state of scrolling */\n trigger: (params?: { x: number; y: number; behavior?: ScrollBehavior }) => void;\n}\n\nexport interface UseScrollTo {\n <Target extends UseScrollToTarget>(target: Target): UseScrollToReturn;\n\n <Target extends UseScrollToTarget>(\n options?: UseScrollToOptions\n ): UseScrollToReturn & { ref: StateRef<Target> };\n}\n\n/**\n * @name useScrollTo\n * @description - Hook for scrolling to a specific element\n * @category Sensors\n *\n * @overload\n * @template Target The target element(s)\n * @param {Target} target The target element for scrolling to\n * @param {number} options.x The horizontal position to scroll to\n * @param {number} options.y The vertical position to scroll to\n * @param {ScrollBehavior} [options.behavior = 'auto'] The scrolling behavior\n * @returns {boolean} The state of scrolling\n *\n * @example\n * const trigger = useScrollTo(ref, options);\n *\n * @overload\n * @template Target The target element(s)\n * @param {number} options.x The horizontal position to scroll to\n * @param {number} options.y The vertical position to scroll to\n * @param {ScrollBehavior} [options.behavior = 'auto'] The scrolling behavior\n * @returns {StateRef<Target>} The state of scrolling\n *\n * @example\n * const { ref, trigger } = useScrollTo(options);\n */\nexport const useScrollTo = ((...params: any[]) => {\n const target = (isTarget(params[0]) ? params[0] : undefined) as UseScrollToTarget | undefined;\n const options = ((target ? params[1] : params[0]) as UseScrollToOptions) ?? {};\n const { x, y, behavior = 'auto', enabled = true } = options;\n const internalRef = useRefState<Element>();\n\n useLayoutEffect(() => {\n if (!enabled) return;\n if (!target && !internalRef.state) return;\n\n const element = (target ? getElement(target) : internalRef.current) as Element;\n if (!element) return;\n\n element.scrollTo({ top: y, left: x, behavior });\n }, [target, internalRef.state]);\n\n const trigger = (params?: { x: number; y: number; behavior?: ScrollBehavior }) => {\n const element = (target ? getElement(target) : internalRef.current) as Element;\n if (!element) return;\n const { x, y, behavior } = params ?? {};\n\n element.scrollTo({ left: x, top: y, behavior });\n };\n\n if (target) return trigger;\n return { ref: internalRef, trigger };\n}) as UseScrollTo;\n"],"names":["useScrollTo","_ref","target","isTarget","arguments","length","undefined","options","x","y","_options$behavior","behavior","_options$enabled","enabled","internalRef","useRefState","useLayoutEffect","state","element","getElement","current","scrollTo","top","left","trigger","params","_ref2","ref"],"mappings":";sRAsEaA,EAAe,WAAsB,IAAAC,EAC1CC,EAAUC,EAAQC,UAAAC,QAAAC,OAAAA,EAAAF,cAAWA,UAAAC,eAAAC,EAAAF,UAAA,QAAeE,EAC5CC,EAA0CN,QAAnCA,EAAKC,EAAME,UAAAC,QAAA,OAAAC,EAAAF,UAAA,GAAAA,UAAAC,QAAA,OAAAC,EAAAF,UAAA,UAAwBH,IAAAA,EAAAA,EAA4B,CAAE,EACtEO,EAA4CD,EAA5CC,EAAGC,EAAyCF,EAAzCE,EAACC,EAAwCH,EAAtCI,SAAAA,OAAW,IAAHD,EAAG,OAAMA,EAAAE,EAAqBL,EAAnBM,QAAAA,OAAU,IAAHD,GAAOA,EACzCE,EAAcC,IAEpBC,GAAgB,WACd,GAAKH,IACAX,GAAWY,EAAYG,OAA5B,CAEA,IAAMC,EAAWhB,EAASiB,EAAWjB,GAAUY,EAAYM,QACtDF,GAELA,EAAQG,SAAS,CAAEC,IAAKb,EAAGc,KAAMf,EAAGG,SAAAA,GALD,CAMpC,GAAE,CAACT,EAAQY,EAAYG,QAExB,IAAMO,EAAU,SAACC,GACf,IAAMP,EAAWhB,EAASiB,EAAWjB,GAAUY,EAAYM,QAC3D,GAAKF,EAAL,CACA,IAAAQ,EAA2BD,QAAAA,EAAU,CAAE,EAA/BjB,EAACkB,EAADlB,EAAGC,EAACiB,EAADjB,EAAGE,EAAQe,EAARf,SAEdO,EAAQG,SAAS,CAAEE,KAAMf,EAAGc,IAAKb,EAAGE,SAAAA,GAHtB,CAIf,EAED,OAAIT,EAAesB,EACZ,CAAEG,IAAKb,EAAaU,QAAAA,EAC7B"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{c as o}from"../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.94 */
|
|
2
|
+
import{c as o}from"../../_rollupPluginBabelHelpers-Dp_7XWBJ.js";import{useStorage as e}from"../useStorage/useStorage.js";import"react";import"../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js";var r=function(r,t,i){return e(r,o(o({},i),{},{initialValue:t,storage:"undefined"!=typeof window?window.localStorage:void 0}))};export{r as useSessionStorage};
|
|
3
3
|
//# sourceMappingURL=useSessionStorage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSessionStorage.js","sources":["../../../../src/hooks/useSessionStorage/useSessionStorage.ts"],"sourcesContent":["import type { UseStorageInitialValue, UseStorageOptions } from '../useStorage/useStorage';\n\nimport { useStorage } from '../useStorage/useStorage';\n\n/**\n * @name useSessionStorage\n * @description - Hook that manages session storage value\n * @category Browser\n *\n * @template Value The type of the value\n * @param {string} key The key of the storage\n * @param {UseStorageInitialValue<Value>} [initialValue] The initial value of the storage\n * @param {UseStorageOptions<Value>} [options] The options of the storage\n *\n * @example\n * const { value, set, remove } = useSessionStorage('key', 'value');\n */\nexport const useSessionStorage = <Value>(\n key: string,\n initialValue?: UseStorageInitialValue<Value>,\n options?: UseStorageOptions<Value>\n)
|
|
1
|
+
{"version":3,"file":"useSessionStorage.js","sources":["../../../../src/hooks/useSessionStorage/useSessionStorage.ts"],"sourcesContent":["import type { UseStorageInitialValue, UseStorageOptions } from '../useStorage/useStorage';\n\nimport { useStorage } from '../useStorage/useStorage';\n\n/**\n * @name useSessionStorage\n * @description - Hook that manages session storage value\n * @category Browser\n *\n * @template Value The type of the value\n * @param {string} key The key of the storage\n * @param {UseStorageInitialValue<Value>} [initialValue] The initial value of the storage\n * @param {UseStorageOptions<Value>} [options] The options of the storage\n *\n * @example\n * const { value, set, remove } = useSessionStorage('key', 'value');\n */\nexport const useSessionStorage = <Value>(\n key: string,\n initialValue?: UseStorageInitialValue<Value>,\n options?: UseStorageOptions<Value>\n) =>\n useStorage(key, {\n ...options,\n initialValue,\n storage: typeof window !== 'undefined' ? window.localStorage : undefined\n });\n"],"names":["useSessionStorage","key","initialValue","options","useStorage","_objectSpread","storage","window","localStorage","undefined"],"mappings":";yMAiBO,IAAMA,EAAoB,SAC/BC,EACAC,EACAC,GAAkC,OAElCC,EAAWH,EAAGI,EAAAA,KACTF,GAAO,GAAA,CACVD,aAAAA,EACAI,QAA2B,oBAAXC,OAAyBA,OAAOC,kBAAeC,IAC/D"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as e}from"../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.94 */
|
|
2
|
+
import{_ as e}from"../../_rollupPluginBabelHelpers-Dp_7XWBJ.js";import{useState as n}from"react";var r=function(r){var t=n(new Set(r)),u=e(t,2),i=u[0],f=u[1];return{value:i,size:i.size,has:function(e){return i.has(e)},add:function(e){return f((function(n){return new Set(n).add(e)}))},remove:function(e){return f((function(n){if(!n.has(e))return n;var r=new Set(n);return r.delete(e),r}))},clear:function(){return f(new Set)},reset:function(){return f(new Set(r))},toggle:function(e){return f((function(n){if(!n.has(e))return new Set(n).add(e);var r=new Set(n);return r.delete(e),r}))},union:function(e){return f(i.union(e))},difference:function(e){return f(i.difference(e))},symmetricDifference:function(e){return f(i.symmetricDifference(e))},intersection:function(e){return f(i.intersection(e))}}};export{r as useSet};
|
|
3
3
|
//# sourceMappingURL=useSet.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{d as r,e,c as a}from"../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.94 */
|
|
2
|
+
import{d as r,e,c as a}from"../../_rollupPluginBabelHelpers-Dp_7XWBJ.js";var n=function(n){var t="undefined"!=typeof navigator&&"share"in navigator,i=function(){var i=r(e().mark((function r(i){var s;return e().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(t){r.next=2;break}return r.abrupt("return");case 2:return(s=a(a({},n),i)).files&&navigator.canShare({files:s.files})&&navigator.share(s),r.abrupt("return",navigator.share(s));case 5:case"end":return r.stop()}}),r)})));return function(r){return i.apply(this,arguments)}}();return{share:i,supported:t}};export{n as useShare};
|
|
3
3
|
//# sourceMappingURL=useShare.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useShare.js","sources":["../../../../src/hooks/useShare/useShare.ts"],"sourcesContent":["/** The use share options type */\nexport interface UseShareParams {\n /**
|
|
1
|
+
{"version":3,"file":"useShare.js","sources":["../../../../src/hooks/useShare/useShare.ts"],"sourcesContent":["/** The use share options type */\nexport interface UseShareParams {\n /** Array of files to be shared */\n files?: File[];\n /** Text content to be shared */\n text?: string;\n /** Title of the content being shared */\n title?: string;\n /** URL link to be shared */\n url?: string;\n}\n\n/** The use share return type */\nexport interface UseShareReturn {\n /** Whether the Web Share API is supported in the current environment */\n supported: boolean;\n /** Function to trigger the native share dialog */\n share: (shareParams: ShareData) => Promise<void>;\n}\n\n/**\n * @name useShare\n * @description - Hook that utilizes the share api\n * @category Browser\n *\n * @param {UseShareParams} [params] The use share options\n * @returns {UseShareReturn}\n *\n * @example\n * const { share, supported } = useShare();\n */\nexport const useShare = (params?: UseShareParams) => {\n const supported = typeof navigator !== 'undefined' && 'share' in navigator;\n\n const share = async (shareParams: ShareData) => {\n if (!supported) return;\n\n const data = {\n ...params,\n ...shareParams\n };\n\n if (data.files && navigator.canShare({ files: data.files })) navigator.share(data);\n\n return navigator.share(data);\n };\n\n return { share, supported };\n};\n"],"names":["useShare","params","supported","navigator","share","_ref","_asyncToGenerator","_regeneratorRuntime","mark","_callee","shareParams","data","wrap","_context","prev","next","abrupt","_objectSpread","files","canShare","stop","_x","apply","this","arguments"],"mappings":";6EA+BaA,EAAW,SAACC,GACvB,IAAMC,EAAiC,oBAAdC,WAA6B,UAAWA,UAE3DC,EAAK,WAAA,IAAAC,EAAAC,EAAAC,IAAAC,MAAG,SAAAC,EAAOC,GAAsB,IAAAC,EAAA,OAAAJ,IAAAK,MAAA,SAAAC,GAAA,cAAAA,EAAAC,KAAAD,EAAAE,MAAA,KAAA,EAAA,GACpCb,EAAS,CAAAW,EAAAE,KAAA,EAAA,KAAA,CAAA,OAAAF,EAAAG,OAAA,UAAA,KAAA,EAOqE,OAL7EL,EAAIM,EAAAA,EACLhB,CAAAA,EAAAA,GACAS,IAGIQ,OAASf,UAAUgB,SAAS,CAAED,MAAOP,EAAKO,SAAUf,UAAUC,MAAMO,GAAME,EAAAG,OAAA,SAE5Eb,UAAUC,MAAMO,IAAK,KAAA,EAAA,IAAA,MAAA,OAAAE,EAAAO,OAAA,GAAAX,OAC7B,OAXKL,SAAKiB,GAAA,OAAAhB,EAAAiB,MAAAC,KAAAC,UAAA,EAAA,GAaX,MAAO,CAAEpB,MAAAA,EAAOF,UAAAA,EAClB"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.94 */
|
|
2
|
+
import{_ as r}from"../../_rollupPluginBabelHelpers-Dp_7XWBJ.js";import{useState as n,useRef as t}from"react";var e=function(e,u){var c=n(e),o=r(c,2),i=o[0],l=o[1],f=n([e]),a=r(f,2),s=a[0],h=a[1],v=t(0);return{history:s,value:i,set:function(r){h((function(n){var t=n.slice(0,v.current+1);return t.push(r),u&&t.length>u&&t.shift(),v.current=t.length-1,t})),l(r)},index:v.current,back:function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;v.current-r<0||(v.current-=r,l(s[v.current]))},forward:function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;v.current+r>=s.length||(v.current+=r,l(s[v.current]))},reset:function(){l(e),h([e]),v.current=0},undo:function(){0!==v.current&&(v.current--,l(s[v.current]),h((function(r){return r.slice(0,v.current+1)})))}}};export{e as useStateHistory};
|
|
3
|
+
//# sourceMappingURL=useStateHistory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useStateHistory.js","sources":["../../../../src/hooks/useStateHistory/useStateHistory.ts"],"sourcesContent":["import { useRef, useState } from 'react';\n\n/** The use state history hook return type */\ninterface UseStateHistoryReturn<Value> {\n /** All history values */\n history: Value[];\n /** Current index in history */\n index: number;\n /** Current value */\n value: Value;\n /** Go back specified number of steps in history (default: 1) */\n back: (steps?: number) => void;\n /** Go forward specified number of steps in history (default: 1) */\n forward: (steps?: number) => void;\n /** Reset history to initial state */\n reset: () => void;\n /** Set a new value */\n set: (value: Value) => void;\n /** Undo the last change */\n undo: () => void;\n}\n\n/**\n * @name useStateHistory\n * @description - Hook that manages state with history functionality\n * @category Utilities\n *\n * @param {Value} initialValue - The initial value to start the history with\n * @param {number} [maxSize=10] - Maximum number of history entries to keep\n * @returns {UseStateHistoryReturn<Value>} Object containing current value, history array and control methods\n *\n * @example\n * const { value, history, index, set, back, forward, reset, undo } = useStateHistory(0);\n */\nexport const useStateHistory = <Value>(\n initialValue: Value,\n maxSize?: number\n): UseStateHistoryReturn<Value> => {\n const [value, setValue] = useState<Value>(initialValue);\n const [history, setHistory] = useState<Value[]>([initialValue]);\n const currentIndexRef = useRef<number>(0);\n\n const set = (value: Value) => {\n setHistory((prevHistory) => {\n const newHistory = prevHistory.slice(0, currentIndexRef.current + 1);\n newHistory.push(value);\n if (maxSize && newHistory.length > maxSize) newHistory.shift();\n currentIndexRef.current = newHistory.length - 1;\n return newHistory;\n });\n setValue(value);\n };\n\n const undo = () => {\n if (currentIndexRef.current === 0) return;\n currentIndexRef.current--;\n setValue(history[currentIndexRef.current]);\n setHistory((prevHistory) => prevHistory.slice(0, currentIndexRef.current + 1));\n };\n\n const back = (steps: number = 1) => {\n if (currentIndexRef.current - steps < 0) return;\n currentIndexRef.current -= steps;\n setValue(history[currentIndexRef.current]);\n };\n\n const forward = (steps: number = 1) => {\n if (currentIndexRef.current + steps >= history.length) return;\n currentIndexRef.current += steps;\n setValue(history[currentIndexRef.current]);\n };\n\n const reset = () => {\n setValue(initialValue);\n setHistory([initialValue]);\n currentIndexRef.current = 0;\n };\n\n return {\n history,\n value,\n set,\n index: currentIndexRef.current,\n back,\n forward,\n reset,\n undo\n };\n};\n"],"names":["useStateHistory","initialValue","maxSize","_useState","useState","_useState2","_slicedToArray","value","setValue","_useState3","_useState4","history","setHistory","currentIndexRef","useRef","set","prevHistory","newHistory","slice","current","push","length","shift","index","back","steps","arguments","undefined","forward","reset","undo"],"mappings":";6GAkCO,IAAMA,EAAkB,SAC7BC,EACAC,GAEA,IAAAC,EAA0BC,EAAgBH,GAAaI,EAAAC,EAAAH,EAAA,GAAhDI,EAAKF,EAAA,GAAEG,EAAQH,EAAA,GACtBI,EAA8BL,EAAkB,CAACH,IAAcS,EAAAJ,EAAAG,EAAA,GAAxDE,EAAOD,EAAA,GAAEE,EAAUF,EAAA,GACpBG,EAAkBC,EAAe,GAsCvC,MAAO,CACLH,QAAAA,EACAJ,MAAAA,EACAQ,IAvCU,SAACR,GACXK,GAAW,SAACI,GACV,IAAMC,EAAaD,EAAYE,MAAM,EAAGL,EAAgBM,QAAU,GAIlE,OAHAF,EAAWG,KAAKb,GACZL,GAAWe,EAAWI,OAASnB,GAASe,EAAWK,QACvDT,EAAgBM,QAAUF,EAAWI,OAAS,EACvCJ,CACT,IACAT,EAASD,EACV,EA+BCgB,MAAOV,EAAgBM,QACvBK,KAvBW,WAAuB,IAAtBC,EAAaC,UAAAL,OAAA,QAAAM,IAAAD,UAAA,GAAAA,UAAA,GAAG,EACxBb,EAAgBM,QAAUM,EAAQ,IACtCZ,EAAgBM,SAAWM,EAC3BjB,EAASG,EAAQE,EAAgBM,UAClC,EAoBCS,QAlBc,WAAuB,IAAtBH,EAAaC,UAAAL,OAAA,QAAAM,IAAAD,UAAA,GAAAA,UAAA,GAAG,EAC3Bb,EAAgBM,QAAUM,GAASd,EAAQU,SAC/CR,EAAgBM,SAAWM,EAC3BjB,EAASG,EAAQE,EAAgBM,UAClC,EAeCU,MAbY,WACZrB,EAASP,GACTW,EAAW,CAACX,IACZY,EAAgBM,QAAU,CAC3B,EAUCW,KAjCW,WACqB,IAA5BjB,EAAgBM,UACpBN,EAAgBM,UAChBX,EAASG,EAAQE,EAAgBM,UACjCP,GAAW,SAACI,GAAW,OAAKA,EAAYE,MAAM,EAAGL,EAAgBM,QAAU,MAC5E,EA8BH"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{b as t,_ as r}from"../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.94 */
|
|
2
|
+
import{b as t,_ as r}from"../../_rollupPluginBabelHelpers-Dp_7XWBJ.js";import{useRef as n,useState as e}from"react";var i=function(i){var u="object"===t(i)?i.max:i,o="object"===t(i)?i.initial:1,c=n(o>u||o<1?1:o),s=e(o),a=r(s,2),f=a[0],l=a[1],p=1===f,b=f===u;return{counts:u,currentStep:f,isFirst:p,isLast:b,next:function(){b||l((function(t){return t+1}))},back:function(){p||l((function(t){return t-1}))},reset:function(){return l(c.current)},set:function(t){return"first"===t?l(c.current):"last"===t||t>=u?l(u):t<=1?l(1):void l(t)}}};export{i as useStep};
|
|
3
3
|
//# sourceMappingURL=useStep.js.map
|
|
@@ -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.94 */
|
|
2
|
+
import{_ as n,c as t}from"../../_rollupPluginBabelHelpers-Dp_7XWBJ.js";import{useState as r,useEffect as o}from"react";var u=function(n){return n?{days:Math.floor(n/86400),hours:Math.floor(n%86400/3600),minutes:Math.floor(n%3600/60),seconds:Math.floor(n%60),count:n}:{days:0,hours:0,minutes:0,seconds:0,count:0}},e=function(){for(var e,s,c=arguments.length,i=new Array(c),a=0;a<c;a++)i[a]=arguments[a];var l=null!==(e="number"==typeof i[0]?i[0]:null===(s=i[0])||void 0===s?void 0:s.initialTime)&&void 0!==e?e:0,f="number"==typeof i[0]?i[1]:i[0],d=r(u(l)),m=n(d,2),h=m[0],v=m[1],p=r(!(null!=f&&f.enabled)),y=n(p,2),b=y[0],g=y[1];return o((function(){if(!b){var n=setInterval((function(){v((function(n){var r=n.count+1;return t(t({},n),{},r%60==0?{minutes:n.minutes+1,seconds:0,count:r}:r%3600==0?{hours:n.hours+1,minutes:0,seconds:0,count:r}:r%86400==0?{days:n.days+1,hours:0,minutes:0,seconds:0,count:r}:{seconds:n.seconds+1,count:r})}))}),1e3);return function(){return clearInterval(n)}}}),[b]),t(t({},h),{},{paused:b,pause:function(){return g(!0)},start:function(){return g(!1)},reset:function(){return v(u(l))},toggle:function(){return g((function(n){return!n}))}})};export{e as useStopwatch};
|
|
3
3
|
//# sourceMappingURL=useStopwatch.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{b as e}from"../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.94 */
|
|
2
|
+
import{b as e}from"../../_rollupPluginBabelHelpers-Dp_7XWBJ.js";import{useSyncExternalStore as n}from"react";import{useIsomorphicLayoutEffect as t}from"../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js";var r=function(e){return window.dispatchEvent(new StorageEvent("storage",e))},o=function(e,n,t){var o=e.getItem(n);e.setItem(n,t),r({key:n,oldValue:o,newValue:t,storageArea:e})},i=function(e,n){var t=e.getItem(n);e.removeItem(n),r({key:n,oldValue:t,newValue:null,storageArea:e})},u=function(e,n){var t=e.getItem(n);if(t)return t},a=function(e){return window.addEventListener("storage",e),function(){return window.removeEventListener("storage",e)}},l=function(){},f=function(r,f){var c,s,d="object"===e(f)?f:void 0,v=d?null==d?void 0:d.initialValue:f;if("undefined"==typeof window)return{value:v instanceof Function?v():v};var m=function(e){return null!=d&&d.serializer?d.serializer(e):JSON.stringify(e)},g=null!==(c=null==d?void 0:d.storage)&&void 0!==c?c:null===(s=window)||void 0===s?void 0:s.localStorage,w=n(a,(function(){return u(g,r)}),l);return t((function(){void 0===u(g,r)&&void 0!==v&&o(g,r,m(v instanceof Function?v():v))}),[r]),{value:w?function(e){if(null!=d&&d.deserializer)return d.deserializer(e);if("undefined"!==e)try{return JSON.parse(e)}catch(n){return e}}(w):void 0,set:function(e){if(null===e)return i(g,r);o(g,r,m(e))},remove:function(){return i(g,r)}}};export{r as dispatchStorageEvent,f as useStorage};
|
|
3
3
|
//# sourceMappingURL=useStorage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStorage.js","sources":["../../../../src/hooks/useStorage/useStorage.ts"],"sourcesContent":["import { useSyncExternalStore } from 'react';\n\nimport { useIsomorphicLayoutEffect } from '../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect';\n\n/* The use storage initial value type */\nexport type UseStorageInitialValue<Value> = (() => Value) | Value;\n\n/* The use storage options type */\nexport interface UseStorageOptions<Value> {\n /* The initial value of the storage */\n initialValue?: UseStorageInitialValue<Value>;\n /* The storage to be used */\n storage?: Storage;\n /* The deserializer function to be invoked */\n deserializer?: (value: string) => Value;\n /* The serializer function to be invoked */\n serializer?: (value: Value) => string;\n}\n\n/* The use storage return type */\nexport interface UseStorageReturn<Value> {\n /* The value of the storage */\n value: Value;\n /* The error state of the storage */\n remove: () => void;\n /* The loading state of the storage */\n set: (value: Value) => void;\n}\n\nexport const dispatchStorageEvent = (params: Partial<StorageEvent>) =>\n window.dispatchEvent(new StorageEvent('storage', params));\n\nconst setStorageItem = (storage: Storage, key: string, value: string) => {\n const oldValue = storage.getItem(key);\n\n storage.setItem(key, value);\n dispatchStorageEvent({ key, oldValue, newValue: value, storageArea: storage });\n};\n\nconst removeStorageItem = (storage: Storage, key: string) => {\n const oldValue = storage.getItem(key);\n\n storage.removeItem(key);\n dispatchStorageEvent({ key, oldValue, newValue: null, storageArea: storage });\n};\n\nconst getStorageItem = (storage: Storage, key: string) => {\n const value = storage.getItem(key);\n if (!value) return undefined;\n return value;\n};\n\nconst storageSubscribe = (callback: () => void) => {\n window.addEventListener('storage', callback);\n return () => window.removeEventListener('storage', callback);\n};\n\nconst getServerSnapshot = () => undefined;\n\n/**\n * @name useStorage\n * @description - Hook that manages storage value\n * @category Utilities\n *\n * @param {string} key The key of the storage\n * @param {(value: Value) => string} [params.serializer] The serializer function\n * @param {(value: string) => Value} [params.deserializer] The deserializer function\n * @param {Storage} [params.storage] The storage\n * @param {UseStorageInitialValue<Value>} [params.initialValue] The initial value of the storage\n * @returns {UseStorageReturn<Value>} The value and the set function\n *\n * @example\n * const { value, set, remove } = useStorage('key', 'value');\n */\nexport const useStorage = <Value>(\n key: string,\n params?: UseStorageInitialValue<Value> | UseStorageOptions<Value>\n) => {\n const options = (typeof params === 'object' ? params : undefined) as UseStorageOptions<Value>;\n const initialValue = (options ? options?.initialValue : params) as UseStorageInitialValue<Value>;\n\n const serializer = (value: Value) => {\n if (options?.serializer) return options.serializer(value);\n return JSON.stringify(value);\n };\n\n const storage = options?.storage ?? window?.localStorage;\n\n const set = (value: Value) => {\n if (value === null) return removeStorageItem(storage, key);\n setStorageItem(storage, key, serializer(value));\n };\n const remove = () => removeStorageItem(storage, key);\n\n const deserializer = (value: string) => {\n if (options?.deserializer) return options.deserializer(value);\n\n if (value === 'undefined') {\n return undefined as unknown as Value;\n }\n\n try {\n return JSON.parse(value) as Value;\n } catch {\n return value as Value;\n }\n };\n\n const getSnapshot = () => getStorageItem(storage, key);\n const store = useSyncExternalStore(storageSubscribe, getSnapshot, getServerSnapshot);\n\n useIsomorphicLayoutEffect(() => {\n const value = getStorageItem(storage, key);\n if (value === undefined && initialValue !== undefined) {\n setStorageItem(\n storage,\n key,\n serializer(initialValue instanceof Function ? initialValue() : initialValue)\n );\n }\n }, [key]);\n\n
|
|
1
|
+
{"version":3,"file":"useStorage.js","sources":["../../../../src/hooks/useStorage/useStorage.ts"],"sourcesContent":["import { useSyncExternalStore } from 'react';\n\nimport { useIsomorphicLayoutEffect } from '../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect';\n\n/* The use storage initial value type */\nexport type UseStorageInitialValue<Value> = (() => Value) | Value;\n\n/* The use storage options type */\nexport interface UseStorageOptions<Value> {\n /* The initial value of the storage */\n initialValue?: UseStorageInitialValue<Value>;\n /* The storage to be used */\n storage?: Storage;\n /* The deserializer function to be invoked */\n deserializer?: (value: string) => Value;\n /* The serializer function to be invoked */\n serializer?: (value: Value) => string;\n}\n\n/* The use storage return type */\nexport interface UseStorageReturn<Value> {\n /* The value of the storage */\n value: Value;\n /* The error state of the storage */\n remove: () => void;\n /* The loading state of the storage */\n set: (value: Value) => void;\n}\n\nexport const dispatchStorageEvent = (params: Partial<StorageEvent>) =>\n window.dispatchEvent(new StorageEvent('storage', params));\n\nconst setStorageItem = (storage: Storage, key: string, value: string) => {\n const oldValue = storage.getItem(key);\n\n storage.setItem(key, value);\n dispatchStorageEvent({ key, oldValue, newValue: value, storageArea: storage });\n};\n\nconst removeStorageItem = (storage: Storage, key: string) => {\n const oldValue = storage.getItem(key);\n\n storage.removeItem(key);\n dispatchStorageEvent({ key, oldValue, newValue: null, storageArea: storage });\n};\n\nconst getStorageItem = (storage: Storage, key: string) => {\n const value = storage.getItem(key);\n if (!value) return undefined;\n return value;\n};\n\nconst storageSubscribe = (callback: () => void) => {\n window.addEventListener('storage', callback);\n return () => window.removeEventListener('storage', callback);\n};\n\nconst getServerSnapshot = () => undefined;\n\n/**\n * @name useStorage\n * @description - Hook that manages storage value\n * @category Utilities\n *\n * @param {string} key The key of the storage\n * @param {(value: Value) => string} [params.serializer] The serializer function\n * @param {(value: string) => Value} [params.deserializer] The deserializer function\n * @param {Storage} [params.storage] The storage\n * @param {UseStorageInitialValue<Value>} [params.initialValue] The initial value of the storage\n * @returns {UseStorageReturn<Value>} The value and the set function\n *\n * @example\n * const { value, set, remove } = useStorage('key', 'value');\n */\nexport const useStorage = <Value>(\n key: string,\n params?: UseStorageInitialValue<Value> | UseStorageOptions<Value>\n) => {\n const options = (typeof params === 'object' ? params : undefined) as UseStorageOptions<Value>;\n const initialValue = (options ? options?.initialValue : params) as UseStorageInitialValue<Value>;\n\n if (typeof window === 'undefined')\n return {\n value: initialValue instanceof Function ? initialValue() : initialValue\n } as UseStorageReturn<Value>;\n\n const serializer = (value: Value) => {\n if (options?.serializer) return options.serializer(value);\n return JSON.stringify(value);\n };\n\n const storage = options?.storage ?? window?.localStorage;\n\n const set = (value: Value) => {\n if (value === null) return removeStorageItem(storage, key);\n setStorageItem(storage, key, serializer(value));\n };\n const remove = () => removeStorageItem(storage, key);\n\n const deserializer = (value: string) => {\n if (options?.deserializer) return options.deserializer(value);\n\n if (value === 'undefined') {\n return undefined as unknown as Value;\n }\n\n try {\n return JSON.parse(value) as Value;\n } catch {\n return value as Value;\n }\n };\n\n const getSnapshot = () => getStorageItem(storage, key);\n const store = useSyncExternalStore(storageSubscribe, getSnapshot, getServerSnapshot);\n\n useIsomorphicLayoutEffect(() => {\n const value = getStorageItem(storage, key);\n if (value === undefined && initialValue !== undefined) {\n setStorageItem(\n storage,\n key,\n serializer(initialValue instanceof Function ? initialValue() : initialValue)\n );\n }\n }, [key]);\n\n return {\n value: store ? deserializer(store) : undefined,\n set,\n remove\n };\n};\n"],"names":["dispatchStorageEvent","params","window","dispatchEvent","StorageEvent","setStorageItem","storage","key","value","oldValue","getItem","setItem","newValue","storageArea","removeStorageItem","removeItem","getStorageItem","storageSubscribe","callback","addEventListener","removeEventListener","getServerSnapshot","useStorage","_options$storage","_window","options","_typeof","undefined","initialValue","Function","serializer","JSON","stringify","localStorage","store","useSyncExternalStore","useIsomorphicLayoutEffect","deserializer","parse","_unused","set","remove"],"mappings":";uNA6BaA,EAAuB,SAACC,GAA6B,OAChEC,OAAOC,cAAc,IAAIC,aAAa,UAAWH,GAAQ,EAErDI,EAAiB,SAACC,EAAkBC,EAAaC,GACrD,IAAMC,EAAWH,EAAQI,QAAQH,GAEjCD,EAAQK,QAAQJ,EAAKC,GACrBR,EAAqB,CAAEO,IAAAA,EAAKE,SAAAA,EAAUG,SAAUJ,EAAOK,YAAaP,GACtE,EAEMQ,EAAoB,SAACR,EAAkBC,GAC3C,IAAME,EAAWH,EAAQI,QAAQH,GAEjCD,EAAQS,WAAWR,GACnBP,EAAqB,CAAEO,IAAAA,EAAKE,SAAAA,EAAUG,SAAU,KAAMC,YAAaP,GACrE,EAEMU,EAAiB,SAACV,EAAkBC,GACxC,IAAMC,EAAQF,EAAQI,QAAQH,GAC9B,GAAKC,EACL,OAAOA,CACT,EAEMS,EAAmB,SAACC,GAExB,OADAhB,OAAOiB,iBAAiB,UAAWD,GAC5B,WAAA,OAAMhB,OAAOkB,oBAAoB,UAAWF,EAAS,CAC9D,EAEMG,EAAoB,WAAe,EAiB5BC,EAAa,SACxBf,EACAN,GACG,IAAAsB,EAAAC,EACGC,EAA6B,WAAlBC,EAAOzB,GAAsBA,OAAS0B,EACjDC,EAAgBH,EAAUA,aAAO,EAAPA,EAASG,aAAe3B,EAExD,GAAsB,oBAAXC,OACT,MAAO,CACLM,MAAOoB,aAAwBC,SAAWD,IAAiBA,GAG/D,IAAME,EAAa,SAACtB,GAClB,OAAIiB,SAAAA,EAASK,WAAmBL,EAAQK,WAAWtB,GAC5CuB,KAAKC,UAAUxB,EACvB,EAEKF,EAA0B,QAAnBiB,EAAGE,aAAO,EAAPA,EAASnB,eAAOiB,IAAAA,EAAAA,UAAAC,EAAItB,cAAM,IAAAsB,OAAA,EAANA,EAAQS,aAuBtCC,EAAQC,EAAqBlB,GADf,WAAH,OAASD,EAAeV,EAASC,EAAI,GACYc,GAalE,OAXAe,GAA0B,gBAEVT,IADAX,EAAeV,EAASC,SACMoB,IAAjBC,GACzBvB,EACEC,EACAC,EACAuB,EAAWF,aAAwBC,SAAWD,IAAiBA,GAGrE,GAAG,CAACrB,IAEG,CACLC,MAAO0B,EA7BY,SAAC1B,GACpB,GAAIiB,SAAAA,EAASY,aAAc,OAAOZ,EAAQY,aAAa7B,GAEvD,GAAc,cAAVA,EAIJ,IACE,OAAOuB,KAAKO,MAAM9B,EACnB,CAAC,MAAA+B,GACA,OAAO/B,CACT,CACD,CAiBgB6B,CAAaH,QAASP,EACrCa,IApCU,SAAChC,GACX,GAAc,OAAVA,EAAgB,OAAOM,EAAkBR,EAASC,GACtDF,EAAeC,EAASC,EAAKuB,EAAWtB,GACzC,EAkCCiC,OAjCa,WAAH,OAAS3B,EAAkBR,EAASC,EAAI,EAmCtD"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.94 */
|
|
2
|
+
import{_ as t}from"../../_rollupPluginBabelHelpers-Dp_7XWBJ.js";import{useState as r}from"react";import{getElement as e}from"../../utils/helpers/getElement.js";import{useIsomorphicLayoutEffect as o}from"../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js";import{useRefState as i}from"../useRefState/useRefState.js";var n=function(){var n,u="string"==typeof(arguments.length<=0?void 0:arguments[0])&&["auto","ltr","rtl"].includes(arguments.length<=0?void 0:arguments[0])||arguments.length<=0?void 0:arguments[0],l=null!==(n=u?arguments.length<=1?void 0:arguments[1]:arguments.length<=0?void 0:arguments[0])&&void 0!==n?n:"ltr",s=i(),v=function(){var t,r=u?e(u):s.current;return null!==(t=null==r?void 0:r.getAttribute("dir"))&&void 0!==t?t:l},f=r(v()),a=t(f,2),c=a[0],m=a[1],d=function(){var t=u?e(u):s.current;t&&(null==t||t.removeAttribute("dir"))},p=function(t){var r=u?e(u):s.current;r&&(m(t),r.setAttribute("dir",t))};return o((function(){if(u||s){var t=u?e(u):s.current;if(t){var r=v();t.setAttribute("dir",r),m(r);var o=new MutationObserver(v);return o.observe(t,{attributes:!0}),function(){o.disconnect()}}}}),[s.current,u]),u?{value:c,set:p,remove:d}:{ref:s,value:c,set:p,remove:d}};export{n as useTextDirection};
|
|
3
3
|
//# sourceMappingURL=useTextDirection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTextDirection.js","sources":["../../../../src/hooks/useTextDirection/useTextDirection.ts"],"sourcesContent":["import type { RefObject } from 'react';\n\nimport { useState } from 'react';\n\nimport { getElement } from '@/utils/helpers';\n\nimport type { StateRef } from '../useRefState/useRefState';\n\nimport { useIsomorphicLayoutEffect } from '../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect';\nimport { useRefState } from '../useRefState/useRefState';\n\n/** The use text direction target element type */\nexport type UseTextDirectionTarget = string | Element | RefObject<Element | null | undefined>;\n\n/** The use text direction value type */\nexport type UseTextDirectionValue = 'auto' | 'ltr' | 'rtl';\n\n/** The use text direction return type */\nexport interface UseTextDirectionReturn {\n /** The current direction */\n value: UseTextDirectionValue;\n /*** The function to remove the direction */\n remove: () => void;\n /*** The function to set the direction */\n set: (value: UseTextDirectionValue | null) => void;\n}\n\nexport interface UseTextDirection {\n <Target extends UseTextDirectionTarget>(\n target: Target,\n initialValue?: UseTextDirectionValue\n ): UseTextDirectionReturn;\n\n <Target extends UseTextDirectionTarget>(\n initialValue?: UseTextDirectionValue,\n target?: never\n ): UseTextDirectionReturn & { ref: StateRef<Target> };\n}\n\n/**\n * @name useTextDirection\n * @description - Hook that can get and set the direction of the element\n * @category Browser\n *\n * @overload\n * @template Target The target element type.\n * @param {UseTextDirectionTarget} target The target element to observe.\n * @param {UseTextDirectionValue} [initialValue = 'ltr'] The initial direction of the element.\n * @returns {UseTextDirectionReturn} An object containing the current text direction of the element.\n *\n * @example\n * const { value, set, remove } = useTextDirection(ref);\n *\n * @overload\n * @template Target The target element type.\n * @param {UseTextDirectionValue} [initialValue = 'ltr'] The initial direction of the element.\n * @returns { { ref: StateRef<Target> } & UseTextDirectionReturn } An object containing the current text direction of the element.\n *\n * @example\n * const { ref, value, set, remove } = useTextDirection();\n */\nexport const useTextDirection = ((...params: any[]) => {\n const target = (\n typeof params[0] !== 'string' || !['auto', 'ltr', 'rtl'].includes(params[0])\n ? params[0]\n : undefined\n ) as UseTextDirectionTarget | undefined;\n const initialValue = ((target ? params[1] : params[0]) as UseTextDirectionValue) ?? 'ltr';\n\n const internalRef = useRefState<Element>();\n\n const getDirection = () => {\n const element = (target ? getElement(target) : internalRef.current) as Element;\n return (element?.getAttribute('dir') as UseTextDirectionValue) ?? initialValue;\n };\n\n const [value, setValue] = useState<UseTextDirectionValue>(getDirection());\n\n const remove = () => {\n const element = (target ? getElement(target) : internalRef.current) as Element;\n if (!element) return;\n\n element?.removeAttribute('dir');\n };\n\n const set = (value: UseTextDirectionValue) => {\n const element = (target ? getElement(target) : internalRef.current) as Element;\n if (!element) return;\n\n setValue(value);\n element.setAttribute('dir', value);\n };\n\n useIsomorphicLayoutEffect(() => {\n if (!target && !internalRef) return;\n\n const element = (target ? getElement(target) : internalRef.current) as Element;\n if (!element) return;\n\n const direction = getDirection();\n element.setAttribute('dir', direction);\n setValue(direction);\n\n const observer = new MutationObserver(getDirection);\n\n observer.observe(element, { attributes: true });\n\n return () => {\n observer.disconnect();\n };\n }, [internalRef.current, target]);\n\n if (target) return { value, set, remove };\n return {\n ref: internalRef,\n value,\n set,\n remove\n };\n}) as UseTextDirection;\n"],"names":["useTextDirection","_ref","target","arguments","length","undefined","includes","initialValue","internalRef","useRefState","getDirection","_ref2","element","getElement","current","getAttribute","_useState","useState","_useState2","_slicedToArray","value","setValue","remove","removeAttribute","set","setAttribute","useIsomorphicLayoutEffect","direction","observer","MutationObserver","observe","attributes","disconnect","ref"],"mappings":";
|
|
1
|
+
{"version":3,"file":"useTextDirection.js","sources":["../../../../src/hooks/useTextDirection/useTextDirection.ts"],"sourcesContent":["import type { RefObject } from 'react';\n\nimport { useState } from 'react';\n\nimport { getElement } from '@/utils/helpers';\n\nimport type { StateRef } from '../useRefState/useRefState';\n\nimport { useIsomorphicLayoutEffect } from '../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect';\nimport { useRefState } from '../useRefState/useRefState';\n\n/** The use text direction target element type */\nexport type UseTextDirectionTarget = string | Element | RefObject<Element | null | undefined>;\n\n/** The use text direction value type */\nexport type UseTextDirectionValue = 'auto' | 'ltr' | 'rtl';\n\n/** The use text direction return type */\nexport interface UseTextDirectionReturn {\n /** The current direction */\n value: UseTextDirectionValue;\n /*** The function to remove the direction */\n remove: () => void;\n /*** The function to set the direction */\n set: (value: UseTextDirectionValue | null) => void;\n}\n\nexport interface UseTextDirection {\n <Target extends UseTextDirectionTarget>(\n target: Target,\n initialValue?: UseTextDirectionValue\n ): UseTextDirectionReturn;\n\n <Target extends UseTextDirectionTarget>(\n initialValue?: UseTextDirectionValue,\n target?: never\n ): UseTextDirectionReturn & { ref: StateRef<Target> };\n}\n\n/**\n * @name useTextDirection\n * @description - Hook that can get and set the direction of the element\n * @category Browser\n *\n * @overload\n * @template Target The target element type.\n * @param {UseTextDirectionTarget} target The target element to observe.\n * @param {UseTextDirectionValue} [initialValue = 'ltr'] The initial direction of the element.\n * @returns {UseTextDirectionReturn} An object containing the current text direction of the element.\n *\n * @example\n * const { value, set, remove } = useTextDirection(ref);\n *\n * @overload\n * @template Target The target element type.\n * @param {UseTextDirectionValue} [initialValue = 'ltr'] The initial direction of the element.\n * @returns { { ref: StateRef<Target> } & UseTextDirectionReturn } An object containing the current text direction of the element.\n *\n * @example\n * const { ref, value, set, remove } = useTextDirection();\n */\nexport const useTextDirection = ((...params: any[]) => {\n const target = (\n typeof params[0] !== 'string' || !['auto', 'ltr', 'rtl'].includes(params[0])\n ? params[0]\n : undefined\n ) as UseTextDirectionTarget | undefined;\n const initialValue = ((target ? params[1] : params[0]) as UseTextDirectionValue) ?? 'ltr';\n\n const internalRef = useRefState<Element>();\n\n const getDirection = () => {\n const element = (target ? getElement(target) : internalRef.current) as Element;\n return (element?.getAttribute('dir') as UseTextDirectionValue) ?? initialValue;\n };\n\n const [value, setValue] = useState<UseTextDirectionValue>(getDirection());\n\n const remove = () => {\n const element = (target ? getElement(target) : internalRef.current) as Element;\n if (!element) return;\n\n element?.removeAttribute('dir');\n };\n\n const set = (value: UseTextDirectionValue) => {\n const element = (target ? getElement(target) : internalRef.current) as Element;\n if (!element) return;\n\n setValue(value);\n element.setAttribute('dir', value);\n };\n\n useIsomorphicLayoutEffect(() => {\n if (!target && !internalRef) return;\n\n const element = (target ? getElement(target) : internalRef.current) as Element;\n if (!element) return;\n\n const direction = getDirection();\n element.setAttribute('dir', direction);\n setValue(direction);\n\n const observer = new MutationObserver(getDirection);\n\n observer.observe(element, { attributes: true });\n\n return () => {\n observer.disconnect();\n };\n }, [internalRef.current, target]);\n\n if (target) return { value, set, remove };\n return {\n ref: internalRef,\n value,\n set,\n remove\n };\n}) as UseTextDirection;\n"],"names":["useTextDirection","_ref","target","arguments","length","undefined","includes","initialValue","internalRef","useRefState","getDirection","_ref2","element","getElement","current","getAttribute","_useState","useState","_useState2","_slicedToArray","value","setValue","remove","removeAttribute","set","setAttribute","useIsomorphicLayoutEffect","direction","observer","MutationObserver","observe","attributes","disconnect","ref"],"mappings":";sUA6DaA,EAAoB,WAAsB,IAAAC,EAC/CC,EACiB,iBAArBC,UAAAC,eAAAC,EAAAF,UAAgB,KAAkB,CAAC,OAAQ,MAAO,OAAOG,SAAQH,UAAAC,QAAAC,OAAAA,EAAAF,UAAA,KAAWA,UAAAC,QAAA,OAExEC,EAFwEF,aAIxEI,EAA+C,QAAnCN,EAAKC,EAAMC,UAAAC,QAAAC,OAAAA,EAAAF,UAAAA,GAAAA,UAAAC,QAAAC,OAAAA,EAAAF,UAAwB,UAAA,IAAAF,EAAAA,EAA+B,MAE9EO,EAAcC,IAEdC,EAAe,WAAM,IAAAC,EACnBC,EAAWV,EAASW,EAAWX,GAAUM,EAAYM,QAC3D,OAAoC,QAApCH,EAAQC,eAAAA,EAASG,aAAa,cAAMJ,IAAAA,EAAAA,EAA8BJ,CACnE,EAEDS,EAA0BC,EAAgCP,KAAeQ,EAAAC,EAAAH,EAAA,GAAlEI,EAAKF,EAAA,GAAEG,EAAQH,EAAA,GAEhBI,EAAS,WACb,IAAMV,EAAWV,EAASW,EAAWX,GAAUM,EAAYM,QACtDF,IAELA,SAAAA,EAASW,gBAAgB,OAC1B,EAEKC,EAAM,SAACJ,GACX,IAAMR,EAAWV,EAASW,EAAWX,GAAUM,EAAYM,QACtDF,IAELS,EAASD,GACTR,EAAQa,aAAa,MAAOL,GAC7B,EAqBD,OAnBAM,GAA0B,WACxB,GAAKxB,GAAWM,EAAhB,CAEA,IAAMI,EAAWV,EAASW,EAAWX,GAAUM,EAAYM,QAC3D,GAAKF,EAAL,CAEA,IAAMe,EAAYjB,IAClBE,EAAQa,aAAa,MAAOE,GAC5BN,EAASM,GAET,IAAMC,EAAW,IAAIC,iBAAiBnB,GAItC,OAFAkB,EAASE,QAAQlB,EAAS,CAAEmB,YAAY,IAEjC,WACLH,EAASI,YACV,CAZa,CAHe,CAgB9B,GAAE,CAACxB,EAAYM,QAASZ,IAErBA,EAAe,CAAEkB,MAAAA,EAAOI,IAAAA,EAAKF,OAAAA,GAC1B,CACLW,IAAKzB,EACLY,MAAAA,EACAI,IAAAA,EACAF,OAAAA,EAEJ"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as e}from"../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.94 */
|
|
2
|
+
import{_ as e}from"../../_rollupPluginBabelHelpers-Dp_7XWBJ.js";import{useState as n,useEffect as t}from"react";import{useRerender as r}from"../useRerender/useRerender.js";var o=function(e){var n,t=null!==(n=e.rangeCount)&&void 0!==n?n:0;return Array.from({length:t},(function(n,t){return e.getRangeAt(t)}))},u=function(){var u,i=r(),c=n("undefined"!=typeof document?document.getSelection():null),l=e(c,2),a=l[0],d=l[1];t((function(){var e=function(){d(document.getSelection()),i()};return document.addEventListener("selectionchange",e),function(){return document.removeEventListener("selectionchange",e)}}),[]);var m=null!==(u=null==a?void 0:a.toString())&&void 0!==u?u:"",f=a?o(a):[],g=f.map((function(e){return e.getBoundingClientRect()}));return{text:m,ranges:f,rects:g,selection:a}};export{o as getRangesSelection,u as useTextSelection};
|
|
3
3
|
//# sourceMappingURL=useTextSelection.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.94 */
|
|
2
2
|
import{useMemo as r}from"react";import{throttle as t}from"../../utils/helpers/throttle.js";import{useEvent as e}from"../useEvent/useEvent.js";var o=function(o,n){var u=e(o);return r((function(){return t(u,n)}),[n])};export{o as useThrottleCallback};
|
|
3
3
|
//# sourceMappingURL=useThrottleCallback.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useThrottleCallback.js","sources":["../../../../src/hooks/useThrottleCallback/useThrottleCallback.ts"],"sourcesContent":["import { useMemo } from 'react';\
|
|
1
|
+
{"version":3,"file":"useThrottleCallback.js","sources":["../../../../src/hooks/useThrottleCallback/useThrottleCallback.ts"],"sourcesContent":["import { useMemo } from 'react';\n\nimport { throttle } from '@/utils/helpers';\n\nimport { useEvent } from '../useEvent/useEvent';\n\n/**\n * @name useThrottleCallback\n * @description - Hook that creates a throttled callback and returns a stable reference of it\n * @category Utilities\n *\n * @template Params The type of the params\n * @template Return The type of the return\n * @param {(...args: Params) => Return} callback The callback function\n * @param {number} delay The delay in milliseconds\n * @returns {(...args: Params) => Return} The callback with throttle\n *\n * @example\n * const throttled = useThrottleCallback(() => console.log('callback'), 500);\n */\nexport const useThrottleCallback = <Params extends unknown[], Return>(\n callback: (...args: Params) => Return,\n delay: number\n) => {\n const internalCallback = useEvent(callback);\n const throttled = useMemo(() => throttle(internalCallback, delay), [delay]);\n\n return throttled;\n};\n"],"names":["useThrottleCallback","callback","delay","internalCallback","useEvent","useMemo","throttle"],"mappings":";8IAoBO,IAAMA,EAAsB,SACjCC,EACAC,GAEA,IAAMC,EAAmBC,EAASH,GAGlC,OAFkBI,GAAQ,WAAA,OAAMC,EAASH,EAAkBD,KAAQ,CAACA,GAGtE"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as r}from"../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.94 */
|
|
2
|
+
import{_ as r}from"../../_rollupPluginBabelHelpers-Dp_7XWBJ.js";import{useRef as t,useState as e,useEffect as o}from"react";import{useThrottleCallback as l}from"../useThrottleCallback/useThrottleCallback.js";import"../../utils/helpers/throttle.js";import"../useEvent/useEvent.js";var s=function(s,u){var n=t(s),a=e(s),i=r(a,2),p=i[0],m=i[1],c=l(m,u);return o((function(){n.current!==s&&(c(s),n.current=s)}),[s]),p};export{s as useThrottleValue};
|
|
3
3
|
//# sourceMappingURL=useThrottleValue.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useThrottleValue.js","sources":["../../../../src/hooks/useThrottleValue/useThrottleValue.ts"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\
|
|
1
|
+
{"version":3,"file":"useThrottleValue.js","sources":["../../../../src/hooks/useThrottleValue/useThrottleValue.ts"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\n\nimport { useThrottleCallback } from '../useThrottleCallback/useThrottleCallback';\n\n/**\n * @name useThrottleValue\n * @description - Hook that creates a throttled value and returns a stable reference of it\n * @category Utilities\n *\n * @template Value The type of the value\n * @param {Value} value The value to be throttled\n * @param {number} delay The delay in milliseconds\n * @returns {Value} The throttled value\n *\n * @example\n * const throttledValue = useThrottleValue(value, 500);\n */\nexport const useThrottleValue = <Value>(value: Value, delay: number) => {\n const previousValueRef = useRef(value);\n const [throttledValue, setThrottleValue] = useState(value);\n\n const throttledSetState = useThrottleCallback(setThrottleValue, delay);\n\n useEffect(() => {\n if (previousValueRef.current === value) return;\n throttledSetState(value);\n previousValueRef.current = value;\n }, [value]);\n\n return throttledValue;\n};\n"],"names":["useThrottleValue","value","delay","previousValueRef","useRef","_useState","useState","_useState2","_slicedToArray","throttledValue","setThrottleValue","throttledSetState","useThrottleCallback","useEffect","current"],"mappings":";wRAiBO,IAAMA,EAAmB,SAAQC,EAAcC,GACpD,IAAMC,EAAmBC,EAAOH,GAChCI,EAA2CC,EAASL,GAAMM,EAAAC,EAAAH,EAAA,GAAnDI,EAAcF,EAAA,GAAEG,EAAgBH,EAAA,GAEjCI,EAAoBC,EAAoBF,EAAkBR,GAQhE,OANAW,GAAU,WACJV,EAAiBW,UAAYb,IACjCU,EAAkBV,GAClBE,EAAiBW,QAAUb,EAC7B,GAAG,CAACA,IAEGQ,CACT"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as r}from"../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.94 */
|
|
2
|
+
import{_ as r}from"../../_rollupPluginBabelHelpers-Dp_7XWBJ.js";import{useState as e}from"react";import{getDate as t}from"../../utils/helpers/getDate.js";import{useInterval as o}from"../useInterval/useInterval.js";var l=function(){var l=e(t()),n=r(l,2),s=n[0],u=n[1];return o((function(){return u(t())}),1e3),s};export{l as useTime};
|
|
3
3
|
//# sourceMappingURL=useTime.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTime.js","sources":["../../../../src/hooks/useTime/useTime.ts"],"sourcesContent":["import { useState } from 'react';\n\nimport { getDate } from '@/utils/helpers';\n\nimport { useInterval } from '../useInterval/useInterval';\n\nexport interface UseTimeReturn {\n day: number;\n hours: number;\n meridiemHours: { value: number; type: string };\n minutes: number;\n month: number;\n seconds: number;\n timestamp: number;\n year: number;\n}\n\n/**\n * @name useTime\n * @description - Hook that gives you current time in different values\n * @category Time\n *\n * @returns {UseTimeReturn} An object containing the current time\n *\n * @example\n * const { seconds, minutes, hours, meridiemHours, day, month, year, timestamp } = useTime();\n */\nexport const useTime = (): UseTimeReturn => {\n const [time, setTime] = useState(getDate());\n useInterval(() => setTime(getDate()), 1000);\n return time;\n};\n"],"names":["useTime","_useState","useState","getDate","_useState2","_slicedToArray","time","setTime","useInterval"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useTime.js","sources":["../../../../src/hooks/useTime/useTime.ts"],"sourcesContent":["import { useState } from 'react';\n\nimport { getDate } from '@/utils/helpers';\n\nimport { useInterval } from '../useInterval/useInterval';\n\nexport interface UseTimeReturn {\n day: number;\n hours: number;\n meridiemHours: { value: number; type: string };\n minutes: number;\n month: number;\n seconds: number;\n timestamp: number;\n year: number;\n}\n\n/**\n * @name useTime\n * @description - Hook that gives you current time in different values\n * @category Time\n *\n * @returns {UseTimeReturn} An object containing the current time\n *\n * @example\n * const { seconds, minutes, hours, meridiemHours, day, month, year, timestamp } = useTime();\n */\nexport const useTime = (): UseTimeReturn => {\n const [time, setTime] = useState(getDate());\n useInterval(() => setTime(getDate()), 1000);\n return time;\n};\n"],"names":["useTime","_useState","useState","getDate","_useState2","_slicedToArray","time","setTime","useInterval"],"mappings":";0NA2BaA,EAAU,WACrB,IAAAC,EAAwBC,EAASC,KAAUC,EAAAC,EAAAJ,EAAA,GAApCK,EAAIF,EAAA,GAAEG,EAAOH,EAAA,GAEpB,OADAI,GAAY,WAAA,OAAMD,EAAQJ,IAAU,GAAE,KAC/BG,CACT"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as r}from"../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.94 */
|
|
2
|
+
import{_ as r}from"../../_rollupPluginBabelHelpers-Dp_7XWBJ.js";import{useState as e,useRef as t,useEffect as n}from"react";import{useEvent as u}from"../useEvent/useEvent.js";function o(o,c){var i=e(!1),m=r(i,2),a=m[0],f=m[1],l=t(),s=u(o);n((function(){return l.current=setTimeout((function(){s(),f(!0)}),c),function(){clearTimeout(l.current)}}),[c]);return{ready:a,clear:function(){clearTimeout(l.current),f(!0)}}}export{o as useTimeout};
|
|
3
3
|
//# sourceMappingURL=useTimeout.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{b as
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.94 */
|
|
2
|
+
import{b as n,_ as t,c as o}from"../../_rollupPluginBabelHelpers-Dp_7XWBJ.js";import{useState as l}from"react";import{useInterval as r}from"../useInterval/useInterval.js";var e=function(n){var t=Math.ceil(n),o=Math.floor(t/86400),l=Math.floor(t%86400/3600),r=Math.floor(t%3600/60);return{seconds:Math.floor(t%60),minutes:r,hours:l,days:o}},a=function(){var a,i=arguments.length<=0?void 0:arguments[0],u="object"===n(arguments.length<=1?void 0:arguments[1])?arguments.length<=1?void 0:arguments[1]:{onExpire:arguments.length<=1?void 0:arguments[1]},c=null===(a=null==u?void 0:u.autostart)||void 0===a||a,s=l(Math.ceil(i/1e3)),v=t(s,2),f=v[0],h=v[1],d=l(c),g=t(d,2),p=g[0],M=g[1];return r((function(){var n,t,o=f-1;(null==u||null===(n=u.onTick)||void 0===n||n.call(u,f),h(o),0===o)&&(M(!1),null==u||null===(t=u.onExpire)||void 0===t||t.call(u))}),1e3,{enabled:p}),o(o({},e(f)),{},{pause:function(){return M(!1)},toggle:function(){return M(!p)},start:function(){M(!0),h(Math.ceil(i/1e3))},restart:function(n){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];h(Math.ceil(n/1e3)),M(t)},running:p})};export{e as getTimeFromSeconds,a as useTimer};
|
|
3
3
|
//# sourceMappingURL=useTimer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTimer.js","sources":["../../../../src/hooks/useTimer/useTimer.ts"],"sourcesContent":["import { useState } from 'react';\n\nimport { useInterval } from '../useInterval/useInterval';\n\nexport const getTimeFromSeconds = (timestamp: number) => {\n const roundedTimestamp = Math.ceil(timestamp);\n const days = Math.floor(roundedTimestamp / (60 * 60 * 24));\n const hours = Math.floor((roundedTimestamp % (60 * 60 * 24)) / (60 * 60));\n const minutes = Math.floor((roundedTimestamp % (60 * 60)) / 60);\n const seconds = Math.floor(roundedTimestamp % 60);\n\n return {\n seconds,\n minutes,\n hours,\n days\n };\n};\n\n/** The use timer options type */\nexport interface UseTimerOptions {\n /** Whether the timer should start automatically */\n autostart?: boolean;\n /** The function to be executed when the timer is expired */\n onExpire?: () => void;\n /** Callback function to be executed on each tick of the timer */\n onTick?: (seconds: number) => void;\n}\n\n/** The use timer return type */\nexport interface UseTimerReturn {\n /** The day count of the timer */\n days: number;\n /** The hour count of the timer */\n hours: number;\n /** The minute count of the timer */\n minutes: number;\n /** flag to indicate if timer is running or not */\n running: boolean;\n /** The second count of the timer */\n seconds: number;\n /** The function to pause the timer */\n pause: () => void;\n /** The function to restart the timer */\n restart: (time: number, autostart?: boolean) => void;\n /** The function to start the timer */\n start: () => void;\n /** The function to toggle the timer */\n toggle: () => void;\n}\n\nexport interface UseTimer {\n (timestamp: number, callback: () => void): UseTimerReturn;\n (timestamp: number, options?: UseTimerOptions): UseTimerReturn;\n}\n\n/**\n * @name useTimer\n * @description - Hook that creates a timer functionality\n * @category Time\n *\n * @overload\n * @param {number} timestamp The timestamp value that define for how long the timer will be running\n * @param {() => void} callback The function to be executed once countdown timer is expired\n *\n * @example\n * const { days, hours, minutes, seconds, toggle, pause, start, restart, running } = useTimer(1000, () => console.log('ready'));\n *\n * @overload\n * @param {number} timestamp The timestamp value that define for how long the timer will be running\n * @param {boolean} options.autostart The flag to decide if timer should start automatically\n * @param {() => void} options.onExpire The function to be executed when the timer is expired\n * @param {(timestamp: number) => void} options.onTick The function to be executed on each tick of the timer\n *\n * @example\n * const { days, hours, minutes, seconds, toggle, pause, start, restart, running } = useTimer(1000);\n */\nexport const useTimer = ((...params: any[]) => {\n const timestamp = params[0];\n const options = (typeof params[1] === 'object' ? params[1] : { onExpire: params[1] }) as\n | UseTimerOptions\n | undefined;\n\n const autostart = options?.autostart ?? true;\n\n const [seconds, setSeconds] = useState(Math.ceil(timestamp / 1000));\n const [running, setRunning] = useState(autostart);\n\n const restart = (timestamp: number, autostart = true) => {\n setSeconds(Math.ceil(timestamp / 1000));\n setRunning(autostart);\n };\n\n const start = () => {\n setRunning(true);\n setSeconds(Math.ceil(timestamp / 1000));\n };\n\n useInterval(\n () => {\n const updatedSeconds = seconds - 1;\n options?.onTick?.(seconds);\n setSeconds(updatedSeconds);\n\n if (updatedSeconds === 0) {\n setRunning(false);\n options?.onExpire?.();\n }\n },\n 1000,\n { enabled: running }\n );\n\n return {\n ...getTimeFromSeconds(seconds),\n pause: () => setRunning(false),\n toggle: () => setRunning(!running),\n start,\n restart,\n running\n };\n}) as UseTimer;\n"],"names":["getTimeFromSeconds","timestamp","roundedTimestamp","Math","ceil","days","floor","hours","minutes","seconds","useTimer","_options$autostart","arguments","length","undefined","options","_typeof","onExpire","autostart","_useState","useState","_useState2","_slicedToArray","setSeconds","_useState3","_useState4","running","setRunning","useInterval","_options$onTick","_options$onExpire","updatedSeconds","onTick","call","enabled","_objectSpread","pause","toggle","start","restart"],"mappings":";+
|
|
1
|
+
{"version":3,"file":"useTimer.js","sources":["../../../../src/hooks/useTimer/useTimer.ts"],"sourcesContent":["import { useState } from 'react';\n\nimport { useInterval } from '../useInterval/useInterval';\n\nexport const getTimeFromSeconds = (timestamp: number) => {\n const roundedTimestamp = Math.ceil(timestamp);\n const days = Math.floor(roundedTimestamp / (60 * 60 * 24));\n const hours = Math.floor((roundedTimestamp % (60 * 60 * 24)) / (60 * 60));\n const minutes = Math.floor((roundedTimestamp % (60 * 60)) / 60);\n const seconds = Math.floor(roundedTimestamp % 60);\n\n return {\n seconds,\n minutes,\n hours,\n days\n };\n};\n\n/** The use timer options type */\nexport interface UseTimerOptions {\n /** Whether the timer should start automatically */\n autostart?: boolean;\n /** The function to be executed when the timer is expired */\n onExpire?: () => void;\n /** Callback function to be executed on each tick of the timer */\n onTick?: (seconds: number) => void;\n}\n\n/** The use timer return type */\nexport interface UseTimerReturn {\n /** The day count of the timer */\n days: number;\n /** The hour count of the timer */\n hours: number;\n /** The minute count of the timer */\n minutes: number;\n /** flag to indicate if timer is running or not */\n running: boolean;\n /** The second count of the timer */\n seconds: number;\n /** The function to pause the timer */\n pause: () => void;\n /** The function to restart the timer */\n restart: (time: number, autostart?: boolean) => void;\n /** The function to start the timer */\n start: () => void;\n /** The function to toggle the timer */\n toggle: () => void;\n}\n\nexport interface UseTimer {\n (timestamp: number, callback: () => void): UseTimerReturn;\n (timestamp: number, options?: UseTimerOptions): UseTimerReturn;\n}\n\n/**\n * @name useTimer\n * @description - Hook that creates a timer functionality\n * @category Time\n *\n * @overload\n * @param {number} timestamp The timestamp value that define for how long the timer will be running\n * @param {() => void} callback The function to be executed once countdown timer is expired\n *\n * @example\n * const { days, hours, minutes, seconds, toggle, pause, start, restart, running } = useTimer(1000, () => console.log('ready'));\n *\n * @overload\n * @param {number} timestamp The timestamp value that define for how long the timer will be running\n * @param {boolean} options.autostart The flag to decide if timer should start automatically\n * @param {() => void} options.onExpire The function to be executed when the timer is expired\n * @param {(timestamp: number) => void} options.onTick The function to be executed on each tick of the timer\n *\n * @example\n * const { days, hours, minutes, seconds, toggle, pause, start, restart, running } = useTimer(1000);\n */\nexport const useTimer = ((...params: any[]) => {\n const timestamp = params[0];\n const options = (typeof params[1] === 'object' ? params[1] : { onExpire: params[1] }) as\n | UseTimerOptions\n | undefined;\n\n const autostart = options?.autostart ?? true;\n\n const [seconds, setSeconds] = useState(Math.ceil(timestamp / 1000));\n const [running, setRunning] = useState(autostart);\n\n const restart = (timestamp: number, autostart = true) => {\n setSeconds(Math.ceil(timestamp / 1000));\n setRunning(autostart);\n };\n\n const start = () => {\n setRunning(true);\n setSeconds(Math.ceil(timestamp / 1000));\n };\n\n useInterval(\n () => {\n const updatedSeconds = seconds - 1;\n options?.onTick?.(seconds);\n setSeconds(updatedSeconds);\n\n if (updatedSeconds === 0) {\n setRunning(false);\n options?.onExpire?.();\n }\n },\n 1000,\n { enabled: running }\n );\n\n return {\n ...getTimeFromSeconds(seconds),\n pause: () => setRunning(false),\n toggle: () => setRunning(!running),\n start,\n restart,\n running\n };\n}) as UseTimer;\n"],"names":["getTimeFromSeconds","timestamp","roundedTimestamp","Math","ceil","days","floor","hours","minutes","seconds","useTimer","_options$autostart","arguments","length","undefined","options","_typeof","onExpire","autostart","_useState","useState","_useState2","_slicedToArray","setSeconds","_useState3","_useState4","running","setRunning","useInterval","_options$onTick","_options$onExpire","updatedSeconds","onTick","call","enabled","_objectSpread","pause","toggle","start","restart"],"mappings":";+KAIaA,EAAqB,SAACC,GACjC,IAAMC,EAAmBC,KAAKC,KAAKH,GAC7BI,EAAOF,KAAKG,MAAMJ,EAAgB,OAClCK,EAAQJ,KAAKG,MAAOJ,EAAoB,MAAa,MACrDM,EAAUL,KAAKG,MAAOJ,EAAgB,KAAgB,IAG5D,MAAO,CACLO,QAHcN,KAAKG,MAAMJ,EAAmB,IAI5CM,QAAAA,EACAD,MAAAA,EACAF,KAAAA,EAEJ,EA4DaK,EAAY,WAAsB,IAAAC,EACvCV,EAASW,UAAAC,QAAAC,OAAAA,EAAAF,UAAY,GACrBG,EAAgC,WAArBC,EAAAJ,UAAAC,eAAAC,EAAAF,UAAqB,IAAQA,UAAAC,QAAAC,OAAAA,EAAAF,UAAe,GAAA,CAAEK,SAAQL,UAAAC,QAAAC,OAAAA,EAAAF,UAAA,IAIjEM,EAA8BP,QAArBA,EAAGI,aAAO,EAAPA,EAASG,iBAASP,IAAAA,GAAAA,EAEpCQ,EAA8BC,EAASjB,KAAKC,KAAKH,EAAY,MAAMoB,EAAAC,EAAAH,EAAA,GAA5DV,EAAOY,EAAA,GAAEE,EAAUF,EAAA,GAC1BG,EAA8BJ,EAASF,GAAUO,EAAAH,EAAAE,EAAA,GAA1CE,EAAOD,EAAA,GAAEE,EAAUF,EAAA,GA2B1B,OAfAG,GACE,WAAM,IAAAC,EAKsBC,EAJpBC,EAAiBtB,EAAU,GACjCM,SAAe,QAARc,EAAPd,EAASiB,cAAM,IAAAH,GAAfA,EAAAI,KAAAlB,EAAkBN,GAClBc,EAAWQ,GAEY,IAAnBA,KACFJ,GAAW,GACXZ,SAAiBe,QAAVA,EAAPf,EAASE,oBAAQa,GAAjBA,EAAAG,KAAAlB,GAEH,GACD,IACA,CAAEmB,QAASR,IAGbS,EAAAA,KACKnC,EAAmBS,IAAQ,GAAA,CAC9B2B,MAAO,WAAF,OAAQT,GAAW,EAAM,EAC9BU,OAAQ,WAAF,OAAQV,GAAYD,EAAQ,EAClCY,MAxBY,WACZX,GAAW,GACXJ,EAAWpB,KAAKC,KAAKH,EAAY,KAClC,EAsBCsC,QA9Bc,SAACtC,GAAwC,IAArBiB,IAASN,UAAAC,OAAA,QAAAC,IAAAF,UAAA,KAAAA,UAAA,GAC3CW,EAAWpB,KAAKC,KAAKH,EAAY,MACjC0B,EAAWT,EACZ,EA4BCQ,QAAAA,GAEJ"}
|