@siberiacancode/reactuse 0.0.53 → 0.0.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{_rollupPluginBabelHelpers-D4KMnNuQ.js → _rollupPluginBabelHelpers-BteBusnh.js} +2 -2
- package/dist/cjs/_rollupPluginBabelHelpers-BteBusnh.js.map +1 -0
- package/dist/cjs/hooks/index.js +2 -2
- package/dist/cjs/hooks/useAsync/useAsync.js +3 -0
- package/dist/cjs/hooks/useAsync/useAsync.js.map +1 -0
- package/dist/cjs/hooks/useBattery/useBattery.js +2 -2
- package/dist/cjs/hooks/useBoolean/useBoolean.js +2 -2
- package/dist/cjs/hooks/useBreakpoints/constants/breakpoints.js +1 -1
- package/dist/cjs/hooks/useBreakpoints/useBreakpoints.js +2 -2
- package/dist/cjs/hooks/useBrowserLanguage/useBrowserLanguage.js +1 -1
- package/dist/cjs/hooks/useClickOutside/useClickOutside.js +2 -2
- package/dist/cjs/hooks/useClipboard/useClipboard.js +2 -2
- package/dist/cjs/hooks/useCounter/useCounter.js +2 -2
- package/dist/cjs/hooks/useCounter/useCounter.js.map +1 -1
- package/dist/cjs/hooks/useDebounceCallback/useDebounceCallback.js +1 -1
- package/dist/cjs/hooks/useDebounceValue/useDebounceValue.js +2 -2
- package/dist/cjs/hooks/useDefault/useDefault.js +2 -2
- package/dist/cjs/hooks/useDidUpdate/useDidUpdate.js +1 -1
- package/dist/cjs/hooks/useDisclosure/useDisclosure.js +2 -2
- package/dist/cjs/hooks/useDocumentEvent/useDocumentEvent.js +1 -1
- package/dist/cjs/hooks/useDocumentTitle/useDocumentTitle.js +2 -2
- package/dist/cjs/hooks/useDocumentVisibility/useDocumentVisibility.js +1 -1
- package/dist/cjs/hooks/useEvent/useEvent.js +1 -1
- package/dist/cjs/hooks/useEventListener/useEventListener.js +1 -1
- package/dist/cjs/hooks/useEyeDropper/useEyeDropper.js +2 -2
- package/dist/cjs/hooks/useFavicon/useFavicon.js +2 -2
- package/dist/cjs/hooks/useField/useField.js +2 -2
- package/dist/cjs/hooks/useFileDialog/useFileDialog.js +2 -2
- package/dist/cjs/hooks/useFps/useFps.js +2 -2
- package/dist/cjs/hooks/useFullscreen/useFullscreen.js +2 -2
- package/dist/cjs/hooks/useGeolocation/useGeolocation.js +2 -2
- package/dist/cjs/hooks/useHash/useHash.js +2 -2
- package/dist/cjs/hooks/useHotkeys/useHotkeys.js +2 -2
- package/dist/cjs/hooks/useHotkeys/useHotkeys.js.map +1 -1
- package/dist/cjs/hooks/useHover/useHover.js +2 -2
- package/dist/cjs/hooks/useIdle/useIdle.js +2 -2
- package/dist/cjs/hooks/useImage/useImage.js +2 -2
- package/dist/cjs/hooks/useInfiniteScroll/useInfiniteScroll.js +2 -2
- package/dist/cjs/hooks/useIntersectionObserver/useIntersectionObserver.js +2 -2
- package/dist/cjs/hooks/useInterval/useInterval.js +2 -2
- package/dist/cjs/hooks/useIsFirstRender/useIsFirstRender.js +1 -1
- package/dist/cjs/hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js +1 -1
- package/dist/cjs/hooks/useKeyPress/useKeyPress.js +2 -2
- package/dist/cjs/hooks/useKeyPressEvent/useKeyPressEvent.js +1 -1
- package/dist/cjs/hooks/useKeyboard/useKeyboard.js +1 -1
- package/dist/cjs/hooks/useKeysPressed/useKeysPressed.js +2 -2
- package/dist/cjs/hooks/useKeysPressed/useKeysPressed.js.map +1 -1
- package/dist/cjs/hooks/useList/useList.js +2 -2
- package/dist/cjs/hooks/useLocalStorage/useLocalStorage.js +2 -2
- package/dist/cjs/hooks/useLocalStorage/useLocalStorage.js.map +1 -1
- package/dist/cjs/hooks/useLogger/useLogger.js +2 -2
- package/dist/cjs/hooks/useLongPress/useLongPress.js +2 -2
- package/dist/cjs/hooks/useMap/useMap.js +2 -2
- package/dist/cjs/hooks/useMeasure/useMeasure.js +2 -2
- package/dist/cjs/hooks/useMediaQuery/useMediaQuery.js +1 -1
- package/dist/cjs/hooks/useMemory/useMemory.js +2 -2
- package/dist/cjs/hooks/useMount/useMount.js +1 -1
- package/dist/cjs/hooks/useMouse/useMouse.js +2 -2
- package/dist/cjs/hooks/useMutation/useMutation.js +2 -2
- package/dist/cjs/hooks/useMutation/useMutation.js.map +1 -1
- package/dist/cjs/hooks/useMutationObserver.js +1 -1
- package/dist/cjs/hooks/useNetwork/useNetwork.js +2 -2
- package/dist/cjs/hooks/useOnline/useOnline.js +1 -1
- package/dist/cjs/hooks/useOperatingSystem/useOperatingSystem.js +1 -1
- package/dist/cjs/hooks/useOrientation/useOrientation.js +2 -2
- package/dist/cjs/hooks/usePageLeave/usePageLeave.js +2 -2
- package/dist/cjs/hooks/usePaint/helpers/Paint.js +2 -2
- package/dist/cjs/hooks/usePaint/helpers/Pointer.js +2 -2
- package/dist/cjs/hooks/usePaint/usePaint.js +2 -2
- package/dist/cjs/hooks/usePermission/usePermission.js +2 -2
- package/dist/cjs/hooks/usePreferredColorScheme/usePreferredColorScheme.js +1 -1
- package/dist/cjs/hooks/usePreferredContrast/usePreferredContrast.js +1 -1
- package/dist/cjs/hooks/usePreferredDark/usePreferredDark.js +1 -1
- package/dist/cjs/hooks/usePreferredLanguages/usePreferredLanguages.js +1 -1
- package/dist/cjs/hooks/usePreferredReducedMotion/usePreferredReducedMotion.js +1 -1
- package/dist/cjs/hooks/usePrevious/usePrevious.js +1 -1
- package/dist/cjs/hooks/useQuery/useQuery.js +2 -2
- package/dist/cjs/hooks/useQuery/useQuery.js.map +1 -1
- package/dist/cjs/hooks/useQueue/useQueue.js +2 -2
- package/dist/cjs/hooks/useRenderCount/useRenderCount.js +1 -1
- package/dist/cjs/hooks/useRenderInfo/useRenderInfo.js +1 -1
- package/dist/cjs/hooks/useRerender/useRerender.js +2 -2
- package/dist/cjs/hooks/useResizeObserver/useResizeObserver.js +2 -2
- package/dist/cjs/hooks/useScript/useScript.js +2 -2
- package/dist/cjs/hooks/useSessionStorage/useSessionStorage.js +2 -2
- package/dist/cjs/hooks/useSessionStorage/useSessionStorage.js.map +1 -1
- package/dist/cjs/hooks/useSet/useSet.js +2 -2
- package/dist/cjs/hooks/useShare/useShare.js +2 -2
- package/dist/cjs/hooks/useStep/useStep.js +2 -2
- package/dist/cjs/hooks/useStopwatch/useStopwatch.js +2 -2
- package/dist/cjs/hooks/useStopwatch/useStopwatch.js.map +1 -1
- package/dist/cjs/hooks/useStorage/useStorage.js +2 -2
- package/dist/cjs/hooks/useStorage/useStorage.js.map +1 -1
- package/dist/cjs/hooks/useTextSelection/useTextSelection.js +2 -2
- package/dist/cjs/hooks/useTime/useTime.js +2 -2
- package/dist/cjs/hooks/useTimeout/useTimeout.js +2 -2
- package/dist/cjs/hooks/useToggle/useToggle.js +2 -2
- package/dist/cjs/hooks/useUnmount/useUnmount.js +1 -1
- package/dist/cjs/hooks/useWebSocket/useWebSocket.js +2 -2
- package/dist/cjs/hooks/useWindowEvent/useWindowEvent.js +1 -1
- package/dist/cjs/hooks/useWindowScroll/useWindowScroll.js +2 -2
- package/dist/cjs/hooks/useWindowSize/useWindowSize.js +2 -2
- package/dist/cjs/hooks/useWizard/useWizard.js +2 -2
- package/dist/cjs/{index-DWXq2in2.js → index-96gzcInk.js} +2 -2
- package/dist/cjs/{index-DWXq2in2.js.map → index-96gzcInk.js.map} +1 -1
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/utils/helpers/debounce.js +1 -1
- package/dist/cjs/utils/helpers/getRetry.js +1 -1
- package/dist/cjs/utils/helpers/getRetry.js.map +1 -1
- package/dist/cjs/utils/helpers/index.js +1 -1
- package/dist/cjs/utils/helpers/isClient.js +1 -1
- package/dist/cjs/utils/helpers/isPermissionAllowed.js +1 -1
- package/dist/cjs/utils/helpers/throttle.js +1 -1
- package/dist/cjs/utils/helpers/time/getDate.js +1 -1
- package/dist/cjs/utils/types/index.js +1 -1
- package/dist/esm/{_rollupPluginBabelHelpers-CIuCCT6y.js → _rollupPluginBabelHelpers--yEi7JQy.js} +2 -2
- package/dist/esm/_rollupPluginBabelHelpers--yEi7JQy.js.map +1 -0
- package/dist/esm/hooks/index.js +2 -2
- package/dist/esm/hooks/useAsync/useAsync.js +3 -0
- package/dist/esm/hooks/useAsync/useAsync.js.map +1 -0
- package/dist/esm/hooks/useBattery/useBattery.js +2 -2
- package/dist/esm/hooks/useBoolean/useBoolean.js +2 -2
- package/dist/esm/hooks/useBreakpoints/constants/breakpoints.js +1 -1
- package/dist/esm/hooks/useBreakpoints/useBreakpoints.js +2 -2
- package/dist/esm/hooks/useBrowserLanguage/useBrowserLanguage.js +1 -1
- package/dist/esm/hooks/useClickOutside/useClickOutside.js +2 -2
- package/dist/esm/hooks/useClipboard/useClipboard.js +2 -2
- package/dist/esm/hooks/useCounter/useCounter.js +2 -2
- package/dist/esm/hooks/useCounter/useCounter.js.map +1 -1
- package/dist/esm/hooks/useDebounceCallback/useDebounceCallback.js +1 -1
- package/dist/esm/hooks/useDebounceValue/useDebounceValue.js +2 -2
- package/dist/esm/hooks/useDefault/useDefault.js +2 -2
- package/dist/esm/hooks/useDidUpdate/useDidUpdate.js +1 -1
- package/dist/esm/hooks/useDisclosure/useDisclosure.js +2 -2
- package/dist/esm/hooks/useDocumentEvent/useDocumentEvent.js +1 -1
- package/dist/esm/hooks/useDocumentTitle/useDocumentTitle.js +2 -2
- package/dist/esm/hooks/useDocumentVisibility/useDocumentVisibility.js +1 -1
- package/dist/esm/hooks/useEvent/useEvent.js +1 -1
- package/dist/esm/hooks/useEventListener/useEventListener.js +1 -1
- package/dist/esm/hooks/useEyeDropper/useEyeDropper.js +2 -2
- package/dist/esm/hooks/useFavicon/useFavicon.js +2 -2
- package/dist/esm/hooks/useField/useField.js +2 -2
- package/dist/esm/hooks/useFileDialog/useFileDialog.js +2 -2
- package/dist/esm/hooks/useFps/useFps.js +2 -2
- package/dist/esm/hooks/useFullscreen/useFullscreen.js +2 -2
- package/dist/esm/hooks/useGeolocation/useGeolocation.js +2 -2
- package/dist/esm/hooks/useHash/useHash.js +2 -2
- package/dist/esm/hooks/useHotkeys/useHotkeys.js +2 -2
- package/dist/esm/hooks/useHotkeys/useHotkeys.js.map +1 -1
- package/dist/esm/hooks/useHover/useHover.js +2 -2
- package/dist/esm/hooks/useIdle/useIdle.js +2 -2
- package/dist/esm/hooks/useImage/useImage.js +2 -2
- package/dist/esm/hooks/useInfiniteScroll/useInfiniteScroll.js +2 -2
- package/dist/esm/hooks/useIntersectionObserver/useIntersectionObserver.js +2 -2
- package/dist/esm/hooks/useInterval/useInterval.js +2 -2
- package/dist/esm/hooks/useIsFirstRender/useIsFirstRender.js +1 -1
- package/dist/esm/hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js +1 -1
- package/dist/esm/hooks/useKeyPress/useKeyPress.js +2 -2
- package/dist/esm/hooks/useKeyPressEvent/useKeyPressEvent.js +1 -1
- package/dist/esm/hooks/useKeyboard/useKeyboard.js +1 -1
- package/dist/esm/hooks/useKeysPressed/useKeysPressed.js +2 -2
- package/dist/esm/hooks/useKeysPressed/useKeysPressed.js.map +1 -1
- package/dist/esm/hooks/useList/useList.js +2 -2
- package/dist/esm/hooks/useLocalStorage/useLocalStorage.js +2 -2
- package/dist/esm/hooks/useLocalStorage/useLocalStorage.js.map +1 -1
- package/dist/esm/hooks/useLogger/useLogger.js +2 -2
- package/dist/esm/hooks/useLongPress/useLongPress.js +2 -2
- package/dist/esm/hooks/useMap/useMap.js +2 -2
- package/dist/esm/hooks/useMeasure/useMeasure.js +2 -2
- package/dist/esm/hooks/useMediaQuery/useMediaQuery.js +1 -1
- package/dist/esm/hooks/useMemory/useMemory.js +2 -2
- package/dist/esm/hooks/useMount/useMount.js +1 -1
- package/dist/esm/hooks/useMouse/useMouse.js +2 -2
- package/dist/esm/hooks/useMutation/useMutation.js +2 -2
- package/dist/esm/hooks/useMutation/useMutation.js.map +1 -1
- package/dist/esm/hooks/useMutationObserver.js +1 -1
- package/dist/esm/hooks/useNetwork/useNetwork.js +2 -2
- package/dist/esm/hooks/useOnline/useOnline.js +1 -1
- package/dist/esm/hooks/useOperatingSystem/useOperatingSystem.js +1 -1
- package/dist/esm/hooks/useOrientation/useOrientation.js +2 -2
- package/dist/esm/hooks/usePageLeave/usePageLeave.js +2 -2
- package/dist/esm/hooks/usePaint/helpers/Paint.js +2 -2
- package/dist/esm/hooks/usePaint/helpers/Pointer.js +2 -2
- package/dist/esm/hooks/usePaint/usePaint.js +2 -2
- package/dist/esm/hooks/usePermission/usePermission.js +2 -2
- package/dist/esm/hooks/usePreferredColorScheme/usePreferredColorScheme.js +1 -1
- package/dist/esm/hooks/usePreferredContrast/usePreferredContrast.js +1 -1
- package/dist/esm/hooks/usePreferredDark/usePreferredDark.js +1 -1
- package/dist/esm/hooks/usePreferredLanguages/usePreferredLanguages.js +1 -1
- package/dist/esm/hooks/usePreferredReducedMotion/usePreferredReducedMotion.js +1 -1
- package/dist/esm/hooks/usePrevious/usePrevious.js +1 -1
- package/dist/esm/hooks/useQuery/useQuery.js +2 -2
- package/dist/esm/hooks/useQuery/useQuery.js.map +1 -1
- package/dist/esm/hooks/useQueue/useQueue.js +2 -2
- package/dist/esm/hooks/useRenderCount/useRenderCount.js +1 -1
- package/dist/esm/hooks/useRenderInfo/useRenderInfo.js +1 -1
- package/dist/esm/hooks/useRerender/useRerender.js +2 -2
- package/dist/esm/hooks/useResizeObserver/useResizeObserver.js +2 -2
- package/dist/esm/hooks/useScript/useScript.js +2 -2
- package/dist/esm/hooks/useSessionStorage/useSessionStorage.js +2 -2
- package/dist/esm/hooks/useSessionStorage/useSessionStorage.js.map +1 -1
- package/dist/esm/hooks/useSet/useSet.js +2 -2
- package/dist/esm/hooks/useShare/useShare.js +2 -2
- package/dist/esm/hooks/useStep/useStep.js +2 -2
- package/dist/esm/hooks/useStopwatch/useStopwatch.js +2 -2
- package/dist/esm/hooks/useStopwatch/useStopwatch.js.map +1 -1
- package/dist/esm/hooks/useStorage/useStorage.js +2 -2
- package/dist/esm/hooks/useStorage/useStorage.js.map +1 -1
- package/dist/esm/hooks/useTextSelection/useTextSelection.js +2 -2
- package/dist/esm/hooks/useTime/useTime.js +2 -2
- package/dist/esm/hooks/useTimeout/useTimeout.js +2 -2
- package/dist/esm/hooks/useToggle/useToggle.js +2 -2
- package/dist/esm/hooks/useUnmount/useUnmount.js +1 -1
- package/dist/esm/hooks/useWebSocket/useWebSocket.js +2 -2
- package/dist/esm/hooks/useWindowEvent/useWindowEvent.js +1 -1
- package/dist/esm/hooks/useWindowScroll/useWindowScroll.js +2 -2
- package/dist/esm/hooks/useWindowSize/useWindowSize.js +2 -2
- package/dist/esm/hooks/useWizard/useWizard.js +2 -2
- package/dist/esm/{index-ngJHDSj5.js → index-5OKmysyE.js} +2 -2
- package/dist/esm/{index-ngJHDSj5.js.map → index-5OKmysyE.js.map} +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/utils/helpers/debounce.js +1 -1
- package/dist/esm/utils/helpers/getRetry.js +1 -1
- package/dist/esm/utils/helpers/getRetry.js.map +1 -1
- package/dist/esm/utils/helpers/index.js +1 -1
- package/dist/esm/utils/helpers/isClient.js +1 -1
- package/dist/esm/utils/helpers/isPermissionAllowed.js +1 -1
- package/dist/esm/utils/helpers/throttle.js +1 -1
- package/dist/esm/utils/helpers/time/getDate.js +1 -1
- package/dist/esm/utils/types/index.js +1 -1
- package/dist/index.d.ts +63 -13
- package/package.json +1 -1
- package/dist/cjs/_rollupPluginBabelHelpers-D4KMnNuQ.js.map +0 -1
- package/dist/esm/_rollupPluginBabelHelpers-CIuCCT6y.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCounter.js","sources":["../../../../src/hooks/useCounter/useCounter.ts"],"sourcesContent":["import type { Dispatch, SetStateAction } from 'react';\nimport { useState } from 'react';\n\n/** The use counter options */\nexport interface UseCounterOptions {\n /** The min of count value */\n min?: number;\n /** The max of count value */\n max?: number;\n}\n\n/** The use counter return type */\nexport interface UseCounterReturn {\n /** The current count value */\n
|
|
1
|
+
{"version":3,"file":"useCounter.js","sources":["../../../../src/hooks/useCounter/useCounter.ts"],"sourcesContent":["import type { Dispatch, SetStateAction } from 'react';\nimport { useState } from 'react';\n\n/** The use counter options */\nexport interface UseCounterOptions {\n /** The min of count value */\n min?: number;\n /** The max of count value */\n max?: number;\n}\n\n/** The use counter return type */\nexport interface UseCounterReturn {\n /** The current count value */\n value: number;\n /** Function to set a specific value to the counter */\n set: Dispatch<SetStateAction<number>>;\n /** Function to reset the counter to its initial value. */\n reset: () => void;\n /** Function to increment the counter */\n inc: (value?: number) => void;\n /** Function to decrement the counter */\n dec: (value?: number) => void;\n}\n\nexport type UseCounter = {\n (initialValue?: number, options?: UseCounterOptions): UseCounterReturn;\n\n (options: UseCounterOptions & { initialValue?: number }, initialValue?: never): UseCounterReturn;\n};\n\n/**\n * @name useCounter\n * @description - Hook that manages a counter with increment, decrement, reset, and set functionalities\n * @category Utilities\n *\n * @overload\n * @param {number} [initialValue=0] The initial number value\n * @param {number} [options.min=Number.NEGATIVE_INFINITY] The min of count value\n * @param {number} [options.max=Number.POSITIVE_INFINITY] The max of count value\n * @returns {UseCounterReturn} An object containing the current count and functions to interact with the counter\n\n * @overload\n * @param {number} [params.initialValue=0] The initial number value\n * @param {number} [params.min=Number.NEGATIVE_INFINITY] The min of count value\n * @param {number} [params.max=Number.POSITIVE_INFINITY] The max of count value\n * @returns {UseCounterReturn} An object containing the current count and functions to interact with the counter\n *\n * @example\n * const { count, dec, inc, reset, set } = useCounter(5);\n *\n * @example\n * const { count, dec, inc, reset, set } = useCounter({ initialValue: 5, min: 0, max: 10 });\n */\nexport const useCounter = ((...params: any[]) => {\n const initialValue =\n typeof params[0] === 'number'\n ? params[0]\n : (params[0] as UseCounterOptions & { initialValue?: number })?.initialValue;\n const { max = Number.POSITIVE_INFINITY, min = Number.NEGATIVE_INFINITY } =\n typeof params[0] === 'number'\n ? ((params[1] ?? {}) as UseCounterOptions)\n : ((params[0] ?? {}) as UseCounterOptions & { initialValue?: number });\n\n const [value, setValue] = useState(initialValue ?? 0);\n\n const inc = (value: number = 1) => {\n setValue((prevValue) => {\n if (typeof max === 'number' && prevValue === max) return prevValue;\n return Math.max(Math.min(max, prevValue + value), min);\n });\n };\n\n const dec = (value: number = 1) => {\n setValue((prevValue) => {\n if (typeof min === 'number' && prevValue === min) return prevValue;\n return Math.min(Math.max(min, prevValue - value), max);\n });\n };\n\n const reset = () => {\n const value = initialValue ?? 0;\n if (typeof max === 'number' && value > max) return setValue(max);\n if (typeof min === 'number' && value < min) return setValue(min);\n setValue(value);\n };\n\n const set = (value: SetStateAction<number>) => {\n setValue((prevValue) => {\n const updatedCount = Math.max(\n min,\n Math.min(max, typeof value === 'number' ? value : value(prevValue))\n );\n\n return updatedCount;\n });\n };\n\n return { value, set, inc, dec, reset };\n}) as UseCounter;\n"],"names":["useCounter","_params$","_params$2","_params$3","_len","arguments","length","params","Array","_key","initialValue","_ref","_ref$max","max","Number","POSITIVE_INFINITY","_ref$min","min","NEGATIVE_INFINITY","_useState","useState","_useState2","_slicedToArray","value","setValue","set","prevValue","Math","inc","undefined","dec","reset"],"mappings":";qGAsDaA,EAAc,WAAsB,IAAA,IAAAC,EAAAC,EAAAC,EAAAC,EAAAC,UAAAC,OAAlBC,EAAMC,IAAAA,MAAAJ,GAAAK,EAAA,EAAAA,EAAAL,EAAAK,IAANF,EAAME,GAAAJ,UAAAI,GACnC,IAAMC,EACiB,iBAAdH,EAAO,GACVA,EAAO,GACG,QADDN,EACRM,EAAO,UAAE,IAAAN,OAAA,EAAVA,EAA8DS,aACpEC,EACuB,iBAAdJ,EAAO,GACCL,QADcA,EACvBK,EAAO,UAAEL,IAAAA,EAAAA,EAAI,CAAA,UAAEC,EACfI,EAAO,UAAE,IAAAJ,EAAAA,EAAI,CAAqD,EAAAS,EAAAD,EAHlEE,IAAAA,OAAG,IAAAD,EAAGE,OAAOC,kBAAiBH,EAAAI,EAAAL,EAAEM,IAAAA,OAAG,IAAAD,EAAGF,OAAOI,kBAAiBF,EAKtEG,EAA0BC,EAASV,QAAAA,EAAgB,GAAEW,EAAAC,EAAAH,EAAA,GAA9CI,EAAKF,EAAA,GAAEG,EAAQH,EAAA,GAkCtB,MAAO,CAAEE,MAAAA,EAAOE,IAXJ,SAACF,GACXC,GAAS,SAACE,GAMR,OALqBC,KAAKd,IACxBI,EACAU,KAAKV,IAAIJ,EAAsB,iBAAVU,EAAqBA,EAAQA,EAAMG,IAI5D,KAGmBE,IAhCT,WAAuB,IAAtBL,EAAalB,UAAAC,OAAA,QAAAuB,IAAAxB,UAAA,GAAAA,UAAA,GAAG,EAC3BmB,GAAS,SAACE,GACR,MAAmB,iBAARb,GAAoBa,IAAcb,EAAYa,EAClDC,KAAKd,IAAIc,KAAKV,IAAIJ,EAAKa,EAAYH,GAAQN,EACpD,KA4BwBa,IAzBd,WAAuB,IAAtBP,EAAalB,UAAAC,OAAA,QAAAuB,IAAAxB,UAAA,GAAAA,UAAA,GAAG,EAC3BmB,GAAS,SAACE,GACR,MAAmB,iBAART,GAAoBS,IAAcT,EAAYS,EAClDC,KAAKV,IAAIU,KAAKd,IAAII,EAAKS,EAAYH,GAAQV,EACpD,KAqB6BkB,MAlBjB,WACZ,IAAMR,EAAQb,QAAAA,EAAgB,EAC9B,MAAmB,iBAARG,GAAoBU,EAAQV,EAAYW,EAASX,GACzC,iBAARI,GAAoBM,EAAQN,EAAYO,EAASP,QAC5DO,EAASD,IAeb"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
2
|
import{useMemo as r}from"react";import{debounce as t}from"../../utils/helpers/debounce.js";import"../../utils/helpers/isClient.js";var e=function(e,i){return r((function(){return t(e,i)}),[i])};export{e as useDebounceCallback};
|
|
3
3
|
//# sourceMappingURL=useDebounceCallback.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as r}from"../../_rollupPluginBabelHelpers
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
|
+
import{_ as r}from"../../_rollupPluginBabelHelpers--yEi7JQy.js";import{useRef as e,useState as o,useEffect as t}from"react";import{useDebounceCallback as l}from"../useDebounceCallback/useDebounceCallback.js";import"../../utils/helpers/debounce.js";import"../../utils/helpers/isClient.js";var u=function(u,s){var i=e(u),n=o(u),c=r(n,2),p=c[0],a=c[1],m=l(a,s);return t((function(){i.current!==u&&(m(u),i.current=u)}),[u]),p};export{u as useDebounceValue};
|
|
3
3
|
//# sourceMappingURL=useDebounceValue.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as r}from"../../_rollupPluginBabelHelpers
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
|
+
import{_ as r}from"../../_rollupPluginBabelHelpers--yEi7JQy.js";import{useState as l}from"react";var o=function(o,e){var t=l(o),a=r(t,2),n=a[0];return[null==n?e:n,a[1]]};export{o as useDefault};
|
|
3
3
|
//# sourceMappingURL=useDefault.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
2
|
import{useRef as r}from"react";import{useIsomorphicLayoutEffect as t}from"../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js";import"../../utils/helpers/isClient.js";var o=function(o,e){var i=r(!0);t((function(){if(!i.current){var r=o();return r&&"function"==typeof r?r:void 0}i.current=!1}),e)};export{o as useDidUpdate};
|
|
3
3
|
//# sourceMappingURL=useDidUpdate.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as n}from"../../_rollupPluginBabelHelpers
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
|
+
import{_ as n}from"../../_rollupPluginBabelHelpers--yEi7JQy.js";import{useState as r}from"react";var o=function(){var o=arguments.length>1?arguments[1]:void 0,l=r(arguments.length>0&&void 0!==arguments[0]&&arguments[0]),e=n(l,2),t=e[0],u=e[1],i=function(){return u((function(n){var r;return n||(null==o||null===(r=o.onOpen)||void 0===r||r.call(o),!0)}))},c=function(){return u((function(n){var r;return n?(null==o||null===(r=o.onClose)||void 0===r||r.call(o),!1):n}))};return{opened:t,open:i,close:c,toggle:function(){return t?c():i()}}};export{o as useDisclosure};
|
|
3
3
|
//# sourceMappingURL=useDisclosure.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
2
|
import{useEventListener as e}from"../useEventListener/useEventListener.js";import"react";import"../useEvent/useEvent.js";var t=function(t,r,n){return e(document,t,r,n)};export{t as useDocumentEvent};
|
|
3
3
|
//# sourceMappingURL=useDocumentEvent.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as t}from"../../_rollupPluginBabelHelpers
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
|
+
import{_ as t}from"../../_rollupPluginBabelHelpers--yEi7JQy.js";import{useRef as e,useState as o}from"react";import{useIsomorphicLayoutEffect as n}from"../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js";import{useMutationObserver as r}from"../useMutationObserver.js";import"../../utils/helpers/isClient.js";function i(i,u){var c=e(document.title),l=o(null!=i?i:document.title),m=t(l,2),s=m[0],f=m[1];r((function(){document&&document.title!==s&&f(document.title)}),{childList:!0},document.head.querySelector("title")),n((function(){if(null!=u&&u.restoreOnUnmount)return function(){document.title=c.current}}),[]);var p=function(t){var e=t.trim();e.length>0&&(document.title=e)};return n((function(){"string"==typeof i&&p(i)}),[i]),[s,p]}export{i as useDocumentTitle};
|
|
3
3
|
//# sourceMappingURL=useDocumentTitle.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
2
|
import{useSyncExternalStore as n}from"react";var t=function(){return document.visibilityState},e=function(){return"hidden"},i=function(n){return document.addEventListener("visibilitychange",n),function(){document.removeEventListener("visibilitychange",n)}},r=function(){return n(i,t,e)};export{r as useDocumentVisibility};
|
|
3
3
|
//# sourceMappingURL=useDocumentVisibility.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
2
|
import{useRef as r,useCallback as t}from"react";var n=function(n){var e=r(n);return e.current=n,t((function(){return e.current.apply(void 0,arguments)}),[])};export{n as useEvent};
|
|
3
3
|
//# sourceMappingURL=useEvent.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
2
|
import{useRef as n,useEffect as t}from"react";import{useEvent as e}from"../useEvent/useEvent.js";var r=function(){var r=(arguments.length<=1?void 0:arguments[1])instanceof Function||arguments.length<=0?void 0:arguments[0],o=r?arguments.length<=1?void 0:arguments[1]:arguments.length<=0?void 0:arguments[0],i=Array.isArray(o)?o:[o],u=r?arguments.length<=2?void 0:arguments[2]:arguments.length<=1?void 0:arguments[1],c=r?arguments.length<=3?void 0:arguments[3]:arguments.length<=2?void 0:arguments[2],f=n(null),v=e(u);if(t((function(){var n=function(n){return v(n)},t=r?function(n){return"function"==typeof n?n():n instanceof Element||n instanceof Window||n instanceof Document?n:n.current}(r):f.current;if(t)return i.forEach((function(e){return t.addEventListener(e,n,c)})),function(){i.forEach((function(e){return t.removeEventListener(e,n,c)}))}}),[r,o,c]),!r)return f};export{r as useEventListener};
|
|
3
3
|
//# sourceMappingURL=useEventListener.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as r,d as e,e as n}from"../../_rollupPluginBabelHelpers
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
|
+
import{_ as r,d as e,e as n}from"../../_rollupPluginBabelHelpers--yEi7JQy.js";import{useState as o}from"react";var t=function(){var t=window&&"EyeDropper"in window,p=o(arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0),a=r(p,2),i=a[0],u=a[1],s=function(){var r=e(n().mark((function r(e){var o,t;return n().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(window.EyeDropper){r.next=2;break}throw new Error("EyeDropper is not supported");case 2:return o=new window.EyeDropper,r.next=5,o.open(e);case 5:return t=r.sent,u(t.sRGBHex),r.abrupt("return",t);case 8:case"end":return r.stop()}}),r)})));return function(e){return r.apply(this,arguments)}}();return{supported:t,value:i,open:s}};export{t as useEyeDropper};
|
|
3
3
|
//# sourceMappingURL=useEyeDropper.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as e}from"../../_rollupPluginBabelHelpers
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
|
+
import{_ as e}from"../../_rollupPluginBabelHelpers--yEi7JQy.js";import{useState as o}from"react";import{useDidUpdate as t}from"../useDidUpdate/useDidUpdate.js";import{useMount as r}from"../useMount/useMount.js";import"../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js";import"../../utils/helpers/isClient.js";var n=function(n){var i,u=o(null!=n?n:null===(i=document.querySelector('link[rel*="icon"]'))||void 0===i?void 0:i.href),c=e(u,2),l=c[0],p=c[1],s=function(e){var o=document.querySelector('link[rel*="icon"]')||document.createElement("link");o.rel="icon",o.href=e,o.type="image/".concat(e.split(".").pop()),document.head.append(o)};return r((function(){n&&s(n)})),t((function(){n&&(p(n),s(n))}),[n]),{href:l,set:function(e){p(e),s(e)}}};export{n as useFavicon};
|
|
3
3
|
//# sourceMappingURL=useFavicon.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as e,d as r,e as n}from"../../_rollupPluginBabelHelpers
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
|
+
import{_ as e,d as r,e as n}from"../../_rollupPluginBabelHelpers--yEi7JQy.js";import{useRef as t,useState as u}from"react";import{useRerender as a}from"../useRerender/useRerender.js";var i=function(i){var l,c,o=null!==(l=null==i?void 0:i.initialValue)&&void 0!==l?l:"",v=t(),d=t(!1),f=a(),s=u(!1),p=e(s,2),m=p[0],h=p[1],g=u(null!==(c=null==i?void 0:i.initialTouched)&&void 0!==c&&c),x=e(g,2),k=x[0],b=x[1],y=u(void 0),L=e(y,2),V=L[0],w=L[1],B=function(){var e,r,n,t;return"radio"===(null===(e=v.current)||void 0===e?void 0:e.type)||"checkbox"===(null===(r=v.current)||void 0===r?void 0:r.type)?v.current.checked:null!==(n=null===(t=v.current)||void 0===t?void 0:t.value)&&void 0!==n?n:o},C=function(e){var r,n;return"radio"===(null===(r=v.current)||void 0===r?void 0:r.type)||"checkbox"===(null===(n=v.current)||void 0===n?void 0:n.type)?(v.current.checked=e,d.current?f.update():void 0):(v.current.value=e,d.current?f.update():void 0)},O=function(e){if(e.required&&!v.current.value)return w(e.required);if(e.minLength&&v.current.value.length<e.minLength.value)return w(e.minLength.message);if(e.maxLength&&v.current.value.length>e.maxLength.value)return w(e.maxLength.message);if(e.min&&Number(v.current.value)<e.min.value)return w(e.min.message);if(e.max&&Number(v.current.value)>e.max.value)return w(e.max.message);if(e.pattern&&!e.pattern.value.test(v.current.value))return w(e.pattern.message);if(e.validate){var r=e.validate(v.current.value);if("string"==typeof r)return w(r)}w(void 0)};return{register:function(e){return{ref:function(r){if(!v.current&&r){if(null!=i&&i.autoFocus&&r.focus(),v.current=r,"radio"===v.current.type)return void(v.current.defaultChecked=(null==i?void 0:i.initialValue)===r.value);if("checkbox"===v.current.type)return void(v.current.defaultChecked=!(null==i||!i.initialValue));v.current.defaultValue=String(o),e&&null!=i&&i.validateOnMount&&O(e)}},onChange:(u=r(n().mark((function r(){return n().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!d.current){r.next=2;break}return r.abrupt("return",f.update());case 2:if(v.current.value!==o&&h(!0),m&&v.current.value===o&&h(!1),!e||null==i||!i.validateOnChange){r.next=7;break}return r.next=7,O(e);case 7:e&&null!=i&&i.validateOnBlur&&w(void 0);case 8:case"end":return r.stop()}}),r)}))),function(){return u.apply(this,arguments)}),onBlur:(t=r(n().mark((function r(){return n().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!e||null==i||!i.validateOnBlur){r.next=3;break}return r.next=3,O(e);case 3:b(!0);case 4:case"end":return r.stop()}}),r)}))),function(){return t.apply(this,arguments)})};var t,u},dirty:m,touched:k,error:V,setError:w,clearError:function(){return w(void 0)},getValue:B,setValue:C,reset:function(){C(o),h(!1),b(!1),w(void 0)},watch:function(){return d.current=!0,B()},focus:function(){v.current.focus()}}};export{i as useField};
|
|
3
3
|
//# sourceMappingURL=useField.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as l}from"../../_rollupPluginBabelHelpers
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
|
+
import{_ as l}from"../../_rollupPluginBabelHelpers--yEi7JQy.js";import{useState as n,useRef as u,useEffect as e}from"react";var r=!0,t="*",i=!1,o=function(){var o="function"==typeof(arguments.length<=0?void 0:arguments[0])?arguments.length<=0?void 0:arguments[0]:void 0,c=o?arguments.length<=0?void 0:arguments[0]:arguments.length<=1?void 0:arguments[1],v=n(null),d=l(v,2),a=d[0],p=d[1],f=u(),m=u(o);m.current=o;var s=function(){var l;p(null),null===(l=m.current)||void 0===l||l.call(m,null),f.current&&(f.current.value="")};return e((function(){var l;return f.current=((l=document.createElement("input")).type="file",l.onchange=function(l){var n,u=l.target.files;p(u),null===(n=m.current)||void 0===n||n.call(m,u)},l),function(){var l;null===(l=f.current)||void 0===l||l.remove()}}),[null==c?void 0:c.multiple,null==c?void 0:c.accept,null==c?void 0:c.capture,null==c?void 0:c.reset]),{value:a,open:function(l){var n,u,e,o,v,d,a;if(f.current){f.current.multiple=null!==(n=null!==(u=null==l?void 0:l.multiple)&&void 0!==u?u:null==c?void 0:c.multiple)&&void 0!==n?n:r,f.current.accept=null!==(e=null!==(o=null==l?void 0:l.accept)&&void 0!==o?o:null==c?void 0:c.accept)&&void 0!==e?e:t;var p=null!==(v=null==l?void 0:l.capture)&&void 0!==v?v:null==c?void 0:c.capture;p&&(f.current.capture=p),(null!==(d=null!==(a=null==l?void 0:l.reset)&&void 0!==a?a:null==c?void 0:c.reset)&&void 0!==d?d:i)&&s(),f.current.click()}},reset:s}};export{o as useFileDialog};
|
|
3
3
|
//# sourceMappingURL=useFileDialog.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as r}from"../../_rollupPluginBabelHelpers
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
|
+
import{_ as r}from"../../_rollupPluginBabelHelpers--yEi7JQy.js";import{useState as n,useEffect as e}from"react";var a=function(){var a=n(0),o=r(a,2),t=o[0],i=o[1];return e((function(){var r,n=0,e=performance.now();return r=requestAnimationFrame((function a(){n+=1;var o=performance.now(),t=o-e;if(t>=1e3){var m=Math.round(1e3*n/t);i(m),n=0,e=o}r=requestAnimationFrame(a)})),function(){cancelAnimationFrame(r)}}),[]),t};export{a as useFps};
|
|
3
3
|
//# sourceMappingURL=useFps.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as n,b as e}from"../../_rollupPluginBabelHelpers
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
|
+
import{_ as n,b as e}from"../../_rollupPluginBabelHelpers--yEi7JQy.js";import{useRef as l,useState as i}from"react";import{s as o}from"../../index-5OKmysyE.js";import{useUnmount as t}from"../useUnmount/useUnmount.js";var r=function(){var r,u=void 0===(arguments.length<=1?void 0:arguments[1])||arguments.length<=0?void 0:arguments[0],a=u?arguments.length<=1?void 0:arguments[1]:arguments.length<=0?void 0:arguments[0],f=l(null),c=i(null!==(r=null==a?void 0:a.initialValue)&&void 0!==r&&r),s=n(c,2),d=s[0],v=s[1],m=function n(){if(o.isEnabled){var e,l;if(o.isFullscreen)null==a||null===(e=a.onEnter)||void 0===e||e.call(a);else o.off("change",n),null==a||null===(l=a.onExit)||void 0===l||l.call(a);v(o.isFullscreen)}},g=function(){var n=u?function(n){return"function"==typeof n?n():n instanceof Element?n:n.current}(u):f.current;if(n&&o.isEnabled)try{o.request(n),o.on("change",m)}catch(n){console.error(n)}},h=function(){o.isEnabled&&o.exit()};return t((function(){o.isEnabled&&o.off("change",m)})),e(e({},!u&&{ref:f}),{},{enter:g,exit:h,toggle:function(){if(d)return h();g()},value:d})};export{r as useFullscreen};
|
|
3
3
|
//# sourceMappingURL=useFullscreen.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as t,b as a}from"../../_rollupPluginBabelHelpers
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
|
+
import{_ as t,b as a}from"../../_rollupPluginBabelHelpers--yEi7JQy.js";import{useState as e,useEffect as i}from"react";var o=function(o){var l=e({loading:!0,error:null,timestamp:Date.now(),accuracy:0,latitude:Number.POSITIVE_INFINITY,longitude:Number.POSITIVE_INFINITY,altitude:null,altitudeAccuracy:null,heading:null,speed:null}),n=t(l,2),u=n[0],r=n[1];return i((function(){var t=function(t){var e=t.coords,i=t.timestamp;r(a(a({},u),{},{loading:!1,timestamp:i,latitude:e.latitude,longitude:e.longitude,altitude:e.altitude,accuracy:e.accuracy,altitudeAccuracy:e.altitudeAccuracy,heading:e.heading,speed:e.speed}))},e=function(t){r(a(a({},u),{},{loading:!1,error:t}))};navigator.geolocation.getCurrentPosition(t,e,o);var i=navigator.geolocation.watchPosition(t,e,o);return function(){navigator.geolocation.clearWatch(i)}}),[null==o?void 0:o.enableHighAccuracy,null==o?void 0:o.maximumAge,null==o?void 0:o.timeout]),u};export{o as useGeolocation};
|
|
3
3
|
//# sourceMappingURL=useGeolocation.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as n}from"../../_rollupPluginBabelHelpers
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
|
+
import{_ as n}from"../../_rollupPluginBabelHelpers--yEi7JQy.js";import{useState as o,useEffect as e}from"react";var r=function(){return decodeURIComponent(window.location.hash.replace("#",""))},t=function(){var t=o(window?r():""),i=n(t,2),a=i[0],c=i[1];return e((function(){var n=function(){return c(r())};return window.addEventListener("hashchange",n),function(){window.removeEventListener("hashchange",n)}})),[a,function(n){window.location.hash=n,c(n)}]};export{t as useHash};
|
|
3
3
|
//# sourceMappingURL=useHash.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as e,a as o}from"../../_rollupPluginBabelHelpers
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
|
+
import{_ as e,a as o}from"../../_rollupPluginBabelHelpers--yEi7JQy.js";import{useState as n}from"react";import{useDidUpdate as t}from"../useDidUpdate/useDidUpdate.js";import{useEventListener as r}from"../useEventListener/useEventListener.js";import"../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js";import"../../utils/helpers/isClient.js";import"../useEvent/useEvent.js";var i=function(e,o){return e.toLowerCase().split(/[+_-]/g).map((function(e){return e.trim()})).every((function(e){return o.find((function(o){return e===o.code.toLocaleLowerCase()||e===o.key.toLocaleLowerCase()||e===o.alias.toLocaleLowerCase()}))}))},u=function(u,l,a){var s,c,d,f,v=null===(s=null==a?void 0:a.enabled)||void 0===s||s,p=null===(c=null==a?void 0:a.preventDefault)||void 0===c||c,m=n([]),y=e(m,2)[1];t((function(){y([])}),[v]),r(null!==(d=null==a?void 0:a.target)&&void 0!==d?d:window,"keydown",(function(e){p&&e.preventDefault(),v&&y((function(n){var t,r,s,c;if(n.some((function(o){return o.code===e.code})))return n;var d=null!==(t=null!==(r=null==a||null===(s=a.aliasMap)||void 0===s?void 0:s[e.key])&&void 0!==r?r:null==a||null===(c=a.aliasMap)||void 0===c?void 0:c[e.key])&&void 0!==t?t:e.code,f=[].concat(o(n),[{key:e.key,code:e.code,alias:d}]);Array.isArray(u)?u.forEach((function(o){i(o,f)&&l(e)})):i(u,f)&&l(e);return f}))})),r(null!==(f=null==a?void 0:a.target)&&void 0!==f?f:window,"keyup",(function(e){v&&y((function(o){return o.filter((function(o){return o.code!==e.code}))}))}))};export{i as isHotkeyMatch,u as useHotkeys};
|
|
3
3
|
//# sourceMappingURL=useHotkeys.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useHotkeys.js","sources":["../../../../src/hooks/useHotkeys/useHotkeys.ts"],"sourcesContent":["import { useState } from 'react';\n\nimport { useDidUpdate } from '../useDidUpdate/useDidUpdate';\nimport type { UseEventListenerTarget } from '../useEventListener/useEventListener';\nimport { useEventListener } from '../useEventListener/useEventListener';\n\n/** The use hotkeys params */\nexport interface UseHotkeysOptions {\n /** The target to attach the event listeners to */\n target?: UseEventListenerTarget;\n
|
|
1
|
+
{"version":3,"file":"useHotkeys.js","sources":["../../../../src/hooks/useHotkeys/useHotkeys.ts"],"sourcesContent":["import { useState } from 'react';\n\nimport { useDidUpdate } from '../useDidUpdate/useDidUpdate';\nimport type { UseEventListenerTarget } from '../useEventListener/useEventListener';\nimport { useEventListener } from '../useEventListener/useEventListener';\n\n/** The use hotkeys params */\nexport interface UseHotkeysOptions {\n /** The target to attach the event listeners to */\n target?: UseEventListenerTarget;\n /** Enable or disable the event listeners */\n enabled?: boolean;\n /** Whether to prevent the default behavior of the event */\n preventDefault?: boolean;\n /** Alias map for hotkeys */\n aliasMap?: Record<string, string>;\n}\n\nexport const isHotkeyMatch = (hotkey: string, keys: UseHotkeysKey[]) =>\n hotkey\n .toLowerCase()\n .split(/[+_-]/g)\n .map((key) => key.trim())\n .every((key) =>\n keys.find(\n (updatedKey) =>\n key === updatedKey.code.toLocaleLowerCase() ||\n key === updatedKey.key.toLocaleLowerCase() ||\n key === updatedKey.alias.toLocaleLowerCase()\n )\n );\n\nexport type UseHotkeysHotkeys = string[] | string;\nexport type UseHotkeysKey = { key: string; code: string; alias: string };\n\n/**\n * @name useHotkeys\n * @description - Hook that listens for hotkeys\n * @category Sensors\n *\n * @param {UseHotkeysHotkeys} hotkeys The key or keys to listen for\n * @param {(event: KeyboardEvent) => void} callback The callback function to be called when the hotkey is pressed\n * @param {UseEventListenerTarget} [options.target=window] The target to attach the event listeners to\n * @param {boolean} [options.enabled=true] Enable or disable the event listeners\n * @param {boolean} [options.preventDefault=true] Whether to prevent the default behavior of the event\n * @param {Record<string, string>} [options.aliasMap] Alias map for hotkeys\n * @returns {useKeysPressedReturns} Array of strings with keys that were press\n *\n * @example\n * useHotkeys('control+a', () => console.log('hotkey pressed'));\n *\n * @example\n * useHotkeys('ControlLeft+KeyA', () => console.log('hotkey pressed'));\n */\nexport const useHotkeys = (\n hotkeys: UseHotkeysHotkeys,\n callback: (event: KeyboardEvent) => void,\n options?: UseHotkeysOptions\n) => {\n const enabled = options?.enabled ?? true;\n const preventDefault = options?.preventDefault ?? true;\n const [, setKeys] = useState<UseHotkeysKey[]>([]);\n\n const onKeyDown = (event: KeyboardEvent) => {\n if (preventDefault) event.preventDefault();\n\n if (!enabled) return;\n\n setKeys((prevKeys) => {\n if (prevKeys.some(({ code }) => code === event.code)) return prevKeys;\n const alias = options?.aliasMap?.[event.key] ?? options?.aliasMap?.[event.key] ?? event.code;\n const updatedKeys = [...prevKeys, { key: event.key, code: event.code, alias }];\n\n if (Array.isArray(hotkeys)) {\n hotkeys.forEach((hotkey) => {\n const isMatch = isHotkeyMatch(hotkey, updatedKeys);\n if (isMatch) callback(event);\n });\n } else {\n const isMatch = isHotkeyMatch(hotkeys, updatedKeys);\n if (isMatch) callback(event);\n }\n\n return updatedKeys;\n });\n };\n\n const onKeyUp = (event: KeyboardEvent) => {\n if (!enabled) return;\n setKeys((prevKeys) => prevKeys.filter(({ code }) => code !== event.code));\n };\n\n useDidUpdate(() => {\n setKeys([]);\n }, [enabled]);\n\n useEventListener(options?.target ?? window, 'keydown', onKeyDown);\n useEventListener(options?.target ?? window, 'keyup', onKeyUp);\n};\n"],"names":["isHotkeyMatch","hotkey","keys","toLowerCase","split","map","key","trim","every","find","updatedKey","code","toLocaleLowerCase","alias","useHotkeys","hotkeys","callback","options","_options$enabled","_options$preventDefau","_options$target","_options$target2","enabled","preventDefault","_useState","useState","setKeys","_slicedToArray","useDidUpdate","useEventListener","target","window","event","prevKeys","_ref2","_options$aliasMap$eve","_options$aliasMap","_options$aliasMap2","some","_ref","aliasMap","updatedKeys","concat","_toConsumableArray","Array","isArray","forEach","filter","_ref3"],"mappings":";4XAkBO,IAAMA,EAAgB,SAACC,EAAgBC,GAAqB,OACjED,EACGE,cACAC,MAAM,UACNC,KAAI,SAACC,GAAG,OAAKA,EAAIC,MAAM,IACvBC,OAAM,SAACF,GAAG,OACTJ,EAAKO,MACH,SAACC,GAAU,OACTJ,IAAQI,EAAWC,KAAKC,qBACxBN,IAAQI,EAAWJ,IAAIM,qBACvBN,IAAQI,EAAWG,MAAMD,mBAAmB,GAC/C,GACF,EAwBQE,EAAa,SACxBC,EACAC,EACAC,GACG,IAAAC,EAAAC,EAAAC,EAAAC,EACGC,EAA0BJ,QAAnBA,EAAGD,aAAO,EAAPA,EAASK,eAAOJ,IAAAA,GAAAA,EAC1BK,EAAwCJ,QAA1BA,EAAGF,aAAO,EAAPA,EAASM,sBAAcJ,IAAAA,GAAAA,EAC9CK,EAAoBC,EAA0B,IAArCC,EAAwCC,EAAAH,EAAA,GAAjC,GA+BhBI,GAAa,WACXF,EAAQ,GACV,GAAG,CAACJ,IAEJO,UAAgBT,EAACH,aAAO,EAAPA,EAASa,cAAM,IAAAV,EAAAA,EAAIW,OAAQ,WAjC1B,SAACC,GACbT,GAAgBS,EAAMT,iBAErBD,GAELI,GAAQ,SAACO,GAAa,IAAAC,EAAAC,EAAAC,EAAAC,EACpB,GAAIJ,EAASK,MAAK,SAAAC,GAAO,OAAAA,EAAJ5B,OAAoBqB,EAAMrB,QAAO,OAAOsB,EAC7D,IAAMpB,EAAwE,QAAnEqB,EAAiC,QAAjCC,EAAGlB,SAAiBmB,QAAVA,EAAPnB,EAASuB,gBAATJ,IAAiBA,OAAjBA,EAAAA,EAAoBJ,EAAM1B,YAAI,IAAA6B,EAAAA,EAAIlB,SAAiB,QAAVoB,EAAPpB,EAASuB,gBAAQ,IAAAH,OAAA,EAAjBA,EAAoBL,EAAM1B,YAAI,IAAA4B,EAAAA,EAAIF,EAAMrB,KAClF8B,EAAWC,GAAAA,OAAAC,EAAOV,GAAU,CAAA,CAAE3B,IAAK0B,EAAM1B,IAAKK,KAAMqB,EAAMrB,KAAME,MAAAA,KAElE+B,MAAMC,QAAQ9B,GAChBA,EAAQ+B,SAAQ,SAAC7C,GACCD,EAAcC,EAAQwC,IACzBzB,EAASgB,EACxB,IAEgBhC,EAAce,EAAS0B,IAC1BzB,EAASgB,GAGxB,OAAOS,CACT,OAaFZ,UAAgBR,EAACJ,aAAO,EAAPA,EAASa,cAAM,IAAAT,EAAAA,EAAIU,OAAQ,SAV5B,SAACC,GACVV,GACLI,GAAQ,SAACO,GAAQ,OAAKA,EAASc,QAAO,SAAAC,GAAO,OAAAA,EAAJrC,OAAoBqB,EAAMrB,aASvE"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{c as n,_ as e}from"../../_rollupPluginBabelHelpers
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
|
+
import{c as n,_ as e}from"../../_rollupPluginBabelHelpers--yEi7JQy.js";import{useState as t,useRef as o}from"react";import{useEventListener as l}from"../useEventListener/useEventListener.js";import"../useEvent/useEvent.js";var i=function(){var i=(arguments.length<=0?void 0:arguments[0])instanceof Function||!("current"in(arguments.length<=0?void 0:arguments[0])||(arguments.length<=0?void 0:arguments[0])instanceof Element)||arguments.length<=0?void 0:arguments[0],r=i?"object"===n(arguments.length<=1?void 0:arguments[1])?arguments.length<=1?void 0:arguments[1]:{onEntry:arguments.length<=1?void 0:arguments[1]}:"object"===n(arguments.length<=0?void 0:arguments[0])?arguments.length<=0?void 0:arguments[0]:{onEntry:arguments.length<=0?void 0:arguments[0]},v=t(!1),u=e(v,2),s=u[0],a=u[1],c=o();return l(null!=i?i:c,"mouseenter",(function(){var n;null==r||null===(n=r.onEntry)||void 0===n||n.call(r),a(!0)})),l(null!=i?i:c,"mouseleave",(function(){var n;null==r||null===(n=r.onLeave)||void 0===n||n.call(r),a(!1)})),i?s:[c,s]};export{i as useHover};
|
|
3
3
|
//# sourceMappingURL=useHover.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as e}from"../../_rollupPluginBabelHelpers
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
|
+
import{_ as e}from"../../_rollupPluginBabelHelpers--yEi7JQy.js";import{useState as t,useEffect as n}from"react";import"../../utils/helpers/isClient.js";import{throttle as i}from"../../utils/helpers/throttle.js";var o=["mousemove","mousedown","keydown","touchstart","wheel","resize"],r=function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:6e4,u=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=u.initialValue,l=void 0!==s&&s,a=u.events,c=void 0===a?o:a,d=t(l),m=e(d,2),v=m[0],f=m[1],h=t(Date.now()),p=e(h,2),w=p[0],E=p[1];return n((function(){var e,t=function(){return f(!0)},n=i((function(){f(!1),E(Date.now()),clearTimeout(e),e=setTimeout(t,r)}),500),o=function(){document.hidden||n()};return e=setTimeout(t,r),c.forEach((function(e){return window.addEventListener(e,n)})),document.addEventListener("visibilitychange",o),function(){c.forEach((function(e){return window.addEventListener(e,n)})),document.removeEventListener("visibilitychange",o),clearTimeout(e)}}),[r,c]),{idle:v,lastActive:w}};export{r as useIdle};
|
|
3
3
|
//# sourceMappingURL=useIdle.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{b as r,a as e,d as s,e as t}from"../../_rollupPluginBabelHelpers
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
|
+
import{b as r,a as e,d as s,e as t}from"../../_rollupPluginBabelHelpers--yEi7JQy.js";import{useQuery as o}from"../useQuery/useQuery.js";import"react";import"../../utils/helpers/getRetry.js";import"../../utils/helpers/isClient.js";import"../useDidUpdate/useDidUpdate.js";import"../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js";import"../useMount/useMount.js";var n=function(){var r=s(t().mark((function r(e){var s,o=arguments;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return s=o.length>1&&void 0!==o[1]?o[1]:{},r.abrupt("return",new Promise((function(r,t){var o=new Image,n=s.srcset,i=s.sizes,u=s.class,a=s.loading,c=s.crossorigin,p=s.referrerPolicy;o.src=e,n&&(o.srcset=n),i&&(o.sizes=i),u&&(o.className=u),a&&(o.loading=a),c&&(o.crossOrigin=c),p&&(o.referrerPolicy=p),o.onload=function(){return r(o)},o.onerror=t})));case 2:case"end":return r.stop()}}),r)})));return function(e){return r.apply(this,arguments)}}(),i=function(s,t){var i,u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return o((function(){return n(s,t)}),r({keys:[s].concat(e(null!==(i=u.keys)&&void 0!==i?i:[]))},u))};export{i as useImage};
|
|
3
3
|
//# sourceMappingURL=useImage.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as r,d as e,e as t}from"../../_rollupPluginBabelHelpers
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
|
+
import{_ as r,d as e,e as t}from"../../_rollupPluginBabelHelpers--yEi7JQy.js";import{useState as n,useRef as o,useEffect as i}from"react";import{useEvent as u}from"../useEvent/useEvent.js";import{useRerender as c}from"../useRerender/useRerender.js";var a=function(){for(var a,s,l,f,v=c(),d=arguments.length,p=new Array(d),m=0;m<d;m++)p[m]=arguments[m];var h=p[1]instanceof Function?p[0]:void 0,g=p[1]instanceof Function?p[1]:p[0],b=null!==(a=null===(s=p[2])||void 0===s?void 0:s.direction)&&void 0!==a?a:"bottom",x=null!==(l=null===(f=p[2])||void 0===f?void 0:f.distance)&&void 0!==l?l:10,E=n(!1),L=r(E,2),j=L[0],k=L[1],w=o(),y=o(g);y.current=g;var H=u(function(){var r=e(t().mark((function r(e){var n,o,i,u,c,a,s;return t().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!j){r.next=2;break}return r.abrupt("return");case 2:if(n=e.target,o=n.clientHeight,i=n.scrollHeight,u=n.scrollTop,c=n.clientWidth,a=n.scrollWidth,s=n.scrollLeft,!({bottom:i-(u+o),top:u,right:a-(s+c),left:s}[b]<=x)){r.next=11;break}return k(!0),r.next=10,y.current(e);case 10:k(!1);case 11:case"end":return r.stop()}}),r)})));return function(e){return r.apply(this,arguments)}}());return i((function(){var r=h?function(r){return"function"==typeof r?r():r instanceof Element?r:r.current}(h):w.current;if(r)return r.addEventListener("scroll",H),function(){r.removeEventListener("scroll",H)}}),[w.current,h,b,x]),h?j:{ref:function(r){w.current||(w.current=r,v.update())},isLoading:j}};export{a as useInfiniteScroll};
|
|
3
3
|
//# sourceMappingURL=useInfiniteScroll.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{c as n,_ as e,b as r}from"../../_rollupPluginBabelHelpers
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
|
+
import{c as n,_ as e,b as r}from"../../_rollupPluginBabelHelpers--yEi7JQy.js";import{useState as t,useRef as o,useEffect as i}from"react";import{useRerender as u}from"../useRerender/useRerender.js";var l=function(){var l,c=u(),d="object"!==n(arguments.length<=0?void 0:arguments[0])||"current"in(arguments.length<=0?void 0:arguments[0])?arguments.length<=0?void 0:arguments[0]:void 0,v=d?arguments.length<=1?void 0:arguments[1]:arguments.length<=0?void 0:arguments[0],s=null===(l=null==v?void 0:v.enabled)||void 0===l||l,a=t(),f=e(a,2),g=f[0],m=f[1],h=o(),p=o();return p.current=null==v?void 0:v.onChange,i((function(){if(s&&h.current){var n=d?function(n){return"function"==typeof n?n():n instanceof Element?n:n.current}(d):h.current;if(n){var t,o=new IntersectionObserver((function(n){var r,t=e(n,1)[0];m(t),null===(r=p.current)||void 0===r||r.call(p,t)}),r(r({},v),{},{root:(t=null==v?void 0:v.root,t?t instanceof Element||t instanceof Document?t:t.current:document)}));return o.observe(n),function(){o.disconnect()}}}}),[h.current,d,null==v?void 0:v.rootMargin,null==v?void 0:v.threshold,null==v?void 0:v.root,s]),d?{entry:g,inView:!(null==g||!g.isIntersecting)}:{ref:function(n){h.current||(h.current=n,c.update())},entry:g,inView:!(null==g||!g.isIntersecting)}};export{l as useIntersectionObserver};
|
|
3
3
|
//# sourceMappingURL=useIntersectionObserver.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{c as r,_ as e}from"../../_rollupPluginBabelHelpers
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
|
+
import{c as r,_ as e}from"../../_rollupPluginBabelHelpers--yEi7JQy.js";import{useState as n,useRef as t,useEffect as l}from"react";import{useEvent as u}from"../useEvent/useEvent.js";var a=function(){for(var a,o,c=arguments.length,i=new Array(c),v=0;v<c;v++)i[v]=arguments[v];var s=i[0],f=null!==(a="number"==typeof i[1]?i[1]:i[1].interval)&&void 0!==a?a:1e3,m="object"===r(i[1])?i[1]:i[2],p=null===(o=null==m?void 0:m.enabled)||void 0===o||o,I=n(null==p||p),b=e(I,2),d=b[0],j=b[1],g=t(),y=u(s);l((function(){if(p)return g.current=setInterval(y,f),function(){clearInterval(g.current)}}),[p,f]);return{isActive:d,pause:function(){j(!1),clearInterval(g.current)},resume:function(){f<=0||(j(!0),clearInterval(g.current),g.current=setInterval(y,f))}}};export{a as useInterval};
|
|
3
3
|
//# sourceMappingURL=useInterval.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
2
|
import{useRef as r}from"react";var t=function(){var t=r(!0);return!0===t.current?(t.current=!1,!0):t.current};export{t as useIsFirstRender};
|
|
3
3
|
//# sourceMappingURL=useIsFirstRender.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
2
|
import{useLayoutEffect as r,useEffect as t}from"react";import{isClient as e}from"../../utils/helpers/isClient.js";var i=e?r:t;export{i as useIsomorphicLayoutEffect};
|
|
3
3
|
//# sourceMappingURL=useIsomorphicLayoutEffect.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as e}from"../../_rollupPluginBabelHelpers
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
|
+
import{_ as e}from"../../_rollupPluginBabelHelpers--yEi7JQy.js";import{useState as r}from"react";import{useEventListener as n}from"../useEventListener/useEventListener.js";import"../useEvent/useEvent.js";var i=function(i,t){var o,u,l=r(!1),s=e(l,2),a=s[0],v=s[1];return n(null!==(o=null==t?void 0:t.target)&&void 0!==o?o:window,"keydown",(function(e){(Array.isArray(i)?i.includes(e.key):e.key===i)&&v(!0)})),n(null!==(u=null==t?void 0:t.target)&&void 0!==u?u:window,"keyup",(function(e){(Array.isArray(i)?i.includes(e.key):e.key===i)&&v(!1)})),a};export{i as useKeyPress};
|
|
3
3
|
//# sourceMappingURL=useKeyPress.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
2
|
import{useEventListener as n}from"../useEventListener/useEventListener.js";import"react";import"../useEvent/useEvent.js";var e=function(){var e=Array.isArray(arguments.length<=0?void 0:arguments[0])?arguments.length<=0?void 0:arguments[0]:[arguments.length<=0?void 0:arguments[0]],t=(arguments.length<=1?void 0:arguments[1])instanceof Function?null:arguments.length<=1?void 0:arguments[1],i=t?arguments.length<=2?void 0:arguments[2]:arguments.length<=1?void 0:arguments[1];n(null!=t?t:window,"keydown",(function(n){e.includes(n.key)&&i(n)}),t?arguments.length<=3?void 0:arguments[3]:arguments.length<=2?void 0:arguments[2])};export{e as useKeyPressEvent};
|
|
3
3
|
//# sourceMappingURL=useKeyPressEvent.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
2
|
import{useEventListener as n}from"../useEventListener/useEventListener.js";import"react";import"../useEvent/useEvent.js";var e=function(e){var o,l;n(null!==(o=null==e?void 0:e.target)&&void 0!==o?o:window,"keydown",(function(n){var o;return null==e||null===(o=e.onKeyDown)||void 0===o?void 0:o.call(e,n)})),n(null!==(l=null==e?void 0:e.target)&&void 0!==l?l:window,"keyup",(function(n){var o;return null==e||null===(o=e.onKeyUp)||void 0===o?void 0:o.call(e,n)}))};export{e as useKeyboard};
|
|
3
3
|
//# sourceMappingURL=useKeyboard.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as e,a as o}from"../../_rollupPluginBabelHelpers
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
|
+
import{_ as e,a as o}from"../../_rollupPluginBabelHelpers--yEi7JQy.js";import{useState as t}from"react";import{useDidUpdate as n}from"../useDidUpdate/useDidUpdate.js";import{useEventListener as r}from"../useEventListener/useEventListener.js";import"../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js";import"../../utils/helpers/isClient.js";import"../useEvent/useEvent.js";var i=function(i){var u,s,l,c=null===(u=null==i?void 0:i.enabled)||void 0===u||u,d=t([]),f=e(d,2),p=f[0],a=f[1];return n((function(){a([])}),[c]),r(null!==(s=null==i?void 0:i.target)&&void 0!==s?s:window,"keydown",(function(e){c&&a((function(t){return t.some((function(o){return o.code===e.code}))?t:[].concat(o(t),[{key:e.key,code:e.code}])}))})),r(null!==(l=null==i?void 0:i.target)&&void 0!==l?l:window,"keyup",(function(e){c&&a((function(o){return o.filter((function(o){return o.code!==e.code}))}))})),p};export{i as useKeysPressed};
|
|
3
3
|
//# sourceMappingURL=useKeysPressed.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useKeysPressed.js","sources":["../../../../src/hooks/useKeysPressed/useKeysPressed.ts"],"sourcesContent":["import { useState } from 'react';\n\nimport { useDidUpdate } from '../useDidUpdate/useDidUpdate';\nimport type { UseEventListenerTarget } from '../useEventListener/useEventListener';\nimport { useEventListener } from '../useEventListener/useEventListener';\n\n/** The use keys pressed params */\ninterface UseKeysPressedParams {\n /** The target to attach the event listeners to */\n target?: UseEventListenerTarget;\n
|
|
1
|
+
{"version":3,"file":"useKeysPressed.js","sources":["../../../../src/hooks/useKeysPressed/useKeysPressed.ts"],"sourcesContent":["import { useState } from 'react';\n\nimport { useDidUpdate } from '../useDidUpdate/useDidUpdate';\nimport type { UseEventListenerTarget } from '../useEventListener/useEventListener';\nimport { useEventListener } from '../useEventListener/useEventListener';\n\n/** The use keys pressed params */\ninterface UseKeysPressedParams {\n /** The target to attach the event listeners to */\n target?: UseEventListenerTarget;\n /** Enable or disable the event listeners */\n enabled?: boolean;\n}\n\n/**\n * @name useKeysPressed\n * @description - Hook for get keys that were pressed\n * @category Sensors\n *\n * @param {UseEventListenerTarget} [params.target=window] The target to attach the event listeners to\n * @param {boolean} [params.enabled=bollean] Enable or disable the event listeners\n * @returns {useKeysPressedReturns} Array of strings with keys that were press\n *\n * @example\n * const pressedKeys = useKeysPressed();\n */\nexport const useKeysPressed = (params?: UseKeysPressedParams) => {\n const enabled = params?.enabled ?? true;\n const [keys, setKeys] = useState<{ key: string; code: string }[]>([]);\n\n const onKeyDown = (event: KeyboardEvent) => {\n if (!enabled) return;\n setKeys((prevKeys) => {\n if (prevKeys.some(({ code }) => code === event.code)) return prevKeys;\n return [...prevKeys, { key: event.key, code: event.code }];\n });\n };\n\n const onKeyUp = (event: KeyboardEvent) => {\n if (!enabled) return;\n setKeys((prevKeys) => prevKeys.filter(({ code }) => code !== event.code));\n };\n\n useDidUpdate(() => {\n setKeys([]);\n }, [enabled]);\n\n useEventListener(params?.target ?? window, 'keydown', onKeyDown);\n useEventListener(params?.target ?? window, 'keyup', onKeyUp);\n\n return keys;\n};\n"],"names":["useKeysPressed","params","_params$enabled","_params$target","_params$target2","enabled","_useState","useState","_useState2","_slicedToArray","keys","setKeys","useDidUpdate","useEventListener","target","window","event","prevKeys","some","_ref","code","concat","_toConsumableArray","key","filter","_ref2"],"mappings":";gYA0BaA,EAAiB,SAACC,GAAkC,IAAAC,EAAAC,EAAAC,EACzDC,EAAyBH,QAAlBA,EAAGD,aAAM,EAANA,EAAQI,eAAOH,IAAAA,GAAAA,EAC/BI,EAAwBC,EAA0C,IAAGC,EAAAC,EAAAH,EAAA,GAA9DI,EAAIF,EAAA,GAAEG,EAAOH,EAAA,GAsBpB,OAPAI,GAAa,WACXD,EAAQ,GACV,GAAG,CAACN,IAEJQ,UAAgBV,EAACF,aAAM,EAANA,EAAQa,cAAM,IAAAX,EAAAA,EAAIY,OAAQ,WAjBzB,SAACC,GACZX,GACLM,GAAQ,SAACM,GACP,OAAIA,EAASC,MAAK,SAAAC,GAAO,OAAAA,EAAJC,OAAoBJ,EAAMI,QAAcH,EAC7D,GAAAI,OAAAC,EAAWL,GAAU,CAAA,CAAEM,IAAKP,EAAMO,IAAKH,KAAMJ,EAAMI,OACrD,OAaFP,UAAgBT,EAACH,aAAM,EAANA,EAAQa,cAAM,IAAAV,EAAAA,EAAIW,OAAQ,SAV3B,SAACC,GACVX,GACLM,GAAQ,SAACM,GAAQ,OAAKA,EAASO,QAAO,SAAAC,GAAO,OAAAA,EAAJL,OAAoBJ,EAAMI,cAU9DV,CACT"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as n,a as t}from"../../_rollupPluginBabelHelpers
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
|
+
import{_ as n,a as t}from"../../_rollupPluginBabelHelpers--yEi7JQy.js";import{useState as r}from"react";var e=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],u=r(e),c=n(u,2),o=c[0],i=c[1];return{value:o,set:i,push:function(n){return i((function(r){return[].concat(t(r),[n])}))},removeAt:function(n){return i((function(r){return[].concat(t(r.slice(0,n)),t(r.slice(n+1)))}))},insertAt:function(n,r){return i((function(e){return[].concat(t(e.slice(0,n)),[r],t(e.slice(n)))}))},updateAt:function(n,t){return i((function(r){return r.map((function(r,e){return e===n?t:r}))}))},clear:function(){return i([])},reset:function(){return i(e)}}};export{e as useList};
|
|
3
3
|
//# sourceMappingURL=useList.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{b as o}from"../../_rollupPluginBabelHelpers
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
|
+
import{b as o}from"../../_rollupPluginBabelHelpers--yEi7JQy.js";import{useStorage as r}from"../useStorage/useStorage.js";import"react";import"../../utils/helpers/isClient.js";import"../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js";var e=function(e,t,i){return r(e,o({initialValue:t,storage:window.localStorage},i))};export{e as useLocalStorage};
|
|
3
3
|
//# sourceMappingURL=useLocalStorage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocalStorage.js","sources":["../../../../src/hooks/useLocalStorage/useLocalStorage.ts"],"sourcesContent":["import type { UseStorageInitialValue, UseStorageOptions } from '../useStorage/useStorage';\nimport { useStorage } from '../useStorage/useStorage';\n\n/**\n * @name useLocalStorage\n * @description - Hook that manages local storage value\n * @category Browser\n *\n * @template Value The type of the value\n * @param {string} key The key of the storage\n * @param {UseStorageInitialValue<Value>} [initialValue] The initial value of the storage\n * @param {UseStorageOptions<Value>} [options] The options of the storage\n *\n * @example\n * const
|
|
1
|
+
{"version":3,"file":"useLocalStorage.js","sources":["../../../../src/hooks/useLocalStorage/useLocalStorage.ts"],"sourcesContent":["import type { UseStorageInitialValue, UseStorageOptions } from '../useStorage/useStorage';\nimport { useStorage } from '../useStorage/useStorage';\n\n/**\n * @name useLocalStorage\n * @description - Hook that manages local storage value\n * @category Browser\n *\n * @template Value The type of the value\n * @param {string} key The key of the storage\n * @param {UseStorageInitialValue<Value>} [initialValue] The initial value of the storage\n * @param {UseStorageOptions<Value>} [options] The options of the storage\n *\n * @example\n * const { value, set, remove } = useLocalStorage('key', 'value');\n */\nexport const useLocalStorage = <Value>(\n key: string,\n initialValue?: UseStorageInitialValue<Value>,\n options?: UseStorageOptions<Value>\n) => useStorage(key, { initialValue, storage: window.localStorage, ...options });\n"],"names":["useLocalStorage","key","initialValue","options","useStorage","_objectSpread","storage","window","localStorage"],"mappings":";iPAgBO,IAAMA,EAAkB,SAC7BC,EACAC,EACAC,GAAkC,OAC/BC,EAAWH,EAAGI,EAAA,CAAIH,aAAAA,EAAcI,QAASC,OAAOC,cAAiBL,GAAU"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{a as o}from"../../_rollupPluginBabelHelpers
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
|
+
import{a as o}from"../../_rollupPluginBabelHelpers--yEi7JQy.js";import{useEffect as t}from"react";import{useDidUpdate as e}from"../useDidUpdate/useDidUpdate.js";import"../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js";import"../../utils/helpers/isClient.js";var n=function(n,c){t((function(){var t;return(t=console).log.apply(t,["".concat(n," mounted")].concat(o(c))),function(){return console.log("".concat(n," unmounted"))}}),[]),e((function(){var t;(t=console).log.apply(t,["".concat(n," updated")].concat(o(c)))}),c)};export{n as useLogger};
|
|
3
3
|
//# sourceMappingURL=useLogger.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as n}from"../../_rollupPluginBabelHelpers
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
|
+
import{_ as n}from"../../_rollupPluginBabelHelpers--yEi7JQy.js";import{useState as l,useRef as e}from"react";import{useEventListener as t}from"../useEventListener/useEventListener.js";import"../useEvent/useEvent.js";var o=function(){var o=(arguments.length<=0?void 0:arguments[0])instanceof Function||!("current"in(arguments.length<=0?void 0:arguments[0]))||arguments.length<=0?void 0:arguments[0],r=o?arguments.length<=1?void 0:arguments[1]:arguments.length<=0?void 0:arguments[0],u=o?arguments.length<=2?void 0:arguments[2]:arguments.length<=1?void 0:arguments[1],i=l(!1),c=n(i,2),v=c[0],s=c[1],a=e(),d=e(),h=e(!1),m=function(n){var l,e;null==u||null===(l=u.onStart)||void 0===l||l.call(u,n),h.current=!0,d.current=setTimeout((function(){r(n),s(!0)}),null!==(e=null==u?void 0:u.threshold)&&void 0!==e?e:400)},f=function(n){var l;if(v)null==u||null===(l=u.onFinish)||void 0===l||l.call(u,n);else if(h.current){var e;null==u||null===(e=u.onCancel)||void 0===e||e.call(u,n)}s(!1),h.current=!1,d.current&&clearTimeout(d.current)};return t(null!=o?o:a,"mousedown",m),t(null!=o?o:a,"touchstart",m),t(null!=o?o:a,"mouseup",f),t(null!=o?o:a,"touchend",f),o?v:[a,v]};export{o as useLongPress};
|
|
3
3
|
//# sourceMappingURL=useLongPress.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as e}from"../../_rollupPluginBabelHelpers
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
|
+
import{_ as e}from"../../_rollupPluginBabelHelpers--yEi7JQy.js";import{useState as r}from"react";var n=function(n){var t=r(new Map(n)),u=e(t,2),a=u[0],o=u[1];return{value:a,size:a.size,set:function(e,r){return o((function(n){return new Map(n).set(e,r)}))},has:function(e){return a.has(e)},remove:function(e){return o((function(r){if(!r.has(e))return r;var n=new Map(r);return n.delete(e),n}))},clear:function(){return o(new Map)},reset:function(){return o(new Map(n))}}};export{n as useMap};
|
|
3
3
|
//# sourceMappingURL=useMap.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as e,b as t}from"../../_rollupPluginBabelHelpers
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
|
+
import{_ as e,b as t}from"../../_rollupPluginBabelHelpers--yEi7JQy.js";import{useRef as r,useState as o}from"react";import{useResizeObserver as i}from"../useResizeObserver/useResizeObserver.js";import"../useRerender/useRerender.js";var s=function(s){var h=r(),n=o({x:0,y:0,width:0,height:0,top:0,left:0,bottom:0,right:0}),f=e(n,2),l=f[0],m=f[1];return i(null!=s?s:h,{onChange:function(t){var r=e(t,1)[0];if(r){var o=r.contentRect,i=o.x,s=o.y,h=o.width,n=o.height,f=o.top,l=o.left,p=o.bottom,u=o.right;m({x:i,y:s,width:h,height:n,top:f,left:l,bottom:p,right:u})}}}),s?l:t({ref:h},l)};export{s as useMeasure};
|
|
3
3
|
//# sourceMappingURL=useMeasure.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
2
|
import{useCallback as n,useSyncExternalStore as e}from"react";var t=function(){return!1},r=function(r){var a=n((function(n){var e=window.matchMedia(r);return e.addEventListener("change",n),function(){e.removeEventListener("change",n)}}),[r]);return e(a,(function(){return window.matchMedia(r).matches}),t)};export{r as useMediaQuery};
|
|
3
3
|
//# sourceMappingURL=useMediaQuery.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as e}from"../../_rollupPluginBabelHelpers
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
|
+
import{_ as e}from"../../_rollupPluginBabelHelpers--yEi7JQy.js";import{useState as r}from"react";import{useInterval as o}from"../useInterval/useInterval.js";import"../useEvent/useEvent.js";var t=function(){var t=performance&&"memory"in performance,a=r({jsHeapSizeLimit:0,totalJSHeapSize:0,usedJSHeapSize:0}),n=e(a,2),m=n[0],p=n[1];return o((function(){return p(performance.memory)}),1e3,{enabled:t}),{supported:t,value:m}};export{t as useMemory};
|
|
3
3
|
//# sourceMappingURL=useMemory.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as e,b as n}from"../../_rollupPluginBabelHelpers
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
|
+
import{_ as e,b as n}from"../../_rollupPluginBabelHelpers--yEi7JQy.js";import{useState as t,useRef as r,useEffect as o}from"react";import{useRerender as i}from"../useRerender/useRerender.js";var u=function(){for(var u=i(),m=arguments.length,c=new Array(m),l=0;l<m;l++)c[l]=arguments[l];var a=c[0],f=t({x:0,y:0,elementX:0,elementY:0,elementPositionX:0,elementPositionY:0}),s=e(f,2),p=s[0],v=s[1],d=r();return o((function(){if(a||d.current){var e=function(e){var t=a?function(e){return"function"==typeof e?e():e instanceof Element?e:e.current}(a):d.current;if(t){var r={x:e.pageX,y:e.pageY},o=t.getBoundingClientRect(),i=o.left,u=o.top,m=i+window.scrollX,c=u+window.scrollY,l=e.pageX-m,f=e.pageY-c;r.elementX=l,r.elementY=f,r.elementPositionX=m,r.elementPositionY=c,v((function(e){return n(n({},e),r)}))}};return document.addEventListener("mousemove",e),function(){document.removeEventListener("mousemove",e)}}}),[d.current,a]),a?p:n({ref:function(e){d.current||(d.current=e,u.update())}},p)};export{u as useMouse};
|
|
3
3
|
//# sourceMappingURL=useMouse.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as r,d as n,e as
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
|
+
import{_ as r,b as l,d as n,e as o}from"../../_rollupPluginBabelHelpers--yEi7JQy.js";import{useState as u}from"react";var e=function(e,t){var i=u(!1),v=r(i,2),a=v[0],d=v[1],c=u(!1),s=r(c,2),y=s[0],f=s[1],p=u(!1),m=r(p,2),D=m[0],E=m[1],S=u(null),b=r(S,2),h=b[0],g=b[1],w=u(null),x=r(w,2),_=x[0],j=x[1],k=function r(n,o){var u;d(!0);var t=null!==(u=null==o?void 0:o.attempt)&&void 0!==u?u:0;return e(n).then((function(r){var l;return null==o||null===(l=o.onSuccess)||void 0===l||l.call(o,r),j(r),E(!0),d(!1),g(null),f(!1),r})).catch((function(u){var e,i="function"==typeof(null==o?void 0:o.retry)?null==o?void 0:o.retry(t,u):null==o?void 0:o.retry,v="function"==typeof(null==o?void 0:o.retryDelay)?null==o?void 0:o.retryDelay(t,u):null==o?void 0:o.retryDelay;return"boolean"==typeof i&&i||i&&i>t?v?void setTimeout((function(){return r(n,l(l({},o),{},{attempt:t+1}))}),v):r(n,l(l({},o),{},{attempt:t+1})):(null==o||null===(e=o.onError)||void 0===e||e.call(o,u),j(null),E(!1),d(!1),g(u),void f(!0))}))},A=function(){var r=n(o().mark((function r(l,n){var u,e,i,v,a;return o().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return a={retry:null!==(u=null==n?void 0:n.retry)&&void 0!==u?u:null==t?void 0:t.retry,retryDelay:null!==(e=null==n?void 0:n.retryDelay)&&void 0!==e?e:null==t?void 0:t.retryDelay,onSuccess:null!==(i=null==n?void 0:n.onSuccess)&&void 0!==i?i:null==t?void 0:t.onSuccess,onError:null!==(v=null==n?void 0:n.onError)&&void 0!==v?v:null==t?void 0:t.onError},r.abrupt("return",k(l,a));case 2:case"end":return r.stop()}}),r)})));return function(l,n){return r.apply(this,arguments)}}();return{data:_,error:h,mutate:function(r,l){var n,o,u,e,i={retry:null!==(n=null==l?void 0:l.retry)&&void 0!==n?n:null==t?void 0:t.retry,retryDelay:null!==(o=null==l?void 0:l.retryDelay)&&void 0!==o?o:null==t?void 0:t.retryDelay,onSuccess:null!==(u=null==l?void 0:l.onSuccess)&&void 0!==u?u:null==t?void 0:t.onSuccess,onError:null!==(e=null==l?void 0:l.onError)&&void 0!==e?e:null==t?void 0:t.onError};k(r,i)},mutateAsync:A,isLoading:a,isError:y,isSuccess:D}};export{e as useMutation};
|
|
3
3
|
//# sourceMappingURL=useMutation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMutation.js","sources":["../../../../src/hooks/useMutation/useMutation.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"useMutation.js","sources":["../../../../src/hooks/useMutation/useMutation.ts"],"sourcesContent":["import { useState } from 'react';\n\n/* The type of the options */\ninterface UseMutationOptions<Data> {\n /* The retry count of requests */\n retry?: boolean | number | ((failureCount: number, error: Error) => boolean);\n /* The retry delay of requests */\n retryDelay?: number | ((retry: number, error: Error) => number);\n /* The callback function to be invoked on success */\n onSuccess?: (data: Data) => void;\n /* The callback function to be invoked on error */\n onError?: (error: Error) => void;\n}\n\n/* The use mutation return type */\ninterface UseMutationReturn<Body, Data> {\n /* The data of the mutation */\n data: Data | null;\n /* The error of the mutation */\n error: Error | null;\n /* The mutate function */\n mutate: (body: Body, options?: UseMutationOptions<Data>) => void;\n /* The mutate async function */\n mutateAsync: (body: Body, options?: UseMutationOptions<Data>) => Promise<Data>;\n /* The loading state of the mutation */\n isLoading: boolean;\n /* The error state of the mutation */\n isError: boolean;\n /* The success state of the mutation */\n isSuccess: boolean;\n}\n\nexport interface RequestOptions<Data> extends UseMutationOptions<Data> {\n /* The attempt count */\n attempt?: number;\n}\n\n/**\n * @name useMutation\n * @description - Hook that defines the logic when mutate data\n * @category Utilities\n *\n * @template Body The type of the body\n * @template Data The type of the data\n * @param {(body: Body) => Promise<Data>} callback The callback function to be invoked\n * @param {boolean | number} [options.retry] The retry count of requests\n * @param {(data: Data) => void} [options.onSuccess] The callback function to be invoked on success\n * @param {(error: Error) => void} [options.onError] The callback function to be invoked on error\n * @returns {UseMutationReturn<Data>} An object with the state of the mutation\n *\n * @example\n * const { mutate, mutateAsync, isLoading, isError, isSuccess, error, data } = useMutation((name) => Promise.resolve(name));\n */\nexport const useMutation = <Body, Data>(\n callback: (body: Body) => Promise<Data>,\n options?: UseMutationOptions<Data>\n) => {\n const [isLoading, setIsLoading] = useState(false);\n const [isError, setIsError] = useState(false);\n const [isSuccess, setIsSuccess] = useState(false);\n\n const [error, setError] = useState<Error | null>(null);\n const [data, setData] = useState<Data | null>(null);\n\n const request = (\n body: Body,\n requestOptions?: RequestOptions<Data>\n ): Promise<Data | undefined> => {\n setIsLoading(true);\n const attempt = requestOptions?.attempt ?? 0;\n\n return callback(body)\n .then((response) => {\n requestOptions?.onSuccess?.(response);\n\n setData(response);\n setIsSuccess(true);\n setIsLoading(false);\n setError(null);\n setIsError(false);\n return response;\n })\n .catch((error: Error) => {\n const retry =\n typeof requestOptions?.retry === 'function'\n ? requestOptions?.retry(attempt, error)\n : requestOptions?.retry;\n\n const retryDelay =\n typeof requestOptions?.retryDelay === 'function'\n ? requestOptions?.retryDelay(attempt, error)\n : requestOptions?.retryDelay;\n\n if (typeof retry === 'boolean' && retry) {\n if (retryDelay) {\n setTimeout(\n () => request(body, { ...requestOptions, attempt: attempt + 1 }),\n retryDelay\n );\n return;\n }\n return request(body, { ...requestOptions, attempt: attempt + 1 });\n }\n\n if (retry && retry > attempt) {\n if (retryDelay) {\n setTimeout(\n () => request(body, { ...requestOptions, attempt: attempt + 1 }),\n retryDelay\n );\n return;\n }\n return request(body, { ...requestOptions, attempt: attempt + 1 });\n }\n\n requestOptions?.onError?.(error);\n setData(null);\n setIsSuccess(false);\n setIsLoading(false);\n setError(error);\n setIsError(true);\n });\n };\n const mutate = (body: Body, mutateOptions?: UseMutationOptions<Data>) => {\n const requestOptions = {\n retry: mutateOptions?.retry ?? options?.retry,\n retryDelay: mutateOptions?.retryDelay ?? options?.retryDelay,\n onSuccess: mutateOptions?.onSuccess ?? options?.onSuccess,\n onError: mutateOptions?.onError ?? options?.onError\n };\n\n request(body, requestOptions);\n };\n\n const mutateAsync = async (body: Body, mutateOptions?: UseMutationOptions<Data>) => {\n const requestOptions = {\n retry: mutateOptions?.retry ?? options?.retry,\n retryDelay: mutateOptions?.retryDelay ?? options?.retryDelay,\n onSuccess: mutateOptions?.onSuccess ?? options?.onSuccess,\n onError: mutateOptions?.onError ?? options?.onError\n };\n\n return request(body, requestOptions) as Promise<Data>;\n };\n\n return {\n data,\n error,\n mutate,\n mutateAsync,\n isLoading,\n isError,\n isSuccess\n } as UseMutationReturn<Body, Data>;\n};\n"],"names":["useMutation","callback","options","_useState","useState","_useState2","_slicedToArray","isLoading","setIsLoading","_useState3","_useState4","isError","setIsError","_useState5","_useState6","isSuccess","setIsSuccess","_useState7","_useState8","error","setError","_useState9","_useState10","data","setData","request","body","requestOptions","_requestOptions$attem","attempt","then","response","_requestOptions$onSuc","onSuccess","call","_requestOptions$onErr","retry","retryDelay","setTimeout","_objectSpread","onError","mutateAsync","_ref","_asyncToGenerator","_regeneratorRuntime","mark","_callee","mutateOptions","_mutateOptions$retry2","_mutateOptions$retryD2","_mutateOptions$onSucc2","_mutateOptions$onErro2","wrap","_context","prev","next","abrupt","stop","_x","_x2","apply","this","arguments","mutate","_mutateOptions$retry","_mutateOptions$retryD","_mutateOptions$onSucc","_mutateOptions$onErro"],"mappings":";sHAqDO,IAAMA,EAAc,SACzBC,EACAC,GAEA,IAAAC,EAAkCC,GAAS,GAAMC,EAAAC,EAAAH,EAAA,GAA1CI,EAASF,EAAA,GAAEG,EAAYH,EAAA,GAC9BI,EAA8BL,GAAS,GAAMM,EAAAJ,EAAAG,EAAA,GAAtCE,EAAOD,EAAA,GAAEE,EAAUF,EAAA,GAC1BG,EAAkCT,GAAS,GAAMU,EAAAR,EAAAO,EAAA,GAA1CE,EAASD,EAAA,GAAEE,EAAYF,EAAA,GAE9BG,EAA0Bb,EAAuB,MAAKc,EAAAZ,EAAAW,EAAA,GAA/CE,EAAKD,EAAA,GAAEE,EAAQF,EAAA,GACtBG,EAAwBjB,EAAsB,MAAKkB,EAAAhB,EAAAe,EAAA,GAA5CE,EAAID,EAAA,GAAEE,EAAOF,EAAA,GAEdG,EAAU,SAAVA,EACJC,EACAC,GAC8B,IAAAC,EAC9BpB,GAAa,GACb,IAAMqB,EAAiCD,QAA1BA,EAAGD,aAAc,EAAdA,EAAgBE,eAAOD,IAAAA,EAAAA,EAAI,EAE3C,OAAO3B,EAASyB,GACbI,MAAK,SAACC,GAAa,IAAAC,EAQlB,OAPAL,SAAyB,QAAXK,EAAdL,EAAgBM,iBAAS,IAAAD,GAAzBA,EAAAE,KAAAP,EAA4BI,GAE5BP,EAAQO,GACRf,GAAa,GACbR,GAAa,GACbY,EAAS,MACTR,GAAW,GACJmB,CACT,IAAE,OACK,SAACZ,GAAiB,IAAAgB,EACjBC,EAC6B,mBAA1BT,aAAc,EAAdA,EAAgBS,OACnBT,aAAAA,EAAAA,EAAgBS,MAAMP,EAASV,GAC/BQ,aAAAA,EAAAA,EAAgBS,MAEhBC,EACkC,mBAA/BV,aAAc,EAAdA,EAAgBU,YACnBV,aAAAA,EAAAA,EAAgBU,WAAWR,EAASV,GACpCQ,aAAAA,EAAAA,EAAgBU,WAEtB,MAAqB,kBAAVD,GAAuBA,GAW9BA,GAASA,EAAQP,EAVfQ,OACFC,YACE,WAAA,OAAMb,EAAQC,EAAIa,EAAAA,KAAOZ,GAAc,GAAA,CAAEE,QAASA,EAAU,IAAI,GAChEQ,GAIGZ,EAAQC,EAAIa,EAAAA,KAAOZ,GAAc,GAAA,CAAEE,QAASA,EAAU,MAc/DF,SAAuB,QAATQ,EAAdR,EAAgBa,eAAO,IAAAL,GAAvBA,EAAAD,KAAAP,EAA0BR,GAC1BK,EAAQ,MACRR,GAAa,GACbR,GAAa,GACbY,EAASD,QACTP,GAAW,GACb,KAaE6B,EAAW,WAAA,IAAAC,EAAAC,EAAAC,IAAAC,MAAG,SAAAC,EAAOpB,EAAYqB,GAAwC,IAAAC,EAAAC,EAAAC,EAAAC,EAAAxB,EAAA,OAAAiB,IAAAQ,MAAA,SAAAC,GAAA,cAAAA,EAAAC,KAAAD,EAAAE,MAAA,KAAA,EAM5E,OALK5B,EAAiB,CACrBS,cAAKY,EAAED,aAAa,EAAbA,EAAeX,aAAK,IAAAY,EAAAA,EAAI9C,aAAO,EAAPA,EAASkC,MACxCC,mBAAUY,EAAEF,aAAa,EAAbA,EAAeV,kBAAU,IAAAY,EAAAA,EAAI/C,aAAO,EAAPA,EAASmC,WAClDJ,kBAASiB,EAAEH,aAAa,EAAbA,EAAed,iBAAS,IAAAiB,EAAAA,EAAIhD,aAAO,EAAPA,EAAS+B,UAChDO,gBAAOW,EAAEJ,aAAa,EAAbA,EAAeP,eAAO,IAAAW,EAAAA,EAAIjD,aAAO,EAAPA,EAASsC,SAC7Ca,EAAAG,OAAA,SAEM/B,EAAQC,EAAMC,IAAe,KAAA,EAAA,IAAA,MAAA,OAAA0B,EAAAI,OAAA,GAAAX,EACrC,KAAA,OAAA,SATgBY,EAAAC,GAAA,OAAAjB,EAAAkB,MAAAC,KAAAC,UAAA,EAAA,GAWjB,MAAO,CACLvC,KAAAA,EACAJ,MAAAA,EACA4C,OAzBa,SAACrC,EAAYqB,GAA6C,IAAAiB,EAAAC,EAAAC,EAAAC,EACjExC,EAAiB,CACrBS,cAAK4B,EAAEjB,aAAa,EAAbA,EAAeX,aAAK,IAAA4B,EAAAA,EAAI9D,aAAO,EAAPA,EAASkC,MACxCC,mBAAU4B,EAAElB,aAAa,EAAbA,EAAeV,kBAAU,IAAA4B,EAAAA,EAAI/D,aAAO,EAAPA,EAASmC,WAClDJ,kBAASiC,EAAEnB,aAAa,EAAbA,EAAed,iBAAS,IAAAiC,EAAAA,EAAIhE,aAAO,EAAPA,EAAS+B,UAChDO,gBAAO2B,EAAEpB,aAAa,EAAbA,EAAeP,eAAO,IAAA2B,EAAAA,EAAIjE,aAAO,EAAPA,EAASsC,SAG9Cf,EAAQC,EAAMC,IAkBdc,YAAAA,EACAlC,UAAAA,EACAI,QAAAA,EACAI,UAAAA,EAEJ"}
|