@siberiacancode/reactuse 0.0.9 → 0.0.11
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-OMepdpg5.js} +3 -3
- package/dist/cjs/_rollupPluginBabelHelpers-OMepdpg5.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/useStorage/useStorage.js.map +1 -1
- 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-TF5Io098.js} +3 -3
- package/dist/esm/_rollupPluginBabelHelpers-TF5Io098.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/useStorage/useStorage.js.map +1 -1
- 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 +99 -8
- package/package.json +2 -1
- package/dist/cjs/_rollupPluginBabelHelpers-Db0KR1gW.js.map +0 -1
- package/dist/esm/_rollupPluginBabelHelpers-Cg3Jntln.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useHover.js","sources":["../../../../src/hooks/useHover/useHover.ts"],"sourcesContent":["import React from 'react';\n\nimport { useEventListener } from '../useEventListener/useEventListener';\n\n//* The use hover options
|
|
1
|
+
{"version":3,"file":"useHover.js","sources":["../../../../src/hooks/useHover/useHover.ts"],"sourcesContent":["import React from 'react';\n\nimport { useEventListener } from '../useEventListener/useEventListener';\n\n//* The use hover options */\nexport interface UseHoverOptions {\n //* The on entry callback */\n onEntry?: () => void;\n //* The on leave callback */\n onLeave?: () => void;\n}\n\n//* The use hover target type */\nexport type UseHoverTarget = React.RefObject<Element | null> | Element;\n//* The use hover return type */\nexport type UseHoverReturn<Target extends UseHoverTarget = any> = [\n React.RefObject<Target>,\n boolean\n];\n\nexport type UseHover = {\n <Target extends UseHoverTarget>(target: Target, callback?: () => void): boolean;\n\n <Target extends UseHoverTarget>(target: Target, options?: UseHoverOptions): boolean;\n\n <Target extends UseHoverTarget>(callback?: () => void, target?: never): UseHoverReturn<Target>;\n\n <Target extends UseHoverTarget>(\n options?: UseHoverOptions,\n target?: never\n ): UseHoverReturn<Target>;\n};\n\n/**\n * @name useHover\n * @description - Hook that defines the logic when hovering an element\n *\n * @example\n * const hovering = useHover(ref, () => console.log('callback'));\n *\n * @example\n * const [ref, hovering] = useHover(() => console.log('callback'));\n *\n * @example\n * const [ref, hovering] = useHover({\n * onEntry: () => console.log('onEntry'),\n * onLeave: () => console.log('onLeave'),\n * });\n *\n * @example\n * const hovering = useHover(ref, {\n * onEntry: () => console.log('onEntry'),\n * onLeave: () => console.log('onLeave'),\n * });\n */\nexport const useHover = ((...params: any[]) => {\n const target = (\n params[0] instanceof Function || !('current' in params[0]) ? undefined : params[0]\n ) as UseHoverTarget | undefined;\n\n const options = (\n target\n ? typeof params[1] === 'object'\n ? params[1]\n : { onEntry: params[1] }\n : typeof params[0] === 'object'\n ? params[0]\n : { onEntry: params[0] }\n ) as UseHoverOptions | undefined;\n\n const [hovering, setHovering] = React.useState(false);\n const internalRef = React.useRef<Element>(null);\n\n const onMouseEnter = () => {\n options?.onEntry?.();\n setHovering(true);\n };\n const onMouseLeave = () => {\n options?.onLeave?.();\n setHovering(false);\n };\n\n useEventListener(target ?? internalRef, 'mouseenter', onMouseEnter);\n useEventListener(target ?? internalRef, 'mouseleave', onMouseLeave);\n\n if (target) return hovering;\n return [internalRef, hovering] as const;\n}) as UseHover;\n"],"names":["useHover","target","arguments","length","undefined","Function","options","_typeof","onEntry","_React$useState","React","useState","_React$useState2","_slicedToArray","hovering","setHovering","internalRef","useRef","useEventListener","_options$onEntry","call","_options$onLeave","onLeave"],"mappings":";2KAuDaA,EAAY,WACvB,IAAMC,GACJC,UAAAC,QAAA,OAAAC,EAAAF,UAAqBG,cAAAA,YAAc,YAASH,UAAAC,eAAAC,EAAAF,UAAA,MAA0BA,UAAAC,QAAA,OAATC,EAASF,UACzC,GAEzBI,EACJL,EACyB,WAArBM,EAAAL,UAAAC,QAAAC,OAAAA,EAAAF,UAAA,IAA6BA,UAAAC,QAAAC,OAAAA,EAAAF,UAE3B,GAAA,CAAEM,QAAON,UAAAC,QAAAC,OAAAA,EAAAF,UAAA,IACU,WAArBK,EAAAL,UAAAC,QAAA,OAAAC,EAAAF,cAA6BA,UAAAC,eAAAC,EAAAF,UAE3B,GAAA,CAAEM,QAAON,UAAAC,QAAAC,OAAAA,EAAAF,UAAA,IAGjBO,EAAgCC,EAAMC,UAAS,GAAMC,EAAAC,EAAAJ,EAAA,GAA9CK,EAAQF,EAAA,GAAEG,EAAWH,EAAA,GACtBI,EAAcN,EAAMO,OAAgB,MAc1C,OAHAC,EAAiBjB,QAAAA,EAAUe,EAAa,cATnB,WAAM,IAAAG,EACzBb,SAAgBa,QAATA,EAAPb,EAASE,mBAAOW,GAAhBA,EAAAC,KAAAd,GACAS,GAAY,MAQdG,EAAiBjB,QAAAA,EAAUe,EAAa,cANnB,WAAM,IAAAK,EACzBf,SAAgBe,QAATA,EAAPf,EAASgB,mBAAOD,GAAhBA,EAAAD,KAAAd,GACAS,GAAY,MAMVd,EAAea,EACZ,CAACE,EAAaF,EACvB"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as e}from"../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.11 */
|
|
2
|
+
import{_ as e}from"../../_rollupPluginBabelHelpers-TF5Io098.js";import t from"react";import"../../utils/helpers/isClient.js";import{throttle as n}from"../../utils/helpers/throttle.js";var i=["mousemove","mousedown","keydown","touchstart","wheel","resize"],o=function(){var o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:6e4,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},u=r.initialState,s=void 0!==u&&u,a=r.events,d=void 0===a?i:a,c=t.useState(s),l=e(c,2),m=l[0],v=l[1],f=t.useState(Date.now()),w=e(f,2),h=w[0],p=w[1];return t.useEffect((function(){var e,t=function(){return v(!0)},i=n((function(){v(!1),p(Date.now()),window.clearTimeout(e),e=setTimeout(t,o)}),500),r=function(){document.hidden||i()};return e=setTimeout(t,o),d.forEach((function(e){return window.addEventListener(e,i)})),document.addEventListener("visibilitychange",r),function(){d.forEach((function(e){return window.addEventListener(e,i)})),document.removeEventListener("visibilitychange",r),window.clearTimeout(e)}}),[o,d]),{idle:m,lastActive:h}};export{o as useIdle};
|
|
3
3
|
//# sourceMappingURL=useIdle.js.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.11 */
|
|
2
|
+
import{a as n,_ as e,b as t}from"../../_rollupPluginBabelHelpers-TF5Io098.js";import r from"react";var o=function(){var o="object"!==n(arguments.length<=0?void 0:arguments[0])||"current"in(arguments.length<=0?void 0:arguments[0])?arguments.length<=0?void 0:arguments[0]:void 0,i=o?arguments.length<=1?void 0:arguments[1]:arguments.length<=0?void 0:arguments[0],l=r.useState(),u=e(l,2),c=u[0],s=u[1],a=r.useRef(null),f=r.useRef();return f.current=null==i?void 0:i.onChange,r.useEffect((function(){var n,r=o?function(n){return"function"==typeof n?n():n instanceof Element?n:n.current}(o):a.current,l=new IntersectionObserver((function(n){var t,r=e(n,1)[0];s(r),null===(t=f.current)||void 0===t||t.call(f,r)}),t(t({},i),{},{root:(n=null==i?void 0:i.root,n?n instanceof Element||n instanceof Document?n:n.current:document)}));return l.observe(r),function(){l.disconnect()}}),[o,null==i?void 0:i.rootMargin,null==i?void 0:i.threshold]),o?{entry:c,inView:!(null==c||!c.isIntersecting)}:{ref:a,entry:c,inView:!(null==c||!c.isIntersecting)}};export{o as useIntersectionObserver};
|
|
3
|
+
//# sourceMappingURL=useIntersectionObserver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useIntersectionObserver.js","sources":["../../../../src/hooks/useIntersectionObserver/useIntersectionObserver.ts"],"sourcesContent":["import React from 'react';\n\nexport type UseIntersectionObserverTarget =\n | React.RefObject<Element | null>\n | (() => Element)\n | Element;\n\nexport interface UseIntersectionObserverOptions extends Omit<IntersectionObserverInit, 'root'> {\n immediate?: boolean;\n onChange?: (entry: IntersectionObserverEntry) => void;\n root?: IntersectionObserverInit['root'] | React.RefObject<Element | null>;\n}\n\nconst getTargetElement = (target: UseIntersectionObserverTarget) => {\n if (typeof target === 'function') {\n return target();\n }\n\n if (target instanceof Element) {\n return target;\n }\n\n return target.current;\n};\n\nconst getRootElement = (root: UseIntersectionObserverOptions['root']) => {\n if (!root) return document;\n\n if (root instanceof Element) {\n return root;\n }\n\n if (root instanceof Document) {\n return root;\n }\n\n return root.current;\n};\n\nexport interface UseIntersectionObserverReturn {\n inView: boolean;\n entry?: IntersectionObserverEntry;\n}\n\nexport type UseIntersectionObserver = {\n <Target extends UseIntersectionObserverTarget>(\n target: Target,\n options?: UseIntersectionObserverOptions\n ): UseIntersectionObserverReturn;\n\n <Target extends UseIntersectionObserverTarget>(\n options?: UseIntersectionObserverOptions,\n target?: never\n ): UseIntersectionObserverReturn & { ref: React.RefObject<Target> };\n};\n\nexport const useIntersectionObserver = ((...params: any[]) => {\n const target = (\n typeof params[0] === 'object' && !('current' in params[0]) ? undefined : params[0]\n ) as UseIntersectionObserverTarget | undefined;\n const options = (target ? params[1] : params[0]) as UseIntersectionObserverOptions | undefined;\n\n const [entry, setEntry] = React.useState<IntersectionObserverEntry>();\n const internalRef = React.useRef<Element>(null);\n\n const onChangeRef = React.useRef<UseIntersectionObserverOptions['onChange']>();\n onChangeRef.current = options?.onChange;\n\n React.useEffect(() => {\n const element = target ? getTargetElement(target) : internalRef.current;\n const observer = new IntersectionObserver(\n ([entry]) => {\n setEntry(entry);\n onChangeRef.current?.(entry);\n },\n {\n ...options,\n root: getRootElement(options?.root)\n }\n );\n\n observer.observe(element!);\n\n return () => {\n observer.disconnect();\n };\n }, [target, options?.rootMargin, options?.threshold]);\n\n if (!target) return { ref: internalRef, entry, inView: !!entry?.isIntersecting };\n return { entry, inView: !!entry?.isIntersecting };\n}) as UseIntersectionObserver;\n"],"names":["useIntersectionObserver","target","_typeof","arguments","length","undefined","options","_React$useState","React","useState","_React$useState2","_slicedToArray","entry","setEntry","internalRef","useRef","onChangeRef","current","onChange","useEffect","root","element","Element","getTargetElement","observer","IntersectionObserver","_ref","_onChangeRef$current","call","_objectSpread","Document","document","observe","disconnect","rootMargin","threshold","inView","isIntersecting","ref"],"mappings":";mGAaA,IA2CaA,EAA2B,WACtC,IAAMC,EACiB,WAArBC,EAAAC,UAAAC,QAAA,OAAAC,EAAAF,UAAqB,KAAc,YAASA,UAAAC,eAAAC,EAAAF,UAAA,IAA0BA,UAAAC,QAAA,OAAAC,EAAAF,UAC1B,QADiBE,EAEzDC,EAAWL,EAAME,UAAAC,QAAAC,OAAAA,EAAAF,UAAA,GAAAA,UAAAC,eAAAC,EAAAF,UAAuE,GAE9FI,EAA0BC,EAAMC,WAAqCC,EAAAC,EAAAJ,EAAA,GAA9DK,EAAKF,EAAA,GAAEG,EAAQH,EAAA,GAChBI,EAAcN,EAAMO,OAAgB,MAEpCC,EAAcR,EAAMO,SAuB1B,OAtBAC,EAAYC,QAAUX,aAAO,EAAPA,EAASY,SAE/BV,EAAMW,WAAU,WACd,IA5CoBC,EA4CdC,EAAUpB,EAxDK,SAACA,GACxB,MAAsB,mBAAXA,EACFA,IAGLA,aAAkBqB,QACbrB,EAGFA,EAAOgB,OAChB,CA8C6BM,CAAiBtB,GAAUa,EAAYG,QAC1DO,EAAW,IAAIC,sBACnB,SAAAC,GAAa,IAAAC,EAAXf,EAAWD,EAAAe,EAAA,GAAN,GACLb,EAASD,GACUe,QAAnBA,EAAAX,EAAYC,eAAZU,IAAmBA,GAAnBA,EAAAC,KAAAZ,EAAsBJ,EACvB,GAAAiB,EAAAA,KAEIvB,GAAO,CAAA,EAAA,CACVc,MApDgBA,EAoDKd,aAAO,EAAPA,EAASc,KAnD/BA,EAEDA,aAAgBE,SAIhBF,aAAgBU,SAHXV,EAOFA,EAAKH,QAVMc,aAyDhB,OAFAP,EAASQ,QAAQX,GAEV,WACLG,EAASS,gBAEV,CAAChC,EAAQK,eAAAA,EAAS4B,WAAY5B,aAAO,EAAPA,EAAS6B,YAErClC,EACE,CAAEW,MAAAA,EAAOwB,SAAUxB,UAAAA,EAAOyB,iBADb,CAAEC,IAAKxB,EAAaF,MAAAA,EAAOwB,SAAUxB,UAAAA,EAAOyB,gBAElE"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.11 */
|
|
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.11 */
|
|
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.11 */
|
|
2
|
+
import{_ as e}from"../../_rollupPluginBabelHelpers-TF5Io098.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.11 */
|
|
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.11 */
|
|
2
|
+
import{_ as e,c as o}from"../../_rollupPluginBabelHelpers-TF5Io098.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.11 */
|
|
2
|
+
import{b as o}from"../../_rollupPluginBabelHelpers-TF5Io098.js";import{useStorage as r}from"../useStorage/useStorage.js";import"react";import"../../utils/helpers/isClient.js";import"../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.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.11 */
|
|
2
|
+
import{c as o}from"../../_rollupPluginBabelHelpers-TF5Io098.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.11 */
|
|
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.11 */
|
|
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.11 */
|
|
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.11 */
|
|
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.11 */
|
|
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.11 */
|
|
2
|
+
import{_ as e}from"../../_rollupPluginBabelHelpers-TF5Io098.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.11 */
|
|
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.11 */
|
|
2
|
+
import{_ as r,c as t,d as e}from"../../_rollupPluginBabelHelpers-TF5Io098.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.11 */
|
|
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.11 */
|
|
2
|
+
import{_ as r}from"../../_rollupPluginBabelHelpers-TF5Io098.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.11 */
|
|
2
|
+
import{_ as e}from"../../_rollupPluginBabelHelpers-TF5Io098.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.11 */
|
|
2
|
+
import{b as o}from"../../_rollupPluginBabelHelpers-TF5Io098.js";import{useStorage as e}from"../useStorage/useStorage.js";import"react";import"../../utils/helpers/isClient.js";import"../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js";var r=function(r,t,s){return e(r,o({initialValue:t,storage:window.sessionStorage},s))};export{r as useSessionStorage};
|
|
3
3
|
//# sourceMappingURL=useSessionStorage.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import r from"react";import{useRerender as e}from"../useRerender/useRerender.js";import"../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.11 */
|
|
2
|
+
import r from"react";import{useRerender as e}from"../useRerender/useRerender.js";import"../../_rollupPluginBabelHelpers-TF5Io098.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.11 */
|
|
2
|
+
import{a as t,_ as r}from"../../_rollupPluginBabelHelpers-TF5Io098.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.11 */
|
|
2
|
+
import{a as e}from"../../_rollupPluginBabelHelpers-TF5Io098.js";import n from"react";import{isClient as t}from"../../utils/helpers/isClient.js";import{useIsomorphicLayoutEffect as r}from"../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js";var i=function(e){return window.dispatchEvent(new StorageEvent("storage",e))},o=function(e,n,t){var r=e.getItem(n);e.setItem(n,t),i({key:n,oldValue:r,newValue:t,storageArea:e})},u=function(e,n){var t=e.getItem(n);e.removeItem(n),i({key:n,oldValue:t,newValue:null,storageArea:e})},a=function(e,n){var t=e.getItem(n);if(t)return t},l=function(e){return window.addEventListener("storage",e),function(){return window.removeEventListener("storage",e)}},s=function(){},f=function(i,f){var c,d="object"===e(f)?f:void 0,v=d?null==d?void 0:d.initialValue:f,m=null!==(c=null==d?void 0:d.storage)&&void 0!==c?c:window.localStorage,g=function(e){return null!=d&&d.serializer?d.serializer(e):JSON.stringify(e)},p=n.useSyncExternalStore(l,(function(){return a(m,i)}),s),w=function(e){if(null===e)return u(m,i);o(m,i,g(e))};r((function(){(void 0===a(m,i)||v)&&o(m,i,g(v instanceof Function?v():v))}),[i]);var y=function(){return u(m,i)};return t?[p?function(e){if(null!=d&&d.deserializer)return d.deserializer(e);if("undefined"!==e)try{return JSON.parse(e)}catch(n){return e}}(p):void 0,w,y]:[v instanceof Function?v():v,w,y]};export{i as dispatchStorageEvent,f as useStorage};
|
|
3
3
|
//# sourceMappingURL=useStorage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStorage.js","sources":["../../../../src/hooks/useStorage/useStorage.ts"],"sourcesContent":["import React from 'react';\n\nimport { useIsomorphicLayoutEffect } from '../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect';\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 =
|
|
1
|
+
{"version":3,"file":"useStorage.js","sources":["../../../../src/hooks/useStorage/useStorage.ts"],"sourcesContent":["import React from 'react';\n\nimport { isClient } from '@/utils/helpers';\n\nimport { useIsomorphicLayoutEffect } from '../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect';\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 = (storage: Storage, key: string) => {\n const value = storage.getItem(key);\n if (!value) return undefined;\n return value;\n};\n\nconst storageSubscribe = (callback: () => void) => {\n window.addEventListener('storage', callback);\n return () => window.removeEventListener('storage', callback);\n};\n\nconst getServerSnapshot = () => undefined;\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(storage, key);\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 useIsomorphicLayoutEffect(() => {\n const value = getStorageItem(storage, key);\n if (value !== undefined && !initialValue) return;\n\n setStorageItem(\n storage,\n key,\n serializer(initialValue instanceof Function ? initialValue() : initialValue)\n );\n }, [key]);\n\n const remove = () => removeStorageItem(storage, key);\n\n if (!isClient)\n return [initialValue instanceof Function ? initialValue() : initialValue, set, remove] as const;\n return [store ? deserializer(store) : undefined, set, remove] as const;\n};\n"],"names":["dispatchStorageEvent","params","window","dispatchEvent","StorageEvent","setStorageItem","storage","key","value","oldValue","getItem","setItem","newValue","storageArea","removeStorageItem","removeItem","getStorageItem","storageSubscribe","callback","addEventListener","removeEventListener","getServerSnapshot","useStorage","_options$storage","options","_typeof","undefined","initialValue","localStorage","serializer","JSON","stringify","store","React","useSyncExternalStore","set","useIsomorphicLayoutEffect","Function","remove","isClient","deserializer","parse","error"],"mappings":";0PAoBaA,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,SAACV,EAAkBC,GACxC,IAAMC,EAAQF,EAAQI,QAAQH,GAC9B,GAAKC,EACL,OAAOA,CACT,EAEMS,EAAmB,SAACC,GAExB,OADAhB,OAAOiB,iBAAiB,UAAWD,GAC5B,WAAA,OAAMhB,OAAOkB,oBAAoB,UAAWF,EAAS,CAC9D,EAEMG,EAAoB,WAAe,EAE5BC,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,IAkBlBwB,EAAQC,EAAMC,qBAAqBjB,GADrB,WAAH,OAASD,EAAeV,EAASC,EAAI,GACkBc,GAElEc,EAAM,SAAC3B,GACX,GAAc,OAAVA,EAAgB,OAAOM,EAAkBR,EAASC,GACtDF,EAAeC,EAASC,EAAKsB,EAAWrB,KAG1C4B,GAA0B,iBAEVV,IADAV,EAAeV,EAASC,IACVoB,IAE5BtB,EACEC,EACAC,EACAsB,EAAWF,aAAwBU,SAAWV,IAAiBA,GAEnE,GAAG,CAACpB,IAEJ,IAAM+B,EAAS,WAAH,OAASxB,EAAkBR,EAASC,EAAI,EAEpD,OAAKgC,EAEE,CAACP,EArCa,SAACxB,GACpB,GAAIgB,SAAAA,EAASgB,aAAc,OAAOhB,EAAQgB,aAAahC,GAEvD,GAAc,cAAVA,EAIJ,IACE,OAAOsB,KAAKW,MAAMjC,EACnB,CAAC,MAAOkC,GACP,OAAOlC,CACT,EA0BcgC,CAAaR,QAASN,EAAWS,EAAKG,GAD7C,CAACX,aAAwBU,SAAWV,IAAiBA,EAAcQ,EAAKG,EAEnF"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/* @license @siberiacancode/reactuse v0.0.
|
|
2
|
-
import{_ as e}from"../../_rollupPluginBabelHelpers-
|
|
1
|
+
/* @license @siberiacancode/reactuse v0.0.11 */
|
|
2
|
+
import{_ as e}from"../../_rollupPluginBabelHelpers-TF5Io098.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.11 */
|
|
2
|
+
import{_ as r}from"../../_rollupPluginBabelHelpers-TF5Io098.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.11 */
|
|
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.11 */
|
|
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.11 */
|
|
2
|
+
import{_ as i}from"../../_rollupPluginBabelHelpers-TF5Io098.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.11 */
|
|
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-TF5Io098.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.11 */
|
|
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.11 */
|
|
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.11 */
|
|
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.11 */
|
|
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.11 */
|
|
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
|