@kubed/hooks 0.2.36 → 0.3.0-alpha.1
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/cjs/useClickOutside/index.js +1 -1
- package/cjs/useClickOutside/index.js.map +1 -1
- package/cjs/useMediaQuery/index.js +1 -1
- package/cjs/useMediaQuery/index.js.map +1 -1
- package/cjs/useMove/index.js +1 -1
- package/cjs/useMove/index.js.map +1 -1
- package/cjs/usePrevious/index.js +1 -1
- package/cjs/usePrevious/index.js.map +1 -1
- package/cjs/useScrollLock/index.js.map +1 -1
- package/esm/useClickOutside/index.js +1 -1
- package/esm/useClickOutside/index.js.map +1 -1
- package/esm/useMediaQuery/index.js +1 -1
- package/esm/useMediaQuery/index.js.map +1 -1
- package/esm/useMove/index.js +1 -1
- package/esm/useMove/index.js.map +1 -1
- package/esm/usePrevious/index.js +1 -1
- package/esm/usePrevious/index.js.map +1 -1
- package/esm/useScrollLock/index.js.map +1 -1
- package/lib/useClickOutside/index.d.ts +1 -1
- package/lib/useClickOutside/index.d.ts.map +1 -1
- package/lib/useHover/index.d.ts +1 -1
- package/lib/useMove/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var o=require("react");const a=["mousedown","touchstart"];function i(r,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var o=require("react");const a=["mousedown","touchstart"];function i(r,n,c){const t=o.useRef(null);return o.useEffect(()=>{const s=e=>{Array.isArray(c)?c.every(u=>!!u&&!u.contains(e.target))&&r():t.current&&!t.current.contains(e.target)&&r()};return(n||a).forEach(e=>document.addEventListener(e,s)),()=>{(n||a).forEach(e=>document.removeEventListener(e,s))}},[t,r,c]),t}exports.useClickOutside=i;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/useClickOutside/index.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\n\nconst DEFAULT_EVENTS = ['mousedown', 'touchstart'];\n\nexport function useClickOutside<T extends HTMLElement = any>(\n handler: () => void,\n events?: string[] | null,\n nodes?: HTMLElement[]\n) {\n const ref = useRef<T>();\n\n useEffect(() => {\n const listener = (event: any) => {\n if (Array.isArray(nodes)) {\n const shouldTrigger = nodes.every((node) => !!node && !node.contains(event.target));\n shouldTrigger && handler();\n } else if (ref.current && !ref.current.contains(event.target)) {\n handler();\n }\n };\n\n (events || DEFAULT_EVENTS).forEach((fn) => document.addEventListener(fn, listener));\n\n return () => {\n (events || DEFAULT_EVENTS).forEach((fn) => document.removeEventListener(fn, listener));\n };\n }, [ref, handler, nodes]);\n\n return ref;\n}\n"],"names":["a","
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/useClickOutside/index.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\n\nconst DEFAULT_EVENTS = ['mousedown', 'touchstart'];\n\nexport function useClickOutside<T extends HTMLElement = any>(\n handler: () => void,\n events?: string[] | null,\n nodes?: HTMLElement[]\n) {\n const ref = useRef<T | null>(null);\n\n useEffect(() => {\n const listener = (event: any) => {\n if (Array.isArray(nodes)) {\n const shouldTrigger = nodes.every((node) => !!node && !node.contains(event.target));\n shouldTrigger && handler();\n } else if (ref.current && !ref.current.contains(event.target)) {\n handler();\n }\n };\n\n (events || DEFAULT_EVENTS).forEach((fn) => document.addEventListener(fn, listener));\n\n return () => {\n (events || DEFAULT_EVENTS).forEach((fn) => document.removeEventListener(fn, listener));\n };\n }, [ref, handler, nodes]);\n\n return ref;\n}\n"],"names":["a","i"],"mappings":";;;;;;AAA8C,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,YAAY,CAAC,CAAQ,SAAS,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAACA,YAAC,CAAC,IAAI,CAAC,CAAC,OAAOC,eAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,GAAE,CAAC,CAAC,OAAM,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,QAAQ,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,QAAQ,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var i=require("react");function
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var i=require("react");function c(e,n){try{return e.addEventListener("change",n),()=>e.removeEventListener("change",n)}catch(t){return e.addListener(n),()=>e.removeListener(n)}}function a(e){return typeof window!="undefined"&&"matchMedia"in window?window.matchMedia(e).matches:!1}function d(e){const[n,t]=i.useState(a(e)),r=i.useRef(null);return i.useEffect(()=>{if("matchMedia"in window)return r.current=window.matchMedia(e),t(r.current.matches),c(r.current,u=>t(u.matches))},[e]),n}exports.useMediaQuery=d;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/useMediaQuery/index.ts"],"sourcesContent":["import { useState, useEffect, useRef } from 'react';\n\ntype MediaQueryCallback = (event: { matches: boolean; media: string }) => void;\n\n/**\n * Older versions of Safari (shipped withCatalina and before) do not support addEventListener on matchMedia\n * https://stackoverflow.com/questions/56466261/matchmedia-addlistener-marked-as-deprecated-addeventlistener-equivalent\n * */\nfunction attachMediaListener(query: MediaQueryList, callback: MediaQueryCallback) {\n try {\n query.addEventListener('change', callback);\n return () => query.removeEventListener('change', callback);\n } catch (e) {\n query.addListener(callback);\n return () => query.removeListener(callback);\n }\n}\n\nfunction getInitialValue(query: string) {\n if (typeof window !== 'undefined' && 'matchMedia' in window) {\n return window.matchMedia(query).matches;\n }\n return false;\n}\n\nexport function useMediaQuery(query: string) {\n const [matches, setMatches] = useState(getInitialValue(query));\n const queryRef = useRef<MediaQueryList>();\n\n // eslint-disable-next-line consistent-return\n useEffect(() => {\n if ('matchMedia' in window) {\n queryRef.current = window.matchMedia(query);\n setMatches(queryRef.current.matches);\n return attachMediaListener(queryRef.current, (event) => setMatches(event.matches));\n }\n }, [query]);\n\n return matches;\n}\n"],"names":["a","d","s"],"mappings":";;;;;;AAA4D,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,OAAO,MAAM,EAAE,WAAW,EAAE,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAQ,SAAS,aAAa,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAACA,cAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAACC,YAAC,
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/useMediaQuery/index.ts"],"sourcesContent":["import { useState, useEffect, useRef } from 'react';\n\ntype MediaQueryCallback = (event: { matches: boolean; media: string }) => void;\n\n/**\n * Older versions of Safari (shipped withCatalina and before) do not support addEventListener on matchMedia\n * https://stackoverflow.com/questions/56466261/matchmedia-addlistener-marked-as-deprecated-addeventlistener-equivalent\n * */\nfunction attachMediaListener(query: MediaQueryList, callback: MediaQueryCallback) {\n try {\n query.addEventListener('change', callback);\n return () => query.removeEventListener('change', callback);\n } catch (e) {\n query.addListener(callback);\n return () => query.removeListener(callback);\n }\n}\n\nfunction getInitialValue(query: string) {\n if (typeof window !== 'undefined' && 'matchMedia' in window) {\n return window.matchMedia(query).matches;\n }\n return false;\n}\n\nexport function useMediaQuery(query: string) {\n const [matches, setMatches] = useState(getInitialValue(query));\n const queryRef = useRef<MediaQueryList | null>(null);\n\n // eslint-disable-next-line consistent-return\n useEffect(() => {\n if ('matchMedia' in window) {\n queryRef.current = window.matchMedia(query);\n setMatches(queryRef.current.matches);\n return attachMediaListener(queryRef.current, (event) => setMatches(event.matches));\n }\n }, [query]);\n\n return matches;\n}\n"],"names":["a","d","s"],"mappings":";;;;;;AAA4D,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,OAAO,MAAM,EAAE,WAAW,EAAE,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAQ,SAAS,aAAa,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAACA,cAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAACC,YAAC,CAAC,IAAI,CAAC,CAAC,OAAOC,eAAC,CAAC,IAAI,CAAC,GAAG,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;;;;"}
|
package/cjs/useMove/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n=require("react"),h=require("../utils/index.js");function b(L,r){const t=n.useRef(),c=n.useRef(!1),o=n.useRef(!1),v=n.useRef(0),[p,m]=n.useState(!1);return n.useEffect(()=>{c.current=!0},[]),n.useEffect(()=>{const a=({x:e,y:S})=>{cancelAnimationFrame(v.current),v.current=requestAnimationFrame(()=>{if(c.current&&t.current){t.current.style.userSelect="none";const u=t.current.getBoundingClientRect();u.width&&u.height&&L({x:h.clamp({value:(e-u.left)/u.width,min:0,max:1}),y:h.clamp({value:(S-u.top)/u.height,min:0,max:1})})}})},x=()=>{document.addEventListener("mousemove",s),document.addEventListener("mouseup",i),document.addEventListener("touchmove",d),document.addEventListener("touchend",i)},y=()=>{document.removeEventListener("mousemove",s),document.removeEventListener("mouseup",i),document.removeEventListener("touchmove",d),document.removeEventListener("touchend",i)},l=()=>{!o.current&&c.current&&(o.current=!0,typeof(r==null?void 0:r.onScrubStart)=="function"&&r.onScrubStart(),m(!0),x())},i=()=>{o.current&&c.current&&(o.current=!1,typeof(r==null?void 0:r.onScrubEnd)=="function"&&r.onScrubEnd(),m(!1),y())},f=e=>{l(),s(e)},s=e=>a({x:e.clientX,y:e.clientY}),E=e=>{l(),e==null||e.preventDefault(),d(e)},d=e=>{e==null||e.preventDefault(),a({x:e.changedTouches[0].clientX,y:e.changedTouches[0].clientY})};return t.current.addEventListener("mousedown",f),t.current.addEventListener("touchstart",E),()=>{t.current&&(t.current.removeEventListener("mousedown",f),t.current.removeEventListener("touchstart",E))}},[t.current]),{ref:t,active:p}}exports.useMove=b;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n=require("react"),h=require("../utils/index.js");function b(L,r){const t=n.useRef(null),c=n.useRef(!1),o=n.useRef(!1),v=n.useRef(0),[p,m]=n.useState(!1);return n.useEffect(()=>{c.current=!0},[]),n.useEffect(()=>{const a=({x:e,y:S})=>{cancelAnimationFrame(v.current),v.current=requestAnimationFrame(()=>{if(c.current&&t.current){t.current.style.userSelect="none";const u=t.current.getBoundingClientRect();u.width&&u.height&&L({x:h.clamp({value:(e-u.left)/u.width,min:0,max:1}),y:h.clamp({value:(S-u.top)/u.height,min:0,max:1})})}})},x=()=>{document.addEventListener("mousemove",s),document.addEventListener("mouseup",i),document.addEventListener("touchmove",d),document.addEventListener("touchend",i)},y=()=>{document.removeEventListener("mousemove",s),document.removeEventListener("mouseup",i),document.removeEventListener("touchmove",d),document.removeEventListener("touchend",i)},l=()=>{!o.current&&c.current&&(o.current=!0,typeof(r==null?void 0:r.onScrubStart)=="function"&&r.onScrubStart(),m(!0),x())},i=()=>{o.current&&c.current&&(o.current=!1,typeof(r==null?void 0:r.onScrubEnd)=="function"&&r.onScrubEnd(),m(!1),y())},f=e=>{l(),s(e)},s=e=>a({x:e.clientX,y:e.clientY}),E=e=>{l(),e==null||e.preventDefault(),d(e)},d=e=>{e==null||e.preventDefault(),a({x:e.changedTouches[0].clientX,y:e.changedTouches[0].clientY})};return t.current.addEventListener("mousedown",f),t.current.addEventListener("touchstart",E),()=>{t.current&&(t.current.removeEventListener("mousedown",f),t.current.removeEventListener("touchstart",E))}},[t.current]),{ref:t,active:p}}exports.useMove=b;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/cjs/useMove/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/useMove/index.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\nimport { useEffect, useState, useRef } from 'react';\nimport { clamp } from '../utils';\n\nexport interface UseMovePosition {\n x: number;\n y: number;\n}\n\nexport const clampUseMovePosition = (position: UseMovePosition) => ({\n x: clamp({ min: 0, max: 1, value: position.x }),\n y: clamp({ min: 0, max: 1, value: position.y }),\n});\n\ninterface useMoveHandlers {\n onScrubStart?(): void;\n onScrubEnd?(): void;\n}\n\nexport function useMove<T extends HTMLElement = HTMLDivElement>(\n onChange: (value: UseMovePosition) => void,\n handlers?: useMoveHandlers\n) {\n const ref = useRef<T>();\n const mounted = useRef<boolean>(false);\n const isSliding = useRef(false);\n const frame = useRef(0);\n const [active, setActive] = useState(false);\n\n useEffect(() => {\n mounted.current = true;\n }, []);\n\n useEffect(() => {\n const onScrub = ({ x, y }: UseMovePosition) => {\n cancelAnimationFrame(frame.current);\n\n frame.current = requestAnimationFrame(() => {\n if (mounted.current && ref.current) {\n ref.current.style.userSelect = 'none';\n const rect = ref.current.getBoundingClientRect();\n\n if (rect.width && rect.height) {\n onChange({\n x: clamp({ value: (x - rect.left) / rect.width, min: 0, max: 1 }),\n y: clamp({ value: (y - rect.top) / rect.height, min: 0, max: 1 }),\n });\n }\n }\n });\n };\n\n const bindEvents = () => {\n document.addEventListener('mousemove', onMouseMove);\n document.addEventListener('mouseup', stopScrubbing);\n document.addEventListener('touchmove', onTouchMove);\n document.addEventListener('touchend', stopScrubbing);\n };\n\n const unbindEvents = () => {\n document.removeEventListener('mousemove', onMouseMove);\n document.removeEventListener('mouseup', stopScrubbing);\n document.removeEventListener('touchmove', onTouchMove);\n document.removeEventListener('touchend', stopScrubbing);\n };\n\n const startScrubbing = () => {\n if (!isSliding.current && mounted.current) {\n isSliding.current = true;\n typeof handlers?.onScrubStart === 'function' && handlers.onScrubStart();\n setActive(true);\n bindEvents();\n }\n };\n\n const stopScrubbing = () => {\n if (isSliding.current && mounted.current) {\n isSliding.current = false;\n typeof handlers?.onScrubEnd === 'function' && handlers.onScrubEnd();\n setActive(false);\n unbindEvents();\n }\n };\n\n const onMouseDown = (event: MouseEvent) => {\n startScrubbing();\n onMouseMove(event);\n };\n\n const onMouseMove = (event: MouseEvent) => onScrub({ x: event.clientX, y: event.clientY });\n\n const onTouchStart = (event: TouchEvent) => {\n startScrubbing();\n event?.preventDefault();\n onTouchMove(event);\n };\n\n const onTouchMove = (event: TouchEvent) => {\n event?.preventDefault();\n onScrub({ x: event.changedTouches[0].clientX, y: event.changedTouches[0].clientY });\n };\n\n ref.current.addEventListener('mousedown', onMouseDown);\n ref.current.addEventListener('touchstart', onTouchStart);\n\n return () => {\n if (ref.current) {\n ref.current.removeEventListener('mousedown', onMouseDown);\n ref.current.removeEventListener('touchstart', onTouchStart);\n }\n };\n }, [ref.current]);\n\n return { ref, active };\n}\n"],"names":["s","g","S","m"],"mappings":";;;;;;;AAAuM,SAAS,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAACA,YAAC,
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/useMove/index.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\nimport { useEffect, useState, useRef } from 'react';\nimport { clamp } from '../utils';\n\nexport interface UseMovePosition {\n x: number;\n y: number;\n}\n\nexport const clampUseMovePosition = (position: UseMovePosition) => ({\n x: clamp({ min: 0, max: 1, value: position.x }),\n y: clamp({ min: 0, max: 1, value: position.y }),\n});\n\ninterface useMoveHandlers {\n onScrubStart?(): void;\n onScrubEnd?(): void;\n}\n\nexport function useMove<T extends HTMLElement = HTMLDivElement>(\n onChange: (value: UseMovePosition) => void,\n handlers?: useMoveHandlers\n) {\n const ref = useRef<T | null>(null);\n const mounted = useRef<boolean>(false);\n const isSliding = useRef(false);\n const frame = useRef(0);\n const [active, setActive] = useState(false);\n\n useEffect(() => {\n mounted.current = true;\n }, []);\n\n useEffect(() => {\n const onScrub = ({ x, y }: UseMovePosition) => {\n cancelAnimationFrame(frame.current);\n\n frame.current = requestAnimationFrame(() => {\n if (mounted.current && ref.current) {\n ref.current.style.userSelect = 'none';\n const rect = ref.current.getBoundingClientRect();\n\n if (rect.width && rect.height) {\n onChange({\n x: clamp({ value: (x - rect.left) / rect.width, min: 0, max: 1 }),\n y: clamp({ value: (y - rect.top) / rect.height, min: 0, max: 1 }),\n });\n }\n }\n });\n };\n\n const bindEvents = () => {\n document.addEventListener('mousemove', onMouseMove);\n document.addEventListener('mouseup', stopScrubbing);\n document.addEventListener('touchmove', onTouchMove);\n document.addEventListener('touchend', stopScrubbing);\n };\n\n const unbindEvents = () => {\n document.removeEventListener('mousemove', onMouseMove);\n document.removeEventListener('mouseup', stopScrubbing);\n document.removeEventListener('touchmove', onTouchMove);\n document.removeEventListener('touchend', stopScrubbing);\n };\n\n const startScrubbing = () => {\n if (!isSliding.current && mounted.current) {\n isSliding.current = true;\n typeof handlers?.onScrubStart === 'function' && handlers.onScrubStart();\n setActive(true);\n bindEvents();\n }\n };\n\n const stopScrubbing = () => {\n if (isSliding.current && mounted.current) {\n isSliding.current = false;\n typeof handlers?.onScrubEnd === 'function' && handlers.onScrubEnd();\n setActive(false);\n unbindEvents();\n }\n };\n\n const onMouseDown = (event: MouseEvent) => {\n startScrubbing();\n onMouseMove(event);\n };\n\n const onMouseMove = (event: MouseEvent) => onScrub({ x: event.clientX, y: event.clientY });\n\n const onTouchStart = (event: TouchEvent) => {\n startScrubbing();\n event?.preventDefault();\n onTouchMove(event);\n };\n\n const onTouchMove = (event: TouchEvent) => {\n event?.preventDefault();\n onScrub({ x: event.changedTouches[0].clientX, y: event.changedTouches[0].clientY });\n };\n\n ref.current.addEventListener('mousedown', onMouseDown);\n ref.current.addEventListener('touchstart', onTouchStart);\n\n return () => {\n if (ref.current) {\n ref.current.removeEventListener('mousedown', onMouseDown);\n ref.current.removeEventListener('touchstart', onTouchStart);\n }\n };\n }, [ref.current]);\n\n return { ref, active };\n}\n"],"names":["s","g","S","m"],"mappings":"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"}
|
package/cjs/usePrevious/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var u=require("react");function t(e){const r=u.useRef();return u.useEffect(()=>{r.current=e},[e]),r.current}exports.usePrevious=t;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var u=require("react");function t(e){const r=u.useRef(void 0);return u.useEffect(()=>{r.current=e},[e]),r.current}exports.usePrevious=t;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/usePrevious/index.ts"],"sourcesContent":["import { useRef, useEffect } from 'react';\n\nexport function usePrevious<T>(value: T): T {\n const ref: any = useRef<T>();\n // Store current value in ref\n useEffect(() => {\n ref.current = value;\n }, [value]);\n\n return ref.current;\n}\n"],"names":["
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/usePrevious/index.ts"],"sourcesContent":["import { useRef, useEffect } from 'react';\n\nexport function usePrevious<T>(value: T): T {\n const ref: any = useRef<T | undefined>(undefined);\n // Store current value in ref\n useEffect(() => {\n ref.current = value;\n }, [value]);\n\n return ref.current;\n}\n"],"names":["n","t"],"mappings":";;;;;;AAAqD,SAAS,WAAW,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAACA,YAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAOC,eAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/useScrollLock/index.ts"],"sourcesContent":["import { useEffect, useRef, useState } from
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/useScrollLock/index.ts"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\n\nexport function useScrollLock(lock?: boolean) {\n const [scrollLocked, setScrollLocked] = useState(lock || false);\n\n // value is stored to prevent body overflow styles override with initial useScrollLock(false)\n const locked = useRef(false);\n\n // after scroll is unlocked body overflow style returns to the previous known value\n const bodyOverflow = useRef<React.CSSProperties['overflow']>(null);\n\n const unlockScroll = () => {\n if (locked.current) {\n locked.current = false;\n document.body.style.overflow = bodyOverflow.current || '';\n }\n };\n\n const lockScroll = () => {\n locked.current = true;\n bodyOverflow.current = document.body.style.overflow;\n document.body.style.overflow = 'hidden';\n };\n\n useEffect(() => {\n if (scrollLocked) {\n lockScroll();\n } else {\n unlockScroll();\n }\n\n return unlockScroll;\n }, [scrollLocked]);\n\n useEffect(() => {\n if (lock !== undefined) {\n setScrollLocked(lock);\n }\n }, [lock]);\n\n useEffect(() => {\n if (lock === undefined && typeof window !== 'undefined') {\n window.document.body.style.overflow === 'hidden' && setScrollLocked(true);\n }\n }, [setScrollLocked]);\n\n return [scrollLocked, setScrollLocked] as const;\n}\n"],"names":["f","d","n"],"mappings":";;;;;;AAAmE,SAAS,aAAa,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAACA,cAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAACC,YAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAACA,YAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,EAAE,EAAE,EAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,SAAQ,CAAC,CAAC,OAAOC,eAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAACA,eAAC,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAACA,eAAC,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,EAAE,OAAO,MAAM,EAAE,WAAW,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{useRef as a,useEffect as i}from"react";const u=["mousedown","touchstart"];function f(r,
|
|
1
|
+
import{useRef as a,useEffect as i}from"react";const u=["mousedown","touchstart"];function f(r,c,n){const t=a(null);return i(()=>{const o=e=>{Array.isArray(n)?n.every(s=>!!s&&!s.contains(e.target))&&r():t.current&&!t.current.contains(e.target)&&r()};return(c||u).forEach(e=>document.addEventListener(e,o)),()=>{(c||u).forEach(e=>document.removeEventListener(e,o))}},[t,r,n]),t}export{f as useClickOutside};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/useClickOutside/index.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\n\nconst DEFAULT_EVENTS = ['mousedown', 'touchstart'];\n\nexport function useClickOutside<T extends HTMLElement = any>(\n handler: () => void,\n events?: string[] | null,\n nodes?: HTMLElement[]\n) {\n const ref = useRef<T>();\n\n useEffect(() => {\n const listener = (event: any) => {\n if (Array.isArray(nodes)) {\n const shouldTrigger = nodes.every((node) => !!node && !node.contains(event.target));\n shouldTrigger && handler();\n } else if (ref.current && !ref.current.contains(event.target)) {\n handler();\n }\n };\n\n (events || DEFAULT_EVENTS).forEach((fn) => document.addEventListener(fn, listener));\n\n return () => {\n (events || DEFAULT_EVENTS).forEach((fn) => document.removeEventListener(fn, listener));\n };\n }, [ref, handler, nodes]);\n\n return ref;\n}\n"],"names":["a","
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/useClickOutside/index.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\n\nconst DEFAULT_EVENTS = ['mousedown', 'touchstart'];\n\nexport function useClickOutside<T extends HTMLElement = any>(\n handler: () => void,\n events?: string[] | null,\n nodes?: HTMLElement[]\n) {\n const ref = useRef<T | null>(null);\n\n useEffect(() => {\n const listener = (event: any) => {\n if (Array.isArray(nodes)) {\n const shouldTrigger = nodes.every((node) => !!node && !node.contains(event.target));\n shouldTrigger && handler();\n } else if (ref.current && !ref.current.contains(event.target)) {\n handler();\n }\n };\n\n (events || DEFAULT_EVENTS).forEach((fn) => document.addEventListener(fn, listener));\n\n return () => {\n (events || DEFAULT_EVENTS).forEach((fn) => document.removeEventListener(fn, listener));\n };\n }, [ref, handler, nodes]);\n\n return ref;\n}\n"],"names":["a","i"],"mappings":";;AAA8C,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,YAAY,CAAC,CAAQ,SAAS,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAACA,MAAC,CAAC,IAAI,CAAC,CAAC,OAAOC,SAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,GAAE,CAAC,CAAC,OAAM,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,QAAQ,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,QAAQ,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{useState as c,useRef as a,useEffect as u}from"react";function d(e,n){try{return e.addEventListener("change",n),()=>e.removeEventListener("change",n)}catch(t){return e.addListener(n),()=>e.removeListener(n)}}function o(e){return typeof window!="undefined"&&"matchMedia"in window?window.matchMedia(e).matches:!1}function s(e){const[n,t]=c(o(e)),r=a();return u(()=>{if("matchMedia"in window)return r.current=window.matchMedia(e),t(r.current.matches),d(r.current,i=>t(i.matches))},[e]),n}export{s as useMediaQuery};
|
|
1
|
+
import{useState as c,useRef as a,useEffect as u}from"react";function d(e,n){try{return e.addEventListener("change",n),()=>e.removeEventListener("change",n)}catch(t){return e.addListener(n),()=>e.removeListener(n)}}function o(e){return typeof window!="undefined"&&"matchMedia"in window?window.matchMedia(e).matches:!1}function s(e){const[n,t]=c(o(e)),r=a(null);return u(()=>{if("matchMedia"in window)return r.current=window.matchMedia(e),t(r.current.matches),d(r.current,i=>t(i.matches))},[e]),n}export{s as useMediaQuery};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/useMediaQuery/index.ts"],"sourcesContent":["import { useState, useEffect, useRef } from 'react';\n\ntype MediaQueryCallback = (event: { matches: boolean; media: string }) => void;\n\n/**\n * Older versions of Safari (shipped withCatalina and before) do not support addEventListener on matchMedia\n * https://stackoverflow.com/questions/56466261/matchmedia-addlistener-marked-as-deprecated-addeventlistener-equivalent\n * */\nfunction attachMediaListener(query: MediaQueryList, callback: MediaQueryCallback) {\n try {\n query.addEventListener('change', callback);\n return () => query.removeEventListener('change', callback);\n } catch (e) {\n query.addListener(callback);\n return () => query.removeListener(callback);\n }\n}\n\nfunction getInitialValue(query: string) {\n if (typeof window !== 'undefined' && 'matchMedia' in window) {\n return window.matchMedia(query).matches;\n }\n return false;\n}\n\nexport function useMediaQuery(query: string) {\n const [matches, setMatches] = useState(getInitialValue(query));\n const queryRef = useRef<MediaQueryList>();\n\n // eslint-disable-next-line consistent-return\n useEffect(() => {\n if ('matchMedia' in window) {\n queryRef.current = window.matchMedia(query);\n setMatches(queryRef.current.matches);\n return attachMediaListener(queryRef.current, (event) => setMatches(event.matches));\n }\n }, [query]);\n\n return matches;\n}\n"],"names":["a","d","s"],"mappings":";;AAA4D,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,OAAO,MAAM,EAAE,WAAW,EAAE,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAQ,SAAS,aAAa,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAACA,QAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAACC,MAAC,
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/useMediaQuery/index.ts"],"sourcesContent":["import { useState, useEffect, useRef } from 'react';\n\ntype MediaQueryCallback = (event: { matches: boolean; media: string }) => void;\n\n/**\n * Older versions of Safari (shipped withCatalina and before) do not support addEventListener on matchMedia\n * https://stackoverflow.com/questions/56466261/matchmedia-addlistener-marked-as-deprecated-addeventlistener-equivalent\n * */\nfunction attachMediaListener(query: MediaQueryList, callback: MediaQueryCallback) {\n try {\n query.addEventListener('change', callback);\n return () => query.removeEventListener('change', callback);\n } catch (e) {\n query.addListener(callback);\n return () => query.removeListener(callback);\n }\n}\n\nfunction getInitialValue(query: string) {\n if (typeof window !== 'undefined' && 'matchMedia' in window) {\n return window.matchMedia(query).matches;\n }\n return false;\n}\n\nexport function useMediaQuery(query: string) {\n const [matches, setMatches] = useState(getInitialValue(query));\n const queryRef = useRef<MediaQueryList | null>(null);\n\n // eslint-disable-next-line consistent-return\n useEffect(() => {\n if ('matchMedia' in window) {\n queryRef.current = window.matchMedia(query);\n setMatches(queryRef.current.matches);\n return attachMediaListener(queryRef.current, (event) => setMatches(event.matches));\n }\n }, [query]);\n\n return matches;\n}\n"],"names":["a","d","s"],"mappings":";;AAA4D,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,OAAO,MAAM,EAAE,WAAW,EAAE,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAQ,SAAS,aAAa,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAACA,QAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAACC,MAAC,CAAC,IAAI,CAAC,CAAC,OAAOC,SAAC,CAAC,IAAI,CAAC,GAAG,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;;;;"}
|
package/esm/useMove/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{useRef as i,useState as b,useEffect as E}from"react";import{clamp as L}from"../utils/index.js";function w(p,n){const t=i(),u=i(!1),c=i(!1),s=i(0),[x,v]=b(!1);return E(()=>{u.current=!0},[]),E(()=>{const a=({x:e,y:g})=>{cancelAnimationFrame(s.current),s.current=requestAnimationFrame(()=>{if(u.current&&t.current){t.current.style.userSelect="none";const r=t.current.getBoundingClientRect();r.width&&r.height&&p({x:L({value:(e-r.left)/r.width,min:0,max:1}),y:L({value:(g-r.top)/r.height,min:0,max:1})})}})},S=()=>{document.addEventListener("mousemove",m),document.addEventListener("mouseup",o),document.addEventListener("touchmove",d),document.addEventListener("touchend",o)},y=()=>{document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",o),document.removeEventListener("touchmove",d),document.removeEventListener("touchend",o)},l=()=>{!c.current&&u.current&&(c.current=!0,typeof(n==null?void 0:n.onScrubStart)=="function"&&n.onScrubStart(),v(!0),S())},o=()=>{c.current&&u.current&&(c.current=!1,typeof(n==null?void 0:n.onScrubEnd)=="function"&&n.onScrubEnd(),v(!1),y())},f=e=>{l(),m(e)},m=e=>a({x:e.clientX,y:e.clientY}),h=e=>{l(),e==null||e.preventDefault(),d(e)},d=e=>{e==null||e.preventDefault(),a({x:e.changedTouches[0].clientX,y:e.changedTouches[0].clientY})};return t.current.addEventListener("mousedown",f),t.current.addEventListener("touchstart",h),()=>{t.current&&(t.current.removeEventListener("mousedown",f),t.current.removeEventListener("touchstart",h))}},[t.current]),{ref:t,active:x}}export{w as useMove};
|
|
1
|
+
import{useRef as i,useState as b,useEffect as E}from"react";import{clamp as L}from"../utils/index.js";function w(p,n){const t=i(null),u=i(!1),c=i(!1),s=i(0),[x,v]=b(!1);return E(()=>{u.current=!0},[]),E(()=>{const a=({x:e,y:g})=>{cancelAnimationFrame(s.current),s.current=requestAnimationFrame(()=>{if(u.current&&t.current){t.current.style.userSelect="none";const r=t.current.getBoundingClientRect();r.width&&r.height&&p({x:L({value:(e-r.left)/r.width,min:0,max:1}),y:L({value:(g-r.top)/r.height,min:0,max:1})})}})},S=()=>{document.addEventListener("mousemove",m),document.addEventListener("mouseup",o),document.addEventListener("touchmove",d),document.addEventListener("touchend",o)},y=()=>{document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",o),document.removeEventListener("touchmove",d),document.removeEventListener("touchend",o)},l=()=>{!c.current&&u.current&&(c.current=!0,typeof(n==null?void 0:n.onScrubStart)=="function"&&n.onScrubStart(),v(!0),S())},o=()=>{c.current&&u.current&&(c.current=!1,typeof(n==null?void 0:n.onScrubEnd)=="function"&&n.onScrubEnd(),v(!1),y())},f=e=>{l(),m(e)},m=e=>a({x:e.clientX,y:e.clientY}),h=e=>{l(),e==null||e.preventDefault(),d(e)},d=e=>{e==null||e.preventDefault(),a({x:e.changedTouches[0].clientX,y:e.changedTouches[0].clientY})};return t.current.addEventListener("mousedown",f),t.current.addEventListener("touchstart",h),()=>{t.current&&(t.current.removeEventListener("mousedown",f),t.current.removeEventListener("touchstart",h))}},[t.current]),{ref:t,active:x}}export{w as useMove};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/esm/useMove/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/useMove/index.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\nimport { useEffect, useState, useRef } from 'react';\nimport { clamp } from '../utils';\n\nexport interface UseMovePosition {\n x: number;\n y: number;\n}\n\nexport const clampUseMovePosition = (position: UseMovePosition) => ({\n x: clamp({ min: 0, max: 1, value: position.x }),\n y: clamp({ min: 0, max: 1, value: position.y }),\n});\n\ninterface useMoveHandlers {\n onScrubStart?(): void;\n onScrubEnd?(): void;\n}\n\nexport function useMove<T extends HTMLElement = HTMLDivElement>(\n onChange: (value: UseMovePosition) => void,\n handlers?: useMoveHandlers\n) {\n const ref = useRef<T>();\n const mounted = useRef<boolean>(false);\n const isSliding = useRef(false);\n const frame = useRef(0);\n const [active, setActive] = useState(false);\n\n useEffect(() => {\n mounted.current = true;\n }, []);\n\n useEffect(() => {\n const onScrub = ({ x, y }: UseMovePosition) => {\n cancelAnimationFrame(frame.current);\n\n frame.current = requestAnimationFrame(() => {\n if (mounted.current && ref.current) {\n ref.current.style.userSelect = 'none';\n const rect = ref.current.getBoundingClientRect();\n\n if (rect.width && rect.height) {\n onChange({\n x: clamp({ value: (x - rect.left) / rect.width, min: 0, max: 1 }),\n y: clamp({ value: (y - rect.top) / rect.height, min: 0, max: 1 }),\n });\n }\n }\n });\n };\n\n const bindEvents = () => {\n document.addEventListener('mousemove', onMouseMove);\n document.addEventListener('mouseup', stopScrubbing);\n document.addEventListener('touchmove', onTouchMove);\n document.addEventListener('touchend', stopScrubbing);\n };\n\n const unbindEvents = () => {\n document.removeEventListener('mousemove', onMouseMove);\n document.removeEventListener('mouseup', stopScrubbing);\n document.removeEventListener('touchmove', onTouchMove);\n document.removeEventListener('touchend', stopScrubbing);\n };\n\n const startScrubbing = () => {\n if (!isSliding.current && mounted.current) {\n isSliding.current = true;\n typeof handlers?.onScrubStart === 'function' && handlers.onScrubStart();\n setActive(true);\n bindEvents();\n }\n };\n\n const stopScrubbing = () => {\n if (isSliding.current && mounted.current) {\n isSliding.current = false;\n typeof handlers?.onScrubEnd === 'function' && handlers.onScrubEnd();\n setActive(false);\n unbindEvents();\n }\n };\n\n const onMouseDown = (event: MouseEvent) => {\n startScrubbing();\n onMouseMove(event);\n };\n\n const onMouseMove = (event: MouseEvent) => onScrub({ x: event.clientX, y: event.clientY });\n\n const onTouchStart = (event: TouchEvent) => {\n startScrubbing();\n event?.preventDefault();\n onTouchMove(event);\n };\n\n const onTouchMove = (event: TouchEvent) => {\n event?.preventDefault();\n onScrub({ x: event.changedTouches[0].clientX, y: event.changedTouches[0].clientY });\n };\n\n ref.current.addEventListener('mousedown', onMouseDown);\n ref.current.addEventListener('touchstart', onTouchStart);\n\n return () => {\n if (ref.current) {\n ref.current.removeEventListener('mousedown', onMouseDown);\n ref.current.removeEventListener('touchstart', onTouchStart);\n }\n };\n }, [ref.current]);\n\n return { ref, active };\n}\n"],"names":["s","g","S","m"],"mappings":";;;AAAuM,SAAS,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAACA,MAAC,
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/useMove/index.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\nimport { useEffect, useState, useRef } from 'react';\nimport { clamp } from '../utils';\n\nexport interface UseMovePosition {\n x: number;\n y: number;\n}\n\nexport const clampUseMovePosition = (position: UseMovePosition) => ({\n x: clamp({ min: 0, max: 1, value: position.x }),\n y: clamp({ min: 0, max: 1, value: position.y }),\n});\n\ninterface useMoveHandlers {\n onScrubStart?(): void;\n onScrubEnd?(): void;\n}\n\nexport function useMove<T extends HTMLElement = HTMLDivElement>(\n onChange: (value: UseMovePosition) => void,\n handlers?: useMoveHandlers\n) {\n const ref = useRef<T | null>(null);\n const mounted = useRef<boolean>(false);\n const isSliding = useRef(false);\n const frame = useRef(0);\n const [active, setActive] = useState(false);\n\n useEffect(() => {\n mounted.current = true;\n }, []);\n\n useEffect(() => {\n const onScrub = ({ x, y }: UseMovePosition) => {\n cancelAnimationFrame(frame.current);\n\n frame.current = requestAnimationFrame(() => {\n if (mounted.current && ref.current) {\n ref.current.style.userSelect = 'none';\n const rect = ref.current.getBoundingClientRect();\n\n if (rect.width && rect.height) {\n onChange({\n x: clamp({ value: (x - rect.left) / rect.width, min: 0, max: 1 }),\n y: clamp({ value: (y - rect.top) / rect.height, min: 0, max: 1 }),\n });\n }\n }\n });\n };\n\n const bindEvents = () => {\n document.addEventListener('mousemove', onMouseMove);\n document.addEventListener('mouseup', stopScrubbing);\n document.addEventListener('touchmove', onTouchMove);\n document.addEventListener('touchend', stopScrubbing);\n };\n\n const unbindEvents = () => {\n document.removeEventListener('mousemove', onMouseMove);\n document.removeEventListener('mouseup', stopScrubbing);\n document.removeEventListener('touchmove', onTouchMove);\n document.removeEventListener('touchend', stopScrubbing);\n };\n\n const startScrubbing = () => {\n if (!isSliding.current && mounted.current) {\n isSliding.current = true;\n typeof handlers?.onScrubStart === 'function' && handlers.onScrubStart();\n setActive(true);\n bindEvents();\n }\n };\n\n const stopScrubbing = () => {\n if (isSliding.current && mounted.current) {\n isSliding.current = false;\n typeof handlers?.onScrubEnd === 'function' && handlers.onScrubEnd();\n setActive(false);\n unbindEvents();\n }\n };\n\n const onMouseDown = (event: MouseEvent) => {\n startScrubbing();\n onMouseMove(event);\n };\n\n const onMouseMove = (event: MouseEvent) => onScrub({ x: event.clientX, y: event.clientY });\n\n const onTouchStart = (event: TouchEvent) => {\n startScrubbing();\n event?.preventDefault();\n onTouchMove(event);\n };\n\n const onTouchMove = (event: TouchEvent) => {\n event?.preventDefault();\n onScrub({ x: event.changedTouches[0].clientX, y: event.changedTouches[0].clientY });\n };\n\n ref.current.addEventListener('mousedown', onMouseDown);\n ref.current.addEventListener('touchstart', onTouchStart);\n\n return () => {\n if (ref.current) {\n ref.current.removeEventListener('mousedown', onMouseDown);\n ref.current.removeEventListener('touchstart', onTouchStart);\n }\n };\n }, [ref.current]);\n\n return { ref, active };\n}\n"],"names":["s","g","S","m"],"mappings":"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"}
|
package/esm/usePrevious/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{useRef as t,useEffect as u}from"react";function
|
|
1
|
+
import{useRef as t,useEffect as u}from"react";function o(r){const e=t(void 0);return u(()=>{e.current=r},[r]),e.current}export{o as usePrevious};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/usePrevious/index.ts"],"sourcesContent":["import { useRef, useEffect } from 'react';\n\nexport function usePrevious<T>(value: T): T {\n const ref: any = useRef<T>();\n // Store current value in ref\n useEffect(() => {\n ref.current = value;\n }, [value]);\n\n return ref.current;\n}\n"],"names":["
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/usePrevious/index.ts"],"sourcesContent":["import { useRef, useEffect } from 'react';\n\nexport function usePrevious<T>(value: T): T {\n const ref: any = useRef<T | undefined>(undefined);\n // Store current value in ref\n useEffect(() => {\n ref.current = value;\n }, [value]);\n\n return ref.current;\n}\n"],"names":["n","t"],"mappings":";;AAAqD,SAAS,WAAW,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAACA,MAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAOC,SAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/useScrollLock/index.ts"],"sourcesContent":["import { useEffect, useRef, useState } from
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/useScrollLock/index.ts"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\n\nexport function useScrollLock(lock?: boolean) {\n const [scrollLocked, setScrollLocked] = useState(lock || false);\n\n // value is stored to prevent body overflow styles override with initial useScrollLock(false)\n const locked = useRef(false);\n\n // after scroll is unlocked body overflow style returns to the previous known value\n const bodyOverflow = useRef<React.CSSProperties['overflow']>(null);\n\n const unlockScroll = () => {\n if (locked.current) {\n locked.current = false;\n document.body.style.overflow = bodyOverflow.current || '';\n }\n };\n\n const lockScroll = () => {\n locked.current = true;\n bodyOverflow.current = document.body.style.overflow;\n document.body.style.overflow = 'hidden';\n };\n\n useEffect(() => {\n if (scrollLocked) {\n lockScroll();\n } else {\n unlockScroll();\n }\n\n return unlockScroll;\n }, [scrollLocked]);\n\n useEffect(() => {\n if (lock !== undefined) {\n setScrollLocked(lock);\n }\n }, [lock]);\n\n useEffect(() => {\n if (lock === undefined && typeof window !== 'undefined') {\n window.document.body.style.overflow === 'hidden' && setScrollLocked(true);\n }\n }, [setScrollLocked]);\n\n return [scrollLocked, setScrollLocked] as const;\n}\n"],"names":["f","d","n"],"mappings":";;AAAmE,SAAS,aAAa,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAACA,QAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAACC,MAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAACA,MAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,EAAE,EAAE,EAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,SAAQ,CAAC,CAAC,OAAOC,SAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAACA,SAAC,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAACA,SAAC,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,EAAE,OAAO,MAAM,EAAE,WAAW,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;;;;"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export declare function useClickOutside<T extends HTMLElement = any>(handler: () => void, events?: string[] | null, nodes?: HTMLElement[]): import("react").
|
|
2
|
+
export declare function useClickOutside<T extends HTMLElement = any>(handler: () => void, events?: string[] | null, nodes?: HTMLElement[]): import("react").RefObject<T>;
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useClickOutside/index.ts"],"names":[],"mappings":";AAIA,wBAAgB,eAAe,CAAC,CAAC,SAAS,WAAW,GAAG,GAAG,EACzD,OAAO,EAAE,MAAM,IAAI,EACnB,MAAM,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,EACxB,KAAK,CAAC,EAAE,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useClickOutside/index.ts"],"names":[],"mappings":";AAIA,wBAAgB,eAAe,CAAC,CAAC,SAAS,WAAW,GAAG,GAAG,EACzD,OAAO,EAAE,MAAM,IAAI,EACnB,MAAM,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,EACxB,KAAK,CAAC,EAAE,WAAW,EAAE,gCAsBtB"}
|
package/lib/useHover/index.d.ts
CHANGED
package/lib/useMove/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ interface useMoveHandlers {
|
|
|
11
11
|
onScrubEnd?(): void;
|
|
12
12
|
}
|
|
13
13
|
export declare function useMove<T extends HTMLElement = HTMLDivElement>(onChange: (value: UseMovePosition) => void, handlers?: useMoveHandlers): {
|
|
14
|
-
ref: import("react").
|
|
14
|
+
ref: import("react").RefObject<T>;
|
|
15
15
|
active: boolean;
|
|
16
16
|
};
|
|
17
17
|
export {};
|