@xiping/react-components 1.0.7 → 1.0.8
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,80 +1,122 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as n, jsx as e, Fragment as p } from "react/jsx-runtime";
|
|
2
|
+
import { useState as B } from "react";
|
|
2
3
|
/* empty css */
|
|
3
|
-
const
|
|
4
|
-
id:
|
|
5
|
-
content:
|
|
6
|
-
sender:
|
|
7
|
-
timestamp:
|
|
8
|
-
isThinking:
|
|
9
|
-
isLoading:
|
|
10
|
-
className:
|
|
11
|
-
style:
|
|
12
|
-
showTimestamp:
|
|
13
|
-
avatarUser:
|
|
14
|
-
avatarAssistant:
|
|
15
|
-
thinkingText:
|
|
16
|
-
customThinkingComponent:
|
|
17
|
-
customUserMessageComponent:
|
|
18
|
-
customAssistantMessageComponent:
|
|
19
|
-
parseContent:
|
|
20
|
-
parsedContent:
|
|
21
|
-
thinkContent:
|
|
4
|
+
const S = ({
|
|
5
|
+
id: w,
|
|
6
|
+
content: l,
|
|
7
|
+
sender: i,
|
|
8
|
+
timestamp: d,
|
|
9
|
+
isThinking: c = !1,
|
|
10
|
+
isLoading: x = !1,
|
|
11
|
+
className: b = "",
|
|
12
|
+
style: L = {},
|
|
13
|
+
showTimestamp: o = !0,
|
|
14
|
+
avatarUser: m,
|
|
15
|
+
avatarAssistant: h,
|
|
16
|
+
thinkingText: C = "思考中...",
|
|
17
|
+
customThinkingComponent: g,
|
|
18
|
+
customUserMessageComponent: u,
|
|
19
|
+
customAssistantMessageComponent: N,
|
|
20
|
+
parseContent: j = !1,
|
|
21
|
+
parsedContent: I,
|
|
22
|
+
thinkContent: $,
|
|
22
23
|
knowledgeSources: r
|
|
23
24
|
}) => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
const [a, T] = B(!0);
|
|
26
|
+
console.log(w, "id");
|
|
27
|
+
const v = (s) => s.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }), k = () => g || /* @__PURE__ */ n("div", { className: "message-thinking", children: [
|
|
28
|
+
/* @__PURE__ */ n("div", { className: "message-thinking-dots", children: [
|
|
27
29
|
/* @__PURE__ */ e("span", {}),
|
|
28
30
|
/* @__PURE__ */ e("span", {}),
|
|
29
31
|
/* @__PURE__ */ e("span", {})
|
|
30
32
|
] }),
|
|
31
|
-
/* @__PURE__ */ e("span", { className: "message-thinking-text", children:
|
|
32
|
-
] }),
|
|
33
|
+
/* @__PURE__ */ e("span", { className: "message-thinking-text", children: C })
|
|
34
|
+
] }), V = () => /* @__PURE__ */ e("div", { className: "message-loading", children: /* @__PURE__ */ e("div", { className: "message-loading-spinner" }) }), f = () => !r || r.length === 0 ? null : /* @__PURE__ */ n("div", { className: "message-knowledge-sources", children: [
|
|
33
35
|
/* @__PURE__ */ e("div", { className: "message-knowledge-sources-header", children: "知识来源:" }),
|
|
34
|
-
/* @__PURE__ */ e("ul", { className: "message-knowledge-sources-list", children: r.map((s,
|
|
36
|
+
/* @__PURE__ */ e("ul", { className: "message-knowledge-sources-list", children: r.map((s, t) => /* @__PURE__ */ n("li", { className: "message-knowledge-source-item", children: [
|
|
35
37
|
s.url ? /* @__PURE__ */ e("a", { href: s.url, target: "_blank", rel: "noopener noreferrer", children: s.title }) : /* @__PURE__ */ e("span", { children: s.title }),
|
|
36
38
|
s.description && /* @__PURE__ */ e("div", { className: "message-knowledge-source-description", children: s.description })
|
|
37
|
-
] },
|
|
38
|
-
] }),
|
|
39
|
-
if (
|
|
40
|
-
return
|
|
41
|
-
if (
|
|
42
|
-
return
|
|
43
|
-
if (
|
|
44
|
-
return
|
|
45
|
-
if (
|
|
46
|
-
const s =
|
|
47
|
-
return /* @__PURE__ */
|
|
48
|
-
|
|
39
|
+
] }, t)) })
|
|
40
|
+
] }), y = () => {
|
|
41
|
+
if (x)
|
|
42
|
+
return V();
|
|
43
|
+
if (i === "user" && u)
|
|
44
|
+
return u;
|
|
45
|
+
if (i === "assistant" && N)
|
|
46
|
+
return N;
|
|
47
|
+
if (j && i === "assistant") {
|
|
48
|
+
const s = I || l, t = $;
|
|
49
|
+
return /* @__PURE__ */ n(p, { children: [
|
|
50
|
+
c && k(),
|
|
49
51
|
s && /* @__PURE__ */ e("div", { className: "message-text", children: s }),
|
|
50
|
-
|
|
51
|
-
/* @__PURE__ */
|
|
52
|
-
|
|
52
|
+
t && /* @__PURE__ */ n("div", { className: "message-think", children: [
|
|
53
|
+
/* @__PURE__ */ n("div", { className: "message-think-header", children: [
|
|
54
|
+
"思考过程:",
|
|
55
|
+
/* @__PURE__ */ e(
|
|
56
|
+
"button",
|
|
57
|
+
{
|
|
58
|
+
className: "message-think-toggle",
|
|
59
|
+
onClick: () => T(!a),
|
|
60
|
+
"aria-label": a ? "隐藏思考过程" : "显示思考过程",
|
|
61
|
+
children: /* @__PURE__ */ e(
|
|
62
|
+
"svg",
|
|
63
|
+
{
|
|
64
|
+
width: "12",
|
|
65
|
+
height: "12",
|
|
66
|
+
viewBox: "0 0 12 12",
|
|
67
|
+
fill: "none",
|
|
68
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
69
|
+
style: {
|
|
70
|
+
transform: a ? "rotate(180deg)" : "rotate(0deg)",
|
|
71
|
+
transition: "transform 0.3s ease"
|
|
72
|
+
},
|
|
73
|
+
children: /* @__PURE__ */ e(
|
|
74
|
+
"path",
|
|
75
|
+
{
|
|
76
|
+
d: "M2 4L6 8L10 4",
|
|
77
|
+
stroke: "currentColor",
|
|
78
|
+
strokeWidth: "1.5",
|
|
79
|
+
strokeLinecap: "round",
|
|
80
|
+
strokeLinejoin: "round"
|
|
81
|
+
}
|
|
82
|
+
)
|
|
83
|
+
}
|
|
84
|
+
)
|
|
85
|
+
}
|
|
86
|
+
)
|
|
87
|
+
] }),
|
|
88
|
+
/* @__PURE__ */ e(
|
|
89
|
+
"div",
|
|
90
|
+
{
|
|
91
|
+
className: `message-think-content ${a ? "visible" : "hidden"}`,
|
|
92
|
+
children: t
|
|
93
|
+
}
|
|
94
|
+
)
|
|
53
95
|
] }),
|
|
54
|
-
|
|
55
|
-
|
|
96
|
+
f(),
|
|
97
|
+
o && /* @__PURE__ */ e("div", { className: "message-timestamp", children: v(d) })
|
|
56
98
|
] });
|
|
57
99
|
}
|
|
58
|
-
return /* @__PURE__ */
|
|
59
|
-
/* @__PURE__ */ e("div", { className: "message-text", children:
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
100
|
+
return /* @__PURE__ */ n(p, { children: [
|
|
101
|
+
/* @__PURE__ */ e("div", { className: "message-text", children: l }),
|
|
102
|
+
c && k(),
|
|
103
|
+
f(),
|
|
104
|
+
o && /* @__PURE__ */ e("div", { className: "message-timestamp", children: v(d) })
|
|
63
105
|
] });
|
|
64
106
|
};
|
|
65
|
-
return /* @__PURE__ */
|
|
107
|
+
return /* @__PURE__ */ n(
|
|
66
108
|
"div",
|
|
67
109
|
{
|
|
68
|
-
className: `message ${
|
|
69
|
-
style:
|
|
110
|
+
className: `message ${i === "user" ? "user" : "assistant"} ${b}`,
|
|
111
|
+
style: L,
|
|
70
112
|
children: [
|
|
71
|
-
/* @__PURE__ */ e("div", { className: "message-avatar", children:
|
|
72
|
-
/* @__PURE__ */ e("div", { className: "message-content", children:
|
|
113
|
+
i === "user" && m || i === "assistant" && h ? /* @__PURE__ */ e("div", { className: "message-avatar", children: i === "user" ? m : h }) : null,
|
|
114
|
+
/* @__PURE__ */ e("div", { className: "message-content", children: y() })
|
|
73
115
|
]
|
|
74
116
|
}
|
|
75
117
|
);
|
|
76
118
|
};
|
|
77
119
|
export {
|
|
78
|
-
|
|
79
|
-
|
|
120
|
+
S as Message,
|
|
121
|
+
S as default
|
|
80
122
|
};
|