UNPKG

@progress/kendo-react-conversational-ui

Version:

React Chat component allows the user to participate in chat sessions with users or chat bots. KendoReact Conversational UI components

9 lines (8 loc) 3.05 kB
/** * @license *------------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the package root for more information *------------------------------------------------------------------------------------------- */ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),v=require("../AIPromptContent.js"),q=require("../AIPromptContext.js"),s=require("../../messages/index.js"),T=require("./AIPromptViewRender.js"),n=require("@progress/kendo-react-layout"),r=require("@progress/kendo-svg-icons"),l=require("@progress/kendo-react-buttons"),k=require("@progress/kendo-react-intl"),g={name:"Output view",buttonText:"Output",buttonIcon:r.commentIcon},w=y=>{const[R,m]=t.useState(""),o=t.useRef(null),[a]=q.useAIPromptContext(),{outputs:i,showOutputRating:E,outputCard:b}=y,{header:d,body:u,actions:p}=b||{},h=k.useLocalization(),P=e=>{a.onPromptRequest&&a.onPromptRequest.call(null,e.prompt,{...e,isRetry:!0}),I()},f=e=>{e!=null&&e.responseContent&&navigator.clipboard.writeText(e.responseContent),m(e.id),setTimeout(()=>{m("")},1e3)},C=(e,c)=>{a.onPromptRequest&&a.onPromptRequest.call(null,e.prompt,{...e,ratingType:c,isRetry:!1}),I()},I=()=>{o&&o.current&&o.current.scrollTo({top:0,behavior:"smooth"})};return t.createElement(T.AIPromptViewRender,{name:g.name},t.createElement(v.AIPromptContent,{ref:o},t.createElement("div",{className:"k-card-list"},i&&i.length>0?i.map((e,c)=>t.createElement(n.Card,{key:`${e.id}_${c}`},t.createElement(n.CardHeader,null,d?d(e):t.createElement(t.Fragment,null,e.title&&t.createElement(n.CardTitle,null,e.title),e.subTitle&&t.createElement(n.CardSubtitle,null,e.subTitle))),t.createElement(n.CardBody,null,u?u(e):e.responseContent),t.createElement(n.CardActions,null,p?p(e):t.createElement(t.Fragment,null,t.createElement(l.Button,{size:"medium",themeColor:"primary",fillMode:"flat",rounded:"medium",title:"Copy",svgIcon:R===e.id?r.copyIcon:r.checkIcon,"aria-hidden":"true",onClick:()=>f(e)},"Copy"),t.createElement(l.Button,{size:"medium",themeColor:"base",fillMode:"flat",rounded:"medium",title:"Retry",svgIcon:r.rotateIcon,"aria-hidden":"true",onClick:()=>P(e)},"Retry"),E&&t.createElement(t.Fragment,null,t.createElement("span",{className:"k-spacer"}),t.createElement(l.Button,{size:"medium",themeColor:e.ratingType==="positive"?"primary":"base",fillMode:"flat",rounded:"medium",title:"Rate up",svgIcon:r.thumbUpOutlineIcon,"aria-hidden":"true",onClick:()=>C(e,"positive")}),t.createElement(l.Button,{size:"medium",themeColor:e.ratingType==="negative"?"primary":"base",fillMode:"flat",rounded:"medium",title:"Rate down",svgIcon:r.thumbDownOutlineIcon,"aria-hidden":"true",onClick:()=>C(e,"negative")})))))):t.createElement(n.Card,null,t.createElement(n.CardBody,null,h.toLanguageString(s.aIPromptNoOutputs,s.messages[s.aIPromptNoOutputs]))))))};exports.AIPromptOutputView=w;exports.outputViewDefaults=g;