@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
10 lines (9 loc) • 2.57 kB
JavaScript
/**
* @license
*-------------------------------------------------------------------------------------------
* Copyright © 2025 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the package root for more information
*-------------------------------------------------------------------------------------------
*/
;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),y=require("../AIPromptContent.js"),j=require("../AIPromptFooter.js"),h=require("@progress/kendo-react-buttons"),i=require("@progress/kendo-react-inputs"),F=require("@progress/kendo-svg-icons"),I=require("@progress/kendo-react-common"),G=require("./AIPromptViewRender.js"),O=require("../AIPromptExpander.js"),z=require("../AIPromptContext.js"),M=require("../../chat/components/SuggestionsGroup.js"),W=require("./constants.js"),D=x=>{const{promptInput:A=i.TextArea,generateButton:f=h.Button,enableSpeechToText:n=!1,promptValue:S,promptSuggestions:a}=x,[r,s]=e.useState(S||""),[o]=z.useAIPromptContext(),[C,p]=I.useCustomComponent(f),[q,m]=I.useCustomComponent(A),E=()=>{o.onPromptRequest&&o.onPromptRequest.call(null,r),s("")},T=t=>{s(t)},R=t=>{s(t.target.value)},k={title:"Generate",children:"Generate",svgIcon:F.sparklesIcon},V={placeholder:"Ask or generate content with AI ...",rows:2},g=Object.keys(p).length>0?p:k,w=Object.keys(m).length>0?m:V,d=t=>{const{isFinal:u,alternatives:P}=t;if(u&&P.length>0){const b=P[0].transcript,v=(()=>{const c=r,B=c&&!c.endsWith(" ")&&!c.endsWith(`
`);return c+(B?" ":"")+b})();s(v)}};let l;return n&&(typeof n=="object"?l={...n,onResult:n.onResult||d}:l={onResult:d}),e.createElement(G.AIPromptViewRender,{name:W.promptViewDefaults.name},e.createElement(y.AIPromptContent,{streaming:o.streaming,onCancel:o.onCancel},e.createElement(q,{value:r,className:"!k-flex-col",suffix:n?e.createElement(e.Fragment,null,e.createElement(i.InputSeparator,{orientation:"horizontal"}),e.createElement(i.InputSuffix,{orientation:"horizontal"},e.createElement(h.SpeechToTextButton,{fillMode:"flat",...l}))):void 0,onChange:R,...w}),a&&a.length>0&&e.createElement(O.AIPromptExpander,{title:"Prompt Suggestions"},e.createElement(M.SuggestionGroup,{suggestionsView:o.suggestionsView,suggestions:a.map((t,u)=>({id:u,text:t,description:t})),onSuggestionClick:t=>{T(t.text)}}))),e.createElement(j.AIPromptFooter,null,e.createElement(C,{themeColor:"primary",fillMode:"solid",rounded:"full",size:"medium",onClick:E,disabled:!r.trim(),...g},g.children)))};exports.AIPromptView=D;