@progress/kendo-vue-conversational-ui 8.1.0-develop.4 → 8.1.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/dist/cdn/js/kendo-vue-conversational-ui.js +1 -1
- package/index.d.mts +6 -0
- package/index.d.ts +6 -0
- package/index.js +1 -1
- package/index.mjs +28 -20
- package/messages/main.d.ts +25 -5
- package/messages/main.js +1 -1
- package/messages/main.mjs +20 -8
- package/package-metadata.js +1 -1
- package/package-metadata.mjs +2 -2
- package/package.json +9 -7
- package/prompt-box/Events.d.ts +76 -0
- package/prompt-box/FileBox.d.ts +60 -0
- package/prompt-box/FileBox.js +8 -0
- package/prompt-box/FileBox.mjs +140 -0
- package/prompt-box/PromptBox.d.ts +180 -0
- package/prompt-box/PromptBox.js +8 -0
- package/prompt-box/PromptBox.mjs +472 -0
- package/prompt-box/PromptBoxActionButton.d.ts +20 -0
- package/prompt-box/PromptBoxActionButton.js +8 -0
- package/prompt-box/PromptBoxActionButton.mjs +19 -0
- package/prompt-box/PromptBoxSpeechToTextButton.d.ts +20 -0
- package/prompt-box/PromptBoxSpeechToTextButton.js +8 -0
- package/prompt-box/PromptBoxSpeechToTextButton.mjs +19 -0
- package/prompt-box/PromptBoxUploadButton.d.ts +95 -0
- package/prompt-box/PromptBoxUploadButton.js +8 -0
- package/prompt-box/PromptBoxUploadButton.mjs +77 -0
- package/prompt-box/interfaces/PromptBoxProps.d.ts +197 -0
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2026 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
import { defineComponent as h, h as u, createVNode as r, mergeProps as d, nextTick as a } from "vue";
|
|
9
|
+
import { Button as m } from "@progress/kendo-vue-buttons";
|
|
10
|
+
import { getTemplate as f, classNames as S, Icon as v, getFileExtensionIcon as L } from "@progress/kendo-vue-common";
|
|
11
|
+
import { xMarkSmOutlineIcon as g } from "@progress/kendo-svg-icons";
|
|
12
|
+
import { provideLocalizationService as b } from "@progress/kendo-vue-intl";
|
|
13
|
+
import { promptBoxRemoveFile as c, messages as F } from "../messages/main.mjs";
|
|
14
|
+
const k = "k-prompt-box", x = 1, z = (e) => "." + (e.split(".").pop() || ""), R = (e) => {
|
|
15
|
+
if (e == null)
|
|
16
|
+
return "";
|
|
17
|
+
if (e === 0)
|
|
18
|
+
return "0 B";
|
|
19
|
+
const t = 1024, s = ["B", "KB", "MB", "GB", "TB"], n = Math.floor(Math.log(e) / Math.log(t));
|
|
20
|
+
return `${Number.parseFloat((e / Math.pow(t, n)).toFixed(2))} ${s[n]}`;
|
|
21
|
+
}, _ = /* @__PURE__ */ h({
|
|
22
|
+
name: "KendoFileBox",
|
|
23
|
+
props: {
|
|
24
|
+
files: {
|
|
25
|
+
type: Array,
|
|
26
|
+
required: !0
|
|
27
|
+
},
|
|
28
|
+
onRemoveFile: {
|
|
29
|
+
type: Function,
|
|
30
|
+
required: !0
|
|
31
|
+
},
|
|
32
|
+
header: {
|
|
33
|
+
type: [Object, Function, String],
|
|
34
|
+
default: void 0
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
inject: {
|
|
38
|
+
kendoLocalizationService: {
|
|
39
|
+
default: null
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
data() {
|
|
43
|
+
return {
|
|
44
|
+
canScrollRight: !1,
|
|
45
|
+
canScrollLeft: !1,
|
|
46
|
+
resizeObserver: null
|
|
47
|
+
};
|
|
48
|
+
},
|
|
49
|
+
watch: {
|
|
50
|
+
files: {
|
|
51
|
+
handler() {
|
|
52
|
+
a(() => {
|
|
53
|
+
this.setupScrollListeners(), this.updateScrollState();
|
|
54
|
+
});
|
|
55
|
+
},
|
|
56
|
+
deep: !0
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
mounted() {
|
|
60
|
+
a(() => {
|
|
61
|
+
this.setupScrollListeners(), this.updateScrollState();
|
|
62
|
+
});
|
|
63
|
+
},
|
|
64
|
+
beforeUnmount() {
|
|
65
|
+
this.cleanupScrollListeners();
|
|
66
|
+
},
|
|
67
|
+
methods: {
|
|
68
|
+
setupScrollListeners() {
|
|
69
|
+
const e = this.$refs.scrollContainer;
|
|
70
|
+
if (!e) {
|
|
71
|
+
this.cleanupScrollListeners();
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
this._scrollContainer !== e && (this.cleanupScrollListeners(), e.addEventListener("scroll", this.updateScrollState, {
|
|
75
|
+
passive: !0
|
|
76
|
+
}), this.resizeObserver = new ResizeObserver(() => this.updateScrollState()), this.resizeObserver.observe(e), this._scrollContainer = e);
|
|
77
|
+
},
|
|
78
|
+
cleanupScrollListeners() {
|
|
79
|
+
this._scrollContainer && (this._scrollContainer.removeEventListener("scroll", this.updateScrollState), this._scrollContainer = null), this.resizeObserver && (this.resizeObserver.disconnect(), this.resizeObserver = null);
|
|
80
|
+
},
|
|
81
|
+
updateScrollState() {
|
|
82
|
+
const e = this.$refs.scrollContainer;
|
|
83
|
+
if (!e)
|
|
84
|
+
return;
|
|
85
|
+
const {
|
|
86
|
+
scrollLeft: t,
|
|
87
|
+
scrollWidth: s,
|
|
88
|
+
clientWidth: n
|
|
89
|
+
} = e, o = t === 0, i = t + n >= s - x;
|
|
90
|
+
this.canScrollLeft = !o, this.canScrollRight = !i;
|
|
91
|
+
},
|
|
92
|
+
handleRemoveFile(e, t) {
|
|
93
|
+
t.stopPropagation(), this.$props.onRemoveFile && this.$props.onRemoveFile(e);
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
render() {
|
|
97
|
+
const e = b(this), {
|
|
98
|
+
files: t,
|
|
99
|
+
header: s
|
|
100
|
+
} = this.$props;
|
|
101
|
+
if (t.length === 0 && !s)
|
|
102
|
+
return null;
|
|
103
|
+
const n = f.call(this, {
|
|
104
|
+
h: u,
|
|
105
|
+
template: s,
|
|
106
|
+
defaultRendering: null
|
|
107
|
+
}), o = e.toLanguageString(c, F[c]), i = t.length > 0 && r("ul", {
|
|
108
|
+
class: S("k-file-box-wrapper", {
|
|
109
|
+
"k-file-box-wrapper-scrollable-start": this.canScrollRight,
|
|
110
|
+
"k-file-box-wrapper-scrollable-end": this.canScrollLeft
|
|
111
|
+
})
|
|
112
|
+
}, [r("div", {
|
|
113
|
+
class: "k-files-scroll",
|
|
114
|
+
ref: "scrollContainer"
|
|
115
|
+
}, [t.map((l) => r("li", {
|
|
116
|
+
key: l.name,
|
|
117
|
+
class: "k-file-box"
|
|
118
|
+
}, [r(v, d({
|
|
119
|
+
size: "xlarge"
|
|
120
|
+
}, L(z(l.name))), null), r("div", {
|
|
121
|
+
class: "k-file-info"
|
|
122
|
+
}, [r("span", {
|
|
123
|
+
class: "k-file-name"
|
|
124
|
+
}, [l.name]), r("span", {
|
|
125
|
+
class: "k-file-size"
|
|
126
|
+
}, [R(l.size)])]), r(m, {
|
|
127
|
+
fillMode: "flat",
|
|
128
|
+
svgIcon: g,
|
|
129
|
+
onClick: (p) => this.handleRemoveFile(l.name, p),
|
|
130
|
+
"aria-label": `${o} ${l.name}`,
|
|
131
|
+
title: `${o} ${l.name}`
|
|
132
|
+
}, null)]))])]);
|
|
133
|
+
return r("div", {
|
|
134
|
+
class: `${k}-header`
|
|
135
|
+
}, [n, i]);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
export {
|
|
139
|
+
_ as FileBox
|
|
140
|
+
};
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2026 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
import { PropType } from 'vue';
|
|
9
|
+
import { AffixTemplateProps, UploadButtonProps } from './interfaces/PromptBoxProps';
|
|
10
|
+
import { PromptBoxBlurEvent, PromptBoxChangeEvent, PromptBoxFocusEvent, PromptBoxPromptActionEvent } from './Events';
|
|
11
|
+
import { UploadFileInfo, UploadOnAddEvent } from '@progress/kendo-vue-upload';
|
|
12
|
+
import { SpeechToTextResultEvent } from '@progress/kendo-vue-buttons';
|
|
13
|
+
/**
|
|
14
|
+
* Represents the PromptBox component.
|
|
15
|
+
*/
|
|
16
|
+
declare const PromptBox: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
17
|
+
value: PropType<string>;
|
|
18
|
+
defaultValue: {
|
|
19
|
+
type: PropType<string>;
|
|
20
|
+
default: string;
|
|
21
|
+
};
|
|
22
|
+
mode: {
|
|
23
|
+
type: PropType<import('./interfaces/PromptBoxProps').PromptBoxMode>;
|
|
24
|
+
default: string;
|
|
25
|
+
};
|
|
26
|
+
rows: {
|
|
27
|
+
type: PropType<number>;
|
|
28
|
+
default: number;
|
|
29
|
+
};
|
|
30
|
+
maxTextAreaHeight: PropType<string>;
|
|
31
|
+
title: PropType<string>;
|
|
32
|
+
disabled: {
|
|
33
|
+
type: PropType<boolean>;
|
|
34
|
+
default: boolean;
|
|
35
|
+
};
|
|
36
|
+
readOnly: {
|
|
37
|
+
type: PropType<boolean>;
|
|
38
|
+
default: boolean;
|
|
39
|
+
};
|
|
40
|
+
placeholder: PropType<string>;
|
|
41
|
+
maxLength: PropType<number>;
|
|
42
|
+
inputAttributes: PropType<Record<string, any>>;
|
|
43
|
+
fillMode: PropType<"flat" | "solid" | "outline">;
|
|
44
|
+
topAffix: PropType<any>;
|
|
45
|
+
startAffix: PropType<any>;
|
|
46
|
+
endAffix: PropType<any>;
|
|
47
|
+
header: PropType<any>;
|
|
48
|
+
loading: {
|
|
49
|
+
type: PropType<boolean>;
|
|
50
|
+
default: boolean;
|
|
51
|
+
};
|
|
52
|
+
uploadButtonConfig: {
|
|
53
|
+
type: PropType<boolean | UploadButtonProps>;
|
|
54
|
+
default: boolean;
|
|
55
|
+
};
|
|
56
|
+
speechToTextButtonConfig: {
|
|
57
|
+
type: PropType<boolean | import('@progress/kendo-vue-buttons').SpeechToTextButtonProps>;
|
|
58
|
+
default: boolean;
|
|
59
|
+
};
|
|
60
|
+
actionButtonConfig: {
|
|
61
|
+
type: PropType<boolean | import('@progress/kendo-vue-buttons').ButtonProps>;
|
|
62
|
+
default: boolean;
|
|
63
|
+
};
|
|
64
|
+
attachments: PropType<UploadFileInfo[]>;
|
|
65
|
+
}>, {}, {
|
|
66
|
+
stateValue: string;
|
|
67
|
+
stateFiles: UploadFileInfo[];
|
|
68
|
+
hasExpanded: boolean;
|
|
69
|
+
initialHeight: number;
|
|
70
|
+
minMultiRowHeight: number;
|
|
71
|
+
isResizing: boolean;
|
|
72
|
+
previousValueLength: number;
|
|
73
|
+
singleLineWidth: number;
|
|
74
|
+
resizeObserver: ResizeObserver;
|
|
75
|
+
resizeTimeout: NodeJS.Timeout;
|
|
76
|
+
onRemoveAttachmentCallback: (fileName: string) => void;
|
|
77
|
+
}, {
|
|
78
|
+
isControlled(): boolean;
|
|
79
|
+
currentValue(): string;
|
|
80
|
+
isFilesControlled(): boolean;
|
|
81
|
+
currentFiles(): UploadFileInfo[];
|
|
82
|
+
canSendMessage(): boolean;
|
|
83
|
+
isMultilineLayout(): boolean;
|
|
84
|
+
hasBuiltInButtons(): boolean;
|
|
85
|
+
hasEndAffixOrButtons(): boolean;
|
|
86
|
+
hasStartAffixOrEndAffixOrButtons(): boolean;
|
|
87
|
+
effectiveRows(): number;
|
|
88
|
+
}, {
|
|
89
|
+
captureInitialDimensions(): void;
|
|
90
|
+
calculateHeight(scrollHeight: number): number;
|
|
91
|
+
resizeMultiMode(textarea: HTMLTextAreaElement): void;
|
|
92
|
+
updateHeight(textarea: HTMLTextAreaElement): void;
|
|
93
|
+
shouldCollapse(textarea: HTMLTextAreaElement): boolean;
|
|
94
|
+
resizeAutoMode(textarea: HTMLTextAreaElement, valueLength: number): void;
|
|
95
|
+
resize(): void;
|
|
96
|
+
setupResizeObserver(): void;
|
|
97
|
+
cleanupResizeObserver(): void;
|
|
98
|
+
handleChange(event: Event): void;
|
|
99
|
+
handleFocus(event: FocusEvent): void;
|
|
100
|
+
handleBlur(event: FocusEvent): void;
|
|
101
|
+
handleButtonMouseDown(event: MouseEvent): void;
|
|
102
|
+
handleActionButtonClick(event: Event): void;
|
|
103
|
+
handleKeyDown(event: KeyboardEvent): void;
|
|
104
|
+
handleSpeechResult(event: SpeechToTextResultEvent): void;
|
|
105
|
+
handleUploadButtonClick(): void;
|
|
106
|
+
onFilesSelect(event: UploadOnAddEvent): void;
|
|
107
|
+
handleRemoveFile(fileName: string): void;
|
|
108
|
+
renderAffix(affix: any, affixProps: AffixTemplateProps): any;
|
|
109
|
+
}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
110
|
+
change: (_event: PromptBoxChangeEvent) => true;
|
|
111
|
+
focus: (_event: PromptBoxFocusEvent) => true;
|
|
112
|
+
blur: (_event: PromptBoxBlurEvent) => true;
|
|
113
|
+
promptaction: (_event: PromptBoxPromptActionEvent) => true;
|
|
114
|
+
}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
115
|
+
value: PropType<string>;
|
|
116
|
+
defaultValue: {
|
|
117
|
+
type: PropType<string>;
|
|
118
|
+
default: string;
|
|
119
|
+
};
|
|
120
|
+
mode: {
|
|
121
|
+
type: PropType<import('./interfaces/PromptBoxProps').PromptBoxMode>;
|
|
122
|
+
default: string;
|
|
123
|
+
};
|
|
124
|
+
rows: {
|
|
125
|
+
type: PropType<number>;
|
|
126
|
+
default: number;
|
|
127
|
+
};
|
|
128
|
+
maxTextAreaHeight: PropType<string>;
|
|
129
|
+
title: PropType<string>;
|
|
130
|
+
disabled: {
|
|
131
|
+
type: PropType<boolean>;
|
|
132
|
+
default: boolean;
|
|
133
|
+
};
|
|
134
|
+
readOnly: {
|
|
135
|
+
type: PropType<boolean>;
|
|
136
|
+
default: boolean;
|
|
137
|
+
};
|
|
138
|
+
placeholder: PropType<string>;
|
|
139
|
+
maxLength: PropType<number>;
|
|
140
|
+
inputAttributes: PropType<Record<string, any>>;
|
|
141
|
+
fillMode: PropType<"flat" | "solid" | "outline">;
|
|
142
|
+
topAffix: PropType<any>;
|
|
143
|
+
startAffix: PropType<any>;
|
|
144
|
+
endAffix: PropType<any>;
|
|
145
|
+
header: PropType<any>;
|
|
146
|
+
loading: {
|
|
147
|
+
type: PropType<boolean>;
|
|
148
|
+
default: boolean;
|
|
149
|
+
};
|
|
150
|
+
uploadButtonConfig: {
|
|
151
|
+
type: PropType<boolean | UploadButtonProps>;
|
|
152
|
+
default: boolean;
|
|
153
|
+
};
|
|
154
|
+
speechToTextButtonConfig: {
|
|
155
|
+
type: PropType<boolean | import('@progress/kendo-vue-buttons').SpeechToTextButtonProps>;
|
|
156
|
+
default: boolean;
|
|
157
|
+
};
|
|
158
|
+
actionButtonConfig: {
|
|
159
|
+
type: PropType<boolean | import('@progress/kendo-vue-buttons').ButtonProps>;
|
|
160
|
+
default: boolean;
|
|
161
|
+
};
|
|
162
|
+
attachments: PropType<UploadFileInfo[]>;
|
|
163
|
+
}>> & Readonly<{
|
|
164
|
+
onBlur?: (_event: PromptBoxBlurEvent) => any;
|
|
165
|
+
onChange?: (_event: PromptBoxChangeEvent) => any;
|
|
166
|
+
onFocus?: (_event: PromptBoxFocusEvent) => any;
|
|
167
|
+
onPromptaction?: (_event: PromptBoxPromptActionEvent) => any;
|
|
168
|
+
}>, {
|
|
169
|
+
disabled: boolean;
|
|
170
|
+
loading: boolean;
|
|
171
|
+
defaultValue: string;
|
|
172
|
+
mode: import('./interfaces/PromptBoxProps').PromptBoxMode;
|
|
173
|
+
rows: number;
|
|
174
|
+
readOnly: boolean;
|
|
175
|
+
uploadButtonConfig: boolean;
|
|
176
|
+
speechToTextButtonConfig: boolean | import('@progress/kendo-vue-buttons').SpeechToTextButtonProps;
|
|
177
|
+
actionButtonConfig: boolean;
|
|
178
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
179
|
+
export { PromptBox };
|
|
180
|
+
export type { PromptBoxProps } from './interfaces/PromptBoxProps';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2026 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const 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.stopSmIcon:y.arrowUpOutlineIcon,class:c?"k-generating":"",onClick:this.handleActionButtonClick,onMousedown:this.handleButtonMouseDown,disabled:!c&&!this.canSendMessage,"aria-disabled":!c&&!this.canSendMessage,"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}:{}},this.isMultilineLayout&&{"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;
|