react-simplikit 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +43 -0
- package/README.md +6 -73
- package/dist/hooks/useAsyncEffect/useAsyncEffect.cjs +2 -2
- package/dist/hooks/useAsyncEffect/useAsyncEffect.d.cts +2 -2
- package/dist/hooks/useAsyncEffect/useAsyncEffect.d.mts +2 -2
- package/dist/hooks/useAsyncEffect/useAsyncEffect.mjs +2 -2
- package/dist/{mobile/hooks → hooks}/useAvoidKeyboard/useAvoidKeyboard.cjs +1 -1
- package/dist/{mobile/hooks → hooks}/useAvoidKeyboard/useAvoidKeyboard.d.cts +1 -1
- package/dist/{mobile/hooks → hooks}/useAvoidKeyboard/useAvoidKeyboard.d.mts +1 -1
- package/dist/{mobile/hooks → hooks}/useAvoidKeyboard/useAvoidKeyboard.mjs +1 -1
- package/dist/{mobile/hooks → hooks}/useBodyScrollLock/useBodyScrollLock.cjs +1 -1
- package/dist/{mobile/hooks → hooks}/useBodyScrollLock/useBodyScrollLock.d.cts +1 -1
- package/dist/{mobile/hooks → hooks}/useBodyScrollLock/useBodyScrollLock.d.mts +1 -1
- package/dist/{mobile/hooks → hooks}/useBodyScrollLock/useBodyScrollLock.mjs +1 -1
- package/dist/hooks/useBooleanState/useBooleanState.cjs +3 -3
- package/dist/hooks/useBooleanState/useBooleanState.d.cts +3 -2
- package/dist/hooks/useBooleanState/useBooleanState.d.mts +3 -2
- package/dist/hooks/useBooleanState/useBooleanState.mjs +3 -3
- package/dist/hooks/useDebounce/debounce.cjs +1 -0
- package/dist/hooks/useDebounce/debounce.mjs +1 -0
- package/dist/hooks/useDebounce/useDebounce.cjs +1 -1
- package/dist/hooks/useDebounce/useDebounce.mjs +1 -1
- package/dist/hooks/useDebouncedCallback/useDebouncedCallback.cjs +31 -36
- package/dist/hooks/useDebouncedCallback/useDebouncedCallback.d.cts +17 -7
- package/dist/hooks/useDebouncedCallback/useDebouncedCallback.d.mts +17 -7
- package/dist/hooks/useDebouncedCallback/useDebouncedCallback.mjs +32 -37
- package/dist/hooks/useDebouncedValue/useDebouncedValue.cjs +64 -0
- package/dist/hooks/useDebouncedValue/useDebouncedValue.d.cts +49 -0
- package/dist/hooks/useDebouncedValue/useDebouncedValue.d.mts +49 -0
- package/dist/hooks/useDebouncedValue/useDebouncedValue.mjs +64 -0
- package/dist/hooks/useDoubleClick/useDoubleClick.cjs +0 -4
- package/dist/hooks/useDoubleClick/useDoubleClick.d.cts +0 -4
- package/dist/hooks/useDoubleClick/useDoubleClick.d.mts +0 -4
- package/dist/hooks/useDoubleClick/useDoubleClick.mjs +0 -4
- package/dist/hooks/useGeolocation/useGeolocation.cjs +0 -4
- package/dist/hooks/useGeolocation/useGeolocation.d.cts +0 -4
- package/dist/hooks/useGeolocation/useGeolocation.d.mts +0 -4
- package/dist/hooks/useGeolocation/useGeolocation.mjs +0 -4
- package/dist/hooks/useImpressionRef/useImpressionRef.cjs +25 -7
- package/dist/hooks/useImpressionRef/useImpressionRef.d.cts +0 -4
- package/dist/hooks/useImpressionRef/useImpressionRef.d.mts +0 -4
- package/dist/hooks/useImpressionRef/useImpressionRef.mjs +26 -8
- package/dist/hooks/useInputState/useInputState.cjs +1 -1
- package/dist/hooks/useInputState/useInputState.d.cts +3 -2
- package/dist/hooks/useInputState/useInputState.d.mts +3 -2
- package/dist/hooks/useInputState/useInputState.mjs +1 -1
- package/dist/hooks/useIntersectionObserver/useIntersectionObserver.cjs +9 -8
- package/dist/hooks/useIntersectionObserver/useIntersectionObserver.d.cts +1 -5
- package/dist/hooks/useIntersectionObserver/useIntersectionObserver.d.mts +1 -5
- package/dist/hooks/useIntersectionObserver/useIntersectionObserver.mjs +9 -8
- package/dist/{mobile/hooks → hooks}/useKeyboardHeight/useKeyboardHeight.cjs +1 -1
- package/dist/{mobile/hooks → hooks}/useKeyboardHeight/useKeyboardHeight.d.cts +1 -1
- package/dist/{mobile/hooks → hooks}/useKeyboardHeight/useKeyboardHeight.d.mts +1 -1
- package/dist/{mobile/hooks → hooks}/useKeyboardHeight/useKeyboardHeight.mjs +1 -1
- package/dist/hooks/useList/useList.cjs +11 -8
- package/dist/hooks/useList/useList.d.cts +12 -9
- package/dist/hooks/useList/useList.d.mts +12 -9
- package/dist/hooks/useList/useList.mjs +11 -8
- package/dist/hooks/useLongPress/useLongPress.cjs +3 -4
- package/dist/hooks/useLongPress/useLongPress.d.cts +0 -4
- package/dist/hooks/useLongPress/useLongPress.d.mts +0 -4
- package/dist/hooks/useLongPress/useLongPress.mjs +4 -5
- package/dist/{mobile/hooks → hooks}/useNetworkStatus/useNetworkStatus.cjs +1 -1
- package/dist/{mobile/hooks → hooks}/useNetworkStatus/useNetworkStatus.d.cts +1 -1
- package/dist/{mobile/hooks → hooks}/useNetworkStatus/useNetworkStatus.d.mts +1 -1
- package/dist/{mobile/hooks → hooks}/useNetworkStatus/useNetworkStatus.mjs +1 -1
- package/dist/hooks/useOutsideClickEffect/useOutsideClickEffect.cjs +0 -4
- package/dist/hooks/useOutsideClickEffect/useOutsideClickEffect.d.cts +0 -4
- package/dist/hooks/useOutsideClickEffect/useOutsideClickEffect.d.mts +0 -4
- package/dist/hooks/useOutsideClickEffect/useOutsideClickEffect.mjs +0 -4
- package/dist/{mobile/hooks → hooks}/usePageVisibility/usePageVisibility.cjs +3 -1
- package/dist/{mobile/hooks → hooks}/usePageVisibility/usePageVisibility.d.cts +3 -1
- package/dist/{mobile/hooks → hooks}/usePageVisibility/usePageVisibility.d.mts +3 -1
- package/dist/{mobile/hooks → hooks}/usePageVisibility/usePageVisibility.mjs +3 -1
- package/dist/hooks/useRefEffect/useRefEffect.cjs +6 -4
- package/dist/hooks/useRefEffect/useRefEffect.mjs +7 -5
- package/dist/{mobile/hooks → hooks}/useSafeAreaInset/useSafeAreaInset.cjs +1 -1
- package/dist/{mobile/hooks → hooks}/useSafeAreaInset/useSafeAreaInset.d.cts +1 -1
- package/dist/{mobile/hooks → hooks}/useSafeAreaInset/useSafeAreaInset.d.mts +1 -1
- package/dist/{mobile/hooks → hooks}/useSafeAreaInset/useSafeAreaInset.mjs +1 -1
- package/dist/{mobile/hooks → hooks}/useScrollDirection/useScrollDirection.cjs +1 -1
- package/dist/{mobile/hooks → hooks}/useScrollDirection/useScrollDirection.d.cts +1 -1
- package/dist/{mobile/hooks → hooks}/useScrollDirection/useScrollDirection.d.mts +1 -1
- package/dist/{mobile/hooks → hooks}/useScrollDirection/useScrollDirection.mjs +1 -1
- package/dist/hooks/useSet/useSet.cjs +11 -2
- package/dist/hooks/useSet/useSet.d.cts +11 -2
- package/dist/hooks/useSet/useSet.d.mts +11 -2
- package/dist/hooks/useSet/useSet.mjs +11 -2
- package/dist/hooks/useStorageState/useStorageState.cjs +1 -1
- package/dist/hooks/useStorageState/useStorageState.d.cts +0 -4
- package/dist/hooks/useStorageState/useStorageState.d.mts +0 -4
- package/dist/hooks/useStorageState/useStorageState.mjs +1 -1
- package/dist/hooks/useThrottle/throttle.cjs +22 -5
- package/dist/hooks/useThrottle/throttle.mjs +22 -5
- package/dist/hooks/useThrottledCallback/useThrottledCallback.cjs +22 -37
- package/dist/hooks/useThrottledCallback/useThrottledCallback.d.cts +18 -11
- package/dist/hooks/useThrottledCallback/useThrottledCallback.d.mts +18 -11
- package/dist/hooks/useThrottledCallback/useThrottledCallback.mjs +23 -38
- package/dist/hooks/useThrottledValue/useThrottledValue.cjs +66 -0
- package/dist/hooks/useThrottledValue/useThrottledValue.d.cts +48 -0
- package/dist/hooks/useThrottledValue/useThrottledValue.d.mts +48 -0
- package/dist/hooks/useThrottledValue/useThrottledValue.mjs +66 -0
- package/dist/hooks/useVisibilityEvent/useVisibilityEvent.cjs +2 -4
- package/dist/hooks/useVisibilityEvent/useVisibilityEvent.d.cts +2 -4
- package/dist/hooks/useVisibilityEvent/useVisibilityEvent.d.mts +2 -4
- package/dist/hooks/useVisibilityEvent/useVisibilityEvent.mjs +2 -4
- package/dist/{mobile/hooks → hooks}/useVisualViewport/useVisualViewport.cjs +1 -1
- package/dist/{mobile/hooks → hooks}/useVisualViewport/useVisualViewport.d.cts +1 -1
- package/dist/{mobile/hooks → hooks}/useVisualViewport/useVisualViewport.d.mts +1 -1
- package/dist/{mobile/hooks → hooks}/useVisualViewport/useVisualViewport.mjs +1 -1
- package/dist/index.cjs +23 -19
- package/dist/index.d.cts +21 -19
- package/dist/index.d.mts +21 -19
- package/dist/index.mjs +22 -20
- package/dist/{mobile/utils → utils}/disableBodyScrollLock/disableBodyScrollLock.cjs +1 -1
- package/dist/{mobile/utils → utils}/disableBodyScrollLock/disableBodyScrollLock.d.cts +1 -1
- package/dist/{mobile/utils → utils}/disableBodyScrollLock/disableBodyScrollLock.d.mts +1 -1
- package/dist/{mobile/utils → utils}/disableBodyScrollLock/disableBodyScrollLock.mjs +1 -1
- package/dist/{mobile/utils → utils}/enableBodyScrollLock/enableBodyScrollLock.cjs +1 -1
- package/dist/{mobile/utils → utils}/enableBodyScrollLock/enableBodyScrollLock.d.cts +1 -1
- package/dist/{mobile/utils → utils}/enableBodyScrollLock/enableBodyScrollLock.d.mts +1 -1
- package/dist/{mobile/utils → utils}/enableBodyScrollLock/enableBodyScrollLock.mjs +1 -1
- package/dist/{mobile/utils → utils}/getKeyboardHeight/getKeyboardHeight.cjs +1 -1
- package/dist/{mobile/utils → utils}/getKeyboardHeight/getKeyboardHeight.d.cts +1 -1
- package/dist/{mobile/utils → utils}/getKeyboardHeight/getKeyboardHeight.d.mts +1 -1
- package/dist/{mobile/utils → utils}/getKeyboardHeight/getKeyboardHeight.mjs +1 -1
- package/dist/{mobile/utils → utils}/getSafeAreaInset/getSafeAreaInset.cjs +1 -1
- package/dist/{mobile/utils → utils}/getSafeAreaInset/getSafeAreaInset.d.cts +1 -1
- package/dist/{mobile/utils → utils}/getSafeAreaInset/getSafeAreaInset.d.mts +1 -1
- package/dist/{mobile/utils → utils}/getSafeAreaInset/getSafeAreaInset.mjs +1 -1
- package/dist/{mobile/utils → utils}/isAndroid/isAndroid.cjs +1 -1
- package/dist/{mobile/utils → utils}/isAndroid/isAndroid.d.cts +1 -1
- package/dist/{mobile/utils → utils}/isAndroid/isAndroid.d.mts +1 -1
- package/dist/{mobile/utils → utils}/isAndroid/isAndroid.mjs +1 -1
- package/dist/{mobile/utils → utils}/isIOS/isIOS.cjs +1 -1
- package/dist/{mobile/utils → utils}/isIOS/isIOS.d.cts +1 -1
- package/dist/{mobile/utils → utils}/isIOS/isIOS.d.mts +1 -1
- package/dist/{mobile/utils → utils}/isIOS/isIOS.mjs +1 -1
- package/dist/{mobile/utils → utils}/isKeyboardVisible/isKeyboardVisible.cjs +1 -1
- package/dist/{mobile/utils → utils}/isKeyboardVisible/isKeyboardVisible.d.cts +1 -1
- package/dist/{mobile/utils → utils}/isKeyboardVisible/isKeyboardVisible.d.mts +1 -1
- package/dist/{mobile/utils → utils}/isKeyboardVisible/isKeyboardVisible.mjs +1 -1
- package/dist/{mobile/utils → utils}/isServer/isServer.cjs +1 -1
- package/dist/{mobile/utils → utils}/isServer/isServer.d.cts +1 -1
- package/dist/{mobile/utils → utils}/isServer/isServer.d.mts +1 -1
- package/dist/{mobile/utils → utils}/isServer/isServer.mjs +1 -1
- package/dist/utils/mergeProps/mergeProps.cjs +1 -1
- package/dist/utils/mergeProps/mergeProps.d.cts +1 -1
- package/dist/utils/mergeProps/mergeProps.d.mts +1 -1
- package/dist/utils/mergeProps/mergeProps.mjs +1 -1
- package/dist/utils/mergeRefs/mergeRefs.cjs +1 -1
- package/dist/utils/mergeRefs/mergeRefs.d.cts +1 -1
- package/dist/utils/mergeRefs/mergeRefs.d.mts +1 -1
- package/dist/utils/mergeRefs/mergeRefs.mjs +1 -1
- package/dist/{mobile/utils → utils}/subscribeKeyboardHeight/subscribeKeyboardHeight.cjs +1 -1
- package/dist/{mobile/utils → utils}/subscribeKeyboardHeight/subscribeKeyboardHeight.d.cts +1 -1
- package/dist/{mobile/utils → utils}/subscribeKeyboardHeight/subscribeKeyboardHeight.d.mts +1 -1
- package/dist/{mobile/utils → utils}/subscribeKeyboardHeight/subscribeKeyboardHeight.mjs +1 -1
- package/package.json +2 -4
- /package/dist/{mobile/hooks → hooks}/useAvoidKeyboard/index.d.cts +0 -0
- /package/dist/{mobile/hooks → hooks}/useAvoidKeyboard/index.d.mts +0 -0
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
const require_usePreservedCallback = require("../usePreservedCallback/usePreservedCallback.cjs");
|
|
3
|
+
const require_usePreservedReference = require("../usePreservedReference/usePreservedReference.cjs");
|
|
3
4
|
const require_useRefEffect = require("../useRefEffect/useRefEffect.cjs");
|
|
4
5
|
let react = require("react");
|
|
5
6
|
//#region src/hooks/useIntersectionObserver/useIntersectionObserver.ts
|
|
6
7
|
/**
|
|
7
|
-
* @deprecated This hook is deprecated as it depends on browser-specific APIs (IntersectionObserver).
|
|
8
|
-
* react-simplikit is now focused on platform-independent, pure state/logic hooks.
|
|
9
|
-
* This hook will be removed in a future major version.
|
|
10
|
-
*
|
|
11
8
|
* @description
|
|
12
9
|
* `useIntersectionObserver` is a React hook that detects whether a specific DOM element is visible on the screen.
|
|
13
10
|
* It uses the `IntersectionObserver` API to execute a callback when the element enters or exits the viewport.
|
|
@@ -15,7 +12,7 @@ let react = require("react");
|
|
|
15
12
|
* @param {(entry: IntersectionObserverEntry) => void} callback - A callback function that is executed when the visibility of the element changes.
|
|
16
13
|
* You can check `entry.isIntersecting` to determine if the element is in view.
|
|
17
14
|
* @param {IntersectionObserverInit} options - Options for the `IntersectionObserver`.
|
|
18
|
-
* @param {
|
|
15
|
+
* @param {Element | Document | null} [options.root] - The element that is used as the viewport for checking visibility of the target.
|
|
19
16
|
* @param {string} [options.rootMargin] - Margin around the root.
|
|
20
17
|
* @param {number | number[]} [options.threshold] - Either a single number or an array of numbers which indicate at what percentage of the target's visibility the observer's callback should be executed.
|
|
21
18
|
*
|
|
@@ -41,18 +38,22 @@ let react = require("react");
|
|
|
41
38
|
*/
|
|
42
39
|
function useIntersectionObserver(callback, options) {
|
|
43
40
|
const preservedCallback = require_usePreservedCallback.usePreservedCallback(callback);
|
|
41
|
+
const preservedOptions = require_usePreservedReference.usePreservedReference(options, areIntersectionOptionsEqual);
|
|
44
42
|
const observer = (0, react.useMemo)(() => {
|
|
45
43
|
if (typeof IntersectionObserver === "undefined") return;
|
|
46
44
|
return new IntersectionObserver(([entry]) => {
|
|
47
45
|
preservedCallback(entry);
|
|
48
|
-
},
|
|
49
|
-
}, [preservedCallback,
|
|
46
|
+
}, preservedOptions);
|
|
47
|
+
}, [preservedCallback, preservedOptions]);
|
|
50
48
|
return require_useRefEffect.useRefEffect((element) => {
|
|
51
49
|
observer?.observe(element);
|
|
52
50
|
return () => {
|
|
53
51
|
observer?.unobserve(element);
|
|
54
52
|
};
|
|
55
|
-
}, [preservedCallback,
|
|
53
|
+
}, [preservedCallback, preservedOptions]);
|
|
54
|
+
}
|
|
55
|
+
function areIntersectionOptionsEqual(a, b) {
|
|
56
|
+
return a.root === b.root && a.rootMargin === b.rootMargin && JSON.stringify(a.threshold) === JSON.stringify(b.threshold);
|
|
56
57
|
}
|
|
57
58
|
//#endregion
|
|
58
59
|
exports.useIntersectionObserver = useIntersectionObserver;
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
//#region src/hooks/useIntersectionObserver/useIntersectionObserver.d.ts
|
|
3
3
|
/**
|
|
4
|
-
* @deprecated This hook is deprecated as it depends on browser-specific APIs (IntersectionObserver).
|
|
5
|
-
* react-simplikit is now focused on platform-independent, pure state/logic hooks.
|
|
6
|
-
* This hook will be removed in a future major version.
|
|
7
|
-
*
|
|
8
4
|
* @description
|
|
9
5
|
* `useIntersectionObserver` is a React hook that detects whether a specific DOM element is visible on the screen.
|
|
10
6
|
* It uses the `IntersectionObserver` API to execute a callback when the element enters or exits the viewport.
|
|
@@ -12,7 +8,7 @@
|
|
|
12
8
|
* @param {(entry: IntersectionObserverEntry) => void} callback - A callback function that is executed when the visibility of the element changes.
|
|
13
9
|
* You can check `entry.isIntersecting` to determine if the element is in view.
|
|
14
10
|
* @param {IntersectionObserverInit} options - Options for the `IntersectionObserver`.
|
|
15
|
-
* @param {
|
|
11
|
+
* @param {Element | Document | null} [options.root] - The element that is used as the viewport for checking visibility of the target.
|
|
16
12
|
* @param {string} [options.rootMargin] - Margin around the root.
|
|
17
13
|
* @param {number | number[]} [options.threshold] - Either a single number or an array of numbers which indicate at what percentage of the target's visibility the observer's callback should be executed.
|
|
18
14
|
*
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
//#region src/hooks/useIntersectionObserver/useIntersectionObserver.d.ts
|
|
3
3
|
/**
|
|
4
|
-
* @deprecated This hook is deprecated as it depends on browser-specific APIs (IntersectionObserver).
|
|
5
|
-
* react-simplikit is now focused on platform-independent, pure state/logic hooks.
|
|
6
|
-
* This hook will be removed in a future major version.
|
|
7
|
-
*
|
|
8
4
|
* @description
|
|
9
5
|
* `useIntersectionObserver` is a React hook that detects whether a specific DOM element is visible on the screen.
|
|
10
6
|
* It uses the `IntersectionObserver` API to execute a callback when the element enters or exits the viewport.
|
|
@@ -12,7 +8,7 @@
|
|
|
12
8
|
* @param {(entry: IntersectionObserverEntry) => void} callback - A callback function that is executed when the visibility of the element changes.
|
|
13
9
|
* You can check `entry.isIntersecting` to determine if the element is in view.
|
|
14
10
|
* @param {IntersectionObserverInit} options - Options for the `IntersectionObserver`.
|
|
15
|
-
* @param {
|
|
11
|
+
* @param {Element | Document | null} [options.root] - The element that is used as the viewport for checking visibility of the target.
|
|
16
12
|
* @param {string} [options.rootMargin] - Margin around the root.
|
|
17
13
|
* @param {number | number[]} [options.threshold] - Either a single number or an array of numbers which indicate at what percentage of the target's visibility the observer's callback should be executed.
|
|
18
14
|
*
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { usePreservedCallback } from "../usePreservedCallback/usePreservedCallback.mjs";
|
|
3
|
+
import { usePreservedReference } from "../usePreservedReference/usePreservedReference.mjs";
|
|
3
4
|
import { useRefEffect } from "../useRefEffect/useRefEffect.mjs";
|
|
4
5
|
import { useMemo } from "react";
|
|
5
6
|
//#region src/hooks/useIntersectionObserver/useIntersectionObserver.ts
|
|
6
7
|
/**
|
|
7
|
-
* @deprecated This hook is deprecated as it depends on browser-specific APIs (IntersectionObserver).
|
|
8
|
-
* react-simplikit is now focused on platform-independent, pure state/logic hooks.
|
|
9
|
-
* This hook will be removed in a future major version.
|
|
10
|
-
*
|
|
11
8
|
* @description
|
|
12
9
|
* `useIntersectionObserver` is a React hook that detects whether a specific DOM element is visible on the screen.
|
|
13
10
|
* It uses the `IntersectionObserver` API to execute a callback when the element enters or exits the viewport.
|
|
@@ -15,7 +12,7 @@ import { useMemo } from "react";
|
|
|
15
12
|
* @param {(entry: IntersectionObserverEntry) => void} callback - A callback function that is executed when the visibility of the element changes.
|
|
16
13
|
* You can check `entry.isIntersecting` to determine if the element is in view.
|
|
17
14
|
* @param {IntersectionObserverInit} options - Options for the `IntersectionObserver`.
|
|
18
|
-
* @param {
|
|
15
|
+
* @param {Element | Document | null} [options.root] - The element that is used as the viewport for checking visibility of the target.
|
|
19
16
|
* @param {string} [options.rootMargin] - Margin around the root.
|
|
20
17
|
* @param {number | number[]} [options.threshold] - Either a single number or an array of numbers which indicate at what percentage of the target's visibility the observer's callback should be executed.
|
|
21
18
|
*
|
|
@@ -41,18 +38,22 @@ import { useMemo } from "react";
|
|
|
41
38
|
*/
|
|
42
39
|
function useIntersectionObserver(callback, options) {
|
|
43
40
|
const preservedCallback = usePreservedCallback(callback);
|
|
41
|
+
const preservedOptions = usePreservedReference(options, areIntersectionOptionsEqual);
|
|
44
42
|
const observer = useMemo(() => {
|
|
45
43
|
if (typeof IntersectionObserver === "undefined") return;
|
|
46
44
|
return new IntersectionObserver(([entry]) => {
|
|
47
45
|
preservedCallback(entry);
|
|
48
|
-
},
|
|
49
|
-
}, [preservedCallback,
|
|
46
|
+
}, preservedOptions);
|
|
47
|
+
}, [preservedCallback, preservedOptions]);
|
|
50
48
|
return useRefEffect((element) => {
|
|
51
49
|
observer?.observe(element);
|
|
52
50
|
return () => {
|
|
53
51
|
observer?.unobserve(element);
|
|
54
52
|
};
|
|
55
|
-
}, [preservedCallback,
|
|
53
|
+
}, [preservedCallback, preservedOptions]);
|
|
54
|
+
}
|
|
55
|
+
function areIntersectionOptionsEqual(a, b) {
|
|
56
|
+
return a.root === b.root && a.rootMargin === b.rootMargin && JSON.stringify(a.threshold) === JSON.stringify(b.threshold);
|
|
56
57
|
}
|
|
57
58
|
//#endregion
|
|
58
59
|
export { useIntersectionObserver };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
const require_subscribeKeyboardHeight = require("../../utils/subscribeKeyboardHeight/subscribeKeyboardHeight.cjs");
|
|
3
3
|
let react = require("react");
|
|
4
|
-
//#region src/
|
|
4
|
+
//#region src/hooks/useKeyboardHeight/useKeyboardHeight.ts
|
|
5
5
|
/**
|
|
6
6
|
* @description
|
|
7
7
|
* `useKeyboardHeight` is a React hook that tracks the on-screen keyboard height.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { subscribeKeyboardHeight } from "../../utils/subscribeKeyboardHeight/subscribeKeyboardHeight.mjs";
|
|
3
3
|
import { useEffect, useState } from "react";
|
|
4
|
-
//#region src/
|
|
4
|
+
//#region src/hooks/useKeyboardHeight/useKeyboardHeight.ts
|
|
5
5
|
/**
|
|
6
6
|
* @description
|
|
7
7
|
* `useKeyboardHeight` is a React hook that tracks the on-screen keyboard height.
|
|
@@ -8,15 +8,18 @@ let react = require("react");
|
|
|
8
8
|
* A React hook that manages an array as state.
|
|
9
9
|
* Provides efficient state management and stable action functions.
|
|
10
10
|
*
|
|
11
|
-
* @
|
|
11
|
+
* @template T - The type of the values held in the list.
|
|
12
12
|
*
|
|
13
|
-
* @
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* - `
|
|
17
|
-
* - `
|
|
18
|
-
* - `
|
|
19
|
-
* - `
|
|
13
|
+
* @param {T[]} [initialState=[]] - Initial array state.
|
|
14
|
+
*
|
|
15
|
+
* @returns {UseListReturn<T>} A tuple containing the array state and actions to manipulate it.
|
|
16
|
+
* - list `ReadonlyArray<T>` - The current array state;
|
|
17
|
+
* - actions.push `(value: T) => void` - Appends a value to the end of the list;
|
|
18
|
+
* - actions.insertAt `(index: number, value: T) => void` - Inserts a value at the specified index;
|
|
19
|
+
* - actions.updateAt `(index: number, value: T) => void` - Updates the value at the specified index;
|
|
20
|
+
* - actions.removeAt `(index: number) => void` - Removes the value at the specified index;
|
|
21
|
+
* - actions.setAll `(values: T[]) => void` - Replaces the entire list with a new array;
|
|
22
|
+
* - actions.reset `() => void` - Resets the list to its initial state;
|
|
20
23
|
*
|
|
21
24
|
* @example
|
|
22
25
|
* ```tsx
|
|
@@ -14,15 +14,18 @@ type UseListReturn<T> = [ReadonlyArray<T>, ListActions<T>];
|
|
|
14
14
|
* A React hook that manages an array as state.
|
|
15
15
|
* Provides efficient state management and stable action functions.
|
|
16
16
|
*
|
|
17
|
-
* @
|
|
18
|
-
*
|
|
19
|
-
* @
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* - `
|
|
23
|
-
* - `
|
|
24
|
-
* - `
|
|
25
|
-
* - `
|
|
17
|
+
* @template T - The type of the values held in the list.
|
|
18
|
+
*
|
|
19
|
+
* @param {T[]} [initialState=[]] - Initial array state.
|
|
20
|
+
*
|
|
21
|
+
* @returns {UseListReturn<T>} A tuple containing the array state and actions to manipulate it.
|
|
22
|
+
* - list `ReadonlyArray<T>` - The current array state;
|
|
23
|
+
* - actions.push `(value: T) => void` - Appends a value to the end of the list;
|
|
24
|
+
* - actions.insertAt `(index: number, value: T) => void` - Inserts a value at the specified index;
|
|
25
|
+
* - actions.updateAt `(index: number, value: T) => void` - Updates the value at the specified index;
|
|
26
|
+
* - actions.removeAt `(index: number) => void` - Removes the value at the specified index;
|
|
27
|
+
* - actions.setAll `(values: T[]) => void` - Replaces the entire list with a new array;
|
|
28
|
+
* - actions.reset `() => void` - Resets the list to its initial state;
|
|
26
29
|
*
|
|
27
30
|
* @example
|
|
28
31
|
* ```tsx
|
|
@@ -14,15 +14,18 @@ type UseListReturn<T> = [ReadonlyArray<T>, ListActions<T>];
|
|
|
14
14
|
* A React hook that manages an array as state.
|
|
15
15
|
* Provides efficient state management and stable action functions.
|
|
16
16
|
*
|
|
17
|
-
* @
|
|
18
|
-
*
|
|
19
|
-
* @
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* - `
|
|
23
|
-
* - `
|
|
24
|
-
* - `
|
|
25
|
-
* - `
|
|
17
|
+
* @template T - The type of the values held in the list.
|
|
18
|
+
*
|
|
19
|
+
* @param {T[]} [initialState=[]] - Initial array state.
|
|
20
|
+
*
|
|
21
|
+
* @returns {UseListReturn<T>} A tuple containing the array state and actions to manipulate it.
|
|
22
|
+
* - list `ReadonlyArray<T>` - The current array state;
|
|
23
|
+
* - actions.push `(value: T) => void` - Appends a value to the end of the list;
|
|
24
|
+
* - actions.insertAt `(index: number, value: T) => void` - Inserts a value at the specified index;
|
|
25
|
+
* - actions.updateAt `(index: number, value: T) => void` - Updates the value at the specified index;
|
|
26
|
+
* - actions.removeAt `(index: number) => void` - Removes the value at the specified index;
|
|
27
|
+
* - actions.setAll `(values: T[]) => void` - Replaces the entire list with a new array;
|
|
28
|
+
* - actions.reset `() => void` - Resets the list to its initial state;
|
|
26
29
|
*
|
|
27
30
|
* @example
|
|
28
31
|
* ```tsx
|
|
@@ -8,15 +8,18 @@ import { useMemo, useState } from "react";
|
|
|
8
8
|
* A React hook that manages an array as state.
|
|
9
9
|
* Provides efficient state management and stable action functions.
|
|
10
10
|
*
|
|
11
|
-
* @
|
|
11
|
+
* @template T - The type of the values held in the list.
|
|
12
12
|
*
|
|
13
|
-
* @
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* - `
|
|
17
|
-
* - `
|
|
18
|
-
* - `
|
|
19
|
-
* - `
|
|
13
|
+
* @param {T[]} [initialState=[]] - Initial array state.
|
|
14
|
+
*
|
|
15
|
+
* @returns {UseListReturn<T>} A tuple containing the array state and actions to manipulate it.
|
|
16
|
+
* - list `ReadonlyArray<T>` - The current array state;
|
|
17
|
+
* - actions.push `(value: T) => void` - Appends a value to the end of the list;
|
|
18
|
+
* - actions.insertAt `(index: number, value: T) => void` - Inserts a value at the specified index;
|
|
19
|
+
* - actions.updateAt `(index: number, value: T) => void` - Updates the value at the specified index;
|
|
20
|
+
* - actions.removeAt `(index: number) => void` - Removes the value at the specified index;
|
|
21
|
+
* - actions.setAll `(values: T[]) => void` - Replaces the entire list with a new array;
|
|
22
|
+
* - actions.reset `() => void` - Resets the list to its initial state;
|
|
20
23
|
*
|
|
21
24
|
* @example
|
|
22
25
|
* ```tsx
|
|
@@ -3,10 +3,6 @@ const require_usePreservedCallback = require("../usePreservedCallback/usePreserv
|
|
|
3
3
|
let react = require("react");
|
|
4
4
|
//#region src/hooks/useLongPress/useLongPress.ts
|
|
5
5
|
/**
|
|
6
|
-
* @deprecated This hook is deprecated as it depends on browser-specific APIs (DOM events, window.setTimeout).
|
|
7
|
-
* react-simplikit is now focused on platform-independent, pure state/logic hooks.
|
|
8
|
-
* This hook will be removed in a future major version.
|
|
9
|
-
*
|
|
10
6
|
* @description
|
|
11
7
|
* `useLongPress` is a React hook that detects when an element is pressed and held for a specified duration.
|
|
12
8
|
* It handles both mouse and touch events, making it work consistently across desktop and mobile devices.
|
|
@@ -89,6 +85,9 @@ function useLongPress(onLongPress, { delay = 500, moveThreshold, onClick, onLong
|
|
|
89
85
|
timeoutRef.current = null;
|
|
90
86
|
}
|
|
91
87
|
}, []);
|
|
88
|
+
(0, react.useEffect)(function cleanupLongPressOnUnmount() {
|
|
89
|
+
return cancelLongPress;
|
|
90
|
+
}, [cancelLongPress]);
|
|
92
91
|
const handlePressStart = (0, react.useCallback)((event) => {
|
|
93
92
|
cancelLongPress();
|
|
94
93
|
const position = getClientPosition(event);
|
|
@@ -12,10 +12,6 @@ type UseLongPressOptions<E extends HTMLElement> = {
|
|
|
12
12
|
onLongPressEnd?: Handler<E>;
|
|
13
13
|
};
|
|
14
14
|
/**
|
|
15
|
-
* @deprecated This hook is deprecated as it depends on browser-specific APIs (DOM events, window.setTimeout).
|
|
16
|
-
* react-simplikit is now focused on platform-independent, pure state/logic hooks.
|
|
17
|
-
* This hook will be removed in a future major version.
|
|
18
|
-
*
|
|
19
15
|
* @description
|
|
20
16
|
* `useLongPress` is a React hook that detects when an element is pressed and held for a specified duration.
|
|
21
17
|
* It handles both mouse and touch events, making it work consistently across desktop and mobile devices.
|
|
@@ -12,10 +12,6 @@ type UseLongPressOptions<E extends HTMLElement> = {
|
|
|
12
12
|
onLongPressEnd?: Handler<E>;
|
|
13
13
|
};
|
|
14
14
|
/**
|
|
15
|
-
* @deprecated This hook is deprecated as it depends on browser-specific APIs (DOM events, window.setTimeout).
|
|
16
|
-
* react-simplikit is now focused on platform-independent, pure state/logic hooks.
|
|
17
|
-
* This hook will be removed in a future major version.
|
|
18
|
-
*
|
|
19
15
|
* @description
|
|
20
16
|
* `useLongPress` is a React hook that detects when an element is pressed and held for a specified duration.
|
|
21
17
|
* It handles both mouse and touch events, making it work consistently across desktop and mobile devices.
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { usePreservedCallback } from "../usePreservedCallback/usePreservedCallback.mjs";
|
|
3
|
-
import { useCallback, useRef } from "react";
|
|
3
|
+
import { useCallback, useEffect, useRef } from "react";
|
|
4
4
|
//#region src/hooks/useLongPress/useLongPress.ts
|
|
5
5
|
/**
|
|
6
|
-
* @deprecated This hook is deprecated as it depends on browser-specific APIs (DOM events, window.setTimeout).
|
|
7
|
-
* react-simplikit is now focused on platform-independent, pure state/logic hooks.
|
|
8
|
-
* This hook will be removed in a future major version.
|
|
9
|
-
*
|
|
10
6
|
* @description
|
|
11
7
|
* `useLongPress` is a React hook that detects when an element is pressed and held for a specified duration.
|
|
12
8
|
* It handles both mouse and touch events, making it work consistently across desktop and mobile devices.
|
|
@@ -89,6 +85,9 @@ function useLongPress(onLongPress, { delay = 500, moveThreshold, onClick, onLong
|
|
|
89
85
|
timeoutRef.current = null;
|
|
90
86
|
}
|
|
91
87
|
}, []);
|
|
88
|
+
useEffect(function cleanupLongPressOnUnmount() {
|
|
89
|
+
return cancelLongPress;
|
|
90
|
+
}, [cancelLongPress]);
|
|
92
91
|
const handlePressStart = useCallback((event) => {
|
|
93
92
|
cancelLongPress();
|
|
94
93
|
const position = getClientPosition(event);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
const require_isServer = require("../../utils/isServer/isServer.cjs");
|
|
3
3
|
let react = require("react");
|
|
4
|
-
//#region src/
|
|
4
|
+
//#region src/hooks/useNetworkStatus/useNetworkStatus.ts
|
|
5
5
|
/**
|
|
6
6
|
* @description
|
|
7
7
|
* `useNetworkStatus` is a React hook that provides access to the Network Information API.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { isServer } from "../../utils/isServer/isServer.mjs";
|
|
3
3
|
import { useEffect, useState } from "react";
|
|
4
|
-
//#region src/
|
|
4
|
+
//#region src/hooks/useNetworkStatus/useNetworkStatus.ts
|
|
5
5
|
/**
|
|
6
6
|
* @description
|
|
7
7
|
* `useNetworkStatus` is a React hook that provides access to the Network Information API.
|
|
@@ -3,10 +3,6 @@ const require_usePreservedCallback = require("../usePreservedCallback/usePreserv
|
|
|
3
3
|
let react = require("react");
|
|
4
4
|
//#region src/hooks/useOutsideClickEffect/useOutsideClickEffect.ts
|
|
5
5
|
/**
|
|
6
|
-
* @deprecated This hook is deprecated as it depends on browser-specific APIs (DOM events, document).
|
|
7
|
-
* react-simplikit is now focused on platform-independent, pure state/logic hooks.
|
|
8
|
-
* This hook will be removed in a future major version.
|
|
9
|
-
*
|
|
10
6
|
* @description
|
|
11
7
|
* `useOutsideClickEffect` is a React hook that triggers a callback when a click event occurs outside the specified container(s).
|
|
12
8
|
* It is useful for closing modals, dropdowns, tooltips, and other UI components when clicking outside.
|
|
@@ -2,10 +2,6 @@
|
|
|
2
2
|
//#region src/hooks/useOutsideClickEffect/useOutsideClickEffect.d.ts
|
|
3
3
|
type OneOrMore<T> = T | T[];
|
|
4
4
|
/**
|
|
5
|
-
* @deprecated This hook is deprecated as it depends on browser-specific APIs (DOM events, document).
|
|
6
|
-
* react-simplikit is now focused on platform-independent, pure state/logic hooks.
|
|
7
|
-
* This hook will be removed in a future major version.
|
|
8
|
-
*
|
|
9
5
|
* @description
|
|
10
6
|
* `useOutsideClickEffect` is a React hook that triggers a callback when a click event occurs outside the specified container(s).
|
|
11
7
|
* It is useful for closing modals, dropdowns, tooltips, and other UI components when clicking outside.
|
|
@@ -2,10 +2,6 @@
|
|
|
2
2
|
//#region src/hooks/useOutsideClickEffect/useOutsideClickEffect.d.ts
|
|
3
3
|
type OneOrMore<T> = T | T[];
|
|
4
4
|
/**
|
|
5
|
-
* @deprecated This hook is deprecated as it depends on browser-specific APIs (DOM events, document).
|
|
6
|
-
* react-simplikit is now focused on platform-independent, pure state/logic hooks.
|
|
7
|
-
* This hook will be removed in a future major version.
|
|
8
|
-
*
|
|
9
5
|
* @description
|
|
10
6
|
* `useOutsideClickEffect` is a React hook that triggers a callback when a click event occurs outside the specified container(s).
|
|
11
7
|
* It is useful for closing modals, dropdowns, tooltips, and other UI components when clicking outside.
|
|
@@ -3,10 +3,6 @@ import { usePreservedCallback } from "../usePreservedCallback/usePreservedCallba
|
|
|
3
3
|
import { useEffect, useRef } from "react";
|
|
4
4
|
//#region src/hooks/useOutsideClickEffect/useOutsideClickEffect.ts
|
|
5
5
|
/**
|
|
6
|
-
* @deprecated This hook is deprecated as it depends on browser-specific APIs (DOM events, document).
|
|
7
|
-
* react-simplikit is now focused on platform-independent, pure state/logic hooks.
|
|
8
|
-
* This hook will be removed in a future major version.
|
|
9
|
-
*
|
|
10
6
|
* @description
|
|
11
7
|
* `useOutsideClickEffect` is a React hook that triggers a callback when a click event occurs outside the specified container(s).
|
|
12
8
|
* It is useful for closing modals, dropdowns, tooltips, and other UI components when clicking outside.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
const require_isServer = require("../../utils/isServer/isServer.cjs");
|
|
3
3
|
let react = require("react");
|
|
4
|
-
//#region src/
|
|
4
|
+
//#region src/hooks/usePageVisibility/usePageVisibility.ts
|
|
5
5
|
/**
|
|
6
6
|
* @description
|
|
7
7
|
* `usePageVisibility` is a React hook that detects page visibility changes.
|
|
@@ -10,6 +10,8 @@ let react = require("react");
|
|
|
10
10
|
*
|
|
11
11
|
* **SSR Behavior**: Returns `{ isVisible: true, visibilityState: 'visible' }` during server-side rendering.
|
|
12
12
|
*
|
|
13
|
+
* @see `useVisibilityEvent` runs a callback on each change instead of returning state.
|
|
14
|
+
*
|
|
13
15
|
* @returns {PageVisibility} Page visibility information
|
|
14
16
|
* - `isVisible` - True if page is currently visible to the user
|
|
15
17
|
* - `visibilityState` - Current visibility state: 'visible' | 'hidden'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
//#region src/
|
|
2
|
+
//#region src/hooks/usePageVisibility/usePageVisibility.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Page visibility state derived from browser's DocumentVisibilityState.
|
|
5
5
|
* Excludes 'prerender' as it is deprecated and not used in modern browsers.
|
|
@@ -22,6 +22,8 @@ type PageVisibility = {
|
|
|
22
22
|
*
|
|
23
23
|
* **SSR Behavior**: Returns `{ isVisible: true, visibilityState: 'visible' }` during server-side rendering.
|
|
24
24
|
*
|
|
25
|
+
* @see `useVisibilityEvent` runs a callback on each change instead of returning state.
|
|
26
|
+
*
|
|
25
27
|
* @returns {PageVisibility} Page visibility information
|
|
26
28
|
* - `isVisible` - True if page is currently visible to the user
|
|
27
29
|
* - `visibilityState` - Current visibility state: 'visible' | 'hidden'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
//#region src/
|
|
2
|
+
//#region src/hooks/usePageVisibility/usePageVisibility.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Page visibility state derived from browser's DocumentVisibilityState.
|
|
5
5
|
* Excludes 'prerender' as it is deprecated and not used in modern browsers.
|
|
@@ -22,6 +22,8 @@ type PageVisibility = {
|
|
|
22
22
|
*
|
|
23
23
|
* **SSR Behavior**: Returns `{ isVisible: true, visibilityState: 'visible' }` during server-side rendering.
|
|
24
24
|
*
|
|
25
|
+
* @see `useVisibilityEvent` runs a callback on each change instead of returning state.
|
|
26
|
+
*
|
|
25
27
|
* @returns {PageVisibility} Page visibility information
|
|
26
28
|
* - `isVisible` - True if page is currently visible to the user
|
|
27
29
|
* - `visibilityState` - Current visibility state: 'visible' | 'hidden'
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { isServer } from "../../utils/isServer/isServer.mjs";
|
|
3
3
|
import { useEffect, useState } from "react";
|
|
4
|
-
//#region src/
|
|
4
|
+
//#region src/hooks/usePageVisibility/usePageVisibility.ts
|
|
5
5
|
/**
|
|
6
6
|
* @description
|
|
7
7
|
* `usePageVisibility` is a React hook that detects page visibility changes.
|
|
@@ -10,6 +10,8 @@ import { useEffect, useState } from "react";
|
|
|
10
10
|
*
|
|
11
11
|
* **SSR Behavior**: Returns `{ isVisible: true, visibilityState: 'visible' }` during server-side rendering.
|
|
12
12
|
*
|
|
13
|
+
* @see `useVisibilityEvent` runs a callback on each change instead of returning state.
|
|
14
|
+
*
|
|
13
15
|
* @returns {PageVisibility} Page visibility information
|
|
14
16
|
* - `isVisible` - True if page is currently visible to the user
|
|
15
17
|
* - `visibilityState` - Current visibility state: 'visible' | 'hidden'
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const require_usePreservedCallback = require("../usePreservedCallback/usePreservedCallback.cjs");
|
|
3
2
|
let react = require("react");
|
|
4
3
|
//#region src/hooks/useRefEffect/useRefEffect.ts
|
|
5
4
|
/**
|
|
@@ -29,15 +28,18 @@ let react = require("react");
|
|
|
29
28
|
*/
|
|
30
29
|
function useRefEffect(callback, deps) {
|
|
31
30
|
"use no memo";
|
|
32
|
-
const
|
|
31
|
+
const callbackRef = (0, react.useMemo)(() => ({ current: callback }), deps);
|
|
32
|
+
(0, react.useEffect)(function syncCallbackRef() {
|
|
33
|
+
callbackRef.current = callback;
|
|
34
|
+
}, [callback, callbackRef]);
|
|
33
35
|
const cleanupCallbackRef = (0, react.useRef)(() => {});
|
|
34
36
|
return (0, react.useCallback)((element) => {
|
|
35
37
|
cleanupCallbackRef.current();
|
|
36
38
|
cleanupCallbackRef.current = () => {};
|
|
37
39
|
if (element == null) return;
|
|
38
|
-
const cleanup =
|
|
40
|
+
const cleanup = callbackRef.current(element);
|
|
39
41
|
if (typeof cleanup === "function") cleanupCallbackRef.current = cleanup;
|
|
40
|
-
}, [
|
|
42
|
+
}, [callbackRef]);
|
|
41
43
|
}
|
|
42
44
|
//#endregion
|
|
43
45
|
exports.useRefEffect = useRefEffect;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import { useCallback, useRef } from "react";
|
|
2
|
+
import { useCallback, useEffect, useMemo, useRef } from "react";
|
|
4
3
|
//#region src/hooks/useRefEffect/useRefEffect.ts
|
|
5
4
|
/**
|
|
6
5
|
* @description
|
|
@@ -29,15 +28,18 @@ import { useCallback, useRef } from "react";
|
|
|
29
28
|
*/
|
|
30
29
|
function useRefEffect(callback, deps) {
|
|
31
30
|
"use no memo";
|
|
32
|
-
const
|
|
31
|
+
const callbackRef = useMemo(() => ({ current: callback }), deps);
|
|
32
|
+
useEffect(function syncCallbackRef() {
|
|
33
|
+
callbackRef.current = callback;
|
|
34
|
+
}, [callback, callbackRef]);
|
|
33
35
|
const cleanupCallbackRef = useRef(() => {});
|
|
34
36
|
return useCallback((element) => {
|
|
35
37
|
cleanupCallbackRef.current();
|
|
36
38
|
cleanupCallbackRef.current = () => {};
|
|
37
39
|
if (element == null) return;
|
|
38
|
-
const cleanup =
|
|
40
|
+
const cleanup = callbackRef.current(element);
|
|
39
41
|
if (typeof cleanup === "function") cleanupCallbackRef.current = cleanup;
|
|
40
|
-
}, [
|
|
42
|
+
}, [callbackRef]);
|
|
41
43
|
}
|
|
42
44
|
//#endregion
|
|
43
45
|
export { useRefEffect };
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
const require_isServer = require("../../utils/isServer/isServer.cjs");
|
|
3
3
|
const require_getSafeAreaInset = require("../../utils/getSafeAreaInset/getSafeAreaInset.cjs");
|
|
4
4
|
let react = require("react");
|
|
5
|
-
//#region src/
|
|
5
|
+
//#region src/hooks/useSafeAreaInset/useSafeAreaInset.ts
|
|
6
6
|
/**
|
|
7
7
|
* @description
|
|
8
8
|
* `useSafeAreaInset` is a React hook that tracks safe area inset changes.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
import { SafeAreaInset } from "../../utils/getSafeAreaInset/getSafeAreaInset.cjs";
|
|
3
|
-
//#region src/
|
|
3
|
+
//#region src/hooks/useSafeAreaInset/useSafeAreaInset.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* @description
|
|
6
6
|
* `useSafeAreaInset` is a React hook that tracks safe area inset changes.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
import { SafeAreaInset } from "../../utils/getSafeAreaInset/getSafeAreaInset.mjs";
|
|
3
|
-
//#region src/
|
|
3
|
+
//#region src/hooks/useSafeAreaInset/useSafeAreaInset.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* @description
|
|
6
6
|
* `useSafeAreaInset` is a React hook that tracks safe area inset changes.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { isServer } from "../../utils/isServer/isServer.mjs";
|
|
3
3
|
import { getSafeAreaInset } from "../../utils/getSafeAreaInset/getSafeAreaInset.mjs";
|
|
4
4
|
import { startTransition, useCallback, useEffect, useState } from "react";
|
|
5
|
-
//#region src/
|
|
5
|
+
//#region src/hooks/useSafeAreaInset/useSafeAreaInset.ts
|
|
6
6
|
/**
|
|
7
7
|
* @description
|
|
8
8
|
* `useSafeAreaInset` is a React hook that tracks safe area inset changes.
|