@oneplatformdev/hooks 0.0.1-beta.6 → 0.1.1-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (181) hide show
  1. package/README.md +2 -2
  2. package/package.json +29 -30
  3. package/index.d.ts +0 -35
  4. package/index.mjs +0 -72
  5. package/useBoolean/index.d.ts +0 -1
  6. package/useBoolean/index.mjs +0 -4
  7. package/useBoolean/package.json +0 -7
  8. package/useBoolean/useBoolean.d.ts +0 -29
  9. package/useBoolean/useBoolean.mjs +0 -16
  10. package/useClickAnyWhere/index.d.ts +0 -1
  11. package/useClickAnyWhere/index.mjs +0 -4
  12. package/useClickAnyWhere/package.json +0 -7
  13. package/useClickAnyWhere/useClickAnyWhere.d.ts +0 -16
  14. package/useClickAnyWhere/useClickAnyWhere.mjs +0 -9
  15. package/useCopyToClipboard/index.d.ts +0 -1
  16. package/useCopyToClipboard/index.mjs +0 -4
  17. package/useCopyToClipboard/package.json +0 -7
  18. package/useCopyToClipboard/useCopyToClipboard.d.ts +0 -33
  19. package/useCopyToClipboard/useCopyToClipboard.mjs +0 -16
  20. package/useCountdown/index.d.ts +0 -1
  21. package/useCountdown/index.mjs +0 -4
  22. package/useCountdown/package.json +0 -7
  23. package/useCountdown/useCountdown.d.ts +0 -46
  24. package/useCountdown/useCountdown.mjs +0 -33
  25. package/useCounter/index.d.ts +0 -1
  26. package/useCounter/index.mjs +0 -4
  27. package/useCounter/package.json +0 -7
  28. package/useCounter/useCounter.d.ts +0 -28
  29. package/useCounter/useCounter.mjs +0 -20
  30. package/useDarkMode/index.d.ts +0 -1
  31. package/useDarkMode/index.mjs +0 -4
  32. package/useDarkMode/package.json +0 -7
  33. package/useDarkMode/useDarkMode.d.ts +0 -45
  34. package/useDarkMode/useDarkMode.mjs +0 -38
  35. package/useDebounceCallback/index.d.ts +0 -2
  36. package/useDebounceCallback/index.mjs +0 -5
  37. package/useDebounceCallback/package.json +0 -7
  38. package/useDebounceCallback/useDebounceCallback.d.ts +0 -61
  39. package/useDebounceCallback/useDebounceCallback.mjs +0 -101
  40. package/useDebounceValue/index.d.ts +0 -1
  41. package/useDebounceValue/index.mjs +0 -4
  42. package/useDebounceValue/package.json +0 -7
  43. package/useDebounceValue/useDebounceValue.d.ts +0 -40
  44. package/useDebounceValue/useDebounceValue.mjs +0 -13
  45. package/useDocumentTitle/index.d.ts +0 -1
  46. package/useDocumentTitle/index.mjs +0 -4
  47. package/useDocumentTitle/package.json +0 -7
  48. package/useDocumentTitle/useDocumentTitle.d.ts +0 -18
  49. package/useDocumentTitle/useDocumentTitle.mjs +0 -16
  50. package/useEventCallback/index.d.ts +0 -1
  51. package/useEventCallback/index.mjs +0 -4
  52. package/useEventCallback/package.json +0 -7
  53. package/useEventCallback/useEventCallback.d.ts +0 -17
  54. package/useEventCallback/useEventCallback.mjs +0 -16
  55. package/useEventListener/index.d.ts +0 -1
  56. package/useEventListener/index.mjs +0 -4
  57. package/useEventListener/package.json +0 -7
  58. package/useEventListener/useEventListener.d.ts +0 -7
  59. package/useEventListener/useEventListener.mjs +0 -20
  60. package/useHover/index.d.ts +0 -1
  61. package/useHover/index.mjs +0 -4
  62. package/useHover/package.json +0 -7
  63. package/useHover/useHover.d.ts +0 -17
  64. package/useHover/useHover.mjs +0 -13
  65. package/useIntersectionObserver/index.d.ts +0 -1
  66. package/useIntersectionObserver/index.mjs +0 -4
  67. package/useIntersectionObserver/package.json +0 -7
  68. package/useIntersectionObserver/useIntersectionObserver.d.ts +0 -71
  69. package/useIntersectionObserver/useIntersectionObserver.mjs +0 -55
  70. package/useInterval/index.d.ts +0 -1
  71. package/useInterval/index.mjs +0 -4
  72. package/useInterval/package.json +0 -7
  73. package/useInterval/useInterval.d.ts +0 -15
  74. package/useInterval/useInterval.mjs +0 -20
  75. package/useIsClient/index.d.ts +0 -1
  76. package/useIsClient/index.mjs +0 -4
  77. package/useIsClient/package.json +0 -7
  78. package/useIsClient/useIsClient.d.ts +0 -12
  79. package/useIsClient/useIsClient.mjs +0 -10
  80. package/useIsMobile/index.d.ts +0 -2
  81. package/useIsMobile/index.mjs +0 -4
  82. package/useIsMobile/package.json +0 -7
  83. package/useIsMobile/types.d.ts +0 -3
  84. package/useIsMobile/types.mjs +0 -1
  85. package/useIsMobile/useIsMobile.d.ts +0 -3
  86. package/useIsMobile/useIsMobile.mjs +0 -16
  87. package/useIsMounted/index.d.ts +0 -1
  88. package/useIsMounted/index.mjs +0 -4
  89. package/useIsMounted/package.json +0 -7
  90. package/useIsMounted/useIsMounted.d.ts +0 -1
  91. package/useIsMounted/useIsMounted.mjs +0 -10
  92. package/useIsomorphicLayoutEffect/index.d.ts +0 -1
  93. package/useIsomorphicLayoutEffect/index.mjs +0 -4
  94. package/useIsomorphicLayoutEffect/package.json +0 -7
  95. package/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.d.ts +0 -16
  96. package/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.mjs +0 -5
  97. package/useLocalStorage/index.d.ts +0 -1
  98. package/useLocalStorage/index.mjs +0 -4
  99. package/useLocalStorage/package.json +0 -7
  100. package/useLocalStorage/useLocalStorage.d.ts +0 -39
  101. package/useLocalStorage/useLocalStorage.mjs +0 -65
  102. package/useLockBody/index.d.ts +0 -1
  103. package/useLockBody/index.mjs +0 -4
  104. package/useLockBody/package.json +0 -7
  105. package/useLockBody/useLockBody.d.ts +0 -1
  106. package/useLockBody/useLockBody.mjs +0 -12
  107. package/useMap/index.d.ts +0 -1
  108. package/useMap/index.mjs +0 -4
  109. package/useMap/package.json +0 -7
  110. package/useMap/useMap.d.ts +0 -47
  111. package/useMap/useMap.mjs +0 -27
  112. package/useMediaQuery/index.d.ts +0 -1
  113. package/useMediaQuery/index.mjs +0 -4
  114. package/useMediaQuery/package.json +0 -7
  115. package/useMediaQuery/useMediaQuery.d.ts +0 -28
  116. package/useMediaQuery/useMediaQuery.mjs +0 -21
  117. package/useOnClickOutside/index.d.ts +0 -1
  118. package/useOnClickOutside/index.mjs +0 -4
  119. package/useOnClickOutside/package.json +0 -7
  120. package/useOnClickOutside/useOnClickOutside.d.ts +0 -24
  121. package/useOnClickOutside/useOnClickOutside.mjs +0 -17
  122. package/useReadLocalStorage/index.d.ts +0 -1
  123. package/useReadLocalStorage/index.mjs +0 -4
  124. package/useReadLocalStorage/package.json +0 -7
  125. package/useReadLocalStorage/useReadLocalStorage.d.ts +0 -13
  126. package/useReadLocalStorage/useReadLocalStorage.mjs +0 -48
  127. package/useResizeObserver/index.d.ts +0 -1
  128. package/useResizeObserver/index.mjs +0 -4
  129. package/useResizeObserver/package.json +0 -7
  130. package/useResizeObserver/useResizeObserver.d.ts +0 -44
  131. package/useResizeObserver/useResizeObserver.mjs +0 -31
  132. package/useScreen/index.d.ts +0 -1
  133. package/useScreen/index.mjs +0 -4
  134. package/useScreen/package.json +0 -7
  135. package/useScreen/useScreen.d.ts +0 -19
  136. package/useScreen/useScreen.mjs +0 -48
  137. package/useScript/index.d.ts +0 -1
  138. package/useScript/index.mjs +0 -4
  139. package/useScript/package.json +0 -7
  140. package/useScript/useScript.d.ts +0 -23
  141. package/useScript/useScript.mjs +0 -45
  142. package/useScrollLock/index.d.ts +0 -1
  143. package/useScrollLock/index.mjs +0 -4
  144. package/useScrollLock/package.json +0 -7
  145. package/useScrollLock/useScrollLock.d.ts +0 -53
  146. package/useScrollLock/useScrollLock.mjs +0 -26
  147. package/useSessionStorage/index.d.ts +0 -1
  148. package/useSessionStorage/index.mjs +0 -4
  149. package/useSessionStorage/package.json +0 -7
  150. package/useSessionStorage/useSessionStorage.d.ts +0 -39
  151. package/useSessionStorage/useSessionStorage.mjs +0 -65
  152. package/useStep/index.d.ts +0 -1
  153. package/useStep/index.mjs +0 -4
  154. package/useStep/package.json +0 -7
  155. package/useStep/useStep.d.ts +0 -31
  156. package/useStep/useStep.mjs +0 -34
  157. package/useTernaryDarkMode/index.d.ts +0 -1
  158. package/useTernaryDarkMode/index.mjs +0 -4
  159. package/useTernaryDarkMode/package.json +0 -7
  160. package/useTernaryDarkMode/useTernaryDarkMode.d.ts +0 -46
  161. package/useTernaryDarkMode/useTernaryDarkMode.mjs +0 -27
  162. package/useTimeout/index.d.ts +0 -1
  163. package/useTimeout/index.mjs +0 -4
  164. package/useTimeout/package.json +0 -7
  165. package/useTimeout/useTimeout.d.ts +0 -16
  166. package/useTimeout/useTimeout.mjs +0 -20
  167. package/useToggle/index.d.ts +0 -1
  168. package/useToggle/index.mjs +0 -4
  169. package/useToggle/package.json +0 -7
  170. package/useToggle/useToggle.d.ts +0 -18
  171. package/useToggle/useToggle.mjs +0 -10
  172. package/useUnmount/index.d.ts +0 -1
  173. package/useUnmount/index.mjs +0 -4
  174. package/useUnmount/package.json +0 -7
  175. package/useUnmount/useUnmount.d.ts +0 -13
  176. package/useUnmount/useUnmount.mjs +0 -13
  177. package/useWindowSize/index.d.ts +0 -1
  178. package/useWindowSize/index.mjs +0 -4
  179. package/useWindowSize/package.json +0 -7
  180. package/useWindowSize/useWindowSize.d.ts +0 -29
  181. package/useWindowSize/useWindowSize.mjs +0 -31
@@ -1,5 +0,0 @@
1
- import { useDebounceCallback as l, useDebounceCallback as u } from "./useDebounceCallback.mjs";
2
- export {
3
- l as default,
4
- u as useDebounceCallback
5
- };
@@ -1,7 +0,0 @@
1
- {
2
- "sideEffects": false,
3
- "main": "./index.mjs",
4
- "module": "./index.mjs",
5
- "default": "./index.mjs",
6
- "types": "./index.d.ts"
7
- }
@@ -1,61 +0,0 @@
1
- /** Configuration options for controlling the behavior of the debounced function. */
2
- type DebounceOptions = {
3
- /**
4
- * Determines whether the function should be invoked on the leading edge of the timeout.
5
- * @default false
6
- */
7
- leading?: boolean;
8
- /**
9
- * Determines whether the function should be invoked on the trailing edge of the timeout.
10
- * @default false
11
- */
12
- trailing?: boolean;
13
- /**
14
- * The maximum time the specified function is allowed to be delayed before it is invoked.
15
- */
16
- maxWait?: number;
17
- };
18
- /** Functions to manage a debounced callback. */
19
- type ControlFunctions = {
20
- /** Cancels pending function invocations. */
21
- cancel: () => void;
22
- /** Immediately invokes pending function invocations. */
23
- flush: () => void;
24
- /**
25
- * Checks if there are any pending function invocations.
26
- * @returns `true` if there are pending invocations, otherwise `false`.
27
- */
28
- isPending: () => boolean;
29
- };
30
- /**
31
- * Represents the state and control functions of a debounced callback.
32
- * Subsequent calls to the debounced function return the result of the last invocation.
33
- * Note: If there are no previous invocations, the result will be undefined.
34
- * Ensure proper handling in your code.
35
- */
36
- export type DebouncedState<T extends (...args: any) => ReturnType<T>> = ((...args: Parameters<T>) => ReturnType<T> | undefined) & ControlFunctions;
37
- /**
38
- * Custom hook that creates a debounced version of a callback function.
39
- * @template T - Type of the original callback function.
40
- * @param {T} func - The callback function to be debounced.
41
- * @param {number} delay - The delay in milliseconds before the callback is invoked (default is `500` milliseconds).
42
- * @param {DebounceOptions} [options] - Options to control the behavior of the debounced function.
43
- * @returns {DebouncedState<T>} A debounced version of the original callback along with control functions.
44
- * @public
45
- * @see [Documentation](https://usehooks-ts.com/react-hook/use-debounce-callback)
46
- * @example
47
- * ```tsx
48
- * const debouncedCallback = useDebounceCallback(
49
- * (searchTerm) => {
50
- * // Perform search after user stops typing for 500 milliseconds
51
- * searchApi(searchTerm);
52
- * },
53
- * 500
54
- * );
55
- *
56
- * // Later in the component
57
- * debouncedCallback('react hooks'); // Will invoke the callback after 500 milliseconds of inactivity.
58
- * ```
59
- */
60
- export declare function useDebounceCallback<T extends (...args: any) => ReturnType<T>>(func: T, delay?: number, options?: DebounceOptions): DebouncedState<T>;
61
- export {};
@@ -1,101 +0,0 @@
1
- import { useRef as _, useMemo as $, useEffect as N } from "react";
2
- import { useUnmount as P } from "../useUnmount/useUnmount.mjs";
3
- var g = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
4
- function R(e) {
5
- return e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
6
- }
7
- var W = "Expected a function", E = NaN, w = "[object Symbol]", A = /^\s+|\s+$/g, B = /^[-+]0x[0-9a-f]+$/i, D = /^0b[01]+$/i, G = /^0o[0-7]+$/i, U = parseInt, H = typeof g == "object" && g && g.Object === Object && g, X = typeof self == "object" && self && self.Object === Object && self, q = H || X || Function("return this")(), z = Object.prototype, J = z.toString, K = Math.max, Q = Math.min, T = function() {
8
- return q.Date.now();
9
- };
10
- function V(e, n, r) {
11
- var o, a, u, f, i, s, d = 0, v = !1, l = !1, p = !0;
12
- if (typeof e != "function")
13
- throw new TypeError(W);
14
- n = S(n) || 0, h(r) && (v = !!r.leading, l = "maxWait" in r, u = l ? K(S(r.maxWait) || 0, n) : u, p = "trailing" in r ? !!r.trailing : p);
15
- function y(t) {
16
- var c = o, b = a;
17
- return o = a = void 0, d = t, f = e.apply(b, c), f;
18
- }
19
- function F(t) {
20
- return d = t, i = setTimeout(m, n), v ? y(t) : f;
21
- }
22
- function C(t) {
23
- var c = t - s, b = t - d, x = n - c;
24
- return l ? Q(x, u - b) : x;
25
- }
26
- function O(t) {
27
- var c = t - s, b = t - d;
28
- return s === void 0 || c >= n || c < 0 || l && b >= u;
29
- }
30
- function m() {
31
- var t = T();
32
- if (O(t))
33
- return I(t);
34
- i = setTimeout(m, C(t));
35
- }
36
- function I(t) {
37
- return i = void 0, p && o ? y(t) : (o = a = void 0, f);
38
- }
39
- function M() {
40
- i !== void 0 && clearTimeout(i), d = 0, o = s = a = i = void 0;
41
- }
42
- function L() {
43
- return i === void 0 ? f : I(T());
44
- }
45
- function j() {
46
- var t = T(), c = O(t);
47
- if (o = arguments, a = this, s = t, c) {
48
- if (i === void 0)
49
- return F(s);
50
- if (l)
51
- return i = setTimeout(m, n), y(s);
52
- }
53
- return i === void 0 && (i = setTimeout(m, n)), f;
54
- }
55
- return j.cancel = M, j.flush = L, j;
56
- }
57
- function h(e) {
58
- var n = typeof e;
59
- return !!e && (n == "object" || n == "function");
60
- }
61
- function Y(e) {
62
- return !!e && typeof e == "object";
63
- }
64
- function Z(e) {
65
- return typeof e == "symbol" || Y(e) && J.call(e) == w;
66
- }
67
- function S(e) {
68
- if (typeof e == "number")
69
- return e;
70
- if (Z(e))
71
- return E;
72
- if (h(e)) {
73
- var n = typeof e.valueOf == "function" ? e.valueOf() : e;
74
- e = h(n) ? n + "" : n;
75
- }
76
- if (typeof e != "string")
77
- return e === 0 ? e : +e;
78
- e = e.replace(A, "");
79
- var r = D.test(e);
80
- return r || G.test(e) ? U(e.slice(2), r ? 2 : 8) : B.test(e) ? E : +e;
81
- }
82
- var ee = V;
83
- const k = /* @__PURE__ */ R(ee);
84
- function re(e, n = 500, r) {
85
- const o = _(null);
86
- P(() => {
87
- o.current && o.current.cancel();
88
- });
89
- const a = $(() => {
90
- const u = k(e, n, r), f = (...i) => u(...i);
91
- return f.cancel = () => {
92
- u.cancel();
93
- }, f.isPending = () => !!o.current, f.flush = () => u.flush(), f;
94
- }, [e, n, r]);
95
- return N(() => {
96
- o.current = k(e, n, r);
97
- }, [e, n, r]), a;
98
- }
99
- export {
100
- re as useDebounceCallback
101
- };
@@ -1 +0,0 @@
1
- export * from './useDebounceValue';
@@ -1,4 +0,0 @@
1
- import { useDebounceValue as u } from "./useDebounceValue.mjs";
2
- export {
3
- u as useDebounceValue
4
- };
@@ -1,7 +0,0 @@
1
- {
2
- "sideEffects": false,
3
- "main": "./index.mjs",
4
- "module": "./index.mjs",
5
- "default": "./index.mjs",
6
- "types": "./index.d.ts"
7
- }
@@ -1,40 +0,0 @@
1
- import { DebouncedState } from '../useDebounceCallback';
2
-
3
- /**
4
- * Hook options.
5
- * @template T - The type of the value.
6
- */
7
- type UseDebounceValueOptions<T> = {
8
- /**
9
- * Determines whether the function should be invoked on the leading edge of the timeout.
10
- * @default false
11
- */
12
- leading?: boolean;
13
- /**
14
- * Determines whether the function should be invoked on the trailing edge of the timeout.
15
- * @default false
16
- */
17
- trailing?: boolean;
18
- /**
19
- * The maximum time the specified function is allowed to be delayed before it is invoked.
20
- */
21
- maxWait?: number;
22
- /** A function to determine if the value has changed. Defaults to a function that checks if the value is strictly equal to the previous value. */
23
- equalityFn?: (left: T, right: T) => boolean;
24
- };
25
- /**
26
- * Custom hook that returns a debounced version of the provided value, along with a function to update it.
27
- * @template T - The type of the value.
28
- * @param {T | (() => T)} initialValue - The value to be debounced.
29
- * @param {number} delay - The delay in milliseconds before the value is updated (default is 500ms).
30
- * @param {object} [options] - Optional configurations for the debouncing behavior.
31
- * @returns {[T, DebouncedState<(value: T) => void>]} An array containing the debounced value and the function to update it.
32
- * @public
33
- * @see [Documentation](https://usehooks-ts.com/react-hook/use-debounce-value)
34
- * @example
35
- * ```tsx
36
- * const [debouncedValue, updateDebouncedValue] = useDebounceValue(inputValue, 500, { leading: true });
37
- * ```
38
- */
39
- export declare function useDebounceValue<T>(initialValue: T | (() => T), delay: number, options?: UseDebounceValueOptions<T>): [T, DebouncedState<(value: T) => void>];
40
- export {};
@@ -1,13 +0,0 @@
1
- import { useState as d, useRef as l } from "react";
2
- import { useDebounceCallback as m } from "../useDebounceCallback/useDebounceCallback.mjs";
3
- function p(c, t, u) {
4
- const a = (u == null ? void 0 : u.equalityFn) ?? ((s, b) => s === b), e = c instanceof Function ? c() : c, [o, f] = d(e), n = l(e), r = m(
5
- f,
6
- t,
7
- u
8
- );
9
- return a(n.current, e) || (r(e), n.current = e), [o, r];
10
- }
11
- export {
12
- p as useDebounceValue
13
- };
@@ -1 +0,0 @@
1
- export * from './useDocumentTitle';
@@ -1,4 +0,0 @@
1
- import { useDocumentTitle as t } from "./useDocumentTitle.mjs";
2
- export {
3
- t as useDocumentTitle
4
- };
@@ -1,7 +0,0 @@
1
- {
2
- "sideEffects": false,
3
- "main": "./index.mjs",
4
- "module": "./index.mjs",
5
- "default": "./index.mjs",
6
- "types": "./index.d.ts"
7
- }
@@ -1,18 +0,0 @@
1
- /** Hook options. */
2
- type UseDocumentTitleOptions = {
3
- /** Whether to keep the title after unmounting the component (default is `true`). */
4
- preserveTitleOnUnmount?: boolean;
5
- };
6
- /**
7
- * Custom hook that sets the document title.
8
- * @param {string} title - The title to set.
9
- * @param {?UseDocumentTitleOptions} [options] - The options.
10
- * @public
11
- * @see [Documentation](https://usehooks-ts.com/react-hook/use-document-title)
12
- * @example
13
- * ```tsx
14
- * useDocumentTitle('My new title');
15
- * ```
16
- */
17
- export declare function useDocumentTitle(title: string, options?: UseDocumentTitleOptions): void;
18
- export {};
@@ -1,16 +0,0 @@
1
- import { useRef as r } from "react";
2
- import { useIsomorphicLayoutEffect as o } from "../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.mjs";
3
- import { useUnmount as i } from "../useUnmount/useUnmount.mjs";
4
- function l(e, n = {}) {
5
- const { preserveTitleOnUnmount: u = !0 } = n, t = r(null);
6
- o(() => {
7
- t.current = window.document.title;
8
- }, []), o(() => {
9
- window.document.title = e;
10
- }, [e]), i(() => {
11
- !u && t.current && (window.document.title = t.current);
12
- });
13
- }
14
- export {
15
- l as useDocumentTitle
16
- };
@@ -1 +0,0 @@
1
- export * from './useEventCallback';
@@ -1,4 +0,0 @@
1
- import { useEventCallback as l } from "./useEventCallback.mjs";
2
- export {
3
- l as useEventCallback
4
- };
@@ -1,7 +0,0 @@
1
- {
2
- "sideEffects": false,
3
- "main": "./index.mjs",
4
- "module": "./index.mjs",
5
- "default": "./index.mjs",
6
- "types": "./index.d.ts"
7
- }
@@ -1,17 +0,0 @@
1
- /**
2
- * Custom hook that creates a memoized event callback.
3
- * @template Args - An array of argument types for the event callback.
4
- * @template R - The return type of the event callback.
5
- * @param {(...args: Args) => R} fn - The callback function.
6
- * @returns {(...args: Args) => R} A memoized event callback function.
7
- * @public
8
- * @see [Documentation](https://usehooks-ts.com/react-hook/use-event-callback)
9
- * @example
10
- * ```tsx
11
- * const handleClick = useEventCallback((event) => {
12
- * // Handle the event here
13
- * });
14
- * ```
15
- */
16
- export declare function useEventCallback<Args extends unknown[], R>(fn: (...args: Args) => R): (...args: Args) => R;
17
- export declare function useEventCallback<Args extends unknown[], R>(fn: ((...args: Args) => R) | undefined): ((...args: Args) => R) | undefined;
@@ -1,16 +0,0 @@
1
- import { useRef as o, useCallback as a } from "react";
2
- import { useIsomorphicLayoutEffect as c } from "../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.mjs";
3
- function i(e) {
4
- const r = o(() => {
5
- throw new Error("Cannot call an event handler while rendering.");
6
- });
7
- return c(() => {
8
- r.current = e;
9
- }, [e]), a((...t) => {
10
- var n;
11
- return (n = r.current) == null ? void 0 : n.call(r, ...t);
12
- }, [r]);
13
- }
14
- export {
15
- i as useEventCallback
16
- };
@@ -1 +0,0 @@
1
- export * from './useEventListener';
@@ -1,4 +0,0 @@
1
- import { useEventListener as t } from "./useEventListener.mjs";
2
- export {
3
- t as useEventListener
4
- };
@@ -1,7 +0,0 @@
1
- {
2
- "sideEffects": false,
3
- "main": "./index.mjs",
4
- "module": "./index.mjs",
5
- "default": "./index.mjs",
6
- "types": "./index.d.ts"
7
- }
@@ -1,7 +0,0 @@
1
- import { RefObject } from 'react';
2
-
3
- declare function useEventListener<K extends keyof MediaQueryListEventMap>(eventName: K, handler: (event: MediaQueryListEventMap[K]) => void, element: RefObject<MediaQueryList>, options?: boolean | AddEventListenerOptions): void;
4
- declare function useEventListener<K extends keyof WindowEventMap>(eventName: K, handler: (event: WindowEventMap[K]) => void, element?: undefined, options?: boolean | AddEventListenerOptions): void;
5
- declare function useEventListener<K extends keyof HTMLElementEventMap & keyof SVGElementEventMap, T extends Element = K extends keyof HTMLElementEventMap ? HTMLDivElement : SVGElement>(eventName: K, handler: ((event: HTMLElementEventMap[K]) => void) | ((event: SVGElementEventMap[K]) => void), element: RefObject<T>, options?: boolean | AddEventListenerOptions): void;
6
- declare function useEventListener<K extends keyof DocumentEventMap>(eventName: K, handler: (event: DocumentEventMap[K]) => void, element: RefObject<Document>, options?: boolean | AddEventListenerOptions): void;
7
- export { useEventListener };
@@ -1,20 +0,0 @@
1
- import { useRef as f, useEffect as i } from "react";
2
- import { useIsomorphicLayoutEffect as E } from "../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.mjs";
3
- function v(s, e, r, n) {
4
- const u = f(e);
5
- E(() => {
6
- u.current = e;
7
- }, [e]), i(() => {
8
- const t = (r == null ? void 0 : r.current) ?? window;
9
- if (!(t && t.addEventListener)) return;
10
- const c = (o) => {
11
- u.current(o);
12
- };
13
- return t.addEventListener(s, c, n), () => {
14
- t.removeEventListener(s, c, n);
15
- };
16
- }, [s, r, n]);
17
- }
18
- export {
19
- v as useEventListener
20
- };
@@ -1 +0,0 @@
1
- export * from './useHover';
@@ -1,4 +0,0 @@
1
- import { useHover as r } from "./useHover.mjs";
2
- export {
3
- r as useHover
4
- };
@@ -1,7 +0,0 @@
1
- {
2
- "sideEffects": false,
3
- "main": "./index.mjs",
4
- "module": "./index.mjs",
5
- "default": "./index.mjs",
6
- "types": "./index.d.ts"
7
- }
@@ -1,17 +0,0 @@
1
- import { RefObject } from 'react';
2
-
3
- /**
4
- * Custom hook that tracks whether a DOM element is being hovered over.
5
- * @template T - The type of the DOM element. Defaults to `HTMLElement`.
6
- * @param {RefObject<T>} elementRef - The ref object for the DOM element to track.
7
- * @returns {boolean} A boolean value indicating whether the element is being hovered over.
8
- * @public
9
- * @see [Documentation](https://usehooks-ts.com/react-hook/use-hover)
10
- * @example
11
- * ```tsx
12
- * const buttonRef = useRef<HTMLButtonElement>(null);
13
- * const isHovered = useHover(buttonRef);
14
- * // Access the isHovered variable to determine if the button is being hovered over.
15
- * ```
16
- */
17
- export declare function useHover<T extends HTMLElement = HTMLElement>(elementRef: RefObject<T>): boolean;
@@ -1,13 +0,0 @@
1
- import { useState as n } from "react";
2
- import { useEventListener as o } from "../useEventListener/useEventListener.mjs";
3
- function m(e) {
4
- const [s, t] = n(!1), r = () => {
5
- t(!0);
6
- }, u = () => {
7
- t(!1);
8
- };
9
- return o("mouseenter", r, e), o("mouseleave", u, e), s;
10
- }
11
- export {
12
- m as useHover
13
- };
@@ -1 +0,0 @@
1
- export * from './useIntersectionObserver';
@@ -1,4 +0,0 @@
1
- import { useIntersectionObserver as o } from "./useIntersectionObserver.mjs";
2
- export {
3
- o as useIntersectionObserver
4
- };
@@ -1,7 +0,0 @@
1
- {
2
- "sideEffects": false,
3
- "main": "./index.mjs",
4
- "module": "./index.mjs",
5
- "default": "./index.mjs",
6
- "types": "./index.d.ts"
7
- }
@@ -1,71 +0,0 @@
1
- /** Represents the options for configuring the Intersection Observer. */
2
- type UseIntersectionObserverOptions = {
3
- /**
4
- * The element that is used as the viewport for checking visibility of the target.
5
- * @default null
6
- */
7
- root?: Element | Document | null;
8
- /**
9
- * A margin around the root.
10
- * @default '0%'
11
- */
12
- rootMargin?: string;
13
- /**
14
- * A threshold indicating the percentage of the target's visibility needed to trigger the callback.
15
- * @default 0
16
- */
17
- threshold?: number | number[];
18
- /**
19
- * If true, freezes the intersection state once the element becomes visible.
20
- * @default false
21
- */
22
- freezeOnceVisible?: boolean;
23
- /**
24
- * A callback function to be invoked when the intersection state changes.
25
- * @param {boolean} isIntersecting - A boolean indicating if the element is intersecting.
26
- * @param {IntersectionObserverEntry} entry - The intersection observer Entry.
27
- * @default undefined
28
- */
29
- onChange?: (isIntersecting: boolean, entry: IntersectionObserverEntry) => void;
30
- /**
31
- * The initial state of the intersection.
32
- * @default false
33
- */
34
- initialIsIntersecting?: boolean;
35
- };
36
- /**
37
- * The return type of the useIntersectionObserver hook.
38
- *
39
- * Supports both tuple and object destructing.
40
- * @param {(node: Element | null) => void} ref - The ref callback function.
41
- * @param {boolean} isIntersecting - A boolean indicating if the element is intersecting.
42
- * @param {IntersectionObserverEntry | undefined} entry - The intersection observer Entry.
43
- */
44
- type IntersectionReturn = [
45
- (node?: Element | null) => void,
46
- boolean,
47
- IntersectionObserverEntry | undefined
48
- ] & {
49
- ref: (node?: Element | null) => void;
50
- isIntersecting: boolean;
51
- entry?: IntersectionObserverEntry;
52
- };
53
- /**
54
- * Custom hook that tracks the intersection of a DOM element with its containing element or the viewport using the [`Intersection Observer API`](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API).
55
- * @param {UseIntersectionObserverOptions} options - The options for the Intersection Observer.
56
- * @returns {IntersectionReturn} The ref callback, a boolean indicating if the element is intersecting, and the intersection observer entry.
57
- * @public
58
- * @see [Documentation](https://usehooks-ts.com/react-hook/use-intersection-observer)
59
- * @example
60
- * ```tsx
61
- * // Example 1
62
- * const [ref, isIntersecting, entry] = useIntersectionObserver({ threshold: 0.5 });
63
- * ```
64
- *
65
- * ```tsx
66
- * // Example 2
67
- * const { ref, isIntersecting, entry } = useIntersectionObserver({ threshold: 0.5 });
68
- * ```
69
- */
70
- export declare function useIntersectionObserver({ threshold, root, rootMargin, freezeOnceVisible, initialIsIntersecting, onChange, }?: UseIntersectionObserverOptions): IntersectionReturn;
71
- export {};
@@ -1,55 +0,0 @@
1
- import { useState as v, useRef as I, useEffect as R } from "react";
2
- function E({
3
- threshold: f = 0,
4
- root: a = null,
5
- rootMargin: l = "0%",
6
- freezeOnceVisible: s = !1,
7
- initialIsIntersecting: u = !1,
8
- onChange: b
9
- } = {}) {
10
- var g;
11
- const [n, m] = v(null), [t, d] = v(() => ({
12
- isIntersecting: u,
13
- entry: void 0
14
- })), i = I(null);
15
- i.current = b;
16
- const c = ((g = t.entry) == null ? void 0 : g.isIntersecting) && s;
17
- R(() => {
18
- if (!n || !("IntersectionObserver" in window) || c) return;
19
- const e = new IntersectionObserver(
20
- (p) => {
21
- const w = Array.isArray(e.thresholds) ? e.thresholds : [e.thresholds];
22
- p.forEach((o) => {
23
- const h = o.isIntersecting && w.some((S) => o.intersectionRatio >= S);
24
- d({ isIntersecting: h, entry: o }), i.current && i.current(h, o);
25
- });
26
- },
27
- { threshold: f, root: a, rootMargin: l }
28
- );
29
- return e.observe(n), () => {
30
- e.disconnect();
31
- };
32
- }, [
33
- n,
34
- // eslint-disable-next-line react-hooks/exhaustive-deps
35
- JSON.stringify(f),
36
- a,
37
- l,
38
- c,
39
- s
40
- ]);
41
- const y = I(null);
42
- R(() => {
43
- var e;
44
- !n && ((e = t.entry) != null && e.target) && !s && !c && y.current !== t.entry.target && (y.current = t.entry.target, d({ isIntersecting: u, entry: void 0 }));
45
- }, [n, t.entry, s, c, u]);
46
- const r = [
47
- m,
48
- !!t.isIntersecting,
49
- t.entry
50
- ];
51
- return r.ref = r[0], r.isIntersecting = r[1], r.entry = r[2], r;
52
- }
53
- export {
54
- E as useIntersectionObserver
55
- };
@@ -1 +0,0 @@
1
- export * from './useInterval';
@@ -1,4 +0,0 @@
1
- import { useInterval as o } from "./useInterval.mjs";
2
- export {
3
- o as useInterval
4
- };
@@ -1,7 +0,0 @@
1
- {
2
- "sideEffects": false,
3
- "main": "./index.mjs",
4
- "module": "./index.mjs",
5
- "default": "./index.mjs",
6
- "types": "./index.d.ts"
7
- }
@@ -1,15 +0,0 @@
1
- /**
2
- * Custom hook that creates an interval that invokes a callback function at a specified delay using the [`setInterval API`](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setInterval).
3
- * @param {() => void} callback - The function to be invoked at each interval.
4
- * @param {number | null} delay - The time, in milliseconds, between each invocation of the callback. Use `null` to clear the interval.
5
- * @public
6
- * @see [Documentation](https://usehooks-ts.com/react-hook/use-interval)
7
- * @example
8
- * ```tsx
9
- * const handleInterval = () => {
10
- * // Code to be executed at each interval
11
- * };
12
- * useInterval(handleInterval, 1000);
13
- * ```
14
- */
15
- export declare function useInterval(callback: () => void, delay: number | null): void;