@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
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/useUnmount/index.ts"],"sourcesContent":["import { useRef, useEffect } from 'react';\n\nexport function useUnmount(fn: () => void) {\n const fnRef = useRef(fn);\n fnRef.current = fn;\n\n useEffect(\n () => () => {\n fnRef.current();\n },\n []\n );\n}\n"],"names":["useRef","useEffect"],"mappings":";;;;;;AACO,SAAS,UAAU,CAAC,EAAE,EAAE;AAC/B,EAAE,MAAM,KAAK,GAAGA,YAAM,CAAC,EAAE,CAAC,CAAC;AAC3B,EAAE,KAAK,CAAC,OAAO,GAAG,EAAE,CAAC;AACrB,EAAEC,eAAS,CAAC,MAAM,MAAM;AACxB,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;AACpB,GAAG,EAAE,EAAE,CAAC,CAAC;AACT;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/useUnmount/index.ts"],"sourcesContent":["import { useRef, useEffect } from 'react';\n\nexport function useUnmount(fn: () => void) {\n const fnRef = useRef(fn);\n fnRef.current = fn;\n\n useEffect(\n () => () => {\n fnRef.current();\n },\n []\n );\n}\n"],"names":["r","n"],"mappings":";;;;;;AAAqD,SAAS,UAAU,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAACA,YAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAACC,eAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,OAAO,GAAE,CAAC,CAAC,EAAE,EAAC;;;;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var react=require("react");function useWindowEvent(e,r,t){react.useEffect(()=>(window.addEventListener(e,r,t),()=>window.removeEventListener(e,r,t)),[])}exports.useWindowEvent=useWindowEvent;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var r=require("react");function i(e,t,n){r.useEffect(()=>(window.addEventListener(e,t,n),()=>window.removeEventListener(e,t,n)),[])}exports.useWindowEvent=i;
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/useWindowEvent/index.ts"],"sourcesContent":["import { useEffect } from 'react';\n\nexport function useWindowEvent<K extends keyof WindowEventMap>(\n type: K,\n listener: (this: Window, ev: WindowEventMap[K]) => any,\n options?: boolean | AddEventListenerOptions\n) {\n useEffect(() => {\n window.addEventListener(type, listener, options);\n return () => window.removeEventListener(type, listener, options);\n }, []);\n}\n"],"names":["useEffect"],"mappings":";;;;;;AACO,SAAS,cAAc,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE;AACxD,EAAEA,eAAS,CAAC,MAAM;AAClB,IAAI,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;AACrD,IAAI,OAAO,MAAM,MAAM,CAAC,mBAAmB,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;AACrE,GAAG,EAAE,EAAE,CAAC,CAAC;AACT;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/useWindowEvent/index.ts"],"sourcesContent":["import { useEffect } from 'react';\n\nexport function useWindowEvent<K extends keyof WindowEventMap>(\n type: K,\n listener: (this: Window, ev: WindowEventMap[K]) => any,\n options?: boolean | AddEventListenerOptions\n) {\n useEffect(() => {\n window.addEventListener(type, listener, options);\n return () => window.removeEventListener(type, listener, options);\n }, []);\n}\n"],"names":["o"],"mappings":";;;;;;AAAyC,SAAS,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAACA,eAAC,CAAC,KAAK,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAC;;;;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var react=require("react");function useWindowResize(i,t){const[n,r]=react.useState(t);react.useEffect(()=>{const e=()=>{r(window.innerWidth),i()};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[n])}exports.useWindowResize=useWindowResize;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react");function o(i,n){const[r,s]=t.useState(n);t.useEffect(()=>{const e=()=>{s(window.innerWidth),i()};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[r])}exports.useWindowResize=o;
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/useWindowResize/index.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nexport function useWindowResize(handler: { (): void }, initialWindowSize?: number) {\n const [windowSize, setWindowSize] = useState<undefined | number>(initialWindowSize);\n useEffect(() => {\n const handleResize = () => {\n setWindowSize(window.innerWidth);\n handler();\n };\n window.addEventListener('resize', handleResize);\n\n return () => window.removeEventListener('resize', handleResize);\n }, [windowSize]);\n}\n"],"names":["useState","useEffect"],"mappings":";;;;;;AACO,SAAS,eAAe,CAAC,OAAO,EAAE,iBAAiB,EAAE;AAC5D,EAAE,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAGA,cAAQ,CAAC,iBAAiB,CAAC,CAAC;AAClE,EAAEC,eAAS,CAAC,MAAM;AAClB,IAAI,MAAM,YAAY,GAAG,MAAM;AAC/B,MAAM,aAAa,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;AACvC,MAAM,OAAO,EAAE,CAAC;AAChB,KAAK,CAAC;AACN,IAAI,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;AACpD,IAAI,OAAO,MAAM,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;AACpE,GAAG,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;AACnB;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/useWindowResize/index.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nexport function useWindowResize(handler: { (): void }, initialWindowSize?: number) {\n const [windowSize, setWindowSize] = useState<undefined | number>(initialWindowSize);\n useEffect(() => {\n const handleResize = () => {\n setWindowSize(window.innerWidth);\n handler();\n };\n window.addEventListener('resize', handleResize);\n\n return () => window.removeEventListener('resize', handleResize);\n }, [windowSize]);\n}\n"],"names":["d","r"],"mappings":";;;;;;AAAuD,SAAS,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAACA,cAAC,CAAC,CAAC,CAAC,CAACC,eAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,GAAE,CAAC,CAAC,OAAO,MAAM,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAC;;;;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});function randomId(){return`kubed-${Math.random().toString(36).substr(2,9)}`}function clamp({value:t,min:n,max:e}){return Math.min(Math.max(t,n),e)}function assignRef(t,n){typeof t=="function"?t(n):typeof t=="object"&&t!==null&&"current"in t&&(t.current=n)}exports.assignRef=assignRef,exports.clamp=clamp,exports.randomId=randomId;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});function r(){return`kubed-${Math.random().toString(36).substr(2,9)}`}function u({value:t,min:e,max:n}){return Math.min(Math.max(t,e),n)}function a(t,e){typeof t=="function"?t(e):typeof t=="object"&&t!==null&&"current"in t&&(t.current=e)}exports.assignRef=a,exports.clamp=u,exports.randomId=r;
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/utils/index.ts"],"sourcesContent":["import React from 'react';\n\nexport function randomId() {\n return `kubed-${Math.random().toString(36).substr(2, 9)}`;\n}\n\ninterface Clamp {\n value: number;\n min: number;\n max: number;\n}\n\nexport function clamp({ value, min, max }: Clamp) {\n return Math.min(Math.max(value, min), max);\n}\n\nexport function assignRef<T = any>(ref: React.ForwardedRef<T>, value: T | null) {\n if (typeof ref === 'function') {\n ref(value);\n } else if (typeof ref === 'object' && ref !== null && 'current' in ref) {\n // eslint-disable-next-line no-param-reassign\n ref.current = value;\n }\n}\n"],"names":[],"mappings":";;;;AAAO,SAAS,QAAQ,GAAG;AAC3B,EAAE,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5D,CAAC;AACM,SAAS,KAAK,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE;AAC3C,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;AAC7C,CAAC;AACM,SAAS,SAAS,CAAC,GAAG,EAAE,KAAK,EAAE;AACtC,EAAE,IAAI,OAAO,GAAG,KAAK,UAAU,EAAE;AACjC,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;AACf,GAAG,MAAM,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,IAAI,SAAS,IAAI,GAAG,EAAE;AAC1E,IAAI,GAAG,CAAC,OAAO,GAAG,KAAK,CAAC;AACxB,GAAG;AACH;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/utils/index.ts"],"sourcesContent":["import React from 'react';\n\nexport function randomId() {\n return `kubed-${Math.random().toString(36).substr(2, 9)}`;\n}\n\ninterface Clamp {\n value: number;\n min: number;\n max: number;\n}\n\nexport function clamp({ value, min, max }: Clamp) {\n return Math.min(Math.max(value, min), max);\n}\n\nexport function assignRef<T = any>(ref: React.ForwardedRef<T>, value: T | null) {\n if (typeof ref === 'function') {\n ref(value);\n } else if (typeof ref === 'object' && ref !== null && 'current' in ref) {\n // eslint-disable-next-line no-param-reassign\n ref.current = value;\n }\n}\n"],"names":[],"mappings":";;;;AAAO,SAAS,QAAQ,EAAE,CAAC,OAAM,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAQ,SAAS,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAQ,SAAS,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,SAAS,GAAG,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,EAAC;;;;;;"}
package/esm/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export{assignRef,clamp,randomId}from"./utils/index.js";export{useId}from"./useId/index.js";export{useBooleanToggle,useToggle}from"./useToggle/index.js";export{useUncontrolled}from"./useUncontrolled/index.js";export{useMediaQuery}from"./useMediaQuery/index.js";export{useReducedMotion}from"./useReducedMotion/index.js";export{useWindowEvent}from"./useWindowEvent/index.js";export{useLocalStorage}from"./useLocalStorage/index.js";export{useForceUpdate}from"./useForceUpdate/index.js";export{useClipboard}from"./useClipboard/index.js";export{useQueue}from"./useQueue/index.js";export{useClickOutside}from"./useClickOutside/index.js";export{useMove}from"./useMove/index.js";export{useHotkeys}from"./useHotkeys/index.js";export{mergeRefs,useMergedRef}from"./useMergedRef/index.js";export{useDebouncedValue}from"./useDebouncedValue/index.js";export{useDidMount}from"./useDidMount/index.js";export{useDidUpdate}from"./useDidUpdate/index.js";export{useUnmount}from"./useUnmount/index.js";export{usePrevious}from"./usePrevious/index.js";export{useScrollLock}from"./useScrollLock/index.js";export{useHover}from"./useHover/index.js";export{useWindowResize}from"./useWindowResize/index.js";export{useDisclosure}from"./useDisclosure/index.js";
1
+ import{assignRef as s,clamp as r,randomId as u}from"./utils/index.js";import{useId as i}from"./useId/index.js";import{useBooleanToggle as n,useToggle as t}from"./useToggle/index.js";import{useUncontrolled as m}from"./useUncontrolled/index.js";import{useMediaQuery as j}from"./useMediaQuery/index.js";import{useReducedMotion as c}from"./useReducedMotion/index.js";import{useWindowEvent as g}from"./useWindowEvent/index.js";import{useLocalStorage as v}from"./useLocalStorage/index.js";import{useForceUpdate as R}from"./useForceUpdate/index.js";import{useClipboard as k}from"./useClipboard/index.js";import{useQueue as w}from"./useQueue/index.js";import{useClickOutside as C}from"./useClickOutside/index.js";import{useMove as L}from"./useMove/index.js";import{useHotkeys as S}from"./useHotkeys/index.js";import{mergeRefs as I,useMergedRef as T}from"./useMergedRef/index.js";import{useDebouncedValue as E}from"./useDebouncedValue/index.js";import{useDidMount as O}from"./useDidMount/index.js";import{useDidUpdate as V}from"./useDidUpdate/index.js";import{useUnmount as h}from"./useUnmount/index.js";import{usePrevious as A}from"./usePrevious/index.js";import{useScrollLock as J}from"./useScrollLock/index.js";import{useHover as N}from"./useHover/index.js";import{useWindowResize as Y}from"./useWindowResize/index.js";import{useDisclosure as _}from"./useDisclosure/index.js";export{s as assignRef,r as clamp,I as mergeRefs,u as randomId,n as useBooleanToggle,C as useClickOutside,k as useClipboard,E as useDebouncedValue,O as useDidMount,V as useDidUpdate,_ as useDisclosure,R as useForceUpdate,S as useHotkeys,N as useHover,i as useId,v as useLocalStorage,j as useMediaQuery,T as useMergedRef,L as useMove,A as usePrevious,w as useQueue,c as useReducedMotion,J as useScrollLock,t as useToggle,m as useUncontrolled,h as useUnmount,g as useWindowEvent,Y as useWindowResize};
2
2
  //# sourceMappingURL=index.js.map
@@ -1,2 +1,2 @@
1
- import{useRef as i,useEffect as f}from"react";const u=["mousedown","touchstart"];function a(e,o,c){const t=i();return f(()=>{const s=r=>{Array.isArray(c)?c.every(n=>!!n&&!n.contains(r.target))&&e():t.current&&!t.current.contains(r.target)&&e()};return(o||u).forEach(r=>document.addEventListener(r,s)),()=>{(o||u).forEach(r=>document.removeEventListener(r,s))}},[t,e,c]),t}export{a as useClickOutside};
1
+ import{useRef as a,useEffect as i}from"react";const u=["mousedown","touchstart"];function f(r,o,n){const t=a();return i(()=>{const c=e=>{Array.isArray(n)?n.every(s=>!!s&&!s.contains(e.target))&&r():t.current&&!t.current.contains(e.target)&&r()};return(o||u).forEach(e=>document.addEventListener(e,c)),()=>{(o||u).forEach(e=>document.removeEventListener(e,c))}},[t,r,n]),t}export{f as useClickOutside};
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/useClickOutside/index.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\n\nconst DEFAULT_EVENTS = ['mousedown', 'touchstart'];\n\nexport function useClickOutside<T extends HTMLElement = any>(\n handler: () => void,\n events?: string[] | null,\n nodes?: HTMLElement[]\n) {\n const ref = useRef<T>();\n\n useEffect(() => {\n const listener = (event: any) => {\n if (Array.isArray(nodes)) {\n const shouldTrigger = nodes.every((node) => !!node && !node.contains(event.target));\n shouldTrigger && handler();\n } else if (ref.current && !ref.current.contains(event.target)) {\n handler();\n }\n };\n\n (events || DEFAULT_EVENTS).forEach((fn) => document.addEventListener(fn, listener));\n\n return () => {\n (events || DEFAULT_EVENTS).forEach((fn) => document.removeEventListener(fn, listener));\n };\n }, [ref, handler, nodes]);\n\n return ref;\n}\n"],"names":[],"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,GAAG,MAAM,EAAE,CAAC;AACvB,EAAE,SAAS,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,MAAC,EAAE,CAAC,OAAOC,SAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,GAAE,CAAC,CAAC,OAAM,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,QAAQ,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,QAAQ,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;;;;"}
@@ -1,2 +1,2 @@
1
- import{useState as r}from"react";function u({timeout:i=2e3}={}){const[a,e]=r(null),[n,o]=r(!1),[s,c]=r(null),l=t=>{clearTimeout(s),c(setTimeout(()=>o(!1),i)),o(t)};return{copy:t=>{"clipboard"in navigator?navigator.clipboard.writeText(t).then(()=>l(!0)).catch(p=>e(p)):e(new Error("useClipboard: navigator.clipboard is not supported"))},reset:()=>{o(!1),e(null),clearTimeout(s)},error:a,copied:n}}export{u as useClipboard};
1
+ import{useState as t}from"react";function s({timeout:a=2e3}={}){const[l,e]=t(null),[n,r]=t(!1),[i,c]=t(null),u=o=>{clearTimeout(i),c(setTimeout(()=>r(!1),a)),r(o)};return{copy:o=>{"clipboard"in navigator?navigator.clipboard.writeText(o).then(()=>u(!0)).catch(p=>e(p)):e(new Error("useClipboard: navigator.clipboard is not supported"))},reset:()=>{r(!1),e(null),clearTimeout(i)},error:l,copied:n}}export{s as useClipboard};
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":[],"mappings":";;AACO,SAAS,YAAY,CAAC,EAAE,OAAO,GAAG,GAAG,EAAE,GAAG,EAAE,EAAE;AACrD,EAAE,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;AAC3C,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC9C,EAAE,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,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,QAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAACA,QAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAACA,QAAC,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
- import{useState as i,useRef as r,useEffect as f}from"react";function d(e,l,u={leading:!1}){const[a,c]=i(e),o=r(!1),s=r(null),t=r(!1),n=()=>window.clearTimeout(s.current);return f(()=>{o.current&&(!t.current&&u.leading?(t.current=!0,c(e)):(n(),s.current=window.setTimeout(()=>{t.current=!1,c(e)},l)))},[e,u.leading]),f(()=>(o.current=!0,n),[]),[a,n]}export{d as useDebouncedValue};
1
+ import{useState as d,useRef as n,useEffect as l}from"react";function f(e,a,u={leading:!1}){const[s,c]=d(e),o=n(!1),i=n(null),r=n(!1),t=()=>window.clearTimeout(i.current);return l(()=>{o.current&&(!r.current&&u.leading?(r.current=!0,c(e)):(t(),i.current=window.setTimeout(()=>{r.current=!1,c(e)},a)))},[e,u.leading]),l(()=>(o.current=!0,t),[]),[s,t]}export{f as useDebouncedValue};
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":[],"mappings":";;AACO,SAAS,iBAAiB,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE;AAC7E,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC7C,EAAE,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;AACnC,EAAE,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;AAClC,EAAE,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;AACpC,EAAE,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;AAC/D,EAAE,SAAS,CAAC,MAAM;AAClB,IAAI,IAAI,UAAU,CAAC,OAAO,EAAE;AAC5B,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,IAAI,OAAO,CAAC,OAAO,EAAE;AACnD,QAAQ,WAAW,CAAC,OAAO,GAAG,IAAI,CAAC;AACnC,QAAQ,QAAQ,CAAC,KAAK,CAAC,CAAC;AACxB,OAAO,MAAM;AACb,QAAQ,MAAM,EAAE,CAAC;AACjB,QAAQ,UAAU,CAAC,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,MAAM;AACrD,UAAU,WAAW,CAAC,OAAO,GAAG,KAAK,CAAC;AACtC,UAAU,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC1B,SAAS,EAAE,IAAI,CAAC,CAAC;AACjB,OAAO;AACP,KAAK;AACL,GAAG,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;AAC/B,EAAE,SAAS,CAAC,MAAM;AAClB,IAAI,UAAU,CAAC,OAAO,GAAG,IAAI,CAAC;AAC9B,IAAI,OAAO,MAAM,CAAC;AAClB,GAAG,EAAE,EAAE,CAAC,CAAC;AACT,EAAE,OAAO,CAAC,MAAM,EAAE,MAAM,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,QAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAACC,MAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAACA,MAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAACA,MAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,OAAOC,SAAC,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,SAAC,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
- import{useEffect as f}from"react";function o(t){f(()=>{typeof t=="function"&&t()},[])}export{o as useDidMount};
1
+ import{useEffect as e}from"react";function f(t){e(()=>{typeof t=="function"&&t()},[])}export{f as useDidMount};
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":[],"mappings":";;AACO,SAAS,WAAW,CAAC,QAAQ,EAAE;AACtC,EAAE,SAAS,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,SAAC,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,UAAU,EAAE,CAAC,GAAE,CAAC,CAAC,EAAE,EAAC;;;;"}
@@ -1,2 +1,2 @@
1
- import{useRef as u,useEffect as f}from"react";function c(t,r){const e=u(!1);f(()=>{e.current?t():e.current=!0},r)}export{c as useDidUpdate};
1
+ import{useRef as c,useEffect as u}from"react";function f(t,r){const e=c(!1);u(()=>{e.current?t():e.current=!0},r)}export{f as useDidUpdate};
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":[],"mappings":";;AACO,SAAS,YAAY,CAAC,EAAE,EAAE,YAAY,EAAE;AAC/C,EAAE,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;AAChC,EAAE,SAAS,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,MAAC,CAAC,CAAC,CAAC,CAAC,CAACC,SAAC,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
- import{useState as l,useCallback as o}from"react";function u(c=!1){const[e,n]=l(c),s=o(()=>n(!0),[]),t=o(()=>n(!1),[]),r=o(()=>e?t():s(),[e,t,s]);return{isOpen:e,open:s,close:t,toggle:r}}export{u as useDisclosure};
1
+ import{useState as u,useCallback as s}from"react";function l(n=!1){const[e,r]=u(n),t=s(()=>r(!0),[]),o=s(()=>r(!1),[]),c=s(()=>e?o():t(),[e,o,t]);return{isOpen:e,open:t,close:o,toggle:c}}export{l as useDisclosure};
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":[],"mappings":";;AACO,SAAS,aAAa,CAAC,aAAa,GAAG,KAAK,EAAE;AACrD,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,aAAa,CAAC,CAAC;AACtD,EAAE,MAAM,IAAI,GAAG,WAAW,CAAC,MAAM,SAAS,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;AACtD,EAAE,MAAM,KAAK,GAAG,WAAW,CAAC,MAAM,SAAS,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC;AACxD,EAAE,MAAM,MAAM,GAAG,WAAW,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,QAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAACC,WAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAACA,WAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAACA,WAAC,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
- import{useReducer as r}from"react";const t=e=>(e+1)%1e6;function c(){const[,e]=r(t,0);return e}export{c as useForceUpdate};
1
+ import{useReducer as t}from"react";const r=e=>(e+1)%1e6;function o(){const[,e]=t(r,0);return e}export{o as useForceUpdate};
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":[],"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,GAAG,UAAU,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,UAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;;;;"}
@@ -1,2 +1,2 @@
1
- import{useEffect as m}from"react";import{getHotkeyMatcher as c}from"./parseHotkey.js";function d(t){m(()=>{const o=e=>{t.forEach(([n,r])=>{c(n)(e)&&(e.preventDefault(),r(e))})};return document.documentElement.addEventListener("keydown",o),()=>document.documentElement.removeEventListener("keydown",o)},[t])}export{d as useHotkeys};
1
+ import{useEffect as m}from"react";import{getHotkeyMatcher as c}from"./parseHotkey.js";function u(t){m(()=>{const o=e=>{t.forEach(([n,r])=>{c(n)(e)&&(e.preventDefault(),r(e))})};return document.documentElement.addEventListener("keydown",o),()=>document.documentElement.removeEventListener("keydown",o)},[t])}export{u as useHotkeys};
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":[],"mappings":";;;AAGO,SAAS,UAAU,CAAC,OAAO,EAAE;AACpC,EAAE,SAAS,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,IAAI,gBAAgB,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,SAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAACC,gBAAC,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
- var _=Object.defineProperty,w=Object.defineProperties,O=Object.getOwnPropertyDescriptors,l=Object.getOwnPropertySymbols,P=Object.prototype.hasOwnProperty,v=Object.prototype.propertyIsEnumerable,c=(r,e,t)=>e in r?_(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,h=(r,e)=>{for(var t in e||(e={}))P.call(e,t)&&c(r,t,e[t]);if(l)for(var t of l(e))v.call(e,t)&&c(r,t,e[t]);return r},K=(r,e)=>w(r,O(e));function p(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 K(h({},t),{key:a})}function g(r,e){const{alt:t,ctrl:o,meta:a,mod:s,shift:u,key:n}=r,{altKey:d,ctrlKey:i,metaKey:f,shiftKey:y,key:m}=e;if(t!==d)return!1;if(s){if(!i&&!f)return!1}else if(o!==i||a!==f)return!1;return u!==y?!1:!!(n&&(m.toLowerCase()===n.toLowerCase()||e.code.replace("Key","").toLowerCase()===n.toLowerCase()))}function k(r){return e=>g(p(r),e)}export{k as getHotkeyMatcher,p as parseHotkey};
1
+ var b=Object.defineProperty,v=Object.defineProperties,w=Object.getOwnPropertyDescriptors,s=Object.getOwnPropertySymbols,O=Object.prototype.hasOwnProperty,h=Object.prototype.propertyIsEnumerable,f=(r,e,t)=>e in r?b(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,j=(r,e)=>{for(var t in e||(e={}))O.call(e,t)&&f(r,t,e[t]);if(s)for(var t of s(e))h.call(e,t)&&f(r,t,e[t]);return r},k=(r,e)=>v(r,w(e));function u(r){const e=r.toLowerCase().split("+").map(o=>o.trim()),t={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 k(j({},t),{key:n})}function K(r,e){const{alt:t,ctrl:a,meta:n,mod:o,shift:y,key:i}=r,{altKey:p,ctrlKey:c,metaKey:l,shiftKey:d,key:m}=e;if(t!==p)return!1;if(o){if(!c&&!l)return!1}else if(a!==c||n!==l)return!1;return y!==d?!1:!!(i&&(m.toLowerCase()===i.toLowerCase()||e.code.replace("Key","").toLowerCase()===i.toLowerCase()))}function C(r){return e=>K(u(r),e)}export{C as getHotkeyMatcher,u as parseHotkey};
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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;AACnB,KAAK;AACL,GAAG;AACH,EAAE,IAAI,KAAK,KAAK,QAAQ,EAAE;AAC1B,IAAI,OAAO,KAAK,CAAC;AACjB,GAAG;AACH,EAAE,IAAI,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,I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C,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,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
- import{useState as u,useRef as v,useEffect as a}from"react";function l(){const[o,n]=u(!1),t=v(null),r=()=>n(!0),s=()=>n(!1);return a(()=>{const e=t==null?void 0:t.current;if(e)return e.addEventListener("mouseenter",r),e.addEventListener("mouseleave",s),()=>{e.removeEventListener("mouseenter",r),e.removeEventListener("mouseleave",s)}},[]),{ref:t,isHovered:o}}export{l as useHover};
1
+ import{useState as u,useRef as v,useEffect as i}from"react";function m(){const[s,r]=u(!1),t=v(null),n=()=>r(!0),o=()=>r(!1);return i(()=>{const e=t==null?void 0:t.current;if(e)return e.addEventListener("mouseenter",n),e.addEventListener("mouseleave",o),()=>{e.removeEventListener("mouseenter",n),e.removeEventListener("mouseleave",o)}},[]),{ref:t,isHovered:s}}export{m as useHover};
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":[],"mappings":";;AACO,SAAS,QAAQ,GAAG;AAC3B,EAAE,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;AACpD,EAAE,MAAM,GAAG,GAAG,MAAM,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,EAAE,SAAS,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,QAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAACC,MAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAOC,SAAC,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
- import{useRef as n}from"react";import{randomId as o}from"../utils/index.js";function d(r,e=o){const t=n(e());return r||t.current}export{d as useId};
1
+ import{useRef as o}from"react";import{randomId as n}from"../utils/index.js";function u(r,e=n){const t=o(e());return r||t.current}export{u as useId};
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":[],"mappings":";;;AAEO,SAAS,KAAK,CAAC,EAAE,EAAE,UAAU,GAAG,QAAQ,EAAE;AACjD,EAAE,MAAM,WAAW,GAAG,MAAM,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,QAAC,CAAC,CAAC,MAAM,CAAC,CAACC,MAAC,CAAC,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,OAAO;;;;"}
@@ -1,2 +1,2 @@
1
- import{useState as w,useCallback as a,useEffect as l}from"react";import{useWindowEvent as g}from"../useWindowEvent/index.js";function u({key:e,defaultValue:t=void 0}){const[n,r]=w(typeof window!="undefined"&&"localStorage"in window?window.localStorage.getItem(e):t!=null?t:""),i=a(o=>{typeof o=="function"?r(c=>{const s=o(c);return window.localStorage.setItem(e,s),s}):(window.localStorage.setItem(e,o),r(o))},[e]);return g("storage",o=>{o.storageArea===window.localStorage&&o.key===e&&r(o.newValue)}),l(()=>{t&&!n&&i(t)},[t,n,i]),[n,i]}export{u as useLocalStorage};
1
+ import{useState as u,useCallback as w,useEffect as s}from"react";import{useWindowEvent as c}from"../useWindowEvent/index.js";function d({key:o,defaultValue:t=void 0}){const[n,a]=u(typeof window!="undefined"&&"localStorage"in window?window.localStorage.getItem(o):t??""),r=w(e=>{typeof e=="function"?a(i=>{const l=e(i);return window.localStorage.setItem(o,l),l}):(window.localStorage.setItem(o,e),a(e))},[o]);return c("storage",e=>{e.storageArea===window.localStorage&&e.key===o&&a(e.newValue)}),s(()=>{t&&!n&&r(t)},[t,n,r]),[n,r]}export{d as useLocalStorage};
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":[],"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,GAAG,QAAQ,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,GAAG,WAAW,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,EAAE,cAAc,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,EAAE,SAAS,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,QAAC,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,WAAC,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,cAAC,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,SAAC,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
- import{useState as a,useRef as c,useEffect as s}from"react";function d(e,t){try{return e.addEventListener("change",t),()=>e.removeEventListener("change",t)}catch(n){return e.addListener(t),()=>e.removeListener(t)}}function o(e){return typeof window!="undefined"&&"matchMedia"in window?window.matchMedia(e).matches:!1}function u(e){const[t,n]=a(o(e)),i=c();return s(()=>{if("matchMedia"in window)return i.current=window.matchMedia(e),n(i.current.matches),d(i.current,r=>n(r.matches))},[e]),t}export{u as useMediaQuery};
1
+ import{useState as c,useRef as a,useEffect as u}from"react";function d(e,n){try{return e.addEventListener("change",n),()=>e.removeEventListener("change",n)}catch(t){return e.addListener(n),()=>e.removeListener(n)}}function o(e){return typeof window!="undefined"&&"matchMedia"in window?window.matchMedia(e).matches:!1}function s(e){const[n,t]=c(o(e)),r=a();return u(()=>{if("matchMedia"in window)return r.current=window.matchMedia(e),t(r.current.matches),d(r.current,i=>t(i.matches))},[e]),n}export{s as useMediaQuery};
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/useMediaQuery/index.ts"],"sourcesContent":["import { useState, useEffect, useRef } from 'react';\n\ntype MediaQueryCallback = (event: { matches: boolean; media: string }) => void;\n\n/**\n * Older versions of Safari (shipped withCatalina and before) do not support addEventListener on matchMedia\n * https://stackoverflow.com/questions/56466261/matchmedia-addlistener-marked-as-deprecated-addeventlistener-equivalent\n * */\nfunction attachMediaListener(query: MediaQueryList, callback: MediaQueryCallback) {\n try {\n query.addEventListener('change', callback);\n return () => query.removeEventListener('change', callback);\n } catch (e) {\n query.addListener(callback);\n return () => query.removeListener(callback);\n }\n}\n\nfunction getInitialValue(query: string) {\n if (typeof window !== 'undefined' && 'matchMedia' in window) {\n return window.matchMedia(query).matches;\n }\n return false;\n}\n\nexport function useMediaQuery(query: string) {\n const [matches, setMatches] = useState(getInitialValue(query));\n const queryRef = useRef<MediaQueryList>();\n\n // eslint-disable-next-line consistent-return\n useEffect(() => {\n if ('matchMedia' in window) {\n queryRef.current = window.matchMedia(query);\n setMatches(queryRef.current.mat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C,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,QAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAACC,MAAC,EAAE,CAAC,OAAOC,SAAC,CAAC,IAAI,CAAC,GAAG,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;;;;"}
@@ -1,2 +1,2 @@
1
- import{useCallback as f}from"react";import{assignRef as t}from"../utils/index.js";function n(...e){return f(r=>{e.forEach(o=>t(o,r))},e)}function i(...e){return r=>{e.forEach(o=>t(o,r))}}export{i as mergeRefs,n as useMergedRef};
1
+ import{useCallback as t}from"react";import{assignRef as o}from"../utils/index.js";function n(...r){return t(e=>{r.forEach(f=>o(f,e))},r)}function i(...r){return e=>{r.forEach(f=>o(f,e))}}export{i as mergeRefs,n as useMergedRef};
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":[],"mappings":";;;AAEO,SAAS,YAAY,CAAC,GAAG,IAAI,EAAE;AACtC,EAAE,OAAO,WAAW,CAAC,CAAC,IAAI,KAAK;AAC/B,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,KAAK,SAAS,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,KAAK,SAAS,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,WAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,EAAEC,SAAC,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,SAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAC,CAAC;;;;"}
@@ -1,2 +1,2 @@
1
- import{useRef as s,useState as y,useEffect as h}from"react";import{clamp as S}from"../utils/index.js";function w(p,n){const t=s(),r=s(!1),u=s(!1),d=s(0),[L,v]=y(!1);return h(()=>{r.current=!0},[]),h(()=>{const a=({x:e,y:x})=>{cancelAnimationFrame(d.current),d.current=requestAnimationFrame(()=>{if(r.current&&t.current){t.current.style.userSelect="none";const o=t.current.getBoundingClientRect();o.width&&o.height&&p({x:S({value:(e-o.left)/o.width,min:0,max:1}),y:S({value:(x-o.top)/o.height,min:0,max:1})})}})},b=()=>{document.addEventListener("mousemove",i),document.addEventListener("mouseup",c),document.addEventListener("touchmove",m),document.addEventListener("touchend",c)},g=()=>{document.removeEventListener("mousemove",i),document.removeEventListener("mouseup",c),document.removeEventListener("touchmove",m),document.removeEventListener("touchend",c)},f=()=>{!u.current&&r.current&&(u.current=!0,typeof(n==null?void 0:n.onScrubStart)=="function"&&n.onScrubStart(),v(!0),b())},c=()=>{u.current&&r.current&&(u.current=!1,typeof(n==null?void 0:n.onScrubEnd)=="function"&&n.onScrubEnd(),v(!1),g())},l=e=>{f(),i(e)},i=e=>a({x:e.clientX,y:e.clientY}),E=e=>{f(),e==null||e.preventDefault(),m(e)},m=e=>{e==null||e.preventDefault(),a({x:e.changedTouches[0].clientX,y:e.changedTouches[0].clientY})};return t.current.addEventListener("mousedown",l),t.current.addEventListener("touchstart",E),()=>{t.current&&(t.current.removeEventListener("mousedown",l),t.current.removeEventListener("touchstart",E))}},[t.current]),{ref:t,active:L}}export{w as useMove};
1
+ import{useRef as i,useState as b,useEffect as E}from"react";import{clamp as L}from"../utils/index.js";function w(p,n){const t=i(),u=i(!1),c=i(!1),s=i(0),[x,v]=b(!1);return E(()=>{u.current=!0},[]),E(()=>{const a=({x:e,y:g})=>{cancelAnimationFrame(s.current),s.current=requestAnimationFrame(()=>{if(u.current&&t.current){t.current.style.userSelect="none";const r=t.current.getBoundingClientRect();r.width&&r.height&&p({x:L({value:(e-r.left)/r.width,min:0,max:1}),y:L({value:(g-r.top)/r.height,min:0,max:1})})}})},S=()=>{document.addEventListener("mousemove",m),document.addEventListener("mouseup",o),document.addEventListener("touchmove",d),document.addEventListener("touchend",o)},y=()=>{document.removeEventListener("mousemove",m),document.removeEventListener("mouseup",o),document.removeEventListener("touchmove",d),document.removeEventListener("touchend",o)},l=()=>{!c.current&&u.current&&(c.current=!0,typeof(n==null?void 0:n.onScrubStart)=="function"&&n.onScrubStart(),v(!0),S())},o=()=>{c.current&&u.current&&(c.current=!1,typeof(n==null?void 0:n.onScrubEnd)=="function"&&n.onScrubEnd(),v(!1),y())},f=e=>{l(),m(e)},m=e=>a({x:e.clientX,y:e.clientY}),h=e=>{l(),e==null||e.preventDefault(),d(e)},d=e=>{e==null||e.preventDefault(),a({x:e.changedTouches[0].clientX,y:e.changedTouches[0].clientY})};return t.current.addEventListener("mousedown",f),t.current.addEventListener("touchstart",h),()=>{t.current&&(t.current.removeEventListener("mousedown",f),t.current.removeEventListener("touchstart",h))}},[t.current]),{ref:t,active:x}}export{w as useMove};
2
2
  //# sourceMappingURL=index.js.map
@@ -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', onTouch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,OAAO,EAAE,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;AAC1F,KAAK,CAAC;AACN,IAAI,GAAG,CAAC,OAAO,CAAC,gBAAgB,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;AAC3D,IAAI,GAAG,CAAC,OAAO,CAAC,gBAAgB,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;AAC7D,IAAI,OAAO,MAAM;AACjB,MAAM,IAAI,GAAG,CAAC,OAAO,EAAE;AACvB,QAAQ,GAAG,CAAC,OAAO,CAAC,mBAAmB,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;AAClE,QAAQ,GAAG,CAAC,OAAO,CAAC,mBAAmB,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;AACpE,OAAO;AACP,KAAK,CAAC;AACN,GAAG,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;AACpB,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,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","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CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,EAAC,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,gBAAgB,CAAC,YAAY,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
- import{useRef as t,useEffect as u}from"react";function c(r){const e=t();return u(()=>{e.current=r},[r]),e.current}export{c as usePrevious};
1
+ import{useRef as t,useEffect as u}from"react";function c(e){const r=t();return u(()=>{r.current=e},[e]),r.current}export{c as usePrevious};
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/usePrevious/index.ts"],"sourcesContent":["import { useRef, useEffect } from 'react';\n\nexport function usePrevious<T>(value: T): T {\n const ref: any = useRef<T>();\n // Store current value in ref\n useEffect(() => {\n ref.current = value;\n }, [value]);\n\n return ref.current;\n}\n"],"names":[],"mappings":";;AACO,SAAS,WAAW,CAAC,KAAK,EAAE;AACnC,EAAE,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC;AACvB,EAAE,SAAS,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,MAAC,EAAE,CAAC,OAAOC,SAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO;;;;"}
@@ -1,2 +1,2 @@
1
- import{useState as r}from"react";function q({initialValues:c=[],limit:e}){const[{state:n,queue:o},a]=r({state:c.slice(0,e),queue:c.slice(e)});return{state:n,queue:o,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:[]}))}}export{q as useQueue};
1
+ import{useState as l}from"react";function r({initialValues:i=[],limit:e}){const[{state:c,queue:n},a]=l({state:i.slice(0,e),queue:i.slice(e)});return{state:c,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:[]}))}}export{r as useQueue};
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":[],"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,GAAG,QAAQ,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,QAAC,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 +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":[],"mappings":";;AACO,SAAS,gBAAgB,GAAG;AACnC,EAAE,OAAO,aAAa,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,aAAC,CAAC,kCAAkC,CAAC;;;;"}
@@ -1,2 +1,2 @@
1
- import{useState as f,useRef as d,useEffect as n}from"react";function s(e){const[t,o]=f(e||!1),r=d(!1),c=d(null),l=()=>{r.current&&(r.current=!1,document.body.style.overflow=c.current||"")},u=()=>{r.current=!0,c.current=document.body.style.overflow,document.body.style.overflow="hidden"};return n(()=>(t?u():l(),l),[t]),n(()=>{e!==void 0&&o(e)},[e]),n(()=>{e===void 0&&typeof window!="undefined"&&window.document.body.style.overflow==="hidden"&&o(!0)},[o]),[t,o]}export{s as useScrollLock};
1
+ import{useState as f,useRef as c,useEffect as n}from"react";function i(o){const[t,e]=f(o||!1),r=c(!1),d=c(null),u=()=>{r.current&&(r.current=!1,document.body.style.overflow=d.current||"")},l=()=>{r.current=!0,d.current=document.body.style.overflow,document.body.style.overflow="hidden"};return n(()=>(t?l():u(),u),[t]),n(()=>{o!==void 0&&e(o)},[o]),n(()=>{o===void 0&&typeof window!="undefined"&&window.document.body.style.overflow==="hidden"&&e(!0)},[e]),[t,e]}export{i as useScrollLock};
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":[],"mappings":";;AACO,SAAS,aAAa,CAAC,IAAI,EAAE;AACpC,EAAE,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAC,IAAI,IAAI,KAAK,CAAC,CAAC;AAClE,EAAE,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;AAC/B,EAAE,MAAM,YAAY,GAAG,MAAM,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,EAAE,SAAS,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,EAAE,SAAS,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,EAAE,SAAS,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,QAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAACC,MAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAACA,MAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,EAAE,EAAE,EAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,SAAQ,CAAC,CAAC,OAAOC,SAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAACA,SAAC,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAACA,SAAC,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,EAAE,OAAO,MAAM,EAAE,WAAW,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;;;;"}
@@ -1,2 +1,2 @@
1
- import{useState as g}from"react";function o(e,t){const[u,r]=g(e);return[u,n=>{typeof n!="undefined"?r(n):r(f=>f===t[0]?t[1]:t[0])}]}function s(e=!1){return o(e,[!0,!1])}export{s as useBooleanToggle,o as useToggle};
1
+ import{useState as c}from"react";function r(e,o){const[t,u]=c(e);return[t,n=>{u(typeof n!="undefined"?n:f=>f===o[0]?o[1]:o[0])}]}function g(e=!1){return r(e,[!0,!1])}export{g as useBooleanToggle,r as useToggle};
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":[],"mappings":";;AACO,SAAS,SAAS,CAAC,YAAY,EAAE,OAAO,EAAE;AACjD,EAAE,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,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,QAAC,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;;;;"}