@trackunit/react-components 0.1.138 → 0.1.139
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/index.cjs.js +7 -8
- package/index.esm.js +7 -8
- package/package.json +1 -1
- package/src/hooks/useTimeout.d.ts +3 -2
package/index.cjs.js
CHANGED
|
@@ -36672,13 +36672,12 @@ const getWindowSize = () => {
|
|
|
36672
36672
|
|
|
36673
36673
|
/**
|
|
36674
36674
|
* @param {UseTimeoutProps} props The props
|
|
36675
|
-
* @returns {{ startTimeout: () => void; stopTimeout: () => void;
|
|
36675
|
+
* @returns {{ startTimeout: () => void; stopTimeout: () => void;}} return
|
|
36676
36676
|
*/
|
|
36677
36677
|
const useTimeout = ({ onTimeout, duration }) => {
|
|
36678
36678
|
const ready = React.useRef(false);
|
|
36679
36679
|
const timeout = React.useRef();
|
|
36680
36680
|
const callback = React.useRef(onTimeout);
|
|
36681
|
-
const isReady = React.useCallback(() => ready.current, []);
|
|
36682
36681
|
const startTimeout = React.useCallback(() => {
|
|
36683
36682
|
ready.current = false;
|
|
36684
36683
|
timeout.current && clearTimeout(timeout.current);
|
|
@@ -36691,16 +36690,16 @@ const useTimeout = ({ onTimeout, duration }) => {
|
|
|
36691
36690
|
ready.current = null;
|
|
36692
36691
|
timeout.current && clearTimeout(timeout.current);
|
|
36693
36692
|
}, []);
|
|
36694
|
-
// update ref when function changes
|
|
36695
36693
|
React.useEffect(() => {
|
|
36696
36694
|
callback.current = onTimeout;
|
|
36697
36695
|
}, [onTimeout]);
|
|
36698
|
-
// startTimeout on mount, stopTimeout on unmount
|
|
36699
36696
|
React.useEffect(() => {
|
|
36700
|
-
|
|
36701
|
-
return
|
|
36702
|
-
|
|
36703
|
-
|
|
36697
|
+
// Cleanup function to clear the timeout when component unmounts
|
|
36698
|
+
return () => {
|
|
36699
|
+
timeout.current && clearTimeout(timeout.current);
|
|
36700
|
+
};
|
|
36701
|
+
}, []);
|
|
36702
|
+
return [startTimeout, stopTimeout];
|
|
36704
36703
|
};
|
|
36705
36704
|
|
|
36706
36705
|
const cvaMoreMenu = cssClassVarianceUtilities.cvaMerge(["p-4"]);
|
package/index.esm.js
CHANGED
|
@@ -36645,13 +36645,12 @@ const getWindowSize = () => {
|
|
|
36645
36645
|
|
|
36646
36646
|
/**
|
|
36647
36647
|
* @param {UseTimeoutProps} props The props
|
|
36648
|
-
* @returns {{ startTimeout: () => void; stopTimeout: () => void;
|
|
36648
|
+
* @returns {{ startTimeout: () => void; stopTimeout: () => void;}} return
|
|
36649
36649
|
*/
|
|
36650
36650
|
const useTimeout = ({ onTimeout, duration }) => {
|
|
36651
36651
|
const ready = useRef(false);
|
|
36652
36652
|
const timeout = useRef();
|
|
36653
36653
|
const callback = useRef(onTimeout);
|
|
36654
|
-
const isReady = useCallback(() => ready.current, []);
|
|
36655
36654
|
const startTimeout = useCallback(() => {
|
|
36656
36655
|
ready.current = false;
|
|
36657
36656
|
timeout.current && clearTimeout(timeout.current);
|
|
@@ -36664,16 +36663,16 @@ const useTimeout = ({ onTimeout, duration }) => {
|
|
|
36664
36663
|
ready.current = null;
|
|
36665
36664
|
timeout.current && clearTimeout(timeout.current);
|
|
36666
36665
|
}, []);
|
|
36667
|
-
// update ref when function changes
|
|
36668
36666
|
useEffect(() => {
|
|
36669
36667
|
callback.current = onTimeout;
|
|
36670
36668
|
}, [onTimeout]);
|
|
36671
|
-
// startTimeout on mount, stopTimeout on unmount
|
|
36672
36669
|
useEffect(() => {
|
|
36673
|
-
|
|
36674
|
-
return
|
|
36675
|
-
|
|
36676
|
-
|
|
36670
|
+
// Cleanup function to clear the timeout when component unmounts
|
|
36671
|
+
return () => {
|
|
36672
|
+
timeout.current && clearTimeout(timeout.current);
|
|
36673
|
+
};
|
|
36674
|
+
}, []);
|
|
36675
|
+
return [startTimeout, stopTimeout];
|
|
36677
36676
|
};
|
|
36678
36677
|
|
|
36679
36678
|
const cvaMoreMenu = cvaMerge(["p-4"]);
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
type Callback = () => void;
|
|
2
|
+
export type UseTimeoutReturn = [Callback, Callback];
|
|
2
3
|
interface UseTimeoutProps {
|
|
3
4
|
onTimeout: () => void;
|
|
4
5
|
duration: number;
|
|
5
6
|
}
|
|
6
7
|
/**
|
|
7
8
|
* @param {UseTimeoutProps} props The props
|
|
8
|
-
* @returns {{ startTimeout: () => void; stopTimeout: () => void;
|
|
9
|
+
* @returns {{ startTimeout: () => void; stopTimeout: () => void;}} return
|
|
9
10
|
*/
|
|
10
11
|
export declare const useTimeout: ({ onTimeout, duration }: UseTimeoutProps) => UseTimeoutReturn;
|
|
11
12
|
export {};
|