@chekinapp/ui 0.0.94 → 0.0.96
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/index.cjs +22 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +21 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -367,6 +367,7 @@ __export(index_exports, {
|
|
|
367
367
|
useClickEscape: () => useClickEscape,
|
|
368
368
|
useCombinedRef: () => useCombinedRef,
|
|
369
369
|
useCopyToClipboard: () => useCopyToClipboard,
|
|
370
|
+
useCountdown: () => useCountdown,
|
|
370
371
|
useDebounce: () => useDebounce,
|
|
371
372
|
useDebouncedFunction: () => useDebouncedFunction,
|
|
372
373
|
useEvent: () => useEvent,
|
|
@@ -399,7 +400,6 @@ __export(index_exports, {
|
|
|
399
400
|
useTimeline: () => useTimeline,
|
|
400
401
|
useTimeout: () => useTimeout,
|
|
401
402
|
useTimeoutRef: () => useTimeoutRef,
|
|
402
|
-
useTimer: () => useTimer,
|
|
403
403
|
useUpdateToast: () => useUpdateToast,
|
|
404
404
|
useValidateDates: () => useValidateDates
|
|
405
405
|
});
|
|
@@ -3786,11 +3786,20 @@ function useSwitchSectionActive(preloadedSectionActive, { canToggle, onToggle, o
|
|
|
3786
3786
|
};
|
|
3787
3787
|
}
|
|
3788
3788
|
|
|
3789
|
-
// src/hooks/use-
|
|
3789
|
+
// src/hooks/use-countdown.ts
|
|
3790
3790
|
var import_react33 = require("react");
|
|
3791
|
-
var
|
|
3792
|
-
|
|
3793
|
-
|
|
3791
|
+
var useCountdown = ({
|
|
3792
|
+
initialTime = 60,
|
|
3793
|
+
enabled = true,
|
|
3794
|
+
onFinish
|
|
3795
|
+
} = {}) => {
|
|
3796
|
+
const [timeLeft, setTimeLeft] = (0, import_react33.useState)(initialTime);
|
|
3797
|
+
const [isTimerRunning, setIsTimerRunning] = (0, import_react33.useState)(enabled);
|
|
3798
|
+
const handleOnFinish = useEvent(onFinish);
|
|
3799
|
+
(0, import_react33.useEffect)(() => {
|
|
3800
|
+
setTimeLeft(initialTime);
|
|
3801
|
+
setIsTimerRunning(enabled);
|
|
3802
|
+
}, [initialTime, enabled]);
|
|
3794
3803
|
(0, import_react33.useEffect)(() => {
|
|
3795
3804
|
if (!isTimerRunning) return;
|
|
3796
3805
|
const timer = setInterval(() => {
|
|
@@ -3805,9 +3814,14 @@ var useTimer = ({ seconds }) => {
|
|
|
3805
3814
|
}, 1e3);
|
|
3806
3815
|
return () => clearInterval(timer);
|
|
3807
3816
|
}, [isTimerRunning]);
|
|
3817
|
+
(0, import_react33.useEffect)(() => {
|
|
3818
|
+
if (timeLeft <= 0) {
|
|
3819
|
+
handleOnFinish();
|
|
3820
|
+
}
|
|
3821
|
+
}, [timeLeft]);
|
|
3808
3822
|
const resetTimer = () => {
|
|
3809
|
-
setTimeLeft(
|
|
3810
|
-
setIsTimerRunning(
|
|
3823
|
+
setTimeLeft(initialTime);
|
|
3824
|
+
setIsTimerRunning(enabled);
|
|
3811
3825
|
};
|
|
3812
3826
|
return {
|
|
3813
3827
|
timeLeft,
|
|
@@ -19197,6 +19211,7 @@ AirbnbSearchInput.displayName = "AirbnbSearchInput";
|
|
|
19197
19211
|
useClickEscape,
|
|
19198
19212
|
useCombinedRef,
|
|
19199
19213
|
useCopyToClipboard,
|
|
19214
|
+
useCountdown,
|
|
19200
19215
|
useDebounce,
|
|
19201
19216
|
useDebouncedFunction,
|
|
19202
19217
|
useEvent,
|
|
@@ -19229,7 +19244,6 @@ AirbnbSearchInput.displayName = "AirbnbSearchInput";
|
|
|
19229
19244
|
useTimeline,
|
|
19230
19245
|
useTimeout,
|
|
19231
19246
|
useTimeoutRef,
|
|
19232
|
-
useTimer,
|
|
19233
19247
|
useUpdateToast,
|
|
19234
19248
|
useValidateDates
|
|
19235
19249
|
});
|