@kubed/hooks 0.0.18 → 0.2.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/cjs/index.js +1 -1
  2. package/cjs/useClickOutside/index.js +1 -1
  3. package/cjs/useClickOutside/index.js.map +1 -1
  4. package/cjs/useClipboard/index.js +1 -1
  5. package/cjs/useClipboard/index.js.map +1 -1
  6. package/cjs/useDebouncedValue/index.js +1 -1
  7. package/cjs/useDebouncedValue/index.js.map +1 -1
  8. package/cjs/useDidMount/index.js +1 -1
  9. package/cjs/useDidMount/index.js.map +1 -1
  10. package/cjs/useDidUpdate/index.js +1 -1
  11. package/cjs/useDidUpdate/index.js.map +1 -1
  12. package/cjs/useDisclosure/index.js +1 -1
  13. package/cjs/useDisclosure/index.js.map +1 -1
  14. package/cjs/useForceUpdate/index.js +1 -1
  15. package/cjs/useForceUpdate/index.js.map +1 -1
  16. package/cjs/useHotkeys/index.js +1 -1
  17. package/cjs/useHotkeys/index.js.map +1 -1
  18. package/cjs/useHotkeys/parseHotkey.js +1 -1
  19. package/cjs/useHotkeys/parseHotkey.js.map +1 -1
  20. package/cjs/useHover/index.js +1 -1
  21. package/cjs/useHover/index.js.map +1 -1
  22. package/cjs/useId/index.js +1 -1
  23. package/cjs/useId/index.js.map +1 -1
  24. package/cjs/useLocalStorage/index.js +1 -1
  25. package/cjs/useLocalStorage/index.js.map +1 -1
  26. package/cjs/useMediaQuery/index.js +1 -1
  27. package/cjs/useMediaQuery/index.js.map +1 -1
  28. package/cjs/useMergedRef/index.js +1 -1
  29. package/cjs/useMergedRef/index.js.map +1 -1
  30. package/cjs/useMove/index.js +1 -1
  31. package/cjs/useMove/index.js.map +1 -1
  32. package/cjs/usePrevious/index.js +1 -1
  33. package/cjs/usePrevious/index.js.map +1 -1
  34. package/cjs/useQueue/index.js +1 -1
  35. package/cjs/useQueue/index.js.map +1 -1
  36. package/cjs/useReducedMotion/index.js +1 -1
  37. package/cjs/useReducedMotion/index.js.map +1 -1
  38. package/cjs/useScrollLock/index.js +1 -1
  39. package/cjs/useScrollLock/index.js.map +1 -1
  40. package/cjs/useToggle/index.js +1 -1
  41. package/cjs/useToggle/index.js.map +1 -1
  42. package/cjs/useUncontrolled/index.js +1 -1
  43. package/cjs/useUncontrolled/index.js.map +1 -1
  44. package/cjs/useUnmount/index.js +1 -1
  45. package/cjs/useUnmount/index.js.map +1 -1
  46. package/cjs/useWindowEvent/index.js +1 -1
  47. package/cjs/useWindowEvent/index.js.map +1 -1
  48. package/cjs/useWindowResize/index.js +1 -1
  49. package/cjs/useWindowResize/index.js.map +1 -1
  50. package/cjs/utils/index.js +1 -1
  51. package/cjs/utils/index.js.map +1 -1
  52. package/esm/index.js +1 -1
  53. package/esm/useClickOutside/index.js +1 -1
  54. package/esm/useClickOutside/index.js.map +1 -1
  55. package/esm/useClipboard/index.js +1 -1
  56. package/esm/useClipboard/index.js.map +1 -1
  57. package/esm/useDebouncedValue/index.js +1 -1
  58. package/esm/useDebouncedValue/index.js.map +1 -1
  59. package/esm/useDidMount/index.js +1 -1
  60. package/esm/useDidMount/index.js.map +1 -1
  61. package/esm/useDidUpdate/index.js +1 -1
  62. package/esm/useDidUpdate/index.js.map +1 -1
  63. package/esm/useDisclosure/index.js +1 -1
  64. package/esm/useDisclosure/index.js.map +1 -1
  65. package/esm/useForceUpdate/index.js +1 -1
  66. package/esm/useForceUpdate/index.js.map +1 -1
  67. package/esm/useHotkeys/index.js +1 -1
  68. package/esm/useHotkeys/index.js.map +1 -1
  69. package/esm/useHotkeys/parseHotkey.js +1 -1
  70. package/esm/useHotkeys/parseHotkey.js.map +1 -1
  71. package/esm/useHover/index.js +1 -1
  72. package/esm/useHover/index.js.map +1 -1
  73. package/esm/useId/index.js +1 -1
  74. package/esm/useId/index.js.map +1 -1
  75. package/esm/useLocalStorage/index.js +1 -1
  76. package/esm/useLocalStorage/index.js.map +1 -1
  77. package/esm/useMediaQuery/index.js +1 -1
  78. package/esm/useMediaQuery/index.js.map +1 -1
  79. package/esm/useMergedRef/index.js +1 -1
  80. package/esm/useMergedRef/index.js.map +1 -1
  81. package/esm/useMove/index.js +1 -1
  82. package/esm/useMove/index.js.map +1 -1
  83. package/esm/usePrevious/index.js +1 -1
  84. package/esm/usePrevious/index.js.map +1 -1
  85. package/esm/useQueue/index.js +1 -1
  86. package/esm/useQueue/index.js.map +1 -1
  87. package/esm/useReducedMotion/index.js.map +1 -1
  88. package/esm/useScrollLock/index.js +1 -1
  89. package/esm/useScrollLock/index.js.map +1 -1
  90. package/esm/useToggle/index.js +1 -1
  91. package/esm/useToggle/index.js.map +1 -1
  92. package/esm/useUncontrolled/index.js +1 -1
  93. package/esm/useUncontrolled/index.js.map +1 -1
  94. package/esm/useUnmount/index.js +1 -1
  95. package/esm/useUnmount/index.js.map +1 -1
  96. package/esm/useWindowEvent/index.js +1 -1
  97. package/esm/useWindowEvent/index.js.map +1 -1
  98. package/esm/useWindowResize/index.js +1 -1
  99. package/esm/useWindowResize/index.js.map +1 -1
  100. package/esm/utils/index.js +1 -1
  101. package/esm/utils/index.js.map +1 -1
  102. package/lib/useHover/index.d.ts +0 -1
  103. package/lib/useHover/index.d.ts.map +1 -1
  104. package/lib/useMove/index.d.ts +0 -1
  105. package/lib/useMove/index.d.ts.map +1 -1
  106. package/package.json +10 -12
  107. package/CHANGELOG.md +0 -108
package/cjs/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var index$n=require("./utils/index.js"),index=require("./useId/index.js"),index$1=require("./useToggle/index.js"),index$2=require("./useUncontrolled/index.js"),index$3=require("./useMediaQuery/index.js"),index$4=require("./useReducedMotion/index.js"),index$5=require("./useWindowEvent/index.js"),index$6=require("./useLocalStorage/index.js"),index$7=require("./useForceUpdate/index.js"),index$8=require("./useClipboard/index.js"),index$9=require("./useQueue/index.js"),index$a=require("./useClickOutside/index.js"),index$b=require("./useMove/index.js"),index$c=require("./useHotkeys/index.js"),index$d=require("./useMergedRef/index.js"),index$e=require("./useDebouncedValue/index.js"),index$f=require("./useDidMount/index.js"),index$g=require("./useDidUpdate/index.js"),index$h=require("./useUnmount/index.js"),index$i=require("./usePrevious/index.js"),index$j=require("./useScrollLock/index.js"),index$k=require("./useHover/index.js"),index$l=require("./useWindowResize/index.js"),index$m=require("./useDisclosure/index.js");exports.assignRef=index$n.assignRef,exports.clamp=index$n.clamp,exports.randomId=index$n.randomId,exports.useId=index.useId,exports.useBooleanToggle=index$1.useBooleanToggle,exports.useToggle=index$1.useToggle,exports.useUncontrolled=index$2.useUncontrolled,exports.useMediaQuery=index$3.useMediaQuery,exports.useReducedMotion=index$4.useReducedMotion,exports.useWindowEvent=index$5.useWindowEvent,exports.useLocalStorage=index$6.useLocalStorage,exports.useForceUpdate=index$7.useForceUpdate,exports.useClipboard=index$8.useClipboard,exports.useQueue=index$9.useQueue,exports.useClickOutside=index$a.useClickOutside,exports.useMove=index$b.useMove,exports.useHotkeys=index$c.useHotkeys,exports.mergeRefs=index$d.mergeRefs,exports.useMergedRef=index$d.useMergedRef,exports.useDebouncedValue=index$e.useDebouncedValue,exports.useDidMount=index$f.useDidMount,exports.useDidUpdate=index$g.useDidUpdate,exports.useUnmount=index$h.useUnmount,exports.usePrevious=index$i.usePrevious,exports.useScrollLock=index$j.useScrollLock,exports.useHover=index$k.useHover,exports.useWindowResize=index$l.useWindowResize,exports.useDisclosure=index$m.useDisclosure;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./utils/index.js"),i=require("./useId/index.js"),u=require("./useToggle/index.js"),r=require("./useUncontrolled/index.js"),d=require("./useMediaQuery/index.js"),n=require("./useReducedMotion/index.js"),o=require("./useWindowEvent/index.js"),a=require("./useLocalStorage/index.js"),x=require("./useForceUpdate/index.js"),l=require("./useClipboard/index.js"),v=require("./useQueue/index.js"),t=require("./useClickOutside/index.js"),c=require("./useMove/index.js"),j=require("./useHotkeys/index.js"),s=require("./useMergedRef/index.js"),q=require("./useDebouncedValue/index.js"),$=require("./useDidMount/index.js"),g=require("./useDidUpdate/index.js"),M=require("./useUnmount/index.js"),R=require("./usePrevious/index.js"),p=require("./useScrollLock/index.js"),D=require("./useHover/index.js"),U=require("./useWindowResize/index.js"),k=require("./useDisclosure/index.js");exports.assignRef=e.assignRef,exports.clamp=e.clamp,exports.randomId=e.randomId,exports.useId=i.useId,exports.useBooleanToggle=u.useBooleanToggle,exports.useToggle=u.useToggle,exports.useUncontrolled=r.useUncontrolled,exports.useMediaQuery=d.useMediaQuery,exports.useReducedMotion=n.useReducedMotion,exports.useWindowEvent=o.useWindowEvent,exports.useLocalStorage=a.useLocalStorage,exports.useForceUpdate=x.useForceUpdate,exports.useClipboard=l.useClipboard,exports.useQueue=v.useQueue,exports.useClickOutside=t.useClickOutside,exports.useMove=c.useMove,exports.useHotkeys=j.useHotkeys,exports.mergeRefs=s.mergeRefs,exports.useMergedRef=s.useMergedRef,exports.useDebouncedValue=q.useDebouncedValue,exports.useDidMount=$.useDidMount,exports.useDidUpdate=g.useDidUpdate,exports.useUnmount=M.useUnmount,exports.usePrevious=R.usePrevious,exports.useScrollLock=p.useScrollLock,exports.useHover=D.useHover,exports.useWindowResize=U.useWindowResize,exports.useDisclosure=k.useDisclosure;
2
2
  //# sourceMappingURL=index.js.map
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var react=require("react");const DEFAULT_EVENTS=["mousedown","touchstart"];function useClickOutside(t,u,s){const r=react.useRef();return react.useEffect(()=>{const c=e=>{Array.isArray(s)?s.every(i=>!!i&&!i.contains(e.target))&&t():r.current&&!r.current.contains(e.target)&&t()};return(u||DEFAULT_EVENTS).forEach(e=>document.addEventListener(e,c)),()=>{(u||DEFAULT_EVENTS).forEach(e=>document.removeEventListener(e,c))}},[r,t,s]),r}exports.useClickOutside=useClickOutside;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var o=require("react");const a=["mousedown","touchstart"];function i(r,u,s){const t=o.useRef();return o.useEffect(()=>{const c=e=>{Array.isArray(s)?s.every(n=>!!n&&!n.contains(e.target))&&r():t.current&&!t.current.contains(e.target)&&r()};return(u||a).forEach(e=>document.addEventListener(e,c)),()=>{(u||a).forEach(e=>document.removeEventListener(e,c))}},[t,r,s]),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":["useRef","useEffect"],"mappings":";;;;;;AACA,MAAM,cAAc,GAAG,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;AAC5C,SAAS,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE;AACxD,EAAE,MAAM,GAAG,GAAGA,YAAM,EAAE,CAAC;AACvB,EAAEC,eAAS,CAAC,MAAM;AAClB,IAAI,MAAM,QAAQ,GAAG,CAAC,KAAK,KAAK;AAChC,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;AAChC,QAAQ,MAAM,aAAa,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;AAC5F,QAAQ,aAAa,IAAI,OAAO,EAAE,CAAC;AACnC,OAAO,MAAM,IAAI,GAAG,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE;AACrE,QAAQ,OAAO,EAAE,CAAC;AAClB,OAAO;AACP,KAAK,CAAC;AACN,IAAI,CAAC,MAAM,IAAI,cAAc,EAAE,OAAO,CAAC,CAAC,EAAE,KAAK,QAAQ,CAAC,gBAAgB,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC,CAAC;AACxF,IAAI,OAAO,MAAM;AACjB,MAAM,CAAC,MAAM,IAAI,cAAc,EAAE,OAAO,CAAC,CAAC,EAAE,KAAK,QAAQ,CAAC,mBAAmB,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC,CAAC;AAC7F,KAAK,CAAC;AACN,GAAG,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;AAC5B,EAAE,OAAO,GAAG,CAAC;AACb;;;;"}
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","u"],"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,EAAE,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 react=require("react");function useClipboard({timeout:s=2e3}={}){const[a,e]=react.useState(null),[i,t]=react.useState(!1),[o,u]=react.useState(null),c=r=>{clearTimeout(o),u(setTimeout(()=>t(!1),s)),t(r)};return{copy:r=>{"clipboard"in navigator?navigator.clipboard.writeText(r).then(()=>c(!0)).catch(l=>e(l)):e(new Error("useClipboard: navigator.clipboard is not supported"))},reset:()=>{t(!1),e(null),clearTimeout(o)},error:a,copied:i}}exports.useClipboard=useClipboard;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var o=require("react");function p({timeout:i=2e3}={}){const[u,e]=o.useState(null),[l,t]=o.useState(!1),[a,c]=o.useState(null),n=r=>{clearTimeout(a),c(setTimeout(()=>t(!1),i)),t(r)};return{copy:r=>{"clipboard"in navigator?navigator.clipboard.writeText(r).then(()=>n(!0)).catch(s=>e(s)):e(new Error("useClipboard: navigator.clipboard is not supported"))},reset:()=>{t(!1),e(null),clearTimeout(a)},error:u,copied:l}}exports.useClipboard=p;
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/useClipboard/index.ts"],"sourcesContent":["import { useState } from 'react';\n\nexport function useClipboard({ timeout = 2000 } = {}) {\n const [error, setError] = useState<Error>(null);\n const [copied, setCopied] = useState(false);\n const [copyTimeout, setCopyTimeout] = useState(null);\n\n const handleCopyResult = (value: boolean) => {\n clearTimeout(copyTimeout);\n setCopyTimeout(setTimeout(() => setCopied(false), timeout));\n setCopied(value);\n };\n\n const copy = (valueToCopy: any) => {\n if ('clipboard' in navigator) {\n navigator.clipboard\n .writeText(valueToCopy)\n .then(() => handleCopyResult(true))\n .catch((err) => setError(err));\n } else {\n setError(new Error('useClipboard: navigator.clipboard is not supported'));\n }\n };\n\n const reset = () => {\n setCopied(false);\n setError(null);\n clearTimeout(copyTimeout);\n };\n\n return { copy, reset, error, copied };\n}\n"],"names":["useState"],"mappings":";;;;;;AACO,SAAS,YAAY,CAAC,EAAE,OAAO,GAAG,GAAG,EAAE,GAAG,EAAE,EAAE;AACrD,EAAE,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAGA,cAAQ,CAAC,IAAI,CAAC,CAAC;AAC3C,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAGA,cAAQ,CAAC,KAAK,CAAC,CAAC;AAC9C,EAAE,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAGA,cAAQ,CAAC,IAAI,CAAC,CAAC;AACvD,EAAE,MAAM,gBAAgB,GAAG,CAAC,KAAK,KAAK;AACtC,IAAI,YAAY,CAAC,WAAW,CAAC,CAAC;AAC9B,IAAI,cAAc,CAAC,UAAU,CAAC,MAAM,SAAS,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;AAChE,IAAI,SAAS,CAAC,KAAK,CAAC,CAAC;AACrB,GAAG,CAAC;AACJ,EAAE,MAAM,IAAI,GAAG,CAAC,WAAW,KAAK;AAChC,IAAI,IAAI,WAAW,IAAI,SAAS,EAAE;AAClC,MAAM,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,MAAM,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,KAAK,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;AAClH,KAAK,MAAM;AACX,MAAM,QAAQ,CAAC,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC,CAAC;AAChF,KAAK;AACL,GAAG,CAAC;AACJ,EAAE,MAAM,KAAK,GAAG,MAAM;AACtB,IAAI,SAAS,CAAC,KAAK,CAAC,CAAC;AACrB,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC;AACnB,IAAI,YAAY,CAAC,WAAW,CAAC,CAAC;AAC9B,GAAG,CAAC;AACJ,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AACxC;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/useClipboard/index.ts"],"sourcesContent":["import { useState } from 'react';\n\nexport function useClipboard({ timeout = 2000 } = {}) {\n const [error, setError] = useState<Error>(null);\n const [copied, setCopied] = useState(false);\n const [copyTimeout, setCopyTimeout] = useState(null);\n\n const handleCopyResult = (value: boolean) => {\n clearTimeout(copyTimeout);\n setCopyTimeout(setTimeout(() => setCopied(false), timeout));\n setCopied(value);\n };\n\n const copy = (valueToCopy: any) => {\n if ('clipboard' in navigator) {\n navigator.clipboard\n .writeText(valueToCopy)\n .then(() => handleCopyResult(true))\n .catch((err) => setError(err));\n } else {\n setError(new Error('useClipboard: navigator.clipboard is not supported'));\n }\n };\n\n const reset = () => {\n setCopied(false);\n setError(null);\n clearTimeout(copyTimeout);\n };\n\n return { copy, reset, error, copied };\n}\n"],"names":["r"],"mappings":";;;;;;AAAwC,SAAS,YAAY,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAACA,cAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAACA,cAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAACA,cAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,OAAM,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,WAAW,GAAG,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,oDAAoD,CAAC,EAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,YAAY,CAAC,CAAC,EAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;;;;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var react=require("react");function useDebouncedValue(e,o,r={leading:!1}){const[f,n]=react.useState(e),c=react.useRef(!1),s=react.useRef(null),t=react.useRef(!1),u=()=>window.clearTimeout(s.current);return react.useEffect(()=>{c.current&&(!t.current&&r.leading?(t.current=!0,n(e)):(u(),s.current=window.setTimeout(()=>{t.current=!1,n(e)},o)))},[e,r.leading]),react.useEffect(()=>(c.current=!0,u),[]),[f,u]}exports.useDebouncedValue=useDebouncedValue;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react");function o(u,i,n={leading:!1}){const[l,c]=e.useState(u),s=e.useRef(!1),a=e.useRef(null),r=e.useRef(!1),t=()=>window.clearTimeout(a.current);return e.useEffect(()=>{s.current&&(!r.current&&n.leading?(r.current=!0,c(u)):(t(),a.current=window.setTimeout(()=>{r.current=!1,c(u)},i)))},[u,n.leading]),e.useEffect(()=>(s.current=!0,t),[]),[l,t]}exports.useDebouncedValue=o;
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/useDebouncedValue/index.ts"],"sourcesContent":["// https://github.com/mantinedev/mantine/blob/master/src/mantine-hooks/src/use-debounced-value/use-debounced-value.ts\nimport { useEffect, useState, useRef } from 'react';\n\nexport function useDebouncedValue<T = any>(value: T, wait: number, options = { leading: false }) {\n const [_value, setValue] = useState(value);\n const mountedRef = useRef(false);\n const timeoutRef = useRef<number>(null);\n const cooldownRef = useRef(false);\n\n const cancel = () => window.clearTimeout(timeoutRef.current);\n\n useEffect(() => {\n if (mountedRef.current) {\n if (!cooldownRef.current && options.leading) {\n cooldownRef.current = true;\n setValue(value);\n } else {\n cancel();\n timeoutRef.current = window.setTimeout(() => {\n cooldownRef.current = false;\n setValue(value);\n }, wait);\n }\n }\n }, [value, options.leading]);\n\n useEffect(() => {\n mountedRef.current = true;\n return cancel;\n }, []);\n\n return [_value, cancel] as const;\n}\n"],"names":["useState","useRef","useEffect"],"mappings":";;;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M,CAAC,CAAC;AAC1B;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/useDebouncedValue/index.ts"],"sourcesContent":["// https://github.com/mantinedev/mantine/blob/master/src/mantine-hooks/src/use-debounced-value/use-debounced-value.ts\nimport { useEffect, useState, useRef } from 'react';\n\nexport function useDebouncedValue<T = any>(value: T, wait: number, options = { leading: false }) {\n const [_value, setValue] = useState(value);\n const mountedRef = useRef(false);\n const timeoutRef = useRef<number>(null);\n const cooldownRef = useRef(false);\n\n const cancel = () => window.clearTimeout(timeoutRef.current);\n\n useEffect(() => {\n if (mountedRef.current) {\n if (!cooldownRef.current && options.leading) {\n cooldownRef.current = true;\n setValue(value);\n } else {\n cancel();\n timeoutRef.current = window.setTimeout(() => {\n cooldownRef.current = false;\n setValue(value);\n }, wait);\n }\n }\n }, [value, options.leading]);\n\n useEffect(() => {\n mountedRef.current = true;\n return cancel;\n }, []);\n\n return [_value, cancel] as const;\n}\n"],"names":["i","r","f"],"mappings":";;;;;;AAAmE,SAAS,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAACA,cAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAACC,YAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAACA,YAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAACA,YAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,OAAOC,eAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAACA,eAAC,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;;;;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var react=require("react");function useDidMount(e){react.useEffect(()=>{typeof e=="function"&&e()},[])}exports.useDidMount=useDidMount;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react");function u(e){t.useEffect(()=>{typeof e=="function"&&e()},[])}exports.useDidMount=u;
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/useDidMount/index.ts"],"sourcesContent":["import { useEffect } from 'react';\n\nexport function useDidMount(callback: () => any): void {\n useEffect(() => {\n if (typeof callback === 'function') {\n callback();\n }\n }, []);\n}\n"],"names":["useEffect"],"mappings":";;;;;;AACO,SAAS,WAAW,CAAC,QAAQ,EAAE;AACtC,EAAEA,eAAS,CAAC,MAAM;AAClB,IAAI,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE;AACxC,MAAM,QAAQ,EAAE,CAAC;AACjB,KAAK;AACL,GAAG,EAAE,EAAE,CAAC,CAAC;AACT;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/useDidMount/index.ts"],"sourcesContent":["import { useEffect } from 'react';\n\nexport function useDidMount(callback: () => any): void {\n useEffect(() => {\n if (typeof callback === 'function') {\n callback();\n }\n }, []);\n}\n"],"names":["t"],"mappings":";;;;;;AAAyC,SAAS,WAAW,CAAC,CAAC,CAAC,CAACA,eAAC,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,UAAU,EAAE,CAAC,GAAE,CAAC,CAAC,EAAE,EAAC;;;;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var react=require("react");function useDidUpdate(t,r){const e=react.useRef(!1);react.useEffect(()=>{e.current?t():e.current=!0},r)}exports.useDidUpdate=useDidUpdate;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react");function c(r,u){const e=t.useRef(!1);t.useEffect(()=>{e.current?r():e.current=!0},u)}exports.useDidUpdate=c;
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/useDidUpdate/index.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\n\nexport function useDidUpdate(fn: () => void, dependencies?: any[]) {\n const mounted = useRef(false);\n\n useEffect(() => {\n if (mounted.current) {\n fn();\n } else {\n mounted.current = true;\n }\n }, dependencies);\n}\n"],"names":["useRef","useEffect"],"mappings":";;;;;;AACO,SAAS,YAAY,CAAC,EAAE,EAAE,YAAY,EAAE;AAC/C,EAAE,MAAM,OAAO,GAAGA,YAAM,CAAC,KAAK,CAAC,CAAC;AAChC,EAAEC,eAAS,CAAC,MAAM;AAClB,IAAI,IAAI,OAAO,CAAC,OAAO,EAAE;AACzB,MAAM,EAAE,EAAE,CAAC;AACX,KAAK,MAAM;AACX,MAAM,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;AAC7B,KAAK;AACL,GAAG,EAAE,YAAY,CAAC,CAAC;AACnB;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/useDidUpdate/index.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\n\nexport function useDidUpdate(fn: () => void, dependencies?: any[]) {\n const mounted = useRef(false);\n\n useEffect(() => {\n if (mounted.current) {\n fn();\n } else {\n mounted.current = true;\n }\n }, dependencies);\n}\n"],"names":["f","u"],"mappings":";;;;;;AAAqD,SAAS,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAACA,YAAC,CAAC,CAAC,CAAC,CAAC,CAACC,eAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,EAAC;;;;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var react=require("react");function useDisclosure(u=!1){const[e,r]=react.useState(u),s=react.useCallback(()=>r(!0),[]),t=react.useCallback(()=>r(!1),[]),c=react.useCallback(()=>e?t():s(),[e,t,s]);return{isOpen:e,open:s,close:t,toggle:c}}exports.useDisclosure=useDisclosure;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react");function a(c=!1){const[s,t]=e.useState(c),u=e.useCallback(()=>t(!0),[]),r=e.useCallback(()=>t(!1),[]),l=e.useCallback(()=>s?r():u(),[s,r,u]);return{isOpen:s,open:u,close:r,toggle:l}}exports.useDisclosure=a;
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/useDisclosure/index.ts"],"sourcesContent":["import { useCallback, useState } from 'react';\n\nexport function useDisclosure(initialIsOpen = false) {\n const [isOpen, setIsOpen] = useState(initialIsOpen);\n\n const open = useCallback(() => setIsOpen(true), []);\n\n const close = useCallback(() => setIsOpen(false), []);\n\n const toggle = useCallback(() => (isOpen ? close() : open()), [isOpen, close, open]);\n\n return { isOpen, open, close, toggle };\n}\n"],"names":["useState","useCallback"],"mappings":";;;;;;AACO,SAAS,aAAa,CAAC,aAAa,GAAG,KAAK,EAAE;AACrD,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAGA,cAAQ,CAAC,aAAa,CAAC,CAAC;AACtD,EAAE,MAAM,IAAI,GAAGC,iBAAW,CAAC,MAAM,SAAS,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;AACtD,EAAE,MAAM,KAAK,GAAGA,iBAAW,CAAC,MAAM,SAAS,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC;AACxD,EAAE,MAAM,MAAM,GAAGA,iBAAW,CAAC,MAAM,MAAM,GAAG,KAAK,EAAE,GAAG,IAAI,EAAE,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;AACrF,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AACzC;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/useDisclosure/index.ts"],"sourcesContent":["import { useCallback, useState } from 'react';\n\nexport function useDisclosure(initialIsOpen = false) {\n const [isOpen, setIsOpen] = useState(initialIsOpen);\n\n const open = useCallback(() => setIsOpen(true), []);\n\n const close = useCallback(() => setIsOpen(false), []);\n\n const toggle = useCallback(() => (isOpen ? close() : open()), [isOpen, close, open]);\n\n return { isOpen, open, close, toggle };\n}\n"],"names":["l","o"],"mappings":";;;;;;AAAyD,SAAS,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAACA,cAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAACC,iBAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAACA,iBAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAACA,iBAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAM,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;;;;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var react=require("react");const reducer=e=>(e+1)%1e6;function useForceUpdate(){const[,e]=react.useReducer(reducer,0);return e}exports.useForceUpdate=useForceUpdate;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var r=require("react");const t=e=>(e+1)%1e6;function u(){const[,e]=r.useReducer(t,0);return e}exports.useForceUpdate=u;
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/useForceUpdate/index.ts"],"sourcesContent":["import { useReducer } from 'react';\n\nconst reducer = (value: number) => (value + 1) % 1000000;\n\nexport function useForceUpdate(): () => void {\n const [, update] = useReducer(reducer, 0);\n return update;\n}\n"],"names":["useReducer"],"mappings":";;;;;;AACA,MAAM,OAAO,GAAG,CAAC,KAAK,KAAK,CAAC,KAAK,GAAG,CAAC,IAAI,GAAG,CAAC;AACtC,SAAS,cAAc,GAAG;AACjC,EAAE,MAAM,GAAG,MAAM,CAAC,GAAGA,gBAAU,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;AAC5C,EAAE,OAAO,MAAM,CAAC;AAChB;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/useForceUpdate/index.ts"],"sourcesContent":["import { useReducer } from 'react';\n\nconst reducer = (value: number) => (value + 1) % 1000000;\n\nexport function useForceUpdate(): () => void {\n const [, update] = useReducer(reducer, 0);\n return update;\n}\n"],"names":["r"],"mappings":";;;;;;AAAmC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,CAAQ,SAAS,cAAc,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,CAACA,gBAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;;;;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var react=require("react"),parseHotkey=require("./parseHotkey.js");function useHotkeys(t){react.useEffect(()=>{const r=e=>{t.forEach(([o,n])=>{parseHotkey.getHotkeyMatcher(o)(e)&&(e.preventDefault(),n(e))})};return document.documentElement.addEventListener("keydown",r),()=>document.documentElement.removeEventListener("keydown",r)},[t])}exports.useHotkeys=useHotkeys;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var u=require("react"),s=require("./parseHotkey.js");function c(t){u.useEffect(()=>{const r=e=>{t.forEach(([n,o])=>{s.getHotkeyMatcher(n)(e)&&(e.preventDefault(),o(e))})};return document.documentElement.addEventListener("keydown",r),()=>document.documentElement.removeEventListener("keydown",r)},[t])}exports.useHotkeys=c;
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/useHotkeys/index.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport { getHotkeyMatcher, getHotkeyHandler } from './parseHotkey';\n\nexport { getHotkeyHandler };\n\ntype HokeyItem = [string, (event: KeyboardEvent) => void];\n\nexport function useHotkeys(hotkeys: HokeyItem[]) {\n useEffect(() => {\n const keydownListener = (event: KeyboardEvent) => {\n hotkeys.forEach(([hotkey, handler]) => {\n if (getHotkeyMatcher(hotkey)(event)) {\n event.preventDefault();\n handler(event);\n }\n });\n };\n\n document.documentElement.addEventListener('keydown', keydownListener);\n return () => document.documentElement.removeEventListener('keydown', keydownListener);\n }, [hotkeys]);\n}\n"],"names":["useEffect","getHotkeyMatcher"],"mappings":";;;;;;;AAGO,SAAS,UAAU,CAAC,OAAO,EAAE;AACpC,EAAEA,eAAS,CAAC,MAAM;AAClB,IAAI,MAAM,eAAe,GAAG,CAAC,KAAK,KAAK;AACvC,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK;AAC7C,QAAQ,IAAIC,4BAAgB,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,EAAE;AAC7C,UAAU,KAAK,CAAC,cAAc,EAAE,CAAC;AACjC,UAAU,OAAO,CAAC,KAAK,CAAC,CAAC;AACzB,SAAS;AACT,OAAO,CAAC,CAAC;AACT,KAAK,CAAC;AACN,IAAI,QAAQ,CAAC,eAAe,CAAC,gBAAgB,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;AAC1E,IAAI,OAAO,MAAM,QAAQ,CAAC,eAAe,CAAC,mBAAmB,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;AAC1F,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;AAChB;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/useHotkeys/index.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport { getHotkeyMatcher, getHotkeyHandler } from './parseHotkey';\n\nexport { getHotkeyHandler };\n\ntype HokeyItem = [string, (event: KeyboardEvent) => void];\n\nexport function useHotkeys(hotkeys: HokeyItem[]) {\n useEffect(() => {\n const keydownListener = (event: KeyboardEvent) => {\n hotkeys.forEach(([hotkey, handler]) => {\n if (getHotkeyMatcher(hotkey)(event)) {\n event.preventDefault();\n handler(event);\n }\n });\n };\n\n document.documentElement.addEventListener('keydown', keydownListener);\n return () => document.documentElement.removeEventListener('keydown', keydownListener);\n }, [hotkeys]);\n}\n"],"names":["d","m"],"mappings":";;;;;;;AAA8I,SAAS,UAAU,CAAC,CAAC,CAAC,CAACA,eAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAACC,4BAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAC,CAAC,EAAC,CAAC,CAAC,OAAO,QAAQ,CAAC,eAAe,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,QAAQ,CAAC,eAAe,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAC;;;;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var __defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(r,e,t)=>e in r?__defProp(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,__spreadValues=(r,e)=>{for(var t in e||(e={}))__hasOwnProp.call(e,t)&&__defNormalProp(r,t,e[t]);if(__getOwnPropSymbols)for(var t of __getOwnPropSymbols(e))__propIsEnum.call(e,t)&&__defNormalProp(r,t,e[t]);return r},__spreadProps=(r,e)=>__defProps(r,__getOwnPropDescs(e));function parseHotkey(r){const e=r.toLowerCase().split("+").map(s=>s.trim()),t={alt:e.includes("alt"),ctrl:e.includes("ctrl"),meta:e.includes("meta"),mod:e.includes("mod"),shift:e.includes("shift")},o=["alt","ctrl","meta","shift","mod"],a=e.find(s=>!o.includes(s));return __spreadProps(__spreadValues({},t),{key:a})}function isExactHotkey(r,e){const{alt:t,ctrl:o,meta:a,mod:s,shift:l,key:n}=r,{altKey:f,ctrlKey:i,metaKey:c,shiftKey:p,key:u}=e;if(t!==f)return!1;if(s){if(!i&&!c)return!1}else if(o!==i||a!==c)return!1;return l!==p?!1:!!(n&&(u.toLowerCase()===n.toLowerCase()||e.code.replace("Key","").toLowerCase()===n.toLowerCase()))}function getHotkeyMatcher(r){return e=>isExactHotkey(parseHotkey(r),e)}exports.getHotkeyMatcher=getHotkeyMatcher,exports.parseHotkey=parseHotkey;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var b=Object.defineProperty,v=Object.defineProperties,O=Object.getOwnPropertyDescriptors,s=Object.getOwnPropertySymbols,h=Object.prototype.hasOwnProperty,w=Object.prototype.propertyIsEnumerable,u=(t,e,r)=>e in t?b(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,k=(t,e)=>{for(var r in e||(e={}))h.call(e,r)&&u(t,r,e[r]);if(s)for(var r of s(e))w.call(e,r)&&u(t,r,e[r]);return t},j=(t,e)=>v(t,O(e));function f(t){const e=t.toLowerCase().split("+").map(o=>o.trim()),r={alt:e.includes("alt"),ctrl:e.includes("ctrl"),meta:e.includes("meta"),mod:e.includes("mod"),shift:e.includes("shift")},a=["alt","ctrl","meta","shift","mod"],n=e.find(o=>!a.includes(o));return j(k({},r),{key:n})}function K(t,e){const{alt:r,ctrl:a,meta:n,mod:o,shift:y,key:c}=t,{altKey:p,ctrlKey:i,metaKey:l,shiftKey:d,key:m}=e;if(r!==p)return!1;if(o){if(!i&&!l)return!1}else if(a!==i||n!==l)return!1;return y!==d?!1:!!(c&&(m.toLowerCase()===c.toLowerCase()||e.code.replace("Key","").toLowerCase()===c.toLowerCase()))}function P(t){return e=>K(f(t),e)}exports.getHotkeyMatcher=P,exports.parseHotkey=f;
2
2
  //# sourceMappingURL=parseHotkey.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"parseHotkey.js","sources":["../../src/useHotkeys/parseHotkey.ts"],"sourcesContent":["export type KeyboardModifiers = {\n alt: boolean;\n ctrl: boolean;\n meta: boolean;\n mod: boolean;\n shift: boolean;\n};\n\nexport type Hotkey = KeyboardModifiers & {\n key?: string;\n};\n\ntype CheckHotkeyMatch = (event: KeyboardEvent) => boolean;\n\nexport function parseHotkey(hotkey: string): Hotkey {\n const keys = hotkey\n .toLowerCase()\n .split('+')\n .map((part) => part.trim());\n\n const modifiers: KeyboardModifiers = {\n alt: keys.includes('alt'),\n ctrl: keys.includes('ctrl'),\n meta: keys.includes('meta'),\n mod: keys.includes('mod'),\n shift: keys.includes('shift'),\n };\n\n const reservedKeys = ['alt', 'ctrl', 'meta', 'shift', 'mod'];\n\n const freeKey = keys.find((key) => !reservedKeys.includes(key));\n\n return {\n ...modifiers,\n key: freeKey,\n };\n}\n\nfunction isExactHotkey(hotkey: Hotkey, event: KeyboardEvent): boolean {\n const { alt, ctrl, meta, mod, shift, key } = hotkey;\n const { altKey, ctrlKey, metaKey, shiftKey, key: pressedKey } = event;\n\n if (alt !== altKey) {\n return false;\n }\n\n if (mod) {\n if (!ctrlKey && !metaKey) {\n return false;\n }\n } else {\n if (ctrl !== ctrlKey) {\n return false;\n }\n if (meta !== metaKey) {\n return false;\n }\n }\n if (shift !== shiftKey) {\n return false;\n }\n\n if (\n key &&\n (pressedKey.toLowerCase() === key.toLowerCase() ||\n event.code.replace('Key', '').toLowerCase() === key.toLowerCase())\n ) {\n return true;\n }\n\n return false;\n}\n\nexport function getHotkeyMatcher(hotkey: string): CheckHotkeyMatch {\n return (event) => isExactHotkey(parseHotkey(hotkey), event);\n}\n\ntype HotkeyItem = [string, (event: React.KeyboardEvent<HTMLElement>) => void];\n\nexport function getHotkeyHandler(hotkeys: HotkeyItem[]) {\n return (event: React.KeyboardEvent<HTMLElement>) => {\n hotkeys.forEach(([hotkey, handler]) => {\n if (getHotkeyMatcher(hotkey)(event.nativeEvent)) {\n event.preventDefault();\n handler(event);\n }\n });\n };\n}\n"],"names":[],"mappings":";;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,UAAU,GAAG,MAAM,CAAC,gBAAgB,CAAC;AACzC,IAAI,iBAAiB,GAAG,MAAM,CAAC,yBAAyB,CAAC;AACzD,IAAI,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC;AACvD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC;AACnD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,oBAAoB,CAAC;AACzD,IAAI,eAAe,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,KAAK,GAAG,IAAI,GAAG,GAAG,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,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AI,GAAG,KAAK,UAAU,CAAC,WAAW,EAAE,KAAK,GAAG,CAAC,WAAW,EAAE,IAAI,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,KAAK,GAAG,CAAC,WAAW,EAAE,CAAC,EAAE;AACpI,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,OAAO,KAAK,CAAC;AACf,CAAC;AACM,SAAS,gBAAgB,CAAC,MAAM,EAAE;AACzC,EAAE,OAAO,CAAC,KAAK,KAAK,aAAa,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,CAAC;AAC9D;;;;;"}
1
+ {"version":3,"file":"parseHotkey.js","sources":["../../src/useHotkeys/parseHotkey.ts"],"sourcesContent":["export type KeyboardModifiers = {\n alt: boolean;\n ctrl: boolean;\n meta: boolean;\n mod: boolean;\n shift: boolean;\n};\n\nexport type Hotkey = KeyboardModifiers & {\n key?: string;\n};\n\ntype CheckHotkeyMatch = (event: KeyboardEvent) => boolean;\n\nexport function parseHotkey(hotkey: string): Hotkey {\n const keys = hotkey\n .toLowerCase()\n .split('+')\n .map((part) => part.trim());\n\n const modifiers: KeyboardModifiers = {\n alt: keys.includes('alt'),\n ctrl: keys.includes('ctrl'),\n meta: keys.includes('meta'),\n mod: keys.includes('mod'),\n shift: keys.includes('shift'),\n };\n\n const reservedKeys = ['alt', 'ctrl', 'meta', 'shift', 'mod'];\n\n const freeKey = keys.find((key) => !reservedKeys.includes(key));\n\n return {\n ...modifiers,\n key: freeKey,\n };\n}\n\nfunction isExactHotkey(hotkey: Hotkey, event: KeyboardEvent): boolean {\n const { alt, ctrl, meta, mod, shift, key } = hotkey;\n const { altKey, ctrlKey, metaKey, shiftKey, key: pressedKey } = event;\n\n if (alt !== altKey) {\n return false;\n }\n\n if (mod) {\n if (!ctrlKey && !metaKey) {\n return false;\n }\n } else {\n if (ctrl !== ctrlKey) {\n return false;\n }\n if (meta !== metaKey) {\n return false;\n }\n }\n if (shift !== shiftKey) {\n return false;\n }\n\n if (\n key &&\n (pressedKey.toLowerCase() === key.toLowerCase() ||\n event.code.replace('Key', '').toLowerCase() === key.toLowerCase())\n ) {\n return true;\n }\n\n return false;\n}\n\nexport function getHotkeyMatcher(hotkey: string): CheckHotkeyMatch {\n return (event) => isExactHotkey(parseHotkey(hotkey), event);\n}\n\ntype HotkeyItem = [string, (event: React.KeyboardEvent<HTMLElement>) => void];\n\nexport function getHotkeyHandler(hotkeys: HotkeyItem[]) {\n return (event: React.KeyboardEvent<HTMLElement>) => {\n hotkeys.forEach(([hotkey, handler]) => {\n if (getHotkeyMatcher(hotkey)(event.nativeEvent)) {\n event.preventDefault();\n handler(event);\n }\n });\n };\n}\n"],"names":[],"mappings":";;;;AAAA,IAAI,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,yBAAyB,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE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AAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,OAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAM,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,OAAM,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAQ,SAAS,gBAAgB,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;;;;;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var react=require("react");function useHover(){const[o,r]=react.useState(!1),t=react.useRef(null),s=()=>r(!0),n=()=>r(!1);return react.useEffect(()=>{const e=t==null?void 0:t.current;if(e)return e.addEventListener("mouseenter",s),e.addEventListener("mouseleave",n),()=>{e.removeEventListener("mouseenter",s),e.removeEventListener("mouseleave",n)}},[]),{ref:t,isHovered:o}}exports.useHover=useHover;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react");function v(){const[o,n]=t.useState(!1),r=t.useRef(null),s=()=>n(!0),u=()=>n(!1);return t.useEffect(()=>{const e=r==null?void 0:r.current;if(e)return e.addEventListener("mouseenter",s),e.addEventListener("mouseleave",u),()=>{e.removeEventListener("mouseenter",s),e.removeEventListener("mouseleave",u)}},[]),{ref:r,isHovered:o}}exports.useHover=v;
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/useHover/index.ts"],"sourcesContent":["import { useState, useRef, useEffect } from 'react';\n\nexport function useHover<T extends HTMLElement = HTMLElement>() {\n const [isHovered, setIsHovered] = useState<boolean>(false);\n const ref = useRef<T>(null);\n\n const handleMouseEnter = () => setIsHovered(true);\n const handleMouseLeave = () => setIsHovered(false);\n\n useEffect(() => {\n const element = ref?.current;\n\n if (element) {\n element.addEventListener('mouseenter', handleMouseEnter);\n element.addEventListener('mouseleave', handleMouseLeave);\n\n return () => {\n element.removeEventListener('mouseenter', handleMouseEnter);\n element.removeEventListener('mouseleave', handleMouseLeave);\n };\n }\n\n return undefined;\n }, []);\n\n return { ref, isHovered };\n}\n"],"names":["useState","useRef","useEffect"],"mappings":";;;;;;AACO,SAAS,QAAQ,GAAG;AAC3B,EAAE,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAGA,cAAQ,CAAC,KAAK,CAAC,CAAC;AACpD,EAAE,MAAM,GAAG,GAAGC,YAAM,CAAC,IAAI,CAAC,CAAC;AAC3B,EAAE,MAAM,gBAAgB,GAAG,MAAM,YAAY,CAAC,IAAI,CAAC,CAAC;AACpD,EAAE,MAAM,gBAAgB,GAAG,MAAM,YAAY,CAAC,KAAK,CAAC,CAAC;AACrD,EAAEC,eAAS,CAAC,MAAM;AAClB,IAAI,MAAM,OAAO,GAAG,GAAG,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC;AACvD,IAAI,IAAI,OAAO,EAAE;AACjB,MAAM,OAAO,CAAC,gBAAgB,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;AAC/D,MAAM,OAAO,CAAC,gBAAgB,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;AAC/D,MAAM,OAAO,MAAM;AACnB,QAAQ,OAAO,CAAC,mBAAmB,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;AACpE,QAAQ,OAAO,CAAC,mBAAmB,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;AACpE,OAAO,CAAC;AACR,KAAK;AACL,IAAI,OAAO,KAAK,CAAC,CAAC;AAClB,GAAG,EAAE,EAAE,CAAC,CAAC;AACT,EAAE,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC;AAC5B;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/useHover/index.ts"],"sourcesContent":["import { useState, useRef, useEffect } from 'react';\n\nexport function useHover<T extends HTMLElement = HTMLElement>() {\n const [isHovered, setIsHovered] = useState<boolean>(false);\n const ref = useRef<T>(null);\n\n const handleMouseEnter = () => setIsHovered(true);\n const handleMouseLeave = () => setIsHovered(false);\n\n useEffect(() => {\n const element = ref?.current;\n\n if (element) {\n element.addEventListener('mouseenter', handleMouseEnter);\n element.addEventListener('mouseleave', handleMouseLeave);\n\n return () => {\n element.removeEventListener('mouseenter', handleMouseEnter);\n element.removeEventListener('mouseleave', handleMouseLeave);\n };\n }\n\n return undefined;\n }, []);\n\n return { ref, isHovered };\n}\n"],"names":["u","a","l"],"mappings":";;;;;;AAAmE,SAAS,QAAQ,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAACA,cAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAACC,YAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAOC,eAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,mBAAmB,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC,YAAY,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;;;;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var react=require("react"),index=require("../utils/index.js");function useId(e,r=index.randomId){const t=react.useRef(r());return e||t.current}exports.useId=useId;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),n=require("../utils/index.js");function s(e,r=n.randomId){const u=t.useRef(r());return e||u.current}exports.useId=s;
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/useId/index.ts"],"sourcesContent":["import { useRef } from 'react';\nimport { randomId } from '../utils';\n\nexport function useId(id?: string, generateId: () => string = randomId) {\n const generatedId = useRef(generateId());\n return id || generatedId.current;\n}\n"],"names":["randomId","useRef"],"mappings":";;;;;;;AAEO,SAAS,KAAK,CAAC,EAAE,EAAE,UAAU,GAAGA,cAAQ,EAAE;AACjD,EAAE,MAAM,WAAW,GAAGC,YAAM,CAAC,UAAU,EAAE,CAAC,CAAC;AAC3C,EAAE,OAAO,EAAE,IAAI,WAAW,CAAC,OAAO,CAAC;AACnC;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/useId/index.ts"],"sourcesContent":["import { useRef } from 'react';\nimport { randomId } from '../utils';\n\nexport function useId(id?: string, generateId: () => string = randomId) {\n const generatedId = useRef(generateId());\n return id || generatedId.current;\n}\n"],"names":["o","n"],"mappings":";;;;;;;AAA0E,SAAS,KAAK,CAAC,CAAC,CAAC,CAAC,CAACA,cAAC,CAAC,CAAC,MAAM,CAAC,CAACC,YAAC,CAAC,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,OAAO;;;;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var react=require("react"),index=require("../useWindowEvent/index.js");function useLocalStorage({key:o,defaultValue:t=void 0}){const[r,n]=react.useState(typeof window!="undefined"&&"localStorage"in window?window.localStorage.getItem(o):t!=null?t:""),s=react.useCallback(e=>{typeof e=="function"?n(a=>{const i=e(a);return window.localStorage.setItem(o,i),i}):(window.localStorage.setItem(o,e),n(e))},[o]);return index.useWindowEvent("storage",e=>{e.storageArea===window.localStorage&&e.key===o&&n(e.newValue)}),react.useEffect(()=>{t&&!r&&s(t)},[t,r,s]),[r,s]}exports.useLocalStorage=useLocalStorage;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var u=require("react"),s=require("../useWindowEvent/index.js");function c({key:t,defaultValue:a=void 0}){const[o,n]=u.useState(typeof window!="undefined"&&"localStorage"in window?window.localStorage.getItem(t):a??""),r=u.useCallback(e=>{typeof e=="function"?n(i=>{const l=e(i);return window.localStorage.setItem(t,l),l}):(window.localStorage.setItem(t,e),n(e))},[t]);return s.useWindowEvent("storage",e=>{e.storageArea===window.localStorage&&e.key===t&&n(e.newValue)}),u.useEffect(()=>{a&&!o&&r(a)},[a,o,r]),[o,r]}exports.useLocalStorage=c;
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/useLocalStorage/index.ts"],"sourcesContent":["// https://github.com/mantinedev/mantine/blob/master/src/mantine-hooks/src/use-local-storage-value/use-local-storage-value.ts\nimport { useState, useCallback, useEffect } from 'react';\nimport { useWindowEvent } from '../useWindowEvent';\n\nexport function useLocalStorage<T extends string>({\n key,\n defaultValue = undefined,\n}: {\n key: string;\n defaultValue?: T;\n}) {\n const [value, setValue] = useState<T>(\n typeof window !== 'undefined' && 'localStorage' in window\n ? (window.localStorage.getItem(key) as T)\n : ((defaultValue ?? '') as T)\n );\n\n const setLocalStorageValue = useCallback(\n (val: T | ((prevState: T) => T)) => {\n if (typeof val === 'function') {\n setValue((current) => {\n const result = val(current);\n window.localStorage.setItem(key, result);\n return result;\n });\n } else {\n window.localStorage.setItem(key, val);\n setValue(val);\n }\n },\n [key]\n );\n\n useWindowEvent('storage', (event) => {\n if (event.storageArea === window.localStorage && event.key === key) {\n setValue(event.newValue as T);\n }\n });\n\n useEffect(() => {\n if (defaultValue && !value) {\n setLocalStorageValue(defaultValue);\n }\n }, [defaultValue, value, setLocalStorageValue]);\n\n return [value, setLocalStorageValue] as const;\n}\n"],"names":["useState","useCallback","useWindowEvent","useEffect"],"mappings":";;;;;;;AAEO,SAAS,eAAe,CAAC;AAChC,EAAE,GAAG;AACL,EAAE,YAAY,GAAG,KAAK,CAAC;AACvB,CAAC,EAAE;AACH,EAAE,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAGA,cAAQ,CAAC,OAAO,MAAM,KAAK,WAAW,IAAI,cAAc,IAAI,MAAM,GAAG,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,YAAY,IAAI,IAAI,GAAG,YAAY,GAAG,EAAE,CAAC,CAAC;AAC9K,EAAE,MAAM,oBAAoB,GAAGC,iBAAW,CAAC,CAAC,GAAG,KAAK;AACpD,IAAI,IAAI,OAAO,GAAG,KAAK,UAAU,EAAE;AACnC,MAAM,QAAQ,CAAC,CAAC,OAAO,KAAK;AAC5B,QAAQ,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC;AACpC,QAAQ,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;AACjD,QAAQ,OAAO,MAAM,CAAC;AACtB,OAAO,CAAC,CAAC;AACT,KAAK,MAAM;AACX,MAAM,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAC5C,MAAM,QAAQ,CAAC,GAAG,CAAC,CAAC;AACpB,KAAK;AACL,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;AACZ,EAAEC,oBAAc,CAAC,SAAS,EAAE,CAAC,KAAK,KAAK;AACvC,IAAI,IAAI,KAAK,CAAC,WAAW,KAAK,MAAM,CAAC,YAAY,IAAI,KAAK,CAAC,GAAG,KAAK,GAAG,EAAE;AACxE,MAAM,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AAC/B,KAAK;AACL,GAAG,CAAC,CAAC;AACL,EAAEC,eAAS,CAAC,MAAM;AAClB,IAAI,IAAI,YAAY,IAAI,CAAC,KAAK,EAAE;AAChC,MAAM,oBAAoB,CAAC,YAAY,CAAC,CAAC;AACzC,KAAK;AACL,GAAG,EAAE,CAAC,YAAY,EAAE,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC;AAClD,EAAE,OAAO,CAAC,KAAK,EAAE,oBAAoB,CAAC,CAAC;AACvC;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/useLocalStorage/index.ts"],"sourcesContent":["// https://github.com/mantinedev/mantine/blob/master/src/mantine-hooks/src/use-local-storage-value/use-local-storage-value.ts\nimport { useState, useCallback, useEffect } from 'react';\nimport { useWindowEvent } from '../useWindowEvent';\n\nexport function useLocalStorage<T extends string>({\n key,\n defaultValue = undefined,\n}: {\n key: string;\n defaultValue?: T;\n}) {\n const [value, setValue] = useState<T>(\n typeof window !== 'undefined' && 'localStorage' in window\n ? (window.localStorage.getItem(key) as T)\n : ((defaultValue ?? '') as T)\n );\n\n const setLocalStorageValue = useCallback(\n (val: T | ((prevState: T) => T)) => {\n if (typeof val === 'function') {\n setValue((current) => {\n const result = val(current);\n window.localStorage.setItem(key, result);\n return result;\n });\n } else {\n window.localStorage.setItem(key, val);\n setValue(val);\n }\n },\n [key]\n );\n\n useWindowEvent('storage', (event) => {\n if (event.storageArea === window.localStorage && event.key === key) {\n setValue(event.newValue as T);\n }\n });\n\n useEffect(() => {\n if (defaultValue && !value) {\n setLocalStorageValue(defaultValue);\n }\n }, [defaultValue, value, setLocalStorageValue]);\n\n return [value, setLocalStorageValue] as const;\n}\n"],"names":["a","w","S","g"],"mappings":";;;;;;;AAA2H,SAAS,eAAe,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAACA,cAAC,CAAC,OAAO,MAAM,EAAE,WAAW,EAAE,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAACC,iBAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAOC,oBAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,GAAG,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC,GAAG,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAC,CAAC,CAAC,CAACC,eAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,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 react=require("react");function attachMediaListener(e,t){try{return e.addEventListener("change",t),()=>e.removeEventListener("change",t)}catch(n){return e.addListener(t),()=>e.removeListener(t)}}function getInitialValue(e){return typeof window!="undefined"&&"matchMedia"in window?window.matchMedia(e).matches:!1}function useMediaQuery(e){const[t,n]=react.useState(getInitialValue(e)),r=react.useRef();return react.useEffect(()=>{if("matchMedia"in window)return r.current=window.matchMedia(e),n(r.current.matches),attachMediaListener(r.current,i=>n(i.matches))},[e]),t}exports.useMediaQuery=useMediaQuery;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var i=require("react");function u(e,t){try{return e.addEventListener("change",t),()=>e.removeEventListener("change",t)}catch(n){return e.addListener(t),()=>e.removeListener(t)}}function a(e){return typeof window!="undefined"&&"matchMedia"in window?window.matchMedia(e).matches:!1}function d(e){const[t,n]=i.useState(a(e)),r=i.useRef();return i.useEffect(()=>{if("matchMedia"in window)return r.current=window.matchMedia(e),n(r.current.matches),u(r.current,c=>n(c.matches))},[e]),t}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":["useState","useRef","useEffect"],"mappings":";;;;;;AACA,SAAS,mBAAmB,CAAC,KAAK,EAAE,QAAQ,EAAE;AAC9C,EAAE,IAAI;AACN,IAAI,KAAK,CAAC,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAC/C,IAAI,OAAO,MAAM,KAAK,CAAC,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAC/D,GAAG,CAAC,OAAO,CAAC,EAAE;AACd,IAAI,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;AAChC,IAAI,OAAO,MAAM,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;AAChD,GAAG;AACH,CAAC;AACD,SAAS,eAAe,CAAC,KAAK,EAAE;AAChC,EAAE,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,YAAY,IAAI,MAAM,EAAE;AAC/D,IAAI,OAAO,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC;AAC5C,GAAG;AACH,EAAE,OAAO,KAAK,CAAC;AACf,CAAC;AACM,SAAS,aAAa,CAAC,KAAK,EAAE;AACrC,EAAE,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAGA,cAAQ,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC;AACjE,EAAE,MAAM,QAAQ,GAAGC,YAAM,EAAE,CAAC;AAC5B,EAAEC,eAAS,CAAC,MAAM;AAClB,IAAI,IAAI,YAAY,IAAI,MAAM,EAAE;AAChC,MAAM,QAAQ,CAAC,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;AAClD,MAAM,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;AAC3C,MAAM,OAAO,mBAAmB,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,KAAK,KAAK,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;AACzF,KAAK;AACL,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;AACd,EAAE,OAAO,OAAO,CAAC;AACjB;;;;"}
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,EAAE,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;;;;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var react=require("react"),index=require("../utils/index.js");function useMergedRef(...e){return react.useCallback(r=>{e.forEach(s=>index.assignRef(s,r))},e)}function mergeRefs(...e){return r=>{e.forEach(s=>index.assignRef(s,r))}}exports.mergeRefs=mergeRefs,exports.useMergedRef=useMergedRef;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react"),u=require("../utils/index.js");function a(...e){return t.useCallback(r=>{e.forEach(s=>u.assignRef(s,r))},e)}function f(...e){return r=>{e.forEach(s=>u.assignRef(s,r))}}exports.mergeRefs=f,exports.useMergedRef=a;
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/useMergedRef/index.ts"],"sourcesContent":["import React, { useCallback } from 'react';\nimport { assignRef } from '../utils';\n\ntype Ref<T> = React.Dispatch<React.SetStateAction<T>> | React.ForwardedRef<T>;\n\nexport function useMergedRef<T = any>(...refs: Ref<T>[]) {\n return useCallback((node: T | null) => {\n refs.forEach((ref) => assignRef(ref, node));\n }, refs);\n}\n\nexport function mergeRefs<T = any>(...refs: Ref<T>[]) {\n return (node: T | null) => {\n refs.forEach((ref) => assignRef(ref, node));\n };\n}\n"],"names":["useCallback","assignRef"],"mappings":";;;;;;;AAEO,SAAS,YAAY,CAAC,GAAG,IAAI,EAAE;AACtC,EAAE,OAAOA,iBAAW,CAAC,CAAC,IAAI,KAAK;AAC/B,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,KAAKC,eAAS,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;AAChD,GAAG,EAAE,IAAI,CAAC,CAAC;AACX,CAAC;AACM,SAAS,SAAS,CAAC,GAAG,IAAI,EAAE;AACnC,EAAE,OAAO,CAAC,IAAI,KAAK;AACnB,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,KAAKA,eAAS,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;AAChD,GAAG,CAAC;AACJ;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/useMergedRef/index.ts"],"sourcesContent":["import React, { useCallback } from 'react';\nimport { assignRef } from '../utils';\n\ntype Ref<T> = React.Dispatch<React.SetStateAction<T>> | React.ForwardedRef<T>;\n\nexport function useMergedRef<T = any>(...refs: Ref<T>[]) {\n return useCallback((node: T | null) => {\n refs.forEach((ref) => assignRef(ref, node));\n }, refs);\n}\n\nexport function mergeRefs<T = any>(...refs: Ref<T>[]) {\n return (node: T | null) => {\n refs.forEach((ref) => assignRef(ref, node));\n };\n}\n"],"names":["c","a"],"mappings":";;;;;;;AAAgF,SAAS,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,OAAOA,iBAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,EAAEC,eAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,CAAC,CAAQ,SAAS,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,EAAEA,eAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAC,CAAC;;;;;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var react=require("react"),index=require("../utils/index.js");function useMove(E,n){const t=react.useRef(),u=react.useRef(!1),o=react.useRef(!1),d=react.useRef(0),[h,m]=react.useState(!1);return react.useEffect(()=>{u.current=!0},[]),react.useEffect(()=>{const a=({x:e,y:b})=>{cancelAnimationFrame(d.current),d.current=requestAnimationFrame(()=>{if(u.current&&t.current){t.current.style.userSelect="none";const r=t.current.getBoundingClientRect();r.width&&r.height&&E({x:index.clamp({value:(e-r.left)/r.width,min:0,max:1}),y:index.clamp({value:(b-r.top)/r.height,min:0,max:1})})}})},p=()=>{document.addEventListener("mousemove",s),document.addEventListener("mouseup",c),document.addEventListener("touchmove",i),document.addEventListener("touchend",c)},S=()=>{document.removeEventListener("mousemove",s),document.removeEventListener("mouseup",c),document.removeEventListener("touchmove",i),document.removeEventListener("touchend",c)},v=()=>{!o.current&&u.current&&(o.current=!0,typeof(n==null?void 0:n.onScrubStart)=="function"&&n.onScrubStart(),m(!0),p())},c=()=>{o.current&&u.current&&(o.current=!1,typeof(n==null?void 0:n.onScrubEnd)=="function"&&n.onScrubEnd(),m(!1),S())},f=e=>{v(),s(e)},s=e=>a({x:e.clientX,y:e.clientY}),l=e=>{v(),e==null||e.preventDefault(),i(e)},i=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",l),()=>{t.current&&(t.current.removeEventListener("mousedown",f),t.current.removeEventListener("touchstart",l))}},[t.current]),{ref:t,active:h}}exports.useMove=useMove;
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;
2
2
  //# sourceMappingURL=index.js.map
@@ -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":["useRef","useState","useEffect","clamp"],"mappings":";;;;;;;AAMO,SAAS,OAAO,CAAC,QAAQ,EAAE,QAAQ,EAAE;AAC5C,EAAE,MAAM,GAAG,GAAGA,YAAM,EAAE,CAAC;AACvB,EAAE,MAAM,OAAO,GAAGA,YAAM,CAAC,KAAK,CAAC,CAAC;AAChC,EAAE,MAAM,SAAS,GAAGA,YAAM,CAAC,KAAK,CAAC,CAAC;AAClC,EAAE,MAAM,KAAK,GAAGA,YAAM,CAAC,CAAC,CAAC,CAAC;AAC1B,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAGC,cAAQ,CAAC,KAAK,CAAC,CAAC;AAC9C,EAAEC,eAAS,CAAC,MAAM;AAClB,IAAI,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;AAC3B,GAAG,EAAE,EAAE,CAAC,CAAC;AACT,EAAEA,eAAS,CAAC,MAAM;AAClB,IAAI,MAAM,OAAO,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC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M,EAAE,CAAC;AACzB;;;;"}
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,EAAE,CAAC,CAAC,CAACA,YAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAACA,YAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAACA,YAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAACC,cAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAOC,eAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,EAAC,CAAC,CAAC,EAAE,CAAC,CAACA,eAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,qBAAqB,CAAC,IAAI,CAAC,GAA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AAY,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,OAAO,CAAC,mBAAmB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,mBAAmB,CAAC,YAAY,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;;;;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var react=require("react");function usePrevious(e){const r=react.useRef();return react.useEffect(()=>{r.current=e},[e]),r.current}exports.usePrevious=usePrevious;
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;
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":["useRef","useEffect"],"mappings":";;;;;;AACO,SAAS,WAAW,CAAC,KAAK,EAAE;AACnC,EAAE,MAAM,GAAG,GAAGA,YAAM,EAAE,CAAC;AACvB,EAAEC,eAAS,CAAC,MAAM;AAClB,IAAI,GAAG,CAAC,OAAO,GAAG,KAAK,CAAC;AACxB,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;AACd,EAAE,OAAO,GAAG,CAAC,OAAO,CAAC;AACrB;;;;"}
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":["t","n"],"mappings":";;;;;;AAAqD,SAAS,WAAW,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAACA,YAAC,EAAE,CAAC,OAAOC,eAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO;;;;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var react=require("react");function useQueue({initialValues:c=[],limit:e}){const[{state:r,queue:n},a]=react.useState({state:c.slice(0,e),queue:c.slice(e)});return{state:r,queue:n,add:(...t)=>a(u=>{const s=[...u.state,...u.queue,...t];return{state:s.slice(0,e),queue:s.slice(e)}}),update:t=>a(u=>{const s=t([...u.state,...u.queue]);return{state:s.slice(0,e),queue:s.slice(e)}}),cleanQueue:()=>a(t=>({state:t.state,queue:[]}))}}exports.useQueue=useQueue;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var l=require("react");function n({initialValues:i=[],limit:e}){const[{state:r,queue:c},a]=l.useState({state:i.slice(0,e),queue:i.slice(e)});return{state:r,queue:c,add:(...t)=>a(u=>{const s=[...u.state,...u.queue,...t];return{state:s.slice(0,e),queue:s.slice(e)}}),update:t=>a(u=>{const s=t([...u.state,...u.queue]);return{state:s.slice(0,e),queue:s.slice(e)}}),cleanQueue:()=>a(t=>({state:t.state,queue:[]}))}}exports.useQueue=n;
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/useQueue/index.ts"],"sourcesContent":["import { useState } from 'react';\n\nexport function useQueue<T>({ initialValues = [], limit }: { initialValues?: T[]; limit: number }) {\n const [{ state, queue }, setState] = useState({\n state: initialValues.slice(0, limit),\n queue: initialValues.slice(limit),\n });\n\n const add = (...items: T[]) =>\n setState((current) => {\n const results = [...current.state, ...current.queue, ...items];\n\n return {\n state: results.slice(0, limit),\n queue: results.slice(limit),\n };\n });\n\n const update = (fn: (state: T[]) => T[]) =>\n setState((current) => {\n const results = fn([...current.state, ...current.queue]);\n\n return {\n state: results.slice(0, limit),\n queue: results.slice(limit),\n };\n });\n\n const cleanQueue = () => setState((current) => ({ state: current.state, queue: [] }));\n\n return {\n state,\n queue,\n add,\n update,\n cleanQueue,\n };\n}\n"],"names":["useState"],"mappings":";;;;;;AACO,SAAS,QAAQ,CAAC,EAAE,aAAa,GAAG,EAAE,EAAE,KAAK,EAAE,EAAE;AACxD,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,QAAQ,CAAC,GAAGA,cAAQ,CAAC;AAChD,IAAI,KAAK,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC;AACxC,IAAI,KAAK,EAAE,aAAa,CAAC,KAAK,CAAC,KAAK,CAAC;AACrC,GAAG,CAAC,CAAC;AACL,EAAE,MAAM,GAAG,GAAG,CAAC,GAAG,KAAK,KAAK,QAAQ,CAAC,CAAC,OAAO,KAAK;AAClD,IAAI,MAAM,OAAO,GAAG,CAAC,GAAG,OAAO,CAAC,KAAK,EAAE,GAAG,OAAO,CAAC,KAAK,EAAE,GAAG,KAAK,CAAC,CAAC;AACnE,IAAI,OAAO;AACX,MAAM,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC;AACpC,MAAM,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC;AACjC,KAAK,CAAC;AACN,GAAG,CAAC,CAAC;AACL,EAAE,MAAM,MAAM,GAAG,CAAC,EAAE,KAAK,QAAQ,CAAC,CAAC,OAAO,KAAK;AAC/C,IAAI,MAAM,OAAO,GAAG,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,KAAK,EAAE,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;AAC7D,IAAI,OAAO;AACX,MAAM,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC;AACpC,MAAM,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC;AACjC,KAAK,CAAC;AACN,GAAG,CAAC,CAAC;AACL,EAAE,MAAM,UAAU,GAAG,MAAM,QAAQ,CAAC,CAAC,OAAO,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;AACxF,EAAE,OAAO;AACT,IAAI,KAAK;AACT,IAAI,KAAK;AACT,IAAI,GAAG;AACP,IAAI,MAAM;AACV,IAAI,UAAU;AACd,GAAG,CAAC;AACJ;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/useQueue/index.ts"],"sourcesContent":["import { useState } from 'react';\n\nexport function useQueue<T>({ initialValues = [], limit }: { initialValues?: T[]; limit: number }) {\n const [{ state, queue }, setState] = useState({\n state: initialValues.slice(0, limit),\n queue: initialValues.slice(limit),\n });\n\n const add = (...items: T[]) =>\n setState((current) => {\n const results = [...current.state, ...current.queue, ...items];\n\n return {\n state: results.slice(0, limit),\n queue: results.slice(limit),\n };\n });\n\n const update = (fn: (state: T[]) => T[]) =>\n setState((current) => {\n const results = fn([...current.state, ...current.queue]);\n\n return {\n state: results.slice(0, limit),\n queue: results.slice(limit),\n };\n });\n\n const cleanQueue = () => setState((current) => ({ state: current.state, queue: [] }));\n\n return {\n state,\n queue,\n add,\n update,\n cleanQueue,\n };\n}\n"],"names":["r"],"mappings":";;;;;;AAAwC,SAAS,QAAQ,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAACA,cAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAM,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,OAAM,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAM,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;;;;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var index=require("../useMediaQuery/index.js");function useReducedMotion(){return index.useMediaQuery("(prefers-reduced-motion: reduce)")}exports.useReducedMotion=useReducedMotion;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../useMediaQuery/index.js");function u(){return e.useMediaQuery("(prefers-reduced-motion: reduce)")}exports.useReducedMotion=u;
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/useReducedMotion/index.ts"],"sourcesContent":["import { useMediaQuery } from '../useMediaQuery';\n\nexport function useReducedMotion() {\n return useMediaQuery('(prefers-reduced-motion: reduce)');\n}\n"],"names":["useMediaQuery"],"mappings":";;;;;;AACO,SAAS,gBAAgB,GAAG;AACnC,EAAE,OAAOA,mBAAa,CAAC,kCAAkC,CAAC,CAAC;AAC3D;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/useReducedMotion/index.ts"],"sourcesContent":["import { useMediaQuery } from '../useMediaQuery';\n\nexport function useReducedMotion() {\n return useMediaQuery('(prefers-reduced-motion: reduce)');\n}\n"],"names":["e"],"mappings":";;;;;;AAAwD,SAAS,gBAAgB,EAAE,CAAC,OAAOA,mBAAC,CAAC,kCAAkC,CAAC;;;;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var react=require("react");function useScrollLock(e){const[t,o]=react.useState(e||!1),r=react.useRef(!1),c=react.useRef(null),u=()=>{r.current&&(r.current=!1,document.body.style.overflow=c.current||"")},l=()=>{r.current=!0,c.current=document.body.style.overflow,document.body.style.overflow="hidden"};return react.useEffect(()=>(t?l():u(),u),[t]),react.useEffect(()=>{e!==void 0&&o(e)},[e]),react.useEffect(()=>{e===void 0&&typeof window!="undefined"&&window.document.body.style.overflow==="hidden"&&o(!0)},[o]),[t,o]}exports.useScrollLock=useScrollLock;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react");function l(o){const[r,t]=e.useState(o||!1),u=e.useRef(!1),c=e.useRef(null),n=()=>{u.current&&(u.current=!1,document.body.style.overflow=c.current||"")},d=()=>{u.current=!0,c.current=document.body.style.overflow,document.body.style.overflow="hidden"};return e.useEffect(()=>(r?d():n(),n),[r]),e.useEffect(()=>{o!==void 0&&t(o)},[o]),e.useEffect(()=>{o===void 0&&typeof window!="undefined"&&window.document.body.style.overflow==="hidden"&&t(!0)},[t]),[r,t]}exports.useScrollLock=l;
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
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":["useState","useRef","useEffect"],"mappings":";;;;;;AACO,SAAS,aAAa,CAAC,IAAI,EAAE;AACpC,EAAE,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAGA,cAAQ,CAAC,IAAI,IAAI,KAAK,CAAC,CAAC;AAClE,EAAE,MAAM,MAAM,GAAGC,YAAM,CAAC,KAAK,CAAC,CAAC;AAC/B,EAAE,MAAM,YAAY,GAAGA,YAAM,CAAC,IAAI,CAAC,CAAC;AACpC,EAAE,MAAM,YAAY,GAAG,MAAM;AAC7B,IAAI,IAAI,MAAM,CAAC,OAAO,EAAE;AACxB,MAAM,MAAM,CAAC,OAAO,GAAG,KAAK,CAAC;AAC7B,MAAM,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,YAAY,CAAC,OAAO,IAAI,EAAE,CAAC;AAChE,KAAK;AACL,GAAG,CAAC;AACJ,EAAE,MAAM,UAAU,GAAG,MAAM;AAC3B,IAAI,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC;AAC1B,IAAI,YAAY,CAAC,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;AACxD,IAAI,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,QAAQ,CAAC;AAC5C,GAAG,CAAC;AACJ,EAAEC,eAAS,CAAC,MAAM;AAClB,IAAI,IAAI,YAAY,EAAE;AACtB,MAAM,UAAU,EAAE,CAAC;AACnB,KAAK,MAAM;AACX,MAAM,YAAY,EAAE,CAAC;AACrB,KAAK;AACL,IAAI,OAAO,YAAY,CAAC;AACxB,GAAG,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;AACrB,EAAEA,eAAS,CAAC,MAAM;AAClB,IAAI,IAAI,IAAI,KAAK,KAAK,CAAC,EAAE;AACzB,MAAM,eAAe,CAAC,IAAI,CAAC,CAAC;AAC5B,KAAK;AACL,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;AACb,EAAEA,eAAS,CAAC,MAAM;AAClB,IAAI,IAAI,IAAI,KAAK,KAAK,CAAC,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;AAC1D,MAAM,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,KAAK,QAAQ,IAAI,eAAe,CAAC,IAAI,CAAC,CAAC;AAChF,KAAK;AACL,GAAG,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC;AACxB,EAAE,OAAO,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC;AACzC;;;;"}
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
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var react=require("react");function useToggle(e,t){const[o,r]=react.useState(e);return[o,u=>{typeof u!="undefined"?r(u):r(s=>s===t[0]?t[1]:t[0])}]}function useBooleanToggle(e=!1){return useToggle(e,[!0,!1])}exports.useBooleanToggle=useBooleanToggle,exports.useToggle=useToggle;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var g=require("react");function r(e,o){const[t,n]=g.useState(e);return[t,u=>{n(typeof u!="undefined"?u:s=>s===o[0]?o[1]:o[0])}]}function l(e=!1){return r(e,[!0,!1])}exports.useBooleanToggle=l,exports.useToggle=r;
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/useToggle/index.ts"],"sourcesContent":["// https://github.com/mantinedev/mantine/blob/master/src/mantine-hooks/src/use-toggle/use-toggle.ts\nimport React, { useState } from 'react';\n\nexport function useToggle<T>(initialValue: T, options: [T, T]) {\n const [state, setState] = useState(initialValue);\n\n const toggle = (value?: React.SetStateAction<T>) => {\n if (typeof value !== 'undefined') {\n setState(value);\n } else {\n setState((current) => {\n if (current === options[0]) {\n return options[1];\n }\n\n return options[0];\n });\n }\n };\n\n return [state, toggle] as const;\n}\n\nexport function useBooleanToggle(initialValue = false) {\n return useToggle(initialValue, [true, false]);\n}\n"],"names":["useState"],"mappings":";;;;;;AACO,SAAS,SAAS,CAAC,YAAY,EAAE,OAAO,EAAE;AACjD,EAAE,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAGA,cAAQ,CAAC,YAAY,CAAC,CAAC;AACnD,EAAE,MAAM,MAAM,GAAG,CAAC,KAAK,KAAK;AAC5B,IAAI,IAAI,OAAO,KAAK,KAAK,WAAW,EAAE;AACtC,MAAM,QAAQ,CAAC,KAAK,CAAC,CAAC;AACtB,KAAK,MAAM;AACX,MAAM,QAAQ,CAAC,CAAC,OAAO,KAAK;AAC5B,QAAQ,IAAI,OAAO,KAAK,OAAO,CAAC,CAAC,CAAC,EAAE;AACpC,UAAU,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;AAC5B,SAAS;AACT,QAAQ,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;AAC1B,OAAO,CAAC,CAAC;AACT,KAAK;AACL,GAAG,CAAC;AACJ,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AACzB,CAAC;AACM,SAAS,gBAAgB,CAAC,YAAY,GAAG,KAAK,EAAE;AACvD,EAAE,OAAO,SAAS,CAAC,YAAY,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;AAChD;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/useToggle/index.ts"],"sourcesContent":["// https://github.com/mantinedev/mantine/blob/master/src/mantine-hooks/src/use-toggle/use-toggle.ts\nimport React, { useState } from 'react';\n\nexport function useToggle<T>(initialValue: T, options: [T, T]) {\n const [state, setState] = useState(initialValue);\n\n const toggle = (value?: React.SetStateAction<T>) => {\n if (typeof value !== 'undefined') {\n setState(value);\n } else {\n setState((current) => {\n if (current === options[0]) {\n return options[1];\n }\n\n return options[0];\n });\n }\n };\n\n return [state, toggle] as const;\n}\n\nexport function useBooleanToggle(initialValue = false) {\n return useToggle(initialValue, [true, false]);\n}\n"],"names":["s"],"mappings":";;;;;;AAAwC,SAAS,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAACA,cAAC,CAAC,CAAC,CAAC,CAAC,OAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,CAAQ,SAAS,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,SAAS,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 react=require("react");function useUncontrolled({value:r,defaultValue:c,finalValue:l,rule:u,onChange:s,onValueUpdate:i}){const o=u(r),t=react.useRef("initial"),a=u(c)?c:l,[p,d]=react.useState(a);let e=o?r:p;!o&&t.current==="controlled"&&(e=l),t.current=o?"controlled":"uncontrolled";const n=t.current,y=f=>{typeof s=="function"&&s(f),n==="uncontrolled"&&d(f)};return react.useEffect(()=>{n==="uncontrolled"&&d(e),typeof i=="function"&&i(e)},[n,e]),[e,y,t.current]}exports.useUncontrolled=useUncontrolled;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var o=require("react");function U({value:r,defaultValue:u,finalValue:c,rule:a,onChange:f,onValueUpdate:s}){const t=a(r),n=o.useRef("initial"),p=a(u)?u:c,[v,d]=o.useState(p);let e=t?r:v;!t&&n.current==="controlled"&&(e=c),n.current=t?"controlled":"uncontrolled";const l=n.current,y=i=>{typeof f=="function"&&f(i),l==="uncontrolled"&&d(i)};return o.useEffect(()=>{l==="uncontrolled"&&d(e),typeof s=="function"&&s(e)},[l,e]),[e,y,n.current]}exports.useUncontrolled=U;
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/useUncontrolled/index.ts"],"sourcesContent":["// https://github.com/mantinedev/mantine/blob/master/src/mantine-hooks/src/use-uncontrolled/use-uncontrolled.ts\nimport { useEffect, useRef, useState } from 'react';\n\nexport type UncontrolledMode = 'initial' | 'controlled' | 'uncontrolled';\n\nexport interface UncontrolledOptions<T> {\n value: T | null | undefined;\n defaultValue: T | null | undefined;\n finalValue: T | null;\n onChange(value: T | null): void;\n onValueUpdate?(value: T | null): void;\n rule: (value: T | null | undefined) => boolean;\n}\n\nexport function useUncontrolled<T>({\n value,\n defaultValue,\n finalValue,\n rule,\n onChange,\n onValueUpdate,\n}: UncontrolledOptions<T>): readonly [T | null, (nextValue: T | null) => void, UncontrolledMode] {\n // determine, whether new props indicate controlled state\n const shouldBeControlled = rule(value);\n\n // initialize state\n const modeRef = useRef<UncontrolledMode>('initial');\n const initialValue = rule(defaultValue) ? defaultValue : finalValue;\n const [uncontrolledValue, setUncontrolledValue] = useState(initialValue);\n\n // compute effective value\n let effectiveValue = shouldBeControlled ? value : uncontrolledValue;\n\n if (!shouldBeControlled && modeRef.current === 'controlled') {\n // We are transitioning from controlled to uncontrolled\n // this transition is special as it happens when clearing out\n // the input using \"invalid\" value (typically null or undefined).\n //\n // Since the value is invalid, doing nothing would mean just\n // transitioning to uncontrolled state and using whatever value\n // it currently holds which is likely not the bavior\n // user expects, so lets change the state to finalValue.\n //\n // The value will be propagated to internal state by useEffect below.\n\n effectiveValue = finalValue;\n }\n modeRef.current = shouldBeControlled ? 'controlled' : 'uncontrolled';\n const mode = modeRef.current;\n\n const handleChange = (nextValue: T | null) => {\n typeof onChange === 'function' && onChange(nextValue);\n\n // Controlled input only triggers onChange event and expects\n // the controller to propagate new value back.\n if (mode === 'uncontrolled') {\n setUncontrolledValue(nextValue);\n }\n };\n\n useEffect(() => {\n if (mode === 'uncontrolled') {\n setUncontrolledValue(effectiveValue);\n }\n typeof onValueUpdate === 'function' && onValueUpdate(effectiveValue);\n }, [mode, effectiveValue]);\n\n return [effectiveValue, handleChange, modeRef.current] as const;\n}\n"],"names":["useRef","useState","useEffect"],"mappings":";;;;;;AACO,SAAS,eAAe,CAAC;AAChC,EAAE,KAAK;AACP,EAAE,YAAY;AACd,EAAE,UAAU;AACZ,EAAE,IAAI;AACN,EAAE,QAAQ;AACV,EAAE,aAAa;AACf,CAAC,EAAE;AACH,EAAE,MAAM,kBAAkB,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;AACzC,EAAE,MAAM,OAAO,GAAGA,YAAM,CAAC,SAAS,CAAC,CAAC;AACpC,EAAE,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,YAAY,GAAG,UAAU,CAAC;AACtE,EAAE,MAAM,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,GAAGC,cAAQ,CAAC,YAAY,CAAC,CAAC;AAC3E,EAAE,IAAI,cAAc,GAAG,kBAAkB,GAAG,KAAK,GAAG,iBAAiB,CAAC;AACtE,EAAE,IAAI,CAAC,kBAAkB,IAAI,OAAO,CAAC,OAAO,KAAK,YAAY,EAAE;AAC/D,IAAI,cAAc,GAAG,UAAU,CAAC;AAChC,GAAG;AACH,EAAE,OAAO,CAAC,OAAO,GAAG,kBAAkB,GAAG,YAAY,GAAG,cAAc,CAAC;AACvE,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC;AAC/B,EAAE,MAAM,YAAY,GAAG,CAAC,SAAS,KAAK;AACtC,IAAI,OAAO,QAAQ,KAAK,UAAU,IAAI,QAAQ,CAAC,SAAS,CAAC,CAAC;AAC1D,IAAI,IAAI,IAAI,KAAK,cAAc,EAAE;AACjC,MAAM,oBAAoB,CAAC,SAAS,CAAC,CAAC;AACtC,KAAK;AACL,GAAG,CAAC;AACJ,EAAEC,eAAS,CAAC,MAAM;AAClB,IAAI,IAAI,IAAI,KAAK,cAAc,EAAE;AACjC,MAAM,oBAAoB,CAAC,cAAc,CAAC,CAAC;AAC3C,KAAK;AACL,IAAI,OAAO,aAAa,KAAK,UAAU,IAAI,aAAa,CAAC,cAAc,CAAC,CAAC;AACzE,GAAG,EAAE,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC;AAC7B,EAAE,OAAO,CAAC,cAAc,EAAE,YAAY,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;AACzD;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/useUncontrolled/index.ts"],"sourcesContent":["// https://github.com/mantinedev/mantine/blob/master/src/mantine-hooks/src/use-uncontrolled/use-uncontrolled.ts\nimport { useEffect, useRef, useState } from 'react';\n\nexport type UncontrolledMode = 'initial' | 'controlled' | 'uncontrolled';\n\nexport interface UncontrolledOptions<T> {\n value: T | null | undefined;\n defaultValue: T | null | undefined;\n finalValue: T | null;\n onChange(value: T | null): void;\n onValueUpdate?(value: T | null): void;\n rule: (value: T | null | undefined) => boolean;\n}\n\nexport function useUncontrolled<T>({\n value,\n defaultValue,\n finalValue,\n rule,\n onChange,\n onValueUpdate,\n}: UncontrolledOptions<T>): readonly [T | null, (nextValue: T | null) => void, UncontrolledMode] {\n // determine, whether new props indicate controlled state\n const shouldBeControlled = rule(value);\n\n // initialize state\n const modeRef = useRef<UncontrolledMode>('initial');\n const initialValue = rule(defaultValue) ? defaultValue : finalValue;\n const [uncontrolledValue, setUncontrolledValue] = useState(initialValue);\n\n // compute effective value\n let effectiveValue = shouldBeControlled ? value : uncontrolledValue;\n\n if (!shouldBeControlled && modeRef.current === 'controlled') {\n // We are transitioning from controlled to uncontrolled\n // this transition is special as it happens when clearing out\n // the input using \"invalid\" value (typically null or undefined).\n //\n // Since the value is invalid, doing nothing would mean just\n // transitioning to uncontrolled state and using whatever value\n // it currently holds which is likely not the bavior\n // user expects, so lets change the state to finalValue.\n //\n // The value will be propagated to internal state by useEffect below.\n\n effectiveValue = finalValue;\n }\n modeRef.current = shouldBeControlled ? 'controlled' : 'uncontrolled';\n const mode = modeRef.current;\n\n const handleChange = (nextValue: T | null) => {\n typeof onChange === 'function' && onChange(nextValue);\n\n // Controlled input only triggers onChange event and expects\n // the controller to propagate new value back.\n if (mode === 'uncontrolled') {\n setUncontrolledValue(nextValue);\n }\n };\n\n useEffect(() => {\n if (mode === 'uncontrolled') {\n setUncontrolledValue(effectiveValue);\n }\n typeof onValueUpdate === 'function' && onValueUpdate(effectiveValue);\n }, [mode, effectiveValue]);\n\n return [effectiveValue, handleChange, modeRef.current] as const;\n}\n"],"names":["U","m","v"],"mappings":";;;;;;AAAmE,SAAS,eAAe,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAACA,YAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAACC,cAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,OAAO,GAAG,YAAY,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,YAAY,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,cAAc,EAAE,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,OAAOC,eAAC,CAAC,IAAI,CAAC,CAAC,GAAG,cAAc,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;;;;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var react=require("react");function useUnmount(e){const t=react.useRef(e);t.current=e,react.useEffect(()=>()=>{t.current()},[])}exports.useUnmount=useUnmount;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var u=require("react");function r(e){const t=u.useRef(e);t.current=e,u.useEffect(()=>()=>{t.current()},[])}exports.useUnmount=r;
2
2
  //# sourceMappingURL=index.js.map