@progress/kendo-react-conversational-ui 13.4.0-develop.2 → 13.4.0-develop.4
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/api/message.interface.d.ts +87 -9
- package/chat/ChatPropsAndState.d.ts +108 -9
- package/chat/Events.d.ts +9 -0
- package/chat/components/ActionGroup.js +1 -1
- package/chat/components/ActionGroup.mjs +58 -48
- package/chat/components/Chat.d.ts +1 -1
- package/chat/components/Chat.js +1 -1
- package/chat/components/Chat.mjs +318 -269
- package/chat/components/ChatContext.d.ts +6 -3
- package/chat/components/ChatMessage.js +1 -1
- package/chat/components/ChatMessage.mjs +237 -177
- package/chat/components/Header.js +1 -1
- package/chat/components/Header.mjs +3 -3
- package/chat/components/NewMessage.d.ts +5 -3
- package/chat/components/NewMessage.js +1 -1
- package/chat/components/NewMessage.mjs +174 -226
- package/chat/components/ScrollButtonsWrapper.js +1 -1
- package/chat/components/ScrollButtonsWrapper.mjs +34 -40
- package/chat/components/SuggestionsGroup.js +1 -1
- package/chat/components/SuggestionsGroup.mjs +40 -39
- package/chat/components/elements/FileBox.js +1 -1
- package/chat/components/elements/FileBox.mjs +33 -41
- package/chat/components/elements/PinnedMessage.js +1 -1
- package/chat/components/elements/PinnedMessage.mjs +24 -22
- package/chat/hooks/useScrollWithButtons.d.ts +4 -0
- package/chat/hooks/useScrollWithButtons.js +1 -1
- package/chat/hooks/useScrollWithButtons.mjs +25 -23
- package/chat/utils/fieldMapping.d.ts +1 -1
- package/chat/utils/fieldMapping.js +1 -1
- package/chat/utils/fieldMapping.mjs +37 -34
- package/chat/utils/scroll.d.ts +15 -1
- package/chat/utils/scroll.js +3 -3
- package/chat/utils/scroll.mjs +92 -65
- package/chat/utils.d.ts +4 -1
- package/chat/utils.js +1 -1
- package/chat/utils.mjs +37 -37
- package/dist/cdn/js/kendo-react-conversational-ui.js +1 -1
- package/index.d.mts +6 -0
- package/index.d.ts +6 -0
- package/index.js +1 -1
- package/index.mjs +39 -31
- package/messages/index.d.ts +50 -0
- package/messages/index.js +1 -1
- package/messages/index.mjs +60 -40
- package/package-metadata.js +1 -1
- package/package-metadata.mjs +1 -1
- package/package.json +11 -11
- package/prompt-box/Events.d.ts +66 -0
- package/prompt-box/FileBox.d.ts +22 -0
- package/prompt-box/FileBox.js +8 -0
- package/prompt-box/FileBox.mjs +72 -0
- package/prompt-box/PromptBox.d.ts +35 -0
- package/prompt-box/PromptBox.js +8 -0
- package/prompt-box/PromptBox.mjs +424 -0
- package/prompt-box/PromptBoxActionButton.d.ts +32 -0
- package/prompt-box/PromptBoxActionButton.js +8 -0
- package/prompt-box/PromptBoxActionButton.mjs +14 -0
- package/prompt-box/PromptBoxSpeechToTextButton.d.ts +32 -0
- package/prompt-box/PromptBoxSpeechToTextButton.js +8 -0
- package/prompt-box/PromptBoxSpeechToTextButton.mjs +14 -0
- package/prompt-box/PromptBoxUploadButton.d.ts +108 -0
- package/prompt-box/PromptBoxUploadButton.js +8 -0
- package/prompt-box/PromptBoxUploadButton.mjs +54 -0
- package/prompt-box/interfaces/PromptBoxProps.d.ts +390 -0
|
@@ -5,31 +5,32 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
import * as
|
|
9
|
-
import { classNames as
|
|
8
|
+
import * as s from "react";
|
|
9
|
+
import { classNames as u } from "@progress/kendo-react-common";
|
|
10
10
|
import { ScrollButtonsWrapper as R } from "./ScrollButtonsWrapper.mjs";
|
|
11
|
-
import { useScrollWithButtons as
|
|
12
|
-
const
|
|
11
|
+
import { useScrollWithButtons as S } from "../hooks/useScrollWithButtons.mjs";
|
|
12
|
+
const N = (f) => {
|
|
13
13
|
const {
|
|
14
|
-
suggestions:
|
|
14
|
+
suggestions: t,
|
|
15
15
|
onSuggestionClick: l,
|
|
16
16
|
suggestionsView: o,
|
|
17
|
-
suggestionTemplate:
|
|
18
|
-
suggestionsLayout:
|
|
19
|
-
dir:
|
|
20
|
-
} =
|
|
21
|
-
enabled:
|
|
22
|
-
dir:
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
17
|
+
suggestionTemplate: a,
|
|
18
|
+
suggestionsLayout: r,
|
|
19
|
+
dir: i
|
|
20
|
+
} = f, d = s.useRef(null), { canScrollLeft: p, canScrollRight: b, scrollLeft: k, scrollRight: y } = S(d, {
|
|
21
|
+
enabled: r === "scrollbuttons" || r === "scroll",
|
|
22
|
+
dir: i,
|
|
23
|
+
mode: r,
|
|
24
|
+
itemsDependency: t
|
|
25
|
+
}), m = s.useCallback(
|
|
26
|
+
(e, n) => {
|
|
27
|
+
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), l == null || l(n));
|
|
27
28
|
},
|
|
28
29
|
[l]
|
|
29
|
-
),
|
|
30
|
-
() =>
|
|
31
|
-
(e) =>
|
|
32
|
-
|
|
30
|
+
), c = s.useCallback(
|
|
31
|
+
() => t.map(
|
|
32
|
+
(e) => a ? /* @__PURE__ */ s.createElement(
|
|
33
|
+
a,
|
|
33
34
|
{
|
|
34
35
|
key: e.id,
|
|
35
36
|
suggestion: e,
|
|
@@ -37,7 +38,7 @@ const w = (b) => {
|
|
|
37
38
|
l == null || l(e);
|
|
38
39
|
}
|
|
39
40
|
}
|
|
40
|
-
) : /* @__PURE__ */
|
|
41
|
+
) : /* @__PURE__ */ s.createElement(
|
|
41
42
|
"span",
|
|
42
43
|
{
|
|
43
44
|
role: "button",
|
|
@@ -45,47 +46,47 @@ const w = (b) => {
|
|
|
45
46
|
"aria-label": e.description,
|
|
46
47
|
"aria-disabled": e.disabled,
|
|
47
48
|
onClick: () => !e.disabled && (l == null ? void 0 : l(e)),
|
|
48
|
-
onKeyDown: (
|
|
49
|
+
onKeyDown: (n) => !e.disabled && m(n, e),
|
|
49
50
|
key: e.id,
|
|
50
51
|
title: e.description,
|
|
51
|
-
className:
|
|
52
|
+
className: u(o === "classic" ? "k-prompt-suggestion" : "k-suggestion", {
|
|
52
53
|
"k-disabled": e.disabled
|
|
53
54
|
})
|
|
54
55
|
},
|
|
55
56
|
e.text
|
|
56
57
|
)
|
|
57
58
|
),
|
|
58
|
-
[
|
|
59
|
+
[t, a, l, o, m]
|
|
59
60
|
);
|
|
60
|
-
if (!
|
|
61
|
+
if (!t || t.length === 0)
|
|
61
62
|
return null;
|
|
62
63
|
if (o === "classic")
|
|
63
|
-
return
|
|
64
|
-
const h = /* @__PURE__ */
|
|
64
|
+
return c();
|
|
65
|
+
const h = r === "scroll" || r === "scrollbuttons", E = /* @__PURE__ */ s.createElement(
|
|
65
66
|
"div",
|
|
66
67
|
{
|
|
67
68
|
role: "group",
|
|
68
|
-
className:
|
|
69
|
-
|
|
70
|
-
"k-suggestion-group-scrollable":
|
|
71
|
-
|
|
72
|
-
|
|
69
|
+
className: u("k-suggestion-group", {
|
|
70
|
+
"k-suggestion-group-scrollable": r === "scroll",
|
|
71
|
+
"k-suggestion-group-scrollable-start": b && (r === "scroll" || r === "scrollbuttons"),
|
|
72
|
+
"k-suggestion-group-scrollable-end": p && (r === "scroll" || r === "scrollbuttons")
|
|
73
|
+
})
|
|
73
74
|
},
|
|
74
|
-
|
|
75
|
+
h ? /* @__PURE__ */ s.createElement("div", { className: "k-suggestions-scroll", ref: d }, c()) : c()
|
|
75
76
|
);
|
|
76
|
-
return /* @__PURE__ */
|
|
77
|
+
return /* @__PURE__ */ s.createElement(
|
|
77
78
|
R,
|
|
78
79
|
{
|
|
79
|
-
visible:
|
|
80
|
-
dir:
|
|
81
|
-
canScrollLeft:
|
|
82
|
-
canScrollRight:
|
|
80
|
+
visible: r === "scrollbuttons",
|
|
81
|
+
dir: i,
|
|
82
|
+
canScrollLeft: p,
|
|
83
|
+
canScrollRight: b,
|
|
83
84
|
onScrollLeft: k,
|
|
84
85
|
onScrollRight: y
|
|
85
86
|
},
|
|
86
|
-
|
|
87
|
+
E
|
|
87
88
|
);
|
|
88
89
|
};
|
|
89
90
|
export {
|
|
90
|
-
|
|
91
|
+
N as SuggestionGroup
|
|
91
92
|
};
|
|
@@ -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
|
|
8
|
+
"use strict";const z=require("react"),m=require("@progress/kendo-react-common"),h=require("@progress/kendo-react-buttons"),E=require("@progress/kendo-svg-icons"),B=require("@progress/kendo-react-intl"),l=require("../../../messages/index.js"),C=require("../ChatContext.js");function b(o){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const a in o)if(a!=="default"){const c=Object.getOwnPropertyDescriptor(o,a);Object.defineProperty(s,a,c.get?c:{enumerable:!0,get:()=>o[a]})}}return s.default=o,Object.freeze(s)}const n=b(z),w=o=>{const{files:s,onFileAction:a,onDownload:c,fileActions:x}=o,{messageFilesLayout:u="vertical"}=C.useChatContext(),g=B.useLocalization(),I=[{id:"download",label:"Download",svgIcon:E.downloadLightIcon}],p=x||I,d=e=>{if(e==null)return"";if(e===0)return"0 B";const t=1024,i=["B","KB","MB","GB","TB"],r=Math.floor(Math.log(e)/Math.log(t));return`${parseFloat((e/Math.pow(t,r)).toFixed(2))} ${i[r]}`},f=e=>"."+e.split(".").pop()||"",v=(e,t)=>{var i,r;(r=(i=e.syntheticEvent)==null?void 0:i.stopPropagation)==null||r.call(i),e.item.id==="download"&&(c==null||c([t])),a==null||a(e.item,e,t)},k=e=>p.length>0&&n.createElement(h.DropDownButton,{fillMode:"flat",svgIcon:E.moreVerticalIcon,onClick:t=>{t.syntheticEvent.stopPropagation()},onItemClick:t=>v(t,e),items:p.map(t=>({id:t.id,icon:t.icon,text:t.label,svgIcon:t.svgIcon})),"aria-label":`${g.toLanguageString(l.fileActions,l.messages[l.fileActions])} ${e.name}`,title:`${g.toLanguageString(l.fileActions,l.messages[l.fileActions])} ${e.name}`}),N=n.useCallback(()=>m.classNames({"k-files-wrap":u==="wrap","k-files-vertical":u==="vertical"},"k-file-box-wrapper"),[u]);return n.createElement("ul",{className:N()},u==="horizontal"?n.createElement("div",{className:"k-files-scroll"},s.map(e=>n.createElement("li",{key:e.name,className:"k-file-box"},n.createElement(m.IconWrap,{size:"xlarge",...m.getFileExtensionIcon(f(e.name))}),n.createElement("div",{className:"k-file-info"},n.createElement("span",{className:"k-file-name"},e.name),n.createElement("span",{className:"k-file-size"},d(e.size))),k(e)))):s.map(e=>n.createElement("li",{key:e.name,className:"k-file-box"},n.createElement(m.IconWrap,{size:"xlarge",...m.getFileExtensionIcon(f(e.name))}),n.createElement("div",{className:"k-file-info"},n.createElement("span",{className:"k-file-name"},e.name),n.createElement("span",{className:"k-file-size"},d(e.size))),k(e))))};module.exports=w;
|
|
@@ -5,62 +5,54 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
import * as
|
|
9
|
-
import { classNames as
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { useLocalization as
|
|
13
|
-
import {
|
|
14
|
-
import { useChatContext as
|
|
15
|
-
const
|
|
16
|
-
const { files:
|
|
8
|
+
import * as a from "react";
|
|
9
|
+
import { classNames as h, IconWrap as u, getFileExtensionIcon as k } from "@progress/kendo-react-common";
|
|
10
|
+
import { DropDownButton as I } from "@progress/kendo-react-buttons";
|
|
11
|
+
import { downloadLightIcon as B, moreVerticalIcon as w } from "@progress/kendo-svg-icons";
|
|
12
|
+
import { useLocalization as F } from "@progress/kendo-react-intl";
|
|
13
|
+
import { fileActions as l, messages as E } from "../../../messages/index.mjs";
|
|
14
|
+
import { useChatContext as C } from "../ChatContext.mjs";
|
|
15
|
+
const P = (x) => {
|
|
16
|
+
const { files: c, onFileAction: i, onDownload: r, fileActions: N } = x, { messageFilesLayout: s = "vertical" } = C(), m = F(), p = N || [{ id: "download", label: "Download", svgIcon: B }], f = (e) => {
|
|
17
17
|
if (e == null)
|
|
18
18
|
return "";
|
|
19
19
|
if (e === 0)
|
|
20
20
|
return "0 B";
|
|
21
|
-
const t = 1024,
|
|
22
|
-
return `${parseFloat((e / Math.pow(t, n)).toFixed(2))} ${
|
|
23
|
-
},
|
|
24
|
-
var
|
|
25
|
-
(n = (
|
|
26
|
-
},
|
|
27
|
-
|
|
21
|
+
const t = 1024, o = ["B", "KB", "MB", "GB", "TB"], n = Math.floor(Math.log(e) / Math.log(t));
|
|
22
|
+
return `${parseFloat((e / Math.pow(t, n)).toFixed(2))} ${o[n]}`;
|
|
23
|
+
}, g = (e) => "." + e.split(".").pop() || "", v = (e, t) => {
|
|
24
|
+
var o, n;
|
|
25
|
+
(n = (o = e.syntheticEvent) == null ? void 0 : o.stopPropagation) == null || n.call(o), e.item.id === "download" && (r == null || r([t])), i == null || i(e.item, e, t);
|
|
26
|
+
}, d = (e) => p.length > 0 && /* @__PURE__ */ a.createElement(
|
|
27
|
+
I,
|
|
28
28
|
{
|
|
29
29
|
fillMode: "flat",
|
|
30
|
-
|
|
31
|
-
svgIcon: N,
|
|
32
|
-
onClick: (t) => {
|
|
33
|
-
t.stopPropagation(), s == null || s(e.name);
|
|
34
|
-
},
|
|
35
|
-
"aria-label": `${c.toLanguageString(p, f[p])} ${e.name}`
|
|
36
|
-
}
|
|
37
|
-
) : m.length > 0 && /* @__PURE__ */ o.createElement(
|
|
38
|
-
M,
|
|
39
|
-
{
|
|
40
|
-
fillMode: "flat",
|
|
41
|
-
themeColor: "base",
|
|
42
|
-
svgIcon: A,
|
|
30
|
+
svgIcon: w,
|
|
43
31
|
onClick: (t) => {
|
|
44
32
|
t.syntheticEvent.stopPropagation();
|
|
45
33
|
},
|
|
46
|
-
onItemClick: (t) =>
|
|
47
|
-
items:
|
|
34
|
+
onItemClick: (t) => v(t, e),
|
|
35
|
+
items: p.map((t) => ({
|
|
48
36
|
id: t.id,
|
|
49
37
|
icon: t.icon,
|
|
50
38
|
text: t.label,
|
|
51
39
|
svgIcon: t.svgIcon
|
|
52
40
|
})),
|
|
53
|
-
"aria-label": `${
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
)} ${e.name}
|
|
41
|
+
"aria-label": `${m.toLanguageString(
|
|
42
|
+
l,
|
|
43
|
+
E[l]
|
|
44
|
+
)} ${e.name}`,
|
|
45
|
+
title: `${m.toLanguageString(l, E[l])} ${e.name}`
|
|
57
46
|
}
|
|
58
|
-
),
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
47
|
+
), z = a.useCallback(() => h(
|
|
48
|
+
{
|
|
49
|
+
"k-files-wrap": s === "wrap",
|
|
50
|
+
"k-files-vertical": s === "vertical"
|
|
51
|
+
},
|
|
52
|
+
"k-file-box-wrapper"
|
|
53
|
+
), [s]);
|
|
54
|
+
return /* @__PURE__ */ a.createElement("ul", { className: z() }, s === "horizontal" ? /* @__PURE__ */ a.createElement("div", { className: "k-files-scroll" }, c.map((e) => /* @__PURE__ */ a.createElement("li", { key: e.name, className: "k-file-box" }, /* @__PURE__ */ a.createElement(u, { size: "xlarge", ...k(g(e.name)) }), /* @__PURE__ */ a.createElement("div", { className: "k-file-info" }, /* @__PURE__ */ a.createElement("span", { className: "k-file-name" }, e.name), /* @__PURE__ */ a.createElement("span", { className: "k-file-size" }, f(e.size))), d(e)))) : c.map((e) => /* @__PURE__ */ a.createElement("li", { key: e.name, className: "k-file-box" }, /* @__PURE__ */ a.createElement(u, { size: "xlarge", ...k(g(e.name)) }), /* @__PURE__ */ a.createElement("div", { className: "k-file-info" }, /* @__PURE__ */ a.createElement("span", { className: "k-file-name" }, e.name), /* @__PURE__ */ a.createElement("span", { className: "k-file-size" }, f(e.size))), d(e))));
|
|
63
55
|
};
|
|
64
56
|
export {
|
|
65
|
-
|
|
57
|
+
P as default
|
|
66
58
|
};
|
|
@@ -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
|
|
8
|
+
"use strict";const k=require("react"),C=require("@progress/kendo-react-common"),M=require("@progress/kendo-react-buttons"),u=require("@progress/kendo-svg-icons"),h=require("@progress/kendo-react-intl"),a=require("../../utils.js"),v=require("../ChatContext.js");function b(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const c=b(k),q=n=>{const{message:e,onUnpin:t,user:s}=n,d=h.useLocalization(),{internalScrollContainerRef:r}=v.useChatContext(),i=c.useRef(null),f=s&&a.isAuthor(s,e),g=c.useCallback(o=>{var l;o.preventDefault(),o.stopPropagation();const p=r==null?void 0:r.current,m=((l=i.current)==null?void 0:l.offsetHeight)||0;a.scrollToMessageById(e.id,p,m)},[e.id,r]);return c.createElement("div",{ref:i,className:`k-message-reference ${f?"k-message-reference-sender":"k-message-reference-receiver"} k-message-pinned`,onClick:g},c.createElement(C.IconWrap,{icon:u.pinOutlineIcon}),c.createElement("div",{className:"k-message-reference-content"},e!=null&&e.isDeleted?s&&a.getDeletedMessageText(a.isAuthor(s,e),d):e==null?void 0:e.text),c.createElement("span",{className:"k-spacer"}),c.createElement(M.Button,{fillMode:"flat",svgIcon:u.xMarkSmOutlineIcon,onClick:o=>{o.stopPropagation(),t==null||t(e)}}))};module.exports=q;
|
|
@@ -6,42 +6,44 @@
|
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
8
|
import * as t from "react";
|
|
9
|
-
import { IconWrap as
|
|
10
|
-
import { Button as
|
|
11
|
-
import {
|
|
12
|
-
import { useLocalization as
|
|
13
|
-
import {
|
|
14
|
-
import { useChatContext as
|
|
15
|
-
const
|
|
16
|
-
const { message: e, onUnpin:
|
|
17
|
-
(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
u(
|
|
9
|
+
import { IconWrap as g } from "@progress/kendo-react-common";
|
|
10
|
+
import { Button as k } from "@progress/kendo-react-buttons";
|
|
11
|
+
import { pinOutlineIcon as M, xMarkSmOutlineIcon as h } from "@progress/kendo-svg-icons";
|
|
12
|
+
import { useLocalization as v } from "@progress/kendo-react-intl";
|
|
13
|
+
import { isAuthor as i, scrollToMessageById as C, getDeletedMessageText as x } from "../../utils.mjs";
|
|
14
|
+
import { useChatContext as E } from "../ChatContext.mjs";
|
|
15
|
+
const H = (l) => {
|
|
16
|
+
const { message: e, onUnpin: r, user: n } = l, m = v(), { internalScrollContainerRef: s } = E(), a = t.useRef(null), f = n && i(n, e), p = t.useCallback(
|
|
17
|
+
(o) => {
|
|
18
|
+
var c;
|
|
19
|
+
o.preventDefault(), o.stopPropagation();
|
|
20
|
+
const d = s == null ? void 0 : s.current, u = ((c = a.current) == null ? void 0 : c.offsetHeight) || 0;
|
|
21
|
+
C(e.id, d, u);
|
|
21
22
|
},
|
|
22
|
-
[e.id,
|
|
23
|
+
[e.id, s]
|
|
23
24
|
);
|
|
24
25
|
return /* @__PURE__ */ t.createElement(
|
|
25
26
|
"div",
|
|
26
27
|
{
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
ref: a,
|
|
29
|
+
className: `k-message-reference ${f ? "k-message-reference-sender" : "k-message-reference-receiver"} k-message-pinned`,
|
|
30
|
+
onClick: p
|
|
29
31
|
},
|
|
30
|
-
/* @__PURE__ */ t.createElement(
|
|
31
|
-
/* @__PURE__ */ t.createElement("div", { className: "k-message-reference-content" }, e != null && e.isDeleted ?
|
|
32
|
+
/* @__PURE__ */ t.createElement(g, { icon: M }),
|
|
33
|
+
/* @__PURE__ */ t.createElement("div", { className: "k-message-reference-content" }, e != null && e.isDeleted ? n && x(i(n, e), m) : e == null ? void 0 : e.text),
|
|
32
34
|
/* @__PURE__ */ t.createElement("span", { className: "k-spacer" }),
|
|
33
35
|
/* @__PURE__ */ t.createElement(
|
|
34
|
-
|
|
36
|
+
k,
|
|
35
37
|
{
|
|
36
38
|
fillMode: "flat",
|
|
37
|
-
svgIcon:
|
|
38
|
-
onClick: (
|
|
39
|
-
|
|
39
|
+
svgIcon: h,
|
|
40
|
+
onClick: (o) => {
|
|
41
|
+
o.stopPropagation(), r == null || r(e);
|
|
40
42
|
}
|
|
41
43
|
}
|
|
42
44
|
)
|
|
43
45
|
);
|
|
44
46
|
};
|
|
45
47
|
export {
|
|
46
|
-
|
|
48
|
+
H as default
|
|
47
49
|
};
|
|
@@ -18,6 +18,10 @@ export interface UseScrollWithButtonsOptions {
|
|
|
18
18
|
* Direction for RTL support
|
|
19
19
|
*/
|
|
20
20
|
dir?: string;
|
|
21
|
+
/**
|
|
22
|
+
* The scroll mode (used to detect mode changes)
|
|
23
|
+
*/
|
|
24
|
+
mode?: string;
|
|
21
25
|
/**
|
|
22
26
|
* Dependencies array that triggers scroll button updates when items change
|
|
23
27
|
*/
|
|
@@ -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 O=require("react");function y(e){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(o,t,r.get?r:{enumerable:!0,get:()=>e[t]})}}return o.default=e,Object.freeze(o)}const s=y(O),E=100,f=1,C=(e,o)=>{const{enabled:t,dir:r,mode:d,itemsDependency:i=[],scrollSpeed:c=E}=o,[S,b]=s.useState(!1),[h,L]=s.useState(!1),n=s.useCallback(()=>{if(e.current&&t){const{scrollLeft:l,scrollWidth:u,clientWidth:a}=e.current,m=l===0,p=r!=="rtl"?l+a>=u-f:a-l>=u-f;b(!m),L(!p)}},[t,r]),v=s.useCallback(()=>{e.current&&t&&e.current.scrollBy({left:r!=="rtl"?-c:c,behavior:"smooth"})},[t,r,c]),g=s.useCallback(()=>{e.current&&t&&e.current.scrollBy({left:r!=="rtl"?c:-c,behavior:"smooth"})},[t,r,c]);return s.useEffect(()=>{const l=e.current;if(!l||!t)return;n();const u=()=>n();l.addEventListener("scroll",u,{passive:!0});const a=new ResizeObserver(n);return a.observe(l),()=>{l.removeEventListener("scroll",u),a.disconnect()}},[t,n,i.length,d]),s.useLayoutEffect(()=>{t&&n()},[t,r,i]),{canScrollLeft:S,canScrollRight:h,scrollLeft:v,scrollRight:g}};exports.useScrollWithButtons=C;
|
|
@@ -6,41 +6,43 @@
|
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
8
|
import * as r from "react";
|
|
9
|
-
const
|
|
10
|
-
const { enabled: t, dir:
|
|
9
|
+
const p = 100, a = 1, y = (l, S) => {
|
|
10
|
+
const { enabled: t, dir: s, mode: d, itemsDependency: i = [], scrollSpeed: c = p } = S, [f, L] = r.useState(!1), [h, b] = r.useState(!1), o = r.useCallback(() => {
|
|
11
11
|
if (l.current && t) {
|
|
12
|
-
const { scrollLeft:
|
|
13
|
-
L(!
|
|
12
|
+
const { scrollLeft: e, scrollWidth: n, clientWidth: u } = l.current, m = e === 0, C = s !== "rtl" ? e + u >= n - a : u - e >= n - a;
|
|
13
|
+
L(!m), b(!C);
|
|
14
14
|
}
|
|
15
|
-
}, [t,
|
|
15
|
+
}, [t, s]), v = r.useCallback(() => {
|
|
16
16
|
l.current && t && l.current.scrollBy({
|
|
17
|
-
left:
|
|
17
|
+
left: s !== "rtl" ? -c : c,
|
|
18
18
|
behavior: "smooth"
|
|
19
19
|
});
|
|
20
|
-
}, [t,
|
|
20
|
+
}, [t, s, c]), E = r.useCallback(() => {
|
|
21
21
|
l.current && t && l.current.scrollBy({
|
|
22
|
-
left:
|
|
22
|
+
left: s !== "rtl" ? c : -c,
|
|
23
23
|
behavior: "smooth"
|
|
24
24
|
});
|
|
25
|
-
}, [t,
|
|
25
|
+
}, [t, s, c]);
|
|
26
26
|
return r.useEffect(() => {
|
|
27
|
-
const
|
|
28
|
-
if (
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
27
|
+
const e = l.current;
|
|
28
|
+
if (!e || !t)
|
|
29
|
+
return;
|
|
30
|
+
o();
|
|
31
|
+
const n = () => o();
|
|
32
|
+
e.addEventListener("scroll", n, { passive: !0 });
|
|
33
|
+
const u = new ResizeObserver(o);
|
|
34
|
+
return u.observe(e), () => {
|
|
35
|
+
e.removeEventListener("scroll", n), u.disconnect();
|
|
36
|
+
};
|
|
37
|
+
}, [t, o, i.length, d]), r.useLayoutEffect(() => {
|
|
36
38
|
t && o();
|
|
37
|
-
}, [t,
|
|
39
|
+
}, [t, s, i]), {
|
|
38
40
|
canScrollLeft: f,
|
|
39
|
-
canScrollRight:
|
|
40
|
-
scrollLeft:
|
|
41
|
-
scrollRight:
|
|
41
|
+
canScrollRight: h,
|
|
42
|
+
scrollLeft: v,
|
|
43
|
+
scrollRight: E
|
|
42
44
|
};
|
|
43
45
|
};
|
|
44
46
|
export {
|
|
45
|
-
|
|
47
|
+
y as useScrollWithButtons
|
|
46
48
|
};
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
import { Message } from '../../
|
|
8
|
+
import { Message } from '../../api/message.interface.js';
|
|
9
9
|
import { FieldMappingConfig } from '../ChatPropsAndState.js';
|
|
10
10
|
/**
|
|
11
11
|
* Default field mapping configuration.
|
|
@@ -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 n={textField:"text",statusField:"status",authorIdField:"authorId",authorNameField:"authorName",authorImageUrlField:"authorImageUrl",authorImageAltTextField:"authorImageAltText",idField:"id",timestampField:"timestamp",filesField:"files",attachmentsField:"attachments",replyToIdField:"replyToId",isDeletedField:"isDeleted",isPinnedField:"isPinned",typingField:"typing",suggestedActionsField:"suggestedActions"},r=(i,d={})=>{const
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n={textField:"text",statusField:"status",authorIdField:"authorId",authorNameField:"authorName",authorImageUrlField:"authorImageUrl",authorImageAltTextField:"authorImageAltText",idField:"id",timestampField:"timestamp",filesField:"files",attachmentsField:"attachments",replyToIdField:"replyToId",isDeletedField:"isDeleted",isPinnedField:"isPinned",typingField:"typing",suggestedActionsField:"suggestedActions",isFailedField:"isFailed"},r=(i,d={})=>{const e={...n,...d};let t;i.author&&typeof i.author=="object"?t={id:i.author.id||i.author[e.authorIdField]||i[e.authorIdField]||"",name:i.author.name||i.author[e.authorNameField]||i[e.authorNameField],avatarUrl:i.author.avatarUrl||i.author[e.authorImageUrlField]||i[e.authorImageUrlField],avatarAltText:i.author.avatarAltText||i.author[e.authorImageAltTextField]||i[e.authorImageAltTextField]}:t={id:i[e.authorIdField]||i.authorId||"",name:i[e.authorNameField]||i.authorName,avatarUrl:i[e.authorImageUrlField]||i.authorImageUrl,avatarAltText:i[e.authorImageAltTextField]||i.authorImageAltText};let o;i.timestamp?o=new Date(i.timestamp):i[e.timestampField]?o=new Date(i[e.timestampField]):o=new Date;const l={id:i.id!==void 0?i.id:i[e.idField],text:i.text!==void 0?i.text:i[e.textField]||"",author:t,timestamp:o,status:i.status!==void 0?i.status:i[e.statusField],attachments:i.attachments!==void 0?i.attachments:i[e.attachmentsField],attachmentLayout:i.attachmentLayout||"list",suggestedActions:i.suggestedActions!==void 0?i.suggestedActions:i[e.suggestedActionsField],isPinned:i.isPinned!==void 0?i.isPinned:i[e.isPinnedField]||!1,typing:i.typing!==void 0?i.typing:i[e.typingField],files:i.files!==void 0?i.files:i[e.filesField]||[],isFailed:i.isFailed!==void 0?i.isFailed:i[e.isFailedField]||!1};return i.pinnedAt&&(l.pinnedAt=new Date(i.pinnedAt)),i.pinnedBy&&(l.pinnedBy=i.pinnedBy),i.replyToId!==void 0?l.replyToId=i.replyToId:i[e.replyToIdField]!==void 0&&(l.replyToId=i[e.replyToIdField]),i.isDeleted!==void 0?l.isDeleted=i.isDeleted:i[e.isDeletedField]!==void 0&&(l.isDeleted=i[e.isDeletedField]),{...l,dataItem:i}},F=(i,d={})=>Array.isArray(i)?i.map(e=>r(e,d)):[],u=i=>i&&typeof i.id!="undefined"&&typeof i.text=="string"&&i.author&&typeof i.author=="object"&&typeof i.author.id!="undefined"&&(i.timestamp instanceof Date||typeof i.timestamp=="string"||typeof i.timestamp=="number"),h=i=>({textField:i.textField,statusField:i.statusField,authorIdField:i.authorIdField,authorNameField:i.authorNameField,authorImageUrlField:i.authorImageUrlField,authorImageAltTextField:i.authorImageAltTextField,idField:i.idField,timestampField:i.timestampField,filesField:i.filesField,attachmentsField:i.attachmentsField,replyToIdField:i.replyToIdField,isDeletedField:i.isDeletedField,isPinnedField:i.isPinnedField,typingField:i.typingField,suggestedActionsField:i.suggestedActionsField,isFailedField:i.isFailedField}),a=(i,d={})=>{const e={...n,...d},t={};return i.id!==void 0&&(t[e.idField]=i.id),i.text!==void 0&&(t[e.textField]=i.text),i.status!==void 0&&(t[e.statusField]=i.status),i.isFailed!==void 0&&(t[e.isFailedField]=i.isFailed),i.timestamp!==void 0&&(t[e.timestampField]=i.timestamp),i.attachments!==void 0&&(t[e.attachmentsField]=i.attachments),i.files!==void 0&&(t[e.filesField]=i.files),i.suggestedActions!==void 0&&(t[e.suggestedActionsField]=i.suggestedActions),i.replyToId!==void 0&&(t[e.replyToIdField]=i.replyToId),i.isDeleted!==void 0&&(t[e.isDeletedField]=i.isDeleted),i.isPinned!==void 0&&(t[e.isPinnedField]=i.isPinned),i.typing!==void 0&&(t[e.typingField]=i.typing),i.author&&(i.author.id!==void 0&&(t[e.authorIdField]=i.author.id),i.author.name!==void 0&&(t[e.authorNameField]=i.author.name),i.author.avatarUrl!==void 0&&(t[e.authorImageUrlField]=i.author.avatarUrl),i.author.avatarAltText!==void 0&&(t[e.authorImageAltTextField]=i.author.avatarAltText)),i.pinnedAt!==void 0&&(t.pinnedAt=i.pinnedAt),i.pinnedBy!==void 0&&(t.pinnedBy=i.pinnedBy),i.attachmentLayout!==void 0&&(t.attachmentLayout=i.attachmentLayout),t};exports.DEFAULT_FIELD_MAPPING=n;exports.extractFieldMappingFromProps=h;exports.isStandardMessageFormat=u;exports.mapDataArrayToMessages=F;exports.mapDataToMessage=r;exports.mapMessageToCustomFormat=a;
|
|
@@ -20,38 +20,40 @@ const n = {
|
|
|
20
20
|
isDeletedField: "isDeleted",
|
|
21
21
|
isPinnedField: "isPinned",
|
|
22
22
|
typingField: "typing",
|
|
23
|
-
suggestedActionsField: "suggestedActions"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
23
|
+
suggestedActionsField: "suggestedActions",
|
|
24
|
+
isFailedField: "isFailed"
|
|
25
|
+
}, F = (i, d = {}) => {
|
|
26
|
+
const e = { ...n, ...d };
|
|
27
|
+
let t;
|
|
28
|
+
i.author && typeof i.author == "object" ? t = {
|
|
29
|
+
id: i.author.id || i.author[e.authorIdField] || i[e.authorIdField] || "",
|
|
30
|
+
name: i.author.name || i.author[e.authorNameField] || i[e.authorNameField],
|
|
31
|
+
avatarUrl: i.author.avatarUrl || i.author[e.authorImageUrlField] || i[e.authorImageUrlField],
|
|
32
|
+
avatarAltText: i.author.avatarAltText || i.author[e.authorImageAltTextField] || i[e.authorImageAltTextField]
|
|
33
|
+
} : t = {
|
|
34
|
+
id: i[e.authorIdField] || i.authorId || "",
|
|
35
|
+
name: i[e.authorNameField] || i.authorName,
|
|
36
|
+
avatarUrl: i[e.authorImageUrlField] || i.authorImageUrl,
|
|
37
|
+
avatarAltText: i[e.authorImageAltTextField] || i.authorImageAltText
|
|
37
38
|
};
|
|
38
39
|
let o;
|
|
39
|
-
i.timestamp ? o = new Date(i.timestamp) : i[
|
|
40
|
+
i.timestamp ? o = new Date(i.timestamp) : i[e.timestampField] ? o = new Date(i[e.timestampField]) : o = /* @__PURE__ */ new Date();
|
|
40
41
|
const l = {
|
|
41
|
-
id: i.id !== void 0 ? i.id : i[
|
|
42
|
-
text: i.text !== void 0 ? i.text : i[
|
|
43
|
-
author:
|
|
42
|
+
id: i.id !== void 0 ? i.id : i[e.idField],
|
|
43
|
+
text: i.text !== void 0 ? i.text : i[e.textField] || "",
|
|
44
|
+
author: t,
|
|
44
45
|
timestamp: o,
|
|
45
|
-
status: i.status !== void 0 ? i.status : i[
|
|
46
|
-
attachments: i.attachments !== void 0 ? i.attachments : i[
|
|
46
|
+
status: i.status !== void 0 ? i.status : i[e.statusField],
|
|
47
|
+
attachments: i.attachments !== void 0 ? i.attachments : i[e.attachmentsField],
|
|
47
48
|
attachmentLayout: i.attachmentLayout || "list",
|
|
48
|
-
suggestedActions: i.suggestedActions !== void 0 ? i.suggestedActions : i[
|
|
49
|
-
isPinned: i.isPinned !== void 0 ? i.isPinned : i[
|
|
50
|
-
typing: i.typing !== void 0 ? i.typing : i[
|
|
51
|
-
files: i.files !== void 0 ? i.files : i[
|
|
49
|
+
suggestedActions: i.suggestedActions !== void 0 ? i.suggestedActions : i[e.suggestedActionsField],
|
|
50
|
+
isPinned: i.isPinned !== void 0 ? i.isPinned : i[e.isPinnedField] || !1,
|
|
51
|
+
typing: i.typing !== void 0 ? i.typing : i[e.typingField],
|
|
52
|
+
files: i.files !== void 0 ? i.files : i[e.filesField] || [],
|
|
53
|
+
isFailed: i.isFailed !== void 0 ? i.isFailed : i[e.isFailedField] || !1
|
|
52
54
|
};
|
|
53
|
-
return i.pinnedAt && (l.pinnedAt = new Date(i.pinnedAt)), i.pinnedBy && (l.pinnedBy = i.pinnedBy), i.replyToId !== void 0 ? l.replyToId = i.replyToId : i[
|
|
54
|
-
},
|
|
55
|
+
return i.pinnedAt && (l.pinnedAt = new Date(i.pinnedAt)), i.pinnedBy && (l.pinnedBy = i.pinnedBy), i.replyToId !== void 0 ? l.replyToId = i.replyToId : i[e.replyToIdField] !== void 0 && (l.replyToId = i[e.replyToIdField]), i.isDeleted !== void 0 ? l.isDeleted = i.isDeleted : i[e.isDeletedField] !== void 0 && (l.isDeleted = i[e.isDeletedField]), { ...l, dataItem: i };
|
|
56
|
+
}, r = (i, d = {}) => Array.isArray(i) ? i.map((e) => F(e, d)) : [], u = (i) => i && typeof i.id != "undefined" && typeof i.text == "string" && i.author && typeof i.author == "object" && typeof i.author.id != "undefined" && (i.timestamp instanceof Date || typeof i.timestamp == "string" || typeof i.timestamp == "number"), h = (i) => ({
|
|
55
57
|
textField: i.textField,
|
|
56
58
|
statusField: i.statusField,
|
|
57
59
|
authorIdField: i.authorIdField,
|
|
@@ -66,16 +68,17 @@ const n = {
|
|
|
66
68
|
isDeletedField: i.isDeletedField,
|
|
67
69
|
isPinnedField: i.isPinnedField,
|
|
68
70
|
typingField: i.typingField,
|
|
69
|
-
suggestedActionsField: i.suggestedActionsField
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
suggestedActionsField: i.suggestedActionsField,
|
|
72
|
+
isFailedField: i.isFailedField
|
|
73
|
+
}), s = (i, d = {}) => {
|
|
74
|
+
const e = { ...n, ...d }, t = {};
|
|
75
|
+
return i.id !== void 0 && (t[e.idField] = i.id), i.text !== void 0 && (t[e.textField] = i.text), i.status !== void 0 && (t[e.statusField] = i.status), i.isFailed !== void 0 && (t[e.isFailedField] = i.isFailed), i.timestamp !== void 0 && (t[e.timestampField] = i.timestamp), i.attachments !== void 0 && (t[e.attachmentsField] = i.attachments), i.files !== void 0 && (t[e.filesField] = i.files), i.suggestedActions !== void 0 && (t[e.suggestedActionsField] = i.suggestedActions), i.replyToId !== void 0 && (t[e.replyToIdField] = i.replyToId), i.isDeleted !== void 0 && (t[e.isDeletedField] = i.isDeleted), i.isPinned !== void 0 && (t[e.isPinnedField] = i.isPinned), i.typing !== void 0 && (t[e.typingField] = i.typing), i.author && (i.author.id !== void 0 && (t[e.authorIdField] = i.author.id), i.author.name !== void 0 && (t[e.authorNameField] = i.author.name), i.author.avatarUrl !== void 0 && (t[e.authorImageUrlField] = i.author.avatarUrl), i.author.avatarAltText !== void 0 && (t[e.authorImageAltTextField] = i.author.avatarAltText)), i.pinnedAt !== void 0 && (t.pinnedAt = i.pinnedAt), i.pinnedBy !== void 0 && (t.pinnedBy = i.pinnedBy), i.attachmentLayout !== void 0 && (t.attachmentLayout = i.attachmentLayout), t;
|
|
73
76
|
};
|
|
74
77
|
export {
|
|
75
78
|
n as DEFAULT_FIELD_MAPPING,
|
|
76
79
|
h as extractFieldMappingFromProps,
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
80
|
+
u as isStandardMessageFormat,
|
|
81
|
+
r as mapDataArrayToMessages,
|
|
82
|
+
F as mapDataToMessage,
|
|
83
|
+
s as mapMessageToCustomFormat
|
|
81
84
|
};
|
package/chat/utils/scroll.d.ts
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
import { Message
|
|
8
|
+
import { Message } from '../../api/message.interface.js';
|
|
9
|
+
import { ChatSuggestion } from '../components/SuggestionsGroup.js';
|
|
9
10
|
import * as React from 'react';
|
|
10
11
|
interface UseChatScrollProps {
|
|
11
12
|
viewItemsWrapperRef: React.RefObject<HTMLDivElement | null>;
|
|
@@ -29,4 +30,17 @@ interface UseChatScrollProps {
|
|
|
29
30
|
* @hidden
|
|
30
31
|
*/
|
|
31
32
|
export declare const useChatScroll: ({ viewItemsWrapperRef, isKeyboardNavigationActiveRef, processedMessages, suggestions }: UseChatScrollProps) => void;
|
|
33
|
+
interface UseHasScrollbarProps {
|
|
34
|
+
elementRef: React.RefObject<HTMLElement | null>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* A custom hook that detects whether a scrollbar is present on an element.
|
|
38
|
+
* Uses ResizeObserver to monitor changes in element dimensions.
|
|
39
|
+
*
|
|
40
|
+
* @param elementRef - Reference to the DOM element to monitor for scrollbar presence
|
|
41
|
+
* @returns boolean indicating whether a vertical scrollbar is visible
|
|
42
|
+
*
|
|
43
|
+
* @hidden
|
|
44
|
+
*/
|
|
45
|
+
export declare const useHasScrollbar: ({ elementRef }: UseHasScrollbarProps) => boolean;
|
|
32
46
|
export {};
|