@progress/kendo-react-conversational-ui 14.5.0-develop.9 → 15.0.0-develop.1
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/README.md +4 -4
- package/ai-prompt/AIPrompt.d.ts +6 -0
- package/ai-prompt/AIPrompt.js +1 -1
- package/ai-prompt/AIPrompt.mjs +40 -38
- package/chat/ChatPropsAndState.d.ts +17 -0
- package/chat/components/Chat.js +1 -1
- package/chat/components/Chat.mjs +224 -222
- package/chat/components/ChatMessage.js +1 -1
- package/chat/components/ChatMessage.mjs +123 -108
- package/chat/hooks/useEndlessScroll.js +1 -1
- package/chat/hooks/useEndlessScroll.mjs +103 -101
- package/dist/cdn/js/kendo-react-conversational-ui.js +1 -1
- package/messages/index.d.ts +5 -0
- package/messages/index.js +1 -1
- package/messages/index.mjs +12 -10
- package/package-metadata.js +1 -1
- package/package-metadata.mjs +2 -2
- package/package.json +11 -11
- package/prompt-box/PromptBox.js +1 -1
- package/prompt-box/PromptBox.mjs +135 -137
|
@@ -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 ye=require("react"),g=require("@progress/kendo-react-common"),
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ye=require("react"),g=require("@progress/kendo-react-common"),S=require("@progress/kendo-react-buttons"),f=require("@progress/kendo-svg-icons"),ne=require("@progress/kendo-react-layout"),c=require("../utils.js"),Ee=require("./ChatContext.js"),xe=require("./elements/FileBox.js"),le=require("@progress/kendo-react-intl"),l=require("../../messages/index.js");function Ie(i){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(i){for(const e in i)if(e!=="default"){const u=Object.getOwnPropertyDescriptor(i,e);Object.defineProperty(r,e,u.get?u:{enumerable:!0,get:()=>i[e]})}}return r.default=i,Object.freeze(r)}const a=Ie(ye),oe=a.forwardRef((i,r)=>{const{item:e,template:u,contentTemplate:D,onRequestSelection:C,tabIndex:ce=-1,dateFormat:H="g",selected:d,allowMessageCollapse:y,messageToolbarActions:E,messageContextMenuActions:x,fileActions:U,isSender:I}=i,{setReplyToMessage:M,messages:X,repliedToMessages:A,user:b,onToolbarAction:F,onContextMenuAction:R,onFileAction:Y,onDownload:m,onResendMessage:L,setShowCopyNotification:w,statusTemplate:q,timestampVisibility:z="onFocus",onReferencedMessageClick:T}=Ee.useChatContext(),[G,O]=a.useState(!1),[J,V]=a.useState(!1),[h,re]=a.useState(!0),[ie,Q]=a.useState(!1),o=le.useLocalization(),Z=le.useInternationalization(),$=a.useRef({left:0,top:0}),v=a.useCallback(()=>{e!=null&&e.text&&c.copyToClipboard(e.text),w&&(w(!0),setTimeout(()=>{w(!1)},3e3))},[e,w]),j=a.useCallback(t=>{t.stopPropagation(),re(s=>!s)},[]),ue=a.useCallback(()=>{Q(!1)},[]),de=a.useCallback(t=>{(t.key==="Tab"||t.key==="Enter"||t.key===" "||t.key==="ArrowUp"||t.key==="ArrowDown")&&Q(!0)},[]),B=a.useRef(null);a.useEffect(()=>{d&&B.current&&B.current.focus()},[d]);const P=a.useCallback(t=>{$.current={left:t.pageX,top:t.pageY},t.preventDefault(),V(!0),O(!0)},[]),ee=a.useCallback(()=>{V(!1),O(!1)},[]),N=a.useCallback((t,s)=>t.isDeleted?c.getDeletedMessageText(s,o):t.text?t.text:"",[o]),te=a.useCallback(t=>{var s;(s=t.item)!=null&&s.text&&(t.item.data.id==="copy"&&!e.isDeleted?v():t.item.data.id==="reply"&&M(e),R&&R(t.item.data,t,e)),V(!1),O(!1)},[e,R,M,v]),ae=a.useCallback(()=>{if(e.replyToId){const t=c.getMessageById(X,e.replyToId)||(A?c.getMessageById(A,e.replyToId):void 0);if(t){const s=n=>{n.preventDefault(),n.stopPropagation(),T==null||T(t.id)};return a.createElement("div",{className:g.classNames("k-message-reference",c.isAuthor(b,t)?"k-message-reference-sender":"k-message-reference-receiver"),onClick:s},a.createElement("div",{className:"k-message-reference-content"},c.convertTextToLinkedContent(N(t,c.isAuthor(b,t)))))}}return null},[e.replyToId,X,A,b,N,T]),K=a.useCallback(()=>{const t=[{id:"reply",label:"Reply",svgIcon:f.undoIcon},{id:"copy",label:"Copy",svgIcon:f.copyIcon}],s=x?[...t.map(n=>x.find(k=>k.id===n.id)||n),...x.filter(n=>!t.some(p=>p.id===n.id))]:t;return a.createElement(ne.ContextMenu,{onSelect:te,onClose:ee,vertical:!0,show:G,offset:$.current},s.map(n=>n.id==="delete"&&!I?null:a.createElement(ne.MenuItem,{key:n.id,text:n.label,icon:n.icon,svgIcon:n.svgIcon,data:n})))},[x,te,ee,G,I]),se=a.useCallback(()=>e.files&&e.files.length>1?a.createElement("div",{className:"k-chat-download-button-wrapper"},a.createElement(S.Button,{className:"k-chat-download-button",fillMode:"flat",svgIcon:f.downloadIcon,size:"small",onClick:t=>{t.stopPropagation(),m&&m(e.files,e)},"aria-label":o.toLanguageString(l.downloadAllFiles,l.messages[l.downloadAllFiles])},a.createElement("span",{className:"k-button-text"},o.toLanguageString(l.downloadAll,l.messages[l.downloadAll])))):null,[e,m,o]),me=a.useCallback(()=>{if(e.typing)return a.createElement("div",{className:"k-chat-bubble k-bubble"},a.createElement("div",{className:"k-bubble-content"},a.createElement("div",{className:"k-typing-indicator"},a.createElement("span",null),a.createElement("span",null),a.createElement("span",null))));if(u){const t=u;return a.createElement(a.Fragment,null,a.createElement(t,{item:e}),K())}else if(e.text||e.files&&e.files.length>0)return a.createElement(a.Fragment,null,a.createElement("div",{className:g.classNames("k-chat-bubble","k-bubble",{"k-bubble-expandable":y,"k-expanded":y&&h,"k-selected":d,"k-active":J}),onClick:()=>C(d?void 0:e.selectionIndex),onContextMenu:P},a.createElement("div",{className:"k-bubble-content"},D?a.createElement(D,{item:e}):a.createElement(a.Fragment,null,(e.text||e.isDeleted||e.replyToId)&&a.createElement("span",{className:"k-chat-bubble-text"},!e.isDeleted&&ae(),c.convertTextToLinkedContent(N(e,c.isAuthor(b,e)))),e.files&&e.files.length>0&&a.createElement(xe,{files:e.files,message:e,onFileAction:Y,onDownload:t=>m==null?void 0:m(t,e),renderInTextarea:!1,fileActions:U}),se())),y&&a.createElement("span",{className:"k-bubble-expandable-indicator",onClick:j,role:"button","aria-label":h?o.toLanguageString(l.collapseMessage,l.messages[l.collapseMessage]):o.toLanguageString(l.expandMessage,l.messages[l.expandMessage]),tabIndex:0,onKeyDown:t=>{(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),j(t))}},a.createElement(g.IconWrap,{icon:h?f.chevronUpIcon:f.chevronDownIcon,size:"medium"}))),K());return null},[e,u,D,y,h,d,J,C,P,ae,N,b,Y,U,se,j,o,K,m]),ge=a.useCallback(()=>{let t=null;return e.timestamp&&(z==="hidden"||(t=a.createElement("time",{className:"k-message-time"},Z.formatDate(e.timestamp,H)))),t},[e.timestamp,H,z,Z]),fe=a.useCallback(()=>{if(!e.status)return null;let t;if(q)t=a.createElement(q,{item:e});else{const s=typeof e.status=="object"&&e.status!==null;let n,p,k;if(s){const _=e.status;n=_.text,p=_.icon,k=_.svgIcon}else n=e.status;let W=null;p?W=a.createElement(g.Icon,{name:p,size:"xsmall"}):k&&(W=a.createElement(g.IconWrap,{icon:k,size:"xsmall"})),t=a.createElement(a.Fragment,null,W,n)}return a.createElement("span",{className:"k-message-status"},t)},[e,q]),pe=a.useCallback(()=>{let t=null;if(e.isFailed){const s=o.toLanguageString(l.messageFailed,l.messages[l.messageFailed]);t=a.createElement("span",{className:"k-message-failed-content"},a.createElement(g.IconWrap,{icon:f.warningTriangleIcon,size:"xsmall"}),a.createElement("span",{className:"k-message-failed-text"},s))}return t},[e,o]),be=a.useCallback(()=>{let t=null;if(e.isFailed){const s=o.toLanguageString(l.retryMessage,l.messages[l.retryMessage]);t=a.createElement(S.Button,{fillMode:"clear",size:"xs",className:"k-resend-button",svgIcon:f.arrowRotateCwIcon,"aria-label":s,title:s,onClick:n=>{n.stopPropagation(),L&&L({message:e,syntheticEvent:n,nativeEvent:n.nativeEvent,target:n.target})}})}return t},[e,o,L]),ke=a.useCallback(()=>g.classNames({"k-focus":d,"k-message-removed":e.isDeleted,"k-message-failed":e.isFailed},"k-message"),[d,e.isDeleted,e.isFailed]),Ce=a.useCallback(()=>E&&E.length>0&&a.createElement(S.Toolbar,{className:"k-chat-message-toolbar",fillMode:"flat",ariaLabel:o.toLanguageString(l.chatMessageToolbar,l.messages[l.chatMessageToolbar])},E.map(t=>t.id==="delete"&&!I?null:a.createElement(S.Button,{key:t.id,fillMode:"flat",className:"k-toolbar-button",icon:t.icon,svgIcon:t.svgIcon,"aria-label":t.label,onClick:s=>{s.stopPropagation(),t.id==="copy"&&!e.isDeleted?v():t.id==="reply"&&M(e),F&&F(t,s,e)},onMouseDown:s=>s.preventDefault()}))),[v,I,e,o,E,F,M]);return a.createElement("div",{key:e.id,"data-message-id":e.id,className:ke(),tabIndex:ce,onMouseDown:ue,onKeyDown:de,onFocus:t=>{ie&&C(e.selectionIndex)},ref:t=>{B.current=t,typeof r=="function"?r(t):r&&(r.current=t)},onContextMenu:u?P:void 0},be(),me(),(e.status||e.timestamp&&z!=="hidden"||e.isFailed)&&a.createElement("div",{className:"k-message-info"},fe(),ge(),pe()),Ce())});oe.displayName="ChatMessage";exports.ChatMessage=oe;
|
|
@@ -7,76 +7,76 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import * as t from "react";
|
|
9
9
|
import { classNames as O, IconWrap as j, Icon as ve } from "@progress/kendo-react-common";
|
|
10
|
-
import { Button as W, Toolbar as
|
|
11
|
-
import { undoIcon as
|
|
12
|
-
import { ContextMenu as
|
|
13
|
-
import { copyToClipboard as
|
|
14
|
-
import { useChatContext as
|
|
15
|
-
import
|
|
16
|
-
import { useLocalization as
|
|
17
|
-
import { downloadAllFiles as le, messages as
|
|
18
|
-
const
|
|
19
|
-
(
|
|
10
|
+
import { Button as W, Toolbar as he } from "@progress/kendo-react-buttons";
|
|
11
|
+
import { undoIcon as Me, copyIcon as Ne, downloadIcon as De, chevronUpIcon as Se, chevronDownIcon as Fe, warningTriangleIcon as Ae, arrowRotateCwIcon as Re } from "@progress/kendo-svg-icons";
|
|
12
|
+
import { ContextMenu as Le, MenuItem as Ve } from "@progress/kendo-react-layout";
|
|
13
|
+
import { copyToClipboard as ze, getDeletedMessageText as Ke, getMessageById as se, isAuthor as H, convertTextToLinkedContent as ne } from "../utils.mjs";
|
|
14
|
+
import { useChatContext as Pe } from "./ChatContext.mjs";
|
|
15
|
+
import Be from "./elements/FileBox.mjs";
|
|
16
|
+
import { useLocalization as Oe, useInternationalization as je } from "@progress/kendo-react-intl";
|
|
17
|
+
import { downloadAllFiles as le, messages as r, downloadAll as oe, collapseMessage as ie, expandMessage as re, messageFailed as ce, retryMessage as ue, chatMessageToolbar as me } from "../../messages/index.mjs";
|
|
18
|
+
const We = t.forwardRef(
|
|
19
|
+
(de, d) => {
|
|
20
20
|
const {
|
|
21
21
|
item: a,
|
|
22
22
|
template: f,
|
|
23
|
-
contentTemplate:
|
|
24
|
-
onRequestSelection:
|
|
25
|
-
tabIndex:
|
|
23
|
+
contentTemplate: v,
|
|
24
|
+
onRequestSelection: g,
|
|
25
|
+
tabIndex: fe = -1,
|
|
26
26
|
dateFormat: U = "g",
|
|
27
27
|
selected: o,
|
|
28
|
-
allowMessageCollapse:
|
|
28
|
+
allowMessageCollapse: p,
|
|
29
29
|
messageToolbarActions: b,
|
|
30
30
|
messageContextMenuActions: k,
|
|
31
31
|
fileActions: q,
|
|
32
32
|
isSender: C
|
|
33
|
-
} =
|
|
33
|
+
} = de, {
|
|
34
34
|
setReplyToMessage: E,
|
|
35
35
|
messages: X,
|
|
36
|
-
repliedToMessages:
|
|
36
|
+
repliedToMessages: h,
|
|
37
37
|
user: u,
|
|
38
|
-
onToolbarAction:
|
|
39
|
-
onContextMenuAction:
|
|
38
|
+
onToolbarAction: M,
|
|
39
|
+
onContextMenuAction: N,
|
|
40
40
|
onFileAction: Y,
|
|
41
41
|
onDownload: i,
|
|
42
|
-
onResendMessage:
|
|
42
|
+
onResendMessage: D,
|
|
43
43
|
setShowCopyNotification: x,
|
|
44
|
-
statusTemplate:
|
|
45
|
-
timestampVisibility:
|
|
46
|
-
onReferencedMessageClick:
|
|
47
|
-
} =
|
|
48
|
-
a != null && a.text &&
|
|
44
|
+
statusTemplate: S,
|
|
45
|
+
timestampVisibility: F = "onFocus",
|
|
46
|
+
onReferencedMessageClick: y
|
|
47
|
+
} = Pe(), [$, A] = t.useState(!1), [G, R] = t.useState(!1), [I, ge] = t.useState(!0), [pe, J] = t.useState(!1), l = Oe(), Q = je(), Z = t.useRef({ left: 0, top: 0 }), w = t.useCallback(() => {
|
|
48
|
+
a != null && a.text && ze(a.text), x && (x(!0), setTimeout(() => {
|
|
49
49
|
x(!1);
|
|
50
50
|
}, 3e3));
|
|
51
|
-
}, [a, x]),
|
|
52
|
-
e.stopPropagation(),
|
|
53
|
-
}, []),
|
|
51
|
+
}, [a, x]), L = t.useCallback((e) => {
|
|
52
|
+
e.stopPropagation(), ge((s) => !s);
|
|
53
|
+
}, []), be = t.useCallback(() => {
|
|
54
54
|
J(!1);
|
|
55
|
-
}, []),
|
|
55
|
+
}, []), ke = t.useCallback((e) => {
|
|
56
56
|
(e.key === "Tab" || e.key === "Enter" || e.key === " " || e.key === "ArrowUp" || e.key === "ArrowDown") && J(!0);
|
|
57
57
|
}, []), V = t.useRef(null);
|
|
58
58
|
t.useEffect(() => {
|
|
59
59
|
o && V.current && V.current.focus();
|
|
60
60
|
}, [o]);
|
|
61
|
-
const
|
|
61
|
+
const z = t.useCallback((e) => {
|
|
62
62
|
Z.current = { left: e.pageX, top: e.pageY }, e.preventDefault(), R(!0), A(!0);
|
|
63
63
|
}, []), _ = t.useCallback(() => {
|
|
64
64
|
R(!1), A(!1);
|
|
65
65
|
}, []), T = t.useCallback(
|
|
66
|
-
(e, s) => e.isDeleted ?
|
|
66
|
+
(e, s) => e.isDeleted ? Ke(s, l) : e.text ? e.text : "",
|
|
67
67
|
[l]
|
|
68
68
|
), ee = t.useCallback(
|
|
69
69
|
(e) => {
|
|
70
70
|
var s;
|
|
71
|
-
(s = e.item) != null && s.text && (e.item.data.id === "copy" && !a.isDeleted ?
|
|
71
|
+
(s = e.item) != null && s.text && (e.item.data.id === "copy" && !a.isDeleted ? w() : e.item.data.id === "reply" && E(a), N && N(e.item.data, e, a)), R(!1), A(!1);
|
|
72
72
|
},
|
|
73
|
-
[a,
|
|
73
|
+
[a, N, E, w]
|
|
74
74
|
), te = t.useCallback(() => {
|
|
75
75
|
if (a.replyToId) {
|
|
76
|
-
const e = se(X, a.replyToId) || (
|
|
76
|
+
const e = se(X, a.replyToId) || (h ? se(h, a.replyToId) : void 0);
|
|
77
77
|
if (e) {
|
|
78
78
|
const s = (n) => {
|
|
79
|
-
n.preventDefault(), n.stopPropagation(),
|
|
79
|
+
n.preventDefault(), n.stopPropagation(), y == null || y(e.id);
|
|
80
80
|
};
|
|
81
81
|
return /* @__PURE__ */ t.createElement(
|
|
82
82
|
"div",
|
|
@@ -94,28 +94,28 @@ const je = t.forwardRef(
|
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
return null;
|
|
97
|
-
}, [a.replyToId, X,
|
|
97
|
+
}, [a.replyToId, X, h, u, T, y]), K = t.useCallback(() => {
|
|
98
98
|
const e = [
|
|
99
99
|
{
|
|
100
100
|
id: "reply",
|
|
101
101
|
label: "Reply",
|
|
102
|
-
svgIcon:
|
|
102
|
+
svgIcon: Me
|
|
103
103
|
},
|
|
104
104
|
{
|
|
105
105
|
id: "copy",
|
|
106
106
|
label: "Copy",
|
|
107
|
-
svgIcon:
|
|
107
|
+
svgIcon: Ne
|
|
108
108
|
}
|
|
109
109
|
], s = k ? [
|
|
110
110
|
...e.map((n) => k.find(
|
|
111
111
|
(m) => m.id === n.id
|
|
112
112
|
) || n),
|
|
113
113
|
...k.filter(
|
|
114
|
-
(n) => !e.some((
|
|
114
|
+
(n) => !e.some((c) => c.id === n.id)
|
|
115
115
|
)
|
|
116
116
|
] : e;
|
|
117
117
|
return /* @__PURE__ */ t.createElement(
|
|
118
|
-
|
|
118
|
+
Le,
|
|
119
119
|
{
|
|
120
120
|
onSelect: ee,
|
|
121
121
|
onClose: _,
|
|
@@ -125,7 +125,7 @@ const je = t.forwardRef(
|
|
|
125
125
|
},
|
|
126
126
|
s.map(
|
|
127
127
|
(n) => n.id === "delete" && !C ? null : /* @__PURE__ */ t.createElement(
|
|
128
|
-
|
|
128
|
+
Ve,
|
|
129
129
|
{
|
|
130
130
|
key: n.id,
|
|
131
131
|
text: n.label,
|
|
@@ -141,18 +141,18 @@ const je = t.forwardRef(
|
|
|
141
141
|
{
|
|
142
142
|
className: "k-chat-download-button",
|
|
143
143
|
fillMode: "flat",
|
|
144
|
-
svgIcon:
|
|
144
|
+
svgIcon: De,
|
|
145
145
|
size: "small",
|
|
146
146
|
onClick: (e) => {
|
|
147
147
|
e.stopPropagation(), i && i(a.files, a);
|
|
148
148
|
},
|
|
149
149
|
"aria-label": l.toLanguageString(
|
|
150
150
|
le,
|
|
151
|
-
|
|
151
|
+
r[le]
|
|
152
152
|
)
|
|
153
153
|
},
|
|
154
|
-
/* @__PURE__ */ t.createElement("span", { className: "k-button-text" }, l.toLanguageString(oe,
|
|
155
|
-
)) : null, [a, i, l]),
|
|
154
|
+
/* @__PURE__ */ t.createElement("span", { className: "k-button-text" }, l.toLanguageString(oe, r[oe]))
|
|
155
|
+
)) : null, [a, i, l]), Ce = t.useCallback(() => {
|
|
156
156
|
if (a.typing)
|
|
157
157
|
return /* @__PURE__ */ t.createElement("div", { className: "k-chat-bubble k-bubble" }, /* @__PURE__ */ t.createElement("div", { className: "k-bubble-content" }, /* @__PURE__ */ t.createElement("div", { className: "k-typing-indicator" }, /* @__PURE__ */ t.createElement("span", null), /* @__PURE__ */ t.createElement("span", null), /* @__PURE__ */ t.createElement("span", null))));
|
|
158
158
|
if (f) {
|
|
@@ -163,18 +163,18 @@ const je = t.forwardRef(
|
|
|
163
163
|
"div",
|
|
164
164
|
{
|
|
165
165
|
className: O("k-chat-bubble", "k-bubble", {
|
|
166
|
-
"k-bubble-expandable":
|
|
167
|
-
"k-expanded":
|
|
166
|
+
"k-bubble-expandable": p,
|
|
167
|
+
"k-expanded": p && I,
|
|
168
168
|
"k-selected": o,
|
|
169
169
|
"k-active": G
|
|
170
170
|
}),
|
|
171
|
-
onClick: () =>
|
|
172
|
-
onContextMenu:
|
|
171
|
+
onClick: () => g(o ? void 0 : a.selectionIndex),
|
|
172
|
+
onContextMenu: z
|
|
173
173
|
},
|
|
174
|
-
/* @__PURE__ */ t.createElement("div", { className: "k-bubble-content" },
|
|
174
|
+
/* @__PURE__ */ t.createElement("div", { className: "k-bubble-content" }, v ? /* @__PURE__ */ t.createElement(v, { item: a }) : /* @__PURE__ */ t.createElement(t.Fragment, null, (a.text || a.isDeleted || a.replyToId) && /* @__PURE__ */ t.createElement("span", { className: "k-chat-bubble-text" }, !a.isDeleted && te(), ne(
|
|
175
175
|
T(a, H(u, a))
|
|
176
176
|
)), a.files && a.files.length > 0 && /* @__PURE__ */ t.createElement(
|
|
177
|
-
|
|
177
|
+
Be,
|
|
178
178
|
{
|
|
179
179
|
files: a.files,
|
|
180
180
|
message: a,
|
|
@@ -184,89 +184,85 @@ const je = t.forwardRef(
|
|
|
184
184
|
fileActions: q
|
|
185
185
|
}
|
|
186
186
|
), ae())),
|
|
187
|
-
|
|
187
|
+
p && /* @__PURE__ */ t.createElement(
|
|
188
188
|
"span",
|
|
189
189
|
{
|
|
190
190
|
className: "k-bubble-expandable-indicator",
|
|
191
|
-
onClick:
|
|
191
|
+
onClick: L,
|
|
192
192
|
role: "button",
|
|
193
|
-
"aria-label":
|
|
193
|
+
"aria-label": I ? l.toLanguageString(
|
|
194
194
|
ie,
|
|
195
|
-
|
|
195
|
+
r[ie]
|
|
196
196
|
) : l.toLanguageString(
|
|
197
197
|
re,
|
|
198
|
-
|
|
198
|
+
r[re]
|
|
199
199
|
),
|
|
200
200
|
tabIndex: 0,
|
|
201
201
|
onKeyDown: (e) => {
|
|
202
|
-
(e.key === "Enter" || e.key === " ") && (e.preventDefault(),
|
|
202
|
+
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), L(e));
|
|
203
203
|
}
|
|
204
204
|
},
|
|
205
|
-
/* @__PURE__ */ t.createElement(j, { icon:
|
|
205
|
+
/* @__PURE__ */ t.createElement(j, { icon: I ? Se : Fe, size: "medium" })
|
|
206
206
|
)
|
|
207
207
|
), K());
|
|
208
208
|
return null;
|
|
209
209
|
}, [
|
|
210
210
|
a,
|
|
211
211
|
f,
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
212
|
+
v,
|
|
213
|
+
p,
|
|
214
|
+
I,
|
|
215
215
|
o,
|
|
216
216
|
G,
|
|
217
|
-
|
|
218
|
-
|
|
217
|
+
g,
|
|
218
|
+
z,
|
|
219
219
|
te,
|
|
220
220
|
T,
|
|
221
221
|
u,
|
|
222
222
|
Y,
|
|
223
223
|
q,
|
|
224
224
|
ae,
|
|
225
|
-
|
|
225
|
+
L,
|
|
226
226
|
l,
|
|
227
227
|
K,
|
|
228
228
|
i
|
|
229
|
-
]),
|
|
229
|
+
]), Ee = t.useCallback(() => {
|
|
230
230
|
let e = null;
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
y === "hidden" || (e = /* @__PURE__ */ t.createElement("time", { className: "k-message-time", "aria-hidden": !s }, Q.formatDate(a.timestamp, U)));
|
|
234
|
-
}
|
|
235
|
-
return e;
|
|
236
|
-
}, [a.timestamp, o, U, y, Q]), Ee = t.useCallback(() => {
|
|
231
|
+
return a.timestamp && (F === "hidden" || (e = /* @__PURE__ */ t.createElement("time", { className: "k-message-time" }, Q.formatDate(a.timestamp, U)))), e;
|
|
232
|
+
}, [a.timestamp, U, F, Q]), xe = t.useCallback(() => {
|
|
237
233
|
if (!a.status)
|
|
238
234
|
return null;
|
|
239
235
|
let e;
|
|
240
|
-
if (
|
|
241
|
-
e = t.createElement(
|
|
236
|
+
if (S)
|
|
237
|
+
e = t.createElement(S, { item: a });
|
|
242
238
|
else {
|
|
243
239
|
const s = typeof a.status == "object" && a.status !== null;
|
|
244
|
-
let n,
|
|
240
|
+
let n, c, m;
|
|
245
241
|
if (s) {
|
|
246
242
|
const B = a.status;
|
|
247
|
-
n = B.text,
|
|
243
|
+
n = B.text, c = B.icon, m = B.svgIcon;
|
|
248
244
|
} else
|
|
249
245
|
n = a.status;
|
|
250
246
|
let P = null;
|
|
251
|
-
|
|
247
|
+
c ? P = /* @__PURE__ */ t.createElement(ve, { name: c, size: "xsmall" }) : m && (P = /* @__PURE__ */ t.createElement(j, { icon: m, size: "xsmall" })), e = /* @__PURE__ */ t.createElement(t.Fragment, null, P, n);
|
|
252
248
|
}
|
|
253
249
|
return /* @__PURE__ */ t.createElement("span", { className: "k-message-status" }, e);
|
|
254
|
-
}, [a,
|
|
250
|
+
}, [a, S]), ye = t.useCallback(() => {
|
|
255
251
|
let e = null;
|
|
256
252
|
if (a.isFailed) {
|
|
257
253
|
const s = l.toLanguageString(
|
|
258
254
|
ce,
|
|
259
|
-
|
|
255
|
+
r[ce]
|
|
260
256
|
);
|
|
261
|
-
e = /* @__PURE__ */ t.createElement("span", { className: "k-message-failed-content" }, /* @__PURE__ */ t.createElement(j, { icon:
|
|
257
|
+
e = /* @__PURE__ */ t.createElement("span", { className: "k-message-failed-content" }, /* @__PURE__ */ t.createElement(j, { icon: Ae, size: "xsmall" }), /* @__PURE__ */ t.createElement("span", { className: "k-message-failed-text" }, s));
|
|
262
258
|
}
|
|
263
259
|
return e;
|
|
264
|
-
}, [a, l]),
|
|
260
|
+
}, [a, l]), Ie = t.useCallback(() => {
|
|
265
261
|
let e = null;
|
|
266
262
|
if (a.isFailed) {
|
|
267
263
|
const s = l.toLanguageString(
|
|
268
264
|
ue,
|
|
269
|
-
|
|
265
|
+
r[ue]
|
|
270
266
|
);
|
|
271
267
|
e = /* @__PURE__ */ t.createElement(
|
|
272
268
|
W,
|
|
@@ -274,11 +270,11 @@ const je = t.forwardRef(
|
|
|
274
270
|
fillMode: "clear",
|
|
275
271
|
size: "xs",
|
|
276
272
|
className: "k-resend-button",
|
|
277
|
-
svgIcon:
|
|
273
|
+
svgIcon: Re,
|
|
278
274
|
"aria-label": s,
|
|
279
275
|
title: s,
|
|
280
276
|
onClick: (n) => {
|
|
281
|
-
n.stopPropagation(),
|
|
277
|
+
n.stopPropagation(), D && D({
|
|
282
278
|
message: a,
|
|
283
279
|
syntheticEvent: n,
|
|
284
280
|
nativeEvent: n.nativeEvent,
|
|
@@ -289,53 +285,72 @@ const je = t.forwardRef(
|
|
|
289
285
|
);
|
|
290
286
|
}
|
|
291
287
|
return e;
|
|
292
|
-
}, [a, l,
|
|
288
|
+
}, [a, l, D]), we = t.useCallback(() => O(
|
|
293
289
|
{
|
|
294
290
|
"k-focus": o,
|
|
295
291
|
"k-message-removed": a.isDeleted,
|
|
296
292
|
"k-message-failed": a.isFailed
|
|
297
293
|
},
|
|
298
294
|
"k-message"
|
|
299
|
-
), [o, a.isDeleted, a.isFailed]),
|
|
300
|
-
|
|
295
|
+
), [o, a.isDeleted, a.isFailed]), Te = t.useCallback(() => b && b.length > 0 && /* @__PURE__ */ t.createElement(
|
|
296
|
+
he,
|
|
301
297
|
{
|
|
302
|
-
|
|
298
|
+
className: "k-chat-message-toolbar",
|
|
303
299
|
fillMode: "flat",
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
300
|
+
ariaLabel: l.toLanguageString(
|
|
301
|
+
me,
|
|
302
|
+
r[me]
|
|
303
|
+
)
|
|
304
|
+
},
|
|
305
|
+
b.map((e) => e.id === "delete" && !C ? null : /* @__PURE__ */ t.createElement(
|
|
306
|
+
W,
|
|
307
|
+
{
|
|
308
|
+
key: e.id,
|
|
309
|
+
fillMode: "flat",
|
|
310
|
+
className: "k-toolbar-button",
|
|
311
|
+
icon: e.icon,
|
|
312
|
+
svgIcon: e.svgIcon,
|
|
313
|
+
"aria-label": e.label,
|
|
314
|
+
onClick: (s) => {
|
|
315
|
+
s.stopPropagation(), e.id === "copy" && !a.isDeleted ? w() : e.id === "reply" && E(a), M && M(e, s, a);
|
|
316
|
+
},
|
|
317
|
+
onMouseDown: (s) => s.preventDefault()
|
|
318
|
+
}
|
|
319
|
+
))
|
|
320
|
+
), [
|
|
321
|
+
w,
|
|
322
|
+
C,
|
|
323
|
+
a,
|
|
324
|
+
l,
|
|
325
|
+
b,
|
|
326
|
+
M,
|
|
327
|
+
E
|
|
328
|
+
]);
|
|
314
329
|
return /* @__PURE__ */ t.createElement(
|
|
315
330
|
"div",
|
|
316
331
|
{
|
|
317
332
|
key: a.id,
|
|
318
333
|
"data-message-id": a.id,
|
|
319
|
-
className:
|
|
320
|
-
tabIndex:
|
|
321
|
-
onMouseDown:
|
|
322
|
-
onKeyDown:
|
|
334
|
+
className: we(),
|
|
335
|
+
tabIndex: fe,
|
|
336
|
+
onMouseDown: be,
|
|
337
|
+
onKeyDown: ke,
|
|
323
338
|
onFocus: (e) => {
|
|
324
|
-
pe &&
|
|
339
|
+
pe && g(a.selectionIndex);
|
|
325
340
|
},
|
|
326
341
|
ref: (e) => {
|
|
327
342
|
V.current = e, typeof d == "function" ? d(e) : d && (d.current = e);
|
|
328
343
|
},
|
|
329
|
-
onContextMenu: f ?
|
|
344
|
+
onContextMenu: f ? z : void 0
|
|
330
345
|
},
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
(a.status || a.timestamp &&
|
|
334
|
-
|
|
346
|
+
Ie(),
|
|
347
|
+
Ce(),
|
|
348
|
+
(a.status || a.timestamp && F !== "hidden" || a.isFailed) && /* @__PURE__ */ t.createElement("div", { className: "k-message-info" }, xe(), Ee(), ye()),
|
|
349
|
+
Te()
|
|
335
350
|
);
|
|
336
351
|
}
|
|
337
352
|
);
|
|
338
|
-
|
|
353
|
+
We.displayName = "ChatMessage";
|
|
339
354
|
export {
|
|
340
|
-
|
|
355
|
+
We as ChatMessage
|
|
341
356
|
};
|
|
@@ -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
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const nt=require("react"),rt=require("../utils.js");function ct(b){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(b){for(const q in b)if(q!=="default"){const e=Object.getOwnPropertyDescriptor(b,q);Object.defineProperty(n,q,e.get?e:{enumerable:!0,get:()=>b[q]})}}return n.default=b,Object.freeze(n)}const r=ct(nt),ut=50,W=100,lt=({scrollMode:b,processedMessages:n,total:q,pageSize:e=ut,startIndex:N,endIndex:Z,onLoadMoreMessages:u,onReferencedMessageClick:j,viewItemsWrapperRef:l,authorId:Y})=>{const k=r.useRef(!1),m=b==="endless",i=q!=null?q:n.length,E=m&&n.length===i&&!k.current,h=m&&(n.length<i||k.current);h&&(k.current=!0);const[D,B]=r.useState(-1),[x,O]=r.useState(-1),v=r.useRef(D),d=r.useRef(x);v.current=D,d.current=x;const o=r.useRef(!1),P=r.useRef(0),w=r.useRef(0),g=r.useRef(0),y=r.useRef(!1),I=r.useRef(i),C=r.useRef(Y);C.current=Y;const $=r.useRef(!1),G=r.useRef(null),U=r.useRef(!1),J=r.useRef(!1),K=r.useRef(!0),Q=r.useRef(i);r.useEffect(()=>{if(E){if(k.current){(D===-1||x===-1)&&(B(0),O(n.length));return}if(D===-1||x===-1){const t=Math.max(0,n.length-e),c=n.length;B(t),O(c)}else if(x<n.length){const t=I.current;if(d.current>=t)O(n.length);else if(n.length>t&&n.slice(t).some(f=>{var T;return((T=f.author)==null?void 0:T.id)!==void 0&&String(f.author.id)===String(C.current)})){const f=Math.max(0,n.length-e);B(f),O(n.length),U.current=!0}}I.current=i}},[E,n.length,e,D,x,i]);const _=N!=null?N:0,R=Z!=null?Z:n.length,z=r.useCallback(()=>{const t=l.current;t&&(P.current=t.scrollHeight,w.current=t.scrollTop,g.current=t.querySelectorAll("[data-message-id]").length)},[l]),A=r.useCallback(t=>{var a,f,T;const c=(a=l.current)==null?void 0:a.closest(".k-chat"),S=((T=(f=l.current)==null?void 0:f.querySelector(".k-message-pinned"))==null?void 0:T.offsetHeight)||0;rt.scrollToMessageById(t,c,S)},[l]);r.useLayoutEffect(()=>{if(!y.current)return;const t=l.current;if(!t){y.current=!1;return}if(t.querySelectorAll("[data-message-id]").length<=g.current)return;const S=t.scrollHeight-P.current;S>0&&(t.scrollTop=w.current+S),y.current=!1,o.current=!1}),r.useLayoutEffect(()=>{if(!U.current)return;const t=l.current;if(!t){U.current=!1;return}x>=n.length&&x>0&&(U.current=!1,t.scrollTop=t.scrollHeight-t.clientHeight)});const L=r.useRef(!1);r.useLayoutEffect(()=>{if(!m||L.current)return;const t=l.current;t&&t.querySelector("[data-message-id]")&&(t.scrollTop=t.scrollHeight-t.clientHeight,L.current=!0)}),r.useEffect(()=>{if(!m)return;const t=l.current;if(!t)return;let c=t.scrollTop;const S=()=>{const{scrollTop:a,scrollHeight:f,clientHeight:T}=t,X=a<c,tt=a>c;if(c=a,!o.current){if(X&&a<=W){if(E){const H=v.current;if(H>0){const F=Math.max(0,H-e);y.current=!0,z(),B(F),u==null||u({startIndex:F,endIndex:d.current})}}else if(h&&_>0){o.current=!0;const H=Math.max(0,_-e);y.current=!0,z(),u==null||u({startIndex:H,endIndex:R})}}if(tt&&f-a-T<=W){if(E){const H=d.current;if(H<n.length){const F=Math.min(n.length,H+e);J.current=!0,O(F),u==null||u({startIndex:v.current,endIndex:F})}}else if(h&&R<i){o.current=!0,J.current=!0;const H=Math.min(i,R+e);u==null||u({startIndex:_,endIndex:H})}}}};return t.addEventListener("scroll",S,{passive:!0}),()=>t.removeEventListener("scroll",S)},[m,E,h,l,e,n.length,_,R,i,u]),r.useEffect(()=>{var a;const t=R>=i;if(!h){Q.current=i,K.current=t;return}const c=Q.current,S=K.current;if(Q.current=i,K.current=t,i>c&&!S&&t){const f=n[n.length-1];C.current!==void 0&&((a=f==null?void 0:f.author)==null?void 0:a.id)!==void 0&&String(f.author.id)===String(C.current)&&($.current=!0,J.current=!0)}},[h,i,R,n]),r.useEffect(()=>{!h||!$.current||($.current=!1,o.current=!1,requestAnimationFrame(()=>{const t=l.current;t&&(t.scrollTop=t.scrollHeight-t.clientHeight)}))},[h,n,l]),r.useEffect(()=>{if(!h||G.current===null)return;const t=G.current,c=l.current;if(!c)return;c.querySelector(`[data-message-id="${t}"]`)&&(G.current=null,o.current=!1,requestAnimationFrame(()=>{A(t)}))},[h,n,l,A]),r.useEffect(()=>{h&&o.current&&!y.current&&(o.current=!1)},[h,_,R]);const s=r.useMemo(()=>{if(E){const t=Math.max(0,D),c=Math.min(n.length,x);if(t>=c){const S=Math.max(0,n.length-e);return n.slice(S)}return n.slice(t,c)}return n},[E,n,D,x,e]),V=r.useMemo(()=>m?E?x>=n.length:R>=i:!0,[m,E,x,n.length,R,i]),p=r.useCallback(()=>{if(!m||V){const t=l.current;t&&t.scrollTo({top:t.scrollHeight-t.clientHeight,behavior:"smooth"});return}if(!o.current){if(E){const t=Math.max(0,n.length-e);B(t),O(n.length),u==null||u({startIndex:t,endIndex:n.length}),requestAnimationFrame(()=>{const c=l.current;c&&(c.scrollTop=c.scrollHeight-c.clientHeight)})}else if(h){$.current=!0,y.current=!1,o.current=!0;const t=Math.max(0,i-e);u==null||u({startIndex:t,endIndex:i})}}},[m,E,h,V,n.length,e,i,u,l]),M=r.useCallback(t=>{if(!m)A(t);else if(E){const c=l.current;if(c==null?void 0:c.querySelector(`[data-message-id="${t}"]`))A(t);else{if(o.current)return;const a=n.findIndex(f=>f.id===t||String(f.id)===String(t));if(a>=0){const f=Math.floor(e/2),T=Math.max(0,a-f),X=Math.min(n.length,T+e);o.current=!0,B(T),O(X),requestAnimationFrame(()=>{requestAnimationFrame(()=>{A(t),o.current=!1})})}}}else if(h){const c=l.current;if(c==null?void 0:c.querySelector(`[data-message-id="${t}"]`))A(t);else{if(o.current)return;G.current=t,y.current=!1,o.current=!0}}j==null||j({id:t})},[m,E,h,l,n,e,j,A]);return{renderedMessages:s,handleScrollToBottom:p,handleReferencedMessageClick:M,isEndless:m,isOnLastBatch:V,skipAutoScrollRef:J}};exports.useEndlessScroll=lt;
|