@siberiacancode/reactuse 0.0.3 → 0.0.5

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.
Files changed (125) hide show
  1. package/dist/cjs/_rollupPluginBabelHelpers-Cva0m6Ep.js +3 -0
  2. package/dist/cjs/_rollupPluginBabelHelpers-Cva0m6Ep.js.map +1 -0
  3. package/dist/cjs/hooks/index.js +2 -2
  4. package/dist/cjs/hooks/useBattery/useBattery.js +3 -0
  5. package/dist/cjs/hooks/useBattery/useBattery.js.map +1 -0
  6. package/dist/cjs/hooks/useBoolean/useBoolean.js +2 -2
  7. package/dist/cjs/hooks/useClickOutside/useClickOutside.js +1 -1
  8. package/dist/cjs/hooks/useClickOutside/useClickOutside.js.map +1 -1
  9. package/dist/cjs/hooks/useCopyToClipboard/useCopyToClipboard.js +2 -2
  10. package/dist/cjs/hooks/useCopyToClipboard/useCopyToClipboard.js.map +1 -1
  11. package/dist/cjs/hooks/useCounter/useCounter.js +2 -2
  12. package/dist/cjs/hooks/useCounter/useCounter.js.map +1 -1
  13. package/dist/cjs/hooks/useDebouncedValue/useDebouncedValue.js +2 -2
  14. package/dist/cjs/hooks/useDocumentTitle/useDocumentTitle.js +2 -2
  15. package/dist/cjs/hooks/useDocumentTitle/useDocumentTitle.js.map +1 -1
  16. package/dist/cjs/hooks/useDocumentVisibility/useDocumentVisibility.js +1 -1
  17. package/dist/cjs/hooks/useDocumentVisibility/useDocumentVisibility.js.map +1 -1
  18. package/dist/cjs/hooks/useEventListener/useEventListener.js +2 -2
  19. package/dist/cjs/hooks/useEventListener/useEventListener.js.map +1 -1
  20. package/dist/cjs/hooks/useHover/useHover.js +2 -2
  21. package/dist/cjs/hooks/useHover/useHover.js.map +1 -1
  22. package/dist/cjs/hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js +1 -1
  23. package/dist/cjs/hooks/useKeyPress/useKeyPress.js +2 -2
  24. package/dist/cjs/hooks/useKeyPress/useKeyPress.js.map +1 -1
  25. package/dist/cjs/hooks/useKeyPressEvent/useKeyPressEvent.js +1 -1
  26. package/dist/cjs/hooks/useKeysPressed/useKeysPressed.js +2 -2
  27. package/dist/cjs/hooks/useKeysPressed/useKeysPressed.js.map +1 -1
  28. package/dist/cjs/hooks/useLocalStorage/useLocalStorage.js +2 -2
  29. package/dist/cjs/hooks/useLocalStorage/useLocalStorage.js.map +1 -1
  30. package/dist/cjs/hooks/useMount/useMount.js +1 -1
  31. package/dist/cjs/hooks/useMutationObserver.js +1 -1
  32. package/dist/cjs/hooks/useNetwork/useNetwork.js +1 -1
  33. package/dist/cjs/hooks/useNetwork/useNetwork.js.map +1 -1
  34. package/dist/cjs/hooks/useNonInitialEffect/useNonInitialEffect.js +1 -1
  35. package/dist/cjs/hooks/useNonInitialEffect/useNonInitialEffect.js.map +1 -1
  36. package/dist/cjs/hooks/useOnline/useOnline.js +1 -1
  37. package/dist/cjs/hooks/useOrientation/useOrientation.js +2 -2
  38. package/dist/cjs/hooks/useRenderCount/useRenderCount.js +1 -1
  39. package/dist/cjs/hooks/useSessionStorage/useSessionStorage.js +2 -2
  40. package/dist/cjs/hooks/useSessionStorage/useSessionStorage.js.map +1 -1
  41. package/dist/cjs/hooks/useStep/useStep.js +3 -0
  42. package/dist/cjs/hooks/useStep/useStep.js.map +1 -0
  43. package/dist/cjs/hooks/useStorage/useStorage.js +2 -2
  44. package/dist/cjs/hooks/useStorage/useStorage.js.map +1 -1
  45. package/dist/cjs/hooks/useTimeout/useTimeout.js +2 -2
  46. package/dist/cjs/hooks/useTimeout/useTimeout.js.map +1 -1
  47. package/dist/cjs/hooks/useToggle/useToggle.js +3 -0
  48. package/dist/cjs/hooks/useToggle/useToggle.js.map +1 -0
  49. package/dist/cjs/hooks/useUnmount/useUnmount.js +1 -1
  50. package/dist/cjs/hooks/useUnmount/useUnmount.js.map +1 -1
  51. package/dist/cjs/hooks/useWindowEvent/useWindowEvent.js +1 -1
  52. package/dist/cjs/hooks/useWindowSize/useWindowSize.js +2 -2
  53. package/dist/cjs/hooks/useWindowSize/useWindowSize.js.map +1 -1
  54. package/dist/cjs/index.js +2 -2
  55. package/dist/cjs/utils/helpers/debounce.js +1 -1
  56. package/dist/cjs/utils/helpers/index.js +1 -1
  57. package/dist/cjs/utils/helpers/isClient.js +1 -1
  58. package/dist/cjs/utils/helpers/isShallowEqual.js +1 -1
  59. package/dist/esm/{_rollupPluginBabelHelpers-BDc6tlcX.js → _rollupPluginBabelHelpers-8YyPIzj_.js} +3 -3
  60. package/dist/esm/_rollupPluginBabelHelpers-8YyPIzj_.js.map +1 -0
  61. package/dist/esm/hooks/index.js +2 -2
  62. package/dist/esm/hooks/useBattery/useBattery.js +3 -0
  63. package/dist/esm/hooks/useBattery/useBattery.js.map +1 -0
  64. package/dist/esm/hooks/useBoolean/useBoolean.js +2 -2
  65. package/dist/esm/hooks/useClickOutside/useClickOutside.js +1 -1
  66. package/dist/esm/hooks/useClickOutside/useClickOutside.js.map +1 -1
  67. package/dist/esm/hooks/useCopyToClipboard/useCopyToClipboard.js +2 -2
  68. package/dist/esm/hooks/useCopyToClipboard/useCopyToClipboard.js.map +1 -1
  69. package/dist/esm/hooks/useCounter/useCounter.js +2 -2
  70. package/dist/esm/hooks/useCounter/useCounter.js.map +1 -1
  71. package/dist/esm/hooks/useDebouncedValue/useDebouncedValue.js +2 -2
  72. package/dist/esm/hooks/useDocumentTitle/useDocumentTitle.js +2 -2
  73. package/dist/esm/hooks/useDocumentTitle/useDocumentTitle.js.map +1 -1
  74. package/dist/esm/hooks/useDocumentVisibility/useDocumentVisibility.js +1 -1
  75. package/dist/esm/hooks/useDocumentVisibility/useDocumentVisibility.js.map +1 -1
  76. package/dist/esm/hooks/useEventListener/useEventListener.js +2 -2
  77. package/dist/esm/hooks/useEventListener/useEventListener.js.map +1 -1
  78. package/dist/esm/hooks/useHover/useHover.js +2 -2
  79. package/dist/esm/hooks/useHover/useHover.js.map +1 -1
  80. package/dist/esm/hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js +1 -1
  81. package/dist/esm/hooks/useKeyPress/useKeyPress.js +2 -2
  82. package/dist/esm/hooks/useKeyPress/useKeyPress.js.map +1 -1
  83. package/dist/esm/hooks/useKeyPressEvent/useKeyPressEvent.js +1 -1
  84. package/dist/esm/hooks/useKeysPressed/useKeysPressed.js +2 -2
  85. package/dist/esm/hooks/useKeysPressed/useKeysPressed.js.map +1 -1
  86. package/dist/esm/hooks/useLocalStorage/useLocalStorage.js +2 -2
  87. package/dist/esm/hooks/useLocalStorage/useLocalStorage.js.map +1 -1
  88. package/dist/esm/hooks/useMount/useMount.js +1 -1
  89. package/dist/esm/hooks/useMutationObserver.js +1 -1
  90. package/dist/esm/hooks/useNetwork/useNetwork.js +1 -1
  91. package/dist/esm/hooks/useNetwork/useNetwork.js.map +1 -1
  92. package/dist/esm/hooks/useNonInitialEffect/useNonInitialEffect.js +1 -1
  93. package/dist/esm/hooks/useNonInitialEffect/useNonInitialEffect.js.map +1 -1
  94. package/dist/esm/hooks/useOnline/useOnline.js +1 -1
  95. package/dist/esm/hooks/useOrientation/useOrientation.js +2 -2
  96. package/dist/esm/hooks/useRenderCount/useRenderCount.js +1 -1
  97. package/dist/esm/hooks/useSessionStorage/useSessionStorage.js +2 -2
  98. package/dist/esm/hooks/useSessionStorage/useSessionStorage.js.map +1 -1
  99. package/dist/esm/hooks/useStep/useStep.js +3 -0
  100. package/dist/esm/hooks/useStep/useStep.js.map +1 -0
  101. package/dist/esm/hooks/useStorage/useStorage.js +2 -2
  102. package/dist/esm/hooks/useStorage/useStorage.js.map +1 -1
  103. package/dist/esm/hooks/useTimeout/useTimeout.js +2 -2
  104. package/dist/esm/hooks/useTimeout/useTimeout.js.map +1 -1
  105. package/dist/esm/hooks/useToggle/useToggle.js +3 -0
  106. package/dist/esm/hooks/useToggle/useToggle.js.map +1 -0
  107. package/dist/esm/hooks/useUnmount/useUnmount.js +1 -1
  108. package/dist/esm/hooks/useUnmount/useUnmount.js.map +1 -1
  109. package/dist/esm/hooks/useWindowEvent/useWindowEvent.js +1 -1
  110. package/dist/esm/hooks/useWindowSize/useWindowSize.js +2 -2
  111. package/dist/esm/hooks/useWindowSize/useWindowSize.js.map +1 -1
  112. package/dist/esm/index.js +2 -2
  113. package/dist/esm/utils/helpers/debounce.js +1 -1
  114. package/dist/esm/utils/helpers/index.js +1 -1
  115. package/dist/esm/utils/helpers/isClient.js +1 -1
  116. package/dist/esm/utils/helpers/isShallowEqual.js +1 -1
  117. package/dist/index.d.ts +221 -45
  118. package/package.json +5 -5
  119. package/dist/cjs/_rollupPluginBabelHelpers-9eGFsb-q.js +0 -3
  120. package/dist/cjs/_rollupPluginBabelHelpers-9eGFsb-q.js.map +0 -1
  121. package/dist/cjs/hooks/useToggle.js +0 -3
  122. package/dist/cjs/hooks/useToggle.js.map +0 -1
  123. package/dist/esm/_rollupPluginBabelHelpers-BDc6tlcX.js.map +0 -1
  124. package/dist/esm/hooks/useToggle.js +0 -3
  125. package/dist/esm/hooks/useToggle.js.map +0 -1
@@ -1,3 +1,3 @@
1
- /* @license @siberiacancode/reactuse v0.0.1 */
2
- import{_ as e,b as n}from"../../_rollupPluginBabelHelpers-BDc6tlcX.js";import r from"react";import{useEventListener as t}from"../useEventListener/useEventListener.js";var o=function(o){var u=r.useState([]),i=e(u,2),l=i[0],s=i[1];return t(null!=o?o:window,"keydown",(function(e){return s([].concat(n(l),[e.key]))})),t(null!=o?o:window,"keyup",(function(e){return s(l.filter((function(n){return n!==e.key})))})),l};export{o as useKeysPressed};
1
+ /* @license @siberiacancode/reactuse v0.0.5 */
2
+ import{_ as e,c as n}from"../../_rollupPluginBabelHelpers-8YyPIzj_.js";import o from"react";import{useEventListener as t}from"../useEventListener/useEventListener.js";var r=function(r){var u,i,c,l=null===(u=null==r?void 0:r.enabled)||void 0===u||u,d=o.useState([]),f=e(d,2),s=f[0],a=f[1];return o.useEffect((function(){a([])}),[l]),t(null!==(i=null==r?void 0:r.target)&&void 0!==i?i:window,"keydown",(function(e){l&&a((function(o){return o.some((function(n){return n.code===e.code}))?o:[].concat(n(o),[{key:e.key,code:e.code}])}))})),t(null!==(c=null==r?void 0:r.target)&&void 0!==c?c:window,"keyup",(function(e){l&&a((function(n){return n.filter((function(n){return n.code!==e.code}))}))})),s};export{r as useKeysPressed};
3
3
  //# sourceMappingURL=useKeysPressed.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useKeysPressed.js","sources":["../../../../src/hooks/useKeysPressed/useKeysPressed.ts"],"sourcesContent":["import React from 'react';\n\nimport type { UseEventListenerTarget } from '../useEventListener/useEventListener';\nimport { useEventListener } from '../useEventListener/useEventListener';\n\nexport const useKeysPressed = (target?: UseEventListenerTarget) => {\n const [keys, setKeys] = React.useState<string[]>([]);\n\n const onKeyDown = (event: KeyboardEvent) => setKeys([...keys, event.key]);\n const onKeyUp = (event: KeyboardEvent) => setKeys(keys.filter((key) => key !== event.key));\n\n useEventListener(target ?? window, 'keydown', onKeyDown);\n useEventListener(target ?? window, 'keyup', onKeyUp);\n\n return keys;\n};\n"],"names":["useKeysPressed","target","_React$useState","React","useState","_React$useState2","_slicedToArray","keys","setKeys","useEventListener","window","event","concat","_toConsumableArray","key","filter"],"mappings":";2KAKaA,EAAiB,SAACC,GAC7B,IAAAC,EAAwBC,EAAMC,SAAmB,IAAGC,EAAAC,EAAAJ,EAAA,GAA7CK,EAAIF,EAAA,GAAEG,EAAOH,EAAA,GAQpB,OAHAI,EAAiBR,QAAAA,EAAUS,OAAQ,WAHjB,SAACC,GAAoB,OAAKH,EAAO,GAAAI,OAAAC,EAAKN,GAAI,CAAEI,EAAMG,MAAK,IAIzEL,EAAiBR,QAAAA,EAAUS,OAAQ,SAHnB,SAACC,GAAoB,OAAKH,EAAQD,EAAKQ,QAAO,SAACD,GAAG,OAAKA,IAAQH,EAAMG,GAAG,IAAE,IAKnFP,CACT"}
1
+ {"version":3,"file":"useKeysPressed.js","sources":["../../../../src/hooks/useKeysPressed/useKeysPressed.ts"],"sourcesContent":["import React from 'react';\n\nimport type { UseEventListenerTarget } from '../useEventListener/useEventListener';\nimport { useEventListener } from '../useEventListener/useEventListener';\n\n/** The use keys pressed params */\ninterface UseKeysPressedParams {\n /** The target to attach the event listeners to */\n target?: UseEventListenerTarget;\n\n /** Enable or disable the event listeners */\n enabled?: boolean;\n}\n\n/**\n * @name useKeysPressed\n * @description - Hook that listens for key press events\n *\n * @param {UseEventListenerTarget} [params.target=window] The target to attach the event listeners to\n * @param {boolean} [params.enabled=bollean] Enable or disable the event listeners\n * @returns {useKeysPressedReturns} Array of strings with keys that were press\n *\n * @example\n * const pressedKeys = useKeysPressed();\n */\nexport const useKeysPressed = (params?: UseKeysPressedParams) => {\n const enabled = params?.enabled ?? true;\n const [keys, setKeys] = React.useState<{ key: string; code: string }[]>([]);\n\n const onKeyDown = (event: KeyboardEvent) => {\n if (!enabled) return;\n setKeys((prevKeys) => {\n if (prevKeys.some(({ code }) => code === event.code)) return prevKeys;\n return [...prevKeys, { key: event.key, code: event.code }];\n });\n };\n\n const onKeyUp = (event: KeyboardEvent) => {\n if (!enabled) return;\n setKeys((prevKeys) => prevKeys.filter(({ code }) => code !== event.code));\n };\n\n React.useEffect(() => {\n setKeys([]);\n }, [enabled]);\n\n useEventListener(params?.target ?? window, 'keydown', onKeyDown);\n useEventListener(params?.target ?? window, 'keyup', onKeyUp);\n\n return keys;\n};\n"],"names":["useKeysPressed","params","_params$enabled","_params$target","_params$target2","enabled","_React$useState","React","useState","_React$useState2","_slicedToArray","keys","setKeys","useEffect","useEventListener","target","window","event","prevKeys","some","_ref","code","concat","_toConsumableArray","key","filter","_ref2"],"mappings":";2KAyBaA,EAAiB,SAACC,GAAkC,IAAAC,EAAAC,EAAAC,EACzDC,EAAyBH,QAAlBA,EAAGD,aAAM,EAANA,EAAQI,eAAOH,IAAAA,GAAAA,EAC/BI,EAAwBC,EAAMC,SAA0C,IAAGC,EAAAC,EAAAJ,EAAA,GAApEK,EAAIF,EAAA,GAAEG,EAAOH,EAAA,GAsBpB,OAPAF,EAAMM,WAAU,WACdD,EAAQ,GACV,GAAG,CAACP,IAEJS,UAAgBX,EAACF,aAAM,EAANA,EAAQc,cAAM,IAAAZ,EAAAA,EAAIa,OAAQ,WAjBzB,SAACC,GACZZ,GACLO,GAAQ,SAACM,GACP,OAAIA,EAASC,MAAK,SAAAC,GAAO,OAAAA,EAAJC,OAAoBJ,EAAMI,QAAcH,EAC7D,GAAAI,OAAAC,EAAWL,GAAU,CAAA,CAAEM,IAAKP,EAAMO,IAAKH,KAAMJ,EAAMI,OACrD,OAaFP,UAAgBV,EAACH,aAAM,EAANA,EAAQc,cAAM,IAAAX,EAAAA,EAAIY,OAAQ,SAV3B,SAACC,GACVZ,GACLO,GAAQ,SAACM,GAAQ,OAAKA,EAASO,QAAO,SAAAC,GAAO,OAAAA,EAAJL,OAAoBJ,EAAMI,cAU9DV,CACT"}
@@ -1,3 +1,3 @@
1
- /* @license @siberiacancode/reactuse v0.0.1 */
2
- import{a as r}from"../../_rollupPluginBabelHelpers-BDc6tlcX.js";import{useStorage as o}from"../useStorage/useStorage.js";import"react";var e=function(e,t,a){return o(e,t,r({storage:window.localStorage},a))};export{e as useLocalStorage};
1
+ /* @license @siberiacancode/reactuse v0.0.5 */
2
+ import{b as r}from"../../_rollupPluginBabelHelpers-8YyPIzj_.js";import{useStorage as o}from"../useStorage/useStorage.js";import"react";var e=function(e,t,a){return o(e,r({initialValue:t,storage:window.localStorage},a))};export{e as useLocalStorage};
3
3
  //# sourceMappingURL=useLocalStorage.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useLocalStorage.js","sources":["../../../../src/hooks/useLocalStorage/useLocalStorage.ts"],"sourcesContent":["import type { UseStorageInitialValue, UseStorageOptions } from '../useStorage/useStorage';\nimport { useStorage } from '../useStorage/useStorage';\n\nexport const useLocalStorage = <Value>(\n key: string,\n initialValue?: UseStorageInitialValue<Value>,\n options?: UseStorageOptions<Value>\n) => useStorage(key, initialValue, { storage: window.localStorage, ...options });\n"],"names":["useLocalStorage","key","initialValue","options","useStorage","_objectSpread","storage","window","localStorage"],"mappings":";uIAGO,IAAMA,EAAkB,SAC7BC,EACAC,EACAC,GAAkC,OAC/BC,EAAWH,EAAKC,EAAYG,EAAA,CAAIC,QAASC,OAAOC,cAAiBL,GAAU"}
1
+ {"version":3,"file":"useLocalStorage.js","sources":["../../../../src/hooks/useLocalStorage/useLocalStorage.ts"],"sourcesContent":["import type { UseStorageInitialValue, UseStorageOptions } from '../useStorage/useStorage';\nimport { useStorage } from '../useStorage/useStorage';\n\nexport const useLocalStorage = <Value>(\n key: string,\n initialValue?: UseStorageInitialValue<Value>,\n options?: UseStorageOptions<Value>\n) => useStorage(key, { initialValue, storage: window.localStorage, ...options });\n"],"names":["useLocalStorage","key","initialValue","options","useStorage","_objectSpread","storage","window","localStorage"],"mappings":";uIAGO,IAAMA,EAAkB,SAC7BC,EACAC,EACAC,GAAkC,OAC/BC,EAAWH,EAAGI,EAAA,CAAIH,aAAAA,EAAcI,QAASC,OAAOC,cAAiBL,GAAU"}
@@ -1,3 +1,3 @@
1
- /* @license @siberiacancode/reactuse v0.0.1 */
1
+ /* @license @siberiacancode/reactuse v0.0.5 */
2
2
  import r from"react";var t=function(t){return r.useEffect(t,[])};export{t as useMount};
3
3
  //# sourceMappingURL=useMount.js.map
@@ -1,3 +1,3 @@
1
- /* @license @siberiacancode/reactuse v0.0.1 */
1
+ /* @license @siberiacancode/reactuse v0.0.5 */
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.1 */
1
+ /* @license @siberiacancode/reactuse v0.0.5 */
2
2
  import n from"react";import"../../utils/helpers/isClient.js";import{isShallowEqual as e}from"../../utils/helpers/isShallowEqual.js";var i=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)},o=function(n){window.addEventListener("online",n,{passive:!0}),window.addEventListener("offline",n,{passive:!0});var e=i();return e&&e.addEventListener("change",n,{passive:!0}),function(){window.removeEventListener("online",n),window.removeEventListener("offline",n),e&&e.removeEventListener("change",n)}},t=function(){throw Error("useNetwork is a client side hook")},r=function(){var r=n.useRef();return n.useSyncExternalStore(o,(function(){var n=navigator.onLine,o=i(),t={online:n,downlink:null==o?void 0:o.downlink,downlinkMax:null==o?void 0:o.downlinkMax,effectiveType:null==o?void 0:o.effectiveType,rtt:null==o?void 0:o.rtt,saveData:null==o?void 0:o.saveData,type:null==o?void 0:o.type};return r.current&&e(r.current,t)?r.current:(r.current=t,t)}),t)};export{i as getConnection,r as useNetwork};
3
3
  //# sourceMappingURL=useNetwork.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useNetwork.js","sources":["../../../../src/hooks/useNetwork/useNetwork.ts"],"sourcesContent":["import React from 'react';\n\nimport { isShallowEqual } from '@/utils/helpers';\n\nexport type ConnectionType = Connection['type'];\nexport type ConnectionEffectiveType = Connection['effectiveType'];\nexport interface UseNetworkReturn {\n online: boolean;\n downlink?: Connection['downlink'];\n downlinkMax?: Connection['downlinkMax'];\n effectiveType?: Connection['effectiveType'];\n rtt?: Connection['rtt'];\n saveData?: Connection['saveData'];\n type?: Connection['type'];\n}\n\nexport const getConnection = () =>\n navigator?.connection || navigator?.mozConnection || navigator?.webkitConnection;\n\nconst subscribe = (callback: () => void) => {\n window.addEventListener('online', callback, { passive: true });\n window.addEventListener('offline', callback, { passive: true });\n\n const connection = getConnection();\n\n if (connection) {\n connection.addEventListener('change', callback, { passive: true });\n }\n\n return () => {\n window.removeEventListener('online', callback);\n window.removeEventListener('offline', callback);\n\n if (connection) {\n connection.removeEventListener('change', callback);\n }\n };\n};\n\nconst getServerSnapshot = () => {\n throw Error('useNetwork is a client side hook');\n};\n\nexport const useNetwork = (): UseNetworkReturn => {\n const cache = React.useRef<UseNetworkReturn>();\n\n const getSnapshot = () => {\n const online = navigator.onLine;\n const connection = getConnection();\n\n const nextState = {\n online,\n downlink: connection?.downlink,\n downlinkMax: connection?.downlinkMax,\n effectiveType: connection?.effectiveType,\n rtt: connection?.rtt,\n saveData: connection?.saveData,\n type: connection?.type\n };\n\n if (cache.current && isShallowEqual(cache.current as any, nextState)) {\n return cache.current;\n }\n\n cache.current = nextState;\n return nextState;\n };\n\n return React.useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\n};\n"],"names":["getConnection","_navigator","_navigator2","_navigator3","navigator","connection","mozConnection","webkitConnection","subscribe","callback","window","addEventListener","passive","removeEventListener","getServerSnapshot","Error","useNetwork","cache","React","useRef","useSyncExternalStore","online","onLine","nextState","downlink","downlinkMax","effectiveType","rtt","saveData","type","current","isShallowEqual"],"mappings":";oIAgBaA,IAAAA,EAAgB,WAAH,IAAAC,EAAAC,EAAAC,EAAA,OACfF,QAATA,EAAAG,iBAAAH,IAASA,OAATA,EAAAA,EAAWI,cAAuBH,QAAbA,EAAIE,iBAAAF,IAASA,OAATA,EAAAA,EAAWI,iBAA0BH,QAAbA,EAAIC,iBAAAD,IAASA,OAATA,EAAAA,EAAWI,iBAAgB,EAE5EC,EAAY,SAACC,GACjBC,OAAOC,iBAAiB,SAAUF,EAAU,CAAEG,SAAS,IACvDF,OAAOC,iBAAiB,UAAWF,EAAU,CAAEG,SAAS,IAExD,IAAMP,EAAaL,IAMnB,OAJIK,GACFA,EAAWM,iBAAiB,SAAUF,EAAU,CAAEG,SAAS,IAGtD,WACLF,OAAOG,oBAAoB,SAAUJ,GACrCC,OAAOG,oBAAoB,UAAWJ,GAElCJ,GACFA,EAAWQ,oBAAoB,SAAUJ,GAG/C,EAEMK,EAAoB,WACxB,MAAMC,MAAM,mCACd,EAEaC,EAAa,WACxB,IAAMC,EAAQC,EAAMC,SAwBpB,OAAOD,EAAME,qBAAqBZ,GAtBd,WAClB,IAAMa,EAASjB,UAAUkB,OACnBjB,EAAaL,IAEbuB,EAAY,CAChBF,OAAAA,EACAG,SAAUnB,aAAAA,EAAAA,EAAYmB,SACtBC,YAAapB,aAAAA,EAAAA,EAAYoB,YACzBC,cAAerB,aAAAA,EAAAA,EAAYqB,cAC3BC,IAAKtB,aAAAA,EAAAA,EAAYsB,IACjBC,SAAUvB,aAAAA,EAAAA,EAAYuB,SACtBC,KAAMxB,aAAU,EAAVA,EAAYwB,MAGpB,OAAIZ,EAAMa,SAAWC,EAAed,EAAMa,QAAgBP,GACjDN,EAAMa,SAGfb,EAAMa,QAAUP,EACTA,KAGiDT,EAC5D"}
1
+ {"version":3,"file":"useNetwork.js","sources":["../../../../src/hooks/useNetwork/useNetwork.ts"],"sourcesContent":["import React from 'react';\n\nimport { isShallowEqual } from '@/utils/helpers';\n\nexport type ConnectionType = Connection['type'];\nexport type ConnectionEffectiveType = Connection['effectiveType'];\n\n/** The use network return type */\nexport interface UseNetworkReturn {\n /** Indicates if the device is currently online */\n online: boolean;\n /** The estimated downlink speed in megabits per seconds */\n downlink?: Connection['downlink'];\n /** The maximum downlink speed, if available */\n downlinkMax?: Connection['downlinkMax'];\n /** The effective type of connection (e.g., '2g', '3g', '4g') */\n effectiveType?: Connection['effectiveType'];\n /** The estimated round-trip time in milliseconds */\n rtt?: Connection['rtt'];\n /** Indicates if the user has enabled data saving mode */\n saveData?: Connection['saveData'];\n /** The type of network connection (e.g., 'wifi', 'cellular') */\n type?: Connection['type'];\n}\n\nexport const getConnection = () =>\n navigator?.connection || navigator?.mozConnection || navigator?.webkitConnection;\n\nconst subscribe = (callback: () => void) => {\n window.addEventListener('online', callback, { passive: true });\n window.addEventListener('offline', callback, { passive: true });\n\n const connection = getConnection();\n\n if (connection) {\n connection.addEventListener('change', callback, { passive: true });\n }\n\n return () => {\n window.removeEventListener('online', callback);\n window.removeEventListener('offline', callback);\n\n if (connection) {\n connection.removeEventListener('change', callback);\n }\n };\n};\n\nconst getServerSnapshot = () => {\n throw Error('useNetwork is a client side hook');\n};\n\n/**\n * @name useNetwork\n * @description - Hook to track network status.\n *\n * @returns {UseNetworkReturn} An object containing the network status.\n *\n * @example\n * const { online, downlink, downlinkMax, effectiveType, rtt, saveData, type } = useNetwork();\n */\nexport const useNetwork = (): UseNetworkReturn => {\n const cache = React.useRef<UseNetworkReturn>();\n\n const getSnapshot = () => {\n const online = navigator.onLine;\n const connection = getConnection();\n\n const nextState = {\n online,\n downlink: connection?.downlink,\n downlinkMax: connection?.downlinkMax,\n effectiveType: connection?.effectiveType,\n rtt: connection?.rtt,\n saveData: connection?.saveData,\n type: connection?.type\n };\n\n if (cache.current && isShallowEqual(cache.current as any, nextState)) {\n return cache.current;\n }\n\n cache.current = nextState;\n return nextState;\n };\n\n return React.useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\n};\n"],"names":["getConnection","_navigator","_navigator2","_navigator3","navigator","connection","mozConnection","webkitConnection","subscribe","callback","window","addEventListener","passive","removeEventListener","getServerSnapshot","Error","useNetwork","cache","React","useRef","useSyncExternalStore","online","onLine","nextState","downlink","downlinkMax","effectiveType","rtt","saveData","type","current","isShallowEqual"],"mappings":";oIAyBaA,IAAAA,EAAgB,WAAH,IAAAC,EAAAC,EAAAC,EAAA,OACfF,QAATA,EAAAG,iBAAAH,IAASA,OAATA,EAAAA,EAAWI,cAAuBH,QAAbA,EAAIE,iBAAAF,IAASA,OAATA,EAAAA,EAAWI,iBAA0BH,QAAbA,EAAIC,iBAAAD,IAASA,OAATA,EAAAA,EAAWI,iBAAgB,EAE5EC,EAAY,SAACC,GACjBC,OAAOC,iBAAiB,SAAUF,EAAU,CAAEG,SAAS,IACvDF,OAAOC,iBAAiB,UAAWF,EAAU,CAAEG,SAAS,IAExD,IAAMP,EAAaL,IAMnB,OAJIK,GACFA,EAAWM,iBAAiB,SAAUF,EAAU,CAAEG,SAAS,IAGtD,WACLF,OAAOG,oBAAoB,SAAUJ,GACrCC,OAAOG,oBAAoB,UAAWJ,GAElCJ,GACFA,EAAWQ,oBAAoB,SAAUJ,GAG/C,EAEMK,EAAoB,WACxB,MAAMC,MAAM,mCACd,EAWaC,EAAa,WACxB,IAAMC,EAAQC,EAAMC,SAwBpB,OAAOD,EAAME,qBAAqBZ,GAtBd,WAClB,IAAMa,EAASjB,UAAUkB,OACnBjB,EAAaL,IAEbuB,EAAY,CAChBF,OAAAA,EACAG,SAAUnB,aAAAA,EAAAA,EAAYmB,SACtBC,YAAapB,aAAAA,EAAAA,EAAYoB,YACzBC,cAAerB,aAAAA,EAAAA,EAAYqB,cAC3BC,IAAKtB,aAAAA,EAAAA,EAAYsB,IACjBC,SAAUvB,aAAAA,EAAAA,EAAYuB,SACtBC,KAAMxB,aAAU,EAAVA,EAAYwB,MAGpB,OAAIZ,EAAMa,SAAWC,EAAed,EAAMa,QAAgBP,GACjDN,EAAMa,SAGfb,EAAMa,QAAUP,EACTA,KAGiDT,EAC5D"}
@@ -1,3 +1,3 @@
1
- /* @license @siberiacancode/reactuse v0.0.1 */
1
+ /* @license @siberiacancode/reactuse v0.0.5 */
2
2
  import r from"react";import{useIsomorphicLayoutEffect as t}from"../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js";import"../../utils/helpers/isClient.js";var o=function(o,e){var i=r.useRef(!0);t((function(){if(!i.current){var r=o();return r&&"function"==typeof r?r:void 0}i.current=!1}),e)};export{o as useNonInitialEffect};
3
3
  //# sourceMappingURL=useNonInitialEffect.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useNonInitialEffect.js","sources":["../../../../src/hooks/useNonInitialEffect/useNonInitialEffect.ts"],"sourcesContent":["import React from 'react';\n\nimport { useIsomorphicLayoutEffect } from '../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect';\n\nexport const useNonInitialEffect = (effect: React.EffectCallback, deps?: React.DependencyList) => {\n const initialRender = React.useRef(true);\n\n useIsomorphicLayoutEffect(() => {\n if (initialRender.current) {\n initialRender.current = false;\n return;\n }\n\n const effectReturns = effect();\n if (effectReturns && typeof effectReturns === 'function') {\n return effectReturns;\n }\n }, deps);\n};\n"],"names":["useNonInitialEffect","effect","deps","initialRender","React","useRef","useIsomorphicLayoutEffect","current","effectReturns"],"mappings":";mKAIO,IAAMA,EAAsB,SAACC,EAA8BC,GAChE,IAAMC,EAAgBC,EAAMC,QAAO,GAEnCC,GAA0B,WACxB,IAAIH,EAAcI,QAAlB,CAKA,IAAMC,EAAgBP,IACtB,OAAIO,GAA0C,mBAAlBA,EACnBA,OADT,CAHA,CAFEL,EAAcI,SAAU,CAQ3B,GAAEL,EACL"}
1
+ {"version":3,"file":"useNonInitialEffect.js","sources":["../../../../src/hooks/useNonInitialEffect/useNonInitialEffect.ts"],"sourcesContent":["import React from 'react';\n\nimport { useIsomorphicLayoutEffect } from '../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect';\n\n/**\n * @name useNonInitialEffect\n * @description – Hook that behaves like useEffect, but skips the effect on the initial render\n *\n * @param {React.EffectCallback} effect The effect callback\n * @param {React.DependencyList} [deps] The dependencies list for the effect\n *\n * @example\n * useNonInitialEffect(() => {\n * console.log('this effect doesn't run on the initial render');\n * });\n */\nexport const useNonInitialEffect = (effect: React.EffectCallback, deps?: React.DependencyList) => {\n const initialRender = React.useRef(true);\n\n useIsomorphicLayoutEffect(() => {\n if (initialRender.current) {\n initialRender.current = false;\n return;\n }\n\n const effectReturns = effect();\n if (effectReturns && typeof effectReturns === 'function') {\n return effectReturns;\n }\n }, deps);\n};\n"],"names":["useNonInitialEffect","effect","deps","initialRender","React","useRef","useIsomorphicLayoutEffect","current","effectReturns"],"mappings":";mKAgBO,IAAMA,EAAsB,SAACC,EAA8BC,GAChE,IAAMC,EAAgBC,EAAMC,QAAO,GAEnCC,GAA0B,WACxB,IAAIH,EAAcI,QAAlB,CAKA,IAAMC,EAAgBP,IACtB,OAAIO,GAA0C,mBAAlBA,EACnBA,OADT,CAHA,CAFEL,EAAcI,SAAU,CAQ3B,GAAEL,EACL"}
@@ -1,3 +1,3 @@
1
- /* @license @siberiacancode/reactuse v0.0.1 */
1
+ /* @license @siberiacancode/reactuse v0.0.5 */
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 */
2
- import{_ as e}from"../../_rollupPluginBabelHelpers-BDc6tlcX.js";import{useState as n}from"react";import{useIsomorphicLayoutEffect as r}from"../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js";import"../../utils/helpers/isClient.js";var o=function(){var o=n({angle:0,type:"landscape-primary"}),t=e(o,2),i=t[0],a=t[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{o as useOrientation};
1
+ /* @license @siberiacancode/reactuse v0.0.5 */
2
+ import{_ as e}from"../../_rollupPluginBabelHelpers-8YyPIzj_.js";import{useState as n}from"react";import{useIsomorphicLayoutEffect as r}from"../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js";import"../../utils/helpers/isClient.js";var o=function(){var o=n({angle:0,type:"landscape-primary"}),t=e(o,2),i=t[0],a=t[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{o as useOrientation};
3
3
  //# sourceMappingURL=useOrientation.js.map
@@ -1,3 +1,3 @@
1
- /* @license @siberiacancode/reactuse v0.0.1 */
1
+ /* @license @siberiacancode/reactuse v0.0.5 */
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.1 */
2
- import{a as r}from"../../_rollupPluginBabelHelpers-BDc6tlcX.js";import{useStorage as o}from"../useStorage/useStorage.js";import"react";var e=function(e,t,s){return o(e,t,r({storage:window.sessionStorage},s))};export{e as useSessionStorage};
1
+ /* @license @siberiacancode/reactuse v0.0.5 */
2
+ import{b as r}from"../../_rollupPluginBabelHelpers-8YyPIzj_.js";import{useStorage as e}from"../useStorage/useStorage.js";import"react";var o=function(o,t,a){return e(o,r({initialValue:t,storage:window.sessionStorage},a))};export{o as useSessionStorage};
3
3
  //# sourceMappingURL=useSessionStorage.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useSessionStorage.js","sources":["../../../../src/hooks/useSessionStorage/useSessionStorage.ts"],"sourcesContent":["import type { UseStorageInitialValue, UseStorageOptions } from '../useStorage/useStorage';\nimport { useStorage } from '../useStorage/useStorage';\n\nexport const useSessionStorage = <Value>(\n key: string,\n initialValue?: UseStorageInitialValue<Value>,\n options?: UseStorageOptions<Value>\n) => useStorage(key, initialValue, { storage: window.sessionStorage, ...options });\n"],"names":["useSessionStorage","key","initialValue","options","useStorage","_objectSpread","storage","window","sessionStorage"],"mappings":";uIAGO,IAAMA,EAAoB,SAC/BC,EACAC,EACAC,GAAkC,OAC/BC,EAAWH,EAAKC,EAAYG,EAAA,CAAIC,QAASC,OAAOC,gBAAmBL,GAAU"}
1
+ {"version":3,"file":"useSessionStorage.js","sources":["../../../../src/hooks/useSessionStorage/useSessionStorage.ts"],"sourcesContent":["import type { UseStorageInitialValue, UseStorageOptions } from '../useStorage/useStorage';\nimport { useStorage } from '../useStorage/useStorage';\n\nexport const useSessionStorage = <Value>(\n key: string,\n initialValue?: UseStorageInitialValue<Value>,\n options?: UseStorageOptions<Value>\n) => useStorage(key, { initialValue, storage: window.sessionStorage, ...options });\n"],"names":["useSessionStorage","key","initialValue","options","useStorage","_objectSpread","storage","window","sessionStorage"],"mappings":";uIAGO,IAAMA,EAAoB,SAC/BC,EACAC,EACAC,GAAkC,OAC/BC,EAAWH,EAAGI,EAAA,CAAIH,aAAAA,EAAcI,QAASC,OAAOC,gBAAmBL,GAAU"}
@@ -0,0 +1,3 @@
1
+ /* @license @siberiacancode/reactuse v0.0.5 */
2
+ import{a as t,_ as r}from"../../_rollupPluginBabelHelpers-8YyPIzj_.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
+ //# sourceMappingURL=useStep.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useStep.js","sources":["../../../../src/hooks/useStep/useStep.ts"],"sourcesContent":["import React from 'react';\n\n/** The use step params */\ninterface UseStepParams {\n /** Initial value for step */\n initial: number;\n /** Maximum value for step */\n max: number;\n}\n\n/** The use step return type */\ninterface UseStepReturn {\n /** Counts of steps */\n counts: number;\n /** Current value of step */\n currentStep: number;\n /** Boolean value if current step is first */\n isFirst: boolean;\n /** Boolean value if current step is last */\n isLast: boolean;\n /** Go to next step */\n next: () => void;\n /** Go to back step */\n back: () => void;\n /** Reset current step to initial value */\n reset: () => void;\n /** Go to custom step */\n set: (value: number | 'last' | 'first') => void;\n}\n\nconst FIRST_STEP_VALUE = 1;\n\n/**\n * @name useStep\n * @description - Hook that create stepper\n *\n * @overload\n * @param {number} max Maximum number of steps\n * @returns {UseStepReturn} An object contains variables and functions to change the step\n *\n * @overload\n * @param {number} params.max Maximum number of steps\n * @param {number} params.initial Initial value for step\n * @returns {UseStepReturn} An object contains variables and functions to change the step\n *\n * @example\n * const step = useStep(5);\n * @example\n * const stepper = useStep({ initial: 2, max: 5 });\n */\nexport const useStep = (params: number | UseStepParams): UseStepReturn => {\n const max = typeof params === 'object' ? params.max : params;\n const initial = typeof params === 'object' ? params.initial : FIRST_STEP_VALUE;\n\n const initialStep = React.useRef(\n initial > max || initial < FIRST_STEP_VALUE ? FIRST_STEP_VALUE : initial\n );\n const [currentStep, setCurrentStep] = React.useState(initial);\n\n const isFirst = currentStep === FIRST_STEP_VALUE;\n const isLast = currentStep === max;\n\n const next = () => {\n if (isLast) return;\n setCurrentStep((prevStep) => prevStep + 1);\n };\n\n const back = () => {\n if (isFirst) return;\n setCurrentStep((prevStep) => prevStep - 1);\n };\n\n const reset = () => setCurrentStep(initialStep.current);\n\n const set = (value: number | 'last' | 'first') => {\n if (value === 'first') return setCurrentStep(initialStep.current);\n if (value === 'last') return setCurrentStep(max);\n if (value >= max) return setCurrentStep(max);\n if (value <= FIRST_STEP_VALUE) return setCurrentStep(FIRST_STEP_VALUE);\n setCurrentStep(value);\n };\n\n return {\n counts: max,\n currentStep,\n isFirst,\n isLast,\n next,\n back,\n reset,\n set\n };\n};\n"],"names":["useStep","params","max","_typeof","initial","initialStep","React","useRef","_React$useState","useState","_React$useState2","_slicedToArray","currentStep","setCurrentStep","isFirst","isLast","counts","next","prevStep","back","reset","current","set","value"],"mappings":";4FA8BA,IAoBaA,EAAU,SAACC,GACtB,IAAMC,EAAwB,WAAlBC,EAAOF,GAAsBA,EAAOC,IAAMD,EAChDG,EAA4B,WAAlBD,EAAOF,GAAsBA,EAAOG,QAtB7B,EAwBjBC,EAAcC,EAAMC,OACxBH,EAAUF,GAAOE,EAzBI,IAyB4CA,GAEnEI,EAAsCF,EAAMG,SAASL,GAAQM,EAAAC,EAAAH,EAAA,GAAtDI,EAAWF,EAAA,GAAEG,EAAcH,EAAA,GAE5BI,EA7BiB,IA6BPF,EACVG,EAASH,IAAgBV,EAsB/B,MAAO,CACLc,OAAQd,EACRU,YAAAA,EACAE,QAAAA,EACAC,OAAAA,EACAE,KAzBW,WACPF,GACJF,GAAe,SAACK,GAAQ,OAAKA,EAAW,MAwBxCC,KArBW,WACPL,GACJD,GAAe,SAACK,GAAQ,OAAKA,EAAW,MAoBxCE,MAjBY,WAAH,OAASP,EAAeR,EAAYgB,QAAQ,EAkBrDC,IAhBU,SAACC,GACX,MAAc,UAAVA,EAA0BV,EAAeR,EAAYgB,SAC3C,SAAVE,GACAA,GAASrB,EADgBW,EAAeX,GAExCqB,GAhDiB,EAgDiBV,EAhDjB,QAiDrBA,EAAeU,IAanB"}
@@ -1,3 +1,3 @@
1
- /* @license @siberiacancode/reactuse v0.0.1 */
2
- import e from"react";var n=function(e){return window.dispatchEvent(new StorageEvent("storage",e))},t=function(e,t,r){var u=e.getItem(t);e.setItem(t,r),n({key:t,oldValue:u,newValue:r,storageArea:e})},r=function(e,t){var r=e.getItem(t);e.removeItem(t),n({key:t,oldValue:r,newValue:null,storageArea:e})},u=function(e,n,t){var r=e.getItem(n);return r?t(r):null},i=function(e){return window.addEventListener("storage",e),function(){return window.removeEventListener("storage",e)}};function o(n,o,l){var a,c=null!==(a=null==l?void 0:l.storage)&&void 0!==a?a:window.localStorage,f=e.useCallback((function(e){return null!=l&&l.serializer?l.serializer(e):JSON.stringify(e)}),[null==l?void 0:l.serializer]),s=e.useCallback((function(e){if(null!=l&&l.deserializer)return l.deserializer(e);if("undefined"!==e)try{return JSON.parse(e)}catch(n){return e}}),[l,o]),d=e.useSyncExternalStore(i,(function(){return u(c,n,s)}),(function(){return function(e){return e instanceof Function?e():e}(o)})),v=e.useCallback((function(e){if(null==e)return r(c,n);t(c,n,f(e))}),[n,d]);return e.useEffect((function(){null===u(c,n,s)&&o&&t(c,n,f(o instanceof Function?o():o))}),[n]),{value:null!=d?d:o?o instanceof Function?o():o:null,set:v,clear:function(){return r(c,n)}}}export{n as dispatchStorageEvent,o as useStorage};
1
+ /* @license @siberiacancode/reactuse v0.0.5 */
2
+ import{a as e}from"../../_rollupPluginBabelHelpers-8YyPIzj_.js";import n from"react";var r=function(e){return window.dispatchEvent(new StorageEvent("storage",e))},t=function(e,n,t){var i=e.getItem(n);e.setItem(n,t),r({key:n,oldValue:i,newValue:t,storageArea:e})},i=function(e,n){var t=e.getItem(n);e.removeItem(n),r({key:n,oldValue:t,newValue:null,storageArea:e})},o=function(e,n,r){var t=e.getItem(n);if(t)return r(t)},u=function(e){return window.addEventListener("storage",e),function(){return window.removeEventListener("storage",e)}},a=function(r,a){var l,f="object"===e(a)?a:void 0,c=f?null==f?void 0:f.initialValue:a,s=null!==(l=null==f?void 0:f.storage)&&void 0!==l?l:window.localStorage,d=function(e){return null!=f&&f.serializer?f.serializer(e):JSON.stringify(e)},v=function(e){if(null!=f&&f.deserializer)return f.deserializer(e);if("undefined"!==e)try{return JSON.parse(e)}catch(n){return e}},g=n.useSyncExternalStore(u,(function(){return o(s,r,v)}),(function(){return function(e){return e instanceof Function?e():e}(c)}));n.useEffect((function(){if(void 0===o(s,r,v)&&c){var e=c instanceof Function?c():c;t(s,r,d(e))}}),[r]);return[g,function(e){if(null===e)return i(s,r);t(s,r,d(e))},function(){return i(s,r)}]};export{r as dispatchStorageEvent,a as useStorage};
3
3
  //# sourceMappingURL=useStorage.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useStorage.js","sources":["../../../../src/hooks/useStorage/useStorage.ts"],"sourcesContent":["import React from 'react';\n\nexport type UseStorageInitialValue<Value> = Value | (() => Value);\nexport interface UseStorageOptions<Value> {\n serializer?: (value: Value) => string;\n deserializer?: (value: string) => Value;\n storage: Storage;\n}\n\nexport const dispatchStorageEvent = (params: Partial<StorageEvent>) =>\n window.dispatchEvent(new StorageEvent('storage', params));\n\nconst setStorageItem = (storage: Storage, key: string, value: string) => {\n const oldValue = storage.getItem(key);\n\n storage.setItem(key, value);\n dispatchStorageEvent({ key, oldValue, newValue: value, storageArea: storage });\n};\n\nconst removeStorageItem = (storage: Storage, key: string) => {\n const oldValue = storage.getItem(key);\n\n storage.removeItem(key);\n dispatchStorageEvent({ key, oldValue, newValue: null, storageArea: storage });\n};\n\nconst getStorageItem = <Value>(\n storage: Storage,\n key: string,\n deserializer: (value: string) => Value\n) => {\n const value = storage.getItem(key);\n if (!value) return null;\n return deserializer(value);\n};\n\nconst storageSubscribe = (callback: () => void) => {\n window.addEventListener('storage', callback);\n return () => window.removeEventListener('storage', callback);\n};\n\nconst getStorageServerSnapshot = <Value>(initialValue: UseStorageInitialValue<Value>) =>\n initialValue instanceof Function ? initialValue() : initialValue;\n\n/**\n * @name useStorage\n * @description - Hook that manages a counter with increment, decrement, reset, and set functionalities\n *\n * @example\n * text\n */\nexport function useStorage<Value = string | null>(\n key: string,\n initialValue?: UseStorageInitialValue<Value>,\n options?: UseStorageOptions<Value>\n) {\n const storage = options?.storage ?? window.localStorage;\n const serializer = React.useCallback<(value: Value) => string>(\n (value) => {\n if (options?.serializer) return options.serializer(value);\n return JSON.stringify(value);\n },\n [options?.serializer]\n );\n\n const deserializer = React.useCallback<(value: string) => Value>(\n (value) => {\n if (options?.deserializer) return options.deserializer(value);\n\n if (value === 'undefined') {\n return undefined as unknown as Value;\n }\n\n try {\n return JSON.parse(value) as Value;\n } catch (error) {\n return value as Value;\n }\n },\n [options, initialValue]\n );\n\n const getSnapshot = () => getStorageItem<Value>(storage, key, deserializer);\n const getServerSnapshot = () => getStorageServerSnapshot(initialValue);\n const store = React.useSyncExternalStore(storageSubscribe, getSnapshot, getServerSnapshot);\n\n const setState = React.useCallback(\n (value: Value) => {\n if (value === undefined || value === null) {\n return removeStorageItem(storage, key);\n }\n\n setStorageItem(storage, key, serializer(value));\n },\n [key, store]\n );\n\n React.useEffect(() => {\n const value = getStorageItem<Value>(storage, key, deserializer);\n if (value !== null || !initialValue) return;\n\n setStorageItem(\n storage,\n key,\n serializer(initialValue instanceof Function ? initialValue() : initialValue)\n );\n }, [key]);\n\n return {\n value:\n store ??\n ((initialValue\n ? initialValue instanceof Function\n ? initialValue()\n : initialValue\n : null) as Value),\n set: setState,\n clear: () => removeStorageItem(storage, key)\n };\n}\n"],"names":["dispatchStorageEvent","params","window","dispatchEvent","StorageEvent","setStorageItem","storage","key","value","oldValue","getItem","setItem","newValue","storageArea","removeStorageItem","removeItem","getStorageItem","deserializer","storageSubscribe","callback","addEventListener","removeEventListener","useStorage","initialValue","options","_options$storage","localStorage","serializer","React","useCallback","JSON","stringify","parse","error","store","useSyncExternalStore","Function","getStorageServerSnapshot","setState","useEffect","set","clear"],"mappings":";yBASaA,EAAuB,SAACC,GAA6B,OAChEC,OAAOC,cAAc,IAAIC,aAAa,UAAWH,GAAQ,EAErDI,EAAiB,SAACC,EAAkBC,EAAaC,GACrD,IAAMC,EAAWH,EAAQI,QAAQH,GAEjCD,EAAQK,QAAQJ,EAAKC,GACrBR,EAAqB,CAAEO,IAAAA,EAAKE,SAAAA,EAAUG,SAAUJ,EAAOK,YAAaP,GACtE,EAEMQ,EAAoB,SAACR,EAAkBC,GAC3C,IAAME,EAAWH,EAAQI,QAAQH,GAEjCD,EAAQS,WAAWR,GACnBP,EAAqB,CAAEO,IAAAA,EAAKE,SAAAA,EAAUG,SAAU,KAAMC,YAAaP,GACrE,EAEMU,EAAiB,SACrBV,EACAC,EACAU,GAEA,IAAMT,EAAQF,EAAQI,QAAQH,GAC9B,OAAKC,EACES,EAAaT,GADD,IAErB,EAEMU,EAAmB,SAACC,GAExB,OADAjB,OAAOkB,iBAAiB,UAAWD,GAC5B,WAAA,OAAMjB,OAAOmB,oBAAoB,UAAWF,EAAS,CAC9D,EAYO,SAASG,EACdf,EACAgB,EACAC,GACA,IAAAC,EACMnB,UAAOmB,EAAGD,aAAAA,EAAAA,EAASlB,eAAO,IAAAmB,EAAAA,EAAIvB,OAAOwB,aACrCC,EAAaC,EAAMC,aACvB,SAACrB,GACC,OAAIgB,SAAAA,EAASG,WAAmBH,EAAQG,WAAWnB,GAC5CsB,KAAKC,UAAUvB,KAExB,CAACgB,eAAAA,EAASG,aAGNV,EAAeW,EAAMC,aACzB,SAACrB,GACC,GAAIgB,SAAAA,EAASP,aAAc,OAAOO,EAAQP,aAAaT,GAEvD,GAAc,cAAVA,EAIJ,IACE,OAAOsB,KAAKE,MAAMxB,EACnB,CAAC,MAAOyB,GACP,OAAOzB,CACT,CACF,GACA,CAACgB,EAASD,IAKNW,EAAQN,EAAMO,qBAAqBjB,GAFrB,WAAH,OAASF,EAAsBV,EAASC,EAAKU,EAAa,IACjD,WAAH,OA1CQ,SAAQM,GAA2C,OAClFA,aAAwBa,SAAWb,IAAiBA,CAAY,CAyChCc,CAAyBd,EAAa,IAGhEe,EAAWV,EAAMC,aACrB,SAACrB,GACC,GAAIA,QACF,OAAOM,EAAkBR,EAASC,GAGpCF,EAAeC,EAASC,EAAKoB,EAAWnB,GAC1C,GACA,CAACD,EAAK2B,IAcR,OAXAN,EAAMW,WAAU,WAEA,OADAvB,EAAsBV,EAASC,EAAKU,IAC3BM,GAEvBlB,EACEC,EACAC,EACAoB,EAAWJ,aAAwBa,SAAWb,IAAiBA,GAEnE,GAAG,CAAChB,IAEG,CACLC,MACE0B,QAAAA,EACEX,EACEA,aAAwBa,SACtBb,IACAA,EACF,KACNiB,IAAKF,EACLG,MAAO,WAAA,OAAM3B,EAAkBR,EAASC,EAAI,EAEhD"}
1
+ {"version":3,"file":"useStorage.js","sources":["../../../../src/hooks/useStorage/useStorage.ts"],"sourcesContent":["import React from 'react';\n\nexport type UseStorageInitialValue<Value> = Value | (() => Value);\nexport interface UseStorageOptions<Value> {\n serializer?: (value: Value) => string;\n deserializer?: (value: string) => Value;\n storage?: Storage;\n initialValue?: UseStorageInitialValue<Value>;\n}\n\nexport type UseStorageReturn<Value> = [\n value: Value,\n set: (value: Value) => void,\n remove: () => void\n];\n\nexport const dispatchStorageEvent = (params: Partial<StorageEvent>) =>\n window.dispatchEvent(new StorageEvent('storage', params));\n\nconst setStorageItem = (storage: Storage, key: string, value: string) => {\n const oldValue = storage.getItem(key);\n\n storage.setItem(key, value);\n dispatchStorageEvent({ key, oldValue, newValue: value, storageArea: storage });\n};\n\nconst removeStorageItem = (storage: Storage, key: string) => {\n const oldValue = storage.getItem(key);\n\n storage.removeItem(key);\n dispatchStorageEvent({ key, oldValue, newValue: null, storageArea: storage });\n};\n\nconst getStorageItem = <Value>(\n storage: Storage,\n key: string,\n deserializer: (value: string) => Value\n) => {\n const value = storage.getItem(key);\n if (!value) return undefined;\n return deserializer(value);\n};\n\nconst storageSubscribe = (callback: () => void) => {\n window.addEventListener('storage', callback);\n return () => window.removeEventListener('storage', callback);\n};\n\nconst getStorageServerSnapshot = <Value>(initialValue: UseStorageInitialValue<Value>) =>\n initialValue instanceof Function ? initialValue() : initialValue;\n\n/**\n * @name useStorage\n * @description - Hook that manages a counter with increment, decrement, reset, and set functionalities\n *\n * @example\n * text\n */\nexport const useStorage = <Value>(\n key: string,\n params?: UseStorageInitialValue<Value> | UseStorageOptions<Value>\n) => {\n const options = (typeof params === 'object' ? params : undefined) as UseStorageOptions<Value>;\n const initialValue = (options ? options?.initialValue : params) as UseStorageInitialValue<Value>;\n\n const storage = options?.storage ?? window.localStorage;\n const serializer = (value: Value) => {\n if (options?.serializer) return options.serializer(value);\n return JSON.stringify(value);\n };\n\n const deserializer = (value: string) => {\n if (options?.deserializer) return options.deserializer(value);\n\n if (value === 'undefined') {\n return undefined as unknown as Value;\n }\n\n try {\n return JSON.parse(value) as Value;\n } catch (error) {\n return value as Value;\n }\n };\n\n const getSnapshot = () => getStorageItem<Value>(storage, key, deserializer);\n const getServerSnapshot = () => getStorageServerSnapshot(initialValue);\n const store = React.useSyncExternalStore(storageSubscribe, getSnapshot, getServerSnapshot);\n\n const set = (value: Value) => {\n if (value === null) return removeStorageItem(storage, key);\n setStorageItem(storage, key, serializer(value));\n };\n\n React.useEffect(() => {\n const value = getStorageItem<Value>(storage, key, deserializer);\n if (value !== undefined || !initialValue) return;\n\n const defaultValue = initialValue instanceof Function ? initialValue() : initialValue;\n\n setStorageItem(storage, key, serializer(defaultValue));\n }, [key]);\n\n const remove = () => removeStorageItem(storage, key);\n\n return [store, set, remove] as const;\n};\n"],"names":["dispatchStorageEvent","params","window","dispatchEvent","StorageEvent","setStorageItem","storage","key","value","oldValue","getItem","setItem","newValue","storageArea","removeStorageItem","removeItem","getStorageItem","deserializer","storageSubscribe","callback","addEventListener","removeEventListener","useStorage","_options$storage","options","_typeof","undefined","initialValue","localStorage","serializer","JSON","stringify","parse","error","store","React","useSyncExternalStore","Function","getStorageServerSnapshot","useEffect","defaultValue"],"mappings":";yFAgBaA,EAAuB,SAACC,GAA6B,OAChEC,OAAOC,cAAc,IAAIC,aAAa,UAAWH,GAAQ,EAErDI,EAAiB,SAACC,EAAkBC,EAAaC,GACrD,IAAMC,EAAWH,EAAQI,QAAQH,GAEjCD,EAAQK,QAAQJ,EAAKC,GACrBR,EAAqB,CAAEO,IAAAA,EAAKE,SAAAA,EAAUG,SAAUJ,EAAOK,YAAaP,GACtE,EAEMQ,EAAoB,SAACR,EAAkBC,GAC3C,IAAME,EAAWH,EAAQI,QAAQH,GAEjCD,EAAQS,WAAWR,GACnBP,EAAqB,CAAEO,IAAAA,EAAKE,SAAAA,EAAUG,SAAU,KAAMC,YAAaP,GACrE,EAEMU,EAAiB,SACrBV,EACAC,EACAU,GAEA,IAAMT,EAAQF,EAAQI,QAAQH,GAC9B,GAAKC,EACL,OAAOS,EAAaT,EACtB,EAEMU,EAAmB,SAACC,GAExB,OADAjB,OAAOkB,iBAAiB,UAAWD,GAC5B,WAAA,OAAMjB,OAAOmB,oBAAoB,UAAWF,EAAS,CAC9D,EAYaG,EAAa,SACxBf,EACAN,GACG,IAAAsB,EACGC,EAA6B,WAAlBC,EAAOxB,GAAsBA,OAASyB,EACjDC,EAAgBH,EAAUA,aAAO,EAAPA,EAASG,aAAe1B,EAElDK,UAAOiB,EAAGC,aAAAA,EAAAA,EAASlB,eAAO,IAAAiB,EAAAA,EAAIrB,OAAO0B,aACrCC,EAAa,SAACrB,GAClB,OAAIgB,SAAAA,EAASK,WAAmBL,EAAQK,WAAWrB,GAC5CsB,KAAKC,UAAUvB,IAGlBS,EAAe,SAACT,GACpB,GAAIgB,SAAAA,EAASP,aAAc,OAAOO,EAAQP,aAAaT,GAEvD,GAAc,cAAVA,EAIJ,IACE,OAAOsB,KAAKE,MAAMxB,EACnB,CAAC,MAAOyB,GACP,OAAOzB,CACT,GAKI0B,EAAQC,EAAMC,qBAAqBlB,GAFrB,WAAH,OAASF,EAAsBV,EAASC,EAAKU,EAAa,IACjD,WAAH,OAtCQ,SAAQU,GAA2C,OAClFA,aAAwBU,SAAWV,IAAiBA,CAAY,CAqChCW,CAAyBX,EAAa,IAQtEQ,EAAMI,WAAU,WAEd,QAAcb,IADAV,EAAsBV,EAASC,EAAKU,IACtBU,EAA5B,CAEA,IAAMa,EAAeb,aAAwBU,SAAWV,IAAiBA,EAEzEtB,EAAeC,EAASC,EAAKsB,EAAWW,GAJE,CAK5C,GAAG,CAACjC,IAIJ,MAAO,CAAC2B,EAhBI,SAAC1B,GACX,GAAc,OAAVA,EAAgB,OAAOM,EAAkBR,EAASC,GACtDF,EAAeC,EAASC,EAAKsB,EAAWrB,KAY3B,WAAH,OAASM,EAAkBR,EAASC,EAAI,EAGtD"}
@@ -1,3 +1,3 @@
1
- /* @license @siberiacancode/reactuse v0.0.1 */
2
- import{_ as e}from"../../_rollupPluginBabelHelpers-BDc6tlcX.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};
1
+ /* @license @siberiacancode/reactuse v0.0.5 */
2
+ import{_ as e}from"../../_rollupPluginBabelHelpers-8YyPIzj_.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 +1 @@
1
- {"version":3,"file":"useTimeout.js","sources":["../../../../src/hooks/useTimeout/useTimeout.ts"],"sourcesContent":["import React from 'react';\n\nimport { useIsomorphicLayoutEffect } from '../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect';\n\nexport function useTimeout(callback: () => void, delay: number) {\n const [ready, setReady] = React.useState(false);\n const internalCallbackRef = React.useRef(callback);\n const timeoutRef = React.useRef<NodeJS.Timeout>();\n\n useIsomorphicLayoutEffect(() => {\n internalCallbackRef.current = callback;\n }, [callback]);\n\n React.useEffect(() => {\n timeoutRef.current = setTimeout(() => {\n internalCallbackRef.current();\n setReady(true);\n }, delay);\n\n return () => {\n clearTimeout(timeoutRef.current);\n };\n }, [delay]);\n\n const clear = () => {\n clearTimeout(timeoutRef.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","internalCallbackRef","useRef","timeoutRef","useIsomorphicLayoutEffect","current","useEffect","setTimeout","clearTimeout","clear"],"mappings":";mOAIO,SAASA,EAAWC,EAAsBC,GAC/C,IAAAC,EAA0BC,EAAMC,UAAS,GAAMC,EAAAC,EAAAJ,EAAA,GAAxCK,EAAKF,EAAA,GAAEG,EAAQH,EAAA,GAChBI,EAAsBN,EAAMO,OAAOV,GACnCW,EAAaR,EAAMO,SAEzBE,GAA0B,WACxBH,EAAoBI,QAAUb,CAChC,GAAG,CAACA,IAEJG,EAAMW,WAAU,WAMd,OALAH,EAAWE,QAAUE,YAAW,WAC9BN,EAAoBI,UACpBL,GAAS,EACV,GAAEP,GAEI,WACLe,aAAaL,EAAWE,SAE5B,GAAG,CAACZ,IAOJ,MAAO,CAAEM,MAAAA,EAAOU,MALF,WACZD,aAAaL,EAAWE,SACxBL,GAAS,IAIb"}
1
+ {"version":3,"file":"useTimeout.js","sources":["../../../../src/hooks/useTimeout/useTimeout.ts"],"sourcesContent":["import React from 'react';\n\nimport { useIsomorphicLayoutEffect } from '../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect';\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 const internalCallbackRef = React.useRef(callback);\n const timeoutRef = React.useRef<NodeJS.Timeout>();\n\n useIsomorphicLayoutEffect(() => {\n internalCallbackRef.current = callback;\n }, [callback]);\n\n React.useEffect(() => {\n timeoutRef.current = setTimeout(() => {\n internalCallbackRef.current();\n setReady(true);\n }, delay);\n\n return () => {\n clearTimeout(timeoutRef.current);\n };\n }, [delay]);\n\n const clear = () => {\n clearTimeout(timeoutRef.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","internalCallbackRef","useRef","timeoutRef","useIsomorphicLayoutEffect","current","useEffect","setTimeout","clearTimeout","clear"],"mappings":";mOAuBO,SAASA,EAAWC,EAAsBC,GAC/C,IAAAC,EAA0BC,EAAMC,UAAS,GAAMC,EAAAC,EAAAJ,EAAA,GAAxCK,EAAKF,EAAA,GAAEG,EAAQH,EAAA,GAChBI,EAAsBN,EAAMO,OAAOV,GACnCW,EAAaR,EAAMO,SAEzBE,GAA0B,WACxBH,EAAoBI,QAAUb,CAChC,GAAG,CAACA,IAEJG,EAAMW,WAAU,WAMd,OALAH,EAAWE,QAAUE,YAAW,WAC9BN,EAAoBI,UACpBL,GAAS,EACV,GAAEP,GAEI,WACLe,aAAaL,EAAWE,SAE5B,GAAG,CAACZ,IAOJ,MAAO,CAAEM,MAAAA,EAAOU,MALF,WACZD,aAAaL,EAAWE,SACxBL,GAAS,IAIb"}
@@ -0,0 +1,3 @@
1
+ /* @license @siberiacancode/reactuse v0.0.5 */
2
+ import{_ as r}from"../../_rollupPluginBabelHelpers-8YyPIzj_.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
+ //# sourceMappingURL=useToggle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useToggle.js","sources":["../../../../src/hooks/useToggle/useToggle.ts"],"sourcesContent":["import React from 'react';\n\nexport type UseToggleReturn<Value> = readonly [Value, (value?: Value) => void];\n\nexport const useToggle = <Value = boolean>(values: readonly Value[] = [false, true] as any) => {\n const [[option], toggle] = React.useReducer(\n (state: Value[], action: React.SetStateAction<Value>) => {\n const value = action instanceof Function ? action(state[0]) : action;\n const index = Math.abs(state.indexOf(value));\n return state.slice(index).concat(state.slice(0, index));\n },\n values as Value[]\n );\n\n return [option, toggle as (value?: Value) => void] as const;\n};\n"],"names":["useToggle","values","arguments","length","undefined","_React$useReducer","React","useReducer","state","action","value","Function","index","Math","abs","indexOf","slice","concat","_React$useReducer2","_slicedToArray"],"mappings":";yFAIaA,EAAY,WAAsE,IAApDC,EAAwBC,UAAAC,eAAAC,IAAAF,UAAA,GAAAA,UAAG,GAAA,EAAC,GAAO,GAC5EG,EAA2BC,EAAMC,YAC/B,SAACC,EAAgBC,GACf,IAAMC,EAAQD,aAAkBE,SAAWF,EAAOD,EAAM,IAAMC,EACxDG,EAAQC,KAAKC,IAAIN,EAAMO,QAAQL,IACrC,OAAOF,EAAMQ,MAAMJ,GAAOK,OAAOT,EAAMQ,MAAM,EAAGJ,GACjD,GACDX,GACDiB,EAAAC,EAAAd,EAAA,GAED,MAAO,CAFNc,EAAAD,EAAA,GAAA,GAPa,GAASA,EAAA,GAUzB"}
@@ -1,3 +1,3 @@
1
- /* @license @siberiacancode/reactuse v0.0.1 */
1
+ /* @license @siberiacancode/reactuse v0.0.5 */
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 +1 @@
1
- {"version":3,"file":"useUnmount.js","sources":["../../../../src/hooks/useUnmount/useUnmount.ts"],"sourcesContent":["import React from 'react';\n\n/**\n * @name useUnmount\n * @description - Hook that defines the logic when unmounting a component\n *\n * @param {() => void} callback The callback function to be invoked on component unmount\n *\n * @returns {void}\n *\n * @example\n * useUnmount(() => console.log('Component unmounted'));\n */\n\nexport const useUnmount = (callback: () => void) => {\n const callbackRef = React.useRef(callback);\n callbackRef.current = callback;\n\n React.useEffect(\n () => () => {\n callbackRef.current();\n },\n []\n );\n};\n"],"names":["useUnmount","callback","callbackRef","React","useRef","current","useEffect"],"mappings":";yBAcaA,EAAa,SAACC,GACzB,IAAMC,EAAcC,EAAMC,OAAOH,GACjCC,EAAYG,QAAUJ,EAEtBE,EAAMG,WACJ,WAAA,OAAM,WACJJ,EAAYG,UACb,GACD,GAEJ"}
1
+ {"version":3,"file":"useUnmount.js","sources":["../../../../src/hooks/useUnmount/useUnmount.ts"],"sourcesContent":["import React from 'react';\n\n/**\n * @name useUnmount\n * @description - Hook that defines the logic when unmounting a component\n *\n * @param {() => void} callback The callback function to be invoked on component unmount\n * @returns {void}\n *\n * @example\n * useUnmount(() => console.log('Component unmounted'));\n */\n\nexport const useUnmount = (callback: () => void) => {\n const callbackRef = React.useRef(callback);\n callbackRef.current = callback;\n\n React.useEffect(\n () => () => {\n callbackRef.current();\n },\n []\n );\n};\n"],"names":["useUnmount","callback","callbackRef","React","useRef","current","useEffect"],"mappings":";yBAaaA,EAAa,SAACC,GACzB,IAAMC,EAAcC,EAAMC,OAAOH,GACjCC,EAAYG,QAAUJ,EAEtBE,EAAMG,WACJ,WAAA,OAAM,WACJJ,EAAYG,UACb,GACD,GAEJ"}
@@ -1,3 +1,3 @@
1
- /* @license @siberiacancode/reactuse v0.0.1 */
1
+ /* @license @siberiacancode/reactuse v0.0.5 */
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.1 */
2
- import{_ as i}from"../../_rollupPluginBabelHelpers-BDc6tlcX.js";import{useState as n}from"react";import{isClient as e}from"../../utils/helpers/isClient.js";import{useEventListener as t}from"../useEventListener/useEventListener.js";var r=function(r){var o,l,d=n({width:e?window.innerWidth:null!==(o=null==r?void 0:r.initialWidth)&&void 0!==o?o:Number.POSITIVE_INFINITY,height:e?window.innerHeight:null!==(l=null==r?void 0:r.initialWidth)&&void 0!==l?l:Number.POSITIVE_INFINITY}),u=i(d,2),h=u[0],s=u[1];return t(window,"resize",(function(){s({width:window.innerWidth,height:window.innerHeight})})),h};export{r as useWindowSize};
1
+ /* @license @siberiacancode/reactuse v0.0.5 */
2
+ import{_ as i}from"../../_rollupPluginBabelHelpers-8YyPIzj_.js";import{useState as n}from"react";import{isClient as e}from"../../utils/helpers/isClient.js";import{useEventListener as t}from"../useEventListener/useEventListener.js";var r=function(r){var o,l,d=n({width:e?window.innerWidth:null!==(o=null==r?void 0:r.initialWidth)&&void 0!==o?o:Number.POSITIVE_INFINITY,height:e?window.innerHeight:null!==(l=null==r?void 0:r.initialWidth)&&void 0!==l?l:Number.POSITIVE_INFINITY}),u=i(d,2),h=u[0],s=u[1];return t(window,"resize",(function(){s({width:window.innerWidth,height:window.innerHeight})})),h};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 { useState } 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 {UseWindowSizeParams} [useWindowSizeParams] The use copy to clipboard params\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] = 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","_useState","useState","width","isClient","window","innerWidth","initialWidth","Number","POSITIVE_INFINITY","height","innerHeight","_useState2","_slicedToArray","size","setSize","useEventListener"],"mappings":";2OAgCaA,EAAgB,SAACC,GAAiC,IAAAC,EAAAC,EAC7DC,EAAwBC,EAAS,CAC/BC,MAAOC,EAAWC,OAAOC,WAAiCP,QAAvBA,EAAGD,aAAAA,EAAAA,EAAQS,wBAAYR,EAAAA,EAAIS,OAAOC,kBACrEC,OAAQN,EAAWC,OAAOM,YAAkC,QAAvBX,EAAGF,aAAAA,EAAAA,EAAQS,oBAAYP,IAAAA,EAAAA,EAAIQ,OAAOC,oBACvEG,EAAAC,EAAAZ,EAAA,GAHKa,EAAIF,EAAA,GAAEG,EAAOH,EAAA,GAYpB,OAPAI,EAAiBX,OAAQ,UAAU,WACjCU,EAAQ,CACNZ,MAAOE,OAAOC,WACdI,OAAQL,OAAOM,aAEnB,IAEOG,CACT"}
1
+ {"version":3,"file":"useWindowSize.js","sources":["../../../../src/hooks/useWindowSize/useWindowSize.ts"],"sourcesContent":["import { useState } 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] = 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","_useState","useState","width","isClient","window","innerWidth","initialWidth","Number","POSITIVE_INFINITY","height","innerHeight","_useState2","_slicedToArray","size","setSize","useEventListener"],"mappings":";2OAiCaA,EAAgB,SAACC,GAAiC,IAAAC,EAAAC,EAC7DC,EAAwBC,EAAS,CAC/BC,MAAOC,EAAWC,OAAOC,WAAiCP,QAAvBA,EAAGD,aAAAA,EAAAA,EAAQS,wBAAYR,EAAAA,EAAIS,OAAOC,kBACrEC,OAAQN,EAAWC,OAAOM,YAAkC,QAAvBX,EAAGF,aAAAA,EAAAA,EAAQS,oBAAYP,IAAAA,EAAAA,EAAIQ,OAAOC,oBACvEG,EAAAC,EAAAZ,EAAA,GAHKa,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.1 */
2
- 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{useDocumentTitle}from"./hooks/useDocumentTitle/useDocumentTitle.js";export{useDocumentVisibility}from"./hooks/useDocumentVisibility/useDocumentVisibility.js";export{useEventListener}from"./hooks/useEventListener/useEventListener.js";export{useHover}from"./hooks/useHover/useHover.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{useMount}from"./hooks/useMount/useMount.js";export{getConnection,useNetwork}from"./hooks/useNetwork/useNetwork.js";export{useNonInitialEffect}from"./hooks/useNonInitialEffect/useNonInitialEffect.js";export{useOnline}from"./hooks/useOnline/useOnline.js";export{useOrientation}from"./hooks/useOrientation/useOrientation.js";export{useRenderCount}from"./hooks/useRenderCount/useRenderCount.js";export{useSessionStorage}from"./hooks/useSessionStorage/useSessionStorage.js";export{dispatchStorageEvent,useStorage}from"./hooks/useStorage/useStorage.js";export{useTimeout}from"./hooks/useTimeout/useTimeout.js";export{useUnmount}from"./hooks/useUnmount/useUnmount.js";export{useWindowEvent}from"./hooks/useWindowEvent/useWindowEvent.js";export{useWindowSize}from"./hooks/useWindowSize/useWindowSize.js";import"./_rollupPluginBabelHelpers-BDc6tlcX.js";import"react";import"./utils/helpers/debounce.js";import"./utils/helpers/isClient.js";import"./hooks/useMutationObserver.js";import"./utils/helpers/isShallowEqual.js";
1
+ /* @license @siberiacancode/reactuse v0.0.5 */
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{useDocumentTitle}from"./hooks/useDocumentTitle/useDocumentTitle.js";export{useDocumentVisibility}from"./hooks/useDocumentVisibility/useDocumentVisibility.js";export{useEventListener}from"./hooks/useEventListener/useEventListener.js";export{useHover}from"./hooks/useHover/useHover.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{useMount}from"./hooks/useMount/useMount.js";export{getConnection,useNetwork}from"./hooks/useNetwork/useNetwork.js";export{useNonInitialEffect}from"./hooks/useNonInitialEffect/useNonInitialEffect.js";export{useOnline}from"./hooks/useOnline/useOnline.js";export{useOrientation}from"./hooks/useOrientation/useOrientation.js";export{useRenderCount}from"./hooks/useRenderCount/useRenderCount.js";export{useSessionStorage}from"./hooks/useSessionStorage/useSessionStorage.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-8YyPIzj_.js";import"react";import"./utils/helpers/debounce.js";import"./utils/helpers/isClient.js";import"./hooks/useMutationObserver.js";import"./utils/helpers/isShallowEqual.js";
3
3
  //# sourceMappingURL=index.js.map
@@ -1,3 +1,3 @@
1
- /* @license @siberiacancode/reactuse v0.0.1 */
1
+ /* @license @siberiacancode/reactuse v0.0.5 */
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 */
1
+ /* @license @siberiacancode/reactuse v0.0.5 */
2
2
  export{debounce}from"./debounce.js";export{isClient}from"./isClient.js";export{isShallowEqual}from"./isShallowEqual.js";
3
3
  //# sourceMappingURL=index.js.map
@@ -1,3 +1,3 @@
1
- /* @license @siberiacancode/reactuse v0.0.1 */
1
+ /* @license @siberiacancode/reactuse v0.0.5 */
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 */
1
+ /* @license @siberiacancode/reactuse v0.0.5 */
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