llmasaservice-ui 0.6.5 → 0.6.6

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/dist/index.js CHANGED
@@ -313,25 +313,16 @@ var ChatPanel = ({
313
313
  }
314
314
  }, [initialPrompt]);
315
315
  (0, import_react3.useEffect)(() => {
316
- var _a, _b;
316
+ var _a;
317
317
  if (scrollToEnd) {
318
318
  if (window.top !== window.self) {
319
- const frameElement = window.frameElement;
320
- if (frameElement) {
321
- const frameRect = frameElement.getBoundingClientRect();
322
- if (frameRect.bottom <= window.innerHeight) {
323
- window.parent.scrollTo({
324
- top: frameRect.bottom + window.scrollY - window.innerHeight,
325
- behavior: "smooth"
326
- });
327
- }
328
- (_a = bottomRef.current) == null ? void 0 : _a.scrollIntoView({
329
- behavior: "smooth",
330
- block: "end"
331
- });
332
- }
319
+ const responseArea = responseAreaRef.current;
320
+ responseArea.scrollTo({
321
+ top: responseArea.scrollHeight,
322
+ behavior: "smooth"
323
+ });
333
324
  } else {
334
- (_b = bottomRef.current) == null ? void 0 : _b.scrollIntoView({ behavior: "smooth", block: "end" });
325
+ (_a = bottomRef.current) == null ? void 0 : _a.scrollIntoView({ behavior: "smooth", block: "end" });
335
326
  }
336
327
  } else {
337
328
  const responseArea = responseAreaRef.current;
package/dist/index.mjs CHANGED
@@ -280,25 +280,16 @@ var ChatPanel = ({
280
280
  }
281
281
  }, [initialPrompt]);
282
282
  useEffect(() => {
283
- var _a, _b;
283
+ var _a;
284
284
  if (scrollToEnd) {
285
285
  if (window.top !== window.self) {
286
- const frameElement = window.frameElement;
287
- if (frameElement) {
288
- const frameRect = frameElement.getBoundingClientRect();
289
- if (frameRect.bottom <= window.innerHeight) {
290
- window.parent.scrollTo({
291
- top: frameRect.bottom + window.scrollY - window.innerHeight,
292
- behavior: "smooth"
293
- });
294
- }
295
- (_a = bottomRef.current) == null ? void 0 : _a.scrollIntoView({
296
- behavior: "smooth",
297
- block: "end"
298
- });
299
- }
286
+ const responseArea = responseAreaRef.current;
287
+ responseArea.scrollTo({
288
+ top: responseArea.scrollHeight,
289
+ behavior: "smooth"
290
+ });
300
291
  } else {
301
- (_b = bottomRef.current) == null ? void 0 : _b.scrollIntoView({ behavior: "smooth", block: "end" });
292
+ (_a = bottomRef.current) == null ? void 0 : _a.scrollIntoView({ behavior: "smooth", block: "end" });
302
293
  }
303
294
  } else {
304
295
  const responseArea = responseAreaRef.current;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "llmasaservice-ui",
3
- "version": "0.6.5",
3
+ "version": "0.6.6",
4
4
  "description": "Prebuilt UI components for LLMAsAService.io",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
package/src/ChatPanel.tsx CHANGED
@@ -250,37 +250,15 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
250
250
  useEffect(() => {
251
251
  if (scrollToEnd) {
252
252
  if (window.top !== window.self) {
253
- // If the ChatPanel is within an iframe
254
- const frameElement = window.frameElement;
255
- if (frameElement) {
256
- const frameRect = frameElement.getBoundingClientRect();
257
- if (frameRect.bottom <= window.innerHeight) {
258
- // Scroll the parent window to position the iframe at the bottom of the screen
259
- window.parent.scrollTo({
260
- top: frameRect.bottom + window.scrollY - window.innerHeight,
261
- behavior: "smooth",
262
- });
263
- }
264
-
265
- bottomRef.current?.scrollIntoView({
266
- behavior: "smooth",
267
- block: "end",
268
- });
269
-
270
- /*
271
- // Scroll the content within the iframe
272
- setTimeout(() => {
273
- bottomRef.current?.scrollIntoView({
274
- behavior: "smooth",
275
- block: "end",
276
- });
277
- }, 300);*/
278
- }
253
+ const responseArea = responseAreaRef.current as any;
254
+ responseArea.scrollTo({
255
+ top: responseArea.scrollHeight,
256
+ behavior: "smooth",
257
+ });
279
258
  } else {
280
259
  // If the ChatPanel is not within an iframe
281
260
  bottomRef.current?.scrollIntoView({ behavior: "smooth", block: "end" });
282
261
  }
283
- //bottomRef.current?.scrollIntoView({ behavior: "smooth", block: "end" });
284
262
  } else {
285
263
  const responseArea = responseAreaRef.current as any;
286
264
  if (responseArea) {
@@ -811,7 +789,7 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
811
789
  </div>
812
790
  ))}
813
791
 
814
- {(followOnQuestions && followOnQuestions.length > 0 && idle) && (
792
+ {followOnQuestions && followOnQuestions.length > 0 && idle && (
815
793
  <div className="suggestions-container">
816
794
  {followOnQuestions.map((question, index) => (
817
795
  <button
@@ -1078,3 +1056,25 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
1078
1056
  };
1079
1057
 
1080
1058
  export default ChatPanel;
1059
+
1060
+ /*
1061
+ // If the ChatPanel is within an iframe
1062
+ const frameElement = window.frameElement;
1063
+ if (frameElement) {
1064
+ const frameRect = frameElement.getBoundingClientRect();
1065
+ if (frameRect.bottom <= window.innerHeight) {
1066
+ // Scroll the bottom of the panel onto the screen first
1067
+ bottomPanelRef.current?.scrollIntoView({
1068
+ behavior: "smooth",
1069
+ block: "end",
1070
+ });
1071
+ }
1072
+ }
1073
+
1074
+ // Scroll the content within the iframe
1075
+ setTimeout(() => {
1076
+ bottomRef.current?.scrollIntoView({
1077
+ behavior: "smooth",
1078
+ block: "end",
1079
+ });
1080
+ }, 300);*/