@siberiacancode/reactuse 0.0.11 → 0.0.12
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-OMepdpg5.js → _rollupPluginBabelHelpers-M-utHMXq.js} +2 -2
- package/dist/cjs/_rollupPluginBabelHelpers-M-utHMXq.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/useClickOutside/useClickOutside.js.map +1 -1
- package/dist/cjs/hooks/useCopyToClipboard/useCopyToClipboard.js +2 -2
- package/dist/cjs/hooks/useCounter/useCounter.js +2 -2
- 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/useDocumentVisibility/useDocumentVisibility.js +1 -1
- package/dist/cjs/hooks/useEvent/useEvent.js +1 -1
- package/dist/cjs/hooks/useEventListener/useEventListener.js +1 -1
- package/dist/cjs/hooks/useFavicon/useFavicon.js +2 -2
- package/dist/cjs/hooks/useFavicon/useFavicon.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/useHover/useHover.js +2 -2
- 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/useKeyPressEvent/useKeyPressEvent.js +1 -1
- package/dist/cjs/hooks/useKeysPressed/useKeysPressed.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/useMediaQuery/useMediaQuery.js +1 -1
- package/dist/cjs/hooks/useMount/useMount.js +1 -1
- package/dist/cjs/hooks/useMutationObserver.js +1 -1
- package/dist/cjs/hooks/useNetwork/useNetwork.js +1 -1
- 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/useOrientation/useOrientation.js.map +1 -1
- package/dist/cjs/hooks/usePageLeave/usePageLeave.js +3 -0
- package/dist/cjs/hooks/usePageLeave/usePageLeave.js.map +1 -0
- package/dist/cjs/hooks/usePrevious/usePrevious.js +1 -1
- 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/useSet/useSet.js.map +1 -1
- package/dist/cjs/hooks/useStep/useStep.js +2 -2
- package/dist/cjs/hooks/useStorage/useStorage.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/hooks/useWindowSize/useWindowSize.js.map +1 -1
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/utils/helpers/debounce.js +1 -1
- package/dist/cjs/utils/helpers/index.js +1 -1
- package/dist/cjs/utils/helpers/isClient.js +1 -1
- package/dist/cjs/utils/helpers/isShallowEqual.js +1 -1
- package/dist/cjs/utils/helpers/throttle.js +1 -1
- package/dist/esm/{_rollupPluginBabelHelpers-TF5Io098.js → _rollupPluginBabelHelpers-BrlXN-wU.js} +2 -2
- package/dist/esm/_rollupPluginBabelHelpers-BrlXN-wU.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/useClickOutside/useClickOutside.js.map +1 -1
- package/dist/esm/hooks/useCopyToClipboard/useCopyToClipboard.js +2 -2
- package/dist/esm/hooks/useCounter/useCounter.js +2 -2
- 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/useDocumentVisibility/useDocumentVisibility.js +1 -1
- package/dist/esm/hooks/useEvent/useEvent.js +1 -1
- package/dist/esm/hooks/useEventListener/useEventListener.js +1 -1
- package/dist/esm/hooks/useFavicon/useFavicon.js +2 -2
- package/dist/esm/hooks/useFavicon/useFavicon.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/useHover/useHover.js +2 -2
- 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/useKeyPressEvent/useKeyPressEvent.js +1 -1
- package/dist/esm/hooks/useKeysPressed/useKeysPressed.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/useMediaQuery/useMediaQuery.js +1 -1
- package/dist/esm/hooks/useMount/useMount.js +1 -1
- package/dist/esm/hooks/useMutationObserver.js +1 -1
- package/dist/esm/hooks/useNetwork/useNetwork.js +1 -1
- 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/useOrientation/useOrientation.js.map +1 -1
- package/dist/esm/hooks/usePageLeave/usePageLeave.js +3 -0
- package/dist/esm/hooks/usePageLeave/usePageLeave.js.map +1 -0
- package/dist/esm/hooks/usePrevious/usePrevious.js +1 -1
- 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/useSet/useSet.js.map +1 -1
- package/dist/esm/hooks/useStep/useStep.js +2 -2
- package/dist/esm/hooks/useStorage/useStorage.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/hooks/useWindowSize/useWindowSize.js.map +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/utils/helpers/debounce.js +1 -1
- package/dist/esm/utils/helpers/index.js +1 -1
- package/dist/esm/utils/helpers/isClient.js +1 -1
- package/dist/esm/utils/helpers/isShallowEqual.js +1 -1
- package/dist/esm/utils/helpers/throttle.js +1 -1
- package/dist/index.d.ts +50 -11
- package/package.json +1 -1
- package/dist/cjs/_rollupPluginBabelHelpers-OMepdpg5.js.map +0 -1
- package/dist/esm/_rollupPluginBabelHelpers-TF5Io098.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.12 */
|
|
2
|
+
import{_ as e}from"../../_rollupPluginBabelHelpers-BrlXN-wU.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.12 */
|
|
2
|
+
import{b as o}from"../../_rollupPluginBabelHelpers-BrlXN-wU.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.12 */
|
|
2
|
+
import r from"react";import{useRerender as e}from"../useRerender/useRerender.js";import"../../_rollupPluginBabelHelpers-BrlXN-wU.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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSet.js","sources":["../../../../src/hooks/useSet/useSet.ts"],"sourcesContent":["import React from 'react';\n\nimport { useRerender } from '../useRerender/useRerender';\n\n/**\n * @name useSet\n * @description - Hook that manages a set structure\n *\n * @template Value The type of the value\n * @param {Value[]} values The initial array of the set\n * @returns {Set<Value>} A set structure\n *\n * @example\n * const set = useSet([1, 2, 3]);\n */\nexport const useSet = <Value>(values
|
|
1
|
+
{"version":3,"file":"useSet.js","sources":["../../../../src/hooks/useSet/useSet.ts"],"sourcesContent":["import React from 'react';\n\nimport { useRerender } from '../useRerender/useRerender';\n\n/**\n * @name useSet\n * @description - Hook that manages a set structure\n *\n * @template Value The type of the value\n * @param {Value[]} [values] The initial array of the set\n * @returns {Set<Value>} A set structure\n *\n * @example\n * const set = useSet([1, 2, 3]);\n */\nexport const useSet = <Value>(values?: Value[]) => {\n const setRef = React.useRef(new Set(values));\n const rerender = useRerender();\n\n setRef.current.add = (...args) => {\n const result = Set.prototype.add.apply(setRef.current, args);\n rerender.update();\n return result;\n };\n\n setRef.current.clear = (...args) => {\n Set.prototype.clear.apply(setRef.current, args);\n rerender.update();\n };\n\n setRef.current.delete = (...args) => {\n const result = Set.prototype.delete.apply(setRef.current, args);\n rerender.update();\n return result;\n };\n\n return setRef.current;\n};\n"],"names":["useSet","values","setRef","React","useRef","Set","rerender","useRerender","current","add","_len","arguments","length","args","Array","_key","result","prototype","apply","update","clear","_len2","_key2","_len3","_key3"],"mappings":";yIAeaA,EAAS,SAAQC,GAC5B,IAAMC,EAASC,EAAMC,OAAO,IAAIC,IAAIJ,IAC9BK,EAAWC,IAmBjB,OAjBAL,EAAOM,QAAQC,IAAM,WAAa,IAAA,IAAAC,EAAAC,UAAAC,OAATC,EAAIC,IAAAA,MAAAJ,GAAAK,EAAA,EAAAA,EAAAL,EAAAK,IAAJF,EAAIE,GAAAJ,UAAAI,GAC3B,IAAMC,EAASX,IAAIY,UAAUR,IAAIS,MAAMhB,EAAOM,QAASK,GAEvD,OADAP,EAASa,SACFH,GAGTd,EAAOM,QAAQY,MAAQ,WAAa,IAAA,IAAAC,EAAAV,UAAAC,OAATC,EAAIC,IAAAA,MAAAO,GAAAC,EAAA,EAAAA,EAAAD,EAAAC,IAAJT,EAAIS,GAAAX,UAAAW,GAC7BjB,IAAIY,UAAUG,MAAMF,MAAMhB,EAAOM,QAASK,GAC1CP,EAASa,UAGXjB,EAAOM,QAAc,OAAG,WAAa,IAAA,IAAAe,EAAAZ,UAAAC,OAATC,EAAIC,IAAAA,MAAAS,GAAAC,EAAA,EAAAA,EAAAD,EAAAC,IAAJX,EAAIW,GAAAb,UAAAa,GAC9B,IAAMR,EAASX,IAAIY,UAAgB,OAACC,MAAMhB,EAAOM,QAASK,GAE1D,OADAP,EAASa,SACFH,GAGFd,EAAOM,OAChB"}
|
|
@@ -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.12 */
|
|
2
|
+
import{a as t,_ as r}from"../../_rollupPluginBabelHelpers-BrlXN-wU.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.12 */
|
|
2
|
+
import{a as e}from"../../_rollupPluginBabelHelpers-BrlXN-wU.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.12 */
|
|
2
|
+
import{_ as e}from"../../_rollupPluginBabelHelpers-BrlXN-wU.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.12 */
|
|
2
|
+
import{_ as r}from"../../_rollupPluginBabelHelpers-BrlXN-wU.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.12 */
|
|
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.12 */
|
|
2
2
|
import{useEventListener as e}from"../useEventListener/useEventListener.js";import"react";var r=function(r,t,n){return e(window,r,t,n)};export{r 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.12 */
|
|
2
|
+
import{_ as i}from"../../_rollupPluginBabelHelpers-BrlXN-wU.js";import e from"react";import{isClient as n}from"../../utils/helpers/isClient.js";import{useEventListener as t}from"../useEventListener/useEventListener.js";var r=function(r){var o,l,d=e.useState({width:n?window.innerWidth:null!==(o=null==r?void 0:r.initialWidth)&&void 0!==o?o:Number.POSITIVE_INFINITY,height:n?window.innerHeight:null!==(l=null==r?void 0:r.initialWidth)&&void 0!==l?l:Number.POSITIVE_INFINITY}),u=i(d,2),s=u[0],h=u[1];return t(window,"resize",(function(){h({width:window.innerWidth,height:window.innerHeight})})),s};export{r as useWindowSize};
|
|
3
3
|
//# sourceMappingURL=useWindowSize.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWindowSize.js","sources":["../../../../src/hooks/useWindowSize/useWindowSize.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"useWindowSize.js","sources":["../../../../src/hooks/useWindowSize/useWindowSize.ts"],"sourcesContent":["import React from 'react';\n\nimport { isClient } from '@/utils/helpers';\n\nimport { useEventListener } from '../useEventListener/useEventListener';\n\n/** The use window size return type */\ninterface UseWindowSizeParams {\n /** The initial window width */\n initialWidth?: number;\n /** The initial window height */\n initialHeight?: number;\n}\n\n/** The use window size return type */\nexport interface UseWindowSizeReturn {\n /** The current window width */\n width: number;\n /** The current window height */\n height: number;\n}\n\n/**\n * @name useWindowSize\n * @description - Hook that manages a window size\n *\n * @param {number} [params.initialWidth=Number.POSITIVE_INFINITY] The initial window width\n * @param {number} [params.initialHeight=Number.POSITIVE_INFINITY] The initial window height\n * @returns {UseWindowSizeReturn} An object containing the current window width and height\n *\n * @example\n * const { width, height } = useWindowSize()\n */\nexport const useWindowSize = (params?: UseWindowSizeParams) => {\n const [size, setSize] = React.useState({\n width: isClient ? window.innerWidth : params?.initialWidth ?? Number.POSITIVE_INFINITY,\n height: isClient ? window.innerHeight : params?.initialWidth ?? Number.POSITIVE_INFINITY\n });\n\n useEventListener(window, 'resize', () => {\n setSize({\n width: window.innerWidth,\n height: window.innerHeight\n });\n });\n\n return size;\n};\n"],"names":["useWindowSize","params","_params$initialWidth","_params$initialWidth2","_React$useState","React","useState","width","isClient","window","innerWidth","initialWidth","Number","POSITIVE_INFINITY","height","innerHeight","_React$useState2","_slicedToArray","size","setSize","useEventListener"],"mappings":";+NAiCaA,EAAgB,SAACC,GAAiC,IAAAC,EAAAC,EAC7DC,EAAwBC,EAAMC,SAAS,CACrCC,MAAOC,EAAWC,OAAOC,WAAiCR,QAAvBA,EAAGD,aAAAA,EAAAA,EAAQU,wBAAYT,EAAAA,EAAIU,OAAOC,kBACrEC,OAAQN,EAAWC,OAAOM,YAAkC,QAAvBZ,EAAGF,aAAAA,EAAAA,EAAQU,oBAAYR,IAAAA,EAAAA,EAAIS,OAAOC,oBACvEG,EAAAC,EAAAb,EAAA,GAHKc,EAAIF,EAAA,GAAEG,EAAOH,EAAA,GAYpB,OAPAI,EAAiBX,OAAQ,UAAU,WACjCU,EAAQ,CACNZ,MAAOE,OAAOC,WACdI,OAAQL,OAAOM,aAEnB,IAEOG,CACT"}
|
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{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{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{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{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{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{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";import"./_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.12 */
|
|
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{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{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{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{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{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";import"./_rollupPluginBabelHelpers-BrlXN-wU.js";import"react";import"./utils/helpers/debounce.js";import"./utils/helpers/isClient.js";import"./hooks/useMutationObserver.js";import"./utils/helpers/throttle.js";import"./utils/helpers/isShallowEqual.js";
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.12 */
|
|
2
2
|
var r=function(r,n){var t;return function(){for(var e=arguments.length,o=new Array(e),u=0;u<e;u++)o[u]=arguments[u];clearTimeout(t),t=setTimeout((function(){return r.apply(void 0,o)}),n)}};export{r as debounce};
|
|
3
3
|
//# sourceMappingURL=debounce.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.12 */
|
|
2
2
|
export{debounce}from"./debounce.js";export{isClient}from"./isClient.js";export{isShallowEqual}from"./isShallowEqual.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.12 */
|
|
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.12 */
|
|
2
2
|
var r=function(r,e){var t=Object.keys(r),n=Object.keys(e);if(t.length!==n.length)return!1;for(var a=0,f=t;a<f.length;a++){var u=f[a];if(r[u]!==e[u])return!1}return!0};export{r as isShallowEqual};
|
|
3
3
|
//# sourceMappingURL=isShallowEqual.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.12 */
|
|
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
|
@@ -45,12 +45,35 @@ type UseBooleanReturn = [
|
|
|
45
45
|
*/
|
|
46
46
|
declare const useBoolean: (initialValue?: boolean) => UseBooleanReturn;
|
|
47
47
|
|
|
48
|
+
/** The use click outside target element type */
|
|
48
49
|
type UseClickOutsideTarget = React.RefObject<Element | null> | (() => Element) | Element;
|
|
50
|
+
/** The use click outside return type */
|
|
49
51
|
type UseClickOutsideReturn<Target extends UseClickOutsideTarget | UseClickOutsideTarget[]> = React.RefObject<Target>;
|
|
50
52
|
type UseClickOutside = {
|
|
51
53
|
<Target extends UseClickOutsideTarget | UseClickOutsideTarget[]>(target: Target, callback: (event: Event) => void): void;
|
|
52
54
|
<Target extends UseClickOutsideTarget | UseClickOutsideTarget[]>(callback: (event: Event) => void, target?: never): UseClickOutsideReturn<Target>;
|
|
53
55
|
};
|
|
56
|
+
/**
|
|
57
|
+
* @name useClickOutside
|
|
58
|
+
* @description - Hook to handle click events outside the specified target element(s)
|
|
59
|
+
*
|
|
60
|
+
* @overload
|
|
61
|
+
* @template Target The target element(s) to detect outside clicks for
|
|
62
|
+
* @param {Target} target The target element(s) to detect outside clicks for
|
|
63
|
+
* @param {(event: Event) => void} callback The callback to execute when a click outside the target is detected
|
|
64
|
+
* @returns {void}
|
|
65
|
+
*
|
|
66
|
+
* @overload
|
|
67
|
+
* @template Target The target element(s) to detect outside clicks for
|
|
68
|
+
* @param {(event: Event) => void} callback The callback to execute when a click outside the target is detected
|
|
69
|
+
* @returns {UseClickOutsideReturn<Target>} A React ref to attach to the target element
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* const ref = useClickOutside<HMLDiTvElement>(() => console.log('click outside'));
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* useClickOutside(ref, () => console.log('click outside'));
|
|
76
|
+
*/
|
|
54
77
|
declare const useClickOutside: UseClickOutside;
|
|
55
78
|
|
|
56
79
|
declare const legacyCopyToClipboard: (value: string) => void;
|
|
@@ -211,25 +234,19 @@ type UseEventListener = {
|
|
|
211
234
|
};
|
|
212
235
|
declare const useEventListener: UseEventListener;
|
|
213
236
|
|
|
214
|
-
/** The use favicon options */
|
|
215
|
-
interface UseFaviconOptions {
|
|
216
|
-
/** The rel of the favicon */
|
|
217
|
-
rel: string;
|
|
218
|
-
}
|
|
219
237
|
/** The use favicon return type */
|
|
220
238
|
type UseFaviconReturn = [string, React.Dispatch<React.SetStateAction<string>>];
|
|
221
239
|
/**
|
|
222
240
|
* @name useFavicon
|
|
223
241
|
* @description - Hook that manages the favicon
|
|
224
242
|
*
|
|
225
|
-
* @param {string} initialFavicon The initial favicon. If not provided, the current favicon will be used
|
|
226
|
-
* @param {string} [options.rel] The rel of the favicon
|
|
243
|
+
* @param {string} [initialFavicon] The initial favicon. If not provided, the current favicon will be used
|
|
227
244
|
* @returns {UseFaviconReturn} An array containing the current favicon and a function to update the favicon
|
|
228
245
|
*
|
|
229
246
|
* @example
|
|
230
247
|
* const { href, set } = useFavicon('https://www.google.com/favicon.ico');
|
|
231
248
|
*/
|
|
232
|
-
declare const useFavicon: (initialHref?: string
|
|
249
|
+
declare const useFavicon: (initialHref?: string) => {
|
|
233
250
|
readonly href: string | undefined;
|
|
234
251
|
readonly set: (favicon: string) => void;
|
|
235
252
|
};
|
|
@@ -364,6 +381,17 @@ type UseIntersectionObserver = {
|
|
|
364
381
|
};
|
|
365
382
|
declare const useIntersectionObserver: UseIntersectionObserver;
|
|
366
383
|
|
|
384
|
+
/**
|
|
385
|
+
* @name useIsFirstRender
|
|
386
|
+
* @description - Hook that returns true if the component is first render
|
|
387
|
+
*
|
|
388
|
+
* @returns {boolean} True if the component is first render
|
|
389
|
+
*
|
|
390
|
+
* @example
|
|
391
|
+
* const isFirstRender = useIsFirstRender();
|
|
392
|
+
*/
|
|
393
|
+
declare const useIsFirstRender: () => boolean;
|
|
394
|
+
|
|
367
395
|
/**
|
|
368
396
|
* @name useIsomorphicLayoutEffect
|
|
369
397
|
* @description - Hook conditionally selects either `useLayoutEffect` or `useEffect` based on the environment
|
|
@@ -562,6 +590,17 @@ interface UseOrientationReturn {
|
|
|
562
590
|
*/
|
|
563
591
|
declare const useOrientation: () => UseOrientationReturn;
|
|
564
592
|
|
|
593
|
+
/**
|
|
594
|
+
* @name usePageLeave
|
|
595
|
+
* @description - Hook what calls given function when mouse leaves the page
|
|
596
|
+
*
|
|
597
|
+
* @param {() => void} onPageLeave The callback function what calls then mouse leaves the page
|
|
598
|
+
*
|
|
599
|
+
* @example
|
|
600
|
+
* usePageLeave(() => console.log('on leave'))
|
|
601
|
+
*/
|
|
602
|
+
declare const usePageLeave: (onPageLeave: () => void) => void;
|
|
603
|
+
|
|
565
604
|
/**
|
|
566
605
|
* @name usePrevious
|
|
567
606
|
* @description - Hook that returns the previous value
|
|
@@ -676,13 +715,13 @@ declare const useSessionStorage: <Value>(key: string, initialValue?: UseStorageI
|
|
|
676
715
|
* @description - Hook that manages a set structure
|
|
677
716
|
*
|
|
678
717
|
* @template Value The type of the value
|
|
679
|
-
* @param {Value[]} values The initial array of the set
|
|
718
|
+
* @param {Value[]} [values] The initial array of the set
|
|
680
719
|
* @returns {Set<Value>} A set structure
|
|
681
720
|
*
|
|
682
721
|
* @example
|
|
683
722
|
* const set = useSet([1, 2, 3]);
|
|
684
723
|
*/
|
|
685
|
-
declare const useSet: <Value>(values
|
|
724
|
+
declare const useSet: <Value>(values?: Value[]) => Set<Value>;
|
|
686
725
|
|
|
687
726
|
/** The use step params */
|
|
688
727
|
interface UseStepParams {
|
|
@@ -825,4 +864,4 @@ declare const useWindowSize: (params?: UseWindowSizeParams) => {
|
|
|
825
864
|
height: number;
|
|
826
865
|
};
|
|
827
866
|
|
|
828
|
-
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
|
|
867
|
+
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 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 UseNetworkReturn, type UseOrientationReturn, type UseQueueReturn, type UseScriptOptions, type UseScriptStatus, type UseStorageInitialValue, type UseStorageOptions, type UseStorageReturn, type UseToggleReturn, type UseWindowSizeReturn, dispatchStorageEvent, getConnection, getOperatingSystem, isHotkeyMatch, legacyCopyToClipboard, useBattery, useBoolean, useClickOutside, useCopyToClipboard, useCounter, useDebouncedValue, useDefault, useDidUpdate, useDocumentTitle, useDocumentVisibility, useEvent, useEventListener, useFavicon, useHash, useHotkeys, useHover, useIdle, useIntersectionObserver, useIsFirstRender, useIsomorphicLayoutEffect, useKeyPress, useKeyPressEvent, useKeysPressed, useLocalStorage, useLogger, useMediaQuery, useMount, useNetwork, useOnline, useOperatingSystem, useOrientation, usePageLeave, usePrevious, useQueue, useRenderCount, useRerender, useScript, useSessionStorage, useSet, useStep, useStorage, useTimeout, useToggle, useUnmount, useWindowEvent, useWindowSize };
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_rollupPluginBabelHelpers-OMepdpg5.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_rollupPluginBabelHelpers-TF5Io098.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|