@oneplatformdev/hooks 0.1.0-15 → 0.1.0-150

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 (223) hide show
  1. package/CHANGELOG.md +585 -0
  2. package/index.d.ts +37 -0
  3. package/index.d.ts.map +1 -0
  4. package/package.json +14 -20
  5. package/useBoolean/index.d.ts +2 -0
  6. package/useBoolean/index.d.ts.map +1 -0
  7. package/useBoolean/index.js +4 -0
  8. package/useBoolean/useBoolean.d.ts +29 -0
  9. package/useBoolean/useBoolean.d.ts.map +1 -0
  10. package/useBoolean/useBoolean.js +16 -0
  11. package/useClickAnyWhere/index.d.ts +2 -0
  12. package/useClickAnyWhere/index.d.ts.map +1 -0
  13. package/useClickAnyWhere/index.js +4 -0
  14. package/useClickAnyWhere/useClickAnyWhere.d.ts +17 -0
  15. package/useClickAnyWhere/useClickAnyWhere.d.ts.map +1 -0
  16. package/useClickAnyWhere/useClickAnyWhere.js +9 -0
  17. package/useCopyToClipboard/index.d.ts +2 -0
  18. package/useCopyToClipboard/index.d.ts.map +1 -0
  19. package/useCopyToClipboard/index.js +4 -0
  20. package/useCopyToClipboard/useCopyToClipboard.d.ts +34 -0
  21. package/useCopyToClipboard/useCopyToClipboard.d.ts.map +1 -0
  22. package/useCopyToClipboard/useCopyToClipboard.js +16 -0
  23. package/useCountdown/index.d.ts +2 -0
  24. package/useCountdown/index.d.ts.map +1 -0
  25. package/useCountdown/index.js +4 -0
  26. package/useCountdown/useCountdown.d.ts +47 -0
  27. package/useCountdown/useCountdown.d.ts.map +1 -0
  28. package/useCountdown/useCountdown.js +33 -0
  29. package/useCounter/index.d.ts +2 -0
  30. package/useCounter/index.d.ts.map +1 -0
  31. package/useCounter/index.js +4 -0
  32. package/useCounter/useCounter.d.ts +28 -0
  33. package/useCounter/useCounter.d.ts.map +1 -0
  34. package/useCounter/useCounter.js +20 -0
  35. package/useDarkMode/index.d.ts +2 -0
  36. package/useDarkMode/index.d.ts.map +1 -0
  37. package/useDarkMode/index.js +4 -0
  38. package/useDarkMode/useDarkMode.d.ts +46 -0
  39. package/useDarkMode/useDarkMode.d.ts.map +1 -0
  40. package/useDarkMode/useDarkMode.js +38 -0
  41. package/useDebounceCallback/index.d.ts +3 -0
  42. package/useDebounceCallback/index.d.ts.map +1 -0
  43. package/useDebounceCallback/index.js +5 -0
  44. package/useDebounceCallback/useDebounceCallback.d.ts +62 -0
  45. package/useDebounceCallback/useDebounceCallback.d.ts.map +1 -0
  46. package/useDebounceCallback/useDebounceCallback.js +21 -0
  47. package/useDebounceValue/index.d.ts +2 -0
  48. package/useDebounceValue/index.d.ts.map +1 -0
  49. package/useDebounceValue/index.js +4 -0
  50. package/useDebounceValue/useDebounceValue.d.ts +40 -0
  51. package/useDebounceValue/useDebounceValue.d.ts.map +1 -0
  52. package/useDebounceValue/useDebounceValue.js +13 -0
  53. package/useDocumentTitle/index.d.ts +2 -0
  54. package/useDocumentTitle/index.d.ts.map +1 -0
  55. package/useDocumentTitle/index.js +4 -0
  56. package/useDocumentTitle/useDocumentTitle.d.ts +19 -0
  57. package/useDocumentTitle/useDocumentTitle.d.ts.map +1 -0
  58. package/useDocumentTitle/useDocumentTitle.js +16 -0
  59. package/useEventCallback/index.d.ts +2 -0
  60. package/useEventCallback/index.d.ts.map +1 -0
  61. package/useEventCallback/index.js +4 -0
  62. package/useEventCallback/useEventCallback.d.ts +18 -0
  63. package/useEventCallback/useEventCallback.d.ts.map +1 -0
  64. package/useEventCallback/useEventCallback.js +13 -0
  65. package/useEventListener/index.d.ts +2 -0
  66. package/useEventListener/index.d.ts.map +1 -0
  67. package/useEventListener/index.js +4 -0
  68. package/useEventListener/useEventListener.d.ts +9 -0
  69. package/useEventListener/useEventListener.d.ts.map +1 -0
  70. package/useEventListener/useEventListener.js +20 -0
  71. package/useHover/index.d.ts +2 -0
  72. package/useHover/index.d.ts.map +1 -0
  73. package/useHover/index.js +4 -0
  74. package/useHover/useHover.d.ts +17 -0
  75. package/useHover/useHover.d.ts.map +1 -0
  76. package/useHover/useHover.js +13 -0
  77. package/useIntersectionObserver/index.d.ts +2 -0
  78. package/useIntersectionObserver/index.d.ts.map +1 -0
  79. package/useIntersectionObserver/index.js +4 -0
  80. package/useIntersectionObserver/useIntersectionObserver.d.ts +72 -0
  81. package/useIntersectionObserver/useIntersectionObserver.d.ts.map +1 -0
  82. package/useIntersectionObserver/useIntersectionObserver.js +53 -0
  83. package/useInterval/index.d.ts +2 -0
  84. package/useInterval/index.d.ts.map +1 -0
  85. package/useInterval/index.js +4 -0
  86. package/useInterval/useInterval.d.ts +16 -0
  87. package/useInterval/useInterval.d.ts.map +1 -0
  88. package/useInterval/useInterval.js +20 -0
  89. package/useIsClient/index.d.ts +2 -0
  90. package/useIsClient/index.d.ts.map +1 -0
  91. package/useIsClient/index.js +4 -0
  92. package/useIsClient/useIsClient.d.ts +13 -0
  93. package/useIsClient/useIsClient.d.ts.map +1 -0
  94. package/useIsClient/useIsClient.js +10 -0
  95. package/useIsMobile/index.d.ts +3 -0
  96. package/useIsMobile/index.d.ts.map +1 -0
  97. package/useIsMobile/index.js +4 -0
  98. package/useIsMobile/types.d.ts +4 -0
  99. package/useIsMobile/types.d.ts.map +1 -0
  100. package/useIsMobile/types.js +1 -0
  101. package/useIsMobile/useIsMobile.d.ts +3 -0
  102. package/useIsMobile/useIsMobile.d.ts.map +1 -0
  103. package/useIsMobile/useIsMobile.js +16 -0
  104. package/useIsMounted/index.d.ts +2 -0
  105. package/useIsMounted/index.d.ts.map +1 -0
  106. package/useIsMounted/index.js +4 -0
  107. package/useIsMounted/useIsMounted.d.ts +2 -0
  108. package/useIsMounted/useIsMounted.d.ts.map +1 -0
  109. package/useIsMounted/useIsMounted.js +10 -0
  110. package/useIsomorphicLayoutEffect/index.d.ts +2 -0
  111. package/useIsomorphicLayoutEffect/index.d.ts.map +1 -0
  112. package/useIsomorphicLayoutEffect/index.js +4 -0
  113. package/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.d.ts +16 -0
  114. package/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.d.ts.map +1 -0
  115. package/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js +5 -0
  116. package/useLocalStorage/index.d.ts +2 -0
  117. package/useLocalStorage/index.d.ts.map +1 -0
  118. package/useLocalStorage/index.js +4 -0
  119. package/useLocalStorage/useLocalStorage.d.ts +39 -0
  120. package/useLocalStorage/useLocalStorage.d.ts.map +1 -0
  121. package/useLocalStorage/useLocalStorage.js +65 -0
  122. package/useLockBody/index.d.ts +2 -0
  123. package/useLockBody/index.d.ts.map +1 -0
  124. package/useLockBody/index.js +4 -0
  125. package/useLockBody/useLockBody.d.ts +2 -0
  126. package/useLockBody/useLockBody.d.ts.map +1 -0
  127. package/useLockBody/useLockBody.js +12 -0
  128. package/useMap/index.d.ts +2 -0
  129. package/useMap/index.d.ts.map +1 -0
  130. package/useMap/index.js +4 -0
  131. package/useMap/useMap.d.ts +48 -0
  132. package/useMap/useMap.d.ts.map +1 -0
  133. package/useMap/useMap.js +27 -0
  134. package/useMediaQuery/index.d.ts +2 -0
  135. package/useMediaQuery/index.d.ts.map +1 -0
  136. package/useMediaQuery/index.js +4 -0
  137. package/useMediaQuery/useMediaQuery.d.ts +29 -0
  138. package/useMediaQuery/useMediaQuery.d.ts.map +1 -0
  139. package/useMediaQuery/useMediaQuery.js +21 -0
  140. package/useOnClickOutside/index.d.ts +2 -0
  141. package/useOnClickOutside/index.d.ts.map +1 -0
  142. package/useOnClickOutside/index.js +4 -0
  143. package/useOnClickOutside/useOnClickOutside.d.ts +24 -0
  144. package/useOnClickOutside/useOnClickOutside.d.ts.map +1 -0
  145. package/useOnClickOutside/useOnClickOutside.js +17 -0
  146. package/useQueryString/index.d.ts +2 -0
  147. package/useQueryString/index.d.ts.map +1 -0
  148. package/useQueryString/index.js +4 -0
  149. package/useQueryString/useQueryString.d.ts +10 -0
  150. package/useQueryString/useQueryString.d.ts.map +1 -0
  151. package/useQueryString/useQueryString.js +10 -0
  152. package/useReadLocalStorage/index.d.ts +2 -0
  153. package/useReadLocalStorage/index.d.ts.map +1 -0
  154. package/useReadLocalStorage/index.js +4 -0
  155. package/useReadLocalStorage/useReadLocalStorage.d.ts +14 -0
  156. package/useReadLocalStorage/useReadLocalStorage.d.ts.map +1 -0
  157. package/useReadLocalStorage/useReadLocalStorage.js +48 -0
  158. package/useResizeObserver/index.d.ts +2 -0
  159. package/useResizeObserver/index.d.ts.map +1 -0
  160. package/useResizeObserver/index.js +4 -0
  161. package/useResizeObserver/useResizeObserver.d.ts +44 -0
  162. package/useResizeObserver/useResizeObserver.d.ts.map +1 -0
  163. package/useResizeObserver/useResizeObserver.js +31 -0
  164. package/useScreen/index.d.ts +2 -0
  165. package/useScreen/index.d.ts.map +1 -0
  166. package/useScreen/index.js +4 -0
  167. package/useScreen/useScreen.d.ts +20 -0
  168. package/useScreen/useScreen.d.ts.map +1 -0
  169. package/useScreen/useScreen.js +48 -0
  170. package/useScript/index.d.ts +2 -0
  171. package/useScript/index.d.ts.map +1 -0
  172. package/useScript/index.js +4 -0
  173. package/useScript/useScript.d.ts +24 -0
  174. package/useScript/useScript.d.ts.map +1 -0
  175. package/useScript/useScript.js +45 -0
  176. package/useScrollLock/index.d.ts +2 -0
  177. package/useScrollLock/index.d.ts.map +1 -0
  178. package/useScrollLock/index.js +4 -0
  179. package/useScrollLock/useScrollLock.d.ts +54 -0
  180. package/useScrollLock/useScrollLock.d.ts.map +1 -0
  181. package/useScrollLock/useScrollLock.js +26 -0
  182. package/useSessionStorage/index.d.ts +2 -0
  183. package/useSessionStorage/index.d.ts.map +1 -0
  184. package/useSessionStorage/index.js +4 -0
  185. package/useSessionStorage/useSessionStorage.d.ts +39 -0
  186. package/useSessionStorage/useSessionStorage.d.ts.map +1 -0
  187. package/useSessionStorage/useSessionStorage.js +65 -0
  188. package/useStep/index.d.ts +2 -0
  189. package/useStep/index.d.ts.map +1 -0
  190. package/useStep/index.js +4 -0
  191. package/useStep/useStep.d.ts +31 -0
  192. package/useStep/useStep.d.ts.map +1 -0
  193. package/useStep/useStep.js +34 -0
  194. package/useTernaryDarkMode/index.d.ts +2 -0
  195. package/useTernaryDarkMode/index.d.ts.map +1 -0
  196. package/useTernaryDarkMode/index.js +4 -0
  197. package/useTernaryDarkMode/useTernaryDarkMode.d.ts +46 -0
  198. package/useTernaryDarkMode/useTernaryDarkMode.d.ts.map +1 -0
  199. package/useTernaryDarkMode/useTernaryDarkMode.js +27 -0
  200. package/useTimeout/index.d.ts +2 -0
  201. package/useTimeout/index.d.ts.map +1 -0
  202. package/useTimeout/index.js +4 -0
  203. package/useTimeout/useTimeout.d.ts +17 -0
  204. package/useTimeout/useTimeout.d.ts.map +1 -0
  205. package/useTimeout/useTimeout.js +20 -0
  206. package/useToggle/index.d.ts +2 -0
  207. package/useToggle/index.d.ts.map +1 -0
  208. package/useToggle/index.js +4 -0
  209. package/useToggle/useToggle.d.ts +18 -0
  210. package/useToggle/useToggle.d.ts.map +1 -0
  211. package/useToggle/useToggle.js +10 -0
  212. package/useUnmount/index.d.ts +2 -0
  213. package/useUnmount/index.d.ts.map +1 -0
  214. package/useUnmount/index.js +4 -0
  215. package/useUnmount/useUnmount.d.ts +14 -0
  216. package/useUnmount/useUnmount.d.ts.map +1 -0
  217. package/useUnmount/useUnmount.js +13 -0
  218. package/useWindowSize/index.d.ts +2 -0
  219. package/useWindowSize/index.d.ts.map +1 -0
  220. package/useWindowSize/index.js +4 -0
  221. package/useWindowSize/useWindowSize.d.ts +30 -0
  222. package/useWindowSize/useWindowSize.d.ts.map +1 -0
  223. package/useWindowSize/useWindowSize.js +31 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLocalStorage.d.ts","sourceRoot":"","sources":["../../src/useLocalStorage/useLocalStorage.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AAKrD,OAAO,CAAC,MAAM,CAAC;IAEb,UAAU,cAAc;QACtB,eAAe,EAAE,WAAW,CAAA;KAC7B;CACF;AAED;;;GAGG;AACH,KAAK,sBAAsB,CAAC,CAAC,IAAI;IAC/B,2DAA2D;IAC3D,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,CAAA;IACjC,kDAAkD;IAClD,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,CAAC,CAAA;IACnC;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAA;CAC9B,CAAA;AAID;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAC/B,GAAG,EAAE,MAAM,EACX,YAAY,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,EAC3B,OAAO,GAAE,sBAAsB,CAAC,CAAC,CAAM,GACtC,CAAC,CAAC,EAAE,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,IAAI,CAAC,CA2I9C"}
@@ -0,0 +1,65 @@
1
+ import { useCallback as a, useState as z, useEffect as F } from "react";
2
+ import { useEventCallback as u } from "../useEventCallback/useEventCallback.js";
3
+ import { useEventListener as l } from "../useEventListener/useEventListener.js";
4
+ const d = typeof window > "u";
5
+ function C(t, r, n = {}) {
6
+ const { initializeWithValue: w = !0 } = n, S = a(
7
+ (e) => n.serializer ? n.serializer(e) : JSON.stringify(e),
8
+ [n]
9
+ ), f = a(
10
+ (e) => {
11
+ if (n.deserializer)
12
+ return n.deserializer(e);
13
+ if (e === "undefined")
14
+ return;
15
+ const o = r instanceof Function ? r() : r;
16
+ let i;
17
+ try {
18
+ i = JSON.parse(e);
19
+ } catch (v) {
20
+ return console.error("Error parsing JSON:", v), o;
21
+ }
22
+ return i;
23
+ },
24
+ [n, r]
25
+ ), c = a(() => {
26
+ const e = r instanceof Function ? r() : r;
27
+ if (d)
28
+ return e;
29
+ try {
30
+ const o = window.localStorage.getItem(t);
31
+ return o ? f(o) : e;
32
+ } catch (o) {
33
+ return console.warn(`Error reading localStorage key “${t}”:`, o), e;
34
+ }
35
+ }, [r, t, f]), [m, s] = z(() => w ? c() : r instanceof Function ? r() : r), h = u((e) => {
36
+ d && console.warn(
37
+ `Tried setting localStorage key “${t}” even though environment is not a client`
38
+ );
39
+ try {
40
+ const o = e instanceof Function ? e(c()) : e;
41
+ window.localStorage.setItem(t, S(o)), s(o), window.dispatchEvent(new StorageEvent("local-storage", { key: t }));
42
+ } catch (o) {
43
+ console.warn(`Error setting localStorage key “${t}”:`, o);
44
+ }
45
+ }), E = u(() => {
46
+ d && console.warn(
47
+ `Tried removing localStorage key “${t}” even though environment is not a client`
48
+ );
49
+ const e = r instanceof Function ? r() : r;
50
+ window.localStorage.removeItem(t), s(e), window.dispatchEvent(new StorageEvent("local-storage", { key: t }));
51
+ });
52
+ F(() => {
53
+ s(c());
54
+ }, [t]);
55
+ const g = a(
56
+ (e) => {
57
+ e.key && e.key !== t || s(c());
58
+ },
59
+ [t, c]
60
+ );
61
+ return l("storage", g), l("local-storage", g), [m, h, E];
62
+ }
63
+ export {
64
+ C as useLocalStorage
65
+ };
@@ -0,0 +1,2 @@
1
+ export * from './useLockBody';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useLockBody/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA"}
@@ -0,0 +1,4 @@
1
+ import { useLockBody as r } from "./useLockBody.js";
2
+ export {
3
+ r as useLockBody
4
+ };
@@ -0,0 +1,2 @@
1
+ export declare function useLockBody(): void;
2
+ //# sourceMappingURL=useLockBody.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLockBody.d.ts","sourceRoot":"","sources":["../../src/useLockBody/useLockBody.tsx"],"names":[],"mappings":"AAGA,wBAAgB,WAAW,SAQ1B"}
@@ -0,0 +1,12 @@
1
+ import * as e from "react";
2
+ function t() {
3
+ e.useLayoutEffect(() => {
4
+ const o = window.getComputedStyle(
5
+ document.body
6
+ ).overflow;
7
+ return document.body.style.overflow = "hidden", () => document.body.style.overflow = o;
8
+ }, []);
9
+ }
10
+ export {
11
+ t as useLockBody
12
+ };
@@ -0,0 +1,2 @@
1
+ export * from './useMap';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useMap/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA"}
@@ -0,0 +1,4 @@
1
+ import { useMap as p } from "./useMap.js";
2
+ export {
3
+ p as useMap
4
+ };
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Represents the type for either a Map or an array of key-value pairs.
3
+ * @template K - The type of keys in the map.
4
+ * @template V - The type of values in the map.
5
+ */
6
+ type MapOrEntries<K, V> = Map<K, V> | [K, V][];
7
+ /**
8
+ * Represents the actions available to interact with the map state.
9
+ * @template K - The type of keys in the map.
10
+ * @template V - The type of values in the map.
11
+ */
12
+ type UseMapActions<K, V> = {
13
+ /** Set a key-value pair in the map. */
14
+ set: (key: K, value: V) => void;
15
+ /** Set all key-value pairs in the map. */
16
+ setAll: (entries: MapOrEntries<K, V>) => void;
17
+ /** Remove a key-value pair from the map. */
18
+ remove: (key: K) => void;
19
+ /** Reset the map to an empty state. */
20
+ reset: Map<K, V>['clear'];
21
+ };
22
+ /**
23
+ * Represents the return type of the `useMap` hook.
24
+ * We hide some setters from the returned map to disable autocompletion.
25
+ * @template K - The type of keys in the map.
26
+ * @template V - The type of values in the map.
27
+ */
28
+ type UseMapReturn<K, V> = [
29
+ Omit<Map<K, V>, 'set' | 'clear' | 'delete'>,
30
+ UseMapActions<K, V>
31
+ ];
32
+ /**
33
+ * Custom hook that manages a key-value [`Map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) state with setter actions.
34
+ * @template K - The type of keys in the map.
35
+ * @template V - The type of values in the map.
36
+ * @param {MapOrEntries<K, V>} [initialState] - The initial state of the map as a Map or an array of key-value pairs (optional).
37
+ * @returns {UseMapReturn<K, V>} A tuple containing the map state and actions to interact with the map.
38
+ * @public
39
+ * @see [Documentation](https://usehooks-ts.com/react-hook/use-map)
40
+ * @example
41
+ * ```tsx
42
+ * const [map, mapActions] = useMap();
43
+ * // Access the `map` state and use `mapActions` to set, remove, or reset entries.
44
+ * ```
45
+ */
46
+ export declare function useMap<K, V>(initialState?: MapOrEntries<K, V>): UseMapReturn<K, V>;
47
+ export {};
48
+ //# sourceMappingURL=useMap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMap.d.ts","sourceRoot":"","sources":["../../src/useMap/useMap.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,KAAK,YAAY,CAAC,CAAC,EAAE,CAAC,IAAI,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAA;AAE9C;;;;GAIG;AACH,KAAK,aAAa,CAAC,CAAC,EAAE,CAAC,IAAI;IACzB,uCAAuC;IACvC,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,IAAI,CAAA;IAC/B,0CAA0C;IAC1C,MAAM,EAAE,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,IAAI,CAAA;IAC7C,4CAA4C;IAC5C,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,IAAI,CAAA;IACxB,uCAAuC;IACvC,KAAK,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;CAC1B,CAAA;AAED;;;;;GAKG;AACH,KAAK,YAAY,CAAC,CAAC,EAAE,CAAC,IAAI;IACxB,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;IAC3C,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC;CACpB,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,CAAC,EACzB,YAAY,GAAE,YAAY,CAAC,CAAC,EAAE,CAAC,CAAa,GAC3C,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,CA8BpB"}
@@ -0,0 +1,27 @@
1
+ import { useState as M, useCallback as a } from "react";
2
+ function w(o = /* @__PURE__ */ new Map()) {
3
+ const [r, t] = M(new Map(o)), c = {
4
+ set: a((e, p) => {
5
+ t((n) => {
6
+ const s = new Map(n);
7
+ return s.set(e, p), s;
8
+ });
9
+ }, []),
10
+ setAll: a((e) => {
11
+ t(() => new Map(e));
12
+ }, []),
13
+ remove: a((e) => {
14
+ t((p) => {
15
+ const n = new Map(p);
16
+ return n.delete(e), n;
17
+ });
18
+ }, []),
19
+ reset: a(() => {
20
+ t(() => /* @__PURE__ */ new Map());
21
+ }, [])
22
+ };
23
+ return [r, c];
24
+ }
25
+ export {
26
+ w as useMap
27
+ };
@@ -0,0 +1,2 @@
1
+ export * from './useMediaQuery';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useMediaQuery/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA"}
@@ -0,0 +1,4 @@
1
+ import { useMediaQuery as o } from "./useMediaQuery.js";
2
+ export {
3
+ o as useMediaQuery
4
+ };
@@ -0,0 +1,29 @@
1
+ /** Hook options. */
2
+ type UseMediaQueryOptions = {
3
+ /**
4
+ * The default value to return if the hook is being run on the server.
5
+ * @default false
6
+ */
7
+ defaultValue?: boolean;
8
+ /**
9
+ * If `true` (default), the hook will initialize reading the media query. In SSR, you should set it to `false`, returning `options.defaultValue` or `false` initially.
10
+ * @default true
11
+ */
12
+ initializeWithValue?: boolean;
13
+ };
14
+ /**
15
+ * Custom hook that tracks the state of a media query using the [`Match Media API`](https://developer.mozilla.org/en-US/docs/Web/API/Window/matchMedia).
16
+ * @param {string} query - The media query to track.
17
+ * @param {?UseMediaQueryOptions} [options] - The options for customizing the behavior of the hook (optional).
18
+ * @returns {boolean} The current state of the media query (true if the query matches, false otherwise).
19
+ * @public
20
+ * @see [Documentation](https://usehooks-ts.com/react-hook/use-media-query)
21
+ * @example
22
+ * ```tsx
23
+ * const isSmallScreen = useMediaQuery('(max-width: 600px)');
24
+ * // Use `isSmallScreen` to conditionally apply styles or logic based on the screen size.
25
+ * ```
26
+ */
27
+ export declare function useMediaQuery(query: string, { defaultValue, initializeWithValue, }?: UseMediaQueryOptions): boolean;
28
+ export {};
29
+ //# sourceMappingURL=useMediaQuery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMediaQuery.d.ts","sourceRoot":"","sources":["../../src/useMediaQuery/useMediaQuery.ts"],"names":[],"mappings":"AAIA,oBAAoB;AACpB,KAAK,oBAAoB,GAAG;IAC1B;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAA;CAC9B,CAAA;AAID;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,MAAM,EACb,EACE,YAAoB,EACpB,mBAA0B,GAC3B,GAAE,oBAAyB,GAC3B,OAAO,CA2CT"}
@@ -0,0 +1,21 @@
1
+ import { useState as c } from "react";
2
+ import { useIsomorphicLayoutEffect as d } from "../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js";
3
+ const m = typeof window > "u";
4
+ function u(n, {
5
+ defaultValue: r = !1,
6
+ initializeWithValue: s = !0
7
+ } = {}) {
8
+ const i = (e) => m ? r : window.matchMedia(e).matches, [o, a] = c(() => s ? i(n) : r);
9
+ function t() {
10
+ a(i(n));
11
+ }
12
+ return d(() => {
13
+ const e = window.matchMedia(n);
14
+ return t(), e.addListener ? e.addListener(t) : e.addEventListener("change", t), () => {
15
+ e.removeListener ? e.removeListener(t) : e.removeEventListener("change", t);
16
+ };
17
+ }, [n]), o;
18
+ }
19
+ export {
20
+ u as useMediaQuery
21
+ };
@@ -0,0 +1,2 @@
1
+ export * from './useOnClickOutside';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useOnClickOutside/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA"}
@@ -0,0 +1,4 @@
1
+ import { useOnClickOutside as o } from "./useOnClickOutside.js";
2
+ export {
3
+ o as useOnClickOutside
4
+ };
@@ -0,0 +1,24 @@
1
+ import { RefObject } from 'react';
2
+ /** Supported event types. */
3
+ type EventType = 'mousedown' | 'mouseup' | 'touchstart' | 'touchend' | 'focusin' | 'focusout';
4
+ /**
5
+ * Custom hook that handles clicks outside a specified element.
6
+ * @template T - The type of the element's reference.
7
+ * @param {RefObject<T> | RefObject<T>[]} ref - The React ref object(s) representing the element(s) to watch for outside clicks.
8
+ * @param {(event: MouseEvent | TouchEvent | FocusEvent) => void} handler - The callback function to be executed when a click outside the element occurs.
9
+ * @param {EventType} [eventType] - The mouse event type to listen for (optional, default is 'mousedown').
10
+ * @param {?AddEventListenerOptions} [eventListenerOptions] - The options object to be passed to the `addEventListener` method (optional).
11
+ * @returns {void}
12
+ * @public
13
+ * @see [Documentation](https://usehooks-ts.com/react-hook/use-on-click-outside)
14
+ * @example
15
+ * ```tsx
16
+ * const containerRef = useRef(null);
17
+ * useOnClickOutside([containerRef], () => {
18
+ * // Handle clicks outside the container.
19
+ * });
20
+ * ```
21
+ */
22
+ export declare function useOnClickOutside<T extends HTMLElement = HTMLElement>(ref: RefObject<T | undefined | null> | RefObject<T | undefined | null>[], handler: (event: MouseEvent | TouchEvent | FocusEvent) => void, eventType?: EventType, eventListenerOptions?: AddEventListenerOptions): void;
23
+ export {};
24
+ //# sourceMappingURL=useOnClickOutside.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useOnClickOutside.d.ts","sourceRoot":"","sources":["../../src/useOnClickOutside/useOnClickOutside.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAItC,6BAA6B;AAC7B,KAAK,SAAS,GACV,WAAW,GACX,SAAS,GACT,YAAY,GACZ,UAAU,GACV,SAAS,GACT,UAAU,CAAA;AAEd;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,EACnE,GAAG,EAAE,SAAS,CAAC,CAAC,GAAG,SAAS,GAAG,IAAI,CAAC,GAAG,SAAS,CAAC,CAAC,GAAG,SAAS,GAAG,IAAI,CAAC,EAAE,EACxE,OAAO,EAAE,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,GAAG,UAAU,KAAK,IAAI,EAC9D,SAAS,GAAE,SAAuB,EAClC,oBAAoB,GAAE,uBAA4B,GACjD,IAAI,CAwBN"}
@@ -0,0 +1,17 @@
1
+ import { useEventListener as u } from "../useEventListener/useEventListener.js";
2
+ function d(t, i, s = "mousedown", o = {}) {
3
+ u(
4
+ s,
5
+ (e) => {
6
+ const n = e.target;
7
+ if (!n || !n.isConnected)
8
+ return;
9
+ (Array.isArray(t) ? t.filter((r) => !!r.current).every((r) => r.current && !r.current.contains(n)) : t.current && !t.current.contains(n)) && i(e);
10
+ },
11
+ void 0,
12
+ o
13
+ );
14
+ }
15
+ export {
16
+ d as useOnClickOutside
17
+ };
@@ -0,0 +1,2 @@
1
+ export * from './useQueryString';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useQueryString/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA"}
@@ -0,0 +1,4 @@
1
+ import { useQueryString as o } from "./useQueryString.js";
2
+ export {
3
+ o as useQueryString
4
+ };
@@ -0,0 +1,10 @@
1
+ type Nullable<T> = {
2
+ [P in keyof T]: T[P] | null;
3
+ };
4
+ type QueryParamsValue = Nullable<string | number | boolean | undefined>;
5
+ type QueryParams = Record<string, QueryParamsValue>;
6
+ export declare const useQueryString: (searchParams: URLSearchParams) => {
7
+ createQueryString: (baseUrl: string, params: QueryParams) => string;
8
+ };
9
+ export {};
10
+ //# sourceMappingURL=useQueryString.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useQueryString.d.ts","sourceRoot":"","sources":["../../src/useQueryString/useQueryString.ts"],"names":[],"mappings":"AAEA,KAAK,QAAQ,CAAC,CAAC,IAAI;KACd,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI;CAC5B,CAAC;AACJ,KAAK,gBAAgB,GAAG,QAAQ,CAAC,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,CAAA;AACvE,KAAK,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAA;AAEnD,eAAO,MAAM,cAAc,GAAI,cAAc,eAAe;iCAER,MAAM,UAAU,WAAW;CAe9E,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { useCallback as c } from "react";
2
+ const g = (e) => ({ createQueryString: c((i, o) => {
3
+ const t = new URLSearchParams(e?.toString());
4
+ return Object.entries(o).forEach(([n, r]) => {
5
+ r === null || r === "" || r === void 0 ? t.delete(n) : t.set(n, String(r));
6
+ }), `${i}?${t.toString()}`;
7
+ }, [e]) });
8
+ export {
9
+ g as useQueryString
10
+ };
@@ -0,0 +1,2 @@
1
+ export * from './useReadLocalStorage';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useReadLocalStorage/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA"}
@@ -0,0 +1,4 @@
1
+ import { useReadLocalStorage as a } from "./useReadLocalStorage.js";
2
+ export {
3
+ a as useReadLocalStorage
4
+ };
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Represents the type for the options available when reading from local storage.
3
+ * @template T - The type of the stored value.
4
+ */
5
+ type Options<T, InitializeWithValue extends boolean | undefined> = {
6
+ /** Custom deserializer function to convert the stored string value to the desired type (optional). */
7
+ deserializer?: (value: string) => T;
8
+ /** If `true` (default), the hook will initialize reading the local storage. In SSR, you should set it to `false`, returning `undefined` initially. */
9
+ initializeWithValue: InitializeWithValue;
10
+ };
11
+ export declare function useReadLocalStorage<T>(key: string, options: Options<T, false>): T | null | undefined;
12
+ export declare function useReadLocalStorage<T>(key: string, options?: Partial<Options<T, true>>): T | null;
13
+ export {};
14
+ //# sourceMappingURL=useReadLocalStorage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useReadLocalStorage.d.ts","sourceRoot":"","sources":["../../src/useReadLocalStorage/useReadLocalStorage.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,KAAK,OAAO,CAAC,CAAC,EAAE,mBAAmB,SAAS,OAAO,GAAG,SAAS,IAAI;IACjE,sGAAsG;IACtG,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,CAAC,CAAA;IACnC,sJAAsJ;IACtJ,mBAAmB,EAAE,mBAAmB,CAAA;CACzC,CAAA;AAGD,wBAAgB,mBAAmB,CAAC,CAAC,EACnC,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,GACzB,CAAC,GAAG,IAAI,GAAG,SAAS,CAAA;AAEvB,wBAAgB,mBAAmB,CAAC,CAAC,EACnC,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,GAClC,CAAC,GAAG,IAAI,CAAA"}
@@ -0,0 +1,48 @@
1
+ import { useCallback as a, useState as S, useEffect as w } from "react";
2
+ import { useEventListener as c } from "../useEventListener/useEventListener.js";
3
+ const d = typeof window > "u";
4
+ function m(e, t = {}) {
5
+ let { initializeWithValue: o = !0 } = t;
6
+ d && (o = !1);
7
+ const l = a(
8
+ (r) => {
9
+ if (t.deserializer)
10
+ return t.deserializer(r);
11
+ if (r === "undefined")
12
+ return;
13
+ let s;
14
+ try {
15
+ s = JSON.parse(r);
16
+ } catch (g) {
17
+ return console.error("Error parsing JSON:", g), null;
18
+ }
19
+ return s;
20
+ },
21
+ [t]
22
+ ), n = a(() => {
23
+ if (d)
24
+ return null;
25
+ try {
26
+ const r = window.localStorage.getItem(e);
27
+ return r ? l(r) : null;
28
+ } catch (r) {
29
+ return console.warn(`Error reading localStorage key “${e}”:`, r), null;
30
+ }
31
+ }, [e, l]), [f, i] = S(() => {
32
+ if (o)
33
+ return n();
34
+ });
35
+ w(() => {
36
+ i(n());
37
+ }, [e]);
38
+ const u = a(
39
+ (r) => {
40
+ r.key && r.key !== e || i(n());
41
+ },
42
+ [e, n]
43
+ );
44
+ return c("storage", u), c("local-storage", u), f;
45
+ }
46
+ export {
47
+ m as useReadLocalStorage
48
+ };
@@ -0,0 +1,2 @@
1
+ export * from './useResizeObserver';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useResizeObserver/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA"}
@@ -0,0 +1,4 @@
1
+ import { useResizeObserver as s } from "./useResizeObserver.js";
2
+ export {
3
+ s as useResizeObserver
4
+ };
@@ -0,0 +1,44 @@
1
+ import { RefObject } from 'react';
2
+ /** The size of the observed element. */
3
+ type Size = {
4
+ /** The width of the observed element. */
5
+ width: number | undefined;
6
+ /** The height of the observed element. */
7
+ height: number | undefined;
8
+ };
9
+ /** The options for the ResizeObserver. */
10
+ type UseResizeObserverOptions<T extends HTMLElement = HTMLElement> = {
11
+ /** The ref of the element to observe. */
12
+ ref: RefObject<T | undefined | null>;
13
+ /**
14
+ * When using `onResize`, the hook doesn't re-render on element size changes; it delegates handling to the provided callback.
15
+ * @default undefined
16
+ */
17
+ onResize?: (size: Size) => void;
18
+ /**
19
+ * The box model to use for the ResizeObserver.
20
+ * @default 'content-box'
21
+ */
22
+ box?: 'border-box' | 'content-box' | 'device-pixel-content-box';
23
+ };
24
+ /**
25
+ * Custom hook that observes the size of an element using the [`ResizeObserver API`](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver).
26
+ * @template T - The type of the element to observe.
27
+ * @param {UseResizeObserverOptions<T>} options - The options for the ResizeObserver.
28
+ * @returns {Size} - The size of the observed element.
29
+ * @public
30
+ * @see [Documentation](https://usehooks-ts.com/react-hook/use-resize-observer)
31
+ * @example
32
+ * ```tsx
33
+ * const myRef = useRef(null);
34
+ * const { width = 0, height = 0 } = useResizeObserver({
35
+ * ref: myRef,
36
+ * box: 'content-box',
37
+ * });
38
+ *
39
+ * <div ref={myRef}>Hello, world!</div>
40
+ * ```
41
+ */
42
+ export declare function useResizeObserver<T extends HTMLElement = HTMLElement>(options: UseResizeObserverOptions<T>): Size;
43
+ export {};
44
+ //# sourceMappingURL=useResizeObserver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useResizeObserver.d.ts","sourceRoot":"","sources":["../../src/useResizeObserver/useResizeObserver.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAItC,wCAAwC;AACxC,KAAK,IAAI,GAAG;IACV,yCAAyC;IACzC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAA;IACzB,0CAA0C;IAC1C,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;CAC3B,CAAA;AAED,0CAA0C;AAC1C,KAAK,wBAAwB,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,IAAI;IACnE,yCAAyC;IACzC,GAAG,EAAE,SAAS,CAAC,CAAC,GAAG,SAAS,GAAG,IAAI,CAAC,CAAA;IACpC;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAA;IAC/B;;;OAGG;IACH,GAAG,CAAC,EAAE,YAAY,GAAG,aAAa,GAAG,0BAA0B,CAAA;CAChE,CAAA;AAOD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,EACnE,OAAO,EAAE,wBAAwB,CAAC,CAAC,CAAC,GACnC,IAAI,CAmDN"}
@@ -0,0 +1,31 @@
1
+ import { useState as g, useRef as z, useEffect as x } from "react";
2
+ import { useIsMounted as l } from "../useIsMounted/useIsMounted.js";
3
+ const w = {
4
+ width: void 0,
5
+ height: void 0
6
+ };
7
+ function B(t) {
8
+ const { ref: e, box: i = "content-box" } = t, [{ width: v, height: a }, b] = g(w), s = l(), n = z({ ...w }), r = z(void 0);
9
+ return r.current = t.onResize, x(() => {
10
+ if (!e.current || typeof window > "u" || !("ResizeObserver" in window)) return;
11
+ const u = new ResizeObserver(([d]) => {
12
+ const h = i === "border-box" ? "borderBoxSize" : i === "device-pixel-content-box" ? "devicePixelContentBoxSize" : "contentBoxSize", o = S(d, h, "inlineSize"), c = S(d, h, "blockSize");
13
+ if (n.current.width !== o || n.current.height !== c) {
14
+ const f = { width: o, height: c };
15
+ n.current.width = o, n.current.height = c, r.current ? r.current(f) : s() && b(f);
16
+ }
17
+ });
18
+ return u.observe(e.current, { box: i }), () => {
19
+ u.disconnect();
20
+ };
21
+ }, [i, e, s]), { width: v, height: a };
22
+ }
23
+ function S(t, e, i) {
24
+ return t[e] ? Array.isArray(t[e]) ? t[e][0][i] : (
25
+ // @ts-ignore Support Firefox's non-standard behavior
26
+ t[e][i]
27
+ ) : e === "contentBoxSize" ? t.contentRect[i === "inlineSize" ? "width" : "height"] : void 0;
28
+ }
29
+ export {
30
+ B as useResizeObserver
31
+ };
@@ -0,0 +1,2 @@
1
+ export * from './useScreen';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/useScreen/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA"}
@@ -0,0 +1,4 @@
1
+ import { useScreen as o } from "./useScreen.js";
2
+ export {
3
+ o as useScreen
4
+ };
@@ -0,0 +1,20 @@
1
+ /**
2
+ * The hooks options.
3
+ * @template InitializeWithValue - If `true` (default), the hook will initialize reading the screen dimensions. In SSR, you should set it to `false`, returning `undefined` initially.
4
+ */
5
+ type UseScreenOptions<InitializeWithValue extends boolean | undefined> = {
6
+ /**
7
+ * If `true` (default), the hook will initialize reading the screen dimensions. In SSR, you should set it to `false`, returning `undefined` initially.
8
+ * @default true
9
+ */
10
+ initializeWithValue: InitializeWithValue;
11
+ /**
12
+ * The delay in milliseconds before the state is updated (disabled by default for retro-compatibility).
13
+ * @default undefined
14
+ */
15
+ debounceDelay?: number;
16
+ };
17
+ export declare function useScreen(options: UseScreenOptions<false>): Screen | undefined;
18
+ export declare function useScreen(options?: Partial<UseScreenOptions<true>>): Screen;
19
+ export {};
20
+ //# sourceMappingURL=useScreen.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useScreen.d.ts","sourceRoot":"","sources":["../../src/useScreen/useScreen.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,KAAK,gBAAgB,CAAC,mBAAmB,SAAS,OAAO,GAAG,SAAS,IAAI;IACvE;;;OAGG;IACH,mBAAmB,EAAE,mBAAmB,CAAA;IACxC;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB,CAAA;AAKD,wBAAgB,SAAS,CAAC,OAAO,EAAE,gBAAgB,CAAC,KAAK,CAAC,GAAG,MAAM,GAAG,SAAS,CAAA;AAE/E,wBAAgB,SAAS,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,GAAG,MAAM,CAAA"}
@@ -0,0 +1,48 @@
1
+ import { useState as w } from "react";
2
+ import { useDebounceCallback as b } from "../useDebounceCallback/useDebounceCallback.js";
3
+ import { useEventListener as v } from "../useEventListener/useEventListener.js";
4
+ import { useIsomorphicLayoutEffect as D } from "../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js";
5
+ const c = typeof window > "u";
6
+ function x(e = {}) {
7
+ let { initializeWithValue: t = !0 } = e;
8
+ c && (t = !1);
9
+ const n = () => {
10
+ if (!c)
11
+ return window.screen;
12
+ }, [u, r] = w(() => {
13
+ if (t)
14
+ return n();
15
+ }), s = b(
16
+ r,
17
+ e.debounceDelay
18
+ );
19
+ function i() {
20
+ const o = n(), a = e.debounceDelay ? s : r;
21
+ if (o) {
22
+ const {
23
+ width: f,
24
+ height: d,
25
+ availHeight: l,
26
+ availWidth: S,
27
+ colorDepth: h,
28
+ orientation: m,
29
+ pixelDepth: p
30
+ } = o;
31
+ a({
32
+ width: f,
33
+ height: d,
34
+ availHeight: l,
35
+ availWidth: S,
36
+ colorDepth: h,
37
+ orientation: m,
38
+ pixelDepth: p
39
+ });
40
+ }
41
+ }
42
+ return v("resize", i), D(() => {
43
+ i();
44
+ }, []), u;
45
+ }
46
+ export {
47
+ x as useScreen
48
+ };