@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 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),T=require("react");;/* empty css */const N=({id:k,content:r,sender:n,timestamp:l,isThinking:d=!1,isLoading:f=!1,className:p="",style:w={},showTimestamp:c=!0,avatarUser:o,avatarAssistant:m,thinkingText:b="思考中...",customThinkingComponent:g,customUserMessageComponent:h,customAssistantMessageComponent:u,parseContent:L=!1,parsedContent:C,thinkContent:M,knowledgeSources:a})=>{const[i,q]=T.useState(!0);console.log(k,"id");const x=s=>s.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),j=()=>g||e.jsxs("div",{className:"message-thinking",children:[e.jsxs("div",{className:"message-thinking-dots",children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]}),e.jsx("span",{className:"message-thinking-text",children:b})]}),I=()=>e.jsx("div",{className:"message-loading",children:e.jsx("div",{className:"message-loading-spinner"})}),v=()=>!a||a.length===0?null:e.jsxs("div",{className:"message-knowledge-sources",children:[e.jsx("div",{className:"message-knowledge-sources-header",children:"知识来源:"}),e.jsx("ul",{className:"message-knowledge-sources-list",children:a.map((s,t)=>e.jsxs("li",{className:"message-knowledge-source-item",children:[s.url?e.jsx("a",{href:s.url,target:"_blank",rel:"noopener noreferrer",children:s.title}):e.jsx("span",{children:s.title}),s.description&&e.jsx("div",{className:"message-knowledge-source-description",children:s.description})]},t))})]}),S=()=>{if(f)return I();if(n==="user"&&h)return h;if(n==="assistant"&&u)return u;if(L&&n==="assistant"){const s=C||r,t=M;return e.jsxs(e.Fragment,{children:[d&&j(),s&&e.jsx("div",{className:"message-text",children:s}),t&&e.jsxs("div",{className:"message-think",children:[e.jsxs("div",{className:"message-think-header",children:["思考过程:",e.jsx("button",{className:"message-think-toggle",onClick:()=>q(!i),"aria-label":i?"隐藏思考过程":"显示思考过程",children:e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{transform:i?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.3s ease"},children:e.jsx("path",{d:"M2 4L6 8L10 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),e.jsx("div",{className:`message-think-content ${i?"visible":"hidden"}`,children:t})]}),v(),c&&e.jsx("div",{className:"message-timestamp",children:x(l)})]})}return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"message-text",children:r}),d&&j(),v(),c&&e.jsx("div",{className:"message-timestamp",children:x(l)})]})};return e.jsxs("div",{className:`message ${n==="user"?"user":"assistant"} ${p}`,style:w,children:[n==="user"&&o||n==="assistant"&&m?e.jsx("div",{className:"message-avatar",children:n==="user"?o:m}):null,e.jsx("div",{className:"message-content",children:S()})]})};exports.Message=N;exports.default=N;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Message.tsx';
|
package/dist/cjs/index.d.ts
CHANGED
package/dist/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});;/* empty css */const t=require("./components/button/Button.js"),r=require("./components/txt-reader/TxtReader.js"),n=require("./components/hyper-text/index.js"),i=require("./components/typing-animation/index.js"),o=require("./components/pinch-content/PinchContent.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});;/* empty css */const t=require("./components/button/Button.js"),r=require("./components/txt-reader/TxtReader.js"),n=require("./components/hyper-text/index.js"),i=require("./components/typing-animation/index.js"),o=require("./components/pinch-content/PinchContent.js"),a=require("./components/image-viewer/ImageViewer.js"),u=require("./components/shimmer-button/ShimmerButton.js"),c=require("./components/image-compare/ImageCompare.js"),s=require("./components/text-animate/TextAnimate.js"),e=require("./components/dock/Duck.js"),m=require("./components/txt-editor/TxtEditor.js"),d=require("./components/message/Message.js");exports.Button=t.Button;exports.TxtReader=r.TxtReader;exports.HyperText=n.HyperText;exports.TypingAnimation=i.TypingAnimation;exports.PinchContent=o.default;exports.ImageViewer=a.default;exports.ShimmerButton=u.ShimmerButton;exports.ImageCompare=c.default;exports.TextAnimate=s.TextAnimate;exports.Dock=e.Dock;exports.DockIcon=e.DockIcon;exports.dockVariants=e.dockVariants;exports.TxtEditor=m.TxtEditor;exports.Message=d.Message;
|