@progress/kendo-react-conversational-ui 12.0.2-develop.5 → 12.0.2-develop.7
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/chat/components/Chat.js +1 -1
- package/chat/components/Chat.mjs +207 -231
- package/chat/components/NewMessage.js +1 -1
- package/chat/components/NewMessage.mjs +96 -84
- package/chat/utils/scroll.js +12 -0
- package/chat/utils/scroll.mjs +161 -0
- package/dist/cdn/js/kendo-react-conversational-ui.js +1 -1
- package/index.d.mts +2 -3
- package/index.d.ts +2 -3
- package/package-metadata.js +1 -1
- package/package-metadata.mjs +2 -2
- package/package.json +11 -11
|
@@ -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"),
|
|
8
|
+
"use strict";const D=require("@progress/kendo-react-common"),re=require("react"),T=require("@progress/kendo-react-buttons"),ce=require("@progress/kendo-react-upload"),ue=require("./SuggestionsGroup.js"),se=require("@progress/kendo-react-inputs"),F=require("@progress/kendo-svg-icons"),ie=require("./ChatContext.js"),ge=require("@progress/kendo-react-intl"),ne=require("../utils.js"),n=require("../../messages/index.js"),fe=require("./elements/FileBox.js");function pe(f){const d=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(f){for(const i in f)if(i!=="default"){const k=Object.getOwnPropertyDescriptor(f,i);Object.defineProperty(d,i,k.get?k:{enumerable:!0,get:()=>f[i]})}}return d.default=f,Object.freeze(d)}const e=pe(re),ae=e.forwardRef((f,d)=>{const{onSendMessage:i,isDirectionRightToLeft:k,placeholder:q,MessageBox:z,suggestions:I,onSuggestionClick:oe,inputValue:C,onInputValueChange:m,suggestionTemplate:le,sendButtonConfig:j,onInputClick:L}=f,{replyToMessage:a,setReplyToMessage:S,user:x,messageListScrollContainerRef:p,speechToTextConfig:E,uploadConfig:R}=ie.useChatContext(),[P]=e.useState(!1),[o,y]=e.useState(void 0),[l,B]=e.useState([]),[K,O]=e.useState(!1),b=e.useRef(null),N=e.useRef(null),r=ge.useLocalization(),g=e.useCallback(()=>{b.current!==null&&b.current.focus()},[]);e.useEffect(()=>{C!==void 0&&C!==o&&(y(C),g())},[C,o,g]),e.useEffect(()=>{a&&g()},[a,g]),e.useLayoutEffect(()=>{K&&(p!=null&&p.current)&&(p.current.scrollTop=p.current.scrollHeight-p.current.clientHeight,O(!1))},[K,p]);const A=e.useCallback(t=>{const s=t.value;y(s),m&&m(s)},[m]),h=e.useMemo(()=>!!(o!=null&&o.trim()||l.length>0),[o,l.length]),M=e.useCallback(t=>{if(t.preventDefault(),i){const s=o;if(h){const c={id:"",author:x,text:s||"",timestamp:new Date,replyToId:a?a.id:void 0,files:l.map(u=>({name:u.name,size:u.size,type:u.extension,rawFile:u.getRawFile?u.getRawFile():u}))};S(null),i(c,t),B([]),y(""),m&&m(""),O(!0)}}},[i,o,x,a,l,S,m,h]),U=e.useCallback(t=>{if(!(t.key==="Enter"&&t.shiftKey))switch(t.key){case"Enter":return t.preventDefault(),M(t);case"Escape":b.current&&b.current.blur();break;default:return}},[M]);e.useImperativeHandle(d,()=>({focusInput:g}),[g]);const H=e.useCallback(t=>{B(s=>s.filter(c=>c.name!==t))},[]),V=e.useCallback(()=>e.createElement(fe,{files:l,onFileRemove:H,renderInTextarea:!0}),[l,H]),_=e.useCallback((t,s)=>t.isDeleted?ne.getDeletedMessageText(s,r):t.text,[r]),G=e.useCallback(()=>{if(a){const t=ne.isAuthor(x,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(T.Button,{fillMode:"flat",themeColor:"base",svgIcon:F.xIcon,onClick:()=>S(null),"aria-label":r.toLanguageString(n.closeReply,n.messages[n.closeReply])}))}return null},[a,x,_,S,r]),$=e.useCallback(t=>{try{const s=Array.from(t.newState);B(c=>[...c,...s]),g()}catch{}},[g]),J=e.useCallback(()=>{N.current&&N.current.actionElement.click()},[]),Q=e.useCallback(t=>{},[]),W=e.useCallback(t=>{const{isFinal:s,alternatives:c}=t;if(c.length>0){const u=c[0];s&&y(w=>(w?`${w} `:"")+u.transcript)}},[]),X=e.useCallback(()=>e.createElement(e.Fragment,null,l.length>0&&V(),a&&e.createElement("span",{className:"k-input-prefix k-input-prefix-horizontal"},G())),[l.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(T.Button,{rounded:"full",fillMode:"solid",themeColor:"primary",className:"k-chat-send",icon:"paper-plane",svgIcon:F.paperPlaneIcon,onClick:M,onMouseDown:Y,onKeyDown:Z,"aria-label":r.toLanguageString(n.newMessageSendButton,n.messages[n.newMessageSendButton]),dir:k?"rtl":void 0,disabled:!h,"aria-disabled":!h,...j}),[M,Y,Z,r,k,h,j]),ee=e.useCallback(()=>{const t=typeof E=="object"?E:void 0,s=typeof R=="object"?R:{},{className:c,...u}=s,w=D.classNames("k-hidden",c);return e.createElement(se.InputSuffix,null,E!==!1&&e.createElement(T.SpeechToTextButton,{fillMode:"clear",themeColor:"base",onError:Q,onResult:W,...t}),e.createElement(T.Button,{key:"attach-file",fillMode:"clear",themeColor:"base",svgIcon:F.paperclipIcon,onClick:J,"aria-label":r.toLanguageString(n.attachFile,n.messages[n.attachFile])}),e.createElement(ce.Upload,{ref:N,files:l,onAdd:$,multiple:!0,autoUpload:!1,...u,className:w}),e.createElement("span",{className:"k-spacer"}),v)},[E,R,l,Q,W,J,$,r,v]),te=e.useMemo(()=>e.createElement(se.TextArea,{className:D.classNames("k-message-box","!k-flex-col",{"k-focus":P}),resizable:"none",rows:1,placeholder:q,value:o,onChange:A,onKeyDown:U,onClick:L,prefix:X,suffix:ee,ref:b,"aria-label":r.toLanguageString(n.newMessageMessageInput,n.messages[n.newMessageMessageInput])}),[P,q,o,A,U,L,X,ee,r]);return e.createElement("div",{className:"k-message-box-wrapper"},I&&I.length>0&&e.createElement(ue.SuggestionGroup,{onSuggestionClick:oe,suggestions:I,suggestionTemplate:le}),z?e.createElement(z,{messageInput:te,sendButton:v}):te)});ae.displayName="NewMessage";module.exports=ae;
|
|
@@ -7,58 +7,59 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { classNames as v } from "@progress/kendo-react-common";
|
|
9
9
|
import * as e from "react";
|
|
10
|
-
import { Button as N, SpeechToTextButton as
|
|
11
|
-
import { Upload as
|
|
12
|
-
import { SuggestionGroup as
|
|
13
|
-
import { InputSuffix as
|
|
14
|
-
import { xIcon as
|
|
15
|
-
import { useChatContext as
|
|
16
|
-
import { useLocalization as
|
|
17
|
-
import { getDeletedMessageText as
|
|
18
|
-
import { closeReply as
|
|
10
|
+
import { Button as N, SpeechToTextButton as re } from "@progress/kendo-react-buttons";
|
|
11
|
+
import { Upload as ce } from "@progress/kendo-react-upload";
|
|
12
|
+
import { SuggestionGroup as ue } from "./SuggestionsGroup.mjs";
|
|
13
|
+
import { InputSuffix as ie, TextArea as me } from "@progress/kendo-react-inputs";
|
|
14
|
+
import { xIcon as fe, paperPlaneIcon as pe, paperclipIcon as ge } from "@progress/kendo-svg-icons";
|
|
15
|
+
import { useChatContext as de } from "./ChatContext.mjs";
|
|
16
|
+
import { useLocalization as ke } from "@progress/kendo-react-intl";
|
|
17
|
+
import { getDeletedMessageText as he, isAuthor as Ce } from "../utils.mjs";
|
|
18
|
+
import { closeReply as _, messages as E, newMessageSendButton as ee, attachFile as te, newMessageMessageInput as se } from "../../messages/index.mjs";
|
|
19
19
|
import be from "./elements/FileBox.mjs";
|
|
20
|
-
const
|
|
20
|
+
const xe = e.forwardRef((ne, ae) => {
|
|
21
21
|
const {
|
|
22
22
|
onSendMessage: S,
|
|
23
23
|
isDirectionRightToLeft: B,
|
|
24
24
|
placeholder: R,
|
|
25
25
|
MessageBox: D,
|
|
26
26
|
suggestions: y,
|
|
27
|
-
onSuggestionClick:
|
|
27
|
+
onSuggestionClick: oe,
|
|
28
28
|
inputValue: g,
|
|
29
29
|
onInputValueChange: m,
|
|
30
|
-
suggestionTemplate:
|
|
31
|
-
sendButtonConfig: F
|
|
32
|
-
|
|
30
|
+
suggestionTemplate: le,
|
|
31
|
+
sendButtonConfig: F,
|
|
32
|
+
onInputClick: z
|
|
33
|
+
} = ne, { replyToMessage: n, setReplyToMessage: d, user: k, messageListScrollContainerRef: i, speechToTextConfig: h, uploadConfig: M } = de(), [L] = e.useState(!1), [a, C] = e.useState(void 0), [o, w] = e.useState([]), [K, A] = e.useState(!1), f = e.useRef(null), T = e.useRef(null), l = ke(), u = e.useCallback(() => {
|
|
33
34
|
f.current !== null && f.current.focus();
|
|
34
35
|
}, []);
|
|
35
36
|
e.useEffect(() => {
|
|
36
|
-
g !== void 0 && g !==
|
|
37
|
-
}, [g,
|
|
38
|
-
|
|
39
|
-
}, [
|
|
40
|
-
|
|
41
|
-
}, [
|
|
42
|
-
const
|
|
37
|
+
g !== void 0 && g !== a && (C(g), u());
|
|
38
|
+
}, [g, a, u]), e.useEffect(() => {
|
|
39
|
+
n && u();
|
|
40
|
+
}, [n, u]), e.useLayoutEffect(() => {
|
|
41
|
+
K && (i != null && i.current) && (i.current.scrollTop = i.current.scrollHeight - i.current.clientHeight, A(!1));
|
|
42
|
+
}, [K, i]);
|
|
43
|
+
const P = e.useCallback(
|
|
43
44
|
(t) => {
|
|
44
45
|
const s = t.value;
|
|
45
|
-
|
|
46
|
+
C(s), m && m(s);
|
|
46
47
|
},
|
|
47
48
|
[m]
|
|
48
49
|
), p = e.useMemo(
|
|
49
|
-
() => !!(
|
|
50
|
-
[
|
|
51
|
-
),
|
|
50
|
+
() => !!(a != null && a.trim() || o.length > 0),
|
|
51
|
+
[a, o.length]
|
|
52
|
+
), b = e.useCallback(
|
|
52
53
|
(t) => {
|
|
53
54
|
if (t.preventDefault(), S) {
|
|
54
|
-
const s =
|
|
55
|
+
const s = a;
|
|
55
56
|
if (p) {
|
|
56
57
|
const r = {
|
|
57
58
|
id: "",
|
|
58
59
|
author: k,
|
|
59
60
|
text: s || "",
|
|
60
61
|
timestamp: /* @__PURE__ */ new Date(),
|
|
61
|
-
replyToId:
|
|
62
|
+
replyToId: n ? n.id : void 0,
|
|
62
63
|
files: o.map((c) => ({
|
|
63
64
|
name: c.name,
|
|
64
65
|
size: c.size,
|
|
@@ -66,26 +67,26 @@ const Ce = e.forwardRef((se, ae) => {
|
|
|
66
67
|
rawFile: c.getRawFile ? c.getRawFile() : c
|
|
67
68
|
}))
|
|
68
69
|
};
|
|
69
|
-
d(null), S(r, t), w([]),
|
|
70
|
+
d(null), S(r, t), w([]), C(""), m && m(""), A(!0);
|
|
70
71
|
}
|
|
71
72
|
}
|
|
72
73
|
},
|
|
73
74
|
[
|
|
74
75
|
S,
|
|
75
|
-
n,
|
|
76
|
-
k,
|
|
77
76
|
a,
|
|
77
|
+
k,
|
|
78
|
+
n,
|
|
78
79
|
o,
|
|
79
80
|
d,
|
|
80
81
|
m,
|
|
81
82
|
p
|
|
82
83
|
]
|
|
83
|
-
),
|
|
84
|
+
), H = e.useCallback(
|
|
84
85
|
(t) => {
|
|
85
86
|
if (!(t.key === "Enter" && t.shiftKey))
|
|
86
87
|
switch (t.key) {
|
|
87
88
|
case "Enter":
|
|
88
|
-
return t.preventDefault(),
|
|
89
|
+
return t.preventDefault(), b(t);
|
|
89
90
|
case "Escape":
|
|
90
91
|
f.current && f.current.blur();
|
|
91
92
|
break;
|
|
@@ -93,7 +94,7 @@ const Ce = e.forwardRef((se, ae) => {
|
|
|
93
94
|
return;
|
|
94
95
|
}
|
|
95
96
|
},
|
|
96
|
-
[
|
|
97
|
+
[b]
|
|
97
98
|
);
|
|
98
99
|
e.useImperativeHandle(
|
|
99
100
|
ae,
|
|
@@ -102,14 +103,14 @@ const Ce = e.forwardRef((se, ae) => {
|
|
|
102
103
|
}),
|
|
103
104
|
[u]
|
|
104
105
|
);
|
|
105
|
-
const
|
|
106
|
+
const U = e.useCallback((t) => {
|
|
106
107
|
w((s) => s.filter((r) => r.name !== t));
|
|
107
|
-
}, []),
|
|
108
|
-
(t, s) => t.isDeleted ?
|
|
108
|
+
}, []), V = e.useCallback(() => /* @__PURE__ */ e.createElement(be, { files: o, onFileRemove: U, renderInTextarea: !0 }), [o, U]), j = e.useCallback(
|
|
109
|
+
(t, s) => t.isDeleted ? he(s, l) : t.text,
|
|
109
110
|
[l]
|
|
110
|
-
),
|
|
111
|
-
if (
|
|
112
|
-
const t =
|
|
111
|
+
), G = e.useCallback(() => {
|
|
112
|
+
if (n) {
|
|
113
|
+
const t = Ce(k, n);
|
|
113
114
|
return /* @__PURE__ */ e.createElement(
|
|
114
115
|
"div",
|
|
115
116
|
{
|
|
@@ -118,22 +119,22 @@ const Ce = e.forwardRef((se, ae) => {
|
|
|
118
119
|
t ? "k-message-reference-sender" : "k-message-reference-receiver"
|
|
119
120
|
)
|
|
120
121
|
},
|
|
121
|
-
/* @__PURE__ */ e.createElement("div", { className: "k-message-reference-content" },
|
|
122
|
+
/* @__PURE__ */ e.createElement("div", { className: "k-message-reference-content" }, j(n, t)),
|
|
122
123
|
/* @__PURE__ */ e.createElement("span", { className: "k-spacer" }),
|
|
123
124
|
/* @__PURE__ */ e.createElement(
|
|
124
125
|
N,
|
|
125
126
|
{
|
|
126
127
|
fillMode: "flat",
|
|
127
128
|
themeColor: "base",
|
|
128
|
-
svgIcon:
|
|
129
|
+
svgIcon: fe,
|
|
129
130
|
onClick: () => d(null),
|
|
130
|
-
"aria-label": l.toLanguageString(
|
|
131
|
+
"aria-label": l.toLanguageString(_, E[_])
|
|
131
132
|
}
|
|
132
133
|
)
|
|
133
134
|
);
|
|
134
135
|
}
|
|
135
136
|
return null;
|
|
136
|
-
}, [
|
|
137
|
+
}, [n, k, j, d, l]), $ = e.useCallback(
|
|
137
138
|
(t) => {
|
|
138
139
|
try {
|
|
139
140
|
const s = Array.from(t.newState);
|
|
@@ -142,18 +143,18 @@ const Ce = e.forwardRef((se, ae) => {
|
|
|
142
143
|
}
|
|
143
144
|
},
|
|
144
145
|
[u]
|
|
145
|
-
),
|
|
146
|
+
), q = e.useCallback(() => {
|
|
146
147
|
T.current && T.current.actionElement.click();
|
|
147
|
-
}, []), q = e.useCallback((t) => {
|
|
148
148
|
}, []), J = e.useCallback((t) => {
|
|
149
|
+
}, []), O = e.useCallback((t) => {
|
|
149
150
|
const { isFinal: s, alternatives: r } = t;
|
|
150
151
|
if (r.length > 0) {
|
|
151
152
|
const c = r[0];
|
|
152
|
-
s &&
|
|
153
|
+
s && C((x) => (x ? `${x} ` : "") + c.transcript);
|
|
153
154
|
}
|
|
154
|
-
}, []),
|
|
155
|
+
}, []), Q = e.useCallback(() => /* @__PURE__ */ e.createElement(e.Fragment, null, o.length > 0 && V(), n && /* @__PURE__ */ e.createElement("span", { className: "k-input-prefix k-input-prefix-horizontal" }, G())), [o.length, n, V, G]), W = e.useCallback((t) => {
|
|
155
156
|
t.preventDefault();
|
|
156
|
-
}, []),
|
|
157
|
+
}, []), X = e.useCallback((t) => {
|
|
157
158
|
t.key === "Escape" && t.currentTarget.blur();
|
|
158
159
|
}, []), I = e.useMemo(
|
|
159
160
|
() => /* @__PURE__ */ e.createElement(
|
|
@@ -164,11 +165,11 @@ const Ce = e.forwardRef((se, ae) => {
|
|
|
164
165
|
themeColor: "primary",
|
|
165
166
|
className: "k-chat-send",
|
|
166
167
|
icon: "paper-plane",
|
|
167
|
-
svgIcon:
|
|
168
|
-
onClick:
|
|
169
|
-
onMouseDown:
|
|
170
|
-
onKeyDown:
|
|
171
|
-
"aria-label": l.toLanguageString(
|
|
168
|
+
svgIcon: pe,
|
|
169
|
+
onClick: b,
|
|
170
|
+
onMouseDown: W,
|
|
171
|
+
onKeyDown: X,
|
|
172
|
+
"aria-label": l.toLanguageString(ee, E[ee]),
|
|
172
173
|
dir: B ? "rtl" : void 0,
|
|
173
174
|
disabled: !p,
|
|
174
175
|
"aria-disabled": !p,
|
|
@@ -176,23 +177,23 @@ const Ce = e.forwardRef((se, ae) => {
|
|
|
176
177
|
}
|
|
177
178
|
),
|
|
178
179
|
[
|
|
179
|
-
|
|
180
|
-
Q,
|
|
180
|
+
b,
|
|
181
181
|
W,
|
|
182
|
+
X,
|
|
182
183
|
l,
|
|
183
184
|
B,
|
|
184
185
|
p,
|
|
185
186
|
F
|
|
186
187
|
]
|
|
187
|
-
),
|
|
188
|
+
), Y = e.useCallback(() => {
|
|
188
189
|
const t = typeof h == "object" ? h : void 0, s = typeof M == "object" ? M : {}, { className: r, ...c } = s, x = v("k-hidden", r);
|
|
189
|
-
return /* @__PURE__ */ e.createElement(
|
|
190
|
-
|
|
190
|
+
return /* @__PURE__ */ e.createElement(ie, null, h !== !1 && /* @__PURE__ */ e.createElement(
|
|
191
|
+
re,
|
|
191
192
|
{
|
|
192
193
|
fillMode: "clear",
|
|
193
194
|
themeColor: "base",
|
|
194
|
-
onError:
|
|
195
|
-
onResult:
|
|
195
|
+
onError: J,
|
|
196
|
+
onResult: O,
|
|
196
197
|
...t
|
|
197
198
|
}
|
|
198
199
|
), /* @__PURE__ */ e.createElement(
|
|
@@ -201,16 +202,16 @@ const Ce = e.forwardRef((se, ae) => {
|
|
|
201
202
|
key: "attach-file",
|
|
202
203
|
fillMode: "clear",
|
|
203
204
|
themeColor: "base",
|
|
204
|
-
svgIcon:
|
|
205
|
-
onClick:
|
|
206
|
-
"aria-label": l.toLanguageString(
|
|
205
|
+
svgIcon: ge,
|
|
206
|
+
onClick: q,
|
|
207
|
+
"aria-label": l.toLanguageString(te, E[te])
|
|
207
208
|
}
|
|
208
209
|
), /* @__PURE__ */ e.createElement(
|
|
209
|
-
|
|
210
|
+
ce,
|
|
210
211
|
{
|
|
211
212
|
ref: T,
|
|
212
213
|
files: o,
|
|
213
|
-
onAdd:
|
|
214
|
+
onAdd: $,
|
|
214
215
|
multiple: !0,
|
|
215
216
|
autoUpload: !1,
|
|
216
217
|
...c,
|
|
@@ -221,44 +222,55 @@ const Ce = e.forwardRef((se, ae) => {
|
|
|
221
222
|
h,
|
|
222
223
|
M,
|
|
223
224
|
o,
|
|
224
|
-
q,
|
|
225
225
|
J,
|
|
226
|
+
O,
|
|
227
|
+
q,
|
|
226
228
|
$,
|
|
227
|
-
G,
|
|
228
229
|
l,
|
|
229
230
|
I
|
|
230
|
-
]),
|
|
231
|
+
]), Z = e.useMemo(
|
|
231
232
|
() => /* @__PURE__ */ e.createElement(
|
|
232
|
-
|
|
233
|
+
me,
|
|
233
234
|
{
|
|
234
|
-
className: v("k-message-box", "!k-flex-col", { "k-focus":
|
|
235
|
+
className: v("k-message-box", "!k-flex-col", { "k-focus": L }),
|
|
235
236
|
resizable: "none",
|
|
236
237
|
rows: 1,
|
|
237
238
|
placeholder: R,
|
|
238
|
-
value:
|
|
239
|
-
onChange:
|
|
240
|
-
onKeyDown:
|
|
241
|
-
|
|
242
|
-
|
|
239
|
+
value: a,
|
|
240
|
+
onChange: P,
|
|
241
|
+
onKeyDown: H,
|
|
242
|
+
onClick: z,
|
|
243
|
+
prefix: Q,
|
|
244
|
+
suffix: Y,
|
|
243
245
|
ref: f,
|
|
244
246
|
"aria-label": l.toLanguageString(
|
|
245
|
-
|
|
246
|
-
E[
|
|
247
|
+
se,
|
|
248
|
+
E[se]
|
|
247
249
|
)
|
|
248
250
|
}
|
|
249
251
|
),
|
|
250
|
-
[
|
|
252
|
+
[
|
|
253
|
+
L,
|
|
254
|
+
R,
|
|
255
|
+
a,
|
|
256
|
+
P,
|
|
257
|
+
H,
|
|
258
|
+
z,
|
|
259
|
+
Q,
|
|
260
|
+
Y,
|
|
261
|
+
l
|
|
262
|
+
]
|
|
251
263
|
);
|
|
252
264
|
return /* @__PURE__ */ e.createElement("div", { className: "k-message-box-wrapper" }, y && y.length > 0 && /* @__PURE__ */ e.createElement(
|
|
253
|
-
|
|
265
|
+
ue,
|
|
254
266
|
{
|
|
255
|
-
onSuggestionClick:
|
|
267
|
+
onSuggestionClick: oe,
|
|
256
268
|
suggestions: y,
|
|
257
|
-
suggestionTemplate:
|
|
269
|
+
suggestionTemplate: le
|
|
258
270
|
}
|
|
259
|
-
), D ? /* @__PURE__ */ e.createElement(D, { messageInput:
|
|
271
|
+
), D ? /* @__PURE__ */ e.createElement(D, { messageInput: Z, sendButton: I }) : Z);
|
|
260
272
|
});
|
|
261
|
-
|
|
273
|
+
xe.displayName = "NewMessage";
|
|
262
274
|
export {
|
|
263
|
-
|
|
275
|
+
xe as default
|
|
264
276
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2025 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react");function _(c){const d=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(c){for(const r in c)if(r!=="default"){const f=Object.getOwnPropertyDescriptor(c,r);Object.defineProperty(d,r,f.get?f:{enumerable:!0,get:()=>c[r]})}}return d.default=c,Object.freeze(d)}const n=_(m),A=50,x=250,T=50,B=100,N=({viewItemsWrapperRef:c,isKeyboardNavigationActiveRef:d,processedMessages:r,suggestions:f})=>{const i=n.useCallback(()=>{c.current&&(c.current.scrollTop=c.current.scrollHeight-c.current.clientHeight)},[c]),u=n.useCallback(()=>{if(!c.current)return!0;const t=c.current,{scrollTop:e,scrollHeight:l,clientHeight:s}=t,a=A+25;return l-e-s<a},[c]),b=n.useCallback(t=>t===0?16:t<=2?32*t:Math.min(50*t,200),[]),S=n.useCallback((t,e)=>{const l=b(t);setTimeout(()=>{!u()&&c.current&&e(t+1)},l)},[b,u,c]),h=n.useCallback(()=>{const t=(e=0)=>{e>5||requestAnimationFrame(()=>{i(),S(e,t)})};t()},[i,S]),C=n.useCallback(()=>{i(),setTimeout(()=>{!u()&&c.current&&i()},50)},[i,u,c]),y=n.useCallback(()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{requestAnimationFrame(C)})})},[C]),O=n.useCallback(()=>{i(),setTimeout(()=>{!u()&&c.current&&h()},25)},[i,u,c,h]),o=n.useCallback((t=!1)=>{if(!c.current||d.current)return;u()&&(t?O():y())},[u,O,y,c,d]);n.useEffect(()=>{const t=window.setTimeout(()=>i(),x);return()=>{clearTimeout(t)}},[i]),n.useEffect(()=>{h()},[r.length,h]),n.useEffect(()=>{const t=window.setTimeout(()=>{o()},T);return()=>{clearTimeout(t)}},[r,o]),n.useEffect(()=>{if(r.length>0){const t=r[r.length-1],e=(t==null?void 0:t.text)||"";(e.includes("```")||e.includes(`
|
|
9
|
+
|
|
10
|
+
`)||e.includes("<pre>")||e.includes("<code>")||e.includes("<table>")||e.length>500)&&o(!0)}},[r,o]),n.useEffect(()=>{if(f&&f.length>0){const t=window.setTimeout(()=>{o()},B);return()=>{clearTimeout(t)}}},[f,o]),n.useEffect(()=>{if(!c.current)return()=>{};let t;const e=new ResizeObserver(()=>{t&&clearTimeout(t),t=window.setTimeout(()=>{o()},T)}),l=c.current.querySelector(".k-message-list-content");return l&&e.observe(l),()=>{e.disconnect()}},[o,c]);const g=n.useCallback(t=>{var l;if(t.type!=="characterData"&&t.type!=="childList")return!1;const e=(l=t.target.textContent)!=null?l:"";return e.includes("```")||e.includes(`
|
|
11
|
+
|
|
12
|
+
`)||e.includes("<pre>")||e.includes("<code>")||e.includes("<table>")||t.addedNodes&&t.addedNodes.length>2},[]),L=n.useCallback(t=>{let e=!1,l=!1;return t.forEach(s=>{var a;(s.type==="childList"||s.type==="characterData"||s.type==="attributes"&&["class","style"].includes((a=s.attributeName)!=null?a:""))&&(e=!0,g(s)&&(l=!0))}),{shouldScroll:e,hasSignificantChange:l}},[g]),k=n.useCallback((t,e)=>{e.current&&clearTimeout(e.current),t?o(!0):e.current=window.setTimeout(()=>{o()},T)},[o]);n.useEffect(()=>{if(!c.current)return()=>{};const t={current:void 0};let e=0;const l=new MutationObserver(s=>{const a=Date.now();if(a-e<16)return;e=a;const{shouldScroll:E,hasSignificantChange:D}=L(s);E&&u()&&k(D,t)});return l.observe(c.current,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["class","style"]}),()=>{l.disconnect(),t.current&&clearTimeout(t.current)}},[u,L,k,c])};exports.useChatScroll=N;
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*-------------------------------------------------------------------------------------------
|
|
4
|
+
* Copyright © 2025 Progress Software Corporation. All rights reserved.
|
|
5
|
+
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
|
+
*-------------------------------------------------------------------------------------------
|
|
7
|
+
*/
|
|
8
|
+
import * as n from "react";
|
|
9
|
+
const x = 50, A = 250, T = 50, m = 100, _ = ({
|
|
10
|
+
viewItemsWrapperRef: c,
|
|
11
|
+
isKeyboardNavigationActiveRef: f,
|
|
12
|
+
processedMessages: a,
|
|
13
|
+
suggestions: h
|
|
14
|
+
}) => {
|
|
15
|
+
const u = n.useCallback(() => {
|
|
16
|
+
c.current && (c.current.scrollTop = c.current.scrollHeight - c.current.clientHeight);
|
|
17
|
+
}, [c]), r = n.useCallback(() => {
|
|
18
|
+
if (!c.current)
|
|
19
|
+
return !0;
|
|
20
|
+
const t = c.current, { scrollTop: e, scrollHeight: l, clientHeight: i } = t, s = x + 25;
|
|
21
|
+
return l - e - i < s;
|
|
22
|
+
}, [c]), b = n.useCallback((t) => t === 0 ? 16 : t <= 2 ? 32 * t : Math.min(50 * t, 200), []), C = n.useCallback(
|
|
23
|
+
(t, e) => {
|
|
24
|
+
const l = b(t);
|
|
25
|
+
setTimeout(() => {
|
|
26
|
+
!r() && c.current && e(t + 1);
|
|
27
|
+
}, l);
|
|
28
|
+
},
|
|
29
|
+
[b, r, c]
|
|
30
|
+
), d = n.useCallback(() => {
|
|
31
|
+
const t = (e = 0) => {
|
|
32
|
+
e > 5 || requestAnimationFrame(() => {
|
|
33
|
+
u(), C(e, t);
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
t();
|
|
37
|
+
}, [u, C]), S = n.useCallback(() => {
|
|
38
|
+
u(), setTimeout(() => {
|
|
39
|
+
!r() && c.current && u();
|
|
40
|
+
}, 50);
|
|
41
|
+
}, [u, r, c]), L = n.useCallback(() => {
|
|
42
|
+
requestAnimationFrame(() => {
|
|
43
|
+
requestAnimationFrame(() => {
|
|
44
|
+
requestAnimationFrame(S);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
}, [S]), E = n.useCallback(() => {
|
|
48
|
+
u(), setTimeout(() => {
|
|
49
|
+
!r() && c.current && d();
|
|
50
|
+
}, 25);
|
|
51
|
+
}, [u, r, c, d]), o = n.useCallback(
|
|
52
|
+
(t = !1) => {
|
|
53
|
+
if (!c.current || f.current)
|
|
54
|
+
return;
|
|
55
|
+
r() && (t ? E() : L());
|
|
56
|
+
},
|
|
57
|
+
[
|
|
58
|
+
r,
|
|
59
|
+
E,
|
|
60
|
+
L,
|
|
61
|
+
c,
|
|
62
|
+
f
|
|
63
|
+
]
|
|
64
|
+
);
|
|
65
|
+
n.useEffect(() => {
|
|
66
|
+
const t = window.setTimeout(() => u(), A);
|
|
67
|
+
return () => {
|
|
68
|
+
clearTimeout(t);
|
|
69
|
+
};
|
|
70
|
+
}, [u]), n.useEffect(() => {
|
|
71
|
+
d();
|
|
72
|
+
}, [a.length, d]), n.useEffect(() => {
|
|
73
|
+
const t = window.setTimeout(() => {
|
|
74
|
+
o();
|
|
75
|
+
}, T);
|
|
76
|
+
return () => {
|
|
77
|
+
clearTimeout(t);
|
|
78
|
+
};
|
|
79
|
+
}, [a, o]), n.useEffect(() => {
|
|
80
|
+
if (a.length > 0) {
|
|
81
|
+
const t = a[a.length - 1], e = (t == null ? void 0 : t.text) || "";
|
|
82
|
+
(e.includes("```") || e.includes(`
|
|
83
|
+
|
|
84
|
+
`) || e.includes("<pre>") || e.includes("<code>") || e.includes("<table>") || e.length > 500) && o(!0);
|
|
85
|
+
}
|
|
86
|
+
}, [a, o]), n.useEffect(() => {
|
|
87
|
+
if (h && h.length > 0) {
|
|
88
|
+
const t = window.setTimeout(() => {
|
|
89
|
+
o();
|
|
90
|
+
}, m);
|
|
91
|
+
return () => {
|
|
92
|
+
clearTimeout(t);
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
}, [h, o]), n.useEffect(() => {
|
|
96
|
+
if (!c.current)
|
|
97
|
+
return () => {
|
|
98
|
+
};
|
|
99
|
+
let t;
|
|
100
|
+
const e = new ResizeObserver(() => {
|
|
101
|
+
t && clearTimeout(t), t = window.setTimeout(() => {
|
|
102
|
+
o();
|
|
103
|
+
}, T);
|
|
104
|
+
}), l = c.current.querySelector(".k-message-list-content");
|
|
105
|
+
return l && e.observe(l), () => {
|
|
106
|
+
e.disconnect();
|
|
107
|
+
};
|
|
108
|
+
}, [o, c]);
|
|
109
|
+
const k = n.useCallback((t) => {
|
|
110
|
+
var l;
|
|
111
|
+
if (t.type !== "characterData" && t.type !== "childList")
|
|
112
|
+
return !1;
|
|
113
|
+
const e = (l = t.target.textContent) != null ? l : "";
|
|
114
|
+
return e.includes("```") || e.includes(`
|
|
115
|
+
|
|
116
|
+
`) || e.includes("<pre>") || e.includes("<code>") || e.includes("<table>") || t.addedNodes && t.addedNodes.length > 2;
|
|
117
|
+
}, []), y = n.useCallback(
|
|
118
|
+
(t) => {
|
|
119
|
+
let e = !1, l = !1;
|
|
120
|
+
return t.forEach((i) => {
|
|
121
|
+
var s;
|
|
122
|
+
(i.type === "childList" || i.type === "characterData" || i.type === "attributes" && ["class", "style"].includes((s = i.attributeName) != null ? s : "")) && (e = !0, k(i) && (l = !0));
|
|
123
|
+
}), { shouldScroll: e, hasSignificantChange: l };
|
|
124
|
+
},
|
|
125
|
+
[k]
|
|
126
|
+
), O = n.useCallback(
|
|
127
|
+
(t, e) => {
|
|
128
|
+
e.current && clearTimeout(e.current), t ? o(!0) : e.current = window.setTimeout(() => {
|
|
129
|
+
o();
|
|
130
|
+
}, T);
|
|
131
|
+
},
|
|
132
|
+
[o]
|
|
133
|
+
);
|
|
134
|
+
n.useEffect(() => {
|
|
135
|
+
if (!c.current)
|
|
136
|
+
return () => {
|
|
137
|
+
};
|
|
138
|
+
const t = { current: void 0 };
|
|
139
|
+
let e = 0;
|
|
140
|
+
const l = new MutationObserver((i) => {
|
|
141
|
+
const s = Date.now();
|
|
142
|
+
if (s - e < 16)
|
|
143
|
+
return;
|
|
144
|
+
e = s;
|
|
145
|
+
const { shouldScroll: D, hasSignificantChange: g } = y(i);
|
|
146
|
+
D && r() && O(g, t);
|
|
147
|
+
});
|
|
148
|
+
return l.observe(c.current, {
|
|
149
|
+
childList: !0,
|
|
150
|
+
subtree: !0,
|
|
151
|
+
characterData: !0,
|
|
152
|
+
attributes: !0,
|
|
153
|
+
attributeFilter: ["class", "style"]
|
|
154
|
+
}), () => {
|
|
155
|
+
l.disconnect(), t.current && clearTimeout(t.current);
|
|
156
|
+
};
|
|
157
|
+
}, [r, y, O, c]);
|
|
158
|
+
};
|
|
159
|
+
export {
|
|
160
|
+
_ as useChatScroll
|
|
161
|
+
};
|