@siberiacancode/reactuse 0.2.3 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/hooks/useMouse/useMouse.cjs +1 -1
- package/dist/cjs/hooks/useMouse/useMouse.cjs.map +1 -1
- package/dist/cjs/hooks/useParallax/useParallax.cjs +1 -1
- package/dist/cjs/hooks/useParallax/useParallax.cjs.map +1 -1
- package/dist/cjs/hooks/useStateHistory/useStateHistory.cjs +1 -1
- package/dist/cjs/hooks/useStateHistory/useStateHistory.cjs.map +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/esm/hooks/useMouse/useMouse.mjs +42 -27
- package/dist/esm/hooks/useMouse/useMouse.mjs.map +1 -1
- package/dist/esm/hooks/useParallax/useParallax.mjs +16 -17
- package/dist/esm/hooks/useParallax/useParallax.mjs.map +1 -1
- package/dist/esm/hooks/useStateHistory/useStateHistory.mjs +78 -24
- package/dist/esm/hooks/useStateHistory/useStateHistory.mjs.map +1 -1
- package/dist/esm/index.mjs +103 -102
- package/dist/types/hooks/useMouse/useMouse.d.ts +8 -5
- package/dist/types/hooks/useStateHistory/useStateHistory.d.ts +43 -3
- package/package.json +4 -4
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Y=require("react"),f=require("../useRefState/useRefState.cjs"),E=require("../../utils/helpers/isTarget.cjs"),y=require("../../utils/helpers/getElement.cjs"),S=(...l)=>{const n=E.isTarget(l[0])?l[0]:void 0,[c,o]=Y.useState({x:0,y:0,elementX:0,elementY:0,elementPositionX:0,elementPositionY:0,clientX:0,clientY:0}),s=f.useRefState();return Y.useEffect(()=>{const r=e=>{const u=n?y.getElement(n):s.current,t={x:e.pageX,y:e.pageY,clientX:e.clientX,clientY:e.clientY};if(u){const{left:i,top:a}=u.getBoundingClientRect(),d=i+window.scrollX,X=a+window.scrollY,g=e.pageX-d,P=e.pageY-X;t.elementX=g,t.elementY=P,t.elementPositionX=d,t.elementPositionY=X,o(w=>({...w,...t}))}else t.elementX=e.pageX,t.elementY=e.pageY,t.elementPositionX=0,t.elementPositionY=0,o(i=>({...i,...t}))},m=()=>{o(e=>({...e,x:e.x+window.scrollX-e.elementPositionX,y:e.y+window.scrollY-e.elementPositionY,elementPositionX:window.scrollX,elementPositionY:window.scrollY}))};return document.addEventListener("scroll",m,{passive:!0}),document.addEventListener("mousemove",r),()=>{document.removeEventListener("scroll",m),document.removeEventListener("mousemove",r)}},[s.state,n]),n?c:{ref:s,...c}};exports.useMouse=S;
|
|
2
2
|
//# sourceMappingURL=useMouse.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMouse.cjs","sources":["../../../../src/hooks/useMouse/useMouse.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nimport type { HookTarget } from '@/utils/helpers';\n\nimport { getElement, isTarget } from '@/utils/helpers';\n\nimport type { StateRef } from '../useRefState/useRefState';\n\nimport { useRefState } from '../useRefState/useRefState';\n\n/** The use mouse return type */\nexport interface UseMouseReturn {\n /** The current
|
|
1
|
+
{"version":3,"file":"useMouse.cjs","sources":["../../../../src/hooks/useMouse/useMouse.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nimport type { HookTarget } from '@/utils/helpers';\n\nimport { getElement, isTarget } from '@/utils/helpers';\n\nimport type { StateRef } from '../useRefState/useRefState';\n\nimport { useRefState } from '../useRefState/useRefState';\n\n/** The use mouse return type */\nexport interface UseMouseReturn {\n /** The current mouse client x position */\n clientX: number;\n /** The current mouse client y position */\n clientY: number;\n /** The current element position x */\n elementPositionX: number;\n /** The current element position y */\n elementPositionY: number;\n /** The current element x position */\n elementX: number;\n /** The current element y position */\n elementY: number;\n /** The current mouse x position */\n x: number;\n /** The current mouse y position */\n y: number;\n}\n\nexport interface UseMouse {\n (target: HookTarget): UseMouseReturn;\n\n <Target extends Element>(\n target?: never\n ): UseMouseReturn & {\n ref: StateRef<Target>;\n };\n\n (target?: Window): UseMouseReturn;\n}\n\n/**\n * @name useMouse\n * @description - Hook that manages a mouse position\n * @category Sensors\n *\n * @overload\n * @param {HookTarget} [target=window] The target element to manage the mouse position for\n * @returns {UseMouseReturn} An object with the current mouse position\n *\n * @example\n * const { x, y, clientX, clientY, elementX, elementY, elementPositionX, elementPositionY } = useMouse(ref);\n *\n * @overload\n * @template Target The target element\n * @returns {UseMouseReturn & { ref: StateRef<Target> }} An object with the current mouse position and a ref\n *\n * @example\n * const { ref, x, y, clientX, clientY, elementX, elementY, elementPositionX, elementPositionY } = useMouse();\n */\nexport const useMouse = ((...params: any[]) => {\n const target = isTarget(params[0]) ? params[0] : undefined;\n\n const [value, setValue] = useState<UseMouseReturn>({\n x: 0,\n y: 0,\n elementX: 0,\n elementY: 0,\n elementPositionX: 0,\n elementPositionY: 0,\n clientX: 0,\n clientY: 0\n });\n\n const internalRef = useRefState<Element>();\n\n useEffect(() => {\n const onMouseMove = (event: MouseEvent) => {\n const element = (target ? getElement(target) : internalRef.current) as Element | undefined;\n\n const updatedValue = {\n x: event.pageX,\n y: event.pageY,\n clientX: event.clientX,\n clientY: event.clientY\n } as typeof value;\n\n if (element) {\n const { left, top } = element.getBoundingClientRect();\n const elementPositionX = left + window.scrollX;\n const elementPositionY = top + window.scrollY;\n const elementX = event.pageX - elementPositionX;\n const elementY = event.pageY - elementPositionY;\n\n updatedValue.elementX = elementX;\n updatedValue.elementY = elementY;\n updatedValue.elementPositionX = elementPositionX;\n updatedValue.elementPositionY = elementPositionY;\n\n setValue((prevValue) => ({\n ...prevValue,\n ...updatedValue\n }));\n } else {\n updatedValue.elementX = event.pageX;\n updatedValue.elementY = event.pageY;\n updatedValue.elementPositionX = 0;\n updatedValue.elementPositionY = 0;\n\n setValue((prevValue) => ({\n ...prevValue,\n ...updatedValue\n }));\n }\n };\n\n const onScroll = () => {\n setValue((prevValue) => ({\n ...prevValue,\n x: prevValue.x + window.scrollX - prevValue.elementPositionX,\n y: prevValue.y + window.scrollY - prevValue.elementPositionY,\n elementPositionX: window.scrollX,\n elementPositionY: window.scrollY\n }));\n };\n\n document.addEventListener('scroll', onScroll, { passive: true });\n document.addEventListener('mousemove', onMouseMove);\n return () => {\n document.removeEventListener('scroll', onScroll);\n document.removeEventListener('mousemove', onMouseMove);\n };\n }, [internalRef.state, target]);\n\n if (target) return value;\n return {\n ref: internalRef,\n ...value\n };\n}) as UseMouse;\n"],"names":["useMouse","params","target","isTarget","value","setValue","useState","internalRef","useRefState","useEffect","onMouseMove","event","element","getElement","updatedValue","left","top","elementPositionX","elementPositionY","elementX","elementY","prevValue","onScroll"],"mappings":"mPA6DaA,EAAY,IAAIC,IAAkB,CACvC,MAAAC,EAASC,WAASF,EAAO,CAAC,CAAC,EAAIA,EAAO,CAAC,EAAI,OAE3C,CAACG,EAAOC,CAAQ,EAAIC,WAAyB,CACjD,EAAG,EACH,EAAG,EACH,SAAU,EACV,SAAU,EACV,iBAAkB,EAClB,iBAAkB,EAClB,QAAS,EACT,QAAS,CAAA,CACV,EAEKC,EAAcC,EAAAA,YAAqB,EA4DzC,OA1DAC,EAAAA,UAAU,IAAM,CACR,MAAAC,EAAeC,GAAsB,CACzC,MAAMC,EAAWV,EAASW,EAAAA,WAAWX,CAAM,EAAIK,EAAY,QAErDO,EAAe,CACnB,EAAGH,EAAM,MACT,EAAGA,EAAM,MACT,QAASA,EAAM,QACf,QAASA,EAAM,OACjB,EAEA,GAAIC,EAAS,CACX,KAAM,CAAE,KAAAG,EAAM,IAAAC,GAAQJ,EAAQ,sBAAsB,EAC9CK,EAAmBF,EAAO,OAAO,QACjCG,EAAmBF,EAAM,OAAO,QAChCG,EAAWR,EAAM,MAAQM,EACzBG,EAAWT,EAAM,MAAQO,EAE/BJ,EAAa,SAAWK,EACxBL,EAAa,SAAWM,EACxBN,EAAa,iBAAmBG,EAChCH,EAAa,iBAAmBI,EAEhCb,EAAUgB,IAAe,CACvB,GAAGA,EACH,GAAGP,CAAA,EACH,CAAA,MAEFA,EAAa,SAAWH,EAAM,MAC9BG,EAAa,SAAWH,EAAM,MAC9BG,EAAa,iBAAmB,EAChCA,EAAa,iBAAmB,EAEhCT,EAAUgB,IAAe,CACvB,GAAGA,EACH,GAAGP,CAAA,EACH,CAEN,EAEMQ,EAAW,IAAM,CACrBjB,EAAUgB,IAAe,CACvB,GAAGA,EACH,EAAGA,EAAU,EAAI,OAAO,QAAUA,EAAU,iBAC5C,EAAGA,EAAU,EAAI,OAAO,QAAUA,EAAU,iBAC5C,iBAAkB,OAAO,QACzB,iBAAkB,OAAO,OAAA,EACzB,CACJ,EAEA,gBAAS,iBAAiB,SAAUC,EAAU,CAAE,QAAS,GAAM,EACtD,SAAA,iBAAiB,YAAaZ,CAAW,EAC3C,IAAM,CACF,SAAA,oBAAoB,SAAUY,CAAQ,EACtC,SAAA,oBAAoB,YAAaZ,CAAW,CACvD,CACC,EAAA,CAACH,EAAY,MAAOL,CAAM,CAAC,EAE1BA,EAAeE,EACZ,CACL,IAAKG,EACL,GAAGH,CACL,CACF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("react"),A=require("../useDeviceOrientation/useDeviceOrientation.cjs"),D=require("../useRefState/useRefState.cjs"),x=require("../useScreenOrientation/useScreenOrientation.cjs"),B=require("../../utils/helpers/isTarget.cjs"),C=require("../../utils/helpers/getElement.cjs"),M=(...
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("react"),A=require("../useDeviceOrientation/useDeviceOrientation.cjs"),D=require("../useRefState/useRefState.cjs"),x=require("../useScreenOrientation/useScreenOrientation.cjs"),B=require("../../utils/helpers/isTarget.cjs"),C=require("../../utils/helpers/getElement.cjs"),M=(...n)=>{const o=B.isTarget(n[0])?n[0]:void 0,p=n[1]?n[1]:n[0],i=D.useRefState(),s=x.useScreenOrientation(),e=A.useDeviceOrientation(),{deviceOrientationRollAdjust:b=a=>a,deviceOrientationTiltAdjust:f=a=>a,mouseRollAdjust:y=a=>a,mouseTiltAdjust:O=a=>a}=p??{},[l,h]=g.useState({roll:0,tilt:0,source:"mouse"});return g.useEffect(()=>{if(!o&&!i.state)return;const a=o?C.getElement(o):i.current;if(!a)return;const v=d=>{const{left:R,top:T}=a.getBoundingClientRect(),k=R+window.scrollX,w=T+window.scrollY,c=()=>e.supported&&(e.value.alpha||e.value.gamma)?"deviceOrientation":"mouse",S=()=>{if(c()==="deviceOrientation"){let t;switch(s.value.orientationType){case"landscape-primary":t=e.value.gamma/90;break;case"landscape-secondary":t=-e.value.gamma/90;break;case"portrait-primary":t=-e.value.beta/90;break;case"portrait-secondary":t=e.value.beta/90;break;default:t=-e.value.beta/90}return b(t)}else{const t=d.pageY-w,r=a.getBoundingClientRect().height,u=-(t-r/2)/r;return y(u)}},q=()=>{if(c()==="deviceOrientation"){let t;switch(s.value.orientationType){case"landscape-primary":t=e.value.beta/90;break;case"landscape-secondary":t=-e.value.beta/90;break;case"portrait-primary":t=e.value.gamma/90;break;case"portrait-secondary":t=-e.value.gamma/90;break;default:t=e.value.gamma/90}return f(t)}else{const t=d.pageX-k,r=a.getBoundingClientRect().width,u=(t-r/2)/r;return O(u)}},j=c(),E=S(),P=q();h({roll:E,source:j,tilt:P})};return document.addEventListener("mousemove",v),()=>{document.removeEventListener("mousemove",v)}},[o,i.state,s.value.angle,s.value.orientationType,e.value.gamma,e.value.beta,e.value.alpha,e.value.absolute]),o?{value:l}:{ref:i,value:l}};exports.useParallax=M;
|
|
2
2
|
//# sourceMappingURL=useParallax.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useParallax.cjs","sources":["../../../../src/hooks/useParallax/useParallax.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nimport type { HookTarget } from '@/utils/helpers';\n\nimport { getElement, isTarget } from '@/utils/helpers';\n\nimport type { StateRef } from '../useRefState/useRefState';\n\nimport { useDeviceOrientation } from '../useDeviceOrientation/useDeviceOrientation';\nimport { useRefState } from '../useRefState/useRefState';\nimport { useScreenOrientation } from '../useScreenOrientation/useScreenOrientation';\n\n/** The use parallax value type */\nexport interface UseParallaxValue {\n /** Roll value. Scaled to `-0.5 ~ 0.5` */\n roll: number;\n /** Sensor source, can be `mouse` or `deviceOrientation` */\n source: 'deviceOrientation' | 'mouse';\n /** Tilt value. Scaled to `-0.5 ~ 0.5` */\n tilt: number;\n}\n\n/** The use parallax options type */\nexport interface UseParallaxOptions {\n /** Device orientation roll adjust function */\n deviceOrientationRollAdjust?: (value: number) => number;\n /** Device orientation tilt adjust function */\n deviceOrientationTiltAdjust?: (value: number) => number;\n /** Mouse roll adjust function */\n mouseRollAdjust?: (value: number) => number;\n /** Mouse tilt adjust function */\n mouseTiltAdjust?: (value: number) => number;\n}\n\ninterface UseParallaxReturn {\n value: UseParallaxValue;\n}\n\nexport interface UseParallax {\n (target: HookTarget, options?: UseParallaxOptions): UseParallaxReturn;\n\n <Target extends Element>(\n options?: UseParallaxOptions,\n target?: never\n ): UseParallaxReturn & {\n ref: StateRef<Target>;\n };\n}\n\n/**\n * @name useParallax\n * @description - Hook to help create parallax effect\n * @category Sensors\n *\n * @overload\n * @param {HookTarget} target The target element for the parallax effect\n * @param {UseParallaxOptions} options The options for the parallax effect\n * @returns {UseParallaxReturn} An object of parallax values\n *\n * @example\n * const { value } = useParallax(ref);\n *\n * @overload\n * @template Target The target element for the parallax effect\n * @param {UseParallaxOptions} options The options for the parallax effect\n * @returns {UseParallaxReturn & { ref: StateRef<Target> }} An object of parallax values\n *\n * @example\n * const { ref, value } = useParallax();\n */\nexport const useParallax = ((...params: any[]) => {\n const target = (isTarget(params[0]) ? params[0] : undefined) as HookTarget | undefined;\n const options = (params[1] ? params[1] : params[0]) as UseParallaxOptions | undefined;\n\n const internalRef = useRefState<Element>();\n\n const screenOrientation = useScreenOrientation();\n const deviceOrientation = useDeviceOrientation();\n\n const {\n deviceOrientationRollAdjust = (value) => value,\n deviceOrientationTiltAdjust = (value) => value,\n mouseRollAdjust = (value) => value,\n mouseTiltAdjust = (value) => value\n } = (options ?? {}) as UseParallaxOptions;\n\n const [value, setValue] = useState({\n roll: 0,\n tilt: 0,\n source: 'mouse'\n });\n\n useEffect(() => {\n if (!target && !internalRef.state) return;\n\n const element = (target ? getElement(target) : internalRef.current) as Element;\n if (!element) return;\n\n
|
|
1
|
+
{"version":3,"file":"useParallax.cjs","sources":["../../../../src/hooks/useParallax/useParallax.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nimport type { HookTarget } from '@/utils/helpers';\n\nimport { getElement, isTarget } from '@/utils/helpers';\n\nimport type { StateRef } from '../useRefState/useRefState';\n\nimport { useDeviceOrientation } from '../useDeviceOrientation/useDeviceOrientation';\nimport { useRefState } from '../useRefState/useRefState';\nimport { useScreenOrientation } from '../useScreenOrientation/useScreenOrientation';\n\n/** The use parallax value type */\nexport interface UseParallaxValue {\n /** Roll value. Scaled to `-0.5 ~ 0.5` */\n roll: number;\n /** Sensor source, can be `mouse` or `deviceOrientation` */\n source: 'deviceOrientation' | 'mouse';\n /** Tilt value. Scaled to `-0.5 ~ 0.5` */\n tilt: number;\n}\n\n/** The use parallax options type */\nexport interface UseParallaxOptions {\n /** Device orientation roll adjust function */\n deviceOrientationRollAdjust?: (value: number) => number;\n /** Device orientation tilt adjust function */\n deviceOrientationTiltAdjust?: (value: number) => number;\n /** Mouse roll adjust function */\n mouseRollAdjust?: (value: number) => number;\n /** Mouse tilt adjust function */\n mouseTiltAdjust?: (value: number) => number;\n}\n\ninterface UseParallaxReturn {\n value: UseParallaxValue;\n}\n\nexport interface UseParallax {\n (target: HookTarget, options?: UseParallaxOptions): UseParallaxReturn;\n\n <Target extends Element>(\n options?: UseParallaxOptions,\n target?: never\n ): UseParallaxReturn & {\n ref: StateRef<Target>;\n };\n}\n\n/**\n * @name useParallax\n * @description - Hook to help create parallax effect\n * @category Sensors\n *\n * @overload\n * @param {HookTarget} target The target element for the parallax effect\n * @param {UseParallaxOptions} options The options for the parallax effect\n * @returns {UseParallaxReturn} An object of parallax values\n *\n * @example\n * const { value } = useParallax(ref);\n *\n * @overload\n * @template Target The target element for the parallax effect\n * @param {UseParallaxOptions} options The options for the parallax effect\n * @returns {UseParallaxReturn & { ref: StateRef<Target> }} An object of parallax values\n *\n * @example\n * const { ref, value } = useParallax();\n */\nexport const useParallax = ((...params: any[]) => {\n const target = (isTarget(params[0]) ? params[0] : undefined) as HookTarget | undefined;\n const options = (params[1] ? params[1] : params[0]) as UseParallaxOptions | undefined;\n\n const internalRef = useRefState<Element>();\n\n const screenOrientation = useScreenOrientation();\n const deviceOrientation = useDeviceOrientation();\n\n const {\n deviceOrientationRollAdjust = (value) => value,\n deviceOrientationTiltAdjust = (value) => value,\n mouseRollAdjust = (value) => value,\n mouseTiltAdjust = (value) => value\n } = (options ?? {}) as UseParallaxOptions;\n\n const [value, setValue] = useState({\n roll: 0,\n tilt: 0,\n source: 'mouse'\n });\n\n useEffect(() => {\n if (!target && !internalRef.state) return;\n\n const element = (target ? getElement(target) : internalRef.current) as Element;\n if (!element) return;\n\n const onMouseMove = (event: MouseEvent) => {\n const { left, top } = element.getBoundingClientRect();\n const elementPositionX = left + window.scrollX;\n const elementPositionY = top + window.scrollY;\n\n const getSource = () => {\n const isDeviceOrientation =\n deviceOrientation.supported &&\n (deviceOrientation.value.alpha || deviceOrientation.value.gamma);\n\n if (isDeviceOrientation) return 'deviceOrientation';\n return 'mouse';\n };\n\n const getRoll = () => {\n const source = getSource();\n if (source === 'deviceOrientation') {\n let value: number;\n switch (screenOrientation.value.orientationType) {\n case 'landscape-primary':\n value = deviceOrientation.value.gamma! / 90;\n break;\n case 'landscape-secondary':\n value = -deviceOrientation.value.gamma! / 90;\n break;\n case 'portrait-primary':\n value = -deviceOrientation.value.beta! / 90;\n break;\n case 'portrait-secondary':\n value = deviceOrientation.value.beta! / 90;\n break;\n default:\n value = -deviceOrientation.value.beta! / 90;\n }\n return deviceOrientationRollAdjust(value);\n } else {\n const y = event.pageY - elementPositionY;\n const height = element.getBoundingClientRect().height;\n const value = -(y - height / 2) / height;\n return mouseRollAdjust(value);\n }\n };\n\n const getTilt = () => {\n const source = getSource();\n if (source === 'deviceOrientation') {\n let value: number;\n switch (screenOrientation.value.orientationType) {\n case 'landscape-primary':\n value = deviceOrientation.value.beta! / 90;\n break;\n case 'landscape-secondary':\n value = -deviceOrientation.value.beta! / 90;\n break;\n case 'portrait-primary':\n value = deviceOrientation.value.gamma! / 90;\n break;\n case 'portrait-secondary':\n value = -deviceOrientation.value.gamma! / 90;\n break;\n default:\n value = deviceOrientation.value.gamma! / 90;\n }\n return deviceOrientationTiltAdjust(value);\n } else {\n const x = event.pageX - elementPositionX;\n const width = element.getBoundingClientRect().width;\n const value = (x - width / 2) / width;\n return mouseTiltAdjust(value);\n }\n };\n\n const source = getSource();\n const roll = getRoll();\n const tilt = getTilt();\n\n setValue({\n roll,\n source,\n tilt\n });\n };\n\n document.addEventListener('mousemove', onMouseMove);\n return () => {\n document.removeEventListener('mousemove', onMouseMove);\n };\n }, [\n target,\n internalRef.state,\n screenOrientation.value.angle,\n screenOrientation.value.orientationType,\n deviceOrientation.value.gamma,\n deviceOrientation.value.beta,\n deviceOrientation.value.alpha,\n deviceOrientation.value.absolute\n ]);\n\n if (target) return { value };\n\n return {\n ref: internalRef,\n value\n };\n}) as UseParallax;\n"],"names":["useParallax","params","target","isTarget","options","internalRef","useRefState","screenOrientation","useScreenOrientation","deviceOrientation","useDeviceOrientation","deviceOrientationRollAdjust","value","deviceOrientationTiltAdjust","mouseRollAdjust","mouseTiltAdjust","setValue","useState","useEffect","element","getElement","onMouseMove","event","left","top","elementPositionX","elementPositionY","getSource","getRoll","y","height","getTilt","x","width","source","roll","tilt"],"mappings":"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"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("react"),u=(r,t)=>{switch(t.type){case"SET":{const{value:n,capacity:e}=t.payload,o=[...r.history.slice(0,r.currentIndex+1),n];o.length>e&&o.shift();const c=[r.history,...r.undoStack];return c.length>e&&c.pop(),{history:o,currentIndex:o.length-1,undoStack:c,redoStack:[]}}case"UNDO":return r.undoStack.length===0?r:{history:r.undoStack[0],currentIndex:r.undoStack[0].length-1,undoStack:r.undoStack.slice(1),redoStack:[r.history,...r.redoStack]};case"REDO":return r.redoStack.length===0?r:{history:r.redoStack[0],currentIndex:r.redoStack[0].length-1,undoStack:[r.history,...r.undoStack],redoStack:r.redoStack.slice(1)};case"BACK":{const{steps:n}=t.payload;return{...r,currentIndex:Math.max(0,r.currentIndex-n)}}case"FORWARD":{const{steps:n}=t.payload;return{...r,currentIndex:Math.min(r.currentIndex+n,r.history.length-1)}}case"RESET":{const{initialValue:n,capacity:e}=t.payload;if(r.history.length===1)return r;const o=[r.history,...r.undoStack];return o.length>e&&o.pop(),{history:[n],currentIndex:0,undoStack:o,redoStack:[]}}default:throw new Error("Unsupported action type")}},p=(r,t=10)=>{const[n,e]=k.useReducer(u,{history:[r],currentIndex:0,undoStack:[],redoStack:[]}),o=n.history[n.currentIndex],c=n.undoStack.length>0,a=n.redoStack.length>0,s=d=>e({type:"SET",payload:{value:d,capacity:t}}),y=()=>e({type:"UNDO"}),i=()=>e({type:"REDO"}),S=(d=1)=>e({type:"BACK",payload:{steps:d}}),h=(d=1)=>e({type:"FORWARD",payload:{steps:d}}),l=()=>e({type:"RESET",payload:{initialValue:r,capacity:t}});return{history:n.history,value:o,set:s,index:n.currentIndex,back:S,forward:h,reset:l,undo:y,redo:i,canUndo:c,canRedo:a}};exports.stateHistoryReducer=u;exports.useStateHistory=p;
|
|
2
2
|
//# sourceMappingURL=useStateHistory.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStateHistory.cjs","sources":["../../../../src/hooks/useStateHistory/useStateHistory.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"useStateHistory.cjs","sources":["../../../../src/hooks/useStateHistory/useStateHistory.ts"],"sourcesContent":["import { useReducer } from 'react';\n\n/** The use state history hook return type */\ninterface UseStateHistoryReturn<Value> {\n /** True if a redo operation can be performed */\n canRedo: boolean;\n /** True if an undo operation can be performed */\n canUndo: boolean;\n /** All history values */\n history: Value[];\n /** Current index in history */\n index: number;\n /** Current value */\n value: Value;\n /** Go back specified number of steps in history (default: 1) */\n back: (steps?: number) => void;\n /** Go forward specified number of steps in history (default: 1) */\n forward: (steps?: number) => void;\n /** Redo the last change */\n redo: () => void;\n /** Reset history to initial state */\n reset: () => void;\n /** Set a new value */\n set: (value: Value) => void;\n /** Undo the last change */\n undo: () => void;\n}\n\nexport type StateHistoryAction<Value> =\n | { type: 'BACK'; payload: { steps: number } }\n | { type: 'FORWARD'; payload: { steps: number } }\n | { type: 'REDO' }\n | { type: 'RESET'; payload: { initialValue: Value; capacity: number } }\n | { type: 'SET'; payload: { value: Value; capacity: number } }\n | { type: 'UNDO' };\n\nexport interface StateHistory<Value> {\n currentIndex: number;\n history: Value[];\n redoStack: Value[][];\n undoStack: Value[][];\n}\n\nexport const stateHistoryReducer = <Value>(\n state: StateHistory<Value>,\n action: StateHistoryAction<Value>\n): StateHistory<Value> => {\n switch (action.type) {\n case 'SET': {\n const { value, capacity } = action.payload;\n\n const newHistory = [...state.history.slice(0, state.currentIndex + 1), value];\n if (newHistory.length > capacity) {\n newHistory.shift();\n }\n\n const newUndoStack = [state.history, ...state.undoStack];\n if (newUndoStack.length > capacity) {\n newUndoStack.pop();\n }\n\n return {\n history: newHistory,\n currentIndex: newHistory.length - 1,\n undoStack: newUndoStack,\n redoStack: []\n };\n }\n\n case 'UNDO': {\n if (state.undoStack.length === 0) return state;\n\n return {\n history: state.undoStack[0],\n currentIndex: state.undoStack[0].length - 1,\n undoStack: state.undoStack.slice(1),\n redoStack: [state.history, ...state.redoStack]\n };\n }\n\n case 'REDO': {\n if (state.redoStack.length === 0) return state;\n\n return {\n history: state.redoStack[0],\n currentIndex: state.redoStack[0].length - 1,\n undoStack: [state.history, ...state.undoStack],\n redoStack: state.redoStack.slice(1)\n };\n }\n\n case 'BACK': {\n const { steps } = action.payload;\n return {\n ...state,\n currentIndex: Math.max(0, state.currentIndex - steps)\n };\n }\n\n case 'FORWARD': {\n const { steps } = action.payload;\n return {\n ...state,\n currentIndex: Math.min(state.currentIndex + steps, state.history.length - 1)\n };\n }\n\n case 'RESET': {\n const { initialValue, capacity } = action.payload;\n if (state.history.length === 1) return state;\n\n const newUndoStack = [state.history, ...state.undoStack];\n if (newUndoStack.length > capacity) {\n newUndoStack.pop();\n }\n\n return {\n history: [initialValue],\n currentIndex: 0,\n undoStack: newUndoStack,\n redoStack: []\n };\n }\n\n default:\n throw new Error('Unsupported action type');\n }\n};\n\n/**\n * @name useStateHistory\n * @description - Hook that manages state with history functionality\n * @category Utilities\n *\n * @param {Value} initialValue - The initial value to start the history with\n * @param {number} [capacity=10] - Maximum number of history entries and undo actions to keep\n * @returns {UseStateHistoryReturn<Value>} Object containing current value, history array and control methods\n *\n * @example\n * const { value, history, index, set, back, forward, reset, undo, redo, canUndo, canRedo } = useStateHistory(0);\n */\nexport const useStateHistory = <Value>(\n initialValue: Value,\n capacity = 10\n): UseStateHistoryReturn<Value> => {\n const [state, dispatch] = useReducer(stateHistoryReducer<Value>, {\n history: [initialValue],\n currentIndex: 0,\n undoStack: [],\n redoStack: []\n });\n\n const value = state.history[state.currentIndex];\n const canUndo = state.undoStack.length > 0;\n const canRedo = state.redoStack.length > 0;\n\n const set = (value: Value) =>\n dispatch({\n type: 'SET',\n payload: { value, capacity }\n });\n\n const undo = () => dispatch({ type: 'UNDO' });\n\n const redo = () => dispatch({ type: 'REDO' });\n\n const back = (steps = 1) => dispatch({ type: 'BACK', payload: { steps } });\n\n const forward = (steps = 1) => dispatch({ type: 'FORWARD', payload: { steps } });\n\n const reset = () => dispatch({ type: 'RESET', payload: { initialValue, capacity } });\n\n return {\n history: state.history,\n value,\n set,\n index: state.currentIndex,\n back,\n forward,\n reset,\n undo,\n redo,\n canUndo,\n canRedo\n };\n};\n"],"names":["stateHistoryReducer","state","action","value","capacity","newHistory","newUndoStack","steps","initialValue","useStateHistory","dispatch","useReducer","canUndo","canRedo","set","undo","redo","back","forward","reset"],"mappings":"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"}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("./helpers/createContext/createContext.cjs"),m=require("./helpers/createReactiveContext/createReactiveContext.cjs"),E=require("./helpers/createStore/createStore.cjs"),p=require("./hooks/useActiveElement/useActiveElement.cjs"),y=require("./hooks/useAsync/useAsync.cjs"),R=require("./hooks/useBattery/useBattery.cjs"),O=require("./hooks/useBluetooth/useBluetooth.cjs"),k=require("./hooks/useBoolean/useBoolean.cjs"),e=require("./hooks/useBreakpoints/useBreakpoints.cjs"),I=require("./hooks/useBrowserLanguage/useBrowserLanguage.cjs"),v=require("./hooks/useClickOutside/useClickOutside.cjs"),D=require("./hooks/useClipboard/useClipboard.cjs"),b=require("./hooks/useConst/useConst.cjs"),s=require("./hooks/useCookie/useCookie.cjs"),r=require("./hooks/useCookies/useCookies.cjs"),h=require("./hooks/useCopy/useCopy.cjs"),A=require("./hooks/useCounter/useCounter.cjs"),L=require("./hooks/useCssVar/useCssVar.cjs"),M=require("./hooks/useDebounceCallback/useDebounceCallback.cjs"),f=require("./hooks/useDebounceValue/useDebounceValue.cjs"),_=require("./hooks/useDefault/useDefault.cjs"),N=require("./hooks/useDeviceMotion/useDeviceMotion.cjs"),B=require("./hooks/useDeviceOrientation/useDeviceOrientation.cjs"),K=require("./hooks/useDevicePixelRatio/useDevicePixelRatio.cjs"),F=require("./hooks/useDidUpdate/useDidUpdate.cjs"),V=require("./hooks/useDisclosure/useDisclosure.cjs"),w=require("./hooks/useDisplayMedia/useDisplayMedia.cjs"),W=require("./hooks/useDocumentEvent/useDocumentEvent.cjs"),U=require("./hooks/useDocumentTitle/useDocumentTitle.cjs"),x=require("./hooks/useDocumentVisibility/useDocumentVisibility.cjs"),H=require("./hooks/useDoubleClick/useDoubleClick.cjs"),Q=require("./hooks/useDropZone/useDropZone.cjs"),z=require("./hooks/useElementSize/useElementSize.cjs"),G=require("./hooks/useEvent/useEvent.cjs"),X=require("./hooks/useEventListener/useEventListener.cjs"),Z=require("./hooks/useEventSource/useEventSource.cjs"),j=require("./hooks/useEyeDropper/useEyeDropper.cjs"),J=require("./hooks/useFavicon/useFavicon.cjs"),Y=require("./hooks/useField/useField.cjs"),$=require("./hooks/useFileDialog/useFileDialog.cjs"),ee=require("./hooks/useFocus/useFocus.cjs"),se=require("./hooks/useFps/useFps.cjs"),ue=require("./hooks/useFul/useFul.cjs"),re=require("./hooks/useFullscreen/useFullscreen.cjs"),n=require("./hooks/useGamepad/useGamepad.cjs"),te=require("./hooks/useGeolocation/useGeolocation.cjs"),oe=require("./hooks/useHash/useHash.cjs"),c=require("./hooks/useHotkeys/useHotkeys.cjs"),ie=require("./hooks/useHover/useHover.cjs"),ne=require("./hooks/useIdle/useIdle.cjs"),ce=require("./hooks/useImage/useImage.cjs"),ae=require("./hooks/useInfiniteScroll/useInfiniteScroll.cjs"),le=require("./hooks/useIntersectionObserver/useIntersectionObserver.cjs"),Se=require("./hooks/useInterval/useInterval.cjs"),qe=require("./hooks/useIsFirstRender/useIsFirstRender.cjs"),ge=require("./hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.cjs"),de=require("./hooks/useKeyboard/useKeyboard.cjs"),Pe=require("./hooks/useKeyPress/useKeyPress.cjs"),Te=require("./hooks/useKeyPressEvent/useKeyPressEvent.cjs"),Ce=require("./hooks/useKeysPressed/useKeysPressed.cjs"),me=require("./hooks/useLastChanged/useLastChanged.cjs"),Ee=require("./hooks/useLatest/useLatest.cjs"),pe=require("./hooks/useLess/useLess.cjs"),ye=require("./hooks/useList/useList.cjs"),Re=require("./hooks/useLocalStorage/useLocalStorage.cjs"),Oe=require("./hooks/useLockCallback/useLockCallback.cjs"),ke=require("./hooks/useLogger/useLogger.cjs"),Ie=require("./hooks/useLongPress/useLongPress.cjs"),ve=require("./hooks/useMap/useMap.cjs"),De=require("./hooks/useMeasure/useMeasure.cjs"),be=require("./hooks/useMediaQuery/useMediaQuery.cjs"),he=require("./hooks/useMemory/useMemory.cjs"),Ae=require("./hooks/useMount/useMount.cjs"),Le=require("./hooks/useMouse/useMouse.cjs"),Me=require("./hooks/useMutation/useMutation.cjs"),fe=require("./hooks/useMutationObserver/useMutationObserver.cjs"),a=require("./hooks/useNetwork/useNetwork.cjs"),_e=require("./hooks/useOffsetPagination/useOffsetPagination.cjs"),Ne=require("./hooks/useOnce/useOnce.cjs"),Be=require("./hooks/useOnline/useOnline.cjs"),l=require("./hooks/useOperatingSystem/useOperatingSystem.cjs"),Ke=require("./hooks/useOptimistic/useOptimistic.cjs"),Fe=require("./hooks/useOrientation/useOrientation.cjs"),Ve=require("./hooks/useOtpCredential/useOtpCredential.cjs"),we=require("./hooks/usePageLeave/usePageLeave.cjs"),t=require("./hooks/usePaint/usePaint.cjs"),We=require("./hooks/useParallax/useParallax.cjs"),Ue=require("./hooks/usePerformanceObserver/usePerformanceObserver.cjs"),xe=require("./hooks/usePermission/usePermission.cjs"),He=require("./hooks/usePointerLock/usePointerLock.cjs"),Qe=require("./hooks/usePostMessage/usePostMessage.cjs"),ze=require("./hooks/usePreferredColorScheme/usePreferredColorScheme.cjs"),Ge=require("./hooks/usePreferredContrast/usePreferredContrast.cjs"),Xe=require("./hooks/usePreferredDark/usePreferredDark.cjs"),Ze=require("./hooks/usePreferredLanguages/usePreferredLanguages.cjs"),je=require("./hooks/usePreferredReducedMotion/usePreferredReducedMotion.cjs"),Je=require("./hooks/usePrevious/usePrevious.cjs"),Ye=require("./hooks/useQuery/useQuery.cjs"),$e=require("./hooks/useQueue/useQueue.cjs"),es=require("./hooks/useRaf/useRaf.cjs"),ss=require("./hooks/useRafValue/useRafValue.cjs"),us=require("./hooks/useRefState/useRefState.cjs"),rs=require("./hooks/useRenderCount/useRenderCount.cjs"),ts=require("./hooks/useRenderInfo/useRenderInfo.cjs"),os=require("./hooks/useRerender/useRerender.cjs"),is=require("./hooks/useResizeObserver/useResizeObserver.cjs"),ns=require("./hooks/useScreenOrientation/useScreenOrientation.cjs"),S=require("./hooks/useScript/useScript.cjs"),cs=require("./hooks/useScroll/useScroll.cjs"),as=require("./hooks/useScrollIntoView/useScrollIntoView.cjs"),ls=require("./hooks/useScrollTo/useScrollTo.cjs"),Ss=require("./hooks/useSessionStorage/useSessionStorage.cjs"),qs=require("./hooks/useSet/useSet.cjs"),gs=require("./hooks/useShare/useShare.cjs"),q=require("./hooks/useSpeechRecognition/useSpeechRecognition.cjs"),ds=require("./hooks/useSpeechSynthesis/useSpeechSynthesis.cjs"),Ps=require("./hooks/useStateHistory/useStateHistory.cjs"),Ts=require("./hooks/useStep/useStep.cjs"),Cs=require("./hooks/useSticky/useSticky.cjs"),ms=require("./hooks/useStopwatch/useStopwatch.cjs"),o=require("./hooks/useStorage/useStorage.cjs"),Es=require("./hooks/useTextDirection/useTextDirection.cjs"),g=require("./hooks/useTextSelection/useTextSelection.cjs"),ps=require("./hooks/useThrottleCallback/useThrottleCallback.cjs"),ys=require("./hooks/useThrottleValue/useThrottleValue.cjs"),Rs=require("./hooks/useTime/useTime.cjs"),Os=require("./hooks/useTimeout/useTimeout.cjs"),d=require("./hooks/useTimer/useTimer.cjs"),ks=require("./hooks/useToggle/useToggle.cjs"),Is=require("./hooks/useUnmount/useUnmount.cjs"),u=require("./hooks/useUrlSearchParams/useUrlSearchParams.cjs"),vs=require("./hooks/useVibrate/useVibrate.cjs"),Ds=require("./hooks/useWakeLock/useWakeLock.cjs"),bs=require("./hooks/useWebSocket/useWebSocket.cjs"),hs=require("./hooks/useWindowEvent/useWindowEvent.cjs"),As=require("./hooks/useWindowFocus/useWindowFocus.cjs"),P=require("./hooks/useWindowScroll/useWindowScroll.cjs"),Ls=require("./hooks/useWindowSize/useWindowSize.cjs"),Ms=require("./hooks/useWizard/useWizard.cjs"),T=require("./utils/helpers/copy.cjs"),fs=require("./utils/helpers/debounce.cjs"),_s=require("./utils/helpers/getDate.cjs"),i=require("./utils/helpers/getElement.cjs"),Ns=require("./utils/helpers/getRetry.cjs"),Bs=require("./utils/helpers/isTarget.cjs"),Ks=require("./utils/helpers/throttle.cjs");exports.createContext=C.createContext;exports.createReactiveContext=m.createReactiveContext;exports.createStore=E.createStore;exports.useActiveElement=p.useActiveElement;exports.useAsync=y.useAsync;exports.useBattery=R.useBattery;exports.useBluetooth=O.useBluetooth;exports.useBoolean=k.useBoolean;exports.BREAKPOINTS_ANT_DESIGN=e.BREAKPOINTS_ANT_DESIGN;exports.BREAKPOINTS_BOOTSTRAP_V5=e.BREAKPOINTS_BOOTSTRAP_V5;exports.BREAKPOINTS_MANTINE=e.BREAKPOINTS_MANTINE;exports.BREAKPOINTS_MASTER_CSS=e.BREAKPOINTS_MASTER_CSS;exports.BREAKPOINTS_MATERIAL_UI=e.BREAKPOINTS_MATERIAL_UI;exports.BREAKPOINTS_PRIME_FLEX=e.BREAKPOINTS_PRIME_FLEX;exports.BREAKPOINTS_QUASAR_V2=e.BREAKPOINTS_QUASAR_V2;exports.BREAKPOINTS_SEMANTIC=e.BREAKPOINTS_SEMANTIC;exports.BREAKPOINTS_TAILWIND=e.BREAKPOINTS_TAILWIND;exports.useBreakpoints=e.useBreakpoints;exports.useBrowserLanguage=I.useBrowserLanguage;exports.useClickOutside=v.useClickOutside;exports.useClipboard=D.useClipboard;exports.useConst=b.useConst;exports.COOKIE_EVENT=s.COOKIE_EVENT;exports.dispatchCookieEvent=s.dispatchCookieEvent;exports.getCookie=s.getCookie;exports.getCookies=s.getCookies;exports.removeCookie=s.removeCookie;exports.removeCookieItem=s.removeCookieItem;exports.setCookie=s.setCookie;exports.setCookieItem=s.setCookieItem;exports.useCookie=s.useCookie;exports.clearCookies=r.clearCookies;exports.getParsedCookies=r.getParsedCookies;exports.useCookies=r.useCookies;exports.useCopy=h.useCopy;exports.useCounter=A.useCounter;exports.useCssVar=L.useCssVar;exports.useDebounceCallback=M.useDebounceCallback;exports.useDebounceValue=f.useDebounceValue;exports.useDefault=_.useDefault;exports.useDeviceMotion=N.useDeviceMotion;exports.useDeviceOrientation=B.useDeviceOrientation;exports.useDevicePixelRatio=K.useDevicePixelRatio;exports.useDidUpdate=F.useDidUpdate;exports.useDisclosure=V.useDisclosure;exports.useDisplayMedia=w.useDisplayMedia;exports.useDocumentEvent=W.useDocumentEvent;exports.useDocumentTitle=U.useDocumentTitle;exports.useDocumentVisibility=x.useDocumentVisibility;exports.useDoubleClick=H.useDoubleClick;exports.useDropZone=Q.useDropZone;exports.useElementSize=z.useElementSize;exports.useEvent=G.useEvent;exports.useEventListener=X.useEventListener;exports.useEventSource=Z.useEventSource;exports.useEyeDropper=j.useEyeDropper;exports.useFavicon=J.useFavicon;exports.useField=Y.useField;exports.useFileDialog=$.useFileDialog;exports.useFocus=ee.useFocus;exports.useFps=se.useFps;exports.useFul=ue.useFul;exports.useFullscreen=re.useFullscreen;exports.mapGamepadToXbox360Controller=n.mapGamepadToXbox360Controller;exports.useGamepad=n.useGamepad;exports.useGeolocation=te.useGeolocation;exports.useHash=oe.useHash;exports.isHotkeyMatch=c.isHotkeyMatch;exports.useHotkeys=c.useHotkeys;exports.useHover=ie.useHover;exports.useIdle=ne.useIdle;exports.useImage=ce.useImage;exports.useInfiniteScroll=ae.useInfiniteScroll;exports.useIntersectionObserver=le.useIntersectionObserver;exports.useInterval=Se.useInterval;exports.useIsFirstRender=qe.useIsFirstRender;exports.useIsomorphicLayoutEffect=ge.useIsomorphicLayoutEffect;exports.useKeyboard=de.useKeyboard;exports.useKeyPress=Pe.useKeyPress;exports.useKeyPressEvent=Te.useKeyPressEvent;exports.useKeysPressed=Ce.useKeysPressed;exports.useLastChanged=me.useLastChanged;exports.useLatest=Ee.useLatest;exports.useLess=pe.useLess;exports.useList=ye.useList;exports.useLocalStorage=Re.useLocalStorage;exports.useLockCallback=Oe.useLockCallback;exports.useLogger=ke.useLogger;exports.useLongPress=Ie.useLongPress;exports.useMap=ve.useMap;exports.useMeasure=De.useMeasure;exports.useMediaQuery=be.useMediaQuery;exports.useMemory=he.useMemory;exports.useMount=Ae.useMount;exports.useMouse=Le.useMouse;exports.useMutation=Me.useMutation;exports.useMutationObserver=fe.useMutationObserver;exports.getConnection=a.getConnection;exports.useNetwork=a.useNetwork;exports.useOffsetPagination=_e.useOffsetPagination;exports.useOnce=Ne.useOnce;exports.useOnline=Be.useOnline;exports.getOperatingSystem=l.getOperatingSystem;exports.useOperatingSystem=l.useOperatingSystem;exports.useOptimistic=Ke.useOptimistic;exports.useOrientation=Fe.useOrientation;exports.useOtpCredential=Ve.useOtpCredential;exports.usePageLeave=we.usePageLeave;exports.Paint=t.Paint;exports.Pointer=t.Pointer;exports.usePaint=t.usePaint;exports.useParallax=We.useParallax;exports.usePerformanceObserver=Ue.usePerformanceObserver;exports.usePermission=xe.usePermission;exports.usePointerLock=He.usePointerLock;exports.usePostMessage=Qe.usePostMessage;exports.usePreferredColorScheme=ze.usePreferredColorScheme;exports.usePreferredContrast=Ge.usePreferredContrast;exports.usePreferredDark=Xe.usePreferredDark;exports.usePreferredLanguages=Ze.usePreferredLanguages;exports.usePreferredReducedMotion=je.usePreferredReducedMotion;exports.usePrevious=Je.usePrevious;exports.useQuery=Ye.useQuery;exports.useQueue=$e.useQueue;exports.useRaf=es.useRaf;exports.useRafValue=ss.useRafValue;exports.useRefState=us.useRefState;exports.useRenderCount=rs.useRenderCount;exports.useRenderInfo=ts.useRenderInfo;exports.useRerender=os.useRerender;exports.useResizeObserver=is.useResizeObserver;exports.useScreenOrientation=ns.useScreenOrientation;exports.SCRIPT_STATUS_ATTRIBUTE_NAME=S.SCRIPT_STATUS_ATTRIBUTE_NAME;exports.useScript=S.useScript;exports.useScroll=cs.useScroll;exports.useScrollIntoView=as.useScrollIntoView;exports.useScrollTo=ls.useScrollTo;exports.useSessionStorage=Ss.useSessionStorage;exports.useSet=qs.useSet;exports.useShare=gs.useShare;exports.getSpeechRecognition=q.getSpeechRecognition;exports.useSpeechRecognition=q.useSpeechRecognition;exports.useSpeechSynthesis=ds.useSpeechSynthesis;exports.useStateHistory=Ps.useStateHistory;exports.useStep=Ts.useStep;exports.useSticky=Cs.useSticky;exports.useStopwatch=ms.useStopwatch;exports.STORAGE_EVENT=o.STORAGE_EVENT;exports.dispatchStorageEvent=o.dispatchStorageEvent;exports.useStorage=o.useStorage;exports.useTextDirection=Es.useTextDirection;exports.getRangesSelection=g.getRangesSelection;exports.useTextSelection=g.useTextSelection;exports.useThrottleCallback=ps.useThrottleCallback;exports.useThrottleValue=ys.useThrottleValue;exports.useTime=Rs.useTime;exports.useTimeout=Os.useTimeout;exports.getTimeFromSeconds=d.getTimeFromSeconds;exports.useTimer=d.useTimer;exports.useToggle=ks.useToggle;exports.useUnmount=Is.useUnmount;exports.createQueryString=u.createQueryString;exports.getUrlSearchParams=u.getUrlSearchParams;exports.setUrlSearchParams=u.setUrlSearchParams;exports.useUrlSearchParams=u.useUrlSearchParams;exports.useVibrate=vs.useVibrate;exports.useWakeLock=Ds.useWakeLock;exports.useWebSocket=bs.useWebSocket;exports.useWindowEvent=hs.useWindowEvent;exports.useWindowFocus=As.useWindowFocus;exports.scrollTo=P.scrollTo;exports.useWindowScroll=P.useWindowScroll;exports.useWindowSize=Ls.useWindowSize;exports.useWizard=Ms.useWizard;exports.copy=T.copy;exports.legacyCopyToClipboard=T.legacyCopyToClipboard;exports.debounce=fs.debounce;exports.getDate=_s.getDate;exports.getElement=i.getElement;exports.target=i.target;exports.targetSymbol=i.targetSymbol;exports.getRetry=Ns.getRetry;exports.isTarget=Bs.isTarget;exports.throttle=Ks.throttle;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("./helpers/createContext/createContext.cjs"),E=require("./helpers/createReactiveContext/createReactiveContext.cjs"),p=require("./helpers/createStore/createStore.cjs"),y=require("./hooks/useActiveElement/useActiveElement.cjs"),R=require("./hooks/useAsync/useAsync.cjs"),O=require("./hooks/useBattery/useBattery.cjs"),k=require("./hooks/useBluetooth/useBluetooth.cjs"),I=require("./hooks/useBoolean/useBoolean.cjs"),e=require("./hooks/useBreakpoints/useBreakpoints.cjs"),v=require("./hooks/useBrowserLanguage/useBrowserLanguage.cjs"),D=require("./hooks/useClickOutside/useClickOutside.cjs"),b=require("./hooks/useClipboard/useClipboard.cjs"),h=require("./hooks/useConst/useConst.cjs"),s=require("./hooks/useCookie/useCookie.cjs"),r=require("./hooks/useCookies/useCookies.cjs"),A=require("./hooks/useCopy/useCopy.cjs"),L=require("./hooks/useCounter/useCounter.cjs"),M=require("./hooks/useCssVar/useCssVar.cjs"),f=require("./hooks/useDebounceCallback/useDebounceCallback.cjs"),_=require("./hooks/useDebounceValue/useDebounceValue.cjs"),N=require("./hooks/useDefault/useDefault.cjs"),B=require("./hooks/useDeviceMotion/useDeviceMotion.cjs"),K=require("./hooks/useDeviceOrientation/useDeviceOrientation.cjs"),F=require("./hooks/useDevicePixelRatio/useDevicePixelRatio.cjs"),V=require("./hooks/useDidUpdate/useDidUpdate.cjs"),w=require("./hooks/useDisclosure/useDisclosure.cjs"),W=require("./hooks/useDisplayMedia/useDisplayMedia.cjs"),U=require("./hooks/useDocumentEvent/useDocumentEvent.cjs"),x=require("./hooks/useDocumentTitle/useDocumentTitle.cjs"),H=require("./hooks/useDocumentVisibility/useDocumentVisibility.cjs"),Q=require("./hooks/useDoubleClick/useDoubleClick.cjs"),z=require("./hooks/useDropZone/useDropZone.cjs"),G=require("./hooks/useElementSize/useElementSize.cjs"),X=require("./hooks/useEvent/useEvent.cjs"),Z=require("./hooks/useEventListener/useEventListener.cjs"),j=require("./hooks/useEventSource/useEventSource.cjs"),J=require("./hooks/useEyeDropper/useEyeDropper.cjs"),Y=require("./hooks/useFavicon/useFavicon.cjs"),$=require("./hooks/useField/useField.cjs"),ee=require("./hooks/useFileDialog/useFileDialog.cjs"),se=require("./hooks/useFocus/useFocus.cjs"),ue=require("./hooks/useFps/useFps.cjs"),re=require("./hooks/useFul/useFul.cjs"),te=require("./hooks/useFullscreen/useFullscreen.cjs"),n=require("./hooks/useGamepad/useGamepad.cjs"),oe=require("./hooks/useGeolocation/useGeolocation.cjs"),ie=require("./hooks/useHash/useHash.cjs"),c=require("./hooks/useHotkeys/useHotkeys.cjs"),ne=require("./hooks/useHover/useHover.cjs"),ce=require("./hooks/useIdle/useIdle.cjs"),ae=require("./hooks/useImage/useImage.cjs"),le=require("./hooks/useInfiniteScroll/useInfiniteScroll.cjs"),Se=require("./hooks/useIntersectionObserver/useIntersectionObserver.cjs"),qe=require("./hooks/useInterval/useInterval.cjs"),ge=require("./hooks/useIsFirstRender/useIsFirstRender.cjs"),de=require("./hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.cjs"),Pe=require("./hooks/useKeyboard/useKeyboard.cjs"),Te=require("./hooks/useKeyPress/useKeyPress.cjs"),Ce=require("./hooks/useKeyPressEvent/useKeyPressEvent.cjs"),me=require("./hooks/useKeysPressed/useKeysPressed.cjs"),Ee=require("./hooks/useLastChanged/useLastChanged.cjs"),pe=require("./hooks/useLatest/useLatest.cjs"),ye=require("./hooks/useLess/useLess.cjs"),Re=require("./hooks/useList/useList.cjs"),Oe=require("./hooks/useLocalStorage/useLocalStorage.cjs"),ke=require("./hooks/useLockCallback/useLockCallback.cjs"),Ie=require("./hooks/useLogger/useLogger.cjs"),ve=require("./hooks/useLongPress/useLongPress.cjs"),De=require("./hooks/useMap/useMap.cjs"),be=require("./hooks/useMeasure/useMeasure.cjs"),he=require("./hooks/useMediaQuery/useMediaQuery.cjs"),Ae=require("./hooks/useMemory/useMemory.cjs"),Le=require("./hooks/useMount/useMount.cjs"),Me=require("./hooks/useMouse/useMouse.cjs"),fe=require("./hooks/useMutation/useMutation.cjs"),_e=require("./hooks/useMutationObserver/useMutationObserver.cjs"),a=require("./hooks/useNetwork/useNetwork.cjs"),Ne=require("./hooks/useOffsetPagination/useOffsetPagination.cjs"),Be=require("./hooks/useOnce/useOnce.cjs"),Ke=require("./hooks/useOnline/useOnline.cjs"),l=require("./hooks/useOperatingSystem/useOperatingSystem.cjs"),Fe=require("./hooks/useOptimistic/useOptimistic.cjs"),Ve=require("./hooks/useOrientation/useOrientation.cjs"),we=require("./hooks/useOtpCredential/useOtpCredential.cjs"),We=require("./hooks/usePageLeave/usePageLeave.cjs"),t=require("./hooks/usePaint/usePaint.cjs"),Ue=require("./hooks/useParallax/useParallax.cjs"),xe=require("./hooks/usePerformanceObserver/usePerformanceObserver.cjs"),He=require("./hooks/usePermission/usePermission.cjs"),Qe=require("./hooks/usePointerLock/usePointerLock.cjs"),ze=require("./hooks/usePostMessage/usePostMessage.cjs"),Ge=require("./hooks/usePreferredColorScheme/usePreferredColorScheme.cjs"),Xe=require("./hooks/usePreferredContrast/usePreferredContrast.cjs"),Ze=require("./hooks/usePreferredDark/usePreferredDark.cjs"),je=require("./hooks/usePreferredLanguages/usePreferredLanguages.cjs"),Je=require("./hooks/usePreferredReducedMotion/usePreferredReducedMotion.cjs"),Ye=require("./hooks/usePrevious/usePrevious.cjs"),$e=require("./hooks/useQuery/useQuery.cjs"),es=require("./hooks/useQueue/useQueue.cjs"),ss=require("./hooks/useRaf/useRaf.cjs"),us=require("./hooks/useRafValue/useRafValue.cjs"),rs=require("./hooks/useRefState/useRefState.cjs"),ts=require("./hooks/useRenderCount/useRenderCount.cjs"),os=require("./hooks/useRenderInfo/useRenderInfo.cjs"),is=require("./hooks/useRerender/useRerender.cjs"),ns=require("./hooks/useResizeObserver/useResizeObserver.cjs"),cs=require("./hooks/useScreenOrientation/useScreenOrientation.cjs"),S=require("./hooks/useScript/useScript.cjs"),as=require("./hooks/useScroll/useScroll.cjs"),ls=require("./hooks/useScrollIntoView/useScrollIntoView.cjs"),Ss=require("./hooks/useScrollTo/useScrollTo.cjs"),qs=require("./hooks/useSessionStorage/useSessionStorage.cjs"),gs=require("./hooks/useSet/useSet.cjs"),ds=require("./hooks/useShare/useShare.cjs"),q=require("./hooks/useSpeechRecognition/useSpeechRecognition.cjs"),Ps=require("./hooks/useSpeechSynthesis/useSpeechSynthesis.cjs"),g=require("./hooks/useStateHistory/useStateHistory.cjs"),Ts=require("./hooks/useStep/useStep.cjs"),Cs=require("./hooks/useSticky/useSticky.cjs"),ms=require("./hooks/useStopwatch/useStopwatch.cjs"),o=require("./hooks/useStorage/useStorage.cjs"),Es=require("./hooks/useTextDirection/useTextDirection.cjs"),d=require("./hooks/useTextSelection/useTextSelection.cjs"),ps=require("./hooks/useThrottleCallback/useThrottleCallback.cjs"),ys=require("./hooks/useThrottleValue/useThrottleValue.cjs"),Rs=require("./hooks/useTime/useTime.cjs"),Os=require("./hooks/useTimeout/useTimeout.cjs"),P=require("./hooks/useTimer/useTimer.cjs"),ks=require("./hooks/useToggle/useToggle.cjs"),Is=require("./hooks/useUnmount/useUnmount.cjs"),u=require("./hooks/useUrlSearchParams/useUrlSearchParams.cjs"),vs=require("./hooks/useVibrate/useVibrate.cjs"),Ds=require("./hooks/useWakeLock/useWakeLock.cjs"),bs=require("./hooks/useWebSocket/useWebSocket.cjs"),hs=require("./hooks/useWindowEvent/useWindowEvent.cjs"),As=require("./hooks/useWindowFocus/useWindowFocus.cjs"),T=require("./hooks/useWindowScroll/useWindowScroll.cjs"),Ls=require("./hooks/useWindowSize/useWindowSize.cjs"),Ms=require("./hooks/useWizard/useWizard.cjs"),C=require("./utils/helpers/copy.cjs"),fs=require("./utils/helpers/debounce.cjs"),_s=require("./utils/helpers/getDate.cjs"),i=require("./utils/helpers/getElement.cjs"),Ns=require("./utils/helpers/getRetry.cjs"),Bs=require("./utils/helpers/isTarget.cjs"),Ks=require("./utils/helpers/throttle.cjs");exports.createContext=m.createContext;exports.createReactiveContext=E.createReactiveContext;exports.createStore=p.createStore;exports.useActiveElement=y.useActiveElement;exports.useAsync=R.useAsync;exports.useBattery=O.useBattery;exports.useBluetooth=k.useBluetooth;exports.useBoolean=I.useBoolean;exports.BREAKPOINTS_ANT_DESIGN=e.BREAKPOINTS_ANT_DESIGN;exports.BREAKPOINTS_BOOTSTRAP_V5=e.BREAKPOINTS_BOOTSTRAP_V5;exports.BREAKPOINTS_MANTINE=e.BREAKPOINTS_MANTINE;exports.BREAKPOINTS_MASTER_CSS=e.BREAKPOINTS_MASTER_CSS;exports.BREAKPOINTS_MATERIAL_UI=e.BREAKPOINTS_MATERIAL_UI;exports.BREAKPOINTS_PRIME_FLEX=e.BREAKPOINTS_PRIME_FLEX;exports.BREAKPOINTS_QUASAR_V2=e.BREAKPOINTS_QUASAR_V2;exports.BREAKPOINTS_SEMANTIC=e.BREAKPOINTS_SEMANTIC;exports.BREAKPOINTS_TAILWIND=e.BREAKPOINTS_TAILWIND;exports.useBreakpoints=e.useBreakpoints;exports.useBrowserLanguage=v.useBrowserLanguage;exports.useClickOutside=D.useClickOutside;exports.useClipboard=b.useClipboard;exports.useConst=h.useConst;exports.COOKIE_EVENT=s.COOKIE_EVENT;exports.dispatchCookieEvent=s.dispatchCookieEvent;exports.getCookie=s.getCookie;exports.getCookies=s.getCookies;exports.removeCookie=s.removeCookie;exports.removeCookieItem=s.removeCookieItem;exports.setCookie=s.setCookie;exports.setCookieItem=s.setCookieItem;exports.useCookie=s.useCookie;exports.clearCookies=r.clearCookies;exports.getParsedCookies=r.getParsedCookies;exports.useCookies=r.useCookies;exports.useCopy=A.useCopy;exports.useCounter=L.useCounter;exports.useCssVar=M.useCssVar;exports.useDebounceCallback=f.useDebounceCallback;exports.useDebounceValue=_.useDebounceValue;exports.useDefault=N.useDefault;exports.useDeviceMotion=B.useDeviceMotion;exports.useDeviceOrientation=K.useDeviceOrientation;exports.useDevicePixelRatio=F.useDevicePixelRatio;exports.useDidUpdate=V.useDidUpdate;exports.useDisclosure=w.useDisclosure;exports.useDisplayMedia=W.useDisplayMedia;exports.useDocumentEvent=U.useDocumentEvent;exports.useDocumentTitle=x.useDocumentTitle;exports.useDocumentVisibility=H.useDocumentVisibility;exports.useDoubleClick=Q.useDoubleClick;exports.useDropZone=z.useDropZone;exports.useElementSize=G.useElementSize;exports.useEvent=X.useEvent;exports.useEventListener=Z.useEventListener;exports.useEventSource=j.useEventSource;exports.useEyeDropper=J.useEyeDropper;exports.useFavicon=Y.useFavicon;exports.useField=$.useField;exports.useFileDialog=ee.useFileDialog;exports.useFocus=se.useFocus;exports.useFps=ue.useFps;exports.useFul=re.useFul;exports.useFullscreen=te.useFullscreen;exports.mapGamepadToXbox360Controller=n.mapGamepadToXbox360Controller;exports.useGamepad=n.useGamepad;exports.useGeolocation=oe.useGeolocation;exports.useHash=ie.useHash;exports.isHotkeyMatch=c.isHotkeyMatch;exports.useHotkeys=c.useHotkeys;exports.useHover=ne.useHover;exports.useIdle=ce.useIdle;exports.useImage=ae.useImage;exports.useInfiniteScroll=le.useInfiniteScroll;exports.useIntersectionObserver=Se.useIntersectionObserver;exports.useInterval=qe.useInterval;exports.useIsFirstRender=ge.useIsFirstRender;exports.useIsomorphicLayoutEffect=de.useIsomorphicLayoutEffect;exports.useKeyboard=Pe.useKeyboard;exports.useKeyPress=Te.useKeyPress;exports.useKeyPressEvent=Ce.useKeyPressEvent;exports.useKeysPressed=me.useKeysPressed;exports.useLastChanged=Ee.useLastChanged;exports.useLatest=pe.useLatest;exports.useLess=ye.useLess;exports.useList=Re.useList;exports.useLocalStorage=Oe.useLocalStorage;exports.useLockCallback=ke.useLockCallback;exports.useLogger=Ie.useLogger;exports.useLongPress=ve.useLongPress;exports.useMap=De.useMap;exports.useMeasure=be.useMeasure;exports.useMediaQuery=he.useMediaQuery;exports.useMemory=Ae.useMemory;exports.useMount=Le.useMount;exports.useMouse=Me.useMouse;exports.useMutation=fe.useMutation;exports.useMutationObserver=_e.useMutationObserver;exports.getConnection=a.getConnection;exports.useNetwork=a.useNetwork;exports.useOffsetPagination=Ne.useOffsetPagination;exports.useOnce=Be.useOnce;exports.useOnline=Ke.useOnline;exports.getOperatingSystem=l.getOperatingSystem;exports.useOperatingSystem=l.useOperatingSystem;exports.useOptimistic=Fe.useOptimistic;exports.useOrientation=Ve.useOrientation;exports.useOtpCredential=we.useOtpCredential;exports.usePageLeave=We.usePageLeave;exports.Paint=t.Paint;exports.Pointer=t.Pointer;exports.usePaint=t.usePaint;exports.useParallax=Ue.useParallax;exports.usePerformanceObserver=xe.usePerformanceObserver;exports.usePermission=He.usePermission;exports.usePointerLock=Qe.usePointerLock;exports.usePostMessage=ze.usePostMessage;exports.usePreferredColorScheme=Ge.usePreferredColorScheme;exports.usePreferredContrast=Xe.usePreferredContrast;exports.usePreferredDark=Ze.usePreferredDark;exports.usePreferredLanguages=je.usePreferredLanguages;exports.usePreferredReducedMotion=Je.usePreferredReducedMotion;exports.usePrevious=Ye.usePrevious;exports.useQuery=$e.useQuery;exports.useQueue=es.useQueue;exports.useRaf=ss.useRaf;exports.useRafValue=us.useRafValue;exports.useRefState=rs.useRefState;exports.useRenderCount=ts.useRenderCount;exports.useRenderInfo=os.useRenderInfo;exports.useRerender=is.useRerender;exports.useResizeObserver=ns.useResizeObserver;exports.useScreenOrientation=cs.useScreenOrientation;exports.SCRIPT_STATUS_ATTRIBUTE_NAME=S.SCRIPT_STATUS_ATTRIBUTE_NAME;exports.useScript=S.useScript;exports.useScroll=as.useScroll;exports.useScrollIntoView=ls.useScrollIntoView;exports.useScrollTo=Ss.useScrollTo;exports.useSessionStorage=qs.useSessionStorage;exports.useSet=gs.useSet;exports.useShare=ds.useShare;exports.getSpeechRecognition=q.getSpeechRecognition;exports.useSpeechRecognition=q.useSpeechRecognition;exports.useSpeechSynthesis=Ps.useSpeechSynthesis;exports.stateHistoryReducer=g.stateHistoryReducer;exports.useStateHistory=g.useStateHistory;exports.useStep=Ts.useStep;exports.useSticky=Cs.useSticky;exports.useStopwatch=ms.useStopwatch;exports.STORAGE_EVENT=o.STORAGE_EVENT;exports.dispatchStorageEvent=o.dispatchStorageEvent;exports.useStorage=o.useStorage;exports.useTextDirection=Es.useTextDirection;exports.getRangesSelection=d.getRangesSelection;exports.useTextSelection=d.useTextSelection;exports.useThrottleCallback=ps.useThrottleCallback;exports.useThrottleValue=ys.useThrottleValue;exports.useTime=Rs.useTime;exports.useTimeout=Os.useTimeout;exports.getTimeFromSeconds=P.getTimeFromSeconds;exports.useTimer=P.useTimer;exports.useToggle=ks.useToggle;exports.useUnmount=Is.useUnmount;exports.createQueryString=u.createQueryString;exports.getUrlSearchParams=u.getUrlSearchParams;exports.setUrlSearchParams=u.setUrlSearchParams;exports.useUrlSearchParams=u.useUrlSearchParams;exports.useVibrate=vs.useVibrate;exports.useWakeLock=Ds.useWakeLock;exports.useWebSocket=bs.useWebSocket;exports.useWindowEvent=hs.useWindowEvent;exports.useWindowFocus=As.useWindowFocus;exports.scrollTo=T.scrollTo;exports.useWindowScroll=T.useWindowScroll;exports.useWindowSize=Ls.useWindowSize;exports.useWizard=Ms.useWizard;exports.copy=C.copy;exports.legacyCopyToClipboard=C.legacyCopyToClipboard;exports.debounce=fs.debounce;exports.getDate=_s.getDate;exports.getElement=i.getElement;exports.target=i.target;exports.targetSymbol=i.targetSymbol;exports.getRetry=Ns.getRetry;exports.isTarget=Bs.isTarget;exports.throttle=Ks.throttle;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,40 +1,55 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
import { useRefState as
|
|
3
|
-
import { isTarget as
|
|
4
|
-
import { getElement as
|
|
5
|
-
const
|
|
6
|
-
const
|
|
1
|
+
import { useState as P, useEffect as g } from "react";
|
|
2
|
+
import { useRefState as p } from "../useRefState/useRefState.mjs";
|
|
3
|
+
import { isTarget as E } from "../../utils/helpers/isTarget.mjs";
|
|
4
|
+
import { getElement as x } from "../../utils/helpers/getElement.mjs";
|
|
5
|
+
const S = (...l) => {
|
|
6
|
+
const o = E(l[0]) ? l[0] : void 0, [m, n] = P({
|
|
7
7
|
x: 0,
|
|
8
8
|
y: 0,
|
|
9
|
-
element: void 0,
|
|
10
9
|
elementX: 0,
|
|
11
10
|
elementY: 0,
|
|
12
11
|
elementPositionX: 0,
|
|
13
|
-
elementPositionY: 0
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
12
|
+
elementPositionY: 0,
|
|
13
|
+
clientX: 0,
|
|
14
|
+
clientY: 0
|
|
15
|
+
}), i = p();
|
|
16
|
+
return g(() => {
|
|
17
|
+
const c = (e) => {
|
|
18
|
+
const X = o ? x(o) : i.current, t = {
|
|
19
|
+
x: e.pageX,
|
|
20
|
+
y: e.pageY,
|
|
21
|
+
clientX: e.clientX,
|
|
22
|
+
clientY: e.clientY
|
|
23
|
+
};
|
|
24
|
+
if (X) {
|
|
25
|
+
const { left: s, top: u } = X.getBoundingClientRect(), Y = s + window.scrollX, d = u + window.scrollY, a = e.pageX - Y, f = e.pageY - d;
|
|
26
|
+
t.elementX = a, t.elementY = f, t.elementPositionX = Y, t.elementPositionY = d, n((w) => ({
|
|
27
|
+
...w,
|
|
28
|
+
...t
|
|
29
|
+
}));
|
|
30
|
+
} else
|
|
31
|
+
t.elementX = e.pageX, t.elementY = e.pageY, t.elementPositionX = 0, t.elementPositionY = 0, n((s) => ({
|
|
32
|
+
...s,
|
|
33
|
+
...t
|
|
34
|
+
}));
|
|
35
|
+
}, r = () => {
|
|
36
|
+
n((e) => ({
|
|
37
|
+
...e,
|
|
38
|
+
x: e.x + window.scrollX - e.elementPositionX,
|
|
39
|
+
y: e.y + window.scrollY - e.elementPositionY,
|
|
40
|
+
elementPositionX: window.scrollX,
|
|
41
|
+
elementPositionY: window.scrollY
|
|
27
42
|
}));
|
|
28
43
|
};
|
|
29
|
-
return document.addEventListener("
|
|
30
|
-
document.removeEventListener("
|
|
44
|
+
return document.addEventListener("scroll", r, { passive: !0 }), document.addEventListener("mousemove", c), () => {
|
|
45
|
+
document.removeEventListener("scroll", r), document.removeEventListener("mousemove", c);
|
|
31
46
|
};
|
|
32
|
-
}, [
|
|
33
|
-
ref:
|
|
34
|
-
...
|
|
47
|
+
}, [i.state, o]), o ? m : {
|
|
48
|
+
ref: i,
|
|
49
|
+
...m
|
|
35
50
|
};
|
|
36
51
|
};
|
|
37
52
|
export {
|
|
38
|
-
|
|
53
|
+
S as useMouse
|
|
39
54
|
};
|
|
40
55
|
//# sourceMappingURL=useMouse.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMouse.mjs","sources":["../../../../src/hooks/useMouse/useMouse.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nimport type { HookTarget } from '@/utils/helpers';\n\nimport { getElement, isTarget } from '@/utils/helpers';\n\nimport type { StateRef } from '../useRefState/useRefState';\n\nimport { useRefState } from '../useRefState/useRefState';\n\n/** The use mouse return type */\nexport interface UseMouseReturn {\n /** The current
|
|
1
|
+
{"version":3,"file":"useMouse.mjs","sources":["../../../../src/hooks/useMouse/useMouse.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nimport type { HookTarget } from '@/utils/helpers';\n\nimport { getElement, isTarget } from '@/utils/helpers';\n\nimport type { StateRef } from '../useRefState/useRefState';\n\nimport { useRefState } from '../useRefState/useRefState';\n\n/** The use mouse return type */\nexport interface UseMouseReturn {\n /** The current mouse client x position */\n clientX: number;\n /** The current mouse client y position */\n clientY: number;\n /** The current element position x */\n elementPositionX: number;\n /** The current element position y */\n elementPositionY: number;\n /** The current element x position */\n elementX: number;\n /** The current element y position */\n elementY: number;\n /** The current mouse x position */\n x: number;\n /** The current mouse y position */\n y: number;\n}\n\nexport interface UseMouse {\n (target: HookTarget): UseMouseReturn;\n\n <Target extends Element>(\n target?: never\n ): UseMouseReturn & {\n ref: StateRef<Target>;\n };\n\n (target?: Window): UseMouseReturn;\n}\n\n/**\n * @name useMouse\n * @description - Hook that manages a mouse position\n * @category Sensors\n *\n * @overload\n * @param {HookTarget} [target=window] The target element to manage the mouse position for\n * @returns {UseMouseReturn} An object with the current mouse position\n *\n * @example\n * const { x, y, clientX, clientY, elementX, elementY, elementPositionX, elementPositionY } = useMouse(ref);\n *\n * @overload\n * @template Target The target element\n * @returns {UseMouseReturn & { ref: StateRef<Target> }} An object with the current mouse position and a ref\n *\n * @example\n * const { ref, x, y, clientX, clientY, elementX, elementY, elementPositionX, elementPositionY } = useMouse();\n */\nexport const useMouse = ((...params: any[]) => {\n const target = isTarget(params[0]) ? params[0] : undefined;\n\n const [value, setValue] = useState<UseMouseReturn>({\n x: 0,\n y: 0,\n elementX: 0,\n elementY: 0,\n elementPositionX: 0,\n elementPositionY: 0,\n clientX: 0,\n clientY: 0\n });\n\n const internalRef = useRefState<Element>();\n\n useEffect(() => {\n const onMouseMove = (event: MouseEvent) => {\n const element = (target ? getElement(target) : internalRef.current) as Element | undefined;\n\n const updatedValue = {\n x: event.pageX,\n y: event.pageY,\n clientX: event.clientX,\n clientY: event.clientY\n } as typeof value;\n\n if (element) {\n const { left, top } = element.getBoundingClientRect();\n const elementPositionX = left + window.scrollX;\n const elementPositionY = top + window.scrollY;\n const elementX = event.pageX - elementPositionX;\n const elementY = event.pageY - elementPositionY;\n\n updatedValue.elementX = elementX;\n updatedValue.elementY = elementY;\n updatedValue.elementPositionX = elementPositionX;\n updatedValue.elementPositionY = elementPositionY;\n\n setValue((prevValue) => ({\n ...prevValue,\n ...updatedValue\n }));\n } else {\n updatedValue.elementX = event.pageX;\n updatedValue.elementY = event.pageY;\n updatedValue.elementPositionX = 0;\n updatedValue.elementPositionY = 0;\n\n setValue((prevValue) => ({\n ...prevValue,\n ...updatedValue\n }));\n }\n };\n\n const onScroll = () => {\n setValue((prevValue) => ({\n ...prevValue,\n x: prevValue.x + window.scrollX - prevValue.elementPositionX,\n y: prevValue.y + window.scrollY - prevValue.elementPositionY,\n elementPositionX: window.scrollX,\n elementPositionY: window.scrollY\n }));\n };\n\n document.addEventListener('scroll', onScroll, { passive: true });\n document.addEventListener('mousemove', onMouseMove);\n return () => {\n document.removeEventListener('scroll', onScroll);\n document.removeEventListener('mousemove', onMouseMove);\n };\n }, [internalRef.state, target]);\n\n if (target) return value;\n return {\n ref: internalRef,\n ...value\n };\n}) as UseMouse;\n"],"names":["useMouse","params","target","isTarget","value","setValue","useState","internalRef","useRefState","useEffect","onMouseMove","event","element","getElement","updatedValue","left","top","elementPositionX","elementPositionY","elementX","elementY","prevValue","onScroll"],"mappings":";;;;AA6Da,MAAAA,IAAY,IAAIC,MAAkB;AACvC,QAAAC,IAASC,EAASF,EAAO,CAAC,CAAC,IAAIA,EAAO,CAAC,IAAI,QAE3C,CAACG,GAAOC,CAAQ,IAAIC,EAAyB;AAAA,IACjD,GAAG;AAAA,IACH,GAAG;AAAA,IACH,UAAU;AAAA,IACV,UAAU;AAAA,IACV,kBAAkB;AAAA,IAClB,kBAAkB;AAAA,IAClB,SAAS;AAAA,IACT,SAAS;AAAA,EAAA,CACV,GAEKC,IAAcC,EAAqB;AA4DzC,SA1DAC,EAAU,MAAM;AACR,UAAAC,IAAc,CAACC,MAAsB;AACzC,YAAMC,IAAWV,IAASW,EAAWX,CAAM,IAAIK,EAAY,SAErDO,IAAe;AAAA,QACnB,GAAGH,EAAM;AAAA,QACT,GAAGA,EAAM;AAAA,QACT,SAASA,EAAM;AAAA,QACf,SAASA,EAAM;AAAA,MACjB;AAEA,UAAIC,GAAS;AACX,cAAM,EAAE,MAAAG,GAAM,KAAAC,MAAQJ,EAAQ,sBAAsB,GAC9CK,IAAmBF,IAAO,OAAO,SACjCG,IAAmBF,IAAM,OAAO,SAChCG,IAAWR,EAAM,QAAQM,GACzBG,IAAWT,EAAM,QAAQO;AAE/B,QAAAJ,EAAa,WAAWK,GACxBL,EAAa,WAAWM,GACxBN,EAAa,mBAAmBG,GAChCH,EAAa,mBAAmBI,GAEhCb,EAAS,CAACgB,OAAe;AAAA,UACvB,GAAGA;AAAA,UACH,GAAGP;AAAA,QAAA,EACH;AAAA,MAAA;AAEF,QAAAA,EAAa,WAAWH,EAAM,OAC9BG,EAAa,WAAWH,EAAM,OAC9BG,EAAa,mBAAmB,GAChCA,EAAa,mBAAmB,GAEhCT,EAAS,CAACgB,OAAe;AAAA,UACvB,GAAGA;AAAA,UACH,GAAGP;AAAA,QAAA,EACH;AAAA,IAEN,GAEMQ,IAAW,MAAM;AACrB,MAAAjB,EAAS,CAACgB,OAAe;AAAA,QACvB,GAAGA;AAAA,QACH,GAAGA,EAAU,IAAI,OAAO,UAAUA,EAAU;AAAA,QAC5C,GAAGA,EAAU,IAAI,OAAO,UAAUA,EAAU;AAAA,QAC5C,kBAAkB,OAAO;AAAA,QACzB,kBAAkB,OAAO;AAAA,MAAA,EACzB;AAAA,IACJ;AAEA,oBAAS,iBAAiB,UAAUC,GAAU,EAAE,SAAS,IAAM,GACtD,SAAA,iBAAiB,aAAaZ,CAAW,GAC3C,MAAM;AACF,eAAA,oBAAoB,UAAUY,CAAQ,GACtC,SAAA,oBAAoB,aAAaZ,CAAW;AAAA,IACvD;AAAA,EACC,GAAA,CAACH,EAAY,OAAOL,CAAM,CAAC,GAE1BA,IAAeE,IACZ;AAAA,IACL,KAAKG;AAAA,IACL,GAAGH;AAAA,EACL;AACF;"}
|
|
@@ -4,24 +4,23 @@ import { useRefState as D } from "../useRefState/useRefState.mjs";
|
|
|
4
4
|
import { useScreenOrientation as P } from "../useScreenOrientation/useScreenOrientation.mjs";
|
|
5
5
|
import { isTarget as X } from "../../utils/helpers/isTarget.mjs";
|
|
6
6
|
import { getElement as Y } from "../../utils/helpers/getElement.mjs";
|
|
7
|
-
const G = (...
|
|
8
|
-
const n = X(
|
|
9
|
-
deviceOrientationRollAdjust: g = (
|
|
10
|
-
deviceOrientationTiltAdjust: f = (
|
|
11
|
-
mouseRollAdjust: b = (
|
|
12
|
-
mouseTiltAdjust: y = (
|
|
13
|
-
} = p ?? {}, [
|
|
7
|
+
const G = (...o) => {
|
|
8
|
+
const n = X(o[0]) ? o[0] : void 0, p = o[1] ? o[1] : o[0], i = D(), s = P(), e = C(), {
|
|
9
|
+
deviceOrientationRollAdjust: g = (a) => a,
|
|
10
|
+
deviceOrientationTiltAdjust: f = (a) => a,
|
|
11
|
+
mouseRollAdjust: b = (a) => a,
|
|
12
|
+
mouseTiltAdjust: y = (a) => a
|
|
13
|
+
} = p ?? {}, [l, O] = x({
|
|
14
14
|
roll: 0,
|
|
15
15
|
tilt: 0,
|
|
16
16
|
source: "mouse"
|
|
17
17
|
});
|
|
18
18
|
return B(() => {
|
|
19
19
|
if (!n && !i.state) return;
|
|
20
|
-
const
|
|
21
|
-
if (!
|
|
22
|
-
console.log("element", o);
|
|
20
|
+
const a = n ? Y(n) : i.current;
|
|
21
|
+
if (!a) return;
|
|
23
22
|
const m = (v) => {
|
|
24
|
-
const { left: h, top: k } =
|
|
23
|
+
const { left: h, top: k } = a.getBoundingClientRect(), w = h + window.scrollX, R = k + window.scrollY, c = () => e.supported && (e.value.alpha || e.value.gamma) ? "deviceOrientation" : "mouse", T = () => {
|
|
25
24
|
if (c() === "deviceOrientation") {
|
|
26
25
|
let t;
|
|
27
26
|
switch (s.value.orientationType) {
|
|
@@ -42,8 +41,8 @@ const G = (...a) => {
|
|
|
42
41
|
}
|
|
43
42
|
return g(t);
|
|
44
43
|
} else {
|
|
45
|
-
const t = v.pageY - R, r =
|
|
46
|
-
return b(
|
|
44
|
+
const t = v.pageY - R, r = a.getBoundingClientRect().height, u = -(t - r / 2) / r;
|
|
45
|
+
return b(u);
|
|
47
46
|
}
|
|
48
47
|
}, j = () => {
|
|
49
48
|
if (c() === "deviceOrientation") {
|
|
@@ -66,8 +65,8 @@ const G = (...a) => {
|
|
|
66
65
|
}
|
|
67
66
|
return f(t);
|
|
68
67
|
} else {
|
|
69
|
-
const t = v.pageX - w, r =
|
|
70
|
-
return y(
|
|
68
|
+
const t = v.pageX - w, r = a.getBoundingClientRect().width, u = (t - r / 2) / r;
|
|
69
|
+
return y(u);
|
|
71
70
|
}
|
|
72
71
|
}, A = c(), E = T(), S = j();
|
|
73
72
|
O({
|
|
@@ -88,9 +87,9 @@ const G = (...a) => {
|
|
|
88
87
|
e.value.beta,
|
|
89
88
|
e.value.alpha,
|
|
90
89
|
e.value.absolute
|
|
91
|
-
]), n ? { value:
|
|
90
|
+
]), n ? { value: l } : {
|
|
92
91
|
ref: i,
|
|
93
|
-
value:
|
|
92
|
+
value: l
|
|
94
93
|
};
|
|
95
94
|
};
|
|
96
95
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useParallax.mjs","sources":["../../../../src/hooks/useParallax/useParallax.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nimport type { HookTarget } from '@/utils/helpers';\n\nimport { getElement, isTarget } from '@/utils/helpers';\n\nimport type { StateRef } from '../useRefState/useRefState';\n\nimport { useDeviceOrientation } from '../useDeviceOrientation/useDeviceOrientation';\nimport { useRefState } from '../useRefState/useRefState';\nimport { useScreenOrientation } from '../useScreenOrientation/useScreenOrientation';\n\n/** The use parallax value type */\nexport interface UseParallaxValue {\n /** Roll value. Scaled to `-0.5 ~ 0.5` */\n roll: number;\n /** Sensor source, can be `mouse` or `deviceOrientation` */\n source: 'deviceOrientation' | 'mouse';\n /** Tilt value. Scaled to `-0.5 ~ 0.5` */\n tilt: number;\n}\n\n/** The use parallax options type */\nexport interface UseParallaxOptions {\n /** Device orientation roll adjust function */\n deviceOrientationRollAdjust?: (value: number) => number;\n /** Device orientation tilt adjust function */\n deviceOrientationTiltAdjust?: (value: number) => number;\n /** Mouse roll adjust function */\n mouseRollAdjust?: (value: number) => number;\n /** Mouse tilt adjust function */\n mouseTiltAdjust?: (value: number) => number;\n}\n\ninterface UseParallaxReturn {\n value: UseParallaxValue;\n}\n\nexport interface UseParallax {\n (target: HookTarget, options?: UseParallaxOptions): UseParallaxReturn;\n\n <Target extends Element>(\n options?: UseParallaxOptions,\n target?: never\n ): UseParallaxReturn & {\n ref: StateRef<Target>;\n };\n}\n\n/**\n * @name useParallax\n * @description - Hook to help create parallax effect\n * @category Sensors\n *\n * @overload\n * @param {HookTarget} target The target element for the parallax effect\n * @param {UseParallaxOptions} options The options for the parallax effect\n * @returns {UseParallaxReturn} An object of parallax values\n *\n * @example\n * const { value } = useParallax(ref);\n *\n * @overload\n * @template Target The target element for the parallax effect\n * @param {UseParallaxOptions} options The options for the parallax effect\n * @returns {UseParallaxReturn & { ref: StateRef<Target> }} An object of parallax values\n *\n * @example\n * const { ref, value } = useParallax();\n */\nexport const useParallax = ((...params: any[]) => {\n const target = (isTarget(params[0]) ? params[0] : undefined) as HookTarget | undefined;\n const options = (params[1] ? params[1] : params[0]) as UseParallaxOptions | undefined;\n\n const internalRef = useRefState<Element>();\n\n const screenOrientation = useScreenOrientation();\n const deviceOrientation = useDeviceOrientation();\n\n const {\n deviceOrientationRollAdjust = (value) => value,\n deviceOrientationTiltAdjust = (value) => value,\n mouseRollAdjust = (value) => value,\n mouseTiltAdjust = (value) => value\n } = (options ?? {}) as UseParallaxOptions;\n\n const [value, setValue] = useState({\n roll: 0,\n tilt: 0,\n source: 'mouse'\n });\n\n useEffect(() => {\n if (!target && !internalRef.state) return;\n\n const element = (target ? getElement(target) : internalRef.current) as Element;\n if (!element) return;\n\n
|
|
1
|
+
{"version":3,"file":"useParallax.mjs","sources":["../../../../src/hooks/useParallax/useParallax.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nimport type { HookTarget } from '@/utils/helpers';\n\nimport { getElement, isTarget } from '@/utils/helpers';\n\nimport type { StateRef } from '../useRefState/useRefState';\n\nimport { useDeviceOrientation } from '../useDeviceOrientation/useDeviceOrientation';\nimport { useRefState } from '../useRefState/useRefState';\nimport { useScreenOrientation } from '../useScreenOrientation/useScreenOrientation';\n\n/** The use parallax value type */\nexport interface UseParallaxValue {\n /** Roll value. Scaled to `-0.5 ~ 0.5` */\n roll: number;\n /** Sensor source, can be `mouse` or `deviceOrientation` */\n source: 'deviceOrientation' | 'mouse';\n /** Tilt value. Scaled to `-0.5 ~ 0.5` */\n tilt: number;\n}\n\n/** The use parallax options type */\nexport interface UseParallaxOptions {\n /** Device orientation roll adjust function */\n deviceOrientationRollAdjust?: (value: number) => number;\n /** Device orientation tilt adjust function */\n deviceOrientationTiltAdjust?: (value: number) => number;\n /** Mouse roll adjust function */\n mouseRollAdjust?: (value: number) => number;\n /** Mouse tilt adjust function */\n mouseTiltAdjust?: (value: number) => number;\n}\n\ninterface UseParallaxReturn {\n value: UseParallaxValue;\n}\n\nexport interface UseParallax {\n (target: HookTarget, options?: UseParallaxOptions): UseParallaxReturn;\n\n <Target extends Element>(\n options?: UseParallaxOptions,\n target?: never\n ): UseParallaxReturn & {\n ref: StateRef<Target>;\n };\n}\n\n/**\n * @name useParallax\n * @description - Hook to help create parallax effect\n * @category Sensors\n *\n * @overload\n * @param {HookTarget} target The target element for the parallax effect\n * @param {UseParallaxOptions} options The options for the parallax effect\n * @returns {UseParallaxReturn} An object of parallax values\n *\n * @example\n * const { value } = useParallax(ref);\n *\n * @overload\n * @template Target The target element for the parallax effect\n * @param {UseParallaxOptions} options The options for the parallax effect\n * @returns {UseParallaxReturn & { ref: StateRef<Target> }} An object of parallax values\n *\n * @example\n * const { ref, value } = useParallax();\n */\nexport const useParallax = ((...params: any[]) => {\n const target = (isTarget(params[0]) ? params[0] : undefined) as HookTarget | undefined;\n const options = (params[1] ? params[1] : params[0]) as UseParallaxOptions | undefined;\n\n const internalRef = useRefState<Element>();\n\n const screenOrientation = useScreenOrientation();\n const deviceOrientation = useDeviceOrientation();\n\n const {\n deviceOrientationRollAdjust = (value) => value,\n deviceOrientationTiltAdjust = (value) => value,\n mouseRollAdjust = (value) => value,\n mouseTiltAdjust = (value) => value\n } = (options ?? {}) as UseParallaxOptions;\n\n const [value, setValue] = useState({\n roll: 0,\n tilt: 0,\n source: 'mouse'\n });\n\n useEffect(() => {\n if (!target && !internalRef.state) return;\n\n const element = (target ? getElement(target) : internalRef.current) as Element;\n if (!element) return;\n\n const onMouseMove = (event: MouseEvent) => {\n const { left, top } = element.getBoundingClientRect();\n const elementPositionX = left + window.scrollX;\n const elementPositionY = top + window.scrollY;\n\n const getSource = () => {\n const isDeviceOrientation =\n deviceOrientation.supported &&\n (deviceOrientation.value.alpha || deviceOrientation.value.gamma);\n\n if (isDeviceOrientation) return 'deviceOrientation';\n return 'mouse';\n };\n\n const getRoll = () => {\n const source = getSource();\n if (source === 'deviceOrientation') {\n let value: number;\n switch (screenOrientation.value.orientationType) {\n case 'landscape-primary':\n value = deviceOrientation.value.gamma! / 90;\n break;\n case 'landscape-secondary':\n value = -deviceOrientation.value.gamma! / 90;\n break;\n case 'portrait-primary':\n value = -deviceOrientation.value.beta! / 90;\n break;\n case 'portrait-secondary':\n value = deviceOrientation.value.beta! / 90;\n break;\n default:\n value = -deviceOrientation.value.beta! / 90;\n }\n return deviceOrientationRollAdjust(value);\n } else {\n const y = event.pageY - elementPositionY;\n const height = element.getBoundingClientRect().height;\n const value = -(y - height / 2) / height;\n return mouseRollAdjust(value);\n }\n };\n\n const getTilt = () => {\n const source = getSource();\n if (source === 'deviceOrientation') {\n let value: number;\n switch (screenOrientation.value.orientationType) {\n case 'landscape-primary':\n value = deviceOrientation.value.beta! / 90;\n break;\n case 'landscape-secondary':\n value = -deviceOrientation.value.beta! / 90;\n break;\n case 'portrait-primary':\n value = deviceOrientation.value.gamma! / 90;\n break;\n case 'portrait-secondary':\n value = -deviceOrientation.value.gamma! / 90;\n break;\n default:\n value = deviceOrientation.value.gamma! / 90;\n }\n return deviceOrientationTiltAdjust(value);\n } else {\n const x = event.pageX - elementPositionX;\n const width = element.getBoundingClientRect().width;\n const value = (x - width / 2) / width;\n return mouseTiltAdjust(value);\n }\n };\n\n const source = getSource();\n const roll = getRoll();\n const tilt = getTilt();\n\n setValue({\n roll,\n source,\n tilt\n });\n };\n\n document.addEventListener('mousemove', onMouseMove);\n return () => {\n document.removeEventListener('mousemove', onMouseMove);\n };\n }, [\n target,\n internalRef.state,\n screenOrientation.value.angle,\n screenOrientation.value.orientationType,\n deviceOrientation.value.gamma,\n deviceOrientation.value.beta,\n deviceOrientation.value.alpha,\n deviceOrientation.value.absolute\n ]);\n\n if (target) return { value };\n\n return {\n ref: internalRef,\n value\n };\n}) as UseParallax;\n"],"names":["useParallax","params","target","isTarget","options","internalRef","useRefState","screenOrientation","useScreenOrientation","deviceOrientation","useDeviceOrientation","deviceOrientationRollAdjust","value","deviceOrientationTiltAdjust","mouseRollAdjust","mouseTiltAdjust","setValue","useState","useEffect","element","getElement","onMouseMove","event","left","top","elementPositionX","elementPositionY","getSource","getRoll","y","height","getTilt","x","width","source","roll","tilt"],"mappings":"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"}
|
|
@@ -1,31 +1,85 @@
|
|
|
1
|
-
import {
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const c =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import { useReducer as p } from "react";
|
|
2
|
+
const k = (n, c) => {
|
|
3
|
+
switch (c.type) {
|
|
4
|
+
case "SET": {
|
|
5
|
+
const { value: r, capacity: o } = c.payload, e = [...n.history.slice(0, n.currentIndex + 1), r];
|
|
6
|
+
e.length > o && e.shift();
|
|
7
|
+
const t = [n.history, ...n.undoStack];
|
|
8
|
+
return t.length > o && t.pop(), {
|
|
9
|
+
history: e,
|
|
10
|
+
currentIndex: e.length - 1,
|
|
11
|
+
undoStack: t,
|
|
12
|
+
redoStack: []
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
case "UNDO":
|
|
16
|
+
return n.undoStack.length === 0 ? n : {
|
|
17
|
+
history: n.undoStack[0],
|
|
18
|
+
currentIndex: n.undoStack[0].length - 1,
|
|
19
|
+
undoStack: n.undoStack.slice(1),
|
|
20
|
+
redoStack: [n.history, ...n.redoStack]
|
|
21
|
+
};
|
|
22
|
+
case "REDO":
|
|
23
|
+
return n.redoStack.length === 0 ? n : {
|
|
24
|
+
history: n.redoStack[0],
|
|
25
|
+
currentIndex: n.redoStack[0].length - 1,
|
|
26
|
+
undoStack: [n.history, ...n.undoStack],
|
|
27
|
+
redoStack: n.redoStack.slice(1)
|
|
28
|
+
};
|
|
29
|
+
case "BACK": {
|
|
30
|
+
const { steps: r } = c.payload;
|
|
31
|
+
return {
|
|
32
|
+
...n,
|
|
33
|
+
currentIndex: Math.max(0, n.currentIndex - r)
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
case "FORWARD": {
|
|
37
|
+
const { steps: r } = c.payload;
|
|
38
|
+
return {
|
|
39
|
+
...n,
|
|
40
|
+
currentIndex: Math.min(n.currentIndex + r, n.history.length - 1)
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
case "RESET": {
|
|
44
|
+
const { initialValue: r, capacity: o } = c.payload;
|
|
45
|
+
if (n.history.length === 1) return n;
|
|
46
|
+
const e = [n.history, ...n.undoStack];
|
|
47
|
+
return e.length > o && e.pop(), {
|
|
48
|
+
history: [r],
|
|
49
|
+
currentIndex: 0,
|
|
50
|
+
undoStack: e,
|
|
51
|
+
redoStack: []
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
default:
|
|
55
|
+
throw new Error("Unsupported action type");
|
|
56
|
+
}
|
|
57
|
+
}, x = (n, c = 10) => {
|
|
58
|
+
const [r, o] = p(k, {
|
|
59
|
+
history: [n],
|
|
60
|
+
currentIndex: 0,
|
|
61
|
+
undoStack: [],
|
|
62
|
+
redoStack: []
|
|
63
|
+
}), e = r.history[r.currentIndex], t = r.undoStack.length > 0, u = r.redoStack.length > 0, a = (d) => o({
|
|
64
|
+
type: "SET",
|
|
65
|
+
payload: { value: d, capacity: c }
|
|
66
|
+
}), y = () => o({ type: "UNDO" }), s = () => o({ type: "REDO" }), h = (d = 1) => o({ type: "BACK", payload: { steps: d } }), i = (d = 1) => o({ type: "FORWARD", payload: { steps: d } }), S = () => o({ type: "RESET", payload: { initialValue: n, capacity: c } });
|
|
17
67
|
return {
|
|
18
|
-
history:
|
|
19
|
-
value:
|
|
20
|
-
set:
|
|
21
|
-
index: r.
|
|
22
|
-
back:
|
|
68
|
+
history: r.history,
|
|
69
|
+
value: e,
|
|
70
|
+
set: a,
|
|
71
|
+
index: r.currentIndex,
|
|
72
|
+
back: h,
|
|
23
73
|
forward: i,
|
|
24
|
-
reset:
|
|
25
|
-
undo: y
|
|
74
|
+
reset: S,
|
|
75
|
+
undo: y,
|
|
76
|
+
redo: s,
|
|
77
|
+
canUndo: t,
|
|
78
|
+
canRedo: u
|
|
26
79
|
};
|
|
27
80
|
};
|
|
28
81
|
export {
|
|
29
|
-
|
|
82
|
+
k as stateHistoryReducer,
|
|
83
|
+
x as useStateHistory
|
|
30
84
|
};
|
|
31
85
|
//# sourceMappingURL=useStateHistory.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStateHistory.mjs","sources":["../../../../src/hooks/useStateHistory/useStateHistory.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"useStateHistory.mjs","sources":["../../../../src/hooks/useStateHistory/useStateHistory.ts"],"sourcesContent":["import { useReducer } from 'react';\n\n/** The use state history hook return type */\ninterface UseStateHistoryReturn<Value> {\n /** True if a redo operation can be performed */\n canRedo: boolean;\n /** True if an undo operation can be performed */\n canUndo: boolean;\n /** All history values */\n history: Value[];\n /** Current index in history */\n index: number;\n /** Current value */\n value: Value;\n /** Go back specified number of steps in history (default: 1) */\n back: (steps?: number) => void;\n /** Go forward specified number of steps in history (default: 1) */\n forward: (steps?: number) => void;\n /** Redo the last change */\n redo: () => void;\n /** Reset history to initial state */\n reset: () => void;\n /** Set a new value */\n set: (value: Value) => void;\n /** Undo the last change */\n undo: () => void;\n}\n\nexport type StateHistoryAction<Value> =\n | { type: 'BACK'; payload: { steps: number } }\n | { type: 'FORWARD'; payload: { steps: number } }\n | { type: 'REDO' }\n | { type: 'RESET'; payload: { initialValue: Value; capacity: number } }\n | { type: 'SET'; payload: { value: Value; capacity: number } }\n | { type: 'UNDO' };\n\nexport interface StateHistory<Value> {\n currentIndex: number;\n history: Value[];\n redoStack: Value[][];\n undoStack: Value[][];\n}\n\nexport const stateHistoryReducer = <Value>(\n state: StateHistory<Value>,\n action: StateHistoryAction<Value>\n): StateHistory<Value> => {\n switch (action.type) {\n case 'SET': {\n const { value, capacity } = action.payload;\n\n const newHistory = [...state.history.slice(0, state.currentIndex + 1), value];\n if (newHistory.length > capacity) {\n newHistory.shift();\n }\n\n const newUndoStack = [state.history, ...state.undoStack];\n if (newUndoStack.length > capacity) {\n newUndoStack.pop();\n }\n\n return {\n history: newHistory,\n currentIndex: newHistory.length - 1,\n undoStack: newUndoStack,\n redoStack: []\n };\n }\n\n case 'UNDO': {\n if (state.undoStack.length === 0) return state;\n\n return {\n history: state.undoStack[0],\n currentIndex: state.undoStack[0].length - 1,\n undoStack: state.undoStack.slice(1),\n redoStack: [state.history, ...state.redoStack]\n };\n }\n\n case 'REDO': {\n if (state.redoStack.length === 0) return state;\n\n return {\n history: state.redoStack[0],\n currentIndex: state.redoStack[0].length - 1,\n undoStack: [state.history, ...state.undoStack],\n redoStack: state.redoStack.slice(1)\n };\n }\n\n case 'BACK': {\n const { steps } = action.payload;\n return {\n ...state,\n currentIndex: Math.max(0, state.currentIndex - steps)\n };\n }\n\n case 'FORWARD': {\n const { steps } = action.payload;\n return {\n ...state,\n currentIndex: Math.min(state.currentIndex + steps, state.history.length - 1)\n };\n }\n\n case 'RESET': {\n const { initialValue, capacity } = action.payload;\n if (state.history.length === 1) return state;\n\n const newUndoStack = [state.history, ...state.undoStack];\n if (newUndoStack.length > capacity) {\n newUndoStack.pop();\n }\n\n return {\n history: [initialValue],\n currentIndex: 0,\n undoStack: newUndoStack,\n redoStack: []\n };\n }\n\n default:\n throw new Error('Unsupported action type');\n }\n};\n\n/**\n * @name useStateHistory\n * @description - Hook that manages state with history functionality\n * @category Utilities\n *\n * @param {Value} initialValue - The initial value to start the history with\n * @param {number} [capacity=10] - Maximum number of history entries and undo actions to keep\n * @returns {UseStateHistoryReturn<Value>} Object containing current value, history array and control methods\n *\n * @example\n * const { value, history, index, set, back, forward, reset, undo, redo, canUndo, canRedo } = useStateHistory(0);\n */\nexport const useStateHistory = <Value>(\n initialValue: Value,\n capacity = 10\n): UseStateHistoryReturn<Value> => {\n const [state, dispatch] = useReducer(stateHistoryReducer<Value>, {\n history: [initialValue],\n currentIndex: 0,\n undoStack: [],\n redoStack: []\n });\n\n const value = state.history[state.currentIndex];\n const canUndo = state.undoStack.length > 0;\n const canRedo = state.redoStack.length > 0;\n\n const set = (value: Value) =>\n dispatch({\n type: 'SET',\n payload: { value, capacity }\n });\n\n const undo = () => dispatch({ type: 'UNDO' });\n\n const redo = () => dispatch({ type: 'REDO' });\n\n const back = (steps = 1) => dispatch({ type: 'BACK', payload: { steps } });\n\n const forward = (steps = 1) => dispatch({ type: 'FORWARD', payload: { steps } });\n\n const reset = () => dispatch({ type: 'RESET', payload: { initialValue, capacity } });\n\n return {\n history: state.history,\n value,\n set,\n index: state.currentIndex,\n back,\n forward,\n reset,\n undo,\n redo,\n canUndo,\n canRedo\n };\n};\n"],"names":["stateHistoryReducer","state","action","value","capacity","newHistory","newUndoStack","steps","initialValue","useStateHistory","dispatch","useReducer","canUndo","canRedo","set","undo","redo","back","forward","reset"],"mappings":"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"}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -6,12 +6,12 @@ import { useAsync as i } from "./hooks/useAsync/useAsync.mjs";
|
|
|
6
6
|
import { useBattery as n } from "./hooks/useBattery/useBattery.mjs";
|
|
7
7
|
import { useBluetooth as l } from "./hooks/useBluetooth/useBluetooth.mjs";
|
|
8
8
|
import { useBoolean as g } from "./hooks/useBoolean/useBoolean.mjs";
|
|
9
|
-
import { BREAKPOINTS_ANT_DESIGN as
|
|
9
|
+
import { BREAKPOINTS_ANT_DESIGN as d, BREAKPOINTS_BOOTSTRAP_V5 as E, BREAKPOINTS_MANTINE as P, BREAKPOINTS_MASTER_CSS as C, BREAKPOINTS_MATERIAL_UI as R, BREAKPOINTS_PRIME_FLEX as I, BREAKPOINTS_QUASAR_V2 as O, BREAKPOINTS_SEMANTIC as y, BREAKPOINTS_TAILWIND as k, useBreakpoints as A } from "./hooks/useBreakpoints/useBreakpoints.mjs";
|
|
10
10
|
import { useBrowserLanguage as D } from "./hooks/useBrowserLanguage/useBrowserLanguage.mjs";
|
|
11
11
|
import { useClickOutside as _ } from "./hooks/useClickOutside/useClickOutside.mjs";
|
|
12
12
|
import { useClipboard as M } from "./hooks/useClipboard/useClipboard.mjs";
|
|
13
13
|
import { useConst as L } from "./hooks/useConst/useConst.mjs";
|
|
14
|
-
import { COOKIE_EVENT as K, dispatchCookieEvent as F, getCookie as V, getCookies as U, removeCookie as w, removeCookieItem as W, setCookie as
|
|
14
|
+
import { COOKIE_EVENT as K, dispatchCookieEvent as F, getCookie as V, getCookies as U, removeCookie as w, removeCookieItem as W, setCookie as H, setCookieItem as G, useCookie as Q } from "./hooks/useCookie/useCookie.mjs";
|
|
15
15
|
import { clearCookies as X, getParsedCookies as Z, useCookies as j } from "./hooks/useCookies/useCookies.mjs";
|
|
16
16
|
import { useCopy as J } from "./hooks/useCopy/useCopy.mjs";
|
|
17
17
|
import { useCounter as $ } from "./hooks/useCounter/useCounter.mjs";
|
|
@@ -24,10 +24,10 @@ import { useDeviceOrientation as ae } from "./hooks/useDeviceOrientation/useDevi
|
|
|
24
24
|
import { useDevicePixelRatio as ce } from "./hooks/useDevicePixelRatio/useDevicePixelRatio.mjs";
|
|
25
25
|
import { useDidUpdate as Se } from "./hooks/useDidUpdate/useDidUpdate.mjs";
|
|
26
26
|
import { useDisclosure as Te } from "./hooks/useDisclosure/useDisclosure.mjs";
|
|
27
|
-
import { useDisplayMedia as
|
|
27
|
+
import { useDisplayMedia as Ee } from "./hooks/useDisplayMedia/useDisplayMedia.mjs";
|
|
28
28
|
import { useDocumentEvent as Ce } from "./hooks/useDocumentEvent/useDocumentEvent.mjs";
|
|
29
29
|
import { useDocumentTitle as Ie } from "./hooks/useDocumentTitle/useDocumentTitle.mjs";
|
|
30
|
-
import { useDocumentVisibility as
|
|
30
|
+
import { useDocumentVisibility as ye } from "./hooks/useDocumentVisibility/useDocumentVisibility.mjs";
|
|
31
31
|
import { useDoubleClick as Ae } from "./hooks/useDoubleClick/useDoubleClick.mjs";
|
|
32
32
|
import { useDropZone as De } from "./hooks/useDropZone/useDropZone.mjs";
|
|
33
33
|
import { useElementSize as _e } from "./hooks/useElementSize/useElementSize.mjs";
|
|
@@ -36,7 +36,7 @@ import { useEventListener as Le } from "./hooks/useEventListener/useEventListene
|
|
|
36
36
|
import { useEventSource as Ke } from "./hooks/useEventSource/useEventSource.mjs";
|
|
37
37
|
import { useEyeDropper as Ve } from "./hooks/useEyeDropper/useEyeDropper.mjs";
|
|
38
38
|
import { useFavicon as we } from "./hooks/useFavicon/useFavicon.mjs";
|
|
39
|
-
import { useField as
|
|
39
|
+
import { useField as He } from "./hooks/useField/useField.mjs";
|
|
40
40
|
import { useFileDialog as Qe } from "./hooks/useFileDialog/useFileDialog.mjs";
|
|
41
41
|
import { useFocus as Xe } from "./hooks/useFocus/useFocus.mjs";
|
|
42
42
|
import { useFps as je } from "./hooks/useFps/useFps.mjs";
|
|
@@ -53,7 +53,7 @@ import { useInfiniteScroll as To } from "./hooks/useInfiniteScroll/useInfiniteSc
|
|
|
53
53
|
import { useIntersectionObserver as Po } from "./hooks/useIntersectionObserver/useIntersectionObserver.mjs";
|
|
54
54
|
import { useInterval as Ro } from "./hooks/useInterval/useInterval.mjs";
|
|
55
55
|
import { useIsFirstRender as Oo } from "./hooks/useIsFirstRender/useIsFirstRender.mjs";
|
|
56
|
-
import { useIsomorphicLayoutEffect as
|
|
56
|
+
import { useIsomorphicLayoutEffect as ko } from "./hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.mjs";
|
|
57
57
|
import { useKeyboard as vo } from "./hooks/useKeyboard/useKeyboard.mjs";
|
|
58
58
|
import { useKeyPress as ho } from "./hooks/useKeyPress/useKeyPress.mjs";
|
|
59
59
|
import { useKeyPressEvent as bo } from "./hooks/useKeyPressEvent/useKeyPressEvent.mjs";
|
|
@@ -62,7 +62,7 @@ import { useLastChanged as Bo } from "./hooks/useLastChanged/useLastChanged.mjs"
|
|
|
62
62
|
import { useLatest as Fo } from "./hooks/useLatest/useLatest.mjs";
|
|
63
63
|
import { useLess as Uo } from "./hooks/useLess/useLess.mjs";
|
|
64
64
|
import { useList as Wo } from "./hooks/useList/useList.mjs";
|
|
65
|
-
import { useLocalStorage as
|
|
65
|
+
import { useLocalStorage as Go } from "./hooks/useLocalStorage/useLocalStorage.mjs";
|
|
66
66
|
import { useLockCallback as zo } from "./hooks/useLockCallback/useLockCallback.mjs";
|
|
67
67
|
import { useLogger as Zo } from "./hooks/useLogger/useLogger.mjs";
|
|
68
68
|
import { useLongPress as qo } from "./hooks/useLongPress/useLongPress.mjs";
|
|
@@ -76,10 +76,10 @@ import { useMutation as ir } from "./hooks/useMutation/useMutation.mjs";
|
|
|
76
76
|
import { useMutationObserver as nr } from "./hooks/useMutationObserver/useMutationObserver.mjs";
|
|
77
77
|
import { getConnection as lr, useNetwork as Sr } from "./hooks/useNetwork/useNetwork.mjs";
|
|
78
78
|
import { useOffsetPagination as Tr } from "./hooks/useOffsetPagination/useOffsetPagination.mjs";
|
|
79
|
-
import { useOnce as
|
|
79
|
+
import { useOnce as Er } from "./hooks/useOnce/useOnce.mjs";
|
|
80
80
|
import { useOnline as Cr } from "./hooks/useOnline/useOnline.mjs";
|
|
81
81
|
import { getOperatingSystem as Ir, useOperatingSystem as Or } from "./hooks/useOperatingSystem/useOperatingSystem.mjs";
|
|
82
|
-
import { useOptimistic as
|
|
82
|
+
import { useOptimistic as kr } from "./hooks/useOptimistic/useOptimistic.mjs";
|
|
83
83
|
import { useOrientation as vr } from "./hooks/useOrientation/useOrientation.mjs";
|
|
84
84
|
import { useOtpCredential as hr } from "./hooks/useOtpCredential/useOtpCredential.mjs";
|
|
85
85
|
import { usePageLeave as br } from "./hooks/usePageLeave/usePageLeave.mjs";
|
|
@@ -87,7 +87,7 @@ import { Paint as Nr, Pointer as Lr, usePaint as Br } from "./hooks/usePaint/use
|
|
|
87
87
|
import { useParallax as Fr } from "./hooks/useParallax/useParallax.mjs";
|
|
88
88
|
import { usePerformanceObserver as Ur } from "./hooks/usePerformanceObserver/usePerformanceObserver.mjs";
|
|
89
89
|
import { usePermission as Wr } from "./hooks/usePermission/usePermission.mjs";
|
|
90
|
-
import { usePointerLock as
|
|
90
|
+
import { usePointerLock as Gr } from "./hooks/usePointerLock/usePointerLock.mjs";
|
|
91
91
|
import { usePostMessage as zr } from "./hooks/usePostMessage/usePostMessage.mjs";
|
|
92
92
|
import { usePreferredColorScheme as Zr } from "./hooks/usePreferredColorScheme/usePreferredColorScheme.mjs";
|
|
93
93
|
import { usePreferredContrast as qr } from "./hooks/usePreferredContrast/usePreferredContrast.mjs";
|
|
@@ -101,11 +101,11 @@ import { useRaf as it } from "./hooks/useRaf/useRaf.mjs";
|
|
|
101
101
|
import { useRafValue as nt } from "./hooks/useRafValue/useRafValue.mjs";
|
|
102
102
|
import { useRefState as lt } from "./hooks/useRefState/useRefState.mjs";
|
|
103
103
|
import { useRenderCount as gt } from "./hooks/useRenderCount/useRenderCount.mjs";
|
|
104
|
-
import { useRenderInfo as
|
|
105
|
-
import { useRerender as
|
|
104
|
+
import { useRenderInfo as dt } from "./hooks/useRenderInfo/useRenderInfo.mjs";
|
|
105
|
+
import { useRerender as Pt } from "./hooks/useRerender/useRerender.mjs";
|
|
106
106
|
import { useResizeObserver as Rt } from "./hooks/useResizeObserver/useResizeObserver.mjs";
|
|
107
107
|
import { useScreenOrientation as Ot } from "./hooks/useScreenOrientation/useScreenOrientation.mjs";
|
|
108
|
-
import { SCRIPT_STATUS_ATTRIBUTE_NAME as
|
|
108
|
+
import { SCRIPT_STATUS_ATTRIBUTE_NAME as kt, useScript as At } from "./hooks/useScript/useScript.mjs";
|
|
109
109
|
import { useScroll as Dt } from "./hooks/useScroll/useScroll.mjs";
|
|
110
110
|
import { useScrollIntoView as _t } from "./hooks/useScrollIntoView/useScrollIntoView.mjs";
|
|
111
111
|
import { useScrollTo as Mt } from "./hooks/useScrollTo/useScrollTo.mjs";
|
|
@@ -113,86 +113,87 @@ import { useSessionStorage as Lt } from "./hooks/useSessionStorage/useSessionSto
|
|
|
113
113
|
import { useSet as Kt } from "./hooks/useSet/useSet.mjs";
|
|
114
114
|
import { useShare as Vt } from "./hooks/useShare/useShare.mjs";
|
|
115
115
|
import { getSpeechRecognition as wt, useSpeechRecognition as Wt } from "./hooks/useSpeechRecognition/useSpeechRecognition.mjs";
|
|
116
|
-
import { useSpeechSynthesis as
|
|
117
|
-
import {
|
|
118
|
-
import { useStep as
|
|
119
|
-
import { useSticky as
|
|
120
|
-
import { useStopwatch as
|
|
121
|
-
import { STORAGE_EVENT as
|
|
122
|
-
import { useTextDirection as
|
|
123
|
-
import { getRangesSelection as
|
|
124
|
-
import { useThrottleCallback as
|
|
125
|
-
import { useThrottleValue as
|
|
126
|
-
import { useTime as
|
|
127
|
-
import { useTimeout as
|
|
128
|
-
import { getTimeFromSeconds as
|
|
129
|
-
import { useToggle as
|
|
130
|
-
import { useUnmount as
|
|
131
|
-
import { createQueryString as
|
|
132
|
-
import { useVibrate as
|
|
133
|
-
import { useWakeLock as
|
|
134
|
-
import { useWebSocket as
|
|
135
|
-
import { useWindowEvent as
|
|
136
|
-
import { useWindowFocus as
|
|
137
|
-
import { scrollTo as
|
|
138
|
-
import { useWindowSize as
|
|
139
|
-
import { useWizard as
|
|
140
|
-
import { copy as
|
|
141
|
-
import { debounce as
|
|
142
|
-
import { getDate as
|
|
143
|
-
import { getElement as
|
|
144
|
-
import { getRetry as
|
|
145
|
-
import { isTarget as
|
|
146
|
-
import { throttle as
|
|
116
|
+
import { useSpeechSynthesis as Gt } from "./hooks/useSpeechSynthesis/useSpeechSynthesis.mjs";
|
|
117
|
+
import { stateHistoryReducer as zt, useStateHistory as Xt } from "./hooks/useStateHistory/useStateHistory.mjs";
|
|
118
|
+
import { useStep as jt } from "./hooks/useStep/useStep.mjs";
|
|
119
|
+
import { useSticky as Jt } from "./hooks/useSticky/useSticky.mjs";
|
|
120
|
+
import { useStopwatch as $t } from "./hooks/useStopwatch/useStopwatch.mjs";
|
|
121
|
+
import { STORAGE_EVENT as os, dispatchStorageEvent as rs, useStorage as ts } from "./hooks/useStorage/useStorage.mjs";
|
|
122
|
+
import { useTextDirection as ms } from "./hooks/useTextDirection/useTextDirection.mjs";
|
|
123
|
+
import { getRangesSelection as us, useTextSelection as fs } from "./hooks/useTextSelection/useTextSelection.mjs";
|
|
124
|
+
import { useThrottleCallback as is } from "./hooks/useThrottleCallback/useThrottleCallback.mjs";
|
|
125
|
+
import { useThrottleValue as ns } from "./hooks/useThrottleValue/useThrottleValue.mjs";
|
|
126
|
+
import { useTime as ls } from "./hooks/useTime/useTime.mjs";
|
|
127
|
+
import { useTimeout as gs } from "./hooks/useTimeout/useTimeout.mjs";
|
|
128
|
+
import { getTimeFromSeconds as ds, useTimer as Es } from "./hooks/useTimer/useTimer.mjs";
|
|
129
|
+
import { useToggle as Cs } from "./hooks/useToggle/useToggle.mjs";
|
|
130
|
+
import { useUnmount as Is } from "./hooks/useUnmount/useUnmount.mjs";
|
|
131
|
+
import { createQueryString as ys, getUrlSearchParams as ks, setUrlSearchParams as As, useUrlSearchParams as vs } from "./hooks/useUrlSearchParams/useUrlSearchParams.mjs";
|
|
132
|
+
import { useVibrate as hs } from "./hooks/useVibrate/useVibrate.mjs";
|
|
133
|
+
import { useWakeLock as bs } from "./hooks/useWakeLock/useWakeLock.mjs";
|
|
134
|
+
import { useWebSocket as Ns } from "./hooks/useWebSocket/useWebSocket.mjs";
|
|
135
|
+
import { useWindowEvent as Bs } from "./hooks/useWindowEvent/useWindowEvent.mjs";
|
|
136
|
+
import { useWindowFocus as Fs } from "./hooks/useWindowFocus/useWindowFocus.mjs";
|
|
137
|
+
import { scrollTo as Us, useWindowScroll as ws } from "./hooks/useWindowScroll/useWindowScroll.mjs";
|
|
138
|
+
import { useWindowSize as Hs } from "./hooks/useWindowSize/useWindowSize.mjs";
|
|
139
|
+
import { useWizard as Qs } from "./hooks/useWizard/useWizard.mjs";
|
|
140
|
+
import { copy as Xs, legacyCopyToClipboard as Zs } from "./utils/helpers/copy.mjs";
|
|
141
|
+
import { debounce as qs } from "./utils/helpers/debounce.mjs";
|
|
142
|
+
import { getDate as Ys } from "./utils/helpers/getDate.mjs";
|
|
143
|
+
import { getElement as em, target as om, targetSymbol as rm } from "./utils/helpers/getElement.mjs";
|
|
144
|
+
import { getRetry as sm } from "./utils/helpers/getRetry.mjs";
|
|
145
|
+
import { isTarget as pm } from "./utils/helpers/isTarget.mjs";
|
|
146
|
+
import { throttle as fm } from "./utils/helpers/throttle.mjs";
|
|
147
147
|
export {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
148
|
+
d as BREAKPOINTS_ANT_DESIGN,
|
|
149
|
+
E as BREAKPOINTS_BOOTSTRAP_V5,
|
|
150
|
+
P as BREAKPOINTS_MANTINE,
|
|
151
151
|
C as BREAKPOINTS_MASTER_CSS,
|
|
152
152
|
R as BREAKPOINTS_MATERIAL_UI,
|
|
153
153
|
I as BREAKPOINTS_PRIME_FLEX,
|
|
154
154
|
O as BREAKPOINTS_QUASAR_V2,
|
|
155
|
-
|
|
156
|
-
|
|
155
|
+
y as BREAKPOINTS_SEMANTIC,
|
|
156
|
+
k as BREAKPOINTS_TAILWIND,
|
|
157
157
|
K as COOKIE_EVENT,
|
|
158
158
|
Nr as Paint,
|
|
159
159
|
Lr as Pointer,
|
|
160
|
-
|
|
161
|
-
|
|
160
|
+
kt as SCRIPT_STATUS_ATTRIBUTE_NAME,
|
|
161
|
+
os as STORAGE_EVENT,
|
|
162
162
|
X as clearCookies,
|
|
163
|
-
|
|
163
|
+
Xs as copy,
|
|
164
164
|
r as createContext,
|
|
165
|
-
|
|
165
|
+
ys as createQueryString,
|
|
166
166
|
s as createReactiveContext,
|
|
167
167
|
p as createStore,
|
|
168
|
-
|
|
168
|
+
qs as debounce,
|
|
169
169
|
F as dispatchCookieEvent,
|
|
170
|
-
|
|
170
|
+
rs as dispatchStorageEvent,
|
|
171
171
|
lr as getConnection,
|
|
172
172
|
V as getCookie,
|
|
173
173
|
U as getCookies,
|
|
174
|
-
|
|
175
|
-
|
|
174
|
+
Ys as getDate,
|
|
175
|
+
em as getElement,
|
|
176
176
|
Ir as getOperatingSystem,
|
|
177
177
|
Z as getParsedCookies,
|
|
178
|
-
|
|
179
|
-
|
|
178
|
+
us as getRangesSelection,
|
|
179
|
+
sm as getRetry,
|
|
180
180
|
wt as getSpeechRecognition,
|
|
181
|
-
|
|
181
|
+
ds as getTimeFromSeconds,
|
|
182
182
|
ks as getUrlSearchParams,
|
|
183
183
|
fo as isHotkeyMatch,
|
|
184
|
-
|
|
185
|
-
|
|
184
|
+
pm as isTarget,
|
|
185
|
+
Zs as legacyCopyToClipboard,
|
|
186
186
|
oo as mapGamepadToXbox360Controller,
|
|
187
187
|
w as removeCookie,
|
|
188
188
|
W as removeCookieItem,
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
om as
|
|
195
|
-
|
|
189
|
+
Us as scrollTo,
|
|
190
|
+
H as setCookie,
|
|
191
|
+
G as setCookieItem,
|
|
192
|
+
As as setUrlSearchParams,
|
|
193
|
+
zt as stateHistoryReducer,
|
|
194
|
+
om as target,
|
|
195
|
+
rm as targetSymbol,
|
|
196
|
+
fm as throttle,
|
|
196
197
|
f as useActiveElement,
|
|
197
198
|
i as useAsync,
|
|
198
199
|
n as useBattery,
|
|
@@ -216,10 +217,10 @@ export {
|
|
|
216
217
|
ce as useDevicePixelRatio,
|
|
217
218
|
Se as useDidUpdate,
|
|
218
219
|
Te as useDisclosure,
|
|
219
|
-
|
|
220
|
+
Ee as useDisplayMedia,
|
|
220
221
|
Ce as useDocumentEvent,
|
|
221
222
|
Ie as useDocumentTitle,
|
|
222
|
-
|
|
223
|
+
ye as useDocumentVisibility,
|
|
223
224
|
Ae as useDoubleClick,
|
|
224
225
|
De as useDropZone,
|
|
225
226
|
_e as useElementSize,
|
|
@@ -228,7 +229,7 @@ export {
|
|
|
228
229
|
Ke as useEventSource,
|
|
229
230
|
Ve as useEyeDropper,
|
|
230
231
|
we as useFavicon,
|
|
231
|
-
|
|
232
|
+
He as useField,
|
|
232
233
|
Qe as useFileDialog,
|
|
233
234
|
Xe as useFocus,
|
|
234
235
|
je as useFps,
|
|
@@ -245,7 +246,7 @@ export {
|
|
|
245
246
|
Po as useIntersectionObserver,
|
|
246
247
|
Ro as useInterval,
|
|
247
248
|
Oo as useIsFirstRender,
|
|
248
|
-
|
|
249
|
+
ko as useIsomorphicLayoutEffect,
|
|
249
250
|
ho as useKeyPress,
|
|
250
251
|
bo as useKeyPressEvent,
|
|
251
252
|
vo as useKeyboard,
|
|
@@ -254,7 +255,7 @@ export {
|
|
|
254
255
|
Fo as useLatest,
|
|
255
256
|
Uo as useLess,
|
|
256
257
|
Wo as useList,
|
|
257
|
-
|
|
258
|
+
Go as useLocalStorage,
|
|
258
259
|
zo as useLockCallback,
|
|
259
260
|
Zo as useLogger,
|
|
260
261
|
qo as useLongPress,
|
|
@@ -268,10 +269,10 @@ export {
|
|
|
268
269
|
nr as useMutationObserver,
|
|
269
270
|
Sr as useNetwork,
|
|
270
271
|
Tr as useOffsetPagination,
|
|
271
|
-
|
|
272
|
+
Er as useOnce,
|
|
272
273
|
Cr as useOnline,
|
|
273
274
|
Or as useOperatingSystem,
|
|
274
|
-
|
|
275
|
+
kr as useOptimistic,
|
|
275
276
|
vr as useOrientation,
|
|
276
277
|
hr as useOtpCredential,
|
|
277
278
|
br as usePageLeave,
|
|
@@ -279,7 +280,7 @@ export {
|
|
|
279
280
|
Fr as useParallax,
|
|
280
281
|
Ur as usePerformanceObserver,
|
|
281
282
|
Wr as usePermission,
|
|
282
|
-
|
|
283
|
+
Gr as usePointerLock,
|
|
283
284
|
zr as usePostMessage,
|
|
284
285
|
Zr as usePreferredColorScheme,
|
|
285
286
|
qr as usePreferredContrast,
|
|
@@ -293,8 +294,8 @@ export {
|
|
|
293
294
|
nt as useRafValue,
|
|
294
295
|
lt as useRefState,
|
|
295
296
|
gt as useRenderCount,
|
|
296
|
-
|
|
297
|
-
|
|
297
|
+
dt as useRenderInfo,
|
|
298
|
+
Pt as useRerender,
|
|
298
299
|
Rt as useResizeObserver,
|
|
299
300
|
Ot as useScreenOrientation,
|
|
300
301
|
At as useScript,
|
|
@@ -305,29 +306,29 @@ export {
|
|
|
305
306
|
Kt as useSet,
|
|
306
307
|
Vt as useShare,
|
|
307
308
|
Wt as useSpeechRecognition,
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
309
|
+
Gt as useSpeechSynthesis,
|
|
310
|
+
Xt as useStateHistory,
|
|
311
|
+
jt as useStep,
|
|
312
|
+
Jt as useSticky,
|
|
313
|
+
$t as useStopwatch,
|
|
314
|
+
ts as useStorage,
|
|
315
|
+
ms as useTextDirection,
|
|
316
|
+
fs as useTextSelection,
|
|
317
|
+
is as useThrottleCallback,
|
|
318
|
+
ns as useThrottleValue,
|
|
319
|
+
ls as useTime,
|
|
320
|
+
gs as useTimeout,
|
|
320
321
|
Es as useTimer,
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
322
|
+
Cs as useToggle,
|
|
323
|
+
Is as useUnmount,
|
|
324
|
+
vs as useUrlSearchParams,
|
|
325
|
+
hs as useVibrate,
|
|
326
|
+
bs as useWakeLock,
|
|
327
|
+
Ns as useWebSocket,
|
|
328
|
+
Bs as useWindowEvent,
|
|
329
|
+
Fs as useWindowFocus,
|
|
330
|
+
ws as useWindowScroll,
|
|
331
|
+
Hs as useWindowSize,
|
|
332
|
+
Qs as useWizard
|
|
332
333
|
};
|
|
333
334
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -2,8 +2,10 @@ import { HookTarget } from '../../utils/helpers';
|
|
|
2
2
|
import { StateRef } from '../useRefState/useRefState';
|
|
3
3
|
/** The use mouse return type */
|
|
4
4
|
export interface UseMouseReturn {
|
|
5
|
-
/** The current
|
|
6
|
-
|
|
5
|
+
/** The current mouse client x position */
|
|
6
|
+
clientX: number;
|
|
7
|
+
/** The current mouse client y position */
|
|
8
|
+
clientY: number;
|
|
7
9
|
/** The current element position x */
|
|
8
10
|
elementPositionX: number;
|
|
9
11
|
/** The current element position y */
|
|
@@ -22,6 +24,7 @@ export interface UseMouse {
|
|
|
22
24
|
<Target extends Element>(target?: never): UseMouseReturn & {
|
|
23
25
|
ref: StateRef<Target>;
|
|
24
26
|
};
|
|
27
|
+
(target?: Window): UseMouseReturn;
|
|
25
28
|
}
|
|
26
29
|
/**
|
|
27
30
|
* @name useMouse
|
|
@@ -29,17 +32,17 @@ export interface UseMouse {
|
|
|
29
32
|
* @category Sensors
|
|
30
33
|
*
|
|
31
34
|
* @overload
|
|
32
|
-
* @param {HookTarget} target The target element to manage the mouse position for
|
|
35
|
+
* @param {HookTarget} [target=window] The target element to manage the mouse position for
|
|
33
36
|
* @returns {UseMouseReturn} An object with the current mouse position
|
|
34
37
|
*
|
|
35
38
|
* @example
|
|
36
|
-
* const { x, y, elementX, elementY, elementPositionX, elementPositionY } = useMouse(ref);
|
|
39
|
+
* const { x, y, clientX, clientY, elementX, elementY, elementPositionX, elementPositionY } = useMouse(ref);
|
|
37
40
|
*
|
|
38
41
|
* @overload
|
|
39
42
|
* @template Target The target element
|
|
40
43
|
* @returns {UseMouseReturn & { ref: StateRef<Target> }} An object with the current mouse position and a ref
|
|
41
44
|
*
|
|
42
45
|
* @example
|
|
43
|
-
* const { ref, x, y, elementX, elementY, elementPositionX, elementPositionY } = useMouse();
|
|
46
|
+
* const { ref, x, y, clientX, clientY, elementX, elementY, elementPositionX, elementPositionY } = useMouse();
|
|
44
47
|
*/
|
|
45
48
|
export declare const useMouse: UseMouse;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
/** The use state history hook return type */
|
|
2
2
|
interface UseStateHistoryReturn<Value> {
|
|
3
|
+
/** True if a redo operation can be performed */
|
|
4
|
+
canRedo: boolean;
|
|
5
|
+
/** True if an undo operation can be performed */
|
|
6
|
+
canUndo: boolean;
|
|
3
7
|
/** All history values */
|
|
4
8
|
history: Value[];
|
|
5
9
|
/** Current index in history */
|
|
@@ -10,6 +14,8 @@ interface UseStateHistoryReturn<Value> {
|
|
|
10
14
|
back: (steps?: number) => void;
|
|
11
15
|
/** Go forward specified number of steps in history (default: 1) */
|
|
12
16
|
forward: (steps?: number) => void;
|
|
17
|
+
/** Redo the last change */
|
|
18
|
+
redo: () => void;
|
|
13
19
|
/** Reset history to initial state */
|
|
14
20
|
reset: () => void;
|
|
15
21
|
/** Set a new value */
|
|
@@ -17,17 +23,51 @@ interface UseStateHistoryReturn<Value> {
|
|
|
17
23
|
/** Undo the last change */
|
|
18
24
|
undo: () => void;
|
|
19
25
|
}
|
|
26
|
+
export type StateHistoryAction<Value> = {
|
|
27
|
+
type: 'BACK';
|
|
28
|
+
payload: {
|
|
29
|
+
steps: number;
|
|
30
|
+
};
|
|
31
|
+
} | {
|
|
32
|
+
type: 'FORWARD';
|
|
33
|
+
payload: {
|
|
34
|
+
steps: number;
|
|
35
|
+
};
|
|
36
|
+
} | {
|
|
37
|
+
type: 'REDO';
|
|
38
|
+
} | {
|
|
39
|
+
type: 'RESET';
|
|
40
|
+
payload: {
|
|
41
|
+
initialValue: Value;
|
|
42
|
+
capacity: number;
|
|
43
|
+
};
|
|
44
|
+
} | {
|
|
45
|
+
type: 'SET';
|
|
46
|
+
payload: {
|
|
47
|
+
value: Value;
|
|
48
|
+
capacity: number;
|
|
49
|
+
};
|
|
50
|
+
} | {
|
|
51
|
+
type: 'UNDO';
|
|
52
|
+
};
|
|
53
|
+
export interface StateHistory<Value> {
|
|
54
|
+
currentIndex: number;
|
|
55
|
+
history: Value[];
|
|
56
|
+
redoStack: Value[][];
|
|
57
|
+
undoStack: Value[][];
|
|
58
|
+
}
|
|
59
|
+
export declare const stateHistoryReducer: <Value>(state: StateHistory<Value>, action: StateHistoryAction<Value>) => StateHistory<Value>;
|
|
20
60
|
/**
|
|
21
61
|
* @name useStateHistory
|
|
22
62
|
* @description - Hook that manages state with history functionality
|
|
23
63
|
* @category Utilities
|
|
24
64
|
*
|
|
25
65
|
* @param {Value} initialValue - The initial value to start the history with
|
|
26
|
-
* @param {number} [
|
|
66
|
+
* @param {number} [capacity=10] - Maximum number of history entries and undo actions to keep
|
|
27
67
|
* @returns {UseStateHistoryReturn<Value>} Object containing current value, history array and control methods
|
|
28
68
|
*
|
|
29
69
|
* @example
|
|
30
|
-
* const { value, history, index, set, back, forward, reset, undo } = useStateHistory(0);
|
|
70
|
+
* const { value, history, index, set, back, forward, reset, undo, redo, canUndo, canRedo } = useStateHistory(0);
|
|
31
71
|
*/
|
|
32
|
-
export declare const useStateHistory: <Value>(initialValue: Value,
|
|
72
|
+
export declare const useStateHistory: <Value>(initialValue: Value, capacity?: number) => UseStateHistoryReturn<Value>;
|
|
33
73
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@siberiacancode/reactuse",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"description": "The ultimate collection of react hooks",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "SIBERIA CAN CODE 🧊",
|
|
@@ -68,17 +68,17 @@
|
|
|
68
68
|
"@testing-library/dom": "^10.4.0",
|
|
69
69
|
"@testing-library/react": "^16.3.0",
|
|
70
70
|
"@types/dom-speech-recognition": "^0.0.6",
|
|
71
|
-
"@types/react": "^19.1.
|
|
71
|
+
"@types/react": "^19.1.6",
|
|
72
72
|
"@types/react-dom": "^19.1.5",
|
|
73
73
|
"@types/web-bluetooth": "^0.0.21",
|
|
74
|
-
"@vitejs/plugin-react": "^4.5.
|
|
74
|
+
"@vitejs/plugin-react": "^4.5.1",
|
|
75
75
|
"core-js": "^3.42.0",
|
|
76
76
|
"react": "^19.1.0",
|
|
77
77
|
"react-dom": "^19.1.0",
|
|
78
78
|
"shx": "^0.4.0",
|
|
79
79
|
"vite": "^6.3.5",
|
|
80
80
|
"vite-plugin-dts": "^4.5.4",
|
|
81
|
-
"vitest": "^3.1
|
|
81
|
+
"vitest": "^3.2.1"
|
|
82
82
|
},
|
|
83
83
|
"lint-staged": {
|
|
84
84
|
"*.{js,ts,tsx}": [
|