@underverse-ui/underverse 0.2.30 → 0.2.32
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 +51 -38
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +51 -38
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2531,11 +2531,6 @@ var ToastProvider = ({ children, position = "top-right", maxToasts = 5 }) => {
|
|
|
2531
2531
|
const updated = [newToast, ...prev];
|
|
2532
2532
|
return updated.slice(0, maxToasts);
|
|
2533
2533
|
});
|
|
2534
|
-
if (toast.duration !== 0) {
|
|
2535
|
-
setTimeout(() => {
|
|
2536
|
-
removeToast(id);
|
|
2537
|
-
}, toast.duration || 5e3);
|
|
2538
|
-
}
|
|
2539
2534
|
},
|
|
2540
2535
|
[maxToasts, removeToast]
|
|
2541
2536
|
);
|
|
@@ -2556,53 +2551,59 @@ var ToastComponent = ({ toast, onRemove }) => {
|
|
|
2556
2551
|
const [isVisible, setIsVisible] = useState9(false);
|
|
2557
2552
|
const [progress, setProgress] = useState9(100);
|
|
2558
2553
|
const [paused, setPaused] = useState9(false);
|
|
2559
|
-
const [startTs] = useState9(() => Date.now());
|
|
2560
2554
|
const total = toast.duration && toast.duration > 0 ? toast.duration : 5e3;
|
|
2561
|
-
const
|
|
2555
|
+
const endTsRef = useRef4(Date.now() + total);
|
|
2556
|
+
const remainingRef = useRef4(total);
|
|
2557
|
+
const pausedRef = useRef4(false);
|
|
2558
|
+
const handleRemove = useCallback2(() => {
|
|
2559
|
+
setIsVisible(false);
|
|
2560
|
+
setTimeout(() => onRemove(toast.id), 150);
|
|
2561
|
+
}, [onRemove, toast.id]);
|
|
2562
2562
|
useEffect2(() => {
|
|
2563
2563
|
setIsVisible(true);
|
|
2564
2564
|
if (toast.duration === 0) return;
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
const remain = Math.max(
|
|
2570
|
-
|
|
2565
|
+
remainingRef.current = total;
|
|
2566
|
+
endTsRef.current = Date.now() + total;
|
|
2567
|
+
const intervalId = window.setInterval(() => {
|
|
2568
|
+
if (!pausedRef.current) {
|
|
2569
|
+
const remain = Math.max(endTsRef.current - Date.now(), 0);
|
|
2570
|
+
remainingRef.current = remain;
|
|
2571
2571
|
setProgress(remain / total * 100);
|
|
2572
2572
|
if (remain === 0) {
|
|
2573
2573
|
handleRemove();
|
|
2574
|
-
return;
|
|
2575
2574
|
}
|
|
2576
2575
|
}
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
return () => cancelAnimationFrame(raf);
|
|
2581
|
-
}, []);
|
|
2582
|
-
const handleRemove = () => {
|
|
2583
|
-
setIsVisible(false);
|
|
2584
|
-
setTimeout(() => onRemove(toast.id), 150);
|
|
2585
|
-
};
|
|
2576
|
+
}, 50);
|
|
2577
|
+
return () => window.clearInterval(intervalId);
|
|
2578
|
+
}, [handleRemove, toast.duration, total]);
|
|
2586
2579
|
const typeConfig = {
|
|
2587
2580
|
success: {
|
|
2588
2581
|
icon: CheckCircle2,
|
|
2589
|
-
|
|
2590
|
-
iconClassName: "text-success"
|
|
2582
|
+
containerClassName: "bg-success/5 border-success/30",
|
|
2583
|
+
iconClassName: "text-success",
|
|
2584
|
+
iconBgClassName: "bg-success/15",
|
|
2585
|
+
accentBarClassName: "bg-success"
|
|
2591
2586
|
},
|
|
2592
2587
|
error: {
|
|
2593
2588
|
icon: AlertCircle2,
|
|
2594
|
-
|
|
2595
|
-
iconClassName: "text-destructive"
|
|
2589
|
+
containerClassName: "bg-destructive/5 border-destructive/30",
|
|
2590
|
+
iconClassName: "text-destructive",
|
|
2591
|
+
iconBgClassName: "bg-destructive/15",
|
|
2592
|
+
accentBarClassName: "bg-destructive"
|
|
2596
2593
|
},
|
|
2597
2594
|
warning: {
|
|
2598
2595
|
icon: AlertTriangle2,
|
|
2599
|
-
|
|
2600
|
-
iconClassName: "text-warning"
|
|
2596
|
+
containerClassName: "bg-warning/5 border-warning/30",
|
|
2597
|
+
iconClassName: "text-warning",
|
|
2598
|
+
iconBgClassName: "bg-warning/15",
|
|
2599
|
+
accentBarClassName: "bg-warning"
|
|
2601
2600
|
},
|
|
2602
2601
|
info: {
|
|
2603
2602
|
icon: Info,
|
|
2604
|
-
|
|
2605
|
-
iconClassName: "text-info"
|
|
2603
|
+
containerClassName: "bg-info/5 border-info/30",
|
|
2604
|
+
iconClassName: "text-info",
|
|
2605
|
+
iconBgClassName: "bg-info/15",
|
|
2606
|
+
accentBarClassName: "bg-info"
|
|
2606
2607
|
}
|
|
2607
2608
|
};
|
|
2608
2609
|
const config = typeConfig[toast.type];
|
|
@@ -2611,18 +2612,30 @@ var ToastComponent = ({ toast, onRemove }) => {
|
|
|
2611
2612
|
"div",
|
|
2612
2613
|
{
|
|
2613
2614
|
className: cn(
|
|
2614
|
-
"relative w-80 rounded-lg border backdrop-blur-
|
|
2615
|
-
"bg-card
|
|
2616
|
-
|
|
2615
|
+
"relative w-80 rounded-r-lg border border-l-0 backdrop-blur-md transition-all duration-300 pointer-events-auto overflow-hidden",
|
|
2616
|
+
"bg-card shadow-xl",
|
|
2617
|
+
"animate-in slide-in-from-right-full",
|
|
2618
|
+
config.containerClassName,
|
|
2617
2619
|
isVisible ? "opacity-100 translate-x-0" : "opacity-0 translate-x-full"
|
|
2618
2620
|
),
|
|
2619
2621
|
role: "status",
|
|
2620
2622
|
"aria-live": toast.type === "error" ? "assertive" : "polite",
|
|
2621
|
-
onMouseEnter: () =>
|
|
2622
|
-
|
|
2623
|
+
onMouseEnter: () => {
|
|
2624
|
+
if (toast.duration === 0) return;
|
|
2625
|
+
pausedRef.current = true;
|
|
2626
|
+
remainingRef.current = Math.max(endTsRef.current - Date.now(), 0);
|
|
2627
|
+
setPaused(true);
|
|
2628
|
+
},
|
|
2629
|
+
onMouseLeave: () => {
|
|
2630
|
+
if (toast.duration === 0) return;
|
|
2631
|
+
pausedRef.current = false;
|
|
2632
|
+
endTsRef.current = Date.now() + remainingRef.current;
|
|
2633
|
+
setPaused(false);
|
|
2634
|
+
},
|
|
2623
2635
|
children: [
|
|
2624
|
-
/* @__PURE__ */
|
|
2625
|
-
|
|
2636
|
+
/* @__PURE__ */ jsx15("div", { className: cn("absolute left-0 top-0 bottom-0 w-1", config.accentBarClassName) }),
|
|
2637
|
+
/* @__PURE__ */ jsxs13("div", { className: "flex items-start gap-3 p-4 pl-5", children: [
|
|
2638
|
+
/* @__PURE__ */ jsx15("div", { className: cn("flex items-center justify-center w-8 h-8 rounded-full shrink-0", config.iconBgClassName), children: /* @__PURE__ */ jsx15(Icon, { className: cn("h-4 w-4", config.iconClassName) }) }),
|
|
2626
2639
|
/* @__PURE__ */ jsxs13("div", { className: "flex-1 space-y-1", children: [
|
|
2627
2640
|
toast.title && /* @__PURE__ */ jsx15("h4", { className: "font-medium text-sm leading-none", children: toast.title }),
|
|
2628
2641
|
/* @__PURE__ */ jsx15("p", { className: "text-sm text-muted-foreground leading-relaxed", children: toast.message }),
|