@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 a, jsx as e, Fragment as v } from "react/jsx-runtime";
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 q = ({
4
- id: f,
5
- content: t,
6
- sender: n,
7
- timestamp: l,
8
- isThinking: d = !1,
9
- isLoading: p = !1,
10
- className: k = "",
11
- style: x = {},
12
- showTimestamp: c = !0,
13
- avatarUser: w,
14
- avatarAssistant: j,
15
- thinkingText: I = "思考中...",
16
- customThinkingComponent: m,
17
- customUserMessageComponent: g,
18
- customAssistantMessageComponent: h,
19
- parseContent: L = !1,
20
- parsedContent: $,
21
- thinkContent: b,
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
- console.log(f, "id");
25
- const o = (s) => s.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }), u = () => m || /* @__PURE__ */ a("div", { className: "message-thinking", children: [
26
- /* @__PURE__ */ a("div", { className: "message-thinking-dots", children: [
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: I })
32
- ] }), C = () => /* @__PURE__ */ e("div", { className: "message-loading", children: /* @__PURE__ */ e("div", { className: "message-loading-spinner" }) }), N = () => !r || r.length === 0 ? null : /* @__PURE__ */ a("div", { className: "message-knowledge-sources", children: [
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, i) => /* @__PURE__ */ a("li", { className: "message-knowledge-source-item", children: [
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
- ] }, i)) })
38
- ] }), F = () => {
39
- if (p)
40
- return C();
41
- if (n === "user" && g)
42
- return g;
43
- if (n === "assistant" && h)
44
- return h;
45
- if (L && n === "assistant") {
46
- const s = $ || t, i = b;
47
- return /* @__PURE__ */ a(v, { children: [
48
- d && u(),
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
- i && /* @__PURE__ */ a("div", { className: "message-think", children: [
51
- /* @__PURE__ */ e("div", { className: "message-think-header", children: "思考过程:" }),
52
- /* @__PURE__ */ e("div", { className: "message-think-content", children: i })
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
- N(),
55
- c && /* @__PURE__ */ e("div", { className: "message-timestamp", children: o(l) })
96
+ f(),
97
+ o && /* @__PURE__ */ e("div", { className: "message-timestamp", children: v(d) })
56
98
  ] });
57
99
  }
58
- return /* @__PURE__ */ a(v, { children: [
59
- /* @__PURE__ */ e("div", { className: "message-text", children: t }),
60
- d && u(),
61
- N(),
62
- c && /* @__PURE__ */ e("div", { className: "message-timestamp", children: o(l) })
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__ */ a(
107
+ return /* @__PURE__ */ n(
66
108
  "div",
67
109
  {
68
- className: `message ${n === "user" ? "user" : "assistant"} ${k}`,
69
- style: x,
110
+ className: `message ${i === "user" ? "user" : "assistant"} ${b}`,
111
+ style: L,
70
112
  children: [
71
- /* @__PURE__ */ e("div", { className: "message-avatar", children: n === "user" ? w : j }),
72
- /* @__PURE__ */ e("div", { className: "message-content", children: F() })
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
- q as Message,
79
- q as default
120
+ S as Message,
121
+ S as default
80
122
  };