@siberiacancode/reactuse 0.3.15 → 0.3.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/_virtual/_rolldown/runtime.cjs +1 -0
- package/dist/cjs/helpers/createContext/createContext.cjs +2 -2
- package/dist/cjs/helpers/createContext/createContext.cjs.map +1 -1
- package/dist/cjs/helpers/createContextHook/createContextHook.cjs +2 -2
- package/dist/cjs/helpers/createContextHook/createContextHook.cjs.map +1 -1
- package/dist/cjs/helpers/createEventEmitter/createEventEmitter.cjs +2 -2
- package/dist/cjs/helpers/createEventEmitter/createEventEmitter.cjs.map +1 -1
- package/dist/cjs/helpers/createReactiveContext/createReactiveContext.cjs +2 -2
- package/dist/cjs/helpers/createReactiveContext/createReactiveContext.cjs.map +1 -1
- package/dist/cjs/helpers/createSharedHook/createSharedHook.cjs +2 -2
- package/dist/cjs/helpers/createSharedHook/createSharedHook.cjs.map +1 -1
- package/dist/cjs/helpers/createStore/createStore.cjs +2 -2
- package/dist/cjs/helpers/createStore/createStore.cjs.map +1 -1
- package/dist/cjs/helpers/makeDestructurable/makeDestructurable.cjs +2 -0
- package/dist/cjs/helpers/makeDestructurable/makeDestructurable.cjs.map +1 -0
- package/dist/cjs/hooks/useActiveElement/useActiveElement.cjs +2 -2
- package/dist/cjs/hooks/useActiveElement/useActiveElement.cjs.map +1 -1
- package/dist/cjs/hooks/useAsync/useAsync.cjs +2 -2
- package/dist/cjs/hooks/useAsync/useAsync.cjs.map +1 -1
- package/dist/cjs/hooks/useAsyncEffect/useAsyncEffect.cjs +2 -2
- package/dist/cjs/hooks/useAsyncEffect/useAsyncEffect.cjs.map +1 -1
- package/dist/cjs/hooks/useAudio/useAudio.cjs +2 -2
- package/dist/cjs/hooks/useAudio/useAudio.cjs.map +1 -1
- package/dist/cjs/hooks/useAutoScroll/useAutoScroll.cjs +2 -2
- package/dist/cjs/hooks/useAutoScroll/useAutoScroll.cjs.map +1 -1
- package/dist/cjs/hooks/useBatchedCallback/useBatchedCallback.cjs +2 -2
- package/dist/cjs/hooks/useBatchedCallback/useBatchedCallback.cjs.map +1 -1
- package/dist/cjs/hooks/useBattery/useBattery.cjs +2 -2
- package/dist/cjs/hooks/useBattery/useBattery.cjs.map +1 -1
- package/dist/cjs/hooks/useBluetooth/useBluetooth.cjs +2 -2
- package/dist/cjs/hooks/useBluetooth/useBluetooth.cjs.map +1 -1
- package/dist/cjs/hooks/useBoolean/useBoolean.cjs +2 -2
- package/dist/cjs/hooks/useBoolean/useBoolean.cjs.map +1 -1
- package/dist/cjs/hooks/useBreakpoints/useBreakpoints.cjs +2 -2
- package/dist/cjs/hooks/useBreakpoints/useBreakpoints.cjs.map +1 -1
- package/dist/cjs/hooks/useBroadcastChannel/useBroadcastChannel.cjs +2 -2
- package/dist/cjs/hooks/useBroadcastChannel/useBroadcastChannel.cjs.map +1 -1
- package/dist/cjs/hooks/useBrowserLanguage/useBrowserLanguage.cjs +2 -2
- package/dist/cjs/hooks/useBrowserLanguage/useBrowserLanguage.cjs.map +1 -1
- package/dist/cjs/hooks/useClickOutside/useClickOutside.cjs +2 -2
- package/dist/cjs/hooks/useClickOutside/useClickOutside.cjs.map +1 -1
- package/dist/cjs/hooks/useClipboard/useClipboard.cjs +2 -2
- package/dist/cjs/hooks/useClipboard/useClipboard.cjs.map +1 -1
- package/dist/cjs/hooks/useConst/useConst.cjs +2 -2
- package/dist/cjs/hooks/useConst/useConst.cjs.map +1 -1
- package/dist/cjs/hooks/useControllableState/useControllableState.cjs +2 -2
- package/dist/cjs/hooks/useControllableState/useControllableState.cjs.map +1 -1
- package/dist/cjs/hooks/useCookie/useCookie.cjs +2 -2
- package/dist/cjs/hooks/useCookie/useCookie.cjs.map +1 -1
- package/dist/cjs/hooks/useCookies/useCookies.cjs +2 -2
- package/dist/cjs/hooks/useCookies/useCookies.cjs.map +1 -1
- package/dist/cjs/hooks/useCopy/useCopy.cjs +2 -2
- package/dist/cjs/hooks/useCopy/useCopy.cjs.map +1 -1
- package/dist/cjs/hooks/useCounter/useCounter.cjs +2 -2
- package/dist/cjs/hooks/useCounter/useCounter.cjs.map +1 -1
- package/dist/cjs/hooks/useCssVar/useCssVar.cjs +2 -2
- package/dist/cjs/hooks/useCssVar/useCssVar.cjs.map +1 -1
- package/dist/cjs/hooks/useDebounceCallback/useDebounceCallback.cjs +2 -2
- package/dist/cjs/hooks/useDebounceCallback/useDebounceCallback.cjs.map +1 -1
- package/dist/cjs/hooks/useDebounceEffect/useDebounceEffect.cjs +2 -2
- package/dist/cjs/hooks/useDebounceEffect/useDebounceEffect.cjs.map +1 -1
- package/dist/cjs/hooks/useDebounceState/useDebounceState.cjs +2 -2
- package/dist/cjs/hooks/useDebounceState/useDebounceState.cjs.map +1 -1
- package/dist/cjs/hooks/useDebounceValue/useDebounceValue.cjs +2 -2
- package/dist/cjs/hooks/useDebounceValue/useDebounceValue.cjs.map +1 -1
- package/dist/cjs/hooks/useDefault/useDefault.cjs +2 -2
- package/dist/cjs/hooks/useDefault/useDefault.cjs.map +1 -1
- package/dist/cjs/hooks/useDeviceMotion/useDeviceMotion.cjs +2 -2
- package/dist/cjs/hooks/useDeviceMotion/useDeviceMotion.cjs.map +1 -1
- package/dist/cjs/hooks/useDeviceOrientation/useDeviceOrientation.cjs +2 -2
- package/dist/cjs/hooks/useDeviceOrientation/useDeviceOrientation.cjs.map +1 -1
- package/dist/cjs/hooks/useDevicePixelRatio/useDevicePixelRatio.cjs +2 -2
- package/dist/cjs/hooks/useDevicePixelRatio/useDevicePixelRatio.cjs.map +1 -1
- package/dist/cjs/hooks/useDidUpdate/useDidUpdate.cjs +2 -2
- package/dist/cjs/hooks/useDidUpdate/useDidUpdate.cjs.map +1 -1
- package/dist/cjs/hooks/useDisclosure/useDisclosure.cjs +2 -2
- package/dist/cjs/hooks/useDisclosure/useDisclosure.cjs.map +1 -1
- package/dist/cjs/hooks/useDisplayMedia/useDisplayMedia.cjs +2 -2
- package/dist/cjs/hooks/useDisplayMedia/useDisplayMedia.cjs.map +1 -1
- package/dist/cjs/hooks/useDocumentEvent/useDocumentEvent.cjs +2 -2
- package/dist/cjs/hooks/useDocumentEvent/useDocumentEvent.cjs.map +1 -1
- package/dist/cjs/hooks/useDocumentTitle/useDocumentTitle.cjs +2 -2
- package/dist/cjs/hooks/useDocumentTitle/useDocumentTitle.cjs.map +1 -1
- package/dist/cjs/hooks/useDocumentVisibility/useDocumentVisibility.cjs +2 -2
- package/dist/cjs/hooks/useDocumentVisibility/useDocumentVisibility.cjs.map +1 -1
- package/dist/cjs/hooks/useDoubleClick/useDoubleClick.cjs +2 -2
- package/dist/cjs/hooks/useDoubleClick/useDoubleClick.cjs.map +1 -1
- package/dist/cjs/hooks/useDropZone/useDropZone.cjs +2 -2
- package/dist/cjs/hooks/useDropZone/useDropZone.cjs.map +1 -1
- package/dist/cjs/hooks/useEvent/useEvent.cjs +2 -2
- package/dist/cjs/hooks/useEvent/useEvent.cjs.map +1 -1
- package/dist/cjs/hooks/useEventListener/useEventListener.cjs +2 -2
- package/dist/cjs/hooks/useEventListener/useEventListener.cjs.map +1 -1
- package/dist/cjs/hooks/useEventSource/useEventSource.cjs +2 -2
- package/dist/cjs/hooks/useEventSource/useEventSource.cjs.map +1 -1
- package/dist/cjs/hooks/useEyeDropper/useEyeDropper.cjs +2 -2
- package/dist/cjs/hooks/useEyeDropper/useEyeDropper.cjs.map +1 -1
- package/dist/cjs/hooks/useFavicon/useFavicon.cjs +2 -2
- package/dist/cjs/hooks/useFavicon/useFavicon.cjs.map +1 -1
- package/dist/cjs/hooks/useField/useField.cjs +2 -2
- package/dist/cjs/hooks/useField/useField.cjs.map +1 -1
- package/dist/cjs/hooks/useFileDialog/useFileDialog.cjs +2 -2
- package/dist/cjs/hooks/useFileDialog/useFileDialog.cjs.map +1 -1
- package/dist/cjs/hooks/useFileSystemAccess/useFileSystemAccess.cjs +2 -0
- package/dist/cjs/hooks/useFileSystemAccess/useFileSystemAccess.cjs.map +1 -0
- package/dist/cjs/hooks/useFocus/useFocus.cjs +2 -2
- package/dist/cjs/hooks/useFocus/useFocus.cjs.map +1 -1
- package/dist/cjs/hooks/useFocusTrap/useFocusTrap.cjs +2 -2
- package/dist/cjs/hooks/useFocusTrap/useFocusTrap.cjs.map +1 -1
- package/dist/cjs/hooks/useFps/useFps.cjs +2 -2
- package/dist/cjs/hooks/useFps/useFps.cjs.map +1 -1
- package/dist/cjs/hooks/useFul/useFul.cjs +2 -2
- package/dist/cjs/hooks/useFul/useFul.cjs.map +1 -1
- package/dist/cjs/hooks/useFullscreen/useFullscreen.cjs +2 -2
- package/dist/cjs/hooks/useFullscreen/useFullscreen.cjs.map +1 -1
- package/dist/cjs/hooks/useGamepad/useGamepad.cjs +2 -2
- package/dist/cjs/hooks/useGamepad/useGamepad.cjs.map +1 -1
- package/dist/cjs/hooks/useGeolocation/useGeolocation.cjs +2 -2
- package/dist/cjs/hooks/useGeolocation/useGeolocation.cjs.map +1 -1
- package/dist/cjs/hooks/useHash/useHash.cjs +2 -2
- package/dist/cjs/hooks/useHash/useHash.cjs.map +1 -1
- package/dist/cjs/hooks/useHotkeys/useHotkeys.cjs +2 -2
- package/dist/cjs/hooks/useHotkeys/useHotkeys.cjs.map +1 -1
- package/dist/cjs/hooks/useHover/useHover.cjs +2 -2
- package/dist/cjs/hooks/useHover/useHover.cjs.map +1 -1
- package/dist/cjs/hooks/useIdle/useIdle.cjs +2 -2
- package/dist/cjs/hooks/useIdle/useIdle.cjs.map +1 -1
- package/dist/cjs/hooks/useImage/useImage.cjs +2 -2
- package/dist/cjs/hooks/useImage/useImage.cjs.map +1 -1
- package/dist/cjs/hooks/useInfiniteScroll/useInfiniteScroll.cjs +2 -2
- package/dist/cjs/hooks/useInfiniteScroll/useInfiniteScroll.cjs.map +1 -1
- package/dist/cjs/hooks/useIntersectionObserver/useIntersectionObserver.cjs +2 -2
- package/dist/cjs/hooks/useIntersectionObserver/useIntersectionObserver.cjs.map +1 -1
- package/dist/cjs/hooks/useInterval/useInterval.cjs +2 -2
- package/dist/cjs/hooks/useInterval/useInterval.cjs.map +1 -1
- package/dist/cjs/hooks/useIsFirstRender/useIsFirstRender.cjs +2 -2
- package/dist/cjs/hooks/useIsFirstRender/useIsFirstRender.cjs.map +1 -1
- package/dist/cjs/hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.cjs +2 -2
- package/dist/cjs/hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.cjs.map +1 -1
- package/dist/cjs/hooks/useKeyPress/useKeyPress.cjs +2 -2
- package/dist/cjs/hooks/useKeyPress/useKeyPress.cjs.map +1 -1
- package/dist/cjs/hooks/useKeyPressEvent/useKeyPressEvent.cjs +2 -2
- package/dist/cjs/hooks/useKeyPressEvent/useKeyPressEvent.cjs.map +1 -1
- package/dist/cjs/hooks/useKeyboard/useKeyboard.cjs +2 -2
- package/dist/cjs/hooks/useKeyboard/useKeyboard.cjs.map +1 -1
- package/dist/cjs/hooks/useKeysPressed/useKeysPressed.cjs +2 -2
- package/dist/cjs/hooks/useKeysPressed/useKeysPressed.cjs.map +1 -1
- package/dist/cjs/hooks/useLastChanged/useLastChanged.cjs +2 -2
- package/dist/cjs/hooks/useLastChanged/useLastChanged.cjs.map +1 -1
- package/dist/cjs/hooks/useLatest/useLatest.cjs +2 -2
- package/dist/cjs/hooks/useLatest/useLatest.cjs.map +1 -1
- package/dist/cjs/hooks/useLess/useLess.cjs +2 -2
- package/dist/cjs/hooks/useLess/useLess.cjs.map +1 -1
- package/dist/cjs/hooks/useList/useList.cjs +2 -2
- package/dist/cjs/hooks/useList/useList.cjs.map +1 -1
- package/dist/cjs/hooks/useLocalStorage/useLocalStorage.cjs +2 -2
- package/dist/cjs/hooks/useLocalStorage/useLocalStorage.cjs.map +1 -1
- package/dist/cjs/hooks/useLockCallback/useLockCallback.cjs +2 -2
- package/dist/cjs/hooks/useLockCallback/useLockCallback.cjs.map +1 -1
- package/dist/cjs/hooks/useLockScroll/useLockScroll.cjs +2 -2
- package/dist/cjs/hooks/useLockScroll/useLockScroll.cjs.map +1 -1
- package/dist/cjs/hooks/useLogger/useLogger.cjs +2 -2
- package/dist/cjs/hooks/useLogger/useLogger.cjs.map +1 -1
- package/dist/cjs/hooks/useLongPress/useLongPress.cjs +2 -2
- package/dist/cjs/hooks/useLongPress/useLongPress.cjs.map +1 -1
- package/dist/cjs/hooks/useMap/useMap.cjs +2 -2
- package/dist/cjs/hooks/useMap/useMap.cjs.map +1 -1
- package/dist/cjs/hooks/useMeasure/useMeasure.cjs +2 -2
- package/dist/cjs/hooks/useMeasure/useMeasure.cjs.map +1 -1
- package/dist/cjs/hooks/useMediaControls/useMediaControls.cjs +2 -2
- package/dist/cjs/hooks/useMediaControls/useMediaControls.cjs.map +1 -1
- package/dist/cjs/hooks/useMediaQuery/useMediaQuery.cjs +2 -2
- package/dist/cjs/hooks/useMediaQuery/useMediaQuery.cjs.map +1 -1
- package/dist/cjs/hooks/useMemory/useMemory.cjs +2 -2
- package/dist/cjs/hooks/useMemory/useMemory.cjs.map +1 -1
- package/dist/cjs/hooks/useMergedRef/useMergedRef.cjs +2 -2
- package/dist/cjs/hooks/useMergedRef/useMergedRef.cjs.map +1 -1
- package/dist/cjs/hooks/useMount/useMount.cjs +2 -2
- package/dist/cjs/hooks/useMount/useMount.cjs.map +1 -1
- package/dist/cjs/hooks/useMouse/useMouse.cjs +2 -2
- package/dist/cjs/hooks/useMouse/useMouse.cjs.map +1 -1
- package/dist/cjs/hooks/useMutation/useMutation.cjs +2 -2
- package/dist/cjs/hooks/useMutation/useMutation.cjs.map +1 -1
- package/dist/cjs/hooks/useMutationObserver/useMutationObserver.cjs +2 -2
- package/dist/cjs/hooks/useMutationObserver/useMutationObserver.cjs.map +1 -1
- package/dist/cjs/hooks/useNetwork/useNetwork.cjs +2 -2
- package/dist/cjs/hooks/useNetwork/useNetwork.cjs.map +1 -1
- package/dist/cjs/hooks/useObjectUrl/useObjectUrl.cjs +2 -0
- package/dist/cjs/hooks/useObjectUrl/useObjectUrl.cjs.map +1 -0
- package/dist/cjs/hooks/useOffsetPagination/useOffsetPagination.cjs +2 -2
- package/dist/cjs/hooks/useOffsetPagination/useOffsetPagination.cjs.map +1 -1
- package/dist/cjs/hooks/useOnce/useOnce.cjs +2 -2
- package/dist/cjs/hooks/useOnce/useOnce.cjs.map +1 -1
- package/dist/cjs/hooks/useOnline/useOnline.cjs +2 -2
- package/dist/cjs/hooks/useOnline/useOnline.cjs.map +1 -1
- package/dist/cjs/hooks/useOperatingSystem/useOperatingSystem.cjs +2 -2
- package/dist/cjs/hooks/useOperatingSystem/useOperatingSystem.cjs.map +1 -1
- package/dist/cjs/hooks/useOptimistic/useOptimistic.cjs +2 -2
- package/dist/cjs/hooks/useOptimistic/useOptimistic.cjs.map +1 -1
- package/dist/cjs/hooks/useOrientation/useOrientation.cjs +2 -2
- package/dist/cjs/hooks/useOrientation/useOrientation.cjs.map +1 -1
- package/dist/cjs/hooks/useOtpCredential/useOtpCredential.cjs +2 -2
- package/dist/cjs/hooks/useOtpCredential/useOtpCredential.cjs.map +1 -1
- package/dist/cjs/hooks/usePageLeave/usePageLeave.cjs +2 -2
- package/dist/cjs/hooks/usePageLeave/usePageLeave.cjs.map +1 -1
- package/dist/cjs/hooks/usePaint/usePaint.cjs +2 -2
- package/dist/cjs/hooks/usePaint/usePaint.cjs.map +1 -1
- package/dist/cjs/hooks/useParallax/useParallax.cjs +2 -2
- package/dist/cjs/hooks/useParallax/useParallax.cjs.map +1 -1
- package/dist/cjs/hooks/usePerformanceObserver/usePerformanceObserver.cjs +2 -2
- package/dist/cjs/hooks/usePerformanceObserver/usePerformanceObserver.cjs.map +1 -1
- package/dist/cjs/hooks/usePermission/usePermission.cjs +2 -2
- package/dist/cjs/hooks/usePermission/usePermission.cjs.map +1 -1
- package/dist/cjs/hooks/usePictureInPicture/usePictureInPicture.cjs +2 -2
- package/dist/cjs/hooks/usePictureInPicture/usePictureInPicture.cjs.map +1 -1
- package/dist/cjs/hooks/usePointerLock/usePointerLock.cjs +2 -2
- package/dist/cjs/hooks/usePointerLock/usePointerLock.cjs.map +1 -1
- package/dist/cjs/hooks/usePostMessage/usePostMessage.cjs +2 -2
- package/dist/cjs/hooks/usePostMessage/usePostMessage.cjs.map +1 -1
- package/dist/cjs/hooks/usePreferredColorScheme/usePreferredColorScheme.cjs +2 -2
- package/dist/cjs/hooks/usePreferredColorScheme/usePreferredColorScheme.cjs.map +1 -1
- package/dist/cjs/hooks/usePreferredContrast/usePreferredContrast.cjs +2 -2
- package/dist/cjs/hooks/usePreferredContrast/usePreferredContrast.cjs.map +1 -1
- package/dist/cjs/hooks/usePreferredDark/usePreferredDark.cjs +2 -2
- package/dist/cjs/hooks/usePreferredDark/usePreferredDark.cjs.map +1 -1
- package/dist/cjs/hooks/usePreferredLanguages/usePreferredLanguages.cjs +2 -2
- package/dist/cjs/hooks/usePreferredLanguages/usePreferredLanguages.cjs.map +1 -1
- package/dist/cjs/hooks/usePreferredReducedMotion/usePreferredReducedMotion.cjs +2 -2
- package/dist/cjs/hooks/usePreferredReducedMotion/usePreferredReducedMotion.cjs.map +1 -1
- package/dist/cjs/hooks/usePrevious/usePrevious.cjs +2 -2
- package/dist/cjs/hooks/usePrevious/usePrevious.cjs.map +1 -1
- package/dist/cjs/hooks/useProgress/useProgress.cjs +2 -2
- package/dist/cjs/hooks/useProgress/useProgress.cjs.map +1 -1
- package/dist/cjs/hooks/useQuery/useQuery.cjs +2 -2
- package/dist/cjs/hooks/useQuery/useQuery.cjs.map +1 -1
- package/dist/cjs/hooks/useQueue/useQueue.cjs +2 -2
- package/dist/cjs/hooks/useQueue/useQueue.cjs.map +1 -1
- package/dist/cjs/hooks/useRaf/useRaf.cjs +2 -2
- package/dist/cjs/hooks/useRaf/useRaf.cjs.map +1 -1
- package/dist/cjs/hooks/useRafState/useRafState.cjs +2 -2
- package/dist/cjs/hooks/useRafState/useRafState.cjs.map +1 -1
- package/dist/cjs/hooks/useRefState/useRefState.cjs +2 -2
- package/dist/cjs/hooks/useRefState/useRefState.cjs.map +1 -1
- package/dist/cjs/hooks/useRenderCount/useRenderCount.cjs +2 -2
- package/dist/cjs/hooks/useRenderCount/useRenderCount.cjs.map +1 -1
- package/dist/cjs/hooks/useRenderInfo/useRenderInfo.cjs +2 -2
- package/dist/cjs/hooks/useRenderInfo/useRenderInfo.cjs.map +1 -1
- package/dist/cjs/hooks/useRerender/useRerender.cjs +2 -2
- package/dist/cjs/hooks/useRerender/useRerender.cjs.map +1 -1
- package/dist/cjs/hooks/useResizeObserver/useResizeObserver.cjs +2 -2
- package/dist/cjs/hooks/useResizeObserver/useResizeObserver.cjs.map +1 -1
- package/dist/cjs/hooks/useRightClick/useRightClick.cjs +2 -2
- package/dist/cjs/hooks/useRightClick/useRightClick.cjs.map +1 -1
- package/dist/cjs/hooks/useScript/useScript.cjs +2 -2
- package/dist/cjs/hooks/useScript/useScript.cjs.map +1 -1
- package/dist/cjs/hooks/useScroll/useScroll.cjs +2 -2
- package/dist/cjs/hooks/useScroll/useScroll.cjs.map +1 -1
- package/dist/cjs/hooks/useScrollIntoView/useScrollIntoView.cjs +2 -2
- package/dist/cjs/hooks/useScrollIntoView/useScrollIntoView.cjs.map +1 -1
- package/dist/cjs/hooks/useScrollTo/useScrollTo.cjs +2 -2
- package/dist/cjs/hooks/useScrollTo/useScrollTo.cjs.map +1 -1
- package/dist/cjs/hooks/useSessionStorage/useSessionStorage.cjs +2 -2
- package/dist/cjs/hooks/useSessionStorage/useSessionStorage.cjs.map +1 -1
- package/dist/cjs/hooks/useSet/useSet.cjs +2 -2
- package/dist/cjs/hooks/useSet/useSet.cjs.map +1 -1
- package/dist/cjs/hooks/useShallowEffect/useShallowEffect.cjs +2 -2
- package/dist/cjs/hooks/useShallowEffect/useShallowEffect.cjs.map +1 -1
- package/dist/cjs/hooks/useShare/useShare.cjs +2 -2
- package/dist/cjs/hooks/useShare/useShare.cjs.map +1 -1
- package/dist/cjs/hooks/useSize/useSize.cjs +2 -2
- package/dist/cjs/hooks/useSize/useSize.cjs.map +1 -1
- package/dist/cjs/hooks/useSpeechRecognition/useSpeechRecognition.cjs +2 -2
- package/dist/cjs/hooks/useSpeechRecognition/useSpeechRecognition.cjs.map +1 -1
- package/dist/cjs/hooks/useSpeechSynthesis/useSpeechSynthesis.cjs +2 -2
- package/dist/cjs/hooks/useSpeechSynthesis/useSpeechSynthesis.cjs.map +1 -1
- package/dist/cjs/hooks/useStateHistory/useStateHistory.cjs +2 -2
- package/dist/cjs/hooks/useStateHistory/useStateHistory.cjs.map +1 -1
- package/dist/cjs/hooks/useStep/useStep.cjs +2 -2
- package/dist/cjs/hooks/useStep/useStep.cjs.map +1 -1
- package/dist/cjs/hooks/useSticky/useSticky.cjs +2 -2
- package/dist/cjs/hooks/useSticky/useSticky.cjs.map +1 -1
- package/dist/cjs/hooks/useStopwatch/useStopwatch.cjs +2 -2
- package/dist/cjs/hooks/useStopwatch/useStopwatch.cjs.map +1 -1
- package/dist/cjs/hooks/useStorage/useStorage.cjs +2 -2
- package/dist/cjs/hooks/useStorage/useStorage.cjs.map +1 -1
- package/dist/cjs/hooks/useTextDirection/useTextDirection.cjs +2 -2
- package/dist/cjs/hooks/useTextDirection/useTextDirection.cjs.map +1 -1
- package/dist/cjs/hooks/useTextSelection/useTextSelection.cjs +2 -2
- package/dist/cjs/hooks/useTextSelection/useTextSelection.cjs.map +1 -1
- package/dist/cjs/hooks/useTextareaAutosize/useTextareaAutosize.cjs +2 -2
- package/dist/cjs/hooks/useTextareaAutosize/useTextareaAutosize.cjs.map +1 -1
- package/dist/cjs/hooks/useThrottleCallback/useThrottleCallback.cjs +2 -2
- package/dist/cjs/hooks/useThrottleCallback/useThrottleCallback.cjs.map +1 -1
- package/dist/cjs/hooks/useThrottleEffect/useThrottleEffect.cjs +2 -2
- package/dist/cjs/hooks/useThrottleEffect/useThrottleEffect.cjs.map +1 -1
- package/dist/cjs/hooks/useThrottleState/useThrottleState.cjs +2 -2
- package/dist/cjs/hooks/useThrottleState/useThrottleState.cjs.map +1 -1
- package/dist/cjs/hooks/useThrottleValue/useThrottleValue.cjs +2 -2
- package/dist/cjs/hooks/useThrottleValue/useThrottleValue.cjs.map +1 -1
- package/dist/cjs/hooks/useTime/useTime.cjs +2 -2
- package/dist/cjs/hooks/useTime/useTime.cjs.map +1 -1
- package/dist/cjs/hooks/useTimeout/useTimeout.cjs +2 -2
- package/dist/cjs/hooks/useTimeout/useTimeout.cjs.map +1 -1
- package/dist/cjs/hooks/useTimer/useTimer.cjs +2 -2
- package/dist/cjs/hooks/useTimer/useTimer.cjs.map +1 -1
- package/dist/cjs/hooks/useToggle/useToggle.cjs +2 -2
- package/dist/cjs/hooks/useToggle/useToggle.cjs.map +1 -1
- package/dist/cjs/hooks/useUnmount/useUnmount.cjs +2 -2
- package/dist/cjs/hooks/useUnmount/useUnmount.cjs.map +1 -1
- package/dist/cjs/hooks/useUrlSearchParam/useUrlSearchParam.cjs +2 -2
- package/dist/cjs/hooks/useUrlSearchParam/useUrlSearchParam.cjs.map +1 -1
- package/dist/cjs/hooks/useUrlSearchParams/useUrlSearchParams.cjs +2 -2
- package/dist/cjs/hooks/useUrlSearchParams/useUrlSearchParams.cjs.map +1 -1
- package/dist/cjs/hooks/useVibrate/useVibrate.cjs +2 -2
- package/dist/cjs/hooks/useVibrate/useVibrate.cjs.map +1 -1
- package/dist/cjs/hooks/useVirtualKeyboard/useVirtualKeyboard.cjs +2 -2
- package/dist/cjs/hooks/useVirtualKeyboard/useVirtualKeyboard.cjs.map +1 -1
- package/dist/cjs/hooks/useVisibility/useVisibility.cjs +2 -2
- package/dist/cjs/hooks/useVisibility/useVisibility.cjs.map +1 -1
- package/dist/cjs/hooks/useWakeLock/useWakeLock.cjs +2 -2
- package/dist/cjs/hooks/useWakeLock/useWakeLock.cjs.map +1 -1
- package/dist/cjs/hooks/useWebSocket/useWebSocket.cjs +2 -2
- package/dist/cjs/hooks/useWebSocket/useWebSocket.cjs.map +1 -1
- package/dist/cjs/hooks/useWindowEvent/useWindowEvent.cjs +2 -2
- package/dist/cjs/hooks/useWindowEvent/useWindowEvent.cjs.map +1 -1
- package/dist/cjs/hooks/useWindowFocus/useWindowFocus.cjs +2 -2
- package/dist/cjs/hooks/useWindowFocus/useWindowFocus.cjs.map +1 -1
- package/dist/cjs/hooks/useWindowScroll/useWindowScroll.cjs +2 -2
- package/dist/cjs/hooks/useWindowScroll/useWindowScroll.cjs.map +1 -1
- package/dist/cjs/hooks/useWindowSize/useWindowSize.cjs +2 -2
- package/dist/cjs/hooks/useWindowSize/useWindowSize.cjs.map +1 -1
- package/dist/cjs/hooks/useWizard/useWizard.cjs +2 -2
- package/dist/cjs/hooks/useWizard/useWizard.cjs.map +1 -1
- package/dist/cjs/index.cjs +1 -2
- package/dist/cjs/utils/helpers/copy.cjs +2 -2
- package/dist/cjs/utils/helpers/copy.cjs.map +1 -1
- package/dist/cjs/utils/helpers/debounce.cjs +2 -2
- package/dist/cjs/utils/helpers/debounce.cjs.map +1 -1
- package/dist/cjs/utils/helpers/getDate.cjs +2 -2
- package/dist/cjs/utils/helpers/getDate.cjs.map +1 -1
- package/dist/cjs/utils/helpers/getRetry.cjs +2 -2
- package/dist/cjs/utils/helpers/getRetry.cjs.map +1 -1
- package/dist/cjs/utils/helpers/isTarget.cjs +2 -2
- package/dist/cjs/utils/helpers/isTarget.cjs.map +1 -1
- package/dist/cjs/utils/helpers/throttle.cjs +2 -2
- package/dist/cjs/utils/helpers/throttle.cjs.map +1 -1
- package/dist/esm/helpers/createContext/createContext.mjs +32 -33
- package/dist/esm/helpers/createContext/createContext.mjs.map +1 -1
- package/dist/esm/helpers/createContextHook/createContextHook.mjs +19 -12
- package/dist/esm/helpers/createContextHook/createContextHook.mjs.map +1 -1
- package/dist/esm/helpers/createEventEmitter/createEventEmitter.mjs +34 -33
- package/dist/esm/helpers/createEventEmitter/createEventEmitter.mjs.map +1 -1
- package/dist/esm/helpers/createReactiveContext/createReactiveContext.mjs +53 -53
- package/dist/esm/helpers/createReactiveContext/createReactiveContext.mjs.map +1 -1
- package/dist/esm/helpers/createSharedHook/createSharedHook.mjs +36 -41
- package/dist/esm/helpers/createSharedHook/createSharedHook.mjs.map +1 -1
- package/dist/esm/helpers/createStore/createStore.mjs +25 -29
- package/dist/esm/helpers/createStore/createStore.mjs.map +1 -1
- package/dist/esm/helpers/makeDestructurable/makeDestructurable.mjs +21 -0
- package/dist/esm/helpers/makeDestructurable/makeDestructurable.mjs.map +1 -0
- package/dist/esm/hooks/useActiveElement/useActiveElement.mjs +28 -27
- package/dist/esm/hooks/useActiveElement/useActiveElement.mjs.map +1 -1
- package/dist/esm/hooks/useAsync/useAsync.mjs +22 -21
- package/dist/esm/hooks/useAsync/useAsync.mjs.map +1 -1
- package/dist/esm/hooks/useAsyncEffect/useAsyncEffect.mjs +10 -9
- package/dist/esm/hooks/useAsyncEffect/useAsyncEffect.mjs.map +1 -1
- package/dist/esm/hooks/useAudio/useAudio.mjs +55 -55
- package/dist/esm/hooks/useAudio/useAudio.mjs.map +1 -1
- package/dist/esm/hooks/useAutoScroll/useAutoScroll.mjs +43 -40
- package/dist/esm/hooks/useAutoScroll/useAutoScroll.mjs.map +1 -1
- package/dist/esm/hooks/useBatchedCallback/useBatchedCallback.mjs +20 -19
- package/dist/esm/hooks/useBatchedCallback/useBatchedCallback.mjs.map +1 -1
- package/dist/esm/hooks/useBattery/useBattery.mjs +32 -29
- package/dist/esm/hooks/useBattery/useBattery.mjs.map +1 -1
- package/dist/esm/hooks/useBluetooth/useBluetooth.mjs +35 -33
- package/dist/esm/hooks/useBluetooth/useBluetooth.mjs.map +1 -1
- package/dist/esm/hooks/useBoolean/useBoolean.mjs +9 -8
- package/dist/esm/hooks/useBoolean/useBoolean.mjs.map +1 -1
- package/dist/esm/hooks/useBreakpoints/useBreakpoints.mjs +90 -104
- package/dist/esm/hooks/useBreakpoints/useBreakpoints.mjs.map +1 -1
- package/dist/esm/hooks/useBroadcastChannel/useBroadcastChannel.mjs +30 -31
- package/dist/esm/hooks/useBroadcastChannel/useBroadcastChannel.mjs.map +1 -1
- package/dist/esm/hooks/useBrowserLanguage/useBrowserLanguage.mjs +7 -6
- package/dist/esm/hooks/useBrowserLanguage/useBrowserLanguage.mjs.map +1 -1
- package/dist/esm/hooks/useClickOutside/useClickOutside.mjs +21 -21
- package/dist/esm/hooks/useClickOutside/useClickOutside.mjs.map +1 -1
- package/dist/esm/hooks/useClipboard/useClipboard.mjs +25 -23
- package/dist/esm/hooks/useClipboard/useClipboard.mjs.map +1 -1
- package/dist/esm/hooks/useConst/useConst.mjs +7 -6
- package/dist/esm/hooks/useConst/useConst.mjs.map +1 -1
- package/dist/esm/hooks/useControllableState/useControllableState.mjs +18 -16
- package/dist/esm/hooks/useControllableState/useControllableState.mjs.map +1 -1
- package/dist/esm/hooks/useCookie/useCookie.mjs +53 -56
- package/dist/esm/hooks/useCookie/useCookie.mjs.map +1 -1
- package/dist/esm/hooks/useCookies/useCookies.mjs +38 -37
- package/dist/esm/hooks/useCookies/useCookies.mjs.map +1 -1
- package/dist/esm/hooks/useCopy/useCopy.mjs +15 -10
- package/dist/esm/hooks/useCopy/useCopy.mjs.map +1 -1
- package/dist/esm/hooks/useCounter/useCounter.mjs +26 -22
- package/dist/esm/hooks/useCounter/useCounter.mjs.map +1 -1
- package/dist/esm/hooks/useCssVar/useCssVar.mjs +42 -32
- package/dist/esm/hooks/useCssVar/useCssVar.mjs.map +1 -1
- package/dist/esm/hooks/useDebounceCallback/useDebounceCallback.mjs +18 -17
- package/dist/esm/hooks/useDebounceCallback/useDebounceCallback.mjs.map +1 -1
- package/dist/esm/hooks/useDebounceEffect/useDebounceEffect.mjs +19 -18
- package/dist/esm/hooks/useDebounceEffect/useDebounceEffect.mjs.map +1 -1
- package/dist/esm/hooks/useDebounceState/useDebounceState.mjs +10 -9
- package/dist/esm/hooks/useDebounceState/useDebounceState.mjs.map +1 -1
- package/dist/esm/hooks/useDebounceValue/useDebounceValue.mjs +12 -11
- package/dist/esm/hooks/useDebounceValue/useDebounceValue.mjs.map +1 -1
- package/dist/esm/hooks/useDefault/useDefault.mjs +9 -8
- package/dist/esm/hooks/useDefault/useDefault.mjs.map +1 -1
- package/dist/esm/hooks/useDeviceMotion/useDeviceMotion.mjs +49 -36
- package/dist/esm/hooks/useDeviceMotion/useDeviceMotion.mjs.map +1 -1
- package/dist/esm/hooks/useDeviceOrientation/useDeviceOrientation.mjs +28 -27
- package/dist/esm/hooks/useDeviceOrientation/useDeviceOrientation.mjs.map +1 -1
- package/dist/esm/hooks/useDevicePixelRatio/useDevicePixelRatio.mjs +18 -14
- package/dist/esm/hooks/useDevicePixelRatio/useDevicePixelRatio.mjs.map +1 -1
- package/dist/esm/hooks/useDidUpdate/useDidUpdate.mjs +15 -18
- package/dist/esm/hooks/useDidUpdate/useDidUpdate.mjs.map +1 -1
- package/dist/esm/hooks/useDisclosure/useDisclosure.mjs +14 -8
- package/dist/esm/hooks/useDisclosure/useDisclosure.mjs.map +1 -1
- package/dist/esm/hooks/useDisplayMedia/useDisplayMedia.mjs +39 -39
- package/dist/esm/hooks/useDisplayMedia/useDisplayMedia.mjs.map +1 -1
- package/dist/esm/hooks/useDocumentEvent/useDocumentEvent.mjs +8 -7
- package/dist/esm/hooks/useDocumentEvent/useDocumentEvent.mjs.map +1 -1
- package/dist/esm/hooks/useDocumentTitle/useDocumentTitle.mjs +28 -27
- package/dist/esm/hooks/useDocumentTitle/useDocumentTitle.mjs.map +1 -1
- package/dist/esm/hooks/useDocumentVisibility/useDocumentVisibility.mjs +9 -8
- package/dist/esm/hooks/useDocumentVisibility/useDocumentVisibility.mjs.map +1 -1
- package/dist/esm/hooks/useDoubleClick/useDoubleClick.mjs +25 -28
- package/dist/esm/hooks/useDoubleClick/useDoubleClick.mjs.map +1 -1
- package/dist/esm/hooks/useDropZone/useDropZone.mjs +55 -47
- package/dist/esm/hooks/useDropZone/useDropZone.mjs.map +1 -1
- package/dist/esm/hooks/useEvent/useEvent.mjs +12 -11
- package/dist/esm/hooks/useEvent/useEvent.mjs.map +1 -1
- package/dist/esm/hooks/useEventListener/useEventListener.mjs +24 -19
- package/dist/esm/hooks/useEventListener/useEventListener.mjs.map +1 -1
- package/dist/esm/hooks/useEventSource/useEventSource.mjs +44 -49
- package/dist/esm/hooks/useEventSource/useEventSource.mjs.map +1 -1
- package/dist/esm/hooks/useEyeDropper/useEyeDropper.mjs +17 -16
- package/dist/esm/hooks/useEyeDropper/useEyeDropper.mjs.map +1 -1
- package/dist/esm/hooks/useFavicon/useFavicon.mjs +20 -18
- package/dist/esm/hooks/useFavicon/useFavicon.mjs.map +1 -1
- package/dist/esm/hooks/useField/useField.mjs +61 -67
- package/dist/esm/hooks/useField/useField.mjs.map +1 -1
- package/dist/esm/hooks/useFileDialog/useFileDialog.mjs +34 -32
- package/dist/esm/hooks/useFileDialog/useFileDialog.mjs.map +1 -1
- package/dist/esm/hooks/useFileSystemAccess/useFileSystemAccess.mjs +59 -0
- package/dist/esm/hooks/useFileSystemAccess/useFileSystemAccess.mjs.map +1 -0
- package/dist/esm/hooks/useFocus/useFocus.mjs +43 -34
- package/dist/esm/hooks/useFocus/useFocus.mjs.map +1 -1
- package/dist/esm/hooks/useFocusTrap/useFocusTrap.mjs +51 -36
- package/dist/esm/hooks/useFocusTrap/useFocusTrap.mjs.map +1 -1
- package/dist/esm/hooks/useFps/useFps.mjs +18 -22
- package/dist/esm/hooks/useFps/useFps.mjs.map +1 -1
- package/dist/esm/hooks/useFul/useFul.mjs +8 -7
- package/dist/esm/hooks/useFul/useFul.mjs.map +1 -1
- package/dist/esm/hooks/useFullscreen/useFullscreen.mjs +39 -42
- package/dist/esm/hooks/useFullscreen/useFullscreen.mjs.map +1 -1
- package/dist/esm/hooks/useGamepad/useGamepad.mjs +76 -83
- package/dist/esm/hooks/useGamepad/useGamepad.mjs.map +1 -1
- package/dist/esm/hooks/useGeolocation/useGeolocation.mjs +50 -45
- package/dist/esm/hooks/useGeolocation/useGeolocation.mjs.map +1 -1
- package/dist/esm/hooks/useHash/useHash.mjs +24 -26
- package/dist/esm/hooks/useHash/useHash.mjs.map +1 -1
- package/dist/esm/hooks/useHotkeys/useHotkeys.mjs +35 -37
- package/dist/esm/hooks/useHotkeys/useHotkeys.mjs.map +1 -1
- package/dist/esm/hooks/useHover/useHover.mjs +30 -25
- package/dist/esm/hooks/useHover/useHover.mjs.map +1 -1
- package/dist/esm/hooks/useIdle/useIdle.mjs +29 -26
- package/dist/esm/hooks/useIdle/useIdle.mjs.map +1 -1
- package/dist/esm/hooks/useImage/useImage.mjs +24 -26
- package/dist/esm/hooks/useImage/useImage.mjs.map +1 -1
- package/dist/esm/hooks/useInfiniteScroll/useInfiniteScroll.mjs +38 -32
- package/dist/esm/hooks/useInfiniteScroll/useInfiniteScroll.mjs.map +1 -1
- package/dist/esm/hooks/useIntersectionObserver/useIntersectionObserver.mjs +38 -37
- package/dist/esm/hooks/useIntersectionObserver/useIntersectionObserver.mjs.map +1 -1
- package/dist/esm/hooks/useInterval/useInterval.mjs +20 -20
- package/dist/esm/hooks/useInterval/useInterval.mjs.map +1 -1
- package/dist/esm/hooks/useIsFirstRender/useIsFirstRender.mjs +8 -7
- package/dist/esm/hooks/useIsFirstRender/useIsFirstRender.mjs.map +1 -1
- package/dist/esm/hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.mjs +7 -6
- package/dist/esm/hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.mjs.map +1 -1
- package/dist/esm/hooks/useKeyPress/useKeyPress.mjs +30 -26
- package/dist/esm/hooks/useKeyPress/useKeyPress.mjs.map +1 -1
- package/dist/esm/hooks/useKeyPressEvent/useKeyPressEvent.mjs +33 -35
- package/dist/esm/hooks/useKeyPressEvent/useKeyPressEvent.mjs.map +1 -1
- package/dist/esm/hooks/useKeyboard/useKeyboard.mjs +16 -19
- package/dist/esm/hooks/useKeyboard/useKeyboard.mjs.map +1 -1
- package/dist/esm/hooks/useKeysPressed/useKeysPressed.mjs +36 -25
- package/dist/esm/hooks/useKeysPressed/useKeysPressed.mjs.map +1 -1
- package/dist/esm/hooks/useLastChanged/useLastChanged.mjs +10 -9
- package/dist/esm/hooks/useLastChanged/useLastChanged.mjs.map +1 -1
- package/dist/esm/hooks/useLatest/useLatest.mjs +14 -16
- package/dist/esm/hooks/useLatest/useLatest.mjs.map +1 -1
- package/dist/esm/hooks/useLess/useLess.mjs +9 -8
- package/dist/esm/hooks/useLess/useLess.mjs.map +1 -1
- package/dist/esm/hooks/useList/useList.mjs +22 -22
- package/dist/esm/hooks/useList/useList.mjs.map +1 -1
- package/dist/esm/hooks/useLocalStorage/useLocalStorage.mjs +10 -9
- package/dist/esm/hooks/useLocalStorage/useLocalStorage.mjs.map +1 -1
- package/dist/esm/hooks/useLockCallback/useLockCallback.mjs +18 -17
- package/dist/esm/hooks/useLockCallback/useLockCallback.mjs.map +1 -1
- package/dist/esm/hooks/useLockScroll/useLockScroll.mjs +44 -39
- package/dist/esm/hooks/useLockScroll/useLockScroll.mjs.map +1 -1
- package/dist/esm/hooks/useLogger/useLogger.mjs +10 -9
- package/dist/esm/hooks/useLogger/useLogger.mjs.map +1 -1
- package/dist/esm/hooks/useLongPress/useLongPress.mjs +30 -26
- package/dist/esm/hooks/useLongPress/useLongPress.mjs.map +1 -1
- package/dist/esm/hooks/useMap/useMap.mjs +21 -20
- package/dist/esm/hooks/useMap/useMap.mjs.map +1 -1
- package/dist/esm/hooks/useMeasure/useMeasure.mjs +45 -32
- package/dist/esm/hooks/useMeasure/useMeasure.mjs.map +1 -1
- package/dist/esm/hooks/useMediaControls/useMediaControls.mjs +67 -68
- package/dist/esm/hooks/useMediaControls/useMediaControls.mjs.map +1 -1
- package/dist/esm/hooks/useMediaQuery/useMediaQuery.mjs +12 -17
- package/dist/esm/hooks/useMediaQuery/useMediaQuery.mjs.map +1 -1
- package/dist/esm/hooks/useMemory/useMemory.mjs +20 -18
- package/dist/esm/hooks/useMemory/useMemory.mjs.map +1 -1
- package/dist/esm/hooks/useMergedRef/useMergedRef.mjs +23 -25
- package/dist/esm/hooks/useMergedRef/useMergedRef.mjs.map +1 -1
- package/dist/esm/hooks/useMount/useMount.mjs +7 -6
- package/dist/esm/hooks/useMount/useMount.mjs.map +1 -1
- package/dist/esm/hooks/useMouse/useMouse.mjs +61 -58
- package/dist/esm/hooks/useMouse/useMouse.mjs.map +1 -1
- package/dist/esm/hooks/useMutation/useMutation.mjs +63 -60
- package/dist/esm/hooks/useMutation/useMutation.mjs.map +1 -1
- package/dist/esm/hooks/useMutationObserver/useMutationObserver.mjs +35 -34
- package/dist/esm/hooks/useMutationObserver/useMutationObserver.mjs.map +1 -1
- package/dist/esm/hooks/useNetwork/useNetwork.mjs +47 -48
- package/dist/esm/hooks/useNetwork/useNetwork.mjs.map +1 -1
- package/dist/esm/hooks/useObjectUrl/useObjectUrl.mjs +20 -0
- package/dist/esm/hooks/useObjectUrl/useObjectUrl.mjs.map +1 -0
- package/dist/esm/hooks/useOffsetPagination/useOffsetPagination.mjs +50 -40
- package/dist/esm/hooks/useOffsetPagination/useOffsetPagination.mjs.map +1 -1
- package/dist/esm/hooks/useOnce/useOnce.mjs +13 -13
- package/dist/esm/hooks/useOnce/useOnce.mjs.map +1 -1
- package/dist/esm/hooks/useOnline/useOnline.mjs +9 -8
- package/dist/esm/hooks/useOnline/useOnline.mjs.map +1 -1
- package/dist/esm/hooks/useOperatingSystem/useOperatingSystem.mjs +12 -12
- package/dist/esm/hooks/useOperatingSystem/useOperatingSystem.mjs.map +1 -1
- package/dist/esm/hooks/useOptimistic/useOptimistic.mjs +14 -13
- package/dist/esm/hooks/useOptimistic/useOptimistic.mjs.map +1 -1
- package/dist/esm/hooks/useOrientation/useOrientation.mjs +30 -29
- package/dist/esm/hooks/useOrientation/useOrientation.mjs.map +1 -1
- package/dist/esm/hooks/useOtpCredential/useOtpCredential.mjs +28 -25
- package/dist/esm/hooks/useOtpCredential/useOtpCredential.mjs.map +1 -1
- package/dist/esm/hooks/usePageLeave/usePageLeave.mjs +15 -14
- package/dist/esm/hooks/usePageLeave/usePageLeave.mjs.map +1 -1
- package/dist/esm/hooks/usePaint/usePaint.mjs +139 -151
- package/dist/esm/hooks/usePaint/usePaint.mjs.map +1 -1
- package/dist/esm/hooks/useParallax/useParallax.mjs +90 -96
- package/dist/esm/hooks/useParallax/useParallax.mjs.map +1 -1
- package/dist/esm/hooks/usePerformanceObserver/usePerformanceObserver.mjs +29 -23
- package/dist/esm/hooks/usePerformanceObserver/usePerformanceObserver.mjs.map +1 -1
- package/dist/esm/hooks/usePermission/usePermission.mjs +25 -27
- package/dist/esm/hooks/usePermission/usePermission.mjs.map +1 -1
- package/dist/esm/hooks/usePictureInPicture/usePictureInPicture.mjs +42 -38
- package/dist/esm/hooks/usePictureInPicture/usePictureInPicture.mjs.map +1 -1
- package/dist/esm/hooks/usePointerLock/usePointerLock.mjs +31 -30
- package/dist/esm/hooks/usePointerLock/usePointerLock.mjs.map +1 -1
- package/dist/esm/hooks/usePostMessage/usePostMessage.mjs +22 -23
- package/dist/esm/hooks/usePostMessage/usePostMessage.mjs.map +1 -1
- package/dist/esm/hooks/usePreferredColorScheme/usePreferredColorScheme.mjs +8 -7
- package/dist/esm/hooks/usePreferredColorScheme/usePreferredColorScheme.mjs.map +1 -1
- package/dist/esm/hooks/usePreferredContrast/usePreferredContrast.mjs +8 -7
- package/dist/esm/hooks/usePreferredContrast/usePreferredContrast.mjs.map +1 -1
- package/dist/esm/hooks/usePreferredDark/usePreferredDark.mjs +6 -5
- package/dist/esm/hooks/usePreferredDark/usePreferredDark.mjs.map +1 -1
- package/dist/esm/hooks/usePreferredLanguages/usePreferredLanguages.mjs +9 -8
- package/dist/esm/hooks/usePreferredLanguages/usePreferredLanguages.mjs.map +1 -1
- package/dist/esm/hooks/usePreferredReducedMotion/usePreferredReducedMotion.mjs +6 -5
- package/dist/esm/hooks/usePreferredReducedMotion/usePreferredReducedMotion.mjs.map +1 -1
- package/dist/esm/hooks/usePrevious/usePrevious.mjs +9 -8
- package/dist/esm/hooks/usePrevious/usePrevious.mjs.map +1 -1
- package/dist/esm/hooks/useProgress/useProgress.mjs +28 -24
- package/dist/esm/hooks/useProgress/useProgress.mjs.map +1 -1
- package/dist/esm/hooks/useQuery/useQuery.mjs +61 -52
- package/dist/esm/hooks/useQuery/useQuery.mjs.map +1 -1
- package/dist/esm/hooks/useQueue/useQueue.mjs +23 -22
- package/dist/esm/hooks/useQueue/useQueue.mjs.map +1 -1
- package/dist/esm/hooks/useRaf/useRaf.mjs +32 -29
- package/dist/esm/hooks/useRaf/useRaf.mjs.map +1 -1
- package/dist/esm/hooks/useRafState/useRafState.mjs +12 -11
- package/dist/esm/hooks/useRafState/useRafState.mjs.map +1 -1
- package/dist/esm/hooks/useRefState/useRefState.mjs +24 -24
- package/dist/esm/hooks/useRefState/useRefState.mjs.map +1 -1
- package/dist/esm/hooks/useRenderCount/useRenderCount.mjs +11 -10
- package/dist/esm/hooks/useRenderCount/useRenderCount.mjs.map +1 -1
- package/dist/esm/hooks/useRenderInfo/useRenderInfo.mjs +14 -13
- package/dist/esm/hooks/useRenderInfo/useRenderInfo.mjs.map +1 -1
- package/dist/esm/hooks/useRerender/useRerender.mjs +6 -5
- package/dist/esm/hooks/useRerender/useRerender.mjs.map +1 -1
- package/dist/esm/hooks/useResizeObserver/useResizeObserver.mjs +33 -24
- package/dist/esm/hooks/useResizeObserver/useResizeObserver.mjs.map +1 -1
- package/dist/esm/hooks/useRightClick/useRightClick.mjs +37 -34
- package/dist/esm/hooks/useRightClick/useRightClick.mjs.map +1 -1
- package/dist/esm/hooks/useScript/useScript.mjs +28 -31
- package/dist/esm/hooks/useScript/useScript.mjs.map +1 -1
- package/dist/esm/hooks/useScroll/useScroll.mjs +95 -81
- package/dist/esm/hooks/useScroll/useScroll.mjs.map +1 -1
- package/dist/esm/hooks/useScrollIntoView/useScrollIntoView.mjs +33 -34
- package/dist/esm/hooks/useScrollIntoView/useScrollIntoView.mjs.map +1 -1
- package/dist/esm/hooks/useScrollTo/useScrollTo.mjs +33 -21
- package/dist/esm/hooks/useScrollTo/useScrollTo.mjs.map +1 -1
- package/dist/esm/hooks/useSessionStorage/useSessionStorage.mjs +10 -9
- package/dist/esm/hooks/useSessionStorage/useSessionStorage.mjs.map +1 -1
- package/dist/esm/hooks/useSet/useSet.mjs +30 -29
- package/dist/esm/hooks/useSet/useSet.mjs.map +1 -1
- package/dist/esm/hooks/useShallowEffect/useShallowEffect.mjs +20 -22
- package/dist/esm/hooks/useShallowEffect/useShallowEffect.mjs.map +1 -1
- package/dist/esm/hooks/useShare/useShare.mjs +18 -14
- package/dist/esm/hooks/useShare/useShare.mjs.map +1 -1
- package/dist/esm/hooks/useSize/useSize.mjs +40 -30
- package/dist/esm/hooks/useSize/useSize.mjs.map +1 -1
- package/dist/esm/hooks/useSpeechRecognition/useSpeechRecognition.mjs +34 -44
- package/dist/esm/hooks/useSpeechRecognition/useSpeechRecognition.mjs.map +1 -1
- package/dist/esm/hooks/useSpeechSynthesis/useSpeechSynthesis.mjs +65 -64
- package/dist/esm/hooks/useSpeechSynthesis/useSpeechSynthesis.mjs.map +1 -1
- package/dist/esm/hooks/useStateHistory/useStateHistory.mjs +96 -84
- package/dist/esm/hooks/useStateHistory/useStateHistory.mjs.map +1 -1
- package/dist/esm/hooks/useStep/useStep.mjs +27 -28
- package/dist/esm/hooks/useStep/useStep.mjs.map +1 -1
- package/dist/esm/hooks/useSticky/useSticky.mjs +36 -30
- package/dist/esm/hooks/useSticky/useSticky.mjs.map +1 -1
- package/dist/esm/hooks/useStopwatch/useStopwatch.mjs +59 -57
- package/dist/esm/hooks/useStopwatch/useStopwatch.mjs.map +1 -1
- package/dist/esm/hooks/useStorage/useStorage.mjs +61 -62
- package/dist/esm/hooks/useStorage/useStorage.mjs.map +1 -1
- package/dist/esm/hooks/useTextDirection/useTextDirection.mjs +35 -30
- package/dist/esm/hooks/useTextDirection/useTextDirection.mjs.map +1 -1
- package/dist/esm/hooks/useTextSelection/useTextSelection.mjs +25 -27
- package/dist/esm/hooks/useTextSelection/useTextSelection.mjs.map +1 -1
- package/dist/esm/hooks/useTextareaAutosize/useTextareaAutosize.mjs +53 -52
- package/dist/esm/hooks/useTextareaAutosize/useTextareaAutosize.mjs.map +1 -1
- package/dist/esm/hooks/useThrottleCallback/useThrottleCallback.mjs +18 -17
- package/dist/esm/hooks/useThrottleCallback/useThrottleCallback.mjs.map +1 -1
- package/dist/esm/hooks/useThrottleEffect/useThrottleEffect.mjs +21 -21
- package/dist/esm/hooks/useThrottleEffect/useThrottleEffect.mjs.map +1 -1
- package/dist/esm/hooks/useThrottleState/useThrottleState.mjs +10 -9
- package/dist/esm/hooks/useThrottleState/useThrottleState.mjs.map +1 -1
- package/dist/esm/hooks/useThrottleValue/useThrottleValue.mjs +12 -11
- package/dist/esm/hooks/useThrottleValue/useThrottleValue.mjs.map +1 -1
- package/dist/esm/hooks/useTime/useTime.mjs +14 -13
- package/dist/esm/hooks/useTime/useTime.mjs.map +1 -1
- package/dist/esm/hooks/useTimeout/useTimeout.mjs +19 -15
- package/dist/esm/hooks/useTimeout/useTimeout.mjs.map +1 -1
- package/dist/esm/hooks/useTimer/useTimer.mjs +61 -66
- package/dist/esm/hooks/useTimer/useTimer.mjs.map +1 -1
- package/dist/esm/hooks/useToggle/useToggle.mjs +12 -11
- package/dist/esm/hooks/useToggle/useToggle.mjs.map +1 -1
- package/dist/esm/hooks/useUnmount/useUnmount.mjs +11 -13
- package/dist/esm/hooks/useUnmount/useUnmount.mjs.map +1 -1
- package/dist/esm/hooks/useUrlSearchParam/useUrlSearchParam.mjs +66 -76
- package/dist/esm/hooks/useUrlSearchParam/useUrlSearchParam.mjs.map +1 -1
- package/dist/esm/hooks/useUrlSearchParams/useUrlSearchParams.mjs +50 -60
- package/dist/esm/hooks/useUrlSearchParams/useUrlSearchParams.mjs.map +1 -1
- package/dist/esm/hooks/useVibrate/useVibrate.mjs +28 -21
- package/dist/esm/hooks/useVibrate/useVibrate.mjs.map +1 -1
- package/dist/esm/hooks/useVirtualKeyboard/useVirtualKeyboard.mjs +30 -29
- package/dist/esm/hooks/useVirtualKeyboard/useVirtualKeyboard.mjs.map +1 -1
- package/dist/esm/hooks/useVisibility/useVisibility.mjs +41 -39
- package/dist/esm/hooks/useVisibility/useVisibility.mjs.map +1 -1
- package/dist/esm/hooks/useWakeLock/useWakeLock.mjs +28 -23
- package/dist/esm/hooks/useWakeLock/useWakeLock.mjs.map +1 -1
- package/dist/esm/hooks/useWebSocket/useWebSocket.mjs +38 -35
- package/dist/esm/hooks/useWebSocket/useWebSocket.mjs.map +1 -1
- package/dist/esm/hooks/useWindowEvent/useWindowEvent.mjs +7 -6
- package/dist/esm/hooks/useWindowEvent/useWindowEvent.mjs.map +1 -1
- package/dist/esm/hooks/useWindowFocus/useWindowFocus.mjs +14 -13
- package/dist/esm/hooks/useWindowFocus/useWindowFocus.mjs.map +1 -1
- package/dist/esm/hooks/useWindowScroll/useWindowScroll.mjs +29 -21
- package/dist/esm/hooks/useWindowScroll/useWindowScroll.mjs.map +1 -1
- package/dist/esm/hooks/useWindowSize/useWindowSize.mjs +24 -23
- package/dist/esm/hooks/useWindowSize/useWindowSize.mjs.map +1 -1
- package/dist/esm/hooks/useWizard/useWizard.mjs +25 -20
- package/dist/esm/hooks/useWizard/useWizard.mjs.map +1 -1
- package/dist/esm/index.mjs +173 -394
- package/dist/esm/utils/helpers/copy.mjs +18 -18
- package/dist/esm/utils/helpers/copy.mjs.map +1 -1
- package/dist/esm/utils/helpers/debounce.mjs +10 -10
- package/dist/esm/utils/helpers/debounce.mjs.map +1 -1
- package/dist/esm/utils/helpers/getDate.mjs +20 -16
- package/dist/esm/utils/helpers/getDate.mjs.map +1 -1
- package/dist/esm/utils/helpers/getRetry.mjs +6 -5
- package/dist/esm/utils/helpers/getRetry.mjs.map +1 -1
- package/dist/esm/utils/helpers/isTarget.mjs +10 -19
- package/dist/esm/utils/helpers/isTarget.mjs.map +1 -1
- package/dist/esm/utils/helpers/throttle.mjs +20 -20
- package/dist/esm/utils/helpers/throttle.mjs.map +1 -1
- package/dist/types/helpers/index.d.ts +1 -0
- package/dist/types/helpers/makeDestructurable/makeDestructurable.d.ts +16 -0
- package/dist/types/hooks/browser.d.ts +2 -0
- package/dist/types/hooks/useEventListener/useEventListener.d.ts +0 -22
- package/dist/types/hooks/useField/useField.d.ts +2 -2
- package/dist/types/hooks/useFileSystemAccess/useFileSystemAccess.d.ts +116 -0
- package/dist/types/hooks/useKeyboard/useKeyboard.d.ts +4 -2
- package/dist/types/hooks/useObjectUrl/useObjectUrl.d.ts +24 -0
- package/dist/types/hooks/usePerformanceObserver/usePerformanceObserver.d.ts +1 -0
- package/dist/types/hooks/useScrollIntoView/useScrollIntoView.d.ts +1 -1
- package/dist/types/hooks/useWebSocket/useWebSocket.d.ts +1 -0
- package/package.json +5 -5
- package/dist/cjs/index.cjs.map +0 -1
- package/dist/esm/index.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSessionStorage.cjs","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 State\n * @usage medium\n *\n * @browserapi sessionStorage https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage\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?: Omit<UseStorageOptions<Value>, 'initialValue' | 'storage'>\n) =>\n useStorage(key, {\n ...options,\n initialValue,\n storage: typeof window !== 'undefined' ? window.sessionStorage : undefined\n });\n"],"
|
|
1
|
+
{"version":3,"file":"useSessionStorage.cjs","names":[],"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 State\n * @usage medium\n *\n * @browserapi sessionStorage https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage\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?: Omit<UseStorageOptions<Value>, 'initialValue' | 'storage'>\n) =>\n useStorage(key, {\n ...options,\n initialValue,\n storage: typeof window !== 'undefined' ? window.sessionStorage : undefined\n });\n"],"mappings":"gDAoBA,IAAa,GACX,EACA,EACA,IAEA,EAAA,WAAW,EAAK,CACd,GAAG,EACH,eACA,QAAS,OAAO,OAAW,IAAc,OAAO,eAAiB,IAAA,GAClE,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=useSet.cjs.map
|
|
1
|
+
require(`../../_virtual/_rolldown/runtime.cjs`);let e=require(`react`);var t=t=>{let[n,r]=(0,e.useState)(new Set(t));return{value:n,size:n.size,has:e=>n.has(e),add:e=>r(t=>new Set(t).add(e)),remove:e=>r(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n}),clear:()=>r(new Set),reset:()=>r(new Set(t)),toggle:e=>r(t=>{if(!t.has(e))return new Set(t).add(e);let n=new Set(t);return n.delete(e),n}),union:e=>r(n.union(e)),difference:e=>r(n.difference(e)),symmetricDifference:e=>r(n.symmetricDifference(e)),intersection:e=>r(n.intersection(e))}};exports.useSet=t;
|
|
2
|
+
//# sourceMappingURL=useSet.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSet.cjs","sources":["../../../../src/hooks/useSet/useSet.ts"],"sourcesContent":["import { useState } from 'react';\n\n/** The use set return type */\ninterface UseSetReturn<Value> {\n /** The size of the set */\n size: number;\n /** The current set */\n value: Set<Value>;\n /** Function to add a value to the set */\n add: (value: Value) => void;\n /** Function to clear the set */\n clear: () => void;\n /** Function to get the symmetric difference of two sets */\n difference: (other: Set<Value>) => void;\n /** Function to check if a value exists in the set */\n has: (value: Value) => boolean;\n /** Function to get the difference of two sets */\n intersection: (other: Set<Value>) => void;\n /** Function to remove a value from the set */\n remove: (value: Value) => void;\n /** Function to toggle a value in the set */\n reset: () => void;\n /** Function to get the symmetric difference of two sets */\n symmetricDifference: (other: Set<Value>) => void;\n /** Function to toggle a value in the set */\n toggle: (value: Value) => void;\n /** Function to get the union of two sets */\n union: (other: Set<Value>) => void;\n}\n\n/**\n * @name useSet\n * @description - Hook that manages a set structure\n * @category State\n * @usage medium\n *\n * @template Value The type of the value\n * @param {Value[]} [values] The initial array of the set\n * @returns {UseSetReturn<Value>} An object containing the current set and functions to interact with the set\n *\n * @example\n * const { value, add, remove, clear, reset, toggle, union, intersection, difference, symmetricDifference, size, has } = useSet([1, 2, 3]);\n */\nexport const useSet = <Value>(values?: Value[]): UseSetReturn<Value> => {\n const [set, setSet] = useState(new Set(values));\n\n const add = (value: Value) => setSet((prevSet) => new Set(prevSet).add(value));\n const remove = (value: Value) =>\n setSet((prevSet) => {\n if (!prevSet.has(value)) return prevSet;\n const newSet = new Set(prevSet);\n newSet.delete(value);\n return newSet;\n });\n const clear = () => setSet(new Set());\n const reset = () => setSet(new Set(values));\n const toggle = (value: Value) =>\n setSet((prevSet) => {\n if (!prevSet.has(value)) return new Set(prevSet).add(value);\n const newSet = new Set(prevSet);\n newSet.delete(value);\n return newSet;\n });\n const union = (other: Set<Value>) => setSet(set.union(other));\n const difference = (other: Set<Value>) => setSet(set.difference(other));\n const symmetricDifference = (other: Set<Value>) => setSet(set.symmetricDifference(other));\n const intersection = (other: Set<Value>) => setSet(set.intersection(other));\n const has = (value: Value) => set.has(value);\n\n return {\n value: set,\n size: set.size,\n has,\n add,\n remove,\n clear,\n reset,\n toggle,\n union,\n difference,\n symmetricDifference,\n intersection\n };\n};\n"],"
|
|
1
|
+
{"version":3,"file":"useSet.cjs","names":[],"sources":["../../../../src/hooks/useSet/useSet.ts"],"sourcesContent":["import { useState } from 'react';\n\n/** The use set return type */\ninterface UseSetReturn<Value> {\n /** The size of the set */\n size: number;\n /** The current set */\n value: Set<Value>;\n /** Function to add a value to the set */\n add: (value: Value) => void;\n /** Function to clear the set */\n clear: () => void;\n /** Function to get the symmetric difference of two sets */\n difference: (other: Set<Value>) => void;\n /** Function to check if a value exists in the set */\n has: (value: Value) => boolean;\n /** Function to get the difference of two sets */\n intersection: (other: Set<Value>) => void;\n /** Function to remove a value from the set */\n remove: (value: Value) => void;\n /** Function to toggle a value in the set */\n reset: () => void;\n /** Function to get the symmetric difference of two sets */\n symmetricDifference: (other: Set<Value>) => void;\n /** Function to toggle a value in the set */\n toggle: (value: Value) => void;\n /** Function to get the union of two sets */\n union: (other: Set<Value>) => void;\n}\n\n/**\n * @name useSet\n * @description - Hook that manages a set structure\n * @category State\n * @usage medium\n *\n * @template Value The type of the value\n * @param {Value[]} [values] The initial array of the set\n * @returns {UseSetReturn<Value>} An object containing the current set and functions to interact with the set\n *\n * @example\n * const { value, add, remove, clear, reset, toggle, union, intersection, difference, symmetricDifference, size, has } = useSet([1, 2, 3]);\n */\nexport const useSet = <Value>(values?: Value[]): UseSetReturn<Value> => {\n const [set, setSet] = useState(new Set(values));\n\n const add = (value: Value) => setSet((prevSet) => new Set(prevSet).add(value));\n const remove = (value: Value) =>\n setSet((prevSet) => {\n if (!prevSet.has(value)) return prevSet;\n const newSet = new Set(prevSet);\n newSet.delete(value);\n return newSet;\n });\n const clear = () => setSet(new Set());\n const reset = () => setSet(new Set(values));\n const toggle = (value: Value) =>\n setSet((prevSet) => {\n if (!prevSet.has(value)) return new Set(prevSet).add(value);\n const newSet = new Set(prevSet);\n newSet.delete(value);\n return newSet;\n });\n const union = (other: Set<Value>) => setSet(set.union(other));\n const difference = (other: Set<Value>) => setSet(set.difference(other));\n const symmetricDifference = (other: Set<Value>) => setSet(set.symmetricDifference(other));\n const intersection = (other: Set<Value>) => setSet(set.intersection(other));\n const has = (value: Value) => set.has(value);\n\n return {\n value: set,\n size: set.size,\n has,\n add,\n remove,\n clear,\n reset,\n toggle,\n union,\n difference,\n symmetricDifference,\n intersection\n };\n};\n"],"mappings":"uEA2CA,IAAa,EAAiB,GAA0C,CACtE,GAAM,CAAC,EAAK,IAAA,EAAA,EAAA,UAAmB,IAAI,IAAI,EAAO,CAAC,CAyB/C,MAAO,CACL,MAAO,EACP,KAAM,EAAI,KACV,IALW,GAAiB,EAAI,IAAI,EAAM,CAM1C,IA3BW,GAAiB,EAAQ,GAAY,IAAI,IAAI,EAAQ,CAAC,IAAI,EAAM,CAAC,CA4B5E,OA3Bc,GACd,EAAQ,GAAY,CAClB,GAAI,CAAC,EAAQ,IAAI,EAAM,CAAE,OAAO,EAChC,IAAM,EAAS,IAAI,IAAI,EAAQ,CAE/B,OADA,EAAO,OAAO,EAAM,CACb,GACP,CAsBF,UArBkB,EAAO,IAAI,IAAM,CAsBnC,UArBkB,EAAO,IAAI,IAAI,EAAO,CAAC,CAsBzC,OArBc,GACd,EAAQ,GAAY,CAClB,GAAI,CAAC,EAAQ,IAAI,EAAM,CAAE,OAAO,IAAI,IAAI,EAAQ,CAAC,IAAI,EAAM,CAC3D,IAAM,EAAS,IAAI,IAAI,EAAQ,CAE/B,OADA,EAAO,OAAO,EAAM,CACb,GACP,CAgBF,MAfa,GAAsB,EAAO,EAAI,MAAM,EAAM,CAAC,CAgB3D,WAfkB,GAAsB,EAAO,EAAI,WAAW,EAAM,CAAC,CAgBrE,oBAf2B,GAAsB,EAAO,EAAI,oBAAoB,EAAM,CAAC,CAgBvF,aAfoB,GAAsB,EAAO,EAAI,aAAa,EAAM,CAAC,CAgB1E"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=useShallowEffect.cjs.map
|
|
1
|
+
require(`../../_virtual/_rolldown/runtime.cjs`);let e=require(`react`);var t=(e,n)=>{if(e===n)return!0;if(e==null||n==null)return e===n;if(typeof e!=typeof n)return!1;if(typeof e!=`object`)return e===n;if(Array.isArray(e)!==Array.isArray(n))return!1;if(Array.isArray(e))return e.length===n.length&&e.every((e,r)=>t(e,n[r]));let r=Object.keys(e),i=Object.keys(n);if(r.length!==i.length)return!1;for(let a of r)if(!i.includes(a)||!t(e[a],n[a]))return!1;return!0},n=(n,r)=>{let i=(0,e.useRef)(r);(!i.current||!t(r,i.current))&&(i.current=r),(0,e.useEffect)(n,i.current)};exports.deepEqual=t,exports.useShallowEffect=n;
|
|
2
|
+
//# sourceMappingURL=useShallowEffect.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useShallowEffect.cjs","sources":["../../../../src/hooks/useShallowEffect/useShallowEffect.ts"],"sourcesContent":["import type { DependencyList, EffectCallback } from 'react';\n\nimport { useEffect, useRef } from 'react';\n\nexport const deepEqual = (a: any, b: any): boolean => {\n if (a === b) return true;\n if (a == null || b == null) return a === b;\n if (typeof a !== typeof b) return false;\n if (typeof a !== 'object') return a === b;\n if (Array.isArray(a) !== Array.isArray(b)) return false;\n\n if (Array.isArray(a))\n return a.length === b.length && a.every((value, index) => deepEqual(value, b[index]));\n\n const keysA = Object.keys(a);\n const keysB = Object.keys(b);\n\n if (keysA.length !== keysB.length) return false;\n\n for (const key of keysA) {\n if (!keysB.includes(key)) return false;\n if (!deepEqual(a[key], b[key])) return false;\n }\n\n return true;\n};\n\n/**\n * @name useShallowEffect\n * @description - Hook that executes an effect only when dependencies change shallowly or deeply\n * @category Lifecycle\n * @usage low\n *\n * @param {EffectCallback} effect The effect callback\n * @param {DependencyList} [deps] The dependencies list for the effect\n *\n * @example\n * useShallowEffect(() => console.log(\"effect\"), [user]);\n */\nexport const useShallowEffect = (effect: EffectCallback, deps?: DependencyList) => {\n const depsRef = useRef<DependencyList>(deps);\n\n if (!depsRef.current || !deepEqual(deps, depsRef.current)) {\n depsRef.current = deps;\n }\n\n useEffect(effect, depsRef.current);\n};\n"],"
|
|
1
|
+
{"version":3,"file":"useShallowEffect.cjs","names":[],"sources":["../../../../src/hooks/useShallowEffect/useShallowEffect.ts"],"sourcesContent":["import type { DependencyList, EffectCallback } from 'react';\n\nimport { useEffect, useRef } from 'react';\n\nexport const deepEqual = (a: any, b: any): boolean => {\n if (a === b) return true;\n if (a == null || b == null) return a === b;\n if (typeof a !== typeof b) return false;\n if (typeof a !== 'object') return a === b;\n if (Array.isArray(a) !== Array.isArray(b)) return false;\n\n if (Array.isArray(a))\n return a.length === b.length && a.every((value, index) => deepEqual(value, b[index]));\n\n const keysA = Object.keys(a);\n const keysB = Object.keys(b);\n\n if (keysA.length !== keysB.length) return false;\n\n for (const key of keysA) {\n if (!keysB.includes(key)) return false;\n if (!deepEqual(a[key], b[key])) return false;\n }\n\n return true;\n};\n\n/**\n * @name useShallowEffect\n * @description - Hook that executes an effect only when dependencies change shallowly or deeply\n * @category Lifecycle\n * @usage low\n *\n * @param {EffectCallback} effect The effect callback\n * @param {DependencyList} [deps] The dependencies list for the effect\n *\n * @example\n * useShallowEffect(() => console.log(\"effect\"), [user]);\n */\nexport const useShallowEffect = (effect: EffectCallback, deps?: DependencyList) => {\n const depsRef = useRef<DependencyList>(deps);\n\n if (!depsRef.current || !deepEqual(deps, depsRef.current)) {\n depsRef.current = deps;\n }\n\n useEffect(effect, depsRef.current);\n};\n"],"mappings":"uEAIA,IAAa,GAAa,EAAQ,IAAoB,CACpD,GAAI,IAAM,EAAG,MAAO,GACpB,GAAI,GAAK,MAAQ,GAAK,KAAM,OAAO,IAAM,EACzC,GAAI,OAAO,GAAM,OAAO,EAAG,MAAO,GAClC,GAAI,OAAO,GAAM,SAAU,OAAO,IAAM,EACxC,GAAI,MAAM,QAAQ,EAAE,GAAK,MAAM,QAAQ,EAAE,CAAE,MAAO,GAElD,GAAI,MAAM,QAAQ,EAAE,CAClB,OAAO,EAAE,SAAW,EAAE,QAAU,EAAE,OAAO,EAAO,IAAU,EAAU,EAAO,EAAE,GAAO,CAAC,CAEvF,IAAM,EAAQ,OAAO,KAAK,EAAE,CACtB,EAAQ,OAAO,KAAK,EAAE,CAE5B,GAAI,EAAM,SAAW,EAAM,OAAQ,MAAO,GAE1C,IAAK,IAAM,KAAO,EAEhB,GADI,CAAC,EAAM,SAAS,EAAI,EACpB,CAAC,EAAU,EAAE,GAAM,EAAE,GAAK,CAAE,MAAO,GAGzC,MAAO,IAeI,GAAoB,EAAwB,IAA0B,CACjF,IAAM,GAAA,EAAA,EAAA,QAAiC,EAAK,EAExC,CAAC,EAAQ,SAAW,CAAC,EAAU,EAAM,EAAQ,QAAQ,IACvD,EAAQ,QAAU,IAGpB,EAAA,EAAA,WAAU,EAAQ,EAAQ,QAAQ"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=useShare.cjs.map
|
|
1
|
+
var e=e=>{let t=typeof navigator<`u`&&`share`in navigator&&!!navigator.share;return{trigger:async n=>{if(!t)return;let r={...e,...n};return r.files&&navigator.canShare({files:r.files})&&navigator.share(r),navigator.share(r)},supported:t}};exports.useShare=e;
|
|
2
|
+
//# sourceMappingURL=useShare.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useShare.cjs","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 trigger: (shareParams: ShareData) => Promise<void>;\n}\n\n/**\n * @name useShare\n * @description - Hook that utilizes the share api\n * @category Browser\n * @usage medium\n *\n * @browserapi share https://developer.mozilla.org/en-US/docs/Web/API/Navigator/share\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 && !!navigator.share;\n\n const trigger = 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 { trigger, supported };\n};\n"],"
|
|
1
|
+
{"version":3,"file":"useShare.cjs","names":[],"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 trigger: (shareParams: ShareData) => Promise<void>;\n}\n\n/**\n * @name useShare\n * @description - Hook that utilizes the share api\n * @category Browser\n * @usage medium\n *\n * @browserapi share https://developer.mozilla.org/en-US/docs/Web/API/Navigator/share\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 && !!navigator.share;\n\n const trigger = 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 { trigger, supported };\n};\n"],"mappings":"AAkCA,IAAa,EAAY,GAA4B,CACnD,IAAM,EAAY,OAAO,UAAc,KAAe,UAAW,WAAa,CAAC,CAAC,UAAU,MAe1F,MAAO,CAAE,QAbO,KAAO,IAA2B,CAChD,GAAI,CAAC,EAAW,OAEhB,IAAM,EAAO,CACX,GAAG,EACH,GAAG,EACJ,CAID,OAFI,EAAK,OAAS,UAAU,SAAS,CAAE,MAAO,EAAK,MAAO,CAAC,EAAE,UAAU,MAAM,EAAK,CAE3E,UAAU,MAAM,EAAK,EAGZ,YAAW"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=useSize.cjs.map
|
|
1
|
+
require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.cjs`),t=require(`../../utils/helpers/isTarget.cjs`),n=require(`../useRefState/useRefState.cjs`);let r=require(`react`);var i=((...i)=>{let a=i[0],[o,s]=(0,r.useState)({width:0,height:0}),[c,l]=(0,r.useState)(),u=n.useRefState();return e.useIsomorphicLayoutEffect(()=>{let e=a?t.isTarget.getElement(a):u.current;if(!e)return;let{width:n,height:r}=e.getBoundingClientRect();s({width:n,height:r});let i=new ResizeObserver(()=>{let{width:t,height:n}=e.getBoundingClientRect();s({width:t,height:n})});return l(i),i.observe(e),()=>{i.disconnect()}},[u.state,a&&t.isTarget.getRawElement(a)]),a?{observer:c,value:o}:{observer:c,ref:u,value:o}});exports.useSize=i;
|
|
2
|
+
//# sourceMappingURL=useSize.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSize.cjs","sources":["../../../../src/hooks/useSize/useSize.ts"],"sourcesContent":["import { useState } from 'react';\n\nimport type { HookTarget } from '@/utils/helpers';\n\nimport { isTarget } from '@/utils/helpers';\n\nimport type { StateRef } from '../useRefState/useRefState';\n\nimport { useIsomorphicLayoutEffect } from '../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect';\nimport { useRefState } from '../useRefState/useRefState';\n\n/** The size value type */\nexport interface UseSizeValue {\n /** The element's height */\n height: number;\n /** The element's width */\n width: number;\n}\n\n/** The use size return type */\nexport interface UseSizeReturn {\n /** The resize observer instance */\n observer?: ResizeObserver;\n /** The current size value */\n value: UseSizeValue;\n}\n\nexport interface UseSize {\n (target: HookTarget): UseSizeReturn;\n\n <Target extends Element>(\n target?: never\n ): {\n ref: StateRef<Target>;\n } & UseSizeReturn;\n}\n\n/**\n * @name useSize\n * @description - Hook that observes and returns the width and height of element\n * @category Elements\n * @usage low\n *\n * @overload\n * @param {HookTarget} target The target element to observe\n * @returns {UseSizeReturn} An object containing the resize observer, current width and height of the element\n *\n * @example\n * const { value, observer } = useSize(ref);\n *\n * @overload\n * @template Target The target element type\n * @returns { { ref: StateRef<Target> } & UseSizeReturn } An object containing the resize observer, current width and height of the element\n *\n * @example\n * const { ref, value, observer } = useSize();\n */\nexport const useSize = ((...params: any[]) => {\n const target = params[0] as HookTarget | undefined;\n const [size, setSize] = useState({ width: 0, height: 0 });\n const [observer, setObserver] = useState<ResizeObserver>();\n const internalRef = useRefState<Element>();\n\n useIsomorphicLayoutEffect(() => {\n const element = (target ? isTarget.getElement(target) : internalRef.current) as Element;\n\n if (!element) return;\n\n const { width, height } = element.getBoundingClientRect();\n setSize({\n width,\n height\n });\n\n const observer = new ResizeObserver(() => {\n const { width, height } = element.getBoundingClientRect();\n setSize({ width, height });\n });\n\n setObserver(observer);\n observer.observe(element);\n\n return () => {\n observer.disconnect();\n };\n }, [internalRef.state, target && isTarget.getRawElement(target)]);\n\n if (target) return { observer, value: size };\n return {\n observer,\n ref: internalRef,\n value: size\n };\n}) as UseSize;\n"],"
|
|
1
|
+
{"version":3,"file":"useSize.cjs","names":[],"sources":["../../../../src/hooks/useSize/useSize.ts"],"sourcesContent":["import { useState } from 'react';\n\nimport type { HookTarget } from '@/utils/helpers';\n\nimport { isTarget } from '@/utils/helpers';\n\nimport type { StateRef } from '../useRefState/useRefState';\n\nimport { useIsomorphicLayoutEffect } from '../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect';\nimport { useRefState } from '../useRefState/useRefState';\n\n/** The size value type */\nexport interface UseSizeValue {\n /** The element's height */\n height: number;\n /** The element's width */\n width: number;\n}\n\n/** The use size return type */\nexport interface UseSizeReturn {\n /** The resize observer instance */\n observer?: ResizeObserver;\n /** The current size value */\n value: UseSizeValue;\n}\n\nexport interface UseSize {\n (target: HookTarget): UseSizeReturn;\n\n <Target extends Element>(\n target?: never\n ): {\n ref: StateRef<Target>;\n } & UseSizeReturn;\n}\n\n/**\n * @name useSize\n * @description - Hook that observes and returns the width and height of element\n * @category Elements\n * @usage low\n *\n * @overload\n * @param {HookTarget} target The target element to observe\n * @returns {UseSizeReturn} An object containing the resize observer, current width and height of the element\n *\n * @example\n * const { value, observer } = useSize(ref);\n *\n * @overload\n * @template Target The target element type\n * @returns { { ref: StateRef<Target> } & UseSizeReturn } An object containing the resize observer, current width and height of the element\n *\n * @example\n * const { ref, value, observer } = useSize();\n */\nexport const useSize = ((...params: any[]) => {\n const target = params[0] as HookTarget | undefined;\n const [size, setSize] = useState({ width: 0, height: 0 });\n const [observer, setObserver] = useState<ResizeObserver>();\n const internalRef = useRefState<Element>();\n\n useIsomorphicLayoutEffect(() => {\n const element = (target ? isTarget.getElement(target) : internalRef.current) as Element;\n\n if (!element) return;\n\n const { width, height } = element.getBoundingClientRect();\n setSize({\n width,\n height\n });\n\n const observer = new ResizeObserver(() => {\n const { width, height } = element.getBoundingClientRect();\n setSize({ width, height });\n });\n\n setObserver(observer);\n observer.observe(element);\n\n return () => {\n observer.disconnect();\n };\n }, [internalRef.state, target && isTarget.getRawElement(target)]);\n\n if (target) return { observer, value: size };\n return {\n observer,\n ref: internalRef,\n value: size\n };\n}) as UseSize;\n"],"mappings":"+OAyDA,IAAa,IAAY,GAAG,IAAkB,CAC5C,IAAM,EAAS,EAAO,GAChB,CAAC,EAAM,IAAA,EAAA,EAAA,UAAoB,CAAE,MAAO,EAAG,OAAQ,EAAG,CAAC,CACnD,CAAC,EAAU,IAAA,EAAA,EAAA,WAAyC,CACpD,EAAc,EAAA,aAAsB,CA2B1C,OAzBA,EAAA,8BAAgC,CAC9B,IAAM,EAAW,EAAS,EAAA,SAAS,WAAW,EAAO,CAAG,EAAY,QAEpE,GAAI,CAAC,EAAS,OAEd,GAAM,CAAE,QAAO,UAAW,EAAQ,uBAAuB,CACzD,EAAQ,CACN,QACA,SACD,CAAC,CAEF,IAAM,EAAW,IAAI,mBAAqB,CACxC,GAAM,CAAE,QAAO,UAAW,EAAQ,uBAAuB,CACzD,EAAQ,CAAE,QAAO,SAAQ,CAAC,EAC1B,CAKF,OAHA,EAAY,EAAS,CACrB,EAAS,QAAQ,EAAQ,KAEZ,CACX,EAAS,YAAY,GAEtB,CAAC,EAAY,MAAO,GAAU,EAAA,SAAS,cAAc,EAAO,CAAC,CAAC,CAE7D,EAAe,CAAE,WAAU,MAAO,EAAM,CACrC,CACL,WACA,IAAK,EACL,MAAO,EACR"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=useSpeechRecognition.cjs.map
|
|
1
|
+
require(`../../_virtual/_rolldown/runtime.cjs`);let e=require(`react`);var t=()=>window?.SpeechRecognition??window?.webkitSpeechRecognition,n=(n={})=>{let r=typeof window<`u`&&!!t(),{continuous:i=!1,interimResults:a=!1,language:o=`en-US`,grammars:s,maxAlternatives:c=1,onStart:l,onEnd:u,onError:d,onResult:f}=n,[p,m]=(0,e.useState)(!1),[h,g]=(0,e.useState)(``),[_,v]=(0,e.useState)(!1),[y,b]=(0,e.useState)(null),[x]=(0,e.useState)(()=>{if(!r)return;let e=new(t());return e.continuous=i,s&&(e.grammars=s),e.interimResults=a,e.lang=o,e.maxAlternatives=c,e.onstart=()=>{m(!0),v(!1),l?.()},e.onerror=e=>{b(e),m(!1),d?.(e)},e.onresult=e=>{let{transcript:t}=e.results[e.resultIndex][0];m(!1),g(t),b(null),f?.(e)},e.onend=()=>{m(!1),u?.(),e.lang=o},e});(0,e.useEffect)(()=>()=>x?.stop(),[]);let S=()=>x?.start(),C=()=>x?.stop();return{supported:r,transcript:h,recognition:x,final:_,listening:p,error:y,start:S,stop:C,toggle:(e=!p)=>e?S():C()}};exports.getSpeechRecognition=t,exports.useSpeechRecognition=n;
|
|
2
|
+
//# sourceMappingURL=useSpeechRecognition.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSpeechRecognition.cjs","sources":["../../../../src/hooks/useSpeechRecognition/useSpeechRecognition.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\n/** The use speech recognition hook options type */\ninterface UseSpeechRecognitionOptions {\n /** If true, recognition continues even after pauses in speech. Default is false */\n continuous?: SpeechRecognition['continuous'];\n /** A list of grammar rules */\n grammars?: SpeechRecognition['grammars'];\n /** If true, interim (non-final) results are provided as the user speaks */\n interimResults?: SpeechRecognition['interimResults'];\n /** The language in which recognition should occur. Must be a valid BCP 47 language tag (e.g., \"en-US\", \"ru-RU\") */\n language?: SpeechRecognition['lang'];\n /** The maximum number of alternative transcripts returned for a given recognition result. Must be a positive integer */\n maxAlternatives?: SpeechRecognition['maxAlternatives'];\n /** Callback invoked when speech recognition ends */\n onEnd?: () => void;\n /** Callback invoked when an error occurs during recognition */\n onError?: (error: SpeechRecognitionErrorEvent) => void;\n /** Callback invoked when recognition produces a result */\n onResult?: (event: SpeechRecognitionEvent) => void;\n /** Callback invoked when speech recognition starts */\n onStart?: () => void;\n}\n\n/** The return type of the useSpeechRecognition hook. */\ninterface UseSpeechRecognitionReturn {\n /** The error state */\n error: SpeechRecognitionErrorEvent | null;\n /** The final transcript */\n final: boolean;\n /** Whether the hook is currently listening for speech */\n listening: boolean;\n /** The speech recognition instance */\n recognition?: SpeechRecognition;\n /** Whether the current browser supports the Web Speech API */\n supported: boolean;\n /** The current transcript */\n transcript: string;\n /** Begins speech recognition */\n start: () => void;\n /** Ends speech recognition, finalizing results */\n stop: () => void;\n /** Toggles the listening state */\n toggle: (value?: boolean) => void;\n}\n\nexport const getSpeechRecognition = () =>\n window?.SpeechRecognition ?? window?.webkitSpeechRecognition;\n\n/**\n * @name useSpeechRecognition\n * @description - Hook that provides a streamlined interface for incorporating speech-to-text functionality\n * @category Browser\n * @usage low\n *\n * @browserapi window.SpeechRecognition https://developer.mozilla.org/en-US/docs/Web/API/SpeechRecognition\n *\n * @param {boolean} [options.continuous=false] Whether recognition should continue after pauses\n * @param {boolean} [options.interimResults=false] Whether interim results should be provided\n * @param {string} [options.language=\"en-US\"] The language for recognition, as a valid BCP 47 tag\n * @param {number} [options.maxAlternatives=1] The maximum number of alternative transcripts to return\n * @param {SpeechGrammarList} [options.grammars] A list of grammar rules\n * @param {() => void} [options.onStart] Callback invoked when speech recognition starts\n * @param {() => void} [options.onEnd] Callback invoked when speech recognition ends\n * @param {(error: SpeechRecognitionErrorEvent) => void} [options.onError] Callback invoked when an error occurs during recognition\n * @param {(event: SpeechRecognitionEvent) => void} [options.onResult] Callback invoked when recognition produces a result\n * @returns {UseSpeechRecognitionReturn} An object containing the speech recognition functionality\n *\n * @example\n * const { supported, value, recognition, listening, error, start, stop, toggle } = useSpeechRecognition();\n */\nexport const useSpeechRecognition = (\n options: UseSpeechRecognitionOptions = {}\n): UseSpeechRecognitionReturn => {\n const supported = typeof window !== 'undefined' && !!getSpeechRecognition();\n\n const {\n continuous = false,\n interimResults = false,\n language = 'en-US',\n grammars,\n maxAlternatives = 1,\n onStart,\n onEnd,\n onError,\n onResult\n } = options;\n\n const [listening, setListening] = useState(false);\n const [transcript, setTranscript] = useState('');\n const [final, setFinal] = useState(false);\n const [error, setError] = useState<SpeechRecognitionErrorEvent | null>(null);\n const [recognition] = useState<SpeechRecognition | undefined>(() => {\n if (!supported) return undefined;\n\n const SpeechRecognition = getSpeechRecognition();\n const speechRecognition = new SpeechRecognition();\n\n speechRecognition.continuous = continuous;\n if (grammars) speechRecognition.grammars = grammars;\n speechRecognition.interimResults = interimResults;\n speechRecognition.lang = language;\n speechRecognition.maxAlternatives = maxAlternatives;\n\n speechRecognition.onstart = () => {\n setListening(true);\n setFinal(false);\n onStart?.();\n };\n speechRecognition.onerror = (event) => {\n setError(event);\n setListening(false);\n onError?.(event);\n };\n speechRecognition.onresult = (event) => {\n const currentResult = event.results[event.resultIndex];\n const { transcript } = currentResult[0];\n\n setListening(false);\n setTranscript(transcript);\n setError(null);\n onResult?.(event);\n };\n speechRecognition.onend = () => {\n setListening(false);\n onEnd?.();\n speechRecognition.lang = language;\n };\n\n return speechRecognition;\n });\n\n useEffect(() => () => recognition?.stop(), []);\n\n const start = () => recognition?.start();\n const stop = () => recognition?.stop();\n\n const toggle = (value = !listening) => {\n if (value) return start();\n return stop();\n };\n\n return {\n supported,\n transcript,\n recognition,\n final,\n listening,\n error,\n start,\n stop,\n toggle\n };\n};\n"],"
|
|
1
|
+
{"version":3,"file":"useSpeechRecognition.cjs","names":[],"sources":["../../../../src/hooks/useSpeechRecognition/useSpeechRecognition.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\n/** The use speech recognition hook options type */\ninterface UseSpeechRecognitionOptions {\n /** If true, recognition continues even after pauses in speech. Default is false */\n continuous?: SpeechRecognition['continuous'];\n /** A list of grammar rules */\n grammars?: SpeechRecognition['grammars'];\n /** If true, interim (non-final) results are provided as the user speaks */\n interimResults?: SpeechRecognition['interimResults'];\n /** The language in which recognition should occur. Must be a valid BCP 47 language tag (e.g., \"en-US\", \"ru-RU\") */\n language?: SpeechRecognition['lang'];\n /** The maximum number of alternative transcripts returned for a given recognition result. Must be a positive integer */\n maxAlternatives?: SpeechRecognition['maxAlternatives'];\n /** Callback invoked when speech recognition ends */\n onEnd?: () => void;\n /** Callback invoked when an error occurs during recognition */\n onError?: (error: SpeechRecognitionErrorEvent) => void;\n /** Callback invoked when recognition produces a result */\n onResult?: (event: SpeechRecognitionEvent) => void;\n /** Callback invoked when speech recognition starts */\n onStart?: () => void;\n}\n\n/** The return type of the useSpeechRecognition hook. */\ninterface UseSpeechRecognitionReturn {\n /** The error state */\n error: SpeechRecognitionErrorEvent | null;\n /** The final transcript */\n final: boolean;\n /** Whether the hook is currently listening for speech */\n listening: boolean;\n /** The speech recognition instance */\n recognition?: SpeechRecognition;\n /** Whether the current browser supports the Web Speech API */\n supported: boolean;\n /** The current transcript */\n transcript: string;\n /** Begins speech recognition */\n start: () => void;\n /** Ends speech recognition, finalizing results */\n stop: () => void;\n /** Toggles the listening state */\n toggle: (value?: boolean) => void;\n}\n\nexport const getSpeechRecognition = () =>\n window?.SpeechRecognition ?? window?.webkitSpeechRecognition;\n\n/**\n * @name useSpeechRecognition\n * @description - Hook that provides a streamlined interface for incorporating speech-to-text functionality\n * @category Browser\n * @usage low\n *\n * @browserapi window.SpeechRecognition https://developer.mozilla.org/en-US/docs/Web/API/SpeechRecognition\n *\n * @param {boolean} [options.continuous=false] Whether recognition should continue after pauses\n * @param {boolean} [options.interimResults=false] Whether interim results should be provided\n * @param {string} [options.language=\"en-US\"] The language for recognition, as a valid BCP 47 tag\n * @param {number} [options.maxAlternatives=1] The maximum number of alternative transcripts to return\n * @param {SpeechGrammarList} [options.grammars] A list of grammar rules\n * @param {() => void} [options.onStart] Callback invoked when speech recognition starts\n * @param {() => void} [options.onEnd] Callback invoked when speech recognition ends\n * @param {(error: SpeechRecognitionErrorEvent) => void} [options.onError] Callback invoked when an error occurs during recognition\n * @param {(event: SpeechRecognitionEvent) => void} [options.onResult] Callback invoked when recognition produces a result\n * @returns {UseSpeechRecognitionReturn} An object containing the speech recognition functionality\n *\n * @example\n * const { supported, value, recognition, listening, error, start, stop, toggle } = useSpeechRecognition();\n */\nexport const useSpeechRecognition = (\n options: UseSpeechRecognitionOptions = {}\n): UseSpeechRecognitionReturn => {\n const supported = typeof window !== 'undefined' && !!getSpeechRecognition();\n\n const {\n continuous = false,\n interimResults = false,\n language = 'en-US',\n grammars,\n maxAlternatives = 1,\n onStart,\n onEnd,\n onError,\n onResult\n } = options;\n\n const [listening, setListening] = useState(false);\n const [transcript, setTranscript] = useState('');\n const [final, setFinal] = useState(false);\n const [error, setError] = useState<SpeechRecognitionErrorEvent | null>(null);\n const [recognition] = useState<SpeechRecognition | undefined>(() => {\n if (!supported) return undefined;\n\n const SpeechRecognition = getSpeechRecognition();\n const speechRecognition = new SpeechRecognition();\n\n speechRecognition.continuous = continuous;\n if (grammars) speechRecognition.grammars = grammars;\n speechRecognition.interimResults = interimResults;\n speechRecognition.lang = language;\n speechRecognition.maxAlternatives = maxAlternatives;\n\n speechRecognition.onstart = () => {\n setListening(true);\n setFinal(false);\n onStart?.();\n };\n speechRecognition.onerror = (event) => {\n setError(event);\n setListening(false);\n onError?.(event);\n };\n speechRecognition.onresult = (event) => {\n const currentResult = event.results[event.resultIndex];\n const { transcript } = currentResult[0];\n\n setListening(false);\n setTranscript(transcript);\n setError(null);\n onResult?.(event);\n };\n speechRecognition.onend = () => {\n setListening(false);\n onEnd?.();\n speechRecognition.lang = language;\n };\n\n return speechRecognition;\n });\n\n useEffect(() => () => recognition?.stop(), []);\n\n const start = () => recognition?.start();\n const stop = () => recognition?.stop();\n\n const toggle = (value = !listening) => {\n if (value) return start();\n return stop();\n };\n\n return {\n supported,\n transcript,\n recognition,\n final,\n listening,\n error,\n start,\n stop,\n toggle\n };\n};\n"],"mappings":"uEA8CA,IAAa,MACX,QAAQ,mBAAqB,QAAQ,wBAwB1B,GACX,EAAuC,EAAE,GACV,CAC/B,IAAM,EAAY,OAAO,OAAW,KAAe,CAAC,CAAC,GAAsB,CAErE,CACJ,aAAa,GACb,iBAAiB,GACjB,WAAW,QACX,WACA,kBAAkB,EAClB,UACA,QACA,UACA,YACE,EAEE,CAAC,EAAW,IAAA,EAAA,EAAA,UAAyB,GAAM,CAC3C,CAAC,EAAY,IAAA,EAAA,EAAA,UAA0B,GAAG,CAC1C,CAAC,EAAO,IAAA,EAAA,EAAA,UAAqB,GAAM,CACnC,CAAC,EAAO,IAAA,EAAA,EAAA,UAAyD,KAAK,CACtE,CAAC,IAAA,EAAA,EAAA,cAA6D,CAClE,GAAI,CAAC,EAAW,OAGhB,IAAM,EAAoB,IADA,GAAsB,EAkChD,MA/BA,GAAkB,WAAa,EAC3B,IAAU,EAAkB,SAAW,GAC3C,EAAkB,eAAiB,EACnC,EAAkB,KAAO,EACzB,EAAkB,gBAAkB,EAEpC,EAAkB,YAAgB,CAChC,EAAa,GAAK,CAClB,EAAS,GAAM,CACf,KAAW,EAEb,EAAkB,QAAW,GAAU,CACrC,EAAS,EAAM,CACf,EAAa,GAAM,CACnB,IAAU,EAAM,EAElB,EAAkB,SAAY,GAAU,CAEtC,GAAM,CAAE,cADc,EAAM,QAAQ,EAAM,aACL,GAErC,EAAa,GAAM,CACnB,EAAc,EAAW,CACzB,EAAS,KAAK,CACd,IAAW,EAAM,EAEnB,EAAkB,UAAc,CAC9B,EAAa,GAAM,CACnB,KAAS,CACT,EAAkB,KAAO,GAGpB,GACP,EAEF,EAAA,EAAA,mBAAsB,GAAa,MAAM,CAAE,EAAE,CAAC,CAE9C,IAAM,MAAc,GAAa,OAAO,CAClC,MAAa,GAAa,MAAM,CAOtC,MAAO,CACL,YACA,aACA,cACA,QACA,YACA,QACA,QACA,OACA,QAdc,EAAQ,CAAC,IACnB,EAAc,GAAO,CAClB,GAAM,CAad"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=useSpeechSynthesis.cjs.map
|
|
1
|
+
require(`../../_virtual/_rolldown/runtime.cjs`);let e=require(`react`);var t=(t={})=>{let n=typeof window<`u`&&`speechSynthesis`in window&&!!window.speechSynthesis,{text:r=``,lang:i=`en-US`,pitch:a=1,rate:o=1,voice:s=null,volume:c=1}=t,[l,u]=(0,e.useState)(!1),[d,f]=(0,e.useState)(`init`),[p,m]=(0,e.useState)(),[h,g]=(0,e.useState)(),_=e=>{e.lang=i,e.pitch=a,e.rate=o,e.volume=c,e.voice=s,e.onstart=()=>{u(!0),f(`play`)},e.onpause=()=>{u(!1),f(`pause`)},e.onresume=()=>{u(!0),f(`play`)},e.onend=()=>{u(!1),f(`end`)},e.onerror=e=>{u(!1),m(e)}};return(0,e.useEffect)(()=>{if(!n)return;let e=new SpeechSynthesisUtterance(r);return _(e),g(e),()=>{window.speechSynthesis?.cancel()}},[r,i,a,o,c,s?.default,s?.lang,s?.localService,s?.name,s?.voiceURI]),{supported:n,playing:l,status:d,utterance:h,error:p,stop:()=>{n&&(window.speechSynthesis?.cancel(),u(!1))},toggle:(e=!l)=>{n&&(e?window.speechSynthesis?.resume():window.speechSynthesis?.pause(),u(e))},speak:e=>{if(n){if(e){let t=new SpeechSynthesisUtterance(e);g(t),_(t)}window.speechSynthesis?.cancel(),h&&window.speechSynthesis?.speak(h),u(!0)}},resume:()=>{u(!0),window.speechSynthesis?.resume()},pause:()=>{u(!1),window.speechSynthesis?.pause()}}};exports.useSpeechSynthesis=t;
|
|
2
|
+
//# sourceMappingURL=useSpeechSynthesis.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSpeechSynthesis.cjs","sources":["../../../../src/hooks/useSpeechSynthesis/useSpeechSynthesis.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\n/** The use speech synthesis status type */\nexport type UseSpeechSynthesisStatus = 'end' | 'init' | 'pause' | 'play';\n\n/** The use speech synthesis options type */\nexport interface UseSpeechSynthesisOptions {\n /** Language for SpeechSynthesis */\n lang?: string;\n /** Gets and sets the pitch at which the utterance will be spoken at. */\n pitch?: number;\n /** Gets and sets the speed at which the utterance will be spoken at. */\n rate?: number;\n /** The text to be spoken */\n text?: string;\n /** Gets and sets the voice that will be used to speak the utterance. */\n voice?: SpeechSynthesisVoice | null;\n /** Gets and sets the volume that the utterance will be spoken at. */\n volume?: number;\n}\n\n/** The use speech synthesis return type */\nexport interface UseSpeechSynthesisReturn {\n /** Any error that occurred during speech synthesis. */\n error: SpeechSynthesisErrorEvent | undefined;\n /** Indicates if speech is currently playing. */\n playing: boolean;\n /** The current status of speech synthesis. */\n status: UseSpeechSynthesisStatus;\n /** Indicates if the SpeechSynthesis API is supported in the current environment. */\n supported: boolean;\n /** The SpeechSynthesisUtterance instance. */\n utterance: SpeechSynthesisUtterance | undefined;\n /** Function to pause speech synthesis. */\n pause: () => void;\n /** Function to resume speech synthesis. */\n resume: () => void;\n /** Function to start speech synthesis. */\n speak: () => void;\n /** Function to stop speech synthesis. */\n stop: () => void;\n /** Function to toggle between play and pause. */\n toggle: (value?: boolean) => void;\n}\n\n/**\n * @name useSpeechSynthesis\n * @description - Hook that provides speech synthesis functionality\n * @category Browser\n * @usage low\n *\n * @browserapi SpeechSynthesis https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesis\n *\n * @params {string} [options.text] - The text to be spoken\n * @params {string} [options.lang] - The language to be spoken\n * @params {number} [options.pitch] - The pitch to be spoken\n * @params {number} [options.rate] - The rate to be spoken\n * @params {SpeechSynthesisVoice} [options.voice] - The voice to be spoken\n * @params {number} [options.volume] - The volume to be spoken\n * @returns {UseSpeechSynthesisReturn} An object containing the speech synthesis state and control methods\n *\n * @example\n * const { supported, playing, status, utterance, error, stop, toggle, speak, resume, pause } = useSpeechSynthesis();\n */\nexport const useSpeechSynthesis = (\n options: UseSpeechSynthesisOptions = {}\n): UseSpeechSynthesisReturn => {\n const supported =\n typeof window !== 'undefined' && 'speechSynthesis' in window && !!window.speechSynthesis;\n\n const { text = '', lang = 'en-US', pitch = 1, rate = 1, voice = null, volume = 1 } = options;\n\n const [playing, setPlaying] = useState(false);\n const [status, setStatus] = useState<UseSpeechSynthesisStatus>('init');\n const [error, setError] = useState<SpeechSynthesisErrorEvent>();\n\n const [utterance, setUtterance] = useState<SpeechSynthesisUtterance>();\n\n const bindSpeechSynthesisUtterance = (speechSynthesisUtterance: SpeechSynthesisUtterance) => {\n speechSynthesisUtterance.lang = lang;\n speechSynthesisUtterance.pitch = pitch;\n speechSynthesisUtterance.rate = rate;\n speechSynthesisUtterance.volume = volume;\n speechSynthesisUtterance.voice = voice;\n\n speechSynthesisUtterance.onstart = () => {\n setPlaying(true);\n setStatus('play');\n };\n\n speechSynthesisUtterance.onpause = () => {\n setPlaying(false);\n setStatus('pause');\n };\n\n speechSynthesisUtterance.onresume = () => {\n setPlaying(true);\n setStatus('play');\n };\n\n speechSynthesisUtterance.onend = () => {\n setPlaying(false);\n setStatus('end');\n };\n\n speechSynthesisUtterance.onerror = (event) => {\n setPlaying(false);\n setError(event);\n };\n };\n\n useEffect(() => {\n if (!supported) return;\n\n const speechSynthesisUtterance = new SpeechSynthesisUtterance(text);\n\n bindSpeechSynthesisUtterance(speechSynthesisUtterance);\n setUtterance(speechSynthesisUtterance);\n\n return () => {\n window.speechSynthesis?.cancel();\n };\n }, [\n text,\n lang,\n pitch,\n rate,\n volume,\n voice?.default,\n voice?.lang,\n voice?.localService,\n voice?.name,\n voice?.voiceURI\n ]);\n\n const speak = (text?: string) => {\n if (!supported) return;\n\n if (text) {\n const utterance = new SpeechSynthesisUtterance(text);\n setUtterance(utterance);\n bindSpeechSynthesisUtterance(utterance);\n }\n\n window.speechSynthesis?.cancel();\n if (utterance) window.speechSynthesis?.speak(utterance);\n setPlaying(true);\n };\n\n const stop = () => {\n if (!supported) return;\n\n window.speechSynthesis?.cancel();\n setPlaying(false);\n };\n\n const toggle = (value = !playing) => {\n if (!supported) return;\n\n if (value) {\n window.speechSynthesis?.resume();\n } else {\n window.speechSynthesis?.pause();\n }\n setPlaying(value);\n };\n\n const resume = () => {\n setPlaying(true);\n window.speechSynthesis?.resume();\n };\n\n const pause = () => {\n setPlaying(false);\n window.speechSynthesis?.pause();\n };\n\n return {\n supported,\n playing,\n status,\n utterance,\n error,\n stop,\n toggle,\n speak,\n resume,\n pause\n };\n};\n"],"
|
|
1
|
+
{"version":3,"file":"useSpeechSynthesis.cjs","names":[],"sources":["../../../../src/hooks/useSpeechSynthesis/useSpeechSynthesis.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\n/** The use speech synthesis status type */\nexport type UseSpeechSynthesisStatus = 'end' | 'init' | 'pause' | 'play';\n\n/** The use speech synthesis options type */\nexport interface UseSpeechSynthesisOptions {\n /** Language for SpeechSynthesis */\n lang?: string;\n /** Gets and sets the pitch at which the utterance will be spoken at. */\n pitch?: number;\n /** Gets and sets the speed at which the utterance will be spoken at. */\n rate?: number;\n /** The text to be spoken */\n text?: string;\n /** Gets and sets the voice that will be used to speak the utterance. */\n voice?: SpeechSynthesisVoice | null;\n /** Gets and sets the volume that the utterance will be spoken at. */\n volume?: number;\n}\n\n/** The use speech synthesis return type */\nexport interface UseSpeechSynthesisReturn {\n /** Any error that occurred during speech synthesis. */\n error: SpeechSynthesisErrorEvent | undefined;\n /** Indicates if speech is currently playing. */\n playing: boolean;\n /** The current status of speech synthesis. */\n status: UseSpeechSynthesisStatus;\n /** Indicates if the SpeechSynthesis API is supported in the current environment. */\n supported: boolean;\n /** The SpeechSynthesisUtterance instance. */\n utterance: SpeechSynthesisUtterance | undefined;\n /** Function to pause speech synthesis. */\n pause: () => void;\n /** Function to resume speech synthesis. */\n resume: () => void;\n /** Function to start speech synthesis. */\n speak: () => void;\n /** Function to stop speech synthesis. */\n stop: () => void;\n /** Function to toggle between play and pause. */\n toggle: (value?: boolean) => void;\n}\n\n/**\n * @name useSpeechSynthesis\n * @description - Hook that provides speech synthesis functionality\n * @category Browser\n * @usage low\n *\n * @browserapi SpeechSynthesis https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesis\n *\n * @params {string} [options.text] - The text to be spoken\n * @params {string} [options.lang] - The language to be spoken\n * @params {number} [options.pitch] - The pitch to be spoken\n * @params {number} [options.rate] - The rate to be spoken\n * @params {SpeechSynthesisVoice} [options.voice] - The voice to be spoken\n * @params {number} [options.volume] - The volume to be spoken\n * @returns {UseSpeechSynthesisReturn} An object containing the speech synthesis state and control methods\n *\n * @example\n * const { supported, playing, status, utterance, error, stop, toggle, speak, resume, pause } = useSpeechSynthesis();\n */\nexport const useSpeechSynthesis = (\n options: UseSpeechSynthesisOptions = {}\n): UseSpeechSynthesisReturn => {\n const supported =\n typeof window !== 'undefined' && 'speechSynthesis' in window && !!window.speechSynthesis;\n\n const { text = '', lang = 'en-US', pitch = 1, rate = 1, voice = null, volume = 1 } = options;\n\n const [playing, setPlaying] = useState(false);\n const [status, setStatus] = useState<UseSpeechSynthesisStatus>('init');\n const [error, setError] = useState<SpeechSynthesisErrorEvent>();\n\n const [utterance, setUtterance] = useState<SpeechSynthesisUtterance>();\n\n const bindSpeechSynthesisUtterance = (speechSynthesisUtterance: SpeechSynthesisUtterance) => {\n speechSynthesisUtterance.lang = lang;\n speechSynthesisUtterance.pitch = pitch;\n speechSynthesisUtterance.rate = rate;\n speechSynthesisUtterance.volume = volume;\n speechSynthesisUtterance.voice = voice;\n\n speechSynthesisUtterance.onstart = () => {\n setPlaying(true);\n setStatus('play');\n };\n\n speechSynthesisUtterance.onpause = () => {\n setPlaying(false);\n setStatus('pause');\n };\n\n speechSynthesisUtterance.onresume = () => {\n setPlaying(true);\n setStatus('play');\n };\n\n speechSynthesisUtterance.onend = () => {\n setPlaying(false);\n setStatus('end');\n };\n\n speechSynthesisUtterance.onerror = (event) => {\n setPlaying(false);\n setError(event);\n };\n };\n\n useEffect(() => {\n if (!supported) return;\n\n const speechSynthesisUtterance = new SpeechSynthesisUtterance(text);\n\n bindSpeechSynthesisUtterance(speechSynthesisUtterance);\n setUtterance(speechSynthesisUtterance);\n\n return () => {\n window.speechSynthesis?.cancel();\n };\n }, [\n text,\n lang,\n pitch,\n rate,\n volume,\n voice?.default,\n voice?.lang,\n voice?.localService,\n voice?.name,\n voice?.voiceURI\n ]);\n\n const speak = (text?: string) => {\n if (!supported) return;\n\n if (text) {\n const utterance = new SpeechSynthesisUtterance(text);\n setUtterance(utterance);\n bindSpeechSynthesisUtterance(utterance);\n }\n\n window.speechSynthesis?.cancel();\n if (utterance) window.speechSynthesis?.speak(utterance);\n setPlaying(true);\n };\n\n const stop = () => {\n if (!supported) return;\n\n window.speechSynthesis?.cancel();\n setPlaying(false);\n };\n\n const toggle = (value = !playing) => {\n if (!supported) return;\n\n if (value) {\n window.speechSynthesis?.resume();\n } else {\n window.speechSynthesis?.pause();\n }\n setPlaying(value);\n };\n\n const resume = () => {\n setPlaying(true);\n window.speechSynthesis?.resume();\n };\n\n const pause = () => {\n setPlaying(false);\n window.speechSynthesis?.pause();\n };\n\n return {\n supported,\n playing,\n status,\n utterance,\n error,\n stop,\n toggle,\n speak,\n resume,\n pause\n };\n};\n"],"mappings":"uEAgEA,IAAa,GACX,EAAqC,EAAE,GACV,CAC7B,IAAM,EACJ,OAAO,OAAW,KAAe,oBAAqB,QAAU,CAAC,CAAC,OAAO,gBAErE,CAAE,OAAO,GAAI,OAAO,QAAS,QAAQ,EAAG,OAAO,EAAG,QAAQ,KAAM,SAAS,GAAM,EAE/E,CAAC,EAAS,IAAA,EAAA,EAAA,UAAuB,GAAM,CACvC,CAAC,EAAQ,IAAA,EAAA,EAAA,UAAgD,OAAO,CAChE,CAAC,EAAO,IAAA,EAAA,EAAA,WAAiD,CAEzD,CAAC,EAAW,IAAA,EAAA,EAAA,WAAoD,CAEhE,EAAgC,GAAuD,CAC3F,EAAyB,KAAO,EAChC,EAAyB,MAAQ,EACjC,EAAyB,KAAO,EAChC,EAAyB,OAAS,EAClC,EAAyB,MAAQ,EAEjC,EAAyB,YAAgB,CACvC,EAAW,GAAK,CAChB,EAAU,OAAO,EAGnB,EAAyB,YAAgB,CACvC,EAAW,GAAM,CACjB,EAAU,QAAQ,EAGpB,EAAyB,aAAiB,CACxC,EAAW,GAAK,CAChB,EAAU,OAAO,EAGnB,EAAyB,UAAc,CACrC,EAAW,GAAM,CACjB,EAAU,MAAM,EAGlB,EAAyB,QAAW,GAAU,CAC5C,EAAW,GAAM,CACjB,EAAS,EAAM,GAsEnB,OAlEA,EAAA,EAAA,eAAgB,CACd,GAAI,CAAC,EAAW,OAEhB,IAAM,EAA2B,IAAI,yBAAyB,EAAK,CAKnE,OAHA,EAA6B,EAAyB,CACtD,EAAa,EAAyB,KAEzB,CACX,OAAO,iBAAiB,QAAQ,GAEjC,CACD,EACA,EACA,EACA,EACA,EACA,GAAO,QACP,GAAO,KACP,GAAO,aACP,GAAO,KACP,GAAO,SACR,CAAC,CA4CK,CACL,YACA,UACA,SACA,YACA,QACA,SAlCiB,CACZ,IAEL,OAAO,iBAAiB,QAAQ,CAChC,EAAW,GAAM,GA+BjB,QA5Bc,EAAQ,CAAC,IAAY,CAC9B,IAED,EACF,OAAO,iBAAiB,QAAQ,CAEhC,OAAO,iBAAiB,OAAO,CAEjC,EAAW,EAAM,GAqBjB,MAlDa,GAAkB,CAC1B,KAEL,IAAI,EAAM,CACR,IAAM,EAAY,IAAI,yBAAyB,EAAK,CACpD,EAAa,EAAU,CACvB,EAA6B,EAAU,CAGzC,OAAO,iBAAiB,QAAQ,CAC5B,GAAW,OAAO,iBAAiB,MAAM,EAAU,CACvD,EAAW,GAAK,GAwChB,WAnBmB,CACnB,EAAW,GAAK,CAChB,OAAO,iBAAiB,QAAQ,EAkBhC,UAfkB,CAClB,EAAW,GAAM,CACjB,OAAO,iBAAiB,OAAO,EAchC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=useStateHistory.cjs.map
|
|
1
|
+
require(`../../_virtual/_rolldown/runtime.cjs`);let e=require(`react`);var t=(e,t)=>{switch(t.type){case`SET`:{let{value:n,capacity:r}=t.payload,i=[...e.history.slice(0,e.currentIndex+1),n];i.length>r&&i.shift();let a=[e.history,...e.undoStack];return a.length>r&&a.pop(),{history:i,currentIndex:i.length-1,undoStack:a,redoStack:[]}}case`UNDO`:return e.undoStack.length===0?e:{history:e.undoStack[0],currentIndex:e.undoStack[0].length-1,undoStack:e.undoStack.slice(1),redoStack:[e.history,...e.redoStack]};case`REDO`:return e.redoStack.length===0?e:{history:e.redoStack[0],currentIndex:e.redoStack[0].length-1,undoStack:[e.history,...e.undoStack],redoStack:e.redoStack.slice(1)};case`BACK`:{let{steps:n}=t.payload;return{...e,currentIndex:Math.max(0,e.currentIndex-n)}}case`FORWARD`:{let{steps:n}=t.payload;return{...e,currentIndex:Math.min(e.currentIndex+n,e.history.length-1)}}case`RESET`:{let{initialValue:n,capacity:r}=t.payload;if(e.history.length===1)return e;let i=[e.history,...e.undoStack];return i.length>r&&i.pop(),{history:[n],currentIndex:0,undoStack:i,redoStack:[]}}default:throw Error(`Unsupported action type`)}},n=(n,r=10)=>{let[i,a]=(0,e.useReducer)(t,{history:[n],currentIndex:0,undoStack:[],redoStack:[]}),o=i.history[i.currentIndex],s=i.undoStack.length>0,c=i.redoStack.length>0;return{history:i.history,value:o,set:e=>a({type:`SET`,payload:{value:e,capacity:r}}),index:i.currentIndex,back:(e=1)=>a({type:`BACK`,payload:{steps:e}}),forward:(e=1)=>a({type:`FORWARD`,payload:{steps:e}}),reset:()=>a({type:`RESET`,payload:{initialValue:n,capacity:r}}),undo:()=>a({type:`UNDO`}),redo:()=>a({type:`REDO`}),canUndo:s,canRedo:c}};exports.stateHistoryReducer=t,exports.useStateHistory=n;
|
|
2
|
+
//# sourceMappingURL=useStateHistory.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStateHistory.cjs","sources":["../../../../src/hooks/useStateHistory/useStateHistory.ts"],"sourcesContent":["import { useReducer } from 'react';\n\n/** The use state history hook return type */\ninterface UseStateHistoryReturn<Value> {\n /** True if a redo operation can be performed */\n canRedo: boolean;\n /** True if an undo operation can be performed */\n canUndo: boolean;\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 /** Redo the last change */\n redo: () => 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\nexport type StateHistoryAction<Value> =\n | { type: 'BACK'; payload: { steps: number } }\n | { type: 'FORWARD'; payload: { steps: number } }\n | { type: 'REDO' }\n | { type: 'RESET'; payload: { initialValue: Value; capacity: number } }\n | { type: 'SET'; payload: { value: Value; capacity: number } }\n | { type: 'UNDO' };\n\nexport interface StateHistory<Value> {\n currentIndex: number;\n history: Value[];\n redoStack: Value[][];\n undoStack: Value[][];\n}\n\nexport const stateHistoryReducer = <Value>(\n state: StateHistory<Value>,\n action: StateHistoryAction<Value>\n): StateHistory<Value> => {\n switch (action.type) {\n case 'SET': {\n const { value, capacity } = action.payload;\n\n const newHistory = [...state.history.slice(0, state.currentIndex + 1), value];\n if (newHistory.length > capacity) {\n newHistory.shift();\n }\n\n const newUndoStack = [state.history, ...state.undoStack];\n if (newUndoStack.length > capacity) {\n newUndoStack.pop();\n }\n\n return {\n history: newHistory,\n currentIndex: newHistory.length - 1,\n undoStack: newUndoStack,\n redoStack: []\n };\n }\n\n case 'UNDO': {\n if (state.undoStack.length === 0) return state;\n\n return {\n history: state.undoStack[0],\n currentIndex: state.undoStack[0].length - 1,\n undoStack: state.undoStack.slice(1),\n redoStack: [state.history, ...state.redoStack]\n };\n }\n\n case 'REDO': {\n if (state.redoStack.length === 0) return state;\n\n return {\n history: state.redoStack[0],\n currentIndex: state.redoStack[0].length - 1,\n undoStack: [state.history, ...state.undoStack],\n redoStack: state.redoStack.slice(1)\n };\n }\n\n case 'BACK': {\n const { steps } = action.payload;\n return {\n ...state,\n currentIndex: Math.max(0, state.currentIndex - steps)\n };\n }\n\n case 'FORWARD': {\n const { steps } = action.payload;\n return {\n ...state,\n currentIndex: Math.min(state.currentIndex + steps, state.history.length - 1)\n };\n }\n\n case 'RESET': {\n const { initialValue, capacity } = action.payload;\n if (state.history.length === 1) return state;\n\n const newUndoStack = [state.history, ...state.undoStack];\n if (newUndoStack.length > capacity) {\n newUndoStack.pop();\n }\n\n return {\n history: [initialValue],\n currentIndex: 0,\n undoStack: newUndoStack,\n redoStack: []\n };\n }\n\n default:\n throw new Error('Unsupported action type');\n }\n};\n\n/**\n * @name useStateHistory\n * @description - Hook that manages state with history functionality\n * @category State\n * @usage medium\n *\n * @param {Value} initialValue - The initial value to start the history with\n * @param {number} [capacity=10] - Maximum number of history entries and undo actions 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, redo, canUndo, canRedo } = useStateHistory(0);\n */\nexport const useStateHistory = <Value>(\n initialValue: Value,\n capacity = 10\n): UseStateHistoryReturn<Value> => {\n const [state, dispatch] = useReducer(stateHistoryReducer<Value>, {\n history: [initialValue],\n currentIndex: 0,\n undoStack: [],\n redoStack: []\n });\n\n const value = state.history[state.currentIndex];\n const canUndo = state.undoStack.length > 0;\n const canRedo = state.redoStack.length > 0;\n\n const set = (value: Value) =>\n dispatch({\n type: 'SET',\n payload: { value, capacity }\n });\n\n const undo = () => dispatch({ type: 'UNDO' });\n\n const redo = () => dispatch({ type: 'REDO' });\n\n const back = (steps = 1) => dispatch({ type: 'BACK', payload: { steps } });\n\n const forward = (steps = 1) => dispatch({ type: 'FORWARD', payload: { steps } });\n\n const reset = () => dispatch({ type: 'RESET', payload: { initialValue, capacity } });\n\n return {\n history: state.history,\n value,\n set,\n index: state.currentIndex,\n back,\n forward,\n reset,\n undo,\n redo,\n canUndo,\n canRedo\n };\n};\n"],"
|
|
1
|
+
{"version":3,"file":"useStateHistory.cjs","names":[],"sources":["../../../../src/hooks/useStateHistory/useStateHistory.ts"],"sourcesContent":["import { useReducer } from 'react';\n\n/** The use state history hook return type */\ninterface UseStateHistoryReturn<Value> {\n /** True if a redo operation can be performed */\n canRedo: boolean;\n /** True if an undo operation can be performed */\n canUndo: boolean;\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 /** Redo the last change */\n redo: () => 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\nexport type StateHistoryAction<Value> =\n | { type: 'BACK'; payload: { steps: number } }\n | { type: 'FORWARD'; payload: { steps: number } }\n | { type: 'REDO' }\n | { type: 'RESET'; payload: { initialValue: Value; capacity: number } }\n | { type: 'SET'; payload: { value: Value; capacity: number } }\n | { type: 'UNDO' };\n\nexport interface StateHistory<Value> {\n currentIndex: number;\n history: Value[];\n redoStack: Value[][];\n undoStack: Value[][];\n}\n\nexport const stateHistoryReducer = <Value>(\n state: StateHistory<Value>,\n action: StateHistoryAction<Value>\n): StateHistory<Value> => {\n switch (action.type) {\n case 'SET': {\n const { value, capacity } = action.payload;\n\n const newHistory = [...state.history.slice(0, state.currentIndex + 1), value];\n if (newHistory.length > capacity) {\n newHistory.shift();\n }\n\n const newUndoStack = [state.history, ...state.undoStack];\n if (newUndoStack.length > capacity) {\n newUndoStack.pop();\n }\n\n return {\n history: newHistory,\n currentIndex: newHistory.length - 1,\n undoStack: newUndoStack,\n redoStack: []\n };\n }\n\n case 'UNDO': {\n if (state.undoStack.length === 0) return state;\n\n return {\n history: state.undoStack[0],\n currentIndex: state.undoStack[0].length - 1,\n undoStack: state.undoStack.slice(1),\n redoStack: [state.history, ...state.redoStack]\n };\n }\n\n case 'REDO': {\n if (state.redoStack.length === 0) return state;\n\n return {\n history: state.redoStack[0],\n currentIndex: state.redoStack[0].length - 1,\n undoStack: [state.history, ...state.undoStack],\n redoStack: state.redoStack.slice(1)\n };\n }\n\n case 'BACK': {\n const { steps } = action.payload;\n return {\n ...state,\n currentIndex: Math.max(0, state.currentIndex - steps)\n };\n }\n\n case 'FORWARD': {\n const { steps } = action.payload;\n return {\n ...state,\n currentIndex: Math.min(state.currentIndex + steps, state.history.length - 1)\n };\n }\n\n case 'RESET': {\n const { initialValue, capacity } = action.payload;\n if (state.history.length === 1) return state;\n\n const newUndoStack = [state.history, ...state.undoStack];\n if (newUndoStack.length > capacity) {\n newUndoStack.pop();\n }\n\n return {\n history: [initialValue],\n currentIndex: 0,\n undoStack: newUndoStack,\n redoStack: []\n };\n }\n\n default:\n throw new Error('Unsupported action type');\n }\n};\n\n/**\n * @name useStateHistory\n * @description - Hook that manages state with history functionality\n * @category State\n * @usage medium\n *\n * @param {Value} initialValue - The initial value to start the history with\n * @param {number} [capacity=10] - Maximum number of history entries and undo actions 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, redo, canUndo, canRedo } = useStateHistory(0);\n */\nexport const useStateHistory = <Value>(\n initialValue: Value,\n capacity = 10\n): UseStateHistoryReturn<Value> => {\n const [state, dispatch] = useReducer(stateHistoryReducer<Value>, {\n history: [initialValue],\n currentIndex: 0,\n undoStack: [],\n redoStack: []\n });\n\n const value = state.history[state.currentIndex];\n const canUndo = state.undoStack.length > 0;\n const canRedo = state.redoStack.length > 0;\n\n const set = (value: Value) =>\n dispatch({\n type: 'SET',\n payload: { value, capacity }\n });\n\n const undo = () => dispatch({ type: 'UNDO' });\n\n const redo = () => dispatch({ type: 'REDO' });\n\n const back = (steps = 1) => dispatch({ type: 'BACK', payload: { steps } });\n\n const forward = (steps = 1) => dispatch({ type: 'FORWARD', payload: { steps } });\n\n const reset = () => dispatch({ type: 'RESET', payload: { initialValue, capacity } });\n\n return {\n history: state.history,\n value,\n set,\n index: state.currentIndex,\n back,\n forward,\n reset,\n undo,\n redo,\n canUndo,\n canRedo\n };\n};\n"],"mappings":"uEA2CA,IAAa,GACX,EACA,IACwB,CACxB,OAAQ,EAAO,KAAf,CACE,IAAK,MAAO,CACV,GAAM,CAAE,QAAO,YAAa,EAAO,QAE7B,EAAa,CAAC,GAAG,EAAM,QAAQ,MAAM,EAAG,EAAM,aAAe,EAAE,CAAE,EAAM,CACzE,EAAW,OAAS,GACtB,EAAW,OAAO,CAGpB,IAAM,EAAe,CAAC,EAAM,QAAS,GAAG,EAAM,UAAU,CAKxD,OAJI,EAAa,OAAS,GACxB,EAAa,KAAK,CAGb,CACL,QAAS,EACT,aAAc,EAAW,OAAS,EAClC,UAAW,EACX,UAAW,EAAE,CACd,CAGH,IAAK,OAGH,OAFI,EAAM,UAAU,SAAW,EAAU,EAElC,CACL,QAAS,EAAM,UAAU,GACzB,aAAc,EAAM,UAAU,GAAG,OAAS,EAC1C,UAAW,EAAM,UAAU,MAAM,EAAE,CACnC,UAAW,CAAC,EAAM,QAAS,GAAG,EAAM,UAAU,CAC/C,CAGH,IAAK,OAGH,OAFI,EAAM,UAAU,SAAW,EAAU,EAElC,CACL,QAAS,EAAM,UAAU,GACzB,aAAc,EAAM,UAAU,GAAG,OAAS,EAC1C,UAAW,CAAC,EAAM,QAAS,GAAG,EAAM,UAAU,CAC9C,UAAW,EAAM,UAAU,MAAM,EAAE,CACpC,CAGH,IAAK,OAAQ,CACX,GAAM,CAAE,SAAU,EAAO,QACzB,MAAO,CACL,GAAG,EACH,aAAc,KAAK,IAAI,EAAG,EAAM,aAAe,EAAM,CACtD,CAGH,IAAK,UAAW,CACd,GAAM,CAAE,SAAU,EAAO,QACzB,MAAO,CACL,GAAG,EACH,aAAc,KAAK,IAAI,EAAM,aAAe,EAAO,EAAM,QAAQ,OAAS,EAAE,CAC7E,CAGH,IAAK,QAAS,CACZ,GAAM,CAAE,eAAc,YAAa,EAAO,QAC1C,GAAI,EAAM,QAAQ,SAAW,EAAG,OAAO,EAEvC,IAAM,EAAe,CAAC,EAAM,QAAS,GAAG,EAAM,UAAU,CAKxD,OAJI,EAAa,OAAS,GACxB,EAAa,KAAK,CAGb,CACL,QAAS,CAAC,EAAa,CACvB,aAAc,EACd,UAAW,EACX,UAAW,EAAE,CACd,CAGH,QACE,MAAU,MAAM,0BAA0B,GAiBnC,GACX,EACA,EAAW,KACsB,CACjC,GAAM,CAAC,EAAO,IAAA,EAAA,EAAA,YAAuB,EAA4B,CAC/D,QAAS,CAAC,EAAa,CACvB,aAAc,EACd,UAAW,EAAE,CACb,UAAW,EAAE,CACd,CAAC,CAEI,EAAQ,EAAM,QAAQ,EAAM,cAC5B,EAAU,EAAM,UAAU,OAAS,EACnC,EAAU,EAAM,UAAU,OAAS,EAkBzC,MAAO,CACL,QAAS,EAAM,QACf,QACA,IAnBW,GACX,EAAS,CACP,KAAM,MACN,QAAS,CAAE,QAAO,WAAU,CAC7B,CAAC,CAgBF,MAAO,EAAM,aACb,MAXY,EAAQ,IAAM,EAAS,CAAE,KAAM,OAAQ,QAAS,CAAE,QAAO,CAAE,CAAC,CAYxE,SAVe,EAAQ,IAAM,EAAS,CAAE,KAAM,UAAW,QAAS,CAAE,QAAO,CAAE,CAAC,CAW9E,UATkB,EAAS,CAAE,KAAM,QAAS,QAAS,CAAE,eAAc,WAAU,CAAE,CAAC,CAUlF,SAlBiB,EAAS,CAAE,KAAM,OAAQ,CAAC,CAmB3C,SAjBiB,EAAS,CAAE,KAAM,OAAQ,CAAC,CAkB3C,UACA,UACD"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=useStep.cjs.map
|
|
1
|
+
require(`../../_virtual/_rolldown/runtime.cjs`);let e=require(`react`);var t=1,n=n=>{let r=typeof n==`object`?n.max:n,i=typeof n==`object`?n.initial:t,a=(0,e.useRef)(i>r||i<t?t:i),[o,s]=(0,e.useState)(i),c=o===t,l=o===r;return{counts:r,currentStep:o,isFirst:c,isLast:l,next:()=>{l||s(e=>e+1)},back:()=>{c||s(e=>e-1)},reset:()=>s(a.current),set:e=>{if(e===`first`)return s(a.current);if(e===`last`||e>=r)return s(r);if(e<=t)return s(t);s(e)}}};exports.useStep=n;
|
|
2
|
+
//# sourceMappingURL=useStep.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStep.cjs","sources":["../../../../src/hooks/useStep/useStep.ts"],"sourcesContent":["import { useRef, useState } from 'react';\n\n/** The use step params type */\nexport interface UseStepParams {\n /** Initial value for step */\n initial: number;\n /** Maximum value for step */\n max: number;\n}\n\n/** The use step return type */\nexport interface UseStepReturn {\n /** Counts of steps */\n counts: number;\n /** Current value of step */\n currentStep: number;\n /** Boolean value if current step is first */\n isFirst: boolean;\n /** Boolean value if current step is last */\n isLast: boolean;\n /** Go to back step */\n back: () => void;\n /** Go to next step */\n next: () => void;\n /** Reset current step to initial value */\n reset: () => void;\n /** Go to custom step */\n set: (value: number | 'first' | 'last') => void;\n}\n\nconst FIRST_STEP_VALUE = 1;\n\n/**\n * @name useStep\n * @description - Hook that create stepper\n * @category State\n * @usage medium\n *\n * @overload\n * @param {number} max Maximum number of steps\n * @returns {UseStepReturn} An object contains variables and functions to change the step\n *\n * @example\n * const stepper = useStep(5);\n *\n * @overload\n * @param {number} params.max Maximum number of steps\n * @param {number} params.initial Initial value for step\n * @returns {UseStepReturn} An object contains variables and functions to change the step\n *\n * @example\n * const stepper = useStep({ initial: 2, max: 5 });\n */\nexport const useStep = (params: number | UseStepParams): UseStepReturn => {\n const max = typeof params === 'object' ? params.max : params;\n const initial = typeof params === 'object' ? params.initial : FIRST_STEP_VALUE;\n\n const initialStep = useRef(\n initial > max || initial < FIRST_STEP_VALUE ? FIRST_STEP_VALUE : initial\n );\n const [currentStep, setCurrentStep] = useState(initial);\n\n const isFirst = currentStep === FIRST_STEP_VALUE;\n const isLast = currentStep === max;\n\n const next = () => {\n if (isLast) return;\n setCurrentStep((prevStep) => prevStep + 1);\n };\n\n const back = () => {\n if (isFirst) return;\n setCurrentStep((prevStep) => prevStep - 1);\n };\n\n const reset = () => setCurrentStep(initialStep.current);\n\n const set = (value: number | 'first' | 'last') => {\n if (value === 'first') return setCurrentStep(initialStep.current);\n if (value === 'last') return setCurrentStep(max);\n if (value >= max) return setCurrentStep(max);\n if (value <= FIRST_STEP_VALUE) return setCurrentStep(FIRST_STEP_VALUE);\n setCurrentStep(value);\n };\n\n return {\n counts: max,\n currentStep,\n isFirst,\n isLast,\n next,\n back,\n reset,\n set\n };\n};\n"],"
|
|
1
|
+
{"version":3,"file":"useStep.cjs","names":[],"sources":["../../../../src/hooks/useStep/useStep.ts"],"sourcesContent":["import { useRef, useState } from 'react';\n\n/** The use step params type */\nexport interface UseStepParams {\n /** Initial value for step */\n initial: number;\n /** Maximum value for step */\n max: number;\n}\n\n/** The use step return type */\nexport interface UseStepReturn {\n /** Counts of steps */\n counts: number;\n /** Current value of step */\n currentStep: number;\n /** Boolean value if current step is first */\n isFirst: boolean;\n /** Boolean value if current step is last */\n isLast: boolean;\n /** Go to back step */\n back: () => void;\n /** Go to next step */\n next: () => void;\n /** Reset current step to initial value */\n reset: () => void;\n /** Go to custom step */\n set: (value: number | 'first' | 'last') => void;\n}\n\nconst FIRST_STEP_VALUE = 1;\n\n/**\n * @name useStep\n * @description - Hook that create stepper\n * @category State\n * @usage medium\n *\n * @overload\n * @param {number} max Maximum number of steps\n * @returns {UseStepReturn} An object contains variables and functions to change the step\n *\n * @example\n * const stepper = useStep(5);\n *\n * @overload\n * @param {number} params.max Maximum number of steps\n * @param {number} params.initial Initial value for step\n * @returns {UseStepReturn} An object contains variables and functions to change the step\n *\n * @example\n * const stepper = useStep({ initial: 2, max: 5 });\n */\nexport const useStep = (params: number | UseStepParams): UseStepReturn => {\n const max = typeof params === 'object' ? params.max : params;\n const initial = typeof params === 'object' ? params.initial : FIRST_STEP_VALUE;\n\n const initialStep = useRef(\n initial > max || initial < FIRST_STEP_VALUE ? FIRST_STEP_VALUE : initial\n );\n const [currentStep, setCurrentStep] = useState(initial);\n\n const isFirst = currentStep === FIRST_STEP_VALUE;\n const isLast = currentStep === max;\n\n const next = () => {\n if (isLast) return;\n setCurrentStep((prevStep) => prevStep + 1);\n };\n\n const back = () => {\n if (isFirst) return;\n setCurrentStep((prevStep) => prevStep - 1);\n };\n\n const reset = () => setCurrentStep(initialStep.current);\n\n const set = (value: number | 'first' | 'last') => {\n if (value === 'first') return setCurrentStep(initialStep.current);\n if (value === 'last') return setCurrentStep(max);\n if (value >= max) return setCurrentStep(max);\n if (value <= FIRST_STEP_VALUE) return setCurrentStep(FIRST_STEP_VALUE);\n setCurrentStep(value);\n };\n\n return {\n counts: max,\n currentStep,\n isFirst,\n isLast,\n next,\n back,\n reset,\n set\n };\n};\n"],"mappings":"uEA8BA,IAAM,EAAmB,EAuBZ,EAAW,GAAkD,CACxE,IAAM,EAAM,OAAO,GAAW,SAAW,EAAO,IAAM,EAChD,EAAU,OAAO,GAAW,SAAW,EAAO,QAAU,EAExD,GAAA,EAAA,EAAA,QACJ,EAAU,GAAO,EAAU,EAAmB,EAAmB,EAClE,CACK,CAAC,EAAa,IAAA,EAAA,EAAA,UAA2B,EAAQ,CAEjD,EAAU,IAAgB,EAC1B,EAAS,IAAgB,EAsB/B,MAAO,CACL,OAAQ,EACR,cACA,UACA,SACA,SAzBiB,CACb,GACJ,EAAgB,GAAa,EAAW,EAAE,EAwB1C,SArBiB,CACb,GACJ,EAAgB,GAAa,EAAW,EAAE,EAoB1C,UAjBkB,EAAe,EAAY,QAAQ,CAkBrD,IAhBW,GAAqC,CAChD,GAAI,IAAU,QAAS,OAAO,EAAe,EAAY,QAAQ,CAEjE,GADI,IAAU,QACV,GAAS,EAAK,OAAO,EAAe,EAAI,CAC5C,GAAI,GAAS,EAAkB,OAAO,EAAe,EAAiB,CACtE,EAAe,EAAM,EAYtB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=useSticky.cjs.map
|
|
1
|
+
require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../utils/helpers/isTarget.cjs`),t=require(`../useRefState/useRefState.cjs`);let n=require(`react`);var r=((...r)=>{let i=e.isTarget(r[0])?r[0]:void 0,a=i?r[1]:r[0],o=a?.axis??`vertical`,s=t.useRefState(),[c,l]=(0,n.useState)(!1);return(0,n.useEffect)(()=>{if(!i&&!s.state)return;let t=i?e.isTarget.getElement(i):s.current;if(!t)return;let n=a?.root?e.isTarget.getElement(a.root):document,r=t.getBoundingClientRect().top+n.scrollTop-n.getBoundingClientRect().top,c=t.getBoundingClientRect().left+n.scrollLeft-n.getBoundingClientRect().left,u=()=>{if(o===`vertical`){let e=n.scrollTop;l(e>=r)}if(o===`horizontal`){let e=n.scrollLeft;l(e>=c)}};return n.addEventListener(`scroll`,u),window.addEventListener(`resize`,u),window.addEventListener(`orientationchange`,u),u(),()=>{n.removeEventListener(`scroll`,u),window.removeEventListener(`resize`,u),window.removeEventListener(`orientationchange`,u)}},[i&&e.isTarget.getRawElement(i),s.state,o,a?.root]),i?{stuck:c}:{stuck:c,ref:s}});exports.useSticky=r;
|
|
2
|
+
//# sourceMappingURL=useSticky.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSticky.cjs","sources":["../../../../src/hooks/useSticky/useSticky.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nimport type { HookTarget } from '@/utils/helpers';\n\nimport { isTarget } from '@/utils/helpers';\n\nimport type { StateRef } from '../useRefState/useRefState';\n\nimport { useRefState } from '../useRefState/useRefState';\n\n/** The use sticky return type */\nexport interface UseStickyReturn {\n stuck: boolean;\n}\n\n/** The use sticky axis type */\nexport type UseStickyAxis = 'horizontal' | 'vertical';\n\n/** The use sticky options type */\nexport interface UseStickyOptions {\n axis?: UseStickyAxis;\n root?: HookTarget;\n}\n\nexport interface UseSticky {\n (target: HookTarget, options?: UseStickyOptions): UseStickyReturn;\n\n <Target extends Element>(\n options?: UseStickyOptions,\n target?: never\n ): UseStickyReturn & {\n ref: StateRef<Target>;\n };\n}\n\n/**\n * @name UseSticky\n * @description - Hook that allows you to detect that your sticky component is stuck\n * @category Elements\n * @usage low\n *\n * @overload\n * @param {HookTarget} target The target sticky element\n * @param {UseStickyAxis} [options.axis='vertical'] The axis of motion of the sticky component\n * @param {UseStickyRoot} [options.root=document] The element that contains your sticky component\n * @returns {UseStickyReturn} The state of the sticky\n *\n * @example\n * const { stuck } = useSticky(ref);\n *\n * @overload\n * @param {UseStickyAxis} [options.axis='vertical'] The axis of motion of the sticky component\n * @param {UseStickyRoot} [options.root=document] The element that contains your sticky component\n * @returns {{ ref: StateRef<Target> } & UseStickyReturn} The state of the sticky\n *\n * @example\n * const { stuck, ref } = useSticky();\n */\nexport const useSticky = ((...params: any[]) => {\n const target = (isTarget(params[0]) ? params[0] : undefined) as HookTarget | undefined;\n const options = (target ? params[1] : params[0]) as UseStickyOptions;\n const axis = options?.axis ?? 'vertical';\n\n const internalRef = useRefState<Element>();\n const [stuck, setStuck] = useState(false);\n\n useEffect(() => {\n if (!target && !internalRef.state) return;\n\n const element = (target ? isTarget.getElement(target) : internalRef.current) as Element;\n if (!element) return;\n\n const root = (options?.root ? isTarget.getElement(options.root) : document) as Element;\n const elementOffsetTop =\n element.getBoundingClientRect().top + root.scrollTop - root.getBoundingClientRect().top;\n const elementOffsetLeft =\n element.getBoundingClientRect().left + root.scrollLeft - root.getBoundingClientRect().left;\n\n const onSticky = () => {\n if (axis === 'vertical') {\n const scrollTop = root.scrollTop;\n setStuck(scrollTop >= elementOffsetTop);\n }\n\n if (axis === 'horizontal') {\n const scrollLeft = root.scrollLeft;\n setStuck(scrollLeft >= elementOffsetLeft);\n }\n };\n\n root.addEventListener('scroll', onSticky);\n window.addEventListener('resize', onSticky);\n window.addEventListener('orientationchange', onSticky);\n\n onSticky();\n\n return () => {\n root.removeEventListener('scroll', onSticky);\n window.removeEventListener('resize', onSticky);\n window.removeEventListener('orientationchange', onSticky);\n };\n }, [target && isTarget.getRawElement(target), internalRef.state, axis, options?.root]);\n\n if (target) return { stuck };\n return {\n stuck,\n ref: internalRef\n };\n}) as UseSticky;\n"],"
|
|
1
|
+
{"version":3,"file":"useSticky.cjs","names":[],"sources":["../../../../src/hooks/useSticky/useSticky.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nimport type { HookTarget } from '@/utils/helpers';\n\nimport { isTarget } from '@/utils/helpers';\n\nimport type { StateRef } from '../useRefState/useRefState';\n\nimport { useRefState } from '../useRefState/useRefState';\n\n/** The use sticky return type */\nexport interface UseStickyReturn {\n stuck: boolean;\n}\n\n/** The use sticky axis type */\nexport type UseStickyAxis = 'horizontal' | 'vertical';\n\n/** The use sticky options type */\nexport interface UseStickyOptions {\n axis?: UseStickyAxis;\n root?: HookTarget;\n}\n\nexport interface UseSticky {\n (target: HookTarget, options?: UseStickyOptions): UseStickyReturn;\n\n <Target extends Element>(\n options?: UseStickyOptions,\n target?: never\n ): UseStickyReturn & {\n ref: StateRef<Target>;\n };\n}\n\n/**\n * @name UseSticky\n * @description - Hook that allows you to detect that your sticky component is stuck\n * @category Elements\n * @usage low\n *\n * @overload\n * @param {HookTarget} target The target sticky element\n * @param {UseStickyAxis} [options.axis='vertical'] The axis of motion of the sticky component\n * @param {UseStickyRoot} [options.root=document] The element that contains your sticky component\n * @returns {UseStickyReturn} The state of the sticky\n *\n * @example\n * const { stuck } = useSticky(ref);\n *\n * @overload\n * @param {UseStickyAxis} [options.axis='vertical'] The axis of motion of the sticky component\n * @param {UseStickyRoot} [options.root=document] The element that contains your sticky component\n * @returns {{ ref: StateRef<Target> } & UseStickyReturn} The state of the sticky\n *\n * @example\n * const { stuck, ref } = useSticky();\n */\nexport const useSticky = ((...params: any[]) => {\n const target = (isTarget(params[0]) ? params[0] : undefined) as HookTarget | undefined;\n const options = (target ? params[1] : params[0]) as UseStickyOptions;\n const axis = options?.axis ?? 'vertical';\n\n const internalRef = useRefState<Element>();\n const [stuck, setStuck] = useState(false);\n\n useEffect(() => {\n if (!target && !internalRef.state) return;\n\n const element = (target ? isTarget.getElement(target) : internalRef.current) as Element;\n if (!element) return;\n\n const root = (options?.root ? isTarget.getElement(options.root) : document) as Element;\n const elementOffsetTop =\n element.getBoundingClientRect().top + root.scrollTop - root.getBoundingClientRect().top;\n const elementOffsetLeft =\n element.getBoundingClientRect().left + root.scrollLeft - root.getBoundingClientRect().left;\n\n const onSticky = () => {\n if (axis === 'vertical') {\n const scrollTop = root.scrollTop;\n setStuck(scrollTop >= elementOffsetTop);\n }\n\n if (axis === 'horizontal') {\n const scrollLeft = root.scrollLeft;\n setStuck(scrollLeft >= elementOffsetLeft);\n }\n };\n\n root.addEventListener('scroll', onSticky);\n window.addEventListener('resize', onSticky);\n window.addEventListener('orientationchange', onSticky);\n\n onSticky();\n\n return () => {\n root.removeEventListener('scroll', onSticky);\n window.removeEventListener('resize', onSticky);\n window.removeEventListener('orientationchange', onSticky);\n };\n }, [target && isTarget.getRawElement(target), internalRef.state, axis, options?.root]);\n\n if (target) return { stuck };\n return {\n stuck,\n ref: internalRef\n };\n}) as UseSticky;\n"],"mappings":"uKA0DA,IAAa,IAAc,GAAG,IAAkB,CAC9C,IAAM,EAAU,EAAA,SAAS,EAAO,GAAG,CAAG,EAAO,GAAK,IAAA,GAC5C,EAAW,EAAS,EAAO,GAAK,EAAO,GACvC,EAAO,GAAS,MAAQ,WAExB,EAAc,EAAA,aAAsB,CACpC,CAAC,EAAO,IAAA,EAAA,EAAA,UAAqB,GAAM,CAwCzC,OAtCA,EAAA,EAAA,eAAgB,CACd,GAAI,CAAC,GAAU,CAAC,EAAY,MAAO,OAEnC,IAAM,EAAW,EAAS,EAAA,SAAS,WAAW,EAAO,CAAG,EAAY,QACpE,GAAI,CAAC,EAAS,OAEd,IAAM,EAAQ,GAAS,KAAO,EAAA,SAAS,WAAW,EAAQ,KAAK,CAAG,SAC5D,EACJ,EAAQ,uBAAuB,CAAC,IAAM,EAAK,UAAY,EAAK,uBAAuB,CAAC,IAChF,EACJ,EAAQ,uBAAuB,CAAC,KAAO,EAAK,WAAa,EAAK,uBAAuB,CAAC,KAElF,MAAiB,CACrB,GAAI,IAAS,WAAY,CACvB,IAAM,EAAY,EAAK,UACvB,EAAS,GAAa,EAAiB,CAGzC,GAAI,IAAS,aAAc,CACzB,IAAM,EAAa,EAAK,WACxB,EAAS,GAAc,EAAkB,GAU7C,OANA,EAAK,iBAAiB,SAAU,EAAS,CACzC,OAAO,iBAAiB,SAAU,EAAS,CAC3C,OAAO,iBAAiB,oBAAqB,EAAS,CAEtD,GAAU,KAEG,CACX,EAAK,oBAAoB,SAAU,EAAS,CAC5C,OAAO,oBAAoB,SAAU,EAAS,CAC9C,OAAO,oBAAoB,oBAAqB,EAAS,GAE1D,CAAC,GAAU,EAAA,SAAS,cAAc,EAAO,CAAE,EAAY,MAAO,EAAM,GAAS,KAAK,CAAC,CAElF,EAAe,CAAE,QAAO,CACrB,CACL,QACA,IAAK,EACN"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=useStopwatch.cjs.map
|
|
1
|
+
require(`../../_virtual/_rolldown/runtime.cjs`);let e=require(`react`);var t=e=>e?{days:Math.floor(e/86400),hours:Math.floor(e%86400/3600),minutes:Math.floor(e%3600/60),seconds:Math.floor(e%60),count:e}:{days:0,hours:0,minutes:0,seconds:0,count:0},n=((...n)=>{let r=(typeof n[0]==`number`?n[0]:n[0]?.initialTime)??0,i=(typeof n[0]==`number`?n[1]:n[0])?.immediately??!1,[a,o]=(0,e.useState)(t(r)),[s,c]=(0,e.useState)(!i&&!r);return(0,e.useEffect)(()=>{if(s)return;let e=()=>{o(e=>{let t=e.count+1;return t%60==0?{...e,minutes:e.minutes+1,seconds:0,count:t}:t%3600==0?{...e,hours:e.hours+1,minutes:0,seconds:0,count:t}:t%(3600*24)==0?{...e,days:e.days+1,hours:0,minutes:0,seconds:0,count:t}:{...e,seconds:e.seconds+1,count:t}})},t=setInterval(()=>e(),1e3);return()=>clearInterval(t)},[s]),{...a,paused:s,pause:()=>c(!0),start:()=>c(!1),reset:()=>o(t(r)),toggle:()=>c(e=>!e)}});exports.useStopwatch=n;
|
|
2
|
+
//# sourceMappingURL=useStopwatch.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStopwatch.cjs","sources":["../../../../src/hooks/useStopwatch/useStopwatch.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nconst getStopwatchTime = (time: number) => {\n if (!time)\n return {\n days: 0,\n hours: 0,\n minutes: 0,\n seconds: 0,\n count: 0\n };\n\n const days = Math.floor(time / 86400);\n const hours = Math.floor((time % 86400) / 3600);\n const minutes = Math.floor((time % 3600) / 60);\n const seconds = Math.floor(time % 60);\n\n return { days, hours, minutes, seconds, count: time };\n};\n\n/** The use stopwatch return type */\nexport interface UseStopwatchReturn {\n /** The total count of the stopwatch */\n count: number;\n /** The day count of the stopwatch */\n days: number;\n /** The hour count of the stopwatch */\n hours: number;\n /** The minute count of the stopwatch */\n minutes: number;\n /** The over state of the stopwatch */\n over: boolean;\n /** The paused state of the stopwatch */\n paused: boolean;\n /** The second count of the stopwatch */\n seconds: number;\n /** The function to pause the stopwatch */\n pause: () => void;\n /** The function to reset the stopwatch */\n reset: () => void;\n /** The function to start the stopwatch */\n start: () => void;\n /** The function to toggle the stopwatch */\n toggle: () => void;\n}\n\n/** The use stopwatch options */\nexport interface UseStopwatchOptions {\n /** The immediately state of the timer */\n immediately?: boolean;\n}\n\ninterface UseStopwatch {\n (initialTime?: number, options?: UseStopwatchOptions): UseStopwatchReturn;\n (options?: UseStopwatchOptions & { initialTime?: number }): UseStopwatchReturn;\n}\n/**\n * @name useStopwatch\n * @description - Hook that creates a stopwatch functionality\n * @category Time\n * @usage high\n *\n * @overload\n * @param {number} [initialTime=0] The initial time of the timer\n * @param {boolean} [options.enabled=true] The enabled state of the timer\n * @returns {UseStopwatchReturn} An object containing the current time and functions to interact with the timer\n *\n * @example\n * const { seconds, minutes, start, pause, reset } = useStopwatch(1000, { enabled: false });\n *\n * @overload\n * @param {number} [options.initialTime=0] -The initial time of the timer\n * @param {boolean} [options.enabled=true] The enabled state of the timer\n * @returns {UseStopwatchReturn} An object containing the current time and functions to interact with the timer\n *\n * @example\n * const { seconds, minutes, start, pause, reset } = useStopwatch({ initialTime: 1000, enabled: false });\n */\nexport const useStopwatch = ((...params: any[]) => {\n const initialTime =\n (typeof params[0] === 'number'\n ? (params[0] as number | undefined)\n : (params[0] as UseStopwatchOptions & { initialTime?: number })?.initialTime) ?? 0;\n\n const options =\n typeof params[0] === 'number'\n ? (params[1] as UseStopwatchOptions | undefined)\n : (params[0] as (UseStopwatchOptions & { initialTime?: number }) | undefined);\n\n const immediately = options?.immediately ?? false;\n\n const [time, setTime] = useState(getStopwatchTime(initialTime));\n const [paused, setPaused] = useState(!immediately && !initialTime);\n\n useEffect(() => {\n if (paused) return;\n const onInterval = () => {\n setTime((prevTime) => {\n const updatedCount = prevTime.count + 1;\n\n if (updatedCount % 60 === 0) {\n return {\n ...prevTime,\n minutes: prevTime.minutes + 1,\n seconds: 0,\n count: updatedCount\n };\n }\n\n if (updatedCount % (60 * 60) === 0) {\n return {\n ...prevTime,\n hours: prevTime.hours + 1,\n minutes: 0,\n seconds: 0,\n count: updatedCount\n };\n }\n\n if (updatedCount % (60 * 60 * 24) === 0) {\n return {\n ...prevTime,\n days: prevTime.days + 1,\n hours: 0,\n minutes: 0,\n seconds: 0,\n count: updatedCount\n };\n }\n\n return {\n ...prevTime,\n seconds: prevTime.seconds + 1,\n count: updatedCount\n };\n });\n };\n\n const interval = setInterval(() => onInterval(), 1000);\n return () => clearInterval(interval);\n }, [paused]);\n\n return {\n ...time,\n paused,\n pause: () => setPaused(true),\n start: () => setPaused(false),\n reset: () => setTime(getStopwatchTime(initialTime)),\n toggle: () => setPaused((prevPause) => !prevPause)\n };\n}) as UseStopwatch;\n"],"
|
|
1
|
+
{"version":3,"file":"useStopwatch.cjs","names":[],"sources":["../../../../src/hooks/useStopwatch/useStopwatch.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nconst getStopwatchTime = (time: number) => {\n if (!time)\n return {\n days: 0,\n hours: 0,\n minutes: 0,\n seconds: 0,\n count: 0\n };\n\n const days = Math.floor(time / 86400);\n const hours = Math.floor((time % 86400) / 3600);\n const minutes = Math.floor((time % 3600) / 60);\n const seconds = Math.floor(time % 60);\n\n return { days, hours, minutes, seconds, count: time };\n};\n\n/** The use stopwatch return type */\nexport interface UseStopwatchReturn {\n /** The total count of the stopwatch */\n count: number;\n /** The day count of the stopwatch */\n days: number;\n /** The hour count of the stopwatch */\n hours: number;\n /** The minute count of the stopwatch */\n minutes: number;\n /** The over state of the stopwatch */\n over: boolean;\n /** The paused state of the stopwatch */\n paused: boolean;\n /** The second count of the stopwatch */\n seconds: number;\n /** The function to pause the stopwatch */\n pause: () => void;\n /** The function to reset the stopwatch */\n reset: () => void;\n /** The function to start the stopwatch */\n start: () => void;\n /** The function to toggle the stopwatch */\n toggle: () => void;\n}\n\n/** The use stopwatch options */\nexport interface UseStopwatchOptions {\n /** The immediately state of the timer */\n immediately?: boolean;\n}\n\ninterface UseStopwatch {\n (initialTime?: number, options?: UseStopwatchOptions): UseStopwatchReturn;\n (options?: UseStopwatchOptions & { initialTime?: number }): UseStopwatchReturn;\n}\n/**\n * @name useStopwatch\n * @description - Hook that creates a stopwatch functionality\n * @category Time\n * @usage high\n *\n * @overload\n * @param {number} [initialTime=0] The initial time of the timer\n * @param {boolean} [options.enabled=true] The enabled state of the timer\n * @returns {UseStopwatchReturn} An object containing the current time and functions to interact with the timer\n *\n * @example\n * const { seconds, minutes, start, pause, reset } = useStopwatch(1000, { enabled: false });\n *\n * @overload\n * @param {number} [options.initialTime=0] -The initial time of the timer\n * @param {boolean} [options.enabled=true] The enabled state of the timer\n * @returns {UseStopwatchReturn} An object containing the current time and functions to interact with the timer\n *\n * @example\n * const { seconds, minutes, start, pause, reset } = useStopwatch({ initialTime: 1000, enabled: false });\n */\nexport const useStopwatch = ((...params: any[]) => {\n const initialTime =\n (typeof params[0] === 'number'\n ? (params[0] as number | undefined)\n : (params[0] as UseStopwatchOptions & { initialTime?: number })?.initialTime) ?? 0;\n\n const options =\n typeof params[0] === 'number'\n ? (params[1] as UseStopwatchOptions | undefined)\n : (params[0] as (UseStopwatchOptions & { initialTime?: number }) | undefined);\n\n const immediately = options?.immediately ?? false;\n\n const [time, setTime] = useState(getStopwatchTime(initialTime));\n const [paused, setPaused] = useState(!immediately && !initialTime);\n\n useEffect(() => {\n if (paused) return;\n const onInterval = () => {\n setTime((prevTime) => {\n const updatedCount = prevTime.count + 1;\n\n if (updatedCount % 60 === 0) {\n return {\n ...prevTime,\n minutes: prevTime.minutes + 1,\n seconds: 0,\n count: updatedCount\n };\n }\n\n if (updatedCount % (60 * 60) === 0) {\n return {\n ...prevTime,\n hours: prevTime.hours + 1,\n minutes: 0,\n seconds: 0,\n count: updatedCount\n };\n }\n\n if (updatedCount % (60 * 60 * 24) === 0) {\n return {\n ...prevTime,\n days: prevTime.days + 1,\n hours: 0,\n minutes: 0,\n seconds: 0,\n count: updatedCount\n };\n }\n\n return {\n ...prevTime,\n seconds: prevTime.seconds + 1,\n count: updatedCount\n };\n });\n };\n\n const interval = setInterval(() => onInterval(), 1000);\n return () => clearInterval(interval);\n }, [paused]);\n\n return {\n ...time,\n paused,\n pause: () => setPaused(true),\n start: () => setPaused(false),\n reset: () => setTime(getStopwatchTime(initialTime)),\n toggle: () => setPaused((prevPause) => !prevPause)\n };\n}) as UseStopwatch;\n"],"mappings":"uEAEA,IAAM,EAAoB,GACnB,EAcE,CAAE,KALI,KAAK,MAAM,EAAO,MAAM,CAKtB,MAJD,KAAK,MAAO,EAAO,MAAS,KAAK,CAIzB,QAHN,KAAK,MAAO,EAAO,KAAQ,GAAG,CAGf,QAFf,KAAK,MAAM,EAAO,GAAG,CAEG,MAAO,EAAM,CAb5C,CACL,KAAM,EACN,MAAO,EACP,QAAS,EACT,QAAS,EACT,MAAO,EACR,CAoEQ,IAAiB,GAAG,IAAkB,CACjD,IAAM,GACH,OAAO,EAAO,IAAO,SACjB,EAAO,GACP,EAAO,IAAuD,cAAgB,EAO/E,GAJJ,OAAO,EAAO,IAAO,SAChB,EAAO,GACP,EAAO,KAEe,aAAe,GAEtC,CAAC,EAAM,IAAA,EAAA,EAAA,UAAoB,EAAiB,EAAY,CAAC,CACzD,CAAC,EAAQ,IAAA,EAAA,EAAA,UAAsB,CAAC,GAAe,CAAC,EAAY,CAkDlE,OAhDA,EAAA,EAAA,eAAgB,CACd,GAAI,EAAQ,OACZ,IAAM,MAAmB,CACvB,EAAS,GAAa,CACpB,IAAM,EAAe,EAAS,MAAQ,EAgCtC,OA9BI,EAAe,IAAO,EACjB,CACL,GAAG,EACH,QAAS,EAAS,QAAU,EAC5B,QAAS,EACT,MAAO,EACR,CAGC,EAAgB,MAAa,EACxB,CACL,GAAG,EACH,MAAO,EAAS,MAAQ,EACxB,QAAS,EACT,QAAS,EACT,MAAO,EACR,CAGC,GAAgB,KAAU,KAAQ,EAC7B,CACL,GAAG,EACH,KAAM,EAAS,KAAO,EACtB,MAAO,EACP,QAAS,EACT,QAAS,EACT,MAAO,EACR,CAGI,CACL,GAAG,EACH,QAAS,EAAS,QAAU,EAC5B,MAAO,EACR,EACD,EAGE,EAAW,gBAAkB,GAAY,CAAE,IAAK,CACtD,UAAa,cAAc,EAAS,EACnC,CAAC,EAAO,CAAC,CAEL,CACL,GAAG,EACH,SACA,UAAa,EAAU,GAAK,CAC5B,UAAa,EAAU,GAAM,CAC7B,UAAa,EAAQ,EAAiB,EAAY,CAAC,CACnD,WAAc,EAAW,GAAc,CAAC,EAAU,CACnD"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=useStorage.cjs.map
|
|
1
|
+
require(`../../_virtual/_rolldown/runtime.cjs`);let e=require(`react`);var t=`reactuse-storage`,n=e=>window.dispatchEvent(new StorageEvent(t,e)),r=(e,t,r)=>{let i=e.getItem(t);e.setItem(t,r),n({key:t,oldValue:i,newValue:r,storageArea:e})},i=(e,t)=>{let r=e.getItem(t);e.removeItem(t),n({key:t,oldValue:r,newValue:null,storageArea:e})},a=(e,t)=>{let n=e.getItem(t);if(n)return n},o=((n,o)=>{let s=typeof o==`object`&&o&&(`serializer`in o||`deserializer`in o||`initialValue`in o||`storage`in o)?o:void 0,c=s?s?.initialValue:o;if(typeof window>`u`)return{value:typeof c==`function`?c():c,set:()=>{},remove:()=>{}};let l=e=>s?.serializer?s.serializer(e):typeof e==`string`?e:JSON.stringify(e),u=s?.storage??window?.localStorage,d=e=>r(u,n,l(e)),f=()=>i(u,n),p=e=>{if(s?.deserializer)return s.deserializer(e);if(e!==`undefined`)try{return JSON.parse(e)}catch{return e}},[m,h]=(0,e.useState)(()=>{let e=a(u,n);if(e===void 0&&c!==void 0){let e=typeof c==`function`?c():c;return r(u,n,l(e)),e}return e?p(e):void 0});return(0,e.useEffect)(()=>{let e=e=>{if(e&&e.storageArea!==u||e&&e.key!==n)return;let t=a(u,n);h(t?p(t):void 0)};return window.addEventListener(t,e),window.addEventListener(`storage`,e,{passive:!0}),()=>{window.removeEventListener(t,e),window.removeEventListener(`storage`,e)}},[n,u]),{value:m,set:d,remove:f}});exports.STORAGE_EVENT=t,exports.dispatchStorageEvent=n,exports.useStorage=o;
|
|
2
|
+
//# sourceMappingURL=useStorage.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStorage.cjs","sources":["../../../../src/hooks/useStorage/useStorage.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\
|
|
1
|
+
{"version":3,"file":"useStorage.cjs","names":[],"sources":["../../../../src/hooks/useStorage/useStorage.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\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 interface UseStorage {\n <Value>(key: string, options?: UseStorageOptions<Value>): UseStorageReturn<Value | undefined>;\n\n <Value>(\n key: string,\n initialValue?: UseStorageInitialValue<Value>\n ): UseStorageReturn<Value | undefined>;\n}\n\nexport const STORAGE_EVENT = 'reactuse-storage';\n\nexport const dispatchStorageEvent = (params: Partial<StorageEvent>) =>\n window.dispatchEvent(new StorageEvent(STORAGE_EVENT, params));\n\nconst setStorageItem = (storage: Storage, key: string, value: string) => {\n const oldValue = storage.getItem(key);\n\n storage.setItem(key, value);\n dispatchStorageEvent({\n key,\n oldValue,\n newValue: value,\n storageArea: storage\n });\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\n/**\n * @name useStorage\n * @description - Hook that manages storage value\n * @category State\n * @usage high\n *\n * @overload\n * @param {string} key The key of the storage\n * @param {UseStorageInitialValue<Value>} [initialValue] The initial value of the storage\n * @returns {UseStorageReturn<Value>} The value and the set function\n *\n * @overload\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>(key: string, params?: any): UseStorageReturn<Value> => {\n const options = (\n typeof params === 'object' &&\n params &&\n ('serializer' in params ||\n 'deserializer' in params ||\n 'initialValue' in params ||\n 'storage' in params)\n ? params\n : undefined\n ) as UseStorageOptions<Value>;\n\n const initialValue = (options ? options?.initialValue : params) as UseStorageInitialValue<Value>;\n\n if (typeof window === 'undefined') {\n const value = typeof initialValue === 'function' ? (initialValue as () => any)() : initialValue;\n return {\n value,\n set: () => {},\n remove: () => {}\n };\n }\n\n const serializer = (value: Value) => {\n if (options?.serializer) return options.serializer(value);\n if (typeof value === 'string') return value;\n return JSON.stringify(value);\n };\n\n const storage = options?.storage ?? window?.localStorage;\n\n const set = (value: Value) => setStorageItem(storage, key, serializer(value));\n const remove = () => removeStorageItem(storage, key);\n\n const deserializer = (value: string) => {\n if (options?.deserializer) return options.deserializer(value);\n if (value === 'undefined') return undefined as unknown as Value;\n\n try {\n return JSON.parse(value) as Value;\n } catch {\n return value as Value;\n }\n };\n\n const [value, setValue] = useState<Value | undefined>(() => {\n const storageValue = getStorageItem(storage, key);\n if (storageValue === undefined && initialValue !== undefined) {\n const value =\n typeof initialValue === 'function' ? (initialValue as () => Value)() : initialValue;\n setStorageItem(storage, key, serializer(value));\n return value;\n }\n return storageValue ? deserializer(storageValue) : undefined;\n });\n\n useEffect(() => {\n const onChange = (event?: StorageEvent) => {\n if (event && event.storageArea !== storage) return;\n if (event && event.key !== key) return;\n\n const storageValue = getStorageItem(storage, key);\n setValue(storageValue ? deserializer(storageValue) : undefined);\n };\n\n window.addEventListener(STORAGE_EVENT, onChange as EventListener);\n window.addEventListener('storage', onChange, { passive: true });\n\n return () => {\n window.removeEventListener(STORAGE_EVENT, onChange as EventListener);\n window.removeEventListener('storage', onChange);\n };\n }, [key, storage]);\n\n return {\n value: value as Value,\n set,\n remove\n };\n}) as UseStorage;\n"],"mappings":"uEAoCA,IAAa,EAAgB,mBAEhB,EAAwB,GACnC,OAAO,cAAc,IAAI,aAAa,EAAe,EAAO,CAAC,CAEzD,GAAkB,EAAkB,EAAa,IAAkB,CACvE,IAAM,EAAW,EAAQ,QAAQ,EAAI,CAErC,EAAQ,QAAQ,EAAK,EAAM,CAC3B,EAAqB,CACnB,MACA,WACA,SAAU,EACV,YAAa,EACd,CAAC,EAGE,GAAqB,EAAkB,IAAgB,CAC3D,IAAM,EAAW,EAAQ,QAAQ,EAAI,CAErC,EAAQ,WAAW,EAAI,CACvB,EAAqB,CAAE,MAAK,WAAU,SAAU,KAAM,YAAa,EAAS,CAAC,EAGzE,GAAkB,EAAkB,IAAgB,CACxD,IAAM,EAAQ,EAAQ,QAAQ,EAAI,CAC7B,KACL,OAAO,GAyBI,IAAsB,EAAa,IAA0C,CACxF,IAAM,EACJ,OAAO,GAAW,UAClB,IACC,eAAgB,GACf,iBAAkB,GAClB,iBAAkB,GAClB,YAAa,GACX,EACA,IAAA,GAGA,EAAgB,EAAU,GAAS,aAAe,EAExD,GAAI,OAAO,OAAW,IAEpB,MAAO,CACL,MAFY,OAAO,GAAiB,WAAc,GAA4B,CAAG,EAGjF,QAAW,GACX,WAAc,GACf,CAGH,IAAM,EAAc,GACd,GAAS,WAAmB,EAAQ,WAAW,EAAM,CACrD,OAAO,GAAU,SAAiB,EAC/B,KAAK,UAAU,EAAM,CAGxB,EAAU,GAAS,SAAW,QAAQ,aAEtC,EAAO,GAAiB,EAAe,EAAS,EAAK,EAAW,EAAM,CAAC,CACvE,MAAe,EAAkB,EAAS,EAAI,CAE9C,EAAgB,GAAkB,CACtC,GAAI,GAAS,aAAc,OAAO,EAAQ,aAAa,EAAM,CACzD,OAAU,YAEd,GAAI,CACF,OAAO,KAAK,MAAM,EAAM,MAClB,CACN,OAAO,IAIL,CAAC,EAAO,IAAA,EAAA,EAAA,cAA8C,CAC1D,IAAM,EAAe,EAAe,EAAS,EAAI,CACjD,GAAI,IAAiB,IAAA,IAAa,IAAiB,IAAA,GAAW,CAC5D,IAAM,EACJ,OAAO,GAAiB,WAAc,GAA8B,CAAG,EAEzE,OADA,EAAe,EAAS,EAAK,EAAW,EAAM,CAAC,CACxC,EAET,OAAO,EAAe,EAAa,EAAa,CAAG,IAAA,IACnD,CAoBF,OAlBA,EAAA,EAAA,eAAgB,CACd,IAAM,EAAY,GAAyB,CAEzC,GADI,GAAS,EAAM,cAAgB,GAC/B,GAAS,EAAM,MAAQ,EAAK,OAEhC,IAAM,EAAe,EAAe,EAAS,EAAI,CACjD,EAAS,EAAe,EAAa,EAAa,CAAG,IAAA,GAAU,EAMjE,OAHA,OAAO,iBAAiB,EAAe,EAA0B,CACjE,OAAO,iBAAiB,UAAW,EAAU,CAAE,QAAS,GAAM,CAAC,KAElD,CACX,OAAO,oBAAoB,EAAe,EAA0B,CACpE,OAAO,oBAAoB,UAAW,EAAS,GAEhD,CAAC,EAAK,EAAQ,CAAC,CAEX,CACE,QACP,MACA,SACD"}
|