@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 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime");;/* empty css */const
|
|
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;
|