229 lines
6.5 KiB
JavaScript
229 lines
6.5 KiB
JavaScript
/*
|
|
* Extracted from browser-delivered Turbopack chunk: 836d2aeda096d319.fb0a464622.js
|
|
* Module id: 777784
|
|
* For reading/searching only; this factory depends on the original Turbopack runtime.
|
|
*/
|
|
|
|
const moduleFactory = (t) => {
|
|
"use strict";
|
|
var e = t.i(462214),
|
|
i = t.i(358379),
|
|
n = t.i(610582),
|
|
o = t.i(955595),
|
|
r = t.i(532527),
|
|
s = t.i(41671),
|
|
a = t.i(791997);
|
|
let l = {
|
|
success: {
|
|
bg: "rgba(78, 199, 64, 0.6)",
|
|
border: "#4a9c3e",
|
|
fg: "white",
|
|
},
|
|
warn: { bg: "rgba(255, 125, 0, 0.6)", border: "#b86a10", fg: "white" },
|
|
error: { bg: "rgba(245, 63, 63, 0.6)", border: "#b84040", fg: "white" },
|
|
info: { bg: "rgba(20, 125, 255, 0.6)", border: "#2a6ebf", fg: "white" },
|
|
message: {
|
|
bg: "rgba(31, 31, 31, 0.9)",
|
|
border: "#363636",
|
|
fg: "white",
|
|
},
|
|
},
|
|
c = {
|
|
success: {
|
|
bg: "rgba(78, 199, 64, 0.6)",
|
|
border: "#7ccc72",
|
|
fg: "white",
|
|
},
|
|
warn: { bg: "rgba(255, 125, 0, 0.6)", border: "#e0944a", fg: "white" },
|
|
error: { bg: "rgba(245, 63, 63, 0.6)", border: "#e07070", fg: "white" },
|
|
info: { bg: "rgba(20, 125, 255, 0.6)", border: "#6aa8e8", fg: "white" },
|
|
message: {
|
|
bg: "rgba(255, 255, 255, 0.95)",
|
|
border: "#E3E3E3",
|
|
fg: "#262626",
|
|
},
|
|
},
|
|
u = null,
|
|
h = 0;
|
|
function d() {
|
|
let [t, r] = (0, i.useState)([]),
|
|
[s, a] = (0, i.useState)(null),
|
|
[l, c] = (0, i.useState)(!1),
|
|
d = (0, i.useRef)([]),
|
|
p = (0, i.useRef)();
|
|
(0, i.useEffect)(
|
|
() => (
|
|
(u = (t, e) => {
|
|
let i = { id: String(++h), type: t, message: e };
|
|
(d.current = [...d.current, i]), r([...d.current]);
|
|
}),
|
|
() => {
|
|
u = null;
|
|
}
|
|
),
|
|
[],
|
|
);
|
|
let f = (0, i.useCallback)(() => {
|
|
d.current.length > 0 ? a(d.current[0]) : a(null);
|
|
}, []),
|
|
g = (0, i.useCallback)(() => {
|
|
s &&
|
|
(clearTimeout(p.current),
|
|
(d.current = d.current.filter((t) => t.id !== s.id)),
|
|
r([...d.current]),
|
|
c(!0),
|
|
a(null));
|
|
}, [s]);
|
|
(0, i.useEffect)(() => {
|
|
s || l || !(d.current.length > 0) || f();
|
|
}, [t, s, l, f]),
|
|
(0, i.useEffect)(() => {
|
|
if (!s) return;
|
|
let t = d.current.findIndex((t) => t.id === s.id);
|
|
return (
|
|
(p.current = setTimeout(
|
|
g,
|
|
t >= 0 && t < d.current.length - 1 ? 1e3 : 3e3,
|
|
)),
|
|
() => clearTimeout(p.current)
|
|
);
|
|
}, [s, t, g]);
|
|
let v = (0, i.useCallback)(() => {
|
|
c(!1), d.current.length > 0 && a(d.current[0]);
|
|
}, []);
|
|
return (0, e.jsx)(n.Portal, {
|
|
children: (0, e.jsx)("div", {
|
|
style: {
|
|
position: "fixed",
|
|
top: 32,
|
|
left: "50%",
|
|
transform: "translateX(-50%)",
|
|
zIndex: "calc(var(--z-toast) + 10)",
|
|
pointerEvents: "none",
|
|
},
|
|
children: (0, e.jsx)(o.AnimatePresence, {
|
|
mode: "wait",
|
|
onExitComplete: v,
|
|
children: s && (0, e.jsx)(m, { item: s, onClose: g }, s.id),
|
|
}),
|
|
}),
|
|
});
|
|
}
|
|
let p = {
|
|
success: s.Icons.circleCheck,
|
|
warn: s.Icons.circleAlert,
|
|
error: s.Icons.circleAlert,
|
|
info: s.Icons.InfoL,
|
|
message: s.Icons.InfoL,
|
|
};
|
|
function m({ item: t, onClose: i }) {
|
|
let n = ((0, a.useCanvasThemeStore)((t) => "light" === t.theme) ? c : l)[
|
|
t.type
|
|
],
|
|
o = p[t.type];
|
|
return (0, e.jsxs)(r.motion.div, {
|
|
initial: { y: 20, opacity: 0 },
|
|
animate: { y: 0, opacity: 1 },
|
|
exit: { y: -20, opacity: 0 },
|
|
transition: { duration: 0.25, ease: "easeInOut" },
|
|
style: {
|
|
display: "flex",
|
|
alignItems: "flex-start",
|
|
gap: 12,
|
|
minHeight: 40,
|
|
paddingLeft: 16,
|
|
paddingRight: 10,
|
|
paddingTop: 8,
|
|
paddingBottom: 8,
|
|
borderRadius: 12,
|
|
border: `1px solid ${n.border}`,
|
|
backgroundColor: n.bg,
|
|
backdropFilter: "blur(16px)",
|
|
WebkitBackdropFilter: "blur(16px)",
|
|
boxShadow:
|
|
"0px 4px 10px rgba(0,0,0,0.12), 0px 2px 4px rgba(0,0,0,0.2)",
|
|
pointerEvents: "auto",
|
|
isolation: "isolate",
|
|
},
|
|
children: [
|
|
(0, e.jsx)(o, {
|
|
width: 18,
|
|
height: 18,
|
|
color: n.fg,
|
|
style: { flexShrink: 0, marginTop: 2 },
|
|
}),
|
|
(0, e.jsx)("span", {
|
|
style: {
|
|
fontSize: 14,
|
|
lineHeight: 1.6,
|
|
color: n.fg,
|
|
maxWidth: "70vw",
|
|
wordBreak: "break-word",
|
|
fontFamily:
|
|
"'PingFang SC', -apple-system, BlinkMacSystemFont, sans-serif",
|
|
},
|
|
children: t.message,
|
|
}),
|
|
(0, e.jsx)("button", {
|
|
type: "button",
|
|
onClick: i,
|
|
"aria-label": "关闭通知",
|
|
style: {
|
|
display: "flex",
|
|
alignItems: "center",
|
|
justifyContent: "center",
|
|
width: 20,
|
|
height: 20,
|
|
padding: 0,
|
|
border: "none",
|
|
background: "transparent",
|
|
cursor: "pointer",
|
|
borderRadius: 4,
|
|
color:
|
|
"white" === n.fg
|
|
? "rgba(255, 255, 255, 0.7)"
|
|
: "rgba(0, 0, 0, 0.4)",
|
|
flexShrink: 0,
|
|
transition: "color 0.15s",
|
|
},
|
|
onMouseEnter: (t) => {
|
|
t.currentTarget.style.color = n.fg;
|
|
},
|
|
onMouseLeave: (t) => {
|
|
t.currentTarget.style.color =
|
|
"white" === n.fg
|
|
? "rgba(255, 255, 255, 0.7)"
|
|
: "rgba(0, 0, 0, 0.4)";
|
|
},
|
|
children: (0, e.jsx)(s.Icons.x, { width: 14, height: 14 }),
|
|
}),
|
|
],
|
|
});
|
|
}
|
|
t.s([
|
|
"Notify",
|
|
0,
|
|
{
|
|
success(t) {
|
|
u?.("success", t);
|
|
},
|
|
error(t) {
|
|
u?.("error", t);
|
|
},
|
|
warn(t) {
|
|
u?.("warn", t);
|
|
},
|
|
info(t) {
|
|
u?.("info", t);
|
|
},
|
|
message(t) {
|
|
u?.("message", t);
|
|
},
|
|
},
|
|
"NotifyContainer",
|
|
() => d,
|
|
]);
|
|
};
|
|
|
|
export default moduleFactory;
|