@siberiacancode/reactuse 0.2.12 → 0.2.13
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/helpers/createContext/createContext.cjs.map +1 -1
- package/dist/cjs/helpers/createReactiveContext/createReactiveContext.cjs.map +1 -1
- package/dist/cjs/helpers/createStore/createStore.cjs.map +1 -1
- package/dist/cjs/hooks/useActiveElement/useActiveElement.cjs +1 -1
- package/dist/cjs/hooks/useActiveElement/useActiveElement.cjs.map +1 -1
- package/dist/cjs/hooks/useAsync/useAsync.cjs.map +1 -1
- package/dist/cjs/hooks/useBattery/useBattery.cjs +1 -1
- package/dist/cjs/hooks/useBattery/useBattery.cjs.map +1 -1
- package/dist/cjs/hooks/useBluetooth/useBluetooth.cjs +1 -1
- package/dist/cjs/hooks/useBluetooth/useBluetooth.cjs.map +1 -1
- package/dist/cjs/hooks/useBoolean/useBoolean.cjs.map +1 -1
- package/dist/cjs/hooks/useBreakpoints/useBreakpoints.cjs.map +1 -1
- package/dist/cjs/hooks/useBrowserLanguage/useBrowserLanguage.cjs.map +1 -1
- package/dist/cjs/hooks/useClickOutside/useClickOutside.cjs.map +1 -1
- package/dist/cjs/hooks/useClipboard/useClipboard.cjs +1 -1
- package/dist/cjs/hooks/useClipboard/useClipboard.cjs.map +1 -1
- package/dist/cjs/hooks/useCookie/useCookie.cjs +1 -1
- package/dist/cjs/hooks/useCookie/useCookie.cjs.map +1 -1
- package/dist/cjs/hooks/useCookies/useCookies.cjs +1 -1
- package/dist/cjs/hooks/useCookies/useCookies.cjs.map +1 -1
- package/dist/cjs/hooks/useCopy/useCopy.cjs.map +1 -1
- package/dist/cjs/hooks/useCounter/useCounter.cjs +1 -1
- package/dist/cjs/hooks/useCounter/useCounter.cjs.map +1 -1
- package/dist/cjs/hooks/useCssVar/useCssVar.cjs +1 -1
- package/dist/cjs/hooks/useCssVar/useCssVar.cjs.map +1 -1
- package/dist/cjs/hooks/useDebounceCallback/useDebounceCallback.cjs.map +1 -1
- package/dist/cjs/hooks/useDebounceValue/useDebounceValue.cjs.map +1 -1
- package/dist/cjs/hooks/useDeviceMotion/useDeviceMotion.cjs +1 -1
- package/dist/cjs/hooks/useDeviceMotion/useDeviceMotion.cjs.map +1 -1
- package/dist/cjs/hooks/useDeviceOrientation/useDeviceOrientation.cjs.map +1 -1
- package/dist/cjs/hooks/useDevicePixelRatio/useDevicePixelRatio.cjs.map +1 -1
- package/dist/cjs/hooks/useDidUpdate/useDidUpdate.cjs.map +1 -1
- package/dist/cjs/hooks/useDisclosure/useDisclosure.cjs +1 -1
- package/dist/cjs/hooks/useDisclosure/useDisclosure.cjs.map +1 -1
- package/dist/cjs/hooks/useDisplayMedia/useDisplayMedia.cjs +1 -1
- package/dist/cjs/hooks/useDisplayMedia/useDisplayMedia.cjs.map +1 -1
- package/dist/cjs/hooks/useDocumentEvent/useDocumentEvent.cjs.map +1 -1
- package/dist/cjs/hooks/useDocumentTitle/useDocumentTitle.cjs +1 -1
- package/dist/cjs/hooks/useDocumentTitle/useDocumentTitle.cjs.map +1 -1
- package/dist/cjs/hooks/useDocumentVisibility/useDocumentVisibility.cjs.map +1 -1
- package/dist/cjs/hooks/useDoubleClick/useDoubleClick.cjs +1 -1
- package/dist/cjs/hooks/useDoubleClick/useDoubleClick.cjs.map +1 -1
- package/dist/cjs/hooks/useDropZone/useDropZone.cjs +1 -1
- package/dist/cjs/hooks/useDropZone/useDropZone.cjs.map +1 -1
- package/dist/cjs/hooks/useElementSize/useElementSize.cjs.map +1 -1
- package/dist/cjs/hooks/useEvent/useEvent.cjs.map +1 -1
- package/dist/cjs/hooks/useEventListener/useEventListener.cjs.map +1 -1
- package/dist/cjs/hooks/useEventSource/useEventSource.cjs +1 -1
- package/dist/cjs/hooks/useEventSource/useEventSource.cjs.map +1 -1
- package/dist/cjs/hooks/useEyeDropper/useEyeDropper.cjs.map +1 -1
- package/dist/cjs/hooks/useFavicon/useFavicon.cjs +1 -1
- package/dist/cjs/hooks/useFavicon/useFavicon.cjs.map +1 -1
- package/dist/cjs/hooks/useField/useField.cjs +1 -1
- package/dist/cjs/hooks/useField/useField.cjs.map +1 -1
- package/dist/cjs/hooks/useFileDialog/useFileDialog.cjs +1 -1
- package/dist/cjs/hooks/useFileDialog/useFileDialog.cjs.map +1 -1
- package/dist/cjs/hooks/useFocus/useFocus.cjs +1 -1
- package/dist/cjs/hooks/useFocus/useFocus.cjs.map +1 -1
- package/dist/cjs/hooks/useFps/useFps.cjs.map +1 -1
- package/dist/cjs/hooks/useFul/useFul.cjs.map +1 -1
- package/dist/cjs/hooks/useFullscreen/useFullscreen.cjs +1 -1
- package/dist/cjs/hooks/useFullscreen/useFullscreen.cjs.map +1 -1
- package/dist/cjs/hooks/useGamepad/useGamepad.cjs.map +1 -1
- package/dist/cjs/hooks/useGeolocation/useGeolocation.cjs +1 -1
- package/dist/cjs/hooks/useGeolocation/useGeolocation.cjs.map +1 -1
- package/dist/cjs/hooks/useHash/useHash.cjs.map +1 -1
- package/dist/cjs/hooks/useHotkeys/useHotkeys.cjs +1 -1
- package/dist/cjs/hooks/useHotkeys/useHotkeys.cjs.map +1 -1
- package/dist/cjs/hooks/useHover/useHover.cjs +1 -1
- package/dist/cjs/hooks/useHover/useHover.cjs.map +1 -1
- package/dist/cjs/hooks/useIdle/useIdle.cjs.map +1 -1
- package/dist/cjs/hooks/useImage/useImage.cjs.map +1 -1
- package/dist/cjs/hooks/useInfiniteScroll/useInfiniteScroll.cjs +1 -1
- package/dist/cjs/hooks/useInfiniteScroll/useInfiniteScroll.cjs.map +1 -1
- package/dist/cjs/hooks/useIntersectionObserver/useIntersectionObserver.cjs +1 -1
- package/dist/cjs/hooks/useIntersectionObserver/useIntersectionObserver.cjs.map +1 -1
- package/dist/cjs/hooks/useInterval/useInterval.cjs +1 -1
- package/dist/cjs/hooks/useInterval/useInterval.cjs.map +1 -1
- package/dist/cjs/hooks/useIsFirstRender/useIsFirstRender.cjs.map +1 -1
- package/dist/cjs/hooks/useKeyPress/useKeyPress.cjs +1 -1
- package/dist/cjs/hooks/useKeyPress/useKeyPress.cjs.map +1 -1
- package/dist/cjs/hooks/useKeyPressEvent/useKeyPressEvent.cjs +1 -1
- package/dist/cjs/hooks/useKeyPressEvent/useKeyPressEvent.cjs.map +1 -1
- package/dist/cjs/hooks/useKeyboard/useKeyboard.cjs +1 -1
- package/dist/cjs/hooks/useKeyboard/useKeyboard.cjs.map +1 -1
- package/dist/cjs/hooks/useKeysPressed/useKeysPressed.cjs +1 -1
- package/dist/cjs/hooks/useKeysPressed/useKeysPressed.cjs.map +1 -1
- package/dist/cjs/hooks/useLastChanged/useLastChanged.cjs +1 -1
- package/dist/cjs/hooks/useLastChanged/useLastChanged.cjs.map +1 -1
- package/dist/cjs/hooks/useLatest/useLatest.cjs +1 -1
- package/dist/cjs/hooks/useLatest/useLatest.cjs.map +1 -1
- package/dist/cjs/hooks/useLess/useLess.cjs.map +1 -1
- package/dist/cjs/hooks/useList/useList.cjs.map +1 -1
- package/dist/cjs/hooks/useLockCallback/useLockCallback.cjs.map +1 -1
- package/dist/cjs/hooks/useLogger/useLogger.cjs.map +1 -1
- package/dist/cjs/hooks/useLongPress/useLongPress.cjs +1 -1
- package/dist/cjs/hooks/useLongPress/useLongPress.cjs.map +1 -1
- package/dist/cjs/hooks/useMap/useMap.cjs.map +1 -1
- package/dist/cjs/hooks/useMeasure/useMeasure.cjs.map +1 -1
- package/dist/cjs/hooks/useMediaQuery/useMediaQuery.cjs.map +1 -1
- package/dist/cjs/hooks/useMemory/useMemory.cjs +1 -1
- package/dist/cjs/hooks/useMemory/useMemory.cjs.map +1 -1
- package/dist/cjs/hooks/useMount/useMount.cjs.map +1 -1
- package/dist/cjs/hooks/useMouse/useMouse.cjs.map +1 -1
- package/dist/cjs/hooks/useMutation/useMutation.cjs +1 -1
- package/dist/cjs/hooks/useMutation/useMutation.cjs.map +1 -1
- package/dist/cjs/hooks/useMutationObserver/useMutationObserver.cjs +1 -1
- package/dist/cjs/hooks/useMutationObserver/useMutationObserver.cjs.map +1 -1
- package/dist/cjs/hooks/useNetwork/useNetwork.cjs +1 -1
- package/dist/cjs/hooks/useNetwork/useNetwork.cjs.map +1 -1
- package/dist/cjs/hooks/useOffsetPagination/useOffsetPagination.cjs.map +1 -1
- package/dist/cjs/hooks/useOnce/useOnce.cjs.map +1 -1
- package/dist/cjs/hooks/useOnline/useOnline.cjs.map +1 -1
- package/dist/cjs/hooks/useOperatingSystem/useOperatingSystem.cjs.map +1 -1
- package/dist/cjs/hooks/useOptimistic/useOptimistic.cjs.map +1 -1
- package/dist/cjs/hooks/useOrientation/useOrientation.cjs.map +1 -1
- package/dist/cjs/hooks/useOtpCredential/useOtpCredential.cjs +1 -1
- package/dist/cjs/hooks/useOtpCredential/useOtpCredential.cjs.map +1 -1
- package/dist/cjs/hooks/usePageLeave/usePageLeave.cjs +1 -1
- package/dist/cjs/hooks/usePageLeave/usePageLeave.cjs.map +1 -1
- package/dist/cjs/hooks/usePaint/usePaint.cjs +1 -1
- package/dist/cjs/hooks/usePaint/usePaint.cjs.map +1 -1
- package/dist/cjs/hooks/useParallax/useParallax.cjs.map +1 -1
- package/dist/cjs/hooks/usePerformanceObserver/usePerformanceObserver.cjs +1 -1
- package/dist/cjs/hooks/usePerformanceObserver/usePerformanceObserver.cjs.map +1 -1
- package/dist/cjs/hooks/usePermission/usePermission.cjs +1 -1
- package/dist/cjs/hooks/usePermission/usePermission.cjs.map +1 -1
- package/dist/cjs/hooks/usePointerLock/usePointerLock.cjs.map +1 -1
- package/dist/cjs/hooks/usePostMessage/usePostMessage.cjs.map +1 -1
- package/dist/cjs/hooks/usePreferredColorScheme/usePreferredColorScheme.cjs.map +1 -1
- package/dist/cjs/hooks/usePreferredContrast/usePreferredContrast.cjs.map +1 -1
- package/dist/cjs/hooks/usePreferredLanguages/usePreferredLanguages.cjs.map +1 -1
- package/dist/cjs/hooks/usePreferredReducedMotion/usePreferredReducedMotion.cjs.map +1 -1
- package/dist/cjs/hooks/usePrevious/usePrevious.cjs +1 -1
- package/dist/cjs/hooks/usePrevious/usePrevious.cjs.map +1 -1
- package/dist/cjs/hooks/useQuery/useQuery.cjs +1 -1
- package/dist/cjs/hooks/useQuery/useQuery.cjs.map +1 -1
- package/dist/cjs/hooks/useQueue/useQueue.cjs.map +1 -1
- package/dist/cjs/hooks/useRaf/useRaf.cjs +1 -1
- package/dist/cjs/hooks/useRaf/useRaf.cjs.map +1 -1
- package/dist/cjs/hooks/useRafValue/useRafValue.cjs.map +1 -1
- package/dist/cjs/hooks/useRefState/useRefState.cjs.map +1 -1
- package/dist/cjs/hooks/useRenderCount/useRenderCount.cjs.map +1 -1
- package/dist/cjs/hooks/useRenderInfo/useRenderInfo.cjs.map +1 -1
- package/dist/cjs/hooks/useRerender/useRerender.cjs.map +1 -1
- package/dist/cjs/hooks/useResizeObserver/useResizeObserver.cjs +1 -1
- package/dist/cjs/hooks/useResizeObserver/useResizeObserver.cjs.map +1 -1
- package/dist/cjs/hooks/useScreenOrientation/useScreenOrientation.cjs +1 -1
- package/dist/cjs/hooks/useScreenOrientation/useScreenOrientation.cjs.map +1 -1
- package/dist/cjs/hooks/useScript/useScript.cjs +1 -1
- package/dist/cjs/hooks/useScript/useScript.cjs.map +1 -1
- package/dist/cjs/hooks/useScroll/useScroll.cjs +1 -1
- package/dist/cjs/hooks/useScroll/useScroll.cjs.map +1 -1
- package/dist/cjs/hooks/useScrollIntoView/useScrollIntoView.cjs.map +1 -1
- package/dist/cjs/hooks/useScrollTo/useScrollTo.cjs.map +1 -1
- package/dist/cjs/hooks/useSet/useSet.cjs.map +1 -1
- package/dist/cjs/hooks/useShare/useShare.cjs.map +1 -1
- package/dist/cjs/hooks/useSpeechRecognition/useSpeechRecognition.cjs +1 -1
- package/dist/cjs/hooks/useSpeechRecognition/useSpeechRecognition.cjs.map +1 -1
- package/dist/cjs/hooks/useSpeechSynthesis/useSpeechSynthesis.cjs +1 -1
- package/dist/cjs/hooks/useSpeechSynthesis/useSpeechSynthesis.cjs.map +1 -1
- package/dist/cjs/hooks/useStateHistory/useStateHistory.cjs.map +1 -1
- package/dist/cjs/hooks/useStep/useStep.cjs.map +1 -1
- package/dist/cjs/hooks/useSticky/useSticky.cjs +1 -1
- package/dist/cjs/hooks/useSticky/useSticky.cjs.map +1 -1
- package/dist/cjs/hooks/useStopwatch/useStopwatch.cjs +1 -1
- package/dist/cjs/hooks/useStopwatch/useStopwatch.cjs.map +1 -1
- package/dist/cjs/hooks/useStorage/useStorage.cjs +1 -1
- package/dist/cjs/hooks/useStorage/useStorage.cjs.map +1 -1
- package/dist/cjs/hooks/useTextDirection/useTextDirection.cjs +1 -1
- package/dist/cjs/hooks/useTextDirection/useTextDirection.cjs.map +1 -1
- package/dist/cjs/hooks/useTextSelection/useTextSelection.cjs +1 -1
- package/dist/cjs/hooks/useTextSelection/useTextSelection.cjs.map +1 -1
- package/dist/cjs/hooks/useThrottleCallback/useThrottleCallback.cjs.map +1 -1
- package/dist/cjs/hooks/useThrottleValue/useThrottleValue.cjs.map +1 -1
- package/dist/cjs/hooks/useTime/useTime.cjs.map +1 -1
- package/dist/cjs/hooks/useTimeout/useTimeout.cjs.map +1 -1
- package/dist/cjs/hooks/useTimer/useTimer.cjs +1 -1
- package/dist/cjs/hooks/useTimer/useTimer.cjs.map +1 -1
- package/dist/cjs/hooks/useToggle/useToggle.cjs.map +1 -1
- package/dist/cjs/hooks/useUnmount/useUnmount.cjs.map +1 -1
- package/dist/cjs/hooks/useUrlSearchParam/useUrlSearchParam.cjs +1 -1
- package/dist/cjs/hooks/useUrlSearchParam/useUrlSearchParam.cjs.map +1 -1
- package/dist/cjs/hooks/useUrlSearchParams/useUrlSearchParams.cjs +1 -1
- package/dist/cjs/hooks/useUrlSearchParams/useUrlSearchParams.cjs.map +1 -1
- package/dist/cjs/hooks/useVibrate/useVibrate.cjs.map +1 -1
- package/dist/cjs/hooks/useWakeLock/useWakeLock.cjs +1 -1
- package/dist/cjs/hooks/useWakeLock/useWakeLock.cjs.map +1 -1
- package/dist/cjs/hooks/useWebSocket/useWebSocket.cjs +1 -1
- package/dist/cjs/hooks/useWebSocket/useWebSocket.cjs.map +1 -1
- package/dist/cjs/hooks/useWindowEvent/useWindowEvent.cjs.map +1 -1
- package/dist/cjs/hooks/useWindowFocus/useWindowFocus.cjs.map +1 -1
- package/dist/cjs/hooks/useWindowScroll/useWindowScroll.cjs.map +1 -1
- package/dist/cjs/hooks/useWindowSize/useWindowSize.cjs +1 -1
- package/dist/cjs/hooks/useWindowSize/useWindowSize.cjs.map +1 -1
- package/dist/cjs/hooks/useWizard/useWizard.cjs +1 -1
- package/dist/cjs/hooks/useWizard/useWizard.cjs.map +1 -1
- package/dist/cjs/utils/helpers/copy.cjs.map +1 -1
- package/dist/cjs/utils/helpers/debounce.cjs.map +1 -1
- package/dist/cjs/utils/helpers/getDate.cjs.map +1 -1
- package/dist/cjs/utils/helpers/getElement.cjs.map +1 -1
- package/dist/cjs/utils/helpers/getRetry.cjs.map +1 -1
- package/dist/cjs/utils/helpers/isTarget.cjs.map +1 -1
- package/dist/cjs/utils/helpers/throttle.cjs.map +1 -1
- package/dist/esm/helpers/createContext/createContext.mjs.map +1 -1
- package/dist/esm/helpers/createReactiveContext/createReactiveContext.mjs.map +1 -1
- package/dist/esm/helpers/createStore/createStore.mjs.map +1 -1
- package/dist/esm/hooks/useActiveElement/useActiveElement.mjs +1 -1
- package/dist/esm/hooks/useActiveElement/useActiveElement.mjs.map +1 -1
- package/dist/esm/hooks/useAsync/useAsync.mjs.map +1 -1
- package/dist/esm/hooks/useBattery/useBattery.mjs +10 -10
- package/dist/esm/hooks/useBattery/useBattery.mjs.map +1 -1
- package/dist/esm/hooks/useBluetooth/useBluetooth.mjs +14 -15
- package/dist/esm/hooks/useBluetooth/useBluetooth.mjs.map +1 -1
- package/dist/esm/hooks/useBoolean/useBoolean.mjs.map +1 -1
- package/dist/esm/hooks/useBreakpoints/useBreakpoints.mjs.map +1 -1
- package/dist/esm/hooks/useBrowserLanguage/useBrowserLanguage.mjs.map +1 -1
- package/dist/esm/hooks/useClickOutside/useClickOutside.mjs.map +1 -1
- package/dist/esm/hooks/useClipboard/useClipboard.mjs +13 -14
- package/dist/esm/hooks/useClipboard/useClipboard.mjs.map +1 -1
- package/dist/esm/hooks/useConst/useConst.mjs.map +1 -1
- package/dist/esm/hooks/useCookie/useCookie.mjs +27 -27
- package/dist/esm/hooks/useCookie/useCookie.mjs.map +1 -1
- package/dist/esm/hooks/useCookies/useCookies.mjs +19 -19
- package/dist/esm/hooks/useCookies/useCookies.mjs.map +1 -1
- package/dist/esm/hooks/useCopy/useCopy.mjs.map +1 -1
- package/dist/esm/hooks/useCounter/useCounter.mjs +5 -6
- package/dist/esm/hooks/useCounter/useCounter.mjs.map +1 -1
- package/dist/esm/hooks/useCssVar/useCssVar.mjs +13 -14
- package/dist/esm/hooks/useCssVar/useCssVar.mjs.map +1 -1
- package/dist/esm/hooks/useDebounceCallback/useDebounceCallback.mjs.map +1 -1
- package/dist/esm/hooks/useDebounceValue/useDebounceValue.mjs.map +1 -1
- package/dist/esm/hooks/useDefault/useDefault.mjs.map +1 -1
- package/dist/esm/hooks/useDeviceMotion/useDeviceMotion.mjs +18 -19
- package/dist/esm/hooks/useDeviceMotion/useDeviceMotion.mjs.map +1 -1
- package/dist/esm/hooks/useDeviceOrientation/useDeviceOrientation.mjs.map +1 -1
- package/dist/esm/hooks/useDevicePixelRatio/useDevicePixelRatio.mjs.map +1 -1
- package/dist/esm/hooks/useDidUpdate/useDidUpdate.mjs.map +1 -1
- package/dist/esm/hooks/useDisclosure/useDisclosure.mjs +5 -11
- package/dist/esm/hooks/useDisclosure/useDisclosure.mjs.map +1 -1
- package/dist/esm/hooks/useDisplayMedia/useDisplayMedia.mjs +28 -28
- package/dist/esm/hooks/useDisplayMedia/useDisplayMedia.mjs.map +1 -1
- package/dist/esm/hooks/useDocumentEvent/useDocumentEvent.mjs.map +1 -1
- package/dist/esm/hooks/useDocumentTitle/useDocumentTitle.mjs +15 -15
- package/dist/esm/hooks/useDocumentTitle/useDocumentTitle.mjs.map +1 -1
- package/dist/esm/hooks/useDocumentVisibility/useDocumentVisibility.mjs.map +1 -1
- package/dist/esm/hooks/useDoubleClick/useDoubleClick.mjs +11 -13
- package/dist/esm/hooks/useDoubleClick/useDoubleClick.mjs.map +1 -1
- package/dist/esm/hooks/useDropZone/useDropZone.mjs +27 -28
- package/dist/esm/hooks/useDropZone/useDropZone.mjs.map +1 -1
- package/dist/esm/hooks/useElementSize/useElementSize.mjs.map +1 -1
- package/dist/esm/hooks/useEvent/useEvent.mjs.map +1 -1
- package/dist/esm/hooks/useEventListener/useEventListener.mjs.map +1 -1
- package/dist/esm/hooks/useEventSource/useEventSource.mjs +37 -40
- package/dist/esm/hooks/useEventSource/useEventSource.mjs.map +1 -1
- package/dist/esm/hooks/useEyeDropper/useEyeDropper.mjs.map +1 -1
- package/dist/esm/hooks/useFavicon/useFavicon.mjs +11 -12
- package/dist/esm/hooks/useFavicon/useFavicon.mjs.map +1 -1
- package/dist/esm/hooks/useField/useField.mjs +45 -49
- package/dist/esm/hooks/useField/useField.mjs.map +1 -1
- package/dist/esm/hooks/useFileDialog/useFileDialog.mjs +22 -25
- package/dist/esm/hooks/useFileDialog/useFileDialog.mjs.map +1 -1
- package/dist/esm/hooks/useFocus/useFocus.mjs +24 -32
- package/dist/esm/hooks/useFocus/useFocus.mjs.map +1 -1
- package/dist/esm/hooks/useFps/useFps.mjs.map +1 -1
- package/dist/esm/hooks/useFul/useFul.mjs.map +1 -1
- package/dist/esm/hooks/useFullscreen/useFullscreen.mjs +23 -24
- package/dist/esm/hooks/useFullscreen/useFullscreen.mjs.map +1 -1
- package/dist/esm/hooks/useGamepad/useGamepad.mjs.map +1 -1
- package/dist/esm/hooks/useGeolocation/useGeolocation.mjs +24 -24
- package/dist/esm/hooks/useGeolocation/useGeolocation.mjs.map +1 -1
- package/dist/esm/hooks/useHash/useHash.mjs.map +1 -1
- package/dist/esm/hooks/useHotkeys/useHotkeys.mjs +24 -25
- package/dist/esm/hooks/useHotkeys/useHotkeys.mjs.map +1 -1
- package/dist/esm/hooks/useHover/useHover.mjs +20 -22
- package/dist/esm/hooks/useHover/useHover.mjs.map +1 -1
- package/dist/esm/hooks/useIdle/useIdle.mjs.map +1 -1
- package/dist/esm/hooks/useImage/useImage.mjs.map +1 -1
- package/dist/esm/hooks/useInfiniteScroll/useInfiniteScroll.mjs +14 -14
- package/dist/esm/hooks/useInfiniteScroll/useInfiniteScroll.mjs.map +1 -1
- package/dist/esm/hooks/useIntersectionObserver/useIntersectionObserver.mjs +19 -20
- package/dist/esm/hooks/useIntersectionObserver/useIntersectionObserver.mjs.map +1 -1
- package/dist/esm/hooks/useInterval/useInterval.mjs +8 -8
- package/dist/esm/hooks/useInterval/useInterval.mjs.map +1 -1
- package/dist/esm/hooks/useIsFirstRender/useIsFirstRender.mjs.map +1 -1
- package/dist/esm/hooks/useKeyPress/useKeyPress.mjs +22 -24
- package/dist/esm/hooks/useKeyPress/useKeyPress.mjs.map +1 -1
- package/dist/esm/hooks/useKeyPressEvent/useKeyPressEvent.mjs +23 -23
- package/dist/esm/hooks/useKeyPressEvent/useKeyPressEvent.mjs.map +1 -1
- package/dist/esm/hooks/useKeyboard/useKeyboard.mjs +16 -22
- package/dist/esm/hooks/useKeyboard/useKeyboard.mjs.map +1 -1
- package/dist/esm/hooks/useKeysPressed/useKeysPressed.mjs +20 -20
- package/dist/esm/hooks/useKeysPressed/useKeysPressed.mjs.map +1 -1
- package/dist/esm/hooks/useLastChanged/useLastChanged.mjs +6 -6
- package/dist/esm/hooks/useLastChanged/useLastChanged.mjs.map +1 -1
- package/dist/esm/hooks/useLatest/useLatest.mjs +12 -4
- package/dist/esm/hooks/useLatest/useLatest.mjs.map +1 -1
- package/dist/esm/hooks/useLess/useLess.mjs.map +1 -1
- package/dist/esm/hooks/useList/useList.mjs.map +1 -1
- package/dist/esm/hooks/useLockCallback/useLockCallback.mjs.map +1 -1
- package/dist/esm/hooks/useLogger/useLogger.mjs.map +1 -1
- package/dist/esm/hooks/useLongPress/useLongPress.mjs +23 -27
- package/dist/esm/hooks/useLongPress/useLongPress.mjs.map +1 -1
- package/dist/esm/hooks/useMap/useMap.mjs.map +1 -1
- package/dist/esm/hooks/useMeasure/useMeasure.mjs.map +1 -1
- package/dist/esm/hooks/useMediaQuery/useMediaQuery.mjs.map +1 -1
- package/dist/esm/hooks/useMemory/useMemory.mjs +1 -1
- package/dist/esm/hooks/useMemory/useMemory.mjs.map +1 -1
- package/dist/esm/hooks/useMount/useMount.mjs.map +1 -1
- package/dist/esm/hooks/useMouse/useMouse.mjs.map +1 -1
- package/dist/esm/hooks/useMutation/useMutation.mjs +38 -42
- package/dist/esm/hooks/useMutation/useMutation.mjs.map +1 -1
- package/dist/esm/hooks/useMutationObserver/useMutationObserver.mjs +12 -12
- package/dist/esm/hooks/useMutationObserver/useMutationObserver.mjs.map +1 -1
- package/dist/esm/hooks/useNetwork/useNetwork.mjs +28 -28
- package/dist/esm/hooks/useNetwork/useNetwork.mjs.map +1 -1
- package/dist/esm/hooks/useOffsetPagination/useOffsetPagination.mjs.map +1 -1
- package/dist/esm/hooks/useOnce/useOnce.mjs.map +1 -1
- package/dist/esm/hooks/useOnline/useOnline.mjs.map +1 -1
- package/dist/esm/hooks/useOperatingSystem/useOperatingSystem.mjs.map +1 -1
- package/dist/esm/hooks/useOptimistic/useOptimistic.mjs.map +1 -1
- package/dist/esm/hooks/useOrientation/useOrientation.mjs.map +1 -1
- package/dist/esm/hooks/useOtpCredential/useOtpCredential.mjs +12 -13
- package/dist/esm/hooks/useOtpCredential/useOtpCredential.mjs.map +1 -1
- package/dist/esm/hooks/usePageLeave/usePageLeave.mjs +6 -6
- package/dist/esm/hooks/usePageLeave/usePageLeave.mjs.map +1 -1
- package/dist/esm/hooks/usePaint/usePaint.mjs +87 -93
- package/dist/esm/hooks/usePaint/usePaint.mjs.map +1 -1
- package/dist/esm/hooks/useParallax/useParallax.mjs.map +1 -1
- package/dist/esm/hooks/usePerformanceObserver/usePerformanceObserver.mjs +17 -19
- package/dist/esm/hooks/usePerformanceObserver/usePerformanceObserver.mjs.map +1 -1
- package/dist/esm/hooks/usePermission/usePermission.mjs +13 -13
- package/dist/esm/hooks/usePermission/usePermission.mjs.map +1 -1
- package/dist/esm/hooks/usePointerLock/usePointerLock.mjs.map +1 -1
- package/dist/esm/hooks/usePostMessage/usePostMessage.mjs.map +1 -1
- package/dist/esm/hooks/usePreferredColorScheme/usePreferredColorScheme.mjs.map +1 -1
- package/dist/esm/hooks/usePreferredContrast/usePreferredContrast.mjs.map +1 -1
- package/dist/esm/hooks/usePreferredDark/usePreferredDark.mjs.map +1 -1
- package/dist/esm/hooks/usePreferredLanguages/usePreferredLanguages.mjs.map +1 -1
- package/dist/esm/hooks/usePrevious/usePrevious.mjs +4 -4
- package/dist/esm/hooks/usePrevious/usePrevious.mjs.map +1 -1
- package/dist/esm/hooks/useQuery/useQuery.mjs +39 -41
- package/dist/esm/hooks/useQuery/useQuery.mjs.map +1 -1
- package/dist/esm/hooks/useQueue/useQueue.mjs.map +1 -1
- package/dist/esm/hooks/useRaf/useRaf.mjs +21 -21
- package/dist/esm/hooks/useRaf/useRaf.mjs.map +1 -1
- package/dist/esm/hooks/useRafValue/useRafValue.mjs.map +1 -1
- package/dist/esm/hooks/useRefState/useRefState.mjs.map +1 -1
- package/dist/esm/hooks/useRenderCount/useRenderCount.mjs.map +1 -1
- package/dist/esm/hooks/useRenderInfo/useRenderInfo.mjs.map +1 -1
- package/dist/esm/hooks/useRerender/useRerender.mjs.map +1 -1
- package/dist/esm/hooks/useResizeObserver/useResizeObserver.mjs +16 -17
- package/dist/esm/hooks/useResizeObserver/useResizeObserver.mjs.map +1 -1
- package/dist/esm/hooks/useScreenOrientation/useScreenOrientation.mjs +11 -11
- package/dist/esm/hooks/useScreenOrientation/useScreenOrientation.mjs.map +1 -1
- package/dist/esm/hooks/useScript/useScript.mjs +16 -16
- package/dist/esm/hooks/useScript/useScript.mjs.map +1 -1
- package/dist/esm/hooks/useScroll/useScroll.mjs +37 -39
- package/dist/esm/hooks/useScroll/useScroll.mjs.map +1 -1
- package/dist/esm/hooks/useScrollIntoView/useScrollIntoView.mjs.map +1 -1
- package/dist/esm/hooks/useScrollTo/useScrollTo.mjs.map +1 -1
- package/dist/esm/hooks/useSet/useSet.mjs.map +1 -1
- package/dist/esm/hooks/useShare/useShare.mjs.map +1 -1
- package/dist/esm/hooks/useSpeechRecognition/useSpeechRecognition.mjs +35 -35
- package/dist/esm/hooks/useSpeechRecognition/useSpeechRecognition.mjs.map +1 -1
- package/dist/esm/hooks/useSpeechSynthesis/useSpeechSynthesis.mjs +36 -42
- package/dist/esm/hooks/useSpeechSynthesis/useSpeechSynthesis.mjs.map +1 -1
- package/dist/esm/hooks/useStateHistory/useStateHistory.mjs.map +1 -1
- package/dist/esm/hooks/useStep/useStep.mjs.map +1 -1
- package/dist/esm/hooks/useSticky/useSticky.mjs +12 -12
- package/dist/esm/hooks/useSticky/useSticky.mjs.map +1 -1
- package/dist/esm/hooks/useStopwatch/useStopwatch.mjs +10 -11
- package/dist/esm/hooks/useStopwatch/useStopwatch.mjs.map +1 -1
- package/dist/esm/hooks/useStorage/useStorage.mjs +27 -27
- package/dist/esm/hooks/useStorage/useStorage.mjs.map +1 -1
- package/dist/esm/hooks/useTextDirection/useTextDirection.mjs +21 -24
- package/dist/esm/hooks/useTextDirection/useTextDirection.mjs.map +1 -1
- package/dist/esm/hooks/useTextSelection/useTextSelection.mjs +7 -7
- package/dist/esm/hooks/useTextSelection/useTextSelection.mjs.map +1 -1
- package/dist/esm/hooks/useThrottleCallback/useThrottleCallback.mjs.map +1 -1
- package/dist/esm/hooks/useThrottleValue/useThrottleValue.mjs.map +1 -1
- package/dist/esm/hooks/useTime/useTime.mjs.map +1 -1
- package/dist/esm/hooks/useTimeout/useTimeout.mjs.map +1 -1
- package/dist/esm/hooks/useTimer/useTimer.mjs +51 -54
- package/dist/esm/hooks/useTimer/useTimer.mjs.map +1 -1
- package/dist/esm/hooks/useToggle/useToggle.mjs.map +1 -1
- package/dist/esm/hooks/useUnmount/useUnmount.mjs.map +1 -1
- package/dist/esm/hooks/useUrlSearchParam/useUrlSearchParam.mjs +38 -38
- package/dist/esm/hooks/useUrlSearchParam/useUrlSearchParam.mjs.map +1 -1
- package/dist/esm/hooks/useUrlSearchParams/useUrlSearchParams.mjs +29 -29
- package/dist/esm/hooks/useUrlSearchParams/useUrlSearchParams.mjs.map +1 -1
- package/dist/esm/hooks/useVibrate/useVibrate.mjs.map +1 -1
- package/dist/esm/hooks/useWakeLock/useWakeLock.mjs +16 -16
- package/dist/esm/hooks/useWakeLock/useWakeLock.mjs.map +1 -1
- package/dist/esm/hooks/useWebSocket/useWebSocket.mjs +28 -38
- package/dist/esm/hooks/useWebSocket/useWebSocket.mjs.map +1 -1
- package/dist/esm/hooks/useWindowEvent/useWindowEvent.mjs.map +1 -1
- package/dist/esm/hooks/useWindowFocus/useWindowFocus.mjs.map +1 -1
- package/dist/esm/hooks/useWindowScroll/useWindowScroll.mjs.map +1 -1
- package/dist/esm/hooks/useWindowSize/useWindowSize.mjs +9 -9
- package/dist/esm/hooks/useWindowSize/useWindowSize.mjs.map +1 -1
- package/dist/esm/hooks/useWizard/useWizard.mjs +9 -11
- package/dist/esm/hooks/useWizard/useWizard.mjs.map +1 -1
- package/dist/esm/utils/helpers/copy.mjs.map +1 -1
- package/dist/esm/utils/helpers/debounce.mjs.map +1 -1
- package/dist/esm/utils/helpers/getDate.mjs.map +1 -1
- package/dist/esm/utils/helpers/getElement.mjs.map +1 -1
- package/dist/esm/utils/helpers/getRetry.mjs.map +1 -1
- package/dist/esm/utils/helpers/isTarget.mjs.map +1 -1
- package/dist/esm/utils/helpers/throttle.mjs.map +1 -1
- package/dist/types/hooks/useLatest/useLatest.d.ts +7 -2
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWebSocket.cjs","sources":["../../../../src/hooks/useWebSocket/useWebSocket.ts"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\n\nimport { getRetry } from '@/utils/helpers';\n\nimport { useEvent } from '../useEvent/useEvent';\n\nexport type UseWebSocketUrl = (() => string) | string;\n\nexport interface UseWebSocketOptions {\n protocols?: Array<'soap' | 'wasm'>;\n retry?: boolean | number;\n onConnected?: (webSocket: WebSocket) => void;\n onDisconnected?: (event: CloseEvent, webSocket: WebSocket) => void;\n onError?: (event: Event, webSocket: WebSocket) => void;\n onMessage?: (event: MessageEvent, webSocket: WebSocket) => void;\n}\n\nexport type UseWebSocketStatus = 'connected' | 'connecting' | 'disconnected' | 'failed';\n\nexport interface UseWebSocketReturn {\n client?: WebSocket;\n close: WebSocket['close'];\n send: WebSocket['send'];\n status: UseWebSocketStatus;\n open: () => void;\n}\n\n/**\n * @name useWebSocket\n * @description - Hook that connects to a WebSocket server and handles incoming and outgoing messages\n * @category Browser\n *\n * @param {UseWebSocketUrl} url The URL of the WebSocket server\n * @param {(webSocket: WebSocket) => void} [options.onConnected] The callback function that is called when the WebSocket connection is established\n * @param {(event: CloseEvent, webSocket: WebSocket) => void} [options.onDisconnected] The callback function that is called when the WebSocket connection is closed\n * @param {(event: Event, webSocket: WebSocket) => void} [options.onError] The callback function that is called when an error occurs\n * @param {(event: MessageEvent, webSocket: WebSocket) => void} [options.onMessage] The callback function that is called when a message is received\n * @param {boolean | number} [options.retry] The number of times to retry the connection\n * @param {Array<'soap' | 'wasm'>} [options.protocols] The list of protocols to use\n * @returns {UseWebSocketReturn} An object with the status, close, send, open, and ws properties\n *\n * @example\n * const { status, close, send, open, client } = useWebSocket('url');\n */\nexport const useWebSocket = (\n url: UseWebSocketUrl,\n options?: UseWebSocketOptions\n): UseWebSocketReturn => {\n const webSocketRef = useRef<WebSocket>(undefined);\n const retryCountRef = useRef(options?.retry ? getRetry(options.retry) : 0);\n const explicityCloseRef = useRef(false);\n\n const [status, setStatus] = useState<UseWebSocketStatus>('connecting');\n\n const send = (data: string | ArrayBufferLike | ArrayBufferView | Blob) =>\n webSocketRef.current?.send(data);\n\n const close = () => {\n explicityCloseRef.current = true;\n webSocketRef.current?.close();\n };\n\n const init = useEvent(() => {\n webSocketRef.current = new WebSocket(\n typeof url === 'function' ? url() : url,\n options?.protocols\n );\n setStatus('connecting');\n\n const webSocket = webSocketRef.current;\n if (!webSocket) return;\n\n webSocket.onopen = () => {\n setStatus('connected');\n options?.onConnected?.(webSocket);\n };\n\n webSocket.onerror = (event) => {\n setStatus('failed');\n options?.onError?.(event, webSocket);\n };\n\n webSocket.onmessage = (event) => options?.onMessage?.(event, webSocket);\n\n webSocket.onclose = (event) => {\n setStatus('disconnected');\n options?.onDisconnected?.(event, webSocket);\n if (explicityCloseRef.current) return;\n\n if (retryCountRef.current > 0) {\n retryCountRef.current -= 1;\n return init();\n }\n retryCountRef.current = options?.retry ? getRetry(options.retry) : 0;\n };\n });\n\n useEffect(() => {\n init();\n\n return () => {\n if (!webSocketRef.current) return;\n webSocketRef.current.close();\n webSocketRef.current = undefined;\n };\n }, [url]);\n\n const open = () => {\n explicityCloseRef.current = false;\n init();\n };\n\n return { client: webSocketRef.current, close, open, send, status };\n};\n"],"names":["useWebSocket","url","options","webSocketRef","useRef","retryCountRef","getRetry","explicityCloseRef","status","setStatus","useState","send","data","
|
|
1
|
+
{"version":3,"file":"useWebSocket.cjs","sources":["../../../../src/hooks/useWebSocket/useWebSocket.ts"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\n\nimport { getRetry } from '@/utils/helpers';\n\nimport { useEvent } from '../useEvent/useEvent';\n\nexport type UseWebSocketUrl = (() => string) | string;\n\nexport interface UseWebSocketOptions {\n protocols?: Array<'soap' | 'wasm'>;\n retry?: boolean | number;\n onConnected?: (webSocket: WebSocket) => void;\n onDisconnected?: (event: CloseEvent, webSocket: WebSocket) => void;\n onError?: (event: Event, webSocket: WebSocket) => void;\n onMessage?: (event: MessageEvent, webSocket: WebSocket) => void;\n}\n\nexport type UseWebSocketStatus = 'connected' | 'connecting' | 'disconnected' | 'failed';\n\nexport interface UseWebSocketReturn {\n client?: WebSocket;\n close: WebSocket['close'];\n send: WebSocket['send'];\n status: UseWebSocketStatus;\n open: () => void;\n}\n\n/**\n * @name useWebSocket\n * @description - Hook that connects to a WebSocket server and handles incoming and outgoing messages\n * @category Browser\n *\n * @param {UseWebSocketUrl} url The URL of the WebSocket server\n * @param {(webSocket: WebSocket) => void} [options.onConnected] The callback function that is called when the WebSocket connection is established\n * @param {(event: CloseEvent, webSocket: WebSocket) => void} [options.onDisconnected] The callback function that is called when the WebSocket connection is closed\n * @param {(event: Event, webSocket: WebSocket) => void} [options.onError] The callback function that is called when an error occurs\n * @param {(event: MessageEvent, webSocket: WebSocket) => void} [options.onMessage] The callback function that is called when a message is received\n * @param {boolean | number} [options.retry] The number of times to retry the connection\n * @param {Array<'soap' | 'wasm'>} [options.protocols] The list of protocols to use\n * @returns {UseWebSocketReturn} An object with the status, close, send, open, and ws properties\n *\n * @example\n * const { status, close, send, open, client } = useWebSocket('url');\n */\nexport const useWebSocket = (\n url: UseWebSocketUrl,\n options?: UseWebSocketOptions\n): UseWebSocketReturn => {\n const webSocketRef = useRef<WebSocket>(undefined);\n const retryCountRef = useRef(options?.retry ? getRetry(options.retry) : 0);\n const explicityCloseRef = useRef(false);\n\n const [status, setStatus] = useState<UseWebSocketStatus>('connecting');\n\n const send = (data: string | ArrayBufferLike | ArrayBufferView | Blob) =>\n webSocketRef.current?.send(data);\n\n const close = () => {\n explicityCloseRef.current = true;\n webSocketRef.current?.close();\n };\n\n const init = useEvent(() => {\n webSocketRef.current = new WebSocket(\n typeof url === 'function' ? url() : url,\n options?.protocols\n );\n setStatus('connecting');\n\n const webSocket = webSocketRef.current;\n if (!webSocket) return;\n\n webSocket.onopen = () => {\n setStatus('connected');\n options?.onConnected?.(webSocket);\n };\n\n webSocket.onerror = (event) => {\n setStatus('failed');\n options?.onError?.(event, webSocket);\n };\n\n webSocket.onmessage = (event) => options?.onMessage?.(event, webSocket);\n\n webSocket.onclose = (event) => {\n setStatus('disconnected');\n options?.onDisconnected?.(event, webSocket);\n if (explicityCloseRef.current) return;\n\n if (retryCountRef.current > 0) {\n retryCountRef.current -= 1;\n return init();\n }\n retryCountRef.current = options?.retry ? getRetry(options.retry) : 0;\n };\n });\n\n useEffect(() => {\n init();\n\n return () => {\n if (!webSocketRef.current) return;\n webSocketRef.current.close();\n webSocketRef.current = undefined;\n };\n }, [url]);\n\n const open = () => {\n explicityCloseRef.current = false;\n init();\n };\n\n return { client: webSocketRef.current, close, open, send, status };\n};\n"],"names":["useWebSocket","url","options","webSocketRef","useRef","retryCountRef","getRetry","explicityCloseRef","status","setStatus","useState","send","data","close","init","useEvent","webSocket","event","useEffect","open"],"mappings":"6LA4CaA,EAAe,CAC1BC,EACAC,IACuB,CACvB,MAAMC,EAAeC,EAAAA,OAAkB,MAAS,EAC1CC,EAAgBD,EAAAA,OAAOF,GAAS,MAAQI,EAAAA,SAASJ,EAAQ,KAAK,EAAI,CAAC,EACnEK,EAAoBH,EAAAA,OAAO,EAAK,EAEhC,CAACI,EAAQC,CAAS,EAAIC,EAAAA,SAA6B,YAAY,EAE/DC,EAAQC,GACZT,EAAa,SAAS,KAAKS,CAAI,EAE3BC,EAAQ,IAAM,CAClBN,EAAkB,QAAU,GAC5BJ,EAAa,SAAS,MAAA,CAAM,EAGxBW,EAAOC,EAAAA,SAAS,IAAM,CAC1BZ,EAAa,QAAU,IAAI,UACzB,OAAOF,GAAQ,WAAaA,EAAA,EAAQA,EACpCC,GAAS,SAAA,EAEXO,EAAU,YAAY,EAEtB,MAAMO,EAAYb,EAAa,QAC1Ba,IAELA,EAAU,OAAS,IAAM,CACvBP,EAAU,WAAW,EACrBP,GAAS,cAAcc,CAAS,CAAA,EAGlCA,EAAU,QAAWC,GAAU,CAC7BR,EAAU,QAAQ,EAClBP,GAAS,UAAUe,EAAOD,CAAS,CAAA,EAGrCA,EAAU,UAAaC,GAAUf,GAAS,YAAYe,EAAOD,CAAS,EAEtEA,EAAU,QAAWC,GAAU,CAG7B,GAFAR,EAAU,cAAc,EACxBP,GAAS,iBAAiBe,EAAOD,CAAS,EACtC,CAAAT,EAAkB,QAEtB,IAAIF,EAAc,QAAU,EAC1B,OAAAA,EAAc,SAAW,EAClBS,EAAA,EAETT,EAAc,QAAUH,GAAS,MAAQI,EAAAA,SAASJ,EAAQ,KAAK,EAAI,EAAA,EACrE,CACD,EAEDgB,EAAAA,UAAU,KACRJ,EAAA,EAEO,IAAM,CACNX,EAAa,UAClBA,EAAa,QAAQ,MAAA,EACrBA,EAAa,QAAU,OAAA,GAExB,CAACF,CAAG,CAAC,EAER,MAAMkB,EAAO,IAAM,CACjBZ,EAAkB,QAAU,GAC5BO,EAAA,CAAK,EAGP,MAAO,CAAE,OAAQX,EAAa,QAAS,MAAAU,EAAO,KAAAM,EAAM,KAAAR,EAAM,OAAAH,CAAA,CAC5D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWindowEvent.cjs","sources":["../../../../src/hooks/useWindowEvent/useWindowEvent.ts"],"sourcesContent":["import { target } from '@/utils/helpers';\n\nimport type { UseEventListenerOptions } from '../useEventListener/useEventListener';\n\nimport { useEventListener } from '../useEventListener/useEventListener';\n\n/**\n * @name useWindowEvent\n * @description - Hook attaches an event listener to the window object for the specified event\n * @category Browser\n *\n * @template Event Key of window event map.\n * @param {Event} event The event to listen for.\n * @param {(event: WindowEventMap[Event]) => void} listener The callback function to be executed when the event is triggered\n * @param {UseEventListenerOptions} [options] The options for the event listener\n * @returns {void}\n *\n * @example\n * useWindowEvent('click', () => console.log('clicked'));\n */\nexport const useWindowEvent = <Event extends keyof WindowEventMap>(\n event: Event,\n listener: (this: Window, event: WindowEventMap[Event]) => any,\n options?: UseEventListenerOptions\n) => useEventListener(target(window), event, listener, options);\n"],"names":["useWindowEvent","event","listener","options","useEventListener","target"],"mappings":"4LAoBaA,EAAiB,CAC5BC,EACAC,EACAC,IACGC,EAAAA,iBAAiBC,
|
|
1
|
+
{"version":3,"file":"useWindowEvent.cjs","sources":["../../../../src/hooks/useWindowEvent/useWindowEvent.ts"],"sourcesContent":["import { target } from '@/utils/helpers';\n\nimport type { UseEventListenerOptions } from '../useEventListener/useEventListener';\n\nimport { useEventListener } from '../useEventListener/useEventListener';\n\n/**\n * @name useWindowEvent\n * @description - Hook attaches an event listener to the window object for the specified event\n * @category Browser\n *\n * @template Event Key of window event map.\n * @param {Event} event The event to listen for.\n * @param {(event: WindowEventMap[Event]) => void} listener The callback function to be executed when the event is triggered\n * @param {UseEventListenerOptions} [options] The options for the event listener\n * @returns {void}\n *\n * @example\n * useWindowEvent('click', () => console.log('clicked'));\n */\nexport const useWindowEvent = <Event extends keyof WindowEventMap>(\n event: Event,\n listener: (this: Window, event: WindowEventMap[Event]) => any,\n options?: UseEventListenerOptions\n) => useEventListener(target(window), event, listener, options);\n"],"names":["useWindowEvent","event","listener","options","useEventListener","target"],"mappings":"4LAoBaA,EAAiB,CAC5BC,EACAC,EACAC,IACGC,EAAAA,iBAAiBC,EAAAA,OAAO,MAAM,EAAGJ,EAAOC,EAAUC,CAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWindowFocus.cjs","sources":["../../../../src/hooks/useWindowFocus/useWindowFocus.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\n/**\n * @name useWindowFocus\n * @description - Hook that provides the current focus state of the window\n * @category Elements\n *\n * @returns {boolean} The current focus state of the window\n *\n * @example\n * const focused = useWindowFocus();\n *\n * @see {@link https://siberiacancode.github.io/reactuse/functions/hooks/useWindowFocus.html}\n */\nexport const useWindowFocus = () => {\n const [focused, setFocused] = useState(false);\n\n useEffect(() => {\n const onFocus = () => setFocused(true);\n const onBlur = () => setFocused(false);\n\n window.addEventListener('focus', onFocus);\n window.addEventListener('blur', onBlur);\n\n return () => {\n window.removeEventListener('focus', onFocus);\n window.removeEventListener('blur', onBlur);\n };\n });\n\n return focused;\n};\n"],"names":["useWindowFocus","focused","setFocused","useState","useEffect","onFocus","onBlur"],"mappings":"yGAcaA,EAAiB,IAAM,CAClC,KAAM,CAACC,EAASC,CAAU,EAAIC,EAAAA,SAAS,EAAK,EAE5CC,OAAAA,EAAAA,UAAU,IAAM,
|
|
1
|
+
{"version":3,"file":"useWindowFocus.cjs","sources":["../../../../src/hooks/useWindowFocus/useWindowFocus.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\n/**\n * @name useWindowFocus\n * @description - Hook that provides the current focus state of the window\n * @category Elements\n *\n * @returns {boolean} The current focus state of the window\n *\n * @example\n * const focused = useWindowFocus();\n *\n * @see {@link https://siberiacancode.github.io/reactuse/functions/hooks/useWindowFocus.html}\n */\nexport const useWindowFocus = () => {\n const [focused, setFocused] = useState(false);\n\n useEffect(() => {\n const onFocus = () => setFocused(true);\n const onBlur = () => setFocused(false);\n\n window.addEventListener('focus', onFocus);\n window.addEventListener('blur', onBlur);\n\n return () => {\n window.removeEventListener('focus', onFocus);\n window.removeEventListener('blur', onBlur);\n };\n });\n\n return focused;\n};\n"],"names":["useWindowFocus","focused","setFocused","useState","useEffect","onFocus","onBlur"],"mappings":"yGAcaA,EAAiB,IAAM,CAClC,KAAM,CAACC,EAASC,CAAU,EAAIC,EAAAA,SAAS,EAAK,EAE5CC,OAAAA,EAAAA,UAAU,IAAM,CACd,MAAMC,EAAU,IAAMH,EAAW,EAAI,EAC/BI,EAAS,IAAMJ,EAAW,EAAK,EAErC,cAAO,iBAAiB,QAASG,CAAO,EACxC,OAAO,iBAAiB,OAAQC,CAAM,EAE/B,IAAM,CACX,OAAO,oBAAoB,QAASD,CAAO,EAC3C,OAAO,oBAAoB,OAAQC,CAAM,CAAA,CAC3C,CACD,EAEML,CACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWindowScroll.cjs","sources":["../../../../src/hooks/useWindowScroll/useWindowScroll.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nexport interface ScrollPosition {\n x: number;\n y: number;\n}\n\nexport const scrollTo = ({\n x,\n y,\n behavior = 'smooth'\n}: Partial<ScrollPosition & ScrollOptions>) => {\n const scrollOptions: ScrollToOptions = { behavior };\n if (typeof x === 'number') scrollOptions.left = x;\n if (typeof y === 'number') scrollOptions.top = y;\n window.scrollTo(scrollOptions);\n};\n\n/**\n * @name useWindowScroll\n * @description - Hook that manages the window scroll position\n * @category Browser\n *\n * @returns {UseWindowScrollReturn} An object containing the current window scroll position\n *\n * @example\n * const { value, scrollTo } = useWindowScroll();\n */\nexport const useWindowScroll = () => {\n const [value, setValue] = useState<ScrollPosition>({\n x: typeof window !== 'undefined' ? window.scrollX : Number.POSITIVE_INFINITY,\n y: typeof window !== 'undefined' ? window.scrollY : Number.POSITIVE_INFINITY\n });\n\n useEffect(() => {\n const onChange = () => setValue({ x: window.scrollX, y: window.scrollY });\n window.addEventListener('scroll', onChange);\n window.addEventListener('resize', onChange);\n return () => {\n window.removeEventListener('scroll', onChange);\n window.removeEventListener('resize', onChange);\n };\n }, []);\n\n return { value, scrollTo };\n};\n"],"names":["scrollTo","x","y","behavior","scrollOptions","useWindowScroll","value","setValue","useState","useEffect","onChange"],"mappings":"yGAOaA,EAAW,CAAC,CACvB,EAAAC,EACA,EAAAC,EACA,SAAAC,EAAW,QACb,IAA+C,
|
|
1
|
+
{"version":3,"file":"useWindowScroll.cjs","sources":["../../../../src/hooks/useWindowScroll/useWindowScroll.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nexport interface ScrollPosition {\n x: number;\n y: number;\n}\n\nexport const scrollTo = ({\n x,\n y,\n behavior = 'smooth'\n}: Partial<ScrollPosition & ScrollOptions>) => {\n const scrollOptions: ScrollToOptions = { behavior };\n if (typeof x === 'number') scrollOptions.left = x;\n if (typeof y === 'number') scrollOptions.top = y;\n window.scrollTo(scrollOptions);\n};\n\n/**\n * @name useWindowScroll\n * @description - Hook that manages the window scroll position\n * @category Browser\n *\n * @returns {UseWindowScrollReturn} An object containing the current window scroll position\n *\n * @example\n * const { value, scrollTo } = useWindowScroll();\n */\nexport const useWindowScroll = () => {\n const [value, setValue] = useState<ScrollPosition>({\n x: typeof window !== 'undefined' ? window.scrollX : Number.POSITIVE_INFINITY,\n y: typeof window !== 'undefined' ? window.scrollY : Number.POSITIVE_INFINITY\n });\n\n useEffect(() => {\n const onChange = () => setValue({ x: window.scrollX, y: window.scrollY });\n window.addEventListener('scroll', onChange);\n window.addEventListener('resize', onChange);\n return () => {\n window.removeEventListener('scroll', onChange);\n window.removeEventListener('resize', onChange);\n };\n }, []);\n\n return { value, scrollTo };\n};\n"],"names":["scrollTo","x","y","behavior","scrollOptions","useWindowScroll","value","setValue","useState","useEffect","onChange"],"mappings":"yGAOaA,EAAW,CAAC,CACvB,EAAAC,EACA,EAAAC,EACA,SAAAC,EAAW,QACb,IAA+C,CAC7C,MAAMC,EAAiC,CAAE,SAAAD,CAAA,EACrC,OAAOF,GAAM,WAAUG,EAAc,KAAOH,GAC5C,OAAOC,GAAM,WAAUE,EAAc,IAAMF,GAC/C,OAAO,SAASE,CAAa,CAC/B,EAYaC,EAAkB,IAAM,CACnC,KAAM,CAACC,EAAOC,CAAQ,EAAIC,WAAyB,CACjD,EAAG,OAAO,OAAW,IAAc,OAAO,QAAU,OAAO,kBAC3D,EAAG,OAAO,OAAW,IAAc,OAAO,QAAU,OAAO,iBAAA,CAC5D,EAEDC,OAAAA,EAAAA,UAAU,IAAM,CACd,MAAMC,EAAW,IAAMH,EAAS,CAAE,EAAG,OAAO,QAAS,EAAG,OAAO,QAAS,EACxE,cAAO,iBAAiB,SAAUG,CAAQ,EAC1C,OAAO,iBAAiB,SAAUA,CAAQ,EACnC,IAAM,CACX,OAAO,oBAAoB,SAAUA,CAAQ,EAC7C,OAAO,oBAAoB,SAAUA,CAAQ,CAAA,CAC/C,EACC,EAAE,EAEE,CAAE,MAAAJ,EAAO,SAAAN,CAAA,CAClB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react"),r=n=>{const e=n?.includeScrollbar??!0,[o,t]=d.useState(()=>typeof window>"u"?{width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY}:{width:e?window.innerWidth:window.document.documentElement.clientWidth,height:e?window.innerHeight:window.document.documentElement.clientHeight});return d.useEffect(()=>{const i=()=>{t(e?{width:window.innerWidth,height:window.innerHeight}:{width:window.document.documentElement.clientWidth,height:window.document.documentElement.clientHeight})};return window.addEventListener("resize",i),()=>{window.removeEventListener("resize",i)}},[n?.includeScrollbar]),o};exports.useWindowSize=r;
|
|
2
2
|
//# sourceMappingURL=useWindowSize.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWindowSize.cjs","sources":["../../../../src/hooks/useWindowSize/useWindowSize.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\n/** The use window size return type */\ninterface UseWindowSizeParams {\n /** Whether to include the scrollbar in the window size calculation */\n includeScrollbar?: boolean;\n}\n\n/** The use window size return type */\nexport interface UseWindowSizeReturn {\n /** The current window height */\n height: number;\n /** The current window width */\n width: number;\n}\n\n/**\n * @name useWindowSize\n * @description - Hook that manages a window size\n * @category Elements\n *\n * @param {number} [params.initialWidth=Number.POSITIVE_INFINITY] The initial window width\n * @param {number} [params.initialHeight=Number.POSITIVE_INFINITY] The initial window height\n * @returns {UseWindowSizeReturn} An object containing the current window width and height\n *\n * @example\n * const { width, height } = useWindowSize();\n */\nexport const useWindowSize = (params?: UseWindowSizeParams) => {\n const includeScrollbar = params?.includeScrollbar ?? true;\n const [size, setSize] = useState(() => {\n if (typeof window === 'undefined') {\n return {\n width: Number.POSITIVE_INFINITY,\n height: Number.POSITIVE_INFINITY\n };\n }\n\n return {\n width: includeScrollbar ? window.innerWidth : window.document.documentElement.clientWidth,\n height: includeScrollbar ? window.innerHeight : window.document.documentElement.clientHeight\n };\n });\n\n useEffect(() => {\n const onResize = () => {\n if (includeScrollbar) {\n setSize({\n width: window.innerWidth,\n height: window.innerHeight\n });\n } else {\n setSize({\n width: window.document.documentElement.clientWidth,\n height: window.document.documentElement.clientHeight\n });\n }\n };\n\n window.addEventListener('resize', onResize);\n return () => {\n window.removeEventListener('resize', onResize);\n };\n }, [params?.includeScrollbar]);\n\n return size;\n};\n"],"names":["useWindowSize","params","includeScrollbar","size","setSize","useState","useEffect","onResize"],"mappings":"yGA4BaA,EAAiBC,GAAiC,
|
|
1
|
+
{"version":3,"file":"useWindowSize.cjs","sources":["../../../../src/hooks/useWindowSize/useWindowSize.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\n/** The use window size return type */\ninterface UseWindowSizeParams {\n /** Whether to include the scrollbar in the window size calculation */\n includeScrollbar?: boolean;\n}\n\n/** The use window size return type */\nexport interface UseWindowSizeReturn {\n /** The current window height */\n height: number;\n /** The current window width */\n width: number;\n}\n\n/**\n * @name useWindowSize\n * @description - Hook that manages a window size\n * @category Elements\n *\n * @param {number} [params.initialWidth=Number.POSITIVE_INFINITY] The initial window width\n * @param {number} [params.initialHeight=Number.POSITIVE_INFINITY] The initial window height\n * @returns {UseWindowSizeReturn} An object containing the current window width and height\n *\n * @example\n * const { width, height } = useWindowSize();\n */\nexport const useWindowSize = (params?: UseWindowSizeParams) => {\n const includeScrollbar = params?.includeScrollbar ?? true;\n const [size, setSize] = useState(() => {\n if (typeof window === 'undefined') {\n return {\n width: Number.POSITIVE_INFINITY,\n height: Number.POSITIVE_INFINITY\n };\n }\n\n return {\n width: includeScrollbar ? window.innerWidth : window.document.documentElement.clientWidth,\n height: includeScrollbar ? window.innerHeight : window.document.documentElement.clientHeight\n };\n });\n\n useEffect(() => {\n const onResize = () => {\n if (includeScrollbar) {\n setSize({\n width: window.innerWidth,\n height: window.innerHeight\n });\n } else {\n setSize({\n width: window.document.documentElement.clientWidth,\n height: window.document.documentElement.clientHeight\n });\n }\n };\n\n window.addEventListener('resize', onResize);\n return () => {\n window.removeEventListener('resize', onResize);\n };\n }, [params?.includeScrollbar]);\n\n return size;\n};\n"],"names":["useWindowSize","params","includeScrollbar","size","setSize","useState","useEffect","onResize"],"mappings":"yGA4BaA,EAAiBC,GAAiC,CAC7D,MAAMC,EAAmBD,GAAQ,kBAAoB,GAC/C,CAACE,EAAMC,CAAO,EAAIC,EAAAA,SAAS,IAC3B,OAAO,OAAW,IACb,CACL,MAAO,OAAO,kBACd,OAAQ,OAAO,iBAAA,EAIZ,CACL,MAAOH,EAAmB,OAAO,WAAa,OAAO,SAAS,gBAAgB,YAC9E,OAAQA,EAAmB,OAAO,YAAc,OAAO,SAAS,gBAAgB,YAAA,CAEnF,EAEDI,OAAAA,EAAAA,UAAU,IAAM,CACd,MAAMC,EAAW,IAAM,CAEnBH,EADEF,EACM,CACN,MAAO,OAAO,WACd,OAAQ,OAAO,WAAA,EAGT,CACN,MAAO,OAAO,SAAS,gBAAgB,YACvC,OAAQ,OAAO,SAAS,gBAAgB,YAAA,CAJzC,CAMH,EAGF,cAAO,iBAAiB,SAAUK,CAAQ,EACnC,IAAM,CACX,OAAO,oBAAoB,SAAUA,CAAQ,CAAA,CAC/C,EACC,CAACN,GAAQ,gBAAgB,CAAC,EAEtBE,CACT"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react"),d=(c,a)=>{const s=a??c[0].id,i=new Map(c.map(t=>[t.id,t])),[r,n]=u.useState(s),[e,o]=u.useState([s]);return{currentStepId:r,set:t=>{if(!i.get(r)?.nodes?.includes(t))throw new Error(`Can't go to ${t} from ${r}`);o([...e,t]),n(t)},reset:()=>{n(s),o([s])},back:()=>{if(e.length===1)return;const t=e[e.length-2];if(!i.get(r)?.nodes?.includes(t))throw new Error(`Can't go to ${t} from ${r}`);o(e.slice(0,-1)),n(e[e.length-2])},history:e}};exports.useWizard=d;
|
|
2
2
|
//# sourceMappingURL=useWizard.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWizard.cjs","sources":["../../../../src/hooks/useWizard/useWizard.ts"],"sourcesContent":["import { useState } from 'react';\n\nexport interface WizardItem<WizardStepId> {\n id: WizardStepId;\n nodes?: WizardStepId[];\n}\n\n/**\n * @name useWizard\n * @description - Hook that manages a wizard\n * @category Utilities\n *\n * @param {WizardItem<WizardStepId>[]} map The map of the wizard\n * @param {WizardStepId} [initialStepId] The initial step id\n * @returns {UseWizardReturn<WizardStepId>} An object containing the current step id and functions to interact with the wizard\n *\n * @example\n * const { currentStepId, set, reset, back, history } = useWizard([\n * { id: 'step1', nodes: ['step2', 'step3'] },\n * { id: 'step2', nodes: ['step3'] },\n * { id: 'step3', nodes: [] },\n * ])\n */\nexport const useWizard = <WizardStepId extends string>(\n map: WizardItem<WizardStepId>[],\n initialStepId?: WizardStepId\n) => {\n const initialId = initialStepId ?? map[0].id;\n const wizardMap = new Map(map.map((wizardItem) => [wizardItem.id, wizardItem]));\n const [currentStepId, setCurrentStepId] = useState(initialId);\n const [history, setHistory] = useState<WizardStepId[]>([initialId]);\n\n const set = (id: WizardStepId) => {\n if (!wizardMap.get(currentStepId)?.nodes?.includes(id))\n throw new Error(`Can't go to ${id} from ${currentStepId}`);\n\n setHistory([...history, id]);\n setCurrentStepId(id);\n };\n\n const back = () => {\n if (history.length === 1) return;\n\n const previousStepId = history[history.length - 2];\n if (!wizardMap.get(currentStepId)?.nodes?.includes(previousStepId))\n throw new Error(`Can't go to ${previousStepId} from ${currentStepId}`);\n\n setHistory(history.slice(0, -1));\n setCurrentStepId(history[history.length - 2]);\n };\n\n const reset = () => {\n setCurrentStepId(initialId);\n setHistory([initialId]);\n };\n\n return { currentStepId, set, reset, back, history };\n};\n"],"names":["useWizard","map","initialStepId","initialId","wizardMap","wizardItem","currentStepId","setCurrentStepId","useState","history","setHistory","id","
|
|
1
|
+
{"version":3,"file":"useWizard.cjs","sources":["../../../../src/hooks/useWizard/useWizard.ts"],"sourcesContent":["import { useState } from 'react';\n\nexport interface WizardItem<WizardStepId> {\n id: WizardStepId;\n nodes?: WizardStepId[];\n}\n\n/**\n * @name useWizard\n * @description - Hook that manages a wizard\n * @category Utilities\n *\n * @param {WizardItem<WizardStepId>[]} map The map of the wizard\n * @param {WizardStepId} [initialStepId] The initial step id\n * @returns {UseWizardReturn<WizardStepId>} An object containing the current step id and functions to interact with the wizard\n *\n * @example\n * const { currentStepId, set, reset, back, history } = useWizard([\n * { id: 'step1', nodes: ['step2', 'step3'] },\n * { id: 'step2', nodes: ['step3'] },\n * { id: 'step3', nodes: [] },\n * ])\n */\nexport const useWizard = <WizardStepId extends string>(\n map: WizardItem<WizardStepId>[],\n initialStepId?: WizardStepId\n) => {\n const initialId = initialStepId ?? map[0].id;\n const wizardMap = new Map(map.map((wizardItem) => [wizardItem.id, wizardItem]));\n const [currentStepId, setCurrentStepId] = useState(initialId);\n const [history, setHistory] = useState<WizardStepId[]>([initialId]);\n\n const set = (id: WizardStepId) => {\n if (!wizardMap.get(currentStepId)?.nodes?.includes(id))\n throw new Error(`Can't go to ${id} from ${currentStepId}`);\n\n setHistory([...history, id]);\n setCurrentStepId(id);\n };\n\n const back = () => {\n if (history.length === 1) return;\n\n const previousStepId = history[history.length - 2];\n if (!wizardMap.get(currentStepId)?.nodes?.includes(previousStepId))\n throw new Error(`Can't go to ${previousStepId} from ${currentStepId}`);\n\n setHistory(history.slice(0, -1));\n setCurrentStepId(history[history.length - 2]);\n };\n\n const reset = () => {\n setCurrentStepId(initialId);\n setHistory([initialId]);\n };\n\n return { currentStepId, set, reset, back, history };\n};\n"],"names":["useWizard","map","initialStepId","initialId","wizardMap","wizardItem","currentStepId","setCurrentStepId","useState","history","setHistory","id","previousStepId"],"mappings":"yGAuBaA,EAAY,CACvBC,EACAC,IACG,CACH,MAAMC,EAAYD,GAAiBD,EAAI,CAAC,EAAE,GACpCG,EAAY,IAAI,IAAIH,EAAI,IAAKI,GAAe,CAACA,EAAW,GAAIA,CAAU,CAAC,CAAC,EACxE,CAACC,EAAeC,CAAgB,EAAIC,EAAAA,SAASL,CAAS,EACtD,CAACM,EAASC,CAAU,EAAIF,EAAAA,SAAyB,CAACL,CAAS,CAAC,EA0BlE,MAAO,CAAE,cAAAG,EAAe,IAxBXK,GAAqB,CAChC,GAAI,CAACP,EAAU,IAAIE,CAAa,GAAG,OAAO,SAASK,CAAE,EACnD,MAAM,IAAI,MAAM,eAAeA,CAAE,SAASL,CAAa,EAAE,EAE3DI,EAAW,CAAC,GAAGD,EAASE,CAAE,CAAC,EAC3BJ,EAAiBI,CAAE,CAAA,EAmBQ,MALf,IAAM,CAClBJ,EAAiBJ,CAAS,EAC1BO,EAAW,CAACP,CAAS,CAAC,CAAA,EAGY,KAhBvB,IAAM,CACjB,GAAIM,EAAQ,SAAW,EAAG,OAE1B,MAAMG,EAAiBH,EAAQA,EAAQ,OAAS,CAAC,EACjD,GAAI,CAACL,EAAU,IAAIE,CAAa,GAAG,OAAO,SAASM,CAAc,EAC/D,MAAM,IAAI,MAAM,eAAeA,CAAc,SAASN,CAAa,EAAE,EAEvEI,EAAWD,EAAQ,MAAM,EAAG,EAAE,CAAC,EAC/BF,EAAiBE,EAAQA,EAAQ,OAAS,CAAC,CAAC,CAAA,EAQJ,QAAAA,CAAA,CAC5C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copy.cjs","sources":["../../../../src/utils/helpers/copy.ts"],"sourcesContent":["export const legacyCopyToClipboard = (value: string) => {\n const tempTextArea = document.createElement('textarea');\n tempTextArea.value = value;\n tempTextArea.readOnly = true;\n tempTextArea.style.fontSize = '16px';\n document.body.appendChild(tempTextArea);\n tempTextArea.select();\n document.execCommand('copy');\n document.body.removeChild(tempTextArea);\n};\n\nexport const copy = async (value: string) => {\n try {\n try {\n await navigator.clipboard.writeText(value);\n } catch {\n return legacyCopyToClipboard(value);\n }\n } catch {\n return legacyCopyToClipboard(value);\n }\n};\n"],"names":["legacyCopyToClipboard","value","tempTextArea","copy"],"mappings":"
|
|
1
|
+
{"version":3,"file":"copy.cjs","sources":["../../../../src/utils/helpers/copy.ts"],"sourcesContent":["export const legacyCopyToClipboard = (value: string) => {\n const tempTextArea = document.createElement('textarea');\n tempTextArea.value = value;\n tempTextArea.readOnly = true;\n tempTextArea.style.fontSize = '16px';\n document.body.appendChild(tempTextArea);\n tempTextArea.select();\n document.execCommand('copy');\n document.body.removeChild(tempTextArea);\n};\n\nexport const copy = async (value: string) => {\n try {\n try {\n await navigator.clipboard.writeText(value);\n } catch {\n return legacyCopyToClipboard(value);\n }\n } catch {\n return legacyCopyToClipboard(value);\n }\n};\n"],"names":["legacyCopyToClipboard","value","tempTextArea","copy"],"mappings":"gFAAO,MAAMA,EAAyBC,GAAkB,CACtD,MAAMC,EAAe,SAAS,cAAc,UAAU,EACtDA,EAAa,MAAQD,EACrBC,EAAa,SAAW,GACxBA,EAAa,MAAM,SAAW,OAC9B,SAAS,KAAK,YAAYA,CAAY,EACtCA,EAAa,OAAA,EACb,SAAS,YAAY,MAAM,EAC3B,SAAS,KAAK,YAAYA,CAAY,CACxC,EAEaC,EAAO,MAAOF,GAAkB,CAC3C,GAAI,CACF,GAAI,CACF,MAAM,UAAU,UAAU,UAAUA,CAAK,CAAA,MACnC,CACN,OAAOD,EAAsBC,CAAK,CAAA,CACpC,MACM,CACN,OAAOD,EAAsBC,CAAK,CAAA,CAEtC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debounce.cjs","sources":["../../../../src/utils/helpers/debounce.ts"],"sourcesContent":["export function debounce<Params extends unknown[]>(\n callback: (...args: Params) => void,\n delay: number\n): (...args: Params) => void {\n let timer: ReturnType<typeof setTimeout>;\n\n return function (this: any, ...args: Params) {\n clearTimeout(timer);\n timer = setTimeout(() => callback.apply(this, args), delay);\n };\n}\n"],"names":["debounce","callback","delay","timer","args"],"mappings":"
|
|
1
|
+
{"version":3,"file":"debounce.cjs","sources":["../../../../src/utils/helpers/debounce.ts"],"sourcesContent":["export function debounce<Params extends unknown[]>(\n callback: (...args: Params) => void,\n delay: number\n): (...args: Params) => void {\n let timer: ReturnType<typeof setTimeout>;\n\n return function (this: any, ...args: Params) {\n clearTimeout(timer);\n timer = setTimeout(() => callback.apply(this, args), delay);\n };\n}\n"],"names":["debounce","callback","delay","timer","args"],"mappings":"gFAAO,SAASA,EACdC,EACAC,EAC2B,CAC3B,IAAIC,EAEJ,OAAO,YAAwBC,EAAc,CAC3C,aAAaD,CAAK,EAClBA,EAAQ,WAAW,IAAMF,EAAS,MAAM,KAAMG,CAAI,EAAGF,CAAK,CAAA,CAE9D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDate.cjs","sources":["../../../../src/utils/helpers/getDate.ts"],"sourcesContent":["export const getDate = (now: Date = new Date()) => {\n const seconds = now.getSeconds();\n const minutes = now.getMinutes();\n const hours = now.getHours();\n const meridiemHours = hours % 12 === 0 ? 12 : hours % 12;\n const meridiemType = hours >= 12 ? 'pm' : 'am';\n const day = now.getDate();\n const month = now.getMonth() + 1;\n const year = now.getFullYear();\n const timestamp = now.getTime();\n\n return {\n seconds,\n minutes,\n hours,\n meridiemHours: { value: meridiemHours, type: meridiemType },\n day,\n month,\n year,\n timestamp\n };\n};\n"],"names":["getDate","now","seconds","minutes","hours","meridiemHours","meridiemType","day","month","year","timestamp"],"mappings":"gFAAO,MAAMA,EAAU,CAACC,EAAY,IAAI,OAAW,
|
|
1
|
+
{"version":3,"file":"getDate.cjs","sources":["../../../../src/utils/helpers/getDate.ts"],"sourcesContent":["export const getDate = (now: Date = new Date()) => {\n const seconds = now.getSeconds();\n const minutes = now.getMinutes();\n const hours = now.getHours();\n const meridiemHours = hours % 12 === 0 ? 12 : hours % 12;\n const meridiemType = hours >= 12 ? 'pm' : 'am';\n const day = now.getDate();\n const month = now.getMonth() + 1;\n const year = now.getFullYear();\n const timestamp = now.getTime();\n\n return {\n seconds,\n minutes,\n hours,\n meridiemHours: { value: meridiemHours, type: meridiemType },\n day,\n month,\n year,\n timestamp\n };\n};\n"],"names":["getDate","now","seconds","minutes","hours","meridiemHours","meridiemType","day","month","year","timestamp"],"mappings":"gFAAO,MAAMA,EAAU,CAACC,EAAY,IAAI,OAAW,CACjD,MAAMC,EAAUD,EAAI,WAAA,EACdE,EAAUF,EAAI,WAAA,EACdG,EAAQH,EAAI,SAAA,EACZI,EAAgBD,EAAQ,KAAO,EAAI,GAAKA,EAAQ,GAChDE,EAAeF,GAAS,GAAK,KAAO,KACpCG,EAAMN,EAAI,QAAA,EACVO,EAAQP,EAAI,SAAA,EAAa,EACzBQ,EAAOR,EAAI,YAAA,EACXS,EAAYT,EAAI,QAAA,EAEtB,MAAO,CACL,QAAAC,EACA,QAAAC,EACA,MAAAC,EACA,cAAe,CAAE,MAAOC,EAAe,KAAMC,CAAA,EAC7C,IAAAC,EACA,MAAAC,EACA,KAAAC,EACA,UAAAC,CAAA,CAEJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getElement.cjs","sources":["../../../../src/utils/helpers/getElement.ts"],"sourcesContent":["import type { RefObject } from 'react';\n\nexport type Target = (() => Element) | string | Document | Element | Window;\nexport type HookTarget =\n | RefObject<Element | null | undefined>\n | {\n value: Target;\n type: symbol;\n };\n\nexport const targetSymbol = Symbol('target');\nexport const target = (target: Target) => ({\n value: target,\n type: targetSymbol\n});\n\nexport const getElement = (target: HookTarget) => {\n if ('current' in target) {\n return target.current;\n }\n\n if (typeof target.value === 'function') {\n return target.value();\n }\n\n if (typeof target.value === 'string') {\n return document.querySelector(target.value);\n }\n\n if (target.value instanceof Document) {\n return target.value;\n }\n\n if (target.value instanceof Window) {\n return target.value;\n }\n\n if (target.value instanceof Element) {\n return target.value;\n }\n\n return target.value;\n};\n"],"names":["targetSymbol","target","getElement"],"mappings":"
|
|
1
|
+
{"version":3,"file":"getElement.cjs","sources":["../../../../src/utils/helpers/getElement.ts"],"sourcesContent":["import type { RefObject } from 'react';\n\nexport type Target = (() => Element) | string | Document | Element | Window;\nexport type HookTarget =\n | RefObject<Element | null | undefined>\n | {\n value: Target;\n type: symbol;\n };\n\nexport const targetSymbol = Symbol('target');\nexport const target = (target: Target) => ({\n value: target,\n type: targetSymbol\n});\n\nexport const getElement = (target: HookTarget) => {\n if ('current' in target) {\n return target.current;\n }\n\n if (typeof target.value === 'function') {\n return target.value();\n }\n\n if (typeof target.value === 'string') {\n return document.querySelector(target.value);\n }\n\n if (target.value instanceof Document) {\n return target.value;\n }\n\n if (target.value instanceof Window) {\n return target.value;\n }\n\n if (target.value instanceof Element) {\n return target.value;\n }\n\n return target.value;\n};\n"],"names":["targetSymbol","target","getElement"],"mappings":"gFAUO,MAAMA,EAAe,OAAO,QAAQ,EAC9BC,EAAUA,IAAoB,CACzC,MAAOA,EACP,KAAMD,CACR,GAEaE,EAAcD,GACrB,YAAaA,EACRA,EAAO,QAGZ,OAAOA,EAAO,OAAU,WACnBA,EAAO,MAAA,EAGZ,OAAOA,EAAO,OAAU,SACnB,SAAS,cAAcA,EAAO,KAAK,GAGxCA,EAAO,iBAAiB,UAIxBA,EAAO,iBAAiB,QAIxBA,EAAO,iBAAiB,QACnBA,EAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRetry.cjs","sources":["../../../../src/utils/helpers/getRetry.ts"],"sourcesContent":["export const getRetry = (retry: boolean | number) => {\n if (typeof retry === 'number') return retry;\n return retry ? 1 : 0;\n};\n"],"names":["getRetry","retry"],"mappings":"
|
|
1
|
+
{"version":3,"file":"getRetry.cjs","sources":["../../../../src/utils/helpers/getRetry.ts"],"sourcesContent":["export const getRetry = (retry: boolean | number) => {\n if (typeof retry === 'number') return retry;\n return retry ? 1 : 0;\n};\n"],"names":["getRetry","retry"],"mappings":"gFAAO,MAAMA,EAAYC,GACnB,OAAOA,GAAU,SAAiBA,EAC/BA,EAAQ,EAAI"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isTarget.cjs","sources":["../../../../src/utils/helpers/isTarget.ts"],"sourcesContent":["import type { HookTarget } from './getElement';\n\nimport { targetSymbol } from './getElement';\n\nexport const isTarget = (target: HookTarget) =>\n typeof target === 'object' && ('current' in target || target.type === targetSymbol);\n"],"names":["isTarget","target","targetSymbol"],"mappings":"oHAIaA,EAAYC,GACvB,OAAOA,GAAW,WAAa,YAAaA,GAAUA,EAAO,OAASC,
|
|
1
|
+
{"version":3,"file":"isTarget.cjs","sources":["../../../../src/utils/helpers/isTarget.ts"],"sourcesContent":["import type { HookTarget } from './getElement';\n\nimport { targetSymbol } from './getElement';\n\nexport const isTarget = (target: HookTarget) =>\n typeof target === 'object' && ('current' in target || target.type === targetSymbol);\n"],"names":["isTarget","target","targetSymbol"],"mappings":"oHAIaA,EAAYC,GACvB,OAAOA,GAAW,WAAa,YAAaA,GAAUA,EAAO,OAASC,EAAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"throttle.cjs","sources":["../../../../src/utils/helpers/throttle.ts"],"sourcesContent":["export const throttle = <Params extends any[]>(\n callback: (...args: Params) => void,\n delay: number\n): ((...args: Params) => void) => {\n let isCalled = false;\n let lastArgs: Params | null = null;\n\n const timer = () => {\n if (!lastArgs) {\n isCalled = false;\n return;\n }\n\n callback.apply(this, lastArgs);\n lastArgs = null;\n setTimeout(timer, delay);\n };\n\n return function (this: any, ...args: Params) {\n if (isCalled) {\n lastArgs = args;\n return;\n }\n\n callback.apply(this, args);\n isCalled = true;\n setTimeout(timer, delay);\n };\n};\n"],"names":["throttle","callback","delay","isCalled","lastArgs","timer","args"],"mappings":"
|
|
1
|
+
{"version":3,"file":"throttle.cjs","sources":["../../../../src/utils/helpers/throttle.ts"],"sourcesContent":["export const throttle = <Params extends any[]>(\n callback: (...args: Params) => void,\n delay: number\n): ((...args: Params) => void) => {\n let isCalled = false;\n let lastArgs: Params | null = null;\n\n const timer = () => {\n if (!lastArgs) {\n isCalled = false;\n return;\n }\n\n callback.apply(this, lastArgs);\n lastArgs = null;\n setTimeout(timer, delay);\n };\n\n return function (this: any, ...args: Params) {\n if (isCalled) {\n lastArgs = args;\n return;\n }\n\n callback.apply(this, args);\n isCalled = true;\n setTimeout(timer, delay);\n };\n};\n"],"names":["throttle","callback","delay","isCalled","lastArgs","timer","args"],"mappings":"gFAAO,MAAMA,EAAW,CACtBC,EACAC,IACgC,CAChC,IAAIC,EAAW,GACXC,EAA0B,KAE9B,MAAMC,EAAQ,IAAM,CAClB,GAAI,CAACD,EAAU,CACbD,EAAW,GACX,MAAA,CAGFF,EAAS,MAAM,OAAMG,CAAQ,EAC7BA,EAAW,KACX,WAAWC,EAAOH,CAAK,CAAA,EAGzB,OAAO,YAAwBI,EAAc,CAC3C,GAAIH,EAAU,CACZC,EAAWE,EACX,MAAA,CAGFL,EAAS,MAAM,KAAMK,CAAI,EACzBH,EAAW,GACX,WAAWE,EAAOH,CAAK,CAAA,CAE3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createContext.mjs","sources":["../../../../src/helpers/createContext/createContext.tsx"],"sourcesContent":["import type { JSX, ReactNode } from 'react';\n\nimport { createContext as createReactContext, useContext, useMemo, useState } from 'react';\n\n/** The create context options type */\nexport interface CreateContextOptions {\n /** Display name for the context (useful for debugging) */\n name?: string;\n /** Whether to throw an error if context is used outside of Provider */\n strict?: boolean;\n}\n\n/** The context value type */\nexport interface ContextValue<Value> {\n /** The context value */\n value: Value | undefined;\n /** The context set function */\n set: (value: Value) => void;\n}\n\n/** The provider props type */\nexport interface ProviderProps<Value> {\n /** The children */\n children?: ReactNode;\n /** The initial value */\n initialValue?: Value;\n}\n\n/** The create context return type */\nexport interface CreateContextReturn<Value> {\n /** The context instance */\n instance: React.Context<ContextValue<Value>>;\n /** The provider component */\n Provider: (props: ProviderProps<Value>) => JSX.Element;\n /** The selector hook */\n useSelect: {\n <Selected>(selector: (value: Value) => Selected): Selected;\n (): ContextValue<Value>;\n };\n}\n\n/**\n * @name createContext\n * @description - Creates a typed context with additional utilities\n * @category Helpers\n *\n * @template Value - The type of value that will be stored in the context\n * @param {Value | undefined} [defaultValue] - Default value for the context\n * @param {CreateContextOptions<Value>} [options] - Additional options for context creation\n * @returns {CreateContextReturn<Value>} Object containing context utilities and components\n *\n * @example\n * const { useSelect, instance, Provider } = createContext<number>(0);\n */\nexport const createContext = <Value,>(\n defaultValue: Value | undefined = undefined,\n options: CreateContextOptions = {}\n): CreateContextReturn<Value> => {\n const Context = createReactContext<{\n value: Value | undefined;\n set: (value: Value) => void;\n }>({\n value: defaultValue,\n set: () => {}\n });\n\n Context.displayName = options.name;\n\n function useSelect(): ContextValue<Value>;\n function useSelect<Selected>(selector: (value: Value) => Selected): Selected;\n function useSelect<Selected>(selector?: (value: Value) => Selected) {\n const context = useContext(Context);\n\n if (!context && options.strict) {\n throw new Error(`Context hook ${options.name} must be used inside a Provider`);\n }\n\n if (!selector) {\n return context;\n }\n\n return selector(context.value as Value);\n }\n\n const Provider = ({ children, initialValue }: ProviderProps<Value>) => {\n const [profile, setProfile] = useState<Value | undefined>(initialValue ?? defaultValue);\n\n const value = useMemo(\n () => ({\n value: profile,\n set: setProfile\n }),\n [profile]\n );\n\n return <Context value={value}>{children}</Context>;\n };\n\n return {\n useSelect,\n instance: Context,\n Provider\n } as const;\n};\n"],"names":["createContext","defaultValue","options","Context","createReactContext","useSelect","selector","context","useContext","children","initialValue","profile","setProfile","useState","value","useMemo","jsx"],"mappings":";;AAsDO,MAAMA,IAAgB,CAC3BC,IAAkC,QAClCC,IAAgC,CAAA,MACD;AAC/B,QAAMC,IAAUC,EAGb;AAAA,IACD,OAAOH;AAAA,IACP,KAAK,MAAM;AAAA,IAAA;AAAA,EAAC,CACb;AAED,EAAAE,EAAQ,cAAcD,EAAQ;AAI9B,WAASG,EAAoBC,GAAuC;
|
|
1
|
+
{"version":3,"file":"createContext.mjs","sources":["../../../../src/helpers/createContext/createContext.tsx"],"sourcesContent":["import type { JSX, ReactNode } from 'react';\n\nimport { createContext as createReactContext, useContext, useMemo, useState } from 'react';\n\n/** The create context options type */\nexport interface CreateContextOptions {\n /** Display name for the context (useful for debugging) */\n name?: string;\n /** Whether to throw an error if context is used outside of Provider */\n strict?: boolean;\n}\n\n/** The context value type */\nexport interface ContextValue<Value> {\n /** The context value */\n value: Value | undefined;\n /** The context set function */\n set: (value: Value) => void;\n}\n\n/** The provider props type */\nexport interface ProviderProps<Value> {\n /** The children */\n children?: ReactNode;\n /** The initial value */\n initialValue?: Value;\n}\n\n/** The create context return type */\nexport interface CreateContextReturn<Value> {\n /** The context instance */\n instance: React.Context<ContextValue<Value>>;\n /** The provider component */\n Provider: (props: ProviderProps<Value>) => JSX.Element;\n /** The selector hook */\n useSelect: {\n <Selected>(selector: (value: Value) => Selected): Selected;\n (): ContextValue<Value>;\n };\n}\n\n/**\n * @name createContext\n * @description - Creates a typed context with additional utilities\n * @category Helpers\n *\n * @template Value - The type of value that will be stored in the context\n * @param {Value | undefined} [defaultValue] - Default value for the context\n * @param {CreateContextOptions<Value>} [options] - Additional options for context creation\n * @returns {CreateContextReturn<Value>} Object containing context utilities and components\n *\n * @example\n * const { useSelect, instance, Provider } = createContext<number>(0);\n */\nexport const createContext = <Value,>(\n defaultValue: Value | undefined = undefined,\n options: CreateContextOptions = {}\n): CreateContextReturn<Value> => {\n const Context = createReactContext<{\n value: Value | undefined;\n set: (value: Value) => void;\n }>({\n value: defaultValue,\n set: () => {}\n });\n\n Context.displayName = options.name;\n\n function useSelect(): ContextValue<Value>;\n function useSelect<Selected>(selector: (value: Value) => Selected): Selected;\n function useSelect<Selected>(selector?: (value: Value) => Selected) {\n const context = useContext(Context);\n\n if (!context && options.strict) {\n throw new Error(`Context hook ${options.name} must be used inside a Provider`);\n }\n\n if (!selector) {\n return context;\n }\n\n return selector(context.value as Value);\n }\n\n const Provider = ({ children, initialValue }: ProviderProps<Value>) => {\n const [profile, setProfile] = useState<Value | undefined>(initialValue ?? defaultValue);\n\n const value = useMemo(\n () => ({\n value: profile,\n set: setProfile\n }),\n [profile]\n );\n\n return <Context value={value}>{children}</Context>;\n };\n\n return {\n useSelect,\n instance: Context,\n Provider\n } as const;\n};\n"],"names":["createContext","defaultValue","options","Context","createReactContext","useSelect","selector","context","useContext","children","initialValue","profile","setProfile","useState","value","useMemo","jsx"],"mappings":";;AAsDO,MAAMA,IAAgB,CAC3BC,IAAkC,QAClCC,IAAgC,CAAA,MACD;AAC/B,QAAMC,IAAUC,EAGb;AAAA,IACD,OAAOH;AAAA,IACP,KAAK,MAAM;AAAA,IAAA;AAAA,EAAC,CACb;AAED,EAAAE,EAAQ,cAAcD,EAAQ;AAI9B,WAASG,EAAoBC,GAAuC;AAClE,UAAMC,IAAUC,EAAWL,CAAO;AAElC,QAAI,CAACI,KAAWL,EAAQ;AACtB,YAAM,IAAI,MAAM,gBAAgBA,EAAQ,IAAI,iCAAiC;AAG/E,WAAKI,IAIEA,EAASC,EAAQ,KAAc,IAH7BA;AAAA,EAG6B;AAiBxC,SAAO;AAAA,IACL,WAAAF;AAAA,IACA,UAAUF;AAAA,IACV,UAjBe,CAAC,EAAE,UAAAM,GAAU,cAAAC,QAAyC;AACrE,YAAM,CAACC,GAASC,CAAU,IAAIC,EAA4BH,KAAgBT,CAAY,GAEhFa,IAAQC;AAAA,QACZ,OAAO;AAAA,UACL,OAAOJ;AAAA,UACP,KAAKC;AAAA,QAAA;AAAA,QAEP,CAACD,CAAO;AAAA,MAAA;AAGV,aAAO,gBAAAK,EAACb,GAAA,EAAQ,OAAAW,GAAe,UAAAL,EAAA,CAAS;AAAA,IAAA;AAAA,EAMxC;AAEJ;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createReactiveContext.mjs","sources":["../../../../src/helpers/createReactiveContext/createReactiveContext.ts"],"sourcesContent":["import type { Context, FC, Provider, ProviderProps, RefObject } from 'react';\n\nimport {\n createContext,\n createElement,\n startTransition,\n useContext,\n useMemo,\n useRef,\n useState\n} from 'react';\n\nimport { useEvent, useIsomorphicLayoutEffect } from '@/hooks';\n\n/** The create reactive context options type */\nexport interface CreateReactiveContextOptions {\n /** Display name for the context (useful for debugging) */\n name?: string;\n /** Whether to throw an error if context is used outside of Provider */\n strict?: boolean;\n}\n\n/** The create reactive context return type */\nexport interface CreateReactiveContextReturn<Value> {\n /** The context instance */\n instance: Context<ReactiveContextValue<Value>>;\n /** The Provider component for the context */\n Provider: Provider<Value>;\n /** A hook to select a part of the context state */\n useSelector: <Selected>(selector?: (state: Value) => Selected) => Selected;\n}\n\ntype ContextListener<Value> = (value: Value) => void;\n\ninterface ReactiveContextValue<Value> {\n /** The listeners for the context */\n listeners: Set<ContextListener<Value>>;\n /** The value for the context */\n value: RefObject<Value>;\n}\n\nconst createProvider = <Value>(originalProvider: Provider<ReactiveContextValue<Value>>) => {\n const Provider: FC<ProviderProps<Value>> = (props) => {\n const valueRef = useRef(props.value);\n const contextValue = useMemo<ReactiveContextValue<Value>>(\n () => ({\n value: valueRef,\n listeners: new Set()\n }),\n []\n );\n\n useIsomorphicLayoutEffect(() => {\n if (!Object.is(valueRef.current, props.value)) {\n valueRef.current = props.value;\n\n startTransition(() => {\n contextValue.listeners.forEach((listener) => {\n listener(valueRef.current);\n });\n });\n }\n }, [props.value]);\n\n return createElement(originalProvider, { value: contextValue }, props.children);\n };\n\n return Provider as unknown as Provider<ReactiveContextValue<Value>>;\n};\n\nconst createReactiveContextSelector = <Value, Selected>(\n Context: Context<ReactiveContextValue<Value>>,\n selector: (state: Value) => Selected,\n options: CreateReactiveContextOptions = {}\n) => {\n const context = useContext(Context);\n\n if (!context && options.strict) {\n throw new Error(`Context hook ${options.name} must be used inside a Provider`);\n }\n\n const [value, setValue] = useState({\n selected: selector(context.value.current),\n value: context.value.current\n });\n\n const dispatch = useEvent((newValue: Value) => {\n setValue((prevValue) => {\n if (Object.is(prevValue.value, newValue)) return prevValue;\n\n const newSelected = selector(newValue);\n if (Object.is(prevValue.selected, newSelected)) return prevValue;\n\n return { value: newValue, selected: newSelected };\n });\n });\n\n useIsomorphicLayoutEffect(() => {\n context.listeners.add(dispatch);\n return () => {\n context.listeners.delete(dispatch);\n };\n }, [context.listeners]);\n\n return value.selected;\n};\n\n/**\n * @name createReactiveContext\n * @description - Creates a typed context selector with optimized updates for state selection\n * @category Helpers\n *\n * @warning - For complex interfaces, we strongly recommend using state management solutions outside of React like createStore, reatom, effector, or zustand instead of context\n *\n * @template Value - The type of value that will be stored in the context\n * @param {Value | undefined} [defaultValue] - Default value for the context\n * @param {CreateReactiveContextOptions<Value>} [options] - Additional options for context creation\n * @returns {CreateReactiveContextReturn<Value>} Object containing context utilities and components\n *\n * @example\n * const { Provider, useSelector, instance } = createReactiveContext<number>(0);\n */\nexport const createReactiveContext = <Value extends Record<string, any>>(\n defaultValue: Value | undefined = undefined,\n options: CreateReactiveContextOptions = {}\n) => {\n const Context = createContext<ReactiveContextValue<Value>>({\n value: { current: defaultValue as Value },\n listeners: new Set()\n });\n\n const Provider = createProvider(Context.Provider) as unknown as Provider<Value>;\n\n Context.displayName = options.name;\n\n function useSelector(): Value;\n function useSelector<SelectedValue>(selector: (state: Value) => SelectedValue): SelectedValue;\n function useSelector<SelectedValue>(selector?: (state: Value) => SelectedValue) {\n return createReactiveContextSelector(\n Context as unknown as Context<ReactiveContextValue<Value>>,\n selector ?? ((state) => state as unknown as SelectedValue),\n options\n );\n }\n\n return { instance: Context, Provider, useSelector };\n};\n"],"names":["createProvider","originalProvider","props","valueRef","useRef","contextValue","useMemo","useIsomorphicLayoutEffect","startTransition","listener","createElement","createReactiveContextSelector","Context","selector","options","context","useContext","value","setValue","useState","dispatch","useEvent","newValue","prevValue","newSelected","createReactiveContext","defaultValue","createContext","Provider","useSelector","state"],"mappings":";;;AAyCA,MAAMA,IAAiB,CAAQC,MACc,CAACC,MAAU;
|
|
1
|
+
{"version":3,"file":"createReactiveContext.mjs","sources":["../../../../src/helpers/createReactiveContext/createReactiveContext.ts"],"sourcesContent":["import type { Context, FC, Provider, ProviderProps, RefObject } from 'react';\n\nimport {\n createContext,\n createElement,\n startTransition,\n useContext,\n useMemo,\n useRef,\n useState\n} from 'react';\n\nimport { useEvent, useIsomorphicLayoutEffect } from '@/hooks';\n\n/** The create reactive context options type */\nexport interface CreateReactiveContextOptions {\n /** Display name for the context (useful for debugging) */\n name?: string;\n /** Whether to throw an error if context is used outside of Provider */\n strict?: boolean;\n}\n\n/** The create reactive context return type */\nexport interface CreateReactiveContextReturn<Value> {\n /** The context instance */\n instance: Context<ReactiveContextValue<Value>>;\n /** The Provider component for the context */\n Provider: Provider<Value>;\n /** A hook to select a part of the context state */\n useSelector: <Selected>(selector?: (state: Value) => Selected) => Selected;\n}\n\ntype ContextListener<Value> = (value: Value) => void;\n\ninterface ReactiveContextValue<Value> {\n /** The listeners for the context */\n listeners: Set<ContextListener<Value>>;\n /** The value for the context */\n value: RefObject<Value>;\n}\n\nconst createProvider = <Value>(originalProvider: Provider<ReactiveContextValue<Value>>) => {\n const Provider: FC<ProviderProps<Value>> = (props) => {\n const valueRef = useRef(props.value);\n const contextValue = useMemo<ReactiveContextValue<Value>>(\n () => ({\n value: valueRef,\n listeners: new Set()\n }),\n []\n );\n\n useIsomorphicLayoutEffect(() => {\n if (!Object.is(valueRef.current, props.value)) {\n valueRef.current = props.value;\n\n startTransition(() => {\n contextValue.listeners.forEach((listener) => {\n listener(valueRef.current);\n });\n });\n }\n }, [props.value]);\n\n return createElement(originalProvider, { value: contextValue }, props.children);\n };\n\n return Provider as unknown as Provider<ReactiveContextValue<Value>>;\n};\n\nconst createReactiveContextSelector = <Value, Selected>(\n Context: Context<ReactiveContextValue<Value>>,\n selector: (state: Value) => Selected,\n options: CreateReactiveContextOptions = {}\n) => {\n const context = useContext(Context);\n\n if (!context && options.strict) {\n throw new Error(`Context hook ${options.name} must be used inside a Provider`);\n }\n\n const [value, setValue] = useState({\n selected: selector(context.value.current),\n value: context.value.current\n });\n\n const dispatch = useEvent((newValue: Value) => {\n setValue((prevValue) => {\n if (Object.is(prevValue.value, newValue)) return prevValue;\n\n const newSelected = selector(newValue);\n if (Object.is(prevValue.selected, newSelected)) return prevValue;\n\n return { value: newValue, selected: newSelected };\n });\n });\n\n useIsomorphicLayoutEffect(() => {\n context.listeners.add(dispatch);\n return () => {\n context.listeners.delete(dispatch);\n };\n }, [context.listeners]);\n\n return value.selected;\n};\n\n/**\n * @name createReactiveContext\n * @description - Creates a typed context selector with optimized updates for state selection\n * @category Helpers\n *\n * @warning - For complex interfaces, we strongly recommend using state management solutions outside of React like createStore, reatom, effector, or zustand instead of context\n *\n * @template Value - The type of value that will be stored in the context\n * @param {Value | undefined} [defaultValue] - Default value for the context\n * @param {CreateReactiveContextOptions<Value>} [options] - Additional options for context creation\n * @returns {CreateReactiveContextReturn<Value>} Object containing context utilities and components\n *\n * @example\n * const { Provider, useSelector, instance } = createReactiveContext<number>(0);\n */\nexport const createReactiveContext = <Value extends Record<string, any>>(\n defaultValue: Value | undefined = undefined,\n options: CreateReactiveContextOptions = {}\n) => {\n const Context = createContext<ReactiveContextValue<Value>>({\n value: { current: defaultValue as Value },\n listeners: new Set()\n });\n\n const Provider = createProvider(Context.Provider) as unknown as Provider<Value>;\n\n Context.displayName = options.name;\n\n function useSelector(): Value;\n function useSelector<SelectedValue>(selector: (state: Value) => SelectedValue): SelectedValue;\n function useSelector<SelectedValue>(selector?: (state: Value) => SelectedValue) {\n return createReactiveContextSelector(\n Context as unknown as Context<ReactiveContextValue<Value>>,\n selector ?? ((state) => state as unknown as SelectedValue),\n options\n );\n }\n\n return { instance: Context, Provider, useSelector };\n};\n"],"names":["createProvider","originalProvider","props","valueRef","useRef","contextValue","useMemo","useIsomorphicLayoutEffect","startTransition","listener","createElement","createReactiveContextSelector","Context","selector","options","context","useContext","value","setValue","useState","dispatch","useEvent","newValue","prevValue","newSelected","createReactiveContext","defaultValue","createContext","Provider","useSelector","state"],"mappings":";;;AAyCA,MAAMA,IAAiB,CAAQC,MACc,CAACC,MAAU;AACpD,QAAMC,IAAWC,EAAOF,EAAM,KAAK,GAC7BG,IAAeC;AAAA,IACnB,OAAO;AAAA,MACL,OAAOH;AAAA,MACP,+BAAe,IAAA;AAAA,IAAI;AAAA,IAErB,CAAA;AAAA,EAAC;AAGH,SAAAI,EAA0B,MAAM;AAC9B,IAAK,OAAO,GAAGJ,EAAS,SAASD,EAAM,KAAK,MAC1CC,EAAS,UAAUD,EAAM,OAEzBM,EAAgB,MAAM;AACpB,MAAAH,EAAa,UAAU,QAAQ,CAACI,MAAa;AAC3C,QAAAA,EAASN,EAAS,OAAO;AAAA,MAAA,CAC1B;AAAA,IAAA,CACF;AAAA,EACH,GACC,CAACD,EAAM,KAAK,CAAC,GAETQ,EAAcT,GAAkB,EAAE,OAAOI,EAAA,GAAgBH,EAAM,QAAQ;AAAA,GAM5ES,IAAgC,CACpCC,GACAC,GACAC,IAAwC,CAAA,MACrC;AACH,QAAMC,IAAUC,EAAWJ,CAAO;AAElC,MAAI,CAACG,KAAWD,EAAQ;AACtB,UAAM,IAAI,MAAM,gBAAgBA,EAAQ,IAAI,iCAAiC;AAG/E,QAAM,CAACG,GAAOC,CAAQ,IAAIC,EAAS;AAAA,IACjC,UAAUN,EAASE,EAAQ,MAAM,OAAO;AAAA,IACxC,OAAOA,EAAQ,MAAM;AAAA,EAAA,CACtB,GAEKK,IAAWC,EAAS,CAACC,MAAoB;AAC7C,IAAAJ,EAAS,CAACK,MAAc;AACtB,UAAI,OAAO,GAAGA,EAAU,OAAOD,CAAQ,EAAG,QAAOC;AAEjD,YAAMC,IAAcX,EAASS,CAAQ;AACrC,aAAI,OAAO,GAAGC,EAAU,UAAUC,CAAW,IAAUD,IAEhD,EAAE,OAAOD,GAAU,UAAUE,EAAA;AAAA,IAAY,CACjD;AAAA,EAAA,CACF;AAED,SAAAjB,EAA0B,OACxBQ,EAAQ,UAAU,IAAIK,CAAQ,GACvB,MAAM;AACX,IAAAL,EAAQ,UAAU,OAAOK,CAAQ;AAAA,EAAA,IAElC,CAACL,EAAQ,SAAS,CAAC,GAEfE,EAAM;AACf,GAiBaQ,IAAwB,CACnCC,IAAkC,QAClCZ,IAAwC,CAAA,MACrC;AACH,QAAMF,IAAUe,EAA2C;AAAA,IACzD,OAAO,EAAE,SAASD,EAAA;AAAA,IAClB,+BAAe,IAAA;AAAA,EAAI,CACpB,GAEKE,IAAW5B,EAAeY,EAAQ,QAAQ;AAEhD,EAAAA,EAAQ,cAAcE,EAAQ;AAI9B,WAASe,EAA2BhB,GAA4C;AAC9E,WAAOF;AAAA,MACLC;AAAA,MACAC,MAAa,CAACiB,MAAUA;AAAA,MACxBhB;AAAA,IAAA;AAAA,EACF;AAGF,SAAO,EAAE,UAAUF,GAAS,UAAAgB,GAAU,aAAAC,EAAA;AACxC;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createStore.mjs","sources":["../../../../src/helpers/createStore/createStore.ts"],"sourcesContent":["import { useSyncExternalStore } from 'react';\n\ntype SetStateAction<Value> = ((prev: Value) => Value) | Value;\ntype StateCreator<Value> = (\n set: (action: SetStateAction<Value>) => void,\n get: () => Value\n) => Value;\n\nexport interface StoreApi<Value> {\n getInitialState: () => Value;\n getState: () => Value;\n setState: (action: SetStateAction<Value>) => void;\n subscribe: (listener: (state: Value, prevState: Value) => void) => () => void;\n}\n\n/**\n * @name createStore\n * @description - Creates a store with state management capabilities\n * @category Helpers\n *\n * @template Value - The type of the store state\n *\n * @param {StateCreator<Value>} createState - Function that initializes the store state\n * @returns {StoreApi<Value>} - Object containing store methods and hook for accessing state\n *\n * @example\n * const { set, get, use, subscribe } = createStore((set) => ({\n * count: 0,\n * increment: () => set(state => ({ count: state.count + 1 }))\n * }));\n */\nexport const createStore = <Value>(createState: StateCreator<Value> | Value) => {\n type Listener = (state: Value, prevState: Value) => void;\n let state: Value;\n const listeners: Set<Listener> = new Set();\n\n const setState = (action: SetStateAction<Value>) => {\n const nextState =\n typeof action === 'function' ? (action as (state: Value) => Value)(state) : action;\n\n if (!Object.is(nextState, state)) {\n const prevState = state;\n state = nextState;\n listeners.forEach((listener) => listener(state, prevState));\n }\n };\n\n const getState = () => state;\n const getInitialState = () => state;\n\n const subscribe = (listener: Listener) => {\n listeners.add(listener);\n return () => listeners.delete(listener);\n };\n if (typeof createState === 'function') {\n state = (createState as StateCreator<Value>)(setState, getState);\n } else {\n state = createState;\n }\n\n const useStore = <Selected>(selector: (state: Value) => Selected) =>\n useSyncExternalStore(\n subscribe,\n () => selector(getState()),\n () => selector(getInitialState())\n );\n\n return {\n set: setState,\n get: getState,\n use: useStore,\n subscribe\n };\n};\n"],"names":["createStore","createState","state","listeners","setState","action","nextState","prevState","listener","getState","getInitialState","subscribe","selector","useSyncExternalStore"],"mappings":";AA+
|
|
1
|
+
{"version":3,"file":"createStore.mjs","sources":["../../../../src/helpers/createStore/createStore.ts"],"sourcesContent":["import { useSyncExternalStore } from 'react';\n\ntype SetStateAction<Value> = ((prev: Value) => Value) | Value;\ntype StateCreator<Value> = (\n set: (action: SetStateAction<Value>) => void,\n get: () => Value\n) => Value;\n\nexport interface StoreApi<Value> {\n getInitialState: () => Value;\n getState: () => Value;\n setState: (action: SetStateAction<Value>) => void;\n subscribe: (listener: (state: Value, prevState: Value) => void) => () => void;\n}\n\n/**\n * @name createStore\n * @description - Creates a store with state management capabilities\n * @category Helpers\n *\n * @template Value - The type of the store state\n *\n * @param {StateCreator<Value>} createState - Function that initializes the store state\n * @returns {StoreApi<Value>} - Object containing store methods and hook for accessing state\n *\n * @example\n * const { set, get, use, subscribe } = createStore((set) => ({\n * count: 0,\n * increment: () => set(state => ({ count: state.count + 1 }))\n * }));\n */\nexport const createStore = <Value>(createState: StateCreator<Value> | Value) => {\n type Listener = (state: Value, prevState: Value) => void;\n let state: Value;\n const listeners: Set<Listener> = new Set();\n\n const setState = (action: SetStateAction<Value>) => {\n const nextState =\n typeof action === 'function' ? (action as (state: Value) => Value)(state) : action;\n\n if (!Object.is(nextState, state)) {\n const prevState = state;\n state = nextState;\n listeners.forEach((listener) => listener(state, prevState));\n }\n };\n\n const getState = () => state;\n const getInitialState = () => state;\n\n const subscribe = (listener: Listener) => {\n listeners.add(listener);\n return () => listeners.delete(listener);\n };\n if (typeof createState === 'function') {\n state = (createState as StateCreator<Value>)(setState, getState);\n } else {\n state = createState;\n }\n\n const useStore = <Selected>(selector: (state: Value) => Selected) =>\n useSyncExternalStore(\n subscribe,\n () => selector(getState()),\n () => selector(getInitialState())\n );\n\n return {\n set: setState,\n get: getState,\n use: useStore,\n subscribe\n };\n};\n"],"names":["createStore","createState","state","listeners","setState","action","nextState","prevState","listener","getState","getInitialState","subscribe","selector","useSyncExternalStore"],"mappings":";AA+BO,MAAMA,IAAc,CAAQC,MAA6C;AAE9E,MAAIC;AACJ,QAAMC,wBAA+B,IAAA,GAE/BC,IAAW,CAACC,MAAkC;AAClD,UAAMC,IACJ,OAAOD,KAAW,aAAcA,EAAmCH,CAAK,IAAIG;AAE9E,QAAI,CAAC,OAAO,GAAGC,GAAWJ,CAAK,GAAG;AAChC,YAAMK,IAAYL;AAClB,MAAAA,IAAQI,GACRH,EAAU,QAAQ,CAACK,MAAaA,EAASN,GAAOK,CAAS,CAAC;AAAA,IAAA;AAAA,EAC5D,GAGIE,IAAW,MAAMP,GACjBQ,IAAkB,MAAMR,GAExBS,IAAY,CAACH,OACjBL,EAAU,IAAIK,CAAQ,GACf,MAAML,EAAU,OAAOK,CAAQ;AAExC,SAAI,OAAOP,KAAgB,aACzBC,IAASD,EAAoCG,GAAUK,CAAQ,IAE/DP,IAAQD,GAUH;AAAA,IACL,KAAKG;AAAA,IACL,KAAKK;AAAA,IACL,KAVe,CAAWG,MAC1BC;AAAA,MACEF;AAAA,MACA,MAAMC,EAASH,GAAU;AAAA,MACzB,MAAMG,EAASF,EAAA,CAAiB;AAAA,IAAA;AAAA,IAOlC,WAAAC;AAAA,EAAA;AAEJ;"}
|
|
@@ -2,7 +2,7 @@ import { useState as i, useEffect as o } from "react";
|
|
|
2
2
|
const d = () => {
|
|
3
3
|
const [u, r] = i(null);
|
|
4
4
|
return o(() => {
|
|
5
|
-
const e = () => r(document
|
|
5
|
+
const e = () => r(document?.activeElement);
|
|
6
6
|
return window.addEventListener("focus", e, !0), window.addEventListener("blur", e, !0), () => {
|
|
7
7
|
window.removeEventListener("focus", e, !0), window.removeEventListener("blur", e, !0);
|
|
8
8
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useActiveElement.mjs","sources":["../../../../src/hooks/useActiveElement/useActiveElement.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\n/**\n * @name useActiveElement\n * @description - Hook that returns the active element\n * @category Elements\n *\n * @returns {ActiveElement | null} The active element\n *\n * @example\n * const activeElement = useActiveElement();\n *\n * @see {@link https://siberiacancode.github.io/reactuse/functions/hooks/useActiveElement.html}\n */\nexport const useActiveElement = <ActiveElement extends HTMLElement>() => {\n const [activeElement, setActiveElement] = useState<ActiveElement | null>(null);\n\n useEffect(() => {\n const onActiveElementChange = () =>\n setActiveElement(document?.activeElement as ActiveElement | null);\n\n window.addEventListener('focus', onActiveElementChange, true);\n window.addEventListener('blur', onActiveElementChange, true);\n\n return () => {\n window.removeEventListener('focus', onActiveElementChange, true);\n window.removeEventListener('blur', onActiveElementChange, true);\n };\n });\n\n useEffect(() => {\n const observer = new MutationObserver((mutations) => {\n mutations\n .filter((mutation) => mutation.removedNodes.length)\n .map((mutation) => Array.from(mutation.removedNodes))\n .flat()\n .forEach((node) => {\n setActiveElement((prevActiveElement) => {\n if (node === prevActiveElement) return document.activeElement as ActiveElement | null;\n return prevActiveElement;\n });\n });\n });\n\n observer.observe(document, {\n childList: true,\n subtree: true\n });\n\n return () => {\n observer.disconnect();\n };\n }, []);\n\n return activeElement;\n};\n"],"names":["useActiveElement","activeElement","setActiveElement","useState","useEffect","onActiveElementChange","observer","mutations","mutation","node","prevActiveElement"],"mappings":";AAcO,MAAMA,IAAmB,MAAyC;AACvE,QAAM,CAACC,GAAeC,CAAgB,IAAIC,EAA+B,IAAI;AAE7E,SAAAC,EAAU,MAAM;AACd,UAAMC,IAAwB,MAC5BH,EAAiB,
|
|
1
|
+
{"version":3,"file":"useActiveElement.mjs","sources":["../../../../src/hooks/useActiveElement/useActiveElement.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\n/**\n * @name useActiveElement\n * @description - Hook that returns the active element\n * @category Elements\n *\n * @returns {ActiveElement | null} The active element\n *\n * @example\n * const activeElement = useActiveElement();\n *\n * @see {@link https://siberiacancode.github.io/reactuse/functions/hooks/useActiveElement.html}\n */\nexport const useActiveElement = <ActiveElement extends HTMLElement>() => {\n const [activeElement, setActiveElement] = useState<ActiveElement | null>(null);\n\n useEffect(() => {\n const onActiveElementChange = () =>\n setActiveElement(document?.activeElement as ActiveElement | null);\n\n window.addEventListener('focus', onActiveElementChange, true);\n window.addEventListener('blur', onActiveElementChange, true);\n\n return () => {\n window.removeEventListener('focus', onActiveElementChange, true);\n window.removeEventListener('blur', onActiveElementChange, true);\n };\n });\n\n useEffect(() => {\n const observer = new MutationObserver((mutations) => {\n mutations\n .filter((mutation) => mutation.removedNodes.length)\n .map((mutation) => Array.from(mutation.removedNodes))\n .flat()\n .forEach((node) => {\n setActiveElement((prevActiveElement) => {\n if (node === prevActiveElement) return document.activeElement as ActiveElement | null;\n return prevActiveElement;\n });\n });\n });\n\n observer.observe(document, {\n childList: true,\n subtree: true\n });\n\n return () => {\n observer.disconnect();\n };\n }, []);\n\n return activeElement;\n};\n"],"names":["useActiveElement","activeElement","setActiveElement","useState","useEffect","onActiveElementChange","observer","mutations","mutation","node","prevActiveElement"],"mappings":";AAcO,MAAMA,IAAmB,MAAyC;AACvE,QAAM,CAACC,GAAeC,CAAgB,IAAIC,EAA+B,IAAI;AAE7E,SAAAC,EAAU,MAAM;AACd,UAAMC,IAAwB,MAC5BH,EAAiB,UAAU,aAAqC;AAElE,kBAAO,iBAAiB,SAASG,GAAuB,EAAI,GAC5D,OAAO,iBAAiB,QAAQA,GAAuB,EAAI,GAEpD,MAAM;AACX,aAAO,oBAAoB,SAASA,GAAuB,EAAI,GAC/D,OAAO,oBAAoB,QAAQA,GAAuB,EAAI;AAAA,IAAA;AAAA,EAChE,CACD,GAEDD,EAAU,MAAM;AACd,UAAME,IAAW,IAAI,iBAAiB,CAACC,MAAc;AACnD,MAAAA,EACG,OAAO,CAACC,MAAaA,EAAS,aAAa,MAAM,EACjD,IAAI,CAACA,MAAa,MAAM,KAAKA,EAAS,YAAY,CAAC,EACnD,OACA,QAAQ,CAACC,MAAS;AACjB,QAAAP,EAAiB,CAACQ,MACZD,MAASC,IAA0B,SAAS,gBACzCA,CACR;AAAA,MAAA,CACF;AAAA,IAAA,CACJ;AAED,WAAAJ,EAAS,QAAQ,UAAU;AAAA,MACzB,WAAW;AAAA,MACX,SAAS;AAAA,IAAA,CACV,GAEM,MAAM;AACX,MAAAA,EAAS,WAAA;AAAA,IAAW;AAAA,EACtB,GACC,EAAE,GAEEL;AACT;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAsync.mjs","sources":["../../../../src/hooks/useAsync/useAsync.ts"],"sourcesContent":["import type { DependencyList } from 'react';\n\nimport { useEffect, useState } from 'react';\n\n/* The use query return type */\nexport interface UseAsyncReturn<Data> {\n /* The state of the query */\n data?: Data;\n /* The error of the query */\n error?: Error;\n /* The error state of the query */\n isError: boolean;\n /* The loading state of the query */\n isLoading: boolean;\n}\n\n/**\n * @name useAsync\n * @description - Hook that provides the state of an async callback\n * @category Utilities\n *\n * @param {() => Promise<Data>} callback The async callback\n * @param {DependencyList} deps The dependencies of the callback\n * @returns {UseAsyncReturn<Data>} The state of the async callback\n *\n * @example\n * const { data, isLoading, isError, error } = useAsync(() => fetch('url'), [deps]);\n */\nexport const useAsync = <Data>(\n callback: () => Promise<Data>,\n deps: DependencyList\n): UseAsyncReturn<Data> => {\n const [isLoading, setIsLoading] = useState(true);\n const [isError, setIsError] = useState(false);\n\n const [error, setError] = useState<Error | undefined>(undefined);\n const [data, setData] = useState<Data | undefined>(undefined);\n\n useEffect(() => {\n setIsLoading(true);\n callback()\n .then((response) => {\n setData(response);\n setError(undefined);\n setIsError(false);\n })\n .catch((error: Error) => {\n setError(error);\n setIsError(true);\n })\n .finally(() => {\n setIsLoading(false);\n });\n }, deps);\n\n return {\n data,\n isLoading,\n isError,\n error\n };\n};\n"],"names":["useAsync","callback","deps","isLoading","setIsLoading","useState","isError","setIsError","error","setError","data","setData","useEffect","response"],"mappings":";
|
|
1
|
+
{"version":3,"file":"useAsync.mjs","sources":["../../../../src/hooks/useAsync/useAsync.ts"],"sourcesContent":["import type { DependencyList } from 'react';\n\nimport { useEffect, useState } from 'react';\n\n/* The use query return type */\nexport interface UseAsyncReturn<Data> {\n /* The state of the query */\n data?: Data;\n /* The error of the query */\n error?: Error;\n /* The error state of the query */\n isError: boolean;\n /* The loading state of the query */\n isLoading: boolean;\n}\n\n/**\n * @name useAsync\n * @description - Hook that provides the state of an async callback\n * @category Utilities\n *\n * @param {() => Promise<Data>} callback The async callback\n * @param {DependencyList} deps The dependencies of the callback\n * @returns {UseAsyncReturn<Data>} The state of the async callback\n *\n * @example\n * const { data, isLoading, isError, error } = useAsync(() => fetch('url'), [deps]);\n */\nexport const useAsync = <Data>(\n callback: () => Promise<Data>,\n deps: DependencyList\n): UseAsyncReturn<Data> => {\n const [isLoading, setIsLoading] = useState(true);\n const [isError, setIsError] = useState(false);\n\n const [error, setError] = useState<Error | undefined>(undefined);\n const [data, setData] = useState<Data | undefined>(undefined);\n\n useEffect(() => {\n setIsLoading(true);\n callback()\n .then((response) => {\n setData(response);\n setError(undefined);\n setIsError(false);\n })\n .catch((error: Error) => {\n setError(error);\n setIsError(true);\n })\n .finally(() => {\n setIsLoading(false);\n });\n }, deps);\n\n return {\n data,\n isLoading,\n isError,\n error\n };\n};\n"],"names":["useAsync","callback","deps","isLoading","setIsLoading","useState","isError","setIsError","error","setError","data","setData","useEffect","response"],"mappings":";AA4BO,MAAMA,IAAW,CACtBC,GACAC,MACyB;AACzB,QAAM,CAACC,GAAWC,CAAY,IAAIC,EAAS,EAAI,GACzC,CAACC,GAASC,CAAU,IAAIF,EAAS,EAAK,GAEtC,CAACG,GAAOC,CAAQ,IAAIJ,EAA4B,MAAS,GACzD,CAACK,GAAMC,CAAO,IAAIN,EAA2B,MAAS;AAE5D,SAAAO,EAAU,MAAM;AACd,IAAAR,EAAa,EAAI,GACjBH,EAAA,EACG,KAAK,CAACY,MAAa;AAClB,MAAAF,EAAQE,CAAQ,GAChBJ,EAAS,MAAS,GAClBF,EAAW,EAAK;AAAA,IAAA,CACjB,EACA,MAAM,CAACC,MAAiB;AACvB,MAAAC,EAASD,CAAK,GACdD,EAAW,EAAI;AAAA,IAAA,CAChB,EACA,QAAQ,MAAM;AACb,MAAAH,EAAa,EAAK;AAAA,IAAA,CACnB;AAAA,EAAA,GACFF,CAAI,GAEA;AAAA,IACL,MAAAQ;AAAA,IACA,WAAAP;AAAA,IACA,SAAAG;AAAA,IACA,OAAAE;AAAA,EAAA;AAEJ;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useState as r, useEffect as c } from "react";
|
|
2
2
|
const h = () => {
|
|
3
|
-
const
|
|
3
|
+
const t = typeof navigator < "u" && "getBattery" in navigator && typeof navigator.getBattery == "function", [a, i] = r({
|
|
4
4
|
loading: !0,
|
|
5
5
|
level: 0,
|
|
6
6
|
charging: !1,
|
|
@@ -8,21 +8,21 @@ const h = () => {
|
|
|
8
8
|
dischargingTime: 0
|
|
9
9
|
});
|
|
10
10
|
return c(() => {
|
|
11
|
-
if (!
|
|
11
|
+
if (!t) return i({ ...a, loading: !1 });
|
|
12
12
|
let e;
|
|
13
|
-
const n = () =>
|
|
13
|
+
const n = () => i({
|
|
14
14
|
loading: !1,
|
|
15
|
-
level:
|
|
16
|
-
charging:
|
|
17
|
-
dischargingTime:
|
|
18
|
-
chargingTime:
|
|
15
|
+
level: e?.level ?? 0,
|
|
16
|
+
charging: e?.charging ?? !1,
|
|
17
|
+
dischargingTime: e?.dischargingTime ?? 0,
|
|
18
|
+
chargingTime: e?.chargingTime ?? 0
|
|
19
19
|
});
|
|
20
|
-
return navigator.getBattery().then((
|
|
21
|
-
e =
|
|
20
|
+
return navigator.getBattery().then((g) => {
|
|
21
|
+
e = g, n(), e.addEventListener("levelchange", n), e.addEventListener("chargingchange", n), e.addEventListener("chargingtimechange", n), e.addEventListener("dischargingtimechange", n);
|
|
22
22
|
}), () => {
|
|
23
23
|
e && (e.removeEventListener("levelchange", n), e.removeEventListener("chargingchange", n), e.removeEventListener("chargingtimechange", n), e.removeEventListener("dischargingtimechange", n));
|
|
24
24
|
};
|
|
25
|
-
}, []), { supported:
|
|
25
|
+
}, []), { supported: t, value: a };
|
|
26
26
|
};
|
|
27
27
|
export {
|
|
28
28
|
h as useBattery
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBattery.mjs","sources":["../../../../src/hooks/useBattery/useBattery.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nexport interface BatteryManager extends EventTarget {\n charging: boolean;\n chargingTime: number;\n dischargingTime: number;\n level: number;\n}\n\ndeclare global {\n interface Navigator {\n readonly getBattery: () => Promise<BatteryManager>;\n }\n}\n\n/** The use battery value type */\nexport interface UseBatteryValue {\n /** Is charging battery? */\n charging: boolean;\n /** Time until the battery is fully charged */\n chargingTime: number;\n /** Time until the battery is completely discharged */\n dischargingTime: number;\n /** Battery charge level from 0 to 1 */\n level: number;\n /** Is battery information loading? */\n loading: boolean;\n}\n\n/** The use battery return type */\nexport interface UseBatteryStateReturn {\n /** Whether the battery api is supported*/\n supported: boolean;\n /** The use battery value type */\n value: UseBatteryValue;\n}\n\n/**\n * @name useBattery\n * @description - Hook for getting information about battery status\n * @category Browser\n *\n * @browserapi navigator.getBattery https://developer.mozilla.org/en-US/docs/Web/API/Navigator/getBattery\n *\n * @returns {UseBatteryStateReturn} Object containing battery information & Battery API support\n *\n * @example\n * const { supported, loading, charging, chargingTime, dischargingTime, level } = useBattery();\n */\nexport const useBattery = (): UseBatteryStateReturn => {\n const supported =\n typeof navigator !== 'undefined' &&\n 'getBattery' in navigator &&\n typeof navigator.getBattery === 'function';\n const [value, setValue] = useState<UseBatteryValue>({\n loading: true,\n level: 0,\n charging: false,\n chargingTime: 0,\n dischargingTime: 0\n });\n\n useEffect(() => {\n if (!supported) return setValue({ ...value, loading: false });\n\n let battery: BatteryManager | null;\n\n const onChange = () =>\n setValue({\n loading: false,\n level: battery?.level ?? 0,\n charging: battery?.charging ?? false,\n dischargingTime: battery?.dischargingTime ?? 0,\n chargingTime: battery?.chargingTime ?? 0\n });\n\n navigator.getBattery().then((batteryManager) => {\n battery = batteryManager;\n onChange();\n\n battery.addEventListener('levelchange', onChange);\n battery.addEventListener('chargingchange', onChange);\n battery.addEventListener('chargingtimechange', onChange);\n battery.addEventListener('dischargingtimechange', onChange);\n });\n\n return () => {\n if (!battery) return;\n battery.removeEventListener('levelchange', onChange);\n battery.removeEventListener('chargingchange', onChange);\n battery.removeEventListener('chargingtimechange', onChange);\n battery.removeEventListener('dischargingtimechange', onChange);\n };\n }, []);\n\n return { supported, value };\n};\n"],"names":["useBattery","supported","value","setValue","useState","useEffect","battery","onChange","batteryManager"],"mappings":";AAiDO,MAAMA,IAAa,MAA6B;
|
|
1
|
+
{"version":3,"file":"useBattery.mjs","sources":["../../../../src/hooks/useBattery/useBattery.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nexport interface BatteryManager extends EventTarget {\n charging: boolean;\n chargingTime: number;\n dischargingTime: number;\n level: number;\n}\n\ndeclare global {\n interface Navigator {\n readonly getBattery: () => Promise<BatteryManager>;\n }\n}\n\n/** The use battery value type */\nexport interface UseBatteryValue {\n /** Is charging battery? */\n charging: boolean;\n /** Time until the battery is fully charged */\n chargingTime: number;\n /** Time until the battery is completely discharged */\n dischargingTime: number;\n /** Battery charge level from 0 to 1 */\n level: number;\n /** Is battery information loading? */\n loading: boolean;\n}\n\n/** The use battery return type */\nexport interface UseBatteryStateReturn {\n /** Whether the battery api is supported*/\n supported: boolean;\n /** The use battery value type */\n value: UseBatteryValue;\n}\n\n/**\n * @name useBattery\n * @description - Hook for getting information about battery status\n * @category Browser\n *\n * @browserapi navigator.getBattery https://developer.mozilla.org/en-US/docs/Web/API/Navigator/getBattery\n *\n * @returns {UseBatteryStateReturn} Object containing battery information & Battery API support\n *\n * @example\n * const { supported, loading, charging, chargingTime, dischargingTime, level } = useBattery();\n */\nexport const useBattery = (): UseBatteryStateReturn => {\n const supported =\n typeof navigator !== 'undefined' &&\n 'getBattery' in navigator &&\n typeof navigator.getBattery === 'function';\n const [value, setValue] = useState<UseBatteryValue>({\n loading: true,\n level: 0,\n charging: false,\n chargingTime: 0,\n dischargingTime: 0\n });\n\n useEffect(() => {\n if (!supported) return setValue({ ...value, loading: false });\n\n let battery: BatteryManager | null;\n\n const onChange = () =>\n setValue({\n loading: false,\n level: battery?.level ?? 0,\n charging: battery?.charging ?? false,\n dischargingTime: battery?.dischargingTime ?? 0,\n chargingTime: battery?.chargingTime ?? 0\n });\n\n navigator.getBattery().then((batteryManager) => {\n battery = batteryManager;\n onChange();\n\n battery.addEventListener('levelchange', onChange);\n battery.addEventListener('chargingchange', onChange);\n battery.addEventListener('chargingtimechange', onChange);\n battery.addEventListener('dischargingtimechange', onChange);\n });\n\n return () => {\n if (!battery) return;\n battery.removeEventListener('levelchange', onChange);\n battery.removeEventListener('chargingchange', onChange);\n battery.removeEventListener('chargingtimechange', onChange);\n battery.removeEventListener('dischargingtimechange', onChange);\n };\n }, []);\n\n return { supported, value };\n};\n"],"names":["useBattery","supported","value","setValue","useState","useEffect","battery","onChange","batteryManager"],"mappings":";AAiDO,MAAMA,IAAa,MAA6B;AACrD,QAAMC,IACJ,OAAO,YAAc,OACrB,gBAAgB,aAChB,OAAO,UAAU,cAAe,YAC5B,CAACC,GAAOC,CAAQ,IAAIC,EAA0B;AAAA,IAClD,SAAS;AAAA,IACT,OAAO;AAAA,IACP,UAAU;AAAA,IACV,cAAc;AAAA,IACd,iBAAiB;AAAA,EAAA,CAClB;AAED,SAAAC,EAAU,MAAM;AACd,QAAI,CAACJ,EAAW,QAAOE,EAAS,EAAE,GAAGD,GAAO,SAAS,IAAO;AAE5D,QAAII;AAEJ,UAAMC,IAAW,MACfJ,EAAS;AAAA,MACP,SAAS;AAAA,MACT,OAAOG,GAAS,SAAS;AAAA,MACzB,UAAUA,GAAS,YAAY;AAAA,MAC/B,iBAAiBA,GAAS,mBAAmB;AAAA,MAC7C,cAAcA,GAAS,gBAAgB;AAAA,IAAA,CACxC;AAEH,qBAAU,WAAA,EAAa,KAAK,CAACE,MAAmB;AAC9C,MAAAF,IAAUE,GACVD,EAAA,GAEAD,EAAQ,iBAAiB,eAAeC,CAAQ,GAChDD,EAAQ,iBAAiB,kBAAkBC,CAAQ,GACnDD,EAAQ,iBAAiB,sBAAsBC,CAAQ,GACvDD,EAAQ,iBAAiB,yBAAyBC,CAAQ;AAAA,IAAA,CAC3D,GAEM,MAAM;AACX,MAAKD,MACLA,EAAQ,oBAAoB,eAAeC,CAAQ,GACnDD,EAAQ,oBAAoB,kBAAkBC,CAAQ,GACtDD,EAAQ,oBAAoB,sBAAsBC,CAAQ,GAC1DD,EAAQ,oBAAoB,yBAAyBC,CAAQ;AAAA,IAAA;AAAA,EAC/D,GACC,EAAE,GAEE,EAAE,WAAAN,GAAW,OAAAC,EAAA;AACtB;"}
|
|
@@ -1,30 +1,29 @@
|
|
|
1
|
-
import { useState as
|
|
1
|
+
import { useState as n, useEffect as D } from "react";
|
|
2
2
|
const h = (d) => {
|
|
3
|
-
const
|
|
4
|
-
if (!
|
|
5
|
-
const
|
|
3
|
+
const o = typeof navigator < "u" && "bluetooth" in navigator, { acceptAllDevices: l = !1, filters: c, optionalServices: u } = d ?? {}, [f, s] = n(!1), [e, r] = n(void 0), [g, i] = n(void 0), p = async () => {
|
|
4
|
+
if (!o) return;
|
|
5
|
+
const t = await navigator.bluetooth.requestDevice({
|
|
6
6
|
acceptAllDevices: l,
|
|
7
7
|
optionalServices: u,
|
|
8
|
-
...
|
|
8
|
+
...c && { filters: c, acceptAllDevices: !1 }
|
|
9
9
|
});
|
|
10
|
-
|
|
10
|
+
r(t);
|
|
11
11
|
};
|
|
12
12
|
return D(() => {
|
|
13
13
|
if (e && e.gatt) {
|
|
14
|
-
const
|
|
14
|
+
const t = async () => {
|
|
15
15
|
if (!e.gatt) return;
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
},
|
|
19
|
-
|
|
16
|
+
const v = await e.gatt.connect();
|
|
17
|
+
i(v), s(v.connected);
|
|
18
|
+
}, a = () => {
|
|
19
|
+
i(void 0), r(void 0), s(!1);
|
|
20
20
|
};
|
|
21
|
-
return e.addEventListener("gattserverdisconnected",
|
|
22
|
-
|
|
23
|
-
e.removeEventListener("gattserverdisconnected", v), (t = e.gatt) == null || t.disconnect();
|
|
21
|
+
return e.addEventListener("gattserverdisconnected", a), t(), () => {
|
|
22
|
+
e.removeEventListener("gattserverdisconnected", a), e.gatt?.disconnect();
|
|
24
23
|
};
|
|
25
24
|
}
|
|
26
25
|
}, [e]), {
|
|
27
|
-
supported:
|
|
26
|
+
supported: o,
|
|
28
27
|
connected: f,
|
|
29
28
|
device: e,
|
|
30
29
|
requestDevice: p,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBluetooth.mjs","sources":["../../../../src/hooks/useBluetooth/useBluetooth.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\n/** The use bluetooth return type */\nexport interface UseBluetoothReturn {\n /** Indicates if bluetooth device is currently connected */\n connected: boolean;\n /** Describe connected bluetooth device */\n device?: BluetoothDevice;\n /** The GATT server for connected bluetooth device */\n server?: BluetoothRemoteGATTServer;\n /** Whether the bluetooth is supported*/\n supported: boolean;\n /** Function to request bluetooth device from the user */\n requestDevice: () => Promise<void>;\n}\n\n/** The use bluetooth options type */\nexport interface UseBluetoothOptions {\n /** The options to request all bluetooth devices */\n acceptAllDevices?: boolean;\n /** Array of filters to apply when scanning bluetooth devices */\n filters?: BluetoothLEScanFilter[];\n /** Array of optional services that the application can use */\n optionalServices?: BluetoothServiceUUID[];\n}\n\n/**\n * @name useBluetooth\n * @description - Hook for getting information about bluetooth\n * @category Browser\n *\n * @browserapi navigator.bluetooth https://developer.mozilla.org/en-US/docs/Web/API/Navigator/bluetooth\n *\n * @param {boolean} [options.acceptAllDevices=false] The options to request all Bluetooth devices\n * @param {Array<BluetoothLEScanFilter>} [options.filters] Array of filters to apply when scanning Bluetooth devices\n * @param {Array<BluetoothServiceUUID>} [options.optionalServices] Array of optional services that the application can use\n * @returns {UseBluetoothReturn} Object containing battery information & Battery API support\n *\n * @example\n * const { supported, connected, device, requestDevice, server } = useBluetooth(options);\n */\nexport const useBluetooth = (options?: UseBluetoothOptions): UseBluetoothReturn => {\n const supported = typeof navigator !== 'undefined' && 'bluetooth' in navigator;\n const { acceptAllDevices = false, filters, optionalServices } = options ?? {};\n\n const [connected, setIsConnected] = useState(false);\n const [device, setDevice] = useState<BluetoothDevice | undefined>(undefined);\n const [server, setServer] = useState<BluetoothRemoteGATTServer | undefined>(undefined);\n\n const requestDevice = async () => {\n if (!supported) return;\n\n const selectedDevice = await navigator.bluetooth.requestDevice({\n acceptAllDevices,\n optionalServices,\n ...(filters && { filters, acceptAllDevices: false })\n });\n\n setDevice(selectedDevice);\n };\n\n useEffect(() => {\n if (device && device.gatt) {\n const connectToBluetoothGATTServer = async () => {\n if (!device.gatt) return;\n const gattServer = await device.gatt.connect();\n setServer(gattServer);\n setIsConnected(gattServer.connected);\n };\n\n const reset = () => {\n setServer(undefined);\n setDevice(undefined);\n setIsConnected(false);\n };\n\n device.addEventListener('gattserverdisconnected', reset);\n connectToBluetoothGATTServer();\n\n return () => {\n device.removeEventListener('gattserverdisconnected', reset);\n device.gatt?.disconnect();\n };\n }\n }, [device]);\n\n return {\n supported,\n connected,\n device,\n requestDevice,\n server\n };\n};\n"],"names":["useBluetooth","options","supported","acceptAllDevices","filters","optionalServices","connected","setIsConnected","useState","device","setDevice","server","setServer","requestDevice","selectedDevice","useEffect","connectToBluetoothGATTServer","gattServer","reset"
|
|
1
|
+
{"version":3,"file":"useBluetooth.mjs","sources":["../../../../src/hooks/useBluetooth/useBluetooth.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\n/** The use bluetooth return type */\nexport interface UseBluetoothReturn {\n /** Indicates if bluetooth device is currently connected */\n connected: boolean;\n /** Describe connected bluetooth device */\n device?: BluetoothDevice;\n /** The GATT server for connected bluetooth device */\n server?: BluetoothRemoteGATTServer;\n /** Whether the bluetooth is supported*/\n supported: boolean;\n /** Function to request bluetooth device from the user */\n requestDevice: () => Promise<void>;\n}\n\n/** The use bluetooth options type */\nexport interface UseBluetoothOptions {\n /** The options to request all bluetooth devices */\n acceptAllDevices?: boolean;\n /** Array of filters to apply when scanning bluetooth devices */\n filters?: BluetoothLEScanFilter[];\n /** Array of optional services that the application can use */\n optionalServices?: BluetoothServiceUUID[];\n}\n\n/**\n * @name useBluetooth\n * @description - Hook for getting information about bluetooth\n * @category Browser\n *\n * @browserapi navigator.bluetooth https://developer.mozilla.org/en-US/docs/Web/API/Navigator/bluetooth\n *\n * @param {boolean} [options.acceptAllDevices=false] The options to request all Bluetooth devices\n * @param {Array<BluetoothLEScanFilter>} [options.filters] Array of filters to apply when scanning Bluetooth devices\n * @param {Array<BluetoothServiceUUID>} [options.optionalServices] Array of optional services that the application can use\n * @returns {UseBluetoothReturn} Object containing battery information & Battery API support\n *\n * @example\n * const { supported, connected, device, requestDevice, server } = useBluetooth(options);\n */\nexport const useBluetooth = (options?: UseBluetoothOptions): UseBluetoothReturn => {\n const supported = typeof navigator !== 'undefined' && 'bluetooth' in navigator;\n const { acceptAllDevices = false, filters, optionalServices } = options ?? {};\n\n const [connected, setIsConnected] = useState(false);\n const [device, setDevice] = useState<BluetoothDevice | undefined>(undefined);\n const [server, setServer] = useState<BluetoothRemoteGATTServer | undefined>(undefined);\n\n const requestDevice = async () => {\n if (!supported) return;\n\n const selectedDevice = await navigator.bluetooth.requestDevice({\n acceptAllDevices,\n optionalServices,\n ...(filters && { filters, acceptAllDevices: false })\n });\n\n setDevice(selectedDevice);\n };\n\n useEffect(() => {\n if (device && device.gatt) {\n const connectToBluetoothGATTServer = async () => {\n if (!device.gatt) return;\n const gattServer = await device.gatt.connect();\n setServer(gattServer);\n setIsConnected(gattServer.connected);\n };\n\n const reset = () => {\n setServer(undefined);\n setDevice(undefined);\n setIsConnected(false);\n };\n\n device.addEventListener('gattserverdisconnected', reset);\n connectToBluetoothGATTServer();\n\n return () => {\n device.removeEventListener('gattserverdisconnected', reset);\n device.gatt?.disconnect();\n };\n }\n }, [device]);\n\n return {\n supported,\n connected,\n device,\n requestDevice,\n server\n };\n};\n"],"names":["useBluetooth","options","supported","acceptAllDevices","filters","optionalServices","connected","setIsConnected","useState","device","setDevice","server","setServer","requestDevice","selectedDevice","useEffect","connectToBluetoothGATTServer","gattServer","reset"],"mappings":";AAyCO,MAAMA,IAAe,CAACC,MAAsD;AACjF,QAAMC,IAAY,OAAO,YAAc,OAAe,eAAe,WAC/D,EAAE,kBAAAC,IAAmB,IAAO,SAAAC,GAAS,kBAAAC,EAAA,IAAqBJ,KAAW,CAAA,GAErE,CAACK,GAAWC,CAAc,IAAIC,EAAS,EAAK,GAC5C,CAACC,GAAQC,CAAS,IAAIF,EAAsC,MAAS,GACrE,CAACG,GAAQC,CAAS,IAAIJ,EAAgD,MAAS,GAE/EK,IAAgB,YAAY;AAChC,QAAI,CAACX,EAAW;AAEhB,UAAMY,IAAiB,MAAM,UAAU,UAAU,cAAc;AAAA,MAC7D,kBAAAX;AAAA,MACA,kBAAAE;AAAA,MACA,GAAID,KAAW,EAAE,SAAAA,GAAS,kBAAkB,GAAA;AAAA,IAAM,CACnD;AAED,IAAAM,EAAUI,CAAc;AAAA,EAAA;AAG1B,SAAAC,EAAU,MAAM;AACd,QAAIN,KAAUA,EAAO,MAAM;AACzB,YAAMO,IAA+B,YAAY;AAC/C,YAAI,CAACP,EAAO,KAAM;AAClB,cAAMQ,IAAa,MAAMR,EAAO,KAAK,QAAA;AACrC,QAAAG,EAAUK,CAAU,GACpBV,EAAeU,EAAW,SAAS;AAAA,MAAA,GAG/BC,IAAQ,MAAM;AAClB,QAAAN,EAAU,MAAS,GACnBF,EAAU,MAAS,GACnBH,EAAe,EAAK;AAAA,MAAA;AAGtB,aAAAE,EAAO,iBAAiB,0BAA0BS,CAAK,GACvDF,EAAA,GAEO,MAAM;AACX,QAAAP,EAAO,oBAAoB,0BAA0BS,CAAK,GAC1DT,EAAO,MAAM,WAAA;AAAA,MAAW;AAAA,IAC1B;AAAA,EACF,GACC,CAACA,CAAM,CAAC,GAEJ;AAAA,IACL,WAAAP;AAAA,IACA,WAAAI;AAAA,IACA,QAAAG;AAAA,IACA,eAAAI;AAAA,IACA,QAAAF;AAAA,EAAA;AAEJ;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBoolean.mjs","sources":["../../../../src/hooks/useBoolean/useBoolean.ts"],"sourcesContent":["import { useState } from 'react';\n\n/** The use boolean return type */\nexport type UseBooleanReturn = [\n /** The current boolean state value */\n value: boolean,\n /** Function to toggle the boolean state */\n toggle: (value?: boolean) => void\n];\n\n/**\n * @name useBoolean\n * @description - Hook provides opportunity to manage boolean state\n * @category Utilities\n *\n * @param {boolean} [initialValue=false] The initial boolean value\n * @returns {UseBooleanReturn} An object containing the boolean state value and utility functions to manipulate the state\n *\n * @example\n * const [on, toggle] = useBoolean()\n */\nexport const useBoolean = (initialValue = false): UseBooleanReturn => {\n const [value, setValue] = useState(initialValue);\n const toggle = (value?: boolean) => setValue((prevValue) => value ?? !prevValue);\n\n return [value, toggle];\n};\n"],"names":["useBoolean","initialValue","value","setValue","useState","prevValue"],"mappings":";
|
|
1
|
+
{"version":3,"file":"useBoolean.mjs","sources":["../../../../src/hooks/useBoolean/useBoolean.ts"],"sourcesContent":["import { useState } from 'react';\n\n/** The use boolean return type */\nexport type UseBooleanReturn = [\n /** The current boolean state value */\n value: boolean,\n /** Function to toggle the boolean state */\n toggle: (value?: boolean) => void\n];\n\n/**\n * @name useBoolean\n * @description - Hook provides opportunity to manage boolean state\n * @category Utilities\n *\n * @param {boolean} [initialValue=false] The initial boolean value\n * @returns {UseBooleanReturn} An object containing the boolean state value and utility functions to manipulate the state\n *\n * @example\n * const [on, toggle] = useBoolean()\n */\nexport const useBoolean = (initialValue = false): UseBooleanReturn => {\n const [value, setValue] = useState(initialValue);\n const toggle = (value?: boolean) => setValue((prevValue) => value ?? !prevValue);\n\n return [value, toggle];\n};\n"],"names":["useBoolean","initialValue","value","setValue","useState","prevValue"],"mappings":";AAqBO,MAAMA,IAAa,CAACC,IAAe,OAA4B;AACpE,QAAM,CAACC,GAAOC,CAAQ,IAAIC,EAASH,CAAY;AAG/C,SAAO,CAACC,GAFO,CAACA,MAAoBC,EAAS,CAACE,MAAcH,KAAS,CAACG,CAAS,CAE1D;AACvB;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBreakpoints.mjs","sources":["../../../../src/hooks/useBreakpoints/useBreakpoints.ts"],"sourcesContent":["import { useEffect } from 'react';\n\nimport { useRerender } from '../useRerender/useRerender';\n\n/** The breakpoints type */\nexport type Breakpoints<Breakpoint extends string = string> = Record<Breakpoint, number>;\n\n/** The use breakpoints strategy */\nexport type UseBreakpointsStrategy = 'desktop-first' | 'mobile-first';\n\nconst match = (query: string) => window.matchMedia(query).matches;\n\n/** The use breakpoints return type */\nexport type UseBreakpointsReturn<Breakpoint extends string = string> = {\n /** The function that checks if the current breakpoint is greater than to the given breakpoint */\n greater: (breakpoint: Breakpoint) => boolean;\n /** The function that checks if the current breakpoint is greater than or equal to the given breakpoint */\n greaterOrEqual: (breakpoint: Breakpoint) => boolean;\n /** The function that checks if the current breakpoint is smaller than to the given breakpoint */\n smaller: (breakpoint: Breakpoint) => boolean;\n /** The function that checks if the current breakpoint is smaller than or equal to the given breakpoint */\n smallerOrEqual: (breakpoint: Breakpoint) => boolean;\n /** The function that checks if the current breakpoint is between to the given breakpoints */\n between: (a: Breakpoint, b: Breakpoint) => boolean;\n /** The function that checks if the current breakpoint is greater than to the given breakpoint */\n isGreater: (breakpoint: Breakpoint) => boolean;\n /** The function that checks if the current breakpoint is greater than or equal to the given breakpoint */\n isGreaterOrEqual: (breakpoint: Breakpoint) => boolean;\n /** The function that checks if the current breakpoint is smaller than to the given breakpoint */\n isSmaller: (breakpoint: Breakpoint) => boolean;\n /** The function that checks if the current breakpoint is smaller than or equal to the given breakpoint */\n isSmallerOrEqual: (breakpoint: Breakpoint) => boolean;\n /** The function that checks if the current breakpoint is between to the given breakpoints */\n isInBetween: (a: Breakpoint, b: Breakpoint) => boolean;\n /** The function that returns the current breakpoints */\n current: () => Breakpoint[];\n /** The function that returns the current active breakpoint */\n active: () => Breakpoint;\n} & Record<Breakpoint, boolean>;\n\n/**\n * @name useBreakpoints\n * @description - Hook that manages breakpoints\n * @category Browser\n *\n * @template {string} Breakpoint The name of the breakpoint\n * @param {Breakpoints<Breakpoint>} breakpoints The breakpoints to use\n * @param {UseBreakpointsStrategy} [strategy=min-width] The strategy to use for matching\n * @returns {UseBreakpointsReturn<Breakpoint>} An object containing the current breakpoint\n *\n * @example\n * const { greaterOrEqual, smallerOrEqual, current } = useBreakpoints({ mobile: 0, tablet: 640, laptop: 1024, desktop: 1280 });\n */\nexport const useBreakpoints = <Breakpoint extends string>(\n breakpoints: Breakpoints<Breakpoint>,\n strategy: UseBreakpointsStrategy = 'mobile-first'\n): UseBreakpointsReturn<Breakpoint> => {\n const rerender = useRerender();\n\n const getValue = (breakpoint: Breakpoint, delta?: number) => {\n if (delta) return `${Number(breakpoints[breakpoint]) + delta}px`;\n return `${breakpoints[breakpoint]}px`;\n };\n\n useEffect(() => {\n const onResize = () => rerender();\n window.addEventListener('resize', onResize);\n return () => {\n window.removeEventListener('resize', onResize);\n };\n }, []);\n\n const greaterOrEqual = (breakpoint: Breakpoint) => match(`(min-width: ${getValue(breakpoint)})`);\n const smallerOrEqual = (breakpoint: Breakpoint) => match(`(max-width: ${getValue(breakpoint)})`);\n const current = () =>\n Object.keys(breakpoints)\n .map((breakpoint) => [breakpoint, greaterOrEqual(breakpoint as Breakpoint)])\n .filter(([, value]) => value)\n .map(([breakpoint]) => breakpoint) as Breakpoint[];\n const active = () => {\n const breakpoints = current();\n return (breakpoints.length ? breakpoints.at(-1) : undefined) as Breakpoint;\n };\n\n const greater = (breakpoint: Breakpoint) => match(`(min-width: ${getValue(breakpoint, 0.1)})`);\n const smaller = (breakpoint: Breakpoint) => match(`(max-width: ${getValue(breakpoint, -0.1)})`);\n const between = (a: Breakpoint, b: Breakpoint) =>\n match(`(min-width: ${getValue(a)}) and (max-width: ${getValue(b, -0.1)})`);\n\n const breakpointsKeys = (Object.keys(breakpoints) as Breakpoint[]).reduce(\n (acc, breakpoint) => {\n const value =\n strategy === 'mobile-first' ? greaterOrEqual(breakpoint) : smallerOrEqual(breakpoint);\n acc[breakpoint] = value;\n return acc;\n },\n {} as Record<Breakpoint, boolean>\n );\n\n return {\n current,\n greaterOrEqual,\n smallerOrEqual,\n active,\n greater,\n smaller,\n between,\n isGreater: greater,\n isGreaterOrEqual: greaterOrEqual,\n isSmaller: smaller,\n isSmallerOrEqual: smallerOrEqual,\n isInBetween: between,\n ...breakpointsKeys\n };\n};\n\n/** Breakpoints from Material UI */\nexport const BREAKPOINTS_MATERIAL_UI = {\n xs: 0,\n sm: 600,\n md: 900,\n lg: 1200,\n xl: 1536\n};\n\n/** Breakpoints from Mantine */\nexport const BREAKPOINTS_MANTINE = {\n xs: 576,\n sm: 768,\n md: 992,\n lg: 1200,\n xl: 1408\n};\n\n/** Breakpoints from Tailwind */\nexport const BREAKPOINTS_TAILWIND = {\n sm: 640,\n md: 768,\n lg: 1024,\n xl: 1280,\n '2xl': 1536\n};\n\n/** Breakpoints from Bootstrap V5 */\nexport const BREAKPOINTS_BOOTSTRAP_V5 = {\n xs: 0,\n sm: 576,\n md: 768,\n lg: 992,\n xl: 1200,\n xxl: 1400\n};\n\n/** Breakpoints from Ant Design */\nexport const BREAKPOINTS_ANT_DESIGN = {\n xs: 480,\n sm: 576,\n md: 768,\n lg: 992,\n xl: 1200,\n xxl: 1600\n};\n\n/** Breakpoints from Quasar V2 */\nexport const BREAKPOINTS_QUASAR_V2 = {\n xs: 0,\n sm: 600,\n md: 1024,\n lg: 1440,\n xl: 1920\n};\n\n/** Sematic Breakpoints */\nexport const BREAKPOINTS_SEMANTIC = {\n mobileS: 320,\n mobileM: 375,\n mobileL: 425,\n tablet: 768,\n laptop: 1024,\n laptopL: 1440,\n desktop4K: 2560\n};\n\n/** Breakpoints from Master CSS */\nexport const BREAKPOINTS_MASTER_CSS = {\n '3xs': 360,\n '2xs': 480,\n xs: 600,\n sm: 768,\n md: 1024,\n lg: 1280,\n xl: 1440,\n '2xl': 1600,\n '3xl': 1920,\n '4xl': 2560\n};\n\n/** Breakpoints from PrimeFlex */\nexport const BREAKPOINTS_PRIME_FLEX = {\n sm: 576,\n md: 768,\n lg: 992,\n xl: 1200\n};\n"],"names":["match","query","useBreakpoints","breakpoints","strategy","rerender","useRerender","getValue","breakpoint","delta","useEffect","onResize","greaterOrEqual","smallerOrEqual","current","value","active","greater","smaller","between","a","b","breakpointsKeys","acc","BREAKPOINTS_MATERIAL_UI","BREAKPOINTS_MANTINE","BREAKPOINTS_TAILWIND","BREAKPOINTS_BOOTSTRAP_V5","BREAKPOINTS_ANT_DESIGN","BREAKPOINTS_QUASAR_V2","BREAKPOINTS_SEMANTIC","BREAKPOINTS_MASTER_CSS","BREAKPOINTS_PRIME_FLEX"],"mappings":";;AAUA,MAAMA,IAAQ,CAACC,MAAkB,OAAO,WAAWA,CAAK,EAAE,SA2C7CC,IAAiB,CAC5BC,GACAC,IAAmC,mBACE;AACrC,QAAMC,IAAWC,
|
|
1
|
+
{"version":3,"file":"useBreakpoints.mjs","sources":["../../../../src/hooks/useBreakpoints/useBreakpoints.ts"],"sourcesContent":["import { useEffect } from 'react';\n\nimport { useRerender } from '../useRerender/useRerender';\n\n/** The breakpoints type */\nexport type Breakpoints<Breakpoint extends string = string> = Record<Breakpoint, number>;\n\n/** The use breakpoints strategy */\nexport type UseBreakpointsStrategy = 'desktop-first' | 'mobile-first';\n\nconst match = (query: string) => window.matchMedia(query).matches;\n\n/** The use breakpoints return type */\nexport type UseBreakpointsReturn<Breakpoint extends string = string> = {\n /** The function that checks if the current breakpoint is greater than to the given breakpoint */\n greater: (breakpoint: Breakpoint) => boolean;\n /** The function that checks if the current breakpoint is greater than or equal to the given breakpoint */\n greaterOrEqual: (breakpoint: Breakpoint) => boolean;\n /** The function that checks if the current breakpoint is smaller than to the given breakpoint */\n smaller: (breakpoint: Breakpoint) => boolean;\n /** The function that checks if the current breakpoint is smaller than or equal to the given breakpoint */\n smallerOrEqual: (breakpoint: Breakpoint) => boolean;\n /** The function that checks if the current breakpoint is between to the given breakpoints */\n between: (a: Breakpoint, b: Breakpoint) => boolean;\n /** The function that checks if the current breakpoint is greater than to the given breakpoint */\n isGreater: (breakpoint: Breakpoint) => boolean;\n /** The function that checks if the current breakpoint is greater than or equal to the given breakpoint */\n isGreaterOrEqual: (breakpoint: Breakpoint) => boolean;\n /** The function that checks if the current breakpoint is smaller than to the given breakpoint */\n isSmaller: (breakpoint: Breakpoint) => boolean;\n /** The function that checks if the current breakpoint is smaller than or equal to the given breakpoint */\n isSmallerOrEqual: (breakpoint: Breakpoint) => boolean;\n /** The function that checks if the current breakpoint is between to the given breakpoints */\n isInBetween: (a: Breakpoint, b: Breakpoint) => boolean;\n /** The function that returns the current breakpoints */\n current: () => Breakpoint[];\n /** The function that returns the current active breakpoint */\n active: () => Breakpoint;\n} & Record<Breakpoint, boolean>;\n\n/**\n * @name useBreakpoints\n * @description - Hook that manages breakpoints\n * @category Browser\n *\n * @template {string} Breakpoint The name of the breakpoint\n * @param {Breakpoints<Breakpoint>} breakpoints The breakpoints to use\n * @param {UseBreakpointsStrategy} [strategy=min-width] The strategy to use for matching\n * @returns {UseBreakpointsReturn<Breakpoint>} An object containing the current breakpoint\n *\n * @example\n * const { greaterOrEqual, smallerOrEqual, current } = useBreakpoints({ mobile: 0, tablet: 640, laptop: 1024, desktop: 1280 });\n */\nexport const useBreakpoints = <Breakpoint extends string>(\n breakpoints: Breakpoints<Breakpoint>,\n strategy: UseBreakpointsStrategy = 'mobile-first'\n): UseBreakpointsReturn<Breakpoint> => {\n const rerender = useRerender();\n\n const getValue = (breakpoint: Breakpoint, delta?: number) => {\n if (delta) return `${Number(breakpoints[breakpoint]) + delta}px`;\n return `${breakpoints[breakpoint]}px`;\n };\n\n useEffect(() => {\n const onResize = () => rerender();\n window.addEventListener('resize', onResize);\n return () => {\n window.removeEventListener('resize', onResize);\n };\n }, []);\n\n const greaterOrEqual = (breakpoint: Breakpoint) => match(`(min-width: ${getValue(breakpoint)})`);\n const smallerOrEqual = (breakpoint: Breakpoint) => match(`(max-width: ${getValue(breakpoint)})`);\n const current = () =>\n Object.keys(breakpoints)\n .map((breakpoint) => [breakpoint, greaterOrEqual(breakpoint as Breakpoint)])\n .filter(([, value]) => value)\n .map(([breakpoint]) => breakpoint) as Breakpoint[];\n const active = () => {\n const breakpoints = current();\n return (breakpoints.length ? breakpoints.at(-1) : undefined) as Breakpoint;\n };\n\n const greater = (breakpoint: Breakpoint) => match(`(min-width: ${getValue(breakpoint, 0.1)})`);\n const smaller = (breakpoint: Breakpoint) => match(`(max-width: ${getValue(breakpoint, -0.1)})`);\n const between = (a: Breakpoint, b: Breakpoint) =>\n match(`(min-width: ${getValue(a)}) and (max-width: ${getValue(b, -0.1)})`);\n\n const breakpointsKeys = (Object.keys(breakpoints) as Breakpoint[]).reduce(\n (acc, breakpoint) => {\n const value =\n strategy === 'mobile-first' ? greaterOrEqual(breakpoint) : smallerOrEqual(breakpoint);\n acc[breakpoint] = value;\n return acc;\n },\n {} as Record<Breakpoint, boolean>\n );\n\n return {\n current,\n greaterOrEqual,\n smallerOrEqual,\n active,\n greater,\n smaller,\n between,\n isGreater: greater,\n isGreaterOrEqual: greaterOrEqual,\n isSmaller: smaller,\n isSmallerOrEqual: smallerOrEqual,\n isInBetween: between,\n ...breakpointsKeys\n };\n};\n\n/** Breakpoints from Material UI */\nexport const BREAKPOINTS_MATERIAL_UI = {\n xs: 0,\n sm: 600,\n md: 900,\n lg: 1200,\n xl: 1536\n};\n\n/** Breakpoints from Mantine */\nexport const BREAKPOINTS_MANTINE = {\n xs: 576,\n sm: 768,\n md: 992,\n lg: 1200,\n xl: 1408\n};\n\n/** Breakpoints from Tailwind */\nexport const BREAKPOINTS_TAILWIND = {\n sm: 640,\n md: 768,\n lg: 1024,\n xl: 1280,\n '2xl': 1536\n};\n\n/** Breakpoints from Bootstrap V5 */\nexport const BREAKPOINTS_BOOTSTRAP_V5 = {\n xs: 0,\n sm: 576,\n md: 768,\n lg: 992,\n xl: 1200,\n xxl: 1400\n};\n\n/** Breakpoints from Ant Design */\nexport const BREAKPOINTS_ANT_DESIGN = {\n xs: 480,\n sm: 576,\n md: 768,\n lg: 992,\n xl: 1200,\n xxl: 1600\n};\n\n/** Breakpoints from Quasar V2 */\nexport const BREAKPOINTS_QUASAR_V2 = {\n xs: 0,\n sm: 600,\n md: 1024,\n lg: 1440,\n xl: 1920\n};\n\n/** Sematic Breakpoints */\nexport const BREAKPOINTS_SEMANTIC = {\n mobileS: 320,\n mobileM: 375,\n mobileL: 425,\n tablet: 768,\n laptop: 1024,\n laptopL: 1440,\n desktop4K: 2560\n};\n\n/** Breakpoints from Master CSS */\nexport const BREAKPOINTS_MASTER_CSS = {\n '3xs': 360,\n '2xs': 480,\n xs: 600,\n sm: 768,\n md: 1024,\n lg: 1280,\n xl: 1440,\n '2xl': 1600,\n '3xl': 1920,\n '4xl': 2560\n};\n\n/** Breakpoints from PrimeFlex */\nexport const BREAKPOINTS_PRIME_FLEX = {\n sm: 576,\n md: 768,\n lg: 992,\n xl: 1200\n};\n"],"names":["match","query","useBreakpoints","breakpoints","strategy","rerender","useRerender","getValue","breakpoint","delta","useEffect","onResize","greaterOrEqual","smallerOrEqual","current","value","active","greater","smaller","between","a","b","breakpointsKeys","acc","BREAKPOINTS_MATERIAL_UI","BREAKPOINTS_MANTINE","BREAKPOINTS_TAILWIND","BREAKPOINTS_BOOTSTRAP_V5","BREAKPOINTS_ANT_DESIGN","BREAKPOINTS_QUASAR_V2","BREAKPOINTS_SEMANTIC","BREAKPOINTS_MASTER_CSS","BREAKPOINTS_PRIME_FLEX"],"mappings":";;AAUA,MAAMA,IAAQ,CAACC,MAAkB,OAAO,WAAWA,CAAK,EAAE,SA2C7CC,IAAiB,CAC5BC,GACAC,IAAmC,mBACE;AACrC,QAAMC,IAAWC,EAAA,GAEXC,IAAW,CAACC,GAAwBC,MACpCA,IAAc,GAAG,OAAON,EAAYK,CAAU,CAAC,IAAIC,CAAK,OACrD,GAAGN,EAAYK,CAAU,CAAC;AAGnC,EAAAE,EAAU,MAAM;AACd,UAAMC,IAAW,MAAMN,EAAA;AACvB,kBAAO,iBAAiB,UAAUM,CAAQ,GACnC,MAAM;AACX,aAAO,oBAAoB,UAAUA,CAAQ;AAAA,IAAA;AAAA,EAC/C,GACC,EAAE;AAEL,QAAMC,IAAiB,CAACJ,MAA2BR,EAAM,eAAeO,EAASC,CAAU,CAAC,GAAG,GACzFK,IAAiB,CAACL,MAA2BR,EAAM,eAAeO,EAASC,CAAU,CAAC,GAAG,GACzFM,IAAU,MACd,OAAO,KAAKX,CAAW,EACpB,IAAI,CAACK,MAAe,CAACA,GAAYI,EAAeJ,CAAwB,CAAC,CAAC,EAC1E,OAAO,CAAC,CAAA,EAAGO,CAAK,MAAMA,CAAK,EAC3B,IAAI,CAAC,CAACP,CAAU,MAAMA,CAAU,GAC/BQ,IAAS,MAAM;AACnB,UAAMb,IAAcW,EAAA;AACpB,WAAQX,EAAY,SAASA,EAAY,GAAG,EAAE,IAAI;AAAA,EAAA,GAG9Cc,IAAU,CAACT,MAA2BR,EAAM,eAAeO,EAASC,GAAY,GAAG,CAAC,GAAG,GACvFU,IAAU,CAACV,MAA2BR,EAAM,eAAeO,EAASC,GAAY,IAAI,CAAC,GAAG,GACxFW,IAAU,CAACC,GAAeC,MAC9BrB,EAAM,eAAeO,EAASa,CAAC,CAAC,qBAAqBb,EAASc,GAAG,IAAI,CAAC,GAAG,GAErEC,IAAmB,OAAO,KAAKnB,CAAW,EAAmB;AAAA,IACjE,CAACoB,GAAKf,MAAe;AACnB,YAAMO,IACJX,MAAa,iBAAiBQ,EAAeJ,CAAU,IAAIK,EAAeL,CAAU;AACtF,aAAAe,EAAIf,CAAU,IAAIO,GACXQ;AAAA,IAAA;AAAA,IAET,CAAA;AAAA,EAAC;AAGH,SAAO;AAAA,IACL,SAAAT;AAAA,IACA,gBAAAF;AAAA,IACA,gBAAAC;AAAA,IACA,QAAAG;AAAA,IACA,SAAAC;AAAA,IACA,SAAAC;AAAA,IACA,SAAAC;AAAA,IACA,WAAWF;AAAA,IACX,kBAAkBL;AAAA,IAClB,WAAWM;AAAA,IACX,kBAAkBL;AAAA,IAClB,aAAaM;AAAA,IACb,GAAGG;AAAA,EAAA;AAEP,GAGaE,IAA0B;AAAA,EACrC,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN,GAGaC,IAAsB;AAAA,EACjC,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN,GAGaC,IAAuB;AAAA,EAClC,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,OAAO;AACT,GAGaC,IAA2B;AAAA,EACtC,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,KAAK;AACP,GAGaC,IAAyB;AAAA,EACpC,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,KAAK;AACP,GAGaC,IAAwB;AAAA,EACnC,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN,GAGaC,IAAuB;AAAA,EAClC,SAAS;AAAA,EACT,SAAS;AAAA,EACT,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,WAAW;AACb,GAGaC,IAAyB;AAAA,EACpC,OAAO;AAAA,EACP,OAAO;AAAA,EACP,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,OAAO;AAAA,EACP,OAAO;AAAA,EACP,OAAO;AACT,GAGaC,IAAyB;AAAA,EACpC,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBrowserLanguage.mjs","sources":["../../../../src/hooks/useBrowserLanguage/useBrowserLanguage.ts"],"sourcesContent":["import { useSyncExternalStore } from 'react';\n\nconst getSnapshot = () => navigator.language;\nconst getServerSnapshot = () => 'undetermined';\nconst subscribe = (callback: () => void) => {\n window.addEventListener('languagechange', callback);\n return () => window.removeEventListener('languagechange', callback);\n};\n\n/**\n * @name useBrowserLanguage\n * @description - Hook that returns the current browser language\n * @category Browser\n *\n * @browserapi navigator.language https://developer.mozilla.org/en-US/docs/Web/API/Navigator/language\n *\n * @returns {string} The current browser language\n *\n * @example\n * const browserLanguage = useBrowserLanguage();\n */\nexport const useBrowserLanguage = () =>\n useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\n"],"names":["getSnapshot","getServerSnapshot","subscribe","callback","useBrowserLanguage","useSyncExternalStore"],"mappings":";AAEA,MAAMA,IAAc,MAAM,UAAU,UAC9BC,IAAoB,MAAM,gBAC1BC,IAAY,CAACC,
|
|
1
|
+
{"version":3,"file":"useBrowserLanguage.mjs","sources":["../../../../src/hooks/useBrowserLanguage/useBrowserLanguage.ts"],"sourcesContent":["import { useSyncExternalStore } from 'react';\n\nconst getSnapshot = () => navigator.language;\nconst getServerSnapshot = () => 'undetermined';\nconst subscribe = (callback: () => void) => {\n window.addEventListener('languagechange', callback);\n return () => window.removeEventListener('languagechange', callback);\n};\n\n/**\n * @name useBrowserLanguage\n * @description - Hook that returns the current browser language\n * @category Browser\n *\n * @browserapi navigator.language https://developer.mozilla.org/en-US/docs/Web/API/Navigator/language\n *\n * @returns {string} The current browser language\n *\n * @example\n * const browserLanguage = useBrowserLanguage();\n */\nexport const useBrowserLanguage = () =>\n useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\n"],"names":["getSnapshot","getServerSnapshot","subscribe","callback","useBrowserLanguage","useSyncExternalStore"],"mappings":";AAEA,MAAMA,IAAc,MAAM,UAAU,UAC9BC,IAAoB,MAAM,gBAC1BC,IAAY,CAACC,OACjB,OAAO,iBAAiB,kBAAkBA,CAAQ,GAC3C,MAAM,OAAO,oBAAoB,kBAAkBA,CAAQ,IAevDC,IAAqB,MAChCC,EAAqBH,GAAWF,GAAaC,CAAiB;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useClickOutside.mjs","sources":["../../../../src/hooks/useClickOutside/useClickOutside.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\n\nimport type { HookTarget } from '@/utils/helpers';\n\nimport { getElement, isTarget } from '@/utils/helpers';\n\nimport type { StateRef } from '../useRefState/useRefState';\n\nimport { useRefState } from '../useRefState/useRefState';\n\nexport interface UseClickOutside {\n (target: HookTarget, callback: (event: Event) => void): void;\n\n <Target extends Element>(callback: (event: Event) => void, target?: never): StateRef<Target>;\n}\n\n/**\n * @name useClickOutside\n * @description - Hook to handle click events outside the specified target element(s)\n * @category Sensors\n *\n * @overload\n * @param {HookTarget} target The target element(s) to detect outside clicks for\n * @param {(event: Event) => void} callback The callback to execute when a click outside the target is detected\n * @returns {void}\n *\n * @example\n * useClickOutside(ref, () => console.log('click outside'));\n *\n * @overload\n * @template Target The target element(s)\n * @param {(event: Event) => void} callback The callback to execute when a click outside the target is detected\n * @returns {(node: Target) => void} A React ref to attach to the target element\n *\n * @example\n * const ref = useClickOutside<HTMLDivElement>(() => console.log('click outside'));\n *\n * @see {@link https://siberiacancode.github.io/reactuse/functions/hooks/useClickOutside.html}\n */\nexport const useClickOutside = ((...params: any[]) => {\n const target = (isTarget(params[0]) ? params[0] : undefined) as HookTarget | undefined;\n const callback = (params[1] ? params[1] : params[0]) as (event: Event) => void;\n\n const internalRef = useRefState<Element>();\n const internalCallbackRef = useRef(callback);\n internalCallbackRef.current = callback;\n\n useEffect(() => {\n if (!target && !internalRef.state) return;\n const onClick = (event: Event) => {\n const element = (target ? getElement(target) : internalRef.current) as Element;\n\n if (element && !element.contains(event.target as Node)) {\n internalCallbackRef.current(event);\n }\n };\n\n document.addEventListener('click', onClick);\n\n return () => {\n document.removeEventListener('click', onClick);\n };\n }, [target, internalRef.state]);\n\n if (target) return;\n return internalRef;\n}) as UseClickOutside;\n"],"names":["useClickOutside","params","target","isTarget","callback","internalRef","useRefState","internalCallbackRef","useRef","useEffect","onClick","event","element","getElement"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"useClickOutside.mjs","sources":["../../../../src/hooks/useClickOutside/useClickOutside.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\n\nimport type { HookTarget } from '@/utils/helpers';\n\nimport { getElement, isTarget } from '@/utils/helpers';\n\nimport type { StateRef } from '../useRefState/useRefState';\n\nimport { useRefState } from '../useRefState/useRefState';\n\nexport interface UseClickOutside {\n (target: HookTarget, callback: (event: Event) => void): void;\n\n <Target extends Element>(callback: (event: Event) => void, target?: never): StateRef<Target>;\n}\n\n/**\n * @name useClickOutside\n * @description - Hook to handle click events outside the specified target element(s)\n * @category Sensors\n *\n * @overload\n * @param {HookTarget} target The target element(s) to detect outside clicks for\n * @param {(event: Event) => void} callback The callback to execute when a click outside the target is detected\n * @returns {void}\n *\n * @example\n * useClickOutside(ref, () => console.log('click outside'));\n *\n * @overload\n * @template Target The target element(s)\n * @param {(event: Event) => void} callback The callback to execute when a click outside the target is detected\n * @returns {(node: Target) => void} A React ref to attach to the target element\n *\n * @example\n * const ref = useClickOutside<HTMLDivElement>(() => console.log('click outside'));\n *\n * @see {@link https://siberiacancode.github.io/reactuse/functions/hooks/useClickOutside.html}\n */\nexport const useClickOutside = ((...params: any[]) => {\n const target = (isTarget(params[0]) ? params[0] : undefined) as HookTarget | undefined;\n const callback = (params[1] ? params[1] : params[0]) as (event: Event) => void;\n\n const internalRef = useRefState<Element>();\n const internalCallbackRef = useRef(callback);\n internalCallbackRef.current = callback;\n\n useEffect(() => {\n if (!target && !internalRef.state) return;\n const onClick = (event: Event) => {\n const element = (target ? getElement(target) : internalRef.current) as Element;\n\n if (element && !element.contains(event.target as Node)) {\n internalCallbackRef.current(event);\n }\n };\n\n document.addEventListener('click', onClick);\n\n return () => {\n document.removeEventListener('click', onClick);\n };\n }, [target, internalRef.state]);\n\n if (target) return;\n return internalRef;\n}) as UseClickOutside;\n"],"names":["useClickOutside","params","target","isTarget","callback","internalRef","useRefState","internalCallbackRef","useRef","useEffect","onClick","event","element","getElement"],"mappings":";;;;AAuCO,MAAMA,IAAmB,IAAIC,MAAkB;AACpD,QAAMC,IAAUC,EAASF,EAAO,CAAC,CAAC,IAAIA,EAAO,CAAC,IAAI,QAC5CG,IAAYH,EAAO,CAAC,IAAIA,EAAO,CAAC,IAAIA,EAAO,CAAC,GAE5CI,IAAcC,EAAA,GACdC,IAAsBC,EAAOJ,CAAQ;AAoB3C,MAnBAG,EAAoB,UAAUH,GAE9BK,EAAU,MAAM;AACd,QAAI,CAACP,KAAU,CAACG,EAAY,MAAO;AACnC,UAAMK,IAAU,CAACC,MAAiB;AAChC,YAAMC,IAAWV,IAASW,EAAWX,CAAM,IAAIG,EAAY;AAE3D,MAAIO,KAAW,CAACA,EAAQ,SAASD,EAAM,MAAc,KACnDJ,EAAoB,QAAQI,CAAK;AAAA,IACnC;AAGF,oBAAS,iBAAiB,SAASD,CAAO,GAEnC,MAAM;AACX,eAAS,oBAAoB,SAASA,CAAO;AAAA,IAAA;AAAA,EAC/C,GACC,CAACR,GAAQG,EAAY,KAAK,CAAC,GAE1B,CAAAH;AACJ,WAAOG;AACT;"}
|