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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/api/message.interface.d.ts +87 -9
  2. package/chat/ChatPropsAndState.d.ts +108 -9
  3. package/chat/Events.d.ts +9 -0
  4. package/chat/components/ActionGroup.js +1 -1
  5. package/chat/components/ActionGroup.mjs +58 -48
  6. package/chat/components/Chat.d.ts +1 -1
  7. package/chat/components/Chat.js +1 -1
  8. package/chat/components/Chat.mjs +318 -269
  9. package/chat/components/ChatContext.d.ts +6 -3
  10. package/chat/components/ChatMessage.js +1 -1
  11. package/chat/components/ChatMessage.mjs +237 -177
  12. package/chat/components/Header.js +1 -1
  13. package/chat/components/Header.mjs +3 -3
  14. package/chat/components/NewMessage.d.ts +5 -3
  15. package/chat/components/NewMessage.js +1 -1
  16. package/chat/components/NewMessage.mjs +174 -226
  17. package/chat/components/ScrollButtonsWrapper.js +1 -1
  18. package/chat/components/ScrollButtonsWrapper.mjs +34 -40
  19. package/chat/components/SuggestionsGroup.js +1 -1
  20. package/chat/components/SuggestionsGroup.mjs +40 -39
  21. package/chat/components/elements/FileBox.js +1 -1
  22. package/chat/components/elements/FileBox.mjs +33 -41
  23. package/chat/components/elements/PinnedMessage.js +1 -1
  24. package/chat/components/elements/PinnedMessage.mjs +24 -22
  25. package/chat/hooks/useScrollWithButtons.d.ts +4 -0
  26. package/chat/hooks/useScrollWithButtons.js +1 -1
  27. package/chat/hooks/useScrollWithButtons.mjs +25 -23
  28. package/chat/utils/fieldMapping.d.ts +1 -1
  29. package/chat/utils/fieldMapping.js +1 -1
  30. package/chat/utils/fieldMapping.mjs +37 -34
  31. package/chat/utils/scroll.d.ts +15 -1
  32. package/chat/utils/scroll.js +3 -3
  33. package/chat/utils/scroll.mjs +92 -65
  34. package/chat/utils.d.ts +4 -1
  35. package/chat/utils.js +1 -1
  36. package/chat/utils.mjs +37 -37
  37. package/dist/cdn/js/kendo-react-conversational-ui.js +1 -1
  38. package/index.d.mts +6 -0
  39. package/index.d.ts +6 -0
  40. package/index.js +1 -1
  41. package/index.mjs +39 -31
  42. package/messages/index.d.ts +50 -0
  43. package/messages/index.js +1 -1
  44. package/messages/index.mjs +60 -40
  45. package/package-metadata.js +1 -1
  46. package/package-metadata.mjs +1 -1
  47. package/package.json +11 -11
  48. package/prompt-box/Events.d.ts +66 -0
  49. package/prompt-box/FileBox.d.ts +22 -0
  50. package/prompt-box/FileBox.js +8 -0
  51. package/prompt-box/FileBox.mjs +72 -0
  52. package/prompt-box/PromptBox.d.ts +35 -0
  53. package/prompt-box/PromptBox.js +8 -0
  54. package/prompt-box/PromptBox.mjs +424 -0
  55. package/prompt-box/PromptBoxActionButton.d.ts +32 -0
  56. package/prompt-box/PromptBoxActionButton.js +8 -0
  57. package/prompt-box/PromptBoxActionButton.mjs +14 -0
  58. package/prompt-box/PromptBoxSpeechToTextButton.d.ts +32 -0
  59. package/prompt-box/PromptBoxSpeechToTextButton.js +8 -0
  60. package/prompt-box/PromptBoxSpeechToTextButton.mjs +14 -0
  61. package/prompt-box/PromptBoxUploadButton.d.ts +108 -0
  62. package/prompt-box/PromptBoxUploadButton.js +8 -0
  63. package/prompt-box/PromptBoxUploadButton.mjs +54 -0
  64. package/prompt-box/interfaces/PromptBoxProps.d.ts +390 -0
@@ -5,8 +5,8 @@
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("react");function A(n){const f=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const l in n)if(l!=="default"){const d=Object.getOwnPropertyDescriptor(n,l);Object.defineProperty(f,l,d.get?d:{enumerable:!0,get:()=>n[l]})}}return f.default=n,Object.freeze(f)}const c=A(m),x=50,B=250,b=50,N=100,j=({viewItemsWrapperRef:n,isKeyboardNavigationActiveRef:f,processedMessages:l,suggestions:d})=>{const a=c.useCallback(()=>{n.current&&(n.current.scrollTop=n.current.scrollHeight-n.current.clientHeight)},[n]),i=c.useCallback(()=>{if(!n.current)return!0;const t=n.current,{scrollTop:e,scrollHeight:r,clientHeight:o}=t,s=x+25;return r-e-o<s},[n]),S=c.useCallback(t=>t===0?16:t<=2?32*t:Math.min(50*t,200),[]),y=c.useCallback((t,e)=>{const r=S(t);setTimeout(()=>{!i()&&n.current&&e(t+1)},r)},[S,i,n]),T=c.useCallback(()=>{const t=(e=0)=>{e>5||requestAnimationFrame(()=>{a(),y(e,t)})};t()},[a,y]),C=c.useCallback(()=>{a(),setTimeout(()=>{!i()&&n.current&&a()},50)},[a,i,n]),g=c.useCallback(()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{requestAnimationFrame(C)})})},[C]),O=c.useCallback(()=>{a(),setTimeout(()=>{!i()&&n.current&&T()},25)},[a,i,n,T]),u=c.useCallback((t=!1)=>{if(!n.current||f.current)return;i()&&(t?O():g())},[i,O,g,n,f]);c.useEffect(()=>{const t=window.setTimeout(()=>a(),B);return()=>{clearTimeout(t)}},[a]),c.useEffect(()=>{T()},[l.length,T]);const E=c.useRef(new Map);c.useEffect(()=>{const t=new Map;let e=!1;l.forEach(r=>{if(r.id!==void 0){const o=r.id,s=!!r.typing,h=E.current.get(o);t.set(o,s),h===!0&&s===!1&&(e=!0)}}),E.current=t,e&&T()},[l,T]),c.useEffect(()=>{const t=window.setTimeout(()=>{u()},b);return()=>{clearTimeout(t)}},[l,u]),c.useEffect(()=>{if(l.length>0){const t=l[l.length-1],e=(t==null?void 0:t.text)||"";(e.includes("```")||e.includes(`
8
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("react");function A(n){const d=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const o in n)if(o!=="default"){const i=Object.getOwnPropertyDescriptor(n,o);Object.defineProperty(d,o,i.get?i:{enumerable:!0,get:()=>n[o]})}}return d.default=n,Object.freeze(d)}const c=A(_),H=50,x=250,y=50,B=100,q=({viewItemsWrapperRef:n,isKeyboardNavigationActiveRef:d,processedMessages:o,suggestions:i})=>{const l=c.useCallback(()=>{n.current&&(n.current.scrollTop=n.current.scrollHeight-n.current.clientHeight)},[n]),u=c.useCallback(()=>{if(!n.current)return!0;const t=n.current,{scrollTop:e,scrollHeight:r,clientHeight:s}=t,f=H+25;return r-e-s<f},[n]),b=c.useCallback(t=>t===0?16:t<=2?32*t:Math.min(50*t,200),[]),T=c.useCallback((t,e)=>{const r=b(t);setTimeout(()=>{!u()&&n.current&&e(t+1)},r)},[b,u,n]),h=c.useCallback(()=>{const t=(e=0)=>{e>5||requestAnimationFrame(()=>{l(),T(e,t)})};t()},[l,T]),C=c.useCallback(()=>{l(),setTimeout(()=>{!u()&&n.current&&l()},50)},[l,u,n]),g=c.useCallback(()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{requestAnimationFrame(C)})})},[C]),O=c.useCallback(()=>{l(),setTimeout(()=>{!u()&&n.current&&h()},25)},[l,u,n,h]),a=c.useCallback((t=!1)=>{if(!n.current||d.current)return;u()&&(t?O():g())},[u,O,g,n,d]);c.useEffect(()=>{const t=window.setTimeout(()=>l(),x);return()=>{clearTimeout(t)}},[l]),c.useEffect(()=>{h()},[o.length,h]);const E=c.useRef(new Map);c.useEffect(()=>{const t=new Map;let e=!1;o.forEach(r=>{if(r.id!==void 0){const s=r.id,f=!!r.typing,S=E.current.get(s);t.set(s,f),S===!0&&f===!1&&(e=!0)}}),E.current=t,e&&h()},[o,h]),c.useEffect(()=>{const t=window.setTimeout(()=>{a()},y);return()=>{clearTimeout(t)}},[o,a]),c.useEffect(()=>{if(o.length>0){const t=o[o.length-1],e=(t==null?void 0:t.text)||"";(e.includes("```")||e.includes(`
9
9
 
10
- `)||e.includes("<pre>")||e.includes("<code>")||e.includes("<table>")||e.length>500)&&u(!0)}},[l,u]),c.useEffect(()=>{if(d&&d.length>0){const t=window.setTimeout(()=>{u()},N);return()=>{clearTimeout(t)}}},[d,u]),c.useEffect(()=>{if(!n.current)return()=>{};let t;const e=new ResizeObserver(()=>{t&&clearTimeout(t),t=window.setTimeout(()=>{u()},b)}),r=n.current.querySelector(".k-message-list-content");return r&&e.observe(r),()=>{e.disconnect()}},[u,n]);const L=c.useCallback(t=>{var r;if(t.type!=="characterData"&&t.type!=="childList")return!1;const e=(r=t.target.textContent)!=null?r:"";return e.includes("```")||e.includes(`
10
+ `)||e.includes("<pre>")||e.includes("<code>")||e.includes("<table>")||e.length>500)&&a(!0)}},[o,a]),c.useEffect(()=>{if(i&&i.length>0){const t=window.setTimeout(()=>{a()},B);return()=>{clearTimeout(t)}}},[i,a]),c.useEffect(()=>{if(!n.current)return()=>{};let t;const e=new ResizeObserver(()=>{t&&clearTimeout(t),t=window.setTimeout(()=>{a()},y)}),r=n.current.querySelector(".k-message-list-content");return r&&e.observe(r),()=>{e.disconnect()}},[a,n]);const L=c.useCallback(t=>{var r;if(t.type!=="characterData"&&t.type!=="childList")return!1;const e=(r=t.target.textContent)!=null?r:"";return e.includes("```")||e.includes(`
11
11
 
12
- `)||e.includes("<pre>")||e.includes("<code>")||e.includes("<table>")||t.addedNodes&&t.addedNodes.length>2},[]),k=c.useCallback(t=>{let e=!1,r=!1;return t.forEach(o=>{var s;(o.type==="childList"||o.type==="characterData"||o.type==="attributes"&&["class","style"].includes((s=o.attributeName)!=null?s:""))&&(e=!0,L(o)&&(r=!0))}),{shouldScroll:e,hasSignificantChange:r}},[L]),D=c.useCallback((t,e)=>{e.current&&clearTimeout(e.current),t?u(!0):e.current=window.setTimeout(()=>{u()},b)},[u]);c.useEffect(()=>{if(!n.current)return()=>{};const t={current:void 0};let e=0;const r=new MutationObserver(o=>{const s=Date.now();if(s-e<16)return;e=s;const{shouldScroll:h,hasSignificantChange:_}=k(o);h&&i()&&D(_,t)});return r.observe(n.current,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["class","style"]}),()=>{r.disconnect(),t.current&&clearTimeout(t.current)}},[i,k,D,n])};exports.useChatScroll=j;
12
+ `)||e.includes("<pre>")||e.includes("<code>")||e.includes("<table>")||t.addedNodes&&t.addedNodes.length>2},[]),k=c.useCallback(t=>{let e=!1,r=!1;return t.forEach(s=>{var f;(s.type==="childList"||s.type==="characterData"||s.type==="attributes"&&["class","style"].includes((f=s.attributeName)!=null?f:""))&&(e=!0,L(s)&&(r=!0))}),{shouldScroll:e,hasSignificantChange:r}},[L]),m=c.useCallback((t,e)=>{e.current&&clearTimeout(e.current),t?a(!0):e.current=window.setTimeout(()=>{a()},y)},[a]);c.useEffect(()=>{if(!n.current)return()=>{};const t={current:void 0};let e=0;const r=new MutationObserver(s=>{const f=Date.now();if(f-e<16)return;e=f;const{shouldScroll:S,hasSignificantChange:D}=k(s);S&&u()&&m(D,t)});return r.observe(n.current,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["class","style"]}),()=>{r.disconnect(),t.current&&clearTimeout(t.current)}},[u,k,m,n])},F=({elementRef:n})=>{const[d,o]=c.useState(!1);return c.useEffect(()=>{const i=n.current;if(!i)return;const l=()=>{const T=i.scrollHeight>i.clientHeight;o(T)};l();const u=new ResizeObserver(()=>{l()});u.observe(i);const b=new MutationObserver(()=>{requestAnimationFrame(l)});return b.observe(i,{childList:!0,subtree:!0,characterData:!0}),()=>{u.disconnect(),b.disconnect()}},[n]),d};exports.useChatScroll=q;exports.useHasScrollbar=F;
@@ -6,117 +6,117 @@
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
8
  import * as c from "react";
9
- const A = 50, _ = 250, h = 50, m = 100, B = ({
9
+ const A = 50, x = 250, C = 50, H = 100, _ = ({
10
10
  viewItemsWrapperRef: n,
11
- isKeyboardNavigationActiveRef: S,
12
- processedMessages: a,
13
- suggestions: f
11
+ isKeyboardNavigationActiveRef: T,
12
+ processedMessages: s,
13
+ suggestions: d
14
14
  }) => {
15
- const s = c.useCallback(() => {
15
+ const o = c.useCallback(() => {
16
16
  n.current && (n.current.scrollTop = n.current.scrollHeight - n.current.clientHeight);
17
- }, [n]), u = c.useCallback(() => {
17
+ }, [n]), l = c.useCallback(() => {
18
18
  if (!n.current)
19
19
  return !0;
20
- const t = n.current, { scrollTop: e, scrollHeight: r, clientHeight: l } = t, i = A + 25;
21
- return r - e - l < i;
22
- }, [n]), b = c.useCallback((t) => t === 0 ? 16 : t <= 2 ? 32 * t : Math.min(50 * t, 200), []), C = c.useCallback(
20
+ const t = n.current, { scrollTop: e, scrollHeight: r, clientHeight: u } = t, a = A + 25;
21
+ return r - e - u < a;
22
+ }, [n]), h = c.useCallback((t) => t === 0 ? 16 : t <= 2 ? 32 * t : Math.min(50 * t, 200), []), b = c.useCallback(
23
23
  (t, e) => {
24
- const r = b(t);
24
+ const r = h(t);
25
25
  setTimeout(() => {
26
- !u() && n.current && e(t + 1);
26
+ !l() && n.current && e(t + 1);
27
27
  }, r);
28
28
  },
29
- [b, u, n]
30
- ), d = c.useCallback(() => {
29
+ [h, l, n]
30
+ ), f = c.useCallback(() => {
31
31
  const t = (e = 0) => {
32
32
  e > 5 || requestAnimationFrame(() => {
33
- s(), C(e, t);
33
+ o(), b(e, t);
34
34
  });
35
35
  };
36
36
  t();
37
- }, [s, C]), y = c.useCallback(() => {
38
- s(), setTimeout(() => {
39
- !u() && n.current && s();
37
+ }, [o, b]), y = c.useCallback(() => {
38
+ o(), setTimeout(() => {
39
+ !l() && n.current && o();
40
40
  }, 50);
41
- }, [s, u, n]), E = c.useCallback(() => {
41
+ }, [o, l, n]), E = c.useCallback(() => {
42
42
  requestAnimationFrame(() => {
43
43
  requestAnimationFrame(() => {
44
44
  requestAnimationFrame(y);
45
45
  });
46
46
  });
47
47
  }, [y]), L = c.useCallback(() => {
48
- s(), setTimeout(() => {
49
- !u() && n.current && d();
48
+ o(), setTimeout(() => {
49
+ !l() && n.current && f();
50
50
  }, 25);
51
- }, [s, u, n, d]), o = c.useCallback(
51
+ }, [o, l, n, f]), i = c.useCallback(
52
52
  (t = !1) => {
53
- if (!n.current || S.current)
53
+ if (!n.current || T.current)
54
54
  return;
55
- u() && (t ? L() : E());
55
+ l() && (t ? L() : E());
56
56
  },
57
57
  [
58
- u,
58
+ l,
59
59
  L,
60
60
  E,
61
61
  n,
62
- S
62
+ T
63
63
  ]
64
64
  );
65
65
  c.useEffect(() => {
66
- const t = window.setTimeout(() => s(), _);
66
+ const t = window.setTimeout(() => o(), x);
67
67
  return () => {
68
68
  clearTimeout(t);
69
69
  };
70
- }, [s]), c.useEffect(() => {
71
- d();
72
- }, [a.length, d]);
73
- const k = c.useRef(/* @__PURE__ */ new Map());
70
+ }, [o]), c.useEffect(() => {
71
+ f();
72
+ }, [s.length, f]);
73
+ const O = c.useRef(/* @__PURE__ */ new Map());
74
74
  c.useEffect(() => {
75
75
  const t = /* @__PURE__ */ new Map();
76
76
  let e = !1;
77
- a.forEach((r) => {
77
+ s.forEach((r) => {
78
78
  if (r.id !== void 0) {
79
- const l = r.id, i = !!r.typing, T = k.current.get(l);
80
- t.set(l, i), T === !0 && i === !1 && (e = !0);
79
+ const u = r.id, a = !!r.typing, S = O.current.get(u);
80
+ t.set(u, a), S === !0 && a === !1 && (e = !0);
81
81
  }
82
- }), k.current = t, e && d();
83
- }, [a, d]), c.useEffect(() => {
82
+ }), O.current = t, e && f();
83
+ }, [s, f]), c.useEffect(() => {
84
84
  const t = window.setTimeout(() => {
85
- o();
86
- }, h);
85
+ i();
86
+ }, C);
87
87
  return () => {
88
88
  clearTimeout(t);
89
89
  };
90
- }, [a, o]), c.useEffect(() => {
91
- if (a.length > 0) {
92
- const t = a[a.length - 1], e = (t == null ? void 0 : t.text) || "";
90
+ }, [s, i]), c.useEffect(() => {
91
+ if (s.length > 0) {
92
+ const t = s[s.length - 1], e = (t == null ? void 0 : t.text) || "";
93
93
  (e.includes("```") || e.includes(`
94
94
 
95
- `) || e.includes("<pre>") || e.includes("<code>") || e.includes("<table>") || e.length > 500) && o(!0);
95
+ `) || e.includes("<pre>") || e.includes("<code>") || e.includes("<table>") || e.length > 500) && i(!0);
96
96
  }
97
- }, [a, o]), c.useEffect(() => {
98
- if (f && f.length > 0) {
97
+ }, [s, i]), c.useEffect(() => {
98
+ if (d && d.length > 0) {
99
99
  const t = window.setTimeout(() => {
100
- o();
101
- }, m);
100
+ i();
101
+ }, H);
102
102
  return () => {
103
103
  clearTimeout(t);
104
104
  };
105
105
  }
106
- }, [f, o]), c.useEffect(() => {
106
+ }, [d, i]), c.useEffect(() => {
107
107
  if (!n.current)
108
108
  return () => {
109
109
  };
110
110
  let t;
111
111
  const e = new ResizeObserver(() => {
112
112
  t && clearTimeout(t), t = window.setTimeout(() => {
113
- o();
114
- }, h);
113
+ i();
114
+ }, C);
115
115
  }), r = n.current.querySelector(".k-message-list-content");
116
116
  return r && e.observe(r), () => {
117
117
  e.disconnect();
118
118
  };
119
- }, [o, n]);
119
+ }, [i, n]);
120
120
  const g = c.useCallback((t) => {
121
121
  var r;
122
122
  if (t.type !== "characterData" && t.type !== "childList")
@@ -125,22 +125,22 @@ const A = 50, _ = 250, h = 50, m = 100, B = ({
125
125
  return e.includes("```") || e.includes(`
126
126
 
127
127
  `) || e.includes("<pre>") || e.includes("<code>") || e.includes("<table>") || t.addedNodes && t.addedNodes.length > 2;
128
- }, []), O = c.useCallback(
128
+ }, []), k = c.useCallback(
129
129
  (t) => {
130
130
  let e = !1, r = !1;
131
- return t.forEach((l) => {
132
- var i;
133
- (l.type === "childList" || l.type === "characterData" || l.type === "attributes" && ["class", "style"].includes((i = l.attributeName) != null ? i : "")) && (e = !0, g(l) && (r = !0));
131
+ return t.forEach((u) => {
132
+ var a;
133
+ (u.type === "childList" || u.type === "characterData" || u.type === "attributes" && ["class", "style"].includes((a = u.attributeName) != null ? a : "")) && (e = !0, g(u) && (r = !0));
134
134
  }), { shouldScroll: e, hasSignificantChange: r };
135
135
  },
136
136
  [g]
137
137
  ), D = c.useCallback(
138
138
  (t, e) => {
139
- e.current && clearTimeout(e.current), t ? o(!0) : e.current = window.setTimeout(() => {
140
- o();
141
- }, h);
139
+ e.current && clearTimeout(e.current), t ? i(!0) : e.current = window.setTimeout(() => {
140
+ i();
141
+ }, C);
142
142
  },
143
- [o]
143
+ [i]
144
144
  );
145
145
  c.useEffect(() => {
146
146
  if (!n.current)
@@ -148,13 +148,13 @@ const A = 50, _ = 250, h = 50, m = 100, B = ({
148
148
  };
149
149
  const t = { current: void 0 };
150
150
  let e = 0;
151
- const r = new MutationObserver((l) => {
152
- const i = Date.now();
153
- if (i - e < 16)
151
+ const r = new MutationObserver((u) => {
152
+ const a = Date.now();
153
+ if (a - e < 16)
154
154
  return;
155
- e = i;
156
- const { shouldScroll: T, hasSignificantChange: x } = O(l);
157
- T && u() && D(x, t);
155
+ e = a;
156
+ const { shouldScroll: S, hasSignificantChange: m } = k(u);
157
+ S && l() && D(m, t);
158
158
  });
159
159
  return r.observe(n.current, {
160
160
  childList: !0,
@@ -165,8 +165,35 @@ const A = 50, _ = 250, h = 50, m = 100, B = ({
165
165
  }), () => {
166
166
  r.disconnect(), t.current && clearTimeout(t.current);
167
167
  };
168
- }, [u, O, D, n]);
168
+ }, [l, k, D, n]);
169
+ }, B = ({ elementRef: n }) => {
170
+ const [T, s] = c.useState(!1);
171
+ return c.useEffect(() => {
172
+ const d = n.current;
173
+ if (!d)
174
+ return;
175
+ const o = () => {
176
+ const b = d.scrollHeight > d.clientHeight;
177
+ s(b);
178
+ };
179
+ o();
180
+ const l = new ResizeObserver(() => {
181
+ o();
182
+ });
183
+ l.observe(d);
184
+ const h = new MutationObserver(() => {
185
+ requestAnimationFrame(o);
186
+ });
187
+ return h.observe(d, {
188
+ childList: !0,
189
+ subtree: !0,
190
+ characterData: !0
191
+ }), () => {
192
+ l.disconnect(), h.disconnect();
193
+ };
194
+ }, [n]), T;
169
195
  };
170
196
  export {
171
- B as useChatScroll
197
+ _ as useChatScroll,
198
+ B as useHasScrollbar
172
199
  };
package/chat/utils.d.ts CHANGED
@@ -27,8 +27,11 @@ export declare const getMessageById: (messages: Message[], id: string | number)
27
27
  /**
28
28
  * @hidden
29
29
  * Scrolls to a message element by its ID
30
+ * @param messageId - The ID of the message to scroll to
31
+ * @param scrollContainer - The scroll container element
32
+ * @param offset - Optional offset in pixels to account for sticky elements (e.g., pinned message height)
30
33
  */
31
- export declare const scrollToMessageById: (messageId: string | number, scrollContainer?: HTMLElement | null) => void;
34
+ export declare const scrollToMessageById: (messageId: string | number, scrollContainer?: HTMLElement | null, offset?: number) => void;
32
35
  /**
33
36
  * @hidden
34
37
  * Regular expression to detect URLs in text
package/chat/utils.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 i=require("react"),n=require("../messages/index.js"),d=(t,s)=>t&&s.author&&t.id===s.author.id,g=(t,s)=>{const o=s.toLanguageString("chatSender.deletedMessage",n.messages[n.chatSenderDeletedMessage]),e=s.toLanguageString("chatReceiver.deletedMessage",n.messages[n.chatReceiverDeletedMessage]);return t?o:e},u=t=>{navigator.clipboard.writeText(t)},h=(t,s)=>t.find(o=>o.id===s),T=(t,s)=>{if(!s)return;const o=s.querySelector(`[data-message-id="${t}"]`);if(!o)return;const e=s.querySelector(".k-message-list");if(e){const c=e.getBoundingClientRect().top,a=o.getBoundingClientRect().top,l=e.scrollTop+(a-c);e.scrollTo({top:l,behavior:"smooth"})}else o.scrollIntoView({behavior:"smooth",block:"start"})},r=/(https?:\/\/[^\s]+)/g,p=t=>{if(!t)return[""];const s=t.split(r),o=[];return s.forEach(e=>{e&&r.test(e)?(r.lastIndex=0,o.push(i.createElement("a",{key:e,href:e,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"underline"}},e))):e&&o.push(e)}),o};exports.URL_REGEX=r;exports.convertTextToLinkedContent=p;exports.copyToClipboard=u;exports.getDeletedMessageText=g;exports.getMessageById=h;exports.isAuthor=d;exports.scrollToMessageById=T;
8
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react"),r=require("../messages/index.js"),g=(e,t)=>e&&t.author&&e.id===t.author.id,u=(e,t)=>{const o=t.toLanguageString("chatSender.deletedMessage",r.messages[r.chatSenderDeletedMessage]),s=t.toLanguageString("chatReceiver.deletedMessage",r.messages[r.chatReceiverDeletedMessage]);return e?o:s},h=e=>{navigator.clipboard.writeText(e)},T=(e,t)=>e.find(o=>o.id===t),p=(e,t,o=0)=>{if(!t)return;const s=t.querySelector(`[data-message-id="${e}"]`);if(!s)return;const n=t.querySelector(".k-message-list");if(n){const a=n.getBoundingClientRect().top,l=s.getBoundingClientRect().top,i=n.scrollTop+(l-a)-o;n.scrollTo({top:i,behavior:"smooth"})}else s.scrollIntoView({behavior:"smooth",block:"start"})},c=/(https?:\/\/[^\s]+)/g,M=e=>{if(!e)return[""];const t=e.split(c),o=[];return t.forEach(s=>{s&&c.test(s)?(c.lastIndex=0,o.push(d.createElement("a",{key:s,href:s,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"underline"}},s))):s&&o.push(s)}),o};exports.URL_REGEX=c;exports.convertTextToLinkedContent=M;exports.copyToClipboard=h;exports.getDeletedMessageText=u;exports.getMessageById=T;exports.isAuthor=g;exports.scrollToMessageById=p;
package/chat/utils.mjs CHANGED
@@ -5,63 +5,63 @@
5
5
  * Licensed under commercial license. See LICENSE.md in the package root for more information
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
- import i from "react";
9
- import { messages as n, chatSenderDeletedMessage as d, chatReceiverDeletedMessage as g } from "../messages/index.mjs";
10
- const f = (t, o) => t && o.author && t.id === o.author.id, p = (t, o) => {
11
- const s = o.toLanguageString(
8
+ import d from "react";
9
+ import { messages as c, chatSenderDeletedMessage as g, chatReceiverDeletedMessage as u } from "../messages/index.mjs";
10
+ const p = (e, t) => e && t.author && e.id === t.author.id, m = (e, t) => {
11
+ const s = t.toLanguageString(
12
12
  "chatSender.deletedMessage",
13
- n[d]
14
- ), e = o.toLanguageString(
13
+ c[g]
14
+ ), o = t.toLanguageString(
15
15
  "chatReceiver.deletedMessage",
16
- n[g]
16
+ c[u]
17
17
  );
18
- return t ? s : e;
19
- }, m = (t) => {
20
- navigator.clipboard.writeText(t);
21
- }, T = (t, o) => t.find((s) => s.id === o), M = (t, o) => {
22
- if (!o)
18
+ return e ? s : o;
19
+ }, T = (e) => {
20
+ navigator.clipboard.writeText(e);
21
+ }, M = (e, t) => e.find((s) => s.id === t), y = (e, t, s = 0) => {
22
+ if (!t)
23
23
  return;
24
- const s = o.querySelector(`[data-message-id="${t}"]`);
25
- if (!s)
24
+ const o = t.querySelector(`[data-message-id="${e}"]`);
25
+ if (!o)
26
26
  return;
27
- const e = o.querySelector(".k-message-list");
28
- if (e) {
29
- const c = e.getBoundingClientRect().top, a = s.getBoundingClientRect().top, l = e.scrollTop + (a - c);
30
- e.scrollTo({
31
- top: l,
27
+ const r = t.querySelector(".k-message-list");
28
+ if (r) {
29
+ const a = r.getBoundingClientRect().top, l = o.getBoundingClientRect().top, i = r.scrollTop + (l - a) - s;
30
+ r.scrollTo({
31
+ top: i,
32
32
  behavior: "smooth"
33
33
  });
34
34
  } else
35
- s.scrollIntoView({
35
+ o.scrollIntoView({
36
36
  behavior: "smooth",
37
37
  block: "start"
38
38
  });
39
- }, r = /(https?:\/\/[^\s]+)/g, y = (t) => {
40
- if (!t)
39
+ }, n = /(https?:\/\/[^\s]+)/g, R = (e) => {
40
+ if (!e)
41
41
  return [""];
42
- const o = t.split(r), s = [];
43
- return o.forEach((e) => {
44
- e && r.test(e) ? (r.lastIndex = 0, s.push(
45
- i.createElement(
42
+ const t = e.split(n), s = [];
43
+ return t.forEach((o) => {
44
+ o && n.test(o) ? (n.lastIndex = 0, s.push(
45
+ d.createElement(
46
46
  "a",
47
47
  {
48
- key: e,
49
- href: e,
48
+ key: o,
49
+ href: o,
50
50
  target: "_blank",
51
51
  rel: "noopener noreferrer",
52
52
  style: { color: "inherit", textDecoration: "underline" }
53
53
  },
54
- e
54
+ o
55
55
  )
56
- )) : e && s.push(e);
56
+ )) : o && s.push(o);
57
57
  }), s;
58
58
  };
59
59
  export {
60
- r as URL_REGEX,
61
- y as convertTextToLinkedContent,
62
- m as copyToClipboard,
63
- p as getDeletedMessageText,
64
- T as getMessageById,
65
- f as isAuthor,
66
- M as scrollToMessageById
60
+ n as URL_REGEX,
61
+ R as convertTextToLinkedContent,
62
+ T as copyToClipboard,
63
+ m as getDeletedMessageText,
64
+ M as getMessageById,
65
+ p as isAuthor,
66
+ y as scrollToMessageById
67
67
  };