@siberiacancode/reactuse 0.0.19 → 0.0.21
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-OWhzq4gx.js → _rollupPluginBabelHelpers-BZYFJ5Fo.js} +2 -2
- package/dist/cjs/_rollupPluginBabelHelpers-BZYFJ5Fo.js.map +1 -0
- package/dist/cjs/hooks/index.js +2 -2
- package/dist/cjs/hooks/useBattery/useBattery.js +2 -2
- package/dist/cjs/hooks/useBoolean/useBoolean.js +2 -2
- package/dist/cjs/hooks/useClickOutside/useClickOutside.js +1 -1
- package/dist/cjs/hooks/useCopyToClipboard/useCopyToClipboard.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/useDebouncedValue/useDebouncedValue.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/useDocumentTitle/useDocumentTitle.js +2 -2
- package/dist/cjs/hooks/useDocumentTitle/useDocumentTitle.js.map +1 -1
- 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 +2 -2
- package/dist/cjs/hooks/useEventListener/useEventListener.js.map +1 -1
- package/dist/cjs/hooks/useFavicon/useFavicon.js +2 -2
- package/dist/cjs/hooks/useFullscreen/useFullscreen.js +2 -2
- package/dist/cjs/hooks/useFullscreen/useFullscreen.js.map +1 -1
- package/dist/cjs/hooks/useHash/useHash.js +2 -2
- package/dist/cjs/hooks/useHotkeys/useHotkeys.js +2 -2
- package/dist/cjs/hooks/useHotkeys/useHotkeys.js.map +1 -1
- package/dist/cjs/hooks/useHover/useHover.js +2 -2
- package/dist/cjs/hooks/useHover/useHover.js.map +1 -1
- package/dist/cjs/hooks/useIdle/useIdle.js +2 -2
- package/dist/cjs/hooks/useIntersectionObserver/useIntersectionObserver.js +2 -2
- package/dist/cjs/hooks/useIntersectionObserver/useIntersectionObserver.js.map +1 -1
- package/dist/cjs/hooks/useInterval/useInterval.js +3 -0
- package/dist/cjs/hooks/useInterval/useInterval.js.map +1 -0
- package/dist/cjs/hooks/useIsFirstRender/useIsFirstRender.js +1 -1
- package/dist/cjs/hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js +1 -1
- package/dist/cjs/hooks/useKeyPress/useKeyPress.js +2 -2
- package/dist/cjs/hooks/useKeyPress/useKeyPress.js.map +1 -1
- package/dist/cjs/hooks/useKeyPressEvent/useKeyPressEvent.js +1 -1
- package/dist/cjs/hooks/useKeyboard/useKeyboard.js +3 -0
- package/dist/cjs/hooks/useKeyboard/useKeyboard.js.map +1 -0
- 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/useLogger/useLogger.js +2 -2
- package/dist/cjs/hooks/useLongPress/useLongPress.js +3 -0
- package/dist/cjs/hooks/useLongPress/useLongPress.js.map +1 -0
- package/dist/cjs/hooks/useMediaQuery/useMediaQuery.js +1 -1
- 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 +3 -0
- package/dist/cjs/hooks/useMutation/useMutation.js.map +1 -0
- 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 +1 -1
- package/dist/cjs/hooks/usePreferredLanguages/usePreferredLanguages.js +1 -1
- package/dist/cjs/hooks/usePrevious/usePrevious.js +1 -1
- package/dist/cjs/hooks/useQuery/useQuery.js +3 -0
- package/dist/cjs/hooks/useQuery/useQuery.js.map +1 -0
- package/dist/cjs/hooks/useQueue/useQueue.js +2 -2
- package/dist/cjs/hooks/useRenderCount/useRenderCount.js +1 -1
- package/dist/cjs/hooks/useRerender/useRerender.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/useStep/useStep.js +2 -2
- package/dist/cjs/hooks/useStorage/useStorage.js +2 -2
- package/dist/cjs/hooks/useTextSelection/useTextSelection.js +2 -2
- package/dist/cjs/hooks/useTimeout/useTimeout.js +2 -2
- package/dist/cjs/hooks/useTimeout/useTimeout.js.map +1 -1
- package/dist/cjs/hooks/useToggle/useToggle.js +2 -2
- package/dist/cjs/hooks/useUnmount/useUnmount.js +1 -1
- package/dist/cjs/hooks/useWindowEvent/useWindowEvent.js +1 -1
- package/dist/cjs/hooks/useWindowSize/useWindowSize.js +2 -2
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/utils/helpers/debounce.js +1 -1
- package/dist/cjs/utils/helpers/getRetry.js +3 -0
- package/dist/cjs/utils/helpers/getRetry.js.map +1 -0
- package/dist/cjs/utils/helpers/index.js +2 -2
- package/dist/cjs/utils/helpers/isClient.js +1 -1
- package/dist/cjs/utils/helpers/throttle.js +1 -1
- package/dist/esm/{_rollupPluginBabelHelpers-DzIe9o0q.js → _rollupPluginBabelHelpers-CuOqjRnD.js} +2 -2
- package/dist/esm/_rollupPluginBabelHelpers-CuOqjRnD.js.map +1 -0
- package/dist/esm/hooks/index.js +2 -2
- package/dist/esm/hooks/useBattery/useBattery.js +2 -2
- package/dist/esm/hooks/useBoolean/useBoolean.js +2 -2
- package/dist/esm/hooks/useClickOutside/useClickOutside.js +1 -1
- package/dist/esm/hooks/useCopyToClipboard/useCopyToClipboard.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/useDebouncedValue/useDebouncedValue.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/useDocumentTitle/useDocumentTitle.js +2 -2
- package/dist/esm/hooks/useDocumentTitle/useDocumentTitle.js.map +1 -1
- 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 +2 -2
- package/dist/esm/hooks/useEventListener/useEventListener.js.map +1 -1
- package/dist/esm/hooks/useFavicon/useFavicon.js +2 -2
- package/dist/esm/hooks/useFullscreen/useFullscreen.js +2 -2
- package/dist/esm/hooks/useFullscreen/useFullscreen.js.map +1 -1
- package/dist/esm/hooks/useHash/useHash.js +2 -2
- package/dist/esm/hooks/useHotkeys/useHotkeys.js +2 -2
- package/dist/esm/hooks/useHotkeys/useHotkeys.js.map +1 -1
- package/dist/esm/hooks/useHover/useHover.js +2 -2
- package/dist/esm/hooks/useHover/useHover.js.map +1 -1
- package/dist/esm/hooks/useIdle/useIdle.js +2 -2
- package/dist/esm/hooks/useIntersectionObserver/useIntersectionObserver.js +2 -2
- package/dist/esm/hooks/useIntersectionObserver/useIntersectionObserver.js.map +1 -1
- package/dist/esm/hooks/useInterval/useInterval.js +3 -0
- package/dist/esm/hooks/useInterval/useInterval.js.map +1 -0
- package/dist/esm/hooks/useIsFirstRender/useIsFirstRender.js +1 -1
- package/dist/esm/hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js +1 -1
- package/dist/esm/hooks/useKeyPress/useKeyPress.js +2 -2
- package/dist/esm/hooks/useKeyPress/useKeyPress.js.map +1 -1
- package/dist/esm/hooks/useKeyPressEvent/useKeyPressEvent.js +1 -1
- package/dist/esm/hooks/useKeyboard/useKeyboard.js +3 -0
- package/dist/esm/hooks/useKeyboard/useKeyboard.js.map +1 -0
- 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/useLogger/useLogger.js +2 -2
- package/dist/esm/hooks/useLongPress/useLongPress.js +3 -0
- package/dist/esm/hooks/useLongPress/useLongPress.js.map +1 -0
- package/dist/esm/hooks/useMediaQuery/useMediaQuery.js +1 -1
- 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 +3 -0
- package/dist/esm/hooks/useMutation/useMutation.js.map +1 -0
- 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 +1 -1
- package/dist/esm/hooks/usePreferredLanguages/usePreferredLanguages.js +1 -1
- package/dist/esm/hooks/usePrevious/usePrevious.js +1 -1
- package/dist/esm/hooks/useQuery/useQuery.js +3 -0
- package/dist/esm/hooks/useQuery/useQuery.js.map +1 -0
- package/dist/esm/hooks/useQueue/useQueue.js +2 -2
- package/dist/esm/hooks/useRenderCount/useRenderCount.js +1 -1
- package/dist/esm/hooks/useRerender/useRerender.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/useStep/useStep.js +2 -2
- package/dist/esm/hooks/useStorage/useStorage.js +2 -2
- package/dist/esm/hooks/useTextSelection/useTextSelection.js +2 -2
- package/dist/esm/hooks/useTimeout/useTimeout.js +2 -2
- package/dist/esm/hooks/useTimeout/useTimeout.js.map +1 -1
- package/dist/esm/hooks/useToggle/useToggle.js +2 -2
- package/dist/esm/hooks/useUnmount/useUnmount.js +1 -1
- package/dist/esm/hooks/useWindowEvent/useWindowEvent.js +1 -1
- package/dist/esm/hooks/useWindowSize/useWindowSize.js +2 -2
- package/dist/esm/index.js +2 -2
- package/dist/esm/utils/helpers/debounce.js +1 -1
- package/dist/esm/utils/helpers/getRetry.js +3 -0
- package/dist/esm/utils/helpers/getRetry.js.map +1 -0
- package/dist/esm/utils/helpers/index.js +2 -2
- package/dist/esm/utils/helpers/isClient.js +1 -1
- package/dist/esm/utils/helpers/throttle.js +1 -1
- package/dist/index.d.ts +193 -13
- package/package.json +1 -1
- package/dist/cjs/_rollupPluginBabelHelpers-OWhzq4gx.js.map +0 -1
- package/dist/esm/_rollupPluginBabelHelpers-DzIe9o0q.js.map +0 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.21 */
|
|
2
2
|
import r from"react";function e(e,n,t){var u=r.useRef(),c=r.useRef(null);return r.useEffect((function(){var r="function"==typeof t?t():t;return(r||c.current)&&(u.current=new MutationObserver(e),u.current.observe(r||c.current,n)),function(){var r;null===(r=u.current)||void 0===r||r.disconnect()}}),[e,n]),c}export{e as useMutationObserver};
|
|
3
3
|
//# sourceMappingURL=useMutationObserver.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as n}from"../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.21 */
|
|
2
|
+
import{_ as n}from"../../_rollupPluginBabelHelpers-CuOqjRnD.js";import e from"react";import{isClient as i}from"../../utils/helpers/isClient.js";var o=function(){var n,e,i;return(null===(n=navigator)||void 0===n?void 0:n.connection)||(null===(e=navigator)||void 0===e?void 0:e.mozConnection)||(null===(i=navigator)||void 0===i?void 0:i.webkitConnection)},t=function(){var t=e.useState((function(){if(!i)return{online:!1,type:void 0,effectiveType:void 0,saveData:!1,downlink:0,downlinkMax:0,rtt:0};var n=navigator.onLine,e=o();return{online:n,downlink:null==e?void 0:e.downlink,downlinkMax:null==e?void 0:e.downlinkMax,effectiveType:null==e?void 0:e.effectiveType,rtt:null==e?void 0:e.rtt,saveData:null==e?void 0:e.saveData,type:null==e?void 0:e.type}})),l=n(t,2),v=l[0],a=l[1];return e.useEffect((function(){var n=function(){var n=navigator.onLine,e=o();a({online:n,downlink:null==e?void 0:e.downlink,downlinkMax:null==e?void 0:e.downlinkMax,effectiveType:null==e?void 0:e.effectiveType,rtt:null==e?void 0:e.rtt,saveData:null==e?void 0:e.saveData,type:null==e?void 0:e.type})};window.addEventListener("online",n,{passive:!0}),window.addEventListener("offline",n,{passive:!0});var e=o();return e&&e.addEventListener("change",n,{passive:!0}),function(){window.removeEventListener("online",n),window.removeEventListener("offline",n),e&&e.removeEventListener("change",n)}})),v};export{o as getConnection,t as useNetwork};
|
|
3
3
|
//# sourceMappingURL=useNetwork.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.21 */
|
|
2
2
|
import n from"react";var e=function(){return navigator.onLine},t=function(){return!1},r=function(n){return window.addEventListener("online",n),window.addEventListener("offline",n),function(){window.removeEventListener("online",n),window.removeEventListener("offline",n)}},o=function(){return n.useSyncExternalStore(r,e,t)};export{o as useOnline};
|
|
3
3
|
//# sourceMappingURL=useOnline.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.21 */
|
|
2
2
|
import n from"react";var i=function(){if("undefined"==typeof window)return"undetermined";var n=window.navigator.userAgent;return/(Macintosh)|(MacIntel)|(MacPPC)|(Mac68K)/i.test(n)?"macos":/(iPhone)|(iPad)|(iPod)/i.test(n)?"ios":/(Win32)|(Win64)|(Windows)|(WinCE)/i.test(n)?"windows":/Android/i.test(n)?"android":/Linux/i.test(n)?"linux":"undetermined"},e=function(){return n.useRef(i()).current};export{i as getOperatingSystem,e as useOperatingSystem};
|
|
3
3
|
//# sourceMappingURL=useOperatingSystem.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as e}from"../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.21 */
|
|
2
|
+
import{_ as e}from"../../_rollupPluginBabelHelpers-CuOqjRnD.js";import n from"react";import{useIsomorphicLayoutEffect as r}from"../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js";import"../../utils/helpers/isClient.js";var t=function(){var t=n.useState({angle:0,type:"landscape-primary"}),o=e(t,2),i=o[0],a=o[1];return r((function(){var e,n=function(){var e=window.screen.orientation,n=e.angle,r=e.type;a({angle:n,type:r})};return null===(e=window.screen.orientation)||void 0===e||e.addEventListener("change",n),function(){var e;return null===(e=window.screen.orientation)||void 0===e?void 0:e.removeEventListener("change",n)}}),[]),i};export{t as useOrientation};
|
|
3
3
|
//# sourceMappingURL=useOrientation.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.21 */
|
|
2
2
|
import"react";import"../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js";import"../../utils/helpers/isClient.js";import{useEventListener as e}from"../useEventListener/useEventListener.js";import"screenfull";import"react-dom";import"../useEvent/useEvent.js";var t=function(t){return e(document,"mouseleave",t)};export{t as usePageLeave};
|
|
3
3
|
//# sourceMappingURL=usePageLeave.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.21 */
|
|
2
2
|
import n from"react";var e=function(){return window.navigator.languages},r=function(){return["en"]},t=function(n){return window.addEventListener("languagechange",n),function(){window.removeEventListener("languagechange",n)}},a=function(){return n.useSyncExternalStore(t,e,r)};export{a as usePreferredLanguages};
|
|
3
3
|
//# sourceMappingURL=usePreferredLanguages.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.21 */
|
|
2
2
|
import r from"react";var e=function(e){var t=r.useRef();return r.useEffect((function(){t.current=e})),t.current};export{e as usePrevious};
|
|
3
3
|
//# sourceMappingURL=usePrevious.js.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.21 */
|
|
2
|
+
import{_ as e}from"../../_rollupPluginBabelHelpers-CuOqjRnD.js";import t from"react";import{getRetry as l}from"../../utils/helpers/getRetry.js";import"../../utils/helpers/isClient.js";var r=function(r,n){var i,u=t.useRef(null!=n&&n.retry?l(n.retry):0),a=t.useState(!1),o=e(a,2),c=o[0],s=o[1],f=t.useState(!1),d=e(f,2),v=d[0],h=d[1],p=t.useState(!1),S=e(p,2),m=S[0],y=S[1],D=t.useState(!(null==n||!n.initialData)),g=e(D,2),j=g[0],E=g[1],R=t.useState(void 0),_=e(R,2),b=_[0],k=_[1],x=t.useState(null==n?void 0:n.initialData),B=e(x,2),C=B[0],F=B[1],H=function e(t){s(!0),"refetch"===t&&y(!0),r().then((function(e){var l,r=null!=n&&n.select?null==n?void 0:n.select(e):e;null==n||null===(l=n.onSuccess)||void 0===l||l.call(n,r),F(r),E(!0),s(!1),k(void 0),h(!1),"refetch"===t&&y(!1)})).catch((function(r){var i;if(u.current>0)return u.current-=1,e(t);null==n||null===(i=n.onError)||void 0===i||i.call(n,r),F(void 0),E(!1),s(!1),k(r),h(!0),"refetch"===t&&y(!1),u.current=null!=n&&n.retry?l(n.retry):0}))};t.useEffect((function(){null!=n&&n.initialData||H("init")}),null!==(i=null==n?void 0:n.keys)&&void 0!==i?i:[]);var L=(null==n?void 0:n.placeholderData)instanceof Function?null==n?void 0:n.placeholderData():null==n?void 0:n.placeholderData;return{data:null!=C?C:L,error:b,refetch:function(){return H("refetch")},isLoading:c,isError:v,isSuccess:j,isRefetching:m}};export{r as useQuery};
|
|
3
|
+
//# sourceMappingURL=useQuery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useQuery.js","sources":["../../../../src/hooks/useQuery/useQuery.ts"],"sourcesContent":["import React from 'react';\n\nimport { getRetry } from '@/utils/helpers';\n\n/* The use query return type */\ninterface UseQueryOptions<QueryData, Data> {\n /* The depends for the hook */\n keys?: React.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}\n\n/* The use query return type */\ninterface UseQueryReturn<Data> {\n /* The state of the query */\n data: Data | undefined;\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 | undefined;\n /* The refetch function */\n refetch: () => void;\n /* The refetch async function */\n isRefetching: boolean;\n}\n\n/**\n * @name useQuery\n * @description - Hook that defines the logic when query data\n *\n * @template Data - The type of the data\n * @param {() => Promise<Data>} callback - The callback function to be invoked\n * @param {React.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 {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('https://example.com/data'));\n */\nexport const useQuery = <QueryData, Data = QueryData>(\n callback: () => Promise<QueryData>,\n options?: UseQueryOptions<QueryData, Data>\n): UseQueryReturn<Data> => {\n const retryCountRef = React.useRef(options?.retry ? getRetry(options.retry) : 0);\n\n const [isLoading, setIsLoading] = React.useState(false);\n const [isError, setIsError] = React.useState(false);\n const [isRefetching, setIsRefetching] = React.useState(false);\n const [isSuccess, setIsSuccess] = React.useState(!!options?.initialData);\n\n const [error, setError] = React.useState<Error | undefined>(undefined);\n const [data, setData] = React.useState<Data | undefined>(options?.initialData);\n\n const request = (action: 'init' | 'refetch') => {\n setIsLoading(true);\n if (action === 'refetch') setIsRefetching(true);\n\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 };\n\n React.useEffect(() => {\n if (options?.initialData) return;\n request('init');\n }, 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$keys","retryCountRef","React","useRef","retry","getRetry","_React$useState","useState","_React$useState2","_slicedToArray","isLoading","setIsLoading","_React$useState3","_React$useState4","isError","setIsError","_React$useState5","_React$useState6","isRefetching","setIsRefetching","_React$useState7","initialData","_React$useState8","isSuccess","setIsSuccess","_React$useState9","undefined","_React$useState10","error","setError","_React$useState11","_React$useState12","data","setData","request","action","then","response","_options$onSuccess","select","onSuccess","call","_options$onError","current","onError","useEffect","keys","placeholderData","Function","refetch"],"mappings":";wLA0DO,IAAMA,EAAW,SACtBC,EACAC,GACyB,IAAAC,EACnBC,EAAgBC,EAAMC,OAAOJ,SAAAA,EAASK,MAAQC,EAASN,EAAQK,OAAS,GAE9EE,EAAkCJ,EAAMK,UAAS,GAAMC,EAAAC,EAAAH,EAAA,GAAhDI,EAASF,EAAA,GAAEG,EAAYH,EAAA,GAC9BI,EAA8BV,EAAMK,UAAS,GAAMM,EAAAJ,EAAAG,EAAA,GAA5CE,EAAOD,EAAA,GAAEE,EAAUF,EAAA,GAC1BG,EAAwCd,EAAMK,UAAS,GAAMU,EAAAR,EAAAO,EAAA,GAAtDE,EAAYD,EAAA,GAAEE,EAAeF,EAAA,GACpCG,EAAkClB,EAAMK,WAAWR,UAAAA,EAASsB,cAAYC,EAAAb,EAAAW,EAAA,GAAjEG,EAASD,EAAA,GAAEE,EAAYF,EAAA,GAE9BG,EAA0BvB,EAAMK,cAA4BmB,GAAUC,EAAAlB,EAAAgB,EAAA,GAA/DG,EAAKD,EAAA,GAAEE,EAAQF,EAAA,GACtBG,EAAwB5B,EAAMK,SAA2BR,aAAO,EAAPA,EAASsB,aAAYU,EAAAtB,EAAAqB,EAAA,GAAvEE,EAAID,EAAA,GAAEE,EAAOF,EAAA,GAEdG,EAAU,SAAVA,EAAWC,GACfxB,GAAa,GACE,YAAXwB,GAAsBhB,GAAgB,GAE1CrB,IACGsC,MAAK,SAACC,GAAa,IAAAC,EACZN,EAAOjC,SAAAA,EAASwC,OAASxC,eAAAA,EAASwC,OAAOF,GAAYA,EAC3DtC,SAAkB,QAAXuC,EAAPvC,EAASyC,iBAAS,IAAAF,GAAlBA,EAAAG,KAAA1C,EAAqBiC,GACrBC,EAAQD,GACRR,GAAa,GACbb,GAAa,GACbkB,OAASH,GACTX,GAAW,GACI,YAAXoB,GAAsBhB,GAAgB,EAC5C,IAAE,OACK,SAACS,GAAiB,IAAAc,EACvB,GAAIzC,EAAc0C,QAAU,EAE1B,OADA1C,EAAc0C,SAAW,EAClBT,EAAQC,GAEjBpC,SAAgB,QAAT2C,EAAP3C,EAAS6C,eAAO,IAAAF,GAAhBA,EAAAD,KAAA1C,EAAmB6B,GACnBK,OAAQP,GACRF,GAAa,GACbb,GAAa,GACbkB,EAASD,GACTb,GAAW,GACI,YAAXoB,GAAsBhB,GAAgB,GAC1ClB,EAAc0C,QAAU5C,SAAAA,EAASK,MAAQC,EAASN,EAAQK,OAAS,CACrE,KAGJF,EAAM2C,WAAU,WACV9C,SAAAA,EAASsB,aACba,EAAQ,OACV,WAAClC,EAAED,aAAAA,EAAAA,EAAS+C,YAAI,IAAA9C,EAAAA,EAAI,IAEpB,IAEM+C,GACJhD,aAAAA,EAAAA,EAASgD,2BAA2BC,SAChCjD,aAAAA,EAAAA,EAASgD,kBACThD,aAAAA,EAAAA,EAASgD,gBAEf,MAAO,CACLf,KAAMA,QAAAA,EAAQe,EACdnB,MAAAA,EACAqB,QAVc,WAAH,OAASf,EAAQ,UAAU,EAWtCxB,UAAAA,EACAI,QAAAA,EACAS,UAAAA,EACAL,aAAAA,EAEJ"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as r,c as t,d as n}from"../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.21 */
|
|
2
|
+
import{_ as r,c as t,d as n}from"../../_rollupPluginBabelHelpers-CuOqjRnD.js";import e from"react";import{flushSync as o}from"react-dom";var u=function(){var u=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],a=e.useState(u),i=r(a,2),c=i[0],f=i[1];return{add:function(r){return f((function(n){return[].concat(t(n),[r])}))},remove:function(){var r;return o((function(){f((function(t){var e=n(t),o=e[0],u=e.slice(1);return r=o,u}))})),r},clear:function(){return f([])},first:c[0],last:c[c.length-1],size:c.length,queue:c}};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.21 */
|
|
2
2
|
import r from"react";var e=function(){var e=r.useRef(0);return r.useEffect((function(){e.current+=1})),e.current};export{e as useRenderCount};
|
|
3
3
|
//# sourceMappingURL=useRenderCount.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as r}from"../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.21 */
|
|
2
|
+
import{_ as r}from"../../_rollupPluginBabelHelpers-CuOqjRnD.js";import t from"react";var e=function(){var e=t.useId(),o=t.useState(e),a=r(o,2),n=a[0],u=a[1];return{id:n,update:function(){return u(Math.random().toString())}}};export{e as useRerender};
|
|
3
3
|
//# sourceMappingURL=useRerender.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as e}from"../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.21 */
|
|
2
|
+
import{_ as e}from"../../_rollupPluginBabelHelpers-CuOqjRnD.js";import t from"react";var r="script-status",n=function(n){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=t.useState((function(){var e=document.querySelector('script[src="'.concat(n,'"]')),t=null==e?void 0:e.getAttribute(r);return t||(e?"unknown":"loading")})),u=e(i,2),c=u[0],a=u[1],s=o.removeOnUnmount,d=void 0===s||s,v=o.async,l=void 0===v||v;return t.useEffect((function(){var t=document.querySelector('script[src="'.concat(n,'"]')),i=null==t?void 0:t.getAttribute(r);if(i)return a(i);if(t)return a("unknown");var u=document.createElement("script");u.src=n,u.async=l;for(var c=0,s=Object.entries(o);c<s.length;c++){var v=e(s[c],2),m=v[0],f=v[1];u.setAttribute(m,String(f))}u.setAttribute(r,"loading"),document.body.appendChild(u);var p=function(){u.setAttribute(r,"ready"),a("ready")},b=function(){u.setAttribute(r,"error"),a("error")};return u.addEventListener("load",p),u.addEventListener("error",b),function(){d&&(u.remove(),u.removeEventListener("load",p),u.removeEventListener("error",b))}}),[n,d]),c};export{r as SCRIPT_STATUS_ATTRIBUTE_NAME,n 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.21 */
|
|
2
|
+
import{b as o}from"../../_rollupPluginBabelHelpers-CuOqjRnD.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 r from"react";import{useRerender as e}from"../useRerender/useRerender.js";import"../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.21 */
|
|
2
|
+
import r from"react";import{useRerender as e}from"../useRerender/useRerender.js";import"../../_rollupPluginBabelHelpers-CuOqjRnD.js";var t=function(t){var n=r.useRef(new Set(t)),a=e();return n.current.add=function(){for(var r=arguments.length,e=new Array(r),t=0;t<r;t++)e[t]=arguments[t];var u=Set.prototype.add.apply(n.current,e);return a.update(),u},n.current.clear=function(){for(var r=arguments.length,e=new Array(r),t=0;t<r;t++)e[t]=arguments[t];Set.prototype.clear.apply(n.current,e),a.update()},n.current.delete=function(){for(var r=arguments.length,e=new Array(r),t=0;t<r;t++)e[t]=arguments[t];var u=Set.prototype.delete.apply(n.current,e);return a.update(),u},n.current};export{t as useSet};
|
|
3
3
|
//# sourceMappingURL=useSet.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{a as t,_ as r}from"../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.21 */
|
|
2
|
+
import{a as t,_ as r}from"../../_rollupPluginBabelHelpers-CuOqjRnD.js";import n from"react";var e=function(e){var u="object"===t(e)?e.max:e,i="object"===t(e)?e.initial:1,o=n.useRef(i>u||i<1?1:i),c=n.useState(i),s=r(c,2),a=s[0],f=s[1],l=1===a,p=a===u;return{counts:u,currentStep:a,isFirst:l,isLast:p,next:function(){p||f((function(t){return t+1}))},back:function(){l||f((function(t){return t-1}))},reset:function(){return f(o.current)},set:function(t){return"first"===t?f(o.current):"last"===t||t>=u?f(u):t<=1?f(1):void f(t)}}};export{e as useStep};
|
|
3
3
|
//# sourceMappingURL=useStep.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{a as e}from"../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.21 */
|
|
2
|
+
import{a as e}from"../../_rollupPluginBabelHelpers-CuOqjRnD.js";import n from"react";import{isClient as t}from"../../utils/helpers/isClient.js";import{useIsomorphicLayoutEffect as r}from"../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js";var i=function(e){return window.dispatchEvent(new StorageEvent("storage",e))},o=function(e,n,t){var r=e.getItem(n);e.setItem(n,t),i({key:n,oldValue:r,newValue:t,storageArea:e})},u=function(e,n){var t=e.getItem(n);e.removeItem(n),i({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(i,f){var c,d="object"===e(f)?f:void 0,v=d?null==d?void 0:d.initialValue:f,m=null!==(c=null==d?void 0:d.storage)&&void 0!==c?c:window.localStorage,g=function(e){return null!=d&&d.serializer?d.serializer(e):JSON.stringify(e)},p=n.useSyncExternalStore(l,(function(){return a(m,i)}),s),w=function(e){if(null===e)return u(m,i);o(m,i,g(e))};r((function(){(void 0===a(m,i)||v)&&o(m,i,g(v instanceof Function?v():v))}),[i]);var y=function(){return u(m,i)};return t?[p?function(e){if(null!=d&&d.deserializer)return d.deserializer(e);if("undefined"!==e)try{return JSON.parse(e)}catch(n){return e}}(p):void 0,w,y]:[v instanceof Function?v():v,w,y]};export{i as dispatchStorageEvent,f as useStorage};
|
|
3
3
|
//# sourceMappingURL=useStorage.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as e}from"../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.21 */
|
|
2
|
+
import{_ as e}from"../../_rollupPluginBabelHelpers-CuOqjRnD.js";import n from"react";import{isClient as t}from"../../utils/helpers/isClient.js";import{useRerender as r}from"../useRerender/useRerender.js";var o=function(e){var n,t=null!==(n=e.rangeCount)&&void 0!==n?n:0;return Array.from({length:t},(function(n,t){return e.getRangeAt(t)}))},u=function(){var u,i=r(),l=n.useState(t?document.getSelection():null),c=e(l,2),s=c[0],a=c[1];n.useEffect((function(){var e=function(){a(document.getSelection()),i.update()};return document.addEventListener("selectionchange",e),function(){return document.removeEventListener("selectionchange",e)}}),[]);var m=null!==(u=null==s?void 0:s.toString())&&void 0!==u?u:"",f=s?o(s):[],d=f.map((function(e){return e.getBoundingClientRect()}));return{text:m,ranges:f,rects:d,selection:s}};export{o as getRangesSelection,u 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.21 */
|
|
2
|
+
import{_ as e}from"../../_rollupPluginBabelHelpers-CuOqjRnD.js";import t from"react";import{useEvent as r}from"../useEvent/useEvent.js";import"../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js";import"../../utils/helpers/isClient.js";function u(u,o){var i=t.useState(!1),n=e(i,2),s=n[0],c=n[1],f=t.useRef(),m=r(u);t.useEffect((function(){return f.current=setTimeout((function(){m(),c(!0)}),o),function(){clearTimeout(f.current)}}),[o]);return{ready:s,clear:function(){clearTimeout(f.current),c(!0)}}}export{u as useTimeout};
|
|
3
3
|
//# sourceMappingURL=useTimeout.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTimeout.js","sources":["../../../../src/hooks/useTimeout/useTimeout.ts"],"sourcesContent":["import React from 'react';\n\nimport {
|
|
1
|
+
{"version":3,"file":"useTimeout.js","sources":["../../../../src/hooks/useTimeout/useTimeout.ts"],"sourcesContent":["import React from 'react';\n\nimport { useEvent } from '../useEvent/useEvent';\n\n/** The use timeout return type */\ninterface UseTimeoutReturn {\n /** Timeout is ready state value */\n ready: boolean;\n /** Function to clear timeout */\n clear: () => void;\n}\n\n/**\n * @name useTimeout\n * @description Hook that executes a callback function after a specified delay\n *\n * @param {() => void} callback The function to be executed after the timeout\n * @param {number} delay The delay in milliseconds before the timeout executes the callback function\n * @returns {UseTimeoutReturn} An object with a `ready` boolean state value and a `clear` function to clear timeout\n *\n * @example\n * const { clear, ready } = useTimeout(() => {}, 5000);\n */\nexport function useTimeout(callback: () => void, delay: number): UseTimeoutReturn {\n const [ready, setReady] = React.useState(false);\n\n const timeoutIdRef = React.useRef<ReturnType<typeof setTimeout>>();\n const internalCallback = useEvent(callback);\n\n React.useEffect(() => {\n timeoutIdRef.current = setTimeout(() => {\n internalCallback();\n setReady(true);\n }, delay);\n\n return () => {\n clearTimeout(timeoutIdRef.current);\n };\n }, [delay]);\n\n const clear = () => {\n clearTimeout(timeoutIdRef.current);\n setReady(true);\n };\n\n return { ready, clear };\n}\n"],"names":["useTimeout","callback","delay","_React$useState","React","useState","_React$useState2","_slicedToArray","ready","setReady","timeoutIdRef","useRef","internalCallback","useEvent","useEffect","current","setTimeout","clearTimeout","clear"],"mappings":";kPAuBO,SAASA,EAAWC,EAAsBC,GAC/C,IAAAC,EAA0BC,EAAMC,UAAS,GAAMC,EAAAC,EAAAJ,EAAA,GAAxCK,EAAKF,EAAA,GAAEG,EAAQH,EAAA,GAEhBI,EAAeN,EAAMO,SACrBC,EAAmBC,EAASZ,GAElCG,EAAMU,WAAU,WAMd,OALAJ,EAAaK,QAAUC,YAAW,WAChCJ,IACAH,GAAS,EACV,GAAEP,GAEI,WACLe,aAAaP,EAAaK,SAE9B,GAAG,CAACb,IAOJ,MAAO,CAAEM,MAAAA,EAAOU,MALF,WACZD,aAAaP,EAAaK,SAC1BN,GAAS,IAIb"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as r}from"../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.21 */
|
|
2
|
+
import{_ as r}from"../../_rollupPluginBabelHelpers-CuOqjRnD.js";import e from"react";var n=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[!1,!0],t=e.useReducer((function(r,e){var n=e instanceof Function?e(r[0]):e,t=Math.abs(r.indexOf(n));return r.slice(t).concat(r.slice(0,t))}),n),o=r(t,2);return[r(o[0],1)[0],o[1]]};export{n as useToggle};
|
|
3
3
|
//# sourceMappingURL=useToggle.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.21 */
|
|
2
2
|
import r from"react";var t=function(t){var e=r.useRef(t);e.current=t,r.useEffect((function(){return function(){e.current()}}),[])};export{t as useUnmount};
|
|
3
3
|
//# sourceMappingURL=useUnmount.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.21 */
|
|
2
2
|
import{useEventListener as e}from"../useEventListener/useEventListener.js";import"react";import"../useEvent/useEvent.js";import"../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js";import"../../utils/helpers/isClient.js";var t=function(t,s,r){return e(window,t,s,r)};export{t as useWindowEvent};
|
|
3
3
|
//# sourceMappingURL=useWindowEvent.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as i}from"../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.21 */
|
|
2
|
+
import{_ as i}from"../../_rollupPluginBabelHelpers-CuOqjRnD.js";import e from"react";import{isClient as n}from"../../utils/helpers/isClient.js";var t=function(t){var r,o,d=e.useState({width:n?window.innerWidth:null!==(r=null==t?void 0:t.initialWidth)&&void 0!==r?r:Number.POSITIVE_INFINITY,height:n?window.innerHeight:null!==(o=null==t?void 0:t.initialWidth)&&void 0!==o?o:Number.POSITIVE_INFINITY}),l=i(d,2),u=l[0],w=l[1];return e.useEffect((function(){var i=function(){w({width:window.innerWidth,height:window.innerHeight})};return window.addEventListener("resize",i),function(){window.removeEventListener("resize",i)}}),[]),u};export{t as useWindowSize};
|
|
3
3
|
//# sourceMappingURL=useWindowSize.js.map
|
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{useClickOutside}from"./hooks/useClickOutside/useClickOutside.js";export{legacyCopyToClipboard,useCopyToClipboard}from"./hooks/useCopyToClipboard/useCopyToClipboard.js";export{useCounter}from"./hooks/useCounter/useCounter.js";export{useDebouncedValue}from"./hooks/useDebouncedValue/useDebouncedValue.js";export{useDefault}from"./hooks/useDefault/useDefault.js";export{useDidUpdate}from"./hooks/useDidUpdate/useDidUpdate.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{useFavicon}from"./hooks/useFavicon/useFavicon.js";export{useFullscreen}from"./hooks/useFullscreen/useFullscreen.js";export{useHash}from"./hooks/useHash/useHash.js";export{isHotkeyMatch,useHotkeys}from"./hooks/useHotkeys/useHotkeys.js";export{useHover}from"./hooks/useHover/useHover.js";export{useIdle}from"./hooks/useIdle/useIdle.js";export{useIntersectionObserver}from"./hooks/useIntersectionObserver/useIntersectionObserver.js";export{useIsFirstRender}from"./hooks/useIsFirstRender/useIsFirstRender.js";export{useIsomorphicLayoutEffect}from"./hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.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{useMediaQuery}from"./hooks/useMediaQuery/useMediaQuery.js";export{useMount}from"./hooks/useMount/useMount.js";export{useMouse}from"./hooks/useMouse/useMouse.js";export{getConnection,useNetwork}from"./hooks/useNetwork/useNetwork.js";export{useOnline}from"./hooks/useOnline/useOnline.js";export{getOperatingSystem,useOperatingSystem}from"./hooks/useOperatingSystem/useOperatingSystem.js";export{useOrientation}from"./hooks/useOrientation/useOrientation.js";export{usePageLeave}from"./hooks/usePageLeave/usePageLeave.js";export{usePreferredLanguages}from"./hooks/usePreferredLanguages/usePreferredLanguages.js";export{usePrevious}from"./hooks/usePrevious/usePrevious.js";export{useQueue}from"./hooks/useQueue/useQueue.js";export{useRenderCount}from"./hooks/useRenderCount/useRenderCount.js";export{useRerender}from"./hooks/useRerender/useRerender.js";export{SCRIPT_STATUS_ATTRIBUTE_NAME,useScript}from"./hooks/useScript/useScript.js";export{useSessionStorage}from"./hooks/useSessionStorage/useSessionStorage.js";export{useSet}from"./hooks/useSet/useSet.js";export{useStep}from"./hooks/useStep/useStep.js";export{dispatchStorageEvent,useStorage}from"./hooks/useStorage/useStorage.js";export{getRangesSelection,useTextSelection}from"./hooks/useTextSelection/useTextSelection.js";export{useTimeout}from"./hooks/useTimeout/useTimeout.js";export{useToggle}from"./hooks/useToggle/useToggle.js";export{useUnmount}from"./hooks/useUnmount/useUnmount.js";export{useWindowEvent}from"./hooks/useWindowEvent/useWindowEvent.js";export{useWindowSize}from"./hooks/useWindowSize/useWindowSize.js";export{debounce}from"./utils/helpers/debounce.js";export{isClient}from"./utils/helpers/isClient.js";export{throttle}from"./utils/helpers/throttle.js";import"./_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.21 */
|
|
2
|
+
export{useBattery}from"./hooks/useBattery/useBattery.js";export{useBoolean}from"./hooks/useBoolean/useBoolean.js";export{useClickOutside}from"./hooks/useClickOutside/useClickOutside.js";export{legacyCopyToClipboard,useCopyToClipboard}from"./hooks/useCopyToClipboard/useCopyToClipboard.js";export{useCounter}from"./hooks/useCounter/useCounter.js";export{useDebouncedValue}from"./hooks/useDebouncedValue/useDebouncedValue.js";export{useDefault}from"./hooks/useDefault/useDefault.js";export{useDidUpdate}from"./hooks/useDidUpdate/useDidUpdate.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{useFavicon}from"./hooks/useFavicon/useFavicon.js";export{useFullscreen}from"./hooks/useFullscreen/useFullscreen.js";export{useHash}from"./hooks/useHash/useHash.js";export{isHotkeyMatch,useHotkeys}from"./hooks/useHotkeys/useHotkeys.js";export{useHover}from"./hooks/useHover/useHover.js";export{useIdle}from"./hooks/useIdle/useIdle.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{useMediaQuery}from"./hooks/useMediaQuery/useMediaQuery.js";export{useMount}from"./hooks/useMount/useMount.js";export{useMouse}from"./hooks/useMouse/useMouse.js";export{useMutation}from"./hooks/useMutation/useMutation.js";export{getConnection,useNetwork}from"./hooks/useNetwork/useNetwork.js";export{useOnline}from"./hooks/useOnline/useOnline.js";export{getOperatingSystem,useOperatingSystem}from"./hooks/useOperatingSystem/useOperatingSystem.js";export{useOrientation}from"./hooks/useOrientation/useOrientation.js";export{usePageLeave}from"./hooks/usePageLeave/usePageLeave.js";export{usePreferredLanguages}from"./hooks/usePreferredLanguages/usePreferredLanguages.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{useRerender}from"./hooks/useRerender/useRerender.js";export{SCRIPT_STATUS_ATTRIBUTE_NAME,useScript}from"./hooks/useScript/useScript.js";export{useSessionStorage}from"./hooks/useSessionStorage/useSessionStorage.js";export{useSet}from"./hooks/useSet/useSet.js";export{useStep}from"./hooks/useStep/useStep.js";export{dispatchStorageEvent,useStorage}from"./hooks/useStorage/useStorage.js";export{getRangesSelection,useTextSelection}from"./hooks/useTextSelection/useTextSelection.js";export{useTimeout}from"./hooks/useTimeout/useTimeout.js";export{useToggle}from"./hooks/useToggle/useToggle.js";export{useUnmount}from"./hooks/useUnmount/useUnmount.js";export{useWindowEvent}from"./hooks/useWindowEvent/useWindowEvent.js";export{useWindowSize}from"./hooks/useWindowSize/useWindowSize.js";export{debounce}from"./utils/helpers/debounce.js";export{getRetry}from"./utils/helpers/getRetry.js";export{isClient}from"./utils/helpers/isClient.js";export{throttle}from"./utils/helpers/throttle.js";import"./_rollupPluginBabelHelpers-CuOqjRnD.js";import"react";import"./hooks/useMutationObserver.js";import"screenfull";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.21 */
|
|
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
|
|
@@ -0,0 +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') {\n return retry;\n }\n\n return retry ? 1 : 0;\n};\n"],"names":["getRetry","retry"],"mappings":";IAAaA,EAAW,SAACC,GACvB,MAAqB,iBAAVA,EACFA,EAGFA,EAAQ,EAAI,CACrB"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
export{debounce}from"./debounce.js";export{isClient}from"./isClient.js";export{throttle}from"./throttle.js";
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.21 */
|
|
2
|
+
export{debounce}from"./debounce.js";export{getRetry}from"./getRetry.js";export{isClient}from"./isClient.js";export{throttle}from"./throttle.js";
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.21 */
|
|
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.21 */
|
|
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
|
package/dist/index.d.ts
CHANGED
|
@@ -95,7 +95,7 @@ interface UseCopyToClipboardReturn {
|
|
|
95
95
|
*/
|
|
96
96
|
declare const useCopyToClipboard: () => UseCopyToClipboardReturn;
|
|
97
97
|
|
|
98
|
-
/** The use counter options */
|
|
98
|
+
/** The use counter options type */
|
|
99
99
|
interface UseCounterOptions {
|
|
100
100
|
/** The min of count value */
|
|
101
101
|
min?: number;
|
|
@@ -185,7 +185,7 @@ declare const useDefault: <Value>(initialValue: Value | (() => Value), defaultVa
|
|
|
185
185
|
*/
|
|
186
186
|
declare const useDidUpdate: (effect: React.EffectCallback, deps?: React.DependencyList) => void;
|
|
187
187
|
|
|
188
|
-
/** The use document title options */
|
|
188
|
+
/** The use document title options type */
|
|
189
189
|
interface UseDocumentTitleOptions {
|
|
190
190
|
/** Restore the previous title on unmount */
|
|
191
191
|
restoreOnUnmount?: boolean;
|
|
@@ -237,7 +237,7 @@ declare const useEvent: <Params extends unknown[], Return>(callback: (...args: P
|
|
|
237
237
|
|
|
238
238
|
type UseEventListenerTarget = React.RefObject<Element | null> | (() => Element) | Element | Window | Document;
|
|
239
239
|
type UseEventListenerOptions = boolean | AddEventListenerOptions;
|
|
240
|
-
type UseEventListenerReturn<Target extends UseEventListenerTarget
|
|
240
|
+
type UseEventListenerReturn<Target extends UseEventListenerTarget> = React.RefObject<Target>;
|
|
241
241
|
type UseEventListener = {
|
|
242
242
|
<Event extends keyof WindowEventMap = keyof WindowEventMap>(target: Window, event: Event | Event[], listener: (this: Window, event: WindowEventMap[Event]) => void, options?: UseEventListenerOptions): void;
|
|
243
243
|
<Event extends keyof DocumentEventMap = keyof DocumentEventMap>(target: Document, event: Event | Event[], listener: (this: Document, event: DocumentEventMap[Event]) => void, options?: UseEventListenerOptions): void;
|
|
@@ -266,7 +266,7 @@ declare const useFavicon: (initialHref?: string) => {
|
|
|
266
266
|
|
|
267
267
|
/** The use fullscreen target element type */
|
|
268
268
|
type UseFullScreenTarget = React.RefObject<Element | null> | (() => Element) | Element;
|
|
269
|
-
/** The use fullscreen options */
|
|
269
|
+
/** The use fullscreen options type */
|
|
270
270
|
interface UseFullScreenOptions {
|
|
271
271
|
/** initial value */
|
|
272
272
|
initialValue?: boolean;
|
|
@@ -348,7 +348,7 @@ type UseHotkeysKey = {
|
|
|
348
348
|
};
|
|
349
349
|
/**
|
|
350
350
|
* @name useHotkeys
|
|
351
|
-
* @description - Hook that listens for
|
|
351
|
+
* @description - Hook that listens for hotkeys
|
|
352
352
|
*
|
|
353
353
|
* @param {UseHotkeysHotkeys} hotkeys The key or keys to listen for
|
|
354
354
|
* @param {(event: KeyboardEvent) => void} callback The callback function to be called when the hotkey is pressed
|
|
@@ -371,10 +371,7 @@ interface UseHoverOptions {
|
|
|
371
371
|
onLeave?: () => void;
|
|
372
372
|
}
|
|
373
373
|
type UseHoverTarget = React.RefObject<Element | null> | Element;
|
|
374
|
-
type UseHoverReturn<Target extends UseHoverTarget
|
|
375
|
-
React.RefObject<Target>,
|
|
376
|
-
boolean
|
|
377
|
-
];
|
|
374
|
+
type UseHoverReturn<Target extends UseHoverTarget> = [React.RefObject<Target>, boolean];
|
|
378
375
|
type UseHover = {
|
|
379
376
|
<Target extends UseHoverTarget>(target: Target, callback?: () => void): boolean;
|
|
380
377
|
<Target extends UseHoverTarget>(target: Target, options?: UseHoverOptions): boolean;
|
|
@@ -453,7 +450,7 @@ declare const useIdle: (milliseconds?: number, { initialValue, events }?: UseIdl
|
|
|
453
450
|
|
|
454
451
|
type UseIntersectionObserverTarget = React.RefObject<Element | null> | (() => Element) | Element;
|
|
455
452
|
interface UseIntersectionObserverOptions extends Omit<IntersectionObserverInit, 'root'> {
|
|
456
|
-
|
|
453
|
+
enabled?: boolean;
|
|
457
454
|
onChange?: (entry: IntersectionObserverEntry) => void;
|
|
458
455
|
root?: IntersectionObserverInit['root'] | React.RefObject<Element | null>;
|
|
459
456
|
}
|
|
@@ -469,6 +466,49 @@ type UseIntersectionObserver = {
|
|
|
469
466
|
};
|
|
470
467
|
declare const useIntersectionObserver: UseIntersectionObserver;
|
|
471
468
|
|
|
469
|
+
/** The use interval options */
|
|
470
|
+
interface UseIntervalOptions {
|
|
471
|
+
/** Start the interval immediately */
|
|
472
|
+
enabled?: boolean;
|
|
473
|
+
}
|
|
474
|
+
/** The use interval return type */
|
|
475
|
+
interface UseIntervalReturn {
|
|
476
|
+
/** Is the interval active */
|
|
477
|
+
isActive: boolean;
|
|
478
|
+
/** Pause the interval */
|
|
479
|
+
pause: () => void;
|
|
480
|
+
/** Resume the interval */
|
|
481
|
+
resume: () => void;
|
|
482
|
+
}
|
|
483
|
+
type UseInterval = {
|
|
484
|
+
(callback: () => void, interval?: number, options?: UseIntervalOptions): UseIntervalReturn;
|
|
485
|
+
(callback: () => void, options?: UseIntervalOptions & {
|
|
486
|
+
interval?: number;
|
|
487
|
+
}): UseIntervalReturn;
|
|
488
|
+
};
|
|
489
|
+
/**
|
|
490
|
+
* @name useInterval
|
|
491
|
+
* @description - Hook that makes and interval and returns controlling functions
|
|
492
|
+
*
|
|
493
|
+
* @overload
|
|
494
|
+
* @param {() => void} callback Any callback function
|
|
495
|
+
* @param {number} [interval=1000] Time in milliseconds
|
|
496
|
+
* @param {boolean} [options.immediate=true] Start the interval immediately
|
|
497
|
+
* @returns {UseIntervalReturn}
|
|
498
|
+
*
|
|
499
|
+
* @example
|
|
500
|
+
* const { isActive, pause, resume } = useInterval(() => console.log('inside interval'), 2500);
|
|
501
|
+
*
|
|
502
|
+
* @overload
|
|
503
|
+
* @param {() => void} callback Any callback function
|
|
504
|
+
* @param {number} [options.interval=1000] Time in milliseconds
|
|
505
|
+
* @param {boolean} [options.immediate=true] Start the interval immediately
|
|
506
|
+
*
|
|
507
|
+
* @example
|
|
508
|
+
* const { isActive, pause, resume } = useInterval(() => console.log('inside interval'), { interval: 2500 });
|
|
509
|
+
*/
|
|
510
|
+
declare const useInterval: UseInterval;
|
|
511
|
+
|
|
472
512
|
/**
|
|
473
513
|
* @name useIsFirstRender
|
|
474
514
|
* @description - Hook that returns true if the component is first render
|
|
@@ -489,9 +529,31 @@ declare const useIsFirstRender: () => boolean;
|
|
|
489
529
|
*/
|
|
490
530
|
declare const useIsomorphicLayoutEffect: typeof React.useEffect;
|
|
491
531
|
|
|
532
|
+
/** The use key press options type */
|
|
533
|
+
type UseKeyboardParams = {
|
|
534
|
+
/** The target to attach the event listeners to */
|
|
535
|
+
target?: UseEventListenerTarget;
|
|
536
|
+
/** The callback function to be invoked on key down */
|
|
537
|
+
onKeyDown?: (event: KeyboardEvent) => void;
|
|
538
|
+
/** The callback function to be invoked on key up */
|
|
539
|
+
onKeyUp?: (event: KeyboardEvent) => void;
|
|
540
|
+
};
|
|
541
|
+
/**
|
|
542
|
+
* @name useKeyboard
|
|
543
|
+
* @description - Hook that help to listen for keyboard events
|
|
544
|
+
*
|
|
545
|
+
* @param {UseEventListenerTarget} [target=window] The target to attach the event listeners to
|
|
546
|
+
* @param {(event: KeyboardEvent) => void} [onKeyDown] The callback function to be invoked on key down
|
|
547
|
+
* @param {(event: KeyboardEvent) => void} [onKeyUp] The callback function to be invoked on key up
|
|
548
|
+
*
|
|
549
|
+
* @example
|
|
550
|
+
* useKeyboard({ onKeyDown: () => console.log('key down'), onKeyUp: () => console.log('key up') })
|
|
551
|
+
*/
|
|
552
|
+
declare const useKeyboard: (params?: UseKeyboardParams) => void;
|
|
553
|
+
|
|
492
554
|
/** The key or keys to listen for */
|
|
493
555
|
type UseKeyPressKey = string | string[];
|
|
494
|
-
/** The use key press options */
|
|
556
|
+
/** The use key press options type */
|
|
495
557
|
type UseKeyPressOptions = {
|
|
496
558
|
/** The target to attach the event listeners to */
|
|
497
559
|
target?: UseEventListenerTarget;
|
|
@@ -527,7 +589,7 @@ interface UseKeysPressedParams {
|
|
|
527
589
|
}
|
|
528
590
|
/**
|
|
529
591
|
* @name useKeysPressed
|
|
530
|
-
* @description - Hook
|
|
592
|
+
* @description - Hook for get keys that were pressed
|
|
531
593
|
*
|
|
532
594
|
* @param {UseEventListenerTarget} [params.target=window] The target to attach the event listeners to
|
|
533
595
|
* @param {boolean} [params.enabled=bollean] Enable or disable the event listeners
|
|
@@ -621,6 +683,53 @@ declare const useLocalStorage: <Value>(key: string, initialValue?: UseStorageIni
|
|
|
621
683
|
*/
|
|
622
684
|
declare const useLogger: (name: string, params: unknown[]) => void;
|
|
623
685
|
|
|
686
|
+
type UseLongPressTarget = React.RefObject<Element | null> | (() => Element) | Element;
|
|
687
|
+
interface UseLongPressOptions {
|
|
688
|
+
threshold?: number;
|
|
689
|
+
onStart?: (event: Event) => void;
|
|
690
|
+
onFinish?: (event: Event) => void;
|
|
691
|
+
onCancel?: (event: Event) => void;
|
|
692
|
+
}
|
|
693
|
+
type UseLongPressReturn<Target extends UseLongPressTarget> = [
|
|
694
|
+
React.RefObject<Target>,
|
|
695
|
+
boolean
|
|
696
|
+
];
|
|
697
|
+
type UseLongPress = {
|
|
698
|
+
<Target extends UseLongPressTarget>(target: Target, callback: (event: Event) => void, options?: UseLongPressOptions): boolean;
|
|
699
|
+
<Target extends UseLongPressTarget>(callback: (event: Event) => void, options?: UseLongPressOptions, target?: never): UseLongPressReturn<Target>;
|
|
700
|
+
};
|
|
701
|
+
/**
|
|
702
|
+
* @name useLongPress
|
|
703
|
+
* @description - Hook that defines the logic when long pressing an element
|
|
704
|
+
*
|
|
705
|
+
* @overload
|
|
706
|
+
* @template Target The target element
|
|
707
|
+
* @param {Target} target The target element to be long pressed
|
|
708
|
+
* @param {(event: Event) => void} callback The callback function to be invoked on long press
|
|
709
|
+
* @param {number} [options.threshold=400] The threshold time in milliseconds
|
|
710
|
+
* @param {(event: Event) => void} [options.onStart] The callback function to be invoked on long press start
|
|
711
|
+
* @param {(event: Event) => void} [options.onFinish] The callback function to be invoked on long press finish
|
|
712
|
+
* @param {(event: Event) => void} [options.onCancel] The callback function to be invoked on long press cancel
|
|
713
|
+
* @returns {void}
|
|
714
|
+
*
|
|
715
|
+
* @example
|
|
716
|
+
* const longPressing = useLongPress(ref, () => console.log('callback'));
|
|
717
|
+
*
|
|
718
|
+
* @overload
|
|
719
|
+
* @template Target The target element
|
|
720
|
+
* @param {Target} target The target element to be long pressed
|
|
721
|
+
* @param {(event: Event) => void} callback The callback function to be invoked on long press
|
|
722
|
+
* @param {number} [options.threshold=400] The threshold time in milliseconds
|
|
723
|
+
* @param {(event: Event) => void} [options.onStart] The callback function to be invoked on long press start
|
|
724
|
+
* @param {(event: Event) => void} [options.onFinish] The callback function to be invoked on long press finish
|
|
725
|
+
* @param {(event: Event) => void} [options.onCancel] The callback function to be invoked on long press cancel
|
|
726
|
+
* @returns {UseLongPressReturn<Target>} The ref of the target element
|
|
727
|
+
*
|
|
728
|
+
* @example
|
|
729
|
+
* const [ref, longPressing] = useLongPress(() => console.log('callback'));
|
|
730
|
+
*/
|
|
731
|
+
declare const useLongPress: UseLongPress;
|
|
732
|
+
|
|
624
733
|
/**
|
|
625
734
|
* @name useMediaQuery
|
|
626
735
|
* @description - Hook that manages a media query
|
|
@@ -688,6 +797,37 @@ type UseMouse = {
|
|
|
688
797
|
*/
|
|
689
798
|
declare const useMouse: UseMouse;
|
|
690
799
|
|
|
800
|
+
interface UseMutationOptions<Data> {
|
|
801
|
+
retry?: boolean | number;
|
|
802
|
+
onSuccess?: (data: Data) => void;
|
|
803
|
+
onError?: (error: Error) => void;
|
|
804
|
+
}
|
|
805
|
+
interface UseMutationReturn<Body, Data> {
|
|
806
|
+
data: Data | null;
|
|
807
|
+
error: Error | null;
|
|
808
|
+
mutate: (body: Body) => void;
|
|
809
|
+
mutateAsync: (body: Body) => Promise<Data>;
|
|
810
|
+
isLoading: boolean;
|
|
811
|
+
isError: boolean;
|
|
812
|
+
isSuccess: boolean;
|
|
813
|
+
}
|
|
814
|
+
/**
|
|
815
|
+
* @name useMutation
|
|
816
|
+
* @description - Hook that defines the logic when mutate data
|
|
817
|
+
*
|
|
818
|
+
* @template Body - The type of the body
|
|
819
|
+
* @template Data - The type of the data
|
|
820
|
+
* @param {(body: Body) => Promise<Data>} callback - The callback function to be invoked
|
|
821
|
+
* @param {boolean | number} [options.retry] - The retry count of requests
|
|
822
|
+
* @param {(data: Data) => void} [options.onSuccess] - The callback function to be invoked on success
|
|
823
|
+
* @param {(error: Error) => void} [options.onError] - The callback function to be invoked on error
|
|
824
|
+
* @returns {UseMutationReturn<Data>} An object with the state of the mutation
|
|
825
|
+
*
|
|
826
|
+
* @example
|
|
827
|
+
* const { mutate, mutateAsync, isLoading, isError, isSuccess, error, data } = useMutation((name) => Promise.resolve(name));
|
|
828
|
+
*/
|
|
829
|
+
declare const useMutation: <Body, Data>(callback: (body: Body) => Promise<Data>, options?: UseMutationOptions<Data>) => UseMutationReturn<Body, Data>;
|
|
830
|
+
|
|
691
831
|
type ConnectionType = Connection['type'];
|
|
692
832
|
type ConnectionEffectiveType = Connection['effectiveType'];
|
|
693
833
|
/** The use network return type */
|
|
@@ -796,6 +936,44 @@ declare const usePreferredLanguages: () => readonly string[];
|
|
|
796
936
|
*/
|
|
797
937
|
declare const usePrevious: <Value>(value: Value) => Value | undefined;
|
|
798
938
|
|
|
939
|
+
interface UseQueryOptions<QueryData, Data> {
|
|
940
|
+
keys?: React.DependencyList;
|
|
941
|
+
onSuccess?: (data: Data) => void;
|
|
942
|
+
onError?: (error: Error) => void;
|
|
943
|
+
select?: (data: QueryData) => Data;
|
|
944
|
+
initialData?: Data | (() => Data);
|
|
945
|
+
placeholderData?: Data | (() => Data);
|
|
946
|
+
retry?: boolean | number;
|
|
947
|
+
}
|
|
948
|
+
interface UseQueryReturn<Data> {
|
|
949
|
+
data: Data | undefined;
|
|
950
|
+
isLoading: boolean;
|
|
951
|
+
isError: boolean;
|
|
952
|
+
isSuccess: boolean;
|
|
953
|
+
error: Error | undefined;
|
|
954
|
+
refetch: () => void;
|
|
955
|
+
isRefetching: boolean;
|
|
956
|
+
}
|
|
957
|
+
/**
|
|
958
|
+
* @name useQuery
|
|
959
|
+
* @description - Hook that defines the logic when query data
|
|
960
|
+
*
|
|
961
|
+
* @template Data - The type of the data
|
|
962
|
+
* @param {() => Promise<Data>} callback - The callback function to be invoked
|
|
963
|
+
* @param {React.DependencyList} [options.keys] - The dependencies for the hook
|
|
964
|
+
* @param {(data: Data) => void} [options.onSuccess] - The callback function to be invoked on success
|
|
965
|
+
* @param {(error: Error) => void} [options.onError] - The callback function to be invoked on error
|
|
966
|
+
* @param {UseQueryOptionsSelect<Data>} [options.select] - The select function to be invoked
|
|
967
|
+
* @param {Data | (() => Data)} [options.initialData] - The initial data for the hook
|
|
968
|
+
* @param {Data | (() => Data)} [options.placeholderData] - The placeholder data for the hook
|
|
969
|
+
* @param {boolean | number} [options.retry] - The retry count of requests
|
|
970
|
+
* @returns {UseQueryReturn<Data>} An object with the state of the query
|
|
971
|
+
*
|
|
972
|
+
* @example
|
|
973
|
+
* const { data, isLoading, isError, isSuccess, error, refetch, isRefetching } = useQuery(() => fetch('https://example.com/data'));
|
|
974
|
+
*/
|
|
975
|
+
declare const useQuery: <QueryData, Data = QueryData>(callback: () => Promise<QueryData>, options?: UseQueryOptions<QueryData, Data>) => UseQueryReturn<Data>;
|
|
976
|
+
|
|
799
977
|
/** The use queue return type */
|
|
800
978
|
interface UseQueueReturn<Value> {
|
|
801
979
|
/** The current queue */
|
|
@@ -1071,8 +1249,10 @@ declare const useWindowSize: (params?: UseWindowSizeParams) => {
|
|
|
1071
1249
|
|
|
1072
1250
|
declare const debounce: <Params extends unknown[]>(callback: (...args: Params) => void, delay: number) => ((...args: Params) => void);
|
|
1073
1251
|
|
|
1252
|
+
declare const getRetry: (retry: number | boolean) => number;
|
|
1253
|
+
|
|
1074
1254
|
declare const isClient: boolean;
|
|
1075
1255
|
|
|
1076
1256
|
declare const throttle: <Params extends any[]>(callback: (...args: Params) => void, delay: number) => ((...args: Params) => void);
|
|
1077
1257
|
|
|
1078
|
-
export { type ConnectionEffectiveType, type ConnectionType, type OperatingSystem, SCRIPT_STATUS_ATTRIBUTE_NAME, type UseClickOutside, type UseClickOutsideReturn, type UseCounter, type UseCounterOptions, type UseCounterParams, type UseCounterReturn, type UseDocumentTitleOptions, type UseDocumentTitleReturn, type UseEventListener, type UseEventListenerOptions, type UseEventListenerReturn, type UseEventListenerTarget, type UseFaviconReturn, type UseFullScreen, type UseFullScreenOptions, type UseFullScreenReturn, type UseHotkeysHotkeys, type UseHotkeysKey, type UseHotkeysOptions, type UseHover, type UseHoverOptions, type UseHoverReturn, type UseHoverTarget, type UseIdleReturn, type UseIntersectionObserver, type UseIntersectionObserverOptions, type UseIntersectionObserverReturn, type UseIntersectionObserverTarget, type UseKeyPressEvent, type UseKeyPressEventKey, type UseKeyPressKey, type UseKeyPressOptions, type UseListReturn, type UseMouse, type UseMouseReturn, type UseNetworkReturn, type UseOrientationReturn, type UseQueueReturn, type UseScriptOptions, type UseScriptStatus, type UseStorageInitialValue, type UseStorageOptions, type UseStorageReturn, type UseTextSelectionReturn, type UseToggleReturn, type UseWindowSizeReturn, debounce, dispatchStorageEvent, getConnection, getOperatingSystem, getRangesSelection, isClient, isHotkeyMatch, legacyCopyToClipboard, throttle, useBattery, useBoolean, useClickOutside, useCopyToClipboard, useCounter, useDebouncedValue, useDefault, useDidUpdate, useDocumentTitle, useDocumentVisibility, useEvent, useEventListener, useFavicon, useFullscreen, useHash, useHotkeys, useHover, useIdle, useIntersectionObserver, useIsFirstRender, useIsomorphicLayoutEffect, useKeyPress, useKeyPressEvent, useKeysPressed, useList, useLocalStorage, useLogger, useMediaQuery, useMount, useMouse, useNetwork, useOnline, useOperatingSystem, useOrientation, usePageLeave, usePreferredLanguages, usePrevious, useQueue, useRenderCount, useRerender, useScript, useSessionStorage, useSet, useStep, useStorage, useTextSelection, useTimeout, useToggle, useUnmount, useWindowEvent, useWindowSize };
|
|
1258
|
+
export { type ConnectionEffectiveType, type ConnectionType, type OperatingSystem, SCRIPT_STATUS_ATTRIBUTE_NAME, type UseClickOutside, type UseClickOutsideReturn, type UseCounter, type UseCounterOptions, type UseCounterParams, type UseCounterReturn, type UseDocumentTitleOptions, type UseDocumentTitleReturn, type UseEventListener, type UseEventListenerOptions, type UseEventListenerReturn, type UseEventListenerTarget, type UseFaviconReturn, type UseFullScreen, type UseFullScreenOptions, type UseFullScreenReturn, type UseHotkeysHotkeys, type UseHotkeysKey, type UseHotkeysOptions, type UseHover, type UseHoverOptions, type UseHoverReturn, type UseHoverTarget, type UseIdleReturn, type UseIntersectionObserver, type UseIntersectionObserverOptions, type UseIntersectionObserverReturn, type UseIntersectionObserverTarget, type UseIntervalOptions, type UseIntervalReturn, type UseKeyPressEvent, type UseKeyPressEventKey, type UseKeyPressKey, type UseKeyPressOptions, type UseKeyboardParams, type UseListReturn, type UseLongPress, type UseLongPressReturn, type UseLongPressTarget, type UseMouse, type UseMouseReturn, type UseNetworkReturn, type UseOrientationReturn, type UseQueueReturn, type UseScriptOptions, type UseScriptStatus, type UseStorageInitialValue, type UseStorageOptions, type UseStorageReturn, type UseTextSelectionReturn, type UseToggleReturn, type UseWindowSizeReturn, debounce, dispatchStorageEvent, getConnection, getOperatingSystem, getRangesSelection, getRetry, isClient, isHotkeyMatch, legacyCopyToClipboard, throttle, useBattery, useBoolean, useClickOutside, useCopyToClipboard, useCounter, useDebouncedValue, useDefault, useDidUpdate, useDocumentTitle, useDocumentVisibility, useEvent, useEventListener, useFavicon, useFullscreen, useHash, useHotkeys, useHover, useIdle, useIntersectionObserver, useInterval, useIsFirstRender, useIsomorphicLayoutEffect, useKeyPress, useKeyPressEvent, useKeyboard, useKeysPressed, useList, useLocalStorage, useLogger, useLongPress, useMediaQuery, useMount, useMouse, useMutation, useNetwork, useOnline, useOperatingSystem, useOrientation, usePageLeave, usePreferredLanguages, usePrevious, useQuery, useQueue, useRenderCount, useRerender, useScript, useSessionStorage, useSet, useStep, useStorage, useTextSelection, useTimeout, useToggle, useUnmount, useWindowEvent, useWindowSize };
|