@xiping/react-components 1.0.6 → 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.
- package/dist/cjs/components/message/Message.d.ts +28 -0
- package/dist/cjs/components/message/Message.js +1 -0
- package/dist/cjs/components/message/index.d.ts +1 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/react-components.css +1 -1
- package/dist/es/components/message/Message.d.ts +28 -0
- package/dist/es/components/message/Message.js +122 -0
- package/dist/es/components/message/index.d.ts +1 -0
- package/dist/es/index.d.ts +1 -0
- package/dist/es/index.js +8 -6
- package/dist/es/react-components.css +1 -1
- package/package.json +15 -15
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
export interface MessageProps {
|
|
3
|
+
id: string;
|
|
4
|
+
content: string;
|
|
5
|
+
sender: "user" | "assistant";
|
|
6
|
+
timestamp: Date;
|
|
7
|
+
isThinking?: boolean;
|
|
8
|
+
isLoading?: boolean;
|
|
9
|
+
className?: string;
|
|
10
|
+
style?: React.CSSProperties;
|
|
11
|
+
showTimestamp?: boolean;
|
|
12
|
+
avatarUser?: React.ReactNode;
|
|
13
|
+
avatarAssistant?: React.ReactNode;
|
|
14
|
+
thinkingText?: string;
|
|
15
|
+
customThinkingComponent?: React.ReactNode;
|
|
16
|
+
customUserMessageComponent?: React.ReactNode;
|
|
17
|
+
customAssistantMessageComponent?: React.ReactNode;
|
|
18
|
+
parseContent?: boolean;
|
|
19
|
+
parsedContent?: string;
|
|
20
|
+
thinkContent?: string;
|
|
21
|
+
knowledgeSources?: Array<{
|
|
22
|
+
title: string;
|
|
23
|
+
description?: string;
|
|
24
|
+
url?: string;
|
|
25
|
+
}>;
|
|
26
|
+
}
|
|
27
|
+
export declare const Message: React.FC<MessageProps>;
|
|
28
|
+
export default Message;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { jsxs as n, jsx as e, Fragment as p } from "react/jsx-runtime";
|
|
2
|
+
import { useState as B } from "react";
|
|
3
|
+
/* empty css */
|
|
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: $,
|
|
23
|
+
knowledgeSources: r
|
|
24
|
+
}) => {
|
|
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: [
|
|
29
|
+
/* @__PURE__ */ e("span", {}),
|
|
30
|
+
/* @__PURE__ */ e("span", {}),
|
|
31
|
+
/* @__PURE__ */ e("span", {})
|
|
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: [
|
|
35
|
+
/* @__PURE__ */ e("div", { className: "message-knowledge-sources-header", children: "知识来源:" }),
|
|
36
|
+
/* @__PURE__ */ e("ul", { className: "message-knowledge-sources-list", children: r.map((s, t) => /* @__PURE__ */ n("li", { className: "message-knowledge-source-item", children: [
|
|
37
|
+
s.url ? /* @__PURE__ */ e("a", { href: s.url, target: "_blank", rel: "noopener noreferrer", children: s.title }) : /* @__PURE__ */ e("span", { children: s.title }),
|
|
38
|
+
s.description && /* @__PURE__ */ e("div", { className: "message-knowledge-source-description", children: s.description })
|
|
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(),
|
|
51
|
+
s && /* @__PURE__ */ e("div", { className: "message-text", children: s }),
|
|
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
|
+
)
|
|
95
|
+
] }),
|
|
96
|
+
f(),
|
|
97
|
+
o && /* @__PURE__ */ e("div", { className: "message-timestamp", children: v(d) })
|
|
98
|
+
] });
|
|
99
|
+
}
|
|
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) })
|
|
105
|
+
] });
|
|
106
|
+
};
|
|
107
|
+
return /* @__PURE__ */ n(
|
|
108
|
+
"div",
|
|
109
|
+
{
|
|
110
|
+
className: `message ${i === "user" ? "user" : "assistant"} ${b}`,
|
|
111
|
+
style: L,
|
|
112
|
+
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() })
|
|
115
|
+
]
|
|
116
|
+
}
|
|
117
|
+
);
|
|
118
|
+
};
|
|
119
|
+
export {
|
|
120
|
+
S as Message,
|
|
121
|
+
S as default
|
|
122
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Message.tsx';
|
package/dist/es/index.d.ts
CHANGED
package/dist/es/index.js
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
/* empty css */
|
|
2
|
-
import { Button as
|
|
2
|
+
import { Button as t } from "./components/button/Button.js";
|
|
3
3
|
import { TxtReader as p } from "./components/txt-reader/TxtReader.js";
|
|
4
4
|
import { HyperText as a } from "./components/hyper-text/index.js";
|
|
5
5
|
import { TypingAnimation as n } from "./components/typing-animation/index.js";
|
|
6
6
|
import { default as d } from "./components/pinch-content/PinchContent.js";
|
|
7
|
-
import { default as
|
|
8
|
-
import { ShimmerButton as
|
|
7
|
+
import { default as c } from "./components/image-viewer/ImageViewer.js";
|
|
8
|
+
import { ShimmerButton as T } from "./components/shimmer-button/ShimmerButton.js";
|
|
9
9
|
import { default as k } from "./components/image-compare/ImageCompare.js";
|
|
10
10
|
import { TextAnimate as I } from "./components/text-animate/TextAnimate.js";
|
|
11
11
|
import { Dock as y, DockIcon as A, dockVariants as B } from "./components/dock/Duck.js";
|
|
12
12
|
import { TxtEditor as D } from "./components/txt-editor/TxtEditor.js";
|
|
13
|
+
import { Message as w } from "./components/message/Message.js";
|
|
13
14
|
export {
|
|
14
|
-
|
|
15
|
+
t as Button,
|
|
15
16
|
y as Dock,
|
|
16
17
|
A as DockIcon,
|
|
17
18
|
a as HyperText,
|
|
18
19
|
k as ImageCompare,
|
|
19
|
-
|
|
20
|
+
c as ImageViewer,
|
|
21
|
+
w as Message,
|
|
20
22
|
d as PinchContent,
|
|
21
|
-
|
|
23
|
+
T as ShimmerButton,
|
|
22
24
|
I as TextAnimate,
|
|
23
25
|
D as TxtEditor,
|
|
24
26
|
p as TxtReader,
|