@progress/kendo-react-conversational-ui 13.4.0-develop.2 → 13.4.0-develop.3

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.
Files changed (64) hide show
  1. package/api/message.interface.d.ts +87 -9
  2. package/chat/ChatPropsAndState.d.ts +108 -9
  3. package/chat/Events.d.ts +9 -0
  4. package/chat/components/ActionGroup.js +1 -1
  5. package/chat/components/ActionGroup.mjs +58 -48
  6. package/chat/components/Chat.d.ts +1 -1
  7. package/chat/components/Chat.js +1 -1
  8. package/chat/components/Chat.mjs +318 -269
  9. package/chat/components/ChatContext.d.ts +6 -3
  10. package/chat/components/ChatMessage.js +1 -1
  11. package/chat/components/ChatMessage.mjs +237 -177
  12. package/chat/components/Header.js +1 -1
  13. package/chat/components/Header.mjs +3 -3
  14. package/chat/components/NewMessage.d.ts +5 -3
  15. package/chat/components/NewMessage.js +1 -1
  16. package/chat/components/NewMessage.mjs +174 -226
  17. package/chat/components/ScrollButtonsWrapper.js +1 -1
  18. package/chat/components/ScrollButtonsWrapper.mjs +34 -40
  19. package/chat/components/SuggestionsGroup.js +1 -1
  20. package/chat/components/SuggestionsGroup.mjs +40 -39
  21. package/chat/components/elements/FileBox.js +1 -1
  22. package/chat/components/elements/FileBox.mjs +33 -41
  23. package/chat/components/elements/PinnedMessage.js +1 -1
  24. package/chat/components/elements/PinnedMessage.mjs +24 -22
  25. package/chat/hooks/useScrollWithButtons.d.ts +4 -0
  26. package/chat/hooks/useScrollWithButtons.js +1 -1
  27. package/chat/hooks/useScrollWithButtons.mjs +25 -23
  28. package/chat/utils/fieldMapping.d.ts +1 -1
  29. package/chat/utils/fieldMapping.js +1 -1
  30. package/chat/utils/fieldMapping.mjs +37 -34
  31. package/chat/utils/scroll.d.ts +15 -1
  32. package/chat/utils/scroll.js +3 -3
  33. package/chat/utils/scroll.mjs +92 -65
  34. package/chat/utils.d.ts +4 -1
  35. package/chat/utils.js +1 -1
  36. package/chat/utils.mjs +37 -37
  37. package/dist/cdn/js/kendo-react-conversational-ui.js +1 -1
  38. package/index.d.mts +6 -0
  39. package/index.d.ts +6 -0
  40. package/index.js +1 -1
  41. package/index.mjs +39 -31
  42. package/messages/index.d.ts +50 -0
  43. package/messages/index.js +1 -1
  44. package/messages/index.mjs +60 -40
  45. package/package-metadata.js +1 -1
  46. package/package-metadata.mjs +1 -1
  47. package/package.json +11 -11
  48. package/prompt-box/Events.d.ts +66 -0
  49. package/prompt-box/FileBox.d.ts +22 -0
  50. package/prompt-box/FileBox.js +8 -0
  51. package/prompt-box/FileBox.mjs +72 -0
  52. package/prompt-box/PromptBox.d.ts +35 -0
  53. package/prompt-box/PromptBox.js +8 -0
  54. package/prompt-box/PromptBox.mjs +424 -0
  55. package/prompt-box/PromptBoxActionButton.d.ts +32 -0
  56. package/prompt-box/PromptBoxActionButton.js +8 -0
  57. package/prompt-box/PromptBoxActionButton.mjs +14 -0
  58. package/prompt-box/PromptBoxSpeechToTextButton.d.ts +32 -0
  59. package/prompt-box/PromptBoxSpeechToTextButton.js +8 -0
  60. package/prompt-box/PromptBoxSpeechToTextButton.mjs +14 -0
  61. package/prompt-box/PromptBoxUploadButton.d.ts +108 -0
  62. package/prompt-box/PromptBoxUploadButton.js +8 -0
  63. package/prompt-box/PromptBoxUploadButton.mjs +54 -0
  64. package/prompt-box/interfaces/PromptBoxProps.d.ts +390 -0
@@ -5,11 +5,11 @@
5
5
  * Licensed under commercial license. See LICENSE.md in the package root for more information
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
- import { ChatMessageBoxProps } from '../ChatPropsAndState.js';
8
+ import { ChatMessageBoxProps, MessageBoxSettings } from '../ChatPropsAndState.js';
9
9
  import { MessageAction, FileAction } from './ChatMessage.js';
10
10
  import { ButtonProps } from '@progress/kendo-react-buttons';
11
11
  import { ChatSuggestion, SuggestionTemplateProps } from './SuggestionsGroup.js';
12
- import { Message } from '../../index.js';
12
+ import { Message } from '../../api/message.interface.js';
13
13
  import * as React from 'react';
14
14
  /**
15
15
  * @hidden
@@ -24,10 +24,12 @@ export interface NewMessageProps {
24
24
  suggestionTemplate?: React.ComponentType<SuggestionTemplateProps>;
25
25
  onSuggestionClick?: (suggestion: ChatSuggestion) => void;
26
26
  onInputValueChange?: (value: string) => void;
27
- sendButtonConfig?: ButtonProps;
27
+ sendButtonConfig?: boolean | ButtonProps;
28
28
  onInputClick?: () => void;
29
29
  suggestionsLayout?: 'scroll' | 'wrap' | 'scrollbuttons';
30
30
  dir?: string;
31
+ messageBoxSettings?: MessageBoxSettings;
32
+ loading?: boolean;
31
33
  }
32
34
  export interface ActionTriggeredEvent {
33
35
  /**
@@ -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";const D=require("@progress/kendo-react-common"),fe=require("react"),I=require("@progress/kendo-react-buttons"),ge=require("@progress/kendo-react-upload"),pe=require("./SuggestionsGroup.js"),ne=require("@progress/kendo-react-inputs"),F=require("@progress/kendo-svg-icons"),de=require("./ChatContext.js"),me=require("@progress/kendo-react-intl"),se=require("../utils.js"),s=require("../../messages/index.js"),ke=require("./elements/FileBox.js");function be(p){const k=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(p){for(const f in p)if(f!=="default"){const b=Object.getOwnPropertyDescriptor(p,f);Object.defineProperty(k,f,b.get?b:{enumerable:!0,get:()=>p[f]})}}return k.default=p,Object.freeze(k)}const e=be(fe),ae=e.forwardRef((p,k)=>{const{onSendMessage:f,isDirectionRightToLeft:b,placeholder:q,MessageBox:z,suggestions:R,onSuggestionClick:oe,inputValue:S,onInputValueChange:m,suggestionTemplate:le,sendButtonConfig:L,onInputClick:j,suggestionsLayout:re,dir:ce}=p,{replyToMessage:a,setReplyToMessage:x,user:E,messageListScrollContainerRef:d,speechToTextConfig:y,uploadConfig:o}=de.useChatContext(),[P]=e.useState(!1),[l,M]=e.useState(void 0),[r,B]=e.useState([]),[K,O]=e.useState(!1),h=e.useRef(null),N=e.useRef(null),c=me.useLocalization(),g=e.useCallback(()=>{h.current!==null&&h.current.focus()},[]);e.useEffect(()=>{S!==void 0&&S!==l&&(M(S),g())},[S,l,g]),e.useEffect(()=>{a&&g()},[a,g]),e.useLayoutEffect(()=>{K&&(d!=null&&d.current)&&(d.current.scrollTop=d.current.scrollHeight-d.current.clientHeight,O(!1))},[K,d]);const U=e.useCallback(t=>{const n=t.value;M(n),m&&m(n)},[m]),C=e.useMemo(()=>!!(l!=null&&l.trim()||o!==!1&&r.length>0),[l,r.length,o]),w=e.useCallback(t=>{if(t.preventDefault(),f){const n=l;if(C){const u={id:"",author:E,text:n||"",timestamp:new Date,replyToId:a?a.id:void 0,files:r.map(i=>({name:i.name,size:i.size,type:i.extension,rawFile:i.getRawFile?i.getRawFile():i}))};x(null),f(u,t),B([]),M(""),m&&m(""),O(!0)}}},[f,l,E,a,r,x,m,C]),A=e.useCallback(t=>{if(!(t.key==="Enter"&&t.shiftKey))switch(t.key){case"Enter":return t.preventDefault(),w(t);case"Escape":h.current&&h.current.blur();break;default:return}},[w]);e.useImperativeHandle(k,()=>({focusInput:g}),[g]);const H=e.useCallback(t=>{B(n=>n.filter(u=>u.name!==t))},[]),V=e.useCallback(()=>o===!1?null:e.createElement(ke,{files:r,onFileRemove:H,renderInTextarea:!0}),[r,H,o]),_=e.useCallback((t,n)=>t.isDeleted?se.getDeletedMessageText(n,c):t.text,[c]),G=e.useCallback(()=>{if(a){const t=se.isAuthor(E,a);return e.createElement("div",{className:D.classNames("k-message-reference",t?"k-message-reference-sender":"k-message-reference-receiver")},e.createElement("div",{className:"k-message-reference-content"},_(a,t)),e.createElement("span",{className:"k-spacer"}),e.createElement(I.Button,{fillMode:"flat",themeColor:"base",svgIcon:F.xIcon,onClick:()=>x(null),"aria-label":c.toLanguageString(s.closeReply,s.messages[s.closeReply])}))}return null},[a,E,_,x,c]),$=e.useCallback(t=>{try{const n=Array.from(t.newState);B(u=>[...u,...n]),g()}catch{}},[g]),J=e.useCallback(()=>{N.current&&o!==!1&&N.current.actionElement.click()},[o]),Q=e.useCallback(t=>{},[]),W=e.useCallback(t=>{const{isFinal:n,alternatives:u}=t;if(u.length>0){const i=u[0];n&&M(T=>(T?`${T} `:"")+i.transcript)}},[]),X=e.useCallback(()=>e.createElement(e.Fragment,null,r.length>0&&V(),a&&e.createElement("span",{className:"k-input-prefix k-input-prefix-horizontal"},G())),[r.length,a,V,G]),Y=e.useCallback(t=>{t.preventDefault()},[]),Z=e.useCallback(t=>{t.key==="Escape"&&t.currentTarget.blur()},[]),v=e.useMemo(()=>e.createElement(I.Button,{rounded:"full",fillMode:"solid",themeColor:"primary",className:"k-chat-send",icon:"paper-plane",svgIcon:F.paperPlaneIcon,onClick:w,onMouseDown:Y,onKeyDown:Z,"aria-label":c.toLanguageString(s.newMessageSendButton,s.messages[s.newMessageSendButton]),dir:b?"rtl":void 0,disabled:!C,"aria-disabled":!C,...L}),[w,Y,Z,c,b,C,L]),ee=e.useCallback(()=>{const t=typeof y=="object"?y:void 0,n=typeof o=="object"?o:{},{className:u,...i}=n,T=D.classNames("k-hidden",u),ue=o!==!1,ie=y!==!1;return e.createElement(ne.InputSuffix,null,ie&&e.createElement(I.SpeechToTextButton,{fillMode:"clear",themeColor:"base",onError:Q,onResult:W,...t}),ue&&e.createElement(e.Fragment,null,e.createElement(I.Button,{key:"attach-file",fillMode:"clear",themeColor:"base",svgIcon:F.paperclipIcon,onClick:J,"aria-label":c.toLanguageString(s.attachFile,s.messages[s.attachFile])}),e.createElement(ge.Upload,{ref:N,files:r,onAdd:$,multiple:!0,autoUpload:!1,...i,className:T})),e.createElement("span",{className:"k-spacer"}),v)},[y,o,r,Q,W,J,$,c,v]),te=e.useMemo(()=>e.createElement(ne.TextArea,{className:D.classNames("k-message-box","!k-flex-col",{"k-focus":P}),resizable:"none",rows:1,placeholder:q,value:l,onChange:U,onKeyDown:A,onClick:j,prefix:X,suffix:ee,ref:h,"aria-label":c.toLanguageString(s.newMessageMessageInput,s.messages[s.newMessageMessageInput])}),[P,q,l,U,A,j,X,ee,c]);return e.createElement("div",{className:"k-message-box-wrapper"},R&&R.length>0&&e.createElement(pe.SuggestionGroup,{onSuggestionClick:oe,suggestions:R,suggestionTemplate:le,suggestionsLayout:re,dir:ce}),z?e.createElement(z,{messageInput:te,sendButton:v}):te)});ae.displayName="NewMessage";module.exports=ae;
8
+ "use strict";const Z=require("@progress/kendo-react-common"),$=require("react"),ee=require("@progress/kendo-react-buttons"),te=require("./SuggestionsGroup.js"),ne=require("@progress/kendo-svg-icons"),se=require("./ChatContext.js"),oe=require("@progress/kendo-react-intl"),H=require("../utils.js"),t=require("../../messages/index.js"),ae=require("../../prompt-box/PromptBoxUploadButton.js"),re=require("../../prompt-box/PromptBox.js");function le(l){const c=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(l){for(const o in l)if(o!=="default"){const g=Object.getOwnPropertyDescriptor(l,o);Object.defineProperty(c,o,g.get?g:{enumerable:!0,get:()=>l[o]})}}return c.default=l,Object.freeze(c)}const e=le($),_=e.memo(({affixProps:l,uploadConfig:c,localizationService:o,onFilesSelect:g,onFileRemove:S})=>{const k=typeof c=="object"?c:{};return c!==!1?e.createElement(ae.PromptBoxUploadButton,{...l.uploadButtonProps,fillMode:"clear",size:void 0,"aria-label":o.toLanguageString(t.attachFile,t.messages[t.attachFile]),title:o.toLanguageString(t.attachFile,t.messages[t.attachFile]),...k,onSelectAttachments:g,onRemoveAttachment:S}):null});_.displayName="UploadButtonAffix";const J=e.forwardRef((l,c)=>{const{onSendMessage:o,isDirectionRightToLeft:g,placeholder:S,MessageBox:k,suggestions:x,onSuggestionClick:K,inputValue:T,onInputValueChange:p,suggestionTemplate:Q,sendButtonConfig:C,onInputClick:E,suggestionsLayout:W,dir:X,messageBoxSettings:r,loading:B}=l,{replyToMessage:u,setReplyToMessage:b,user:M,messageListScrollContainerRef:m,speechToTextConfig:A,uploadConfig:P}=se.useChatContext(),[Y,F]=e.useState(""),[y,R]=e.useState([]),[I,L]=e.useState(!1),v=e.useRef(null),s=oe.useLocalization(),f=T!==void 0,w=f?T:Y,i=e.useCallback(()=>{v.current!==null&&v.current.focus()},[]);e.useEffect(()=>{u&&i()},[u,i]),e.useLayoutEffect(()=>{I&&(m!=null&&m.current)&&(m.current.scrollTop=m.current.scrollHeight-m.current.clientHeight,L(!1))},[I,m]);const q=e.useCallback(n=>{if(n.preventDefault(),o){const h={id:"",author:M,text:w||"",timestamp:new Date,replyToId:u?u.id:void 0,files:y.map(d=>({name:d.name,size:d.size,type:d.extension,rawFile:d.getRawFile?d.getRawFile():d}))};b(null),o(h,n),R([]),f||F(""),p&&p(""),L(!0),i()}},[o,w,M,u,y,b,p,i,f]);e.useImperativeHandle(c,()=>({focusInput:i}),[i]);const N=e.useCallback(n=>{R(a=>a.filter(h=>h.name!==n))},[]),D=e.useCallback((n,a)=>n.isDeleted?H.getDeletedMessageText(a,s):n.text,[s]),j=e.useCallback(()=>{if(u){const n=H.isAuthor(M,u);return e.createElement("div",{className:Z.classNames("k-message-reference",n?"k-message-reference-sender":"k-message-reference-receiver")},e.createElement("div",{className:"k-message-reference-content"},D(u,n)),e.createElement("span",{className:"k-spacer"}),e.createElement(ee.Button,{fillMode:"flat",svgIcon:ne.xMarkSmOutlineIcon,onClick:()=>b(null),"aria-label":s.toLanguageString(t.closeReply,t.messages[t.closeReply]),title:s.toLanguageString(t.closeReply,t.messages[t.closeReply])}))}return null},[u,M,D,b,s]),G=e.useCallback(n=>{try{const a=Array.from(n.allFiles);R(a)}catch{}},[]);e.useEffect(()=>{i()},[T,i]);const O=e.useCallback(n=>{const a=n.value;f||F(a),p&&p(a||"")},[f,p]),U=e.useCallback(n=>{q(n.syntheticEvent)},[q]),V=e.useCallback(n=>e.createElement(_,{affixProps:n,uploadConfig:P,localizationService:s,onFilesSelect:G,onFileRemove:N}),[P,s,G,N]),z=e.useMemo(()=>{const n=typeof C=="object"?C:{},h=C!==!1?{"aria-label":B?s.toLanguageString(t.chatStopGenerating,t.messages[t.chatStopGenerating]):s.toLanguageString(t.newMessageSendButton,t.messages[t.newMessageSendButton]),title:B?s.toLanguageString(t.chatStopGenerating,t.messages[t.chatStopGenerating]):s.toLanguageString(t.newMessageSendButton,t.messages[t.newMessageSendButton]),dir:g?"rtl":void 0,...n}:!1;return e.createElement(re.PromptBox,{header:j(),ref:v,placeholder:S,value:w,onChange:O,onPromptAction:U,mode:(r==null?void 0:r.mode)||"multi",rows:(r==null?void 0:r.rows)||2,maxTextAreaHeight:(r==null?void 0:r.maxTextAreaHeight)||"110",loading:B,speechToTextButtonConfig:A,actionButtonConfig:h,attachments:y,startAffix:V,inputAttributes:{onClick:E,"aria-label":s.toLanguageString(t.newMessageMessageInput,t.messages[t.newMessageMessageInput])}})},[S,w,O,U,r,B,A,C,y,j,V,s,g,E]);return e.createElement("div",{className:"k-message-box-wrapper"},x&&x.length>0&&e.createElement(te.SuggestionGroup,{onSuggestionClick:K,suggestions:x,suggestionTemplate:Q,suggestionsLayout:W,dir:X}),k?e.createElement(k,{messageInput:z}):z)});J.displayName="NewMessage";module.exports=J;
@@ -5,276 +5,224 @@
5
5
  * Licensed under commercial license. See LICENSE.md in the package root for more information
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
- import { classNames as v } from "@progress/kendo-react-common";
8
+ import { classNames as te } from "@progress/kendo-react-common";
9
9
  import * as e from "react";
10
- import { Button as N, SpeechToTextButton as fe } from "@progress/kendo-react-buttons";
11
- import { Upload as me } from "@progress/kendo-react-upload";
12
- import { SuggestionGroup as pe } from "./SuggestionsGroup.mjs";
13
- import { InputSuffix as ge, TextArea as de } from "@progress/kendo-react-inputs";
14
- import { xIcon as ke, paperPlaneIcon as he, paperclipIcon as Ce } from "@progress/kendo-svg-icons";
15
- import { useChatContext as be } from "./ChatContext.mjs";
16
- import { useLocalization as xe } from "@progress/kendo-react-intl";
17
- import { getDeletedMessageText as Ee, isAuthor as Se } from "../utils.mjs";
18
- import { closeReply as _, messages as S, newMessageSendButton as ee, attachFile as te, newMessageMessageInput as se } from "../../messages/index.mjs";
19
- import ye from "./elements/FileBox.mjs";
20
- const Te = e.forwardRef((ne, ae) => {
10
+ import { Button as oe } from "@progress/kendo-react-buttons";
11
+ import { SuggestionGroup as ne } from "./SuggestionsGroup.mjs";
12
+ import { xMarkSmOutlineIcon as ae } from "@progress/kendo-svg-icons";
13
+ import { useChatContext as se } from "./ChatContext.mjs";
14
+ import { useLocalization as re } from "@progress/kendo-react-intl";
15
+ import { getDeletedMessageText as le, isAuthor as ce } from "../utils.mjs";
16
+ import { closeReply as v, messages as r, chatStopGenerating as y, newMessageSendButton as w, newMessageMessageInput as W, attachFile as E } from "../../messages/index.mjs";
17
+ import { PromptBoxUploadButton as ie } from "../../prompt-box/PromptBoxUploadButton.mjs";
18
+ import { PromptBox as ue } from "../../prompt-box/PromptBox.mjs";
19
+ const X = e.memo(
20
+ ({ affixProps: A, uploadConfig: g, localizationService: i, onFilesSelect: d, onFileRemove: h }) => {
21
+ const C = typeof g == "object" ? g : {};
22
+ return g !== !1 ? /* @__PURE__ */ e.createElement(
23
+ ie,
24
+ {
25
+ ...A.uploadButtonProps,
26
+ fillMode: "clear",
27
+ size: void 0,
28
+ "aria-label": i.toLanguageString(E, r[E]),
29
+ title: i.toLanguageString(E, r[E]),
30
+ ...C,
31
+ onSelectAttachments: d,
32
+ onRemoveAttachment: h
33
+ }
34
+ ) : null;
35
+ }
36
+ );
37
+ X.displayName = "UploadButtonAffix";
38
+ const me = e.forwardRef((A, g) => {
21
39
  const {
22
- onSendMessage: y,
23
- isDirectionRightToLeft: B,
24
- placeholder: F,
25
- MessageBox: R,
26
- suggestions: T,
27
- onSuggestionClick: oe,
28
- inputValue: d,
29
- onInputValueChange: m,
30
- suggestionTemplate: le,
31
- sendButtonConfig: D,
32
- onInputClick: L,
33
- suggestionsLayout: re,
34
- dir: ce
35
- } = ne, { replyToMessage: n, setReplyToMessage: k, user: h, messageListScrollContainerRef: f, speechToTextConfig: C, uploadConfig: a } = be(), [z] = e.useState(!1), [o, b] = e.useState(void 0), [l, M] = e.useState([]), [K, A] = e.useState(!1), p = e.useRef(null), w = e.useRef(null), r = xe(), i = e.useCallback(() => {
36
- p.current !== null && p.current.focus();
40
+ onSendMessage: i,
41
+ isDirectionRightToLeft: d,
42
+ placeholder: h,
43
+ MessageBox: C,
44
+ suggestions: x,
45
+ onSuggestionClick: Y,
46
+ inputValue: L,
47
+ onInputValueChange: u,
48
+ suggestionTemplate: Z,
49
+ sendButtonConfig: S,
50
+ onInputClick: I,
51
+ suggestionsLayout: _,
52
+ dir: $,
53
+ messageBoxSettings: a,
54
+ loading: k
55
+ } = A, { replyToMessage: s, setReplyToMessage: T, user: b, messageListScrollContainerRef: c, speechToTextConfig: N, uploadConfig: P } = se(), [ee, V] = e.useState(""), [B, R] = e.useState([]), [D, H] = e.useState(!1), F = e.useRef(null), o = re(), p = L !== void 0, M = p ? L : ee, l = e.useCallback(() => {
56
+ F.current !== null && F.current.focus();
37
57
  }, []);
38
58
  e.useEffect(() => {
39
- d !== void 0 && d !== o && (b(d), i());
40
- }, [d, o, i]), e.useEffect(() => {
41
- n && i();
42
- }, [n, i]), e.useLayoutEffect(() => {
43
- K && (f != null && f.current) && (f.current.scrollTop = f.current.scrollHeight - f.current.clientHeight, A(!1));
44
- }, [K, f]);
45
- const P = e.useCallback(
59
+ s && l();
60
+ }, [s, l]), e.useLayoutEffect(() => {
61
+ D && (c != null && c.current) && (c.current.scrollTop = c.current.scrollHeight - c.current.clientHeight, H(!1));
62
+ }, [D, c]);
63
+ const U = e.useCallback(
46
64
  (t) => {
47
- const s = t.value;
48
- b(s), m && m(s);
49
- },
50
- [m]
51
- ), g = e.useMemo(
52
- () => !!(o != null && o.trim() || a !== !1 && l.length > 0),
53
- [o, l.length, a]
54
- ), x = e.useCallback(
55
- (t) => {
56
- if (t.preventDefault(), y) {
57
- const s = o;
58
- if (g) {
59
- const c = {
60
- id: "",
61
- author: h,
62
- text: s || "",
63
- timestamp: /* @__PURE__ */ new Date(),
64
- replyToId: n ? n.id : void 0,
65
- files: l.map((u) => ({
66
- name: u.name,
67
- size: u.size,
68
- type: u.extension,
69
- rawFile: u.getRawFile ? u.getRawFile() : u
70
- }))
71
- };
72
- k(null), y(c, t), M([]), b(""), m && m(""), A(!0);
73
- }
65
+ if (t.preventDefault(), i) {
66
+ const f = {
67
+ id: "",
68
+ author: b,
69
+ text: M || "",
70
+ timestamp: /* @__PURE__ */ new Date(),
71
+ replyToId: s ? s.id : void 0,
72
+ files: B.map((m) => ({
73
+ name: m.name,
74
+ size: m.size,
75
+ type: m.extension,
76
+ rawFile: m.getRawFile ? m.getRawFile() : m
77
+ }))
78
+ };
79
+ T(null), i(f, t), R([]), p || V(""), u && u(""), H(!0), l();
74
80
  }
75
81
  },
76
82
  [
77
- y,
78
- o,
79
- h,
80
- n,
83
+ i,
84
+ M,
85
+ b,
86
+ s,
87
+ B,
88
+ T,
89
+ u,
81
90
  l,
82
- k,
83
- m,
84
- g
91
+ p
85
92
  ]
86
- ), U = e.useCallback(
87
- (t) => {
88
- if (!(t.key === "Enter" && t.shiftKey))
89
- switch (t.key) {
90
- case "Enter":
91
- return t.preventDefault(), x(t);
92
- case "Escape":
93
- p.current && p.current.blur();
94
- break;
95
- default:
96
- return;
97
- }
98
- },
99
- [x]
100
93
  );
101
94
  e.useImperativeHandle(
102
- ae,
95
+ g,
103
96
  () => ({
104
- focusInput: i
97
+ focusInput: l
105
98
  }),
106
- [i]
99
+ [l]
107
100
  );
108
- const H = e.useCallback((t) => {
109
- M((s) => s.filter((c) => c.name !== t));
110
- }, []), V = e.useCallback(() => a === !1 ? null : /* @__PURE__ */ e.createElement(ye, { files: l, onFileRemove: H, renderInTextarea: !0 }), [l, H, a]), j = e.useCallback(
111
- (t, s) => t.isDeleted ? Ee(s, r) : t.text,
112
- [r]
101
+ const z = e.useCallback((t) => {
102
+ R((n) => n.filter((f) => f.name !== t));
103
+ }, []), j = e.useCallback(
104
+ (t, n) => t.isDeleted ? le(n, o) : t.text,
105
+ [o]
113
106
  ), G = e.useCallback(() => {
114
- if (n) {
115
- const t = Se(h, n);
107
+ if (s) {
108
+ const t = ce(b, s);
116
109
  return /* @__PURE__ */ e.createElement(
117
110
  "div",
118
111
  {
119
- className: v(
112
+ className: te(
120
113
  "k-message-reference",
121
114
  t ? "k-message-reference-sender" : "k-message-reference-receiver"
122
115
  )
123
116
  },
124
- /* @__PURE__ */ e.createElement("div", { className: "k-message-reference-content" }, j(n, t)),
117
+ /* @__PURE__ */ e.createElement("div", { className: "k-message-reference-content" }, j(s, t)),
125
118
  /* @__PURE__ */ e.createElement("span", { className: "k-spacer" }),
126
119
  /* @__PURE__ */ e.createElement(
127
- N,
120
+ oe,
128
121
  {
129
122
  fillMode: "flat",
130
- themeColor: "base",
131
- svgIcon: ke,
132
- onClick: () => k(null),
133
- "aria-label": r.toLanguageString(_, S[_])
123
+ svgIcon: ae,
124
+ onClick: () => T(null),
125
+ "aria-label": o.toLanguageString(v, r[v]),
126
+ title: o.toLanguageString(v, r[v])
134
127
  }
135
128
  )
136
129
  );
137
130
  }
138
131
  return null;
139
- }, [n, h, j, k, r]), $ = e.useCallback(
132
+ }, [s, b, j, T, o]), O = e.useCallback((t) => {
133
+ try {
134
+ const n = Array.from(t.allFiles);
135
+ R(n);
136
+ } catch {
137
+ }
138
+ }, []);
139
+ e.useEffect(() => {
140
+ l();
141
+ }, [L, l]);
142
+ const q = e.useCallback(
140
143
  (t) => {
141
- try {
142
- const s = Array.from(t.newState);
143
- M((c) => [...c, ...s]), i();
144
- } catch {
145
- }
144
+ const n = t.value;
145
+ p || V(n), u && u(n || "");
146
146
  },
147
- [i]
148
- ), q = e.useCallback(() => {
149
- w.current && a !== !1 && w.current.actionElement.click();
150
- }, [a]), J = e.useCallback((t) => {
151
- }, []), O = e.useCallback((t) => {
152
- const { isFinal: s, alternatives: c } = t;
153
- if (c.length > 0) {
154
- const u = c[0];
155
- s && b((E) => (E ? `${E} ` : "") + u.transcript);
156
- }
157
- }, []), Q = e.useCallback(() => /* @__PURE__ */ e.createElement(e.Fragment, null, l.length > 0 && V(), n && /* @__PURE__ */ e.createElement("span", { className: "k-input-prefix k-input-prefix-horizontal" }, G())), [l.length, n, V, G]), W = e.useCallback((t) => {
158
- t.preventDefault();
159
- }, []), X = e.useCallback((t) => {
160
- t.key === "Escape" && t.currentTarget.blur();
161
- }, []), I = e.useMemo(
162
- () => /* @__PURE__ */ e.createElement(
163
- N,
164
- {
165
- rounded: "full",
166
- fillMode: "solid",
167
- themeColor: "primary",
168
- className: "k-chat-send",
169
- icon: "paper-plane",
170
- svgIcon: he,
171
- onClick: x,
172
- onMouseDown: W,
173
- onKeyDown: X,
174
- "aria-label": r.toLanguageString(ee, S[ee]),
175
- dir: B ? "rtl" : void 0,
176
- disabled: !g,
177
- "aria-disabled": !g,
178
- ...D
179
- }
180
- ),
181
- [
182
- x,
183
- W,
147
+ [p, u]
148
+ ), J = e.useCallback(
149
+ (t) => {
150
+ U(t.syntheticEvent);
151
+ },
152
+ [U]
153
+ ), K = e.useCallback(
154
+ (t) => /* @__PURE__ */ e.createElement(
184
155
  X,
185
- r,
186
- B,
187
- g,
188
- D
189
- ]
190
- ), Y = e.useCallback(() => {
191
- const t = typeof C == "object" ? C : void 0, s = typeof a == "object" ? a : {}, { className: c, ...u } = s, E = v("k-hidden", c), ue = a !== !1, ie = C !== !1;
192
- return /* @__PURE__ */ e.createElement(ge, null, ie && /* @__PURE__ */ e.createElement(
193
- fe,
194
- {
195
- fillMode: "clear",
196
- themeColor: "base",
197
- onError: J,
198
- onResult: O,
199
- ...t
200
- }
201
- ), ue && /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(
202
- N,
203
156
  {
204
- key: "attach-file",
205
- fillMode: "clear",
206
- themeColor: "base",
207
- svgIcon: Ce,
208
- onClick: q,
209
- "aria-label": r.toLanguageString(te, S[te])
157
+ affixProps: t,
158
+ uploadConfig: P,
159
+ localizationService: o,
160
+ onFilesSelect: O,
161
+ onFileRemove: z
210
162
  }
211
- ), /* @__PURE__ */ e.createElement(
212
- me,
163
+ ),
164
+ [P, o, O, z]
165
+ ), Q = e.useMemo(() => {
166
+ const t = typeof S == "object" ? S : {}, f = S !== !1 ? {
167
+ "aria-label": k ? o.toLanguageString(y, r[y]) : o.toLanguageString(w, r[w]),
168
+ title: k ? o.toLanguageString(y, r[y]) : o.toLanguageString(w, r[w]),
169
+ dir: d ? "rtl" : void 0,
170
+ ...t
171
+ } : !1;
172
+ return /* @__PURE__ */ e.createElement(
173
+ ue,
213
174
  {
214
- ref: w,
215
- files: l,
216
- onAdd: $,
217
- multiple: !0,
218
- autoUpload: !1,
219
- ...u,
220
- className: E
175
+ header: G(),
176
+ ref: F,
177
+ placeholder: h,
178
+ value: M,
179
+ onChange: q,
180
+ onPromptAction: J,
181
+ mode: (a == null ? void 0 : a.mode) || "multi",
182
+ rows: (a == null ? void 0 : a.rows) || 2,
183
+ maxTextAreaHeight: (a == null ? void 0 : a.maxTextAreaHeight) || "110",
184
+ loading: k,
185
+ speechToTextButtonConfig: N,
186
+ actionButtonConfig: f,
187
+ attachments: B,
188
+ startAffix: K,
189
+ inputAttributes: {
190
+ onClick: I,
191
+ "aria-label": o.toLanguageString(
192
+ W,
193
+ r[W]
194
+ )
195
+ }
221
196
  }
222
- )), /* @__PURE__ */ e.createElement("span", { className: "k-spacer" }), I);
197
+ );
223
198
  }, [
224
- C,
225
- a,
226
- l,
227
- J,
228
- O,
199
+ h,
200
+ M,
229
201
  q,
230
- $,
231
- r,
202
+ J,
203
+ a,
204
+ k,
205
+ N,
206
+ S,
207
+ B,
208
+ G,
209
+ K,
210
+ o,
211
+ d,
232
212
  I
233
- ]), Z = e.useMemo(
234
- () => /* @__PURE__ */ e.createElement(
235
- de,
236
- {
237
- className: v("k-message-box", "!k-flex-col", { "k-focus": z }),
238
- resizable: "none",
239
- rows: 1,
240
- placeholder: F,
241
- value: o,
242
- onChange: P,
243
- onKeyDown: U,
244
- onClick: L,
245
- prefix: Q,
246
- suffix: Y,
247
- ref: p,
248
- "aria-label": r.toLanguageString(
249
- se,
250
- S[se]
251
- )
252
- }
253
- ),
254
- [
255
- z,
256
- F,
257
- o,
258
- P,
259
- U,
260
- L,
261
- Q,
262
- Y,
263
- r
264
- ]
265
- );
266
- return /* @__PURE__ */ e.createElement("div", { className: "k-message-box-wrapper" }, T && T.length > 0 && /* @__PURE__ */ e.createElement(
267
- pe,
213
+ ]);
214
+ return /* @__PURE__ */ e.createElement("div", { className: "k-message-box-wrapper" }, x && x.length > 0 && /* @__PURE__ */ e.createElement(
215
+ ne,
268
216
  {
269
- onSuggestionClick: oe,
270
- suggestions: T,
271
- suggestionTemplate: le,
272
- suggestionsLayout: re,
273
- dir: ce
217
+ onSuggestionClick: Y,
218
+ suggestions: x,
219
+ suggestionTemplate: Z,
220
+ suggestionsLayout: _,
221
+ dir: $
274
222
  }
275
- ), R ? /* @__PURE__ */ e.createElement(R, { messageInput: Z, sendButton: I }) : Z);
223
+ ), C ? /* @__PURE__ */ e.createElement(C, { messageInput: Q }) : Q);
276
224
  });
277
- Te.displayName = "NewMessage";
225
+ me.displayName = "NewMessage";
278
226
  export {
279
- Te as default
227
+ me as default
280
228
  };
@@ -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 p=require("react"),m=require("@progress/kendo-react-buttons"),r=require("@progress/kendo-svg-icons"),v=require("@progress/kendo-react-intl"),n=require("../../messages/index.js");function L(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const o in t)if(o!=="default"){const l=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(e,o,l.get?l:{enumerable:!0,get:()=>t[o]})}}return e.default=t,Object.freeze(e)}const c=L(p),h=({visible:t,dir:e,canScrollLeft:o,canScrollRight:l,onScrollLeft:b,onScrollRight:f,children:s})=>{const a=v.useLocalization();if(!t)return s;const i=a.toLanguageString(n.scrollLeft,n.messages[n.scrollLeft]),u=a.toLanguageString(n.scrollRight,n.messages[n.scrollRight]),g=e!=="rtl"?i:u,d=e!=="rtl"?u:i;return c.createElement("div",{className:"k-suggestion-scrollwrap"},c.createElement(m.Button,{fillMode:"solid",themeColor:"base",size:"medium",rounded:"medium",svgIcon:e==="rtl"?r.chevronRightIcon:r.chevronLeftIcon,onClick:b,disabled:!o,className:"k-icon-button","aria-label":g,title:g}),s,c.createElement(m.Button,{fillMode:"solid",themeColor:"base",size:"medium",rounded:"medium",svgIcon:e==="rtl"?r.chevronLeftIcon:r.chevronRightIcon,onClick:f,disabled:!l,className:"k-icon-button","aria-label":d,title:d}))};exports.ScrollButtonsWrapper=h;
8
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("react"),b=require("@progress/kendo-react-buttons"),r=require("@progress/kendo-svg-icons"),v=require("@progress/kendo-react-intl"),l=require("../../messages/index.js");function L(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const o in t)if(o!=="default"){const n=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(e,o,n.get?n:{enumerable:!0,get:()=>t[o]})}}return e.default=t,Object.freeze(e)}const c=L(p),S=({visible:t,dir:e,canScrollLeft:o,canScrollRight:n,onScrollLeft:d,onScrollRight:m,children:a})=>{const s=v.useLocalization();if(!t)return a;const i=s.toLanguageString(l.scrollLeft,l.messages[l.scrollLeft]),u=s.toLanguageString(l.scrollRight,l.messages[l.scrollRight]),g=e!=="rtl"?i:u,f=e!=="rtl"?u:i;return c.createElement("div",{className:"k-suggestion-scrollwrap"},c.createElement(b.Button,{fillMode:"flat",size:"small",svgIcon:e==="rtl"?r.chevronRightIcon:r.chevronLeftIcon,onClick:d,disabled:!o,"aria-label":g,title:g}),a,c.createElement(b.Button,{fillMode:"flat",size:"small",svgIcon:e==="rtl"?r.chevronLeftIcon:r.chevronRightIcon,onClick:m,disabled:!n,"aria-label":f,title:f}))};exports.ScrollButtonsWrapper=S;
@@ -5,54 +5,48 @@
5
5
  * Licensed under commercial license. See LICENSE.md in the package root for more information
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
- import * as o from "react";
9
- import { Button as n } from "@progress/kendo-react-buttons";
10
- import { chevronRightIcon as c, chevronLeftIcon as m } from "@progress/kendo-svg-icons";
11
- import { useLocalization as h } from "@progress/kendo-react-intl";
12
- import { scrollLeft as u, messages as g, scrollRight as d } from "../../messages/index.mjs";
13
- const R = ({
14
- visible: b,
15
- dir: e,
16
- canScrollLeft: f,
17
- canScrollRight: p,
18
- onScrollLeft: L,
19
- onScrollRight: v,
20
- children: t
8
+ import * as e from "react";
9
+ import { Button as c } from "@progress/kendo-react-buttons";
10
+ import { chevronRightIcon as i, chevronLeftIcon as m } from "@progress/kendo-svg-icons";
11
+ import { useLocalization as z } from "@progress/kendo-react-intl";
12
+ import { scrollLeft as g, messages as f, scrollRight as p } from "../../messages/index.mjs";
13
+ const k = ({
14
+ visible: L,
15
+ dir: t,
16
+ canScrollLeft: b,
17
+ canScrollRight: u,
18
+ onScrollLeft: v,
19
+ onScrollRight: h,
20
+ children: l
21
21
  }) => {
22
- const l = h();
23
- if (!b)
24
- return t;
25
- const r = l.toLanguageString(u, g[u]), a = l.toLanguageString(d, g[d]), s = e !== "rtl" ? r : a, i = e !== "rtl" ? a : r;
26
- return /* @__PURE__ */ o.createElement("div", { className: "k-suggestion-scrollwrap" }, /* @__PURE__ */ o.createElement(
27
- n,
22
+ const o = z();
23
+ if (!L)
24
+ return l;
25
+ const r = o.toLanguageString(g, f[g]), a = o.toLanguageString(p, f[p]), s = t !== "rtl" ? r : a, n = t !== "rtl" ? a : r;
26
+ return /* @__PURE__ */ e.createElement("div", { className: "k-suggestion-scrollwrap" }, /* @__PURE__ */ e.createElement(
27
+ c,
28
28
  {
29
- fillMode: "solid",
30
- themeColor: "base",
31
- size: "medium",
32
- rounded: "medium",
33
- svgIcon: e === "rtl" ? c : m,
34
- onClick: L,
35
- disabled: !f,
36
- className: "k-icon-button",
29
+ fillMode: "flat",
30
+ size: "small",
31
+ svgIcon: t === "rtl" ? i : m,
32
+ onClick: v,
33
+ disabled: !b,
37
34
  "aria-label": s,
38
35
  title: s
39
36
  }
40
- ), t, /* @__PURE__ */ o.createElement(
41
- n,
37
+ ), l, /* @__PURE__ */ e.createElement(
38
+ c,
42
39
  {
43
- fillMode: "solid",
44
- themeColor: "base",
45
- size: "medium",
46
- rounded: "medium",
47
- svgIcon: e === "rtl" ? m : c,
48
- onClick: v,
49
- disabled: !p,
50
- className: "k-icon-button",
51
- "aria-label": i,
52
- title: i
40
+ fillMode: "flat",
41
+ size: "small",
42
+ svgIcon: t === "rtl" ? m : i,
43
+ onClick: h,
44
+ disabled: !u,
45
+ "aria-label": n,
46
+ title: n
53
47
  }
54
48
  ));
55
49
  };
56
50
  export {
57
- R as ScrollButtonsWrapper
51
+ k as ScrollButtonsWrapper
58
52
  };
@@ -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"),p=require("@progress/kendo-react-common"),h=require("./ScrollButtonsWrapper.js"),D=require("../hooks/useScrollWithButtons.js");function O(r){const l=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(l,t,s.get?s:{enumerable:!0,get:()=>r[t]})}}return l.default=r,Object.freeze(l)}const o=O(R),g=r=>{const{suggestions:l,onSuggestionClick:t,suggestionsView:s,suggestionTemplate:c,suggestionsLayout:a,dir:i}=r,u=o.useRef(null),{canScrollLeft:f,canScrollRight:m,scrollLeft:y,scrollRight:S}=D.useScrollWithButtons(u,{enabled:a==="scrollbuttons",dir:i,itemsDependency:l}),d=o.useCallback((e,n)=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),t==null||t(n))},[t]),b=o.useCallback(()=>l.map(e=>c?o.createElement(c,{key:e.id,suggestion:e,onClick:()=>{t==null||t(e)}}):o.createElement("span",{role:"button",tabIndex:e.disabled?-1:0,"aria-label":e.description,"aria-disabled":e.disabled,onClick:()=>!e.disabled&&(t==null?void 0:t(e)),onKeyDown:n=>!e.disabled&&d(n,e),key:e.id,title:e.description,className:p.classNames(s==="classic"?"k-prompt-suggestion":"k-suggestion",{"k-disabled":e.disabled})},e.text)),[l,c,t,s,d]);if(!l||l.length===0)return null;if(s==="classic")return b();const k=o.createElement("div",{role:"group",className:p.classNames("k-suggestion-group",{"k-suggestion-group-scrollable":a==="scroll"}),ref:a==="scrollbuttons"?u:void 0},b());return o.createElement(h.ScrollButtonsWrapper,{visible:a==="scrollbuttons",dir:i,canScrollLeft:f,canScrollRight:m,onScrollLeft:y,onScrollRight:S},k)};exports.SuggestionGroup=g;
8
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const R=require("react"),f=require("@progress/kendo-react-common"),h=require("./ScrollButtonsWrapper.js"),D=require("../hooks/useScrollWithButtons.js");function E(o){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const t in o)if(t!=="default"){const c=Object.getOwnPropertyDescriptor(o,t);Object.defineProperty(r,t,c.get?c:{enumerable:!0,get:()=>o[t]})}}return r.default=o,Object.freeze(r)}const s=E(R),N=o=>{const{suggestions:r,onSuggestionClick:t,suggestionsView:c,suggestionTemplate:n,suggestionsLayout:l,dir:u}=o,d=s.useRef(null),{canScrollLeft:b,canScrollRight:p,scrollLeft:g,scrollRight:k}=D.useScrollWithButtons(d,{enabled:l==="scrollbuttons"||l==="scroll",dir:u,mode:l,itemsDependency:r}),m=s.useCallback((e,i)=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),t==null||t(i))},[t]),a=s.useCallback(()=>r.map(e=>n?s.createElement(n,{key:e.id,suggestion:e,onClick:()=>{t==null||t(e)}}):s.createElement("span",{role:"button",tabIndex:e.disabled?-1:0,"aria-label":e.description,"aria-disabled":e.disabled,onClick:()=>!e.disabled&&(t==null?void 0:t(e)),onKeyDown:i=>!e.disabled&&m(i,e),key:e.id,title:e.description,className:f.classNames(c==="classic"?"k-prompt-suggestion":"k-suggestion",{"k-disabled":e.disabled})},e.text)),[r,n,t,c,m]);if(!r||r.length===0)return null;if(c==="classic")return a();const y=l==="scroll"||l==="scrollbuttons",S=s.createElement("div",{role:"group",className:f.classNames("k-suggestion-group",{"k-suggestion-group-scrollable":l==="scroll","k-suggestion-group-scrollable-start":p&&(l==="scroll"||l==="scrollbuttons"),"k-suggestion-group-scrollable-end":b&&(l==="scroll"||l==="scrollbuttons")})},y?s.createElement("div",{className:"k-suggestions-scroll",ref:d},a()):a());return s.createElement(h.ScrollButtonsWrapper,{visible:l==="scrollbuttons",dir:u,canScrollLeft:b,canScrollRight:p,onScrollLeft:g,onScrollRight:k},S)};exports.SuggestionGroup=N;