react-simplikit 0.0.49 → 0.0.51
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/index.d.cts +1 -1
- package/dist/hooks/useAsyncEffect/index.cjs +5 -0
- package/dist/hooks/useCounter/index.cjs +12 -14
- package/dist/hooks/useInterval/index.cjs +12 -2
- package/dist/hooks/usePrevious/index.d.cts +3 -3
- package/dist/index.cjs +29 -16
- package/esm/components/ImpressionArea/index.d.ts +1 -1
- package/esm/hooks/useAsyncEffect/index.js +5 -0
- package/esm/hooks/useCounter/index.js +12 -14
- package/esm/hooks/useInterval/index.js +13 -3
- package/esm/hooks/usePrevious/index.d.ts +3 -3
- package/esm/index.js +48 -35
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ElementType, ReactNode, Ref } from 'react';
|
|
2
2
|
import { UseImpressionRefOptions } from '../../hooks/useImpressionRef/index.cjs';
|
|
3
3
|
|
|
4
|
-
type Element<T extends ElementType,
|
|
4
|
+
type Element<T extends ElementType, IntrinsicElementsOf = T extends keyof React.JSX.IntrinsicElements ? React.JSX.IntrinsicElements[T] : HTMLElement> = IntrinsicElementsOf extends React.ClassAttributes<infer E extends HTMLElement> ? E : HTMLElement;
|
|
5
5
|
type Props<Tag extends ElementType> = React.ComponentPropsWithoutRef<Tag> & UseImpressionRefOptions & {
|
|
6
6
|
as?: Tag;
|
|
7
7
|
children?: ReactNode;
|
|
@@ -30,10 +30,15 @@ var import_react = require("react");
|
|
|
30
30
|
function useAsyncEffect(effect, deps) {
|
|
31
31
|
(0, import_react.useEffect)(() => {
|
|
32
32
|
let cleanup;
|
|
33
|
+
let isCleaned = false;
|
|
33
34
|
effect().then((result) => {
|
|
34
35
|
cleanup = result;
|
|
36
|
+
if (isCleaned) {
|
|
37
|
+
cleanup?.();
|
|
38
|
+
}
|
|
35
39
|
});
|
|
36
40
|
return () => {
|
|
41
|
+
isCleaned = true;
|
|
37
42
|
cleanup?.();
|
|
38
43
|
};
|
|
39
44
|
}, deps);
|
|
@@ -27,27 +27,25 @@ module.exports = __toCommonJS(useCounter_exports);
|
|
|
27
27
|
|
|
28
28
|
// src/hooks/useCounter/useCounter.ts
|
|
29
29
|
var import_react = require("react");
|
|
30
|
+
var validateValue = (value, { min, max }) => {
|
|
31
|
+
if (min !== void 0 && value < min) {
|
|
32
|
+
return min;
|
|
33
|
+
}
|
|
34
|
+
if (max !== void 0 && value > max) {
|
|
35
|
+
return max;
|
|
36
|
+
}
|
|
37
|
+
return value;
|
|
38
|
+
};
|
|
30
39
|
function useCounter(initialValue = 0, { min, max, step = 1 } = {}) {
|
|
31
|
-
const
|
|
32
|
-
let validatedValue = value;
|
|
33
|
-
if (min !== void 0 && validatedValue < min) {
|
|
34
|
-
validatedValue = min;
|
|
35
|
-
}
|
|
36
|
-
if (max !== void 0 && validatedValue > max) {
|
|
37
|
-
validatedValue = max;
|
|
38
|
-
}
|
|
39
|
-
return validatedValue;
|
|
40
|
-
};
|
|
41
|
-
const [count, setCountState] = (0, import_react.useState)(() => validateValue(initialValue));
|
|
42
|
-
const validateValueMemoized = (0, import_react.useCallback)(validateValue, [min, max]);
|
|
40
|
+
const [count, setCountState] = (0, import_react.useState)(() => validateValue(initialValue, { min, max }));
|
|
43
41
|
const setCount = (0, import_react.useCallback)(
|
|
44
42
|
(value) => {
|
|
45
43
|
setCountState((prev) => {
|
|
46
44
|
const nextValue = typeof value === "function" ? value(prev) : value;
|
|
47
|
-
return
|
|
45
|
+
return validateValue(nextValue, { min, max });
|
|
48
46
|
});
|
|
49
47
|
},
|
|
50
|
-
[
|
|
48
|
+
[min, max]
|
|
51
49
|
);
|
|
52
50
|
const increment = (0, import_react.useCallback)(() => {
|
|
53
51
|
setCount((prev) => prev + step);
|
|
@@ -49,11 +49,21 @@ function useInterval(callback, options) {
|
|
|
49
49
|
const immediate = typeof options === "number" ? false : options.immediate;
|
|
50
50
|
const enabled = typeof options === "number" ? true : options.enabled ?? true;
|
|
51
51
|
const preservedCallback = usePreservedCallback(callback);
|
|
52
|
+
const immediateCalledRef = (0, import_react2.useRef)(false);
|
|
52
53
|
(0, import_react2.useEffect)(
|
|
53
54
|
function runImmediateCallback() {
|
|
54
|
-
if (immediate
|
|
55
|
-
|
|
55
|
+
if (immediate !== true) {
|
|
56
|
+
immediateCalledRef.current = false;
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (!enabled) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (immediateCalledRef.current) {
|
|
63
|
+
return;
|
|
56
64
|
}
|
|
65
|
+
immediateCalledRef.current = true;
|
|
66
|
+
preservedCallback();
|
|
57
67
|
},
|
|
58
68
|
[immediate, preservedCallback, enabled]
|
|
59
69
|
);
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @description
|
|
3
3
|
* `usePrevious` is a React hook that returns the previous value of the input state.
|
|
4
|
-
* It preserves the previous value unchanged when re-
|
|
4
|
+
* It preserves the previous value unchanged when re-renders occur without state changes.
|
|
5
5
|
* If the state is an object or requires custom change detection, a `compare` function can be provided.
|
|
6
6
|
* By default, state changes are detected using `prev === next`.
|
|
7
7
|
*
|
|
8
8
|
* @template T - The type of the state.
|
|
9
9
|
* @param {T} state - The state whose previous value is to be tracked.
|
|
10
|
-
* @param {(prev: T
|
|
10
|
+
* @param {(prev: T, next: T) => boolean} [compare] - An optional comparison function to determine if the state has changed.
|
|
11
11
|
*
|
|
12
|
-
* @returns {T
|
|
12
|
+
* @returns {T} The previous value of the state.
|
|
13
13
|
*
|
|
14
14
|
* @example
|
|
15
15
|
* const [count, setCount] = useState(0);
|
package/dist/index.cjs
CHANGED
|
@@ -349,10 +349,15 @@ var import_react9 = require("react");
|
|
|
349
349
|
function useAsyncEffect(effect, deps) {
|
|
350
350
|
(0, import_react9.useEffect)(() => {
|
|
351
351
|
let cleanup;
|
|
352
|
+
let isCleaned = false;
|
|
352
353
|
effect().then((result) => {
|
|
353
354
|
cleanup = result;
|
|
355
|
+
if (isCleaned) {
|
|
356
|
+
cleanup?.();
|
|
357
|
+
}
|
|
354
358
|
});
|
|
355
359
|
return () => {
|
|
360
|
+
isCleaned = true;
|
|
356
361
|
cleanup?.();
|
|
357
362
|
};
|
|
358
363
|
}, deps);
|
|
@@ -440,27 +445,25 @@ function isSetStateAction(next) {
|
|
|
440
445
|
|
|
441
446
|
// src/hooks/useCounter/useCounter.ts
|
|
442
447
|
var import_react14 = require("react");
|
|
448
|
+
var validateValue = (value, { min, max }) => {
|
|
449
|
+
if (min !== void 0 && value < min) {
|
|
450
|
+
return min;
|
|
451
|
+
}
|
|
452
|
+
if (max !== void 0 && value > max) {
|
|
453
|
+
return max;
|
|
454
|
+
}
|
|
455
|
+
return value;
|
|
456
|
+
};
|
|
443
457
|
function useCounter(initialValue = 0, { min, max, step = 1 } = {}) {
|
|
444
|
-
const
|
|
445
|
-
let validatedValue = value;
|
|
446
|
-
if (min !== void 0 && validatedValue < min) {
|
|
447
|
-
validatedValue = min;
|
|
448
|
-
}
|
|
449
|
-
if (max !== void 0 && validatedValue > max) {
|
|
450
|
-
validatedValue = max;
|
|
451
|
-
}
|
|
452
|
-
return validatedValue;
|
|
453
|
-
};
|
|
454
|
-
const [count, setCountState] = (0, import_react14.useState)(() => validateValue(initialValue));
|
|
455
|
-
const validateValueMemoized = (0, import_react14.useCallback)(validateValue, [min, max]);
|
|
458
|
+
const [count, setCountState] = (0, import_react14.useState)(() => validateValue(initialValue, { min, max }));
|
|
456
459
|
const setCount = (0, import_react14.useCallback)(
|
|
457
460
|
(value) => {
|
|
458
461
|
setCountState((prev) => {
|
|
459
462
|
const nextValue = typeof value === "function" ? value(prev) : value;
|
|
460
|
-
return
|
|
463
|
+
return validateValue(nextValue, { min, max });
|
|
461
464
|
});
|
|
462
465
|
},
|
|
463
|
-
[
|
|
466
|
+
[min, max]
|
|
464
467
|
);
|
|
465
468
|
const increment = (0, import_react14.useCallback)(() => {
|
|
466
469
|
setCount((prev) => prev + step);
|
|
@@ -689,11 +692,21 @@ function useInterval(callback, options) {
|
|
|
689
692
|
const immediate = typeof options === "number" ? false : options.immediate;
|
|
690
693
|
const enabled = typeof options === "number" ? true : options.enabled ?? true;
|
|
691
694
|
const preservedCallback = usePreservedCallback(callback);
|
|
695
|
+
const immediateCalledRef = (0, import_react20.useRef)(false);
|
|
692
696
|
(0, import_react20.useEffect)(
|
|
693
697
|
function runImmediateCallback() {
|
|
694
|
-
if (immediate
|
|
695
|
-
|
|
698
|
+
if (immediate !== true) {
|
|
699
|
+
immediateCalledRef.current = false;
|
|
700
|
+
return;
|
|
701
|
+
}
|
|
702
|
+
if (!enabled) {
|
|
703
|
+
return;
|
|
704
|
+
}
|
|
705
|
+
if (immediateCalledRef.current) {
|
|
706
|
+
return;
|
|
696
707
|
}
|
|
708
|
+
immediateCalledRef.current = true;
|
|
709
|
+
preservedCallback();
|
|
697
710
|
},
|
|
698
711
|
[immediate, preservedCallback, enabled]
|
|
699
712
|
);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ElementType, ReactNode, Ref } from 'react';
|
|
2
2
|
import { UseImpressionRefOptions } from '../../hooks/useImpressionRef/index.js';
|
|
3
3
|
|
|
4
|
-
type Element<T extends ElementType,
|
|
4
|
+
type Element<T extends ElementType, IntrinsicElementsOf = T extends keyof React.JSX.IntrinsicElements ? React.JSX.IntrinsicElements[T] : HTMLElement> = IntrinsicElementsOf extends React.ClassAttributes<infer E extends HTMLElement> ? E : HTMLElement;
|
|
5
5
|
type Props<Tag extends ElementType> = React.ComponentPropsWithoutRef<Tag> & UseImpressionRefOptions & {
|
|
6
6
|
as?: Tag;
|
|
7
7
|
children?: ReactNode;
|
|
@@ -5,10 +5,15 @@ import { useEffect } from "react";
|
|
|
5
5
|
function useAsyncEffect(effect, deps) {
|
|
6
6
|
useEffect(() => {
|
|
7
7
|
let cleanup;
|
|
8
|
+
let isCleaned = false;
|
|
8
9
|
effect().then((result) => {
|
|
9
10
|
cleanup = result;
|
|
11
|
+
if (isCleaned) {
|
|
12
|
+
cleanup?.();
|
|
13
|
+
}
|
|
10
14
|
});
|
|
11
15
|
return () => {
|
|
16
|
+
isCleaned = true;
|
|
12
17
|
cleanup?.();
|
|
13
18
|
};
|
|
14
19
|
}, deps);
|
|
@@ -2,27 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
// src/hooks/useCounter/useCounter.ts
|
|
4
4
|
import { useCallback, useState } from "react";
|
|
5
|
+
var validateValue = (value, { min, max }) => {
|
|
6
|
+
if (min !== void 0 && value < min) {
|
|
7
|
+
return min;
|
|
8
|
+
}
|
|
9
|
+
if (max !== void 0 && value > max) {
|
|
10
|
+
return max;
|
|
11
|
+
}
|
|
12
|
+
return value;
|
|
13
|
+
};
|
|
5
14
|
function useCounter(initialValue = 0, { min, max, step = 1 } = {}) {
|
|
6
|
-
const
|
|
7
|
-
let validatedValue = value;
|
|
8
|
-
if (min !== void 0 && validatedValue < min) {
|
|
9
|
-
validatedValue = min;
|
|
10
|
-
}
|
|
11
|
-
if (max !== void 0 && validatedValue > max) {
|
|
12
|
-
validatedValue = max;
|
|
13
|
-
}
|
|
14
|
-
return validatedValue;
|
|
15
|
-
};
|
|
16
|
-
const [count, setCountState] = useState(() => validateValue(initialValue));
|
|
17
|
-
const validateValueMemoized = useCallback(validateValue, [min, max]);
|
|
15
|
+
const [count, setCountState] = useState(() => validateValue(initialValue, { min, max }));
|
|
18
16
|
const setCount = useCallback(
|
|
19
17
|
(value) => {
|
|
20
18
|
setCountState((prev) => {
|
|
21
19
|
const nextValue = typeof value === "function" ? value(prev) : value;
|
|
22
|
-
return
|
|
20
|
+
return validateValue(nextValue, { min, max });
|
|
23
21
|
});
|
|
24
22
|
},
|
|
25
|
-
[
|
|
23
|
+
[min, max]
|
|
26
24
|
);
|
|
27
25
|
const increment = useCallback(() => {
|
|
28
26
|
setCount((prev) => prev + step);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
// src/hooks/useInterval/useInterval.ts
|
|
4
|
-
import { useEffect as useEffect2 } from "react";
|
|
4
|
+
import { useEffect as useEffect2, useRef as useRef2 } from "react";
|
|
5
5
|
|
|
6
6
|
// src/hooks/usePreservedCallback/usePreservedCallback.ts
|
|
7
7
|
import { useCallback, useEffect, useRef } from "react";
|
|
@@ -24,11 +24,21 @@ function useInterval(callback, options) {
|
|
|
24
24
|
const immediate = typeof options === "number" ? false : options.immediate;
|
|
25
25
|
const enabled = typeof options === "number" ? true : options.enabled ?? true;
|
|
26
26
|
const preservedCallback = usePreservedCallback(callback);
|
|
27
|
+
const immediateCalledRef = useRef2(false);
|
|
27
28
|
useEffect2(
|
|
28
29
|
function runImmediateCallback() {
|
|
29
|
-
if (immediate
|
|
30
|
-
|
|
30
|
+
if (immediate !== true) {
|
|
31
|
+
immediateCalledRef.current = false;
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (!enabled) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (immediateCalledRef.current) {
|
|
38
|
+
return;
|
|
31
39
|
}
|
|
40
|
+
immediateCalledRef.current = true;
|
|
41
|
+
preservedCallback();
|
|
32
42
|
},
|
|
33
43
|
[immediate, preservedCallback, enabled]
|
|
34
44
|
);
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @description
|
|
3
3
|
* `usePrevious` is a React hook that returns the previous value of the input state.
|
|
4
|
-
* It preserves the previous value unchanged when re-
|
|
4
|
+
* It preserves the previous value unchanged when re-renders occur without state changes.
|
|
5
5
|
* If the state is an object or requires custom change detection, a `compare` function can be provided.
|
|
6
6
|
* By default, state changes are detected using `prev === next`.
|
|
7
7
|
*
|
|
8
8
|
* @template T - The type of the state.
|
|
9
9
|
* @param {T} state - The state whose previous value is to be tracked.
|
|
10
|
-
* @param {(prev: T
|
|
10
|
+
* @param {(prev: T, next: T) => boolean} [compare] - An optional comparison function to determine if the state has changed.
|
|
11
11
|
*
|
|
12
|
-
* @returns {T
|
|
12
|
+
* @returns {T} The previous value of the state.
|
|
13
13
|
*
|
|
14
14
|
* @example
|
|
15
15
|
* const [count, setCount] = useState(0);
|
package/esm/index.js
CHANGED
|
@@ -287,10 +287,15 @@ import { useEffect as useEffect4 } from "react";
|
|
|
287
287
|
function useAsyncEffect(effect, deps) {
|
|
288
288
|
useEffect4(() => {
|
|
289
289
|
let cleanup;
|
|
290
|
+
let isCleaned = false;
|
|
290
291
|
effect().then((result) => {
|
|
291
292
|
cleanup = result;
|
|
293
|
+
if (isCleaned) {
|
|
294
|
+
cleanup?.();
|
|
295
|
+
}
|
|
292
296
|
});
|
|
293
297
|
return () => {
|
|
298
|
+
isCleaned = true;
|
|
294
299
|
cleanup?.();
|
|
295
300
|
};
|
|
296
301
|
}, deps);
|
|
@@ -378,27 +383,25 @@ function isSetStateAction(next) {
|
|
|
378
383
|
|
|
379
384
|
// src/hooks/useCounter/useCounter.ts
|
|
380
385
|
import { useCallback as useCallback8, useState as useState3 } from "react";
|
|
386
|
+
var validateValue = (value, { min, max }) => {
|
|
387
|
+
if (min !== void 0 && value < min) {
|
|
388
|
+
return min;
|
|
389
|
+
}
|
|
390
|
+
if (max !== void 0 && value > max) {
|
|
391
|
+
return max;
|
|
392
|
+
}
|
|
393
|
+
return value;
|
|
394
|
+
};
|
|
381
395
|
function useCounter(initialValue = 0, { min, max, step = 1 } = {}) {
|
|
382
|
-
const
|
|
383
|
-
let validatedValue = value;
|
|
384
|
-
if (min !== void 0 && validatedValue < min) {
|
|
385
|
-
validatedValue = min;
|
|
386
|
-
}
|
|
387
|
-
if (max !== void 0 && validatedValue > max) {
|
|
388
|
-
validatedValue = max;
|
|
389
|
-
}
|
|
390
|
-
return validatedValue;
|
|
391
|
-
};
|
|
392
|
-
const [count, setCountState] = useState3(() => validateValue(initialValue));
|
|
393
|
-
const validateValueMemoized = useCallback8(validateValue, [min, max]);
|
|
396
|
+
const [count, setCountState] = useState3(() => validateValue(initialValue, { min, max }));
|
|
394
397
|
const setCount = useCallback8(
|
|
395
398
|
(value) => {
|
|
396
399
|
setCountState((prev) => {
|
|
397
400
|
const nextValue = typeof value === "function" ? value(prev) : value;
|
|
398
|
-
return
|
|
401
|
+
return validateValue(nextValue, { min, max });
|
|
399
402
|
});
|
|
400
403
|
},
|
|
401
|
-
[
|
|
404
|
+
[min, max]
|
|
402
405
|
);
|
|
403
406
|
const increment = useCallback8(() => {
|
|
404
407
|
setCount((prev) => prev + step);
|
|
@@ -621,17 +624,27 @@ function echo(v) {
|
|
|
621
624
|
}
|
|
622
625
|
|
|
623
626
|
// src/hooks/useInterval/useInterval.ts
|
|
624
|
-
import { useEffect as useEffect10 } from "react";
|
|
627
|
+
import { useEffect as useEffect10, useRef as useRef9 } from "react";
|
|
625
628
|
function useInterval(callback, options) {
|
|
626
629
|
const delay = typeof options === "number" ? options : options.delay;
|
|
627
630
|
const immediate = typeof options === "number" ? false : options.immediate;
|
|
628
631
|
const enabled = typeof options === "number" ? true : options.enabled ?? true;
|
|
629
632
|
const preservedCallback = usePreservedCallback(callback);
|
|
633
|
+
const immediateCalledRef = useRef9(false);
|
|
630
634
|
useEffect10(
|
|
631
635
|
function runImmediateCallback() {
|
|
632
|
-
if (immediate
|
|
633
|
-
|
|
636
|
+
if (immediate !== true) {
|
|
637
|
+
immediateCalledRef.current = false;
|
|
638
|
+
return;
|
|
639
|
+
}
|
|
640
|
+
if (!enabled) {
|
|
641
|
+
return;
|
|
642
|
+
}
|
|
643
|
+
if (immediateCalledRef.current) {
|
|
644
|
+
return;
|
|
634
645
|
}
|
|
646
|
+
immediateCalledRef.current = true;
|
|
647
|
+
preservedCallback();
|
|
635
648
|
},
|
|
636
649
|
[immediate, preservedCallback, enabled]
|
|
637
650
|
);
|
|
@@ -666,9 +679,9 @@ var useIsomorphicLayoutEffect = isServer ? useEffect12 : useLayoutEffect;
|
|
|
666
679
|
import { useMemo as useMemo5, useState as useState7 } from "react";
|
|
667
680
|
|
|
668
681
|
// src/hooks/usePreservedReference/usePreservedReference.ts
|
|
669
|
-
import { useMemo as useMemo4, useRef as
|
|
682
|
+
import { useMemo as useMemo4, useRef as useRef10 } from "react";
|
|
670
683
|
function usePreservedReference(value, areValuesEqual = areDeeplyEqual) {
|
|
671
|
-
const ref =
|
|
684
|
+
const ref = useRef10(value);
|
|
672
685
|
return useMemo4(() => {
|
|
673
686
|
if (!areValuesEqual(ref.current, value)) {
|
|
674
687
|
ref.current = value;
|
|
@@ -722,7 +735,7 @@ function useList(initialState = []) {
|
|
|
722
735
|
}
|
|
723
736
|
|
|
724
737
|
// src/hooks/useLoading/useLoading.ts
|
|
725
|
-
import { useCallback as useCallback12, useEffect as useEffect13, useMemo as useMemo6, useRef as
|
|
738
|
+
import { useCallback as useCallback12, useEffect as useEffect13, useMemo as useMemo6, useRef as useRef11, useState as useState8 } from "react";
|
|
726
739
|
function useLoading() {
|
|
727
740
|
const [loading, setLoading] = useState8(false);
|
|
728
741
|
const ref = useIsMountedRef();
|
|
@@ -743,7 +756,7 @@ function useLoading() {
|
|
|
743
756
|
return useMemo6(() => [loading, startTransition], [loading, startTransition]);
|
|
744
757
|
}
|
|
745
758
|
function useIsMountedRef() {
|
|
746
|
-
const ref =
|
|
759
|
+
const ref = useRef11({ isMounted: true }).current;
|
|
747
760
|
useEffect13(
|
|
748
761
|
function trackMountedState() {
|
|
749
762
|
ref.isMounted = true;
|
|
@@ -757,11 +770,11 @@ function useIsMountedRef() {
|
|
|
757
770
|
}
|
|
758
771
|
|
|
759
772
|
// src/hooks/useLongPress/useLongPress.ts
|
|
760
|
-
import { useCallback as useCallback13, useRef as
|
|
773
|
+
import { useCallback as useCallback13, useRef as useRef12 } from "react";
|
|
761
774
|
function useLongPress(onLongPress, { delay = 500, moveThreshold, onClick, onLongPressEnd } = {}) {
|
|
762
|
-
const timeoutRef =
|
|
763
|
-
const isLongPressActiveRef =
|
|
764
|
-
const initialPositionRef =
|
|
775
|
+
const timeoutRef = useRef12(null);
|
|
776
|
+
const isLongPressActiveRef = useRef12(false);
|
|
777
|
+
const initialPositionRef = useRef12({ x: 0, y: 0 });
|
|
765
778
|
const preservedOnLongPress = usePreservedCallback(onLongPress);
|
|
766
779
|
const preservedOnClick = usePreservedCallback(onClick || (() => {
|
|
767
780
|
}));
|
|
@@ -868,9 +881,9 @@ function useMap(initialState = /* @__PURE__ */ new Map()) {
|
|
|
868
881
|
}
|
|
869
882
|
|
|
870
883
|
// src/hooks/useOutsideClickEffect/useOutsideClickEffect.ts
|
|
871
|
-
import { useEffect as useEffect14, useRef as
|
|
884
|
+
import { useEffect as useEffect14, useRef as useRef13 } from "react";
|
|
872
885
|
function useOutsideClickEffect(container, callback) {
|
|
873
|
-
const containers =
|
|
886
|
+
const containers = useRef13([]);
|
|
874
887
|
const handleDocumentClick = usePreservedCallback(({ target }) => {
|
|
875
888
|
if (target === null) {
|
|
876
889
|
return;
|
|
@@ -895,12 +908,12 @@ function useOutsideClickEffect(container, callback) {
|
|
|
895
908
|
}
|
|
896
909
|
|
|
897
910
|
// src/hooks/usePrevious/usePrevious.ts
|
|
898
|
-
import { useRef as
|
|
911
|
+
import { useRef as useRef14 } from "react";
|
|
899
912
|
var strictEquals = (prev, next) => prev === next;
|
|
900
913
|
function usePrevious(state, compare = strictEquals) {
|
|
901
|
-
const prevRef =
|
|
902
|
-
const currentRef =
|
|
903
|
-
const isFirstRender =
|
|
914
|
+
const prevRef = useRef14(state);
|
|
915
|
+
const currentRef = useRef14(state);
|
|
916
|
+
const isFirstRender = useRef14(true);
|
|
904
917
|
if (isFirstRender.current) {
|
|
905
918
|
isFirstRender.current = false;
|
|
906
919
|
return prevRef.current;
|
|
@@ -956,7 +969,7 @@ function useSet(initialState = /* @__PURE__ */ new Set()) {
|
|
|
956
969
|
}
|
|
957
970
|
|
|
958
971
|
// src/hooks/useStorageState/useStorageState.ts
|
|
959
|
-
import { useCallback as useCallback15, useRef as
|
|
972
|
+
import { useCallback as useCallback15, useRef as useRef15, useSyncExternalStore } from "react";
|
|
960
973
|
|
|
961
974
|
// src/hooks/useStorageState/storage.ts
|
|
962
975
|
var MemoStorage = class {
|
|
@@ -1068,7 +1081,7 @@ function useStorageState(key, {
|
|
|
1068
1081
|
...options
|
|
1069
1082
|
} = {}) {
|
|
1070
1083
|
const serializedDefaultValue = defaultValue;
|
|
1071
|
-
const cache =
|
|
1084
|
+
const cache = useRef15({
|
|
1072
1085
|
data: null,
|
|
1073
1086
|
parsed: serializedDefaultValue
|
|
1074
1087
|
});
|
|
@@ -1160,14 +1173,14 @@ function useThrottle(callback, wait, options) {
|
|
|
1160
1173
|
}
|
|
1161
1174
|
|
|
1162
1175
|
// src/hooks/useThrottledCallback/useThrottledCallback.ts
|
|
1163
|
-
import { useCallback as useCallback16, useEffect as useEffect16, useRef as
|
|
1176
|
+
import { useCallback as useCallback16, useEffect as useEffect16, useRef as useRef16 } from "react";
|
|
1164
1177
|
function useThrottledCallback({
|
|
1165
1178
|
onChange,
|
|
1166
1179
|
timeThreshold,
|
|
1167
1180
|
edges = ["leading", "trailing"]
|
|
1168
1181
|
}) {
|
|
1169
1182
|
const handleChange = usePreservedCallback(onChange);
|
|
1170
|
-
const ref =
|
|
1183
|
+
const ref = useRef16({ value: false, clearPreviousThrottle: () => {
|
|
1171
1184
|
} });
|
|
1172
1185
|
useEffect16(function cleanupThrottleOnUnmount() {
|
|
1173
1186
|
const current = ref.current;
|