@xiping/react-components 1.0.7 → 1.0.9
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"),C=require("react"),a=require("react-markdown");;/* empty css */const b=({id:L,content:l,sender:i,timestamp:o,isThinking:d=!1,isLoading:y=!1,className:M="",style:S={},showTimestamp:c=!0,avatarUser:h,avatarAssistant:m,thinkingText:V="思考中...",customThinkingComponent:g,customUserMessageComponent:u,customAssistantMessageComponent:x,parseContent:q=!1,parsedContent:j,thinkContent:r,knowledgeSources:n})=>{const[t,p]=C.useState(!0),[B,v]=C.useState("idle");console.log(L,"id");const k=s=>s.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),H=async()=>{try{await navigator.clipboard.writeText(l),v("copied"),setTimeout(()=>v("idle"),2e3)}catch(s){console.error("复制失败:",s)}},N=()=>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:V})]}),W=()=>e.jsx("div",{className:"message-loading",children:e.jsx("div",{className:"message-loading-spinner"})}),w=()=>!n||n.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:n.map((s,$)=>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})]},$))})]}),f=()=>i==="user"?null:e.jsxs("button",{className:"message-copy-button",onClick:H,"aria-label":"Copy message",title:"Copy message",children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M13.3333 6H7.33333C6.59695 6 6 6.59695 6 7.33333V13.3333C6 14.0697 6.59695 14.6667 7.33333 14.6667H13.3333C14.0697 14.6667 14.6667 14.0697 14.6667 13.3333V7.33333C14.6667 6.59695 14.0697 6 13.3333 6Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M3.33333 10H2.66667C2.31305 10 1.97391 9.85953 1.72386 9.60948C1.47381 9.35943 1.33334 9.02029 1.33334 8.66667V2.66667C1.33334 2.31305 1.47381 1.97391 1.72386 1.72386C1.97391 1.47381 2.31305 1.33334 2.66667 1.33334H8.66667C9.02029 1.33334 9.35943 1.47381 9.60948 1.72386C9.85953 1.97391 10 2.31305 10 2.66667V3.33334",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),B==="copied"&&e.jsx("span",{className:"message-copy-tooltip",children:"Copied"})]});return i==="user"&&u?u:i==="assistant"&&x?x:e.jsxs("div",{className:`message ${i==="user"?"user":"assistant"} ${M}`,style:S,children:[i==="user"&&h||i==="assistant"&&m?e.jsx("div",{className:"message-avatar",children:i==="user"?h:m}):null,e.jsx("div",{className:"message-content",children:y?W():q&&i==="assistant"?e.jsxs(e.Fragment,{children:[r&&e.jsxs("div",{className:"message-think",children:[e.jsxs("div",{className:"message-think-header",children:["思考过程:",e.jsx("button",{className:"message-think-toggle",onClick:()=>p(!t),"aria-label":t?"隐藏思考过程":"显示思考过程",children:e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{transform:t?"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 ${t?"visible":"hidden"}`,children:e.jsx(a,{children:r})})]}),d&&N(),j&&e.jsxs("div",{className:"message-text-container",children:[e.jsx("div",{className:"message-text",children:e.jsx(a,{children:j})}),f()]}),w(),c&&e.jsx("div",{className:"message-timestamp",children:k(o)})]}):e.jsxs(e.Fragment,{children:[r&&e.jsxs("div",{className:"message-think",children:[e.jsxs("div",{className:"message-think-header",children:["思考过程:",e.jsx("button",{className:"message-think-toggle",onClick:()=>p(!t),"aria-label":t?"隐藏思考过程":"显示思考过程",children:e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{transform:t?"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 ${t?"visible":"hidden"}`,children:e.jsx(a,{children:r})})]}),e.jsxs("div",{className:"message-text-container",children:[e.jsx("div",{className:"message-text",children:e.jsx(a,{children:l})}),f()]}),d&&N(),w(),c&&e.jsx("div",{className:"message-timestamp",children:k(o)})]})})]})};exports.Message=b;exports.default=b;
|