@hkyhy/marsun-components-core 0.1.128 → 0.1.129

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.
@@ -1,323 +1,345 @@
1
- import { jsxs as m, jsx as a } from "react/jsx-runtime";
2
- import { notification as pe, Button as F, Badge as Re, Drawer as Pe, Space as ye, Checkbox as ee, message as ge } from "antd";
3
- import k from "classnames";
4
- import { forwardRef as De, useState as p, useRef as v, useMemo as he, useCallback as x, useImperativeHandle as Me, useEffect as T } from "react";
5
- import { sanitizeInboxHtml as _e } from "../sanitizeInboxHtml.js";
6
- import { INBOX_BADGE_REFRESH_EVENT as ve } from "../requestInboxBadgeRefresh.js";
7
- import { emphasizeQuoted as U } from "./emphasizeQuoted.js";
8
- import { filterInboxActionsForHost as Ae, resolveInboxItemActions as Ie, isInboxButtonDriven as Oe } from "./inboxItemActions.js";
9
- import { inboxSceneLabel as wt, isTerminalActionStatus as Nt, normalizeInboxActions as Et, resolveInboxSceneKey as St } from "./inboxItemActions.js";
10
- import { loadInboxToastPrefs as He, shouldToastForMessageType as Fe, saveInboxToastPrefs as Ue } from "./toastPrefs.js";
11
- import { DEFAULT_INBOX_TOAST_PREFS as Bt } from "./toastPrefs.js";
1
+ import { jsxs as m, jsx as o } from "react/jsx-runtime";
2
+ import { notification as Me, Badge as Oe, Button as z, Drawer as Ie, Space as Te, Checkbox as ne, message as be } from "antd";
3
+ import P from "classnames";
4
+ import { forwardRef as He, useState as y, useRef as h, useMemo as we, useCallback as N, useImperativeHandle as Fe, useEffect as T } from "react";
5
+ import { createPortal as Ue } from "react-dom";
6
+ import { sanitizeInboxHtml as ze } from "../sanitizeInboxHtml.js";
7
+ import { INBOX_BADGE_REFRESH_EVENT as Ne } from "../requestInboxBadgeRefresh.js";
8
+ import { emphasizeQuoted as re } from "./emphasizeQuoted.js";
9
+ import { filterInboxActionsForHost as Ge, resolveInboxItemActions as Ke, isInboxButtonDriven as $e } from "./inboxItemActions.js";
10
+ import { inboxSceneLabel as Pt, isTerminalActionStatus as Rt, normalizeInboxActions as _t, resolveInboxSceneKey as At } from "./inboxItemActions.js";
11
+ import { loadInboxToastPrefs as je, shouldToastForMessageType as Ve, saveInboxToastPrefs as We } from "./toastPrefs.js";
12
+ import { DEFAULT_INBOX_TOAST_PREFS as Mt } from "./toastPrefs.js";
12
13
  import r from "./style.module.scss.js";
13
- import z, { SEMANTIC_COLORS as D } from "../../../Tag/SemanticTag.js";
14
- import { Bell as ze } from "../../../Icons/Bell.js";
15
- import Ge from "../../../StateBar/StateBar.js";
16
- import Ke from "../../../SegmentedRadio/SegmentedRadio.js";
17
- import $e from "../../../Layout/PageSpin/index.js";
18
- import je from "../../../Empty/Empty.js";
19
- import Ve from "../../../VirtualScrollbar/VirtualScrollbar/index.js";
20
- const We = [
14
+ import { Bell as Qe } from "../../../Icons/Bell.js";
15
+ import oe, { SEMANTIC_COLORS as D } from "../../../Tag/SemanticTag.js";
16
+ import Xe from "../../../StateBar/StateBar.js";
17
+ import Ye from "../../../SegmentedRadio/SegmentedRadio.js";
18
+ import Je from "../../../Layout/PageSpin/index.js";
19
+ import qe from "../../../Empty/Empty.js";
20
+ import Ze from "../../../VirtualScrollbar/VirtualScrollbar/index.js";
21
+ const et = 6e3, tt = [
21
22
  { key: "", label: "全部" },
22
23
  { key: "alert", label: "预警" },
23
24
  { key: "action", label: "行动" },
24
25
  { key: "remind", label: "提醒" }
25
- ], Qe = {
26
+ ], nt = {
26
27
  alert: "预警",
27
28
  action: "行动",
28
29
  remind: "提醒"
29
- }, Xe = 300, Ye = 1500, Je = 72;
30
- function Te(u) {
31
- const s = String(u || "").trim().toLowerCase();
32
- return s ? Qe[s] || s : "";
30
+ }, rt = 300, ot = 1500, at = 72;
31
+ function Ee(d) {
32
+ const a = String(d || "").trim().toLowerCase();
33
+ return a ? nt[a] || a : "";
33
34
  }
34
- function te(u) {
35
- const s = String(u || "").trim().toLowerCase();
36
- return s === "alert" ? D.DANGER : s === "action" ? D.PRIMARY : s === "remind" ? D.WARNING : D.DEFAULT;
35
+ function Se(d) {
36
+ const a = String(d || "").trim().toLowerCase();
37
+ return a === "alert" ? D.DANGER : a === "action" ? D.PRIMARY : a === "remind" ? D.WARNING : D.DEFAULT;
37
38
  }
38
- function qe(u) {
39
- return [u.factory, u.variety, u.metric].map((s) => String(s || "").trim()).filter(Boolean).join(" · ");
39
+ function lt(d) {
40
+ return [d.factory, d.variety, d.metric].map((a) => String(a || "").trim()).filter(Boolean).join(" · ");
40
41
  }
41
- function Ze(u) {
42
- return String(u || "").trim() || D.DEFAULT;
42
+ function st(d) {
43
+ return String(d || "").trim() || D.DEFAULT;
43
44
  }
44
- function et(u) {
45
+ function it(d) {
45
46
  try {
46
- const s = JSON.parse(u);
47
- if (!s || typeof s != "object") return null;
48
- const M = String(s.messageType || s.message_type || "").trim(), C = String(s.title || "").trim(), S = String(s.summary || "").trim();
49
- return !M && !C && !S ? null : {
47
+ const a = JSON.parse(d);
48
+ if (!a || typeof a != "object") return null;
49
+ const M = String(a.messageType || a.message_type || "").trim(), R = String(a.title || "").trim(), B = String(a.summary || "").trim();
50
+ return !M && !R && !B ? null : {
50
51
  messageType: M || void 0,
51
- title: C || void 0,
52
- summary: S || void 0
52
+ title: R || void 0,
53
+ summary: B || void 0
53
54
  };
54
55
  } catch {
55
56
  return null;
56
57
  }
57
58
  }
58
- const vt = De(function({
59
- fetchInbox: s,
59
+ const Bt = He(function({
60
+ fetchInbox: a,
60
61
  markRead: M,
61
- onNavigate: C,
62
- pollMs: S = 0,
63
- locationKey: ne,
64
- pageSize: b = 20,
65
- className: be,
66
- title: we = "站内信",
62
+ onNavigate: R,
63
+ pollMs: B = 0,
64
+ locationKey: ae,
65
+ pageSize: E = 20,
66
+ className: Le,
67
+ title: ke = "站内信",
67
68
  streamPath: G = "/api/v1/msg-center/inbox/stream",
68
69
  getAccessToken: K,
69
- onItemAction: re
70
- }, Ne) {
71
- const [$, L] = p(!1), [ae, oe] = p(!1), [j, se] = p(""), [_, A] = p([]), [R, I] = p(0), [le, V] = p({}), [W, Ee] = p(""), [O, Se] = p("all"), [P, Le] = p(() => He()), [Be, ie] = p(!1), w = v(null), N = v(null), Q = v(null), ce = v(!1), de = v(P);
72
- de.current = P;
73
- const X = v(1), Y = v(!1), B = v(!1), H = he(
70
+ onItemAction: le
71
+ }, Be) {
72
+ const [$, x] = y(!1), [se, ie] = y(!1), [j, ce] = y(""), [O, I] = y([]), [_, H] = y(0), [de, V] = y({}), [W, xe] = y(""), [F, Ce] = y("all"), [A, Pe] = y(() => je()), [Re, ue] = y(!1), [b, Q] = y(null), S = h(null), L = h(null), X = h(null), f = h(null), me = h(!1), fe = h(A);
73
+ fe.current = A;
74
+ const Y = h(1), J = h(!1), C = h(!1), U = we(
74
75
  () => ({
75
76
  messageType: W || void 0,
76
- unreadOnly: O === "unread" || void 0,
77
- readOnly: O === "read" || void 0
77
+ unreadOnly: F === "unread" || void 0,
78
+ readOnly: F === "read" || void 0
78
79
  }),
79
- [W, O]
80
- ), J = x(async () => {
81
- oe(!0), se(""), X.current = 1, B.current = !1;
80
+ [W, F]
81
+ ), q = N(async () => {
82
+ ie(!0), ce(""), Y.current = 1, C.current = !1;
82
83
  try {
83
- const e = await s({
84
+ const e = await a({
84
85
  currentPage: 1,
85
- pageSize: b,
86
- ...H
86
+ pageSize: E,
87
+ ...U
87
88
  }), t = (e == null ? void 0 : e.pageData) || [], n = typeof (e == null ? void 0 : e.total) == "number" ? e.total : t.length;
88
- A(t), B.current = t.length > 0 && t.length < n, I(typeof (e == null ? void 0 : e.unreadTotal) == "number" ? e.unreadTotal : 0), V((e == null ? void 0 : e.unreadByMessageType) || {});
89
+ I(t), C.current = t.length > 0 && t.length < n, H(typeof (e == null ? void 0 : e.unreadTotal) == "number" ? e.unreadTotal : 0), V((e == null ? void 0 : e.unreadByMessageType) || {});
89
90
  } catch (e) {
90
- A([]), B.current = !1, se(e instanceof Error ? e.message : String(e));
91
+ I([]), C.current = !1, ce(e instanceof Error ? e.message : String(e));
91
92
  } finally {
92
- oe(!1);
93
+ ie(!1);
93
94
  }
94
- }, [s, b, H]), ue = x(async () => {
95
- if (!(Y.current || !B.current)) {
96
- Y.current = !0, ie(!0);
95
+ }, [a, E, U]), pe = N(async () => {
96
+ if (!(J.current || !C.current)) {
97
+ J.current = !0, ue(!0);
97
98
  try {
98
- const e = X.current + 1, t = await s({
99
+ const e = Y.current + 1, t = await a({
99
100
  currentPage: e,
100
- pageSize: b,
101
- ...H
102
- }), n = (t == null ? void 0 : t.pageData) || [], o = typeof (t == null ? void 0 : t.total) == "number" ? t.total : 0;
103
- A((i) => {
104
- const l = new Set(i.map((f) => f.id)), c = n.filter((f) => (f == null ? void 0 : f.id) && !l.has(f.id)), g = c.length ? [...i, ...c] : i;
105
- return B.current = c.length > 0 && (o > 0 ? g.length < o : c.length >= b), g;
106
- }), n.length && (X.current = e), typeof (t == null ? void 0 : t.unreadTotal) == "number" && I(t.unreadTotal), t != null && t.unreadByMessageType && V(t.unreadByMessageType);
101
+ pageSize: E,
102
+ ...U
103
+ }), n = (t == null ? void 0 : t.pageData) || [], l = typeof (t == null ? void 0 : t.total) == "number" ? t.total : 0;
104
+ I((i) => {
105
+ const s = new Set(i.map((p) => p.id)), u = n.filter((p) => (p == null ? void 0 : p.id) && !s.has(p.id)), v = u.length ? [...i, ...u] : i;
106
+ return C.current = u.length > 0 && (l > 0 ? v.length < l : u.length >= E), v;
107
+ }), n.length && (Y.current = e), typeof (t == null ? void 0 : t.unreadTotal) == "number" && H(t.unreadTotal), t != null && t.unreadByMessageType && V(t.unreadByMessageType);
107
108
  } catch {
108
- B.current = !1;
109
+ C.current = !1;
109
110
  } finally {
110
- Y.current = !1, ie(!1);
111
+ J.current = !1, ue(!1);
111
112
  }
112
113
  }
113
- }, [s, b, H]), ke = x(
114
+ }, [a, E, U]), _e = N(
114
115
  (e) => {
115
116
  const t = e.currentTarget;
116
- t.scrollHeight - t.scrollTop - t.clientHeight <= Je && ue();
117
+ t.scrollHeight - t.scrollTop - t.clientHeight <= at && pe();
117
118
  },
118
- [ue]
119
- ), y = x(async () => {
119
+ [pe]
120
+ ), g = N(async () => {
120
121
  try {
121
- const e = await s({ currentPage: 1, pageSize: b });
122
- I(typeof (e == null ? void 0 : e.unreadTotal) == "number" ? e.unreadTotal : 0), V((e == null ? void 0 : e.unreadByMessageType) || {});
122
+ const e = await a({ currentPage: 1, pageSize: E });
123
+ H(typeof (e == null ? void 0 : e.unreadTotal) == "number" ? e.unreadTotal : 0), V((e == null ? void 0 : e.unreadByMessageType) || {});
123
124
  } catch {
124
125
  }
125
- }, [s, b]), me = x(() => {
126
- const e = Q.current;
127
- if (Q.current = null, !e || !Fe(de.current, e.messageType)) return;
128
- const t = e.title || "新站内信", n = e.summary || "", o = Te(e.messageType), i = () => {
129
- pe.destroy(), L(!0);
130
- }, l = `inbox-badge-${e.messageType || "msg"}-${Date.now()}`;
131
- pe.open({
132
- key: l,
133
- className: k("marsun-inbox-toast", r.toastNotice),
134
- closable: !0,
135
- title: /* @__PURE__ */ m("div", { className: r.toastHead, children: [
136
- /* @__PURE__ */ a("span", { className: r.toastTitle, children: U(t) }),
137
- o ? /* @__PURE__ */ a(
138
- z,
139
- {
140
- color: te(e.messageType),
141
- className: r.typeTag,
142
- children: o
143
- }
144
- ) : null
145
- ] }),
146
- message: /* @__PURE__ */ m("div", { className: r.toastHead, children: [
147
- /* @__PURE__ */ a("span", { className: r.toastTitle, children: U(t) }),
148
- o ? /* @__PURE__ */ a(
149
- z,
150
- {
151
- color: te(e.messageType),
152
- className: r.typeTag,
153
- children: o
154
- }
155
- ) : null
156
- ] }),
157
- description: /* @__PURE__ */ m("div", { className: r.toastBody, children: [
158
- n ? /* @__PURE__ */ a("div", { className: r.toastDesc, children: U(n) }) : null,
159
- /* @__PURE__ */ a("div", { className: r.toastActions, children: /* @__PURE__ */ a(
160
- F,
161
- {
162
- type: "primary",
163
- size: "small",
164
- onClick: (c) => {
165
- c.stopPropagation(), i();
166
- },
167
- children: "查看"
168
- }
169
- ) })
170
- ] }),
171
- placement: "topRight",
172
- duration: 6,
173
- onClick: i
174
- });
175
- }, []), h = x(
126
+ }, [a, E]), Z = N(() => {
127
+ f.current != null && (window.clearTimeout(f.current), f.current = null), Q(null);
128
+ }, []), ye = N(() => {
129
+ Z(), x(!0);
130
+ }, [Z]), ge = N(() => {
131
+ const e = X.current;
132
+ if (X.current = null, !e || !Ve(fe.current, e.messageType)) return;
133
+ f.current != null && (window.clearTimeout(f.current), f.current = null);
134
+ const t = `inbox-badge-${e.messageType || "msg"}-${Date.now()}`;
135
+ Q({
136
+ key: t,
137
+ title: e.title || "新站内信",
138
+ summary: e.summary || "",
139
+ messageType: e.messageType
140
+ }), f.current = window.setTimeout(() => {
141
+ f.current = null, Q(null);
142
+ }, et);
143
+ }, []), w = N(
176
144
  (e) => {
177
- e && (Q.current = e, me()), N.current != null && window.clearTimeout(N.current), N.current = window.setTimeout(() => {
178
- N.current = null, y();
179
- }, Ye);
145
+ e && (X.current = e, ge()), L.current != null && window.clearTimeout(L.current), L.current = window.setTimeout(() => {
146
+ L.current = null, g();
147
+ }, ot);
180
148
  },
181
- [y, me]
149
+ [g, ge]
182
150
  );
183
- Me(Ne, () => ({ refreshBadge: y }), [y]), T(() => {
184
- y();
185
- }, [y]), T(() => {
186
- if (ne !== void 0) {
187
- if (!ce.current) {
188
- ce.current = !0;
151
+ Fe(Be, () => ({ refreshBadge: g }), [g]), T(() => {
152
+ g();
153
+ }, [g]), T(() => {
154
+ if (ae !== void 0) {
155
+ if (!me.current) {
156
+ me.current = !0;
189
157
  return;
190
158
  }
191
- h();
159
+ w();
192
160
  }
193
- }, [ne, h]), T(() => {
194
- if (S <= 0) return;
161
+ }, [ae, w]), T(() => {
162
+ if (B <= 0) return;
195
163
  const e = window.setInterval(() => {
196
- y();
197
- }, S);
164
+ g();
165
+ }, B);
198
166
  return () => window.clearInterval(e);
199
- }, [S, y]), T(() => {
167
+ }, [B, g]), T(() => {
200
168
  const e = () => {
201
- w.current != null && window.clearTimeout(w.current), w.current = window.setTimeout(() => {
202
- w.current = null, h();
203
- }, Xe);
169
+ S.current != null && window.clearTimeout(S.current), S.current = window.setTimeout(() => {
170
+ S.current = null, w();
171
+ }, rt);
204
172
  }, t = () => {
205
173
  document.visibilityState === "visible" && e();
206
174
  };
207
175
  return window.addEventListener("focus", e), document.addEventListener("visibilitychange", t), () => {
208
- window.removeEventListener("focus", e), document.removeEventListener("visibilitychange", t), w.current != null && (window.clearTimeout(w.current), w.current = null);
176
+ window.removeEventListener("focus", e), document.removeEventListener("visibilitychange", t), S.current != null && (window.clearTimeout(S.current), S.current = null);
209
177
  };
210
- }, [h]), T(() => {
178
+ }, [w]), T(() => {
211
179
  const e = (t) => {
212
180
  const n = t.detail;
213
- h((n == null ? void 0 : n.preview) || void 0);
181
+ w((n == null ? void 0 : n.preview) || void 0);
214
182
  };
215
- return window.addEventListener(ve, e), () => window.removeEventListener(ve, e);
216
- }, [h]), T(() => () => {
217
- N.current != null && (window.clearTimeout(N.current), N.current = null);
183
+ return window.addEventListener(Ne, e), () => window.removeEventListener(Ne, e);
184
+ }, [w]), T(() => {
185
+ Me.destroy();
186
+ }, []), T(() => () => {
187
+ L.current != null && (window.clearTimeout(L.current), L.current = null), f.current != null && (window.clearTimeout(f.current), f.current = null);
218
188
  }, []), T(() => {
219
189
  if (G === !1 || typeof K != "function" || typeof window > "u" || typeof EventSource > "u") return;
220
190
  const e = String(G || "/api/v1/msg-center/inbox/stream").trim();
221
- let t = !1, n = null, o = null, i = 0;
222
- const l = (d) => {
223
- const E = d, Ce = typeof (E == null ? void 0 : E.data) == "string" ? et(E.data) : null;
224
- h(Ce);
225
- }, c = () => {
226
- o != null && (window.clearTimeout(o), o = null);
227
- }, g = () => {
228
- if (t || o != null) return;
229
- const d = Math.min(3e4, 1e3 * 2 ** Math.min(i, 5));
230
- i += 1, o = window.setTimeout(() => {
231
- o = null, f();
232
- }, d);
233
- }, f = () => {
191
+ let t = !1, n = null, l = null, i = 0;
192
+ const s = (c) => {
193
+ const k = c, De = typeof (k == null ? void 0 : k.data) == "string" ? it(k.data) : null;
194
+ w(De);
195
+ }, u = () => {
196
+ l != null && (window.clearTimeout(l), l = null);
197
+ }, v = () => {
198
+ if (t || l != null) return;
199
+ const c = Math.min(3e4, 1e3 * 2 ** Math.min(i, 5));
200
+ i += 1, l = window.setTimeout(() => {
201
+ l = null, p();
202
+ }, c);
203
+ }, p = () => {
234
204
  if (t) return;
235
- const d = String(K() || "").trim();
236
- if (!d) {
237
- g();
205
+ const c = String(K() || "").trim();
206
+ if (!c) {
207
+ v();
238
208
  return;
239
209
  }
240
- n && (n.removeEventListener("badge", l), n.removeEventListener("inbox", l), n.close(), n = null);
241
- const E = new URL(e, window.location.origin);
242
- E.searchParams.set("access_token", d);
210
+ n && (n.removeEventListener("badge", s), n.removeEventListener("inbox", s), n.close(), n = null);
211
+ const k = new URL(e, window.location.origin);
212
+ k.searchParams.set("access_token", c);
243
213
  try {
244
- n = new EventSource(E.toString());
214
+ n = new EventSource(k.toString());
245
215
  } catch {
246
- g();
216
+ v();
247
217
  return;
248
218
  }
249
- n.addEventListener("badge", l), n.addEventListener("inbox", l), n.onopen = () => {
219
+ n.addEventListener("badge", s), n.addEventListener("inbox", s), n.onopen = () => {
250
220
  i = 0;
251
221
  }, n.onerror = () => {
252
- t || (n == null || n.close(), n = null, g());
222
+ t || (n == null || n.close(), n = null, v());
253
223
  };
254
224
  };
255
- return f(), () => {
256
- t = !0, c(), n && (n.removeEventListener("badge", l), n.removeEventListener("inbox", l), n.close(), n = null);
225
+ return p(), () => {
226
+ t = !0, u(), n && (n.removeEventListener("badge", s), n.removeEventListener("inbox", s), n.close(), n = null);
257
227
  };
258
- }, [G, K, h]), T(() => {
259
- $ && J();
260
- }, [$, J]);
261
- const xe = he(
262
- () => We.map((e) => {
263
- const t = e.key ? le[e.key] || 0 : R;
228
+ }, [G, K, w]), T(() => {
229
+ $ && q();
230
+ }, [$, q]);
231
+ const Ae = we(
232
+ () => tt.map((e) => {
233
+ const t = e.key ? de[e.key] || 0 : _;
264
234
  return {
265
235
  key: e.key || "all",
266
236
  label: t > 0 ? `${e.label} (${t})` : e.label
267
237
  };
268
238
  }),
269
- [le, R]
270
- ), q = (e, t) => {
271
- Le((n) => {
272
- const o = { ...n, [e]: t };
273
- return Ue(o), o;
239
+ [de, _]
240
+ ), ee = (e, t) => {
241
+ Pe((n) => {
242
+ const l = { ...n, [e]: t };
243
+ return We(l), l;
274
244
  });
275
- }, Z = async (e, t) => {
245
+ }, te = async (e, t) => {
276
246
  if (!e.read)
277
247
  try {
278
- await M(e.id), A((o) => o.map((i) => i.id === e.id ? { ...i, read: !0 } : i)), I((o) => Math.max(0, o - 1));
279
- } catch (o) {
280
- ge.error(o instanceof Error ? o.message : "标记已读失败");
248
+ await M(e.id), I((l) => l.map((i) => i.id === e.id ? { ...i, read: !0 } : i)), H((l) => Math.max(0, l - 1));
249
+ } catch (l) {
250
+ be.error(l instanceof Error ? l.message : "标记已读失败");
281
251
  return;
282
252
  }
283
253
  const n = String(e.href || "").trim();
284
254
  if (n) {
285
- if (C) {
286
- C(n, e), L(!1);
255
+ if (R) {
256
+ R(n, e), x(!1);
287
257
  return;
288
258
  }
289
- n.startsWith("http://") || n.startsWith("https://") ? window.open(n, "_blank", "noopener,noreferrer") : window.location.assign(n), L(!1);
259
+ n.startsWith("http://") || n.startsWith("https://") ? window.open(n, "_blank", "noopener,noreferrer") : window.location.assign(n), x(!1);
290
260
  }
291
- }, fe = async (e, t) => {
261
+ }, ve = async (e, t) => {
292
262
  if (!t.disabled) {
293
- if (re) {
263
+ if (le) {
294
264
  try {
295
- await re(t.kind, e), L(!1), J(), y();
265
+ await le(t.kind, e), x(!1), q(), g();
296
266
  } catch (n) {
297
- ge.error(n instanceof Error ? n.message : "操作失败");
267
+ be.error(n instanceof Error ? n.message : "操作失败");
298
268
  }
299
269
  return;
300
270
  }
301
- await Z(e);
271
+ await te(e);
302
272
  }
303
- };
304
- return /* @__PURE__ */ m("div", { className: k(r.bellWrap, be), children: [
305
- /* @__PURE__ */ a(Re, { count: R, size: "small", overflowCount: 99, offset: [-4, 4], children: /* @__PURE__ */ a(
306
- F,
273
+ }, he = b ? Ee(b.messageType) : "";
274
+ return /* @__PURE__ */ m("div", { className: P(r.bellWrap, Le), children: [
275
+ /* @__PURE__ */ o(Oe, { count: _, size: "small", overflowCount: 99, offset: [-4, 4], children: /* @__PURE__ */ o(
276
+ z,
307
277
  {
308
278
  type: "text",
309
279
  className: r.bellBtn,
310
- icon: /* @__PURE__ */ a(ze, { size: 16, "aria-hidden": !0 }),
311
- "aria-label": R > 0 ? `站内信,${R} 条未读` : "站内信",
312
- onClick: () => L(!0)
280
+ icon: /* @__PURE__ */ o(Qe, { size: 16, "aria-hidden": !0 }),
281
+ "aria-label": _ > 0 ? `站内信,${_} 条未读` : "站内信",
282
+ onClick: () => x(!0)
313
283
  }
314
284
  ) }),
285
+ b && typeof document < "u" ? Ue(
286
+ /* @__PURE__ */ o("div", { className: r.toastHost, "data-testid": "inbox-live-toast-host", children: /* @__PURE__ */ m(
287
+ "div",
288
+ {
289
+ className: P("marsun-inbox-toast", r.toastNotice),
290
+ role: "alert",
291
+ "data-testid": "inbox-live-toast",
292
+ onClick: ye,
293
+ children: [
294
+ /* @__PURE__ */ o(
295
+ "button",
296
+ {
297
+ type: "button",
298
+ className: r.toastClose,
299
+ "aria-label": "关闭",
300
+ onClick: (e) => {
301
+ e.stopPropagation(), Z();
302
+ },
303
+ children: "×"
304
+ }
305
+ ),
306
+ /* @__PURE__ */ m("div", { className: r.toastHead, children: [
307
+ /* @__PURE__ */ o("span", { className: r.toastTitle, children: re(b.title) }),
308
+ he ? /* @__PURE__ */ o(
309
+ oe,
310
+ {
311
+ color: Se(b.messageType),
312
+ className: r.typeTag,
313
+ children: he
314
+ }
315
+ ) : null
316
+ ] }),
317
+ /* @__PURE__ */ m("div", { className: r.toastBody, children: [
318
+ b.summary ? /* @__PURE__ */ o("div", { className: r.toastDesc, children: re(b.summary) }) : null,
319
+ /* @__PURE__ */ o("div", { className: r.toastActions, children: /* @__PURE__ */ o(
320
+ z,
321
+ {
322
+ type: "primary",
323
+ size: "small",
324
+ onClick: (e) => {
325
+ e.stopPropagation(), ye();
326
+ },
327
+ children: "查看"
328
+ }
329
+ ) })
330
+ ] })
331
+ ]
332
+ },
333
+ b.key
334
+ ) }),
335
+ document.body
336
+ ) : null,
315
337
  /* @__PURE__ */ m(
316
- Pe,
338
+ Ie,
317
339
  {
318
- title: we,
340
+ title: ke,
319
341
  open: $,
320
- onClose: () => L(!1),
342
+ onClose: () => x(!1),
321
343
  size: 420,
322
344
  destroyOnClose: !1,
323
345
  className: r.drawer,
@@ -326,23 +348,23 @@ const vt = De(function({
326
348
  body: { padding: "12px 16px" }
327
349
  },
328
350
  children: [
329
- /* @__PURE__ */ a(
330
- Ge,
351
+ /* @__PURE__ */ o(
352
+ Xe,
331
353
  {
332
354
  className: r.typeTabs,
333
355
  size: "small",
334
356
  activeKey: W || "all",
335
- onChange: (e) => Ee(e === "all" ? "" : e),
336
- stateOption: xe,
357
+ onChange: (e) => xe(e === "all" ? "" : e),
358
+ stateOption: Ae,
337
359
  isInner: !0
338
360
  }
339
361
  ),
340
- /* @__PURE__ */ a("div", { className: r.filterRow, children: /* @__PURE__ */ a(
341
- Ke,
362
+ /* @__PURE__ */ o("div", { className: r.filterRow, children: /* @__PURE__ */ o(
363
+ Ye,
342
364
  {
343
365
  size: "small",
344
- value: O,
345
- onChange: (e) => Se(e),
366
+ value: F,
367
+ onChange: (e) => Ce(e),
346
368
  options: [
347
369
  { value: "all", label: "全部" },
348
370
  { value: "unread", label: "未读" },
@@ -351,116 +373,116 @@ const vt = De(function({
351
373
  }
352
374
  ) }),
353
375
  /* @__PURE__ */ m("div", { className: r.toastPrefs, "data-testid": "inbox-toast-prefs", children: [
354
- /* @__PURE__ */ a("div", { className: r.toastPrefsTitle, children: "消息提示" }),
355
- /* @__PURE__ */ a("p", { className: r.toastPrefsHint, children: "本机浏览器偏好,非租户策略" }),
356
- /* @__PURE__ */ m(ye, { size: 12, wrap: !0, children: [
357
- /* @__PURE__ */ a(
358
- ee,
376
+ /* @__PURE__ */ o("div", { className: r.toastPrefsTitle, children: "消息提示" }),
377
+ /* @__PURE__ */ o("p", { className: r.toastPrefsHint, children: "本机浏览器偏好,非租户策略" }),
378
+ /* @__PURE__ */ m(Te, { size: 12, wrap: !0, children: [
379
+ /* @__PURE__ */ o(
380
+ ne,
359
381
  {
360
- checked: P.alert,
361
- onChange: (e) => q("alert", e.target.checked),
382
+ checked: A.alert,
383
+ onChange: (e) => ee("alert", e.target.checked),
362
384
  children: "预警弹出"
363
385
  }
364
386
  ),
365
- /* @__PURE__ */ a(
366
- ee,
387
+ /* @__PURE__ */ o(
388
+ ne,
367
389
  {
368
- checked: P.action,
369
- onChange: (e) => q("action", e.target.checked),
390
+ checked: A.action,
391
+ onChange: (e) => ee("action", e.target.checked),
370
392
  children: "行动弹出"
371
393
  }
372
394
  ),
373
- /* @__PURE__ */ a(
374
- ee,
395
+ /* @__PURE__ */ o(
396
+ ne,
375
397
  {
376
- checked: P.remind,
377
- onChange: (e) => q("remind", e.target.checked),
398
+ checked: A.remind,
399
+ onChange: (e) => ee("remind", e.target.checked),
378
400
  children: "提醒弹出"
379
401
  }
380
402
  )
381
403
  ] })
382
404
  ] }),
383
- j ? /* @__PURE__ */ a("p", { className: r.error, children: j }) : null,
384
- /* @__PURE__ */ a("div", { className: k("inbox-bell-list-pane", r.listPane), children: /* @__PURE__ */ a($e, { spinning: ae && _.length === 0, children: !ae && !j && _.length === 0 ? /* @__PURE__ */ a(je, { description: "暂无站内信" }) : _.length === 0 ? null : /* @__PURE__ */ m(
385
- Ve,
405
+ j ? /* @__PURE__ */ o("p", { className: r.error, children: j }) : null,
406
+ /* @__PURE__ */ o("div", { className: P("inbox-bell-list-pane", r.listPane), children: /* @__PURE__ */ o(Je, { spinning: se && O.length === 0, children: !se && !j && O.length === 0 ? /* @__PURE__ */ o(qe, { description: "暂无站内信" }) : O.length === 0 ? null : /* @__PURE__ */ m(
407
+ Ze,
386
408
  {
387
- wrapperClassName: k("inbox-bell-list-scroll", r.listScroll),
409
+ wrapperClassName: P("inbox-bell-list-scroll", r.listScroll),
388
410
  className: r.listViewport,
389
411
  "data-testid": "inbox-bell-list-scroll",
390
- onScroll: ke,
412
+ onScroll: _e,
391
413
  children: [
392
- /* @__PURE__ */ a("ul", { className: r.list, children: _.map((e) => {
393
- const t = Te(e.messageType), n = String(e.levelLabel || e.level || "").trim(), o = !!n, i = _e(e.bodyHtml), l = Ae(
394
- Ie(e)
395
- ), c = Oe(e), g = qe(e), f = !!l.primary;
396
- return /* @__PURE__ */ a("li", { children: /* @__PURE__ */ m(
414
+ /* @__PURE__ */ o("ul", { className: r.list, children: O.map((e) => {
415
+ const t = Ee(e.messageType), n = String(e.levelLabel || e.level || "").trim(), l = !!n, i = ze(e.bodyHtml), s = Ge(
416
+ Ke(e)
417
+ ), u = $e(e), v = lt(e), p = !!s.primary;
418
+ return /* @__PURE__ */ o("li", { children: /* @__PURE__ */ m(
397
419
  "div",
398
420
  {
399
- className: k(
421
+ className: P(
400
422
  r.item,
401
423
  !e.read && r.itemUnread,
402
- c && r.itemStatic
424
+ u && r.itemStatic
403
425
  ),
404
- role: c ? void 0 : "button",
405
- tabIndex: c ? void 0 : 0,
406
- onClick: c ? void 0 : () => void Z(e),
407
- onKeyDown: c ? void 0 : (d) => {
408
- (d.key === "Enter" || d.key === " ") && (d.preventDefault(), Z(e));
426
+ role: u ? void 0 : "button",
427
+ tabIndex: u ? void 0 : 0,
428
+ onClick: u ? void 0 : () => void te(e),
429
+ onKeyDown: u ? void 0 : (c) => {
430
+ (c.key === "Enter" || c.key === " ") && (c.preventDefault(), te(e));
409
431
  },
410
432
  children: [
411
433
  /* @__PURE__ */ m("div", { className: r.itemHeader, children: [
412
434
  /* @__PURE__ */ m("span", { className: r.itemHeaderLeft, children: [
413
- /* @__PURE__ */ a("span", { className: r.itemTitle, title: e.title || "(无标题)", children: e.title || "(无标题)" }),
414
- t ? /* @__PURE__ */ a(
415
- z,
435
+ /* @__PURE__ */ o("span", { className: r.itemTitle, title: e.title || "(无标题)", children: e.title || "(无标题)" }),
436
+ t ? /* @__PURE__ */ o(
437
+ oe,
416
438
  {
417
- color: te(e.messageType),
439
+ color: Se(e.messageType),
418
440
  className: r.typeTag,
419
441
  children: t
420
442
  }
421
443
  ) : null
422
444
  ] }),
423
- /* @__PURE__ */ a("span", { className: r.itemTime, children: e.createdAt || "" })
445
+ /* @__PURE__ */ o("span", { className: r.itemTime, children: e.createdAt || "" })
424
446
  ] }),
425
- /* @__PURE__ */ a("div", { className: r.itemBody, children: i ? /* @__PURE__ */ a(
447
+ /* @__PURE__ */ o("div", { className: r.itemBody, children: i ? /* @__PURE__ */ o(
426
448
  "div",
427
449
  {
428
450
  className: r.itemBodyHtml,
429
451
  dangerouslySetInnerHTML: { __html: i }
430
452
  }
431
- ) : e.summary ? /* @__PURE__ */ a("span", { className: r.itemSummary, children: U(e.summary) }) : null }),
432
- g ? /* @__PURE__ */ a("span", { className: r.itemMeta, children: g }) : null,
433
- o ? /* @__PURE__ */ a("div", { className: r.itemFooterTags, children: /* @__PURE__ */ a(
434
- z,
453
+ ) : e.summary ? /* @__PURE__ */ o("span", { className: r.itemSummary, children: re(e.summary) }) : null }),
454
+ v ? /* @__PURE__ */ o("span", { className: r.itemMeta, children: v }) : null,
455
+ l ? /* @__PURE__ */ o("div", { className: r.itemFooterTags, children: /* @__PURE__ */ o(
456
+ oe,
435
457
  {
436
- color: Ze(e.levelColor),
458
+ color: st(e.levelColor),
437
459
  className: r.typeTag,
438
460
  children: n
439
461
  }
440
462
  ) }) : null,
441
- f && l.primary ? /* @__PURE__ */ a(
463
+ p && s.primary ? /* @__PURE__ */ o(
442
464
  "div",
443
465
  {
444
466
  className: r.itemActions,
445
- onClick: (d) => d.stopPropagation(),
446
- onKeyDown: (d) => d.stopPropagation(),
447
- children: /* @__PURE__ */ m(ye, { size: 8, wrap: !0, children: [
448
- /* @__PURE__ */ a(
449
- F,
467
+ onClick: (c) => c.stopPropagation(),
468
+ onKeyDown: (c) => c.stopPropagation(),
469
+ children: /* @__PURE__ */ m(Te, { size: 8, wrap: !0, children: [
470
+ /* @__PURE__ */ o(
471
+ z,
450
472
  {
451
473
  size: "small",
452
474
  type: "primary",
453
- onClick: () => void fe(e, l.primary),
454
- children: l.primary.label
475
+ onClick: () => void ve(e, s.primary),
476
+ children: s.primary.label
455
477
  }
456
478
  ),
457
- l.secondary ? /* @__PURE__ */ a(
458
- F,
479
+ s.secondary ? /* @__PURE__ */ o(
480
+ z,
459
481
  {
460
482
  size: "small",
461
483
  type: "link",
462
- onClick: () => void fe(e, l.secondary),
463
- children: l.secondary.label
484
+ onClick: () => void ve(e, s.secondary),
485
+ children: s.secondary.label
464
486
  }
465
487
  ) : null
466
488
  ] })
@@ -470,7 +492,7 @@ const vt = De(function({
470
492
  }
471
493
  ) }, e.id);
472
494
  }) }),
473
- Be ? /* @__PURE__ */ a("p", { className: k("inbox-bell-list-footer", r.listFooter), children: "加载中…" }) : null
495
+ Re ? /* @__PURE__ */ o("p", { className: P("inbox-bell-list-footer", r.listFooter), children: "加载中…" }) : null
474
496
  ]
475
497
  }
476
498
  ) }) })
@@ -480,17 +502,17 @@ const vt = De(function({
480
502
  ] });
481
503
  });
482
504
  export {
483
- Bt as DEFAULT_INBOX_TOAST_PREFS,
484
- vt as default,
485
- Ae as filterInboxActionsForHost,
486
- wt as inboxSceneLabel,
487
- Oe as isInboxButtonDriven,
488
- Nt as isTerminalActionStatus,
489
- He as loadInboxToastPrefs,
490
- Et as normalizeInboxActions,
491
- Ie as resolveInboxItemActions,
492
- St as resolveInboxSceneKey,
493
- Ue as saveInboxToastPrefs,
494
- Fe as shouldToastForMessageType
505
+ Mt as DEFAULT_INBOX_TOAST_PREFS,
506
+ Bt as default,
507
+ Ge as filterInboxActionsForHost,
508
+ Pt as inboxSceneLabel,
509
+ $e as isInboxButtonDriven,
510
+ Rt as isTerminalActionStatus,
511
+ je as loadInboxToastPrefs,
512
+ _t as normalizeInboxActions,
513
+ Ke as resolveInboxItemActions,
514
+ At as resolveInboxSceneKey,
515
+ We as saveInboxToastPrefs,
516
+ Ve as shouldToastForMessageType
495
517
  };
496
518
  //# sourceMappingURL=InboxBell.js.map