@siberiacancode/reactuse 0.0.19 → 0.0.20
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-BNQyJZ2M.js} +2 -2
- package/dist/cjs/_rollupPluginBabelHelpers-BNQyJZ2M.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/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/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-jvrIKhwu.js} +2 -2
- package/dist/esm/_rollupPluginBabelHelpers-jvrIKhwu.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/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/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 +149 -12
- 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.
|
|
2
|
-
import{_ as e}from"../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.20 */
|
|
2
|
+
import{_ as e}from"../../_rollupPluginBabelHelpers-jvrIKhwu.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.20 */
|
|
2
|
+
import{b as o}from"../../_rollupPluginBabelHelpers-jvrIKhwu.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.20 */
|
|
2
|
+
import r from"react";import{useRerender as e}from"../useRerender/useRerender.js";import"../../_rollupPluginBabelHelpers-jvrIKhwu.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.20 */
|
|
2
|
+
import{a as t,_ as r}from"../../_rollupPluginBabelHelpers-jvrIKhwu.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.20 */
|
|
2
|
+
import{a as e}from"../../_rollupPluginBabelHelpers-jvrIKhwu.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.20 */
|
|
2
|
+
import{_ as e}from"../../_rollupPluginBabelHelpers-jvrIKhwu.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.20 */
|
|
2
|
+
import{_ as e}from"../../_rollupPluginBabelHelpers-jvrIKhwu.js";import r from"react";import{useIsomorphicLayoutEffect as t}from"../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js";import"../../utils/helpers/isClient.js";function u(u,o){var n=r.useState(!1),c=e(n,2),i=c[0],f=c[1],s=r.useRef(u),m=r.useRef();t((function(){s.current=u}),[u]),r.useEffect((function(){return m.current=setTimeout((function(){s.current(),f(!0)}),o),function(){clearTimeout(m.current)}}),[o]);return{ready:i,clear:function(){clearTimeout(m.current),f(!0)}}}export{u 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.20 */
|
|
2
|
+
import{_ as r}from"../../_rollupPluginBabelHelpers-jvrIKhwu.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.20 */
|
|
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.20 */
|
|
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.20 */
|
|
2
|
+
import{_ as i}from"../../_rollupPluginBabelHelpers-jvrIKhwu.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.20 */
|
|
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{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-jvrIKhwu.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.20 */
|
|
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.20 */
|
|
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.20 */
|
|
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.20 */
|
|
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;
|
|
@@ -489,9 +486,31 @@ declare const useIsFirstRender: () => boolean;
|
|
|
489
486
|
*/
|
|
490
487
|
declare const useIsomorphicLayoutEffect: typeof React.useEffect;
|
|
491
488
|
|
|
489
|
+
/** The use key press options type */
|
|
490
|
+
type UseKeyboardParams = {
|
|
491
|
+
/** The target to attach the event listeners to */
|
|
492
|
+
target?: UseEventListenerTarget;
|
|
493
|
+
/** The callback function to be invoked on key down */
|
|
494
|
+
onKeyDown?: (event: KeyboardEvent) => void;
|
|
495
|
+
/** The callback function to be invoked on key up */
|
|
496
|
+
onKeyUp?: (event: KeyboardEvent) => void;
|
|
497
|
+
};
|
|
498
|
+
/**
|
|
499
|
+
* @name useKeyboard
|
|
500
|
+
* @description - Hook that listens for key press events
|
|
501
|
+
*
|
|
502
|
+
* @param {UseEventListenerTarget} [target=window] The target to attach the event listeners to
|
|
503
|
+
* @param {(event: KeyboardEvent) => void} [onKeyDown] The callback function to be invoked on key down
|
|
504
|
+
* @param {(event: KeyboardEvent) => void} [onKeyUp] The callback function to be invoked on key up
|
|
505
|
+
*
|
|
506
|
+
* @example
|
|
507
|
+
* useKeyboard({ onKeyDown: () => console.log('key down'), onKeyUp: () => console.log('key up') })
|
|
508
|
+
*/
|
|
509
|
+
declare const useKeyboard: (params?: UseKeyboardParams) => void;
|
|
510
|
+
|
|
492
511
|
/** The key or keys to listen for */
|
|
493
512
|
type UseKeyPressKey = string | string[];
|
|
494
|
-
/** The use key press options */
|
|
513
|
+
/** The use key press options type */
|
|
495
514
|
type UseKeyPressOptions = {
|
|
496
515
|
/** The target to attach the event listeners to */
|
|
497
516
|
target?: UseEventListenerTarget;
|
|
@@ -527,7 +546,7 @@ interface UseKeysPressedParams {
|
|
|
527
546
|
}
|
|
528
547
|
/**
|
|
529
548
|
* @name useKeysPressed
|
|
530
|
-
* @description - Hook
|
|
549
|
+
* @description - Hook for get keys that were pressed
|
|
531
550
|
*
|
|
532
551
|
* @param {UseEventListenerTarget} [params.target=window] The target to attach the event listeners to
|
|
533
552
|
* @param {boolean} [params.enabled=bollean] Enable or disable the event listeners
|
|
@@ -621,6 +640,53 @@ declare const useLocalStorage: <Value>(key: string, initialValue?: UseStorageIni
|
|
|
621
640
|
*/
|
|
622
641
|
declare const useLogger: (name: string, params: unknown[]) => void;
|
|
623
642
|
|
|
643
|
+
type UseLongPressTarget = React.RefObject<Element | null> | (() => Element) | Element;
|
|
644
|
+
interface UseLongPressOptions {
|
|
645
|
+
threshold?: number;
|
|
646
|
+
onStart?: (event: Event) => void;
|
|
647
|
+
onFinish?: (event: Event) => void;
|
|
648
|
+
onCancel?: (event: Event) => void;
|
|
649
|
+
}
|
|
650
|
+
type UseLongPressReturn<Target extends UseLongPressTarget> = [
|
|
651
|
+
React.RefObject<Target>,
|
|
652
|
+
boolean
|
|
653
|
+
];
|
|
654
|
+
type UseLongPress = {
|
|
655
|
+
<Target extends UseLongPressTarget>(target: Target, callback: (event: Event) => void, options?: UseLongPressOptions): boolean;
|
|
656
|
+
<Target extends UseLongPressTarget>(callback: (event: Event) => void, options?: UseLongPressOptions, target?: never): UseLongPressReturn<Target>;
|
|
657
|
+
};
|
|
658
|
+
/**
|
|
659
|
+
* @name useLongPress
|
|
660
|
+
* @description - Hook that defines the logic when long pressing an element
|
|
661
|
+
*
|
|
662
|
+
* @overload
|
|
663
|
+
* @template Target The target element
|
|
664
|
+
* @param {Target} target The target element to be long pressed
|
|
665
|
+
* @param {(event: Event) => void} callback The callback function to be invoked on long press
|
|
666
|
+
* @param {number} [options.threshold=400] The threshold time in milliseconds
|
|
667
|
+
* @param {(event: Event) => void} [options.onStart] The callback function to be invoked on long press start
|
|
668
|
+
* @param {(event: Event) => void} [options.onFinish] The callback function to be invoked on long press finish
|
|
669
|
+
* @param {(event: Event) => void} [options.onCancel] The callback function to be invoked on long press cancel
|
|
670
|
+
* @returns {void}
|
|
671
|
+
*
|
|
672
|
+
* @example
|
|
673
|
+
* const longPressing = useLongPress(ref, () => console.log('callback'));
|
|
674
|
+
*
|
|
675
|
+
* @overload
|
|
676
|
+
* @template Target The target element
|
|
677
|
+
* @param {Target} target The target element to be long pressed
|
|
678
|
+
* @param {(event: Event) => void} callback The callback function to be invoked on long press
|
|
679
|
+
* @param {number} [options.threshold=400] The threshold time in milliseconds
|
|
680
|
+
* @param {(event: Event) => void} [options.onStart] The callback function to be invoked on long press start
|
|
681
|
+
* @param {(event: Event) => void} [options.onFinish] The callback function to be invoked on long press finish
|
|
682
|
+
* @param {(event: Event) => void} [options.onCancel] The callback function to be invoked on long press cancel
|
|
683
|
+
* @returns {UseLongPressReturn<Target>} The ref of the target element
|
|
684
|
+
*
|
|
685
|
+
* @example
|
|
686
|
+
* const [ref, longPressing] = useLongPress(() => console.log('callback'));
|
|
687
|
+
*/
|
|
688
|
+
declare const useLongPress: UseLongPress;
|
|
689
|
+
|
|
624
690
|
/**
|
|
625
691
|
* @name useMediaQuery
|
|
626
692
|
* @description - Hook that manages a media query
|
|
@@ -688,6 +754,37 @@ type UseMouse = {
|
|
|
688
754
|
*/
|
|
689
755
|
declare const useMouse: UseMouse;
|
|
690
756
|
|
|
757
|
+
interface UseMutationOptions<Data> {
|
|
758
|
+
retry?: boolean | number;
|
|
759
|
+
onSuccess?: (data: Data) => void;
|
|
760
|
+
onError?: (error: Error) => void;
|
|
761
|
+
}
|
|
762
|
+
interface UseMutationReturn<Body, Data> {
|
|
763
|
+
data: Data | null;
|
|
764
|
+
error: Error | null;
|
|
765
|
+
mutate: (body: Body) => void;
|
|
766
|
+
mutateAsync: (body: Body) => Promise<Data>;
|
|
767
|
+
isLoading: boolean;
|
|
768
|
+
isError: boolean;
|
|
769
|
+
isSuccess: boolean;
|
|
770
|
+
}
|
|
771
|
+
/**
|
|
772
|
+
* @name useMutation
|
|
773
|
+
* @description - Hook that defines the logic when mutate data
|
|
774
|
+
*
|
|
775
|
+
* @template Body - The type of the body
|
|
776
|
+
* @template Data - The type of the data
|
|
777
|
+
* @param {(body: Body) => Promise<Data>} callback - The callback function to be invoked
|
|
778
|
+
* @param {boolean | number} [options.retry] - The retry count of requests
|
|
779
|
+
* @param {(data: Data) => void} [options.onSuccess] - The callback function to be invoked on success
|
|
780
|
+
* @param {(error: Error) => void} [options.onError] - The callback function to be invoked on error
|
|
781
|
+
* @returns {UseMutationReturn<Data>} An object with the state of the mutation
|
|
782
|
+
*
|
|
783
|
+
* @example
|
|
784
|
+
* const { mutate, mutateAsync, isLoading, isError, isSuccess, error, data } = useMutation((name) => Promise.resolve(name));
|
|
785
|
+
*/
|
|
786
|
+
declare const useMutation: <Body, Data>(callback: (body: Body) => Promise<Data>, options?: UseMutationOptions<Data>) => UseMutationReturn<Body, Data>;
|
|
787
|
+
|
|
691
788
|
type ConnectionType = Connection['type'];
|
|
692
789
|
type ConnectionEffectiveType = Connection['effectiveType'];
|
|
693
790
|
/** The use network return type */
|
|
@@ -796,6 +893,44 @@ declare const usePreferredLanguages: () => readonly string[];
|
|
|
796
893
|
*/
|
|
797
894
|
declare const usePrevious: <Value>(value: Value) => Value | undefined;
|
|
798
895
|
|
|
896
|
+
interface UseQueryOptions<QueryData, Data> {
|
|
897
|
+
keys?: React.DependencyList;
|
|
898
|
+
onSuccess?: (data: Data) => void;
|
|
899
|
+
onError?: (error: Error) => void;
|
|
900
|
+
select?: (data: QueryData) => Data;
|
|
901
|
+
initialData?: Data | (() => Data);
|
|
902
|
+
placeholderData?: Data | (() => Data);
|
|
903
|
+
retry?: boolean | number;
|
|
904
|
+
}
|
|
905
|
+
interface UseQueryReturn<Data> {
|
|
906
|
+
data: Data | undefined;
|
|
907
|
+
isLoading: boolean;
|
|
908
|
+
isError: boolean;
|
|
909
|
+
isSuccess: boolean;
|
|
910
|
+
error: Error | undefined;
|
|
911
|
+
refetch: () => void;
|
|
912
|
+
isRefetching: boolean;
|
|
913
|
+
}
|
|
914
|
+
/**
|
|
915
|
+
* @name useQuery
|
|
916
|
+
* @description - Hook that defines the logic when query data
|
|
917
|
+
*
|
|
918
|
+
* @template Data - The type of the data
|
|
919
|
+
* @param {() => Promise<Data>} callback - The callback function to be invoked
|
|
920
|
+
* @param {React.DependencyList} [options.keys] - The dependencies for the hook
|
|
921
|
+
* @param {(data: Data) => void} [options.onSuccess] - The callback function to be invoked on success
|
|
922
|
+
* @param {(error: Error) => void} [options.onError] - The callback function to be invoked on error
|
|
923
|
+
* @param {UseQueryOptionsSelect<Data>} [options.select] - The select function to be invoked
|
|
924
|
+
* @param {Data | (() => Data)} [options.initialData] - The initial data for the hook
|
|
925
|
+
* @param {Data | (() => Data)} [options.placeholderData] - The placeholder data for the hook
|
|
926
|
+
* @param {boolean | number} [options.retry] - The retry count of requests
|
|
927
|
+
* @returns {UseQueryReturn<Data>} An object with the state of the query
|
|
928
|
+
*
|
|
929
|
+
* @example
|
|
930
|
+
* const { data, isLoading, isError, isSuccess, error, refetch, isRefetching } = useQuery(() => fetch('https://example.com/data'));
|
|
931
|
+
*/
|
|
932
|
+
declare const useQuery: <QueryData, Data = QueryData>(callback: () => Promise<QueryData>, options?: UseQueryOptions<QueryData, Data>) => UseQueryReturn<Data>;
|
|
933
|
+
|
|
799
934
|
/** The use queue return type */
|
|
800
935
|
interface UseQueueReturn<Value> {
|
|
801
936
|
/** The current queue */
|
|
@@ -1071,8 +1206,10 @@ declare const useWindowSize: (params?: UseWindowSizeParams) => {
|
|
|
1071
1206
|
|
|
1072
1207
|
declare const debounce: <Params extends unknown[]>(callback: (...args: Params) => void, delay: number) => ((...args: Params) => void);
|
|
1073
1208
|
|
|
1209
|
+
declare const getRetry: (retry: number | boolean) => number;
|
|
1210
|
+
|
|
1074
1211
|
declare const isClient: boolean;
|
|
1075
1212
|
|
|
1076
1213
|
declare const throttle: <Params extends any[]>(callback: (...args: Params) => void, delay: number) => ((...args: Params) => void);
|
|
1077
1214
|
|
|
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 };
|
|
1215
|
+
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 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, 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 };
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_rollupPluginBabelHelpers-OWhzq4gx.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_rollupPluginBabelHelpers-DzIe9o0q.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|