react-simplikit 0.0.50 → 0.0.52
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/dist/components/ImpressionArea/ImpressionArea.cjs +57 -0
- package/{esm/components/ImpressionArea/index.d.ts → dist/components/ImpressionArea/ImpressionArea.d.cts} +9 -8
- package/dist/components/ImpressionArea/ImpressionArea.d.mts +48 -0
- package/dist/components/ImpressionArea/ImpressionArea.mjs +57 -0
- package/dist/components/ImpressionArea/index.d.cts +2 -46
- package/dist/components/ImpressionArea/index.d.mts +3 -0
- package/dist/components/Separated/Separated.cjs +38 -0
- package/{esm/components/Separated/index.d.ts → dist/components/Separated/Separated.d.cts} +7 -7
- package/dist/components/Separated/Separated.d.mts +38 -0
- package/dist/components/Separated/Separated.mjs +38 -0
- package/dist/components/Separated/index.d.cts +2 -37
- package/dist/components/Separated/index.d.mts +3 -0
- package/dist/components/SwitchCase/SwitchCase.cjs +40 -0
- package/{esm/components/SwitchCase/index.d.ts → dist/components/SwitchCase/SwitchCase.d.cts} +7 -8
- package/dist/components/SwitchCase/SwitchCase.d.mts +45 -0
- package/dist/components/SwitchCase/SwitchCase.mjs +40 -0
- package/dist/components/SwitchCase/index.d.cts +2 -45
- package/dist/components/SwitchCase/index.d.mts +3 -0
- package/dist/hooks/useAsyncEffect/index.d.cts +2 -24
- package/dist/hooks/useAsyncEffect/index.d.mts +3 -0
- package/dist/hooks/useAsyncEffect/useAsyncEffect.cjs +39 -0
- package/{esm/hooks/useAsyncEffect/index.d.ts → dist/hooks/useAsyncEffect/useAsyncEffect.d.cts} +4 -3
- package/dist/hooks/useAsyncEffect/useAsyncEffect.d.mts +26 -0
- package/dist/hooks/useAsyncEffect/useAsyncEffect.mjs +39 -0
- package/dist/hooks/useBooleanState/useBooleanState.cjs +36 -0
- package/dist/hooks/useBooleanState/{index.d.cts → useBooleanState.d.cts} +4 -2
- package/{esm/hooks/useBooleanState/index.d.ts → dist/hooks/useBooleanState/useBooleanState.d.mts} +4 -2
- package/dist/hooks/useBooleanState/useBooleanState.mjs +36 -0
- package/dist/hooks/useCallbackOncePerRender/index.d.cts +2 -39
- package/dist/hooks/useCallbackOncePerRender/index.d.mts +3 -0
- package/dist/hooks/useCallbackOncePerRender/useCallbackOncePerRender.cjs +52 -0
- package/{esm/hooks/useCallbackOncePerRender/index.d.ts → dist/hooks/useCallbackOncePerRender/useCallbackOncePerRender.d.cts} +4 -3
- package/dist/hooks/useCallbackOncePerRender/useCallbackOncePerRender.d.mts +41 -0
- package/dist/hooks/useCallbackOncePerRender/useCallbackOncePerRender.mjs +52 -0
- package/dist/hooks/useConditionalEffect/index.d.cts +2 -42
- package/dist/hooks/useConditionalEffect/index.d.mts +3 -0
- package/dist/hooks/useConditionalEffect/useConditionalEffect.cjs +57 -0
- package/{esm/hooks/useConditionalEffect/index.d.ts → dist/hooks/useConditionalEffect/useConditionalEffect.d.cts} +4 -3
- package/dist/hooks/useConditionalEffect/useConditionalEffect.d.mts +44 -0
- package/dist/hooks/useConditionalEffect/useConditionalEffect.mjs +57 -0
- package/dist/hooks/useControlledState/index.d.cts +2 -50
- package/dist/hooks/useControlledState/index.d.mts +3 -0
- package/dist/hooks/useControlledState/useControlledState.cjs +60 -0
- package/{esm/hooks/useControlledState/index.d.ts → dist/hooks/useControlledState/useControlledState.d.cts} +11 -10
- package/dist/hooks/useControlledState/useControlledState.d.mts +52 -0
- package/dist/hooks/useControlledState/useControlledState.mjs +60 -0
- package/dist/hooks/useCounter/useCounter.cjs +75 -0
- package/{esm/hooks/useCounter/index.d.ts → dist/hooks/useCounter/useCounter.d.cts} +12 -10
- package/dist/hooks/useCounter/{index.d.cts → useCounter.d.mts} +12 -10
- package/dist/hooks/useCounter/useCounter.mjs +75 -0
- package/dist/hooks/useDebounce/debounce.cjs +49 -0
- package/dist/hooks/useDebounce/debounce.d.cts +8 -0
- package/dist/hooks/useDebounce/debounce.d.mts +8 -0
- package/dist/hooks/useDebounce/debounce.mjs +49 -0
- package/dist/hooks/useDebounce/useDebounce.cjs +66 -0
- package/{esm/hooks/useDebounce/index.d.ts → dist/hooks/useDebounce/useDebounce.d.cts} +6 -8
- package/dist/hooks/useDebounce/{index.d.cts → useDebounce.d.mts} +6 -8
- package/dist/hooks/useDebounce/useDebounce.mjs +66 -0
- package/dist/hooks/useDebouncedCallback/useDebouncedCallback.cjs +62 -0
- package/{esm/hooks/useDebouncedCallback/index.d.ts → dist/hooks/useDebouncedCallback/useDebouncedCallback.d.cts} +9 -7
- package/dist/hooks/useDebouncedCallback/{index.d.cts → useDebouncedCallback.d.mts} +9 -7
- package/dist/hooks/useDebouncedCallback/useDebouncedCallback.mjs +62 -0
- package/dist/hooks/useDoubleClick/index.d.cts +2 -45
- package/dist/hooks/useDoubleClick/index.d.mts +3 -0
- package/dist/hooks/useDoubleClick/useDoubleClick.cjs +64 -0
- package/{esm/hooks/useDoubleClick/index.d.ts → dist/hooks/useDoubleClick/useDoubleClick.d.cts} +8 -7
- package/dist/hooks/useDoubleClick/useDoubleClick.d.mts +47 -0
- package/dist/hooks/useDoubleClick/useDoubleClick.mjs +64 -0
- package/dist/hooks/useGeolocation/useGeolocation.cjs +210 -0
- package/{esm/hooks/useGeolocation/index.d.ts → dist/hooks/useGeolocation/useGeolocation.d.cts} +26 -24
- package/dist/hooks/useGeolocation/{index.d.cts → useGeolocation.d.mts} +26 -24
- package/dist/hooks/useGeolocation/useGeolocation.mjs +209 -0
- package/dist/hooks/useImpressionRef/useImpressionRef.cjs +67 -0
- package/{esm/hooks/useImpressionRef/index.d.ts → dist/hooks/useImpressionRef/useImpressionRef.d.cts} +10 -8
- package/dist/hooks/useImpressionRef/{index.d.cts → useImpressionRef.d.mts} +10 -8
- package/dist/hooks/useImpressionRef/useImpressionRef.mjs +67 -0
- package/dist/hooks/useInputState/index.d.cts +2 -22
- package/dist/hooks/useInputState/index.d.mts +3 -0
- package/dist/hooks/useInputState/useInputState.cjs +32 -0
- package/{esm/hooks/useInputState/index.d.ts → dist/hooks/useInputState/useInputState.d.cts} +4 -3
- package/dist/hooks/useInputState/useInputState.d.mts +24 -0
- package/dist/hooks/useInputState/useInputState.mjs +32 -0
- package/dist/hooks/useIntersectionObserver/useIntersectionObserver.cjs +58 -0
- package/dist/hooks/useIntersectionObserver/{index.d.cts → useIntersectionObserver.d.cts} +4 -2
- package/{esm/hooks/useIntersectionObserver/index.d.ts → dist/hooks/useIntersectionObserver/useIntersectionObserver.d.mts} +4 -2
- package/dist/hooks/useIntersectionObserver/useIntersectionObserver.mjs +58 -0
- package/dist/hooks/useInterval/useInterval.cjs +65 -0
- package/dist/hooks/useInterval/{index.d.cts → useInterval.d.cts} +7 -5
- package/{esm/hooks/useInterval/index.d.ts → dist/hooks/useInterval/useInterval.d.mts} +7 -5
- package/dist/hooks/useInterval/useInterval.mjs +65 -0
- package/dist/hooks/useIsClient/useIsClient.cjs +49 -0
- package/dist/hooks/useIsClient/{index.d.cts → useIsClient.d.cts} +4 -2
- package/{esm/hooks/useIsClient/index.d.ts → dist/hooks/useIsClient/useIsClient.d.mts} +4 -2
- package/dist/hooks/useIsClient/useIsClient.mjs +49 -0
- package/dist/hooks/useIsomorphicLayoutEffect/index.d.cts +2 -24
- package/dist/hooks/useIsomorphicLayoutEffect/index.d.mts +3 -0
- package/dist/hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.cjs +25 -0
- package/{esm/hooks/useIsomorphicLayoutEffect/index.d.ts → dist/hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.d.cts} +4 -3
- package/dist/hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.d.mts +26 -0
- package/dist/hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.mjs +25 -0
- package/dist/hooks/useList/useList.cjs +94 -0
- package/{esm/hooks/useList/index.d.ts → dist/hooks/useList/useList.d.cts} +10 -8
- package/dist/hooks/useList/{index.d.cts → useList.d.mts} +10 -8
- package/dist/hooks/useList/useList.mjs +94 -0
- package/dist/hooks/useLoading/useLoading.cjs +61 -0
- package/dist/hooks/useLoading/{index.d.cts → useLoading.d.cts} +4 -2
- package/{esm/hooks/useLoading/index.d.ts → dist/hooks/useLoading/useLoading.d.mts} +4 -2
- package/dist/hooks/useLoading/useLoading.mjs +61 -0
- package/dist/hooks/useLongPress/index.d.cts +2 -73
- package/dist/hooks/useLongPress/index.d.mts +3 -0
- package/dist/hooks/useLongPress/useLongPress.cjs +133 -0
- package/{esm/hooks/useLongPress/index.d.ts → dist/hooks/useLongPress/useLongPress.d.cts} +18 -17
- package/dist/hooks/useLongPress/useLongPress.d.mts +75 -0
- package/dist/hooks/useLongPress/useLongPress.mjs +133 -0
- package/dist/hooks/useMap/useMap.cjs +64 -0
- package/dist/hooks/useMap/{index.d.cts → useMap.d.cts} +12 -10
- package/{esm/hooks/useMap/index.d.ts → dist/hooks/useMap/useMap.d.mts} +12 -10
- package/dist/hooks/useMap/useMap.mjs +64 -0
- package/dist/hooks/useOutsideClickEffect/useOutsideClickEffect.cjs +51 -0
- package/{esm/hooks/useOutsideClickEffect/index.d.ts → dist/hooks/useOutsideClickEffect/useOutsideClickEffect.d.cts} +4 -2
- package/dist/hooks/useOutsideClickEffect/{index.d.cts → useOutsideClickEffect.d.mts} +4 -2
- package/dist/hooks/useOutsideClickEffect/useOutsideClickEffect.mjs +51 -0
- package/dist/hooks/usePreservedCallback/usePreservedCallback.cjs +41 -0
- package/dist/hooks/usePreservedCallback/{index.d.cts → usePreservedCallback.d.cts} +4 -2
- package/{esm/hooks/usePreservedCallback/index.d.ts → dist/hooks/usePreservedCallback/usePreservedCallback.d.mts} +4 -2
- package/dist/hooks/usePreservedCallback/usePreservedCallback.mjs +41 -0
- package/dist/hooks/usePreservedReference/usePreservedReference.cjs +55 -0
- package/dist/hooks/usePreservedReference/{index.d.cts → usePreservedReference.d.cts} +4 -2
- package/{esm/hooks/usePreservedReference/index.d.ts → dist/hooks/usePreservedReference/usePreservedReference.d.mts} +4 -2
- package/dist/hooks/usePreservedReference/usePreservedReference.mjs +55 -0
- package/dist/hooks/usePrevious/usePrevious.cjs +38 -0
- package/{esm/hooks/usePrevious/index.d.ts → dist/hooks/usePrevious/usePrevious.d.cts} +4 -2
- package/dist/hooks/usePrevious/{index.d.cts → usePrevious.d.mts} +4 -2
- package/dist/hooks/usePrevious/usePrevious.mjs +38 -0
- package/dist/hooks/useRefEffect/index.d.cts +2 -30
- package/dist/hooks/useRefEffect/index.d.mts +3 -0
- package/dist/hooks/useRefEffect/useRefEffect.cjs +42 -0
- package/{esm/hooks/useRefEffect/index.d.ts → dist/hooks/useRefEffect/useRefEffect.d.cts} +4 -3
- package/dist/hooks/useRefEffect/useRefEffect.d.mts +32 -0
- package/dist/hooks/useRefEffect/useRefEffect.mjs +42 -0
- package/dist/hooks/useSet/useSet.cjs +79 -0
- package/dist/hooks/useSet/{index.d.cts → useSet.d.cts} +9 -7
- package/{esm/hooks/useSet/index.d.ts → dist/hooks/useSet/useSet.d.mts} +9 -7
- package/dist/hooks/useSet/useSet.mjs +79 -0
- package/dist/hooks/useStorageState/index.d.cts +2 -60
- package/dist/hooks/useStorageState/index.d.mts +3 -0
- package/dist/hooks/useStorageState/storage.cjs +85 -0
- package/dist/hooks/useStorageState/storage.d.cts +10 -0
- package/dist/hooks/useStorageState/storage.d.mts +10 -0
- package/dist/hooks/useStorageState/storage.mjs +80 -0
- package/dist/hooks/useStorageState/useStorageState.cjs +81 -0
- package/{esm/hooks/useStorageState/index.d.ts → dist/hooks/useStorageState/useStorageState.d.cts} +10 -15
- package/dist/hooks/useStorageState/useStorageState.d.mts +56 -0
- package/dist/hooks/useStorageState/useStorageState.mjs +81 -0
- package/dist/hooks/useThrottle/throttle.cjs +19 -0
- package/dist/hooks/useThrottle/throttle.d.cts +19 -0
- package/dist/hooks/useThrottle/throttle.d.mts +19 -0
- package/dist/hooks/useThrottle/throttle.mjs +19 -0
- package/dist/hooks/useThrottle/useThrottle.cjs +49 -0
- package/dist/hooks/useThrottle/{index.d.cts → useThrottle.d.cts} +6 -19
- package/{esm/hooks/useThrottle/index.d.ts → dist/hooks/useThrottle/useThrottle.d.mts} +6 -19
- package/dist/hooks/useThrottle/useThrottle.mjs +49 -0
- package/dist/hooks/useThrottledCallback/useThrottledCallback.cjs +57 -0
- package/{esm/hooks/useThrottledCallback/index.d.ts → dist/hooks/useThrottledCallback/useThrottledCallback.d.cts} +8 -6
- package/dist/hooks/useThrottledCallback/{index.d.cts → useThrottledCallback.d.mts} +8 -6
- package/dist/hooks/useThrottledCallback/useThrottledCallback.mjs +57 -0
- package/dist/hooks/useTimeout/useTimeout.cjs +40 -0
- package/dist/hooks/useTimeout/{index.d.cts → useTimeout.d.cts} +4 -2
- package/{esm/hooks/useTimeout/index.d.ts → dist/hooks/useTimeout/useTimeout.d.mts} +4 -2
- package/dist/hooks/useTimeout/useTimeout.mjs +40 -0
- package/dist/hooks/useToggle/useToggle.cjs +34 -0
- package/dist/hooks/useToggle/{index.d.cts → useToggle.d.cts} +4 -4
- package/{esm/hooks/useToggle/index.d.ts → dist/hooks/useToggle/useToggle.d.mts} +4 -4
- package/dist/hooks/useToggle/useToggle.mjs +34 -0
- package/dist/hooks/useVisibilityEvent/useVisibilityEvent.cjs +42 -0
- package/{esm/hooks/useVisibilityEvent/index.d.ts → dist/hooks/useVisibilityEvent/useVisibilityEvent.d.cts} +5 -3
- package/dist/hooks/useVisibilityEvent/{index.d.cts → useVisibilityEvent.d.mts} +5 -3
- package/dist/hooks/useVisibilityEvent/useVisibilityEvent.mjs +42 -0
- package/dist/index.cjs +77 -1382
- package/dist/index.d.cts +56 -40
- package/dist/index.d.mts +56 -0
- package/dist/index.mjs +40 -0
- package/dist/utils/buildContext/buildContext.cjs +50 -0
- package/{esm/utils/buildContext/index.d.ts → dist/utils/buildContext/buildContext.d.cts} +7 -7
- package/dist/utils/buildContext/buildContext.d.mts +38 -0
- package/dist/utils/buildContext/buildContext.mjs +50 -0
- package/dist/utils/buildContext/index.d.cts +2 -37
- package/dist/utils/buildContext/index.d.mts +3 -0
- package/dist/utils/mergeProps/index.d.cts +2 -25
- package/dist/utils/mergeProps/index.d.mts +3 -0
- package/dist/utils/mergeProps/mergeProps.cjs +53 -0
- package/{esm/utils/mergeProps/index.d.ts → dist/utils/mergeProps/mergeProps.d.cts} +7 -8
- package/dist/utils/mergeProps/mergeProps.d.mts +25 -0
- package/dist/utils/mergeProps/mergeProps.mjs +53 -0
- package/dist/utils/mergeRefs/index.d.cts +2 -38
- package/dist/utils/mergeRefs/index.d.mts +3 -0
- package/dist/utils/mergeRefs/mergeRefs.cjs +50 -0
- package/{esm/utils/mergeRefs/index.d.ts → dist/utils/mergeRefs/mergeRefs.d.cts} +4 -3
- package/dist/utils/mergeRefs/mergeRefs.d.mts +40 -0
- package/dist/utils/mergeRefs/mergeRefs.mjs +50 -0
- package/package.json +9 -11
- package/dist/components/ImpressionArea/index.cjs +0 -295
- package/dist/components/Separated/index.cjs +0 -41
- package/dist/components/SwitchCase/index.cjs +0 -36
- package/dist/hooks/useAsyncEffect/index.cjs +0 -44
- package/dist/hooks/useBooleanState/index.cjs +0 -46
- package/dist/hooks/useCallbackOncePerRender/index.cjs +0 -63
- package/dist/hooks/useConditionalEffect/index.cjs +0 -51
- package/dist/hooks/useControlledState/index.cjs +0 -57
- package/dist/hooks/useCounter/index.cjs +0 -70
- package/dist/hooks/useDebounce/index.cjs +0 -130
- package/dist/hooks/useDebouncedCallback/index.cjs +0 -148
- package/dist/hooks/useDoubleClick/index.cjs +0 -79
- package/dist/hooks/useGeolocation/index.cjs +0 -154
- package/dist/hooks/useImpressionRef/index.cjs +0 -258
- package/dist/hooks/useInputState/index.cjs +0 -46
- package/dist/hooks/useIntersectionObserver/index.cjs +0 -95
- package/dist/hooks/useInterval/index.cjs +0 -74
- package/dist/hooks/useIsClient/index.cjs +0 -40
- package/dist/hooks/useIsomorphicLayoutEffect/index.cjs +0 -35
- package/dist/hooks/useList/index.cjs +0 -104
- package/dist/hooks/useLoading/index.cjs +0 -65
- package/dist/hooks/useLongPress/index.cjs +0 -127
- package/dist/hooks/useMap/index.cjs +0 -78
- package/dist/hooks/useOutsideClickEffect/index.cjs +0 -74
- package/dist/hooks/usePreservedCallback/index.cjs +0 -45
- package/dist/hooks/usePreservedReference/index.cjs +0 -45
- package/dist/hooks/usePrevious/index.cjs +0 -48
- package/dist/hooks/useRefEffect/index.cjs +0 -72
- package/dist/hooks/useSet/index.cjs +0 -105
- package/dist/hooks/useStorageState/index.cjs +0 -196
- package/dist/hooks/useThrottle/index.cjs +0 -151
- package/dist/hooks/useThrottledCallback/index.cjs +0 -172
- package/dist/hooks/useTimeout/index.cjs +0 -57
- package/dist/hooks/useToggle/index.cjs +0 -37
- package/dist/hooks/useVisibilityEvent/index.cjs +0 -47
- package/dist/utils/buildContext/index.cjs +0 -56
- package/dist/utils/mergeProps/index.cjs +0 -71
- package/dist/utils/mergeRefs/index.cjs +0 -46
- package/esm/components/ImpressionArea/index.js +0 -269
- package/esm/components/Separated/index.js +0 -15
- package/esm/components/SwitchCase/index.js +0 -10
- package/esm/hooks/useAsyncEffect/index.js +0 -18
- package/esm/hooks/useBooleanState/index.js +0 -20
- package/esm/hooks/useCallbackOncePerRender/index.js +0 -37
- package/esm/hooks/useConditionalEffect/index.js +0 -25
- package/esm/hooks/useControlledState/index.js +0 -31
- package/esm/hooks/useCounter/index.js +0 -44
- package/esm/hooks/useDebounce/index.js +0 -104
- package/esm/hooks/useDebouncedCallback/index.js +0 -122
- package/esm/hooks/useDoubleClick/index.js +0 -53
- package/esm/hooks/useGeolocation/index.js +0 -128
- package/esm/hooks/useImpressionRef/index.js +0 -232
- package/esm/hooks/useInputState/index.js +0 -20
- package/esm/hooks/useIntersectionObserver/index.js +0 -69
- package/esm/hooks/useInterval/index.js +0 -48
- package/esm/hooks/useIsClient/index.js +0 -14
- package/esm/hooks/useIsomorphicLayoutEffect/index.js +0 -9
- package/esm/hooks/useList/index.js +0 -78
- package/esm/hooks/useLoading/index.js +0 -39
- package/esm/hooks/useLongPress/index.js +0 -101
- package/esm/hooks/useMap/index.js +0 -52
- package/esm/hooks/useOutsideClickEffect/index.js +0 -48
- package/esm/hooks/usePreservedCallback/index.js +0 -19
- package/esm/hooks/usePreservedReference/index.js +0 -19
- package/esm/hooks/usePrevious/index.js +0 -22
- package/esm/hooks/useRefEffect/index.js +0 -46
- package/esm/hooks/useSet/index.js +0 -79
- package/esm/hooks/useStorageState/index.js +0 -170
- package/esm/hooks/useThrottle/index.js +0 -125
- package/esm/hooks/useThrottledCallback/index.js +0 -146
- package/esm/hooks/useTimeout/index.js +0 -31
- package/esm/hooks/useToggle/index.js +0 -11
- package/esm/hooks/useVisibilityEvent/index.js +0 -21
- package/esm/index.d.ts +0 -40
- package/esm/index.js +0 -1320
- package/esm/utils/buildContext/index.js +0 -30
- package/esm/utils/mergeProps/index.js +0 -45
- package/esm/utils/mergeRefs/index.js +0 -20
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
-
|
|
21
|
-
// src/hooks/useSet/index.ts
|
|
22
|
-
var useSet_exports = {};
|
|
23
|
-
__export(useSet_exports, {
|
|
24
|
-
useSet: () => useSet
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(useSet_exports);
|
|
27
|
-
|
|
28
|
-
// src/hooks/useSet/useSet.ts
|
|
29
|
-
var import_react3 = require("react");
|
|
30
|
-
|
|
31
|
-
// src/hooks/usePreservedCallback/usePreservedCallback.ts
|
|
32
|
-
var import_react = require("react");
|
|
33
|
-
function usePreservedCallback(callback) {
|
|
34
|
-
const callbackRef = (0, import_react.useRef)(callback);
|
|
35
|
-
(0, import_react.useEffect)(
|
|
36
|
-
function syncCallbackRef() {
|
|
37
|
-
callbackRef.current = callback;
|
|
38
|
-
},
|
|
39
|
-
[callback]
|
|
40
|
-
);
|
|
41
|
-
return (0, import_react.useCallback)((...args) => {
|
|
42
|
-
return callbackRef.current(...args);
|
|
43
|
-
}, []);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// src/hooks/usePreservedReference/usePreservedReference.ts
|
|
47
|
-
var import_react2 = require("react");
|
|
48
|
-
function usePreservedReference(value, areValuesEqual = areDeeplyEqual) {
|
|
49
|
-
const ref = (0, import_react2.useRef)(value);
|
|
50
|
-
return (0, import_react2.useMemo)(() => {
|
|
51
|
-
if (!areValuesEqual(ref.current, value)) {
|
|
52
|
-
ref.current = value;
|
|
53
|
-
}
|
|
54
|
-
return ref.current;
|
|
55
|
-
}, [areValuesEqual, value]);
|
|
56
|
-
}
|
|
57
|
-
function areDeeplyEqual(x, y) {
|
|
58
|
-
return JSON.stringify(x) === JSON.stringify(y);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// src/hooks/useSet/useSet.ts
|
|
62
|
-
function useSet(initialState = /* @__PURE__ */ new Set()) {
|
|
63
|
-
const [set, setSet] = (0, import_react3.useState)(() => new Set(initialState));
|
|
64
|
-
const preservedInitialState = usePreservedReference(initialState);
|
|
65
|
-
const add = usePreservedCallback((value) => {
|
|
66
|
-
setSet((prev) => {
|
|
67
|
-
const nextSet = new Set(prev);
|
|
68
|
-
nextSet.add(value);
|
|
69
|
-
return nextSet;
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
const remove = usePreservedCallback((value) => {
|
|
73
|
-
setSet((prev) => {
|
|
74
|
-
const nextSet = new Set(prev);
|
|
75
|
-
nextSet.delete(value);
|
|
76
|
-
return nextSet;
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
const toggle = usePreservedCallback((value) => {
|
|
80
|
-
setSet((prev) => {
|
|
81
|
-
const nextSet = new Set(prev);
|
|
82
|
-
if (nextSet.has(value)) {
|
|
83
|
-
nextSet.delete(value);
|
|
84
|
-
} else {
|
|
85
|
-
nextSet.add(value);
|
|
86
|
-
}
|
|
87
|
-
return nextSet;
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
const setAll = usePreservedCallback((values) => {
|
|
91
|
-
setSet(() => new Set(values));
|
|
92
|
-
});
|
|
93
|
-
const reset = usePreservedCallback(() => {
|
|
94
|
-
setSet(() => new Set(preservedInitialState));
|
|
95
|
-
});
|
|
96
|
-
const actions = (0, import_react3.useMemo)(
|
|
97
|
-
() => ({ add, remove, toggle, setAll, reset }),
|
|
98
|
-
[add, remove, toggle, setAll, reset]
|
|
99
|
-
);
|
|
100
|
-
return [set, actions];
|
|
101
|
-
}
|
|
102
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
103
|
-
0 && (module.exports = {
|
|
104
|
-
useSet
|
|
105
|
-
});
|
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
-
|
|
21
|
-
// src/hooks/useStorageState/index.ts
|
|
22
|
-
var useStorageState_exports = {};
|
|
23
|
-
__export(useStorageState_exports, {
|
|
24
|
-
useStorageState: () => useStorageState
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(useStorageState_exports);
|
|
27
|
-
|
|
28
|
-
// src/hooks/useStorageState/useStorageState.ts
|
|
29
|
-
var import_react = require("react");
|
|
30
|
-
|
|
31
|
-
// src/hooks/useStorageState/storage.ts
|
|
32
|
-
var MemoStorage = class {
|
|
33
|
-
storage = /* @__PURE__ */ new Map();
|
|
34
|
-
get(key) {
|
|
35
|
-
return this.storage.get(key) ?? null;
|
|
36
|
-
}
|
|
37
|
-
set(key, value) {
|
|
38
|
-
this.storage.set(key, value);
|
|
39
|
-
}
|
|
40
|
-
remove(key) {
|
|
41
|
-
this.storage.delete(key);
|
|
42
|
-
}
|
|
43
|
-
clear() {
|
|
44
|
-
this.storage.clear();
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
var LocalStorage = class {
|
|
48
|
-
static canUse() {
|
|
49
|
-
const TEST_KEY = generateTestKey();
|
|
50
|
-
try {
|
|
51
|
-
localStorage.setItem(TEST_KEY, "test");
|
|
52
|
-
localStorage.removeItem(TEST_KEY);
|
|
53
|
-
return true;
|
|
54
|
-
} catch {
|
|
55
|
-
return false;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
get(key) {
|
|
59
|
-
return localStorage.getItem(key);
|
|
60
|
-
}
|
|
61
|
-
set(key, value) {
|
|
62
|
-
localStorage.setItem(key, value);
|
|
63
|
-
}
|
|
64
|
-
remove(key) {
|
|
65
|
-
localStorage.removeItem(key);
|
|
66
|
-
}
|
|
67
|
-
clear() {
|
|
68
|
-
localStorage.clear();
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
var SessionStorage = class {
|
|
72
|
-
static canUse() {
|
|
73
|
-
const TEST_KEY = generateTestKey();
|
|
74
|
-
try {
|
|
75
|
-
sessionStorage.setItem(TEST_KEY, "test");
|
|
76
|
-
sessionStorage.removeItem(TEST_KEY);
|
|
77
|
-
return true;
|
|
78
|
-
} catch {
|
|
79
|
-
return false;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
get(key) {
|
|
83
|
-
return sessionStorage.getItem(key);
|
|
84
|
-
}
|
|
85
|
-
set(key, value) {
|
|
86
|
-
sessionStorage.setItem(key, value);
|
|
87
|
-
}
|
|
88
|
-
remove(key) {
|
|
89
|
-
sessionStorage.removeItem(key);
|
|
90
|
-
}
|
|
91
|
-
clear() {
|
|
92
|
-
sessionStorage.clear();
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
function generateTestKey() {
|
|
96
|
-
return new Array(4).fill(null).map(() => Math.random().toString(36).slice(2)).join("");
|
|
97
|
-
}
|
|
98
|
-
function generateStorage() {
|
|
99
|
-
if (LocalStorage.canUse()) {
|
|
100
|
-
return new LocalStorage();
|
|
101
|
-
}
|
|
102
|
-
return new MemoStorage();
|
|
103
|
-
}
|
|
104
|
-
function generateSessionStorage() {
|
|
105
|
-
if (SessionStorage.canUse()) {
|
|
106
|
-
return new SessionStorage();
|
|
107
|
-
}
|
|
108
|
-
return new MemoStorage();
|
|
109
|
-
}
|
|
110
|
-
var safeLocalStorage = generateStorage();
|
|
111
|
-
var safeSessionStorage = generateSessionStorage();
|
|
112
|
-
|
|
113
|
-
// src/hooks/useStorageState/useStorageState.ts
|
|
114
|
-
var listeners = /* @__PURE__ */ new Set();
|
|
115
|
-
var emitListeners = () => {
|
|
116
|
-
listeners.forEach((listener) => listener());
|
|
117
|
-
};
|
|
118
|
-
function isPlainObject(value) {
|
|
119
|
-
if (typeof value !== "object") {
|
|
120
|
-
return false;
|
|
121
|
-
}
|
|
122
|
-
const proto = Object.getPrototypeOf(value);
|
|
123
|
-
const hasObjectPrototype = proto === Object.prototype;
|
|
124
|
-
if (!hasObjectPrototype) {
|
|
125
|
-
return false;
|
|
126
|
-
}
|
|
127
|
-
return Object.prototype.toString.call(value) === "[object Object]";
|
|
128
|
-
}
|
|
129
|
-
var ensureSerializable = (value) => {
|
|
130
|
-
if (value[0] != null && !["string", "number", "boolean"].includes(typeof value[0]) && !(isPlainObject(value[0]) || Array.isArray(value[0]))) {
|
|
131
|
-
throw new Error("Received a non-serializable value");
|
|
132
|
-
}
|
|
133
|
-
return value;
|
|
134
|
-
};
|
|
135
|
-
function useStorageState(key, {
|
|
136
|
-
storage = safeLocalStorage,
|
|
137
|
-
defaultValue,
|
|
138
|
-
...options
|
|
139
|
-
} = {}) {
|
|
140
|
-
const serializedDefaultValue = defaultValue;
|
|
141
|
-
const cache = (0, import_react.useRef)({
|
|
142
|
-
data: null,
|
|
143
|
-
parsed: serializedDefaultValue
|
|
144
|
-
});
|
|
145
|
-
const getSnapshot = (0, import_react.useCallback)(() => {
|
|
146
|
-
const deserializer = "deserializer" in options ? options.deserializer : JSON.parse;
|
|
147
|
-
const data = storage.get(key);
|
|
148
|
-
if (data !== cache.current.data) {
|
|
149
|
-
try {
|
|
150
|
-
cache.current.parsed = data != null ? deserializer(data) : defaultValue;
|
|
151
|
-
} catch {
|
|
152
|
-
cache.current.parsed = serializedDefaultValue;
|
|
153
|
-
}
|
|
154
|
-
cache.current.data = data;
|
|
155
|
-
}
|
|
156
|
-
return cache.current.parsed;
|
|
157
|
-
}, [defaultValue, key, storage]);
|
|
158
|
-
const storageState = (0, import_react.useSyncExternalStore)(
|
|
159
|
-
(onStoreChange) => {
|
|
160
|
-
listeners.add(onStoreChange);
|
|
161
|
-
const handler = (event) => {
|
|
162
|
-
if (event.key === key) {
|
|
163
|
-
onStoreChange();
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
window.addEventListener("storage", handler);
|
|
167
|
-
return () => {
|
|
168
|
-
listeners.delete(onStoreChange);
|
|
169
|
-
window.removeEventListener("storage", handler);
|
|
170
|
-
};
|
|
171
|
-
},
|
|
172
|
-
() => getSnapshot(),
|
|
173
|
-
() => serializedDefaultValue
|
|
174
|
-
);
|
|
175
|
-
const setStorageState = (0, import_react.useCallback)(
|
|
176
|
-
(value) => {
|
|
177
|
-
const serializer = "serializer" in options ? options.serializer : JSON.stringify;
|
|
178
|
-
const nextValue = typeof value === "function" ? value(getSnapshot()) : value;
|
|
179
|
-
if (nextValue == null) {
|
|
180
|
-
storage.remove(key);
|
|
181
|
-
} else {
|
|
182
|
-
storage.set(key, serializer(nextValue));
|
|
183
|
-
}
|
|
184
|
-
emitListeners();
|
|
185
|
-
},
|
|
186
|
-
[getSnapshot, key, storage]
|
|
187
|
-
);
|
|
188
|
-
const refreshStorageState = (0, import_react.useCallback)(() => {
|
|
189
|
-
setStorageState(getSnapshot());
|
|
190
|
-
}, [storage, getSnapshot, setStorageState]);
|
|
191
|
-
return ensureSerializable([storageState, setStorageState, refreshStorageState]);
|
|
192
|
-
}
|
|
193
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
194
|
-
0 && (module.exports = {
|
|
195
|
-
useStorageState
|
|
196
|
-
});
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
-
|
|
21
|
-
// src/hooks/useThrottle/index.ts
|
|
22
|
-
var useThrottle_exports = {};
|
|
23
|
-
__export(useThrottle_exports, {
|
|
24
|
-
useThrottle: () => useThrottle
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(useThrottle_exports);
|
|
27
|
-
|
|
28
|
-
// src/hooks/useThrottle/useThrottle.ts
|
|
29
|
-
var import_react3 = require("react");
|
|
30
|
-
|
|
31
|
-
// src/hooks/usePreservedCallback/usePreservedCallback.ts
|
|
32
|
-
var import_react = require("react");
|
|
33
|
-
function usePreservedCallback(callback) {
|
|
34
|
-
const callbackRef = (0, import_react.useRef)(callback);
|
|
35
|
-
(0, import_react.useEffect)(
|
|
36
|
-
function syncCallbackRef() {
|
|
37
|
-
callbackRef.current = callback;
|
|
38
|
-
},
|
|
39
|
-
[callback]
|
|
40
|
-
);
|
|
41
|
-
return (0, import_react.useCallback)((...args) => {
|
|
42
|
-
return callbackRef.current(...args);
|
|
43
|
-
}, []);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// src/hooks/usePreservedReference/usePreservedReference.ts
|
|
47
|
-
var import_react2 = require("react");
|
|
48
|
-
function usePreservedReference(value, areValuesEqual = areDeeplyEqual) {
|
|
49
|
-
const ref = (0, import_react2.useRef)(value);
|
|
50
|
-
return (0, import_react2.useMemo)(() => {
|
|
51
|
-
if (!areValuesEqual(ref.current, value)) {
|
|
52
|
-
ref.current = value;
|
|
53
|
-
}
|
|
54
|
-
return ref.current;
|
|
55
|
-
}, [areValuesEqual, value]);
|
|
56
|
-
}
|
|
57
|
-
function areDeeplyEqual(x, y) {
|
|
58
|
-
return JSON.stringify(x) === JSON.stringify(y);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// src/hooks/useDebounce/debounce.ts
|
|
62
|
-
function debounce(func, debounceMs, { edges = ["leading", "trailing"] } = {}) {
|
|
63
|
-
let pendingThis = void 0;
|
|
64
|
-
let pendingArgs = null;
|
|
65
|
-
const leading = edges != null && edges.includes("leading");
|
|
66
|
-
const trailing = edges == null || edges.includes("trailing");
|
|
67
|
-
const invoke = () => {
|
|
68
|
-
if (pendingArgs !== null) {
|
|
69
|
-
func.apply(pendingThis, pendingArgs);
|
|
70
|
-
pendingThis = void 0;
|
|
71
|
-
pendingArgs = null;
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
const onTimerEnd = () => {
|
|
75
|
-
if (trailing) {
|
|
76
|
-
invoke();
|
|
77
|
-
}
|
|
78
|
-
cancel();
|
|
79
|
-
};
|
|
80
|
-
let timeoutId = null;
|
|
81
|
-
const schedule = () => {
|
|
82
|
-
if (timeoutId != null) {
|
|
83
|
-
clearTimeout(timeoutId);
|
|
84
|
-
}
|
|
85
|
-
timeoutId = setTimeout(() => {
|
|
86
|
-
timeoutId = null;
|
|
87
|
-
onTimerEnd();
|
|
88
|
-
}, debounceMs);
|
|
89
|
-
};
|
|
90
|
-
const cancelTimer = () => {
|
|
91
|
-
if (timeoutId !== null) {
|
|
92
|
-
clearTimeout(timeoutId);
|
|
93
|
-
timeoutId = null;
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
const cancel = () => {
|
|
97
|
-
cancelTimer();
|
|
98
|
-
pendingThis = void 0;
|
|
99
|
-
pendingArgs = null;
|
|
100
|
-
};
|
|
101
|
-
const debounced = function(...args) {
|
|
102
|
-
pendingThis = this;
|
|
103
|
-
pendingArgs = args;
|
|
104
|
-
const isFirstCall = timeoutId == null;
|
|
105
|
-
schedule();
|
|
106
|
-
if (leading && isFirstCall) {
|
|
107
|
-
invoke();
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
debounced.cancel = cancel;
|
|
111
|
-
return debounced;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// src/hooks/useThrottle/throttle.ts
|
|
115
|
-
function throttle(func, throttleMs, { edges = ["leading", "trailing"] } = {}) {
|
|
116
|
-
let pendingAt = null;
|
|
117
|
-
const debounced = debounce(func, throttleMs, { edges });
|
|
118
|
-
const throttled = function(...args) {
|
|
119
|
-
if (pendingAt == null) {
|
|
120
|
-
pendingAt = Date.now();
|
|
121
|
-
} else {
|
|
122
|
-
if (Date.now() - pendingAt >= throttleMs) {
|
|
123
|
-
pendingAt = Date.now();
|
|
124
|
-
debounced.cancel();
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
debounced(...args);
|
|
128
|
-
};
|
|
129
|
-
throttled.cancel = debounced.cancel;
|
|
130
|
-
return throttled;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
// src/hooks/useThrottle/useThrottle.ts
|
|
134
|
-
function useThrottle(callback, wait, options) {
|
|
135
|
-
const preservedCallback = usePreservedCallback(callback);
|
|
136
|
-
const preservedOptions = usePreservedReference(options ?? {});
|
|
137
|
-
const throttledCallback = (0, import_react3.useMemo)(
|
|
138
|
-
() => throttle(preservedCallback, wait, preservedOptions),
|
|
139
|
-
[preservedOptions, preservedCallback, wait]
|
|
140
|
-
);
|
|
141
|
-
(0, import_react3.useEffect)(() => {
|
|
142
|
-
return () => {
|
|
143
|
-
throttledCallback.cancel();
|
|
144
|
-
};
|
|
145
|
-
}, [throttledCallback]);
|
|
146
|
-
return throttledCallback;
|
|
147
|
-
}
|
|
148
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
149
|
-
0 && (module.exports = {
|
|
150
|
-
useThrottle
|
|
151
|
-
});
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
-
|
|
21
|
-
// src/hooks/useThrottledCallback/index.ts
|
|
22
|
-
var useThrottledCallback_exports = {};
|
|
23
|
-
__export(useThrottledCallback_exports, {
|
|
24
|
-
useThrottledCallback: () => useThrottledCallback
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(useThrottledCallback_exports);
|
|
27
|
-
|
|
28
|
-
// src/hooks/useThrottledCallback/useThrottledCallback.ts
|
|
29
|
-
var import_react3 = require("react");
|
|
30
|
-
|
|
31
|
-
// src/hooks/usePreservedCallback/usePreservedCallback.ts
|
|
32
|
-
var import_react = require("react");
|
|
33
|
-
function usePreservedCallback(callback) {
|
|
34
|
-
const callbackRef = (0, import_react.useRef)(callback);
|
|
35
|
-
(0, import_react.useEffect)(
|
|
36
|
-
function syncCallbackRef() {
|
|
37
|
-
callbackRef.current = callback;
|
|
38
|
-
},
|
|
39
|
-
[callback]
|
|
40
|
-
);
|
|
41
|
-
return (0, import_react.useCallback)((...args) => {
|
|
42
|
-
return callbackRef.current(...args);
|
|
43
|
-
}, []);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// src/hooks/usePreservedReference/usePreservedReference.ts
|
|
47
|
-
var import_react2 = require("react");
|
|
48
|
-
function usePreservedReference(value, areValuesEqual = areDeeplyEqual) {
|
|
49
|
-
const ref = (0, import_react2.useRef)(value);
|
|
50
|
-
return (0, import_react2.useMemo)(() => {
|
|
51
|
-
if (!areValuesEqual(ref.current, value)) {
|
|
52
|
-
ref.current = value;
|
|
53
|
-
}
|
|
54
|
-
return ref.current;
|
|
55
|
-
}, [areValuesEqual, value]);
|
|
56
|
-
}
|
|
57
|
-
function areDeeplyEqual(x, y) {
|
|
58
|
-
return JSON.stringify(x) === JSON.stringify(y);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// src/hooks/useDebounce/debounce.ts
|
|
62
|
-
function debounce(func, debounceMs, { edges = ["leading", "trailing"] } = {}) {
|
|
63
|
-
let pendingThis = void 0;
|
|
64
|
-
let pendingArgs = null;
|
|
65
|
-
const leading = edges != null && edges.includes("leading");
|
|
66
|
-
const trailing = edges == null || edges.includes("trailing");
|
|
67
|
-
const invoke = () => {
|
|
68
|
-
if (pendingArgs !== null) {
|
|
69
|
-
func.apply(pendingThis, pendingArgs);
|
|
70
|
-
pendingThis = void 0;
|
|
71
|
-
pendingArgs = null;
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
const onTimerEnd = () => {
|
|
75
|
-
if (trailing) {
|
|
76
|
-
invoke();
|
|
77
|
-
}
|
|
78
|
-
cancel();
|
|
79
|
-
};
|
|
80
|
-
let timeoutId = null;
|
|
81
|
-
const schedule = () => {
|
|
82
|
-
if (timeoutId != null) {
|
|
83
|
-
clearTimeout(timeoutId);
|
|
84
|
-
}
|
|
85
|
-
timeoutId = setTimeout(() => {
|
|
86
|
-
timeoutId = null;
|
|
87
|
-
onTimerEnd();
|
|
88
|
-
}, debounceMs);
|
|
89
|
-
};
|
|
90
|
-
const cancelTimer = () => {
|
|
91
|
-
if (timeoutId !== null) {
|
|
92
|
-
clearTimeout(timeoutId);
|
|
93
|
-
timeoutId = null;
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
const cancel = () => {
|
|
97
|
-
cancelTimer();
|
|
98
|
-
pendingThis = void 0;
|
|
99
|
-
pendingArgs = null;
|
|
100
|
-
};
|
|
101
|
-
const debounced = function(...args) {
|
|
102
|
-
pendingThis = this;
|
|
103
|
-
pendingArgs = args;
|
|
104
|
-
const isFirstCall = timeoutId == null;
|
|
105
|
-
schedule();
|
|
106
|
-
if (leading && isFirstCall) {
|
|
107
|
-
invoke();
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
debounced.cancel = cancel;
|
|
111
|
-
return debounced;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// src/hooks/useThrottle/throttle.ts
|
|
115
|
-
function throttle(func, throttleMs, { edges = ["leading", "trailing"] } = {}) {
|
|
116
|
-
let pendingAt = null;
|
|
117
|
-
const debounced = debounce(func, throttleMs, { edges });
|
|
118
|
-
const throttled = function(...args) {
|
|
119
|
-
if (pendingAt == null) {
|
|
120
|
-
pendingAt = Date.now();
|
|
121
|
-
} else {
|
|
122
|
-
if (Date.now() - pendingAt >= throttleMs) {
|
|
123
|
-
pendingAt = Date.now();
|
|
124
|
-
debounced.cancel();
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
debounced(...args);
|
|
128
|
-
};
|
|
129
|
-
throttled.cancel = debounced.cancel;
|
|
130
|
-
return throttled;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
// src/hooks/useThrottledCallback/useThrottledCallback.ts
|
|
134
|
-
function useThrottledCallback({
|
|
135
|
-
onChange,
|
|
136
|
-
timeThreshold,
|
|
137
|
-
edges = ["leading", "trailing"]
|
|
138
|
-
}) {
|
|
139
|
-
const handleChange = usePreservedCallback(onChange);
|
|
140
|
-
const ref = (0, import_react3.useRef)({ value: false, clearPreviousThrottle: () => {
|
|
141
|
-
} });
|
|
142
|
-
(0, import_react3.useEffect)(function cleanupThrottleOnUnmount() {
|
|
143
|
-
const current = ref.current;
|
|
144
|
-
return () => {
|
|
145
|
-
current.clearPreviousThrottle();
|
|
146
|
-
};
|
|
147
|
-
}, []);
|
|
148
|
-
const preservedEdges = usePreservedReference(edges);
|
|
149
|
-
return (0, import_react3.useCallback)(
|
|
150
|
-
(nextValue) => {
|
|
151
|
-
if (nextValue === ref.current.value) {
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
const throttled = throttle(
|
|
155
|
-
() => {
|
|
156
|
-
handleChange(nextValue);
|
|
157
|
-
ref.current.value = nextValue;
|
|
158
|
-
},
|
|
159
|
-
timeThreshold,
|
|
160
|
-
{ edges: preservedEdges }
|
|
161
|
-
);
|
|
162
|
-
ref.current.clearPreviousThrottle();
|
|
163
|
-
throttled();
|
|
164
|
-
ref.current.clearPreviousThrottle = throttled.cancel;
|
|
165
|
-
},
|
|
166
|
-
[handleChange, timeThreshold, preservedEdges]
|
|
167
|
-
);
|
|
168
|
-
}
|
|
169
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
170
|
-
0 && (module.exports = {
|
|
171
|
-
useThrottledCallback
|
|
172
|
-
});
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
-
|
|
21
|
-
// src/hooks/useTimeout/index.ts
|
|
22
|
-
var useTimeout_exports = {};
|
|
23
|
-
__export(useTimeout_exports, {
|
|
24
|
-
useTimeout: () => useTimeout
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(useTimeout_exports);
|
|
27
|
-
|
|
28
|
-
// src/hooks/useTimeout/useTimeout.ts
|
|
29
|
-
var import_react2 = require("react");
|
|
30
|
-
|
|
31
|
-
// src/hooks/usePreservedCallback/usePreservedCallback.ts
|
|
32
|
-
var import_react = require("react");
|
|
33
|
-
function usePreservedCallback(callback) {
|
|
34
|
-
const callbackRef = (0, import_react.useRef)(callback);
|
|
35
|
-
(0, import_react.useEffect)(
|
|
36
|
-
function syncCallbackRef() {
|
|
37
|
-
callbackRef.current = callback;
|
|
38
|
-
},
|
|
39
|
-
[callback]
|
|
40
|
-
);
|
|
41
|
-
return (0, import_react.useCallback)((...args) => {
|
|
42
|
-
return callbackRef.current(...args);
|
|
43
|
-
}, []);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// src/hooks/useTimeout/useTimeout.ts
|
|
47
|
-
function useTimeout(callback, delay = 0) {
|
|
48
|
-
const preservedCallback = usePreservedCallback(callback);
|
|
49
|
-
(0, import_react2.useEffect)(() => {
|
|
50
|
-
const timeoutId = setTimeout(preservedCallback, delay);
|
|
51
|
-
return () => clearTimeout(timeoutId);
|
|
52
|
-
}, [delay, preservedCallback]);
|
|
53
|
-
}
|
|
54
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
55
|
-
0 && (module.exports = {
|
|
56
|
-
useTimeout
|
|
57
|
-
});
|