@progress/kendo-react-conversational-ui 14.5.0-develop.8 → 14.5.0-develop.9
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 +5 -5
- package/ai-prompt/views/AIPromptOutputView.js +1 -1
- package/ai-prompt/views/AIPromptOutputView.mjs +6 -6
- package/chat/components/Chat.js +1 -1
- package/chat/components/Chat.mjs +17 -17
- package/chat/components/ChatMessage.js +1 -1
- package/chat/components/ChatMessage.mjs +56 -55
- package/chat/components/Header.js +1 -1
- package/chat/components/Header.mjs +1 -1
- package/chat/components/NewMessage.js +1 -1
- package/chat/components/NewMessage.mjs +49 -48
- package/chat/components/Notification.js +1 -1
- package/chat/components/Notification.mjs +1 -1
- package/chat/components/elements/FileBox.js +1 -1
- package/chat/components/elements/FileBox.mjs +10 -9
- package/chat/components/elements/PinnedMessage.js +1 -1
- package/chat/components/elements/PinnedMessage.mjs +14 -13
- package/dist/cdn/js/kendo-react-conversational-ui.js +1 -1
- package/inline-ai-prompt/InlineAIPrompt.js +1 -1
- package/inline-ai-prompt/InlineAIPrompt.mjs +10 -10
- package/inline-ai-prompt/InlineAIPromptInput.js +1 -1
- package/inline-ai-prompt/InlineAIPromptInput.mjs +1 -1
- package/package-metadata.js +1 -1
- package/package-metadata.mjs +2 -2
- package/package.json +17 -12
- package/prompt-box/FileBox.js +1 -1
- package/prompt-box/FileBox.mjs +21 -20
- package/prompt-box/PromptBox.js +1 -1
- package/prompt-box/PromptBox.mjs +30 -30
|
@@ -9,10 +9,10 @@ import * as t from "react";
|
|
|
9
9
|
import { Card as se, CardBody as re, CardActions as le, ContextMenu as ce } from "@progress/kendo-react-layout";
|
|
10
10
|
import { Button as E } from "@progress/kendo-react-buttons";
|
|
11
11
|
import { TextArea as me } from "@progress/kendo-react-inputs";
|
|
12
|
-
import { copyIcon as ie,
|
|
13
|
-
import { validatePackage as fe, getLicenseMessage as Ce, classNames as he, WatermarkOverlay as
|
|
12
|
+
import { copyIcon as ie, cancelIcon as de, checkIcon as pe } from "@progress/kendo-svg-icons";
|
|
13
|
+
import { validatePackage as fe, getLicenseMessage as Ce, classNames as he, WatermarkOverlay as ge } from "@progress/kendo-react-common";
|
|
14
14
|
import { packageMetadata as x } from "../package-metadata.mjs";
|
|
15
|
-
import { InlineAIPromptPopup as
|
|
15
|
+
import { InlineAIPromptPopup as ue } from "./InlineAIPromptPopup.mjs";
|
|
16
16
|
import { InlineAIPromptInput as ke } from "./InlineAIPromptInput.mjs";
|
|
17
17
|
import { AIPromptContent as ye } from "../ai-prompt/AIPromptContent.mjs";
|
|
18
18
|
const Te = (v) => {
|
|
@@ -39,8 +39,8 @@ const Te = (v) => {
|
|
|
39
39
|
onClose: m,
|
|
40
40
|
animate: K = !0,
|
|
41
41
|
appendTo: W,
|
|
42
|
-
commands:
|
|
43
|
-
onCommandExecute:
|
|
42
|
+
commands: g,
|
|
43
|
+
onCommandExecute: u,
|
|
44
44
|
style: $,
|
|
45
45
|
className: q,
|
|
46
46
|
popupOptions: z = {},
|
|
@@ -90,7 +90,7 @@ const Te = (v) => {
|
|
|
90
90
|
}, Z = () => {
|
|
91
91
|
C(!1);
|
|
92
92
|
}, L = (e) => {
|
|
93
|
-
C(!1),
|
|
93
|
+
C(!1), u && u(e);
|
|
94
94
|
}, ee = (e) => e == null ? void 0 : e.map((n) => ({
|
|
95
95
|
text: n.text,
|
|
96
96
|
svgIcon: n.svgIcon,
|
|
@@ -149,12 +149,12 @@ const Te = (v) => {
|
|
|
149
149
|
generateButton: P,
|
|
150
150
|
enableSpeechToText: D,
|
|
151
151
|
streaming: s,
|
|
152
|
-
commands:
|
|
152
|
+
commands: g
|
|
153
153
|
}
|
|
154
154
|
))
|
|
155
|
-
), M && /* @__PURE__ */ t.createElement(
|
|
155
|
+
), M && /* @__PURE__ */ t.createElement(ge, { message: b }));
|
|
156
156
|
return /* @__PURE__ */ t.createElement(t.Fragment, null, /* @__PURE__ */ t.createElement(
|
|
157
|
-
|
|
157
|
+
ue,
|
|
158
158
|
{
|
|
159
159
|
show: N,
|
|
160
160
|
anchor: R,
|
|
@@ -172,7 +172,7 @@ const Te = (v) => {
|
|
|
172
172
|
show: j,
|
|
173
173
|
offset: G,
|
|
174
174
|
onClose: Z,
|
|
175
|
-
items: ee(
|
|
175
|
+
items: ee(g),
|
|
176
176
|
onSelect: (e) => {
|
|
177
177
|
var a, o;
|
|
178
178
|
const n = (a = e.item) == null ? void 0 : a.data;
|
|
@@ -5,5 +5,5 @@
|
|
|
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 q=require("react"),y=require("@progress/kendo-react-buttons"),s=require("@progress/kendo-react-inputs"),f=require("@progress/kendo-svg-icons"),d=require("@progress/kendo-react-common");function V(t){const c=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const a in t)if(a!=="default"){const l=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(c,a,l.get?l:{enumerable:!0,get:()=>t[a]})}}return c.default=t,Object.freeze(c)}const e=V(q),G=({placeholder:t="Ask or generate content with AI...",promptValue:c,onMenuClick:a,promptInput:l=s.TextArea,generateButton:B,enableSpeechToText:u=!1,streaming:n=!1,commands:p,onPromptRequest:g,onPromptCancel:h})=>{const[r,k]=e.useState(c||""),[x,I]=d.useCustomComponent(B),[P,S]=d.useCustomComponent(l),E=l===s.TextArea||P===s.TextArea,j={svgIcon:n?f.
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("react"),y=require("@progress/kendo-react-buttons"),s=require("@progress/kendo-react-inputs"),f=require("@progress/kendo-svg-icons"),d=require("@progress/kendo-react-common");function V(t){const c=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const a in t)if(a!=="default"){const l=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(c,a,l.get?l:{enumerable:!0,get:()=>t[a]})}}return c.default=t,Object.freeze(c)}const e=V(q),G=({placeholder:t="Ask or generate content with AI...",promptValue:c,onMenuClick:a,promptInput:l=s.TextArea,generateButton:B,enableSpeechToText:u=!1,streaming:n=!1,commands:p,onPromptRequest:g,onPromptCancel:h})=>{const[r,k]=e.useState(c||""),[x,I]=d.useCustomComponent(B),[P,S]=d.useCustomComponent(l),E=l===s.TextArea||P===s.TextArea,j={svgIcon:n?f.stopIcon:f.paperPlaneIcon,active:(!!n).toString(),title:"Send Button","aria-label":"Send Button",disabled:!r.trim()&&!n,"aria-disabled":!r.trim()&&!n},O={placeholder:t,className:"!k-flex-row",...E?{autoSize:!0}:{},rows:1},b=p&&p.length>0,w=Object.keys(I).length>0?I:j,R=Object.keys(S).length>0?S:O,v=o=>{const{isFinal:m,alternatives:C}=o;if(m&&C.length>0){const D=C[0].transcript,M=(()=>{const i=r,T=i&&!i.endsWith(" ")&&!i.endsWith(`
|
|
9
9
|
`);return i+(T?" ":"")+D})();k(M)}},N=o=>{const m=o.target.value;k(m)},A=()=>{r.trim()&&g&&g(r.trim())};return e.createElement(P,{value:r,onChange:N,onKeyDown:o=>{o.key==="Enter"&&!o.shiftKey&&(o.preventDefault(),A())},prefix:b||u?e.createElement(e.Fragment,null,e.createElement(s.InputPrefix,{className:"!k-align-items-start"},b&&e.createElement(y.Button,{"aria-label":"Commands Button",title:"Commands Button",fillMode:"flat",svgIcon:f.menuIcon,onClick:a}),u&&e.createElement(y.SpeechToTextButton,{fillMode:"flat",...typeof u=="object"?{...u,onResult:u.onResult||v}:{onResult:v}})),e.createElement(s.InputSeparator,null)):void 0,suffix:e.createElement(s.InputSuffix,{className:"!k-align-items-start"},e.createElement(x,{className:d.classNames("k-prompt-send",{"k-generating":n,"k-active":n}),fillMode:"flat",onClick:n?h:A,...w})),...R})};exports.InlineAIPromptInput=G;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import * as t from "react";
|
|
9
9
|
import { Button as M, SpeechToTextButton as R } from "@progress/kendo-react-buttons";
|
|
10
10
|
import { TextArea as l, InputSuffix as F, InputPrefix as K, InputSeparator as O } from "@progress/kendo-react-inputs";
|
|
11
|
-
import {
|
|
11
|
+
import { stopIcon as W, paperPlaneIcon as z, menuIcon as T } from "@progress/kendo-svg-icons";
|
|
12
12
|
import { useCustomComponent as B, classNames as $ } from "@progress/kendo-react-common";
|
|
13
13
|
const U = ({
|
|
14
14
|
placeholder: P = "Ask or generate content with AI...",
|
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=Object.freeze({name:"@progress/kendo-react-conversational-ui",productName:"KendoReact",productCode:"KENDOUIREACT",productCodes:["KENDOUIREACT"],publishDate:
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=Object.freeze({name:"@progress/kendo-react-conversational-ui",productName:"KendoReact",productCode:"KENDOUIREACT",productCodes:["KENDOUIREACT"],publishDate: 1778599524,version:"14.5.0-develop.9",licensingDocsUrl:"https://www.telerik.com/kendo-react-ui/components/my-license/?utm_medium=product&utm_source=kendoreact&utm_campaign=kendo-ui-react-purchase-license-keys-warning"});exports.packageMetadata=e;
|
package/package-metadata.mjs
CHANGED
|
@@ -7,8 +7,8 @@ export const packageMetadata = Object.freeze({
|
|
|
7
7
|
productName: 'KendoReact',
|
|
8
8
|
productCode: 'KENDOUIREACT',
|
|
9
9
|
productCodes: ['KENDOUIREACT'],
|
|
10
|
-
publishDate:
|
|
11
|
-
version: '14.5.0-develop.
|
|
10
|
+
publishDate: 1778599524,
|
|
11
|
+
version: '14.5.0-develop.9',
|
|
12
12
|
licensingDocsUrl:
|
|
13
13
|
'https://www.telerik.com/kendo-react-ui/components/my-license/?utm_medium=product&utm_source=kendoreact&utm_campaign=kendo-ui-react-purchase-license-keys-warning'
|
|
14
14
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@progress/kendo-react-conversational-ui",
|
|
3
|
-
"version": "14.5.0-develop.
|
|
3
|
+
"version": "14.5.0-develop.9",
|
|
4
4
|
"description": "React Chat component allows the user to participate in chat sessions with users or chat bots. KendoReact Conversational UI components",
|
|
5
5
|
"author": "Progress",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
@@ -26,16 +26,16 @@
|
|
|
26
26
|
"sideEffects": false,
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"@progress/kendo-licensing": "^1.7.2",
|
|
29
|
-
"@progress/kendo-react-animation": "14.5.0-develop.
|
|
30
|
-
"@progress/kendo-react-buttons": "14.5.0-develop.
|
|
31
|
-
"@progress/kendo-react-common": "14.5.0-develop.
|
|
32
|
-
"@progress/kendo-react-intl": "14.5.0-develop.
|
|
33
|
-
"@progress/kendo-react-inputs": "14.5.0-develop.
|
|
34
|
-
"@progress/kendo-react-layout": "14.5.0-develop.
|
|
35
|
-
"@progress/kendo-react-notification": "14.5.0-develop.
|
|
36
|
-
"@progress/kendo-react-popup": "14.5.0-develop.
|
|
37
|
-
"@progress/kendo-react-upload": "14.5.0-develop.
|
|
38
|
-
"@progress/kendo-svg-icons": "^4.0.0",
|
|
29
|
+
"@progress/kendo-react-animation": "14.5.0-develop.9",
|
|
30
|
+
"@progress/kendo-react-buttons": "14.5.0-develop.9",
|
|
31
|
+
"@progress/kendo-react-common": "14.5.0-develop.9",
|
|
32
|
+
"@progress/kendo-react-intl": "14.5.0-develop.9",
|
|
33
|
+
"@progress/kendo-react-inputs": "14.5.0-develop.9",
|
|
34
|
+
"@progress/kendo-react-layout": "14.5.0-develop.9",
|
|
35
|
+
"@progress/kendo-react-notification": "14.5.0-develop.9",
|
|
36
|
+
"@progress/kendo-react-popup": "14.5.0-develop.9",
|
|
37
|
+
"@progress/kendo-react-upload": "14.5.0-develop.9",
|
|
38
|
+
"@progress/kendo-svg-icons": "^4.9.0 || ^5.0.0",
|
|
39
39
|
"react": "^18.0.0 || ^19.0.0",
|
|
40
40
|
"react-dom": "^18.0.0 || ^19.0.0"
|
|
41
41
|
},
|
|
@@ -120,7 +120,7 @@
|
|
|
120
120
|
"package": {
|
|
121
121
|
"productName": "KendoReact",
|
|
122
122
|
"productCode": "KENDOUIREACT",
|
|
123
|
-
"publishDate":
|
|
123
|
+
"publishDate": 1778599524,
|
|
124
124
|
"licensingDocsUrl": "https://www.telerik.com/kendo-react-ui/components/my-license/?utm_medium=product&utm_source=kendoreact&utm_campaign=kendo-ui-react-purchase-license-keys-warning"
|
|
125
125
|
}
|
|
126
126
|
},
|
|
@@ -130,5 +130,10 @@
|
|
|
130
130
|
},
|
|
131
131
|
"publishConfig": {
|
|
132
132
|
"access": "public"
|
|
133
|
+
},
|
|
134
|
+
"peerDependenciesMeta": {
|
|
135
|
+
"@progress/kendo-svg-icons": {
|
|
136
|
+
"optional": true
|
|
137
|
+
}
|
|
133
138
|
}
|
|
134
139
|
}
|
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 R=require("react"),b=require("@progress/kendo-react-buttons"),m=require("@progress/kendo-react-common"),B=require("@progress/kendo-svg-icons"),L=require("@progress/kendo-react-intl"),
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const R=require("react"),b=require("@progress/kendo-react-buttons"),m=require("@progress/kendo-react-common"),B=require("@progress/kendo-svg-icons"),L=require("@progress/kendo-react-intl"),a=require("../messages/index.js");function F(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const o in e)if(o!=="default"){const l=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(r,o,l.get?l:{enumerable:!0,get:()=>e[o]})}}return r.default=e,Object.freeze(r)}const n=F(R),O="k-prompt-box",z=1,N=e=>"."+e.split(".").pop()||"",C=e=>{if(e==null)return"";if(e===0)return"0 B";const r=1024,o=["B","KB","MB","GB","TB"],l=Math.floor(Math.log(e)/Math.log(r));return`${parseFloat((e/Math.pow(r,l)).toFixed(2))} ${o[l]}`},M=e=>e?typeof e=="function"?e():e:null,h=({files:e,onRemoveFile:r,header:o})=>{const l=L.useLocalization(),u=n.useRef(null),[p,f]=n.useState(!1),[d,g]=n.useState(!1),c=n.useCallback(()=>{const t=u.current;if(!t)return;const{scrollLeft:s,scrollWidth:i,clientWidth:E}=t,k=s===0,x=s+E>=i-z;g(!k),f(!x)},[]);if(n.useLayoutEffect(()=>{c()},[e,c]),n.useEffect(()=>{const t=u.current;if(!t)return;const s=()=>c(),i=new ResizeObserver(c);return i.observe(t),t.addEventListener("scroll",s,{passive:!0}),()=>{t.removeEventListener("scroll",s),i.disconnect()}},[c,e.length]),e.length===0&&!o)return null;const S=M(o),v=e.length>0&&n.createElement("ul",{className:m.classNames("k-file-box-wrapper",{"k-file-box-wrapper-scrollable-start":p,"k-file-box-wrapper-scrollable-end":d})},n.createElement("div",{className:"k-files-scroll",ref:u},e.map(t=>n.createElement("li",{key:t.name,className:"k-file-box"},n.createElement(m.IconWrap,{size:"xlarge",...m.getFileExtensionIcon(N(t.name))}),n.createElement("div",{className:"k-file-info"},n.createElement("span",{className:"k-file-name"},t.name),n.createElement("span",{className:"k-file-size"},C(t.size))),n.createElement(b.Button,{fillMode:"flat",size:"xs",svgIcon:B.xCircleIcon,onClick:s=>{s.stopPropagation(),r(t.name)},"aria-label":`${l.toLanguageString(a.promptBoxRemoveFile,a.messages[a.promptBoxRemoveFile])} ${t.name}`,title:`${l.toLanguageString(a.promptBoxRemoveFile,a.messages[a.promptBoxRemoveFile])} ${t.name}`})))));return n.createElement("div",{className:`${O}-header`},S,v)};exports.FileBox=h;
|
package/prompt-box/FileBox.mjs
CHANGED
|
@@ -7,52 +7,53 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import * as n from "react";
|
|
9
9
|
import { Button as L } from "@progress/kendo-react-buttons";
|
|
10
|
-
import { classNames as
|
|
11
|
-
import {
|
|
12
|
-
import { useLocalization as
|
|
10
|
+
import { classNames as z, IconWrap as B, getFileExtensionIcon as N } from "@progress/kendo-react-common";
|
|
11
|
+
import { xCircleIcon as R } from "@progress/kendo-svg-icons";
|
|
12
|
+
import { useLocalization as h } from "@progress/kendo-react-intl";
|
|
13
13
|
import { promptBoxRemoveFile as i, messages as u } from "../messages/index.mjs";
|
|
14
|
-
const
|
|
14
|
+
const C = "k-prompt-box", b = 1, F = (e) => "." + e.split(".").pop() || "", M = (e) => {
|
|
15
15
|
if (e == null)
|
|
16
16
|
return "";
|
|
17
17
|
if (e === 0)
|
|
18
18
|
return "0 B";
|
|
19
|
-
const
|
|
20
|
-
return `${parseFloat((e / Math.pow(
|
|
21
|
-
},
|
|
22
|
-
const o =
|
|
19
|
+
const a = 1024, s = ["B", "KB", "MB", "GB", "TB"], o = Math.floor(Math.log(e) / Math.log(a));
|
|
20
|
+
return `${parseFloat((e / Math.pow(a, o)).toFixed(2))} ${s[o]}`;
|
|
21
|
+
}, $ = (e) => e ? typeof e == "function" ? e() : e : null, T = ({ files: e, onRemoveFile: a, header: s }) => {
|
|
22
|
+
const o = h(), m = n.useRef(null), [p, f] = n.useState(!1), [d, g] = n.useState(!1), l = n.useCallback(() => {
|
|
23
23
|
const t = m.current;
|
|
24
24
|
if (!t)
|
|
25
25
|
return;
|
|
26
|
-
const { scrollLeft: r, scrollWidth: c, clientWidth:
|
|
27
|
-
g(!
|
|
26
|
+
const { scrollLeft: r, scrollWidth: c, clientWidth: v } = t, x = r === 0, k = r + v >= c - b;
|
|
27
|
+
g(!x), f(!k);
|
|
28
28
|
}, []);
|
|
29
29
|
if (n.useLayoutEffect(() => {
|
|
30
|
-
|
|
31
|
-
}, [e,
|
|
30
|
+
l();
|
|
31
|
+
}, [e, l]), n.useEffect(() => {
|
|
32
32
|
const t = m.current;
|
|
33
33
|
if (!t)
|
|
34
34
|
return;
|
|
35
|
-
const r = () =>
|
|
35
|
+
const r = () => l(), c = new ResizeObserver(l);
|
|
36
36
|
return c.observe(t), t.addEventListener("scroll", r, { passive: !0 }), () => {
|
|
37
37
|
t.removeEventListener("scroll", r), c.disconnect();
|
|
38
38
|
};
|
|
39
|
-
}, [
|
|
39
|
+
}, [l, e.length]), e.length === 0 && !s)
|
|
40
40
|
return null;
|
|
41
|
-
const E =
|
|
41
|
+
const E = $(s), S = e.length > 0 && /* @__PURE__ */ n.createElement(
|
|
42
42
|
"ul",
|
|
43
43
|
{
|
|
44
|
-
className:
|
|
44
|
+
className: z("k-file-box-wrapper", {
|
|
45
45
|
"k-file-box-wrapper-scrollable-start": p,
|
|
46
46
|
"k-file-box-wrapper-scrollable-end": d
|
|
47
47
|
})
|
|
48
48
|
},
|
|
49
|
-
/* @__PURE__ */ n.createElement("div", { className: "k-files-scroll", ref: m }, e.map((t) => /* @__PURE__ */ n.createElement("li", { key: t.name, className: "k-file-box" }, /* @__PURE__ */ n.createElement(
|
|
49
|
+
/* @__PURE__ */ n.createElement("div", { className: "k-files-scroll", ref: m }, e.map((t) => /* @__PURE__ */ n.createElement("li", { key: t.name, className: "k-file-box" }, /* @__PURE__ */ n.createElement(B, { size: "xlarge", ...N(F(t.name)) }), /* @__PURE__ */ n.createElement("div", { className: "k-file-info" }, /* @__PURE__ */ n.createElement("span", { className: "k-file-name" }, t.name), /* @__PURE__ */ n.createElement("span", { className: "k-file-size" }, M(t.size))), /* @__PURE__ */ n.createElement(
|
|
50
50
|
L,
|
|
51
51
|
{
|
|
52
52
|
fillMode: "flat",
|
|
53
|
-
|
|
53
|
+
size: "xs",
|
|
54
|
+
svgIcon: R,
|
|
54
55
|
onClick: (r) => {
|
|
55
|
-
r.stopPropagation(),
|
|
56
|
+
r.stopPropagation(), a(t.name);
|
|
56
57
|
},
|
|
57
58
|
"aria-label": `${o.toLanguageString(
|
|
58
59
|
i,
|
|
@@ -65,7 +66,7 @@ const M = "k-prompt-box", b = 1, C = (e) => "." + e.split(".").pop() || "", F =
|
|
|
65
66
|
}
|
|
66
67
|
))))
|
|
67
68
|
);
|
|
68
|
-
return /* @__PURE__ */ n.createElement("div", { className: `${
|
|
69
|
+
return /* @__PURE__ */ n.createElement("div", { className: `${C}-header` }, E, S);
|
|
69
70
|
};
|
|
70
71
|
export {
|
|
71
72
|
T as FileBox
|
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 Ge=require("react"),o=require("prop-types"),d=require("@progress/kendo-react-common"),se=require("@progress/kendo-svg-icons"),Ke=require("./PromptBoxActionButton.js"),Xe=require("./PromptBoxSpeechToTextButton.js"),Ze=require("./PromptBoxUploadButton.js"),Je=require("./FileBox.js"),Ee=require("../package-metadata.js"),Qe=require("@progress/kendo-react-intl"),a=require("../messages/index.js");function Ye(E){const N=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(E){for(const F in E)if(F!=="default"){const j=Object.getOwnPropertyDescriptor(E,F);Object.defineProperty(N,F,j.get?j:{enumerable:!0,get:()=>E[F]})}}return N.default=E,Object.freeze(N)}const t=Ye(Ge),g="k-prompt-box",et=20,tt=50,y={mode:"auto",rows:1,defaultValue:"",disabled:!1,readOnly:!1,loading:!1,uploadButtonConfig:!1,speechToTextButtonConfig:!0,actionButtonConfig:!0},re=t.forwardRef((E,N)=>{const F=!d.validatePackage(Ee.packageMetadata,{component:"PromptBox"}),j=d.getLicenseMessage(Ee.packageMetadata),v=Qe.useLocalization(),Se={...y,...E},{mode:s=y.mode,fillMode:le,rows:M=y.rows,maxTextAreaHeight:u,value:ae,defaultValue:Te=y.defaultValue,disabled:p=y.disabled,readOnly:Ae=y.readOnly,placeholder:Re,title:Fe,maxLength:we,inputAttributes:Pe,topAffix:ie,startAffix:k,endAffix:x,header:Oe,onChange:w,onFocus:Z,onBlur:J,onPromptAction:Q,attachments:ce,loading:C=y.loading,uploadButtonConfig:h=y.uploadButtonConfig,speechToTextButtonConfig:z=y.speechToTextButtonConfig,actionButtonConfig:q=y.actionButtonConfig,className:Ne,style:Me,...He}=Se,r=t.useRef(null),[Le,_]=t.useState(Te),[Ie,Y]=t.useState([]),[c,ue]=t.useState(!1),fe=t.useRef(null),D=t.useRef(null),H=t.useRef(0),pe=t.useRef(0),L=t.useRef(!1),me=t.useRef(0),U=t.useRef(0),S=t.useCallback((e,n)=>e?typeof e=="function"?e(n):e:null,[]),T=ae!==void 0,f=T?ae:Le,A=ce!==void 0,R=A?ce:Ie,I=t.useMemo(()=>!!(f!=null&&f.trim()||R.length>0),[f,R.length]),P=t.useCallback(()=>{if(!r.current||s==="single")return;const e=r.current,n=globalThis.getComputedStyle(e),l=Number.parseFloat(n.lineHeight)||et,i=Number.parseFloat(n.paddingTop)||0,B=Number.parseFloat(n.paddingBottom)||0;H.current=e.offsetHeight||l+i+B,pe.current=l*M+i+B,s==="auto"&&!c&&(U.current=e.offsetWidth)},[s,M,c]),$e=t.useCallback(()=>s==="auto"?1:M,[s,M]),de=t.useCallback(e=>{if(u){const n=Number.parseInt(u,10);if(e>n)return n}return Math.max(pe.current,e)},[u]),W=t.useCallback(e=>{e.style.overflow="hidden",e.style.height=`${H.current}px`;const n=e.scrollHeight,l=de(n);e.style.height=`${l}px`,u&&n>Number.parseInt(u,10)&&(e.style.overflow="")},[de,u]),V=t.useCallback(e=>{e.style.overflow="hidden",e.style.height=`${H.current}px`;const n=e.scrollHeight,l=u?Math.min(n,Number.parseInt(u,10)):n;e.style.height=`${l}px`,u&&n>Number.parseInt(u,10)&&(e.style.overflow="")},[u]),ge=t.useCallback(e=>{if(U.current<=0)return!1;const n=e.style.height,l=e.style.width;e.style.overflow="hidden",e.style.width=`${U.current}px`,e.style.height=`${H.current}px`;const i=e.scrollWidth<=U.current&&e.scrollHeight<=H.current;return e.style.overflow="",l?e.style.width=l:e.style.width="",n?e.style.height=n:e.style.height="",i},[]),G=t.useCallback((e,n)=>{if(L.current)return;if((e.scrollWidth>e.clientWidth||e.scrollHeight>e.clientHeight)&&!c){L.current=!0,ue(!0);return}if(c){V(e);const i=me.current;n<i&&ge(e)&&(e.style.height="",L.current=!0,ue(!1))}},[c,V,ge]),O=t.useCallback(()=>{var l;if(s==="single"||!r.current)return;const e=r.current,n=((l=e.value)==null?void 0:l.length)||0;s==="multi"?W(e):s==="auto"&&G(e,n)},[s,W,G]);t.useEffect(()=>{s!=="single"&&r.current&&P()},[s,P]),t.useEffect(()=>{s!=="single"&&r.current&&(P(),O())},[M,s,P,O]),t.useEffect(()=>{if(s!=="single"&&r.current){const e=(f==null?void 0:f.length)||0;requestAnimationFrame(()=>{if(r.current){const n=r.current;s==="multi"?W(n):s==="auto"&&G(n,e),me.current=e}})}},[f,s,W,G]),t.useEffect(()=>{s==="auto"&&c&&r.current&&requestAnimationFrame(()=>{if(r.current){const e=r.current;V(e),L.current=!1}})},[c,s,V]),t.useEffect(()=>{if(s==="auto"&&r.current){const e=r.current;c||(e.style.height="",e.style.overflow="",L.current=!1)}},[s,c]),t.useEffect(()=>{if(s==="single"||!r.current)return;const e=r.current;let n;const l=()=>{clearTimeout(n),n=setTimeout(()=>{r.current&&(s==="auto"&&!c&&P(),O())},tt)},i=new ResizeObserver(l);return i.observe(e),()=>{i.disconnect(),clearTimeout(n)}},[s,c,P,O]);const m=t.useCallback(()=>({focus:()=>{var e;return(e=r.current)==null?void 0:e.focus()},blur:()=>{var e;return(e=r.current)==null?void 0:e.blur()},element:r.current,get value(){return f}}),[f]);t.useImperativeHandle(N,m);const je=t.useCallback(e=>{const n=e.target.value;!T&&!p&&_(n),w&&!p&&d.dispatchEvent(w,e,{...m(),value:n},{value:n}),s!=="single"&&O()},[_,w,p,T,m,s,O]),ze=t.useCallback(e=>{Z&&!p&&d.dispatchEvent(Z,e,m(),void 0)},[Z,p,m]),qe=t.useCallback(e=>{J&&!p&&d.dispatchEvent(J,e,m(),void 0)},[J,p,m]),he=t.useCallback(e=>{e.preventDefault()},[]),K=t.useCallback(e=>{Q&&d.dispatchEvent(Q,e,m(),{value:f,attachments:R}),T||_(""),A||Y([])},[Q,m,f,R,T,A]),_e=t.useCallback(e=>{if(!(e.key==="Enter"&&e.shiftKey)){if(e.key==="ArrowUp"||e.key==="ArrowDown"){e.stopPropagation();return}if(e.key==="Enter"){if(e.preventDefault(),C)return;I&&K(e)}}},[K,C,I]),be={disabled:p,readOnly:Ae,placeholder:Re,title:Fe,maxLength:we,"aria-label":v.toLanguageString(a.promptBoxInput,a.messages[a.promptBoxInput]),value:f,onKeyDown:_e,...Pe,onChange:je,onFocus:ze,onBlur:qe,ref:r},Be=t.useCallback(e=>{var i,B;const{isFinal:n,alternatives:l}=e;if(l.length>0){const ne=l[0];if(n){const X=((i=r.current)==null?void 0:i.value)||"",$=(X?`${X} `:"")+ne.transcript;if(T||_($),w&&!p){const ke={target:r.current,currentTarget:r.current};d.dispatchEvent(w,ke,{...m(),value:$},{value:$})}}}(B=r.current)==null||B.focus()},[T,w,p,m]),ye=t.useCallback(()=>{var e,n;(n=(e=fe.current)==null?void 0:e.actionElement)==null||n.click()},[]),ve=t.useCallback(e=>{var i;const n=Array.from(e.affectedFiles),l=typeof h=="object"&&h.onSelectAttachments;A||Y(B=>[...B,...n]),l&&l({selectedFiles:e.affectedFiles,allFiles:e.newState}),(i=r.current)==null||i.focus()},[h,A]),b=t.useMemo(()=>({uploadButtonProps:{fillMode:"flat",svgIcon:se.paperclipOutlineAltRightIcon,size:"small",rounded:"full",onClick:ye,onFilesAdd:ve,files:R,uploadRef:fe,"aria-label":v.toLanguageString(a.promptBoxAttachFile,a.messages[a.promptBoxAttachFile]),title:v.toLanguageString(a.promptBoxAttachFile,a.messages[a.promptBoxAttachFile]),_registerRemoveCallback:e=>{D.current=e}},speechToTextButtonProps:{fillMode:"flat",size:"small",rounded:"full",onResult:Be},actionButtonProps:{rounded:"full",size:"small",svgIcon:C?se.stopSmIcon:se.arrowUpOutlineIcon,className:C?"k-generating":"",onClick:K,onMouseDown:he,disabled:!C&&!I,"aria-disabled":!C&&!I,"aria-label":C?v.toLanguageString(a.promptBoxStopGenerating,a.messages[a.promptBoxStopGenerating]):v.toLanguageString(a.promptBoxSendButton,a.messages[a.promptBoxSendButton]),title:C?v.toLanguageString(a.promptBoxStopGenerating,a.messages[a.promptBoxStopGenerating]):v.toLanguageString(a.promptBoxSendButton,a.messages[a.promptBoxSendButton]),"aria-live":"polite"}}),[Be,ve,R,K,he,C,ye,v,I]),De=t.useCallback(e=>{A||Y(l=>l.filter(i=>i.name!==e));const n=typeof h=="object"&&h.onRemoveAttachment;n&&(D.current=n),D.current&&D.current(e)},[h,A]),ee=()=>{const e=z!==!1,n=q!==!1,l=h!==!1,i=typeof z=="object"?z:void 0,B=typeof h=="object"?h:{},{restrictions:ne,multiple:X=!0,accept:$,onSelectAttachments:ke,onRemoveAttachment:nt,...We}=B,oe={restrictions:ne,multiple:X,accept:$},Ve=typeof q=="object"?q:void 0;return t.createElement(t.Fragment,null,l&&t.createElement(Ze.PromptBoxUploadButton,{...b.uploadButtonProps,restrictions:oe.restrictions,multiple:oe.multiple,accept:oe.accept,...We}),e&&t.createElement(Xe.PromptBoxSpeechToTextButton,{...b.speechToTextButtonProps,...i}),n&&t.createElement(Ke.PromptBoxActionButton,{...b.actionButtonProps,...Ve}))},te=s==="multi"||s==="auto"&&c,xe=h!==!1||z!==!1||q!==!1,Ce=x||xe,Ue=k||x||xe;return t.createElement("div",{"aria-label":v.toLanguageString(a.promptBoxAriaLabel,a.messages[a.promptBoxAriaLabel]),...He,className:d.classNames(Ne,"k-input",g,{[`k-input-${le}`]:le,"k-disabled":p,"k-prompt-box-singleline":s==="single","k-prompt-box-multiline":te}),style:Me},t.createElement(Je.FileBox,{files:R,onRemoveFile:De,header:Oe}),s==="single"?t.createElement("div",{className:`${g}-content`},k&&t.createElement("div",{className:`${g}-affix`},S(k,b)),t.createElement("input",{...be,className:d.classNames("k-input-inner",`${g}-input`)}),Ce?t.createElement("div",{className:`${g}-affix`},x&&S(x,b),ee()):null):t.createElement("div",{className:`${g}-content`},s==="multi"&&ie&&t.createElement("div",{className:`${g}-affix`},S(ie,b)),s==="auto"&&!c&&k&&t.createElement("div",{className:`${g}-affix`},S(k,b)),t.createElement("textarea",{...be,className:d.classNames("k-input-inner",`${g}-textarea`),rows:$e(),style:u?{maxHeight:u}:{},...te&&{"aria-multiline":"true"}}),s==="auto"&&!c&&Ce?t.createElement("div",{className:`${g}-affix`},x&&S(x,b),ee()):null,te&&Ue?t.createElement("div",{className:`${g}-affix`},k&&S(k,b),(k||x)&&t.createElement("div",{className:"k-spacer"}),x&&S(x,b),ee()):null),F&&t.createElement(d.WatermarkOverlay,{message:j}))});re.propTypes={value:o.string,defaultValue:o.string,mode:o.oneOf(["single","multi","auto"]),rows:o.number,maxTextAreaHeight:o.string,title:o.string,disabled:o.bool,readOnly:o.bool,placeholder:o.string,maxLength:o.number,inputAttributes:o.object,fillMode:o.oneOf(["solid","flat","outline"]),topAffix:o.oneOfType([o.func,o.element,o.string]),startAffix:o.oneOfType([o.func,o.element,o.string]),endAffix:o.oneOfType([o.func,o.element,o.string]),header:o.oneOfType([o.func,o.element,o.string]),onChange:o.func,onFocus:o.func,onBlur:o.func,loading:o.bool,uploadButtonConfig:o.oneOfType([o.bool,o.object]),speechToTextButtonConfig:o.oneOfType([o.bool,o.object]),actionButtonConfig:o.oneOfType([o.bool,o.object]),attachments:o.array,onPromptAction:o.func,className:o.string,style:o.object};re.displayName="KendoPromptBox";exports.PromptBox=re;
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ge=require("react"),o=require("prop-types"),d=require("@progress/kendo-react-common"),se=require("@progress/kendo-svg-icons"),Ke=require("./PromptBoxActionButton.js"),Xe=require("./PromptBoxSpeechToTextButton.js"),Ze=require("./PromptBoxUploadButton.js"),Je=require("./FileBox.js"),Ee=require("../package-metadata.js"),Qe=require("@progress/kendo-react-intl"),a=require("../messages/index.js");function Ye(E){const O=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(E){for(const F in E)if(F!=="default"){const j=Object.getOwnPropertyDescriptor(E,F);Object.defineProperty(O,F,j.get?j:{enumerable:!0,get:()=>E[F]})}}return O.default=E,Object.freeze(O)}const t=Ye(Ge),g="k-prompt-box",et=20,tt=50,y={mode:"auto",rows:1,defaultValue:"",disabled:!1,readOnly:!1,loading:!1,uploadButtonConfig:!1,speechToTextButtonConfig:!0,actionButtonConfig:!0},re=t.forwardRef((E,O)=>{const F=!d.validatePackage(Ee.packageMetadata,{component:"PromptBox"}),j=d.getLicenseMessage(Ee.packageMetadata),v=Qe.useLocalization(),Se={...y,...E},{mode:s=y.mode,fillMode:le,rows:M=y.rows,maxTextAreaHeight:u,value:ae,defaultValue:Te=y.defaultValue,disabled:p=y.disabled,readOnly:Ae=y.readOnly,placeholder:Re,title:Fe,maxLength:we,inputAttributes:Pe,topAffix:ie,startAffix:k,endAffix:x,header:Ne,onChange:w,onFocus:Z,onBlur:J,onPromptAction:Q,attachments:ce,loading:C=y.loading,uploadButtonConfig:h=y.uploadButtonConfig,speechToTextButtonConfig:z=y.speechToTextButtonConfig,actionButtonConfig:q=y.actionButtonConfig,className:Oe,style:Me,...He}=Se,r=t.useRef(null),[Le,_]=t.useState(Te),[Ie,Y]=t.useState([]),[c,ue]=t.useState(!1),fe=t.useRef(null),D=t.useRef(null),H=t.useRef(0),pe=t.useRef(0),L=t.useRef(!1),me=t.useRef(0),U=t.useRef(0),S=t.useCallback((e,n)=>e?typeof e=="function"?e(n):e:null,[]),T=ae!==void 0,f=T?ae:Le,A=ce!==void 0,R=A?ce:Ie,I=t.useMemo(()=>!!(f!=null&&f.trim()||R.length>0),[f,R.length]),P=t.useCallback(()=>{if(!r.current||s==="single")return;const e=r.current,n=globalThis.getComputedStyle(e),l=Number.parseFloat(n.lineHeight)||et,i=Number.parseFloat(n.paddingTop)||0,B=Number.parseFloat(n.paddingBottom)||0;H.current=e.offsetHeight||l+i+B,pe.current=l*M+i+B,s==="auto"&&!c&&(U.current=e.offsetWidth)},[s,M,c]),$e=t.useCallback(()=>s==="auto"?1:M,[s,M]),de=t.useCallback(e=>{if(u){const n=Number.parseInt(u,10);if(e>n)return n}return Math.max(pe.current,e)},[u]),W=t.useCallback(e=>{e.style.overflow="hidden",e.style.height=`${H.current}px`;const n=e.scrollHeight,l=de(n);e.style.height=`${l}px`,u&&n>Number.parseInt(u,10)&&(e.style.overflow="")},[de,u]),V=t.useCallback(e=>{e.style.overflow="hidden",e.style.height=`${H.current}px`;const n=e.scrollHeight,l=u?Math.min(n,Number.parseInt(u,10)):n;e.style.height=`${l}px`,u&&n>Number.parseInt(u,10)&&(e.style.overflow="")},[u]),ge=t.useCallback(e=>{if(U.current<=0)return!1;const n=e.style.height,l=e.style.width;e.style.overflow="hidden",e.style.width=`${U.current}px`,e.style.height=`${H.current}px`;const i=e.scrollWidth<=U.current&&e.scrollHeight<=H.current;return e.style.overflow="",l?e.style.width=l:e.style.width="",n?e.style.height=n:e.style.height="",i},[]),G=t.useCallback((e,n)=>{if(L.current)return;if((e.scrollWidth>e.clientWidth||e.scrollHeight>e.clientHeight)&&!c){L.current=!0,ue(!0);return}if(c){V(e);const i=me.current;n<i&&ge(e)&&(e.style.height="",L.current=!0,ue(!1))}},[c,V,ge]),N=t.useCallback(()=>{var l;if(s==="single"||!r.current)return;const e=r.current,n=((l=e.value)==null?void 0:l.length)||0;s==="multi"?W(e):s==="auto"&&G(e,n)},[s,W,G]);t.useEffect(()=>{s!=="single"&&r.current&&P()},[s,P]),t.useEffect(()=>{s!=="single"&&r.current&&(P(),N())},[M,s,P,N]),t.useEffect(()=>{if(s!=="single"&&r.current){const e=(f==null?void 0:f.length)||0;requestAnimationFrame(()=>{if(r.current){const n=r.current;s==="multi"?W(n):s==="auto"&&G(n,e),me.current=e}})}},[f,s,W,G]),t.useEffect(()=>{s==="auto"&&c&&r.current&&requestAnimationFrame(()=>{if(r.current){const e=r.current;V(e),L.current=!1}})},[c,s,V]),t.useEffect(()=>{if(s==="auto"&&r.current){const e=r.current;c||(e.style.height="",e.style.overflow="",L.current=!1)}},[s,c]),t.useEffect(()=>{if(s==="single"||!r.current)return;const e=r.current;let n;const l=()=>{clearTimeout(n),n=setTimeout(()=>{r.current&&(s==="auto"&&!c&&P(),N())},tt)},i=new ResizeObserver(l);return i.observe(e),()=>{i.disconnect(),clearTimeout(n)}},[s,c,P,N]);const m=t.useCallback(()=>({focus:()=>{var e;return(e=r.current)==null?void 0:e.focus()},blur:()=>{var e;return(e=r.current)==null?void 0:e.blur()},element:r.current,get value(){return f}}),[f]);t.useImperativeHandle(O,m);const je=t.useCallback(e=>{const n=e.target.value;!T&&!p&&_(n),w&&!p&&d.dispatchEvent(w,e,{...m(),value:n},{value:n}),s!=="single"&&N()},[_,w,p,T,m,s,N]),ze=t.useCallback(e=>{Z&&!p&&d.dispatchEvent(Z,e,m(),void 0)},[Z,p,m]),qe=t.useCallback(e=>{J&&!p&&d.dispatchEvent(J,e,m(),void 0)},[J,p,m]),he=t.useCallback(e=>{e.preventDefault()},[]),K=t.useCallback(e=>{Q&&d.dispatchEvent(Q,e,m(),{value:f,attachments:R}),T||_(""),A||Y([])},[Q,m,f,R,T,A]),_e=t.useCallback(e=>{if(!(e.key==="Enter"&&e.shiftKey)){if(e.key==="ArrowUp"||e.key==="ArrowDown"){e.stopPropagation();return}if(e.key==="Enter"){if(e.preventDefault(),C)return;I&&K(e)}}},[K,C,I]),be={disabled:p,readOnly:Ae,placeholder:Re,title:Fe,maxLength:we,"aria-label":v.toLanguageString(a.promptBoxInput,a.messages[a.promptBoxInput]),value:f,onKeyDown:_e,...Pe,onChange:je,onFocus:ze,onBlur:qe,ref:r},Be=t.useCallback(e=>{var i,B;const{isFinal:n,alternatives:l}=e;if(l.length>0){const ne=l[0];if(n){const X=((i=r.current)==null?void 0:i.value)||"",$=(X?`${X} `:"")+ne.transcript;if(T||_($),w&&!p){const ke={target:r.current,currentTarget:r.current};d.dispatchEvent(w,ke,{...m(),value:$},{value:$})}}}(B=r.current)==null||B.focus()},[T,w,p,m]),ye=t.useCallback(()=>{var e,n;(n=(e=fe.current)==null?void 0:e.actionElement)==null||n.click()},[]),ve=t.useCallback(e=>{var i;const n=Array.from(e.affectedFiles),l=typeof h=="object"&&h.onSelectAttachments;A||Y(B=>[...B,...n]),l&&l({selectedFiles:e.affectedFiles,allFiles:e.newState}),(i=r.current)==null||i.focus()},[h,A]),b=t.useMemo(()=>({uploadButtonProps:{fillMode:"flat",svgIcon:se.paperclipIcon,size:"small",rounded:"full",onClick:ye,onFilesAdd:ve,files:R,uploadRef:fe,"aria-label":v.toLanguageString(a.promptBoxAttachFile,a.messages[a.promptBoxAttachFile]),title:v.toLanguageString(a.promptBoxAttachFile,a.messages[a.promptBoxAttachFile]),_registerRemoveCallback:e=>{D.current=e}},speechToTextButtonProps:{fillMode:"flat",size:"small",rounded:"full",onResult:Be},actionButtonProps:{rounded:"full",size:"small",svgIcon:C?se.stopIcon:se.arrowUpIcon,className:C?"k-generating":"",onClick:K,onMouseDown:he,disabled:!C&&!I,"aria-disabled":!C&&!I,"aria-label":C?v.toLanguageString(a.promptBoxStopGenerating,a.messages[a.promptBoxStopGenerating]):v.toLanguageString(a.promptBoxSendButton,a.messages[a.promptBoxSendButton]),title:C?v.toLanguageString(a.promptBoxStopGenerating,a.messages[a.promptBoxStopGenerating]):v.toLanguageString(a.promptBoxSendButton,a.messages[a.promptBoxSendButton]),"aria-live":"polite"}}),[Be,ve,R,K,he,C,ye,v,I]),De=t.useCallback(e=>{A||Y(l=>l.filter(i=>i.name!==e));const n=typeof h=="object"&&h.onRemoveAttachment;n&&(D.current=n),D.current&&D.current(e)},[h,A]),ee=()=>{const e=z!==!1,n=q!==!1,l=h!==!1,i=typeof z=="object"?z:void 0,B=typeof h=="object"?h:{},{restrictions:ne,multiple:X=!0,accept:$,onSelectAttachments:ke,onRemoveAttachment:nt,...We}=B,oe={restrictions:ne,multiple:X,accept:$},Ve=typeof q=="object"?q:void 0;return t.createElement(t.Fragment,null,l&&t.createElement(Ze.PromptBoxUploadButton,{...b.uploadButtonProps,restrictions:oe.restrictions,multiple:oe.multiple,accept:oe.accept,...We}),e&&t.createElement(Xe.PromptBoxSpeechToTextButton,{...b.speechToTextButtonProps,...i}),n&&t.createElement(Ke.PromptBoxActionButton,{...b.actionButtonProps,...Ve}))},te=s==="multi"||s==="auto"&&c,xe=h!==!1||z!==!1||q!==!1,Ce=x||xe,Ue=k||x||xe;return t.createElement("div",{"aria-label":v.toLanguageString(a.promptBoxAriaLabel,a.messages[a.promptBoxAriaLabel]),...He,className:d.classNames(Oe,"k-input",g,{[`k-input-${le}`]:le,"k-disabled":p,"k-prompt-box-singleline":s==="single","k-prompt-box-multiline":te}),style:Me},t.createElement(Je.FileBox,{files:R,onRemoveFile:De,header:Ne}),s==="single"?t.createElement("div",{className:`${g}-content`},k&&t.createElement("div",{className:`${g}-affix`},S(k,b)),t.createElement("input",{...be,className:d.classNames("k-input-inner",`${g}-input`)}),Ce?t.createElement("div",{className:`${g}-affix`},x&&S(x,b),ee()):null):t.createElement("div",{className:`${g}-content`},s==="multi"&&ie&&t.createElement("div",{className:`${g}-affix`},S(ie,b)),s==="auto"&&!c&&k&&t.createElement("div",{className:`${g}-affix`},S(k,b)),t.createElement("textarea",{...be,className:d.classNames("k-input-inner",`${g}-textarea`),rows:$e(),style:u?{maxHeight:u}:{},...te&&{"aria-multiline":"true"}}),s==="auto"&&!c&&Ce?t.createElement("div",{className:`${g}-affix`},x&&S(x,b),ee()):null,te&&Ue?t.createElement("div",{className:`${g}-affix`},k&&S(k,b),(k||x)&&t.createElement("div",{className:"k-spacer"}),x&&S(x,b),ee()):null),F&&t.createElement(d.WatermarkOverlay,{message:j}))});re.propTypes={value:o.string,defaultValue:o.string,mode:o.oneOf(["single","multi","auto"]),rows:o.number,maxTextAreaHeight:o.string,title:o.string,disabled:o.bool,readOnly:o.bool,placeholder:o.string,maxLength:o.number,inputAttributes:o.object,fillMode:o.oneOf(["solid","flat","outline"]),topAffix:o.oneOfType([o.func,o.element,o.string]),startAffix:o.oneOfType([o.func,o.element,o.string]),endAffix:o.oneOfType([o.func,o.element,o.string]),header:o.oneOfType([o.func,o.element,o.string]),onChange:o.func,onFocus:o.func,onBlur:o.func,loading:o.bool,uploadButtonConfig:o.oneOfType([o.bool,o.object]),speechToTextButtonConfig:o.oneOfType([o.bool,o.object]),actionButtonConfig:o.oneOfType([o.bool,o.object]),attachments:o.array,onPromptAction:o.func,className:o.string,style:o.object};re.displayName="KendoPromptBox";exports.PromptBox=re;
|
package/prompt-box/PromptBox.mjs
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import * as t from "react";
|
|
9
9
|
import o from "prop-types";
|
|
10
|
-
import { validatePackage as Qe, getLicenseMessage as Ye, dispatchEvent as
|
|
11
|
-
import {
|
|
10
|
+
import { validatePackage as Qe, getLicenseMessage as Ye, dispatchEvent as O, classNames as oe, WatermarkOverlay as et } from "@progress/kendo-react-common";
|
|
11
|
+
import { stopIcon as tt, arrowUpIcon as nt, paperclipIcon as ot } from "@progress/kendo-svg-icons";
|
|
12
12
|
import { PromptBoxActionButton as st } from "./PromptBoxActionButton.mjs";
|
|
13
13
|
import { PromptBoxSpeechToTextButton as lt } from "./PromptBoxSpeechToTextButton.mjs";
|
|
14
14
|
import { PromptBoxUploadButton as rt } from "./PromptBoxUploadButton.mjs";
|
|
@@ -27,18 +27,18 @@ const p = "k-prompt-box", ct = 20, ut = 50, b = {
|
|
|
27
27
|
speechToTextButtonConfig: !0,
|
|
28
28
|
actionButtonConfig: !0
|
|
29
29
|
}, Te = t.forwardRef((Ae, Re) => {
|
|
30
|
-
const we = !Qe(ke, { component: "PromptBox" }),
|
|
30
|
+
const we = !Qe(ke, { component: "PromptBox" }), Fe = Ye(ke), y = at(), Se = { ...b, ...Ae }, {
|
|
31
31
|
mode: s = b.mode,
|
|
32
32
|
fillMode: se,
|
|
33
|
-
rows:
|
|
33
|
+
rows: S = b.rows,
|
|
34
34
|
maxTextAreaHeight: c,
|
|
35
35
|
value: le,
|
|
36
36
|
defaultValue: Pe = b.defaultValue,
|
|
37
37
|
disabled: f = b.disabled,
|
|
38
38
|
readOnly: Ne = b.readOnly,
|
|
39
39
|
placeholder: He,
|
|
40
|
-
title:
|
|
41
|
-
maxLength:
|
|
40
|
+
title: Le,
|
|
41
|
+
maxLength: Oe,
|
|
42
42
|
inputAttributes: Me,
|
|
43
43
|
topAffix: re,
|
|
44
44
|
startAffix: C,
|
|
@@ -56,7 +56,7 @@ const p = "k-prompt-box", ct = 20, ut = 50, b = {
|
|
|
56
56
|
className: $e,
|
|
57
57
|
style: ze,
|
|
58
58
|
...je
|
|
59
|
-
} =
|
|
59
|
+
} = Se, l = t.useRef(null), [De, $] = t.useState(Pe), [_e, Q] = t.useState([]), [a, ae] = t.useState(!1), ce = t.useRef(null), z = t.useRef(null), P = t.useRef(0), ue = t.useRef(0), N = t.useRef(!1), fe = t.useRef(0), j = t.useRef(0), E = t.useCallback(
|
|
60
60
|
(e, n) => e ? typeof e == "function" ? e(n) : e : null,
|
|
61
61
|
[]
|
|
62
62
|
), x = le !== void 0, u = x ? le : De, T = ie !== void 0, A = T ? ie : _e, H = t.useMemo(
|
|
@@ -66,8 +66,8 @@ const p = "k-prompt-box", ct = 20, ut = 50, b = {
|
|
|
66
66
|
if (!l.current || s === "single")
|
|
67
67
|
return;
|
|
68
68
|
const e = l.current, n = globalThis.getComputedStyle(e), r = Number.parseFloat(n.lineHeight) || ct, i = Number.parseFloat(n.paddingTop) || 0, h = Number.parseFloat(n.paddingBottom) || 0;
|
|
69
|
-
P.current = e.offsetHeight || r + i + h, ue.current = r *
|
|
70
|
-
}, [s,
|
|
69
|
+
P.current = e.offsetHeight || r + i + h, ue.current = r * S + i + h, s === "auto" && !a && (j.current = e.offsetWidth);
|
|
70
|
+
}, [s, S, a]), We = t.useCallback(() => s === "auto" ? 1 : S, [s, S]), me = t.useCallback(
|
|
71
71
|
(e) => {
|
|
72
72
|
if (c) {
|
|
73
73
|
const n = Number.parseInt(c, 10);
|
|
@@ -113,7 +113,7 @@ const p = "k-prompt-box", ct = 20, ut = 50, b = {
|
|
|
113
113
|
}
|
|
114
114
|
},
|
|
115
115
|
[a, _, pe]
|
|
116
|
-
),
|
|
116
|
+
), F = t.useCallback(() => {
|
|
117
117
|
var r;
|
|
118
118
|
if (s === "single" || !l.current)
|
|
119
119
|
return;
|
|
@@ -123,8 +123,8 @@ const p = "k-prompt-box", ct = 20, ut = 50, b = {
|
|
|
123
123
|
t.useEffect(() => {
|
|
124
124
|
s !== "single" && l.current && w();
|
|
125
125
|
}, [s, w]), t.useEffect(() => {
|
|
126
|
-
s !== "single" && l.current && (w(),
|
|
127
|
-
}, [
|
|
126
|
+
s !== "single" && l.current && (w(), F());
|
|
127
|
+
}, [S, s, w, F]), t.useEffect(() => {
|
|
128
128
|
if (s !== "single" && l.current) {
|
|
129
129
|
const e = (u == null ? void 0 : u.length) || 0;
|
|
130
130
|
requestAnimationFrame(() => {
|
|
@@ -153,13 +153,13 @@ const p = "k-prompt-box", ct = 20, ut = 50, b = {
|
|
|
153
153
|
let n;
|
|
154
154
|
const r = () => {
|
|
155
155
|
clearTimeout(n), n = setTimeout(() => {
|
|
156
|
-
l.current && (s === "auto" && !a && w(),
|
|
156
|
+
l.current && (s === "auto" && !a && w(), F());
|
|
157
157
|
}, ut);
|
|
158
158
|
}, i = new ResizeObserver(r);
|
|
159
159
|
return i.observe(e), () => {
|
|
160
160
|
i.disconnect(), clearTimeout(n);
|
|
161
161
|
};
|
|
162
|
-
}, [s, a, w,
|
|
162
|
+
}, [s, a, w, F]);
|
|
163
163
|
const m = t.useCallback(() => ({
|
|
164
164
|
focus: () => {
|
|
165
165
|
var e;
|
|
@@ -178,7 +178,7 @@ const p = "k-prompt-box", ct = 20, ut = 50, b = {
|
|
|
178
178
|
const Ue = t.useCallback(
|
|
179
179
|
(e) => {
|
|
180
180
|
const n = e.target.value;
|
|
181
|
-
!x && !f && $(n), R && !f &&
|
|
181
|
+
!x && !f && $(n), R && !f && O(
|
|
182
182
|
R,
|
|
183
183
|
e,
|
|
184
184
|
{
|
|
@@ -186,24 +186,24 @@ const p = "k-prompt-box", ct = 20, ut = 50, b = {
|
|
|
186
186
|
value: n
|
|
187
187
|
},
|
|
188
188
|
{ value: n }
|
|
189
|
-
), s !== "single" &&
|
|
189
|
+
), s !== "single" && F();
|
|
190
190
|
},
|
|
191
|
-
[$, R, f, x, m, s,
|
|
191
|
+
[$, R, f, x, m, s, F]
|
|
192
192
|
), Ve = t.useCallback(
|
|
193
193
|
(e) => {
|
|
194
|
-
X && !f &&
|
|
194
|
+
X && !f && O(X, e, m(), void 0);
|
|
195
195
|
},
|
|
196
196
|
[X, f, m]
|
|
197
197
|
), Ke = t.useCallback(
|
|
198
198
|
(e) => {
|
|
199
|
-
Z && !f &&
|
|
199
|
+
Z && !f && O(Z, e, m(), void 0);
|
|
200
200
|
},
|
|
201
201
|
[Z, f, m]
|
|
202
202
|
), de = t.useCallback((e) => {
|
|
203
203
|
e.preventDefault();
|
|
204
204
|
}, []), U = t.useCallback(
|
|
205
205
|
(e) => {
|
|
206
|
-
J &&
|
|
206
|
+
J && O(
|
|
207
207
|
J,
|
|
208
208
|
e,
|
|
209
209
|
m(),
|
|
@@ -233,8 +233,8 @@ const p = "k-prompt-box", ct = 20, ut = 50, b = {
|
|
|
233
233
|
disabled: f,
|
|
234
234
|
readOnly: Ne,
|
|
235
235
|
placeholder: He,
|
|
236
|
-
title:
|
|
237
|
-
maxLength:
|
|
236
|
+
title: Le,
|
|
237
|
+
maxLength: Oe,
|
|
238
238
|
"aria-label": y.toLanguageString(Ee, k[Ee]),
|
|
239
239
|
value: u,
|
|
240
240
|
// let them rewrite kb navigation if needed
|
|
@@ -251,20 +251,20 @@ const p = "k-prompt-box", ct = 20, ut = 50, b = {
|
|
|
251
251
|
if (r.length > 0) {
|
|
252
252
|
const te = r[0];
|
|
253
253
|
if (n) {
|
|
254
|
-
const V = ((i = l.current) == null ? void 0 : i.value) || "",
|
|
255
|
-
if (x || $(
|
|
254
|
+
const V = ((i = l.current) == null ? void 0 : i.value) || "", L = (V ? `${V} ` : "") + te.transcript;
|
|
255
|
+
if (x || $(L), R && !f) {
|
|
256
256
|
const Ce = {
|
|
257
257
|
target: l.current,
|
|
258
258
|
currentTarget: l.current
|
|
259
259
|
};
|
|
260
|
-
|
|
260
|
+
O(
|
|
261
261
|
R,
|
|
262
262
|
Ce,
|
|
263
263
|
{
|
|
264
264
|
...m(),
|
|
265
|
-
value:
|
|
265
|
+
value: L
|
|
266
266
|
},
|
|
267
|
-
{ value:
|
|
267
|
+
{ value: L }
|
|
268
268
|
);
|
|
269
269
|
}
|
|
270
270
|
}
|
|
@@ -342,11 +342,11 @@ const p = "k-prompt-box", ct = 20, ut = 50, b = {
|
|
|
342
342
|
const e = M !== !1, n = I !== !1, r = d !== !1, i = typeof M == "object" ? M : void 0, h = typeof d == "object" ? d : {}, {
|
|
343
343
|
restrictions: te,
|
|
344
344
|
multiple: V = !0,
|
|
345
|
-
accept:
|
|
345
|
+
accept: L,
|
|
346
346
|
onSelectAttachments: Ce,
|
|
347
347
|
onRemoveAttachment: ft,
|
|
348
348
|
...Ze
|
|
349
|
-
} = h, ne = { restrictions: te, multiple: V, accept:
|
|
349
|
+
} = h, ne = { restrictions: te, multiple: V, accept: L }, Je = typeof I == "object" ? I : void 0;
|
|
350
350
|
return /* @__PURE__ */ t.createElement(t.Fragment, null, r && /* @__PURE__ */ t.createElement(
|
|
351
351
|
rt,
|
|
352
352
|
{
|
|
@@ -388,7 +388,7 @@ const p = "k-prompt-box", ct = 20, ut = 50, b = {
|
|
|
388
388
|
...ee && { "aria-multiline": "true" }
|
|
389
389
|
}
|
|
390
390
|
), s === "auto" && !a && Be ? /* @__PURE__ */ t.createElement("div", { className: `${p}-affix` }, v && E(v, g), Y()) : null, ee && Xe ? /* @__PURE__ */ t.createElement("div", { className: `${p}-affix` }, C && E(C, g), (C || v) && /* @__PURE__ */ t.createElement("div", { className: "k-spacer" }), v && E(v, g), Y()) : null),
|
|
391
|
-
we && /* @__PURE__ */ t.createElement(et, { message:
|
|
391
|
+
we && /* @__PURE__ */ t.createElement(et, { message: Fe })
|
|
392
392
|
);
|
|
393
393
|
});
|
|
394
394
|
Te.propTypes = {
|