llmasaservice-ui 0.6.5 → 0.6.7

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;
@@ -447,7 +438,15 @@ var ChatPanel = ({
447
438
  }
448
439
  const scrollToBottom = () => {
449
440
  var _a;
450
- (_a = bottomRef.current) == null ? void 0 : _a.scrollIntoView({ behavior: "smooth", block: "end" });
441
+ if (window.top !== window.self) {
442
+ const responseArea = responseAreaRef.current;
443
+ responseArea.scrollTo({
444
+ top: responseArea.scrollHeight,
445
+ behavior: "smooth"
446
+ });
447
+ } else {
448
+ (_a = bottomRef.current) == null ? void 0 : _a.scrollIntoView({ behavior: "smooth" });
449
+ }
451
450
  };
452
451
  const CodeBlock = (_a) => {
453
452
  var _b = _a, { node, className, children, style } = _b, props = __objRest(_b, ["node", "className", "children", "style"]);
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;
@@ -414,7 +405,15 @@ var ChatPanel = ({
414
405
  }
415
406
  const scrollToBottom = () => {
416
407
  var _a;
417
- (_a = bottomRef.current) == null ? void 0 : _a.scrollIntoView({ behavior: "smooth", block: "end" });
408
+ if (window.top !== window.self) {
409
+ const responseArea = responseAreaRef.current;
410
+ responseArea.scrollTo({
411
+ top: responseArea.scrollHeight,
412
+ behavior: "smooth"
413
+ });
414
+ } else {
415
+ (_a = bottomRef.current) == null ? void 0 : _a.scrollIntoView({ behavior: "smooth" });
416
+ }
418
417
  };
419
418
  const CodeBlock = (_a) => {
420
419
  var _b = _a, { node, className, children, style } = _b, props = __objRest(_b, ["node", "className", "children", "style"]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "llmasaservice-ui",
3
- "version": "0.6.5",
3
+ "version": "0.6.7",
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) {
@@ -427,23 +405,16 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
427
405
  }
428
406
 
429
407
  const scrollToBottom = () => {
430
- bottomRef.current?.scrollIntoView({ behavior: "smooth", block: "end" });
431
-
432
- /*
433
408
  if (window.top !== window.self) {
434
- // If the ChatPanel is within an iframe
435
- bottomRef.current?.scrollIntoView({ behavior: "smooth" });
436
- const frameElement = window.frameElement;
437
- if (frameElement) {
438
- window.parent.scrollTo({
439
- top: frameElement.getBoundingClientRect().top + window.scrollY,
440
- behavior: "smooth",
441
- });
442
- }
409
+ const responseArea = responseAreaRef.current as any;
410
+ responseArea.scrollTo({
411
+ top: responseArea.scrollHeight,
412
+ behavior: "smooth",
413
+ });
443
414
  } else {
444
415
  // If the ChatPanel is not within an iframe
445
416
  bottomRef.current?.scrollIntoView({ behavior: "smooth" });
446
- }*/
417
+ }
447
418
  };
448
419
 
449
420
  const CodeBlock = ({ node, className, children, style, ...props }: any) => {
@@ -811,7 +782,7 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
811
782
  </div>
812
783
  ))}
813
784
 
814
- {(followOnQuestions && followOnQuestions.length > 0 && idle) && (
785
+ {followOnQuestions && followOnQuestions.length > 0 && idle && (
815
786
  <div className="suggestions-container">
816
787
  {followOnQuestions.map((question, index) => (
817
788
  <button