react-simplikit 0.2.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 +23 -0
- package/README.md +6 -33
- 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 +9 -32
- package/dist/hooks/useDebouncedCallback/useDebouncedCallback.mjs +10 -33
- 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/useImpressionRef/useImpressionRef.cjs +19 -3
- package/dist/hooks/useImpressionRef/useImpressionRef.mjs +20 -4
- 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 +8 -3
- package/dist/hooks/useIntersectionObserver/useIntersectionObserver.mjs +8 -3
- 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/useLongPress/useLongPress.cjs +3 -0
- package/dist/hooks/useLongPress/useLongPress.mjs +4 -1
- 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/{mobile/hooks → hooks}/usePageVisibility/usePageVisibility.cjs +1 -1
- package/dist/{mobile/hooks → hooks}/usePageVisibility/usePageVisibility.d.cts +1 -1
- package/dist/{mobile/hooks → hooks}/usePageVisibility/usePageVisibility.d.mts +1 -1
- package/dist/{mobile/hooks → hooks}/usePageVisibility/usePageVisibility.mjs +1 -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/useStorageState/useStorageState.cjs +1 -1
- 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 +7 -29
- package/dist/hooks/useThrottledCallback/useThrottledCallback.mjs +8 -30
- 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/{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/{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 -2
- /package/dist/{mobile/hooks → hooks}/useAvoidKeyboard/index.d.cts +0 -0
- /package/dist/{mobile/hooks → hooks}/useAvoidKeyboard/index.d.mts +0 -0
|
@@ -2,17 +2,34 @@
|
|
|
2
2
|
import { debounce } from "../useDebounce/debounce.mjs";
|
|
3
3
|
//#region src/hooks/useThrottle/throttle.ts
|
|
4
4
|
function throttle(func, throttleMs, { edges = ["leading", "trailing"] } = {}) {
|
|
5
|
+
const leading = edges.includes("leading");
|
|
6
|
+
const trailing = edges.includes("trailing");
|
|
5
7
|
let pendingAt = null;
|
|
6
|
-
|
|
8
|
+
let isPending = false;
|
|
9
|
+
const debounced = debounce(function(...args) {
|
|
10
|
+
pendingAt = Date.now();
|
|
11
|
+
isPending = false;
|
|
12
|
+
func.apply(this, args);
|
|
13
|
+
}, throttleMs, { edges });
|
|
7
14
|
const throttled = function(...args) {
|
|
8
|
-
if (pendingAt
|
|
9
|
-
|
|
15
|
+
if (pendingAt === null) pendingAt = Date.now();
|
|
16
|
+
const windowElapsed = Date.now() - pendingAt >= throttleMs;
|
|
17
|
+
if (windowElapsed && (leading || trailing && isPending)) {
|
|
10
18
|
pendingAt = Date.now();
|
|
19
|
+
isPending = false;
|
|
20
|
+
func.apply(this, args);
|
|
11
21
|
debounced.cancel();
|
|
22
|
+
debounced.schedule();
|
|
23
|
+
return;
|
|
12
24
|
}
|
|
13
|
-
|
|
25
|
+
if (windowElapsed) pendingAt = Date.now();
|
|
26
|
+
isPending = true;
|
|
27
|
+
debounced.apply(this, args);
|
|
28
|
+
};
|
|
29
|
+
throttled.cancel = () => {
|
|
30
|
+
isPending = false;
|
|
31
|
+
debounced.cancel();
|
|
14
32
|
};
|
|
15
|
-
throttled.cancel = debounced.cancel;
|
|
16
33
|
return throttled;
|
|
17
34
|
}
|
|
18
35
|
//#endregion
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const
|
|
3
|
-
const require_usePreservedReference = require("../usePreservedReference/usePreservedReference.cjs");
|
|
4
|
-
const require_throttle = require("../useThrottle/throttle.cjs");
|
|
2
|
+
const require_useThrottle = require("../useThrottle/useThrottle.cjs");
|
|
5
3
|
let react = require("react");
|
|
6
4
|
//#region src/hooks/useThrottledCallback/useThrottledCallback.ts
|
|
7
5
|
/**
|
|
@@ -41,32 +39,12 @@ const NOT_INVOKED = Symbol("NOT_INVOKED");
|
|
|
41
39
|
* }
|
|
42
40
|
*/
|
|
43
41
|
function useThrottledCallback({ onChange, timeThreshold, edges = ["leading", "trailing"] }) {
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const current = ref.current;
|
|
51
|
-
return () => {
|
|
52
|
-
current.clearPreviousThrottle();
|
|
53
|
-
};
|
|
54
|
-
}, []);
|
|
55
|
-
const preservedEdges = require_usePreservedReference.usePreservedReference(edges);
|
|
56
|
-
return (0, react.useCallback)((nextValue) => {
|
|
57
|
-
ref.current.clearPreviousThrottle();
|
|
58
|
-
if (nextValue === ref.current.value) return;
|
|
59
|
-
const throttled = require_throttle.throttle(() => {
|
|
60
|
-
handleChange(nextValue);
|
|
61
|
-
ref.current.value = nextValue;
|
|
62
|
-
}, timeThreshold, { edges: preservedEdges });
|
|
63
|
-
throttled();
|
|
64
|
-
ref.current.clearPreviousThrottle = throttled.cancel;
|
|
65
|
-
}, [
|
|
66
|
-
handleChange,
|
|
67
|
-
timeThreshold,
|
|
68
|
-
preservedEdges
|
|
69
|
-
]);
|
|
42
|
+
const lastForwardedRef = (0, react.useRef)(NOT_INVOKED);
|
|
43
|
+
return require_useThrottle.useThrottle((nextValue) => {
|
|
44
|
+
if (nextValue === lastForwardedRef.current) return;
|
|
45
|
+
onChange(nextValue);
|
|
46
|
+
lastForwardedRef.current = nextValue;
|
|
47
|
+
}, timeThreshold, { edges });
|
|
70
48
|
}
|
|
71
49
|
//#endregion
|
|
72
50
|
exports.useThrottledCallback = useThrottledCallback;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { throttle } from "../useThrottle/throttle.mjs";
|
|
5
|
-
import { useCallback, useEffect, useRef } from "react";
|
|
2
|
+
import { useThrottle } from "../useThrottle/useThrottle.mjs";
|
|
3
|
+
import { useRef } from "react";
|
|
6
4
|
//#region src/hooks/useThrottledCallback/useThrottledCallback.ts
|
|
7
5
|
/**
|
|
8
6
|
* Marks that no value has been forwarded to `onChange` yet.
|
|
@@ -41,32 +39,12 @@ const NOT_INVOKED = Symbol("NOT_INVOKED");
|
|
|
41
39
|
* }
|
|
42
40
|
*/
|
|
43
41
|
function useThrottledCallback({ onChange, timeThreshold, edges = ["leading", "trailing"] }) {
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const current = ref.current;
|
|
51
|
-
return () => {
|
|
52
|
-
current.clearPreviousThrottle();
|
|
53
|
-
};
|
|
54
|
-
}, []);
|
|
55
|
-
const preservedEdges = usePreservedReference(edges);
|
|
56
|
-
return useCallback((nextValue) => {
|
|
57
|
-
ref.current.clearPreviousThrottle();
|
|
58
|
-
if (nextValue === ref.current.value) return;
|
|
59
|
-
const throttled = throttle(() => {
|
|
60
|
-
handleChange(nextValue);
|
|
61
|
-
ref.current.value = nextValue;
|
|
62
|
-
}, timeThreshold, { edges: preservedEdges });
|
|
63
|
-
throttled();
|
|
64
|
-
ref.current.clearPreviousThrottle = throttled.cancel;
|
|
65
|
-
}, [
|
|
66
|
-
handleChange,
|
|
67
|
-
timeThreshold,
|
|
68
|
-
preservedEdges
|
|
69
|
-
]);
|
|
42
|
+
const lastForwardedRef = useRef(NOT_INVOKED);
|
|
43
|
+
return useThrottle((nextValue) => {
|
|
44
|
+
if (nextValue === lastForwardedRef.current) return;
|
|
45
|
+
onChange(nextValue);
|
|
46
|
+
lastForwardedRef.current = nextValue;
|
|
47
|
+
}, timeThreshold, { edges });
|
|
70
48
|
}
|
|
71
49
|
//#endregion
|
|
72
50
|
export { useThrottledCallback };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
const require_useThrottle = require("../useThrottle/useThrottle.cjs");
|
|
3
|
+
let react = require("react");
|
|
4
|
+
//#region src/hooks/useThrottledValue/useThrottledValue.ts
|
|
5
|
+
/**
|
|
6
|
+
* @description
|
|
7
|
+
* `useThrottledValue` is a React hook that returns a throttled copy of the given value.
|
|
8
|
+
* The caller keeps owning the state; the returned value follows it at most once per `wait` milliseconds,
|
|
9
|
+
* which is useful for driving expensive renders from scroll position, pointer position, or an element's
|
|
10
|
+
* size on resize.
|
|
11
|
+
*
|
|
12
|
+
* On the first render and on the server the value is returned as is. A change is never scheduled
|
|
13
|
+
* on mount, so the first change after mount is applied immediately when `leading` is `true`.
|
|
14
|
+
* If both `leading` and `trailing` are `false`, the returned value never updates.
|
|
15
|
+
*
|
|
16
|
+
* The value is compared by reference. Passing a new object or array on every render keeps
|
|
17
|
+
* the returned value updating every `wait` milliseconds; stabilize the reference first, for
|
|
18
|
+
* example with `usePreservedReference`.
|
|
19
|
+
*
|
|
20
|
+
* @template T - The type of the value.
|
|
21
|
+
* @param {T} value - The value to throttle.
|
|
22
|
+
* @param {number} wait - The length of the throttle window in milliseconds.
|
|
23
|
+
* @param {ThrottleOptions} [options] - Configuration options for throttle behavior.
|
|
24
|
+
* @param {boolean} [options.leading=true] - If `true`, the first change in a window is applied immediately.
|
|
25
|
+
* @param {boolean} [options.trailing=true] - If `true`, the last change in a window is applied `wait` milliseconds after that change.
|
|
26
|
+
*
|
|
27
|
+
* @returns {T} The throttled value.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* import { useThrottledValue } from 'react-simplikit';
|
|
31
|
+
* import { useState } from 'react';
|
|
32
|
+
*
|
|
33
|
+
* function ScrollProgress() {
|
|
34
|
+
* const [scrollY, setScrollY] = useState(0);
|
|
35
|
+
* const throttledScrollY = useThrottledValue(scrollY, 100);
|
|
36
|
+
*
|
|
37
|
+
* return (
|
|
38
|
+
* <div onScroll={e => setScrollY(e.currentTarget.scrollTop)}>
|
|
39
|
+
* <ProgressBar position={throttledScrollY} />
|
|
40
|
+
* </div>
|
|
41
|
+
* );
|
|
42
|
+
* }
|
|
43
|
+
*/
|
|
44
|
+
function useThrottledValue(value, wait, { leading = true, trailing = true } = {}) {
|
|
45
|
+
const [throttledValue, setThrottledValue] = (0, react.useState)(() => value);
|
|
46
|
+
const throttled = require_useThrottle.useThrottle((next) => setThrottledValue(() => next), wait, { edges: toEdges(leading, trailing) });
|
|
47
|
+
const lastForwardedRef = (0, react.useRef)(value);
|
|
48
|
+
(0, react.useEffect)(function forwardChangedValue() {
|
|
49
|
+
if (Object.is(lastForwardedRef.current, value) && Object.is(value, throttledValue)) return;
|
|
50
|
+
lastForwardedRef.current = value;
|
|
51
|
+
throttled(value);
|
|
52
|
+
}, [
|
|
53
|
+
value,
|
|
54
|
+
throttledValue,
|
|
55
|
+
throttled
|
|
56
|
+
]);
|
|
57
|
+
return throttledValue;
|
|
58
|
+
}
|
|
59
|
+
function toEdges(leading, trailing) {
|
|
60
|
+
const edges = [];
|
|
61
|
+
if (leading) edges.push("leading");
|
|
62
|
+
if (trailing) edges.push("trailing");
|
|
63
|
+
return edges;
|
|
64
|
+
}
|
|
65
|
+
//#endregion
|
|
66
|
+
exports.useThrottledValue = useThrottledValue;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/hooks/useThrottledValue/useThrottledValue.d.ts
|
|
3
|
+
type ThrottleOptions = {
|
|
4
|
+
leading?: boolean;
|
|
5
|
+
trailing?: boolean;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* @description
|
|
9
|
+
* `useThrottledValue` is a React hook that returns a throttled copy of the given value.
|
|
10
|
+
* The caller keeps owning the state; the returned value follows it at most once per `wait` milliseconds,
|
|
11
|
+
* which is useful for driving expensive renders from scroll position, pointer position, or an element's
|
|
12
|
+
* size on resize.
|
|
13
|
+
*
|
|
14
|
+
* On the first render and on the server the value is returned as is. A change is never scheduled
|
|
15
|
+
* on mount, so the first change after mount is applied immediately when `leading` is `true`.
|
|
16
|
+
* If both `leading` and `trailing` are `false`, the returned value never updates.
|
|
17
|
+
*
|
|
18
|
+
* The value is compared by reference. Passing a new object or array on every render keeps
|
|
19
|
+
* the returned value updating every `wait` milliseconds; stabilize the reference first, for
|
|
20
|
+
* example with `usePreservedReference`.
|
|
21
|
+
*
|
|
22
|
+
* @template T - The type of the value.
|
|
23
|
+
* @param {T} value - The value to throttle.
|
|
24
|
+
* @param {number} wait - The length of the throttle window in milliseconds.
|
|
25
|
+
* @param {ThrottleOptions} [options] - Configuration options for throttle behavior.
|
|
26
|
+
* @param {boolean} [options.leading=true] - If `true`, the first change in a window is applied immediately.
|
|
27
|
+
* @param {boolean} [options.trailing=true] - If `true`, the last change in a window is applied `wait` milliseconds after that change.
|
|
28
|
+
*
|
|
29
|
+
* @returns {T} The throttled value.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* import { useThrottledValue } from 'react-simplikit';
|
|
33
|
+
* import { useState } from 'react';
|
|
34
|
+
*
|
|
35
|
+
* function ScrollProgress() {
|
|
36
|
+
* const [scrollY, setScrollY] = useState(0);
|
|
37
|
+
* const throttledScrollY = useThrottledValue(scrollY, 100);
|
|
38
|
+
*
|
|
39
|
+
* return (
|
|
40
|
+
* <div onScroll={e => setScrollY(e.currentTarget.scrollTop)}>
|
|
41
|
+
* <ProgressBar position={throttledScrollY} />
|
|
42
|
+
* </div>
|
|
43
|
+
* );
|
|
44
|
+
* }
|
|
45
|
+
*/
|
|
46
|
+
declare function useThrottledValue<T>(value: T, wait: number, { leading, trailing }?: ThrottleOptions): T;
|
|
47
|
+
//#endregion
|
|
48
|
+
export { useThrottledValue };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/hooks/useThrottledValue/useThrottledValue.d.ts
|
|
3
|
+
type ThrottleOptions = {
|
|
4
|
+
leading?: boolean;
|
|
5
|
+
trailing?: boolean;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* @description
|
|
9
|
+
* `useThrottledValue` is a React hook that returns a throttled copy of the given value.
|
|
10
|
+
* The caller keeps owning the state; the returned value follows it at most once per `wait` milliseconds,
|
|
11
|
+
* which is useful for driving expensive renders from scroll position, pointer position, or an element's
|
|
12
|
+
* size on resize.
|
|
13
|
+
*
|
|
14
|
+
* On the first render and on the server the value is returned as is. A change is never scheduled
|
|
15
|
+
* on mount, so the first change after mount is applied immediately when `leading` is `true`.
|
|
16
|
+
* If both `leading` and `trailing` are `false`, the returned value never updates.
|
|
17
|
+
*
|
|
18
|
+
* The value is compared by reference. Passing a new object or array on every render keeps
|
|
19
|
+
* the returned value updating every `wait` milliseconds; stabilize the reference first, for
|
|
20
|
+
* example with `usePreservedReference`.
|
|
21
|
+
*
|
|
22
|
+
* @template T - The type of the value.
|
|
23
|
+
* @param {T} value - The value to throttle.
|
|
24
|
+
* @param {number} wait - The length of the throttle window in milliseconds.
|
|
25
|
+
* @param {ThrottleOptions} [options] - Configuration options for throttle behavior.
|
|
26
|
+
* @param {boolean} [options.leading=true] - If `true`, the first change in a window is applied immediately.
|
|
27
|
+
* @param {boolean} [options.trailing=true] - If `true`, the last change in a window is applied `wait` milliseconds after that change.
|
|
28
|
+
*
|
|
29
|
+
* @returns {T} The throttled value.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* import { useThrottledValue } from 'react-simplikit';
|
|
33
|
+
* import { useState } from 'react';
|
|
34
|
+
*
|
|
35
|
+
* function ScrollProgress() {
|
|
36
|
+
* const [scrollY, setScrollY] = useState(0);
|
|
37
|
+
* const throttledScrollY = useThrottledValue(scrollY, 100);
|
|
38
|
+
*
|
|
39
|
+
* return (
|
|
40
|
+
* <div onScroll={e => setScrollY(e.currentTarget.scrollTop)}>
|
|
41
|
+
* <ProgressBar position={throttledScrollY} />
|
|
42
|
+
* </div>
|
|
43
|
+
* );
|
|
44
|
+
* }
|
|
45
|
+
*/
|
|
46
|
+
declare function useThrottledValue<T>(value: T, wait: number, { leading, trailing }?: ThrottleOptions): T;
|
|
47
|
+
//#endregion
|
|
48
|
+
export { useThrottledValue };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useThrottle } from "../useThrottle/useThrottle.mjs";
|
|
3
|
+
import { useEffect, useRef, useState } from "react";
|
|
4
|
+
//#region src/hooks/useThrottledValue/useThrottledValue.ts
|
|
5
|
+
/**
|
|
6
|
+
* @description
|
|
7
|
+
* `useThrottledValue` is a React hook that returns a throttled copy of the given value.
|
|
8
|
+
* The caller keeps owning the state; the returned value follows it at most once per `wait` milliseconds,
|
|
9
|
+
* which is useful for driving expensive renders from scroll position, pointer position, or an element's
|
|
10
|
+
* size on resize.
|
|
11
|
+
*
|
|
12
|
+
* On the first render and on the server the value is returned as is. A change is never scheduled
|
|
13
|
+
* on mount, so the first change after mount is applied immediately when `leading` is `true`.
|
|
14
|
+
* If both `leading` and `trailing` are `false`, the returned value never updates.
|
|
15
|
+
*
|
|
16
|
+
* The value is compared by reference. Passing a new object or array on every render keeps
|
|
17
|
+
* the returned value updating every `wait` milliseconds; stabilize the reference first, for
|
|
18
|
+
* example with `usePreservedReference`.
|
|
19
|
+
*
|
|
20
|
+
* @template T - The type of the value.
|
|
21
|
+
* @param {T} value - The value to throttle.
|
|
22
|
+
* @param {number} wait - The length of the throttle window in milliseconds.
|
|
23
|
+
* @param {ThrottleOptions} [options] - Configuration options for throttle behavior.
|
|
24
|
+
* @param {boolean} [options.leading=true] - If `true`, the first change in a window is applied immediately.
|
|
25
|
+
* @param {boolean} [options.trailing=true] - If `true`, the last change in a window is applied `wait` milliseconds after that change.
|
|
26
|
+
*
|
|
27
|
+
* @returns {T} The throttled value.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* import { useThrottledValue } from 'react-simplikit';
|
|
31
|
+
* import { useState } from 'react';
|
|
32
|
+
*
|
|
33
|
+
* function ScrollProgress() {
|
|
34
|
+
* const [scrollY, setScrollY] = useState(0);
|
|
35
|
+
* const throttledScrollY = useThrottledValue(scrollY, 100);
|
|
36
|
+
*
|
|
37
|
+
* return (
|
|
38
|
+
* <div onScroll={e => setScrollY(e.currentTarget.scrollTop)}>
|
|
39
|
+
* <ProgressBar position={throttledScrollY} />
|
|
40
|
+
* </div>
|
|
41
|
+
* );
|
|
42
|
+
* }
|
|
43
|
+
*/
|
|
44
|
+
function useThrottledValue(value, wait, { leading = true, trailing = true } = {}) {
|
|
45
|
+
const [throttledValue, setThrottledValue] = useState(() => value);
|
|
46
|
+
const throttled = useThrottle((next) => setThrottledValue(() => next), wait, { edges: toEdges(leading, trailing) });
|
|
47
|
+
const lastForwardedRef = useRef(value);
|
|
48
|
+
useEffect(function forwardChangedValue() {
|
|
49
|
+
if (Object.is(lastForwardedRef.current, value) && Object.is(value, throttledValue)) return;
|
|
50
|
+
lastForwardedRef.current = value;
|
|
51
|
+
throttled(value);
|
|
52
|
+
}, [
|
|
53
|
+
value,
|
|
54
|
+
throttledValue,
|
|
55
|
+
throttled
|
|
56
|
+
]);
|
|
57
|
+
return throttledValue;
|
|
58
|
+
}
|
|
59
|
+
function toEdges(leading, trailing) {
|
|
60
|
+
const edges = [];
|
|
61
|
+
if (leading) edges.push("leading");
|
|
62
|
+
if (trailing) edges.push("trailing");
|
|
63
|
+
return edges;
|
|
64
|
+
}
|
|
65
|
+
//#endregion
|
|
66
|
+
export { useThrottledValue };
|
|
@@ -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/useVisualViewport/useVisualViewport.ts
|
|
5
5
|
/**
|
|
6
6
|
* @description
|
|
7
7
|
* `useVisualViewport` is a React hook that tracks Visual Viewport changes.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { isServer } from "../../utils/isServer/isServer.mjs";
|
|
3
3
|
import { startTransition, useCallback, useEffect, useState } from "react";
|
|
4
|
-
//#region src/
|
|
4
|
+
//#region src/hooks/useVisualViewport/useVisualViewport.ts
|
|
5
5
|
/**
|
|
6
6
|
* @description
|
|
7
7
|
* `useVisualViewport` is a React hook that tracks Visual Viewport changes.
|
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const require_usePreservedCallback = require("./hooks/usePreservedCallback/usePreservedCallback.cjs");
|
|
4
|
+
const require_useDebounce = require("./hooks/useDebounce/useDebounce.cjs");
|
|
4
5
|
const require_useDebouncedCallback = require("./hooks/useDebouncedCallback/useDebouncedCallback.cjs");
|
|
6
|
+
const require_usePreservedReference = require("./hooks/usePreservedReference/usePreservedReference.cjs");
|
|
5
7
|
const require_useRefEffect = require("./hooks/useRefEffect/useRefEffect.cjs");
|
|
6
8
|
const require_useIntersectionObserver = require("./hooks/useIntersectionObserver/useIntersectionObserver.cjs");
|
|
7
9
|
const require_useVisibilityEvent = require("./hooks/useVisibilityEvent/useVisibilityEvent.cjs");
|
|
@@ -11,49 +13,49 @@ const require_ImpressionArea = require("./components/ImpressionArea/ImpressionAr
|
|
|
11
13
|
const require_Separated = require("./components/Separated/Separated.cjs");
|
|
12
14
|
const require_SwitchCase = require("./components/SwitchCase/SwitchCase.cjs");
|
|
13
15
|
const require_useAsyncEffect = require("./hooks/useAsyncEffect/useAsyncEffect.cjs");
|
|
16
|
+
const require_isServer = require("./utils/isServer/isServer.cjs");
|
|
17
|
+
const require_getKeyboardHeight = require("./utils/getKeyboardHeight/getKeyboardHeight.cjs");
|
|
18
|
+
const require_subscribeKeyboardHeight = require("./utils/subscribeKeyboardHeight/subscribeKeyboardHeight.cjs");
|
|
19
|
+
const require_useKeyboardHeight = require("./hooks/useKeyboardHeight/useKeyboardHeight.cjs");
|
|
20
|
+
const require_useAvoidKeyboard = require("./hooks/useAvoidKeyboard/useAvoidKeyboard.cjs");
|
|
21
|
+
const require_disableBodyScrollLock = require("./utils/disableBodyScrollLock/disableBodyScrollLock.cjs");
|
|
22
|
+
const require_enableBodyScrollLock = require("./utils/enableBodyScrollLock/enableBodyScrollLock.cjs");
|
|
23
|
+
const require_useBodyScrollLock = require("./hooks/useBodyScrollLock/useBodyScrollLock.cjs");
|
|
14
24
|
const require_useBooleanState = require("./hooks/useBooleanState/useBooleanState.cjs");
|
|
15
25
|
const require_useCallbackOncePerRender = require("./hooks/useCallbackOncePerRender/useCallbackOncePerRender.cjs");
|
|
16
26
|
const require_useConditionalEffect = require("./hooks/useConditionalEffect/useConditionalEffect.cjs");
|
|
17
27
|
const require_useControlledState = require("./hooks/useControlledState/useControlledState.cjs");
|
|
18
28
|
const require_useCounter = require("./hooks/useCounter/useCounter.cjs");
|
|
19
|
-
const
|
|
29
|
+
const require_useDebouncedValue = require("./hooks/useDebouncedValue/useDebouncedValue.cjs");
|
|
20
30
|
const require_useDoubleClick = require("./hooks/useDoubleClick/useDoubleClick.cjs");
|
|
21
31
|
const require_useGeolocation = require("./hooks/useGeolocation/useGeolocation.cjs");
|
|
22
32
|
const require_useInputState = require("./hooks/useInputState/useInputState.cjs");
|
|
23
33
|
const require_useInterval = require("./hooks/useInterval/useInterval.cjs");
|
|
24
34
|
const require_useIsClient = require("./hooks/useIsClient/useIsClient.cjs");
|
|
25
35
|
const require_useIsomorphicLayoutEffect = require("./hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.cjs");
|
|
26
|
-
const require_usePreservedReference = require("./hooks/usePreservedReference/usePreservedReference.cjs");
|
|
27
36
|
const require_useList = require("./hooks/useList/useList.cjs");
|
|
28
37
|
const require_useLoading = require("./hooks/useLoading/useLoading.cjs");
|
|
29
38
|
const require_useLongPress = require("./hooks/useLongPress/useLongPress.cjs");
|
|
30
39
|
const require_useMap = require("./hooks/useMap/useMap.cjs");
|
|
40
|
+
const require_useNetworkStatus = require("./hooks/useNetworkStatus/useNetworkStatus.cjs");
|
|
31
41
|
const require_useOutsideClickEffect = require("./hooks/useOutsideClickEffect/useOutsideClickEffect.cjs");
|
|
42
|
+
const require_usePageVisibility = require("./hooks/usePageVisibility/usePageVisibility.cjs");
|
|
32
43
|
const require_usePrevious = require("./hooks/usePrevious/usePrevious.cjs");
|
|
44
|
+
const require_getSafeAreaInset = require("./utils/getSafeAreaInset/getSafeAreaInset.cjs");
|
|
45
|
+
const require_useSafeAreaInset = require("./hooks/useSafeAreaInset/useSafeAreaInset.cjs");
|
|
46
|
+
const require_useScrollDirection = require("./hooks/useScrollDirection/useScrollDirection.cjs");
|
|
33
47
|
const require_useSet = require("./hooks/useSet/useSet.cjs");
|
|
34
48
|
const require_useStorageState = require("./hooks/useStorageState/useStorageState.cjs");
|
|
35
49
|
const require_useThrottle = require("./hooks/useThrottle/useThrottle.cjs");
|
|
36
50
|
const require_useThrottledCallback = require("./hooks/useThrottledCallback/useThrottledCallback.cjs");
|
|
51
|
+
const require_useThrottledValue = require("./hooks/useThrottledValue/useThrottledValue.cjs");
|
|
37
52
|
const require_useTimeout = require("./hooks/useTimeout/useTimeout.cjs");
|
|
38
53
|
const require_useToggle = require("./hooks/useToggle/useToggle.cjs");
|
|
39
|
-
const
|
|
40
|
-
const require_getKeyboardHeight = require("./mobile/utils/getKeyboardHeight/getKeyboardHeight.cjs");
|
|
41
|
-
const require_subscribeKeyboardHeight = require("./mobile/utils/subscribeKeyboardHeight/subscribeKeyboardHeight.cjs");
|
|
42
|
-
const require_useKeyboardHeight = require("./mobile/hooks/useKeyboardHeight/useKeyboardHeight.cjs");
|
|
43
|
-
const require_useAvoidKeyboard = require("./mobile/hooks/useAvoidKeyboard/useAvoidKeyboard.cjs");
|
|
44
|
-
const require_disableBodyScrollLock = require("./mobile/utils/disableBodyScrollLock/disableBodyScrollLock.cjs");
|
|
45
|
-
const require_enableBodyScrollLock = require("./mobile/utils/enableBodyScrollLock/enableBodyScrollLock.cjs");
|
|
46
|
-
const require_useBodyScrollLock = require("./mobile/hooks/useBodyScrollLock/useBodyScrollLock.cjs");
|
|
47
|
-
const require_useNetworkStatus = require("./mobile/hooks/useNetworkStatus/useNetworkStatus.cjs");
|
|
48
|
-
const require_usePageVisibility = require("./mobile/hooks/usePageVisibility/usePageVisibility.cjs");
|
|
49
|
-
const require_getSafeAreaInset = require("./mobile/utils/getSafeAreaInset/getSafeAreaInset.cjs");
|
|
50
|
-
const require_useSafeAreaInset = require("./mobile/hooks/useSafeAreaInset/useSafeAreaInset.cjs");
|
|
51
|
-
const require_useScrollDirection = require("./mobile/hooks/useScrollDirection/useScrollDirection.cjs");
|
|
52
|
-
const require_useVisualViewport = require("./mobile/hooks/useVisualViewport/useVisualViewport.cjs");
|
|
53
|
-
const require_isAndroid = require("./mobile/utils/isAndroid/isAndroid.cjs");
|
|
54
|
-
const require_isIOS = require("./mobile/utils/isIOS/isIOS.cjs");
|
|
55
|
-
const require_isKeyboardVisible = require("./mobile/utils/isKeyboardVisible/isKeyboardVisible.cjs");
|
|
54
|
+
const require_useVisualViewport = require("./hooks/useVisualViewport/useVisualViewport.cjs");
|
|
56
55
|
const require_buildContext = require("./utils/buildContext/buildContext.cjs");
|
|
56
|
+
const require_isAndroid = require("./utils/isAndroid/isAndroid.cjs");
|
|
57
|
+
const require_isIOS = require("./utils/isIOS/isIOS.cjs");
|
|
58
|
+
const require_isKeyboardVisible = require("./utils/isKeyboardVisible/isKeyboardVisible.cjs");
|
|
57
59
|
const require_mergeProps = require("./utils/mergeProps/mergeProps.cjs");
|
|
58
60
|
exports.ImpressionArea = require_ImpressionArea.ImpressionArea;
|
|
59
61
|
exports.Separated = require_Separated.Separated;
|
|
@@ -80,6 +82,7 @@ exports.useControlledState = require_useControlledState.useControlledState;
|
|
|
80
82
|
exports.useCounter = require_useCounter.useCounter;
|
|
81
83
|
exports.useDebounce = require_useDebounce.useDebounce;
|
|
82
84
|
exports.useDebouncedCallback = require_useDebouncedCallback.useDebouncedCallback;
|
|
85
|
+
exports.useDebouncedValue = require_useDebouncedValue.useDebouncedValue;
|
|
83
86
|
exports.useDoubleClick = require_useDoubleClick.useDoubleClick;
|
|
84
87
|
exports.useGeolocation = require_useGeolocation.useGeolocation;
|
|
85
88
|
exports.useImpressionRef = require_useImpressionRef.useImpressionRef;
|
|
@@ -106,6 +109,7 @@ exports.useSet = require_useSet.useSet;
|
|
|
106
109
|
exports.useStorageState = require_useStorageState.useStorageState;
|
|
107
110
|
exports.useThrottle = require_useThrottle.useThrottle;
|
|
108
111
|
exports.useThrottledCallback = require_useThrottledCallback.useThrottledCallback;
|
|
112
|
+
exports.useThrottledValue = require_useThrottledValue.useThrottledValue;
|
|
109
113
|
exports.useTimeout = require_useTimeout.useTimeout;
|
|
110
114
|
exports.useToggle = require_useToggle.useToggle;
|
|
111
115
|
exports.useVisibilityEvent = require_useVisibilityEvent.useVisibilityEvent;
|
package/dist/index.d.cts
CHANGED
|
@@ -8,6 +8,9 @@ import { SwitchCase } from "./components/SwitchCase/SwitchCase.cjs";
|
|
|
8
8
|
import "./components/SwitchCase/index.cjs";
|
|
9
9
|
import { useAsyncEffect } from "./hooks/useAsyncEffect/useAsyncEffect.cjs";
|
|
10
10
|
import "./hooks/useAsyncEffect/index.cjs";
|
|
11
|
+
import { useAvoidKeyboard } from "./hooks/useAvoidKeyboard/useAvoidKeyboard.cjs";
|
|
12
|
+
import "./hooks/useAvoidKeyboard/index.cjs";
|
|
13
|
+
import { useBodyScrollLock } from "./hooks/useBodyScrollLock/useBodyScrollLock.cjs";
|
|
11
14
|
import { useBooleanState } from "./hooks/useBooleanState/useBooleanState.cjs";
|
|
12
15
|
import { useCallbackOncePerRender } from "./hooks/useCallbackOncePerRender/useCallbackOncePerRender.cjs";
|
|
13
16
|
import "./hooks/useCallbackOncePerRender/index.cjs";
|
|
@@ -18,6 +21,7 @@ import "./hooks/useControlledState/index.cjs";
|
|
|
18
21
|
import { useCounter } from "./hooks/useCounter/useCounter.cjs";
|
|
19
22
|
import { useDebounce } from "./hooks/useDebounce/useDebounce.cjs";
|
|
20
23
|
import { useDebouncedCallback } from "./hooks/useDebouncedCallback/useDebouncedCallback.cjs";
|
|
24
|
+
import { useDebouncedValue } from "./hooks/useDebouncedValue/useDebouncedValue.cjs";
|
|
21
25
|
import { useDoubleClick } from "./hooks/useDoubleClick/useDoubleClick.cjs";
|
|
22
26
|
import "./hooks/useDoubleClick/index.cjs";
|
|
23
27
|
import { useGeolocation } from "./hooks/useGeolocation/useGeolocation.cjs";
|
|
@@ -28,47 +32,45 @@ import { useInterval } from "./hooks/useInterval/useInterval.cjs";
|
|
|
28
32
|
import { useIsClient } from "./hooks/useIsClient/useIsClient.cjs";
|
|
29
33
|
import { useIsomorphicLayoutEffect } from "./hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.cjs";
|
|
30
34
|
import "./hooks/useIsomorphicLayoutEffect/index.cjs";
|
|
35
|
+
import { useKeyboardHeight } from "./hooks/useKeyboardHeight/useKeyboardHeight.cjs";
|
|
31
36
|
import { useList } from "./hooks/useList/useList.cjs";
|
|
32
37
|
import { useLoading } from "./hooks/useLoading/useLoading.cjs";
|
|
33
38
|
import { useLongPress } from "./hooks/useLongPress/useLongPress.cjs";
|
|
34
39
|
import "./hooks/useLongPress/index.cjs";
|
|
35
40
|
import { useMap } from "./hooks/useMap/useMap.cjs";
|
|
41
|
+
import { ConnectionType, EffectiveConnectionType, NetworkStatus, useNetworkStatus } from "./hooks/useNetworkStatus/useNetworkStatus.cjs";
|
|
36
42
|
import { useOutsideClickEffect } from "./hooks/useOutsideClickEffect/useOutsideClickEffect.cjs";
|
|
43
|
+
import { PageVisibility, VisibilityState, usePageVisibility } from "./hooks/usePageVisibility/usePageVisibility.cjs";
|
|
37
44
|
import { usePreservedCallback } from "./hooks/usePreservedCallback/usePreservedCallback.cjs";
|
|
38
45
|
import { usePreservedReference } from "./hooks/usePreservedReference/usePreservedReference.cjs";
|
|
39
46
|
import { usePrevious } from "./hooks/usePrevious/usePrevious.cjs";
|
|
40
47
|
import { useRefEffect } from "./hooks/useRefEffect/useRefEffect.cjs";
|
|
41
48
|
import "./hooks/useRefEffect/index.cjs";
|
|
49
|
+
import { SafeAreaInset, getSafeAreaInset } from "./utils/getSafeAreaInset/getSafeAreaInset.cjs";
|
|
50
|
+
import { useSafeAreaInset } from "./hooks/useSafeAreaInset/useSafeAreaInset.cjs";
|
|
51
|
+
import { useScrollDirection } from "./hooks/useScrollDirection/useScrollDirection.cjs";
|
|
42
52
|
import { useSet } from "./hooks/useSet/useSet.cjs";
|
|
43
53
|
import { useStorageState } from "./hooks/useStorageState/useStorageState.cjs";
|
|
44
54
|
import "./hooks/useStorageState/index.cjs";
|
|
45
55
|
import { useThrottle } from "./hooks/useThrottle/useThrottle.cjs";
|
|
46
56
|
import { useThrottledCallback } from "./hooks/useThrottledCallback/useThrottledCallback.cjs";
|
|
57
|
+
import { useThrottledValue } from "./hooks/useThrottledValue/useThrottledValue.cjs";
|
|
47
58
|
import { useTimeout } from "./hooks/useTimeout/useTimeout.cjs";
|
|
48
59
|
import { useToggle } from "./hooks/useToggle/useToggle.cjs";
|
|
49
60
|
import { useVisibilityEvent } from "./hooks/useVisibilityEvent/useVisibilityEvent.cjs";
|
|
50
|
-
import {
|
|
51
|
-
import "./mobile/hooks/useAvoidKeyboard/index.cjs";
|
|
52
|
-
import { useBodyScrollLock } from "./mobile/hooks/useBodyScrollLock/useBodyScrollLock.cjs";
|
|
53
|
-
import { useKeyboardHeight } from "./mobile/hooks/useKeyboardHeight/useKeyboardHeight.cjs";
|
|
54
|
-
import { ConnectionType, EffectiveConnectionType, NetworkStatus, useNetworkStatus } from "./mobile/hooks/useNetworkStatus/useNetworkStatus.cjs";
|
|
55
|
-
import { PageVisibility, VisibilityState, usePageVisibility } from "./mobile/hooks/usePageVisibility/usePageVisibility.cjs";
|
|
56
|
-
import { SafeAreaInset, getSafeAreaInset } from "./mobile/utils/getSafeAreaInset/getSafeAreaInset.cjs";
|
|
57
|
-
import { useSafeAreaInset } from "./mobile/hooks/useSafeAreaInset/useSafeAreaInset.cjs";
|
|
58
|
-
import { useScrollDirection } from "./mobile/hooks/useScrollDirection/useScrollDirection.cjs";
|
|
59
|
-
import { useVisualViewport } from "./mobile/hooks/useVisualViewport/useVisualViewport.cjs";
|
|
60
|
-
import { disableBodyScrollLock } from "./mobile/utils/disableBodyScrollLock/disableBodyScrollLock.cjs";
|
|
61
|
-
import { enableBodyScrollLock } from "./mobile/utils/enableBodyScrollLock/enableBodyScrollLock.cjs";
|
|
62
|
-
import { getKeyboardHeight } from "./mobile/utils/getKeyboardHeight/getKeyboardHeight.cjs";
|
|
63
|
-
import { isAndroid } from "./mobile/utils/isAndroid/isAndroid.cjs";
|
|
64
|
-
import { isIOS } from "./mobile/utils/isIOS/isIOS.cjs";
|
|
65
|
-
import { isKeyboardVisible } from "./mobile/utils/isKeyboardVisible/isKeyboardVisible.cjs";
|
|
66
|
-
import { isServer } from "./mobile/utils/isServer/isServer.cjs";
|
|
67
|
-
import { subscribeKeyboardHeight } from "./mobile/utils/subscribeKeyboardHeight/subscribeKeyboardHeight.cjs";
|
|
61
|
+
import { useVisualViewport } from "./hooks/useVisualViewport/useVisualViewport.cjs";
|
|
68
62
|
import { buildContext } from "./utils/buildContext/buildContext.cjs";
|
|
69
63
|
import "./utils/buildContext/index.cjs";
|
|
64
|
+
import { disableBodyScrollLock } from "./utils/disableBodyScrollLock/disableBodyScrollLock.cjs";
|
|
65
|
+
import { enableBodyScrollLock } from "./utils/enableBodyScrollLock/enableBodyScrollLock.cjs";
|
|
66
|
+
import { getKeyboardHeight } from "./utils/getKeyboardHeight/getKeyboardHeight.cjs";
|
|
67
|
+
import { isAndroid } from "./utils/isAndroid/isAndroid.cjs";
|
|
68
|
+
import { isIOS } from "./utils/isIOS/isIOS.cjs";
|
|
69
|
+
import { isKeyboardVisible } from "./utils/isKeyboardVisible/isKeyboardVisible.cjs";
|
|
70
|
+
import { isServer } from "./utils/isServer/isServer.cjs";
|
|
70
71
|
import { mergeProps } from "./utils/mergeProps/mergeProps.cjs";
|
|
71
72
|
import "./utils/mergeProps/index.cjs";
|
|
72
73
|
import { mergeRefs } from "./utils/mergeRefs/mergeRefs.cjs";
|
|
73
74
|
import "./utils/mergeRefs/index.cjs";
|
|
74
|
-
|
|
75
|
+
import { subscribeKeyboardHeight } from "./utils/subscribeKeyboardHeight/subscribeKeyboardHeight.cjs";
|
|
76
|
+
export { type ConnectionType, type EffectiveConnectionType, ImpressionArea, type NetworkStatus, type PageVisibility, type SafeAreaInset, Separated, SwitchCase, type VisibilityState, buildContext, disableBodyScrollLock, enableBodyScrollLock, getKeyboardHeight, getSafeAreaInset, isAndroid, isIOS, isKeyboardVisible, isServer, mergeProps, mergeRefs, subscribeKeyboardHeight, useAsyncEffect, useAvoidKeyboard, useBodyScrollLock, useBooleanState, useCallbackOncePerRender, useConditionalEffect, useControlledState, useCounter, useDebounce, useDebouncedCallback, useDebouncedValue, useDoubleClick, useGeolocation, useImpressionRef, useInputState, useIntersectionObserver, useInterval, useIsClient, useIsomorphicLayoutEffect, useKeyboardHeight, useList, useLoading, useLongPress, useMap, useNetworkStatus, useOutsideClickEffect, usePageVisibility, usePreservedCallback, usePreservedReference, usePrevious, useRefEffect, useSafeAreaInset, useScrollDirection, useSet, useStorageState, useThrottle, useThrottledCallback, useThrottledValue, useTimeout, useToggle, useVisibilityEvent, useVisualViewport };
|