@siberiacancode/reactuse 0.0.9 → 0.0.10
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-Db0KR1gW.js → _rollupPluginBabelHelpers-BvBejAnn.js} +3 -3
- package/dist/cjs/_rollupPluginBabelHelpers-BvBejAnn.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 +2 -2
- 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/useDocumentTitle/useDocumentTitle.js.map +1 -1
- package/dist/cjs/hooks/useDocumentVisibility/useDocumentVisibility.js +2 -2
- package/dist/cjs/hooks/useDocumentVisibility/useDocumentVisibility.js.map +1 -1
- package/dist/cjs/hooks/useEvent/useEvent.js +3 -0
- package/dist/cjs/hooks/useEvent/useEvent.js.map +1 -0
- package/dist/cjs/hooks/useEventListener/useEventListener.js +1 -1
- package/dist/cjs/hooks/useFavicon/useFavicon.js +2 -2
- package/dist/cjs/hooks/useHash/useHash.js +2 -2
- package/dist/cjs/hooks/useHotkeys/useHotkeys.js +3 -0
- package/dist/cjs/hooks/useHotkeys/useHotkeys.js.map +1 -0
- package/dist/cjs/hooks/useHover/useHover.js +2 -2
- package/dist/cjs/hooks/useHover/useHover.js.map +1 -1
- package/dist/cjs/hooks/useIdle/useIdle.js +2 -2
- package/dist/cjs/hooks/useIntersectionObserver/useIntersectionObserver.js +3 -0
- package/dist/cjs/hooks/useIntersectionObserver/useIntersectionObserver.js.map +1 -0
- package/dist/cjs/hooks/useIsFirstRender/useIsFirstRender.js +1 -1
- package/dist/cjs/hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js +1 -1
- package/dist/cjs/hooks/useKeyPress/useKeyPress.js +2 -2
- package/dist/cjs/hooks/useKeyPressEvent/useKeyPressEvent.js +1 -1
- package/dist/cjs/hooks/useKeysPressed/useKeysPressed.js +2 -2
- package/dist/cjs/hooks/useKeysPressed/useKeysPressed.js.map +1 -1
- 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/usePrevious/usePrevious.js +1 -1
- package/dist/cjs/hooks/useQueue/useQueue.js +3 -0
- package/dist/cjs/hooks/useQueue/useQueue.js.map +1 -0
- 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/useScript/useScript.js.map +1 -1
- package/dist/cjs/hooks/useSessionStorage/useSessionStorage.js +2 -2
- package/dist/cjs/hooks/useSet/useSet.js +2 -2
- package/dist/cjs/hooks/useStep/useStep.js +2 -2
- package/dist/cjs/hooks/useStorage/useStorage.js +2 -2
- package/dist/cjs/hooks/useTimeout/useTimeout.js +2 -2
- package/dist/cjs/hooks/useToggle/useToggle.js +2 -2
- package/dist/cjs/hooks/useUnmount/useUnmount.js +1 -1
- package/dist/cjs/hooks/useWindowEvent/useWindowEvent.js +1 -1
- package/dist/cjs/hooks/useWindowSize/useWindowSize.js +2 -2
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/utils/helpers/debounce.js +1 -1
- package/dist/cjs/utils/helpers/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-Cg3Jntln.js → _rollupPluginBabelHelpers-D5_r4iwW.js} +3 -3
- package/dist/esm/_rollupPluginBabelHelpers-D5_r4iwW.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 +2 -2
- 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/useDocumentTitle/useDocumentTitle.js.map +1 -1
- package/dist/esm/hooks/useDocumentVisibility/useDocumentVisibility.js +2 -2
- package/dist/esm/hooks/useDocumentVisibility/useDocumentVisibility.js.map +1 -1
- package/dist/esm/hooks/useEvent/useEvent.js +3 -0
- package/dist/esm/hooks/useEvent/useEvent.js.map +1 -0
- package/dist/esm/hooks/useEventListener/useEventListener.js +1 -1
- package/dist/esm/hooks/useFavicon/useFavicon.js +2 -2
- package/dist/esm/hooks/useHash/useHash.js +2 -2
- package/dist/esm/hooks/useHotkeys/useHotkeys.js +3 -0
- package/dist/esm/hooks/useHotkeys/useHotkeys.js.map +1 -0
- package/dist/esm/hooks/useHover/useHover.js +2 -2
- package/dist/esm/hooks/useHover/useHover.js.map +1 -1
- package/dist/esm/hooks/useIdle/useIdle.js +2 -2
- package/dist/esm/hooks/useIntersectionObserver/useIntersectionObserver.js +3 -0
- package/dist/esm/hooks/useIntersectionObserver/useIntersectionObserver.js.map +1 -0
- package/dist/esm/hooks/useIsFirstRender/useIsFirstRender.js +1 -1
- package/dist/esm/hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js +1 -1
- package/dist/esm/hooks/useKeyPress/useKeyPress.js +2 -2
- package/dist/esm/hooks/useKeyPressEvent/useKeyPressEvent.js +1 -1
- package/dist/esm/hooks/useKeysPressed/useKeysPressed.js +2 -2
- package/dist/esm/hooks/useKeysPressed/useKeysPressed.js.map +1 -1
- 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/usePrevious/usePrevious.js +1 -1
- package/dist/esm/hooks/useQueue/useQueue.js +3 -0
- package/dist/esm/hooks/useQueue/useQueue.js.map +1 -0
- 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/useScript/useScript.js.map +1 -1
- package/dist/esm/hooks/useSessionStorage/useSessionStorage.js +2 -2
- package/dist/esm/hooks/useSet/useSet.js +2 -2
- package/dist/esm/hooks/useStep/useStep.js +2 -2
- package/dist/esm/hooks/useStorage/useStorage.js +2 -2
- package/dist/esm/hooks/useTimeout/useTimeout.js +2 -2
- package/dist/esm/hooks/useToggle/useToggle.js +2 -2
- package/dist/esm/hooks/useUnmount/useUnmount.js +1 -1
- package/dist/esm/hooks/useWindowEvent/useWindowEvent.js +1 -1
- package/dist/esm/hooks/useWindowSize/useWindowSize.js +2 -2
- package/dist/esm/index.js +2 -2
- package/dist/esm/utils/helpers/debounce.js +1 -1
- package/dist/esm/utils/helpers/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 +96 -5
- package/package.json +2 -1
- package/dist/cjs/_rollupPluginBabelHelpers-Db0KR1gW.js.map +0 -1
- package/dist/esm/_rollupPluginBabelHelpers-Cg3Jntln.js.map +0 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.9 */
|
|
2
2
|
import r from"react";var e=function(){var e=r.useRef(!0);return!0===e.current?(e.current=!1,!0):e.current};export{e as useIsFirstRender};
|
|
3
3
|
//# sourceMappingURL=useIsFirstRender.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.9 */
|
|
2
2
|
import e from"react";import{isClient as t}from"../../utils/helpers/isClient.js";var r=t?e.useLayoutEffect:e.useEffect;export{r as useIsomorphicLayoutEffect};
|
|
3
3
|
//# sourceMappingURL=useIsomorphicLayoutEffect.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as e}from"../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.9 */
|
|
2
|
+
import{_ as e}from"../../_rollupPluginBabelHelpers-D5_r4iwW.js";import r from"react";import{useEventListener as n}from"../useEventListener/useEventListener.js";var i=function(i,t){var o,u,l=r.useState(!1),s=e(l,2),a=s[0],y=s[1];return n(null!==(o=null==t?void 0:t.target)&&void 0!==o?o:window,"keydown",(function(e){(Array.isArray(i)?i.includes(e.key):e.key===i)&&y(!0)})),n(null!==(u=null==t?void 0:t.target)&&void 0!==u?u:window,"keyup",(function(e){(Array.isArray(i)?i.includes(e.key):e.key===i)&&y(!1)})),a};export{i as useKeyPress};
|
|
3
3
|
//# sourceMappingURL=useKeyPress.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.9 */
|
|
2
2
|
import{useEventListener as n}from"../useEventListener/useEventListener.js";import"react";var e=function(){var e=Array.isArray(arguments.length<=0?void 0:arguments[0])?arguments.length<=0?void 0:arguments[0]:[arguments.length<=0?void 0:arguments[0]],t=(arguments.length<=1?void 0:arguments[1])instanceof Function?null:arguments.length<=1?void 0:arguments[1],i=t?arguments.length<=2?void 0:arguments[2]:arguments.length<=1?void 0:arguments[1];n(null!=t?t:window,"keydown",(function(n){e.includes(n.key)&&i(n)}),t?arguments.length<=3?void 0:arguments[3]:arguments.length<=2?void 0:arguments[2])};export{e as useKeyPressEvent};
|
|
3
3
|
//# sourceMappingURL=useKeyPressEvent.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as e,c as
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.9 */
|
|
2
|
+
import{_ as e,c as o}from"../../_rollupPluginBabelHelpers-D5_r4iwW.js";import t from"react";import{useDidUpdate as n}from"../useDidUpdate/useDidUpdate.js";import{useEvent as r}from"../useEvent/useEvent.js";import{useEventListener as i}from"../useEventListener/useEventListener.js";import"../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js";import"../../utils/helpers/isClient.js";var u=function(u){var s,c,l,d=null===(s=null==u?void 0:u.enabled)||void 0===s||s,f=t.useState([]),p=e(f,2),a=p[0],m=p[1],v=r((function(e){d&&m((function(t){return t.some((function(o){return o.code===e.code}))?t:[].concat(o(t),[{key:e.key,code:e.code}])}))})),j=r((function(e){d&&m((function(o){return o.filter((function(o){return o.code!==e.code}))}))}));return n((function(){m([])}),[d]),i(null!==(c=null==u?void 0:u.target)&&void 0!==c?c:window,"keydown",v),i(null!==(l=null==u?void 0:u.target)&&void 0!==l?l:window,"keyup",j),a};export{u 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\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
|
|
1
|
+
{"version":3,"file":"useKeysPressed.js","sources":["../../../../src/hooks/useKeysPressed/useKeysPressed.ts"],"sourcesContent":["import React from 'react';\n\nimport { useDidUpdate } from '../useDidUpdate/useDidUpdate';\nimport { useEvent } from '../useEvent/useEvent';\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 = useEvent((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 = useEvent((event: KeyboardEvent) => {\n if (!enabled) return;\n setKeys((prevKeys) => prevKeys.filter(({ code }) => code !== event.code));\n });\n\n useDidUpdate(() => {\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","onKeyDown","useEvent","event","prevKeys","some","_ref","code","concat","_toConsumableArray","key","onKeyUp","filter","_ref2","useDidUpdate","useEventListener","target","window"],"mappings":";uYA2BaA,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,GAEdI,EAAYC,GAAS,SAACC,GACrBV,GACLO,GAAQ,SAACI,GACP,OAAIA,EAASC,MAAK,SAAAC,GAAO,OAAAA,EAAJC,OAAoBJ,EAAMI,QAAcH,EAC7D,GAAAI,OAAAC,EAAWL,GAAU,CAAA,CAAEM,IAAKP,EAAMO,IAAKH,KAAMJ,EAAMI,OACrD,GACF,IAEMI,EAAUT,GAAS,SAACC,GACnBV,GACLO,GAAQ,SAACI,GAAQ,OAAKA,EAASQ,QAAO,SAAAC,GAAO,OAAAA,EAAJN,OAAoBJ,EAAMI,UACrE,IASA,OAPAO,GAAa,WACXd,EAAQ,GACV,GAAG,CAACP,IAEJsB,UAAgBxB,EAACF,aAAM,EAANA,EAAQ2B,cAAM,IAAAzB,EAAAA,EAAI0B,OAAQ,UAAWhB,GACtDc,UAAgBvB,EAACH,aAAM,EAANA,EAAQ2B,cAAM,IAAAxB,EAAAA,EAAIyB,OAAQ,QAASN,GAE7CZ,CACT"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{b as o}from"../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.9 */
|
|
2
|
+
import{b as o}from"../../_rollupPluginBabelHelpers-D5_r4iwW.js";import{useStorage as r}from"../useStorage/useStorage.js";import"react";import"../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js";import"../../utils/helpers/isClient.js";var e=function(e,t,i){return r(e,o({initialValue:t,storage:window.localStorage},i))};export{e as useLocalStorage};
|
|
3
3
|
//# sourceMappingURL=useLocalStorage.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{c as o}from"../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.9 */
|
|
2
|
+
import{c as o}from"../../_rollupPluginBabelHelpers-D5_r4iwW.js";import t from"react";import{useDidUpdate as e}from"../useDidUpdate/useDidUpdate.js";import"../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js";import"../../utils/helpers/isClient.js";var c=function(c,n){t.useEffect((function(){var t;return(t=console).log.apply(t,["".concat(c," mounted")].concat(o(n))),function(){return console.log("".concat(c," unmounted"))}}),[]),e((function(){var t;(t=console).log.apply(t,["".concat(c," updated")].concat(o(n)))}),n)};export{c as useLogger};
|
|
3
3
|
//# sourceMappingURL=useLogger.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.9 */
|
|
2
2
|
import n from"react";var e=function(){return!1},t=function(t){var r=n.useCallback((function(n){var e=window.matchMedia(t);return e.addEventListener("change",n),function(){e.removeEventListener("change",n)}}),[t]);return n.useSyncExternalStore(r,(function(){return window.matchMedia(t).matches}),e)};export{t as useMediaQuery};
|
|
3
3
|
//# sourceMappingURL=useMediaQuery.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.9 */
|
|
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
|
+
/* @license @siberiacancode/reactuse v0.0.9 */
|
|
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)},t=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)}},o=function(){return{online:!1,type:void 0,effectiveType:void 0,saveData:!1,downlink:0,downlinkMax:0,rtt:0}},r=function(){var r=n.useRef();return n.useSyncExternalStore(t,(function(){var n=navigator.onLine,t=i(),o={online:n,downlink:null==t?void 0:t.downlink,downlinkMax:null==t?void 0:t.downlinkMax,effectiveType:null==t?void 0:t.effectiveType,rtt:null==t?void 0:t.rtt,saveData:null==t?void 0:t.saveData,type:null==t?void 0:t.type};return r.current&&e(r.current,o)?r.current:(r.current=o,o)}),o)};export{i as getConnection,r as useNetwork};
|
|
3
3
|
//# sourceMappingURL=useNetwork.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.9 */
|
|
2
2
|
import n from"react";var e=function(){return navigator.onLine},t=function(){return!1},r=function(n){return window.addEventListener("online",n),window.addEventListener("offline",n),function(){window.removeEventListener("online",n),window.removeEventListener("offline",n)}},o=function(){return n.useSyncExternalStore(r,e,t)};export{o as useOnline};
|
|
3
3
|
//# sourceMappingURL=useOnline.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.9 */
|
|
2
2
|
import n from"react";var i=function(){if("undefined"==typeof window)return"undetermined";var n=window.navigator.userAgent;return/(Macintosh)|(MacIntel)|(MacPPC)|(Mac68K)/i.test(n)?"macos":/(iPhone)|(iPad)|(iPod)/i.test(n)?"ios":/(Win32)|(Win64)|(Windows)|(WinCE)/i.test(n)?"windows":/Android/i.test(n)?"android":/Linux/i.test(n)?"linux":"undetermined"},e=function(){return n.useRef(i()).current};export{i as getOperatingSystem,e as useOperatingSystem};
|
|
3
3
|
//# sourceMappingURL=useOperatingSystem.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as e}from"../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.9 */
|
|
2
|
+
import{_ as e}from"../../_rollupPluginBabelHelpers-D5_r4iwW.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
|
+
/* @license @siberiacancode/reactuse v0.0.9 */
|
|
2
2
|
import r from"react";var e=function(e){var t=r.useRef();return r.useEffect((function(){t.current=e})),t.current};export{e as usePrevious};
|
|
3
3
|
//# sourceMappingURL=usePrevious.js.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.9 */
|
|
2
|
+
import{_ as r,c as t,d as e}from"../../_rollupPluginBabelHelpers-D5_r4iwW.js";import n from"react";var u=function(){var u=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],o=n.useState(u),a=r(o,2),i=a[0],c=a[1];return{add:function(r){return c((function(e){return[].concat(t(e),[r])}))},remove:function(){var r;return c((function(t){var n=e(t),u=n[0],o=n.slice(1);return r=u,o})),r},clear:function(){return c([])},first:i[0],last:i[i.length-1],size:i.length,queue:i}};export{u as useQueue};
|
|
3
|
+
//# sourceMappingURL=useQueue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useQueue.js","sources":["../../../../src/hooks/useQueue/useQueue.ts"],"sourcesContent":["import React from 'react';\n\n/** The use queue return type */\nexport interface UseQueueReturn<Value> {\n /** The current queue */\n queue: Value[];\n /** Add an element to the queue */\n add: (element: Value) => void;\n /** Remove an element from the queue */\n remove: () => Value;\n /** Clear the queue */\n clear: () => void;\n /** Get the first element of the queue */\n first: Value;\n /** Get the last element of the queue */\n last: Value;\n /** Get the size of the queue */\n size: number;\n}\n\n/**\n * @name useQueue\n * @description - Hook that manages a queue\n *\n * @template Value The type of the value\n * @param {Value[]} [initialValue=[]] The initial value of the queue\n * @returns {UseQueueReturn} An object containing the current queue and functions to interact with the queue\n *\n * @example\n * const { queue, add, remove, clear, first, last, size } = useQueue([1, 2, 3]);\n */\nexport const useQueue = <Value>(initialValue: Value[] = []): UseQueueReturn<Value> => {\n const [queue, setQueue] = React.useState(initialValue);\n\n const add = (element: Value) => setQueue((queue) => [...queue, element]);\n const clear = () => setQueue([]);\n const remove = () => {\n let removed;\n setQueue(([first, ...rest]) => {\n removed = first;\n return rest;\n });\n return removed as Value;\n };\n\n return {\n add,\n remove,\n clear,\n first: queue[0],\n last: queue[queue.length - 1],\n size: queue.length,\n queue\n };\n};\n"],"names":["useQueue","initialValue","arguments","length","undefined","_React$useState","React","useState","_React$useState2","_slicedToArray","queue","setQueue","add","element","concat","_toConsumableArray","remove","removed","_ref","_ref2","_toArray","first","rest","slice","clear","last","size"],"mappings":";uGA+BaA,EAAW,WAA8D,IAAtDC,EAAqBC,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,GAAG,GACtDG,EAA0BC,EAAMC,SAASN,GAAaO,EAAAC,EAAAJ,EAAA,GAA/CK,EAAKF,EAAA,GAAEG,EAAQH,EAAA,GAatB,MAAO,CACLI,IAZU,SAACC,GAAc,OAAKF,GAAS,SAACD,GAAK,MAAA,GAAAI,OAAAC,EAASL,IAAOG,GAAO,GAAE,EAatEG,OAXa,WACb,IAAIC,EAKJ,OAJAN,GAAS,SAAAO,GAAsB,IAAAC,EAAAC,EAAAF,GAApBG,EAAKF,EAAA,GAAKG,EAAIH,EAAAI,MAAA,GAEvB,OADAN,EAAUI,EACHC,CACT,IACOL,GAMPO,MAbY,WAAH,OAASb,EAAS,GAAG,EAc9BU,MAAOX,EAAM,GACbe,KAAMf,EAAMA,EAAMP,OAAS,GAC3BuB,KAAMhB,EAAMP,OACZO,MAAAA,EAEJ"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.9 */
|
|
2
2
|
import r from"react";var e=function(){var e=r.useRef(0);return r.useEffect((function(){e.current+=1})),e.current};export{e as useRenderCount};
|
|
3
3
|
//# sourceMappingURL=useRenderCount.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as r}from"../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.9 */
|
|
2
|
+
import{_ as r}from"../../_rollupPluginBabelHelpers-D5_r4iwW.js";import t from"react";var e=function(){var e=t.useId(),o=t.useState(e),a=r(o,2),n=a[0],u=a[1];return{id:n,update:function(){return u(Math.random().toString())}}};export{e as useRerender};
|
|
3
3
|
//# sourceMappingURL=useRerender.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as e}from"../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.9 */
|
|
2
|
+
import{_ as e}from"../../_rollupPluginBabelHelpers-D5_r4iwW.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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useScript.js","sources":["../../../../src/hooks/useScript/useScript.ts"],"sourcesContent":["import React from 'react';\n\nexport type UseScriptStatus = 'loading' | 'ready' | 'error' | 'unknown';\nexport const SCRIPT_STATUS_ATTRIBUTE_NAME = 'script-status';\n\nexport interface UseScriptOptions extends React.ComponentProps<'script'> {\n removeOnUnmount?: boolean;\n}\n\n/**\n * @name useScript\n * @description - Hook that manages a script with onLoad, onError, and removeOnUnmount functionalities\n *\n * @param {string} src The source of the script\n * @param {UseScriptOptions} [options] The options of the script extends from attributes script tag\n * @param {boolean} [options.removeOnUnmount=true] Whether to remove the script on unmount\n * @param {boolean} [options.async=true] Whether to load the script asynchronously\n * @returns {UseScriptStatus} The status of the script\n *\n * @example\n * const status = useScript('https://example.com/script.js');\n */\nexport const useScript = (src: string, options: UseScriptOptions = {}) => {\n const [status, setStatus] = React.useState<UseScriptStatus>(() => {\n const script = document.querySelector(`script[src=\"${src}\"]`) as HTMLScriptElement;\n const scriptStatus = script?.getAttribute(SCRIPT_STATUS_ATTRIBUTE_NAME) as UseScriptStatus;\n if (scriptStatus) return scriptStatus;\n if (script) return 'unknown';\n\n return 'loading';\n });\n const { removeOnUnmount = true, async = true } = options;\n\n React.useEffect(() => {\n const existedScript = document.querySelector(`script[src=\"${src}\"]`) as HTMLScriptElement;\n const scriptStatus = existedScript?.getAttribute(\n SCRIPT_STATUS_ATTRIBUTE_NAME\n ) as UseScriptStatus;\n if (scriptStatus) return setStatus(scriptStatus);\n if (existedScript) return setStatus('unknown');\n\n const script = document.createElement('script');\n script.src = src;\n script.async = async;\n\n for (const [key, value] of Object.entries(options)) {\n script.setAttribute(key, String(value));\n }\n\n script.setAttribute(SCRIPT_STATUS_ATTRIBUTE_NAME, 'loading');\n document.body.appendChild(script);\n\n const onLoad = () => {\n script.setAttribute(SCRIPT_STATUS_ATTRIBUTE_NAME, 'ready');\n setStatus('ready');\n };\n\n const onError = () => {\n script.setAttribute(SCRIPT_STATUS_ATTRIBUTE_NAME, 'error');\n setStatus('error');\n };\n\n const removeEventListeners = () => {\n script.removeEventListener('load', onLoad);\n script.removeEventListener('error', onError);\n };\n\n script.addEventListener('load', onLoad);\n script.addEventListener('error', onError);\n\n return () => {\n if (removeOnUnmount) {\n script.remove();\n removeEventListeners();\n }\n };\n }, [src, removeOnUnmount]);\n\n return status;\n};\n"],"names":["SCRIPT_STATUS_ATTRIBUTE_NAME","useScript","src","options","arguments","length","undefined","_React$useState","React","useState","script","document","querySelector","concat","scriptStatus","getAttribute","_React$useState2","_slicedToArray","status","setStatus","_options$removeOnUnmo","removeOnUnmount","_options$async","async","useEffect","existedScript","createElement","_i","_Object$entries","Object","entries","_Object$entries$_i","key","value","setAttribute","String","body","appendChild","onLoad","onError","addEventListener","remove","removeEventListener"],"mappings":";
|
|
1
|
+
{"version":3,"file":"useScript.js","sources":["../../../../src/hooks/useScript/useScript.ts"],"sourcesContent":["import React from 'react';\n\n/** The use script status */\nexport type UseScriptStatus = 'loading' | 'ready' | 'error' | 'unknown';\nexport const SCRIPT_STATUS_ATTRIBUTE_NAME = 'script-status';\n\n/** The use script options extends from attributes script tag */\nexport interface UseScriptOptions extends React.ComponentProps<'script'> {\n /** Whether to remove the script on unmount */\n removeOnUnmount?: boolean;\n}\n\n/**\n * @name useScript\n * @description - Hook that manages a script with onLoad, onError, and removeOnUnmount functionalities\n *\n * @param {string} src The source of the script\n * @param {UseScriptOptions} [options] The options of the script extends from attributes script tag\n * @param {boolean} [options.removeOnUnmount=true] Whether to remove the script on unmount\n * @param {boolean} [options.async=true] Whether to load the script asynchronously\n * @returns {UseScriptStatus} The status of the script\n *\n * @example\n * const status = useScript('https://example.com/script.js');\n */\nexport const useScript = (src: string, options: UseScriptOptions = {}) => {\n const [status, setStatus] = React.useState<UseScriptStatus>(() => {\n const script = document.querySelector(`script[src=\"${src}\"]`) as HTMLScriptElement;\n const scriptStatus = script?.getAttribute(SCRIPT_STATUS_ATTRIBUTE_NAME) as UseScriptStatus;\n if (scriptStatus) return scriptStatus;\n if (script) return 'unknown';\n\n return 'loading';\n });\n const { removeOnUnmount = true, async = true } = options;\n\n React.useEffect(() => {\n const existedScript = document.querySelector(`script[src=\"${src}\"]`) as HTMLScriptElement;\n const scriptStatus = existedScript?.getAttribute(\n SCRIPT_STATUS_ATTRIBUTE_NAME\n ) as UseScriptStatus;\n if (scriptStatus) return setStatus(scriptStatus);\n if (existedScript) return setStatus('unknown');\n\n const script = document.createElement('script');\n script.src = src;\n script.async = async;\n\n for (const [key, value] of Object.entries(options)) {\n script.setAttribute(key, String(value));\n }\n\n script.setAttribute(SCRIPT_STATUS_ATTRIBUTE_NAME, 'loading');\n document.body.appendChild(script);\n\n const onLoad = () => {\n script.setAttribute(SCRIPT_STATUS_ATTRIBUTE_NAME, 'ready');\n setStatus('ready');\n };\n\n const onError = () => {\n script.setAttribute(SCRIPT_STATUS_ATTRIBUTE_NAME, 'error');\n setStatus('error');\n };\n\n const removeEventListeners = () => {\n script.removeEventListener('load', onLoad);\n script.removeEventListener('error', onError);\n };\n\n script.addEventListener('load', onLoad);\n script.addEventListener('error', onError);\n\n return () => {\n if (removeOnUnmount) {\n script.remove();\n removeEventListeners();\n }\n };\n }, [src, removeOnUnmount]);\n\n return status;\n};\n"],"names":["SCRIPT_STATUS_ATTRIBUTE_NAME","useScript","src","options","arguments","length","undefined","_React$useState","React","useState","script","document","querySelector","concat","scriptStatus","getAttribute","_React$useState2","_slicedToArray","status","setStatus","_options$removeOnUnmo","removeOnUnmount","_options$async","async","useEffect","existedScript","createElement","_i","_Object$entries","Object","entries","_Object$entries$_i","key","value","setAttribute","String","body","appendChild","onLoad","onError","addEventListener","remove","removeEventListener"],"mappings":";qFAIO,IAAMA,EAA+B,gBAqB/BC,EAAY,SAACC,GAAgD,IAAnCC,EAAyBC,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,GAAG,CAAA,EACjEG,EAA4BC,EAAMC,UAA0B,WAC1D,IAAMC,EAASC,SAASC,6BAAaC,OAAgBX,EAAG,OAClDY,EAAeJ,aAAAA,EAAAA,EAAQK,aAAaf,GAC1C,OAAIc,IACAJ,EAAe,UAEZ,UACT,IAAEM,EAAAC,EAAAV,EAAA,GAPKW,EAAMF,EAAA,GAAEG,EAASH,EAAA,GAQxBI,EAAiDjB,EAAzCkB,gBAAAA,OAAkB,IAAHD,GAAOA,EAAAE,EAAmBnB,EAAjBoB,MAAAA,OAAQ,IAAHD,GAAOA,EA+C5C,OA7CAd,EAAMgB,WAAU,WACd,IAAMC,EAAgBd,SAASC,6BAAaC,OAAgBX,EAAG,OACzDY,EAAeW,aAAAA,EAAAA,EAAeV,aAClCf,GAEF,GAAIc,EAAc,OAAOK,EAAUL,GACnC,GAAIW,EAAe,OAAON,EAAU,WAEpC,IAAMT,EAASC,SAASe,cAAc,UACtChB,EAAOR,IAAMA,EACbQ,EAAOa,MAAQA,EAEf,IAAA,IAAAI,EAAAC,EAAAA,EAA2BC,OAAOC,QAAQ3B,GAAQwB,EAAAC,EAAAvB,OAAAsB,IAAE,CAA/C,IAAAI,EAAAd,EAAAW,EAAAD,GAAA,GAAOK,EAAGD,EAAA,GAAEE,EAAKF,EAAA,GACpBrB,EAAOwB,aAAaF,EAAKG,OAAOF,GAClC,CAEAvB,EAAOwB,aAAalC,EAA8B,WAClDW,SAASyB,KAAKC,YAAY3B,GAE1B,IAAM4B,EAAS,WACb5B,EAAOwB,aAAalC,EAA8B,SAClDmB,EAAU,UAGNoB,EAAU,WACd7B,EAAOwB,aAAalC,EAA8B,SAClDmB,EAAU,UAWZ,OAHAT,EAAO8B,iBAAiB,OAAQF,GAChC5B,EAAO8B,iBAAiB,QAASD,GAE1B,WACDlB,IACFX,EAAO+B,SATT/B,EAAOgC,oBAAoB,OAAQJ,GACnC5B,EAAOgC,oBAAoB,QAASH,IAYxC,GAAG,CAACrC,EAAKmB,IAEFH,CACT"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{b as o}from"../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.9 */
|
|
2
|
+
import{b as o}from"../../_rollupPluginBabelHelpers-D5_r4iwW.js";import{useStorage as e}from"../useStorage/useStorage.js";import"react";import"../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js";import"../../utils/helpers/isClient.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.9 */
|
|
2
|
+
import r from"react";import{useRerender as e}from"../useRerender/useRerender.js";import"../../_rollupPluginBabelHelpers-D5_r4iwW.js";var t=function(t){var n=r.useRef(new Set(t)),a=e();return n.current.add=function(){for(var r=arguments.length,e=new Array(r),t=0;t<r;t++)e[t]=arguments[t];var u=Set.prototype.add.apply(n.current,e);return a.update(),u},n.current.clear=function(){for(var r=arguments.length,e=new Array(r),t=0;t<r;t++)e[t]=arguments[t];Set.prototype.clear.apply(n.current,e),a.update()},n.current.delete=function(){for(var r=arguments.length,e=new Array(r),t=0;t<r;t++)e[t]=arguments[t];var u=Set.prototype.delete.apply(n.current,e);return a.update(),u},n.current};export{t as useSet};
|
|
3
3
|
//# sourceMappingURL=useSet.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{a as t,_ as r}from"../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.9 */
|
|
2
|
+
import{a as t,_ as r}from"../../_rollupPluginBabelHelpers-D5_r4iwW.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.9 */
|
|
2
|
+
import{a as e}from"../../_rollupPluginBabelHelpers-D5_r4iwW.js";import n from"react";import{useIsomorphicLayoutEffect as t}from"../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js";import"../../utils/helpers/isClient.js";var r=function(e){return window.dispatchEvent(new StorageEvent("storage",e))},i=function(e,n,t){var i=e.getItem(n);e.setItem(n,t),r({key:n,oldValue:i,newValue:t,storageArea:e})},o=function(e,n){var t=e.getItem(n);e.removeItem(n),r({key:n,oldValue:t,newValue:null,storageArea:e})},u=function(e,n,t){var r=e.getItem(n);if(r)return t(r)},a=function(e){return window.addEventListener("storage",e),function(){return window.removeEventListener("storage",e)}},l=function(r,l){var s,c="object"===e(l)?l:void 0,f=c?null==c?void 0:c.initialValue:l,d=null!==(s=null==c?void 0:c.storage)&&void 0!==s?s:window.localStorage,m=function(e){return null!=c&&c.serializer?c.serializer(e):JSON.stringify(e)},v=function(e){if(null!=c&&c.deserializer)return c.deserializer(e);if("undefined"!==e)try{return JSON.parse(e)}catch(n){return e}},g=n.useSyncExternalStore(a,(function(){return u(d,r,v)}),(function(){return function(e){return e instanceof Function?e():e}(f)}));t((function(){(void 0===u(d,r,v)||f)&&i(d,r,m(f instanceof Function?f():f))}),[r]);return[g,function(e){if(null===e)return o(d,r);i(d,r,m(e))},function(){return o(d,r)}]};export{r as dispatchStorageEvent,l 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.9 */
|
|
2
|
+
import{_ as e}from"../../_rollupPluginBabelHelpers-D5_r4iwW.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.9 */
|
|
2
|
+
import{_ as r}from"../../_rollupPluginBabelHelpers-D5_r4iwW.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.9 */
|
|
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.9 */
|
|
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.9 */
|
|
2
|
+
import{_ as i}from"../../_rollupPluginBabelHelpers-D5_r4iwW.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
|
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{useEventListener}from"./hooks/useEventListener/useEventListener.js";export{useFavicon}from"./hooks/useFavicon/useFavicon.js";export{useHash}from"./hooks/useHash/useHash.js";export{useHover}from"./hooks/useHover/useHover.js";export{useIdle}from"./hooks/useIdle/useIdle.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{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.9 */
|
|
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-D5_r4iwW.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.9 */
|
|
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.9 */
|
|
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.9 */
|
|
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.9 */
|
|
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.9 */
|
|
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
|
@@ -46,10 +46,10 @@ type UseBooleanReturn = [
|
|
|
46
46
|
declare const useBoolean: (initialValue?: boolean) => UseBooleanReturn;
|
|
47
47
|
|
|
48
48
|
type UseClickOutsideTarget = React.RefObject<Element | null> | (() => Element) | Element;
|
|
49
|
-
type UseClickOutsideReturn<Target extends UseClickOutsideTarget |
|
|
49
|
+
type UseClickOutsideReturn<Target extends UseClickOutsideTarget | UseClickOutsideTarget[]> = React.RefObject<Target>;
|
|
50
50
|
type UseClickOutside = {
|
|
51
|
-
<Target extends UseClickOutsideTarget |
|
|
52
|
-
<Target extends UseClickOutsideTarget |
|
|
51
|
+
<Target extends UseClickOutsideTarget | UseClickOutsideTarget[]>(target: Target, callback: (event: Event) => void): void;
|
|
52
|
+
<Target extends UseClickOutsideTarget | UseClickOutsideTarget[]>(callback: (event: Event) => void, target?: never): UseClickOutsideReturn<Target>;
|
|
53
53
|
};
|
|
54
54
|
declare const useClickOutside: UseClickOutside;
|
|
55
55
|
|
|
@@ -161,7 +161,7 @@ declare const useDefault: <Value>(initialValue: Value | (() => Value), defaultVa
|
|
|
161
161
|
*/
|
|
162
162
|
declare const useDidUpdate: (effect: React.EffectCallback, deps?: React.DependencyList) => void;
|
|
163
163
|
|
|
164
|
-
/** The use document title options
|
|
164
|
+
/** The use document title options */
|
|
165
165
|
interface UseDocumentTitleOptions {
|
|
166
166
|
/** Restore the previous title on unmount */
|
|
167
167
|
restoreOnUnmount?: boolean;
|
|
@@ -197,6 +197,8 @@ declare function useDocumentTitle(value?: string, options?: UseDocumentTitleOpti
|
|
|
197
197
|
*/
|
|
198
198
|
declare const useDocumentVisibility: () => DocumentVisibilityState;
|
|
199
199
|
|
|
200
|
+
declare const useEvent: <Params extends unknown[], Return>(callback: (...args: Params) => Return) => ((...args: Params) => Return);
|
|
201
|
+
|
|
200
202
|
type UseEventListenerTarget = React.RefObject<Element | null> | (() => Element) | Element | Window | Document;
|
|
201
203
|
type UseEventListenerOptions = boolean | AddEventListenerOptions;
|
|
202
204
|
type UseEventListenerReturn<Target extends UseEventListenerTarget = any> = React.RefObject<Target>;
|
|
@@ -245,6 +247,44 @@ type UseHashReturn = [string, (value: string) => void];
|
|
|
245
247
|
*/
|
|
246
248
|
declare const useHash: () => UseHashReturn;
|
|
247
249
|
|
|
250
|
+
/** The use keys pressed params */
|
|
251
|
+
interface UseHotkeysOptions {
|
|
252
|
+
/** The target to attach the event listeners to */
|
|
253
|
+
target?: UseEventListenerTarget;
|
|
254
|
+
/** Enable or disable the event listeners */
|
|
255
|
+
enabled?: boolean;
|
|
256
|
+
/** Whether to prevent the default behavior of the event */
|
|
257
|
+
preventDefault?: boolean;
|
|
258
|
+
/** Alias map for hotkeys */
|
|
259
|
+
aliasMap?: Record<string, string>;
|
|
260
|
+
}
|
|
261
|
+
declare const isHotkeyMatch: (hotkey: string, keys: UseHotkeysKey[]) => boolean;
|
|
262
|
+
type UseHotkeysHotkeys = string[] | string;
|
|
263
|
+
type UseHotkeysKey = {
|
|
264
|
+
key: string;
|
|
265
|
+
code: string;
|
|
266
|
+
alias: string;
|
|
267
|
+
};
|
|
268
|
+
/**
|
|
269
|
+
* @name useHotkeys
|
|
270
|
+
* @description - Hook that listens for key press events
|
|
271
|
+
*
|
|
272
|
+
* @param {UseHotkeysHotkeys} hotkeys The key or keys to listen for
|
|
273
|
+
* @param {(event: KeyboardEvent) => void} callback The callback function to be called when the hotkey is pressed
|
|
274
|
+
* @param {UseEventListenerTarget} [options.target=window] The target to attach the event listeners to
|
|
275
|
+
* @param {boolean} [options.enabled=true] Enable or disable the event listeners
|
|
276
|
+
* @param {boolean} [options.preventDefault=true] Whether to prevent the default behavior of the event
|
|
277
|
+
* @param {Record<string, string>} [options.aliasMap] Alias map for hotkeys
|
|
278
|
+
* @returns {useKeysPressedReturns} Array of strings with keys that were press
|
|
279
|
+
*
|
|
280
|
+
* @example
|
|
281
|
+
* useHotkeys('control+a', () => console.log('hotkey pressed'));
|
|
282
|
+
*
|
|
283
|
+
* @example
|
|
284
|
+
* useHotkeys('ControlLeft+KeyA', () => console.log('hotkey pressed'));
|
|
285
|
+
*/
|
|
286
|
+
declare const useHotkeys: (hotkeys: UseHotkeysHotkeys, callback: (event: KeyboardEvent) => void, options?: UseHotkeysOptions) => void;
|
|
287
|
+
|
|
248
288
|
interface UseHoverOptions {
|
|
249
289
|
onEntry?: () => void;
|
|
250
290
|
onLeave?: () => void;
|
|
@@ -306,6 +346,24 @@ interface UseIdleReturn {
|
|
|
306
346
|
*/
|
|
307
347
|
declare const useIdle: (milliseconds?: number, { initialState, events }?: UseIdleOptions) => UseIdleReturn;
|
|
308
348
|
|
|
349
|
+
type UseIntersectionObserverTarget = React.RefObject<Element | null> | (() => Element) | Element;
|
|
350
|
+
interface UseIntersectionObserverOptions extends Omit<IntersectionObserverInit, 'root'> {
|
|
351
|
+
immediate?: boolean;
|
|
352
|
+
onChange?: (entry: IntersectionObserverEntry) => void;
|
|
353
|
+
root?: IntersectionObserverInit['root'] | React.RefObject<Element | null>;
|
|
354
|
+
}
|
|
355
|
+
interface UseIntersectionObserverReturn {
|
|
356
|
+
inView: boolean;
|
|
357
|
+
entry?: IntersectionObserverEntry;
|
|
358
|
+
}
|
|
359
|
+
type UseIntersectionObserver = {
|
|
360
|
+
<Target extends UseIntersectionObserverTarget>(target: Target, options?: UseIntersectionObserverOptions): UseIntersectionObserverReturn;
|
|
361
|
+
<Target extends UseIntersectionObserverTarget>(options?: UseIntersectionObserverOptions, target?: never): UseIntersectionObserverReturn & {
|
|
362
|
+
ref: React.RefObject<Target>;
|
|
363
|
+
};
|
|
364
|
+
};
|
|
365
|
+
declare const useIntersectionObserver: UseIntersectionObserver;
|
|
366
|
+
|
|
309
367
|
/**
|
|
310
368
|
* @name useIsomorphicLayoutEffect
|
|
311
369
|
* @description - Hook conditionally selects either `useLayoutEffect` or `useEffect` based on the environment
|
|
@@ -517,6 +575,36 @@ declare const useOrientation: () => UseOrientationReturn;
|
|
|
517
575
|
*/
|
|
518
576
|
declare const usePrevious: <Value>(value: Value) => Value | undefined;
|
|
519
577
|
|
|
578
|
+
/** The use queue return type */
|
|
579
|
+
interface UseQueueReturn<Value> {
|
|
580
|
+
/** The current queue */
|
|
581
|
+
queue: Value[];
|
|
582
|
+
/** Add an element to the queue */
|
|
583
|
+
add: (element: Value) => void;
|
|
584
|
+
/** Remove an element from the queue */
|
|
585
|
+
remove: () => Value;
|
|
586
|
+
/** Clear the queue */
|
|
587
|
+
clear: () => void;
|
|
588
|
+
/** Get the first element of the queue */
|
|
589
|
+
first: Value;
|
|
590
|
+
/** Get the last element of the queue */
|
|
591
|
+
last: Value;
|
|
592
|
+
/** Get the size of the queue */
|
|
593
|
+
size: number;
|
|
594
|
+
}
|
|
595
|
+
/**
|
|
596
|
+
* @name useQueue
|
|
597
|
+
* @description - Hook that manages a queue
|
|
598
|
+
*
|
|
599
|
+
* @template Value The type of the value
|
|
600
|
+
* @param {Value[]} [initialValue=[]] The initial value of the queue
|
|
601
|
+
* @returns {UseQueueReturn} An object containing the current queue and functions to interact with the queue
|
|
602
|
+
*
|
|
603
|
+
* @example
|
|
604
|
+
* const { queue, add, remove, clear, first, last, size } = useQueue([1, 2, 3]);
|
|
605
|
+
*/
|
|
606
|
+
declare const useQueue: <Value>(initialValue?: Value[]) => UseQueueReturn<Value>;
|
|
607
|
+
|
|
520
608
|
/**
|
|
521
609
|
* @name useRenderCount
|
|
522
610
|
* @description - Hook returns count component render times
|
|
@@ -546,9 +634,12 @@ interface UseRerenderReturns {
|
|
|
546
634
|
*/
|
|
547
635
|
declare const useRerender: () => UseRerenderReturns;
|
|
548
636
|
|
|
637
|
+
/** The use script status */
|
|
549
638
|
type UseScriptStatus = 'loading' | 'ready' | 'error' | 'unknown';
|
|
550
639
|
declare const SCRIPT_STATUS_ATTRIBUTE_NAME = "script-status";
|
|
640
|
+
/** The use script options extends from attributes script tag */
|
|
551
641
|
interface UseScriptOptions extends React.ComponentProps<'script'> {
|
|
642
|
+
/** Whether to remove the script on unmount */
|
|
552
643
|
removeOnUnmount?: boolean;
|
|
553
644
|
}
|
|
554
645
|
/**
|
|
@@ -734,4 +825,4 @@ declare const useWindowSize: (params?: UseWindowSizeParams) => {
|
|
|
734
825
|
height: number;
|
|
735
826
|
};
|
|
736
827
|
|
|
737
|
-
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 UseFaviconOptions, type UseFaviconReturn, type UseHover, type UseHoverOptions, type UseHoverReturn, type UseHoverTarget, type UseIdleReturn, type UseKeyPressEvent, type UseKeyPressEventKey, type UseKeyPressKey, type UseKeyPressOptions, type UseNetworkReturn, type UseOrientationReturn, type UseScriptOptions, type UseScriptStatus, type UseStorageInitialValue, type UseStorageOptions, type UseStorageReturn, type UseToggleReturn, type UseWindowSizeReturn, dispatchStorageEvent, getConnection, getOperatingSystem, legacyCopyToClipboard, useBattery, useBoolean, useClickOutside, useCopyToClipboard, useCounter, useDebouncedValue, useDefault, useDidUpdate, useDocumentTitle, useDocumentVisibility, useEventListener, useFavicon, useHash, useHover, useIdle, useIsomorphicLayoutEffect, useKeyPress, useKeyPressEvent, useKeysPressed, useLocalStorage, useLogger, useMediaQuery, useMount, useNetwork, useOnline, useOperatingSystem, useOrientation, usePrevious, useRenderCount, useRerender, useScript, useSessionStorage, useSet, useStep, useStorage, useTimeout, useToggle, useUnmount, useWindowEvent, useWindowSize };
|
|
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 UseFaviconOptions, 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, useIsomorphicLayoutEffect, useKeyPress, useKeyPressEvent, useKeysPressed, useLocalStorage, useLogger, useMediaQuery, useMount, useNetwork, useOnline, useOperatingSystem, useOrientation, usePrevious, useQueue, useRenderCount, useRerender, useScript, useSessionStorage, useSet, useStep, useStorage, useTimeout, useToggle, useUnmount, useWindowEvent, useWindowSize };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@siberiacancode/reactuse",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"description": "Ultimate tool",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"module": "dist/esm/index.js",
|
|
33
33
|
"types": "dist/index.d.ts",
|
|
34
34
|
"scripts": {
|
|
35
|
+
"prepublish": "yarn type && yarn unit-test run && yarn build",
|
|
35
36
|
"build": "shx rm -rf dist && rollup -c --bundleConfigAsCjs",
|
|
36
37
|
"lint": "eslint . --ext ts --ext tsx --no-error-on-unmatched-pattern --fix",
|
|
37
38
|
"format": "prettier --write **/*.{ts,jsm,md}",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_rollupPluginBabelHelpers-Db0KR1gW.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_rollupPluginBabelHelpers-Cg3Jntln.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|