@hkyhy/marsun-components-core 0.1.11 → 0.1.15
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/README.md +31 -6
- package/dist/components/AgentHub/Chat/Action/CreateButton.js +8 -0
- package/dist/components/AgentHub/Chat/Action/CreateButton.js.map +1 -0
- package/dist/components/AgentHub/Chat/Action/ManageActionButtons.js +20 -0
- package/dist/components/AgentHub/Chat/Action/ManageActionButtons.js.map +1 -0
- package/dist/components/AgentHub/Chat/Action/SessionActionButtons.js +24 -0
- package/dist/components/AgentHub/Chat/Action/SessionActionButtons.js.map +1 -0
- package/dist/components/AgentHub/Chat/Action/handlers.d.ts +0 -5
- package/dist/components/AgentHub/Chat/Detail/ChatInput/index.js +65 -0
- package/dist/components/AgentHub/Chat/Detail/ChatInput/index.js.map +1 -0
- package/dist/components/AgentHub/Chat/Detail/ChatInput/style.module.scss.js +12 -0
- package/dist/components/AgentHub/Chat/Detail/ChatInput/style.module.scss.js.map +1 -0
- package/dist/components/AgentHub/Chat/Detail/ChatPanel/index.d.ts +31 -0
- package/dist/components/AgentHub/Chat/Detail/ChatPanel/index.js +85 -0
- package/dist/components/AgentHub/Chat/Detail/ChatPanel/index.js.map +1 -0
- package/dist/components/AgentHub/Chat/Detail/ChatPanel/style.module.scss.js +14 -0
- package/dist/components/AgentHub/Chat/Detail/ChatPanel/style.module.scss.js.map +1 -0
- package/dist/components/AgentHub/Chat/Detail/ChatSuggestionRow/index.d.ts +9 -0
- package/dist/components/AgentHub/Chat/Detail/ChatSuggestionRow/index.js +22 -0
- package/dist/components/AgentHub/Chat/Detail/ChatSuggestionRow/index.js.map +1 -0
- package/dist/components/AgentHub/Chat/Detail/ChatSuggestionRow/style.module.scss.js +8 -0
- package/dist/components/AgentHub/Chat/Detail/ChatSuggestionRow/style.module.scss.js.map +1 -0
- package/dist/components/AgentHub/Chat/Detail/CitationContent/index.js +21 -0
- package/dist/components/AgentHub/Chat/Detail/CitationContent/index.js.map +1 -0
- package/dist/components/AgentHub/Chat/Detail/CitationContent/style.module.scss.js +8 -0
- package/dist/components/AgentHub/Chat/Detail/CitationContent/style.module.scss.js.map +1 -0
- package/dist/components/AgentHub/Chat/Detail/CitationInlineBadge/index.js +17 -0
- package/dist/components/AgentHub/Chat/Detail/CitationInlineBadge/index.js.map +1 -0
- package/dist/components/AgentHub/Chat/Detail/CitationInlineBadge/style.module.scss.js +7 -0
- package/dist/components/AgentHub/Chat/Detail/CitationInlineBadge/style.module.scss.js.map +1 -0
- package/dist/components/AgentHub/Chat/Detail/CitationMarkdownContent/index.js +68 -0
- package/dist/components/AgentHub/Chat/Detail/CitationMarkdownContent/index.js.map +1 -0
- package/dist/components/AgentHub/Chat/Detail/CitationMarkdownContent/style.module.scss.js +7 -0
- package/dist/components/AgentHub/Chat/Detail/CitationMarkdownContent/style.module.scss.js.map +1 -0
- package/dist/components/AgentHub/Chat/Detail/CitationPanel/index.js +247 -0
- package/dist/components/AgentHub/Chat/Detail/CitationPanel/index.js.map +1 -0
- package/dist/components/AgentHub/Chat/Detail/CitationPanel/style.module.scss.js +31 -0
- package/dist/components/AgentHub/Chat/Detail/CitationPanel/style.module.scss.js.map +1 -0
- package/dist/components/AgentHub/Chat/Detail/MermaidBlock/index.js +43 -0
- package/dist/components/AgentHub/Chat/Detail/MermaidBlock/index.js.map +1 -0
- package/dist/components/AgentHub/Chat/Detail/MermaidBlock/style.module.scss.js +8 -0
- package/dist/components/AgentHub/Chat/Detail/MermaidBlock/style.module.scss.js.map +1 -0
- package/dist/components/AgentHub/Chat/Detail/MessageActions/index.js +103 -0
- package/dist/components/AgentHub/Chat/Detail/MessageActions/index.js.map +1 -0
- package/dist/components/AgentHub/Chat/Detail/MessageActions/style.module.scss.js +14 -0
- package/dist/components/AgentHub/Chat/Detail/MessageActions/style.module.scss.js.map +1 -0
- package/dist/components/AgentHub/Chat/Detail/MessageEditPopover/index.js +58 -0
- package/dist/components/AgentHub/Chat/Detail/MessageEditPopover/index.js.map +1 -0
- package/dist/components/AgentHub/Chat/Detail/MessageEditPopover/style.module.scss.js +9 -0
- package/dist/components/AgentHub/Chat/Detail/MessageEditPopover/style.module.scss.js.map +1 -0
- package/dist/components/AgentHub/Chat/Detail/MessageItem/index.js +309 -0
- package/dist/components/AgentHub/Chat/Detail/MessageItem/index.js.map +1 -0
- package/dist/components/AgentHub/Chat/Detail/MessageItem/style.module.scss.js +24 -0
- package/dist/components/AgentHub/Chat/Detail/MessageItem/style.module.scss.js.map +1 -0
- package/dist/components/AgentHub/Chat/Detail/ThinkingSection/index.js +122 -0
- package/dist/components/AgentHub/Chat/Detail/ThinkingSection/index.js.map +1 -0
- package/dist/components/AgentHub/Chat/Detail/ThinkingSection/style.module.scss.js +25 -0
- package/dist/components/AgentHub/Chat/Detail/ThinkingSection/style.module.scss.js.map +1 -0
- package/dist/components/AgentHub/Chat/Detail/index.d.ts +12 -0
- package/dist/components/AgentHub/Chat/Form/Form.js +37 -0
- package/dist/components/AgentHub/Chat/Form/Form.js.map +1 -0
- package/dist/components/AgentHub/Chat/List/ChatCard/index.js +86 -0
- package/dist/components/AgentHub/Chat/List/ChatCard/index.js.map +1 -0
- package/dist/components/AgentHub/Chat/List/ChatCard/style.module.scss.js +25 -0
- package/dist/components/AgentHub/Chat/List/ChatCard/style.module.scss.js.map +1 -0
- package/dist/components/AgentHub/Chat/List/FilterBar.js +17 -0
- package/dist/components/AgentHub/Chat/List/FilterBar.js.map +1 -0
- package/dist/components/AgentHub/Chat/List/SessionSidebar/index.js +156 -0
- package/dist/components/AgentHub/Chat/List/SessionSidebar/index.js.map +1 -0
- package/dist/components/AgentHub/Chat/List/SessionSidebar/style.module.scss.js +28 -0
- package/dist/components/AgentHub/Chat/List/SessionSidebar/style.module.scss.js.map +1 -0
- package/dist/components/AgentHub/Chat/Modal/FormModal.js +58 -0
- package/dist/components/AgentHub/Chat/Modal/FormModal.js.map +1 -0
- package/dist/components/AgentHub/Chat/hooks/useAutoScrollToBottom.js +35 -0
- package/dist/components/AgentHub/Chat/hooks/useAutoScrollToBottom.js.map +1 -0
- package/dist/components/AgentHub/Chat/hooks/useChat.js +51 -0
- package/dist/components/AgentHub/Chat/hooks/useChat.js.map +1 -0
- package/dist/components/AgentHub/Chat/hooks/useChatSessions.js +60 -0
- package/dist/components/AgentHub/Chat/hooks/useChatSessions.js.map +1 -0
- package/dist/components/AgentHub/Chat/hooks/useSSECompletion.js +69 -0
- package/dist/components/AgentHub/Chat/hooks/useSSECompletion.js.map +1 -0
- package/dist/components/AgentHub/Chat/hooks/useTypewriter.js +39 -0
- package/dist/components/AgentHub/Chat/hooks/useTypewriter.js.map +1 -0
- package/dist/components/AgentHub/Chat/index.d.ts +1 -0
- package/dist/components/AgentHub/Chat/utils/citationContent.js +169 -0
- package/dist/components/AgentHub/Chat/utils/citationContent.js.map +1 -0
- package/dist/components/AgentHub/Chat/utils/messageContent.js +85 -0
- package/dist/components/AgentHub/Chat/utils/messageContent.js.map +1 -0
- package/dist/components/AgentHub/Chat/utils/sanitizeMermaidChart.js +22 -0
- package/dist/components/AgentHub/Chat/utils/sanitizeMermaidChart.js.map +1 -0
- package/dist/components/AgentHub/Chat/utils/sessionMessages.js +151 -0
- package/dist/components/AgentHub/Chat/utils/sessionMessages.js.map +1 -0
- package/dist/components/AgentHub/KnowledgeBase/Action/CreateButton.js +8 -0
- package/dist/components/AgentHub/KnowledgeBase/Action/CreateButton.js.map +1 -0
- package/dist/components/AgentHub/KnowledgeBase/Action/ManageActionButtons.js +20 -0
- package/dist/components/AgentHub/KnowledgeBase/Action/ManageActionButtons.js.map +1 -0
- package/dist/components/AgentHub/KnowledgeBase/Detail/DocumentTable/index.js +110 -0
- package/dist/components/AgentHub/KnowledgeBase/Detail/DocumentTable/index.js.map +1 -0
- package/dist/components/AgentHub/KnowledgeBase/Detail/DocumentTable/style.module.scss.js +7 -0
- package/dist/components/AgentHub/KnowledgeBase/Detail/DocumentTable/style.module.scss.js.map +1 -0
- package/dist/components/AgentHub/KnowledgeBase/Detail/ParseStatusTag/index.js +18 -0
- package/dist/components/AgentHub/KnowledgeBase/Detail/ParseStatusTag/index.js.map +1 -0
- package/dist/components/AgentHub/KnowledgeBase/Detail/ParseStatusTag/style.module.scss.js +7 -0
- package/dist/components/AgentHub/KnowledgeBase/Detail/ParseStatusTag/style.module.scss.js.map +1 -0
- package/dist/components/AgentHub/KnowledgeBase/Form/Form.js +31 -0
- package/dist/components/AgentHub/KnowledgeBase/Form/Form.js.map +1 -0
- package/dist/components/AgentHub/KnowledgeBase/List/FilterBar.js +17 -0
- package/dist/components/AgentHub/KnowledgeBase/List/FilterBar.js.map +1 -0
- package/dist/components/AgentHub/KnowledgeBase/List/KnowledgeCard/index.js +118 -0
- package/dist/components/AgentHub/KnowledgeBase/List/KnowledgeCard/index.js.map +1 -0
- package/dist/components/AgentHub/KnowledgeBase/List/KnowledgeCard/style.module.scss.js +23 -0
- package/dist/components/AgentHub/KnowledgeBase/List/KnowledgeCard/style.module.scss.js.map +1 -0
- package/dist/components/AgentHub/KnowledgeBase/Modal/FormModal.js +47 -0
- package/dist/components/AgentHub/KnowledgeBase/Modal/FormModal.js.map +1 -0
- package/dist/components/AgentHub/KnowledgeBase/constants/types.js +28 -0
- package/dist/components/AgentHub/KnowledgeBase/constants/types.js.map +1 -0
- package/dist/components/AgentHub/KnowledgeBase/hooks/useKBDocuments.js +21 -0
- package/dist/components/AgentHub/KnowledgeBase/hooks/useKBDocuments.js.map +1 -0
- package/dist/components/AgentHub/KnowledgeBase/hooks/useKnowledgeBase.js +32 -0
- package/dist/components/AgentHub/KnowledgeBase/hooks/useKnowledgeBase.js.map +1 -0
- package/dist/components/Filter/FilterDateRange/index.d.ts +2 -0
- package/dist/components/Filter/FilterDateRange/index.js +62 -51
- package/dist/components/Filter/FilterDateRange/index.js.map +1 -1
- package/dist/components/Filter/FilterSelect/index.d.ts +6 -2
- package/dist/components/Filter/FilterSelect/index.js +132 -107
- package/dist/components/Filter/FilterSelect/index.js.map +1 -1
- package/dist/components/Filter/FilterTrigger/index.d.ts +2 -2
- package/dist/components/Filter/FilterTrigger/index.js.map +1 -1
- package/dist/components/Filter/FilterTrigger/style.module.scss.js +4 -4
- package/dist/components/Filter/index.d.ts +1 -1
- package/dist/components/Icons/index.js +153 -145
- package/dist/components/Icons/index.js.map +1 -1
- package/dist/components/LlmFormattedText/LlmFormattedText/index.d.ts +8 -0
- package/dist/components/LlmFormattedText/LlmFormattedText/index.js +42 -0
- package/dist/components/LlmFormattedText/LlmFormattedText/index.js.map +1 -0
- package/dist/components/LlmFormattedText/LlmFormattedText/style.module.scss.js +17 -0
- package/dist/components/LlmFormattedText/LlmFormattedText/style.module.scss.js.map +1 -0
- package/dist/components/LlmFormattedText/index.d.ts +4 -0
- package/dist/components/LlmFormattedText/parseLlmText.d.ts +14 -0
- package/dist/components/LlmFormattedText/parseLlmText.js +77 -0
- package/dist/components/LlmFormattedText/parseLlmText.js.map +1 -0
- package/dist/components/Sparkline/Sparkline/index.d.ts +11 -0
- package/dist/components/Sparkline/Sparkline/index.js +46 -0
- package/dist/components/Sparkline/Sparkline/index.js.map +1 -0
- package/dist/components/Sparkline/Sparkline/style.module.scss.js +8 -0
- package/dist/components/Sparkline/Sparkline/style.module.scss.js.map +1 -0
- package/dist/components/Sparkline/index.d.ts +2 -0
- package/dist/components/TooltipInfo/TooltipInfo.js +29 -20
- package/dist/components/TooltipInfo/TooltipInfo.js.map +1 -1
- package/dist/components/index.d.ts +2 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.js +291 -175
- package/dist/index.js.map +1 -1
- package/dist/marsun-components-core.css +1 -1
- package/dist/styles/global.css +1 -1
- package/dist/theme/constants.d.ts +47 -1
- package/dist/theme/constants.js +50 -5
- package/dist/theme/constants.js.map +1 -1
- package/dist/theme/index.d.ts +2 -2
- package/dist/theme/index.js +8 -6
- package/dist/theme/theme.d.ts +10 -0
- package/dist/theme/theme.js +24 -34
- package/dist/theme/theme.js.map +1 -1
- package/dist/theme/tokens.css +139 -0
- package/package.json +6 -3
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { jsxs as l, jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { X as N, ChevronDown as y } from "../../../../Icons/index.js";
|
|
3
|
+
import { Button as b, Empty as f } from "antd";
|
|
4
|
+
import i from "classnames";
|
|
5
|
+
import C, { useState as E, useRef as k, useEffect as x, useCallback as v } from "react";
|
|
6
|
+
import S from "../CitationContent/index.js";
|
|
7
|
+
import t from "./style.module.scss.js";
|
|
8
|
+
import w from "../../../../VirtualScrollbar/VirtualScrollbar/index.js";
|
|
9
|
+
import { formatCitationMeta as D, resolveCitationTitle as R } from "../../utils/citationContent.js";
|
|
10
|
+
const q = ({
|
|
11
|
+
citation: o,
|
|
12
|
+
index: c,
|
|
13
|
+
highlighted: r,
|
|
14
|
+
expanded: s,
|
|
15
|
+
onToggle: p,
|
|
16
|
+
itemRef: d
|
|
17
|
+
}) => {
|
|
18
|
+
const h = D(o), e = !!o.content, n = R(o, c), m = v(
|
|
19
|
+
(u) => {
|
|
20
|
+
e && (u.key === "Enter" || u.key === " ") && (u.preventDefault(), p());
|
|
21
|
+
},
|
|
22
|
+
[e, p]
|
|
23
|
+
);
|
|
24
|
+
return /* @__PURE__ */ l(
|
|
25
|
+
"article",
|
|
26
|
+
{
|
|
27
|
+
ref: d,
|
|
28
|
+
className: i(
|
|
29
|
+
"citation-panel-citation-item",
|
|
30
|
+
t["citation-panel-citation-item"],
|
|
31
|
+
r && "citation-panel-citation-item-highlighted",
|
|
32
|
+
r && t["citation-panel-citation-item-highlighted"]
|
|
33
|
+
),
|
|
34
|
+
children: [
|
|
35
|
+
r && /* @__PURE__ */ a(
|
|
36
|
+
"span",
|
|
37
|
+
{
|
|
38
|
+
className: i(
|
|
39
|
+
"citation-panel-citation-item-marker",
|
|
40
|
+
t["citation-panel-citation-item-marker"],
|
|
41
|
+
"bg-primary"
|
|
42
|
+
),
|
|
43
|
+
"aria-hidden": !0
|
|
44
|
+
}
|
|
45
|
+
),
|
|
46
|
+
/* @__PURE__ */ l(
|
|
47
|
+
"div",
|
|
48
|
+
{
|
|
49
|
+
className: i(
|
|
50
|
+
"citation-panel-citation-item-body",
|
|
51
|
+
t["citation-panel-citation-item-body"]
|
|
52
|
+
),
|
|
53
|
+
children: [
|
|
54
|
+
/* @__PURE__ */ a(
|
|
55
|
+
"span",
|
|
56
|
+
{
|
|
57
|
+
className: i(
|
|
58
|
+
"citation-panel-citation-item-index",
|
|
59
|
+
t["citation-panel-citation-item-index"],
|
|
60
|
+
r ? "citation-item-index-highlighted" : "citation-item-index-default",
|
|
61
|
+
r ? t["citation-panel-citation-item-index-highlighted"] : t["citation-panel-citation-item-index-default"]
|
|
62
|
+
),
|
|
63
|
+
children: c + 1
|
|
64
|
+
}
|
|
65
|
+
),
|
|
66
|
+
/* @__PURE__ */ l(
|
|
67
|
+
"div",
|
|
68
|
+
{
|
|
69
|
+
className: i(
|
|
70
|
+
"citation-panel-citation-item-content",
|
|
71
|
+
t["citation-panel-citation-item-content"]
|
|
72
|
+
),
|
|
73
|
+
children: [
|
|
74
|
+
/* @__PURE__ */ l(
|
|
75
|
+
"div",
|
|
76
|
+
{
|
|
77
|
+
role: e ? "button" : void 0,
|
|
78
|
+
tabIndex: e ? 0 : void 0,
|
|
79
|
+
"aria-expanded": e ? s : void 0,
|
|
80
|
+
onClick: e ? p : void 0,
|
|
81
|
+
onKeyDown: m,
|
|
82
|
+
className: i(
|
|
83
|
+
"citation-panel-citation-item-header",
|
|
84
|
+
t["citation-panel-citation-item-header"],
|
|
85
|
+
e && "citation-panel-citation-item-header-interactive",
|
|
86
|
+
e && t["citation-panel-citation-item-header-interactive"]
|
|
87
|
+
),
|
|
88
|
+
children: [
|
|
89
|
+
/* @__PURE__ */ l(
|
|
90
|
+
"div",
|
|
91
|
+
{
|
|
92
|
+
className: i(
|
|
93
|
+
"citation-panel-citation-item-header-main",
|
|
94
|
+
t["citation-panel-citation-item-header-main"]
|
|
95
|
+
),
|
|
96
|
+
children: [
|
|
97
|
+
/* @__PURE__ */ a(
|
|
98
|
+
"h4",
|
|
99
|
+
{
|
|
100
|
+
className: i(
|
|
101
|
+
"citation-panel-citation-item-title",
|
|
102
|
+
t["citation-panel-citation-item-title"]
|
|
103
|
+
),
|
|
104
|
+
title: n,
|
|
105
|
+
children: n
|
|
106
|
+
}
|
|
107
|
+
),
|
|
108
|
+
h && /* @__PURE__ */ a(
|
|
109
|
+
"p",
|
|
110
|
+
{
|
|
111
|
+
className: i(
|
|
112
|
+
"citation-panel-citation-item-meta",
|
|
113
|
+
t["citation-panel-citation-item-meta"]
|
|
114
|
+
),
|
|
115
|
+
children: h
|
|
116
|
+
}
|
|
117
|
+
)
|
|
118
|
+
]
|
|
119
|
+
}
|
|
120
|
+
),
|
|
121
|
+
e && /* @__PURE__ */ a(
|
|
122
|
+
y,
|
|
123
|
+
{
|
|
124
|
+
className: i(
|
|
125
|
+
"citation-panel-citation-item-chevron",
|
|
126
|
+
t["citation-panel-citation-item-chevron"],
|
|
127
|
+
s && "citation-panel-citation-item-chevron-expanded",
|
|
128
|
+
s && t["citation-panel-citation-item-chevron-expanded"]
|
|
129
|
+
),
|
|
130
|
+
"aria-hidden": !0
|
|
131
|
+
}
|
|
132
|
+
)
|
|
133
|
+
]
|
|
134
|
+
}
|
|
135
|
+
),
|
|
136
|
+
s && o.content && /* @__PURE__ */ a(
|
|
137
|
+
"blockquote",
|
|
138
|
+
{
|
|
139
|
+
className: i(
|
|
140
|
+
"citation-panel-citation-item-quote",
|
|
141
|
+
t["citation-panel-citation-item-quote"]
|
|
142
|
+
),
|
|
143
|
+
children: /* @__PURE__ */ a(S, { content: o.content })
|
|
144
|
+
}
|
|
145
|
+
)
|
|
146
|
+
]
|
|
147
|
+
}
|
|
148
|
+
)
|
|
149
|
+
]
|
|
150
|
+
}
|
|
151
|
+
)
|
|
152
|
+
]
|
|
153
|
+
}
|
|
154
|
+
);
|
|
155
|
+
}, $ = ({ citations: o, highlightedIndex: c, onClose: r }) => {
|
|
156
|
+
const [s, p] = E(() => /* @__PURE__ */ new Set()), d = k([]);
|
|
157
|
+
x(() => {
|
|
158
|
+
if (c === void 0 || c < 0) return;
|
|
159
|
+
p((n) => new Set(n).add(c));
|
|
160
|
+
const e = d.current[c];
|
|
161
|
+
e && requestAnimationFrame(() => {
|
|
162
|
+
e.scrollIntoView({ behavior: "smooth", block: "nearest" });
|
|
163
|
+
});
|
|
164
|
+
}, [c, o]);
|
|
165
|
+
const h = v((e) => {
|
|
166
|
+
p((n) => {
|
|
167
|
+
const m = new Set(n);
|
|
168
|
+
return m.has(e) ? m.delete(e) : m.add(e), m;
|
|
169
|
+
});
|
|
170
|
+
}, []);
|
|
171
|
+
return /* @__PURE__ */ l(
|
|
172
|
+
"div",
|
|
173
|
+
{
|
|
174
|
+
className: i(
|
|
175
|
+
"citation-panel-citation-panel",
|
|
176
|
+
t["citation-panel-citation-panel"]
|
|
177
|
+
),
|
|
178
|
+
children: [
|
|
179
|
+
/* @__PURE__ */ l("header", { className: i("citation-panel-header", t["citation-panel-header"]), children: [
|
|
180
|
+
/* @__PURE__ */ a("h3", { className: i("citation-panel-title", t["citation-panel-title"]), children: "引用来源" }),
|
|
181
|
+
/* @__PURE__ */ l(
|
|
182
|
+
"div",
|
|
183
|
+
{
|
|
184
|
+
className: i(
|
|
185
|
+
"citation-panel-header-actions",
|
|
186
|
+
t["citation-panel-header-actions"]
|
|
187
|
+
),
|
|
188
|
+
children: [
|
|
189
|
+
o.length > 0 && /* @__PURE__ */ a("span", { className: i("citation-panel-count", t["citation-panel-count"]), children: o.length }),
|
|
190
|
+
r && /* @__PURE__ */ a(
|
|
191
|
+
b,
|
|
192
|
+
{
|
|
193
|
+
type: "text",
|
|
194
|
+
icon: /* @__PURE__ */ a(
|
|
195
|
+
N,
|
|
196
|
+
{
|
|
197
|
+
className: i(
|
|
198
|
+
"citation-panel-citation-summary-icon",
|
|
199
|
+
t["citation-panel-citation-summary-icon"]
|
|
200
|
+
)
|
|
201
|
+
}
|
|
202
|
+
),
|
|
203
|
+
size: "small",
|
|
204
|
+
onClick: r,
|
|
205
|
+
className: i("citation-panel-close-btn", t["citation-panel-close-btn"])
|
|
206
|
+
}
|
|
207
|
+
)
|
|
208
|
+
]
|
|
209
|
+
}
|
|
210
|
+
)
|
|
211
|
+
] }),
|
|
212
|
+
o.length === 0 ? /* @__PURE__ */ a("div", { className: i("citation-panel-empty", t["citation-panel-empty"]), children: /* @__PURE__ */ a(f, { description: "暂无引用来源", image: f.PRESENTED_IMAGE_SIMPLE }) }) : /* @__PURE__ */ a(
|
|
213
|
+
w,
|
|
214
|
+
{
|
|
215
|
+
wrapperClassName: i("citation-panel-empty", t["citation-panel-empty"]),
|
|
216
|
+
children: o.map((e, n) => /* @__PURE__ */ l(C.Fragment, { children: [
|
|
217
|
+
n > 0 && /* @__PURE__ */ a(
|
|
218
|
+
"div",
|
|
219
|
+
{
|
|
220
|
+
className: i("citation-panel-divider", t["citation-panel-divider"]),
|
|
221
|
+
role: "separator"
|
|
222
|
+
}
|
|
223
|
+
),
|
|
224
|
+
/* @__PURE__ */ a(
|
|
225
|
+
q,
|
|
226
|
+
{
|
|
227
|
+
citation: e,
|
|
228
|
+
index: n,
|
|
229
|
+
highlighted: c === n,
|
|
230
|
+
expanded: s.has(n),
|
|
231
|
+
onToggle: () => h(n),
|
|
232
|
+
itemRef: (m) => {
|
|
233
|
+
d.current[n] = m;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
)
|
|
237
|
+
] }, e.id ?? `${e.doc_id ?? "cite"}-${n}`))
|
|
238
|
+
}
|
|
239
|
+
)
|
|
240
|
+
]
|
|
241
|
+
}
|
|
242
|
+
);
|
|
243
|
+
};
|
|
244
|
+
export {
|
|
245
|
+
$ as default
|
|
246
|
+
};
|
|
247
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../../src/components/AgentHub/Chat/Detail/CitationPanel/index.tsx"],"sourcesContent":["import { VirtualScrollbar } from '@/components/VirtualScrollbar';\nimport { ChevronDown, X } from '@/components/Icons';\nimport type { Citation } from '@/components/AgentHub/types';\nimport { Button, Empty } from 'antd';\nimport classNames from 'classnames';\nimport React, { useCallback, useEffect, useRef, useState } from 'react';\nimport { formatCitationMeta, resolveCitationTitle } from '../../utils';\nimport CitationContent from '../CitationContent';\nimport styles from './style.module.scss';\n\nexport interface CitationPanelProps {\n citations: Citation[];\n highlightedIndex?: number;\n onClose?: () => void;\n}\n\ninterface CitationItemProps {\n citation: Citation;\n index: number;\n highlighted?: boolean;\n expanded: boolean;\n onToggle: () => void;\n itemRef?: (el: HTMLElement | null) => void;\n}\n\nconst CitationItem: React.FC<CitationItemProps> = ({\n citation,\n index,\n highlighted,\n expanded,\n onToggle,\n itemRef,\n}) => {\n const meta = formatCitationMeta(citation);\n const hasContent = Boolean(citation.content);\n const title = resolveCitationTitle(citation, index);\n\n const handleKeyDown = useCallback(\n (e: React.KeyboardEvent) => {\n if (!hasContent) return;\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n onToggle();\n }\n },\n [hasContent, onToggle],\n );\n\n return (\n <article\n ref={itemRef}\n className={classNames(\n 'citation-panel-citation-item',\n styles['citation-panel-citation-item'],\n highlighted && 'citation-panel-citation-item-highlighted',\n highlighted && styles['citation-panel-citation-item-highlighted'],\n )}\n >\n {highlighted && (\n <span\n className={classNames(\n 'citation-panel-citation-item-marker',\n styles['citation-panel-citation-item-marker'],\n 'bg-primary',\n )}\n aria-hidden\n />\n )}\n\n <div\n className={classNames(\n 'citation-panel-citation-item-body',\n styles['citation-panel-citation-item-body'],\n )}\n >\n <span\n className={classNames(\n 'citation-panel-citation-item-index',\n styles['citation-panel-citation-item-index'],\n highlighted ? 'citation-item-index-highlighted' : 'citation-item-index-default',\n highlighted\n ? styles['citation-panel-citation-item-index-highlighted']\n : styles['citation-panel-citation-item-index-default'],\n )}\n >\n {index + 1}\n </span>\n\n <div\n className={classNames(\n 'citation-panel-citation-item-content',\n styles['citation-panel-citation-item-content'],\n )}\n >\n <div\n role={hasContent ? 'button' : undefined}\n tabIndex={hasContent ? 0 : undefined}\n aria-expanded={hasContent ? expanded : undefined}\n onClick={hasContent ? onToggle : undefined}\n onKeyDown={handleKeyDown}\n className={classNames(\n 'citation-panel-citation-item-header',\n styles['citation-panel-citation-item-header'],\n hasContent && 'citation-panel-citation-item-header-interactive',\n hasContent && styles['citation-panel-citation-item-header-interactive'],\n )}\n >\n <div\n className={classNames(\n 'citation-panel-citation-item-header-main',\n styles['citation-panel-citation-item-header-main'],\n )}\n >\n <h4\n className={classNames(\n 'citation-panel-citation-item-title',\n styles['citation-panel-citation-item-title'],\n )}\n title={title}\n >\n {title}\n </h4>\n {meta && (\n <p\n className={classNames(\n 'citation-panel-citation-item-meta',\n styles['citation-panel-citation-item-meta'],\n )}\n >\n {meta}\n </p>\n )}\n </div>\n\n {hasContent && (\n <ChevronDown\n className={classNames(\n 'citation-panel-citation-item-chevron',\n styles['citation-panel-citation-item-chevron'],\n expanded && 'citation-panel-citation-item-chevron-expanded',\n expanded && styles['citation-panel-citation-item-chevron-expanded'],\n )}\n aria-hidden\n />\n )}\n </div>\n\n {expanded && citation.content && (\n <blockquote\n className={classNames(\n 'citation-panel-citation-item-quote',\n styles['citation-panel-citation-item-quote'],\n )}\n >\n <CitationContent content={citation.content} />\n </blockquote>\n )}\n </div>\n </div>\n </article>\n );\n};\n\nconst CitationPanel: React.FC<CitationPanelProps> = ({ citations, highlightedIndex, onClose }) => {\n const [expandedSet, setExpandedSet] = useState<Set<number>>(() => new Set());\n const itemRefs = useRef<(HTMLElement | null)[]>([]);\n\n useEffect(() => {\n if (highlightedIndex === undefined || highlightedIndex < 0) return;\n setExpandedSet((prev) => new Set(prev).add(highlightedIndex));\n const el = itemRefs.current[highlightedIndex];\n if (el) {\n requestAnimationFrame(() => {\n el.scrollIntoView({ behavior: 'smooth', block: 'nearest' });\n });\n }\n }, [highlightedIndex, citations]);\n\n const toggleExpanded = useCallback((index: number) => {\n setExpandedSet((prev) => {\n const next = new Set(prev);\n if (next.has(index)) next.delete(index);\n else next.add(index);\n return next;\n });\n }, []);\n\n return (\n <div\n className={classNames(\n 'citation-panel-citation-panel',\n styles['citation-panel-citation-panel'],\n )}\n >\n <header className={classNames('citation-panel-header', styles['citation-panel-header'])}>\n <h3 className={classNames('citation-panel-title', styles['citation-panel-title'])}>\n 引用来源\n </h3>\n <div\n className={classNames(\n 'citation-panel-header-actions',\n styles['citation-panel-header-actions'],\n )}\n >\n {citations.length > 0 && (\n <span className={classNames('citation-panel-count', styles['citation-panel-count'])}>\n {citations.length}\n </span>\n )}\n {onClose && (\n <Button\n type=\"text\"\n icon={\n <X\n className={classNames(\n 'citation-panel-citation-summary-icon',\n styles['citation-panel-citation-summary-icon'],\n )}\n />\n }\n size=\"small\"\n onClick={onClose}\n className={classNames('citation-panel-close-btn', styles['citation-panel-close-btn'])}\n />\n )}\n </div>\n </header>\n\n {citations.length === 0 ? (\n <div className={classNames('citation-panel-empty', styles['citation-panel-empty'])}>\n <Empty description=\"暂无引用来源\" image={Empty.PRESENTED_IMAGE_SIMPLE} />\n </div>\n ) : (\n <VirtualScrollbar\n wrapperClassName={classNames('citation-panel-empty', styles['citation-panel-empty'])}\n >\n {citations.map((c, i) => (\n <React.Fragment key={c.id ?? `${c.doc_id ?? 'cite'}-${i}`}>\n {i > 0 && (\n <div\n className={classNames('citation-panel-divider', styles['citation-panel-divider'])}\n role=\"separator\"\n />\n )}\n <CitationItem\n citation={c}\n index={i}\n highlighted={highlightedIndex === i}\n expanded={expandedSet.has(i)}\n onToggle={() => toggleExpanded(i)}\n itemRef={(el) => {\n itemRefs.current[i] = el;\n }}\n />\n </React.Fragment>\n ))}\n </VirtualScrollbar>\n )}\n </div>\n );\n};\n\nexport default CitationPanel;\n"],"names":["CitationItem","citation","index","highlighted","expanded","onToggle","itemRef","meta","formatCitationMeta","hasContent","title","resolveCitationTitle","handleKeyDown","useCallback","e","jsxs","classNames","styles","jsx","ChevronDown","CitationContent","CitationPanel","citations","highlightedIndex","onClose","expandedSet","setExpandedSet","useState","itemRefs","useRef","useEffect","prev","el","toggleExpanded","next","Button","X","Empty","VirtualScrollbar","c","i","React"],"mappings":";;;;;;;;;AAyBA,MAAMA,IAA4C,CAAC;AAAA,EACjD,UAAAC;AAAA,EACA,OAAAC;AAAA,EACA,aAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,SAAAC;AACF,MAAM;AACJ,QAAMC,IAAOC,EAAmBP,CAAQ,GAClCQ,IAAa,EAAQR,EAAS,SAC9BS,IAAQC,EAAqBV,GAAUC,CAAK,GAE5CU,IAAgBC;AAAA,IACpB,CAACC,MAA2B;AAC1B,MAAKL,MACDK,EAAE,QAAQ,WAAWA,EAAE,QAAQ,SACjCA,EAAE,eAAA,GACFT,EAAA;AAAA,IAEJ;AAAA,IACA,CAACI,GAAYJ,CAAQ;AAAA,EAAA;AAGvB,SACE,gBAAAU;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,KAAKT;AAAA,MACL,WAAWU;AAAA,QACT;AAAA,QACAC,EAAO,8BAA8B;AAAA,QACrCd,KAAe;AAAA,QACfA,KAAec,EAAO,0CAA0C;AAAA,MAAA;AAAA,MAGjE,UAAA;AAAA,QAAAd,KACC,gBAAAe;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,WAAWF;AAAA,cACT;AAAA,cACAC,EAAO,qCAAqC;AAAA,cAC5C;AAAA,YAAA;AAAA,YAEF,eAAW;AAAA,UAAA;AAAA,QAAA;AAAA,QAIf,gBAAAF;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,WAAWC;AAAA,cACT;AAAA,cACAC,EAAO,mCAAmC;AAAA,YAAA;AAAA,YAG5C,UAAA;AAAA,cAAA,gBAAAC;AAAA,gBAAC;AAAA,gBAAA;AAAA,kBACC,WAAWF;AAAA,oBACT;AAAA,oBACAC,E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AAAC,EAACmB,KAAM,aAAY,UAAS,OAAOA,EAAM,uBAAA,CAAwB,GACnE,IAEA,gBAAAnB;AAAA,UAACoB;AAAA,UAAA;AAAA,YACC,kBAAkBtB,EAAW,wBAAwBC,EAAO,sBAAsB,CAAC;AAAA,YAElF,UAAAK,EAAU,IAAI,CAACiB,GAAGC,MACjB,gBAAAzB,EAAC0B,EAAM,UAAN,EACE,UAAA;AAAA,cAAAD,IAAI,KACH,gBAAAtB;AAAA,gBAAC;AAAA,gBAAA;AAAA,kBACC,WAAWF,EAAW,0BAA0BC,EAAO,wBAAwB,CAAC;AAAA,kBAChF,MAAK;AAAA,gBAAA;AAAA,cAAA;AAAA,cAGT,gBAAAC;AAAA,gBAAClB;AAAA,gBAAA;AAAA,kBACC,UAAUuC;AAAA,kBACV,OAAOC;AAAA,kBACP,aAAajB,MAAqBiB;AAAA,kBAClC,UAAUf,EAAY,IAAIe,CAAC;AAAA,kBAC3B,UAAU,MAAMP,EAAeO,CAAC;AAAA,kBAChC,SAAS,CAACR,MAAO;AACf,oBAAAJ,EAAS,QAAQY,CAAC,IAAIR;AAAA,kBACxB;AAAA,gBAAA;AAAA,cAAA;AAAA,YACF,KAhBmBO,EAAE,MAAM,GAAGA,EAAE,UAAU,MAAM,IAAIC,CAAC,EAiBvD,CACD;AAAA,UAAA;AAAA,QAAA;AAAA,MACH;AAAA,IAAA;AAAA,EAAA;AAIR;"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const t = {
|
|
2
|
+
"citation-panel-empty": "_citation-panel-empty_13e4b_1",
|
|
3
|
+
"citation-panel-citation-summary-icon": "_citation-panel-citation-summary-icon_13e4b_8",
|
|
4
|
+
"citation-panel-citation-panel": "_citation-panel-citation-panel_13e4b_12",
|
|
5
|
+
"citation-panel-header": "_citation-panel-header_13e4b_20",
|
|
6
|
+
"citation-panel-title": "_citation-panel-title_13e4b_31",
|
|
7
|
+
"citation-panel-header-actions": "_citation-panel-header-actions_13e4b_39",
|
|
8
|
+
"citation-panel-count": "_citation-panel-count_13e4b_45",
|
|
9
|
+
"citation-panel-close-btn": "_citation-panel-close-btn_13e4b_53",
|
|
10
|
+
"citation-panel-divider": "_citation-panel-divider_13e4b_61",
|
|
11
|
+
"citation-panel-citation-item": "_citation-panel-citation-item_13e4b_68",
|
|
12
|
+
"citation-panel-citation-item-highlighted": "_citation-panel-citation-item-highlighted_13e4b_74",
|
|
13
|
+
"citation-panel-citation-item-marker": "_citation-panel-citation-item-marker_13e4b_78",
|
|
14
|
+
"citation-panel-citation-item-body": "_citation-panel-citation-item-body_13e4b_88",
|
|
15
|
+
"citation-panel-citation-item-index": "_citation-panel-citation-item-index_13e4b_94",
|
|
16
|
+
"citation-panel-citation-item-index-highlighted": "_citation-panel-citation-item-index-highlighted_13e4b_109",
|
|
17
|
+
"citation-panel-citation-item-index-default": "_citation-panel-citation-item-index-default_13e4b_113",
|
|
18
|
+
"citation-panel-citation-item-content": "_citation-panel-citation-item-content_13e4b_119",
|
|
19
|
+
"citation-panel-citation-item-header": "_citation-panel-citation-item-header_13e4b_124",
|
|
20
|
+
"citation-panel-citation-item-header-main": "_citation-panel-citation-item-header-main_13e4b_134",
|
|
21
|
+
"citation-panel-citation-item-header-interactive": "_citation-panel-citation-item-header-interactive_13e4b_139",
|
|
22
|
+
"citation-panel-citation-item-title": "_citation-panel-citation-item-title_13e4b_147",
|
|
23
|
+
"citation-panel-citation-item-meta": "_citation-panel-citation-item-meta_13e4b_160",
|
|
24
|
+
"citation-panel-citation-item-chevron": "_citation-panel-citation-item-chevron_13e4b_168",
|
|
25
|
+
"citation-panel-citation-item-chevron-expanded": "_citation-panel-citation-item-chevron-expanded_13e4b_176",
|
|
26
|
+
"citation-panel-citation-item-quote": "_citation-panel-citation-item-quote_13e4b_180"
|
|
27
|
+
};
|
|
28
|
+
export {
|
|
29
|
+
t as default
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=style.module.scss.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style.module.scss.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { jsx as t, jsxs as M } from "react/jsx-runtime";
|
|
2
|
+
import c from "mermaid";
|
|
3
|
+
import { useRef as d, useId as N, useState as u, useEffect as y } from "react";
|
|
4
|
+
import { sanitizeMermaidChart as I } from "../../utils/sanitizeMermaidChart.js";
|
|
5
|
+
import g from "./style.module.scss.js";
|
|
6
|
+
import s from "classnames";
|
|
7
|
+
let f = !1;
|
|
8
|
+
function z(e) {
|
|
9
|
+
const r = e instanceof Error ? e.message : "";
|
|
10
|
+
return /parse error/i.test(r) ? "图表语法有误,无法渲染" : r || "Mermaid 图表渲染失败";
|
|
11
|
+
}
|
|
12
|
+
const k = ({ chart: e, error: r }) => /* @__PURE__ */ M("div", { className: "mermaid-block mermaid-block--fallback", children: [
|
|
13
|
+
/* @__PURE__ */ t("pre", { children: /* @__PURE__ */ t("code", { className: "language-mermaid", children: e }) }),
|
|
14
|
+
r ? /* @__PURE__ */ t("p", { className: s("mermaid-block-content", g["mermaid-block-content"]), children: r }) : null
|
|
15
|
+
] }), _ = ({ chart: e, enabled: r = !0 }) => {
|
|
16
|
+
const p = d(null), b = N(), h = d(`mermaid-${b.replace(/:/g, "")}`), [m, a] = u(null), [o, i] = u(null);
|
|
17
|
+
return y(() => {
|
|
18
|
+
if (!r) {
|
|
19
|
+
a(null), i(null);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
let l = !1;
|
|
23
|
+
return (async () => {
|
|
24
|
+
try {
|
|
25
|
+
f || (c.initialize({
|
|
26
|
+
startOnLoad: !1,
|
|
27
|
+
securityLevel: "strict",
|
|
28
|
+
theme: "default"
|
|
29
|
+
}), f = !0);
|
|
30
|
+
const n = I(e), { svg: v } = await c.render(h.current, n);
|
|
31
|
+
l || (a(v), i(null));
|
|
32
|
+
} catch (n) {
|
|
33
|
+
l || (a(null), i(z(n)));
|
|
34
|
+
}
|
|
35
|
+
})(), () => {
|
|
36
|
+
l = !0;
|
|
37
|
+
};
|
|
38
|
+
}, [e, r]), r ? o ? /* @__PURE__ */ t(k, { chart: e, error: o }) : m ? /* @__PURE__ */ t("div", { ref: p, className: "mermaid-block", dangerouslySetInnerHTML: { __html: m } }) : /* @__PURE__ */ t("div", { className: s("mermaid-block", "mermaid-block--loading", s("mermaid-block-col", g["mermaid-block-col"])), children: "图表加载中…" }) : /* @__PURE__ */ t(k, { chart: e });
|
|
39
|
+
};
|
|
40
|
+
export {
|
|
41
|
+
_ as default
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../../src/components/AgentHub/Chat/Detail/MermaidBlock/index.tsx"],"sourcesContent":["import mermaid from 'mermaid';\nimport React, { useEffect, useId, useRef, useState } from 'react';\nimport { sanitizeMermaidChart } from '../../utils/sanitizeMermaidChart';\nimport styles from './style.module.scss';\nimport classNames from 'classnames';\n\nexport interface MermaidBlockProps {\n chart: string;\n enabled?: boolean;\n}\n\nlet mermaidInitialized = false;\n\nfunction formatMermaidError(err: unknown): string {\n const message = err instanceof Error ? err.message : '';\n if (/parse error/i.test(message)) {\n return '图表语法有误,无法渲染';\n }\n return message || 'Mermaid 图表渲染失败';\n}\n\nconst MermaidFallback: React.FC<{ chart: string; error?: string }> = ({ chart, error }) => (\n <div className=\"mermaid-block mermaid-block--fallback\">\n <pre>\n <code className=\"language-mermaid\">{chart}</code>\n </pre>\n {error ? <p className={classNames('mermaid-block-content', styles['mermaid-block-content'])}>{error}</p> : null}\n </div>\n);\n\nconst MermaidBlock: React.FC<MermaidBlockProps> = ({ chart, enabled = true }) => {\n const containerRef = useRef<HTMLDivElement>(null);\n const reactId = useId();\n const renderIdRef = useRef(`mermaid-${reactId.replace(/:/g, '')}`);\n const [svg, setSvg] = useState<string | null>(null);\n const [error, setError] = useState<string | null>(null);\n\n useEffect(() => {\n if (!enabled) {\n setSvg(null);\n setError(null);\n return;\n }\n\n let cancelled = false;\n\n const renderChart = async () => {\n try {\n if (!mermaidInitialized) {\n mermaid.initialize({\n startOnLoad: false,\n securityLevel: 'strict',\n theme: 'default',\n });\n mermaidInitialized = true;\n }\n\n const sanitizedChart = sanitizeMermaidChart(chart);\n const { svg: renderedSvg } = await mermaid.render(renderIdRef.current, sanitizedChart);\n if (!cancelled) {\n setSvg(renderedSvg);\n setError(null);\n }\n } catch (err) {\n if (!cancelled) {\n setSvg(null);\n setError(formatMermaidError(err));\n }\n }\n };\n\n void renderChart();\n\n return () => {\n cancelled = true;\n };\n }, [chart, enabled]);\n\n if (!enabled) {\n return <MermaidFallback chart={chart} />;\n }\n\n if (error) {\n return <MermaidFallback chart={chart} error={error} />;\n }\n\n if (!svg) {\n return (\n <div className={classNames('mermaid-block', 'mermaid-block--loading', classNames('mermaid-block-col', styles['mermaid-block-col']))}>\n 图表加载中…\n </div>\n );\n }\n\n return (\n <div ref={containerRef} className=\"mermaid-block\" dangerouslySetInnerHTML={{ __html: svg }} />\n );\n};\n\nexport default MermaidBlock;\n"],"names":["mermaidInitialized","formatMermaidError","err","message","MermaidFallback","chart","error","jsxs","jsx","classNames","styles","MermaidBlock","enabled","containerRef","useRef","reactId","useId","renderIdRef","svg","setSvg","useState","setError","useEffect","cancelled","mermaid","sanitizedChart","sanitizeMermaidChart","renderedSvg"],"mappings":";;;;;;AAWA,IAAIA,IAAqB;AAEzB,SAASC,EAAmBC,GAAsB;AAChD,QAAMC,IAAUD,aAAe,QAAQA,EAAI,UAAU;AACrD,SAAI,eAAe,KAAKC,CAAO,IACtB,gBAEFA,KAAW;AACpB;AAEA,MAAMC,IAA+D,CAAC,EAAE,OAAAC,GAAO,OAAAC,QAC7E,gBAAAC,EAAC,OAAA,EAAI,WAAU,yCACb,UAAA;AAAA,EAAA,gBAAAC,EAAC,SACC,UAAA,gBAAAA,EAAC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KAAKK,GAAc,WAAU,iBAAgB,yBAAyB,EAAE,QAAQK,EAAA,EAAI,CAAG,IAP1F,gBAAAV,EAAC,OAAA,EAAI,WAAWC,EAAW,iBAAiB,0BAA0BA,EAAW,qBAAqBC,EAAO,mBAAmB,CAAC,CAAC,GAAG,UAAA,UAErI,IAXK,gBAAAF,EAACJ,KAAgB,OAAAC,GAAc;AAkB1C;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style.module.scss.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { Pencil as b, Copy as r, RotateCw as g, ThumbsUp as k, ThumbsDown as f } from "../../../../Icons/index.js";
|
|
3
|
+
import { Button as h, Tooltip as d } from "antd";
|
|
4
|
+
import i from "./style.module.scss.js";
|
|
5
|
+
import n from "classnames";
|
|
6
|
+
import u from "../MessageEditPopover/index.js";
|
|
7
|
+
const A = ({
|
|
8
|
+
items: e,
|
|
9
|
+
align: m = "left",
|
|
10
|
+
editPopover: t,
|
|
11
|
+
actionsVisible: c
|
|
12
|
+
}) => {
|
|
13
|
+
const l = e.filter((s) => !s.hidden);
|
|
14
|
+
return l.length === 0 ? null : /* @__PURE__ */ a(
|
|
15
|
+
"div",
|
|
16
|
+
{
|
|
17
|
+
className: n(
|
|
18
|
+
"message-actions-message-actions",
|
|
19
|
+
i["message-actions-message-actions"],
|
|
20
|
+
c && "message-actions-visible",
|
|
21
|
+
c && i["message-actions-visible"],
|
|
22
|
+
m === "right" ? n("message-actions-right", i["message-actions-right"]) : n("message-actions-left", i["message-actions-left"])
|
|
23
|
+
),
|
|
24
|
+
children: l.map((s) => {
|
|
25
|
+
const o = /* @__PURE__ */ a(
|
|
26
|
+
h,
|
|
27
|
+
{
|
|
28
|
+
type: "text",
|
|
29
|
+
size: "small",
|
|
30
|
+
icon: s.icon,
|
|
31
|
+
disabled: s.disabled,
|
|
32
|
+
onClick: s.onClick,
|
|
33
|
+
className: n(
|
|
34
|
+
"message-actions-message-action-btn",
|
|
35
|
+
i["message-actions-message-action-btn"],
|
|
36
|
+
s.active ? n("message-actions-message-action-btn-active", i["message-actions-message-action-btn-active"]) : n("message-actions-message-action-btn-default", i["message-actions-message-action-btn-default"])
|
|
37
|
+
),
|
|
38
|
+
"aria-label": s.label,
|
|
39
|
+
"aria-pressed": s.active
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
return s.key === "edit" && t ? /* @__PURE__ */ a(u, { ...t, children: /* @__PURE__ */ a("span", { className: n("message-actions-message-action-btn-wrap", i["message-actions-message-action-btn-wrap"]), children: /* @__PURE__ */ a(d, { title: s.label, children: o }) }) }, s.key) : /* @__PURE__ */ a(d, { title: s.label, children: o }, s.key);
|
|
43
|
+
})
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
}, M = (e) => [
|
|
47
|
+
{
|
|
48
|
+
key: "edit",
|
|
49
|
+
label: "重新编辑",
|
|
50
|
+
icon: /* @__PURE__ */ a(b, {}),
|
|
51
|
+
onClick: e.onEdit ?? (() => {
|
|
52
|
+
}),
|
|
53
|
+
hidden: !e.onEdit,
|
|
54
|
+
disabled: e.editDisabled
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
key: "copy",
|
|
58
|
+
label: "复制",
|
|
59
|
+
icon: /* @__PURE__ */ a(r, {}),
|
|
60
|
+
onClick: e.onCopy
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
key: "resend",
|
|
64
|
+
label: "重新发送",
|
|
65
|
+
icon: /* @__PURE__ */ a(g, {}),
|
|
66
|
+
onClick: e.onResend ?? (() => {
|
|
67
|
+
}),
|
|
68
|
+
hidden: !e.onResend
|
|
69
|
+
}
|
|
70
|
+
], N = (e) => [
|
|
71
|
+
{
|
|
72
|
+
key: "like",
|
|
73
|
+
label: "赞",
|
|
74
|
+
icon: /* @__PURE__ */ a(k, {}),
|
|
75
|
+
onClick: e.onLike ?? (() => {
|
|
76
|
+
}),
|
|
77
|
+
hidden: !e.onLike,
|
|
78
|
+
disabled: e.feedbackDisabled,
|
|
79
|
+
active: e.thumbup === !0
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
key: "dislike",
|
|
83
|
+
label: "踩",
|
|
84
|
+
icon: /* @__PURE__ */ a(f, {}),
|
|
85
|
+
onClick: e.onDislike ?? (() => {
|
|
86
|
+
}),
|
|
87
|
+
hidden: !e.onDislike,
|
|
88
|
+
disabled: e.feedbackDisabled,
|
|
89
|
+
active: e.thumbup === !1
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
key: "copy",
|
|
93
|
+
label: "复制",
|
|
94
|
+
icon: /* @__PURE__ */ a(r, {}),
|
|
95
|
+
onClick: e.onCopy
|
|
96
|
+
}
|
|
97
|
+
];
|
|
98
|
+
export {
|
|
99
|
+
N as createAssistantMessageActions,
|
|
100
|
+
M as createUserMessageActions,
|
|
101
|
+
A as default
|
|
102
|
+
};
|
|
103
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../../src/components/AgentHub/Chat/Detail/MessageActions/index.tsx"],"sourcesContent":["import { Copy, Pencil, RotateCw, ThumbsDown, ThumbsUp } from '@/components/Icons';\nimport { Button, Tooltip } from 'antd';\nimport React from 'react';\nimport styles from './style.module.scss';\nimport classNames from 'classnames';\nimport MessageEditPopover, { type MessageEditPopoverProps } from '../MessageEditPopover';\n\nexport type MessageActionKey = 'edit' | 'copy' | 'resend' | 'like' | 'dislike';\n\nexport interface MessageActionItem {\n key: MessageActionKey;\n label: string;\n icon: React.ReactNode;\n onClick: () => void;\n hidden?: boolean;\n disabled?: boolean;\n active?: boolean;\n}\n\nexport interface MessageActionsProps {\n items: MessageActionItem[];\n align?: 'left' | 'right';\n editPopover?: Omit<MessageEditPopoverProps, 'children'>;\n actionsVisible?: boolean;\n}\n\nconst MessageActions: React.FC<MessageActionsProps> = ({\n items,\n align = 'left',\n editPopover,\n actionsVisible,\n}) => {\n const visibleItems = items.filter((item) => !item.hidden);\n if (visibleItems.length === 0) return null;\n\n return (\n <div\n className={classNames('message-actions-message-actions', styles['message-actions-message-actions'],\n actionsVisible && 'message-actions-visible',\n actionsVisible && styles['message-actions-visible'],\n align === 'right'\n ? classNames('message-actions-right', styles['message-actions-right'])\n : classNames('message-actions-left', styles['message-actions-left']),\n )}\n >\n {visibleItems.map((item) => {\n const button = (\n <Button\n type=\"text\"\n size=\"small\"\n icon={item.icon}\n disabled={item.disabled}\n onClick={item.onClick}\n className={classNames('message-actions-message-action-btn', styles['message-actions-message-action-btn'],\n item.active\n ? classNames('message-actions-message-action-btn-active', styles['message-actions-message-action-btn-active'])\n : classNames('message-actions-message-action-btn-default', styles['message-actions-message-action-btn-default']),\n )}\n aria-label={item.label}\n aria-pressed={item.active}\n />\n );\n\n if (item.key === 'edit' && editPopover) {\n return (\n <MessageEditPopover key={item.key} {...editPopover}>\n <span className={classNames('message-actions-message-action-btn-wrap', styles['message-actions-message-action-btn-wrap'])}>\n <Tooltip title={item.label}>{button}</Tooltip>\n </span>\n </MessageEditPopover>\n );\n }\n\n return (\n <Tooltip key={item.key} title={item.label}>\n {button}\n </Tooltip>\n );\n })}\n </div>\n );\n};\n\nexport const createUserMessageActions = (options: {\n onEdit?: () => void;\n onCopy: () => void;\n onResend?: () => void;\n editDisabled?: boolean;\n}): MessageActionItem[] => [\n {\n key: 'edit',\n label: '重新编辑',\n icon: <Pencil />,\n onClick: options.onEdit ?? (() => {}),\n hidden: !options.onEdit,\n disabled: options.editDisabled,\n },\n {\n key: 'copy',\n label: '复制',\n icon: <Copy />,\n onClick: options.onCopy,\n },\n {\n key: 'resend',\n label: '重新发送',\n icon: <RotateCw />,\n onClick: options.onResend ?? (() => {}),\n hidden: !options.onResend,\n },\n];\n\nexport const createAssistantMessageActions = (options: {\n onCopy: () => void;\n onLike?: () => void;\n onDislike?: () => void;\n thumbup?: boolean | null;\n feedbackDisabled?: boolean;\n}): MessageActionItem[] => [\n {\n key: 'like',\n label: '赞',\n icon: <ThumbsUp />,\n onClick: options.onLike ?? (() => {}),\n hidden: !options.onLike,\n disabled: options.feedbackDisabled,\n active: options.thumbup === true,\n },\n {\n key: 'dislike',\n label: '踩',\n icon: <ThumbsDown />,\n onClick: options.onDislike ?? (() => {}),\n hidden: !options.onDislike,\n disabled: options.feedbackDisabled,\n active: options.thumbup === false,\n },\n {\n key: 'copy',\n label: '复制',\n icon: <Copy />,\n onClick: options.onCopy,\n },\n];\n\nexport default MessageActions;\n"],"names":["MessageActions","items","align","editPopover","actionsVisible","visibleItems","item","jsx","classNames","styles","button","Button","MessageEditPopover","Tooltip","createUserMessageActions","options","Pencil","Copy","RotateCw","createAssistantMessageActions","ThumbsUp","ThumbsDown"],"mappings":";;;;;;AA0BA,MAAMA,IAAgD,CAAC;AAAA,EACrD,OAAAC;AAAA,EACA,OAAAC,IAAQ;AAAA,EACR,aAAAC;AAAA,EACA,gBAAAC;AACF,MAAM;AACJ,QAAMC,IAAeJ,EAAM,OAAO,CAACK,MAAS,CAACA,EAAK,MAAM;AACxD,SAAID,EAAa,WAAW,IAAU,OAGpC,gBAAAE;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAWC;AAAA,QAAW;AAAA,QAAmCC,EAAO,iCAAiC;AAAA,QAC/FL,KAAkB;AAAA,QAClBA,KAAkBK,EAAO,yBAAyB;AAAA,QAClDP,MAAU,UACNM,EAAW,yBAAyBC,EAAO,uBAAuB,CAAC,IACnED,EAAW,wBAAwBC,EAAO,sBAAsB,CAAC;AAAA,MAAA;AAAA,MAGtE,UAAAJ,EAAa,IAAI,CAACC,MAAS;AAC1B,cAAMI,IACJ,gBAAAH;AAAA,UAACI;AAAA,UAAA;AAAA,YACC,MAAK;AAAA,YACL,MAAK;AAAA,YACL,MAAML,EAAK;AAAA,YACX,UAAUA,EAAK;AAAA,YACf,SAASA,EAAK;AAAA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AAOK,GAAA,EAAS;AAAA,IAChB,SAASL,EAAQ,WAAW,MAAM;AAAA,IAAC;AAAA,IACnC,QAAQ,CAACA,EAAQ;AAAA,IACjB,UAAUA,EAAQ;AAAA,IAClB,QAAQA,EAAQ,YAAY;AAAA,EAAA;AAAA,EAE9B;AAAA,IACE,KAAK;AAAA,IACL,OAAO;AAAA,IACP,wBAAOM,GAAA,EAAW;AAAA,IAClB,SAASN,EAAQ,cAAc,MAAM;AAAA,IAAC;AAAA,IACtC,QAAQ,CAACA,EAAQ;AAAA,IACjB,UAAUA,EAAQ;AAAA,IAClB,QAAQA,EAAQ,YAAY;AAAA,EAAA;AAAA,EAE9B;AAAA,IACE,KAAK;AAAA,IACL,OAAO;AAAA,IACP,wBAAOE,GAAA,EAAK;AAAA,IACZ,SAASF,EAAQ;AAAA,EAAA;AAErB;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const e = {
|
|
2
|
+
"message-actions-message-actions": "_message-actions-message-actions_2eqe2_1",
|
|
3
|
+
"message-actions-visible": "_message-actions-visible_2eqe2_13",
|
|
4
|
+
"message-actions-left": "_message-actions-left_2eqe2_17",
|
|
5
|
+
"message-actions-right": "_message-actions-right_2eqe2_21",
|
|
6
|
+
"message-actions-message-action-btn": "_message-actions-message-action-btn_2eqe2_25",
|
|
7
|
+
"message-actions-message-action-btn-default": "_message-actions-message-action-btn-default_2eqe2_31",
|
|
8
|
+
"message-actions-message-action-btn-active": "_message-actions-message-action-btn-active_2eqe2_38",
|
|
9
|
+
"message-actions-message-action-btn-wrap": "_message-actions-message-action-btn-wrap_2eqe2_42"
|
|
10
|
+
};
|
|
11
|
+
export {
|
|
12
|
+
e as default
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=style.module.scss.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style.module.scss.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { jsxs as d, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { Input as v, Button as l, Popover as y } from "antd";
|
|
3
|
+
import { useEffect as h, useMemo as x } from "react";
|
|
4
|
+
import i from "./style.module.scss.js";
|
|
5
|
+
import a from "classnames";
|
|
6
|
+
const K = ({
|
|
7
|
+
open: o,
|
|
8
|
+
value: t,
|
|
9
|
+
originalContent: s,
|
|
10
|
+
onOpenChange: n,
|
|
11
|
+
onChange: m,
|
|
12
|
+
onConfirm: p,
|
|
13
|
+
onCancel: f,
|
|
14
|
+
children: u
|
|
15
|
+
}) => {
|
|
16
|
+
h(() => {
|
|
17
|
+
o && m(s);
|
|
18
|
+
}, [o, s, m]);
|
|
19
|
+
const c = x(
|
|
20
|
+
() => t.trim().length > 0 && t.trim() !== s.trim(),
|
|
21
|
+
[t, s]
|
|
22
|
+
), g = /* @__PURE__ */ d("div", { className: a("message-edit-popover-main", i["message-edit-popover-main"]), children: [
|
|
23
|
+
/* @__PURE__ */ r(
|
|
24
|
+
v.TextArea,
|
|
25
|
+
{
|
|
26
|
+
value: t,
|
|
27
|
+
onChange: (e) => m(e.target.value),
|
|
28
|
+
autoSize: { minRows: 2, maxRows: 6 },
|
|
29
|
+
placeholder: "编辑消息内容",
|
|
30
|
+
className: a("message-edit-popover-section", i["message-edit-popover-section"]),
|
|
31
|
+
onKeyDown: (e) => {
|
|
32
|
+
e.key === "Enter" && (e.metaKey || e.ctrlKey) && c && (e.preventDefault(), p());
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
),
|
|
36
|
+
/* @__PURE__ */ d("div", { className: a("message-edit-popover-group", i["message-edit-popover-group"]), children: [
|
|
37
|
+
/* @__PURE__ */ r(l, { size: "small", onClick: f, children: "取消" }),
|
|
38
|
+
/* @__PURE__ */ r(l, { type: "primary", size: "small", disabled: !c, onClick: p, children: "确认" })
|
|
39
|
+
] })
|
|
40
|
+
] });
|
|
41
|
+
return /* @__PURE__ */ r(
|
|
42
|
+
y,
|
|
43
|
+
{
|
|
44
|
+
open: o,
|
|
45
|
+
onOpenChange: n,
|
|
46
|
+
content: g,
|
|
47
|
+
trigger: [],
|
|
48
|
+
placement: "bottom",
|
|
49
|
+
arrow: { pointAtCenter: !0 },
|
|
50
|
+
destroyOnHidden: !0,
|
|
51
|
+
children: u
|
|
52
|
+
}
|
|
53
|
+
);
|
|
54
|
+
};
|
|
55
|
+
export {
|
|
56
|
+
K as default
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../../src/components/AgentHub/Chat/Detail/MessageEditPopover/index.tsx"],"sourcesContent":["import { Button, Input, Popover } from 'antd';\nimport React, { useEffect, useMemo } from 'react';\nimport styles from './style.module.scss';\nimport classNames from 'classnames';\n\nexport interface MessageEditPopoverProps {\n open: boolean;\n value: string;\n originalContent: string;\n onOpenChange: (open: boolean) => void;\n onChange: (value: string) => void;\n onConfirm: () => void;\n onCancel: () => void;\n children: React.ReactNode;\n}\n\nconst MessageEditPopover: React.FC<MessageEditPopoverProps> = ({\n open,\n value,\n originalContent,\n onOpenChange,\n onChange,\n onConfirm,\n onCancel,\n children,\n}) => {\n useEffect(() => {\n if (open) {\n onChange(originalContent);\n }\n }, [open, originalContent, onChange]);\n\n const canConfirm = useMemo(\n () => value.trim().length > 0 && value.trim() !== originalContent.trim(),\n [value, originalContent],\n );\n\n const content = (\n <div className={classNames('message-edit-popover-main', styles['message-edit-popover-main'])}>\n <Input.TextArea\n value={value}\n onChange={(e) => onChange(e.target.value)}\n autoSize={{ minRows: 2, maxRows: 6 }}\n placeholder=\"编辑消息内容\"\n className={classNames('message-edit-popover-section', styles['message-edit-popover-section'])}\n onKeyDown={(e) => {\n if (e.key === 'Enter' && (e.metaKey || e.ctrlKey) && canConfirm) {\n e.preventDefault();\n onConfirm();\n }\n }}\n />\n <div className={classNames('message-edit-popover-group', styles['message-edit-popover-group'])}>\n <Button size=\"small\" onClick={onCancel}>\n 取消\n </Button>\n <Button type=\"primary\" size=\"small\" disabled={!canConfirm} onClick={onConfirm}>\n 确认\n </Button>\n </div>\n </div>\n );\n\n return (\n <Popover\n open={open}\n onOpenChange={onOpenChange}\n content={content}\n trigger={[]}\n placement=\"bottom\"\n arrow={{ pointAtCenter: true }}\n destroyOnHidden\n >\n {children}\n </Popover>\n );\n};\n\nexport default MessageEditPopover;\n"],"names":["MessageEditPopover","open","value","originalContent","onOpenChange","onChange","onConfirm","onCancel","children","useEffect","canConfirm","useMemo","content","classNames","styles","jsx","Input","jsxs","Button","Popover"],"mappings":";;;;;AAgBA,MAAMA,IAAwD,CAAC;AAAA,EAC7D,MAAAC;AAAA,EACA,OAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,cAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC;AACF,MAAM;AACJ,EAAAC,EAAU,MAAM;AACd,IAAIR,KACFI,EAASF,CAAe;AAAA,EAE5B,GAAG,CAACF,GAAME,GAAiBE,CAAQ,CAAC;AAEpC,QAAMK,IAAaC;AAAA,IACjB,MAAMT,EAAM,KAAA,EAAO,SAAS,KAAKA,EAAM,KAAA,MAAWC,EAAgB,KAAA;AAAA,IAClE,CAACD,GAAOC,CAAe;AAAA,EAAA,GAGnBS,sBACH,OAAA,EAAI,WAAWC,EAAW,6BAA6BC,EAAO,2BAA2B,CAAC,GACzF,UAAA;AAAA,IAAA,gBAAAC;AAAA,MAACC,EAAM;AAAA,MAAN;AAAA,QACC,OAAAd;AAAA,QACA,UAAU,CAAC,MAAMG,EAAS,EAAE,OAAO,KAAK;AAAA,QACxC,UAAU,EAAE,SAAS,GAAG,SAAS,EAAA;AAAA,QACjC,aAAY;AAAA,QACZ,WAAWQ,EAAW,gCAAgCC,EAAO,8BAA8B,CAAC;AAAA,QAC5F,WAAW,CAAC,MAAM;AAChB,UAAI,EAAE,QAAQ,YAAY,EAAE,WAAW,EAAE,YAAYJ,MACnD,EAAE,eAAA,GACFJ,EAAA;AAAA,QAEJ;AAAA,MAAA;AAAA,IAAA;AAAA,IAEF,gBAAAW,EAAC,SAAI,WAAWJ,EAAW,8BAA8BC,EAAO,4BAA4B,CAAC,GAC3F,UAAA;AAAA,MAAA,gBAAAC,EAACG,GAAA,EAAO,MAAK,SAAQ,SAASX,GAAU,UAAA,MAExC;AAAA,MACA,gBAAAQ,EAACG,GAAA,EAAO,MAAK,WAAU,MAAK,SAAQ,UAAU,CAACR,GAAY,SAASJ,GAAW,UAAA,KAAA,CAE/E;AAAA,IAAA,EAAA,CACF;AAAA,EAAA,GACF;AAGF,SACE,gBAAAS;AAAA,IAACI;AAAA,IAAA;AAAA,MACC,MAAAlB;AAAA,MACA,cAAAG;AAAA,MACA,SAAAQ;AAAA,MACA,SAAS,CAAA;AAAA,MACT,WAAU;AAAA,MACV,OAAO,EAAE,eAAe,GAAA;AAAA,MACxB,iBAAe;AAAA,MAEd,UAAAJ;AAAA,IAAA;AAAA,EAAA;AAGP;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const e = {
|
|
2
|
+
"message-edit-popover-main": "_message-edit-popover-main_1ba21_1",
|
|
3
|
+
"message-edit-popover-section": "_message-edit-popover-section_1ba21_5",
|
|
4
|
+
"message-edit-popover-group": "_message-edit-popover-group_1ba21_9"
|
|
5
|
+
};
|
|
6
|
+
export {
|
|
7
|
+
e as default
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=style.module.scss.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style.module.scss.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
|