@siberiacancode/reactuse 0.0.54 → 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-s0b9uPmg.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/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/useList/useList.js +2 -2
- package/dist/cjs/hooks/useLocalStorage/useLocalStorage.js +2 -2
- 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/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/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-fy8Yvkbz.js → index-96gzcInk.js} +2 -2
- package/dist/cjs/{index-fy8Yvkbz.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-0IYrm-Ud.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/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/useList/useList.js +2 -2
- package/dist/esm/hooks/useLocalStorage/useLocalStorage.js +2 -2
- 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/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/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-B9lnRo2n.js → index-5OKmysyE.js} +2 -2
- package/dist/esm/{index-B9lnRo2n.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 +29 -8
- package/package.json +1 -1
- package/dist/cjs/_rollupPluginBabelHelpers-s0b9uPmg.js.map +0 -1
- package/dist/esm/_rollupPluginBabelHelpers-0IYrm-Ud.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useQuery.js","sources":["../../../../src/hooks/useQuery/useQuery.ts"],"sourcesContent":["import type { DependencyList } from 'react';\nimport { useEffect, useRef, useState } from 'react';\n\nimport { getRetry } from '@/utils/helpers';\n\nimport { useDidUpdate } from '../useDidUpdate/useDidUpdate';\nimport { useMount } from '../useMount/useMount';\n\n/* The use query return type */\nexport interface UseQueryOptions<QueryData, Data> {\n /* The depends for the hook */\n keys?: DependencyList;\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 /* The select function to be invoked */\n select?: (data: QueryData) => Data;\n /* The initial data for the hook */\n initialData?: Data | (() => Data);\n /* The placeholder data for the hook */\n placeholderData?: Data | (() => Data);\n /* The retry count of requests */\n retry?: boolean | number;\n /* The refetch interval */\n refetchInterval?: number;\n /* The enabled state of the query */\n enabled?: boolean;\n}\n\n/* The use query return type */\nexport interface UseQueryReturn<Data> {\n /* The state of the query */\n data?: Data;\n /* The loading state of the query */\n isLoading: boolean;\n /* The error state of the query */\n isError: boolean;\n /* The success state of the query */\n isSuccess: boolean;\n /* The success state of the query */\n error?: Error;\n /* The refetch function */\n refetch: () => void;\n /* The refetching state of the query */\n isRefetching: boolean;\n}\n\n/**\n * @name useQuery\n * @description - Hook that defines the logic when query data\n * @category Utilities\n *\n * @template Data The type of the data\n * @param {() => Promise<Data>} callback The callback function to be invoked\n * @param {DependencyList} [options.keys] The dependencies for the hook\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 * @param {UseQueryOptionsSelect<Data>} [options.select] The select function to be invoked\n * @param {Data | (() => Data)} [options.initialData] The initial data for the hook\n * @param {Data | (() => Data)} [options.placeholderData] The placeholder data for the hook\n * @param {number} [options.refetchInterval] The refetch interval\n * @param {boolean | number} [options.retry] The retry count of requests\n * @returns {UseQueryReturn<Data>} An object with the state of the query\n *\n * @example\n * const { data, isLoading, isError, isSuccess, error, refetch, isRefetching } = useQuery(() => fetch('
|
|
1
|
+
{"version":3,"file":"useQuery.js","sources":["../../../../src/hooks/useQuery/useQuery.ts"],"sourcesContent":["import type { DependencyList } from 'react';\nimport { useEffect, useRef, useState } from 'react';\n\nimport { getRetry } from '@/utils/helpers';\n\nimport { useDidUpdate } from '../useDidUpdate/useDidUpdate';\nimport { useMount } from '../useMount/useMount';\n\n/* The use query return type */\nexport interface UseQueryOptions<QueryData, Data> {\n /* The depends for the hook */\n keys?: DependencyList;\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 /* The select function to be invoked */\n select?: (data: QueryData) => Data;\n /* The initial data for the hook */\n initialData?: Data | (() => Data);\n /* The placeholder data for the hook */\n placeholderData?: Data | (() => Data);\n /* The retry count of requests */\n retry?: boolean | number;\n /* The refetch interval */\n refetchInterval?: number;\n /* The enabled state of the query */\n enabled?: boolean;\n}\n\n/* The use query return type */\nexport interface UseQueryReturn<Data> {\n /* The state of the query */\n data?: Data;\n /* The loading state of the query */\n isLoading: boolean;\n /* The error state of the query */\n isError: boolean;\n /* The success state of the query */\n isSuccess: boolean;\n /* The success state of the query */\n error?: Error;\n /* The refetch function */\n refetch: () => void;\n /* The refetching state of the query */\n isRefetching: boolean;\n}\n\n/**\n * @name useQuery\n * @description - Hook that defines the logic when query data\n * @category Utilities\n *\n * @template Data The type of the data\n * @param {() => Promise<Data>} callback The callback function to be invoked\n * @param {DependencyList} [options.keys] The dependencies for the hook\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 * @param {UseQueryOptionsSelect<Data>} [options.select] The select function to be invoked\n * @param {Data | (() => Data)} [options.initialData] The initial data for the hook\n * @param {Data | (() => Data)} [options.placeholderData] The placeholder data for the hook\n * @param {number} [options.refetchInterval] The refetch interval\n * @param {boolean | number} [options.retry] The retry count of requests\n * @returns {UseQueryReturn<Data>} An object with the state of the query\n *\n * @example\n * const { data, isLoading, isError, isSuccess, error, refetch, isRefetching } = useQuery(() => fetch('url'));\n */\nexport const useQuery = <QueryData, Data = QueryData>(\n callback: () => Promise<QueryData>,\n options?: UseQueryOptions<QueryData, Data>\n): UseQueryReturn<Data> => {\n const enabled = options?.enabled ?? true;\n const retryCountRef = useRef(options?.retry ? getRetry(options.retry) : 0);\n\n const [isLoading, setIsLoading] = useState(false);\n const [isError, setIsError] = useState(false);\n const [isRefetching, setIsRefetching] = useState(false);\n const [isSuccess, setIsSuccess] = useState(!!options?.initialData);\n\n const [error, setError] = useState<Error | undefined>(undefined);\n const [data, setData] = useState<Data | undefined>(options?.initialData);\n\n const intervalIdRef = useRef<ReturnType<typeof setInterval>>();\n\n const request = (action: 'init' | 'refetch') => {\n setIsLoading(true);\n if (action === 'refetch') setIsRefetching(true);\n callback()\n .then((response) => {\n const data = options?.select ? options?.select(response) : response;\n options?.onSuccess?.(data as Data);\n setData(data as Data);\n setIsSuccess(true);\n setIsLoading(false);\n setError(undefined);\n setIsError(false);\n if (action === 'refetch') setIsRefetching(false);\n })\n .catch((error: Error) => {\n if (retryCountRef.current > 0) {\n retryCountRef.current -= 1;\n return request(action);\n }\n options?.onError?.(error);\n setData(undefined);\n setIsSuccess(false);\n setIsLoading(false);\n setError(error);\n setIsError(true);\n if (action === 'refetch') setIsRefetching(false);\n retryCountRef.current = options?.retry ? getRetry(options.retry) : 0;\n })\n .finally(() => {\n if (options?.refetchInterval) {\n const interval = setInterval(() => {\n clearInterval(interval);\n request('refetch');\n }, options?.refetchInterval);\n intervalIdRef.current = interval;\n }\n });\n };\n\n useMount(() => {\n if (!enabled) return;\n request('init');\n });\n\n useDidUpdate(() => {\n if (!enabled) return;\n request('refetch');\n }, [enabled, ...(options?.keys ?? [])]);\n\n useEffect(() => {\n return () => {\n clearInterval(intervalIdRef.current);\n };\n }, [enabled, options?.refetchInterval, options?.retry, ...(options?.keys ?? [])]);\n\n const refetch = () => request('refetch');\n\n const placeholderData =\n options?.placeholderData instanceof Function\n ? options?.placeholderData()\n : options?.placeholderData;\n\n return {\n data: data ?? placeholderData,\n error,\n refetch,\n isLoading,\n isError,\n isSuccess,\n isRefetching\n };\n};\n"],"names":["useQuery","callback","options","_options$enabled","_options$keys","_options$keys2","enabled","retryCountRef","useRef","retry","getRetry","_useState","useState","_useState2","_slicedToArray","isLoading","setIsLoading","_useState3","_useState4","isError","setIsError","_useState5","_useState6","isRefetching","setIsRefetching","_useState7","initialData","_useState8","isSuccess","setIsSuccess","_useState9","undefined","_useState10","error","setError","_useState11","_useState12","data","setData","intervalIdRef","request","action","then","response","_options$onSuccess","select","onSuccess","call","_options$onError","current","onError","refetchInterval","interval","setInterval","clearInterval","useMount","useDidUpdate","concat","_toConsumableArray","keys","useEffect","placeholderData","Function","refetch"],"mappings":";0ZAoEO,IAAMA,EAAW,SACtBC,EACAC,GACyB,IAAAC,EAAAC,EAAAC,EACnBC,EAA0BH,QAAnBA,EAAGD,aAAO,EAAPA,EAASI,eAAOH,IAAAA,GAAAA,EAC1BI,EAAgBC,EAAON,SAAAA,EAASO,MAAQC,EAASR,EAAQO,OAAS,GAExEE,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,EAAwCT,GAAS,GAAMU,EAAAR,EAAAO,EAAA,GAAhDE,EAAYD,EAAA,GAAEE,EAAeF,EAAA,GACpCG,EAAkCb,IAAWV,UAAAA,EAASwB,cAAYC,EAAAb,EAAAW,EAAA,GAA3DG,EAASD,EAAA,GAAEE,EAAYF,EAAA,GAE9BG,EAA0BlB,OAA4BmB,GAAUC,EAAAlB,EAAAgB,EAAA,GAAzDG,EAAKD,EAAA,GAAEE,EAAQF,EAAA,GACtBG,EAAwBvB,EAA2BV,aAAAA,EAAAA,EAASwB,aAAYU,EAAAtB,EAAAqB,EAAA,GAAjEE,EAAID,EAAA,GAAEE,EAAOF,EAAA,GAEdG,EAAgB/B,IAEhBgC,EAAU,SAAVA,EAAWC,GACfzB,GAAa,GACE,YAAXyB,GAAsBjB,GAAgB,GAC1CvB,IACGyC,MAAK,SAACC,GAAa,IAAAC,EACZP,EAAOnC,SAAAA,EAAS2C,OAAS3C,eAAAA,EAAS2C,OAAOF,GAAYA,EAC3DzC,SAAkB,QAAX0C,EAAP1C,EAAS4C,iBAAS,IAAAF,GAAlBA,EAAAG,KAAA7C,EAAqBmC,GACrBC,EAAQD,GACRR,GAAa,GACbb,GAAa,GACbkB,OAASH,GACTX,GAAW,GACI,YAAXqB,GAAsBjB,GAAgB,EAC5C,IAAE,OACK,SAACS,GAAiB,IAAAe,EACvB,GAAIzC,EAAc0C,QAAU,EAE1B,OADA1C,EAAc0C,SAAW,EAClBT,EAAQC,GAEjBvC,SAAgB,QAAT8C,EAAP9C,EAASgD,eAAO,IAAAF,GAAhBA,EAAAD,KAAA7C,EAAmB+B,GACnBK,OAAQP,GACRF,GAAa,GACbb,GAAa,GACbkB,EAASD,GACTb,GAAW,GACI,YAAXqB,GAAsBjB,GAAgB,GAC1CjB,EAAc0C,QAAU/C,SAAAA,EAASO,MAAQC,EAASR,EAAQO,OAAS,KAE7D,SAAC,WACP,GAAIP,SAAAA,EAASiD,gBAAiB,CAC5B,IAAMC,EAAWC,aAAY,WAC3BC,cAAcF,GACdZ,EAAQ,aACPtC,eAAAA,EAASiD,iBACZZ,EAAcU,QAAUG,CAC1B,CACF,KAGJG,GAAS,WACFjD,GACLkC,EAAQ,OACV,IAEAgB,GAAa,WACNlD,GACLkC,EAAQ,aACT,CAAGlC,GAAOmD,OAAAC,EAAmBtD,QAAnBA,EAAMF,aAAAA,EAAAA,EAASyD,gBAAIvD,EAAAA,EAAI,MAElCwD,GAAU,WACR,OAAO,WACLN,cAAcf,EAAcU,SAEhC,IAAI3C,EAASJ,aAAAA,EAAAA,EAASiD,gBAAiBjD,aAAAA,EAAAA,EAASO,OAAKgD,OAAAC,UAAArD,EAAMH,aAAAA,EAAAA,EAASyD,YAAI,IAAAtD,EAAAA,EAAI,MAE5E,IAEMwD,GACJ3D,aAAAA,EAAAA,EAAS2D,2BAA2BC,SAChC5D,aAAAA,EAAAA,EAAS2D,kBACT3D,aAAAA,EAAAA,EAAS2D,gBAEf,MAAO,CACLxB,KAAMA,QAAAA,EAAQwB,EACd5B,MAAAA,EACA8B,QAVc,WAAH,OAASvB,EAAQ,UAAU,EAWtCzB,UAAAA,EACAI,QAAAA,EACAS,UAAAA,EACAL,aAAAA,EAEJ"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as r,a as n,f as t}from"../../_rollupPluginBabelHelpers
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
|
+
import{_ as r,a as n,f as t}from"../../_rollupPluginBabelHelpers--yEi7JQy.js";import{useState as e}from"react";import{flushSync as o}from"react-dom";var u=function(){var u=e(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]),a=r(u,2),i=a[0],c=a[1];return{add:function(r){return c((function(t){return[].concat(n(t),[r])}))},remove:function(){var r;return o((function(){c((function(n){var e=t(n),o=e[0],u=e.slice(1);return r=o,u}))})),r},clear:function(){return c([])},first:i[0],last:i[i.length-1],size:i.length,queue:i}};export{u as useQueue};
|
|
3
3
|
//# sourceMappingURL=useQueue.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,useEffect as t}from"react";var n=function(){var n=r(0);return t((function(){n.current+=1})),n.current};export{n as useRenderCount};
|
|
3
3
|
//# sourceMappingURL=useRenderCount.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
2
|
import{useRef as e}from"react";var n=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Unknown",r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],t=e({component:n,renders:0,timestamp:Date.now(),sinceLast:0}),c=Date.now();return t.current.renders+=1,t.current.sinceLast=t.current.timestamp?c-t.current.timestamp:0,t.current.timestamp=c,r&&(console.group("".concat(n," info, render number: ").concat(t.current.renders)),console.log("Timestamp: ".concat(t.current.timestamp)),console.log("Since last render: ".concat(t.current.sinceLast)),console.log("Renders: ".concat(t.current.renders)),console.dir(t.current),console.groupEnd()),t.current};export{n as useRenderInfo};
|
|
3
3
|
//# sourceMappingURL=useRenderInfo.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as r}from"../../_rollupPluginBabelHelpers
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
|
+
import{_ as r}from"../../_rollupPluginBabelHelpers--yEi7JQy.js";import{useId as t,useState as o}from"react";var n=function(){var n=t(),a=o(n),e=r(a,2),i=e[0],u=e[1];return{id:i,update:function(){return u(Math.random().toString())}}};export{n as useRerender};
|
|
3
3
|
//# sourceMappingURL=useRerender.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{c as n,_ as r}from"../../_rollupPluginBabelHelpers
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
|
+
import{c as n,_ as r}from"../../_rollupPluginBabelHelpers--yEi7JQy.js";import{useState as e,useRef as t,useEffect as o}from"react";import{useRerender as i}from"../useRerender/useRerender.js";var u=function(n){return"function"==typeof n?n():n instanceof Element?n:n.current},c=function(){var c,l=i(),v="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,a=v?arguments.length<=1?void 0:arguments[1]:arguments.length<=0?void 0:arguments[0],f=null===(c=null==a?void 0:a.enabled)||void 0===c||c,s=e([]),d=r(s,2),b=d[0],g=d[1],h=t(),p=t();return p.current=null==a?void 0:a.onChange,o((function(){if(f){if(Array.isArray(v)){if(!v.length)return;var n=new ResizeObserver((function(r){var e;g(r),null===(e=p.current)||void 0===e||e.call(p,r,n)}));return v.forEach((function(r){var e=u(r);e&&n.observe(e,a)})),function(){n.disconnect()}}var r=v?u(v):h.current;if(r){var e=new ResizeObserver((function(n){var r;g(n),null===(r=p.current)||void 0===r||r.call(p,n,e)}));return e.observe(r,a),function(){e.disconnect()}}}}),[h.current,v,null==a?void 0:a.box,f]),v?{entries:b}:{ref:function(n){h.current||(h.current=n,l.update())},entries:b}};export{c as useResizeObserver};
|
|
3
3
|
//# sourceMappingURL=useResizeObserver.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 t,useEffect as e}from"react";var n="script-status",o=function(o){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},u=t((function(){var r=document.querySelector('script[src="'.concat(o,'"]')),t=null==r?void 0:r.getAttribute(n);return t||(r?"unknown":"loading")})),c=r(u,2),a=c[0],s=c[1],d=i.removeOnUnmount,v=void 0===d||d,l=i.async,m=void 0===l||l;return e((function(){var t=document.querySelector('script[src="'.concat(o,'"]')),e=null==t?void 0:t.getAttribute(n);if(e)return s(e);if(t)return s("unknown");var u=document.createElement("script");u.src=o,u.async=m;for(var c=0,a=Object.entries(i);c<a.length;c++){var d=r(a[c],2),l=d[0],f=d[1];u.setAttribute(l,String(f))}u.setAttribute(n,"loading"),document.body.appendChild(u);var p=function(){u.setAttribute(n,"ready"),s("ready")},b=function(){u.setAttribute(n,"error"),s("error")};return u.addEventListener("load",p),u.addEventListener("error",b),function(){v&&(u.remove(),u.removeEventListener("load",p),u.removeEventListener("error",b))}}),[o,v]),a};export{n as SCRIPT_STATUS_ATTRIBUTE_NAME,o as useScript};
|
|
3
3
|
//# sourceMappingURL=useScript.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{b as o}from"../../_rollupPluginBabelHelpers
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
|
+
import{b as o}from"../../_rollupPluginBabelHelpers--yEi7JQy.js";import{useStorage as e}from"../useStorage/useStorage.js";import"react";import"../../utils/helpers/isClient.js";import"../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js";var r=function(r,t,s){return e(r,o({initialValue:t,storage:window.sessionStorage},s))};export{r as useSessionStorage};
|
|
3
3
|
//# sourceMappingURL=useSessionStorage.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 n}from"react";var r=function(r){var t=n(new Set(r)),u=e(t,2),i=u[0],f=u[1];return{value:i,size:i.size,has:function(e){return i.has(e)},add:function(e){return f((function(n){return new Set(n).add(e)}))},remove:function(e){return f((function(n){if(!n.has(e))return n;var r=new Set(n);return r.delete(e),r}))},clear:function(){return f(new Set)},reset:function(){return f(new Set(r))},toggle:function(e){return f((function(n){if(!n.has(e))return new Set(n).add(e);var r=new Set(n);return r.delete(e),r}))},union:function(e){return f(i.union(e))},difference:function(e){return f(i.difference(e))},symmetricDifference:function(e){return f(i.symmetricDifference(e))},intersection:function(e){return f(i.intersection(e))}}};export{r as useSet};
|
|
3
3
|
//# sourceMappingURL=useSet.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{d as r,e as a,b as e}from"../../_rollupPluginBabelHelpers
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
|
+
import{d as r,e as a,b as e}from"../../_rollupPluginBabelHelpers--yEi7JQy.js";var n=function(n){var t=navigator&&"share"in navigator,s=function(){var s=r(a().mark((function r(s){var i;return a().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(t){r.next=2;break}return r.abrupt("return");case 2:return(i=e(e({},n),s)).files&&navigator.canShare({files:i.files})&&navigator.share(i),r.abrupt("return",navigator.share(i));case 5:case"end":return r.stop()}}),r)})));return function(r){return s.apply(this,arguments)}}();return{share:s,supported:t}};export{n as useShare};
|
|
3
3
|
//# sourceMappingURL=useShare.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{c as t,_ as r}from"../../_rollupPluginBabelHelpers
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
|
+
import{c as t,_ as r}from"../../_rollupPluginBabelHelpers--yEi7JQy.js";import{useRef as n,useState as e}from"react";var i=function(i){var u="object"===t(i)?i.max:i,o="object"===t(i)?i.initial:1,c=n(o>u||o<1?1:o),s=e(o),a=r(s,2),f=a[0],l=a[1],p=1===f,m=f===u;return{counts:u,currentStep:f,isFirst:p,isLast:m,next:function(){m||l((function(t){return t+1}))},back:function(){p||l((function(t){return t-1}))},reset:function(){return l(c.current)},set:function(t){return"first"===t?l(c.current):"last"===t||t>=u?l(u):t<=1?l(1):void l(t)}}};export{i as useStep};
|
|
3
3
|
//# sourceMappingURL=useStep.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as n,b as t}from"../../_rollupPluginBabelHelpers
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
|
+
import{_ as n,b as t}from"../../_rollupPluginBabelHelpers--yEi7JQy.js";import{useState as r,useEffect as o}from"react";import"../../utils/helpers/isClient.js";import{useEvent as e}from"../useEvent/useEvent.js";import"../../index-5OKmysyE.js";import"react-dom";var u=function(n){return n?{days:Math.floor(n/86400),hours:Math.floor(n%86400/3600),minutes:Math.floor(n%3600/60),seconds:Math.floor(n%60),count:n}:{days:0,hours:0,minutes:0,seconds:0,count:0}},s=function(){for(var s,i,c=arguments.length,a=new Array(c),l=0;l<c;l++)a[l]=arguments[l];var f=null!==(s="number"==typeof a[0]?a[0]:null===(i=a[0])||void 0===i?void 0:i.initialTime)&&void 0!==s?s:0,d="number"==typeof a[0]?a[1]:a[0],m=r(u(f)),p=n(m,2),v=p[0],h=p[1],y=r(!(null!=d&&d.enabled)),b=n(y,2),g=b[0],j=b[1],M=e((function(){var n=v.count+1;return n%60==0?h(t(t({},v),{},{minutes:v.minutes+1,seconds:0,count:n})):n%3600==0?h(t(t({},v),{},{hours:v.hours+1,minutes:0,seconds:0,count:n})):n%86400==0?h(t(t({},v),{},{days:v.days+1,hours:0,minutes:0,seconds:0,count:n})):void h(t(t({},v),{},{seconds:v.seconds+1,count:n}))}));return o((function(){if(!g){var n=setInterval((function(){return M()}),1e3);return function(){return clearInterval(n)}}}),[g]),t(t({},v),{},{paused:g,pause:function(){return j(!0)},start:function(){return j(!1)},reset:function(){return h(u(f))},toggle:function(){return j((function(n){return!n}))}})};export{s as useStopwatch};
|
|
3
3
|
//# sourceMappingURL=useStopwatch.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{c as e}from"../../_rollupPluginBabelHelpers
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
|
+
import{c as e}from"../../_rollupPluginBabelHelpers--yEi7JQy.js";import{useSyncExternalStore as n}from"react";import{isClient as t}from"../../utils/helpers/isClient.js";import{useIsomorphicLayoutEffect as r}from"../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js";var o=function(e){return window.dispatchEvent(new StorageEvent("storage",e))},i=function(e,n,t){var r=e.getItem(n);e.setItem(n,t),o({key:n,oldValue:r,newValue:t,storageArea:e})},u=function(e,n){var t=e.getItem(n);e.removeItem(n),o({key:n,oldValue:t,newValue:null,storageArea:e})},a=function(e,n){var t=e.getItem(n);if(t)return t},l=function(e){return window.addEventListener("storage",e),function(){return window.removeEventListener("storage",e)}},s=function(){},f=function(o,f){var c,v="object"===e(f)?f:void 0,d=v?null==v?void 0:v.initialValue:f,m=null!==(c=null==v?void 0:v.storage)&&void 0!==c?c:window.localStorage,g=function(e){return null!=v&&v.serializer?v.serializer(e):JSON.stringify(e)},p=n(l,(function(){return a(m,o)}),s),w=function(e){if(null===e)return u(m,o);i(m,o,g(e))};r((function(){void 0===a(m,o)&&void 0!==d&&i(m,o,g(d instanceof Function?d():d))}),[o]);var I=function(){return u(m,o)};return t?{value:p?function(e){if(null!=v&&v.deserializer)return v.deserializer(e);if("undefined"!==e)try{return JSON.parse(e)}catch(n){return e}}(p):void 0,set:w,remove:I}:{value:d instanceof Function?d():d,set:w,remove:I}};export{o as dispatchStorageEvent,f as useStorage};
|
|
3
3
|
//# sourceMappingURL=useStorage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStorage.js","sources":["../../../../src/hooks/useStorage/useStorage.ts"],"sourcesContent":["import { useSyncExternalStore } from 'react';\n\nimport { isClient } from '@/utils/helpers';\n\nimport { useIsomorphicLayoutEffect } from '../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect';\n\n/* The use storage initial value type */\nexport type UseStorageInitialValue<Value> = Value | (() => Value);\n\n/* The use storage options type */\nexport interface UseStorageOptions<Value> {\n /* The serializer function to be invoked */\n serializer?: (value: Value) => string;\n /* The deserializer function to be invoked */\n deserializer?: (value: string) => Value;\n /* The storage to be used */\n storage?: Storage;\n /* The initial value of the storage */\n initialValue?: UseStorageInitialValue<Value>;\n}\n\n/* The use storage return type */\nexport type UseStorageReturn<Value> = {\n /* The value of the storage */\n value: Value;\n /* The loading state of the storage */\n set: (value: Value) => void;\n /* The error state of the storage */\n remove: () => void;\n};\n\nexport const dispatchStorageEvent = (params: Partial<StorageEvent>) =>\n window.dispatchEvent(new StorageEvent('storage', params));\n\nconst setStorageItem = (storage: Storage, key: string, value: string) => {\n const oldValue = storage.getItem(key);\n\n storage.setItem(key, value);\n dispatchStorageEvent({ key, oldValue, newValue: value, storageArea: storage });\n};\n\nconst removeStorageItem = (storage: Storage, key: string) => {\n const oldValue = storage.getItem(key);\n\n storage.removeItem(key);\n dispatchStorageEvent({ key, oldValue, newValue: null, storageArea: storage });\n};\n\nconst getStorageItem = (storage: Storage, key: string) => {\n const value = storage.getItem(key);\n if (!value) return undefined;\n return value;\n};\n\nconst storageSubscribe = (callback: () => void) => {\n window.addEventListener('storage', callback);\n return () => window.removeEventListener('storage', callback);\n};\n\nconst getServerSnapshot = () => undefined;\n\n/**\n * @name useStorage\n * @description - Hook that manages storage value\n * @category Utilities\n *\n * @param {string} key The key of the storage\n * @param {(value: Value) => string} [params.serializer] The serializer function\n * @param {(value: string) => Value} [params.deserializer] The deserializer function\n * @param {Storage} [params.storage] The storage\n * @param {UseStorageInitialValue<Value>} [params.initialValue] The initial value of the storage\n * @returns {UseStorageReturn<Value>} The value and the set function\n *\n * @example\n * const { value, set, remove } = useStorage('key', 'value');\n */\nexport const useStorage = <Value>(\n key: string,\n params?: UseStorageInitialValue<Value> | UseStorageOptions<Value>\n) => {\n const options = (typeof params === 'object' ? params : undefined) as UseStorageOptions<Value>;\n const initialValue = (options ? options?.initialValue : params) as UseStorageInitialValue<Value>;\n\n const storage = options?.storage ?? window.localStorage;\n const serializer = (value: Value) => {\n if (options?.serializer) return options.serializer(value);\n return JSON.stringify(value);\n };\n\n const deserializer = (value: string) => {\n if (options?.deserializer) return options.deserializer(value);\n\n if (value === 'undefined') {\n return undefined as unknown as Value;\n }\n\n try {\n return JSON.parse(value) as Value;\n } catch (error) {\n return value as Value;\n }\n };\n\n const getSnapshot = () => getStorageItem(storage, key);\n const store = useSyncExternalStore(storageSubscribe, getSnapshot, getServerSnapshot);\n\n const set = (value: Value) => {\n if (value === null) return removeStorageItem(storage, key);\n setStorageItem(storage, key, serializer(value));\n };\n\n useIsomorphicLayoutEffect(() => {\n const value = getStorageItem(storage, key);\n if (value === undefined &&
|
|
1
|
+
{"version":3,"file":"useStorage.js","sources":["../../../../src/hooks/useStorage/useStorage.ts"],"sourcesContent":["import { useSyncExternalStore } from 'react';\n\nimport { isClient } from '@/utils/helpers';\n\nimport { useIsomorphicLayoutEffect } from '../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect';\n\n/* The use storage initial value type */\nexport type UseStorageInitialValue<Value> = Value | (() => Value);\n\n/* The use storage options type */\nexport interface UseStorageOptions<Value> {\n /* The serializer function to be invoked */\n serializer?: (value: Value) => string;\n /* The deserializer function to be invoked */\n deserializer?: (value: string) => Value;\n /* The storage to be used */\n storage?: Storage;\n /* The initial value of the storage */\n initialValue?: UseStorageInitialValue<Value>;\n}\n\n/* The use storage return type */\nexport type UseStorageReturn<Value> = {\n /* The value of the storage */\n value: Value;\n /* The loading state of the storage */\n set: (value: Value) => void;\n /* The error state of the storage */\n remove: () => void;\n};\n\nexport const dispatchStorageEvent = (params: Partial<StorageEvent>) =>\n window.dispatchEvent(new StorageEvent('storage', params));\n\nconst setStorageItem = (storage: Storage, key: string, value: string) => {\n const oldValue = storage.getItem(key);\n\n storage.setItem(key, value);\n dispatchStorageEvent({ key, oldValue, newValue: value, storageArea: storage });\n};\n\nconst removeStorageItem = (storage: Storage, key: string) => {\n const oldValue = storage.getItem(key);\n\n storage.removeItem(key);\n dispatchStorageEvent({ key, oldValue, newValue: null, storageArea: storage });\n};\n\nconst getStorageItem = (storage: Storage, key: string) => {\n const value = storage.getItem(key);\n if (!value) return undefined;\n return value;\n};\n\nconst storageSubscribe = (callback: () => void) => {\n window.addEventListener('storage', callback);\n return () => window.removeEventListener('storage', callback);\n};\n\nconst getServerSnapshot = () => undefined;\n\n/**\n * @name useStorage\n * @description - Hook that manages storage value\n * @category Utilities\n *\n * @param {string} key The key of the storage\n * @param {(value: Value) => string} [params.serializer] The serializer function\n * @param {(value: string) => Value} [params.deserializer] The deserializer function\n * @param {Storage} [params.storage] The storage\n * @param {UseStorageInitialValue<Value>} [params.initialValue] The initial value of the storage\n * @returns {UseStorageReturn<Value>} The value and the set function\n *\n * @example\n * const { value, set, remove } = useStorage('key', 'value');\n */\nexport const useStorage = <Value>(\n key: string,\n params?: UseStorageInitialValue<Value> | UseStorageOptions<Value>\n) => {\n const options = (typeof params === 'object' ? params : undefined) as UseStorageOptions<Value>;\n const initialValue = (options ? options?.initialValue : params) as UseStorageInitialValue<Value>;\n\n const storage = options?.storage ?? window.localStorage;\n const serializer = (value: Value) => {\n if (options?.serializer) return options.serializer(value);\n return JSON.stringify(value);\n };\n\n const deserializer = (value: string) => {\n if (options?.deserializer) return options.deserializer(value);\n\n if (value === 'undefined') {\n return undefined as unknown as Value;\n }\n\n try {\n return JSON.parse(value) as Value;\n } catch (error) {\n return value as Value;\n }\n };\n\n const getSnapshot = () => getStorageItem(storage, key);\n const store = useSyncExternalStore(storageSubscribe, getSnapshot, getServerSnapshot);\n\n const set = (value: Value) => {\n if (value === null) return removeStorageItem(storage, key);\n setStorageItem(storage, key, serializer(value));\n };\n\n useIsomorphicLayoutEffect(() => {\n const value = getStorageItem(storage, key);\n if (value === undefined && initialValue !== undefined) {\n setStorageItem(\n storage,\n key,\n serializer(initialValue instanceof Function ? initialValue() : initialValue)\n );\n }\n }, [key]);\n\n const remove = () => removeStorageItem(storage, key);\n\n if (!isClient)\n return {\n value: initialValue instanceof Function ? initialValue() : initialValue,\n set,\n remove\n };\n return {\n value: store ? deserializer(store) : undefined,\n set,\n remove\n };\n};\n"],"names":["dispatchStorageEvent","params","window","dispatchEvent","StorageEvent","setStorageItem","storage","key","value","oldValue","getItem","setItem","newValue","storageArea","removeStorageItem","removeItem","getStorageItem","storageSubscribe","callback","addEventListener","removeEventListener","getServerSnapshot","useStorage","_options$storage","options","_typeof","undefined","initialValue","localStorage","serializer","JSON","stringify","store","useSyncExternalStore","set","useIsomorphicLayoutEffect","Function","remove","isClient","deserializer","parse","error"],"mappings":";kRA+BaA,EAAuB,SAACC,GAA6B,OAChEC,OAAOC,cAAc,IAAIC,aAAa,UAAWH,GAAQ,EAErDI,EAAiB,SAACC,EAAkBC,EAAaC,GACrD,IAAMC,EAAWH,EAAQI,QAAQH,GAEjCD,EAAQK,QAAQJ,EAAKC,GACrBR,EAAqB,CAAEO,IAAAA,EAAKE,SAAAA,EAAUG,SAAUJ,EAAOK,YAAaP,GACtE,EAEMQ,EAAoB,SAACR,EAAkBC,GAC3C,IAAME,EAAWH,EAAQI,QAAQH,GAEjCD,EAAQS,WAAWR,GACnBP,EAAqB,CAAEO,IAAAA,EAAKE,SAAAA,EAAUG,SAAU,KAAMC,YAAaP,GACrE,EAEMU,EAAiB,SAACV,EAAkBC,GACxC,IAAMC,EAAQF,EAAQI,QAAQH,GAC9B,GAAKC,EACL,OAAOA,CACT,EAEMS,EAAmB,SAACC,GAExB,OADAhB,OAAOiB,iBAAiB,UAAWD,GAC5B,WAAA,OAAMhB,OAAOkB,oBAAoB,UAAWF,EAAS,CAC9D,EAEMG,EAAoB,WAAe,EAiB5BC,EAAa,SACxBf,EACAN,GACG,IAAAsB,EACGC,EAA6B,WAAlBC,EAAOxB,GAAsBA,OAASyB,EACjDC,EAAgBH,EAAUA,aAAO,EAAPA,EAASG,aAAe1B,EAElDK,UAAOiB,EAAGC,aAAAA,EAAAA,EAASlB,eAAO,IAAAiB,EAAAA,EAAIrB,OAAO0B,aACrCC,EAAa,SAACrB,GAClB,OAAIgB,SAAAA,EAASK,WAAmBL,EAAQK,WAAWrB,GAC5CsB,KAAKC,UAAUvB,IAkBlBwB,EAAQC,EAAqBhB,GADf,WAAH,OAASD,EAAeV,EAASC,EAAI,GACYc,GAE5Da,EAAM,SAAC1B,GACX,GAAc,OAAVA,EAAgB,OAAOM,EAAkBR,EAASC,GACtDF,EAAeC,EAASC,EAAKsB,EAAWrB,KAG1C2B,GAA0B,gBAEVT,IADAV,EAAeV,EAASC,SACMmB,IAAjBC,GACzBtB,EACEC,EACAC,EACAsB,EAAWF,aAAwBS,SAAWT,IAAiBA,GAGrE,GAAG,CAACpB,IAEJ,IAAM8B,EAAS,WAAH,OAASvB,EAAkBR,EAASC,EAAI,EAEpD,OAAK+B,EAME,CACL9B,MAAOwB,EA1CY,SAACxB,GACpB,GAAIgB,SAAAA,EAASe,aAAc,OAAOf,EAAQe,aAAa/B,GAEvD,GAAc,cAAVA,EAIJ,IACE,OAAOsB,KAAKU,MAAMhC,EACnB,CAAC,MAAOiC,GACP,OAAOjC,CACT,EA+Be+B,CAAaP,QAASN,EACrCQ,IAAAA,EACAG,OAAAA,GARO,CACL7B,MAAOmB,aAAwBS,SAAWT,IAAiBA,EAC3DO,IAAAA,EACAG,OAAAA,EAON"}
|
|
@@ -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 n,useEffect as t}from"react";import{isClient as r}from"../../utils/helpers/isClient.js";import{useRerender as o}from"../useRerender/useRerender.js";var u=function(e){var n,t=null!==(n=e.rangeCount)&&void 0!==n?n:0;return Array.from({length:t},(function(n,t){return e.getRangeAt(t)}))},i=function(){var i,l=o(),c=n(r?document.getSelection():null),a=e(c,2),s=a[0],m=a[1];t((function(){var e=function(){m(document.getSelection()),l.update()};return document.addEventListener("selectionchange",e),function(){return document.removeEventListener("selectionchange",e)}}),[]);var d=null!==(i=null==s?void 0:s.toString())&&void 0!==i?i:"",g=s?u(s):[],f=g.map((function(e){return e.getBoundingClientRect()}));return{text:d,ranges:g,rects:f,selection:s}};export{u as getRangesSelection,i as useTextSelection};
|
|
3
3
|
//# sourceMappingURL=useTextSelection.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"../../utils/helpers/isClient.js";import{getDate as t}from"../../utils/helpers/time/getDate.js";import{useInterval as s}from"../useInterval/useInterval.js";import"../useEvent/useEvent.js";var i=function(){var i=r(t()),o=e(i,2),l=o[0],n=o[1];return s((function(){return n(t())}),1e3),l};export{i as useTime};
|
|
3
3
|
//# sourceMappingURL=useTime.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 e,useRef as t,useEffect as n}from"react";import{useEvent as u}from"../useEvent/useEvent.js";function o(o,c){var i=e(!1),m=r(i,2),a=m[0],f=m[1],l=t(),s=u(o);n((function(){return l.current=setTimeout((function(){s(),f(!0)}),c),function(){clearTimeout(l.current)}}),[c]);return{ready:a,clear:function(){clearTimeout(l.current),f(!0)}}}export{o as useTimeout};
|
|
3
3
|
//# sourceMappingURL=useTimeout.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as r}from"../../_rollupPluginBabelHelpers
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
|
+
import{_ as r}from"../../_rollupPluginBabelHelpers--yEi7JQy.js";import{useReducer as n}from"react";var t=function(){var t=n((function(r,n){var t=n instanceof Function?n(r[0]):n,e=Math.abs(r.indexOf(t));return r.slice(e).concat(r.slice(0,e))}),arguments.length>0&&void 0!==arguments[0]?arguments[0]:[!1,!0]),e=r(t,2);return[r(e[0],1)[0],e[1]]};export{t as useToggle};
|
|
3
3
|
//# sourceMappingURL=useToggle.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,useEffect as n}from"react";var t=function(t){var c=r(t);c.current=t,n((function(){return function(){c.current()}}),[])};export{t as useUnmount};
|
|
3
3
|
//# sourceMappingURL=useUnmount.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{useRef as r,useState as e,useEffect as o}from"react";import{getRetry as t}from"../../utils/helpers/getRetry.js";import"../../utils/helpers/isClient.js";import{useEvent as l}from"../useEvent/useEvent.js";var u=function(u,c){var i=r(),s=r(null!=c&&c.retry?t(c.retry):0),v=r(!1),a=e("connecting"),d=n(a,2),f=d[0],p=d[1],m=l((function(){i.current=new WebSocket("function"==typeof u?u():u,null==c?void 0:c.protocols),p("connecting");var n=i.current;n&&(n.onopen=function(){var r;p("connected"),null==c||null===(r=c.onConnected)||void 0===r||r.call(c,n)},n.onerror=function(r){var e;p("failed"),null==c||null===(e=c.onError)||void 0===e||e.call(c,r,n)},n.onmessage=function(r){var e;return null==c||null===(e=c.onMessage)||void 0===e?void 0:e.call(c,r,n)},n.onclose=function(r){var e;if(p("disconnected"),null==c||null===(e=c.onDisconnected)||void 0===e||e.call(c,r,n),!v.current)return s.current>0?(s.current-=1,m()):void(s.current=null!=c&&c.retry?t(c.retry):0)})}));o((function(){return m(),function(){i.current&&(i.current.close(),i.current=void 0)}}),[u]);return{client:i.current,close:function(){var n;v.current=!0,null===(n=i.current)||void 0===n||n.close()},open:function(){v.current=!1,m()},send:function(n){var r;return null===(r=i.current)||void 0===r?void 0:r.send(n)},status:f}};export{u as useWebSocket};
|
|
3
3
|
//# sourceMappingURL=useWebSocket.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(window,t,r,n)};export{t as useWindowEvent};
|
|
3
3
|
//# sourceMappingURL=useWindowEvent.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 o,useEffect as e}from"react";import{isClient as n}from"../../utils/helpers/isClient.js";var i=function(r){var o=r.x,e=r.y,n=r.behavior,i={behavior:void 0===n?"smooth":n};"number"==typeof o&&(i.left=o),"number"==typeof e&&(i.top=e),window.scrollTo(i)},t=function(){var t=o({x:n?window.scrollX:Number.POSITIVE_INFINITY,y:n?window.scrollY:Number.POSITIVE_INFINITY}),l=r(t,2),s=l[0],w=l[1];return e((function(){var r=function(){return w({x:window.scrollX,y:window.scrollY})};return window.addEventListener("scroll",r),window.addEventListener("resize",r),function(){window.removeEventListener("scroll",r),window.removeEventListener("resize",r)}}),[]),{value:s,scrollTo:i}};export{i as scrollTo,t as useWindowScroll};
|
|
3
3
|
//# sourceMappingURL=useWindowScroll.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 n,useEffect as i}from"react";import{isClient as t}from"../../utils/helpers/isClient.js";var o=function(o){var r,d=null===(r=null==o?void 0:o.includeScrollbar)||void 0===r||r,l=n((function(){return t?{width:d?window.innerWidth:window.document.documentElement.clientWidth,height:d?window.innerHeight:window.document.documentElement.clientHeight}:{width:Number.POSITIVE_INFINITY,height:Number.POSITIVE_INFINITY}})),u=e(l,2),w=u[0],c=u[1];return i((function(){var e=function(){c(d?{width:window.innerWidth,height:window.innerHeight}:{width:window.document.documentElement.clientWidth,height:window.document.documentElement.clientHeight})};return window.addEventListener("resize",e),function(){window.removeEventListener("resize",e)}}),[null==o?void 0:o.includeScrollbar]),w};export{o as useWindowSize};
|
|
3
3
|
//# sourceMappingURL=useWindowSize.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as n,a as o}from"../../_rollupPluginBabelHelpers
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
|
+
import{_ as n,a as o}from"../../_rollupPluginBabelHelpers--yEi7JQy.js";import{useState as t}from"react";var r=function(r,e){var c=null!=e?e:r[0].id,i=new Map(r.map((function(n){return[n.id,n]}))),l=t(c),a=n(l,2),u=a[0],f=a[1],s=t([c]),d=n(s,2),v=d[0],g=d[1];return{currentStepId:u,set:function(n){var t;if(null===(t=i.get(u))||void 0===t||null===(t=t.nodes)||void 0===t||!t.includes(n))throw new Error("Can't go to ".concat(n," from ").concat(u));g([].concat(o(v),[n])),f(n)},reset:function(){f(c),g([c])},back:function(){var n;if(1!==v.length){var o=v[v.length-2];if(null===(n=i.get(u))||void 0===n||null===(n=n.nodes)||void 0===n||!n.includes(o))throw new Error("Can't go to ".concat(o," from ").concat(u));g(v.slice(0,-1)),f(v[v.length-2])}},history:v}};export{r as useWizard};
|
|
3
3
|
//# sourceMappingURL=useWizard.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
2
|
const e=[["requestFullscreen","exitFullscreen","fullscreenElement","fullscreenEnabled","fullscreenchange","fullscreenerror"],["webkitRequestFullscreen","webkitExitFullscreen","webkitFullscreenElement","webkitFullscreenEnabled","webkitfullscreenchange","webkitfullscreenerror"],["webkitRequestFullScreen","webkitCancelFullScreen","webkitCurrentFullScreenElement","webkitCancelFullScreen","webkitfullscreenchange","webkitfullscreenerror"],["mozRequestFullScreen","mozCancelFullScreen","mozFullScreenElement","mozFullScreenEnabled","mozfullscreenchange","mozfullscreenerror"],["msRequestFullscreen","msExitFullscreen","msFullscreenElement","msFullscreenEnabled","MSFullscreenChange","MSFullscreenError"]],n=(()=>{if("undefined"==typeof document)return!1;const n=e[0],l={};for(const r of e){const e=r?.[1];if(e in document){for(const[e,c]of r.entries())l[n[e]]=c;return l}}return!1})(),l={change:n.fullscreenchange,error:n.fullscreenerror};let r={request:(e=document.documentElement,l)=>new Promise(((c,t)=>{const s=()=>{r.off("change",s),c()};r.on("change",s);const o=e[n.requestFullscreen](l);o instanceof Promise&&o.then(s).catch(t)})),exit:()=>new Promise(((e,l)=>{if(!r.isFullscreen)return void e();const c=()=>{r.off("change",c),e()};r.on("change",c);const t=document[n.exitFullscreen]();t instanceof Promise&&t.then(c).catch(l)})),toggle:(e,n)=>r.isFullscreen?r.exit():r.request(e,n),onchange(e){r.on("change",e)},onerror(e){r.on("error",e)},on(e,n){const r=l[e];r&&document.addEventListener(r,n,!1)},off(e,n){const r=l[e];r&&document.removeEventListener(r,n,!1)},raw:n};Object.defineProperties(r,{isFullscreen:{get:()=>Boolean(document[n.fullscreenElement])},element:{enumerable:!0,get:()=>document[n.fullscreenElement]??void 0},isEnabled:{enumerable:!0,get:()=>Boolean(document[n.fullscreenEnabled])}}),n||(r={isEnabled:!1});var c=r;export{c as s};
|
|
3
|
-
//# sourceMappingURL=index-
|
|
3
|
+
//# sourceMappingURL=index-5OKmysyE.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-5OKmysyE.js","sources":["../../node_modules/screenfull/index.js"],"sourcesContent":["/* eslint-disable promise/prefer-await-to-then */\n\nconst methodMap = [\n\t[\n\t\t'requestFullscreen',\n\t\t'exitFullscreen',\n\t\t'fullscreenElement',\n\t\t'fullscreenEnabled',\n\t\t'fullscreenchange',\n\t\t'fullscreenerror',\n\t],\n\t// New WebKit\n\t[\n\t\t'webkitRequestFullscreen',\n\t\t'webkitExitFullscreen',\n\t\t'webkitFullscreenElement',\n\t\t'webkitFullscreenEnabled',\n\t\t'webkitfullscreenchange',\n\t\t'webkitfullscreenerror',\n\n\t],\n\t// Old WebKit\n\t[\n\t\t'webkitRequestFullScreen',\n\t\t'webkitCancelFullScreen',\n\t\t'webkitCurrentFullScreenElement',\n\t\t'webkitCancelFullScreen',\n\t\t'webkitfullscreenchange',\n\t\t'webkitfullscreenerror',\n\n\t],\n\t[\n\t\t'mozRequestFullScreen',\n\t\t'mozCancelFullScreen',\n\t\t'mozFullScreenElement',\n\t\t'mozFullScreenEnabled',\n\t\t'mozfullscreenchange',\n\t\t'mozfullscreenerror',\n\t],\n\t[\n\t\t'msRequestFullscreen',\n\t\t'msExitFullscreen',\n\t\t'msFullscreenElement',\n\t\t'msFullscreenEnabled',\n\t\t'MSFullscreenChange',\n\t\t'MSFullscreenError',\n\t],\n];\n\nconst nativeAPI = (() => {\n\tif (typeof document === 'undefined') {\n\t\treturn false;\n\t}\n\n\tconst unprefixedMethods = methodMap[0];\n\tconst returnValue = {};\n\n\tfor (const methodList of methodMap) {\n\t\tconst exitFullscreenMethod = methodList?.[1];\n\t\tif (exitFullscreenMethod in document) {\n\t\t\tfor (const [index, method] of methodList.entries()) {\n\t\t\t\treturnValue[unprefixedMethods[index]] = method;\n\t\t\t}\n\n\t\t\treturn returnValue;\n\t\t}\n\t}\n\n\treturn false;\n})();\n\nconst eventNameMap = {\n\tchange: nativeAPI.fullscreenchange,\n\terror: nativeAPI.fullscreenerror,\n};\n\n// eslint-disable-next-line import/no-mutable-exports\nlet screenfull = {\n\t// eslint-disable-next-line default-param-last\n\trequest(element = document.documentElement, options) {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tconst onFullScreenEntered = () => {\n\t\t\t\tscreenfull.off('change', onFullScreenEntered);\n\t\t\t\tresolve();\n\t\t\t};\n\n\t\t\tscreenfull.on('change', onFullScreenEntered);\n\n\t\t\tconst returnPromise = element[nativeAPI.requestFullscreen](options);\n\n\t\t\tif (returnPromise instanceof Promise) {\n\t\t\t\treturnPromise.then(onFullScreenEntered).catch(reject);\n\t\t\t}\n\t\t});\n\t},\n\texit() {\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tif (!screenfull.isFullscreen) {\n\t\t\t\tresolve();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst onFullScreenExit = () => {\n\t\t\t\tscreenfull.off('change', onFullScreenExit);\n\t\t\t\tresolve();\n\t\t\t};\n\n\t\t\tscreenfull.on('change', onFullScreenExit);\n\n\t\t\tconst returnPromise = document[nativeAPI.exitFullscreen]();\n\n\t\t\tif (returnPromise instanceof Promise) {\n\t\t\t\treturnPromise.then(onFullScreenExit).catch(reject);\n\t\t\t}\n\t\t});\n\t},\n\ttoggle(element, options) {\n\t\treturn screenfull.isFullscreen ? screenfull.exit() : screenfull.request(element, options);\n\t},\n\tonchange(callback) {\n\t\tscreenfull.on('change', callback);\n\t},\n\tonerror(callback) {\n\t\tscreenfull.on('error', callback);\n\t},\n\ton(event, callback) {\n\t\tconst eventName = eventNameMap[event];\n\t\tif (eventName) {\n\t\t\tdocument.addEventListener(eventName, callback, false);\n\t\t}\n\t},\n\toff(event, callback) {\n\t\tconst eventName = eventNameMap[event];\n\t\tif (eventName) {\n\t\t\tdocument.removeEventListener(eventName, callback, false);\n\t\t}\n\t},\n\traw: nativeAPI,\n};\n\nObject.defineProperties(screenfull, {\n\tisFullscreen: {\n\t\tget: () => Boolean(document[nativeAPI.fullscreenElement]),\n\t},\n\telement: {\n\t\tenumerable: true,\n\t\tget: () => document[nativeAPI.fullscreenElement] ?? undefined,\n\t},\n\tisEnabled: {\n\t\tenumerable: true,\n\t\t// Coerce to boolean in case of old WebKit.\n\t\tget: () => Boolean(document[nativeAPI.fullscreenEnabled]),\n\t},\n});\n\nif (!nativeAPI) {\n\tscreenfull = {isEnabled: false};\n}\n\nexport default screenfull;\n"],"names":["methodMap","nativeAPI","document","unprefixedMethods","returnValue","methodList","exitFullscreenMethod","index","method","entries","eventNameMap","change","fullscreenchange","error","fullscreenerror","screenfull","request","element","documentElement","options","Promise","resolve","reject","onFullScreenEntered","off","on","returnPromise","requestFullscreen","then","catch","exit","isFullscreen","onFullScreenExit","exitFullscreen","toggle","onchange","callback","onerror","event","eventName","addEventListener","removeEventListener","raw","Object","defineProperties","get","Boolean","fullscreenElement","enumerable","undefined","isEnabled","fullscreenEnabled","screenfull$1"],"mappings":";AAEA,MAAMA,EAAY,CACjB,CACC,oBACA,iBACA,oBACA,oBACA,mBACA,mBAGD,CACC,0BACA,uBACA,0BACA,0BACA,yBACA,yBAID,CACC,0BACA,yBACA,iCACA,yBACA,yBACA,yBAGD,CACC,uBACA,sBACA,uBACA,uBACA,sBACA,sBAED,CACC,sBACA,mBACA,sBACA,sBACA,qBACA,sBAIIC,EAAY,MACjB,GAAwB,oBAAbC,SACV,OAAO,EAGR,MAAMC,EAAoBH,EAAU,GAC9BI,EAAc,CAAA,EAEpB,IAAK,MAAMC,KAAcL,EAAW,CACnC,MAAMM,EAAuBD,IAAa,GAC1C,GAAIC,KAAwBJ,SAAU,CACrC,IAAK,MAAOK,EAAOC,KAAWH,EAAWI,UACxCL,EAAYD,EAAkBI,IAAUC,EAGzC,OAAOJ,CACP,CACD,CAED,OAAO,CACP,EApBiB,GAsBZM,EAAe,CACpBC,OAAQV,EAAUW,iBAClBC,MAAOZ,EAAUa,iBAIlB,IAAIC,EAAa,CAEhBC,QAAO,CAACC,EAAUf,SAASgB,gBAAiBC,IACpC,IAAIC,SAAQ,CAACC,EAASC,KAC5B,MAAMC,EAAsB,KAC3BR,EAAWS,IAAI,SAAUD,GACzBF,GAAS,EAGVN,EAAWU,GAAG,SAAUF,GAExB,MAAMG,EAAgBT,EAAQhB,EAAU0B,mBAAmBR,GAEvDO,aAAyBN,SAC5BM,EAAcE,KAAKL,GAAqBM,MAAMP,EAC9C,IAGHQ,KAAI,IACI,IAAIV,SAAQ,CAACC,EAASC,KAC5B,IAAKP,EAAWgB,aAEf,YADAV,IAID,MAAMW,EAAmB,KACxBjB,EAAWS,IAAI,SAAUQ,GACzBX,GAAS,EAGVN,EAAWU,GAAG,SAAUO,GAExB,MAAMN,EAAgBxB,SAASD,EAAUgC,kBAErCP,aAAyBN,SAC5BM,EAAcE,KAAKI,GAAkBH,MAAMP,EAC3C,IAGHY,OAAM,CAACjB,EAASE,IACRJ,EAAWgB,aAAehB,EAAWe,OAASf,EAAWC,QAAQC,EAASE,GAElF,QAAAgB,CAASC,GACRrB,EAAWU,GAAG,SAAUW,EACxB,EACD,OAAAC,CAAQD,GACPrB,EAAWU,GAAG,QAASW,EACvB,EACD,EAAAX,CAAGa,EAAOF,GACT,MAAMG,EAAY7B,EAAa4B,GAC3BC,GACHrC,SAASsC,iBAAiBD,EAAWH,GAAU,EAEhD,EACD,GAAAZ,CAAIc,EAAOF,GACV,MAAMG,EAAY7B,EAAa4B,GAC3BC,GACHrC,SAASuC,oBAAoBF,EAAWH,GAAU,EAEnD,EACDM,IAAKzC,GAGN0C,OAAOC,iBAAiB7B,EAAY,CACnCgB,aAAc,CACbc,IAAK,IAAMC,QAAQ5C,SAASD,EAAU8C,qBAEvC9B,QAAS,CACR+B,YAAY,EACZH,IAAK,IAAM3C,SAASD,EAAU8C,yBAAsBE,GAErDC,UAAW,CACVF,YAAY,EAEZH,IAAK,IAAMC,QAAQ5C,SAASD,EAAUkD,uBAInClD,IACJc,EAAa,CAACmC,WAAW,IAG1B,IAAAE,EAAerC","x_google_ignoreList":[0]}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
export{useBattery}from"./hooks/useBattery/useBattery.js";export{useBoolean}from"./hooks/useBoolean/useBoolean.js";export{useBreakpoints}from"./hooks/useBreakpoints/useBreakpoints.js";export{useBrowserLanguage}from"./hooks/useBrowserLanguage/useBrowserLanguage.js";export{useClickOutside}from"./hooks/useClickOutside/useClickOutside.js";export{useClipboard}from"./hooks/useClipboard/useClipboard.js";export{useCounter}from"./hooks/useCounter/useCounter.js";export{useDebounceCallback}from"./hooks/useDebounceCallback/useDebounceCallback.js";export{useDebounceValue}from"./hooks/useDebounceValue/useDebounceValue.js";export{useDefault}from"./hooks/useDefault/useDefault.js";export{useDidUpdate}from"./hooks/useDidUpdate/useDidUpdate.js";export{useDisclosure}from"./hooks/useDisclosure/useDisclosure.js";export{useDocumentEvent}from"./hooks/useDocumentEvent/useDocumentEvent.js";export{useDocumentTitle}from"./hooks/useDocumentTitle/useDocumentTitle.js";export{useDocumentVisibility}from"./hooks/useDocumentVisibility/useDocumentVisibility.js";export{useEvent}from"./hooks/useEvent/useEvent.js";export{useEventListener}from"./hooks/useEventListener/useEventListener.js";export{useEyeDropper}from"./hooks/useEyeDropper/useEyeDropper.js";export{useFavicon}from"./hooks/useFavicon/useFavicon.js";export{useField}from"./hooks/useField/useField.js";export{useFileDialog}from"./hooks/useFileDialog/useFileDialog.js";export{useFps}from"./hooks/useFps/useFps.js";export{useFullscreen}from"./hooks/useFullscreen/useFullscreen.js";export{useGeolocation}from"./hooks/useGeolocation/useGeolocation.js";export{useHash}from"./hooks/useHash/useHash.js";export{useHotkeys}from"./hooks/useHotkeys/useHotkeys.js";export{useHover}from"./hooks/useHover/useHover.js";export{useIdle}from"./hooks/useIdle/useIdle.js";export{useImage}from"./hooks/useImage/useImage.js";export{useInfiniteScroll}from"./hooks/useInfiniteScroll/useInfiniteScroll.js";export{useIntersectionObserver}from"./hooks/useIntersectionObserver/useIntersectionObserver.js";export{useInterval}from"./hooks/useInterval/useInterval.js";export{useIsFirstRender}from"./hooks/useIsFirstRender/useIsFirstRender.js";export{useIsomorphicLayoutEffect}from"./hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js";export{useKeyboard}from"./hooks/useKeyboard/useKeyboard.js";export{useKeyPress}from"./hooks/useKeyPress/useKeyPress.js";export{useKeyPressEvent}from"./hooks/useKeyPressEvent/useKeyPressEvent.js";export{useKeysPressed}from"./hooks/useKeysPressed/useKeysPressed.js";export{useList}from"./hooks/useList/useList.js";export{useLocalStorage}from"./hooks/useLocalStorage/useLocalStorage.js";export{useLogger}from"./hooks/useLogger/useLogger.js";export{useLongPress}from"./hooks/useLongPress/useLongPress.js";export{useMap}from"./hooks/useMap/useMap.js";export{useMeasure}from"./hooks/useMeasure/useMeasure.js";export{useMediaQuery}from"./hooks/useMediaQuery/useMediaQuery.js";export{useMemory}from"./hooks/useMemory/useMemory.js";export{useMount}from"./hooks/useMount/useMount.js";export{useMouse}from"./hooks/useMouse/useMouse.js";export{useMutation}from"./hooks/useMutation/useMutation.js";export{useNetwork}from"./hooks/useNetwork/useNetwork.js";export{useOnline}from"./hooks/useOnline/useOnline.js";export{useOperatingSystem}from"./hooks/useOperatingSystem/useOperatingSystem.js";export{useOrientation}from"./hooks/useOrientation/useOrientation.js";export{usePageLeave}from"./hooks/usePageLeave/usePageLeave.js";export{usePaint}from"./hooks/usePaint/usePaint.js";export{usePermission}from"./hooks/usePermission/usePermission.js";export{usePreferredColorScheme}from"./hooks/usePreferredColorScheme/usePreferredColorScheme.js";export{usePreferredContrast}from"./hooks/usePreferredContrast/usePreferredContrast.js";export{usePreferredDark}from"./hooks/usePreferredDark/usePreferredDark.js";export{usePreferredLanguages}from"./hooks/usePreferredLanguages/usePreferredLanguages.js";export{usePreferredReducedMotion}from"./hooks/usePreferredReducedMotion/usePreferredReducedMotion.js";export{usePrevious}from"./hooks/usePrevious/usePrevious.js";export{useQuery}from"./hooks/useQuery/useQuery.js";export{useQueue}from"./hooks/useQueue/useQueue.js";export{useRenderCount}from"./hooks/useRenderCount/useRenderCount.js";export{useRenderInfo}from"./hooks/useRenderInfo/useRenderInfo.js";export{useRerender}from"./hooks/useRerender/useRerender.js";export{useResizeObserver}from"./hooks/useResizeObserver/useResizeObserver.js";export{useScript}from"./hooks/useScript/useScript.js";export{useSessionStorage}from"./hooks/useSessionStorage/useSessionStorage.js";export{useSet}from"./hooks/useSet/useSet.js";export{useShare}from"./hooks/useShare/useShare.js";export{useStep}from"./hooks/useStep/useStep.js";export{useStopwatch}from"./hooks/useStopwatch/useStopwatch.js";export{useStorage}from"./hooks/useStorage/useStorage.js";export{useTextSelection}from"./hooks/useTextSelection/useTextSelection.js";export{useTime}from"./hooks/useTime/useTime.js";export{useTimeout}from"./hooks/useTimeout/useTimeout.js";export{useToggle}from"./hooks/useToggle/useToggle.js";export{useUnmount}from"./hooks/useUnmount/useUnmount.js";export{useWebSocket}from"./hooks/useWebSocket/useWebSocket.js";export{useWindowEvent}from"./hooks/useWindowEvent/useWindowEvent.js";export{useWindowSize}from"./hooks/useWindowSize/useWindowSize.js";export{useWizard}from"./hooks/useWizard/useWizard.js";export{debounce}from"./utils/helpers/debounce.js";export{getRetry}from"./utils/helpers/getRetry.js";export{isClient}from"./utils/helpers/isClient.js";export{isPermissionAllowed}from"./utils/helpers/isPermissionAllowed.js";export{throttle}from"./utils/helpers/throttle.js";export{getDate}from"./utils/helpers/time/getDate.js";import"./_rollupPluginBabelHelpers
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
|
+
export{useAsync}from"./hooks/useAsync/useAsync.js";export{useBattery}from"./hooks/useBattery/useBattery.js";export{useBoolean}from"./hooks/useBoolean/useBoolean.js";export{useBreakpoints}from"./hooks/useBreakpoints/useBreakpoints.js";export{useBrowserLanguage}from"./hooks/useBrowserLanguage/useBrowserLanguage.js";export{useClickOutside}from"./hooks/useClickOutside/useClickOutside.js";export{useClipboard}from"./hooks/useClipboard/useClipboard.js";export{useCounter}from"./hooks/useCounter/useCounter.js";export{useDebounceCallback}from"./hooks/useDebounceCallback/useDebounceCallback.js";export{useDebounceValue}from"./hooks/useDebounceValue/useDebounceValue.js";export{useDefault}from"./hooks/useDefault/useDefault.js";export{useDidUpdate}from"./hooks/useDidUpdate/useDidUpdate.js";export{useDisclosure}from"./hooks/useDisclosure/useDisclosure.js";export{useDocumentEvent}from"./hooks/useDocumentEvent/useDocumentEvent.js";export{useDocumentTitle}from"./hooks/useDocumentTitle/useDocumentTitle.js";export{useDocumentVisibility}from"./hooks/useDocumentVisibility/useDocumentVisibility.js";export{useEvent}from"./hooks/useEvent/useEvent.js";export{useEventListener}from"./hooks/useEventListener/useEventListener.js";export{useEyeDropper}from"./hooks/useEyeDropper/useEyeDropper.js";export{useFavicon}from"./hooks/useFavicon/useFavicon.js";export{useField}from"./hooks/useField/useField.js";export{useFileDialog}from"./hooks/useFileDialog/useFileDialog.js";export{useFps}from"./hooks/useFps/useFps.js";export{useFullscreen}from"./hooks/useFullscreen/useFullscreen.js";export{useGeolocation}from"./hooks/useGeolocation/useGeolocation.js";export{useHash}from"./hooks/useHash/useHash.js";export{useHotkeys}from"./hooks/useHotkeys/useHotkeys.js";export{useHover}from"./hooks/useHover/useHover.js";export{useIdle}from"./hooks/useIdle/useIdle.js";export{useImage}from"./hooks/useImage/useImage.js";export{useInfiniteScroll}from"./hooks/useInfiniteScroll/useInfiniteScroll.js";export{useIntersectionObserver}from"./hooks/useIntersectionObserver/useIntersectionObserver.js";export{useInterval}from"./hooks/useInterval/useInterval.js";export{useIsFirstRender}from"./hooks/useIsFirstRender/useIsFirstRender.js";export{useIsomorphicLayoutEffect}from"./hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js";export{useKeyboard}from"./hooks/useKeyboard/useKeyboard.js";export{useKeyPress}from"./hooks/useKeyPress/useKeyPress.js";export{useKeyPressEvent}from"./hooks/useKeyPressEvent/useKeyPressEvent.js";export{useKeysPressed}from"./hooks/useKeysPressed/useKeysPressed.js";export{useList}from"./hooks/useList/useList.js";export{useLocalStorage}from"./hooks/useLocalStorage/useLocalStorage.js";export{useLogger}from"./hooks/useLogger/useLogger.js";export{useLongPress}from"./hooks/useLongPress/useLongPress.js";export{useMap}from"./hooks/useMap/useMap.js";export{useMeasure}from"./hooks/useMeasure/useMeasure.js";export{useMediaQuery}from"./hooks/useMediaQuery/useMediaQuery.js";export{useMemory}from"./hooks/useMemory/useMemory.js";export{useMount}from"./hooks/useMount/useMount.js";export{useMouse}from"./hooks/useMouse/useMouse.js";export{useMutation}from"./hooks/useMutation/useMutation.js";export{useNetwork}from"./hooks/useNetwork/useNetwork.js";export{useOnline}from"./hooks/useOnline/useOnline.js";export{useOperatingSystem}from"./hooks/useOperatingSystem/useOperatingSystem.js";export{useOrientation}from"./hooks/useOrientation/useOrientation.js";export{usePageLeave}from"./hooks/usePageLeave/usePageLeave.js";export{usePaint}from"./hooks/usePaint/usePaint.js";export{usePermission}from"./hooks/usePermission/usePermission.js";export{usePreferredColorScheme}from"./hooks/usePreferredColorScheme/usePreferredColorScheme.js";export{usePreferredContrast}from"./hooks/usePreferredContrast/usePreferredContrast.js";export{usePreferredDark}from"./hooks/usePreferredDark/usePreferredDark.js";export{usePreferredLanguages}from"./hooks/usePreferredLanguages/usePreferredLanguages.js";export{usePreferredReducedMotion}from"./hooks/usePreferredReducedMotion/usePreferredReducedMotion.js";export{usePrevious}from"./hooks/usePrevious/usePrevious.js";export{useQuery}from"./hooks/useQuery/useQuery.js";export{useQueue}from"./hooks/useQueue/useQueue.js";export{useRenderCount}from"./hooks/useRenderCount/useRenderCount.js";export{useRenderInfo}from"./hooks/useRenderInfo/useRenderInfo.js";export{useRerender}from"./hooks/useRerender/useRerender.js";export{useResizeObserver}from"./hooks/useResizeObserver/useResizeObserver.js";export{useScript}from"./hooks/useScript/useScript.js";export{useSessionStorage}from"./hooks/useSessionStorage/useSessionStorage.js";export{useSet}from"./hooks/useSet/useSet.js";export{useShare}from"./hooks/useShare/useShare.js";export{useStep}from"./hooks/useStep/useStep.js";export{useStopwatch}from"./hooks/useStopwatch/useStopwatch.js";export{useStorage}from"./hooks/useStorage/useStorage.js";export{useTextSelection}from"./hooks/useTextSelection/useTextSelection.js";export{useTime}from"./hooks/useTime/useTime.js";export{useTimeout}from"./hooks/useTimeout/useTimeout.js";export{useToggle}from"./hooks/useToggle/useToggle.js";export{useUnmount}from"./hooks/useUnmount/useUnmount.js";export{useWebSocket}from"./hooks/useWebSocket/useWebSocket.js";export{useWindowEvent}from"./hooks/useWindowEvent/useWindowEvent.js";export{useWindowSize}from"./hooks/useWindowSize/useWindowSize.js";export{useWizard}from"./hooks/useWizard/useWizard.js";export{debounce}from"./utils/helpers/debounce.js";export{getRetry}from"./utils/helpers/getRetry.js";export{isClient}from"./utils/helpers/isClient.js";export{isPermissionAllowed}from"./utils/helpers/isPermissionAllowed.js";export{throttle}from"./utils/helpers/throttle.js";export{getDate}from"./utils/helpers/time/getDate.js";import"./_rollupPluginBabelHelpers--yEi7JQy.js";import"react";import"./hooks/useBreakpoints/constants/breakpoints.js";import"./hooks/useMutationObserver.js";import"./index-5OKmysyE.js";import"./hooks/usePaint/helpers/Paint.js";import"./hooks/usePaint/helpers/Pointer.js";import"react-dom";
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
2
|
var r=function(r,n){var t;return function(){for(var e=arguments.length,o=new Array(e),u=0;u<e;u++)o[u]=arguments[u];clearTimeout(t),t=setTimeout((function(){return r.apply(void 0,o)}),n)}};export{r as debounce};
|
|
3
3
|
//# sourceMappingURL=debounce.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRetry.js","sources":["../../../../src/utils/helpers/getRetry.ts"],"sourcesContent":["export const getRetry = (retry: number | boolean) => {\n if (typeof retry === 'number')
|
|
1
|
+
{"version":3,"file":"getRetry.js","sources":["../../../../src/utils/helpers/getRetry.ts"],"sourcesContent":["export const getRetry = (retry: number | boolean) => {\n if (typeof retry === 'number') return retry;\n return retry ? 1 : 0;\n};\n"],"names":["getRetry","retry"],"mappings":";IAAaA,EAAW,SAACC,GACvB,MAAqB,iBAAVA,EAA2BA,EAC/BA,EAAQ,EAAI,CACrB"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
2
|
export{debounce}from"./debounce.js";export{getRetry}from"./getRetry.js";export{isClient}from"./isClient.js";export{isPermissionAllowed}from"./isPermissionAllowed.js";export{throttle}from"./throttle.js";export{getDate}from"./time/getDate.js";
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
2
|
var n,d,e=!("undefined"==typeof window||null===(n=window)||void 0===n||!n.document||null===(d=window)||void 0===d||null===(d=d.document)||void 0===d||!d.createElement);export{e as isClient};
|
|
3
3
|
//# sourceMappingURL=isClient.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
2
|
var n=function(n,t){var o=!1;return function(){o||(n.apply(void 0,arguments),o=!0,setTimeout((function(){o=!1}),t))}};export{n as throttle};
|
|
3
3
|
//# sourceMappingURL=throttle.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
2
|
var e=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Date,t=e.getSeconds(),n=e.getMinutes(),r=e.getHours();return{seconds:t,minutes:n,hours:r,meridiemHours:{value:r%12==0?12:r%12,type:r>=12?"pm":"am"},day:e.getDate(),month:e.getMonth()+1,year:e.getFullYear(),timestamp:e.getTime()}};export{e as getDate};
|
|
3
3
|
//# sourceMappingURL=getDate.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.55 */
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,26 @@
|
|
|
1
|
-
import { BatteryManager, EyeDropperConstructor, ColorSelectionOptions, ColorSelectionResult, Connection } from '@/utils/types';
|
|
2
1
|
import * as react from 'react';
|
|
3
|
-
import { RefObject, Dispatch, SetStateAction, EffectCallback,
|
|
2
|
+
import { DependencyList, RefObject, Dispatch, SetStateAction, EffectCallback, ComponentProps, useEffect } from 'react';
|
|
3
|
+
import { BatteryManager, EyeDropperConstructor, ColorSelectionOptions, ColorSelectionResult, Connection } from '@/utils/types';
|
|
4
|
+
|
|
5
|
+
interface UseAsyncReturn<Data> {
|
|
6
|
+
data?: Data;
|
|
7
|
+
isLoading: boolean;
|
|
8
|
+
isError: boolean;
|
|
9
|
+
error?: Error;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* @name useAsync
|
|
13
|
+
* @description - Hook that provides the state of an async callback
|
|
14
|
+
* @category Utilities
|
|
15
|
+
*
|
|
16
|
+
* @param {() => Promise<Data>} callback - The async callback
|
|
17
|
+
* @param {DependencyList} [deps] - The dependencies of the callback
|
|
18
|
+
* @returns {UseAsyncReturn<Data>} - The state of the async callback
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* const { data, isLoading, isError, error } = useAsync(() => fetch('url'), [deps]);
|
|
22
|
+
*/
|
|
23
|
+
declare const useAsync: <Data>(callback: () => Promise<Data>, deps?: DependencyList) => UseAsyncReturn<Data>;
|
|
4
24
|
|
|
5
25
|
declare global {
|
|
6
26
|
interface Navigator {
|
|
@@ -178,7 +198,7 @@ interface UseCounterOptions {
|
|
|
178
198
|
/** The use counter return type */
|
|
179
199
|
interface UseCounterReturn {
|
|
180
200
|
/** The current count value */
|
|
181
|
-
|
|
201
|
+
value: number;
|
|
182
202
|
/** Function to set a specific value to the counter */
|
|
183
203
|
set: Dispatch<SetStateAction<number>>;
|
|
184
204
|
/** Function to reset the counter to its initial value. */
|
|
@@ -838,7 +858,7 @@ interface UseQueryReturn<Data> {
|
|
|
838
858
|
* @returns {UseQueryReturn<Data>} An object with the state of the query
|
|
839
859
|
*
|
|
840
860
|
* @example
|
|
841
|
-
* const { data, isLoading, isError, isSuccess, error, refetch, isRefetching } = useQuery(() => fetch('
|
|
861
|
+
* const { data, isLoading, isError, isSuccess, error, refetch, isRefetching } = useQuery(() => fetch('url'));
|
|
842
862
|
*/
|
|
843
863
|
declare const useQuery: <QueryData, Data = QueryData>(callback: () => Promise<QueryData>, options?: UseQueryOptions<QueryData, Data>) => UseQueryReturn<Data>;
|
|
844
864
|
|
|
@@ -1405,15 +1425,16 @@ type UseMouse = {
|
|
|
1405
1425
|
declare const useMouse: UseMouse;
|
|
1406
1426
|
|
|
1407
1427
|
interface UseMutationOptions<Data> {
|
|
1408
|
-
retry?: boolean | number;
|
|
1428
|
+
retry?: boolean | number | ((failureCount: number, error: Error) => boolean);
|
|
1429
|
+
retryDelay?: number | ((retry: number, error: Error) => number);
|
|
1409
1430
|
onSuccess?: (data: Data) => void;
|
|
1410
1431
|
onError?: (error: Error) => void;
|
|
1411
1432
|
}
|
|
1412
1433
|
interface UseMutationReturn<Body, Data> {
|
|
1413
1434
|
data: Data | null;
|
|
1414
1435
|
error: Error | null;
|
|
1415
|
-
mutate: (body: Body) => void;
|
|
1416
|
-
mutateAsync: (body: Body) => Promise<Data>;
|
|
1436
|
+
mutate: (body: Body, options?: UseMutationOptions<Data>) => void;
|
|
1437
|
+
mutateAsync: (body: Body, options?: UseMutationOptions<Data>) => Promise<Data>;
|
|
1417
1438
|
isLoading: boolean;
|
|
1418
1439
|
isError: boolean;
|
|
1419
1440
|
isSuccess: boolean;
|
|
@@ -2305,4 +2326,4 @@ declare const getDate: (now?: Date) => {
|
|
|
2305
2326
|
timestamp: number;
|
|
2306
2327
|
};
|
|
2307
2328
|
|
|
2308
|
-
export { debounce, getDate, getRetry, isClient, isPermissionAllowed, throttle, useBattery, useBoolean, useBreakpoints, useBrowserLanguage, useClickOutside, useClipboard, useCounter, useDebounceCallback, useDebounceValue, useDefault, useDidUpdate, useDisclosure, useDocumentEvent, useDocumentTitle, useDocumentVisibility, useEvent, useEventListener, useEyeDropper, useFavicon, useField, useFileDialog, useFps, useFullscreen, useGeolocation, useHash, useHotkeys, useHover, useIdle, useImage, useInfiniteScroll, useIntersectionObserver, useInterval, useIsFirstRender, useIsomorphicLayoutEffect, useKeyPress, useKeyPressEvent, useKeyboard, useKeysPressed, useList, useLocalStorage, useLogger, useLongPress, useMap, useMeasure, useMediaQuery, useMemory, useMount, useMouse, useMutation, useNetwork, useOnline, useOperatingSystem, useOrientation, usePageLeave, usePaint, usePermission, usePreferredColorScheme, usePreferredContrast, usePreferredDark, usePreferredLanguages, usePreferredReducedMotion, usePrevious, useQuery, useQueue, useRenderCount, useRenderInfo, useRerender, useResizeObserver, useScript, useSessionStorage, useSet, useShare, useStep, useStopwatch, useStorage, useTextSelection, useTime, useTimeout, useToggle, useUnmount, useWebSocket, useWindowEvent, useWindowSize, useWizard };
|
|
2329
|
+
export { debounce, getDate, getRetry, isClient, isPermissionAllowed, throttle, useAsync, useBattery, useBoolean, useBreakpoints, useBrowserLanguage, useClickOutside, useClipboard, useCounter, useDebounceCallback, useDebounceValue, useDefault, useDidUpdate, useDisclosure, useDocumentEvent, useDocumentTitle, useDocumentVisibility, useEvent, useEventListener, useEyeDropper, useFavicon, useField, useFileDialog, useFps, useFullscreen, useGeolocation, useHash, useHotkeys, useHover, useIdle, useImage, useInfiniteScroll, useIntersectionObserver, useInterval, useIsFirstRender, useIsomorphicLayoutEffect, useKeyPress, useKeyPressEvent, useKeyboard, useKeysPressed, useList, useLocalStorage, useLogger, useLongPress, useMap, useMeasure, useMediaQuery, useMemory, useMount, useMouse, useMutation, useNetwork, useOnline, useOperatingSystem, useOrientation, usePageLeave, usePaint, usePermission, usePreferredColorScheme, usePreferredContrast, usePreferredDark, usePreferredLanguages, usePreferredReducedMotion, usePrevious, useQuery, useQueue, useRenderCount, useRenderInfo, useRerender, useResizeObserver, useScript, useSessionStorage, useSet, useShare, useStep, useStopwatch, useStorage, useTextSelection, useTime, useTimeout, useToggle, useUnmount, useWebSocket, useWindowEvent, useWindowSize, useWizard };
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_rollupPluginBabelHelpers-s0b9uPmg.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_rollupPluginBabelHelpers-0IYrm-Ud.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|