@progress/kendo-react-conversational-ui 11.4.0-develop.2 → 11.4.0-develop.4
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/ai-prompt/views/AIPromptOutputView.js +1 -1
- package/ai-prompt/views/AIPromptOutputView.mjs +8 -8
- package/dist/cdn/js/kendo-react-conversational-ui.js +1 -1
- package/index.d.mts +209 -0
- package/index.d.ts +209 -0
- package/index.js +1 -1
- package/index.mjs +11 -9
- package/inline-ai-prompt/InlineAIPrompt.js +8 -0
- package/inline-ai-prompt/InlineAIPrompt.mjs +175 -0
- package/inline-ai-prompt/InlineAIPromptInput.js +9 -0
- package/inline-ai-prompt/InlineAIPromptInput.mjs +102 -0
- package/inline-ai-prompt/InlineAIPromptPopup.js +8 -0
- package/inline-ai-prompt/InlineAIPromptPopup.mjs +36 -0
- package/package-metadata.js +1 -1
- package/package-metadata.mjs +2 -2
- package/package.json +7 -7
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),v=require("../AIPromptContent.js"),q=require("../AIPromptContext.js"),m=require("../../messages/index.js"),O=require("./AIPromptViewRender.js"),n=require("@progress/kendo-react-layout"),r=require("@progress/kendo-svg-icons"),a=require("@progress/kendo-react-buttons"),x=require("@progress/kendo-react-intl"),g={name:"Output view",buttonText:"Output",buttonIcon:r.commentIcon},A=y=>{const[R,d]=e.useState(""),o=e.useRef(null),[l]=q.useAIPromptContext(),{outputs:s,showOutputRating:I,outputCard:b}=y,{header:u,body:p,actions:C}=b||{},h=x.useLocalization(),T=t=>{l.onPromptRequest&&l.onPromptRequest.call(null,t.prompt,{...t,isRetry:!0}),E()},w=t=>{t!=null&&t.responseContent&&navigator.clipboard.writeText(t.responseContent),d(t.id),setTimeout(()=>{d("")},1e3)},k=(t,i)=>{l.onPromptRequest&&l.onPromptRequest.call(null,t.prompt,{...t,ratingType:i,isRetry:!1}),E()},E=()=>{o&&o.current&&o.current.scrollTo({top:0,behavior:"smooth"})},P=e.createElement(n.Card,null,e.createElement(n.CardHeader,null,e.createElement(n.CardTitle,null,e.createElement("span",{className:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"200px"}})),e.createElement(n.CardSubtitle,null,e.createElement("span",{className:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"100%"}}))),e.createElement(n.CardBody,null,e.createElement("span",{className:"k-skeleton k-skeleton-rect k-skeleton-pulse",style:{height:"80px"}})),e.createElement(n.CardActions,null,e.createElement("span",{className:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"100%"}}))),c=s==null?void 0:s.map((t,i)=>e.createElement(n.Card,{key:`${t.id}_${i}`},e.createElement(n.CardHeader,null,u?u(t):e.createElement(e.Fragment,null,t.title&&e.createElement(n.CardTitle,null,t.title),t.subTitle&&e.createElement(n.CardSubtitle,null,t.subTitle))),e.createElement(n.CardBody,null,p?p(t):t.responseContent),e.createElement(n.CardActions,null,C?C(t):e.createElement(e.Fragment,null,e.createElement(a.Button,{size:"medium",themeColor:"primary",fillMode:"flat",rounded:"medium",title:"Copy",svgIcon:R===t.id?r.checkIcon:r.copyIcon,onClick:()=>w(t)},"Copy"),e.createElement(a.Button,{size:"medium",themeColor:"base",fillMode:"flat",rounded:"medium",title:"Retry",svgIcon:r.arrowRotateCwIcon,onClick:()=>T(t)},"Retry"),I&&e.createElement(e.Fragment,null,e.createElement("span",{className:"k-spacer"}),e.createElement(a.Button,{size:"medium",themeColor:t.ratingType==="positive"?"primary":"base",fillMode:"flat",rounded:"medium",title:"Rate up",svgIcon:r.thumbUpOutlineIcon,onClick:()=>k(t,"positive")}),e.createElement(a.Button,{size:"medium",themeColor:t.ratingType==="negative"?"primary":"base",fillMode:"flat",rounded:"medium",title:"Rate down",svgIcon:r.thumbDownOutlineIcon,onClick:()=>k(t,"negative")})))))),f=e.createElement(n.Card,null,e.createElement(n.CardBody,null,h.toLanguageString(m.aIPromptNoOutputs,m.messages[m.aIPromptNoOutputs])));return e.createElement(O.AIPromptViewRender,{name:g.name},e.createElement(v.AIPromptContent,{ref:o,streaming:l.streaming,onCancel:l.onCancel},e.createElement("div",{className:"k-card-list"},l.streaming&&P,c,(!c||c.length===0)&&!l.streaming&&f)))};exports.AIPromptOutputView=A;exports.outputViewDefaults=g;
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
import e from "react";
|
|
9
9
|
import { AIPromptContent as N } from "../AIPromptContent.mjs";
|
|
10
10
|
import { useAIPromptContext as z } from "../AIPromptContext.mjs";
|
|
11
|
-
import { aIPromptNoOutputs as
|
|
11
|
+
import { aIPromptNoOutputs as E, messages as A } from "../../messages/index.mjs";
|
|
12
12
|
import { AIPromptViewRender as q } from "./AIPromptViewRender.mjs";
|
|
13
13
|
import { Card as s, CardHeader as g, CardTitle as f, CardSubtitle as y, CardBody as c, CardActions as R } from "@progress/kendo-react-layout";
|
|
14
|
-
import { commentIcon as M, checkIcon as F, copyIcon as S,
|
|
14
|
+
import { commentIcon as M, checkIcon as F, copyIcon as S, arrowRotateCwIcon as V, thumbUpOutlineIcon as _, thumbDownOutlineIcon as B } from "@progress/kendo-svg-icons";
|
|
15
15
|
import { Button as r } from "@progress/kendo-react-buttons";
|
|
16
16
|
import { useLocalization as D } from "@progress/kendo-react-intl";
|
|
17
17
|
const L = {
|
|
@@ -19,15 +19,15 @@ const L = {
|
|
|
19
19
|
buttonText: "Output",
|
|
20
20
|
buttonIcon: M
|
|
21
21
|
}, X = (h) => {
|
|
22
|
-
const [b, i] = e.useState(""), l = e.useRef(null), [n] = z(), { outputs: o, showOutputRating: I, outputCard: T } = h, { header: d, body: p, actions: u } = T || {},
|
|
23
|
-
n.onPromptRequest && n.onPromptRequest.call(null, t.prompt, { ...t, isRetry: !0 }),
|
|
22
|
+
const [b, i] = e.useState(""), l = e.useRef(null), [n] = z(), { outputs: o, showOutputRating: I, outputCard: T } = h, { header: d, body: p, actions: u } = T || {}, w = D(), v = (t) => {
|
|
23
|
+
n.onPromptRequest && n.onPromptRequest.call(null, t.prompt, { ...t, isRetry: !0 }), C();
|
|
24
24
|
}, x = (t) => {
|
|
25
25
|
t != null && t.responseContent && navigator.clipboard.writeText(t.responseContent), i(t.id), setTimeout(() => {
|
|
26
26
|
i("");
|
|
27
27
|
}, 1e3);
|
|
28
28
|
}, k = (t, m) => {
|
|
29
|
-
n.onPromptRequest && n.onPromptRequest.call(null, t.prompt, { ...t, ratingType: m, isRetry: !1 }),
|
|
30
|
-
},
|
|
29
|
+
n.onPromptRequest && n.onPromptRequest.call(null, t.prompt, { ...t, ratingType: m, isRetry: !1 }), C();
|
|
30
|
+
}, C = () => {
|
|
31
31
|
l && l.current && l.current.scrollTo({ top: 0, behavior: "smooth" });
|
|
32
32
|
}, P = /* @__PURE__ */ e.createElement(s, null, /* @__PURE__ */ e.createElement(g, null, /* @__PURE__ */ e.createElement(f, null, /* @__PURE__ */ e.createElement("span", { className: "k-skeleton k-skeleton-text k-skeleton-pulse", style: { width: "200px" } })), /* @__PURE__ */ e.createElement(y, null, /* @__PURE__ */ e.createElement("span", { className: "k-skeleton k-skeleton-text k-skeleton-pulse", style: { width: "100%" } }))), /* @__PURE__ */ e.createElement(c, null, /* @__PURE__ */ e.createElement("span", { className: "k-skeleton k-skeleton-rect k-skeleton-pulse", style: { height: "80px" } })), /* @__PURE__ */ e.createElement(R, null, /* @__PURE__ */ e.createElement("span", { className: "k-skeleton k-skeleton-text k-skeleton-pulse", style: { width: "100%" } }))), a = o == null ? void 0 : o.map((t, m) => /* @__PURE__ */ e.createElement(s, { key: `${t.id}_${m}` }, /* @__PURE__ */ e.createElement(g, null, d ? d(t) : /* @__PURE__ */ e.createElement(e.Fragment, null, t.title && /* @__PURE__ */ e.createElement(f, null, t.title), t.subTitle && /* @__PURE__ */ e.createElement(y, null, t.subTitle))), /* @__PURE__ */ e.createElement(c, null, p ? p(t) : t.responseContent), /* @__PURE__ */ e.createElement(R, null, u ? u(t) : /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(
|
|
33
33
|
r,
|
|
@@ -50,7 +50,7 @@ const L = {
|
|
|
50
50
|
rounded: "medium",
|
|
51
51
|
title: "Retry",
|
|
52
52
|
svgIcon: V,
|
|
53
|
-
onClick: () =>
|
|
53
|
+
onClick: () => v(t)
|
|
54
54
|
},
|
|
55
55
|
"Retry"
|
|
56
56
|
), I && /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("span", { className: "k-spacer" }), /* @__PURE__ */ e.createElement(
|
|
@@ -75,7 +75,7 @@ const L = {
|
|
|
75
75
|
svgIcon: B,
|
|
76
76
|
onClick: () => k(t, "negative")
|
|
77
77
|
}
|
|
78
|
-
)))))), O = /* @__PURE__ */ e.createElement(s, null, /* @__PURE__ */ e.createElement(c, null,
|
|
78
|
+
)))))), O = /* @__PURE__ */ e.createElement(s, null, /* @__PURE__ */ e.createElement(c, null, w.toLanguageString(E, A[E])));
|
|
79
79
|
return /* @__PURE__ */ e.createElement(q, { name: L.name }, /* @__PURE__ */ e.createElement(N, { ref: l, streaming: n.streaming, onCancel: n.onCancel }, /* @__PURE__ */ e.createElement("div", { className: "k-card-list" }, n.streaming && P, a, (!a || a.length === 0) && !n.streaming && O)));
|
|
80
80
|
};
|
|
81
81
|
export {
|
|
@@ -12,4 +12,4 @@
|
|
|
12
12
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
13
13
|
*-------------------------------------------------------------------------------------------
|
|
14
14
|
*/
|
|
15
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("@progress/kendo-react-common"),require("@progress/kendo-react-intl"),require("prop-types"),require("@progress/kendo-svg-icons"),require("@progress/kendo-react-buttons"),require("@progress/kendo-react-layout"),require("@progress/kendo-react-inputs")):"function"==typeof define&&define.amd?define(["exports","react","@progress/kendo-react-common","@progress/kendo-react-intl","prop-types","@progress/kendo-svg-icons","@progress/kendo-react-buttons","@progress/kendo-react-layout","@progress/kendo-react-inputs"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).KendoReactConversationalUi={},e.React,e.KendoReactCommon,e.KendoReactIntl,e.PropTypes,e.KendoSvgIcons,e.KendoReactButtons,e.KendoReactLayout,e.KendoReactInputs)}(this,(function(e,t,s,n,o,a,r,i,l){"use strict";function c(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(s){if("default"!==s){var n=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,n.get?n:{enumerable:!0,get:function(){return e[s]}})}})),t.default=e,Object.freeze(t)}var p=c(t);let m=class extends p.Component{componentDidUpdate(e){!e.selected&&this.props.selected&&this.elementToFocus.focus()}};const u=class extends m{render(){return p.createElement("div",{className:this.getClassNames(),tabIndex:this.props.tabIndex,onClick:()=>this.props.onRequestSelection(this.props.item.selectionIndex),onFocus:()=>this.props.onRequestSelection(this.props.item.selectionIndex),ref:e=>{this.elementToFocus=e}},this.getTimestampView(),this.getMainView(),this.getStatusView())}getMainView(){return this.props.item.typing?p.createElement("div",{className:"k-chat-bubble"},p.createElement("div",{className:"k-typing-indicator"},p.createElement("span",null),p.createElement("span",null),p.createElement("span",null))):this.props.template?p.createElement(this.props.template,{item:this.props.item}):this.props.item.text?p.createElement("div",{className:"k-chat-bubble"},this.props.item.text):null}getTimestampView(){let e=null;return this.props.item.timestamp&&(e=p.createElement("time",{className:"k-message-time","aria-hidden":!this.props.selected},n.provideIntlService(this).formatDate(this.props.item.timestamp,this.props.dateFormat))),e}getStatusView(){let e=null;return this.props.item.status&&(e=p.createElement("span",{className:"k-message-status"},this.props.item.status)),e}getClassNames(){return s.classNames({"k-only":this.props.isOnlyItemInGroup},{"k-first":this.props.isFirstItemInGroup&&!this.props.isOnlyItemInGroup},{"k-last":this.props.isLastItemInGroup&&!this.props.isOnlyItemInGroup},{"k-selected":this.props.selected},{"k-focus":this.props.selected},"k-message")}};u.defaultProps={dateFormat:"g",tabIndex:-1};let h=u;n.registerForIntl(h);const d=(e,t)=>e&&t.author&&e.id===t.author.id,g=e=>e[e.length-1],k=e=>(t,s,n)=>{const o=n===e-1;return((e,t)=>{const s=t.timestamp,n=g(e);if(s&&(!n||((e,t)=>e&&t&&(t.getDate()!==e.getDate()||t.getMonth()!==e.getMonth()||t.getFullYear()!==e.getFullYear()))(s,n.timestamp))){const t={type:"date-marker",timestamp:s,trackBy:s.getTime()};e.push(t)}})(t,s),((e,t,s)=>{const n=g(e);let o;t.typing&&!s||(n&&"message-group"===n.type&&(o=n.messages),o&&d(t.author,g(o))?o.push(t):e.push({type:"message-group",messages:[t],author:t.author,timestamp:t.timestamp,trackBy:t}))})(t,s,o),s.attachments&&s.attachments.length>1&&t.push({type:"attachment-group",attachments:s.attachments,attachmentLayout:s.attachmentLayout,timestamp:s.timestamp,trackBy:s}),s.suggestedActions&&o&&t.push({type:"action-group",actions:s.suggestedActions,timestamp:s.timestamp,trackBy:s}),t};let I=class extends m{constructor(){super(...arguments),this.onKeyDown=e=>{e.keyCode===s.Keys.enter&&this.props.onActionExecute(this.props.item,e)}}render(){return p.createElement("span",{role:"button",className:this.getClassNames(),onClick:e=>this.props.onActionExecute(this.props.item,e),ref:e=>{this.elementToFocus=e},onKeyDown:this.onKeyDown,tabIndex:0},this.props.item.title||this.props.item.value)}getClassNames(){return s.classNames("k-quick-reply",{"k-first":this.props.isFirstItemInGroup},{"k-last":this.props.isLastItemInGroup},{"k-selected":this.props.selected},{"k-focus":this.props.selected})}},E=class extends p.Component{constructor(){super(...arguments),this.state={selectedItemIndex:null},this.onRequestContainerSelection=()=>this.props.onRequestSelection(this.props.group.selectionIndex),this.onKeyDown=e=>{let t,n,o=null;this.isKeyboardNavigationLeftRight?(t=s.Keys.left,n=s.Keys.right):(t=s.Keys.up,n=s.Keys.down),e.keyCode===t?o=this.navigate(!1):e.keyCode===n&&(o=this.navigate(!0)),null!==o&&(e.preventDefault(),e.stopPropagation())}}static getDerivedStateFromProps(e,t){return e.selected||null===t.selectedItemIndex?e.selected&&null===t.selectedItemIndex?{selectedItemIndex:0}:null:{selectedItemIndex:null}}navigate(e,t=0){let s=null;const n=this.state.selectedItemIndex;return e?null===n?s=t:n<this.getLastSelectionIndex()&&(s=n+1):null===n?s=0:n>0&&(s=n-1),null!==s&&this.setState({selectedItemIndex:s}),s}get isKeyboardNavigationLeftRight(){return!0}getLastSelectionIndex(){let e=-1;if("action-group"===this.props.group.type){const t=this.props.group;e=t.actions?t.actions.length-1:-1}else if("attachment-group"===this.props.group.type){const t=this.props.group;e=t.attachments?t.attachments.length-1:-1}return e}};class v extends E{constructor(e){super(e)}render(){const e=this.props.group.actions?this.props.group.actions.length-1:0;return p.createElement("div",{className:this.getClassNames(),onClick:this.onRequestContainerSelection,onKeyDown:this.onKeyDown},this.props.group.actions&&this.props.group.actions.map(((t,s)=>p.createElement(I,{item:t,onActionExecute:this.props.onActionExecute,selected:s===this.state.selectedItemIndex,isFirstItemInGroup:0===s,isLastItemInGroup:s===e,key:s}))))}getClassNames(){return s.classNames("k-quick-replies")}}let C=class extends m{render(){return p.createElement("div",{className:this.getClassNames(),tabIndex:this.getTabIndexValue(),onClick:this.props.onClick,ref:e=>{this.elementToFocus=e}},this.props.template?p.createElement(this.props.template,{item:this.props.item}):p.createElement("div",{className:"k-card"},p.createElement("div",{className:"k-card-body"},this.getTitleView(),this.getSubtitleView(),this.getContentView())))}getTabIndexValue(){if(void 0!==this.props.tabbable)return this.props.tabbable?0:-1}getClassNames(){return s.classNames({"k-selected":this.props.selected},{"k-focus":this.props.selected},{"k-first":this.props.isFirstItemInGroup},{"k-last":this.props.isLastItemInGroup})}getTitleView(){return this.props.item.title?p.createElement("h5",{className:"k-card-title"},this.props.item.title):null}getSubtitleView(){return this.props.item.subtitle?p.createElement("h6",{className:"k-card-subtitle"},this.props.item.subtitle):null}getContentView(){return 0===this.props.item.contentType.indexOf("image/")?p.createElement("img",{src:this.props.item.content}):this.props.item.content}};class y extends E{render(){const e=this.isCardDeckLayout(this.props),t=p.createElement("div",{className:this.getClassNames(),onKeyDown:e?void 0:this.onKeyDown},this.props.group.attachments.map(((e,t)=>p.createElement(C,{item:e,template:this.props.itemTemplate,selected:t===this.state.selectedItemIndex,tabbable:this.props.isLastGroup&&t===this.state.selectedItemIndex,isFirstItemInGroup:0===t,isLastItemInGroup:t===this.getLastItemIndex(),onClick:()=>this.onAttachmentClick(t),key:t}))));return e?p.createElement("div",{className:"k-card-deck-scrollwrap",onKeyDown:this.onKeyDown},this.getLeftScrollBtn(),t,this.getRightScrollBtn()):t}get isKeyboardNavigationLeftRight(){return this.isCardDeckLayout(this.props)}getLastItemIndex(){return this.props.group.attachments.length-1}getLeftScrollBtn(){let e=null;return this.isCardDeckLayout(this.props)&&this.state.selectedItemIndex&&(e=p.createElement(r.Button,{icon:"chevron-left",onClick:()=>this.onNavigateBtnClick(!1),svgIcon:a.chevronLeftIcon})),e}getRightScrollBtn(){let e=null;return this.isCardDeckLayout(this.props)&&this.state.selectedItemIndex!==this.getLastItemIndex()&&(e=p.createElement(r.Button,{icon:"chevron-right",onClick:()=>this.onNavigateBtnClick(!0),svgIcon:a.chevronRightIcon})),e}onAttachmentClick(e){this.onRequestContainerSelection(),this.setState({selectedItemIndex:e})}onNavigateBtnClick(e){this.onRequestContainerSelection(),this.navigate(e,1)}isCardDeckLayout(e){return"list"!==e.group.attachmentLayout}getClassNames(){return s.classNames({"k-card-list":this.props.group.attachmentLayout,"k-card-deck":this.isCardDeckLayout(this.props)})}}let f=class extends p.Component{render(){const e=this.props.item;return p.createElement("div",{className:"k-timestamp"},n.provideIntlService(this).formatDate(e.timestamp,"D"))}};n.registerForIntl(f);const b="newMessage.sendButton",w="newMessage.optionsButton",x="newMessage.messageInput",N="avatar.alt",T="messageList.ariaLabel",S="aIPrompt.noOutputs",R="aIPrompt.cancel",L={[b]:"Send",[w]:"Options",[x]:"Message",[N]:"Avatar",[T]:"Message list",[R]:"Cancel",[S]:"No output from AI available"};class B extends p.Component{render(){const{avatarUrl:e,avatarAltText:t,name:s}=this.props.group.author,o=n.provideLocalizationService(this);return p.createElement("div",{className:this.getMsgGroupClassNames()},s&&p.createElement("p",{className:"k-author"},s),e&&p.createElement(i.Avatar,{type:"image"},p.createElement("img",{src:e,alt:void 0!==t?t:o.toLanguageString(N,L[N])})),this.getGroupMessagesView())}getMsgGroupClassNames(){return s.classNames("k-message-group",{"k-no-avatar":!this.props.group.author.avatarUrl,"k-alt":d(this.props.user,this.props.group.messages[0])})}getGroupMessagesView(){const e=this.props.group.messages.length-1;return this.props.group.messages.map(((t,s)=>{const n=[p.createElement(this.props.message,{item:t,template:this.props.itemTemplate,selected:t.selectionIndex===this.props.selectedItemIndex,onRequestSelection:this.props.onRequestSelection,tabIndex:s===e&&this.props.isLastGroup?0:-1,isFirstItemInGroup:0===s,isLastItemInGroup:s===e,isOnlyItemInGroup:0===e,key:s})];return t.attachments&&1===t.attachments.length&&n.push(p.createElement(C,{item:t.attachments[0],template:this.props.attachmentTemplate,selected:!1,key:`att-${s}`})),n}))}}const D=p.forwardRef(((e,t)=>{const{className:n,...o}=e,a=p.useRef(null),i=p.useRef(null);p.useImperativeHandle(i,(()=>({element:a.current,props:e}))),p.useImperativeHandle(t,(()=>i.current));const l=p.useMemo((()=>s.classNames("k-chat-toolbar k-toolbar",n)),[n]);return p.useEffect((()=>{null!==a.current&&s.focusFirstFocusableChild(a.current,[...s.TABBABLE_ELEMENTS])}),[]),p.createElement(r.Toolbar,{id:e.id,ref:e=>{e&&(a.current=e.element)},className:l,...o},p.createElement("div",{className:"k-button-list k-toolbar-group"},e.children))}));D.displayName="KendoReactChatToolbar";class V extends p.Component{constructor(){super(...arguments),this.state={focused:!1},this.inputEl=null,this.toolbarBtnRef=p.createRef(),this.onInputKeyDown=e=>{switch(e.key){case"Enter":return this.sendMessage(e);case"F10":return this.openToolbar(e);default:return}},this.sendMessage=e=>{if(this.props.onMessageSend&&null!==this.inputEl){const t=this.inputEl.value;if(t){const s={author:this.props.user,text:t,timestamp:new Date};this.props.onMessageSend(s,e)}}null!==this.inputEl&&(this.inputEl.value=null)},this.openToolbar=e=>{null!==this.toolbarBtnRef.current&&(e.preventDefault(),this.props.onToolbarActionButtonClick(!this.props.showToolbar,e))}}render(){const e=n.provideLocalizationService(this),t=p.createElement("input",{type:"text",className:this.getClassNames(),placeholder:this.props.placeholder,onKeyDown:this.onInputKeyDown,onFocus:()=>this.setState({focused:!0}),onBlur:()=>this.setState({focused:!1}),ref:e=>{this.inputEl=e},"aria-label":e.toLanguageString(x,L[x])}),s=p.createElement(r.Button,{fillMode:"flat",themeColor:"base",className:"k-chat-send",icon:"paper-plane",svgIcon:a.paperPlaneIcon,onClick:this.sendMessage,"aria-label":e.toLanguageString(b,L[b]),dir:this.props.isDirectionRightToLeft?"rtl":void 0}),o=p.createElement(r.Button,{ref:this.toolbarBtnRef,fillMode:"flat",themeColor:"base",icon:"more-horizontal",svgIcon:a.moreHorizontalIcon,onClick:e=>this.props.onToolbarActionButtonClick(!this.props.showToolbar,e),"aria-label":e.toLanguageString(w,L[w])});return p.createElement(p.Fragment,null,p.createElement("span",{className:"k-message-box k-textbox k-input k-input-md k-rounded-md k-input-solid"},this.props.MessageBox?p.createElement(this.props.MessageBox,{messageInput:t,sendButton:s,toolbarButton:o}):p.createElement(p.Fragment,null,t,p.createElement("span",{className:"k-input-separator k-input-separator-vertical"}),p.createElement("span",{className:"k-input-suffix k-input-suffix-horizontal"},this.props.toolbar&&o,s))),this.props.showToolbar&&p.createElement(D,null,this.props.toolbar))}focusInput(){null!==this.inputEl&&this.inputEl.focus()}getClassNames(){return s.classNames("k-input-inner",{"k-focus":this.state.focused})}}const M={name:"@progress/kendo-react-conversational-ui",productName:"KendoReact",productCode:"KENDOUIREACT",productCodes:["KENDOUIREACT"],publishDate:0,version:"11.4.0-develop.2",licensingDocsUrl:"https://www.telerik.com/kendo-react-ui/components/my-license/"},A=class e extends p.Component{constructor(e){super(e),this.viewItems=[],this.isDirectionRightToLeft=!1,this.scrollToBottomOnLoadingData=!0,this.showLicenseWatermark=!1,this.onFocus=()=>{clearTimeout(this.timeoutIdForChatLosingFocus)},this.onBlur=()=>{this.timeoutIdForChatLosingFocus=window.setTimeout((()=>{this.setState({selectedItemIndex:null})}),0)},this.onSelectionRequested=e=>{this.setState({selectedItemIndex:e})},this.onKeyDown=e=>{let t=null;const n=null!==this.state.selectedItemIndex?this.state.selectedItemIndex:this.viewItems.lastSelectionIndex;e.keyCode===s.Keys.up?null===n?t=0:n>0&&(t=n-1):e.keyCode===s.Keys.down&&(null===n?t=0:n<this.viewItems.lastSelectionIndex&&(t=n+1)),null!==t&&(this.setState({selectedItemIndex:t}),e.preventDefault())},this.onMessageSend=(e,t)=>{s.dispatchEvent(this.props.onMessageSend,t,this,{message:e})},this.onActionExecute=(e,t)=>{if(s.dispatchEvent(this.props.onActionExecute,t,this,{action:e}),!t.isDefaultPrevented()){switch(e.type){case"reply":this.onMessageSend({author:this.props.user,text:e.value,timestamp:new Date},t);break;case"call":window.open("tel:"+e.value);break;case"openUrl":window.open(e.value)}this.newMsgComp.focusInput()}},this.showLicenseWatermark=!s.validatePackage(M,{component:"Chat"}),this.state={selectedItemIndex:null,isFirstRender:!0}}render(){this.viewItems=this.getViewItemsFromMsgs(this.props.messages),this.isDirectionRightToLeft=this.checkIsDirectionRightToLeft(this.props);const e=n.provideLocalizationService(this);return p.createElement("div",{style:{width:this.props.width,position:"relative"},onKeyDown:this.onKeyDown,className:this.getClassNames(),ref:e=>{this.chatWrapperEl=e}},p.createElement("div",{className:"k-message-list k-avatars",onBlur:this.onBlur,onFocus:this.onFocus,role:"log","aria-label":e.toLanguageString(T,L[T]),"aria-live":"polite",onScroll:e=>{this.scrollToBottomOnLoadingData=e.currentTarget.scrollTop===e.currentTarget.scrollHeight-e.currentTarget.clientHeight},ref:e=>{this.viewItemsWrapperEl=e}},p.createElement("div",{className:"k-message-list-content"},this.renderViewItems())),p.createElement(V,{user:this.props.user,onMessageSend:this.onMessageSend,isDirectionRightToLeft:this.isDirectionRightToLeft,ref:e=>{this.newMsgComp=e},placeholder:this.props.placeholder,MessageBox:this.props.messageBox,toolbar:this.props.toolbar,onToolbarActionButtonClick:this.props.onToolbarActionExecute,showToolbar:this.props.showToolbar}),this.showLicenseWatermark&&p.createElement(s.WatermarkOverlay,null))}componentDidMount(){this.setState({isFirstRender:!1},(()=>{this.nextTickId=window.setTimeout((()=>this.scrollViewItemsToBottom()),250)}))}componentWillUnmount(){clearTimeout(this.nextTickId)}componentDidUpdate(e){e.messages.length!==this.props.messages.length&&this.scrollToBottomOnLoadingData&&this.scrollViewItemsToBottom()}getClassNames(){return s.classNames("k-chat",this.props.className,{"k-rtl":this.isDirectionRightToLeft})}checkIsDirectionRightToLeft(e){return!!(void 0!==e.dir?"rtl"===e.dir:this.chatWrapperEl&&"rtl"===getComputedStyle(this.chatWrapperEl).direction)}renderViewItems(){const t=this.viewItems.length-1;return this.viewItems.map(((s,n)=>"date-marker"===s.type?p.createElement(f,{item:s,key:n}):"message-group"===s.type?p.createElement(B,{group:s,itemTemplate:this.props.messageTemplate,attachmentTemplate:this.props.attachmentTemplate,user:this.props.user,selectedItemIndex:this.state.selectedItemIndex,onRequestSelection:this.onSelectionRequested,isLastGroup:n===t,key:n,message:this.props.message||e.defaultProps.message}):"attachment-group"===s.type?p.createElement(y,{group:s,itemTemplate:this.props.attachmentTemplate,onRequestSelection:this.onSelectionRequested,selected:s.selectionIndex===this.state.selectedItemIndex,isLastGroup:n===t,key:n}):"action-group"===s.type?p.createElement(v,{group:s,onActionExecute:this.onActionExecute,onRequestSelection:this.onSelectionRequested,selected:s.selectionIndex===this.state.selectedItemIndex,isLastGroup:n===t,key:n}):void 0))}scrollViewItemsToBottom(){this.viewItemsWrapperEl&&(this.viewItemsWrapperEl.scrollTop=this.viewItemsWrapperEl.scrollHeight-this.viewItemsWrapperEl.clientHeight)}getViewItemsFromMsgs(e){return e.length>0?(e=>{const t=e.slice().reduce(k(e.length),[]);return function(e){let t=0;e.forEach((e=>{"message-group"===e.type?e.messages.forEach((e=>{e.selectionIndex=t++})):("attachment-group"===e.type||"action-group"===e.type)&&(e.selectionIndex=t++)})),e.lastSelectionIndex=t-1}(t),t})(e):[]}};A.propTypes={messages:o.arrayOf(o.object),user:o.object,messageTemplate:o.any,attachmentTemplate:o.any,width:o.oneOfType([o.string,o.number]),onMessageSend:o.func,onActionExecute:o.func,dir:o.string,messageBox:o.any},A.defaultProps={messages:[],dateFormat:"g",message:h};let F=A;class K extends p.Component{constructor(){super(...arguments),this.onBtnClick=(e,t)=>{s.dispatchEvent(this.props.onActionExecute,t,this,{action:e})}}render(){return p.createElement("div",{className:"k-card"},p.createElement("img",{className:"k-card-image",src:this.props.imageUrl,style:{maxWidth:this.props.imageMaxWidth}}),p.createElement("div",{className:"k-card-body"},this.getTitleView(),this.getSubtitleView()),p.createElement("div",{className:"k-card-actions k-card-actions-vertical"},this.getActionsView()))}getActionsView(){return this.props.actions.map(((e,t)=>p.createElement("span",{className:"k-card-action",key:t},p.createElement(r.Button,{fillMode:"flat",onClick:t=>this.onBtnClick(e,t)},e.title))))}getTitleView(){let e=null;return this.props.title&&(e=p.createElement("h5",{className:"k-card-title"},this.props.title)),e}getSubtitleView(){let e=null;return this.props.subtitle&&(e=p.createElement("h6",{className:"k-card-subtitle"},this.props.subtitle)),e}}const q=e=>{const{activeView:s,toolbarItems:n,activeViewChange:o}=e;return t.createElement("div",{className:"k-prompt-header"},t.createElement(r.Toolbar,{keyboardNavigation:!1,role:"toolbar",className:"k-toolbar-flat"},n.map((e=>t.isValidElement(e)?e:t.createElement(r.Button,{key:e.name,className:s===e.name?"k-selected":"",size:"medium",themeColor:"primary",fillMode:"flat",rounded:"full",title:e.buttonText,svgIcon:e.buttonIcon,onClick:()=>(e=>{null==o||o.call(null,e)})(e.name)},e.buttonText)))))},P=t.forwardRef(((e,s)=>{const{children:o,streaming:i,onCancel:l}=e,c=n.useLocalization().toLanguageString(R,L[R]);return t.createElement("div",{className:"k-prompt-content",ref:s},i&&t.createElement(r.FloatingActionButton,{onClick:l,svgIcon:a.stopSmIcon,icon:"stop-sm",size:"small",positionMode:"absolute",className:"k-prompt-stop-fab k-generating","aria-label":c,title:c}),t.createElement("div",{className:"k-prompt-view"},o))}));P.displayName="KendoReactAIPromptContent";const O=e=>{const{children:s}=e;return t.createElement("div",{className:"k-prompt-footer"},t.createElement("div",{className:"k-actions k-actions-start k-actions-horizontal k-prompt-actions"},s))},G=t.createContext([{},()=>{}]),z=()=>t.useContext(G),W=e=>{const[t]=z();return t.activeView===e.name?e.children:null},U=e=>{const[s,n]=t.useState(!0),{children:o,title:i}=e;return t.createElement("div",{className:"k-prompt-expander"},t.createElement(r.Button,{fillMode:"flat",svgIcon:s?a.chevronUpIcon:a.chevronDownIcon,title:i,onClick:()=>n(!s)},i),s&&t.createElement("div",{className:"k-prompt-expander-content"},o))},H={name:"prompt-view",buttonText:"Ask AI",buttonIcon:a.sparklesIcon},j={name:"Output view",buttonText:"Output",buttonIcon:a.commentIcon},$={name:"Commands view",buttonIcon:a.moreHorizontalIcon},Y=e=>null==e?void 0:e.map((e=>t.createElement(i.PanelBarItem,{title:e.text,key:e.id,svgIcon:e.svgIcon,data:e},e.children&&Y(e.children||[]))));e.AIPrompt=e=>{const{activeView:n,toolbarItems:o,children:a,onActiveViewChange:r,onPromptRequest:i,onCommandExecute:l,style:c,dir:p,className:m,streaming:u,onCancel:h,...d}=e,g=o||[H,j],[k,I]=t.useState({activeView:n}),E={...k,activeView:n,streaming:u,onCancel:h,onActiveViewChange:r,onPromptRequest:i,onCommandExecute:l};return t.createElement(G.Provider,{value:[E,e=>{I(e)}]},t.createElement("div",{className:s.classNames("k-prompt",m),style:c,dir:p,...d},t.createElement(q,{activeView:E.activeView,toolbarItems:g,activeViewChange:r}),a))},e.AIPromptCommandsView=e=>{const{commands:s}=e,[n]=z();return t.createElement(W,{name:$.name},t.createElement(P,{streaming:n.streaming,onCancel:n.onCancel},t.createElement("div",{className:"k-prompt-view"},t.createElement(i.PanelBar,{onSelect:e=>{var t,s,o;const a=null==(s=null==(t=e.target)?void 0:t.props)?void 0:s.data;null!=(o=a.children)&&o.length||n.onCommandExecute&&n.onCommandExecute.call(null,a)},selected:""},Y(null!=s?s:[])))))},e.AIPromptContent=P,e.AIPromptFooter=O,e.AIPromptOutputView=e=>{const[s,o]=t.useState(""),l=t.useRef(null),[c]=z(),{outputs:p,showOutputRating:m,outputCard:u}=e,{header:h,body:d,actions:g}=u||{},k=n.useLocalization(),I=(e,t)=>{c.onPromptRequest&&c.onPromptRequest.call(null,e.prompt,{...e,ratingType:t,isRetry:!1}),E()},E=()=>{l&&l.current&&l.current.scrollTo({top:0,behavior:"smooth"})},v=t.createElement(i.Card,null,t.createElement(i.CardHeader,null,t.createElement(i.CardTitle,null,t.createElement("span",{className:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"200px"}})),t.createElement(i.CardSubtitle,null,t.createElement("span",{className:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"100%"}}))),t.createElement(i.CardBody,null,t.createElement("span",{className:"k-skeleton k-skeleton-rect k-skeleton-pulse",style:{height:"80px"}})),t.createElement(i.CardActions,null,t.createElement("span",{className:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"100%"}}))),C=null==p?void 0:p.map(((e,n)=>t.createElement(i.Card,{key:`${e.id}_${n}`},t.createElement(i.CardHeader,null,h?h(e):t.createElement(t.Fragment,null,e.title&&t.createElement(i.CardTitle,null,e.title),e.subTitle&&t.createElement(i.CardSubtitle,null,e.subTitle))),t.createElement(i.CardBody,null,d?d(e):e.responseContent),t.createElement(i.CardActions,null,g?g(e):t.createElement(t.Fragment,null,t.createElement(r.Button,{size:"medium",themeColor:"primary",fillMode:"flat",rounded:"medium",title:"Copy",svgIcon:s===e.id?a.checkIcon:a.copyIcon,onClick:()=>(e=>{null!=e&&e.responseContent&&navigator.clipboard.writeText(e.responseContent),o(e.id),setTimeout((()=>{o("")}),1e3)})(e)},"Copy"),t.createElement(r.Button,{size:"medium",themeColor:"base",fillMode:"flat",rounded:"medium",title:"Retry",svgIcon:a.rotateIcon,onClick:()=>(e=>{c.onPromptRequest&&c.onPromptRequest.call(null,e.prompt,{...e,isRetry:!0}),E()})(e)},"Retry"),m&&t.createElement(t.Fragment,null,t.createElement("span",{className:"k-spacer"}),t.createElement(r.Button,{size:"medium",themeColor:"positive"===e.ratingType?"primary":"base",fillMode:"flat",rounded:"medium",title:"Rate up",svgIcon:a.thumbUpOutlineIcon,onClick:()=>I(e,"positive")}),t.createElement(r.Button,{size:"medium",themeColor:"negative"===e.ratingType?"primary":"base",fillMode:"flat",rounded:"medium",title:"Rate down",svgIcon:a.thumbDownOutlineIcon,onClick:()=>I(e,"negative")}))))))),y=t.createElement(i.Card,null,t.createElement(i.CardBody,null,k.toLanguageString(S,L[S])));return t.createElement(W,{name:j.name},t.createElement(P,{ref:l,streaming:c.streaming,onCancel:c.onCancel},t.createElement("div",{className:"k-card-list"},c.streaming&&v,C,(!C||0===C.length)&&!c.streaming&&y)))},e.AIPromptView=e=>{const{promptInput:n=l.TextArea,generateButton:o=r.Button,promptValue:i,promptSuggestions:c}=e,[p,m]=t.useState(i||""),[u]=z(),[h,d]=s.useCustomComponent(o),[g,k]=s.useCustomComponent(n),I={title:"Generate",children:"Generate",svgIcon:a.sparklesIcon},E=Object.keys(d).length>0?d:I,v=Object.keys(k).length>0?k:{placeholder:"Ask or generate content with AI ...",rows:2};return t.createElement(W,{name:H.name},t.createElement(P,{streaming:u.streaming,onCancel:u.onCancel},t.createElement(g,{value:p,onChange:e=>{m(e.target.value)},...v}),c&&c.length>0&&t.createElement(U,{title:"Prompt Suggestions"},t.createElement("div",{className:"k-suggestion-group"},c.map((e=>t.createElement("div",{key:e,className:"k-suggestion",onClick:()=>(e=>{m(e)})(e),tabIndex:0},e)))))),t.createElement(O,null,t.createElement(h,{themeColor:"primary",fillMode:"solid",rounded:"full",size:"medium",onClick:()=>{u.onPromptRequest&&u.onPromptRequest.call(null,p),m("")},disabled:!p.trim(),...E},E.children)))},e.AIPromptViewRender=W,e.Chat=F,e.ChatMessage=h,e.HeroCard=K,e.PromptHeader=q,e.commandsViewDefaults=$,e.outputViewDefaults=j,e.promptViewDefaults=H}));
|
|
15
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("@progress/kendo-react-common"),require("@progress/kendo-react-intl"),require("prop-types"),require("@progress/kendo-svg-icons"),require("@progress/kendo-react-buttons"),require("@progress/kendo-react-layout"),require("@progress/kendo-react-inputs"),require("@progress/kendo-react-popup")):"function"==typeof define&&define.amd?define(["exports","react","@progress/kendo-react-common","@progress/kendo-react-intl","prop-types","@progress/kendo-svg-icons","@progress/kendo-react-buttons","@progress/kendo-react-layout","@progress/kendo-react-inputs","@progress/kendo-react-popup"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).KendoReactConversationalUi={},e.React,e.KendoReactCommon,e.KendoReactIntl,e.PropTypes,e.KendoSvgIcons,e.KendoReactButtons,e.KendoReactLayout,e.KendoReactInputs,e.KendoReactPopup)}(this,(function(e,t,s,n,o,a,r,i,l,c){"use strict";function p(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(s){if("default"!==s){var n=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,n.get?n:{enumerable:!0,get:function(){return e[s]}})}})),t.default=e,Object.freeze(t)}var m=p(t);let u=class extends m.Component{componentDidUpdate(e){!e.selected&&this.props.selected&&this.elementToFocus.focus()}};const d=class extends u{render(){return m.createElement("div",{className:this.getClassNames(),tabIndex:this.props.tabIndex,onClick:()=>this.props.onRequestSelection(this.props.item.selectionIndex),onFocus:()=>this.props.onRequestSelection(this.props.item.selectionIndex),ref:e=>{this.elementToFocus=e}},this.getTimestampView(),this.getMainView(),this.getStatusView())}getMainView(){return this.props.item.typing?m.createElement("div",{className:"k-chat-bubble"},m.createElement("div",{className:"k-typing-indicator"},m.createElement("span",null),m.createElement("span",null),m.createElement("span",null))):this.props.template?m.createElement(this.props.template,{item:this.props.item}):this.props.item.text?m.createElement("div",{className:"k-chat-bubble"},this.props.item.text):null}getTimestampView(){let e=null;return this.props.item.timestamp&&(e=m.createElement("time",{className:"k-message-time","aria-hidden":!this.props.selected},n.provideIntlService(this).formatDate(this.props.item.timestamp,this.props.dateFormat))),e}getStatusView(){let e=null;return this.props.item.status&&(e=m.createElement("span",{className:"k-message-status"},this.props.item.status)),e}getClassNames(){return s.classNames({"k-only":this.props.isOnlyItemInGroup},{"k-first":this.props.isFirstItemInGroup&&!this.props.isOnlyItemInGroup},{"k-last":this.props.isLastItemInGroup&&!this.props.isOnlyItemInGroup},{"k-selected":this.props.selected},{"k-focus":this.props.selected},"k-message")}};d.defaultProps={dateFormat:"g",tabIndex:-1};let h=d;n.registerForIntl(h);const g=(e,t)=>e&&t.author&&e.id===t.author.id,k=e=>e[e.length-1],I=e=>(t,s,n)=>{const o=n===e-1;return((e,t)=>{const s=t.timestamp,n=k(e);if(s&&(!n||((e,t)=>e&&t&&(t.getDate()!==e.getDate()||t.getMonth()!==e.getMonth()||t.getFullYear()!==e.getFullYear()))(s,n.timestamp))){const t={type:"date-marker",timestamp:s,trackBy:s.getTime()};e.push(t)}})(t,s),((e,t,s)=>{const n=k(e);let o;t.typing&&!s||(n&&"message-group"===n.type&&(o=n.messages),o&&g(t.author,k(o))?o.push(t):e.push({type:"message-group",messages:[t],author:t.author,timestamp:t.timestamp,trackBy:t}))})(t,s,o),s.attachments&&s.attachments.length>1&&t.push({type:"attachment-group",attachments:s.attachments,attachmentLayout:s.attachmentLayout,timestamp:s.timestamp,trackBy:s}),s.suggestedActions&&o&&t.push({type:"action-group",actions:s.suggestedActions,timestamp:s.timestamp,trackBy:s}),t};let E=class extends u{constructor(){super(...arguments),this.onKeyDown=e=>{e.keyCode===s.Keys.enter&&this.props.onActionExecute(this.props.item,e)}}render(){return m.createElement("span",{role:"button",className:this.getClassNames(),onClick:e=>this.props.onActionExecute(this.props.item,e),ref:e=>{this.elementToFocus=e},onKeyDown:this.onKeyDown,tabIndex:0},this.props.item.title||this.props.item.value)}getClassNames(){return s.classNames("k-quick-reply",{"k-first":this.props.isFirstItemInGroup},{"k-last":this.props.isLastItemInGroup},{"k-selected":this.props.selected},{"k-focus":this.props.selected})}},v=class extends m.Component{constructor(){super(...arguments),this.state={selectedItemIndex:null},this.onRequestContainerSelection=()=>this.props.onRequestSelection(this.props.group.selectionIndex),this.onKeyDown=e=>{let t,n,o=null;this.isKeyboardNavigationLeftRight?(t=s.Keys.left,n=s.Keys.right):(t=s.Keys.up,n=s.Keys.down),e.keyCode===t?o=this.navigate(!1):e.keyCode===n&&(o=this.navigate(!0)),null!==o&&(e.preventDefault(),e.stopPropagation())}}static getDerivedStateFromProps(e,t){return e.selected||null===t.selectedItemIndex?e.selected&&null===t.selectedItemIndex?{selectedItemIndex:0}:null:{selectedItemIndex:null}}navigate(e,t=0){let s=null;const n=this.state.selectedItemIndex;return e?null===n?s=t:n<this.getLastSelectionIndex()&&(s=n+1):null===n?s=0:n>0&&(s=n-1),null!==s&&this.setState({selectedItemIndex:s}),s}get isKeyboardNavigationLeftRight(){return!0}getLastSelectionIndex(){let e=-1;if("action-group"===this.props.group.type){const t=this.props.group;e=t.actions?t.actions.length-1:-1}else if("attachment-group"===this.props.group.type){const t=this.props.group;e=t.attachments?t.attachments.length-1:-1}return e}};class C extends v{constructor(e){super(e)}render(){const e=this.props.group.actions?this.props.group.actions.length-1:0;return m.createElement("div",{className:this.getClassNames(),onClick:this.onRequestContainerSelection,onKeyDown:this.onKeyDown},this.props.group.actions&&this.props.group.actions.map(((t,s)=>m.createElement(E,{item:t,onActionExecute:this.props.onActionExecute,selected:s===this.state.selectedItemIndex,isFirstItemInGroup:0===s,isLastItemInGroup:s===e,key:s}))))}getClassNames(){return s.classNames("k-quick-replies")}}let y=class extends u{render(){return m.createElement("div",{className:this.getClassNames(),tabIndex:this.getTabIndexValue(),onClick:this.props.onClick,ref:e=>{this.elementToFocus=e}},this.props.template?m.createElement(this.props.template,{item:this.props.item}):m.createElement("div",{className:"k-card"},m.createElement("div",{className:"k-card-body"},this.getTitleView(),this.getSubtitleView(),this.getContentView())))}getTabIndexValue(){if(void 0!==this.props.tabbable)return this.props.tabbable?0:-1}getClassNames(){return s.classNames({"k-selected":this.props.selected},{"k-focus":this.props.selected},{"k-first":this.props.isFirstItemInGroup},{"k-last":this.props.isLastItemInGroup})}getTitleView(){return this.props.item.title?m.createElement("h5",{className:"k-card-title"},this.props.item.title):null}getSubtitleView(){return this.props.item.subtitle?m.createElement("h6",{className:"k-card-subtitle"},this.props.item.subtitle):null}getContentView(){return 0===this.props.item.contentType.indexOf("image/")?m.createElement("img",{src:this.props.item.content}):this.props.item.content}};class f extends v{render(){const e=this.isCardDeckLayout(this.props),t=m.createElement("div",{className:this.getClassNames(),onKeyDown:e?void 0:this.onKeyDown},this.props.group.attachments.map(((e,t)=>m.createElement(y,{item:e,template:this.props.itemTemplate,selected:t===this.state.selectedItemIndex,tabbable:this.props.isLastGroup&&t===this.state.selectedItemIndex,isFirstItemInGroup:0===t,isLastItemInGroup:t===this.getLastItemIndex(),onClick:()=>this.onAttachmentClick(t),key:t}))));return e?m.createElement("div",{className:"k-card-deck-scrollwrap",onKeyDown:this.onKeyDown},this.getLeftScrollBtn(),t,this.getRightScrollBtn()):t}get isKeyboardNavigationLeftRight(){return this.isCardDeckLayout(this.props)}getLastItemIndex(){return this.props.group.attachments.length-1}getLeftScrollBtn(){let e=null;return this.isCardDeckLayout(this.props)&&this.state.selectedItemIndex&&(e=m.createElement(r.Button,{icon:"chevron-left",onClick:()=>this.onNavigateBtnClick(!1),svgIcon:a.chevronLeftIcon})),e}getRightScrollBtn(){let e=null;return this.isCardDeckLayout(this.props)&&this.state.selectedItemIndex!==this.getLastItemIndex()&&(e=m.createElement(r.Button,{icon:"chevron-right",onClick:()=>this.onNavigateBtnClick(!0),svgIcon:a.chevronRightIcon})),e}onAttachmentClick(e){this.onRequestContainerSelection(),this.setState({selectedItemIndex:e})}onNavigateBtnClick(e){this.onRequestContainerSelection(),this.navigate(e,1)}isCardDeckLayout(e){return"list"!==e.group.attachmentLayout}getClassNames(){return s.classNames({"k-card-list":this.props.group.attachmentLayout,"k-card-deck":this.isCardDeckLayout(this.props)})}}let b=class extends m.Component{render(){const e=this.props.item;return m.createElement("div",{className:"k-timestamp"},n.provideIntlService(this).formatDate(e.timestamp,"D"))}};n.registerForIntl(b);const w="newMessage.sendButton",x="newMessage.optionsButton",N="newMessage.messageInput",T="avatar.alt",S="messageList.ariaLabel",R="aIPrompt.noOutputs",B="aIPrompt.cancel",L={[w]:"Send",[x]:"Options",[N]:"Message",[T]:"Avatar",[S]:"Message list",[B]:"Cancel",[R]:"No output from AI available"};class D extends m.Component{render(){const{avatarUrl:e,avatarAltText:t,name:s}=this.props.group.author,o=n.provideLocalizationService(this);return m.createElement("div",{className:this.getMsgGroupClassNames()},s&&m.createElement("p",{className:"k-author"},s),e&&m.createElement(i.Avatar,{type:"image"},m.createElement("img",{src:e,alt:void 0!==t?t:o.toLanguageString(T,L[T])})),this.getGroupMessagesView())}getMsgGroupClassNames(){return s.classNames("k-message-group",{"k-no-avatar":!this.props.group.author.avatarUrl,"k-alt":g(this.props.user,this.props.group.messages[0])})}getGroupMessagesView(){const e=this.props.group.messages.length-1;return this.props.group.messages.map(((t,s)=>{const n=[m.createElement(this.props.message,{item:t,template:this.props.itemTemplate,selected:t.selectionIndex===this.props.selectedItemIndex,onRequestSelection:this.props.onRequestSelection,tabIndex:s===e&&this.props.isLastGroup?0:-1,isFirstItemInGroup:0===s,isLastItemInGroup:s===e,isOnlyItemInGroup:0===e,key:s})];return t.attachments&&1===t.attachments.length&&n.push(m.createElement(y,{item:t.attachments[0],template:this.props.attachmentTemplate,selected:!1,key:`att-${s}`})),n}))}}const A=m.forwardRef(((e,t)=>{const{className:n,...o}=e,a=m.useRef(null),i=m.useRef(null);m.useImperativeHandle(i,(()=>({element:a.current,props:e}))),m.useImperativeHandle(t,(()=>i.current));const l=m.useMemo((()=>s.classNames("k-chat-toolbar k-toolbar",n)),[n]);return m.useEffect((()=>{null!==a.current&&s.focusFirstFocusableChild(a.current,[...s.TABBABLE_ELEMENTS])}),[]),m.createElement(r.Toolbar,{id:e.id,ref:e=>{e&&(a.current=e.element)},className:l,...o},m.createElement("div",{className:"k-button-list k-toolbar-group"},e.children))}));A.displayName="KendoReactChatToolbar";class M extends m.Component{constructor(){super(...arguments),this.state={focused:!1},this.inputEl=null,this.toolbarBtnRef=m.createRef(),this.onInputKeyDown=e=>{switch(e.key){case"Enter":return this.sendMessage(e);case"F10":return this.openToolbar(e);default:return}},this.sendMessage=e=>{if(this.props.onMessageSend&&null!==this.inputEl){const t=this.inputEl.value;if(t){const s={author:this.props.user,text:t,timestamp:new Date};this.props.onMessageSend(s,e)}}null!==this.inputEl&&(this.inputEl.value=null)},this.openToolbar=e=>{null!==this.toolbarBtnRef.current&&(e.preventDefault(),this.props.onToolbarActionButtonClick(!this.props.showToolbar,e))}}render(){const e=n.provideLocalizationService(this),t=m.createElement("input",{type:"text",className:this.getClassNames(),placeholder:this.props.placeholder,onKeyDown:this.onInputKeyDown,onFocus:()=>this.setState({focused:!0}),onBlur:()=>this.setState({focused:!1}),ref:e=>{this.inputEl=e},"aria-label":e.toLanguageString(N,L[N])}),s=m.createElement(r.Button,{fillMode:"flat",themeColor:"base",className:"k-chat-send",icon:"paper-plane",svgIcon:a.paperPlaneIcon,onClick:this.sendMessage,"aria-label":e.toLanguageString(w,L[w]),dir:this.props.isDirectionRightToLeft?"rtl":void 0}),o=m.createElement(r.Button,{ref:this.toolbarBtnRef,fillMode:"flat",themeColor:"base",icon:"more-horizontal",svgIcon:a.moreHorizontalIcon,onClick:e=>this.props.onToolbarActionButtonClick(!this.props.showToolbar,e),"aria-label":e.toLanguageString(x,L[x])});return m.createElement(m.Fragment,null,m.createElement("span",{className:"k-message-box k-textbox k-input k-input-md k-rounded-md k-input-solid"},this.props.MessageBox?m.createElement(this.props.MessageBox,{messageInput:t,sendButton:s,toolbarButton:o}):m.createElement(m.Fragment,null,t,m.createElement("span",{className:"k-input-separator k-input-separator-vertical"}),m.createElement("span",{className:"k-input-suffix k-input-suffix-horizontal"},this.props.toolbar&&o,s))),this.props.showToolbar&&m.createElement(A,null,this.props.toolbar))}focusInput(){null!==this.inputEl&&this.inputEl.focus()}getClassNames(){return s.classNames("k-input-inner",{"k-focus":this.state.focused})}}const V={name:"@progress/kendo-react-conversational-ui",productName:"KendoReact",productCode:"KENDOUIREACT",productCodes:["KENDOUIREACT"],publishDate:0,version:"11.4.0-develop.4",licensingDocsUrl:"https://www.telerik.com/kendo-react-ui/components/my-license/"},P=class e extends m.Component{constructor(e){super(e),this.viewItems=[],this.isDirectionRightToLeft=!1,this.scrollToBottomOnLoadingData=!0,this.showLicenseWatermark=!1,this.onFocus=()=>{clearTimeout(this.timeoutIdForChatLosingFocus)},this.onBlur=()=>{this.timeoutIdForChatLosingFocus=window.setTimeout((()=>{this.setState({selectedItemIndex:null})}),0)},this.onSelectionRequested=e=>{this.setState({selectedItemIndex:e})},this.onKeyDown=e=>{let t=null;const n=null!==this.state.selectedItemIndex?this.state.selectedItemIndex:this.viewItems.lastSelectionIndex;e.keyCode===s.Keys.up?null===n?t=0:n>0&&(t=n-1):e.keyCode===s.Keys.down&&(null===n?t=0:n<this.viewItems.lastSelectionIndex&&(t=n+1)),null!==t&&(this.setState({selectedItemIndex:t}),e.preventDefault())},this.onMessageSend=(e,t)=>{s.dispatchEvent(this.props.onMessageSend,t,this,{message:e})},this.onActionExecute=(e,t)=>{if(s.dispatchEvent(this.props.onActionExecute,t,this,{action:e}),!t.isDefaultPrevented()){switch(e.type){case"reply":this.onMessageSend({author:this.props.user,text:e.value,timestamp:new Date},t);break;case"call":window.open("tel:"+e.value);break;case"openUrl":window.open(e.value)}this.newMsgComp.focusInput()}},this.showLicenseWatermark=!s.validatePackage(V,{component:"Chat"}),this.state={selectedItemIndex:null,isFirstRender:!0}}render(){this.viewItems=this.getViewItemsFromMsgs(this.props.messages),this.isDirectionRightToLeft=this.checkIsDirectionRightToLeft(this.props);const e=n.provideLocalizationService(this);return m.createElement("div",{style:{width:this.props.width,position:"relative"},onKeyDown:this.onKeyDown,className:this.getClassNames(),ref:e=>{this.chatWrapperEl=e}},m.createElement("div",{className:"k-message-list k-avatars",onBlur:this.onBlur,onFocus:this.onFocus,role:"log","aria-label":e.toLanguageString(S,L[S]),"aria-live":"polite",onScroll:e=>{this.scrollToBottomOnLoadingData=e.currentTarget.scrollTop===e.currentTarget.scrollHeight-e.currentTarget.clientHeight},ref:e=>{this.viewItemsWrapperEl=e}},m.createElement("div",{className:"k-message-list-content"},this.renderViewItems())),m.createElement(M,{user:this.props.user,onMessageSend:this.onMessageSend,isDirectionRightToLeft:this.isDirectionRightToLeft,ref:e=>{this.newMsgComp=e},placeholder:this.props.placeholder,MessageBox:this.props.messageBox,toolbar:this.props.toolbar,onToolbarActionButtonClick:this.props.onToolbarActionExecute,showToolbar:this.props.showToolbar}),this.showLicenseWatermark&&m.createElement(s.WatermarkOverlay,null))}componentDidMount(){this.setState({isFirstRender:!1},(()=>{this.nextTickId=window.setTimeout((()=>this.scrollViewItemsToBottom()),250)}))}componentWillUnmount(){clearTimeout(this.nextTickId)}componentDidUpdate(e){e.messages.length!==this.props.messages.length&&this.scrollToBottomOnLoadingData&&this.scrollViewItemsToBottom()}getClassNames(){return s.classNames("k-chat",this.props.className,{"k-rtl":this.isDirectionRightToLeft})}checkIsDirectionRightToLeft(e){return!!(void 0!==e.dir?"rtl"===e.dir:this.chatWrapperEl&&"rtl"===getComputedStyle(this.chatWrapperEl).direction)}renderViewItems(){const t=this.viewItems.length-1;return this.viewItems.map(((s,n)=>"date-marker"===s.type?m.createElement(b,{item:s,key:n}):"message-group"===s.type?m.createElement(D,{group:s,itemTemplate:this.props.messageTemplate,attachmentTemplate:this.props.attachmentTemplate,user:this.props.user,selectedItemIndex:this.state.selectedItemIndex,onRequestSelection:this.onSelectionRequested,isLastGroup:n===t,key:n,message:this.props.message||e.defaultProps.message}):"attachment-group"===s.type?m.createElement(f,{group:s,itemTemplate:this.props.attachmentTemplate,onRequestSelection:this.onSelectionRequested,selected:s.selectionIndex===this.state.selectedItemIndex,isLastGroup:n===t,key:n}):"action-group"===s.type?m.createElement(C,{group:s,onActionExecute:this.onActionExecute,onRequestSelection:this.onSelectionRequested,selected:s.selectionIndex===this.state.selectedItemIndex,isLastGroup:n===t,key:n}):void 0))}scrollViewItemsToBottom(){this.viewItemsWrapperEl&&(this.viewItemsWrapperEl.scrollTop=this.viewItemsWrapperEl.scrollHeight-this.viewItemsWrapperEl.clientHeight)}getViewItemsFromMsgs(e){return e.length>0?(e=>{const t=e.slice().reduce(I(e.length),[]);return function(e){let t=0;e.forEach((e=>{"message-group"===e.type?e.messages.forEach((e=>{e.selectionIndex=t++})):("attachment-group"===e.type||"action-group"===e.type)&&(e.selectionIndex=t++)})),e.lastSelectionIndex=t-1}(t),t})(e):[]}};P.propTypes={messages:o.arrayOf(o.object),user:o.object,messageTemplate:o.any,attachmentTemplate:o.any,width:o.oneOfType([o.string,o.number]),onMessageSend:o.func,onActionExecute:o.func,dir:o.string,messageBox:o.any},P.defaultProps={messages:[],dateFormat:"g",message:h};let F=P;class K extends m.Component{constructor(){super(...arguments),this.onBtnClick=(e,t)=>{s.dispatchEvent(this.props.onActionExecute,t,this,{action:e})}}render(){return m.createElement("div",{className:"k-card"},m.createElement("img",{className:"k-card-image",src:this.props.imageUrl,style:{maxWidth:this.props.imageMaxWidth}}),m.createElement("div",{className:"k-card-body"},this.getTitleView(),this.getSubtitleView()),m.createElement("div",{className:"k-card-actions k-card-actions-vertical"},this.getActionsView()))}getActionsView(){return this.props.actions.map(((e,t)=>m.createElement("span",{className:"k-card-action",key:t},m.createElement(r.Button,{fillMode:"flat",onClick:t=>this.onBtnClick(e,t)},e.title))))}getTitleView(){let e=null;return this.props.title&&(e=m.createElement("h5",{className:"k-card-title"},this.props.title)),e}getSubtitleView(){let e=null;return this.props.subtitle&&(e=m.createElement("h6",{className:"k-card-subtitle"},this.props.subtitle)),e}}const O=e=>{const{activeView:s,toolbarItems:n,activeViewChange:o}=e;return t.createElement("div",{className:"k-prompt-header"},t.createElement(r.Toolbar,{keyboardNavigation:!1,role:"toolbar",className:"k-toolbar-flat"},n.map((e=>t.isValidElement(e)?e:t.createElement(r.Button,{key:e.name,className:s===e.name?"k-selected":"",size:"medium",themeColor:"primary",fillMode:"flat",rounded:"full",title:e.buttonText,svgIcon:e.buttonIcon,onClick:()=>(e=>{null==o||o.call(null,e)})(e.name)},e.buttonText)))))},q=t.forwardRef(((e,s)=>{const{children:o,streaming:i,onCancel:l}=e,c=n.useLocalization().toLanguageString(B,L[B]);return t.createElement("div",{className:"k-prompt-content",ref:s},i&&t.createElement(r.FloatingActionButton,{onClick:l,svgIcon:a.stopSmIcon,icon:"stop-sm",size:"small",positionMode:"absolute",className:"k-prompt-stop-fab k-generating","aria-label":c,title:c}),t.createElement("div",{className:"k-prompt-view"},o))}));q.displayName="KendoReactAIPromptContent";const G=e=>{const{children:s}=e;return t.createElement("div",{className:"k-prompt-footer"},t.createElement("div",{className:"k-actions k-actions-start k-actions-horizontal k-prompt-actions"},s))},z=t.createContext([{},()=>{}]),W=()=>t.useContext(z),j=e=>{const[t]=W();return t.activeView===e.name?e.children:null},U=e=>{const[s,n]=t.useState(!0),{children:o,title:i}=e;return t.createElement("div",{className:"k-prompt-expander"},t.createElement(r.Button,{fillMode:"flat",svgIcon:s?a.chevronUpIcon:a.chevronDownIcon,title:i,onClick:()=>n(!s)},i),s&&t.createElement("div",{className:"k-prompt-expander-content"},o))},H={name:"prompt-view",buttonText:"Ask AI",buttonIcon:a.sparklesIcon},$={name:"Output view",buttonText:"Output",buttonIcon:a.commentIcon},_={name:"Commands view",buttonIcon:a.moreHorizontalIcon},Y=e=>null==e?void 0:e.map((e=>t.createElement(i.PanelBarItem,{title:e.text,key:e.id,svgIcon:e.svgIcon,data:e},e.children&&Y(e.children||[])))),J=({show:e=!1,anchor:s,onOpen:n,onClose:o,animate:a=!0,appendTo:r,popupOptions:i={},children:l,style:p})=>t.createElement(c.Popup,{show:e,anchor:s,style:p,animate:a,appendTo:r,onOpen:n,onClose:o,...i},l),Q=({placeholder:e="Ask or generate content with AI...",promptValue:n,onMenuClick:o,promptInput:i=l.TextArea,generateButton:c,enableSpeechToText:p=!1,streaming:m=!1,commands:u,onPromptRequest:d,onPromptCancel:h})=>{const[g,k]=t.useState(n||""),[I,E]=s.useCustomComponent(c),[v,C]=s.useCustomComponent(i),y={svgIcon:m?a.stopSmIcon:a.paperPlaneIcon,active:m,title:"Send Button","aria-label":"Send Button",disabled:!g.trim()&&!m,"aria-disabled":!g.trim()&&!m},f={placeholder:e,className:"!k-flex-row",autoSize:!0,rows:1},b=u&&u.length>0,w=Object.keys(E).length>0?E:y,x=Object.keys(C).length>0?C:f,N=e=>{const{isFinal:t,alternatives:s}=e;if(t&&s.length>0){const e=s[0].transcript,t=(()=>{const t=g,s=t&&!t.endsWith(" ")&&!t.endsWith("\n");return t+(s?" ":"")+e})();k(t)}},T=()=>{g.trim()&&d&&d(g.trim())};return t.createElement(v,{value:g,onChange:e=>{const t=e.target.value;k(t)},onKeyDown:e=>{"Enter"===e.key&&!e.shiftKey&&(e.preventDefault(),T())},prefix:b||p?t.createElement(t.Fragment,null,t.createElement(l.InputPrefix,{className:"!k-align-items-start"},b&&t.createElement(r.Button,{"aria-label":"Commands Button",title:"Commands Button",fillMode:"flat",svgIcon:a.menuIcon,onClick:o}),p&&t.createElement(r.SpeechToTextButton,{fillMode:"flat",..."object"==typeof p?{...p,onResult:p.onResult||N}:{onResult:N}})),t.createElement(l.InputSeparator,null)):void 0,suffix:t.createElement(l.InputSuffix,{className:"!k-align-items-start"},t.createElement(I,{className:s.classNames("k-prompt-send",{"k-generating":m,"k-active":m}),fillMode:"flat",onClick:m?h:T,...w})),...x})};e.AIPrompt=e=>{const{activeView:n,toolbarItems:o,children:a,onActiveViewChange:r,onPromptRequest:i,onCommandExecute:l,style:c,dir:p,className:m,streaming:u,onCancel:d,...h}=e,g=o||[H,$],[k,I]=t.useState({activeView:n}),E={...k,activeView:n,streaming:u,onCancel:d,onActiveViewChange:r,onPromptRequest:i,onCommandExecute:l};return t.createElement(z.Provider,{value:[E,e=>{I(e)}]},t.createElement("div",{className:s.classNames("k-prompt",m),style:c,dir:p,...h},t.createElement(O,{activeView:E.activeView,toolbarItems:g,activeViewChange:r}),a))},e.AIPromptCommandsView=e=>{const{commands:s}=e,[n]=W();return t.createElement(j,{name:_.name},t.createElement(q,{streaming:n.streaming,onCancel:n.onCancel},t.createElement("div",{className:"k-prompt-view"},t.createElement(i.PanelBar,{onSelect:e=>{var t,s,o;const a=null==(s=null==(t=e.target)?void 0:t.props)?void 0:s.data;null!=(o=a.children)&&o.length||n.onCommandExecute&&n.onCommandExecute.call(null,a)},selected:""},Y(null!=s?s:[])))))},e.AIPromptContent=q,e.AIPromptFooter=G,e.AIPromptOutputView=e=>{const[s,o]=t.useState(""),l=t.useRef(null),[c]=W(),{outputs:p,showOutputRating:m,outputCard:u}=e,{header:d,body:h,actions:g}=u||{},k=n.useLocalization(),I=(e,t)=>{c.onPromptRequest&&c.onPromptRequest.call(null,e.prompt,{...e,ratingType:t,isRetry:!1}),E()},E=()=>{l&&l.current&&l.current.scrollTo({top:0,behavior:"smooth"})},v=t.createElement(i.Card,null,t.createElement(i.CardHeader,null,t.createElement(i.CardTitle,null,t.createElement("span",{className:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"200px"}})),t.createElement(i.CardSubtitle,null,t.createElement("span",{className:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"100%"}}))),t.createElement(i.CardBody,null,t.createElement("span",{className:"k-skeleton k-skeleton-rect k-skeleton-pulse",style:{height:"80px"}})),t.createElement(i.CardActions,null,t.createElement("span",{className:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"100%"}}))),C=null==p?void 0:p.map(((e,n)=>t.createElement(i.Card,{key:`${e.id}_${n}`},t.createElement(i.CardHeader,null,d?d(e):t.createElement(t.Fragment,null,e.title&&t.createElement(i.CardTitle,null,e.title),e.subTitle&&t.createElement(i.CardSubtitle,null,e.subTitle))),t.createElement(i.CardBody,null,h?h(e):e.responseContent),t.createElement(i.CardActions,null,g?g(e):t.createElement(t.Fragment,null,t.createElement(r.Button,{size:"medium",themeColor:"primary",fillMode:"flat",rounded:"medium",title:"Copy",svgIcon:s===e.id?a.checkIcon:a.copyIcon,onClick:()=>(e=>{null!=e&&e.responseContent&&navigator.clipboard.writeText(e.responseContent),o(e.id),setTimeout((()=>{o("")}),1e3)})(e)},"Copy"),t.createElement(r.Button,{size:"medium",themeColor:"base",fillMode:"flat",rounded:"medium",title:"Retry",svgIcon:a.arrowRotateCwIcon,onClick:()=>(e=>{c.onPromptRequest&&c.onPromptRequest.call(null,e.prompt,{...e,isRetry:!0}),E()})(e)},"Retry"),m&&t.createElement(t.Fragment,null,t.createElement("span",{className:"k-spacer"}),t.createElement(r.Button,{size:"medium",themeColor:"positive"===e.ratingType?"primary":"base",fillMode:"flat",rounded:"medium",title:"Rate up",svgIcon:a.thumbUpOutlineIcon,onClick:()=>I(e,"positive")}),t.createElement(r.Button,{size:"medium",themeColor:"negative"===e.ratingType?"primary":"base",fillMode:"flat",rounded:"medium",title:"Rate down",svgIcon:a.thumbDownOutlineIcon,onClick:()=>I(e,"negative")}))))))),y=t.createElement(i.Card,null,t.createElement(i.CardBody,null,k.toLanguageString(R,L[R])));return t.createElement(j,{name:$.name},t.createElement(q,{ref:l,streaming:c.streaming,onCancel:c.onCancel},t.createElement("div",{className:"k-card-list"},c.streaming&&v,C,(!C||0===C.length)&&!c.streaming&&y)))},e.AIPromptView=e=>{const{promptInput:n=l.TextArea,generateButton:o=r.Button,promptValue:i,promptSuggestions:c}=e,[p,m]=t.useState(i||""),[u]=W(),[d,h]=s.useCustomComponent(o),[g,k]=s.useCustomComponent(n),I={title:"Generate",children:"Generate",svgIcon:a.sparklesIcon},E=Object.keys(h).length>0?h:I,v=Object.keys(k).length>0?k:{placeholder:"Ask or generate content with AI ...",rows:2};return t.createElement(j,{name:H.name},t.createElement(q,{streaming:u.streaming,onCancel:u.onCancel},t.createElement(g,{value:p,onChange:e=>{m(e.target.value)},...v}),c&&c.length>0&&t.createElement(U,{title:"Prompt Suggestions"},t.createElement("div",{className:"k-suggestion-group"},c.map((e=>t.createElement("div",{key:e,className:"k-suggestion",onClick:()=>(e=>{m(e)})(e),tabIndex:0},e)))))),t.createElement(G,null,t.createElement(d,{themeColor:"primary",fillMode:"solid",rounded:"full",size:"medium",onClick:()=>{u.onPromptRequest&&u.onPromptRequest.call(null,p),m("")},disabled:!p.trim(),...E},E.children)))},e.AIPromptViewRender=j,e.Chat=F,e.ChatMessage=h,e.HeroCard=K,e.InlineAIPrompt=e=>{const{outputs:n=[],outputCard:o,promptInput:c=l.TextArea,generateButton:p=r.Button,promptPlaceholder:m="Ask or generate content with AI...",promptValue:u,onPromptRequest:d,onCopy:h,onDiscard:g,outputActions:k,onOutputAction:I,enableSpeechToText:E=!1,streaming:v,onPromptCancel:C,show:y=!1,anchor:f,width:b,height:w,onOpen:x,onClose:N,animate:T=!0,appendTo:S,commands:R,onCommandExecute:B,style:L,className:D,popupOptions:A={},...M}=e,[V,P]=t.useState(""),[F,K]=t.useState(!1),[O,G]=t.useState({left:0,top:0}),z=t.useRef(null),{body:W,actions:j}=o||{},U=k||[{id:"copy",text:"Copy",svgIcon:a.copyIcon,themeColor:"primary",title:"Copy"},{id:"discard",text:"Discard",svgIcon:a.cancelOutlineIcon,themeColor:"base",title:"Discard"}],H=(e,t)=>{switch(e.id){case"copy":(e=>{e.responseContent&&(navigator.clipboard.writeText(e.responseContent),P(e.id),setTimeout((()=>P("")),1e3)),null==h||h(e)})(t);break;case"discard":(e=>{null==g||g(e)})(t);break;default:null==I||I(e,t)}},$=t.useCallback((e=>{"Escape"===e.key&&(v&&C?C():!v&&N&&N({target:null}))}),[v,C,N]),_={...L,...b&&{width:b},...w&&{height:w}},Y={...b&&{width:b},...w&&{height:w}},X=t.createElement("div",{className:s.classNames("k-prompt",D),style:_,onKeyDown:$,...M},t.createElement(q,{ref:z},n&&n.length>0&&t.createElement("div",{className:"k-card-list"},n.map(((e,s)=>t.createElement(i.Card,{key:`${e.id}_${s}`},t.createElement(i.CardBody,null,W?W(e):e.responseContent),t.createElement(i.CardActions,null,j?j(e):t.createElement(t.Fragment,null,U.map((s=>{var n;return t.createElement(r.Button,{key:s.id,size:"medium",themeColor:s.themeColor||"primary",fillMode:"flat",rounded:"medium",title:null!=(n=s.title)?n:s.text,svgIcon:"copy"===s.id&&V===e.id?a.checkIcon:s.svgIcon,"aria-hidden":"true",onClick:()=>H(s,e)},s.text)})))))))),t.createElement(Q,{promptValue:u,placeholder:m,onPromptRequest:d,onMenuClick:e=>{if(!z.current)return;const t=z.current.getBoundingClientRect();G({left:t.left,top:t.bottom}),K(!0)},onPromptCancel:C,promptInput:c,generateButton:p,enableSpeechToText:E,streaming:v,commands:R})));return t.createElement(t.Fragment,null,t.createElement(J,{show:y,anchor:f,onOpen:x,onClose:N,animate:T,appendTo:S,popupOptions:A,style:Y},X),t.createElement(i.ContextMenu,{show:F,offset:O,onClose:()=>{K(!1)},items:(e=>null==e?void 0:e.map((e=>({text:e.text,svgIcon:e.svgIcon,data:e,items:e.children?e.children.map((e=>({text:e.text,data:e}))):void 0}))))(R),onSelect:e=>{var t,s;const n=null==(t=e.item)?void 0:t.data;n&&(null==(s=n.children)||!s.length)&&(e=>{K(!1),B&&B(e)})(n)}}))},e.PromptHeader=O,e.commandsViewDefaults=_,e.outputViewDefaults=$,e.promptViewDefaults=H}));
|
package/index.d.mts
CHANGED
|
@@ -11,7 +11,10 @@ import { CustomComponent } from '@progress/kendo-react-common';
|
|
|
11
11
|
import { default as default_2 } from 'prop-types';
|
|
12
12
|
import { default as default_3 } from 'react';
|
|
13
13
|
import { JSX } from 'react/jsx-runtime';
|
|
14
|
+
import { PopupAnimation } from '@progress/kendo-react-popup';
|
|
15
|
+
import { PopupProps } from '@progress/kendo-react-popup';
|
|
14
16
|
import * as React_2 from 'react';
|
|
17
|
+
import { SpeechToTextButtonProps } from '@progress/kendo-react-buttons';
|
|
15
18
|
import { SVGIcon } from '@progress/kendo-svg-icons';
|
|
16
19
|
import { SVGIcon as SVGIcon_2 } from '@progress/kendo-react-common';
|
|
17
20
|
import { TextAreaProps } from '@progress/kendo-react-inputs';
|
|
@@ -72,6 +75,17 @@ export declare interface AIPromptCardInterface {
|
|
|
72
75
|
actions?: (props: AIPromptOutputInterface) => default_3.ReactNode;
|
|
73
76
|
}
|
|
74
77
|
|
|
78
|
+
declare interface AIPromptCardInterface_2 {
|
|
79
|
+
/**
|
|
80
|
+
* Custom template for AIPromptCard body.
|
|
81
|
+
*/
|
|
82
|
+
body?: (props: InlineAIPromptOutputInterface) => default_3.ReactNode;
|
|
83
|
+
/**
|
|
84
|
+
* Custom template for AIPromptCard actions.
|
|
85
|
+
*/
|
|
86
|
+
actions?: (props: InlineAIPromptOutputInterface) => default_3.ReactNode;
|
|
87
|
+
}
|
|
88
|
+
|
|
75
89
|
/**
|
|
76
90
|
* The props of the AIPromptCommandsView component.
|
|
77
91
|
*/
|
|
@@ -710,6 +724,11 @@ export declare interface CommandItemInterface {
|
|
|
710
724
|
* Specifies the name of the SVG icon that will be rendered for the command.
|
|
711
725
|
*/
|
|
712
726
|
svgIcon?: SVGIcon_2;
|
|
727
|
+
/**
|
|
728
|
+
* Optional prompt function that takes selected text and returns a formatted prompt.
|
|
729
|
+
* This is used by default commands and can be used by custom commands.
|
|
730
|
+
*/
|
|
731
|
+
prompt?: (selection: string) => string;
|
|
713
732
|
}
|
|
714
733
|
|
|
715
734
|
/**
|
|
@@ -789,6 +808,173 @@ export declare interface HeroCardProps {
|
|
|
789
808
|
imageMaxWidth?: string | number;
|
|
790
809
|
}
|
|
791
810
|
|
|
811
|
+
export declare const InlineAIPrompt: (props: InlineAIPromptProps) => JSX.Element;
|
|
812
|
+
|
|
813
|
+
export declare interface InlineAIPromptOutputInterface {
|
|
814
|
+
/**
|
|
815
|
+
* Example usage of the `id` property:
|
|
816
|
+
* ```jsx
|
|
817
|
+
* const output = { id: 1, responseContent: 'Generated content' };
|
|
818
|
+
* ```
|
|
819
|
+
*/
|
|
820
|
+
id: string | number;
|
|
821
|
+
/**
|
|
822
|
+
* Example usage of the `prompt` property:
|
|
823
|
+
* ```jsx
|
|
824
|
+
* const output = { prompt: 'User prompt', responseContent: 'Generated content' };
|
|
825
|
+
* ```
|
|
826
|
+
*/
|
|
827
|
+
prompt?: string;
|
|
828
|
+
/**
|
|
829
|
+
* Example usage of the `responseContent` property:
|
|
830
|
+
* ```jsx
|
|
831
|
+
* const output = { responseContent: 'Generated content' };
|
|
832
|
+
* ```
|
|
833
|
+
*/
|
|
834
|
+
responseContent: string;
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
declare interface InlineAIPromptPopupProps {
|
|
838
|
+
/**
|
|
839
|
+
* Controls the visibility of the popup.
|
|
840
|
+
*
|
|
841
|
+
* @default false
|
|
842
|
+
*/
|
|
843
|
+
show?: boolean;
|
|
844
|
+
/**
|
|
845
|
+
* The element that serves as an anchor for the popup.
|
|
846
|
+
*/
|
|
847
|
+
anchor?: HTMLElement | null;
|
|
848
|
+
/**
|
|
849
|
+
* Fires when the popup is opened.
|
|
850
|
+
*/
|
|
851
|
+
onOpen?: (event: {
|
|
852
|
+
target: any;
|
|
853
|
+
}) => void;
|
|
854
|
+
/**
|
|
855
|
+
* Fires when the popup is closed.
|
|
856
|
+
*/
|
|
857
|
+
onClose?: (event: {
|
|
858
|
+
target: any;
|
|
859
|
+
}) => void;
|
|
860
|
+
/**
|
|
861
|
+
* Controls the animation of the popup.
|
|
862
|
+
*
|
|
863
|
+
* @default true
|
|
864
|
+
*/
|
|
865
|
+
animate?: boolean | PopupAnimation;
|
|
866
|
+
/**
|
|
867
|
+
* The container element where the popup will be rendered.
|
|
868
|
+
* If not specified, the popup will be rendered in the document body.
|
|
869
|
+
*/
|
|
870
|
+
appendTo?: HTMLElement;
|
|
871
|
+
/**
|
|
872
|
+
* Object which passes props directly to the Popup component.
|
|
873
|
+
*/
|
|
874
|
+
popupOptions?: PopupProps;
|
|
875
|
+
/**
|
|
876
|
+
* The content to render inside the popup.
|
|
877
|
+
*/
|
|
878
|
+
children?: default_3.ReactNode;
|
|
879
|
+
/**
|
|
880
|
+
* Additional CSS styles for the popup content.
|
|
881
|
+
*/
|
|
882
|
+
style?: default_3.CSSProperties;
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
export declare interface InlineAIPromptProps extends Omit<default_3.HTMLAttributes<HTMLElement>, 'onCopy'>, InlineAIPromptPopupProps {
|
|
886
|
+
/**
|
|
887
|
+
* Example usage of the `style` property:
|
|
888
|
+
* ```jsx
|
|
889
|
+
* <InlineAIPrompt style={{ backgroundColor: 'lightblue' }} />
|
|
890
|
+
* ```
|
|
891
|
+
*/
|
|
892
|
+
style?: default_3.CSSProperties;
|
|
893
|
+
/**
|
|
894
|
+
* The collection of outputs to display as cards
|
|
895
|
+
*/
|
|
896
|
+
outputs?: InlineAIPromptOutputInterface[];
|
|
897
|
+
/**
|
|
898
|
+
* Represents a template that allows you to define custom Card fields for:
|
|
899
|
+
* header, body, actions
|
|
900
|
+
* The custom fields will override the default one.
|
|
901
|
+
*/
|
|
902
|
+
outputCard?: AIPromptCardInterface_2;
|
|
903
|
+
/**
|
|
904
|
+
* Placeholder text for the prompt input
|
|
905
|
+
*/
|
|
906
|
+
promptPlaceholder?: string;
|
|
907
|
+
/**
|
|
908
|
+
* The initial value of the prompt input
|
|
909
|
+
*/
|
|
910
|
+
promptValue?: string;
|
|
911
|
+
/**
|
|
912
|
+
* Callback when user submits a prompt
|
|
913
|
+
*/
|
|
914
|
+
onPromptRequest?: (prompt: string, outputItem?: InlineAIPromptOutputInterface) => void;
|
|
915
|
+
/**
|
|
916
|
+
* Specifies the callback for cancel action.
|
|
917
|
+
*/
|
|
918
|
+
onPromptCancel?: () => void;
|
|
919
|
+
/**
|
|
920
|
+
* Fires each time the user clicks Copy button in the card.
|
|
921
|
+
*/
|
|
922
|
+
onCopy?: (output: InlineAIPromptOutputInterface) => void;
|
|
923
|
+
/**
|
|
924
|
+
* Fires each time the user clicks Discard button in the card.
|
|
925
|
+
*/
|
|
926
|
+
onDiscard?: (output: InlineAIPromptOutputInterface) => void;
|
|
927
|
+
/**
|
|
928
|
+
* The collection of output actions that will be rendered in the card actions.
|
|
929
|
+
* If not specified, default actions (copy, discard) will be used.
|
|
930
|
+
* You can override built-in actions.
|
|
931
|
+
*/
|
|
932
|
+
outputActions?: OutputActionInterface[];
|
|
933
|
+
/**
|
|
934
|
+
* Fires when an action command is executed.
|
|
935
|
+
* Built-in actions (copy, discard) are handled internally by the component.
|
|
936
|
+
* All other actions are handled by this callback.
|
|
937
|
+
*/
|
|
938
|
+
onOutputAction?: (command: OutputActionInterface, output: InlineAIPromptOutputInterface) => void;
|
|
939
|
+
/**
|
|
940
|
+
* Accepts a custom component that can be used to render the prompt input.
|
|
941
|
+
*/
|
|
942
|
+
promptInput?: CustomComponent<TextAreaProps>;
|
|
943
|
+
/**
|
|
944
|
+
* Accepts a custom component that can be used to render the generate button.
|
|
945
|
+
*/
|
|
946
|
+
generateButton?: CustomComponent<ButtonProps>;
|
|
947
|
+
/**
|
|
948
|
+
* Show speech to text button in input. When true, shows the button with default settings.
|
|
949
|
+
* When an object is provided, passes those props directly to the SpeechToTextButton component.
|
|
950
|
+
*
|
|
951
|
+
* @default false
|
|
952
|
+
*/
|
|
953
|
+
enableSpeechToText?: boolean | SpeechToTextButtonProps;
|
|
954
|
+
/**
|
|
955
|
+
* Specifies if the content is being streamed.
|
|
956
|
+
*/
|
|
957
|
+
streaming?: boolean;
|
|
958
|
+
/**
|
|
959
|
+
* The collection of commands that will be rendered in the context menu.
|
|
960
|
+
* If not specified, default AI text editing commands will be used.
|
|
961
|
+
*/
|
|
962
|
+
commands?: CommandInterface[];
|
|
963
|
+
/**
|
|
964
|
+
* The width of the component.
|
|
965
|
+
*/
|
|
966
|
+
width?: number | string;
|
|
967
|
+
/**
|
|
968
|
+
* The height of the component.
|
|
969
|
+
*/
|
|
970
|
+
height?: number | string;
|
|
971
|
+
/**
|
|
972
|
+
* Fires when a command from the context menu is executed.
|
|
973
|
+
* Exposes the selected command and current prompt value as event data.
|
|
974
|
+
*/
|
|
975
|
+
onCommandExecute?: (command: CommandItemInterface) => void;
|
|
976
|
+
}
|
|
977
|
+
|
|
792
978
|
/**
|
|
793
979
|
* Represents a Chat message.
|
|
794
980
|
*
|
|
@@ -849,6 +1035,29 @@ export declare interface Message {
|
|
|
849
1035
|
export declare interface MessageModel extends Message, Selectable {
|
|
850
1036
|
}
|
|
851
1037
|
|
|
1038
|
+
export declare interface OutputActionInterface {
|
|
1039
|
+
/**
|
|
1040
|
+
* The unique identifier for the action command
|
|
1041
|
+
*/
|
|
1042
|
+
id: string;
|
|
1043
|
+
/**
|
|
1044
|
+
* The text to display on the button
|
|
1045
|
+
*/
|
|
1046
|
+
text: string;
|
|
1047
|
+
/**
|
|
1048
|
+
* The SVG icon to display on the button
|
|
1049
|
+
*/
|
|
1050
|
+
svgIcon?: any;
|
|
1051
|
+
/**
|
|
1052
|
+
* The theme color of the button
|
|
1053
|
+
*/
|
|
1054
|
+
themeColor?: ButtonProps['themeColor'];
|
|
1055
|
+
/**
|
|
1056
|
+
* The title attribute for the button (tooltip)
|
|
1057
|
+
*/
|
|
1058
|
+
title?: string;
|
|
1059
|
+
}
|
|
1060
|
+
|
|
852
1061
|
/**
|
|
853
1062
|
* Specifies the default values for Output view Toolbar.
|
|
854
1063
|
*/
|
package/index.d.ts
CHANGED
|
@@ -11,7 +11,10 @@ import { CustomComponent } from '@progress/kendo-react-common';
|
|
|
11
11
|
import { default as default_2 } from 'prop-types';
|
|
12
12
|
import { default as default_3 } from 'react';
|
|
13
13
|
import { JSX } from 'react/jsx-runtime';
|
|
14
|
+
import { PopupAnimation } from '@progress/kendo-react-popup';
|
|
15
|
+
import { PopupProps } from '@progress/kendo-react-popup';
|
|
14
16
|
import * as React_2 from 'react';
|
|
17
|
+
import { SpeechToTextButtonProps } from '@progress/kendo-react-buttons';
|
|
15
18
|
import { SVGIcon } from '@progress/kendo-svg-icons';
|
|
16
19
|
import { SVGIcon as SVGIcon_2 } from '@progress/kendo-react-common';
|
|
17
20
|
import { TextAreaProps } from '@progress/kendo-react-inputs';
|
|
@@ -72,6 +75,17 @@ export declare interface AIPromptCardInterface {
|
|
|
72
75
|
actions?: (props: AIPromptOutputInterface) => default_3.ReactNode;
|
|
73
76
|
}
|
|
74
77
|
|
|
78
|
+
declare interface AIPromptCardInterface_2 {
|
|
79
|
+
/**
|
|
80
|
+
* Custom template for AIPromptCard body.
|
|
81
|
+
*/
|
|
82
|
+
body?: (props: InlineAIPromptOutputInterface) => default_3.ReactNode;
|
|
83
|
+
/**
|
|
84
|
+
* Custom template for AIPromptCard actions.
|
|
85
|
+
*/
|
|
86
|
+
actions?: (props: InlineAIPromptOutputInterface) => default_3.ReactNode;
|
|
87
|
+
}
|
|
88
|
+
|
|
75
89
|
/**
|
|
76
90
|
* The props of the AIPromptCommandsView component.
|
|
77
91
|
*/
|
|
@@ -710,6 +724,11 @@ export declare interface CommandItemInterface {
|
|
|
710
724
|
* Specifies the name of the SVG icon that will be rendered for the command.
|
|
711
725
|
*/
|
|
712
726
|
svgIcon?: SVGIcon_2;
|
|
727
|
+
/**
|
|
728
|
+
* Optional prompt function that takes selected text and returns a formatted prompt.
|
|
729
|
+
* This is used by default commands and can be used by custom commands.
|
|
730
|
+
*/
|
|
731
|
+
prompt?: (selection: string) => string;
|
|
713
732
|
}
|
|
714
733
|
|
|
715
734
|
/**
|
|
@@ -789,6 +808,173 @@ export declare interface HeroCardProps {
|
|
|
789
808
|
imageMaxWidth?: string | number;
|
|
790
809
|
}
|
|
791
810
|
|
|
811
|
+
export declare const InlineAIPrompt: (props: InlineAIPromptProps) => JSX.Element;
|
|
812
|
+
|
|
813
|
+
export declare interface InlineAIPromptOutputInterface {
|
|
814
|
+
/**
|
|
815
|
+
* Example usage of the `id` property:
|
|
816
|
+
* ```jsx
|
|
817
|
+
* const output = { id: 1, responseContent: 'Generated content' };
|
|
818
|
+
* ```
|
|
819
|
+
*/
|
|
820
|
+
id: string | number;
|
|
821
|
+
/**
|
|
822
|
+
* Example usage of the `prompt` property:
|
|
823
|
+
* ```jsx
|
|
824
|
+
* const output = { prompt: 'User prompt', responseContent: 'Generated content' };
|
|
825
|
+
* ```
|
|
826
|
+
*/
|
|
827
|
+
prompt?: string;
|
|
828
|
+
/**
|
|
829
|
+
* Example usage of the `responseContent` property:
|
|
830
|
+
* ```jsx
|
|
831
|
+
* const output = { responseContent: 'Generated content' };
|
|
832
|
+
* ```
|
|
833
|
+
*/
|
|
834
|
+
responseContent: string;
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
declare interface InlineAIPromptPopupProps {
|
|
838
|
+
/**
|
|
839
|
+
* Controls the visibility of the popup.
|
|
840
|
+
*
|
|
841
|
+
* @default false
|
|
842
|
+
*/
|
|
843
|
+
show?: boolean;
|
|
844
|
+
/**
|
|
845
|
+
* The element that serves as an anchor for the popup.
|
|
846
|
+
*/
|
|
847
|
+
anchor?: HTMLElement | null;
|
|
848
|
+
/**
|
|
849
|
+
* Fires when the popup is opened.
|
|
850
|
+
*/
|
|
851
|
+
onOpen?: (event: {
|
|
852
|
+
target: any;
|
|
853
|
+
}) => void;
|
|
854
|
+
/**
|
|
855
|
+
* Fires when the popup is closed.
|
|
856
|
+
*/
|
|
857
|
+
onClose?: (event: {
|
|
858
|
+
target: any;
|
|
859
|
+
}) => void;
|
|
860
|
+
/**
|
|
861
|
+
* Controls the animation of the popup.
|
|
862
|
+
*
|
|
863
|
+
* @default true
|
|
864
|
+
*/
|
|
865
|
+
animate?: boolean | PopupAnimation;
|
|
866
|
+
/**
|
|
867
|
+
* The container element where the popup will be rendered.
|
|
868
|
+
* If not specified, the popup will be rendered in the document body.
|
|
869
|
+
*/
|
|
870
|
+
appendTo?: HTMLElement;
|
|
871
|
+
/**
|
|
872
|
+
* Object which passes props directly to the Popup component.
|
|
873
|
+
*/
|
|
874
|
+
popupOptions?: PopupProps;
|
|
875
|
+
/**
|
|
876
|
+
* The content to render inside the popup.
|
|
877
|
+
*/
|
|
878
|
+
children?: default_3.ReactNode;
|
|
879
|
+
/**
|
|
880
|
+
* Additional CSS styles for the popup content.
|
|
881
|
+
*/
|
|
882
|
+
style?: default_3.CSSProperties;
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
export declare interface InlineAIPromptProps extends Omit<default_3.HTMLAttributes<HTMLElement>, 'onCopy'>, InlineAIPromptPopupProps {
|
|
886
|
+
/**
|
|
887
|
+
* Example usage of the `style` property:
|
|
888
|
+
* ```jsx
|
|
889
|
+
* <InlineAIPrompt style={{ backgroundColor: 'lightblue' }} />
|
|
890
|
+
* ```
|
|
891
|
+
*/
|
|
892
|
+
style?: default_3.CSSProperties;
|
|
893
|
+
/**
|
|
894
|
+
* The collection of outputs to display as cards
|
|
895
|
+
*/
|
|
896
|
+
outputs?: InlineAIPromptOutputInterface[];
|
|
897
|
+
/**
|
|
898
|
+
* Represents a template that allows you to define custom Card fields for:
|
|
899
|
+
* header, body, actions
|
|
900
|
+
* The custom fields will override the default one.
|
|
901
|
+
*/
|
|
902
|
+
outputCard?: AIPromptCardInterface_2;
|
|
903
|
+
/**
|
|
904
|
+
* Placeholder text for the prompt input
|
|
905
|
+
*/
|
|
906
|
+
promptPlaceholder?: string;
|
|
907
|
+
/**
|
|
908
|
+
* The initial value of the prompt input
|
|
909
|
+
*/
|
|
910
|
+
promptValue?: string;
|
|
911
|
+
/**
|
|
912
|
+
* Callback when user submits a prompt
|
|
913
|
+
*/
|
|
914
|
+
onPromptRequest?: (prompt: string, outputItem?: InlineAIPromptOutputInterface) => void;
|
|
915
|
+
/**
|
|
916
|
+
* Specifies the callback for cancel action.
|
|
917
|
+
*/
|
|
918
|
+
onPromptCancel?: () => void;
|
|
919
|
+
/**
|
|
920
|
+
* Fires each time the user clicks Copy button in the card.
|
|
921
|
+
*/
|
|
922
|
+
onCopy?: (output: InlineAIPromptOutputInterface) => void;
|
|
923
|
+
/**
|
|
924
|
+
* Fires each time the user clicks Discard button in the card.
|
|
925
|
+
*/
|
|
926
|
+
onDiscard?: (output: InlineAIPromptOutputInterface) => void;
|
|
927
|
+
/**
|
|
928
|
+
* The collection of output actions that will be rendered in the card actions.
|
|
929
|
+
* If not specified, default actions (copy, discard) will be used.
|
|
930
|
+
* You can override built-in actions.
|
|
931
|
+
*/
|
|
932
|
+
outputActions?: OutputActionInterface[];
|
|
933
|
+
/**
|
|
934
|
+
* Fires when an action command is executed.
|
|
935
|
+
* Built-in actions (copy, discard) are handled internally by the component.
|
|
936
|
+
* All other actions are handled by this callback.
|
|
937
|
+
*/
|
|
938
|
+
onOutputAction?: (command: OutputActionInterface, output: InlineAIPromptOutputInterface) => void;
|
|
939
|
+
/**
|
|
940
|
+
* Accepts a custom component that can be used to render the prompt input.
|
|
941
|
+
*/
|
|
942
|
+
promptInput?: CustomComponent<TextAreaProps>;
|
|
943
|
+
/**
|
|
944
|
+
* Accepts a custom component that can be used to render the generate button.
|
|
945
|
+
*/
|
|
946
|
+
generateButton?: CustomComponent<ButtonProps>;
|
|
947
|
+
/**
|
|
948
|
+
* Show speech to text button in input. When true, shows the button with default settings.
|
|
949
|
+
* When an object is provided, passes those props directly to the SpeechToTextButton component.
|
|
950
|
+
*
|
|
951
|
+
* @default false
|
|
952
|
+
*/
|
|
953
|
+
enableSpeechToText?: boolean | SpeechToTextButtonProps;
|
|
954
|
+
/**
|
|
955
|
+
* Specifies if the content is being streamed.
|
|
956
|
+
*/
|
|
957
|
+
streaming?: boolean;
|
|
958
|
+
/**
|
|
959
|
+
* The collection of commands that will be rendered in the context menu.
|
|
960
|
+
* If not specified, default AI text editing commands will be used.
|
|
961
|
+
*/
|
|
962
|
+
commands?: CommandInterface[];
|
|
963
|
+
/**
|
|
964
|
+
* The width of the component.
|
|
965
|
+
*/
|
|
966
|
+
width?: number | string;
|
|
967
|
+
/**
|
|
968
|
+
* The height of the component.
|
|
969
|
+
*/
|
|
970
|
+
height?: number | string;
|
|
971
|
+
/**
|
|
972
|
+
* Fires when a command from the context menu is executed.
|
|
973
|
+
* Exposes the selected command and current prompt value as event data.
|
|
974
|
+
*/
|
|
975
|
+
onCommandExecute?: (command: CommandItemInterface) => void;
|
|
976
|
+
}
|
|
977
|
+
|
|
792
978
|
/**
|
|
793
979
|
* Represents a Chat message.
|
|
794
980
|
*
|
|
@@ -849,6 +1035,29 @@ export declare interface Message {
|
|
|
849
1035
|
export declare interface MessageModel extends Message, Selectable {
|
|
850
1036
|
}
|
|
851
1037
|
|
|
1038
|
+
export declare interface OutputActionInterface {
|
|
1039
|
+
/**
|
|
1040
|
+
* The unique identifier for the action command
|
|
1041
|
+
*/
|
|
1042
|
+
id: string;
|
|
1043
|
+
/**
|
|
1044
|
+
* The text to display on the button
|
|
1045
|
+
*/
|
|
1046
|
+
text: string;
|
|
1047
|
+
/**
|
|
1048
|
+
* The SVG icon to display on the button
|
|
1049
|
+
*/
|
|
1050
|
+
svgIcon?: any;
|
|
1051
|
+
/**
|
|
1052
|
+
* The theme color of the button
|
|
1053
|
+
*/
|
|
1054
|
+
themeColor?: ButtonProps['themeColor'];
|
|
1055
|
+
/**
|
|
1056
|
+
* The title attribute for the button (tooltip)
|
|
1057
|
+
*/
|
|
1058
|
+
title?: string;
|
|
1059
|
+
}
|
|
1060
|
+
|
|
852
1061
|
/**
|
|
853
1062
|
* Specifies the default values for Output view Toolbar.
|
|
854
1063
|
*/
|
package/index.js
CHANGED
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
8
|
"use client";
|
|
9
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./components/ChatMessage.js"),m=require("./components/Chat.js"),p=require("./components/templates/HeroCard.js"),i=require("./ai-prompt/AIPrompt.js"),
|
|
9
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./components/ChatMessage.js"),m=require("./components/Chat.js"),p=require("./components/templates/HeroCard.js"),i=require("./ai-prompt/AIPrompt.js"),n=require("./ai-prompt/AIPromptHeader.js"),s=require("./ai-prompt/AIPromptFooter.js"),u=require("./ai-prompt/AIPromptContent.js"),e=require("./ai-prompt/views/AIPromptView.js"),t=require("./ai-prompt/views/AIPromptOutputView.js"),r=require("./ai-prompt/views/AIPromptCommandsView.js"),a=require("./ai-prompt/views/AIPromptViewRender.js"),I=require("./inline-ai-prompt/InlineAIPrompt.js");exports.ChatMessage=o.ChatMessage;exports.Chat=m.Chat;exports.HeroCard=p.HeroCard;exports.AIPrompt=i.AIPrompt;exports.PromptHeader=n.PromptHeader;exports.AIPromptFooter=s.AIPromptFooter;exports.AIPromptContent=u.AIPromptContent;exports.AIPromptView=e.AIPromptView;exports.promptViewDefaults=e.promptViewDefaults;exports.AIPromptOutputView=t.AIPromptOutputView;exports.outputViewDefaults=t.outputViewDefaults;exports.AIPromptCommandsView=r.AIPromptCommandsView;exports.commandsViewDefaults=r.commandsViewDefaults;exports.AIPromptViewRender=a.AIPromptViewRender;exports.InlineAIPrompt=I.InlineAIPrompt;
|
package/index.mjs
CHANGED
|
@@ -10,26 +10,28 @@ import { ChatMessage as t } from "./components/ChatMessage.mjs";
|
|
|
10
10
|
import { Chat as m } from "./components/Chat.mjs";
|
|
11
11
|
import { HeroCard as f } from "./components/templates/HeroCard.mjs";
|
|
12
12
|
import { AIPrompt as a } from "./ai-prompt/AIPrompt.mjs";
|
|
13
|
-
import { PromptHeader as
|
|
14
|
-
import { AIPromptFooter as
|
|
15
|
-
import { AIPromptContent as
|
|
16
|
-
import { AIPromptView as
|
|
13
|
+
import { PromptHeader as P } from "./ai-prompt/AIPromptHeader.mjs";
|
|
14
|
+
import { AIPromptFooter as A } from "./ai-prompt/AIPromptFooter.mjs";
|
|
15
|
+
import { AIPromptContent as s } from "./ai-prompt/AIPromptContent.mjs";
|
|
16
|
+
import { AIPromptView as w, promptViewDefaults as V } from "./ai-prompt/views/AIPromptView.mjs";
|
|
17
17
|
import { AIPromptOutputView as C, outputViewDefaults as l } from "./ai-prompt/views/AIPromptOutputView.mjs";
|
|
18
18
|
import { AIPromptCommandsView as h, commandsViewDefaults as H } from "./ai-prompt/views/AIPromptCommandsView.mjs";
|
|
19
19
|
import { AIPromptViewRender as g } from "./ai-prompt/views/AIPromptViewRender.mjs";
|
|
20
|
+
import { InlineAIPrompt as M } from "./inline-ai-prompt/InlineAIPrompt.mjs";
|
|
20
21
|
export {
|
|
21
22
|
a as AIPrompt,
|
|
22
23
|
h as AIPromptCommandsView,
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
s as AIPromptContent,
|
|
25
|
+
A as AIPromptFooter,
|
|
25
26
|
C as AIPromptOutputView,
|
|
26
|
-
|
|
27
|
+
w as AIPromptView,
|
|
27
28
|
g as AIPromptViewRender,
|
|
28
29
|
m as Chat,
|
|
29
30
|
t as ChatMessage,
|
|
30
31
|
f as HeroCard,
|
|
31
|
-
|
|
32
|
+
M as InlineAIPrompt,
|
|
33
|
+
P as PromptHeader,
|
|
32
34
|
H as commandsViewDefaults,
|
|
33
35
|
l as outputViewDefaults,
|
|
34
|
-
|
|
36
|
+
V as promptViewDefaults
|
|
35
37
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2025 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),d=require("@progress/kendo-react-layout"),x=require("@progress/kendo-react-buttons"),re=require("@progress/kendo-react-inputs"),I=require("@progress/kendo-svg-icons"),ae=require("@progress/kendo-react-common"),le=require("./InlineAIPromptPopup.js"),ce=require("./InlineAIPromptInput.js"),ie=require("../ai-prompt/AIPromptContent.js"),de=P=>{const{outputs:m=[],outputCard:b,promptInput:M=re.TextArea,generateButton:S=x.Button,promptPlaceholder:q="Ask or generate content with AI...",promptValue:w,onPromptRequest:O,onCopy:p,onDiscard:u,outputActions:A,onOutputAction:C,enableSpeechToText:R=!1,streaming:r,onPromptCancel:a,show:T=!1,anchor:B,width:l,height:c,onOpen:D,onClose:i,animate:N=!0,appendTo:F,commands:y,onCommandExecute:k,style:K,className:$,popupOptions:j={},...z}=P,[V,g]=t.useState(""),[_,h]=t.useState(!1),[G,H]=t.useState({left:0,top:0}),f=t.useRef(null),{body:E,actions:v}=b||{},J=[{id:"copy",text:"Copy",svgIcon:I.copyIcon,themeColor:"primary",title:"Copy"},{id:"discard",text:"Discard",svgIcon:I.cancelOutlineIcon,themeColor:"base",title:"Discard"}],Q=A||J,U=e=>{e.responseContent&&(navigator.clipboard.writeText(e.responseContent),g(e.id),setTimeout(()=>g(""),1e3)),p==null||p(e)},W=e=>{u==null||u(e)},X=(e,n)=>{switch(e.id){case"copy":U(n);break;case"discard":W(n);break;default:C==null||C(e,n);break}},Y=e=>{if(!f.current)return;const n=f.current.getBoundingClientRect();H({left:n.left,top:n.bottom}),h(!0)},Z=()=>{h(!1)},L=e=>{h(!1),k&&k(e)},ee=e=>e==null?void 0:e.map(n=>({text:n.text,svgIcon:n.svgIcon,data:n,items:n.children?n.children.map(o=>({text:o.text,data:o})):void 0})),te=t.useCallback(e=>{e.key==="Escape"&&(r&&a?a():!r&&i&&i({target:null}))},[r,a,i]),ne={...K,...l&&{width:l},...c&&{height:c}},oe={...l&&{width:l},...c&&{height:c}},se=t.createElement("div",{className:ae.classNames("k-prompt",$),style:ne,onKeyDown:te,...z},t.createElement(ie.AIPromptContent,{ref:f},m&&m.length>0&&t.createElement("div",{className:"k-card-list"},m.map((e,n)=>t.createElement(d.Card,{key:`${e.id}_${n}`},t.createElement(d.CardBody,null,E?E(e):e.responseContent),t.createElement(d.CardActions,null,v?v(e):t.createElement(t.Fragment,null,Q.map(o=>{var s;return t.createElement(x.Button,{key:o.id,size:"medium",themeColor:o.themeColor||"primary",fillMode:"flat",rounded:"medium",title:(s=o.title)!=null?s:o.text,svgIcon:o.id==="copy"&&V===e.id?I.checkIcon:o.svgIcon,"aria-hidden":"true",onClick:()=>X(o,e)},o.text)})))))),t.createElement(ce.InlineAIPromptInput,{promptValue:w,placeholder:q,onPromptRequest:O,onMenuClick:Y,onPromptCancel:a,promptInput:M,generateButton:S,enableSpeechToText:R,streaming:r,commands:y})));return t.createElement(t.Fragment,null,t.createElement(le.InlineAIPromptPopup,{show:T,anchor:B,onOpen:D,onClose:i,animate:N,appendTo:F,popupOptions:j,style:oe},se),t.createElement(d.ContextMenu,{show:_,offset:G,onClose:Z,items:ee(y),onSelect:e=>{var o,s;const n=(o=e.item)==null?void 0:o.data;n&&!((s=n.children)!=null&&s.length)&&L(n)}}))};exports.InlineAIPrompt=de;
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2025 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
import t from "react";
|
|
9
|
+
import { Card as ne, CardBody as oe, CardActions as re, ContextMenu as ae } from "@progress/kendo-react-layout";
|
|
10
|
+
import { Button as x } from "@progress/kendo-react-buttons";
|
|
11
|
+
import { TextArea as se } from "@progress/kendo-react-inputs";
|
|
12
|
+
import { checkIcon as le, copyIcon as ce, cancelOutlineIcon as me } from "@progress/kendo-svg-icons";
|
|
13
|
+
import { classNames as ie } from "@progress/kendo-react-common";
|
|
14
|
+
import { InlineAIPromptPopup as de } from "./InlineAIPromptPopup.mjs";
|
|
15
|
+
import { InlineAIPromptInput as pe } from "./InlineAIPromptInput.mjs";
|
|
16
|
+
import { AIPromptContent as fe } from "../ai-prompt/AIPromptContent.mjs";
|
|
17
|
+
const be = (E) => {
|
|
18
|
+
const {
|
|
19
|
+
outputs: i = [],
|
|
20
|
+
outputCard: v,
|
|
21
|
+
promptInput: b = se,
|
|
22
|
+
generateButton: M = x,
|
|
23
|
+
promptPlaceholder: w = "Ask or generate content with AI...",
|
|
24
|
+
promptValue: O,
|
|
25
|
+
onPromptRequest: S,
|
|
26
|
+
onCopy: d,
|
|
27
|
+
onDiscard: p,
|
|
28
|
+
outputActions: P,
|
|
29
|
+
onOutputAction: f,
|
|
30
|
+
enableSpeechToText: T = !1,
|
|
31
|
+
streaming: a,
|
|
32
|
+
onPromptCancel: s,
|
|
33
|
+
show: A = !1,
|
|
34
|
+
anchor: B,
|
|
35
|
+
width: l,
|
|
36
|
+
height: c,
|
|
37
|
+
onOpen: D,
|
|
38
|
+
onClose: m,
|
|
39
|
+
animate: R = !0,
|
|
40
|
+
appendTo: N,
|
|
41
|
+
commands: u,
|
|
42
|
+
onCommandExecute: y,
|
|
43
|
+
style: _,
|
|
44
|
+
className: F,
|
|
45
|
+
popupOptions: K = {},
|
|
46
|
+
...$
|
|
47
|
+
} = E, [q, I] = t.useState(""), [z, C] = t.useState(!1), [V, j] = t.useState({
|
|
48
|
+
left: 0,
|
|
49
|
+
top: 0
|
|
50
|
+
}), h = t.useRef(null), { body: g, actions: k } = v || {}, G = P || [
|
|
51
|
+
{
|
|
52
|
+
id: "copy",
|
|
53
|
+
text: "Copy",
|
|
54
|
+
svgIcon: ce,
|
|
55
|
+
themeColor: "primary",
|
|
56
|
+
title: "Copy"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
id: "discard",
|
|
60
|
+
text: "Discard",
|
|
61
|
+
svgIcon: me,
|
|
62
|
+
themeColor: "base",
|
|
63
|
+
title: "Discard"
|
|
64
|
+
}
|
|
65
|
+
], H = (e) => {
|
|
66
|
+
e.responseContent && (navigator.clipboard.writeText(e.responseContent), I(e.id), setTimeout(() => I(""), 1e3)), d == null || d(e);
|
|
67
|
+
}, J = (e) => {
|
|
68
|
+
p == null || p(e);
|
|
69
|
+
}, Q = (e, n) => {
|
|
70
|
+
switch (e.id) {
|
|
71
|
+
case "copy":
|
|
72
|
+
H(n);
|
|
73
|
+
break;
|
|
74
|
+
case "discard":
|
|
75
|
+
J(n);
|
|
76
|
+
break;
|
|
77
|
+
default:
|
|
78
|
+
f == null || f(e, n);
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
}, U = (e) => {
|
|
82
|
+
if (!h.current)
|
|
83
|
+
return;
|
|
84
|
+
const n = h.current.getBoundingClientRect();
|
|
85
|
+
j({
|
|
86
|
+
left: n.left,
|
|
87
|
+
top: n.bottom
|
|
88
|
+
}), C(!0);
|
|
89
|
+
}, W = () => {
|
|
90
|
+
C(!1);
|
|
91
|
+
}, X = (e) => {
|
|
92
|
+
C(!1), y && y(e);
|
|
93
|
+
}, Y = (e) => e == null ? void 0 : e.map((n) => ({
|
|
94
|
+
text: n.text,
|
|
95
|
+
svgIcon: n.svgIcon,
|
|
96
|
+
data: n,
|
|
97
|
+
items: n.children ? n.children.map((o) => ({
|
|
98
|
+
text: o.text,
|
|
99
|
+
data: o
|
|
100
|
+
})) : void 0
|
|
101
|
+
})), Z = t.useCallback(
|
|
102
|
+
(e) => {
|
|
103
|
+
e.key === "Escape" && (a && s ? s() : !a && m && m({ target: null }));
|
|
104
|
+
},
|
|
105
|
+
[a, s, m]
|
|
106
|
+
), L = {
|
|
107
|
+
..._,
|
|
108
|
+
...l && { width: l },
|
|
109
|
+
...c && { height: c }
|
|
110
|
+
}, ee = {
|
|
111
|
+
...l && { width: l },
|
|
112
|
+
...c && { height: c }
|
|
113
|
+
}, te = /* @__PURE__ */ t.createElement("div", { className: ie("k-prompt", F), style: L, onKeyDown: Z, ...$ }, /* @__PURE__ */ t.createElement(fe, { ref: h }, i && i.length > 0 && /* @__PURE__ */ t.createElement("div", { className: "k-card-list" }, i.map((e, n) => /* @__PURE__ */ t.createElement(ne, { key: `${e.id}_${n}` }, /* @__PURE__ */ t.createElement(oe, null, g ? g(e) : e.responseContent), /* @__PURE__ */ t.createElement(re, null, k ? k(e) : /* @__PURE__ */ t.createElement(t.Fragment, null, G.map((o) => {
|
|
114
|
+
var r;
|
|
115
|
+
return /* @__PURE__ */ t.createElement(
|
|
116
|
+
x,
|
|
117
|
+
{
|
|
118
|
+
key: o.id,
|
|
119
|
+
size: "medium",
|
|
120
|
+
themeColor: o.themeColor || "primary",
|
|
121
|
+
fillMode: "flat",
|
|
122
|
+
rounded: "medium",
|
|
123
|
+
title: (r = o.title) != null ? r : o.text,
|
|
124
|
+
svgIcon: o.id === "copy" && q === e.id ? le : o.svgIcon,
|
|
125
|
+
"aria-hidden": "true",
|
|
126
|
+
onClick: () => Q(o, e)
|
|
127
|
+
},
|
|
128
|
+
o.text
|
|
129
|
+
);
|
|
130
|
+
})))))), /* @__PURE__ */ t.createElement(
|
|
131
|
+
pe,
|
|
132
|
+
{
|
|
133
|
+
promptValue: O,
|
|
134
|
+
placeholder: w,
|
|
135
|
+
onPromptRequest: S,
|
|
136
|
+
onMenuClick: U,
|
|
137
|
+
onPromptCancel: s,
|
|
138
|
+
promptInput: b,
|
|
139
|
+
generateButton: M,
|
|
140
|
+
enableSpeechToText: T,
|
|
141
|
+
streaming: a,
|
|
142
|
+
commands: u
|
|
143
|
+
}
|
|
144
|
+
)));
|
|
145
|
+
return /* @__PURE__ */ t.createElement(t.Fragment, null, /* @__PURE__ */ t.createElement(
|
|
146
|
+
de,
|
|
147
|
+
{
|
|
148
|
+
show: A,
|
|
149
|
+
anchor: B,
|
|
150
|
+
onOpen: D,
|
|
151
|
+
onClose: m,
|
|
152
|
+
animate: R,
|
|
153
|
+
appendTo: N,
|
|
154
|
+
popupOptions: K,
|
|
155
|
+
style: ee
|
|
156
|
+
},
|
|
157
|
+
te
|
|
158
|
+
), /* @__PURE__ */ t.createElement(
|
|
159
|
+
ae,
|
|
160
|
+
{
|
|
161
|
+
show: z,
|
|
162
|
+
offset: V,
|
|
163
|
+
onClose: W,
|
|
164
|
+
items: Y(u),
|
|
165
|
+
onSelect: (e) => {
|
|
166
|
+
var o, r;
|
|
167
|
+
const n = (o = e.item) == null ? void 0 : o.data;
|
|
168
|
+
n && !((r = n.children) != null && r.length) && X(n);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
));
|
|
172
|
+
};
|
|
173
|
+
export {
|
|
174
|
+
be as InlineAIPrompt
|
|
175
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2025 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),P=require("@progress/kendo-react-buttons"),r=require("@progress/kendo-react-inputs"),c=require("@progress/kendo-svg-icons"),u=require("@progress/kendo-react-common"),G=({placeholder:v="Ask or generate content with AI...",promptValue:B,onMenuClick:S,promptInput:h=r.TextArea,generateButton:A,enableSpeechToText:s=!1,streaming:e=!1,commands:i,onPromptRequest:m,onPromptCancel:E})=>{const[o,p]=t.useState(B||""),[y,d]=u.useCustomComponent(A),[x,f]=u.useCustomComponent(h),b={svgIcon:e?c.stopSmIcon:c.paperPlaneIcon,active:e,title:"Send Button","aria-label":"Send Button",disabled:!o.trim()&&!e,"aria-disabled":!o.trim()&&!e},w={placeholder:v,className:"!k-flex-row",autoSize:!0,rows:1},I=i&&i.length>0,R=Object.keys(d).length>0?d:b,N=Object.keys(f).length>0?f:w,k=n=>{const{isFinal:l,alternatives:C}=n;if(l&&C.length>0){const q=C[0].transcript,M=(()=>{const a=o,V=a&&!a.endsWith(" ")&&!a.endsWith(`
|
|
9
|
+
`);return a+(V?" ":"")+q})();p(M)}},j=n=>{const l=n.target.value;p(l)},g=()=>{o.trim()&&m&&m(o.trim())};return t.createElement(x,{value:o,onChange:j,onKeyDown:n=>{n.key==="Enter"&&!n.shiftKey&&(n.preventDefault(),g())},prefix:I||s?t.createElement(t.Fragment,null,t.createElement(r.InputPrefix,{className:"!k-align-items-start"},I&&t.createElement(P.Button,{"aria-label":"Commands Button",title:"Commands Button",fillMode:"flat",svgIcon:c.menuIcon,onClick:S}),s&&t.createElement(P.SpeechToTextButton,{fillMode:"flat",...typeof s=="object"?{...s,onResult:s.onResult||k}:{onResult:k}})),t.createElement(r.InputSeparator,null)):void 0,suffix:t.createElement(r.InputSuffix,{className:"!k-align-items-start"},t.createElement(y,{className:u.classNames("k-prompt-send",{"k-generating":e,"k-active":e}),fillMode:"flat",onClick:e?E:g,...R})),...N})};exports.InlineAIPromptInput=G;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2025 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
import t from "react";
|
|
9
|
+
import { Button as G, SpeechToTextButton as M } from "@progress/kendo-react-buttons";
|
|
10
|
+
import { InputPrefix as R, InputSeparator as D, InputSuffix as F, TextArea as K } from "@progress/kendo-react-inputs";
|
|
11
|
+
import { stopSmIcon as O, paperPlaneIcon as W, menuIcon as _ } from "@progress/kendo-svg-icons";
|
|
12
|
+
import { useCustomComponent as I, classNames as z } from "@progress/kendo-react-common";
|
|
13
|
+
const U = ({
|
|
14
|
+
placeholder: g = "Ask or generate content with AI...",
|
|
15
|
+
promptValue: h,
|
|
16
|
+
onMenuClick: B,
|
|
17
|
+
promptInput: P = K,
|
|
18
|
+
generateButton: v,
|
|
19
|
+
enableSpeechToText: a = !1,
|
|
20
|
+
streaming: e = !1,
|
|
21
|
+
commands: l,
|
|
22
|
+
onPromptRequest: c,
|
|
23
|
+
onPromptCancel: C
|
|
24
|
+
}) => {
|
|
25
|
+
const [o, i] = t.useState(h || ""), [E, u] = I(
|
|
26
|
+
v
|
|
27
|
+
), [x, m] = I(P), A = {
|
|
28
|
+
svgIcon: e ? O : W,
|
|
29
|
+
active: e,
|
|
30
|
+
title: "Send Button",
|
|
31
|
+
"aria-label": "Send Button",
|
|
32
|
+
disabled: !o.trim() && !e,
|
|
33
|
+
"aria-disabled": !o.trim() && !e
|
|
34
|
+
}, S = {
|
|
35
|
+
placeholder: g,
|
|
36
|
+
className: "!k-flex-row",
|
|
37
|
+
autoSize: !0,
|
|
38
|
+
rows: 1
|
|
39
|
+
}, f = l && l.length > 0, w = Object.keys(u).length > 0 ? u : A, y = Object.keys(m).length > 0 ? m : S, p = (n) => {
|
|
40
|
+
const { isFinal: s, alternatives: k } = n;
|
|
41
|
+
if (s && k.length > 0) {
|
|
42
|
+
const b = k[0].transcript, V = (() => {
|
|
43
|
+
const r = o, j = r && !r.endsWith(" ") && !r.endsWith(`
|
|
44
|
+
`);
|
|
45
|
+
return r + (j ? " " : "") + b;
|
|
46
|
+
})();
|
|
47
|
+
i(V);
|
|
48
|
+
}
|
|
49
|
+
}, N = (n) => {
|
|
50
|
+
const s = n.target.value;
|
|
51
|
+
i(s);
|
|
52
|
+
}, d = () => {
|
|
53
|
+
o.trim() && c && c(o.trim());
|
|
54
|
+
};
|
|
55
|
+
return /* @__PURE__ */ t.createElement(
|
|
56
|
+
x,
|
|
57
|
+
{
|
|
58
|
+
value: o,
|
|
59
|
+
onChange: N,
|
|
60
|
+
onKeyDown: (n) => {
|
|
61
|
+
n.key === "Enter" && !n.shiftKey && (n.preventDefault(), d());
|
|
62
|
+
},
|
|
63
|
+
prefix: f || a ? /* @__PURE__ */ t.createElement(t.Fragment, null, /* @__PURE__ */ t.createElement(R, { className: "!k-align-items-start" }, f && /* @__PURE__ */ t.createElement(
|
|
64
|
+
G,
|
|
65
|
+
{
|
|
66
|
+
"aria-label": "Commands Button",
|
|
67
|
+
title: "Commands Button",
|
|
68
|
+
fillMode: "flat",
|
|
69
|
+
svgIcon: _,
|
|
70
|
+
onClick: B
|
|
71
|
+
}
|
|
72
|
+
), a && /* @__PURE__ */ t.createElement(
|
|
73
|
+
M,
|
|
74
|
+
{
|
|
75
|
+
fillMode: "flat",
|
|
76
|
+
...typeof a == "object" ? {
|
|
77
|
+
...a,
|
|
78
|
+
onResult: a.onResult || p
|
|
79
|
+
} : {
|
|
80
|
+
onResult: p
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
)), /* @__PURE__ */ t.createElement(D, null)) : void 0,
|
|
84
|
+
suffix: /* @__PURE__ */ t.createElement(F, { className: "!k-align-items-start" }, /* @__PURE__ */ t.createElement(
|
|
85
|
+
E,
|
|
86
|
+
{
|
|
87
|
+
className: z("k-prompt-send", {
|
|
88
|
+
"k-generating": e,
|
|
89
|
+
"k-active": e
|
|
90
|
+
}),
|
|
91
|
+
fillMode: "flat",
|
|
92
|
+
onClick: e ? C : d,
|
|
93
|
+
...w
|
|
94
|
+
}
|
|
95
|
+
)),
|
|
96
|
+
...y
|
|
97
|
+
}
|
|
98
|
+
);
|
|
99
|
+
};
|
|
100
|
+
export {
|
|
101
|
+
U as InlineAIPromptInput
|
|
102
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2025 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react"),P=require("@progress/kendo-react-popup"),a=({show:e=!1,anchor:t,onOpen:o,onClose:r,animate:n=!0,appendTo:p,popupOptions:u={},children:c,style:i})=>l.createElement(P.Popup,{show:e,anchor:t,style:i,animate:n,appendTo:p,onOpen:o,onClose:r,...u},c);exports.InlineAIPromptPopup=a;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2025 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
import f from "react";
|
|
9
|
+
import { Popup as l } from "@progress/kendo-react-popup";
|
|
10
|
+
const P = ({
|
|
11
|
+
show: e = !1,
|
|
12
|
+
anchor: t,
|
|
13
|
+
onOpen: r,
|
|
14
|
+
onClose: o,
|
|
15
|
+
animate: p = !0,
|
|
16
|
+
appendTo: m,
|
|
17
|
+
popupOptions: n = {},
|
|
18
|
+
children: u,
|
|
19
|
+
style: a
|
|
20
|
+
}) => /* @__PURE__ */ f.createElement(
|
|
21
|
+
l,
|
|
22
|
+
{
|
|
23
|
+
show: e,
|
|
24
|
+
anchor: t,
|
|
25
|
+
style: a,
|
|
26
|
+
animate: p,
|
|
27
|
+
appendTo: m,
|
|
28
|
+
onOpen: r,
|
|
29
|
+
onClose: o,
|
|
30
|
+
...n
|
|
31
|
+
},
|
|
32
|
+
u
|
|
33
|
+
);
|
|
34
|
+
export {
|
|
35
|
+
P as InlineAIPromptPopup
|
|
36
|
+
};
|
package/package-metadata.js
CHANGED
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e={name:"@progress/kendo-react-conversational-ui",productName:"KendoReact",productCode:"KENDOUIREACT",productCodes:["KENDOUIREACT"],publishDate:
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e={name:"@progress/kendo-react-conversational-ui",productName:"KendoReact",productCode:"KENDOUIREACT",productCodes:["KENDOUIREACT"],publishDate: 1754046323,version:"11.4.0-develop.4",licensingDocsUrl:"https://www.telerik.com/kendo-react-ui/components/my-license/"};exports.packageMetadata=e;
|
package/package-metadata.mjs
CHANGED
|
@@ -10,8 +10,8 @@ const e = {
|
|
|
10
10
|
productName: "KendoReact",
|
|
11
11
|
productCode: "KENDOUIREACT",
|
|
12
12
|
productCodes: ["KENDOUIREACT"],
|
|
13
|
-
publishDate:
|
|
14
|
-
version: "11.4.0-develop.
|
|
13
|
+
publishDate: 1754046323,
|
|
14
|
+
version: "11.4.0-develop.4",
|
|
15
15
|
licensingDocsUrl: "https://www.telerik.com/kendo-react-ui/components/my-license/"
|
|
16
16
|
};
|
|
17
17
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@progress/kendo-react-conversational-ui",
|
|
3
|
-
"version": "11.4.0-develop.
|
|
3
|
+
"version": "11.4.0-develop.4",
|
|
4
4
|
"description": "React Chat component allows the user to participate in chat sessions with users or chat bots. KendoReact Conversational UI components",
|
|
5
5
|
"author": "Progress",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
@@ -26,11 +26,11 @@
|
|
|
26
26
|
"sideEffects": false,
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"@progress/kendo-licensing": "^1.6.0",
|
|
29
|
-
"@progress/kendo-react-buttons": "11.4.0-develop.
|
|
30
|
-
"@progress/kendo-react-common": "11.4.0-develop.
|
|
31
|
-
"@progress/kendo-react-intl": "11.4.0-develop.
|
|
32
|
-
"@progress/kendo-react-inputs": "11.4.0-develop.
|
|
33
|
-
"@progress/kendo-react-layout": "11.4.0-develop.
|
|
29
|
+
"@progress/kendo-react-buttons": "11.4.0-develop.4",
|
|
30
|
+
"@progress/kendo-react-common": "11.4.0-develop.4",
|
|
31
|
+
"@progress/kendo-react-intl": "11.4.0-develop.4",
|
|
32
|
+
"@progress/kendo-react-inputs": "11.4.0-develop.4",
|
|
33
|
+
"@progress/kendo-react-layout": "11.4.0-develop.4",
|
|
34
34
|
"@progress/kendo-svg-icons": "^4.0.0",
|
|
35
35
|
"react": "^16.8.2 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc",
|
|
36
36
|
"react-dom": "^16.8.2 || ^17.0.0 || ^18.0.0 || ^19.0.0 || ^19.0.0-rc"
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"package": {
|
|
60
60
|
"productName": "KendoReact",
|
|
61
61
|
"productCode": "KENDOUIREACT",
|
|
62
|
-
"publishDate":
|
|
62
|
+
"publishDate": 1754046323,
|
|
63
63
|
"licensingDocsUrl": "https://www.telerik.com/kendo-react-ui/components/my-license/"
|
|
64
64
|
}
|
|
65
65
|
},
|