raku-toast-react 1.0.8 → 1.0.10
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/ToastProvider.d.ts.map +1 -1
- package/dist/ToastProvider.js +10 -3
- package/dist/toast-store.d.ts +1 -0
- package/dist/toast-store.d.ts.map +1 -1
- package/dist/toast-store.js +34 -12
- package/dist/toast.css +8 -3
- package/package.json +10 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToastProvider.d.ts","sourceRoot":"","sources":["../src/ToastProvider.tsx"],"names":[],"mappings":"AAKA,OAAO,aAAa,CAAC;AAErB,eAAO,MAAM,aAAa,+
|
|
1
|
+
{"version":3,"file":"ToastProvider.d.ts","sourceRoot":"","sources":["../src/ToastProvider.tsx"],"names":[],"mappings":"AAKA,OAAO,aAAa,CAAC;AAErB,eAAO,MAAM,aAAa,+CAwFzB,CAAC"}
|
package/dist/ToastProvider.js
CHANGED
|
@@ -12,7 +12,7 @@ export const ToastProvider = () => {
|
|
|
12
12
|
error: _jsx(XCircle, { size: 22, className: "text-white" }),
|
|
13
13
|
info: _jsx(Info, { size: 22, className: "text-white" }),
|
|
14
14
|
};
|
|
15
|
-
return (_jsx("div", { className: "fixed top-1/2
|
|
15
|
+
return (_jsx("div", { className: "fixed top-1/2 right-4 z-50 w-60 sm:w-72 pointer-events-none", children: _jsx("div", { className: "relative h-[600px]", children: toasts.map((t, index) => {
|
|
16
16
|
const offset = index * 78;
|
|
17
17
|
const scale = 1 - index * 0.03;
|
|
18
18
|
const opacity = 1 - index * 0.12;
|
|
@@ -25,7 +25,14 @@ export const ToastProvider = () => {
|
|
|
25
25
|
}, className: "toast-item absolute top-0 right-0 w-full flex items-start gap-3 sm:gap-4 px-4 py-3 sm:px-5 sm:py-4 rounded-2xl sm:rounded-lg shadow-2xl backdrop-blur-lg hover:scale-[1.02]", onMouseEnter: () => toastStore.pause(t.id), onMouseLeave: () => toastStore.resume(t.id), children: [_jsx("div", { className: `absolute inset-0 rounded-2xl sm:rounded-lg opacity-90 blur-sm shadow-lg ${t.type === "success"
|
|
26
26
|
? "bg-gradient-to-r from-purple-500 to-indigo-500"
|
|
27
27
|
: t.type === "error"
|
|
28
|
-
? "bg-gradient-to-r from-pink-500 to-
|
|
29
|
-
: "bg-gradient-to-r from-indigo-500 to-purple-600"}` }), _jsxs("div", { className: "relative flex w-full gap-3 sm:gap-4", children: [_jsx("div", { className: "mt-1", children: icons[t.type] }), _jsxs("div", { className: "flex-1", children: [_jsx("p", { className: "text-sm sm:text-base font-bold text-white drop-shadow-md", children: t.type.toUpperCase() }), _jsx("p", { className: "text-xs sm:text-sm text-white/90 leading-snug drop-shadow", children: t.message })
|
|
28
|
+
? "bg-gradient-to-r from-pink-500 to-rose-500"
|
|
29
|
+
: "bg-gradient-to-r from-indigo-500 to-purple-600"}` }), _jsxs("div", { className: "relative flex w-full gap-3 sm:gap-4", children: [_jsx("div", { className: "mt-1", children: icons[t.type] }), _jsxs("div", { className: "flex-1", children: [_jsx("p", { className: "text-sm sm:text-base font-bold text-white drop-shadow-md", children: t.type.toUpperCase() }), _jsx("p", { className: "text-xs sm:text-sm text-white/90 leading-snug drop-shadow", children: t.message }), _jsx("div", { className: "mt-2 sm:mt-3 h-1 sm:h-2 w-full rounded-full bg-white/20 overflow-hidden", children: _jsx("div", { className: `toast-progress ${t.type === "success"
|
|
30
|
+
? "toast-success"
|
|
31
|
+
: t.type === "error"
|
|
32
|
+
? "toast-error"
|
|
33
|
+
: "toast-info"} ${t._animate ? "animate-progress" : ""}`, style: {
|
|
34
|
+
animationDuration: `${t._remaining ?? t.duration ?? 3000}ms`,
|
|
35
|
+
animationPlayState: t._paused ? "paused" : "running",
|
|
36
|
+
} }) })] }), _jsx("button", { onClick: () => toastStore.remove(t.id), className: "text-white transition p-1 sm:p-2 rounded-lg hover:bg-white/20 cursor-pointer", children: _jsx(X, { size: 18, className: "sm:text-[20px]" }) })] })] }, t.id));
|
|
30
37
|
}) }) }));
|
|
31
38
|
};
|
package/dist/toast-store.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toast-store.d.ts","sourceRoot":"","sources":["../src/toast-store.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,CAAC;AAErD,MAAM,WAAW,KAAK;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,SAAS,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"toast-store.d.ts","sourceRoot":"","sources":["../src/toast-store.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,CAAC;AAErD,MAAM,WAAW,KAAK;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,SAAS,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAMD,eAAO,MAAM,UAAU;kBACP,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,IAAI;kBAQzB,MAAM,SAAQ,SAAS,aAAqB,MAAM;oBA8BhD,MAAM;mBASP,MAAM;oBAyBL,MAAM;CAsBvB,CAAC"}
|
package/dist/toast-store.js
CHANGED
|
@@ -10,29 +10,34 @@ export const toastStore = {
|
|
|
10
10
|
};
|
|
11
11
|
},
|
|
12
12
|
push(message, type = "info", duration = 3000) {
|
|
13
|
-
const
|
|
13
|
+
const newToast = {
|
|
14
14
|
id: ++id,
|
|
15
15
|
message,
|
|
16
16
|
type,
|
|
17
17
|
duration,
|
|
18
18
|
_remaining: duration,
|
|
19
19
|
_animate: false, // start false
|
|
20
|
+
_paused: false,
|
|
20
21
|
};
|
|
21
|
-
|
|
22
|
+
// Add toast immutably
|
|
23
|
+
toasts = [newToast, ...toasts];
|
|
22
24
|
listeners.forEach((l) => l(toasts));
|
|
23
|
-
// Trigger
|
|
25
|
+
// Trigger animation on next tick
|
|
24
26
|
requestAnimationFrame(() => {
|
|
25
|
-
|
|
27
|
+
toasts = toasts.map((t) => t.id === newToast.id ? { ...t, _animate: true } : t);
|
|
26
28
|
listeners.forEach((l) => l(toasts));
|
|
27
29
|
});
|
|
28
30
|
// Start auto-remove timer
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
newToast._startTime = Date.now();
|
|
32
|
+
newToast._timeout = window.setTimeout(() => {
|
|
33
|
+
toastStore.remove(newToast.id);
|
|
34
|
+
}, duration);
|
|
31
35
|
},
|
|
32
36
|
remove(toastId) {
|
|
33
37
|
const toast = toasts.find((t) => t.id === toastId);
|
|
34
38
|
if (toast?._timeout)
|
|
35
39
|
clearTimeout(toast._timeout);
|
|
40
|
+
// Remove immutably
|
|
36
41
|
toasts = toasts.filter((t) => t.id !== toastId);
|
|
37
42
|
listeners.forEach((l) => l(toasts));
|
|
38
43
|
},
|
|
@@ -41,18 +46,35 @@ export const toastStore = {
|
|
|
41
46
|
if (!toast || !toast._timeout)
|
|
42
47
|
return;
|
|
43
48
|
clearTimeout(toast._timeout);
|
|
44
|
-
toast.
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
49
|
+
const remaining = (toast._remaining ?? toast.duration ?? 3000) -
|
|
50
|
+
(Date.now() - (toast._startTime ?? 0));
|
|
51
|
+
// Update immutably
|
|
52
|
+
toasts = toasts.map((t) => t.id === toastId
|
|
53
|
+
? {
|
|
54
|
+
...t,
|
|
55
|
+
_paused: true,
|
|
56
|
+
_timeout: undefined,
|
|
57
|
+
_remaining: remaining,
|
|
58
|
+
}
|
|
59
|
+
: t);
|
|
48
60
|
listeners.forEach((l) => l(toasts));
|
|
49
61
|
},
|
|
50
62
|
resume(toastId) {
|
|
51
63
|
const toast = toasts.find((t) => t.id === toastId);
|
|
52
64
|
if (!toast || toast._timeout)
|
|
53
65
|
return;
|
|
54
|
-
|
|
55
|
-
|
|
66
|
+
const timeout = window.setTimeout(() => {
|
|
67
|
+
toastStore.remove(toastId);
|
|
68
|
+
}, toast._remaining ?? 3000);
|
|
69
|
+
// Update immutably
|
|
70
|
+
toasts = toasts.map((t) => t.id === toastId
|
|
71
|
+
? {
|
|
72
|
+
...t,
|
|
73
|
+
_paused: false,
|
|
74
|
+
_startTime: Date.now(),
|
|
75
|
+
_timeout: timeout,
|
|
76
|
+
}
|
|
77
|
+
: t);
|
|
56
78
|
listeners.forEach((l) => l(toasts));
|
|
57
79
|
},
|
|
58
80
|
};
|
package/dist/toast.css
CHANGED
|
@@ -17,6 +17,11 @@
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
/* Colors */
|
|
20
|
-
.toast-success { background-color: #
|
|
21
|
-
.toast-error { background-color: #
|
|
22
|
-
.toast-info { background-color: #
|
|
20
|
+
/* .toast-success { background-color: #9a34ff !important; }
|
|
21
|
+
.toast-error { background-color: #ff4ae7 !important; }
|
|
22
|
+
.toast-info { background-color: #3145ff !important; } */
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
.toast-success { background-color: #ffffffec !important; }
|
|
26
|
+
.toast-error { background-color: #ffffffec !important; }
|
|
27
|
+
.toast-info { background-color: #ffffffec !important; }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "raku-toast-react",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
4
4
|
"description": "A lightweight React toast library with gradient and animation",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -13,16 +13,16 @@
|
|
|
13
13
|
"postbuild": "cp src/toast.css dist/toast.css"
|
|
14
14
|
},
|
|
15
15
|
"peerDependencies": {
|
|
16
|
-
"react": "^
|
|
17
|
-
"react-dom": "^
|
|
18
|
-
"lucide-react": "
|
|
16
|
+
"react": "^19.2.1",
|
|
17
|
+
"react-dom": "^19.2.1",
|
|
18
|
+
"lucide-react": "^0.544.0"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@types/react": "^
|
|
22
|
-
"@types/react-dom": "^
|
|
23
|
-
"lucide-react": "^0.
|
|
24
|
-
"react": "^
|
|
25
|
-
"react-dom": "^
|
|
26
|
-
"typescript": "^5.
|
|
21
|
+
"@types/react": "^19.2.1",
|
|
22
|
+
"@types/react-dom": "^19.2.1",
|
|
23
|
+
"lucide-react": "^0.544.0",
|
|
24
|
+
"react": "^19.2.1",
|
|
25
|
+
"react-dom": "^19.2.1",
|
|
26
|
+
"typescript": "^5.9.3"
|
|
27
27
|
}
|
|
28
28
|
}
|