@progress/kendo-react-conversational-ui 14.3.3-develop.1 → 14.4.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/ai-prompt/AIPromptContent.js +1 -1
- package/ai-prompt/AIPromptContent.mjs +2 -2
- package/ai-prompt/views/AIPromptOutputView.js +1 -1
- package/ai-prompt/views/AIPromptOutputView.mjs +63 -36
- package/chat/ChatPropsAndState.d.ts +65 -0
- package/chat/Events.d.ts +19 -0
- package/chat/components/Chat.js +1 -1
- package/chat/components/Chat.mjs +373 -314
- package/chat/components/ChatContext.d.ts +2 -0
- package/chat/components/ChatMessage.js +1 -1
- package/chat/components/ChatMessage.mjs +174 -175
- package/chat/components/elements/PinnedMessage.d.ts +1 -0
- package/chat/components/elements/PinnedMessage.js +1 -1
- package/chat/components/elements/PinnedMessage.mjs +17 -21
- package/chat/hooks/useEndlessScroll.d.ts +49 -0
- package/chat/hooks/useEndlessScroll.js +8 -0
- package/chat/hooks/useEndlessScroll.mjs +267 -0
- package/chat/utils/scroll.d.ts +5 -2
- package/chat/utils/scroll.js +1 -1
- package/chat/utils/scroll.mjs +89 -83
- package/dist/cdn/js/kendo-react-conversational-ui.js +1 -1
- 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";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("react"),f=require("@progress/kendo-svg-icons"),b=require("@progress/kendo-react-buttons"),
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("react"),f=require("@progress/kendo-svg-icons"),b=require("@progress/kendo-react-buttons"),r=require("../messages/index.js"),k=require("@progress/kendo-react-intl"),I=require("./AIPromptContext.js"),C=require("./views/constants.js");function P(e){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(o,t,n.get?n:{enumerable:!0,get:()=>e[t]})}}return o.default=e,Object.freeze(o)}const a=P(g),l=a.forwardRef((e,o)=>{const{children:t,streaming:n,onCancel:c}=e,s=k.useLocalization().toLanguageString(r.aIPromptCancel,r.messages[r.aIPromptCancel]),[u]=I.useAIPromptContext(),m=u.activeView===C.outputViewDefaults.name,p=n&&!m,d=a.useCallback(i=>{i.key==="Escape"&&n&&c&&(i.preventDefault(),c())},[n,c]);return a.createElement("div",{className:"k-prompt-content",ref:o,onKeyDown:d},p&&a.createElement(b.FloatingActionButton,{onClick:c,svgIcon:f.stopSmIcon,icon:"stop-sm",size:"medium",positionMode:"absolute",className:"k-prompt-stop-fab k-generating","aria-label":s,title:s}),a.createElement("div",{className:"k-prompt-view"},t))});l.displayName="KendoReactAIPromptContent";exports.AIPromptContent=l;
|
|
@@ -13,13 +13,13 @@ import { useLocalization as w } from "@progress/kendo-react-intl";
|
|
|
13
13
|
import { useAIPromptContext as k } from "./AIPromptContext.mjs";
|
|
14
14
|
import { outputViewDefaults as C } from "./views/constants.mjs";
|
|
15
15
|
const I = t.forwardRef((m, r) => {
|
|
16
|
-
const { children: s, streaming:
|
|
16
|
+
const { children: s, streaming: e, onCancel: o } = m, n = w().toLanguageString(i, d[i]), [c] = k(), l = c.activeView === C.name, p = e && !l, u = t.useCallback(
|
|
17
17
|
(a) => {
|
|
18
18
|
a.key === "Escape" && e && o && (a.preventDefault(), o());
|
|
19
19
|
},
|
|
20
20
|
[e, o]
|
|
21
21
|
);
|
|
22
|
-
return /* @__PURE__ */ t.createElement("div", { className: "k-prompt-content", ref: r, onKeyDown: u },
|
|
22
|
+
return /* @__PURE__ */ t.createElement("div", { className: "k-prompt-content", ref: r, onKeyDown: u }, p && /* @__PURE__ */ t.createElement(
|
|
23
23
|
g,
|
|
24
24
|
{
|
|
25
25
|
onClick: o,
|
|
@@ -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 q=require("react"),S=require("../AIPromptContent.js"),A=require("../AIPromptContext.js"),i=require("../../messages/index.js"),B=require("./AIPromptViewRender.js"),o=require("@progress/kendo-react-layout"),s=require("@progress/kendo-svg-icons"),m=require("@progress/kendo-react-buttons"),x=require("@progress/kendo-react-intl"),z=require("./constants.js");function N(l){const d=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(l){for(const r in l)if(r!=="default"){const a=Object.getOwnPropertyDescriptor(l,r);Object.defineProperty(d,r,a.get?a:{enumerable:!0,get:()=>l[r]})}}return d.default=l,Object.freeze(d)}const e=N(q),M=l=>{const[d,r]=e.useState(""),a=e.useRef(null),[n]=A.useAIPromptContext(),{outputs:p,showOutputRating:b,outputCard:R}=l,{header:g,body:k,actions:E}=R||{},f=x.useLocalization(),u=f.toLanguageString(i.aIPromptCancel,i.messages[i.aIPromptCancel]),P=t=>{n.onPromptRequest&&n.onPromptRequest.call(null,t.prompt,{...t,isRetry:!0}),I()},h=t=>{t!=null&&t.responseContent&&navigator.clipboard.writeText(t.responseContent),r(t.id),setTimeout(()=>{r("")},1e3)},y=(t,c)=>{n.onPromptRequest&&n.onPromptRequest.call(null,t.prompt,{...t,ratingType:c,isRetry:!1}),I()},I=()=>{a&&a.current&&a.current.scrollTo({top:0,behavior:"smooth"})},v=e.createElement(o.Card,null,e.createElement(o.CardHeader,null,e.createElement(o.CardTitle,null,e.createElement("span",{className:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"200px"}})),e.createElement(o.CardSubtitle,null,e.createElement("span",{className:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"100%"}}))),e.createElement(o.CardBody,null,e.createElement("span",{className:"k-skeleton k-skeleton-rect k-skeleton-pulse",style:{height:"80px"}})),e.createElement(o.CardActions,null,n.streaming&&n.onCancel?e.createElement(m.Button,{size:"medium",themeColor:"base",fillMode:"flat",rounded:"medium",svgIcon:s.stopSmIcon,title:u,onClick:n.onCancel},u):e.createElement("span",{className:"k-skeleton k-skeleton-text k-skeleton-pulse",style:{width:"100%"}}))),T=(t,c)=>E?E(t):c&&n.onCancel?e.createElement(m.Button,{size:"medium",themeColor:"base",fillMode:"flat",rounded:"medium",svgIcon:s.stopSmIcon,title:u,onClick:n.onCancel},u):e.createElement(e.Fragment,null,e.createElement(m.Button,{size:"medium",themeColor:"primary",fillMode:"flat",rounded:"medium",title:"Copy",svgIcon:d===t.id?s.checkIcon:s.copyIcon,onClick:()=>h(t)},"Copy"),e.createElement(m.Button,{size:"medium",themeColor:"base",fillMode:"flat",rounded:"medium",title:"Retry",svgIcon:s.arrowRotateCwIcon,onClick:()=>P(t)},"Retry"),b&&e.createElement(e.Fragment,null,e.createElement("span",{className:"k-spacer"}),e.createElement(m.Button,{size:"medium",themeColor:t.ratingType==="positive"?"primary":"base",fillMode:"flat",rounded:"medium",title:"Rate up",svgIcon:s.thumbUpOutlineIcon,onClick:()=>y(t,"positive")}),e.createElement(m.Button,{size:"medium",themeColor:t.ratingType==="negative"?"primary":"base",fillMode:"flat",rounded:"medium",title:"Rate down",svgIcon:s.thumbDownOutlineIcon,onClick:()=>y(t,"negative")}))),C=p==null?void 0:p.map((t,c)=>{const O=!!(n.streaming&&!n.loading&&c===0);return e.createElement(o.Card,{key:`${t.id}_${c}`},e.createElement(o.CardHeader,null,g?g(t):e.createElement(e.Fragment,null,t.title&&e.createElement(o.CardTitle,null,t.title),t.subTitle&&e.createElement(o.CardSubtitle,null,t.subTitle))),e.createElement(o.CardBody,null,k?k(t):t.responseContent),e.createElement(o.CardActions,null,T(t,O)))}),w=e.createElement(o.Card,null,e.createElement(o.CardBody,null,f.toLanguageString(i.aIPromptNoOutputs,i.messages[i.aIPromptNoOutputs])));return e.createElement(B.AIPromptViewRender,{name:z.outputViewDefaults.name},e.createElement(S.AIPromptContent,{ref:a,streaming:n.streaming,onCancel:n.onCancel},e.createElement("div",{className:"k-card-list"},n.loading&&v,C,(!C||C.length===0)&&!n.loading&&w)))};exports.AIPromptOutputView=M;
|
|
@@ -6,75 +6,102 @@
|
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
8
|
import * as e from "react";
|
|
9
|
-
import { AIPromptContent as
|
|
10
|
-
import { useAIPromptContext as
|
|
11
|
-
import {
|
|
12
|
-
import { AIPromptViewRender as
|
|
13
|
-
import { Card as
|
|
14
|
-
import { checkIcon as
|
|
15
|
-
import { Button as
|
|
16
|
-
import { useLocalization as
|
|
17
|
-
import { outputViewDefaults as
|
|
18
|
-
const
|
|
19
|
-
const [
|
|
20
|
-
n.onPromptRequest && n.onPromptRequest.call(null, t.prompt, { ...t, isRetry: !0 }),
|
|
21
|
-
},
|
|
22
|
-
t != null && t.responseContent && navigator.clipboard.writeText(t.responseContent),
|
|
23
|
-
|
|
9
|
+
import { AIPromptContent as B } from "../AIPromptContent.mjs";
|
|
10
|
+
import { useAIPromptContext as F } from "../AIPromptContext.mjs";
|
|
11
|
+
import { aIPromptCancel as f, messages as y, aIPromptNoOutputs as R } from "../../messages/index.mjs";
|
|
12
|
+
import { AIPromptViewRender as L } from "./AIPromptViewRender.mjs";
|
|
13
|
+
import { Card as i, CardHeader as h, CardTitle as I, CardSubtitle as b, CardBody as c, CardActions as v } from "@progress/kendo-react-layout";
|
|
14
|
+
import { stopSmIcon as T, checkIcon as V, copyIcon as D, arrowRotateCwIcon as $, thumbUpOutlineIcon as H, thumbDownOutlineIcon as U } from "@progress/kendo-svg-icons";
|
|
15
|
+
import { Button as o } from "@progress/kendo-react-buttons";
|
|
16
|
+
import { useLocalization as _ } from "@progress/kendo-react-intl";
|
|
17
|
+
import { outputViewDefaults as j } from "./constants.mjs";
|
|
18
|
+
const te = (w) => {
|
|
19
|
+
const [P, d] = e.useState(""), r = e.useRef(null), [n] = F(), { outputs: m, showOutputRating: x, outputCard: z } = w, { header: p, body: u, actions: C } = z || {}, g = _(), a = g.toLanguageString(f, y[f]), A = (t) => {
|
|
20
|
+
n.onPromptRequest && n.onPromptRequest.call(null, t.prompt, { ...t, isRetry: !0 }), E();
|
|
21
|
+
}, N = (t) => {
|
|
22
|
+
t != null && t.responseContent && navigator.clipboard.writeText(t.responseContent), d(t.id), setTimeout(() => {
|
|
23
|
+
d("");
|
|
24
24
|
}, 1e3);
|
|
25
|
-
},
|
|
26
|
-
n.onPromptRequest && n.onPromptRequest.call(null, t.prompt, { ...t, ratingType:
|
|
27
|
-
},
|
|
28
|
-
|
|
29
|
-
},
|
|
30
|
-
|
|
25
|
+
}, k = (t, l) => {
|
|
26
|
+
n.onPromptRequest && n.onPromptRequest.call(null, t.prompt, { ...t, ratingType: l, isRetry: !1 }), E();
|
|
27
|
+
}, E = () => {
|
|
28
|
+
r && r.current && r.current.scrollTo({ top: 0, behavior: "smooth" });
|
|
29
|
+
}, O = /* @__PURE__ */ e.createElement(i, null, /* @__PURE__ */ e.createElement(h, null, /* @__PURE__ */ e.createElement(I, null, /* @__PURE__ */ e.createElement("span", { className: "k-skeleton k-skeleton-text k-skeleton-pulse", style: { width: "200px" } })), /* @__PURE__ */ e.createElement(b, null, /* @__PURE__ */ e.createElement("span", { className: "k-skeleton k-skeleton-text k-skeleton-pulse", style: { width: "100%" } }))), /* @__PURE__ */ e.createElement(c, null, /* @__PURE__ */ e.createElement("span", { className: "k-skeleton k-skeleton-rect k-skeleton-pulse", style: { height: "80px" } })), /* @__PURE__ */ e.createElement(v, null, n.streaming && n.onCancel ? /* @__PURE__ */ e.createElement(
|
|
30
|
+
o,
|
|
31
|
+
{
|
|
32
|
+
size: "medium",
|
|
33
|
+
themeColor: "base",
|
|
34
|
+
fillMode: "flat",
|
|
35
|
+
rounded: "medium",
|
|
36
|
+
svgIcon: T,
|
|
37
|
+
title: a,
|
|
38
|
+
onClick: n.onCancel
|
|
39
|
+
},
|
|
40
|
+
a
|
|
41
|
+
) : /* @__PURE__ */ e.createElement("span", { className: "k-skeleton k-skeleton-text k-skeleton-pulse", style: { width: "100%" } }))), M = (t, l) => C ? C(t) : l && n.onCancel ? /* @__PURE__ */ e.createElement(
|
|
42
|
+
o,
|
|
43
|
+
{
|
|
44
|
+
size: "medium",
|
|
45
|
+
themeColor: "base",
|
|
46
|
+
fillMode: "flat",
|
|
47
|
+
rounded: "medium",
|
|
48
|
+
svgIcon: T,
|
|
49
|
+
title: a,
|
|
50
|
+
onClick: n.onCancel
|
|
51
|
+
},
|
|
52
|
+
a
|
|
53
|
+
) : /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(
|
|
54
|
+
o,
|
|
31
55
|
{
|
|
32
56
|
size: "medium",
|
|
33
57
|
themeColor: "primary",
|
|
34
58
|
fillMode: "flat",
|
|
35
59
|
rounded: "medium",
|
|
36
60
|
title: "Copy",
|
|
37
|
-
svgIcon:
|
|
38
|
-
onClick: () =>
|
|
61
|
+
svgIcon: P === t.id ? V : D,
|
|
62
|
+
onClick: () => N(t)
|
|
39
63
|
},
|
|
40
64
|
"Copy"
|
|
41
65
|
), /* @__PURE__ */ e.createElement(
|
|
42
|
-
|
|
66
|
+
o,
|
|
43
67
|
{
|
|
44
68
|
size: "medium",
|
|
45
69
|
themeColor: "base",
|
|
46
70
|
fillMode: "flat",
|
|
47
71
|
rounded: "medium",
|
|
48
72
|
title: "Retry",
|
|
49
|
-
svgIcon:
|
|
50
|
-
onClick: () =>
|
|
73
|
+
svgIcon: $,
|
|
74
|
+
onClick: () => A(t)
|
|
51
75
|
},
|
|
52
76
|
"Retry"
|
|
53
|
-
),
|
|
54
|
-
|
|
77
|
+
), x && /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("span", { className: "k-spacer" }), /* @__PURE__ */ e.createElement(
|
|
78
|
+
o,
|
|
55
79
|
{
|
|
56
80
|
size: "medium",
|
|
57
81
|
themeColor: t.ratingType === "positive" ? "primary" : "base",
|
|
58
82
|
fillMode: "flat",
|
|
59
83
|
rounded: "medium",
|
|
60
84
|
title: "Rate up",
|
|
61
|
-
svgIcon:
|
|
62
|
-
onClick: () =>
|
|
85
|
+
svgIcon: H,
|
|
86
|
+
onClick: () => k(t, "positive")
|
|
63
87
|
}
|
|
64
88
|
), /* @__PURE__ */ e.createElement(
|
|
65
|
-
|
|
89
|
+
o,
|
|
66
90
|
{
|
|
67
91
|
size: "medium",
|
|
68
92
|
themeColor: t.ratingType === "negative" ? "primary" : "base",
|
|
69
93
|
fillMode: "flat",
|
|
70
94
|
rounded: "medium",
|
|
71
95
|
title: "Rate down",
|
|
72
|
-
svgIcon:
|
|
73
|
-
onClick: () =>
|
|
96
|
+
svgIcon: U,
|
|
97
|
+
onClick: () => k(t, "negative")
|
|
74
98
|
}
|
|
75
|
-
)))
|
|
76
|
-
|
|
99
|
+
))), s = m == null ? void 0 : m.map((t, l) => {
|
|
100
|
+
const q = !!(n.streaming && !n.loading && l === 0);
|
|
101
|
+
return /* @__PURE__ */ e.createElement(i, { key: `${t.id}_${l}` }, /* @__PURE__ */ e.createElement(h, null, p ? p(t) : /* @__PURE__ */ e.createElement(e.Fragment, null, t.title && /* @__PURE__ */ e.createElement(I, null, t.title), t.subTitle && /* @__PURE__ */ e.createElement(b, null, t.subTitle))), /* @__PURE__ */ e.createElement(c, null, u ? u(t) : t.responseContent), /* @__PURE__ */ e.createElement(v, null, M(t, q)));
|
|
102
|
+
}), S = /* @__PURE__ */ e.createElement(i, null, /* @__PURE__ */ e.createElement(c, null, g.toLanguageString(R, y[R])));
|
|
103
|
+
return /* @__PURE__ */ e.createElement(L, { name: j.name }, /* @__PURE__ */ e.createElement(B, { ref: r, streaming: n.streaming, onCancel: n.onCancel }, /* @__PURE__ */ e.createElement("div", { className: "k-card-list" }, n.loading && O, s, (!s || s.length === 0) && !n.loading && S)));
|
|
77
104
|
};
|
|
78
105
|
export {
|
|
79
|
-
|
|
106
|
+
te as AIPromptOutputView
|
|
80
107
|
};
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
8
|
import { Message, ChatActionExecuteEvent, ChatSendMessageEvent, ChatResendMessageEvent, PromptBoxMode } from '../index.js';
|
|
9
|
+
import { ChatLoadMoreEvent, ChatReferencedMessageClickEvent } from './Events.js';
|
|
9
10
|
import { ChatMessageProps, ChatMessageTemplateProps, FileAction, MessageAction } from './components/ChatMessage.js';
|
|
10
11
|
import { ChatSuggestion, SuggestionTemplateProps } from './components/SuggestionsGroup.js';
|
|
11
12
|
import { ButtonProps, SpeechToTextButtonProps } from '@progress/kendo-react-buttons';
|
|
@@ -202,6 +203,13 @@ export type MessageWidthMode = 'full' | 'standard';
|
|
|
202
203
|
* - `hidden`—Timestamps are never visible for any messages.
|
|
203
204
|
*/
|
|
204
205
|
export type TimestampVisibilityMode = 'onFocus' | 'hidden';
|
|
206
|
+
/**
|
|
207
|
+
* Controls the scroll behavior of the message list.
|
|
208
|
+
* - `scrollable`—Default mode. All messages are rendered with standard scroll behavior.
|
|
209
|
+
* - `endless`—Endless scroll mode. The Chat starts by rendering the last `pageSize` messages
|
|
210
|
+
* and prepends older ones as the user scrolls up. DOM grows within a session; only pin clicks reset it.
|
|
211
|
+
*/
|
|
212
|
+
export type ScrollMode = 'scrollable' | 'endless';
|
|
205
213
|
/**
|
|
206
214
|
* Configuration for the Message Box (PromptBox component).
|
|
207
215
|
*/
|
|
@@ -646,6 +654,63 @@ export interface ChatProps extends FieldMappingConfig {
|
|
|
646
654
|
* ```
|
|
647
655
|
*/
|
|
648
656
|
loading?: boolean;
|
|
657
|
+
/**
|
|
658
|
+
* Controls the scroll behavior of the message list.
|
|
659
|
+
* - `scrollable`—Default mode. All messages are rendered with standard scroll behavior.
|
|
660
|
+
* - `endless`—Endless scroll mode. The Chat starts by rendering the last `pageSize` messages
|
|
661
|
+
* and prepends older ones as the user scrolls up.
|
|
662
|
+
*
|
|
663
|
+
* @default 'scrollable'
|
|
664
|
+
*/
|
|
665
|
+
scrollMode?: ScrollMode;
|
|
666
|
+
/**
|
|
667
|
+
* The total number of messages in the conversation.
|
|
668
|
+
* Used to determine the mode: when `messages.length === total`, the Chat manages rendering
|
|
669
|
+
* internally (built-in mode); when `messages.length < total`, the Chat fires `onLoadMore`
|
|
670
|
+
* for the consumer to fetch data (remote mode).
|
|
671
|
+
*/
|
|
672
|
+
total?: number;
|
|
673
|
+
/**
|
|
674
|
+
* How many messages to load per scroll-triggered batch.
|
|
675
|
+
*
|
|
676
|
+
* @default 50
|
|
677
|
+
*/
|
|
678
|
+
pageSize?: number;
|
|
679
|
+
/**
|
|
680
|
+
* The index in the full conversation that `messages[0]` corresponds to.
|
|
681
|
+
* Only relevant in remote mode (`messages.length < total`).
|
|
682
|
+
*/
|
|
683
|
+
startIndex?: number;
|
|
684
|
+
/**
|
|
685
|
+
* The index (exclusive) in the full conversation that marks the end of the current batch.
|
|
686
|
+
* Only relevant in remote mode (`messages.length < total`).
|
|
687
|
+
*/
|
|
688
|
+
endIndex?: number;
|
|
689
|
+
/**
|
|
690
|
+
* Fires only in remote mode (`messages.length < total`) when the user scrolls near the edge
|
|
691
|
+
* of the rendered message window.
|
|
692
|
+
*/
|
|
693
|
+
onLoadMore?: (event: ChatLoadMoreEvent) => void;
|
|
694
|
+
/**
|
|
695
|
+
* The full set of pinned messages in the conversation.
|
|
696
|
+
* Only needed in remote mode (`messages.length < total`).
|
|
697
|
+
* The Chat uses this to render the pinned message indicator when the pinned message
|
|
698
|
+
* is outside the current batch. In built-in mode, the Chat has all messages and can
|
|
699
|
+
* look them up directly. This collection is stable — set once on load and updated
|
|
700
|
+
* only when pins change.
|
|
701
|
+
*/
|
|
702
|
+
pinnedMessages?: Message[];
|
|
703
|
+
/**
|
|
704
|
+
* Messages that are reply targets for messages in the current batch but live outside `messages[]`.
|
|
705
|
+
* Only needed in remote mode (`messages.length < total`).
|
|
706
|
+
* The Chat uses this to render reply previews when the replied-to message is not in the current batch.
|
|
707
|
+
* This collection is scoped per batch — rebuilt on each `onLoadMore` or batch replacement.
|
|
708
|
+
*/
|
|
709
|
+
repliedToMessages?: Message[];
|
|
710
|
+
/**
|
|
711
|
+
* Fires when the user clicks a referenced message (pinned indicator or reply preview).
|
|
712
|
+
*/
|
|
713
|
+
onReferencedMessageClick?: (event: ChatReferencedMessageClickEvent) => void;
|
|
649
714
|
}
|
|
650
715
|
/**
|
|
651
716
|
* @hidden
|
package/chat/Events.d.ts
CHANGED
|
@@ -57,3 +57,22 @@ export interface ChatToolbarActionExecuteEvent extends BaseEvent<React.Component
|
|
|
57
57
|
*/
|
|
58
58
|
show: boolean;
|
|
59
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* Arguments for the `onLoadMore` event of the Chat.
|
|
62
|
+
* Fires in remote mode (`messages.length < total`) when the user scrolls near the edge
|
|
63
|
+
* of the rendered message window.
|
|
64
|
+
*/
|
|
65
|
+
export interface ChatLoadMoreEvent {
|
|
66
|
+
/** The start index of the requested message range (inclusive). */
|
|
67
|
+
startIndex: number;
|
|
68
|
+
/** The end index of the requested message range (exclusive). */
|
|
69
|
+
endIndex: number;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Arguments for the `onReferencedMessageClick` event of the Chat.
|
|
73
|
+
* Fires when the user clicks a referenced message (pinned indicator or reply preview).
|
|
74
|
+
*/
|
|
75
|
+
export interface ChatReferencedMessageClickEvent {
|
|
76
|
+
/** The id of the referenced message that was clicked. */
|
|
77
|
+
id: string | number;
|
|
78
|
+
}
|
package/chat/components/Chat.js
CHANGED
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("@progress/kendo-react-common"),n=require("prop-types"),Tt=require("react"),St=require("@progress/kendo-react-buttons"),Ct=require("@progress/kendo-svg-icons"),Mt=require("../ViewItem.js"),bt=require("./ActionGroup.js"),kt=require("./AttachmentGroup.js"),vt=require("./DateMarker.js"),Et=require("./MessageGroup.js"),xt=require("./NewMessage.js"),Rt=require("./Header.js"),wt=require("./elements/PinnedMessage.js"),At=require("./Notification.js"),qt=require("./ChatContext.js"),Ft=require("./ChatMessage.js"),Pe=require("../../package-metadata.js"),l=require("../../messages/index.js"),Lt=require("@progress/kendo-react-intl"),je=require("../utils/fieldMapping.js"),Ue=require("../utils/scroll.js"),Bt=require("../utils/messageSettings.js");function It(p){const d=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(p){for(const i in p)if(i!=="default"){const M=Object.getOwnPropertyDescriptor(p,i);Object.defineProperty(d,i,M.get?M:{enumerable:!0,get:()=>p[i]})}}return d.default=p,Object.freeze(d)}const t=It(Tt),D=t.forwardRef((p,d)=>{const{messages:i=[],messageTemplate:M,messageContentTemplate:O,attachmentTemplate:R,width:Ve,height:He,onSendMessage:b,onSuggestionClick:P,onInputValueChange:j,onActionExecute:w,dir:T,messageBox:Ke,placeholder:We,className:U,style:ze,message:V=Ft.ChatMessage,authorId:u,suggestions:Ge,suggestionTemplate:_e,suggestionsLayout:$e="scroll",quickActionsLayout:H="scroll",inputValue:Je,headerTemplate:S,noDataTemplate:C,timestampTemplate:K,statusTemplate:W,userStatusTemplate:z,allowMessageCollapse:G,messageToolbarActions:_,messageContextMenuActions:$,fileActions:v,onUnpin:Qe,messageWidthMode:J,showAvatar:Q,showUsername:X,timestampVisibility:Y,authorMessageSettings:Z,receiverMessageSettings:ee,onToolbarAction:te,onContextMenuAction:se,onFileAction:ne,onDownload:oe,speechToTextConfig:ae,uploadConfig:re,sendButtonConfig:Xe,messageFilesLayout:le,scrollToBottomButton:A=!0,autoScrollThreshold:Ye,textField:ie,statusField:ce,authorIdField:ue,authorNameField:ge,authorImageUrlField:me,authorImageAltTextField:de,idField:pe,timestampField:fe,filesField:he,attachmentsField:ye,replyToIdField:Te,isDeletedField:Se,isPinnedField:Ce,typingField:Me,suggestedActionsField:be,isFailedField:ke,onResendMessage:ve,messageBoxSettings:Ze,loading:et,...tt}=p,[f,q]=t.useState(null),[F,st]=t.useState(!1),[nt,Ee]=t.useState(!1),[xe,Re]=t.useState(null),[h,we]=t.useState(null),[ot,Ae]=t.useState(!1),L=t.useRef(null),qe=t.useRef(null),c=t.useRef(null),Fe=t.useRef(null),B=t.useRef(void 0),I=t.useRef(!1),N=t.useRef(null),Le=t.useRef(""),a=t.useMemo(()=>{if(!i||i.length===0)return[];const s={textField:ie,statusField:ce,authorIdField:ue,authorNameField:ge,authorImageUrlField:me,authorImageAltTextField:de,idField:pe,timestampField:fe,filesField:he,attachmentsField:ye,replyToIdField:Te,isDeletedField:Se,isPinnedField:Ce,typingField:Me,suggestedActionsField:be,isFailedField:ke};return!Object.values(s).some(o=>o!==void 0)&&je.isStandardMessageFormat(i[0])?i.map(o=>({...o,timestamp:o.timestamp?new Date(o.timestamp):o.timestamp})):je.mapDataArrayToMessages(i,s)},[i,ie,ce,ue,ge,me,de,pe,fe,he,ye,Te,Se,Ce,Me,be,ke]);t.useEffect(()=>{if(u===Le.current&&N.current){we(N.current);return}if(u&&a.length>0){const s=a.find(o=>o.author&&(o.author.id===u||o.author.id===String(u))),e=(s==null?void 0:s.author)||{id:u};N.current=e,Le.current=u,we(e)}},[u,a]);const y=t.useMemo(()=>a.length>0?Mt.convertMsgsToViewItems(a):[],[a]),at=t.useMemo(()=>!m.validatePackage(Pe.packageMetadata,{component:"Chat"}),[]),rt=m.getLicenseMessage(Pe.packageMetadata),Be=t.useMemo(()=>a.find(s=>s.isPinned),[a]),E=Lt.useLocalization();Ue.useChatScroll({viewItemsWrapperRef:c,isKeyboardNavigationActiveRef:I,processedMessages:a,authorId:u,autoScrollThreshold:Ye});const lt=Ue.useHasScrollbar({elementRef:c}),it=t.useCallback(()=>{clearTimeout(B.current)},[]),ct=t.useCallback(()=>{B.current=window.setTimeout(()=>{q(null)},0)},[]),x=t.useCallback(s=>{q(s)},[]),ut=t.useCallback(s=>{let e=null;const o=f!==null?f:y.lastSelectionIndex;s.keyCode===m.Keys.up?o===null?e=0:o>0&&(e=o-1):s.keyCode===m.Keys.down?o===null?e=0:o<y.lastSelectionIndex&&(e=o+1):s.keyCode===m.Keys.home?e=0:s.keyCode===m.Keys.end&&(e=y.lastSelectionIndex),e!==null&&(q(e),I.current=!0,s.preventDefault())},[f,y]),Ie=t.useCallback((s,e,o)=>{var g;if(w&&w({action:{value:s.value,title:s.title,type:s.type},syntheticEvent:e,nativeEvent:e.nativeEvent,target:e.currentTarget}),!e.isDefaultPrevented()){switch(s.type){case"reply":b&&b({message:{id:"",author:h,text:s.value,timestamp:new Date},syntheticEvent:e,nativeEvent:e.nativeEvent,target:e.currentTarget});break;case"call":window.open("tel:"+s.value);break;case"openUrl":window.open(s.value);break}(g=Fe.current)==null||g.focusInput()}},[w,b,h]),gt=t.useCallback(()=>{c.current&&(c.current.scrollTop=c.current.scrollHeight-c.current.clientHeight)},[]),mt=t.useCallback(()=>m.classNames("k-chat",U,{"k-rtl":F}),[U,F]),dt=t.useCallback(()=>{const s=y.length-1;return y.map((e,o)=>{var g;if(e.type==="date-marker")return t.createElement(vt,{item:e,key:e.trackBy,timestampTemplate:K});if(e.type==="message-group"){const k={allowMessageCollapse:G,messageWidthMode:J,showAvatar:Q,showUsername:X,messageTemplate:M,messageContentTemplate:O,messageToolbarActions:_,messageContextMenuActions:$,fileActions:v},r=Bt.resolveMessageSettings((g=e==null?void 0:e.messages)==null?void 0:g[0],u,k,Z,ee);return t.createElement(Et,{group:e,itemTemplate:r.messageTemplate,contentTemplate:r.messageContentTemplate,attachmentTemplate:R,user:h,selectedItemIndex:f,onRequestSelection:x,isLastGroup:o===s,key:e.messages[0].selectionIndex,message:V,allowMessageCollapse:r.allowMessageCollapse,messageToolbarActions:r.messageToolbarActions,messageContextMenuActions:r.messageContextMenuActions,fileActions:r.fileActions,messageWidthMode:r.messageWidthMode,showAvatar:r.showAvatar,showUsername:r.showUsername})}else{if(e.type==="attachment-group")return t.createElement(kt,{group:e,itemTemplate:R,onRequestSelection:x,selected:e.selectionIndex===f,isLastGroup:o===s,key:e.selectionIndex});if(e.type==="action-group")return t.createElement(bt,{group:e,onActionExecute:Ie,onRequestSelection:x,selected:e.selectionIndex===f,key:e.selectionIndex,quickActionsLayout:H,dir:T})}return null})},[y,K,M,O,R,h,f,x,V,G,_,$,v,J,Q,X,u,Z,ee,Ie,H,T]),pt=t.useCallback(()=>S?typeof S=="function"?S():S:null,[S]),ft=t.useCallback(()=>C?typeof C=="function"?C():C:null,[C]);t.useEffect(()=>{const s=T!==void 0?T==="rtl":L.current&&getComputedStyle(L.current).direction==="rtl";st(!!s)},[T]),t.useEffect(()=>()=>{clearTimeout(B.current)},[]),t.useEffect(()=>{if(!A||!c.current)return;let s,e;const o=()=>{s=void 0;const Ne=c.current;if(!Ne)return;const{scrollHeight:De,scrollTop:yt,clientHeight:Oe}=Ne;!(De>Oe)||De-yt-Oe<=100?(e!==void 0&&(clearTimeout(e),e=void 0),Ae(!1)):e!=null||(e=setTimeout(()=>{e=void 0,Ae(!0)},300))},g=()=>{s===void 0&&(s=requestAnimationFrame(o))},k=c.current;k.addEventListener("scroll",g,{passive:!0});const r=new MutationObserver(g);return r.observe(k,{childList:!0,subtree:!0,characterData:!0}),()=>{k.removeEventListener("scroll",g),r.disconnect(),s!==void 0&&cancelAnimationFrame(s),e!==void 0&&clearTimeout(e)}},[A]);const ht=t.useMemo(()=>({replyToMessage:xe,setReplyToMessage:Re,messages:a,user:h,internalScrollContainerRef:qe,messageListScrollContainerRef:c,onToolbarAction:te,onContextMenuAction:se,onFileAction:ne,setShowCopyNotification:Ee,onDownload:oe,onResendMessage:ve,fileActions:v,speechToTextConfig:ae,uploadConfig:re,statusTemplate:W,userStatusTemplate:z,messageFilesLayout:le,timestampVisibility:Y}),[xe,Re,a,h,te,se,ne,Ee,oe,ve,v,ae,re,W,z,le,Y]);return t.createElement(qt.default.Provider,{value:ht},t.createElement("div",{style:{width:Ve,height:He,position:"relative",overflow:"hidden",...ze},onKeyDown:ut,className:mt(),ref:s=>{L.current=s,qe.current=s,typeof d=="function"?d(s):d&&(d.current=s)},...tt},S!==void 0&&t.createElement(Rt,null,pt()),t.createElement("div",{className:"k-message-list",onBlur:ct,onFocus:it,role:"log","aria-label":E.toLanguageString(l.ariaLabelMessageList,l.messages[l.ariaLabelMessageList]),"aria-live":"polite",ref:c},Be&&t.createElement(wt,{message:Be,onUnpin:Qe,user:h}),t.createElement("div",{className:m.classNames("k-message-list-content",{"k-message-list-content-empty":a.length===0})},a.length===0&&C!==void 0&&ft(),a.length>0&&dt()),A&&ot&&t.createElement("div",{className:"k-chat-scroll-to-bottom-container"},t.createElement(St.FloatingActionButton,{svgIcon:Ct.arrowDownOutlineIcon,size:"small",themeColor:"light",rounded:"full",onClick:gt,"aria-label":E.toLanguageString(l.scrollToBottom,l.messages[l.scrollToBottom]),title:E.toLanguageString(l.scrollToBottom,l.messages[l.scrollToBottom])}))),lt&&t.createElement("div",{className:"k-separator"}),t.createElement(xt,{onSendMessage:(s,e)=>{b&&b({message:s,syntheticEvent:e,nativeEvent:e.nativeEvent,target:e.currentTarget})},onSuggestionClick:s=>{P&&P(s)},isDirectionRightToLeft:F,ref:Fe,placeholder:We,MessageBox:Ke,suggestions:Ge,suggestionTemplate:_e,inputValue:Je,onInputValueChange:s=>{j&&j(s)},onInputClick:()=>{I.current=!1},sendButtonConfig:Xe,suggestionsLayout:$e,dir:T,messageBoxSettings:Ze,loading:et}),t.createElement(At,{show:nt,text:E.toLanguageString(l.chatCopyNotification,l.messages[l.chatCopyNotification])}),at&&t.createElement(m.WatermarkOverlay,{message:rt})))});D.displayName="Chat";D.propTypes={messages:n.arrayOf(n.object),user:n.object,messageTemplate:n.any,messageContentTemplate:n.any,attachmentTemplate:n.any,width:n.oneOfType([n.string,n.number]),style:n.object,onSendMessage:n.func,onActionExecute:n.func,dir:n.string,messageBox:n.any,noDataTemplate:n.oneOfType([n.element,n.func]),suggestionsLayout:n.oneOf(["scroll","wrap","scrollbuttons"]),quickActionsLayout:n.oneOf(["scroll","wrap","scrollbuttons"]),userStatusTemplate:n.elementType,messageFilesLayout:n.oneOf(["vertical","wrap","horizontal"]),showAvatar:n.bool,showUsername:n.bool,authorMessageSettings:n.object,receiverMessageSettings:n.object};exports.Chat=D;
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@progress/kendo-react-common"),n=require("prop-types"),Bt=require("react"),It=require("@progress/kendo-react-buttons"),Nt=require("@progress/kendo-svg-icons"),Ot=require("../ViewItem.js"),Dt=require("./ActionGroup.js"),Pt=require("./AttachmentGroup.js"),jt=require("./DateMarker.js"),Ut=require("./MessageGroup.js"),Vt=require("./NewMessage.js"),zt=require("./Header.js"),Kt=require("./elements/PinnedMessage.js"),Wt=require("./Notification.js"),Gt=require("./ChatContext.js"),Ht=require("./ChatMessage.js"),Ge=require("../../package-metadata.js"),a=require("../../messages/index.js"),_t=require("@progress/kendo-react-intl"),He=require("../utils/fieldMapping.js"),_e=require("../utils/scroll.js"),$t=require("../utils/messageSettings.js"),Jt=require("../hooks/useEndlessScroll.js");function Qt(f){const d=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(f){for(const r in f)if(r!=="default"){const k=Object.getOwnPropertyDescriptor(f,r);Object.defineProperty(d,r,k.get?k:{enumerable:!0,get:()=>f[r]})}}return d.default=f,Object.freeze(d)}const t=Qt(Bt),W=t.forwardRef((f,d)=>{const{messages:r=[],messageTemplate:k,messageContentTemplate:G,attachmentTemplate:B,width:$e,height:Je,onSendMessage:v,onSuggestionClick:H,onInputValueChange:_,onActionExecute:I,dir:S,messageBox:Qe,placeholder:Xe,className:$,style:Ye,message:J=Ht.ChatMessage,authorId:l,suggestions:Ze,suggestionTemplate:et,suggestionsLayout:tt="scroll",quickActionsLayout:Q="scroll",inputValue:st,headerTemplate:C,noDataTemplate:T,timestampTemplate:X,statusTemplate:Y,userStatusTemplate:Z,allowMessageCollapse:ee,messageToolbarActions:te,messageContextMenuActions:se,fileActions:A,onUnpin:nt,messageWidthMode:ne,showAvatar:oe,showUsername:ae,timestampVisibility:re,authorMessageSettings:le,receiverMessageSettings:ie,onToolbarAction:ce,onContextMenuAction:ue,onFileAction:de,onDownload:ge,speechToTextConfig:me,uploadConfig:fe,sendButtonConfig:ot,messageFilesLayout:pe,scrollToBottomButton:N=!0,autoScrollThreshold:at,textField:he,statusField:ye,authorIdField:Me,authorNameField:Se,authorImageUrlField:Ce,authorImageAltTextField:Te,idField:be,timestampField:ke,filesField:ve,attachmentsField:Ee,replyToIdField:Re,isDeletedField:xe,isPinnedField:Ae,typingField:qe,suggestedActionsField:Le,isFailedField:Fe,onResendMessage:we,messageBoxSettings:rt,loading:lt,scrollMode:it,total:ct,pageSize:ut,startIndex:dt,endIndex:gt,onLoadMore:mt,pinnedMessages:O,repliedToMessages:Be,onReferencedMessageClick:ft,...pt}=f,[p,D]=t.useState(null),[P,ht]=t.useState(!1),[yt,Ie]=t.useState(!1),[Ne,Oe]=t.useState(null),[h,De]=t.useState(null),[Mt,Pe]=t.useState(!1),j=t.useRef(null),je=t.useRef(null),g=t.useRef(null),Ue=t.useRef(null),U=t.useRef(void 0),V=t.useRef(!1),z=t.useRef(null),Ve=t.useRef(""),m=t.useMemo(()=>{if(!r||r.length===0)return[];const s={textField:he,statusField:ye,authorIdField:Me,authorNameField:Se,authorImageUrlField:Ce,authorImageAltTextField:Te,idField:be,timestampField:ke,filesField:ve,attachmentsField:Ee,replyToIdField:Re,isDeletedField:xe,isPinnedField:Ae,typingField:qe,suggestedActionsField:Le,isFailedField:Fe};return!Object.values(s).some(o=>o!==void 0)&&He.isStandardMessageFormat(r[0])?r.map(o=>({...o,timestamp:o.timestamp?new Date(o.timestamp):o.timestamp})):He.mapDataArrayToMessages(r,s)},[r,he,ye,Me,Se,Ce,Te,be,ke,ve,Ee,Re,xe,Ae,qe,Le,Fe]);t.useEffect(()=>{if(l===Ve.current&&z.current){De(z.current);return}if(l&&m.length>0){const s=m.find(o=>o.author&&(o.author.id===l||o.author.id===String(l))),e=(s==null?void 0:s.author)||{id:l};z.current=e,Ve.current=l,De(e)}},[l,m]);const{renderedMessages:y,handleScrollToBottom:St,handleReferencedMessageClick:K,isEndless:Ct,isOnLastBatch:ze,skipAutoScrollRef:Tt}=Jt.useEndlessScroll({scrollMode:it,processedMessages:m,total:ct,pageSize:ut,startIndex:dt,endIndex:gt,onLoadMore:mt,onReferencedMessageClick:ft,viewItemsWrapperRef:g,authorId:l}),M=t.useMemo(()=>y.length>0?Ot.convertMsgsToViewItems(y):[],[y]),bt=t.useMemo(()=>!u.validatePackage(Ge.packageMetadata,{component:"Chat"}),[]),kt=u.getLicenseMessage(Ge.packageMetadata),Ke=t.useMemo(()=>{if(O)return O.find(e=>e.isPinned);const s=m.find(e=>e.isPinned);if(s)return s},[m,O]),q=_t.useLocalization();_e.useMessageAutoScroll({viewItemsWrapperRef:g,isKeyboardNavigationActiveRef:V,processedMessages:y,authorId:l,autoScrollThreshold:at,isEndless:Ct,isOnLastBatch:ze,skipAutoScrollRef:Tt});const vt=_e.useHasScrollbar({elementRef:g}),Et=t.useCallback(()=>{clearTimeout(U.current)},[]),Rt=t.useCallback(()=>{U.current=window.setTimeout(()=>{D(null)},0)},[]),L=t.useCallback(s=>{D(s)},[]),xt=t.useCallback(s=>{let e=null;const o=p!==null?p:M.lastSelectionIndex;s.keyCode===u.Keys.up?o===null?e=0:o>0&&(e=o-1):s.keyCode===u.Keys.down?o===null?e=0:o<M.lastSelectionIndex&&(e=o+1):s.keyCode===u.Keys.home?e=0:s.keyCode===u.Keys.end&&(e=M.lastSelectionIndex),e!==null&&(D(e),V.current=!0,s.preventDefault())},[p,M]),We=t.useCallback((s,e,o)=>{var c;if(I&&I({action:{value:s.value,title:s.title,type:s.type},syntheticEvent:e,nativeEvent:e.nativeEvent,target:e.currentTarget}),!e.isDefaultPrevented()){switch(s.type){case"reply":v&&v({message:{id:"",author:h,text:s.value,timestamp:new Date},syntheticEvent:e,nativeEvent:e.nativeEvent,target:e.currentTarget});break;case"call":window.open("tel:"+s.value);break;case"openUrl":window.open(s.value);break}(c=Ue.current)==null||c.focusInput()}},[I,v,h]),At=t.useCallback(()=>u.classNames("k-chat",$,{"k-rtl":P}),[$,P]),qt=t.useCallback(()=>{const s=M.length-1;return M.map((e,o)=>{var c,b,E,R,x,F;if(e.type==="date-marker")return t.createElement(jt,{item:e,key:e.trackBy,timestampTemplate:X});if(e.type==="message-group"){const w={allowMessageCollapse:ee,messageWidthMode:ne,showAvatar:oe,showUsername:ae,messageTemplate:k,messageContentTemplate:G,messageToolbarActions:te,messageContextMenuActions:se,fileActions:A},i=$t.resolveMessageSettings((c=e==null?void 0:e.messages)==null?void 0:c[0],l,w,le,ie);return t.createElement(Ut,{group:e,itemTemplate:i.messageTemplate,contentTemplate:i.messageContentTemplate,attachmentTemplate:B,user:h,selectedItemIndex:p,onRequestSelection:L,isLastGroup:o===s,key:(b=e.messages[0].id)!=null?b:e.messages[0].selectionIndex,message:J,allowMessageCollapse:i.allowMessageCollapse,messageToolbarActions:i.messageToolbarActions,messageContextMenuActions:i.messageContextMenuActions,fileActions:i.fileActions,messageWidthMode:i.messageWidthMode,showAvatar:i.showAvatar,showUsername:i.showUsername})}else{if(e.type==="attachment-group")return t.createElement(Pt,{group:e,itemTemplate:B,onRequestSelection:L,selected:e.selectionIndex===p,isLastGroup:o===s,key:`att-${(R=(E=e.trackBy)==null?void 0:E.id)!=null?R:e.selectionIndex}`});if(e.type==="action-group")return t.createElement(Dt,{group:e,onActionExecute:We,onRequestSelection:L,selected:e.selectionIndex===p,key:`act-${(F=(x=e.trackBy)==null?void 0:x.id)!=null?F:e.selectionIndex}`,quickActionsLayout:Q,dir:S})}return null})},[M,X,k,G,B,h,p,L,J,ee,te,se,A,ne,oe,ae,l,le,ie,We,Q,S]),Lt=t.useCallback(()=>C?typeof C=="function"?C():C:null,[C]),Ft=t.useCallback(()=>T?typeof T=="function"?T():T:null,[T]);t.useEffect(()=>{const s=S!==void 0?S==="rtl":j.current&&getComputedStyle(j.current).direction==="rtl";ht(!!s)},[S]),t.useEffect(()=>()=>{clearTimeout(U.current)},[]),t.useEffect(()=>{if(!N||!g.current)return;let s,e;const o=()=>{s=void 0;const R=g.current;if(!R)return;const{scrollHeight:x,scrollTop:F,clientHeight:w}=R;!(x>w)||x-F-w<=100?(e!==void 0&&(clearTimeout(e),e=void 0),Pe(!1)):e!=null||(e=setTimeout(()=>{e=void 0,Pe(!0)},300))},c=()=>{s===void 0&&(s=requestAnimationFrame(o))},b=g.current;b.addEventListener("scroll",c,{passive:!0});const E=new MutationObserver(c);return E.observe(b,{childList:!0,subtree:!0,characterData:!0}),()=>{b.removeEventListener("scroll",c),E.disconnect(),s!==void 0&&cancelAnimationFrame(s),e!==void 0&&clearTimeout(e)}},[N]);const wt=t.useMemo(()=>({replyToMessage:Ne,setReplyToMessage:Oe,messages:m,repliedToMessages:Be,user:h,internalScrollContainerRef:je,messageListScrollContainerRef:g,onToolbarAction:ce,onContextMenuAction:ue,onFileAction:de,setShowCopyNotification:Ie,onDownload:ge,onResendMessage:we,fileActions:A,speechToTextConfig:me,uploadConfig:fe,statusTemplate:Y,userStatusTemplate:Z,messageFilesLayout:pe,timestampVisibility:re,onReferencedMessageClick:K}),[Ne,Oe,m,Be,h,ce,ue,de,Ie,ge,we,A,me,fe,Y,Z,pe,re,K]);return t.createElement(Gt.default.Provider,{value:wt},t.createElement("div",{style:{width:$e,height:Je,position:"relative",overflow:"hidden",...Ye},onKeyDown:xt,className:At(),ref:s=>{j.current=s,je.current=s,typeof d=="function"?d(s):d&&(d.current=s)},...pt},C!==void 0&&t.createElement(zt,null,Lt()),t.createElement("div",{className:"k-message-list",onBlur:Rt,onFocus:Et,role:"log","aria-label":q.toLanguageString(a.ariaLabelMessageList,a.messages[a.ariaLabelMessageList]),"aria-live":"polite",ref:g,style:{scrollBehavior:"auto"}},Ke&&t.createElement(Kt,{message:Ke,onUnpin:nt,user:h,onReferencedMessageClick:K}),t.createElement("div",{className:u.classNames("k-message-list-content",{"k-message-list-content-empty":y.length===0})},y.length===0&&T!==void 0&&Ft(),y.length>0&&qt()),N&&(Mt||!ze)&&t.createElement("div",{className:"k-chat-scroll-to-bottom-container"},t.createElement(It.FloatingActionButton,{svgIcon:Nt.arrowDownOutlineIcon,size:"small",themeColor:"light",rounded:"full",onClick:St,"aria-label":q.toLanguageString(a.scrollToBottom,a.messages[a.scrollToBottom]),title:q.toLanguageString(a.scrollToBottom,a.messages[a.scrollToBottom])}))),vt&&t.createElement("div",{className:"k-separator"}),t.createElement(Vt,{onSendMessage:(s,e)=>{v&&v({message:s,syntheticEvent:e,nativeEvent:e.nativeEvent,target:e.currentTarget})},onSuggestionClick:s=>{H&&H(s)},isDirectionRightToLeft:P,ref:Ue,placeholder:Xe,MessageBox:Qe,suggestions:Ze,suggestionTemplate:et,inputValue:st,onInputValueChange:s=>{_&&_(s)},onInputClick:()=>{V.current=!1},sendButtonConfig:ot,suggestionsLayout:tt,dir:S,messageBoxSettings:rt,loading:lt}),t.createElement(Wt,{show:yt,text:q.toLanguageString(a.chatCopyNotification,a.messages[a.chatCopyNotification])}),bt&&t.createElement(u.WatermarkOverlay,{message:kt})))});W.displayName="Chat";W.propTypes={messages:n.arrayOf(n.object),user:n.object,messageTemplate:n.any,messageContentTemplate:n.any,attachmentTemplate:n.any,width:n.oneOfType([n.string,n.number]),style:n.object,onSendMessage:n.func,onActionExecute:n.func,dir:n.string,messageBox:n.any,noDataTemplate:n.oneOfType([n.element,n.func]),suggestionsLayout:n.oneOf(["scroll","wrap","scrollbuttons"]),quickActionsLayout:n.oneOf(["scroll","wrap","scrollbuttons"]),userStatusTemplate:n.elementType,messageFilesLayout:n.oneOf(["vertical","wrap","horizontal"]),showAvatar:n.bool,showUsername:n.bool,authorMessageSettings:n.object,receiverMessageSettings:n.object,scrollMode:n.oneOf(["scrollable","endless"]),total:n.number,pageSize:n.number,startIndex:n.number,endIndex:n.number,onLoadMore:n.func,pinnedMessages:n.arrayOf(n.object),repliedToMessages:n.arrayOf(n.object),onReferencedMessageClick:n.func};exports.Chat=W;
|