@progress/kendo-vue-conversational-ui 8.4.0-develop.3 → 8.4.0-develop.5
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/AIPromptContent.js +1 -1
- package/ai-prompt/AIPromptContent.mjs +1 -1
- package/ai-prompt/views/AIPromptOutputView.js +1 -1
- package/ai-prompt/views/AIPromptOutputView.mjs +1 -1
- package/dist/cdn/js/kendo-vue-conversational-ui.js +1 -1
- package/package-metadata.js +1 -1
- package/package-metadata.mjs +2 -2
- package/package.json +15 -10
- package/prompt-box/FileBox.js +1 -1
- package/prompt-box/FileBox.mjs +5 -5
- package/prompt-box/PromptBox.js +1 -1
- package/prompt-box/PromptBox.mjs +13 -13
|
@@ -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("vue"),n=require("@progress/kendo-vue-common"),s=require("@progress/kendo-svg-icons"),i=require("@progress/kendo-vue-buttons"),r=require("./views/constants.js"),a=e.defineComponent({name:"KendoAIPromptContent",props:{onCancel:Function,streaming:Boolean},inject:{kendoAIPrompt:{default:null}},computed:{showFloatingButton(){var o;const t=((o=this.kendoAIPrompt)==null?void 0:o.activeView)===r.outputViewDefaults.name;return this.streaming&&t}},methods:{handleKeyDown(t){t.key==="Escape"&&this.showFloatingButton&&this.onCancel&&(t.preventDefault(),this.$props.onCancel())}},render(){const t=n.getDefaultSlots(this);return e.createVNode("div",{class:"k-prompt-content",onKeydown:this.handleKeyDown},[this.showFloatingButton&&e.createVNode(i.FloatingActionButton,{onClick:this.onCancel,svgIcon:s.
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),n=require("@progress/kendo-vue-common"),s=require("@progress/kendo-svg-icons"),i=require("@progress/kendo-vue-buttons"),r=require("./views/constants.js"),a=e.defineComponent({name:"KendoAIPromptContent",props:{onCancel:Function,streaming:Boolean},inject:{kendoAIPrompt:{default:null}},computed:{showFloatingButton(){var o;const t=((o=this.kendoAIPrompt)==null?void 0:o.activeView)===r.outputViewDefaults.name;return this.streaming&&t}},methods:{handleKeyDown(t){t.key==="Escape"&&this.showFloatingButton&&this.onCancel&&(t.preventDefault(),this.$props.onCancel())}},render(){const t=n.getDefaultSlots(this);return e.createVNode("div",{class:"k-prompt-content",onKeydown:this.handleKeyDown},[this.showFloatingButton&&e.createVNode(i.FloatingActionButton,{onClick:this.onCancel,svgIcon:s.stopIcon,size:"small",positionMode:"absolute",class:"k-prompt-stop-fab k-generating"},null),e.createVNode("div",{class:"k-prompt-view"},[t])])}});exports.AIPromptContent=a;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { defineComponent as e, createVNode as o } from "vue";
|
|
9
9
|
import { getDefaultSlots as i } from "@progress/kendo-vue-common";
|
|
10
|
-
import {
|
|
10
|
+
import { stopIcon as s } from "@progress/kendo-svg-icons";
|
|
11
11
|
import { FloatingActionButton as r } from "@progress/kendo-vue-buttons";
|
|
12
12
|
import { outputViewDefaults as a } from "./views/constants.mjs";
|
|
13
13
|
const d = /* @__PURE__ */ e({
|
|
@@ -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("vue"),C=require("../AIPromptContent.js"),c=require("../../messages/main.js"),g=require("./AIPromptViewRender.js"),N=require("./constants.js"),n=require("@progress/kendo-vue-layout"),l=require("@progress/kendo-svg-icons"),s=require("@progress/kendo-vue-buttons"),P=require("@progress/kendo-vue-intl");function b(t){return typeof t=="function"||Object.prototype.toString.call(t)==="[object Object]"&&!e.isVNode(t)}let R=(function(t){return t.positive="positive",t.negative="negative",t})({});const v=e.defineComponent({name:"KendoAIPromptOutputView",emits:{copy:null,retry:null,rating:null},props:{outputs:Array,outputCard:Object,showOutputRating:Boolean},inject:{kendoAIPrompt:{default:null},kendoLocalizationService:{default:null}},data(){return{copiedIndex:-1,copyButtonIcon:l.copyIcon,contentRef:null}},methods:{retryPrompt(t){this.$emit("retry",t),this.kendoAIPrompt.onPromptRequest&&this.kendoAIPrompt.onPromptRequest.call(null,t.prompt,{...t,isRetry:!0}),this.scrollToTopOutput()},copyToClipboard(t,r){t!=null&&t.responseContent&&navigator.clipboard.writeText(t.responseContent),this.copiedIndex=r,this.copyButtonIcon=l.checkIcon,this.$emit("copy",t==null?void 0:t.responseContent),setTimeout(()=>{this.copyButtonIcon=l.copyIcon,this.copiedIndex=-1},1e3)},outputRating(t,r){this.$emit("rating",t,r),this.kendoAIPrompt.onPromptRequest&&this.kendoAIPrompt.onPromptRequest.call(null,t.prompt,{...t,ratingType:r,isRetry:!1}),this.scrollToTopOutput()},scrollToTopOutput(){var t,r;(r=(t=this.contentRef)==null?void 0:t.scrollTo)==null||r.call(t,{top:0,behavior:"smooth"})}},render(){let t;const{outputs:r,showOutputRating:k,outputCard:y}=this.$props,f=P.provideLocalizationService(this),{header:u,body:p,actions:m}=y||{},I=e.createVNode(n.Card,null,{default:()=>[e.createVNode(n.CardHeader,null,{default:()=>[e.createVNode(n.CardTitle,null,{default:()=>[e.createVNode("span",{class:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"200px"}},null)]}),e.createVNode(n.CardSubtitle,null,{default:()=>[e.createVNode("span",{class:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"100%"}},null)]})]}),e.createVNode(n.CardBody,null,{default:()=>[e.createVNode("span",{class:"k-skeleton k-skeleton-rect k-skeleton-pulse",style:{height:"80px"}},null)]}),e.createVNode(n.CardActions,null,{default:()=>[e.createVNode("span",{class:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"100%"}},null)]})]}),d=r==null?void 0:r.map((o,a)=>e.createVNode(n.Card,{key:`${o.id}_${a}`,class:o.class},{default:()=>[e.createVNode(n.CardHeader,null,{default:()=>[u?u(o):e.createVNode(e.Fragment,null,[o.title&&e.createVNode(n.CardTitle,null,{default:()=>[o.title]}),o.subTitle&&e.createVNode(n.CardSubtitle,null,{default:()=>[o.subTitle]})])]}),e.createVNode(n.CardBody,null,{default:()=>[p?p(o):o.responseContent]}),e.createVNode(n.CardActions,null,{default:()=>[m?m(o):e.createVNode(e.Fragment,null,[e.createVNode(s.Button,{type:"button",size:"medium",themeColor:"primary",fillMode:"flat",rounded:"medium",title:"Copy",svgIcon:this.copiedIndex===a?this.copyButtonIcon:l.copyIcon,"aria-hidden":"true",onClick:()=>this.copyToClipboard(o,a)},{default:()=>["Copy"]}),e.createVNode(s.Button,{type:"button",size:"medium",themeColor:"base",fillMode:"flat",rounded:"medium",title:"Retry",svgIcon:l.arrowRotateCwIcon,"aria-hidden":"true",onClick:()=>this.retryPrompt(o)},{default:()=>["Retry"]}),k&&e.createVNode(e.Fragment,null,[e.createVNode("span",{class:"k-spacer"},null),e.createVNode(s.Button,{type:"button",size:"medium",themeColor:o.ratingType==="positive"?"primary":"base",fillMode:"flat",rounded:"medium",title:"Rate up",svgIcon:l.
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),C=require("../AIPromptContent.js"),c=require("../../messages/main.js"),g=require("./AIPromptViewRender.js"),N=require("./constants.js"),n=require("@progress/kendo-vue-layout"),l=require("@progress/kendo-svg-icons"),s=require("@progress/kendo-vue-buttons"),P=require("@progress/kendo-vue-intl");function b(t){return typeof t=="function"||Object.prototype.toString.call(t)==="[object Object]"&&!e.isVNode(t)}let R=(function(t){return t.positive="positive",t.negative="negative",t})({});const v=e.defineComponent({name:"KendoAIPromptOutputView",emits:{copy:null,retry:null,rating:null},props:{outputs:Array,outputCard:Object,showOutputRating:Boolean},inject:{kendoAIPrompt:{default:null},kendoLocalizationService:{default:null}},data(){return{copiedIndex:-1,copyButtonIcon:l.copyIcon,contentRef:null}},methods:{retryPrompt(t){this.$emit("retry",t),this.kendoAIPrompt.onPromptRequest&&this.kendoAIPrompt.onPromptRequest.call(null,t.prompt,{...t,isRetry:!0}),this.scrollToTopOutput()},copyToClipboard(t,r){t!=null&&t.responseContent&&navigator.clipboard.writeText(t.responseContent),this.copiedIndex=r,this.copyButtonIcon=l.checkIcon,this.$emit("copy",t==null?void 0:t.responseContent),setTimeout(()=>{this.copyButtonIcon=l.copyIcon,this.copiedIndex=-1},1e3)},outputRating(t,r){this.$emit("rating",t,r),this.kendoAIPrompt.onPromptRequest&&this.kendoAIPrompt.onPromptRequest.call(null,t.prompt,{...t,ratingType:r,isRetry:!1}),this.scrollToTopOutput()},scrollToTopOutput(){var t,r;(r=(t=this.contentRef)==null?void 0:t.scrollTo)==null||r.call(t,{top:0,behavior:"smooth"})}},render(){let t;const{outputs:r,showOutputRating:k,outputCard:y}=this.$props,f=P.provideLocalizationService(this),{header:u,body:p,actions:m}=y||{},I=e.createVNode(n.Card,null,{default:()=>[e.createVNode(n.CardHeader,null,{default:()=>[e.createVNode(n.CardTitle,null,{default:()=>[e.createVNode("span",{class:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"200px"}},null)]}),e.createVNode(n.CardSubtitle,null,{default:()=>[e.createVNode("span",{class:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"100%"}},null)]})]}),e.createVNode(n.CardBody,null,{default:()=>[e.createVNode("span",{class:"k-skeleton k-skeleton-rect k-skeleton-pulse",style:{height:"80px"}},null)]}),e.createVNode(n.CardActions,null,{default:()=>[e.createVNode("span",{class:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"100%"}},null)]})]}),d=r==null?void 0:r.map((o,a)=>e.createVNode(n.Card,{key:`${o.id}_${a}`,class:o.class},{default:()=>[e.createVNode(n.CardHeader,null,{default:()=>[u?u(o):e.createVNode(e.Fragment,null,[o.title&&e.createVNode(n.CardTitle,null,{default:()=>[o.title]}),o.subTitle&&e.createVNode(n.CardSubtitle,null,{default:()=>[o.subTitle]})])]}),e.createVNode(n.CardBody,null,{default:()=>[p?p(o):o.responseContent]}),e.createVNode(n.CardActions,null,{default:()=>[m?m(o):e.createVNode(e.Fragment,null,[e.createVNode(s.Button,{type:"button",size:"medium",themeColor:"primary",fillMode:"flat",rounded:"medium",title:"Copy",svgIcon:this.copiedIndex===a?this.copyButtonIcon:l.copyIcon,"aria-hidden":"true",onClick:()=>this.copyToClipboard(o,a)},{default:()=>["Copy"]}),e.createVNode(s.Button,{type:"button",size:"medium",themeColor:"base",fillMode:"flat",rounded:"medium",title:"Retry",svgIcon:l.arrowRotateCwIcon,"aria-hidden":"true",onClick:()=>this.retryPrompt(o)},{default:()=>["Retry"]}),k&&e.createVNode(e.Fragment,null,[e.createVNode("span",{class:"k-spacer"},null),e.createVNode(s.Button,{type:"button",size:"medium",themeColor:o.ratingType==="positive"?"primary":"base",fillMode:"flat",rounded:"medium",title:"Rate up",svgIcon:l.thumbUpIcon,"aria-hidden":"true",onClick:()=>this.outputRating(o,"positive")},null),e.createVNode(s.Button,{type:"button",size:"medium",themeColor:o.ratingType==="negative"?"primary":"base",fillMode:"flat",rounded:"medium",title:"Rate down",svgIcon:l.thumbDownIcon,"aria-hidden":"true",onClick:()=>this.outputRating(o,"negative")},null)])])]})]})),V=e.createVNode(n.Card,null,{default:()=>[e.createVNode(n.CardBody,null,b(t=f.toLanguageString(c.aIPromptNoOutputs,c.messages[c.aIPromptNoOutputs]))?t:{default:()=>[t]})]});return e.createVNode(g.AIPromptViewRender,{name:N.outputViewDefaults.name},{default:()=>{var o,a;return[e.createVNode(C.AIPromptContent,{ref:i=>this.contentRef=i,streaming:(o=this.kendoAIPrompt)==null?void 0:o.streaming,onCancel:(a=this.kendoAIPrompt)==null?void 0:a.onCancel},{default:()=>{var i,h;return[e.createVNode("div",{class:"k-card-list"},[((i=this.kendoAIPrompt)==null?void 0:i.loading)&&I,d,(!d||d.length===0)&&!((h=this.kendoAIPrompt)!=null&&h.loading)&&V])]}})]}})}});exports.AIPromptOutputRating=R;exports.AIPromptOutputView=v;
|
|
@@ -11,7 +11,7 @@ import { aIPromptNoOutputs as k, messages as x } from "../../messages/main.mjs";
|
|
|
11
11
|
import { AIPromptViewRender as B } from "./AIPromptViewRender.mjs";
|
|
12
12
|
import { outputViewDefaults as z } from "./constants.mjs";
|
|
13
13
|
import { Card as d, CardHeader as y, CardTitle as g, CardSubtitle as I, CardBody as p, CardActions as C } from "@progress/kendo-vue-layout";
|
|
14
|
-
import { copyIcon as m, arrowRotateCwIcon as S,
|
|
14
|
+
import { copyIcon as m, arrowRotateCwIcon as S, thumbUpIcon as V, thumbDownIcon as $, checkIcon as j } from "@progress/kendo-svg-icons";
|
|
15
15
|
import { Button as r } from "@progress/kendo-vue-buttons";
|
|
16
16
|
import { provideLocalizationService as q } from "@progress/kendo-vue-intl";
|
|
17
17
|
function M(e) {
|
|
@@ -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("vue"),require("@progress/kendo-vue-common"),require("@progress/kendo-vue-buttons"),require("@progress/kendo-svg-icons"),require("@progress/kendo-vue-inputs"),require("@progress/kendo-vue-layout"),require("@progress/kendo-vue-intl"),require("@progress/kendo-vue-upload")):"function"==typeof define&&define.amd?define(["exports","vue","@progress/kendo-vue-common","@progress/kendo-vue-buttons","@progress/kendo-svg-icons","@progress/kendo-vue-inputs","@progress/kendo-vue-layout","@progress/kendo-vue-intl","@progress/kendo-vue-upload"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).KendoVueConversationalUi={},e.Vue,e.KendoVueCommon,e.KendoVueButtons,e.KendoSVGIcons,e.KendoVueInputs,e.KendoVueLayout,e.KendoVueIntl,e.KendoVueUpload)}(this,function(e,t,o,n,i,s,l,r,a){"use strict";function u(e){return"function"==typeof e||"[object Object]"===Object.prototype.toString.call(e)&&!t.isVNode(e)}const d=t.defineComponent({name:"KendoAIPromptHeader",props:{activeView:String,toolbarItems:Array,onActiveviewchange:Function},methods:{handleClick(e){this.$emit("activeviewchange",e)}},render(){let e;const{activeView:i,toolbarItems:s}=this.$props;return t.createVNode("div",{class:"k-prompt-header"},[t.createVNode(n.Toolbar,{overflow:"none",keyboardNavigation:!1,class:"k-toolbar-flat"},u(e=s.map(function(e){const s=o.getTemplate.call(this,{h:t.h,template:e.content,defaultRendering:null,additionalProps:{item:e}});return e.content?s:t.createVNode(n.Button,{type:"button",key:e.name,class:o.classNames("k-toolbar-item",{"k-selected":i===e.name}),size:"medium",themeColor:"primary",fillMode:"flat",rounded:"full",title:e.buttonText,svgIcon:e.buttonIcon,onClick:()=>this.handleClick(e.name)},{default:()=>[e.buttonText]})},this))?e:{default:()=>[e]})])}}),c={name:"Output view",buttonText:"Output",buttonIcon:i.commentIcon},p={name:"Commands view",buttonIcon:i.moreHorizontalIcon},h={name:"Prompt view",buttonText:"Ask AI",buttonIcon:i.sparklesIcon},m={name:"@progress/kendo-vue-conversational-ui",productName:"Kendo UI for Vue",productCode:"KENDOUIVUE",productCodes:["KENDOUIVUE"],publishDate:0,version:"8.4.0-develop.3",licensingDocsUrl:"https://www.telerik.com/kendo-vue-ui/my-license/"},g=t.defineComponent({name:"KendoAIPrompt",props:{activeView:{type:String,required:!0},dir:String,toolbarItems:Array,outputs:Array,promptPlaceholder:String,streaming:Boolean,loading:Boolean,suggestionsView:{type:String,default:"classic"}},provide(){return{kendoAIPrompt:this.$data.contextState}},data(){return{showLicenseWatermark:!1,licenseMessage:"",contextState:{activeView:this.$props.activeView,streaming:this.$props.streaming,loading:this.$props.loading,onCancel:this.onCancel,onActiveViewChange:this.onActiveViewChange,onPromptRequest:this.onPromptRequest,onCommandExecute:this.onCommandExecute,onStateAction:this.onStateAction,suggestionsView:this.$props.suggestionsView}}},watch:{activeView(e){this.contextState.activeView=e},streaming(e){this.contextState.streaming=e},loading(e){this.contextState.loading=e}},methods:{onStateAction(e){this.contextState.activeView=e.activeView},onActiveViewChange(e){this.$emit("activeviewchange",e)},onPromptRequest(e,t){this.$emit("promptrequest",e,t)},onCommandExecute(e){this.$emit("commandexecute",e)},onCancel(){this.$emit("cancel")}},render(){o.validatePackage(m),this.showLicenseWatermark=o.shouldShowValidationUI(m),this.licenseMessage=o.getLicenseMessage(m);const e=o.getDefaultSlots(this),{toolbarItems:n,dir:i}=this.$props,s=(n||[h,c]).map(e=>{const t=o.templateRendering.call(this,e.content,o.getListeners.call(this));return{...e,content:t}}),l=this.showLicenseWatermark?t.createVNode(o.WatermarkOverlay,{message:this.licenseMessage},null):null;return t.createVNode("div",{class:"k-prompt",dir:i},[t.createVNode(d,{activeView:this.contextState.activeView,toolbarItems:s,onActiveviewchange:this.onActiveViewChange},null),e,l])}}),f=t.defineComponent({name:"KendoAIPromptFooter",render(){const e=o.getDefaultSlots(this);return t.createVNode("div",{class:"k-prompt-footer"},[t.createVNode("div",{class:"k-actions k-actions-start k-actions-horizontal k-prompt-actions"},[e])])}}),v=t.defineComponent({name:"KendoAIPromptContent",props:{onCancel:Function,streaming:Boolean},inject:{kendoAIPrompt:{default:null}},computed:{showFloatingButton(){var e;const t=(null==(e=this.kendoAIPrompt)?void 0:e.activeView)===c.name;return this.streaming&&t}},methods:{handleKeyDown(e){"Escape"===e.key&&this.showFloatingButton&&this.onCancel&&(e.preventDefault(),this.$props.onCancel())}},render(){const e=o.getDefaultSlots(this);return t.createVNode("div",{class:"k-prompt-content",onKeydown:this.handleKeyDown},[this.showFloatingButton&&t.createVNode(n.FloatingActionButton,{onClick:this.onCancel,svgIcon:i.stopSmIcon,size:"small",positionMode:"absolute",class:"k-prompt-stop-fab k-generating"},null),t.createVNode("div",{class:"k-prompt-view"},[e])])}}),k=t.defineComponent({name:"KendoAIPromptViewRender",inheritAttrs:!1,props:{name:String},inject:{kendoAIPrompt:{default:null}},render(){const e=o.getDefaultSlots(this);return this.kendoAIPrompt.activeView===this.$props.name?e:null}});function b(e){return"function"==typeof e||"[object Object]"===Object.prototype.toString.call(e)&&!t.isVNode(e)}const V=t.defineComponent({name:"KendoAIPromptExpander",props:{title:String},data:()=>({expanded:!0}),methods:{buttonClick(){this.expanded=!this.expanded}},render(){const e=o.getDefaultSlots(this),{title:s}=this.$props;return t.createVNode("div",{class:"k-prompt-expander"},[t.createVNode(n.Button,{type:"button",fillMode:"flat",svgIcon:this.expanded?i.chevronUpIcon:i.chevronDownIcon,title:s,onClick:this.buttonClick},b(s)?s:{default:()=>[s]}),this.expanded&&t.createVNode("div",{class:"k-prompt-expander-content"},[e])])}}),x=t.defineComponent({name:"KendoSuggestionGroup",props:{suggestions:{type:Array,required:!0},onSuggestionClick:{type:Function,required:!0},suggestionsView:{type:String,default:"classic"}},methods:{handleSuggestionClick(e,t){t.disabled||this.onSuggestionClick(e,t)},handleKeyDown(e,t){("Enter"===e.key||" "===e.key)&&(e.preventDefault(),this.onSuggestionClick(e,t))}},render(){const{suggestions:e,suggestionsView:n}=this.$props,i=()=>e.map(e=>t.createVNode("span",{role:"button",tabindex:e.disabled?-1:0,"aria-label":e.description,"aria-disabled":e.disabled,onClick:t=>!e.disabled&&this.handleSuggestionClick(t,e),onKeydown:t=>!e.disabled&&this.handleKeyDown(t,e),key:e.id,title:e.description,class:o.classNames("classic"===n?"k-prompt-suggestion":"k-suggestion",{"k-disabled":e.disabled})},[e.text]));return"classic"===n?i():t.createVNode("div",{role:"group",class:"k-suggestion-group"},[i()])}});function y(e){return"function"==typeof e||"[object Object]"===Object.prototype.toString.call(e)&&!t.isVNode(e)}const A=t.defineComponent({name:"KendoAIPromptView",props:{promptInput:[Object,String],generateButton:[Object,String],promptValue:String,promptSuggestions:Array,enableSpeechToText:[Boolean,Object]},inject:{kendoAIPrompt:{default:null}},computed:{computedValue(){return void 0!==this.$props.promptValue?this.$props.promptValue:this.value}},data:()=>({value:""}),methods:{handleOnRequest(){this.kendoAIPrompt.onPromptRequest&&this.kendoAIPrompt.onPromptRequest.call(null,this.computedValue),this.value=""},handleSuggestionSelect(e){this.value=e},onTextChange(e){this.value=e.value},onSpeechResult(e){if(e.isFinal&&e.alternatives.length>0){const t=e.alternatives[0].transcript,o=this.value,n=o&&!o.endsWith(" ")&&!o.endsWith("\n");this.value=o+(n?" ":"")+t}},onSpeechStart(){},onSpeechEnd(){},getButtonDisabledState(){const e=void 0!==this.$props.promptValue?this.$props.promptValue:this.value;return!(null!=e&&e.trim())}},render(){const e="Generate",{promptSuggestions:l,enableSpeechToText:r}=this.$props,a=o.templateRendering.call(this,this.$props.promptInput,o.getListeners.call(this)),u=t.createVNode(s.TextArea,{value:this.computedValue,onInput:this.onTextChange,placeholder:"Ask or generate content with AI ...",rows:2,class:"!k-flex-col",inputSuffix:()=>r?t.createVNode(t.Fragment,null,[t.createVNode(s.InputSeparator,{orientation:"horizontal"},null),t.createVNode("div",{class:"k-input-suffix k-input-suffix-horizontal"},[t.createVNode(n.SpeechToTextButton,t.mergeProps({fillMode:"flat",onStart:this.onSpeechStart,onEnd:this.onSpeechEnd,onResult:this.onSpeechResult},"object"==typeof r?r:{}),null)])]):null},null),d=o.getTemplate.call(this,{h:t.h,template:a,defaultRendering:u}),c=o.templateRendering.call(this,this.$props.generateButton,o.getListeners.call(this)),p=t.createVNode(n.Button,{type:"button",themeColor:"primary",fillMode:"solid","aria-hidden":"true",rounded:"full",size:"medium",onClick:this.handleOnRequest,disabled:this.getButtonDisabledState(),title:"Generate",svgIcon:i.sparklesIcon},y(e)?e:{default:()=>[e]}),m=o.getTemplate.call(this,{h:t.h,template:c,defaultRendering:p});return t.createVNode(k,{name:h.name},{default:()=>{var e,o;return[t.createVNode(v,{streaming:null==(e=this.kendoAIPrompt)?void 0:e.streaming,onCancel:null==(o=this.kendoAIPrompt)?void 0:o.onCancel},{default:()=>[d,l&&l.length>0&&t.createVNode(V,{title:"Prompt Suggestions"},{default:()=>{var e;return[t.createVNode(x,{suggestionsView:null==(e=this.kendoAIPrompt)?void 0:e.suggestionsView,suggestions:l.map((e,t)=>({id:t,text:e,description:e})),onSuggestionClick:(e,t)=>this.handleSuggestionSelect(t.text)},null)]}})]}),t.createVNode(f,null,y(m)?m:{default:()=>[m]})]}})}}),C="avatar.alt",S="messageList.ariaLabel",$="aIPrompt.noOutputs",I="promptBox.input",N="promptBox.sendButton",w="promptBox.attachFile",B="promptBox.removeFile",R="promptBox.stopGenerating",P="promptBox.ariaLabel",F={[C]:"Avatar",[S]:"Message list",[$]:"No output from Ai available",[I]:"Prompt",[N]:"Send",[w]:"Attach file",[B]:"Remove file",[R]:"Stop generating",[P]:"Prompt box"};function T(e){return"function"==typeof e||"[object Object]"===Object.prototype.toString.call(e)&&!t.isVNode(e)}let O=function(e){return e.positive="positive",e.negative="negative",e}({});const z=t.defineComponent({name:"KendoAIPromptOutputView",emits:{copy:null,retry:null,rating:null},props:{outputs:Array,outputCard:Object,showOutputRating:Boolean},inject:{kendoAIPrompt:{default:null},kendoLocalizationService:{default:null}},data:()=>({copiedIndex:-1,copyButtonIcon:i.copyIcon,contentRef:null}),methods:{retryPrompt(e){this.$emit("retry",e),this.kendoAIPrompt.onPromptRequest&&this.kendoAIPrompt.onPromptRequest.call(null,e.prompt,{...e,isRetry:!0}),this.scrollToTopOutput()},copyToClipboard(e,t){null!=e&&e.responseContent&&navigator.clipboard.writeText(e.responseContent),this.copiedIndex=t,this.copyButtonIcon=i.checkIcon,this.$emit("copy",null==e?void 0:e.responseContent),setTimeout(()=>{this.copyButtonIcon=i.copyIcon,this.copiedIndex=-1},1e3)},outputRating(e,t){this.$emit("rating",e,t),this.kendoAIPrompt.onPromptRequest&&this.kendoAIPrompt.onPromptRequest.call(null,e.prompt,{...e,ratingType:t,isRetry:!1}),this.scrollToTopOutput()},scrollToTopOutput(){var e,t;null==(t=null==(e=this.contentRef)?void 0:e.scrollTo)||t.call(e,{top:0,behavior:"smooth"})}},render(){let e;const{outputs:o,showOutputRating:s,outputCard:a}=this.$props,u=r.provideLocalizationService(this),{header:d,body:p,actions:h}=a||{},m=t.createVNode(l.Card,null,{default:()=>[t.createVNode(l.CardHeader,null,{default:()=>[t.createVNode(l.CardTitle,null,{default:()=>[t.createVNode("span",{class:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"200px"}},null)]}),t.createVNode(l.CardSubtitle,null,{default:()=>[t.createVNode("span",{class:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"100%"}},null)]})]}),t.createVNode(l.CardBody,null,{default:()=>[t.createVNode("span",{class:"k-skeleton k-skeleton-rect k-skeleton-pulse",style:{height:"80px"}},null)]}),t.createVNode(l.CardActions,null,{default:()=>[t.createVNode("span",{class:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"100%"}},null)]})]}),g=null==o?void 0:o.map((e,o)=>t.createVNode(l.Card,{key:`${e.id}_${o}`,class:e.class},{default:()=>[t.createVNode(l.CardHeader,null,{default:()=>[d?d(e):t.createVNode(t.Fragment,null,[e.title&&t.createVNode(l.CardTitle,null,{default:()=>[e.title]}),e.subTitle&&t.createVNode(l.CardSubtitle,null,{default:()=>[e.subTitle]})])]}),t.createVNode(l.CardBody,null,{default:()=>[p?p(e):e.responseContent]}),t.createVNode(l.CardActions,null,{default:()=>[h?h(e):t.createVNode(t.Fragment,null,[t.createVNode(n.Button,{type:"button",size:"medium",themeColor:"primary",fillMode:"flat",rounded:"medium",title:"Copy",svgIcon:this.copiedIndex===o?this.copyButtonIcon:i.copyIcon,"aria-hidden":"true",onClick:()=>this.copyToClipboard(e,o)},{default:()=>["Copy"]}),t.createVNode(n.Button,{type:"button",size:"medium",themeColor:"base",fillMode:"flat",rounded:"medium",title:"Retry",svgIcon:i.arrowRotateCwIcon,"aria-hidden":"true",onClick:()=>this.retryPrompt(e)},{default:()=>["Retry"]}),s&&t.createVNode(t.Fragment,null,[t.createVNode("span",{class:"k-spacer"},null),t.createVNode(n.Button,{type:"button",size:"medium",themeColor:"positive"===e.ratingType?"primary":"base",fillMode:"flat",rounded:"medium",title:"Rate up",svgIcon:i.thumbUpOutlineIcon,"aria-hidden":"true",onClick:()=>this.outputRating(e,"positive")},null),t.createVNode(n.Button,{type:"button",size:"medium",themeColor:"negative"===e.ratingType?"primary":"base",fillMode:"flat",rounded:"medium",title:"Rate down",svgIcon:i.thumbDownOutlineIcon,"aria-hidden":"true",onClick:()=>this.outputRating(e,"negative")},null)])])]})]})),f=t.createVNode(l.Card,null,{default:()=>[t.createVNode(l.CardBody,null,T(e=u.toLanguageString($,F[$]))?e:{default:()=>[e]})]});return t.createVNode(k,{name:c.name},{default:()=>{var e,o;return[t.createVNode(v,{ref:e=>this.contentRef=e,streaming:null==(e=this.kendoAIPrompt)?void 0:e.streaming,onCancel:null==(o=this.kendoAIPrompt)?void 0:o.onCancel},{default:()=>{var e,o;return[t.createVNode("div",{class:"k-card-list"},[(null==(e=this.kendoAIPrompt)?void 0:e.loading)&&m,g,(!g||0===g.length)&&!(null!=(o=this.kendoAIPrompt)&&o.loading)&&f])]}})]}})}}),L=t.defineComponent({name:"KendoAIPromptCommandsView",props:{commands:Array},inject:{kendoAIPrompt:{default:null}},render(){const{commands:e}=this.$props,o=e=>{var t;const o=e.target;(null==(t=o.items)||!t.length)&&this.kendoAIPrompt.onCommandExecute&&(this.$emit("commandexecute",o),this.kendoAIPrompt.onCommandExecute.call(null,o))};return t.createVNode(k,{name:p.name},{default:()=>{var n,i;return[t.createVNode(v,{streaming:null==(n=this.kendoAIPrompt)?void 0:n.streaming,onCancel:null==(i=this.kendoAIPrompt)?void 0:i.onCancel},{default:()=>[t.createVNode("div",{class:"k-prompt-view"},[t.createVNode(l.PanelBar,{onSelect:o,items:e},null)])]})]}})}}),M=t.defineComponent({name:"KendoPromptBoxActionButton",inheritAttrs:!1,render(){return t.createVNode(n.Button,this.$attrs,null)}}),E=t.defineComponent({name:"KendoPromptBoxSpeechToTextButton",inheritAttrs:!1,render(){return t.createVNode(n.SpeechToTextButton,this.$attrs,null)}}),j=t.defineComponent({name:"KendoPromptBoxUploadButton",inheritAttrs:!1,props:{onFilesAdd:Function,files:{type:Array,default:()=>[]},restrictions:Object,multiple:{type:Boolean,default:!0},accept:String,onSelectAttachments:Function,onRemoveAttachment:Function,_registerRemoveCallback:Function},setup(e){const o=t.ref(null);return t.watch(()=>e.onRemoveAttachment,t=>{e._registerRemoveCallback&&t&&e._registerRemoveCallback(t)},{immediate:!0}),t.onUnmounted(()=>{e._registerRemoveCallback&&e.onRemoveAttachment&&e._registerRemoveCallback(void 0)}),{uploadRef:o,handleFilesAdd:t=>{e.onFilesAdd&&e.onFilesAdd(t),e.onSelectAttachments&&e.onSelectAttachments({selectedFiles:t.affectedFiles,allFiles:t.newState})}}},render(){const{onFilesAdd:e,files:o,restrictions:i,multiple:s,accept:l,onSelectAttachments:r,onRemoveAttachment:u,_registerRemoveCallback:d,_uploadRef:c,...p}=this.$attrs;return t.createVNode(t.Fragment,null,[t.createVNode(n.Button,p,null),t.createVNode(a.Upload,{ref:e=>{this.uploadRef=e,c&&(c.value=e)},files:this.files,onAdd:this.handleFilesAdd,autoUpload:!1,restrictions:this.restrictions,multiple:this.multiple,accept:this.accept,class:"k-hidden"},null)])}}),H=e=>"."+(e.split(".").pop()||""),K=e=>{if(null==e)return"";if(0===e)return"0 B";const t=Math.floor(Math.log(e)/Math.log(1024));return`${Number.parseFloat((e/Math.pow(1024,t)).toFixed(2))} ${["B","KB","MB","GB","TB"][t]}`},D=t.defineComponent({name:"KendoFileBox",props:{files:{type:Array,required:!0},onRemoveFile:{type:Function,required:!0},header:{type:[Object,Function,String],default:void 0}},inject:{kendoLocalizationService:{default:null}},data:()=>({canScrollRight:!1,canScrollLeft:!1,resizeObserver:null}),watch:{files:{handler(){t.nextTick(()=>{this.setupScrollListeners(),this.updateScrollState()})},deep:!0}},mounted(){t.nextTick(()=>{this.setupScrollListeners(),this.updateScrollState()})},beforeUnmount(){this.cleanupScrollListeners()},methods:{setupScrollListeners(){const e=this.$refs.scrollContainer;e?this._scrollContainer!==e&&(this.cleanupScrollListeners(),e.addEventListener("scroll",this.updateScrollState,{passive:!0}),this.resizeObserver=new ResizeObserver(()=>this.updateScrollState()),this.resizeObserver.observe(e),this._scrollContainer=e):this.cleanupScrollListeners()},cleanupScrollListeners(){this._scrollContainer&&(this._scrollContainer.removeEventListener("scroll",this.updateScrollState),this._scrollContainer=null),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null)},updateScrollState(){const e=this.$refs.scrollContainer;if(!e)return;const{scrollLeft:t,scrollWidth:o,clientWidth:n}=e,i=0===t,s=t+n>=o-1;this.canScrollLeft=!i,this.canScrollRight=!s},handleRemoveFile(e,t){t.stopPropagation(),this.$props.onRemoveFile&&this.$props.onRemoveFile(e)}},render(){const e=r.provideLocalizationService(this),{files:s,header:l}=this.$props;if(0===s.length&&!l)return null;const a=o.getTemplate.call(this,{h:t.h,template:l,defaultRendering:null}),u=e.toLanguageString(B,F[B]),d=s.length>0&&t.createVNode("ul",{class:o.classNames("k-file-box-wrapper",{"k-file-box-wrapper-scrollable-start":this.canScrollRight,"k-file-box-wrapper-scrollable-end":this.canScrollLeft})},[t.createVNode("div",{class:"k-files-scroll",ref:"scrollContainer"},[s.map(e=>t.createVNode("li",{key:e.name,class:"k-file-box"},[t.createVNode(o.Icon,t.mergeProps({size:"xlarge"},o.getFileExtensionIcon(H(e.name))),null),t.createVNode("div",{class:"k-file-info"},[t.createVNode("span",{class:"k-file-name"},[e.name]),t.createVNode("span",{class:"k-file-size"},[K(e.size)])]),t.createVNode(n.Button,{fillMode:"flat",svgIcon:i.xMarkSmOutlineIcon,onClick:t=>this.handleRemoveFile(e.name,t),"aria-label":`${u} ${e.name}`,title:`${u} ${e.name}`},null)]))])]);return t.createVNode("div",{class:"k-prompt-box-header"},[a,d])}}),q="k-prompt-box",U=t.defineComponent({name:"KendoPromptBox",emits:{change:e=>!0,focus:e=>!0,blur:e=>!0,promptaction:e=>!0},props:{value:String,defaultValue:{type:String,default:""},mode:{type:String,default:"auto"},rows:{type:Number,default:1},maxTextAreaHeight:String,title:String,disabled:{type:Boolean,default:!1},readOnly:{type:Boolean,default:!1},placeholder:String,maxLength:Number,inputAttributes:Object,fillMode:String,topAffix:[Object,Function,String],startAffix:[Object,Function,String],endAffix:[Object,Function,String],header:[Object,Function,String],loading:{type:Boolean,default:!1},uploadButtonConfig:{type:[Boolean,Object],default:!1},speechToTextButtonConfig:{type:[Boolean,Object],default:!0},actionButtonConfig:{type:[Boolean,Object],default:!0},attachments:Array},inject:{kendoLocalizationService:{default:null}},created(){o.validatePackage(m),this._uploadRef=t.ref(null)},data(){return{stateValue:this.$props.defaultValue||"",stateFiles:[],hasExpanded:!1,initialHeight:0,minMultiRowHeight:0,isResizing:!1,previousValueLength:0,singleLineWidth:0,resizeObserver:null,resizeTimeout:null,onRemoveAttachmentCallback:null}},computed:{isControlled(){return void 0!==this.$props.value},currentValue(){return this.isControlled?this.$props.value||"":this.stateValue},isFilesControlled(){return void 0!==this.$props.attachments},currentFiles(){return this.isFilesControlled?this.$props.attachments||[]:this.stateFiles},canSendMessage(){var e;return!!(null!=(e=this.currentValue)&&e.trim()||this.currentFiles.length>0)},isMultilineLayout(){return"multi"===this.$props.mode||"auto"===this.$props.mode&&this.hasExpanded},hasBuiltInButtons(){return!1!==this.$props.uploadButtonConfig||!1!==this.$props.speechToTextButtonConfig||!1!==this.$props.actionButtonConfig},hasEndAffixOrButtons(){return!!this.$props.endAffix||this.hasBuiltInButtons},hasStartAffixOrEndAffixOrButtons(){return!!this.$props.startAffix||!!this.$props.endAffix||this.hasBuiltInButtons},effectiveRows(){return"auto"===this.$props.mode?1:this.$props.rows}},watch:{currentValue(e){if("single"===this.$props.mode)return;const t=(null==e?void 0:e.length)||0;requestAnimationFrame(()=>{const e=this.$refs.inputElement;e&&("multi"===this.$props.mode?this.resizeMultiMode(e):"auto"===this.$props.mode&&this.resizeAutoMode(e,t),this.previousValueLength=t)})},rows(){"single"!==this.$props.mode&&(this.captureInitialDimensions(),this.resize())},maxTextAreaHeight(){"single"!==this.$props.mode&&this.resize()},mode(){"single"!==this.$props.mode&&t.nextTick(()=>{this.captureInitialDimensions(),this.resize()})},hasExpanded(e){if("auto"===this.$props.mode&&e&&requestAnimationFrame(()=>{const e=this.$refs.inputElement;e&&(this.updateHeight(e),this.isResizing=!1)}),"auto"===this.$props.mode&&!e){const e=this.$refs.inputElement;e&&(e.style.height="",e.style.overflow="",this.isResizing=!1)}}},mounted(){"single"!==this.$props.mode&&this.captureInitialDimensions(),this.setupResizeObserver()},beforeUnmount(){this.cleanupResizeObserver()},methods:{captureInitialDimensions(){const e=this.$refs.inputElement;if(!e||"single"===this.$props.mode)return;const t=globalThis.getComputedStyle(e),o=Number.parseFloat(t.lineHeight)||20,n=Number.parseFloat(t.paddingTop)||0,i=Number.parseFloat(t.paddingBottom)||0;this.initialHeight=e.offsetHeight||o+n+i,this.minMultiRowHeight=o*this.$props.rows+n+i,"auto"===this.$props.mode&&!this.hasExpanded&&(this.singleLineWidth=e.offsetWidth)},calculateHeight(e){if(this.$props.maxTextAreaHeight){const t=Number.parseInt(this.$props.maxTextAreaHeight,10);if(e>t)return t}return Math.max(this.minMultiRowHeight,e)},resizeMultiMode(e){e.style.overflow="hidden",e.style.height=`${this.initialHeight}px`;const t=e.scrollHeight,o=this.calculateHeight(t);e.style.height=`${o}px`,this.$props.maxTextAreaHeight&&t>Number.parseInt(this.$props.maxTextAreaHeight,10)&&(e.style.overflow="")},updateHeight(e){e.style.overflow="hidden",e.style.height=`${this.initialHeight}px`;const t=e.scrollHeight,o=this.$props.maxTextAreaHeight?Math.min(t,Number.parseInt(this.$props.maxTextAreaHeight,10)):t;e.style.height=`${o}px`,this.$props.maxTextAreaHeight&&t>Number.parseInt(this.$props.maxTextAreaHeight,10)&&(e.style.overflow="")},shouldCollapse(e){if(this.singleLineWidth<=0)return!1;const t=e.style.height,o=e.style.width;e.style.overflow="hidden",e.style.width=`${this.singleLineWidth}px`,e.style.height=`${this.initialHeight}px`;const n=e.scrollWidth<=this.singleLineWidth&&e.scrollHeight<=this.initialHeight;return e.style.overflow="",e.style.width=o||"",e.style.height=t||"",n},resizeAutoMode(e,t){if(!this.isResizing){if((e.scrollWidth>e.clientWidth||e.scrollHeight>e.clientHeight)&&!this.hasExpanded)return this.isResizing=!0,void(this.hasExpanded=!0);if(this.hasExpanded){this.updateHeight(e);t<this.previousValueLength&&this.shouldCollapse(e)&&(e.style.height="",this.isResizing=!0,this.hasExpanded=!1)}}},resize(){var e;if("single"===this.$props.mode)return;const t=this.$refs.inputElement;if(!t)return;const o=(null==(e=t.value)?void 0:e.length)||0;"multi"===this.$props.mode?this.resizeMultiMode(t):"auto"===this.$props.mode&&this.resizeAutoMode(t,o)},setupResizeObserver(){if("single"===this.$props.mode)return;const e=this.$refs.inputElement;e&&(this.resizeObserver=new ResizeObserver(()=>{this.resizeTimeout&&clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout(()=>{"auto"===this.$props.mode&&!this.hasExpanded&&this.captureInitialDimensions(),this.resize()},50)}),this.resizeObserver.observe(e))},cleanupResizeObserver(){this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.resizeTimeout&&(clearTimeout(this.resizeTimeout),this.resizeTimeout=null)},handleChange(e){const t=e.target.value;!this.isControlled&&!this.$props.disabled&&(this.stateValue=t),this.$props.disabled||this.$emit("change",{event:e,value:t}),"single"!==this.$props.mode&&this.resize()},handleFocus(e){this.$props.disabled||this.$emit("focus",{event:e})},handleBlur(e){this.$props.disabled||this.$emit("blur",{event:e})},handleButtonMouseDown(e){e.preventDefault()},handleActionButtonClick(e){this.$emit("promptaction",{event:e,value:this.currentValue,attachments:this.currentFiles}),this.isControlled||(this.stateValue=""),this.isFilesControlled||(this.stateFiles=[])},handleKeyDown(e){if("Enter"!==e.key||!e.shiftKey){if("ArrowUp"===e.key||"ArrowDown"===e.key)return void e.stopPropagation();if("Enter"===e.key){if(e.preventDefault(),this.$props.loading)return;this.canSendMessage&&this.handleActionButtonClick(e)}}},handleSpeechResult(e){var t;const{isFinal:o,alternatives:n}=e;if(n.length>0){const e=n[0];if(o){const t=this.$refs.inputElement,o=(null==t?void 0:t.value)||"",n=(o?`${o} `:"")+e.transcript;if(this.isControlled||(this.stateValue=n),!this.$props.disabled){const e={target:t,currentTarget:t};this.$emit("change",{event:e,value:n})}}}null==(t=this.$refs.inputElement)||t.focus()},handleUploadButtonClick(){const e=this._uploadRef.value;if(null!=e&&e.$el){const t=e.$el.querySelector('input[type="file"]');t&&t.click()}},onFilesSelect(e){var t;const o=Array.from(e.affectedFiles),n=this.$props.uploadButtonConfig,i="object"==typeof n&&n,s=i?i.onSelectAttachments:void 0;this.isFilesControlled||(this.stateFiles=[...this.stateFiles,...o]),s&&s({selectedFiles:e.affectedFiles,allFiles:e.newState}),null==(t=this.$refs.inputElement)||t.focus()},handleRemoveFile(e){this.isFilesControlled||(this.stateFiles=this.stateFiles.filter(t=>t.name!==e));const t=this.$props.uploadButtonConfig,o="object"==typeof t&&t,n=o?o.onRemoveAttachment:void 0;n&&(this.onRemoveAttachmentCallback=n),this.onRemoveAttachmentCallback&&this.onRemoveAttachmentCallback(e)},renderAffix:(e,t)=>e?"function"==typeof e?e(t):e:null},render(){const e=r.provideLocalizationService(this),{mode:n,fillMode:s,maxTextAreaHeight:l,disabled:a,readOnly:u,placeholder:d,title:c,maxLength:p,inputAttributes:h,topAffix:g,startAffix:f,endAffix:v,header:k,loading:b,speechToTextButtonConfig:V,actionButtonConfig:x,uploadButtonConfig:y}=this.$props,A={uploadButtonProps:{fillMode:"flat",svgIcon:i.paperclipOutlineAltRightIcon,size:"small",rounded:"full",onClick:this.handleUploadButtonClick,onFilesAdd:this.onFilesSelect,files:this.currentFiles,_uploadRef:this._uploadRef,"aria-label":e.toLanguageString(w,F[w]),title:e.toLanguageString(w,F[w]),_registerRemoveCallback:e=>{this.onRemoveAttachmentCallback=e||null}},speechToTextButtonProps:{fillMode:"flat",size:"small",rounded:"full",onResult:this.handleSpeechResult},actionButtonProps:{rounded:"full",size:"small",svgIcon:b?i.stopIcon:i.arrowUpIcon,class:b?"k-generating k-active":"",onClick:this.handleActionButtonClick,onMousedown:this.handleButtonMouseDown,disabled:!b&&!this.canSendMessage,"aria-disabled":!b&&!this.canSendMessage||void 0,"aria-label":b?e.toLanguageString(R,F[R]):e.toLanguageString(N,F[N]),title:b?e.toLanguageString(R,F[R]):e.toLanguageString(N,F[N]),"aria-live":"polite"}},C=()=>{const e=!1!==V,o=!1!==x,n=!1!==y,i="object"==typeof V?V:void 0,s="object"==typeof y?y:{},{restrictions:l,multiple:r=!0,accept:a,onSelectAttachments:u,onRemoveAttachment:d,...c}=s,p={restrictions:l,multiple:r,accept:a},h="object"==typeof x?x:void 0;return t.createVNode(t.Fragment,null,[n&&t.createVNode(j,t.mergeProps({ref:"uploadButton"},A.uploadButtonProps,{restrictions:p.restrictions,multiple:p.multiple,accept:p.accept},c),null),e&&t.createVNode(E,t.mergeProps(A.speechToTextButtonProps,i),null),o&&t.createVNode(M,t.mergeProps(A.actionButtonProps,h),null)])},S={disabled:a,readOnly:u,placeholder:d,title:c,maxLength:p,"aria-label":e.toLanguageString(I,F[I]),value:this.currentValue,onKeydown:this.handleKeyDown,...h,onInput:this.handleChange,onFocus:this.handleFocus,onBlur:this.handleBlur,ref:"inputElement"};return t.createVNode("div",{"aria-label":e.toLanguageString(P,F[P]),class:o.classNames("k-input",q,{[`k-input-${s}`]:s,"k-disabled":a,"k-prompt-box-singleline":"single"===n,"k-prompt-box-multiline":this.isMultilineLayout})},[t.createVNode(D,{files:this.currentFiles,onRemoveFile:this.handleRemoveFile,header:o.templateRendering.call(this,k,o.getListeners.call(this))},null),"single"===n?(()=>t.createVNode("div",{class:`${q}-content`},[f&&t.createVNode("div",{class:`${q}-affix`},[this.renderAffix(f,A)]),t.createVNode("input",t.mergeProps(S,{class:o.classNames("k-input-inner",`${q}-input`)}),null),this.hasEndAffixOrButtons?t.createVNode("div",{class:`${q}-affix`},[v&&this.renderAffix(v,A),C()]):null]))():(()=>t.createVNode("div",{class:`${q}-content`},["multi"===n&&g&&t.createVNode("div",{class:`${q}-affix`},[this.renderAffix(g,A)]),"auto"===n&&f&&t.createVNode("div",{class:`${q}-affix`,style:{display:this.hasExpanded?"none":void 0}},[this.renderAffix(f,A)]),t.createVNode("textarea",t.mergeProps(S,{class:o.classNames("k-input-inner",`${q}-textarea`),rows:this.effectiveRows,style:l?{maxHeight:l}:{}},"single"!==n&&{"aria-multiline":"true"}),null),"auto"===n&&this.hasEndAffixOrButtons?t.createVNode("div",{class:`${q}-affix`,style:{display:this.hasExpanded?"none":void 0}},[v&&this.renderAffix(v,A),C()]):null,this.hasStartAffixOrEndAffixOrButtons?t.createVNode("div",{class:`${q}-affix`,style:{display:this.isMultilineLayout?void 0:"none"}},[f&&this.renderAffix(f,A),(f||v)&&t.createVNode("div",{class:"k-spacer"},null),v&&this.renderAffix(v,A),C()]):null]))(),o.shouldShowValidationUI(m)&&t.createVNode(o.WatermarkOverlay,{message:o.getLicenseMessage(m)},null)])}});e.AIPrompt=g,e.AIPromptCommandsView=L,e.AIPromptContent=v,e.AIPromptFooter=f,e.AIPromptHeader=d,e.AIPromptOutputRating=O,e.AIPromptOutputView=z,e.AIPromptView=A,e.AIPromptViewRender=k,e.PromptBox=U,e.PromptBoxActionButton=M,e.PromptBoxSpeechToTextButton=E,e.PromptBoxUploadButton=j,e.SuggestionGroup=x,e.commandsViewDefaults=p,e.outputViewDefaults=c,e.promptViewDefaults=h});
|
|
15
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue"),require("@progress/kendo-vue-common"),require("@progress/kendo-vue-buttons"),require("@progress/kendo-svg-icons"),require("@progress/kendo-vue-inputs"),require("@progress/kendo-vue-layout"),require("@progress/kendo-vue-intl"),require("@progress/kendo-vue-upload")):"function"==typeof define&&define.amd?define(["exports","vue","@progress/kendo-vue-common","@progress/kendo-vue-buttons","@progress/kendo-svg-icons","@progress/kendo-vue-inputs","@progress/kendo-vue-layout","@progress/kendo-vue-intl","@progress/kendo-vue-upload"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).KendoVueConversationalUi={},e.Vue,e.KendoVueCommon,e.KendoVueButtons,e.KendoSVGIcons,e.KendoVueInputs,e.KendoVueLayout,e.KendoVueIntl,e.KendoVueUpload)}(this,function(e,t,o,n,i,s,l,r,a){"use strict";function d(e){return"function"==typeof e||"[object Object]"===Object.prototype.toString.call(e)&&!t.isVNode(e)}const u=t.defineComponent({name:"KendoAIPromptHeader",props:{activeView:String,toolbarItems:Array,onActiveviewchange:Function},methods:{handleClick(e){this.$emit("activeviewchange",e)}},render(){let e;const{activeView:i,toolbarItems:s}=this.$props;return t.createVNode("div",{class:"k-prompt-header"},[t.createVNode(n.Toolbar,{overflow:"none",keyboardNavigation:!1,class:"k-toolbar-flat"},d(e=s.map(function(e){const s=o.getTemplate.call(this,{h:t.h,template:e.content,defaultRendering:null,additionalProps:{item:e}});return e.content?s:t.createVNode(n.Button,{type:"button",key:e.name,class:o.classNames("k-toolbar-item",{"k-selected":i===e.name}),size:"medium",themeColor:"primary",fillMode:"flat",rounded:"full",title:e.buttonText,svgIcon:e.buttonIcon,onClick:()=>this.handleClick(e.name)},{default:()=>[e.buttonText]})},this))?e:{default:()=>[e]})])}}),c={name:"Output view",buttonText:"Output",buttonIcon:i.commentIcon},p={name:"Commands view",buttonIcon:i.moreHorizontalIcon},h={name:"Prompt view",buttonText:"Ask AI",buttonIcon:i.sparklesIcon},m={name:"@progress/kendo-vue-conversational-ui",productName:"Kendo UI for Vue",productCode:"KENDOUIVUE",productCodes:["KENDOUIVUE"],publishDate:0,version:"8.4.0-develop.5",licensingDocsUrl:"https://www.telerik.com/kendo-vue-ui/my-license/"},g=t.defineComponent({name:"KendoAIPrompt",props:{activeView:{type:String,required:!0},dir:String,toolbarItems:Array,outputs:Array,promptPlaceholder:String,streaming:Boolean,loading:Boolean,suggestionsView:{type:String,default:"classic"}},provide(){return{kendoAIPrompt:this.$data.contextState}},data(){return{showLicenseWatermark:!1,licenseMessage:"",contextState:{activeView:this.$props.activeView,streaming:this.$props.streaming,loading:this.$props.loading,onCancel:this.onCancel,onActiveViewChange:this.onActiveViewChange,onPromptRequest:this.onPromptRequest,onCommandExecute:this.onCommandExecute,onStateAction:this.onStateAction,suggestionsView:this.$props.suggestionsView}}},watch:{activeView(e){this.contextState.activeView=e},streaming(e){this.contextState.streaming=e},loading(e){this.contextState.loading=e}},methods:{onStateAction(e){this.contextState.activeView=e.activeView},onActiveViewChange(e){this.$emit("activeviewchange",e)},onPromptRequest(e,t){this.$emit("promptrequest",e,t)},onCommandExecute(e){this.$emit("commandexecute",e)},onCancel(){this.$emit("cancel")}},render(){o.validatePackage(m),this.showLicenseWatermark=o.shouldShowValidationUI(m),this.licenseMessage=o.getLicenseMessage(m);const e=o.getDefaultSlots(this),{toolbarItems:n,dir:i}=this.$props,s=(n||[h,c]).map(e=>{const t=o.templateRendering.call(this,e.content,o.getListeners.call(this));return{...e,content:t}}),l=this.showLicenseWatermark?t.createVNode(o.WatermarkOverlay,{message:this.licenseMessage},null):null;return t.createVNode("div",{class:"k-prompt",dir:i},[t.createVNode(u,{activeView:this.contextState.activeView,toolbarItems:s,onActiveviewchange:this.onActiveViewChange},null),e,l])}}),f=t.defineComponent({name:"KendoAIPromptFooter",render(){const e=o.getDefaultSlots(this);return t.createVNode("div",{class:"k-prompt-footer"},[t.createVNode("div",{class:"k-actions k-actions-start k-actions-horizontal k-prompt-actions"},[e])])}}),v=t.defineComponent({name:"KendoAIPromptContent",props:{onCancel:Function,streaming:Boolean},inject:{kendoAIPrompt:{default:null}},computed:{showFloatingButton(){var e;const t=(null==(e=this.kendoAIPrompt)?void 0:e.activeView)===c.name;return this.streaming&&t}},methods:{handleKeyDown(e){"Escape"===e.key&&this.showFloatingButton&&this.onCancel&&(e.preventDefault(),this.$props.onCancel())}},render(){const e=o.getDefaultSlots(this);return t.createVNode("div",{class:"k-prompt-content",onKeydown:this.handleKeyDown},[this.showFloatingButton&&t.createVNode(n.FloatingActionButton,{onClick:this.onCancel,svgIcon:i.stopIcon,size:"small",positionMode:"absolute",class:"k-prompt-stop-fab k-generating"},null),t.createVNode("div",{class:"k-prompt-view"},[e])])}}),k=t.defineComponent({name:"KendoAIPromptViewRender",inheritAttrs:!1,props:{name:String},inject:{kendoAIPrompt:{default:null}},render(){const e=o.getDefaultSlots(this);return this.kendoAIPrompt.activeView===this.$props.name?e:null}});function b(e){return"function"==typeof e||"[object Object]"===Object.prototype.toString.call(e)&&!t.isVNode(e)}const V=t.defineComponent({name:"KendoAIPromptExpander",props:{title:String},data:()=>({expanded:!0}),methods:{buttonClick(){this.expanded=!this.expanded}},render(){const e=o.getDefaultSlots(this),{title:s}=this.$props;return t.createVNode("div",{class:"k-prompt-expander"},[t.createVNode(n.Button,{type:"button",fillMode:"flat",svgIcon:this.expanded?i.chevronUpIcon:i.chevronDownIcon,title:s,onClick:this.buttonClick},b(s)?s:{default:()=>[s]}),this.expanded&&t.createVNode("div",{class:"k-prompt-expander-content"},[e])])}}),x=t.defineComponent({name:"KendoSuggestionGroup",props:{suggestions:{type:Array,required:!0},onSuggestionClick:{type:Function,required:!0},suggestionsView:{type:String,default:"classic"}},methods:{handleSuggestionClick(e,t){t.disabled||this.onSuggestionClick(e,t)},handleKeyDown(e,t){("Enter"===e.key||" "===e.key)&&(e.preventDefault(),this.onSuggestionClick(e,t))}},render(){const{suggestions:e,suggestionsView:n}=this.$props,i=()=>e.map(e=>t.createVNode("span",{role:"button",tabindex:e.disabled?-1:0,"aria-label":e.description,"aria-disabled":e.disabled,onClick:t=>!e.disabled&&this.handleSuggestionClick(t,e),onKeydown:t=>!e.disabled&&this.handleKeyDown(t,e),key:e.id,title:e.description,class:o.classNames("classic"===n?"k-prompt-suggestion":"k-suggestion",{"k-disabled":e.disabled})},[e.text]));return"classic"===n?i():t.createVNode("div",{role:"group",class:"k-suggestion-group"},[i()])}});function y(e){return"function"==typeof e||"[object Object]"===Object.prototype.toString.call(e)&&!t.isVNode(e)}const C=t.defineComponent({name:"KendoAIPromptView",props:{promptInput:[Object,String],generateButton:[Object,String],promptValue:String,promptSuggestions:Array,enableSpeechToText:[Boolean,Object]},inject:{kendoAIPrompt:{default:null}},computed:{computedValue(){return void 0!==this.$props.promptValue?this.$props.promptValue:this.value}},data:()=>({value:""}),methods:{handleOnRequest(){this.kendoAIPrompt.onPromptRequest&&this.kendoAIPrompt.onPromptRequest.call(null,this.computedValue),this.value=""},handleSuggestionSelect(e){this.value=e},onTextChange(e){this.value=e.value},onSpeechResult(e){if(e.isFinal&&e.alternatives.length>0){const t=e.alternatives[0].transcript,o=this.value,n=o&&!o.endsWith(" ")&&!o.endsWith("\n");this.value=o+(n?" ":"")+t}},onSpeechStart(){},onSpeechEnd(){},getButtonDisabledState(){const e=void 0!==this.$props.promptValue?this.$props.promptValue:this.value;return!(null!=e&&e.trim())}},render(){const e="Generate",{promptSuggestions:l,enableSpeechToText:r}=this.$props,a=o.templateRendering.call(this,this.$props.promptInput,o.getListeners.call(this)),d=t.createVNode(s.TextArea,{value:this.computedValue,onInput:this.onTextChange,placeholder:"Ask or generate content with AI ...",rows:2,class:"!k-flex-col",inputSuffix:()=>r?t.createVNode(t.Fragment,null,[t.createVNode(s.InputSeparator,{orientation:"horizontal"},null),t.createVNode("div",{class:"k-input-suffix k-input-suffix-horizontal"},[t.createVNode(n.SpeechToTextButton,t.mergeProps({fillMode:"flat",onStart:this.onSpeechStart,onEnd:this.onSpeechEnd,onResult:this.onSpeechResult},"object"==typeof r?r:{}),null)])]):null},null),u=o.getTemplate.call(this,{h:t.h,template:a,defaultRendering:d}),c=o.templateRendering.call(this,this.$props.generateButton,o.getListeners.call(this)),p=t.createVNode(n.Button,{type:"button",themeColor:"primary",fillMode:"solid","aria-hidden":"true",rounded:"full",size:"medium",onClick:this.handleOnRequest,disabled:this.getButtonDisabledState(),title:"Generate",svgIcon:i.sparklesIcon},y(e)?e:{default:()=>[e]}),m=o.getTemplate.call(this,{h:t.h,template:c,defaultRendering:p});return t.createVNode(k,{name:h.name},{default:()=>{var e,o;return[t.createVNode(v,{streaming:null==(e=this.kendoAIPrompt)?void 0:e.streaming,onCancel:null==(o=this.kendoAIPrompt)?void 0:o.onCancel},{default:()=>[u,l&&l.length>0&&t.createVNode(V,{title:"Prompt Suggestions"},{default:()=>{var e;return[t.createVNode(x,{suggestionsView:null==(e=this.kendoAIPrompt)?void 0:e.suggestionsView,suggestions:l.map((e,t)=>({id:t,text:e,description:e})),onSuggestionClick:(e,t)=>this.handleSuggestionSelect(t.text)},null)]}})]}),t.createVNode(f,null,y(m)?m:{default:()=>[m]})]}})}}),A="avatar.alt",S="messageList.ariaLabel",$="aIPrompt.noOutputs",I="promptBox.input",N="promptBox.sendButton",w="promptBox.attachFile",B="promptBox.removeFile",R="promptBox.stopGenerating",P="promptBox.ariaLabel",F={[A]:"Avatar",[S]:"Message list",[$]:"No output from Ai available",[I]:"Prompt",[N]:"Send",[w]:"Attach file",[B]:"Remove file",[R]:"Stop generating",[P]:"Prompt box"};function T(e){return"function"==typeof e||"[object Object]"===Object.prototype.toString.call(e)&&!t.isVNode(e)}let O=function(e){return e.positive="positive",e.negative="negative",e}({});const z=t.defineComponent({name:"KendoAIPromptOutputView",emits:{copy:null,retry:null,rating:null},props:{outputs:Array,outputCard:Object,showOutputRating:Boolean},inject:{kendoAIPrompt:{default:null},kendoLocalizationService:{default:null}},data:()=>({copiedIndex:-1,copyButtonIcon:i.copyIcon,contentRef:null}),methods:{retryPrompt(e){this.$emit("retry",e),this.kendoAIPrompt.onPromptRequest&&this.kendoAIPrompt.onPromptRequest.call(null,e.prompt,{...e,isRetry:!0}),this.scrollToTopOutput()},copyToClipboard(e,t){null!=e&&e.responseContent&&navigator.clipboard.writeText(e.responseContent),this.copiedIndex=t,this.copyButtonIcon=i.checkIcon,this.$emit("copy",null==e?void 0:e.responseContent),setTimeout(()=>{this.copyButtonIcon=i.copyIcon,this.copiedIndex=-1},1e3)},outputRating(e,t){this.$emit("rating",e,t),this.kendoAIPrompt.onPromptRequest&&this.kendoAIPrompt.onPromptRequest.call(null,e.prompt,{...e,ratingType:t,isRetry:!1}),this.scrollToTopOutput()},scrollToTopOutput(){var e,t;null==(t=null==(e=this.contentRef)?void 0:e.scrollTo)||t.call(e,{top:0,behavior:"smooth"})}},render(){let e;const{outputs:o,showOutputRating:s,outputCard:a}=this.$props,d=r.provideLocalizationService(this),{header:u,body:p,actions:h}=a||{},m=t.createVNode(l.Card,null,{default:()=>[t.createVNode(l.CardHeader,null,{default:()=>[t.createVNode(l.CardTitle,null,{default:()=>[t.createVNode("span",{class:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"200px"}},null)]}),t.createVNode(l.CardSubtitle,null,{default:()=>[t.createVNode("span",{class:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"100%"}},null)]})]}),t.createVNode(l.CardBody,null,{default:()=>[t.createVNode("span",{class:"k-skeleton k-skeleton-rect k-skeleton-pulse",style:{height:"80px"}},null)]}),t.createVNode(l.CardActions,null,{default:()=>[t.createVNode("span",{class:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"100%"}},null)]})]}),g=null==o?void 0:o.map((e,o)=>t.createVNode(l.Card,{key:`${e.id}_${o}`,class:e.class},{default:()=>[t.createVNode(l.CardHeader,null,{default:()=>[u?u(e):t.createVNode(t.Fragment,null,[e.title&&t.createVNode(l.CardTitle,null,{default:()=>[e.title]}),e.subTitle&&t.createVNode(l.CardSubtitle,null,{default:()=>[e.subTitle]})])]}),t.createVNode(l.CardBody,null,{default:()=>[p?p(e):e.responseContent]}),t.createVNode(l.CardActions,null,{default:()=>[h?h(e):t.createVNode(t.Fragment,null,[t.createVNode(n.Button,{type:"button",size:"medium",themeColor:"primary",fillMode:"flat",rounded:"medium",title:"Copy",svgIcon:this.copiedIndex===o?this.copyButtonIcon:i.copyIcon,"aria-hidden":"true",onClick:()=>this.copyToClipboard(e,o)},{default:()=>["Copy"]}),t.createVNode(n.Button,{type:"button",size:"medium",themeColor:"base",fillMode:"flat",rounded:"medium",title:"Retry",svgIcon:i.arrowRotateCwIcon,"aria-hidden":"true",onClick:()=>this.retryPrompt(e)},{default:()=>["Retry"]}),s&&t.createVNode(t.Fragment,null,[t.createVNode("span",{class:"k-spacer"},null),t.createVNode(n.Button,{type:"button",size:"medium",themeColor:"positive"===e.ratingType?"primary":"base",fillMode:"flat",rounded:"medium",title:"Rate up",svgIcon:i.thumbUpIcon,"aria-hidden":"true",onClick:()=>this.outputRating(e,"positive")},null),t.createVNode(n.Button,{type:"button",size:"medium",themeColor:"negative"===e.ratingType?"primary":"base",fillMode:"flat",rounded:"medium",title:"Rate down",svgIcon:i.thumbDownIcon,"aria-hidden":"true",onClick:()=>this.outputRating(e,"negative")},null)])])]})]})),f=t.createVNode(l.Card,null,{default:()=>[t.createVNode(l.CardBody,null,T(e=d.toLanguageString($,F[$]))?e:{default:()=>[e]})]});return t.createVNode(k,{name:c.name},{default:()=>{var e,o;return[t.createVNode(v,{ref:e=>this.contentRef=e,streaming:null==(e=this.kendoAIPrompt)?void 0:e.streaming,onCancel:null==(o=this.kendoAIPrompt)?void 0:o.onCancel},{default:()=>{var e,o;return[t.createVNode("div",{class:"k-card-list"},[(null==(e=this.kendoAIPrompt)?void 0:e.loading)&&m,g,(!g||0===g.length)&&!(null!=(o=this.kendoAIPrompt)&&o.loading)&&f])]}})]}})}}),L=t.defineComponent({name:"KendoAIPromptCommandsView",props:{commands:Array},inject:{kendoAIPrompt:{default:null}},render(){const{commands:e}=this.$props,o=e=>{var t;const o=e.target;(null==(t=o.items)||!t.length)&&this.kendoAIPrompt.onCommandExecute&&(this.$emit("commandexecute",o),this.kendoAIPrompt.onCommandExecute.call(null,o))};return t.createVNode(k,{name:p.name},{default:()=>{var n,i;return[t.createVNode(v,{streaming:null==(n=this.kendoAIPrompt)?void 0:n.streaming,onCancel:null==(i=this.kendoAIPrompt)?void 0:i.onCancel},{default:()=>[t.createVNode("div",{class:"k-prompt-view"},[t.createVNode(l.PanelBar,{onSelect:o,items:e},null)])]})]}})}}),M=t.defineComponent({name:"KendoPromptBoxActionButton",inheritAttrs:!1,render(){return t.createVNode(n.Button,this.$attrs,null)}}),E=t.defineComponent({name:"KendoPromptBoxSpeechToTextButton",inheritAttrs:!1,render(){return t.createVNode(n.SpeechToTextButton,this.$attrs,null)}}),j=t.defineComponent({name:"KendoPromptBoxUploadButton",inheritAttrs:!1,props:{onFilesAdd:Function,files:{type:Array,default:()=>[]},restrictions:Object,multiple:{type:Boolean,default:!0},accept:String,onSelectAttachments:Function,onRemoveAttachment:Function,_registerRemoveCallback:Function},setup(e){const o=t.ref(null);return t.watch(()=>e.onRemoveAttachment,t=>{e._registerRemoveCallback&&t&&e._registerRemoveCallback(t)},{immediate:!0}),t.onUnmounted(()=>{e._registerRemoveCallback&&e.onRemoveAttachment&&e._registerRemoveCallback(void 0)}),{uploadRef:o,handleFilesAdd:t=>{e.onFilesAdd&&e.onFilesAdd(t),e.onSelectAttachments&&e.onSelectAttachments({selectedFiles:t.affectedFiles,allFiles:t.newState})}}},render(){const{onFilesAdd:e,files:o,restrictions:i,multiple:s,accept:l,onSelectAttachments:r,onRemoveAttachment:d,_registerRemoveCallback:u,_uploadRef:c,...p}=this.$attrs;return t.createVNode(t.Fragment,null,[t.createVNode(n.Button,p,null),t.createVNode(a.Upload,{ref:e=>{this.uploadRef=e,c&&(c.value=e)},files:this.files,onAdd:this.handleFilesAdd,autoUpload:!1,restrictions:this.restrictions,multiple:this.multiple,accept:this.accept,class:"k-hidden"},null)])}}),H=e=>"."+(e.split(".").pop()||""),K=e=>{if(null==e)return"";if(0===e)return"0 B";const t=Math.floor(Math.log(e)/Math.log(1024));return`${Number.parseFloat((e/Math.pow(1024,t)).toFixed(2))} ${["B","KB","MB","GB","TB"][t]}`},D=t.defineComponent({name:"KendoFileBox",props:{files:{type:Array,required:!0},onRemoveFile:{type:Function,required:!0},header:{type:[Object,Function,String],default:void 0}},inject:{kendoLocalizationService:{default:null}},data:()=>({canScrollRight:!1,canScrollLeft:!1,resizeObserver:null}),watch:{files:{handler(){t.nextTick(()=>{this.setupScrollListeners(),this.updateScrollState()})},deep:!0}},mounted(){t.nextTick(()=>{this.setupScrollListeners(),this.updateScrollState()})},beforeUnmount(){this.cleanupScrollListeners()},methods:{setupScrollListeners(){const e=this.$refs.scrollContainer;e?this._scrollContainer!==e&&(this.cleanupScrollListeners(),e.addEventListener("scroll",this.updateScrollState,{passive:!0}),this.resizeObserver=new ResizeObserver(()=>this.updateScrollState()),this.resizeObserver.observe(e),this._scrollContainer=e):this.cleanupScrollListeners()},cleanupScrollListeners(){this._scrollContainer&&(this._scrollContainer.removeEventListener("scroll",this.updateScrollState),this._scrollContainer=null),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null)},updateScrollState(){const e=this.$refs.scrollContainer;if(!e)return;const{scrollLeft:t,scrollWidth:o,clientWidth:n}=e,i=0===t,s=t+n>=o-1;this.canScrollLeft=!i,this.canScrollRight=!s},handleRemoveFile(e,t){t.stopPropagation(),this.$props.onRemoveFile&&this.$props.onRemoveFile(e)}},render(){const e=r.provideLocalizationService(this),{files:s,header:l}=this.$props;if(0===s.length&&!l)return null;const a=o.getTemplate.call(this,{h:t.h,template:l,defaultRendering:null}),d=e.toLanguageString(B,F[B]),u=s.length>0&&t.createVNode("ul",{class:o.classNames("k-file-box-wrapper",{"k-file-box-wrapper-scrollable-start":this.canScrollRight,"k-file-box-wrapper-scrollable-end":this.canScrollLeft})},[t.createVNode("div",{class:"k-files-scroll",ref:"scrollContainer"},[s.map(e=>t.createVNode("li",{key:e.name,class:"k-file-box"},[t.createVNode(o.Icon,t.mergeProps({size:"xlarge"},o.getFileExtensionIcon(H(e.name))),null),t.createVNode("div",{class:"k-file-info"},[t.createVNode("span",{class:"k-file-name"},[e.name]),t.createVNode("span",{class:"k-file-size"},[K(e.size)])]),t.createVNode(n.Button,{fillMode:"flat",svgIcon:i.xCircleIcon,onClick:t=>this.handleRemoveFile(e.name,t),"aria-label":`${d} ${e.name}`,title:`${d} ${e.name}`},null)]))])]);return t.createVNode("div",{class:"k-prompt-box-header"},[a,u])}}),q="k-prompt-box",U=t.defineComponent({name:"KendoPromptBox",emits:{change:e=>!0,focus:e=>!0,blur:e=>!0,promptaction:e=>!0},props:{value:String,defaultValue:{type:String,default:""},mode:{type:String,default:"auto"},rows:{type:Number,default:1},maxTextAreaHeight:String,title:String,disabled:{type:Boolean,default:!1},readOnly:{type:Boolean,default:!1},placeholder:String,maxLength:Number,inputAttributes:Object,fillMode:String,topAffix:[Object,Function,String],startAffix:[Object,Function,String],endAffix:[Object,Function,String],header:[Object,Function,String],loading:{type:Boolean,default:!1},uploadButtonConfig:{type:[Boolean,Object],default:!1},speechToTextButtonConfig:{type:[Boolean,Object],default:!0},actionButtonConfig:{type:[Boolean,Object],default:!0},attachments:Array},inject:{kendoLocalizationService:{default:null}},created(){o.validatePackage(m),this._uploadRef=t.ref(null)},data(){return{stateValue:this.$props.defaultValue||"",stateFiles:[],hasExpanded:!1,initialHeight:0,minMultiRowHeight:0,isResizing:!1,previousValueLength:0,singleLineWidth:0,resizeObserver:null,resizeTimeout:null,onRemoveAttachmentCallback:null}},computed:{isControlled(){return void 0!==this.$props.value},currentValue(){return this.isControlled?this.$props.value||"":this.stateValue},isFilesControlled(){return void 0!==this.$props.attachments},currentFiles(){return this.isFilesControlled?this.$props.attachments||[]:this.stateFiles},canSendMessage(){var e;return!!(null!=(e=this.currentValue)&&e.trim()||this.currentFiles.length>0)},isMultilineLayout(){return"multi"===this.$props.mode||"auto"===this.$props.mode&&this.hasExpanded},hasBuiltInButtons(){return!1!==this.$props.uploadButtonConfig||!1!==this.$props.speechToTextButtonConfig||!1!==this.$props.actionButtonConfig},hasEndAffixOrButtons(){return!!this.$props.endAffix||this.hasBuiltInButtons},hasStartAffixOrEndAffixOrButtons(){return!!this.$props.startAffix||!!this.$props.endAffix||this.hasBuiltInButtons},effectiveRows(){return"auto"===this.$props.mode?1:this.$props.rows}},watch:{currentValue(e){if("single"===this.$props.mode)return;const t=(null==e?void 0:e.length)||0;requestAnimationFrame(()=>{const e=this.$refs.inputElement;e&&("multi"===this.$props.mode?this.resizeMultiMode(e):"auto"===this.$props.mode&&this.resizeAutoMode(e,t),this.previousValueLength=t)})},rows(){"single"!==this.$props.mode&&(this.captureInitialDimensions(),this.resize())},maxTextAreaHeight(){"single"!==this.$props.mode&&this.resize()},mode(){"single"!==this.$props.mode&&t.nextTick(()=>{this.captureInitialDimensions(),this.resize()})},hasExpanded(e){if("auto"===this.$props.mode&&e&&requestAnimationFrame(()=>{const e=this.$refs.inputElement;e&&(this.updateHeight(e),this.isResizing=!1)}),"auto"===this.$props.mode&&!e){const e=this.$refs.inputElement;e&&(e.style.height="",e.style.overflow="",this.isResizing=!1)}}},mounted(){"single"!==this.$props.mode&&this.captureInitialDimensions(),this.setupResizeObserver()},beforeUnmount(){this.cleanupResizeObserver()},methods:{captureInitialDimensions(){const e=this.$refs.inputElement;if(!e||"single"===this.$props.mode)return;const t=globalThis.getComputedStyle(e),o=Number.parseFloat(t.lineHeight)||20,n=Number.parseFloat(t.paddingTop)||0,i=Number.parseFloat(t.paddingBottom)||0;this.initialHeight=e.offsetHeight||o+n+i,this.minMultiRowHeight=o*this.$props.rows+n+i,"auto"===this.$props.mode&&!this.hasExpanded&&(this.singleLineWidth=e.offsetWidth)},calculateHeight(e){if(this.$props.maxTextAreaHeight){const t=Number.parseInt(this.$props.maxTextAreaHeight,10);if(e>t)return t}return Math.max(this.minMultiRowHeight,e)},resizeMultiMode(e){e.style.overflow="hidden",e.style.height=`${this.initialHeight}px`;const t=e.scrollHeight,o=this.calculateHeight(t);e.style.height=`${o}px`,this.$props.maxTextAreaHeight&&t>Number.parseInt(this.$props.maxTextAreaHeight,10)&&(e.style.overflow="")},updateHeight(e){e.style.overflow="hidden",e.style.height=`${this.initialHeight}px`;const t=e.scrollHeight,o=this.$props.maxTextAreaHeight?Math.min(t,Number.parseInt(this.$props.maxTextAreaHeight,10)):t;e.style.height=`${o}px`,this.$props.maxTextAreaHeight&&t>Number.parseInt(this.$props.maxTextAreaHeight,10)&&(e.style.overflow="")},shouldCollapse(e){if(this.singleLineWidth<=0)return!1;const t=e.style.height,o=e.style.width;e.style.overflow="hidden",e.style.width=`${this.singleLineWidth}px`,e.style.height=`${this.initialHeight}px`;const n=e.scrollWidth<=this.singleLineWidth&&e.scrollHeight<=this.initialHeight;return e.style.overflow="",e.style.width=o||"",e.style.height=t||"",n},resizeAutoMode(e,t){if(!this.isResizing){if((e.scrollWidth>e.clientWidth||e.scrollHeight>e.clientHeight)&&!this.hasExpanded)return this.isResizing=!0,void(this.hasExpanded=!0);if(this.hasExpanded){this.updateHeight(e);t<this.previousValueLength&&this.shouldCollapse(e)&&(e.style.height="",this.isResizing=!0,this.hasExpanded=!1)}}},resize(){var e;if("single"===this.$props.mode)return;const t=this.$refs.inputElement;if(!t)return;const o=(null==(e=t.value)?void 0:e.length)||0;"multi"===this.$props.mode?this.resizeMultiMode(t):"auto"===this.$props.mode&&this.resizeAutoMode(t,o)},setupResizeObserver(){if("single"===this.$props.mode)return;const e=this.$refs.inputElement;e&&(this.resizeObserver=new ResizeObserver(()=>{this.resizeTimeout&&clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout(()=>{"auto"===this.$props.mode&&!this.hasExpanded&&this.captureInitialDimensions(),this.resize()},50)}),this.resizeObserver.observe(e))},cleanupResizeObserver(){this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.resizeTimeout&&(clearTimeout(this.resizeTimeout),this.resizeTimeout=null)},handleChange(e){const t=e.target.value;!this.isControlled&&!this.$props.disabled&&(this.stateValue=t),this.$props.disabled||this.$emit("change",{event:e,value:t}),"single"!==this.$props.mode&&this.resize()},handleFocus(e){this.$props.disabled||this.$emit("focus",{event:e})},handleBlur(e){this.$props.disabled||this.$emit("blur",{event:e})},handleButtonMouseDown(e){e.preventDefault()},handleActionButtonClick(e){this.$emit("promptaction",{event:e,value:this.currentValue,attachments:this.currentFiles}),this.isControlled||(this.stateValue=""),this.isFilesControlled||(this.stateFiles=[])},handleKeyDown(e){if("Enter"!==e.key||!e.shiftKey){if("ArrowUp"===e.key||"ArrowDown"===e.key)return void e.stopPropagation();if("Enter"===e.key){if(e.preventDefault(),this.$props.loading)return;this.canSendMessage&&this.handleActionButtonClick(e)}}},handleSpeechResult(e){var t;const{isFinal:o,alternatives:n}=e;if(n.length>0){const e=n[0];if(o){const t=this.$refs.inputElement,o=(null==t?void 0:t.value)||"",n=(o?`${o} `:"")+e.transcript;if(this.isControlled||(this.stateValue=n),!this.$props.disabled){const e={target:t,currentTarget:t};this.$emit("change",{event:e,value:n})}}}null==(t=this.$refs.inputElement)||t.focus()},handleUploadButtonClick(){const e=this._uploadRef.value;if(null!=e&&e.$el){const t=e.$el.querySelector('input[type="file"]');t&&t.click()}},onFilesSelect(e){var t;const o=Array.from(e.affectedFiles),n=this.$props.uploadButtonConfig,i="object"==typeof n&&n,s=i?i.onSelectAttachments:void 0;this.isFilesControlled||(this.stateFiles=[...this.stateFiles,...o]),s&&s({selectedFiles:e.affectedFiles,allFiles:e.newState}),null==(t=this.$refs.inputElement)||t.focus()},handleRemoveFile(e){this.isFilesControlled||(this.stateFiles=this.stateFiles.filter(t=>t.name!==e));const t=this.$props.uploadButtonConfig,o="object"==typeof t&&t,n=o?o.onRemoveAttachment:void 0;n&&(this.onRemoveAttachmentCallback=n),this.onRemoveAttachmentCallback&&this.onRemoveAttachmentCallback(e)},renderAffix:(e,t)=>e?"function"==typeof e?e(t):e:null},render(){const e=r.provideLocalizationService(this),{mode:n,fillMode:s,maxTextAreaHeight:l,disabled:a,readOnly:d,placeholder:u,title:c,maxLength:p,inputAttributes:h,topAffix:g,startAffix:f,endAffix:v,header:k,loading:b,speechToTextButtonConfig:V,actionButtonConfig:x,uploadButtonConfig:y}=this.$props,C={uploadButtonProps:{fillMode:"flat",svgIcon:i.paperclipIcon,size:"small",rounded:"full",onClick:this.handleUploadButtonClick,onFilesAdd:this.onFilesSelect,files:this.currentFiles,_uploadRef:this._uploadRef,"aria-label":e.toLanguageString(w,F[w]),title:e.toLanguageString(w,F[w]),_registerRemoveCallback:e=>{this.onRemoveAttachmentCallback=e||null}},speechToTextButtonProps:{fillMode:"flat",size:"small",rounded:"full",onResult:this.handleSpeechResult},actionButtonProps:{rounded:"full",size:"small",svgIcon:b?i.stopIcon:i.arrowUpIcon,class:b?"k-generating k-active":"",onClick:this.handleActionButtonClick,onMousedown:this.handleButtonMouseDown,disabled:!b&&!this.canSendMessage,"aria-disabled":!b&&!this.canSendMessage||void 0,"aria-label":b?e.toLanguageString(R,F[R]):e.toLanguageString(N,F[N]),title:b?e.toLanguageString(R,F[R]):e.toLanguageString(N,F[N]),"aria-live":"polite"}},A=()=>{const e=!1!==V,o=!1!==x,n=!1!==y,i="object"==typeof V?V:void 0,s="object"==typeof y?y:{},{restrictions:l,multiple:r=!0,accept:a,onSelectAttachments:d,onRemoveAttachment:u,...c}=s,p={restrictions:l,multiple:r,accept:a},h="object"==typeof x?x:void 0;return t.createVNode(t.Fragment,null,[n&&t.createVNode(j,t.mergeProps({ref:"uploadButton"},C.uploadButtonProps,{restrictions:p.restrictions,multiple:p.multiple,accept:p.accept},c),null),e&&t.createVNode(E,t.mergeProps(C.speechToTextButtonProps,i),null),o&&t.createVNode(M,t.mergeProps(C.actionButtonProps,h),null)])},S={disabled:a,readOnly:d,placeholder:u,title:c,maxLength:p,"aria-label":e.toLanguageString(I,F[I]),value:this.currentValue,onKeydown:this.handleKeyDown,...h,onInput:this.handleChange,onFocus:this.handleFocus,onBlur:this.handleBlur,ref:"inputElement"};return t.createVNode("div",{"aria-label":e.toLanguageString(P,F[P]),class:o.classNames("k-input",q,{[`k-input-${s}`]:s,"k-disabled":a,"k-prompt-box-singleline":"single"===n,"k-prompt-box-multiline":this.isMultilineLayout})},[t.createVNode(D,{files:this.currentFiles,onRemoveFile:this.handleRemoveFile,header:o.templateRendering.call(this,k,o.getListeners.call(this))},null),"single"===n?(()=>t.createVNode("div",{class:`${q}-content`},[f&&t.createVNode("div",{class:`${q}-affix`},[this.renderAffix(f,C)]),t.createVNode("input",t.mergeProps(S,{class:o.classNames("k-input-inner",`${q}-input`)}),null),this.hasEndAffixOrButtons?t.createVNode("div",{class:`${q}-affix`},[v&&this.renderAffix(v,C),A()]):null]))():(()=>t.createVNode("div",{class:`${q}-content`},["multi"===n&&g&&t.createVNode("div",{class:`${q}-affix`},[this.renderAffix(g,C)]),"auto"===n&&f&&t.createVNode("div",{class:`${q}-affix`,style:{display:this.hasExpanded?"none":void 0}},[this.renderAffix(f,C)]),t.createVNode("textarea",t.mergeProps(S,{class:o.classNames("k-input-inner",`${q}-textarea`),rows:this.effectiveRows,style:l?{maxHeight:l}:{}},"single"!==n&&{"aria-multiline":"true"}),null),"auto"===n&&this.hasEndAffixOrButtons?t.createVNode("div",{class:`${q}-affix`,style:{display:this.hasExpanded?"none":void 0}},[v&&this.renderAffix(v,C),A()]):null,this.hasStartAffixOrEndAffixOrButtons?t.createVNode("div",{class:`${q}-affix`,style:{display:this.isMultilineLayout?void 0:"none"}},[f&&this.renderAffix(f,C),(f||v)&&t.createVNode("div",{class:"k-spacer"},null),v&&this.renderAffix(v,C),A()]):null]))(),o.shouldShowValidationUI(m)&&t.createVNode(o.WatermarkOverlay,{message:o.getLicenseMessage(m)},null)])}});e.AIPrompt=g,e.AIPromptCommandsView=L,e.AIPromptContent=v,e.AIPromptFooter=f,e.AIPromptHeader=u,e.AIPromptOutputRating=O,e.AIPromptOutputView=z,e.AIPromptView=C,e.AIPromptViewRender=k,e.PromptBox=U,e.PromptBoxActionButton=M,e.PromptBoxSpeechToTextButton=E,e.PromptBoxUploadButton=j,e.SuggestionGroup=x,e.commandsViewDefaults=p,e.outputViewDefaults=c,e.promptViewDefaults=h});
|
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-vue-conversational-ui",productName:"Kendo UI for Vue",productCode:"KENDOUIVUE",productCodes:["KENDOUIVUE"],publishDate:
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e={name:"@progress/kendo-vue-conversational-ui",productName:"Kendo UI for Vue",productCode:"KENDOUIVUE",productCodes:["KENDOUIVUE"],publishDate: 1779202370,version:"8.4.0-develop.5",licensingDocsUrl:"https://www.telerik.com/kendo-vue-ui/my-license/"};exports.packageMetadata=e;
|
package/package-metadata.mjs
CHANGED
|
@@ -10,8 +10,8 @@ const e = {
|
|
|
10
10
|
productName: "Kendo UI for Vue",
|
|
11
11
|
productCode: "KENDOUIVUE",
|
|
12
12
|
productCodes: ["KENDOUIVUE"],
|
|
13
|
-
publishDate:
|
|
14
|
-
version: "8.4.0-develop.
|
|
13
|
+
publishDate: 1779202370,
|
|
14
|
+
version: "8.4.0-develop.5",
|
|
15
15
|
licensingDocsUrl: "https://www.telerik.com/kendo-vue-ui/my-license/"
|
|
16
16
|
};
|
|
17
17
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@progress/kendo-vue-conversational-ui",
|
|
3
|
-
"version": "8.4.0-develop.
|
|
3
|
+
"version": "8.4.0-develop.5",
|
|
4
4
|
"description": "TODO",
|
|
5
5
|
"author": "Progress",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
@@ -25,14 +25,14 @@
|
|
|
25
25
|
"sideEffects": false,
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"@progress/kendo-licensing": "^1.7.2",
|
|
28
|
-
"@progress/kendo-vue-buttons": "8.4.0-develop.
|
|
29
|
-
"@progress/kendo-vue-common": "8.4.0-develop.
|
|
30
|
-
"@progress/kendo-vue-intl": "8.4.0-develop.
|
|
31
|
-
"@progress/kendo-vue-inputs": "8.4.0-develop.
|
|
32
|
-
"@progress/kendo-vue-layout": "8.4.0-develop.
|
|
33
|
-
"@progress/kendo-vue-popup": "8.4.0-develop.
|
|
34
|
-
"@progress/kendo-vue-upload": "8.4.0-develop.
|
|
35
|
-
"@progress/kendo-svg-icons": "^4.
|
|
28
|
+
"@progress/kendo-vue-buttons": "8.4.0-develop.5",
|
|
29
|
+
"@progress/kendo-vue-common": "8.4.0-develop.5",
|
|
30
|
+
"@progress/kendo-vue-intl": "8.4.0-develop.5",
|
|
31
|
+
"@progress/kendo-vue-inputs": "8.4.0-develop.5",
|
|
32
|
+
"@progress/kendo-vue-layout": "8.4.0-develop.5",
|
|
33
|
+
"@progress/kendo-vue-popup": "8.4.0-develop.5",
|
|
34
|
+
"@progress/kendo-vue-upload": "8.4.0-develop.5",
|
|
35
|
+
"@progress/kendo-svg-icons": "^4.9.0 || ^5.0.0",
|
|
36
36
|
"vue": "^3.0.2"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {},
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"package": {
|
|
53
53
|
"productName": "Kendo UI for Vue",
|
|
54
54
|
"productCode": "KENDOUIVUE",
|
|
55
|
-
"publishDate":
|
|
55
|
+
"publishDate": 1779202370,
|
|
56
56
|
"licensingDocsUrl": "https://www.telerik.com/kendo-vue-ui/my-license/"
|
|
57
57
|
}
|
|
58
58
|
},
|
|
@@ -62,5 +62,10 @@
|
|
|
62
62
|
"repository": {
|
|
63
63
|
"type": "git",
|
|
64
64
|
"url": "git+https://github.com/telerik/kendo-vue.git"
|
|
65
|
+
},
|
|
66
|
+
"peerDependenciesMeta": {
|
|
67
|
+
"@progress/kendo-svg-icons": {
|
|
68
|
+
"optional": true
|
|
69
|
+
}
|
|
65
70
|
}
|
|
66
71
|
}
|
package/prompt-box/FileBox.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 t=require("vue"),d=require("@progress/kendo-vue-buttons"),i=require("@progress/kendo-vue-common"),p=require("@progress/kendo-svg-icons"),h=require("@progress/kendo-vue-intl"),c=require("../messages/main.js"),S="k-prompt-box",
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("vue"),d=require("@progress/kendo-vue-buttons"),i=require("@progress/kendo-vue-common"),p=require("@progress/kendo-svg-icons"),h=require("@progress/kendo-vue-intl"),c=require("../messages/main.js"),S="k-prompt-box",f=1,m=e=>"."+(e.split(".").pop()||""),v=e=>{if(e==null)return"";if(e===0)return"0 B";const r=1024,s=["B","KB","MB","GB","TB"],o=Math.floor(Math.log(e)/Math.log(r));return`${Number.parseFloat((e/Math.pow(r,o)).toFixed(2))} ${s[o]}`},g=t.defineComponent({name:"KendoFileBox",props:{files:{type:Array,required:!0},onRemoveFile:{type:Function,required:!0},header:{type:[Object,Function,String],default:void 0}},inject:{kendoLocalizationService:{default:null}},data(){return{canScrollRight:!1,canScrollLeft:!1,resizeObserver:null}},watch:{files:{handler(){t.nextTick(()=>{this.setupScrollListeners(),this.updateScrollState()})},deep:!0}},mounted(){t.nextTick(()=>{this.setupScrollListeners(),this.updateScrollState()})},beforeUnmount(){this.cleanupScrollListeners()},methods:{setupScrollListeners(){const e=this.$refs.scrollContainer;if(!e){this.cleanupScrollListeners();return}this._scrollContainer!==e&&(this.cleanupScrollListeners(),e.addEventListener("scroll",this.updateScrollState,{passive:!0}),this.resizeObserver=new ResizeObserver(()=>this.updateScrollState()),this.resizeObserver.observe(e),this._scrollContainer=e)},cleanupScrollListeners(){this._scrollContainer&&(this._scrollContainer.removeEventListener("scroll",this.updateScrollState),this._scrollContainer=null),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null)},updateScrollState(){const e=this.$refs.scrollContainer;if(!e)return;const{scrollLeft:r,scrollWidth:s,clientWidth:o}=e,l=r===0,a=r+o>=s-f;this.canScrollLeft=!l,this.canScrollRight=!a},handleRemoveFile(e,r){r.stopPropagation(),this.$props.onRemoveFile&&this.$props.onRemoveFile(e)}},render(){const e=h.provideLocalizationService(this),{files:r,header:s}=this.$props;if(r.length===0&&!s)return null;const o=i.getTemplate.call(this,{h:t.h,template:s,defaultRendering:null}),l=e.toLanguageString(c.promptBoxRemoveFile,c.messages[c.promptBoxRemoveFile]),a=r.length>0&&t.createVNode("ul",{class:i.classNames("k-file-box-wrapper",{"k-file-box-wrapper-scrollable-start":this.canScrollRight,"k-file-box-wrapper-scrollable-end":this.canScrollLeft})},[t.createVNode("div",{class:"k-files-scroll",ref:"scrollContainer"},[r.map(n=>t.createVNode("li",{key:n.name,class:"k-file-box"},[t.createVNode(i.Icon,t.mergeProps({size:"xlarge"},i.getFileExtensionIcon(m(n.name))),null),t.createVNode("div",{class:"k-file-info"},[t.createVNode("span",{class:"k-file-name"},[n.name]),t.createVNode("span",{class:"k-file-size"},[v(n.size)])]),t.createVNode(d.Button,{fillMode:"flat",svgIcon:p.xCircleIcon,onClick:u=>this.handleRemoveFile(n.name,u),"aria-label":`${l} ${n.name}`,title:`${l} ${n.name}`},null)]))])]);return t.createVNode("div",{class:`${S}-header`},[o,a])}});exports.FileBox=g;
|
package/prompt-box/FileBox.mjs
CHANGED
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
import { defineComponent as h, h as u, createVNode as r, mergeProps as d, nextTick as a } from "vue";
|
|
9
9
|
import { Button as m } from "@progress/kendo-vue-buttons";
|
|
10
10
|
import { getTemplate as f, classNames as S, Icon as v, getFileExtensionIcon as L } from "@progress/kendo-vue-common";
|
|
11
|
-
import {
|
|
11
|
+
import { xCircleIcon as g } from "@progress/kendo-svg-icons";
|
|
12
12
|
import { provideLocalizationService as b } from "@progress/kendo-vue-intl";
|
|
13
13
|
import { promptBoxRemoveFile as c, messages as F } from "../messages/main.mjs";
|
|
14
|
-
const
|
|
14
|
+
const x = "k-prompt-box", k = 1, z = (e) => "." + (e.split(".").pop() || ""), C = (e) => {
|
|
15
15
|
if (e == null)
|
|
16
16
|
return "";
|
|
17
17
|
if (e === 0)
|
|
@@ -86,7 +86,7 @@ const k = "k-prompt-box", x = 1, z = (e) => "." + (e.split(".").pop() || ""), R
|
|
|
86
86
|
scrollLeft: t,
|
|
87
87
|
scrollWidth: s,
|
|
88
88
|
clientWidth: n
|
|
89
|
-
} = e, o = t === 0, i = t + n >= s -
|
|
89
|
+
} = e, o = t === 0, i = t + n >= s - k;
|
|
90
90
|
this.canScrollLeft = !o, this.canScrollRight = !i;
|
|
91
91
|
},
|
|
92
92
|
handleRemoveFile(e, t) {
|
|
@@ -123,7 +123,7 @@ const k = "k-prompt-box", x = 1, z = (e) => "." + (e.split(".").pop() || ""), R
|
|
|
123
123
|
class: "k-file-name"
|
|
124
124
|
}, [l.name]), r("span", {
|
|
125
125
|
class: "k-file-size"
|
|
126
|
-
}, [
|
|
126
|
+
}, [C(l.size)])]), r(m, {
|
|
127
127
|
fillMode: "flat",
|
|
128
128
|
svgIcon: g,
|
|
129
129
|
onClick: (p) => this.handleRemoveFile(l.name, p),
|
|
@@ -131,7 +131,7 @@ const k = "k-prompt-box", x = 1, z = (e) => "." + (e.split(".").pop() || ""), R
|
|
|
131
131
|
title: `${o} ${l.name}`
|
|
132
132
|
}, null)]))])]);
|
|
133
133
|
return r("div", {
|
|
134
|
-
class: `${
|
|
134
|
+
class: `${x}-header`
|
|
135
135
|
}, [n, i]);
|
|
136
136
|
}
|
|
137
137
|
});
|
package/prompt-box/PromptBox.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 s=require("vue"),h=require("@progress/kendo-vue-common"),y=require("@progress/kendo-svg-icons"),I=require("./PromptBoxActionButton.js"),j=require("./PromptBoxSpeechToTextButton.js"),_=require("./PromptBoxUploadButton.js"),D=require("./FileBox.js"),S=require("../package-metadata.js"),q=require("@progress/kendo-vue-intl"),o=require("../messages/main.js"),l="k-prompt-box",U=20,W=50,G=s.defineComponent({name:"KendoPromptBox",emits:{change:e=>!0,focus:e=>!0,blur:e=>!0,promptaction:e=>!0},props:{value:String,defaultValue:{type:String,default:""},mode:{type:String,default:"auto"},rows:{type:Number,default:1},maxTextAreaHeight:String,title:String,disabled:{type:Boolean,default:!1},readOnly:{type:Boolean,default:!1},placeholder:String,maxLength:Number,inputAttributes:Object,fillMode:String,topAffix:[Object,Function,String],startAffix:[Object,Function,String],endAffix:[Object,Function,String],header:[Object,Function,String],loading:{type:Boolean,default:!1},uploadButtonConfig:{type:[Boolean,Object],default:!1},speechToTextButtonConfig:{type:[Boolean,Object],default:!0},actionButtonConfig:{type:[Boolean,Object],default:!0},attachments:Array},inject:{kendoLocalizationService:{default:null}},created(){h.validatePackage(S.packageMetadata),this._uploadRef=s.ref(null)},data(){return{stateValue:this.$props.defaultValue||"",stateFiles:[],hasExpanded:!1,initialHeight:0,minMultiRowHeight:0,isResizing:!1,previousValueLength:0,singleLineWidth:0,resizeObserver:null,resizeTimeout:null,onRemoveAttachmentCallback:null}},computed:{isControlled(){return this.$props.value!==void 0},currentValue(){return this.isControlled?this.$props.value||"":this.stateValue},isFilesControlled(){return this.$props.attachments!==void 0},currentFiles(){return this.isFilesControlled?this.$props.attachments||[]:this.stateFiles},canSendMessage(){var e;return!!((e=this.currentValue)!=null&&e.trim()||this.currentFiles.length>0)},isMultilineLayout(){return this.$props.mode==="multi"||this.$props.mode==="auto"&&this.hasExpanded},hasBuiltInButtons(){return this.$props.uploadButtonConfig!==!1||this.$props.speechToTextButtonConfig!==!1||this.$props.actionButtonConfig!==!1},hasEndAffixOrButtons(){return!!this.$props.endAffix||this.hasBuiltInButtons},hasStartAffixOrEndAffixOrButtons(){return!!this.$props.startAffix||!!this.$props.endAffix||this.hasBuiltInButtons},effectiveRows(){return this.$props.mode==="auto"?1:this.$props.rows}},watch:{currentValue(e){if(this.$props.mode==="single")return;const t=(e==null?void 0:e.length)||0;requestAnimationFrame(()=>{const i=this.$refs.inputElement;i&&(this.$props.mode==="multi"?this.resizeMultiMode(i):this.$props.mode==="auto"&&this.resizeAutoMode(i,t),this.previousValueLength=t)})},rows(){this.$props.mode!=="single"&&(this.captureInitialDimensions(),this.resize())},maxTextAreaHeight(){this.$props.mode!=="single"&&this.resize()},mode(){this.$props.mode!=="single"&&s.nextTick(()=>{this.captureInitialDimensions(),this.resize()})},hasExpanded(e){if(this.$props.mode==="auto"&&e&&requestAnimationFrame(()=>{const t=this.$refs.inputElement;t&&(this.updateHeight(t),this.isResizing=!1)}),this.$props.mode==="auto"&&!e){const t=this.$refs.inputElement;t&&(t.style.height="",t.style.overflow="",this.isResizing=!1)}}},mounted(){this.$props.mode!=="single"&&this.captureInitialDimensions(),this.setupResizeObserver()},beforeUnmount(){this.cleanupResizeObserver()},methods:{captureInitialDimensions(){const e=this.$refs.inputElement;if(!e||this.$props.mode==="single")return;const t=globalThis.getComputedStyle(e),i=Number.parseFloat(t.lineHeight)||U,n=Number.parseFloat(t.paddingTop)||0,r=Number.parseFloat(t.paddingBottom)||0;this.initialHeight=e.offsetHeight||i+n+r,this.minMultiRowHeight=i*this.$props.rows+n+r,this.$props.mode==="auto"&&!this.hasExpanded&&(this.singleLineWidth=e.offsetWidth)},calculateHeight(e){if(this.$props.maxTextAreaHeight){const t=Number.parseInt(this.$props.maxTextAreaHeight,10);if(e>t)return t}return Math.max(this.minMultiRowHeight,e)},resizeMultiMode(e){e.style.overflow="hidden",e.style.height=`${this.initialHeight}px`;const t=e.scrollHeight,i=this.calculateHeight(t);e.style.height=`${i}px`,this.$props.maxTextAreaHeight&&t>Number.parseInt(this.$props.maxTextAreaHeight,10)&&(e.style.overflow="")},updateHeight(e){e.style.overflow="hidden",e.style.height=`${this.initialHeight}px`;const t=e.scrollHeight,i=this.$props.maxTextAreaHeight?Math.min(t,Number.parseInt(this.$props.maxTextAreaHeight,10)):t;e.style.height=`${i}px`,this.$props.maxTextAreaHeight&&t>Number.parseInt(this.$props.maxTextAreaHeight,10)&&(e.style.overflow="")},shouldCollapse(e){if(this.singleLineWidth<=0)return!1;const t=e.style.height,i=e.style.width;e.style.overflow="hidden",e.style.width=`${this.singleLineWidth}px`,e.style.height=`${this.initialHeight}px`;const n=e.scrollWidth<=this.singleLineWidth&&e.scrollHeight<=this.initialHeight;return e.style.overflow="",e.style.width=i||"",e.style.height=t||"",n},resizeAutoMode(e,t){if(this.isResizing)return;if((e.scrollWidth>e.clientWidth||e.scrollHeight>e.clientHeight)&&!this.hasExpanded){this.isResizing=!0,this.hasExpanded=!0;return}if(this.hasExpanded){this.updateHeight(e);const n=this.previousValueLength;t<n&&this.shouldCollapse(e)&&(e.style.height="",this.isResizing=!0,this.hasExpanded=!1)}},resize(){var i;if(this.$props.mode==="single")return;const e=this.$refs.inputElement;if(!e)return;const t=((i=e.value)==null?void 0:i.length)||0;this.$props.mode==="multi"?this.resizeMultiMode(e):this.$props.mode==="auto"&&this.resizeAutoMode(e,t)},setupResizeObserver(){if(this.$props.mode==="single")return;const e=this.$refs.inputElement;e&&(this.resizeObserver=new ResizeObserver(()=>{this.resizeTimeout&&clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout(()=>{this.$props.mode==="auto"&&!this.hasExpanded&&this.captureInitialDimensions(),this.resize()},W)}),this.resizeObserver.observe(e))},cleanupResizeObserver(){this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.resizeTimeout&&(clearTimeout(this.resizeTimeout),this.resizeTimeout=null)},handleChange(e){const i=e.target.value;!this.isControlled&&!this.$props.disabled&&(this.stateValue=i),this.$props.disabled||this.$emit("change",{event:e,value:i}),this.$props.mode!=="single"&&this.resize()},handleFocus(e){this.$props.disabled||this.$emit("focus",{event:e})},handleBlur(e){this.$props.disabled||this.$emit("blur",{event:e})},handleButtonMouseDown(e){e.preventDefault()},handleActionButtonClick(e){this.$emit("promptaction",{event:e,value:this.currentValue,attachments:this.currentFiles}),this.isControlled||(this.stateValue=""),this.isFilesControlled||(this.stateFiles=[])},handleKeyDown(e){if(!(e.key==="Enter"&&e.shiftKey)){if(e.key==="ArrowUp"||e.key==="ArrowDown"){e.stopPropagation();return}if(e.key==="Enter"){if(e.preventDefault(),this.$props.loading)return;this.canSendMessage&&this.handleActionButtonClick(e)}}},handleSpeechResult(e){var n;const{isFinal:t,alternatives:i}=e;if(i.length>0){const r=i[0];if(t){const a=this.$refs.inputElement,f=(a==null?void 0:a.value)||"",g=(f?`${f} `:"")+r.transcript;if(this.isControlled||(this.stateValue=g),!this.$props.disabled){const m={target:a,currentTarget:a};this.$emit("change",{event:m,value:g})}}}(n=this.$refs.inputElement)==null||n.focus()},handleUploadButtonClick(){const e=this._uploadRef.value;if(e!=null&&e.$el){const t=e.$el.querySelector('input[type="file"]');t&&t.click()}},onFilesSelect(e){var a;const t=Array.from(e.affectedFiles),i=this.$props.uploadButtonConfig,n=typeof i=="object"&&i,r=n?n.onSelectAttachments:void 0;this.isFilesControlled||(this.stateFiles=[...this.stateFiles,...t]),r&&r({selectedFiles:e.affectedFiles,allFiles:e.newState}),(a=this.$refs.inputElement)==null||a.focus()},handleRemoveFile(e){this.isFilesControlled||(this.stateFiles=this.stateFiles.filter(r=>r.name!==e));const t=this.$props.uploadButtonConfig,i=typeof t=="object"&&t,n=i?i.onRemoveAttachment:void 0;n&&(this.onRemoveAttachmentCallback=n),this.onRemoveAttachmentCallback&&this.onRemoveAttachmentCallback(e)},renderAffix(e,t){return e?typeof e=="function"?e(t):e:null}},render(){const e=q.provideLocalizationService(this),{mode:t,fillMode:i,maxTextAreaHeight:n,disabled:r,readOnly:a,placeholder:f,title:g,maxLength:m,inputAttributes:T,topAffix:C,startAffix:p,endAffix:d,header:z,loading:c,speechToTextButtonConfig:x,actionButtonConfig:B,uploadButtonConfig:$}=this.$props,u={uploadButtonProps:{fillMode:"flat",svgIcon:y.paperclipOutlineAltRightIcon,size:"small",rounded:"full",onClick:this.handleUploadButtonClick,onFilesAdd:this.onFilesSelect,files:this.currentFiles,_uploadRef:this._uploadRef,"aria-label":e.toLanguageString(o.promptBoxAttachFile,o.messages[o.promptBoxAttachFile]),title:e.toLanguageString(o.promptBoxAttachFile,o.messages[o.promptBoxAttachFile]),_registerRemoveCallback:A=>{this.onRemoveAttachmentCallback=A||null}},speechToTextButtonProps:{fillMode:"flat",size:"small",rounded:"full",onResult:this.handleSpeechResult},actionButtonProps:{rounded:"full",size:"small",svgIcon:c?y.stopIcon:y.arrowUpIcon,class:c?"k-generating k-active":"",onClick:this.handleActionButtonClick,onMousedown:this.handleButtonMouseDown,disabled:!c&&!this.canSendMessage,"aria-disabled":!c&&!this.canSendMessage?!0:void 0,"aria-label":c?e.toLanguageString(o.promptBoxStopGenerating,o.messages[o.promptBoxStopGenerating]):e.toLanguageString(o.promptBoxSendButton,o.messages[o.promptBoxSendButton]),title:c?e.toLanguageString(o.promptBoxStopGenerating,o.messages[o.promptBoxStopGenerating]):e.toLanguageString(o.promptBoxSendButton,o.messages[o.promptBoxSendButton]),"aria-live":"polite"}},v=()=>{const A=x!==!1,k=B!==!1,E=$!==!1,M=typeof x=="object"?x:void 0,O=typeof $=="object"?$:{},{restrictions:L,multiple:w=!0,accept:V,onSelectAttachments:K,onRemoveAttachment:X,...N}=O,b={restrictions:L,multiple:w,accept:V},P=typeof B=="object"?B:void 0;return s.createVNode(s.Fragment,null,[E&&s.createVNode(_.PromptBoxUploadButton,s.mergeProps({ref:"uploadButton"},u.uploadButtonProps,{restrictions:b.restrictions,multiple:b.multiple,accept:b.accept},N),null),A&&s.createVNode(j.PromptBoxSpeechToTextButton,s.mergeProps(u.speechToTextButtonProps,M),null),k&&s.createVNode(I.PromptBoxActionButton,s.mergeProps(u.actionButtonProps,P),null)])},F={disabled:r,readOnly:a,placeholder:f,title:g,maxLength:m,"aria-label":e.toLanguageString(o.promptBoxInput,o.messages[o.promptBoxInput]),value:this.currentValue,onKeydown:this.handleKeyDown,...T,onInput:this.handleChange,onFocus:this.handleFocus,onBlur:this.handleBlur,ref:"inputElement"},H=()=>s.createVNode("div",{class:`${l}-content`},[p&&s.createVNode("div",{class:`${l}-affix`},[this.renderAffix(p,u)]),s.createVNode("input",s.mergeProps(F,{class:h.classNames("k-input-inner",`${l}-input`)}),null),this.hasEndAffixOrButtons?s.createVNode("div",{class:`${l}-affix`},[d&&this.renderAffix(d,u),v()]):null]),R=()=>s.createVNode("div",{class:`${l}-content`},[t==="multi"&&C&&s.createVNode("div",{class:`${l}-affix`},[this.renderAffix(C,u)]),t==="auto"&&p&&s.createVNode("div",{class:`${l}-affix`,style:{display:this.hasExpanded?"none":void 0}},[this.renderAffix(p,u)]),s.createVNode("textarea",s.mergeProps(F,{class:h.classNames("k-input-inner",`${l}-textarea`),rows:this.effectiveRows,style:n?{maxHeight:n}:{}},t!=="single"&&{"aria-multiline":"true"}),null),t==="auto"&&this.hasEndAffixOrButtons?s.createVNode("div",{class:`${l}-affix`,style:{display:this.hasExpanded?"none":void 0}},[d&&this.renderAffix(d,u),v()]):null,this.hasStartAffixOrEndAffixOrButtons?s.createVNode("div",{class:`${l}-affix`,style:{display:this.isMultilineLayout?void 0:"none"}},[p&&this.renderAffix(p,u),(p||d)&&s.createVNode("div",{class:"k-spacer"},null),d&&this.renderAffix(d,u),v()]):null]);return s.createVNode("div",{"aria-label":e.toLanguageString(o.promptBoxAriaLabel,o.messages[o.promptBoxAriaLabel]),class:h.classNames("k-input",l,{[`k-input-${i}`]:i,"k-disabled":r,"k-prompt-box-singleline":t==="single","k-prompt-box-multiline":this.isMultilineLayout})},[s.createVNode(D.FileBox,{files:this.currentFiles,onRemoveFile:this.handleRemoveFile,header:h.templateRendering.call(this,z,h.getListeners.call(this))},null),t==="single"?H():R(),h.shouldShowValidationUI(S.packageMetadata)&&s.createVNode(h.WatermarkOverlay,{message:h.getLicenseMessage(S.packageMetadata)},null)])}});exports.PromptBox=G;
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("vue"),h=require("@progress/kendo-vue-common"),y=require("@progress/kendo-svg-icons"),I=require("./PromptBoxActionButton.js"),j=require("./PromptBoxSpeechToTextButton.js"),_=require("./PromptBoxUploadButton.js"),D=require("./FileBox.js"),S=require("../package-metadata.js"),q=require("@progress/kendo-vue-intl"),o=require("../messages/main.js"),l="k-prompt-box",U=20,W=50,G=s.defineComponent({name:"KendoPromptBox",emits:{change:e=>!0,focus:e=>!0,blur:e=>!0,promptaction:e=>!0},props:{value:String,defaultValue:{type:String,default:""},mode:{type:String,default:"auto"},rows:{type:Number,default:1},maxTextAreaHeight:String,title:String,disabled:{type:Boolean,default:!1},readOnly:{type:Boolean,default:!1},placeholder:String,maxLength:Number,inputAttributes:Object,fillMode:String,topAffix:[Object,Function,String],startAffix:[Object,Function,String],endAffix:[Object,Function,String],header:[Object,Function,String],loading:{type:Boolean,default:!1},uploadButtonConfig:{type:[Boolean,Object],default:!1},speechToTextButtonConfig:{type:[Boolean,Object],default:!0},actionButtonConfig:{type:[Boolean,Object],default:!0},attachments:Array},inject:{kendoLocalizationService:{default:null}},created(){h.validatePackage(S.packageMetadata),this._uploadRef=s.ref(null)},data(){return{stateValue:this.$props.defaultValue||"",stateFiles:[],hasExpanded:!1,initialHeight:0,minMultiRowHeight:0,isResizing:!1,previousValueLength:0,singleLineWidth:0,resizeObserver:null,resizeTimeout:null,onRemoveAttachmentCallback:null}},computed:{isControlled(){return this.$props.value!==void 0},currentValue(){return this.isControlled?this.$props.value||"":this.stateValue},isFilesControlled(){return this.$props.attachments!==void 0},currentFiles(){return this.isFilesControlled?this.$props.attachments||[]:this.stateFiles},canSendMessage(){var e;return!!((e=this.currentValue)!=null&&e.trim()||this.currentFiles.length>0)},isMultilineLayout(){return this.$props.mode==="multi"||this.$props.mode==="auto"&&this.hasExpanded},hasBuiltInButtons(){return this.$props.uploadButtonConfig!==!1||this.$props.speechToTextButtonConfig!==!1||this.$props.actionButtonConfig!==!1},hasEndAffixOrButtons(){return!!this.$props.endAffix||this.hasBuiltInButtons},hasStartAffixOrEndAffixOrButtons(){return!!this.$props.startAffix||!!this.$props.endAffix||this.hasBuiltInButtons},effectiveRows(){return this.$props.mode==="auto"?1:this.$props.rows}},watch:{currentValue(e){if(this.$props.mode==="single")return;const t=(e==null?void 0:e.length)||0;requestAnimationFrame(()=>{const i=this.$refs.inputElement;i&&(this.$props.mode==="multi"?this.resizeMultiMode(i):this.$props.mode==="auto"&&this.resizeAutoMode(i,t),this.previousValueLength=t)})},rows(){this.$props.mode!=="single"&&(this.captureInitialDimensions(),this.resize())},maxTextAreaHeight(){this.$props.mode!=="single"&&this.resize()},mode(){this.$props.mode!=="single"&&s.nextTick(()=>{this.captureInitialDimensions(),this.resize()})},hasExpanded(e){if(this.$props.mode==="auto"&&e&&requestAnimationFrame(()=>{const t=this.$refs.inputElement;t&&(this.updateHeight(t),this.isResizing=!1)}),this.$props.mode==="auto"&&!e){const t=this.$refs.inputElement;t&&(t.style.height="",t.style.overflow="",this.isResizing=!1)}}},mounted(){this.$props.mode!=="single"&&this.captureInitialDimensions(),this.setupResizeObserver()},beforeUnmount(){this.cleanupResizeObserver()},methods:{captureInitialDimensions(){const e=this.$refs.inputElement;if(!e||this.$props.mode==="single")return;const t=globalThis.getComputedStyle(e),i=Number.parseFloat(t.lineHeight)||U,n=Number.parseFloat(t.paddingTop)||0,r=Number.parseFloat(t.paddingBottom)||0;this.initialHeight=e.offsetHeight||i+n+r,this.minMultiRowHeight=i*this.$props.rows+n+r,this.$props.mode==="auto"&&!this.hasExpanded&&(this.singleLineWidth=e.offsetWidth)},calculateHeight(e){if(this.$props.maxTextAreaHeight){const t=Number.parseInt(this.$props.maxTextAreaHeight,10);if(e>t)return t}return Math.max(this.minMultiRowHeight,e)},resizeMultiMode(e){e.style.overflow="hidden",e.style.height=`${this.initialHeight}px`;const t=e.scrollHeight,i=this.calculateHeight(t);e.style.height=`${i}px`,this.$props.maxTextAreaHeight&&t>Number.parseInt(this.$props.maxTextAreaHeight,10)&&(e.style.overflow="")},updateHeight(e){e.style.overflow="hidden",e.style.height=`${this.initialHeight}px`;const t=e.scrollHeight,i=this.$props.maxTextAreaHeight?Math.min(t,Number.parseInt(this.$props.maxTextAreaHeight,10)):t;e.style.height=`${i}px`,this.$props.maxTextAreaHeight&&t>Number.parseInt(this.$props.maxTextAreaHeight,10)&&(e.style.overflow="")},shouldCollapse(e){if(this.singleLineWidth<=0)return!1;const t=e.style.height,i=e.style.width;e.style.overflow="hidden",e.style.width=`${this.singleLineWidth}px`,e.style.height=`${this.initialHeight}px`;const n=e.scrollWidth<=this.singleLineWidth&&e.scrollHeight<=this.initialHeight;return e.style.overflow="",e.style.width=i||"",e.style.height=t||"",n},resizeAutoMode(e,t){if(this.isResizing)return;if((e.scrollWidth>e.clientWidth||e.scrollHeight>e.clientHeight)&&!this.hasExpanded){this.isResizing=!0,this.hasExpanded=!0;return}if(this.hasExpanded){this.updateHeight(e);const n=this.previousValueLength;t<n&&this.shouldCollapse(e)&&(e.style.height="",this.isResizing=!0,this.hasExpanded=!1)}},resize(){var i;if(this.$props.mode==="single")return;const e=this.$refs.inputElement;if(!e)return;const t=((i=e.value)==null?void 0:i.length)||0;this.$props.mode==="multi"?this.resizeMultiMode(e):this.$props.mode==="auto"&&this.resizeAutoMode(e,t)},setupResizeObserver(){if(this.$props.mode==="single")return;const e=this.$refs.inputElement;e&&(this.resizeObserver=new ResizeObserver(()=>{this.resizeTimeout&&clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout(()=>{this.$props.mode==="auto"&&!this.hasExpanded&&this.captureInitialDimensions(),this.resize()},W)}),this.resizeObserver.observe(e))},cleanupResizeObserver(){this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.resizeTimeout&&(clearTimeout(this.resizeTimeout),this.resizeTimeout=null)},handleChange(e){const i=e.target.value;!this.isControlled&&!this.$props.disabled&&(this.stateValue=i),this.$props.disabled||this.$emit("change",{event:e,value:i}),this.$props.mode!=="single"&&this.resize()},handleFocus(e){this.$props.disabled||this.$emit("focus",{event:e})},handleBlur(e){this.$props.disabled||this.$emit("blur",{event:e})},handleButtonMouseDown(e){e.preventDefault()},handleActionButtonClick(e){this.$emit("promptaction",{event:e,value:this.currentValue,attachments:this.currentFiles}),this.isControlled||(this.stateValue=""),this.isFilesControlled||(this.stateFiles=[])},handleKeyDown(e){if(!(e.key==="Enter"&&e.shiftKey)){if(e.key==="ArrowUp"||e.key==="ArrowDown"){e.stopPropagation();return}if(e.key==="Enter"){if(e.preventDefault(),this.$props.loading)return;this.canSendMessage&&this.handleActionButtonClick(e)}}},handleSpeechResult(e){var n;const{isFinal:t,alternatives:i}=e;if(i.length>0){const r=i[0];if(t){const a=this.$refs.inputElement,f=(a==null?void 0:a.value)||"",g=(f?`${f} `:"")+r.transcript;if(this.isControlled||(this.stateValue=g),!this.$props.disabled){const m={target:a,currentTarget:a};this.$emit("change",{event:m,value:g})}}}(n=this.$refs.inputElement)==null||n.focus()},handleUploadButtonClick(){const e=this._uploadRef.value;if(e!=null&&e.$el){const t=e.$el.querySelector('input[type="file"]');t&&t.click()}},onFilesSelect(e){var a;const t=Array.from(e.affectedFiles),i=this.$props.uploadButtonConfig,n=typeof i=="object"&&i,r=n?n.onSelectAttachments:void 0;this.isFilesControlled||(this.stateFiles=[...this.stateFiles,...t]),r&&r({selectedFiles:e.affectedFiles,allFiles:e.newState}),(a=this.$refs.inputElement)==null||a.focus()},handleRemoveFile(e){this.isFilesControlled||(this.stateFiles=this.stateFiles.filter(r=>r.name!==e));const t=this.$props.uploadButtonConfig,i=typeof t=="object"&&t,n=i?i.onRemoveAttachment:void 0;n&&(this.onRemoveAttachmentCallback=n),this.onRemoveAttachmentCallback&&this.onRemoveAttachmentCallback(e)},renderAffix(e,t){return e?typeof e=="function"?e(t):e:null}},render(){const e=q.provideLocalizationService(this),{mode:t,fillMode:i,maxTextAreaHeight:n,disabled:r,readOnly:a,placeholder:f,title:g,maxLength:m,inputAttributes:T,topAffix:C,startAffix:p,endAffix:d,header:z,loading:c,speechToTextButtonConfig:x,actionButtonConfig:B,uploadButtonConfig:$}=this.$props,u={uploadButtonProps:{fillMode:"flat",svgIcon:y.paperclipIcon,size:"small",rounded:"full",onClick:this.handleUploadButtonClick,onFilesAdd:this.onFilesSelect,files:this.currentFiles,_uploadRef:this._uploadRef,"aria-label":e.toLanguageString(o.promptBoxAttachFile,o.messages[o.promptBoxAttachFile]),title:e.toLanguageString(o.promptBoxAttachFile,o.messages[o.promptBoxAttachFile]),_registerRemoveCallback:b=>{this.onRemoveAttachmentCallback=b||null}},speechToTextButtonProps:{fillMode:"flat",size:"small",rounded:"full",onResult:this.handleSpeechResult},actionButtonProps:{rounded:"full",size:"small",svgIcon:c?y.stopIcon:y.arrowUpIcon,class:c?"k-generating k-active":"",onClick:this.handleActionButtonClick,onMousedown:this.handleButtonMouseDown,disabled:!c&&!this.canSendMessage,"aria-disabled":!c&&!this.canSendMessage?!0:void 0,"aria-label":c?e.toLanguageString(o.promptBoxStopGenerating,o.messages[o.promptBoxStopGenerating]):e.toLanguageString(o.promptBoxSendButton,o.messages[o.promptBoxSendButton]),title:c?e.toLanguageString(o.promptBoxStopGenerating,o.messages[o.promptBoxStopGenerating]):e.toLanguageString(o.promptBoxSendButton,o.messages[o.promptBoxSendButton]),"aria-live":"polite"}},v=()=>{const b=x!==!1,R=B!==!1,E=$!==!1,M=typeof x=="object"?x:void 0,L=typeof $=="object"?$:{},{restrictions:O,multiple:w=!0,accept:V,onSelectAttachments:K,onRemoveAttachment:X,...N}=L,A={restrictions:O,multiple:w,accept:V},P=typeof B=="object"?B:void 0;return s.createVNode(s.Fragment,null,[E&&s.createVNode(_.PromptBoxUploadButton,s.mergeProps({ref:"uploadButton"},u.uploadButtonProps,{restrictions:A.restrictions,multiple:A.multiple,accept:A.accept},N),null),b&&s.createVNode(j.PromptBoxSpeechToTextButton,s.mergeProps(u.speechToTextButtonProps,M),null),R&&s.createVNode(I.PromptBoxActionButton,s.mergeProps(u.actionButtonProps,P),null)])},F={disabled:r,readOnly:a,placeholder:f,title:g,maxLength:m,"aria-label":e.toLanguageString(o.promptBoxInput,o.messages[o.promptBoxInput]),value:this.currentValue,onKeydown:this.handleKeyDown,...T,onInput:this.handleChange,onFocus:this.handleFocus,onBlur:this.handleBlur,ref:"inputElement"},H=()=>s.createVNode("div",{class:`${l}-content`},[p&&s.createVNode("div",{class:`${l}-affix`},[this.renderAffix(p,u)]),s.createVNode("input",s.mergeProps(F,{class:h.classNames("k-input-inner",`${l}-input`)}),null),this.hasEndAffixOrButtons?s.createVNode("div",{class:`${l}-affix`},[d&&this.renderAffix(d,u),v()]):null]),k=()=>s.createVNode("div",{class:`${l}-content`},[t==="multi"&&C&&s.createVNode("div",{class:`${l}-affix`},[this.renderAffix(C,u)]),t==="auto"&&p&&s.createVNode("div",{class:`${l}-affix`,style:{display:this.hasExpanded?"none":void 0}},[this.renderAffix(p,u)]),s.createVNode("textarea",s.mergeProps(F,{class:h.classNames("k-input-inner",`${l}-textarea`),rows:this.effectiveRows,style:n?{maxHeight:n}:{}},t!=="single"&&{"aria-multiline":"true"}),null),t==="auto"&&this.hasEndAffixOrButtons?s.createVNode("div",{class:`${l}-affix`,style:{display:this.hasExpanded?"none":void 0}},[d&&this.renderAffix(d,u),v()]):null,this.hasStartAffixOrEndAffixOrButtons?s.createVNode("div",{class:`${l}-affix`,style:{display:this.isMultilineLayout?void 0:"none"}},[p&&this.renderAffix(p,u),(p||d)&&s.createVNode("div",{class:"k-spacer"},null),d&&this.renderAffix(d,u),v()]):null]);return s.createVNode("div",{"aria-label":e.toLanguageString(o.promptBoxAriaLabel,o.messages[o.promptBoxAriaLabel]),class:h.classNames("k-input",l,{[`k-input-${i}`]:i,"k-disabled":r,"k-prompt-box-singleline":t==="single","k-prompt-box-multiline":this.isMultilineLayout})},[s.createVNode(D.FileBox,{files:this.currentFiles,onRemoveFile:this.handleRemoveFile,header:h.templateRendering.call(this,z,h.getListeners.call(this))},null),t==="single"?H():k(),h.shouldShowValidationUI(S.packageMetadata)&&s.createVNode(h.WatermarkOverlay,{message:h.getLicenseMessage(S.packageMetadata)},null)])}});exports.PromptBox=G;
|
package/prompt-box/PromptBox.mjs
CHANGED
|
@@ -7,14 +7,14 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { defineComponent as U, createVNode as n, nextTick as K, ref as q, mergeProps as f, Fragment as G } from "vue";
|
|
9
9
|
import { classNames as S, templateRendering as X, getListeners as Z, shouldShowValidationUI as J, WatermarkOverlay as Q, getLicenseMessage as Y, validatePackage as ee } from "@progress/kendo-vue-common";
|
|
10
|
-
import { stopIcon as te, arrowUpIcon as ie,
|
|
10
|
+
import { stopIcon as te, arrowUpIcon as ie, paperclipIcon as se } from "@progress/kendo-svg-icons";
|
|
11
11
|
import { PromptBoxActionButton as ne } from "./PromptBoxActionButton.mjs";
|
|
12
12
|
import { PromptBoxSpeechToTextButton as oe } from "./PromptBoxSpeechToTextButton.mjs";
|
|
13
13
|
import { PromptBoxUploadButton as le } from "./PromptBoxUploadButton.mjs";
|
|
14
14
|
import { FileBox as re } from "./FileBox.mjs";
|
|
15
15
|
import { packageMetadata as T } from "../package-metadata.mjs";
|
|
16
16
|
import { provideLocalizationService as ae } from "@progress/kendo-vue-intl";
|
|
17
|
-
import { promptBoxStopGenerating as
|
|
17
|
+
import { promptBoxStopGenerating as g, messages as h, promptBoxSendButton as $, promptBoxAttachFile as x, promptBoxInput as R, promptBoxAriaLabel as E } from "../messages/main.mjs";
|
|
18
18
|
const l = "k-prompt-box", he = 20, ue = 50, ye = /* @__PURE__ */ U({
|
|
19
19
|
name: "KendoPromptBox",
|
|
20
20
|
emits: {
|
|
@@ -285,15 +285,15 @@ const l = "k-prompt-box", he = 20, ue = 50, ye = /* @__PURE__ */ U({
|
|
|
285
285
|
if (i.length > 0) {
|
|
286
286
|
const o = i[0];
|
|
287
287
|
if (t) {
|
|
288
|
-
const r = this.$refs.inputElement, c = (r == null ? void 0 : r.value) || "",
|
|
289
|
-
if (this.isControlled || (this.stateValue =
|
|
288
|
+
const r = this.$refs.inputElement, c = (r == null ? void 0 : r.value) || "", m = (c ? `${c} ` : "") + o.transcript;
|
|
289
|
+
if (this.isControlled || (this.stateValue = m), !this.$props.disabled) {
|
|
290
290
|
const v = {
|
|
291
291
|
target: r,
|
|
292
292
|
currentTarget: r
|
|
293
293
|
};
|
|
294
294
|
this.$emit("change", {
|
|
295
295
|
event: v,
|
|
296
|
-
value:
|
|
296
|
+
value: m
|
|
297
297
|
});
|
|
298
298
|
}
|
|
299
299
|
}
|
|
@@ -332,13 +332,13 @@ const l = "k-prompt-box", he = 20, ue = 50, ye = /* @__PURE__ */ U({
|
|
|
332
332
|
disabled: o,
|
|
333
333
|
readOnly: r,
|
|
334
334
|
placeholder: c,
|
|
335
|
-
title:
|
|
335
|
+
title: m,
|
|
336
336
|
maxLength: v,
|
|
337
|
-
inputAttributes:
|
|
337
|
+
inputAttributes: L,
|
|
338
338
|
topAffix: z,
|
|
339
339
|
startAffix: u,
|
|
340
340
|
endAffix: p,
|
|
341
|
-
header:
|
|
341
|
+
header: O,
|
|
342
342
|
loading: d,
|
|
343
343
|
speechToTextButtonConfig: B,
|
|
344
344
|
actionButtonConfig: b,
|
|
@@ -374,8 +374,8 @@ const l = "k-prompt-box", he = 20, ue = 50, ye = /* @__PURE__ */ U({
|
|
|
374
374
|
onMousedown: this.handleButtonMouseDown,
|
|
375
375
|
disabled: !d && !this.canSendMessage,
|
|
376
376
|
"aria-disabled": !d && !this.canSendMessage ? !0 : void 0,
|
|
377
|
-
"aria-label": d ? e.toLanguageString(
|
|
378
|
-
title: d ? e.toLanguageString(
|
|
377
|
+
"aria-label": d ? e.toLanguageString(g, h[g]) : e.toLanguageString($, h[$]),
|
|
378
|
+
title: d ? e.toLanguageString(g, h[g]) : e.toLanguageString($, h[$]),
|
|
379
379
|
"aria-live": "polite"
|
|
380
380
|
}
|
|
381
381
|
}, y = () => {
|
|
@@ -402,12 +402,12 @@ const l = "k-prompt-box", he = 20, ue = 50, ye = /* @__PURE__ */ U({
|
|
|
402
402
|
disabled: o,
|
|
403
403
|
readOnly: r,
|
|
404
404
|
placeholder: c,
|
|
405
|
-
title:
|
|
405
|
+
title: m,
|
|
406
406
|
maxLength: v,
|
|
407
407
|
"aria-label": e.toLanguageString(R, h[R]),
|
|
408
408
|
value: this.currentValue,
|
|
409
409
|
onKeydown: this.handleKeyDown,
|
|
410
|
-
...
|
|
410
|
+
...L,
|
|
411
411
|
onInput: this.handleChange,
|
|
412
412
|
onFocus: this.handleFocus,
|
|
413
413
|
onBlur: this.handleBlur,
|
|
@@ -461,7 +461,7 @@ const l = "k-prompt-box", he = 20, ue = 50, ye = /* @__PURE__ */ U({
|
|
|
461
461
|
}, [n(re, {
|
|
462
462
|
files: this.currentFiles,
|
|
463
463
|
onRemoveFile: this.handleRemoveFile,
|
|
464
|
-
header: X.call(this,
|
|
464
|
+
header: X.call(this, O, Z.call(this))
|
|
465
465
|
}, null), t === "single" ? k() : w(), J(T) && n(Q, {
|
|
466
466
|
message: Y(T)
|
|
467
467
|
}, null)]);
|