@a.izzuddin/ai-chat 0.2.26 → 0.2.27-beta.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.
@@ -987,6 +987,11 @@
987
987
  }
988
988
  ]
989
989
  },
990
+ {
991
+ "kind": "field",
992
+ "name": "_viewportResizeHandler",
993
+ "privacy": "private"
994
+ },
990
995
  {
991
996
  "kind": "method",
992
997
  "name": "scrollToBottom",
package/dist/index.d.mts CHANGED
@@ -213,7 +213,9 @@ declare class AIChat extends LitElement {
213
213
  private loadMessagesFromStorage;
214
214
  private clearMessagesFromStorage;
215
215
  private formatMessageContent;
216
+ private _viewportResizeHandler;
216
217
  connectedCallback(): Promise<void>;
218
+ disconnectedCallback(): void;
217
219
  updated(changedProperties: PropertyValues): void;
218
220
  private scrollToBottom;
219
221
  /**
package/dist/index.d.ts CHANGED
@@ -213,7 +213,9 @@ declare class AIChat extends LitElement {
213
213
  private loadMessagesFromStorage;
214
214
  private clearMessagesFromStorage;
215
215
  private formatMessageContent;
216
+ private _viewportResizeHandler;
216
217
  connectedCallback(): Promise<void>;
218
+ disconnectedCallback(): void;
217
219
  updated(changedProperties: PropertyValues): void;
218
220
  private scrollToBottom;
219
221
  /**
package/dist/index.js CHANGED
@@ -5373,7 +5373,7 @@ MarkdownIt.prototype.renderInline = function(src, env) {
5373
5373
  var lib_default = MarkdownIt;
5374
5374
 
5375
5375
  // src/components/ai-chat.ts
5376
- console.log("Chatbot Ver = 0.2.25-beta.5");
5376
+ console.log("Chatbot Ver = 0.2.27-beta.1");
5377
5377
  var md = new lib_default({
5378
5378
  html: false,
5379
5379
  // Disable HTML tags in source for security
@@ -5385,6 +5385,13 @@ var md = new lib_default({
5385
5385
  exports.AIChat = class AIChat extends lit.LitElement {
5386
5386
  constructor() {
5387
5387
  super();
5388
+ this._viewportResizeHandler = () => {
5389
+ const vv = window.visualViewport;
5390
+ if (vv) {
5391
+ this.style.setProperty("--viewport-height", `${vv.height}px`);
5392
+ this.style.setProperty("--viewport-offset-top", `${vv.offsetTop}px`);
5393
+ }
5394
+ };
5388
5395
  this.apiUrl = "";
5389
5396
  this.sessionId = "default-session";
5390
5397
  this.chatTitle = "My AI Agent";
@@ -5528,6 +5535,11 @@ ${this.welcomeSubtitle}` : this.welcomeMessage;
5528
5535
  }
5529
5536
  async connectedCallback() {
5530
5537
  super.connectedCallback();
5538
+ if (window.visualViewport) {
5539
+ window.visualViewport.addEventListener("resize", this._viewportResizeHandler);
5540
+ window.visualViewport.addEventListener("scroll", this._viewportResizeHandler);
5541
+ this._viewportResizeHandler();
5542
+ }
5531
5543
  const savedMessages = this.loadMessagesFromStorage();
5532
5544
  if (this.initialMessages && this.initialMessages.length > 0) {
5533
5545
  this.messages = [...this.initialMessages];
@@ -5598,6 +5610,13 @@ ${this.welcomeSubtitle}` : this.welcomeMessage;
5598
5610
  }, 500);
5599
5611
  }
5600
5612
  }
5613
+ disconnectedCallback() {
5614
+ super.disconnectedCallback();
5615
+ if (window.visualViewport) {
5616
+ window.visualViewport.removeEventListener("resize", this._viewportResizeHandler);
5617
+ window.visualViewport.removeEventListener("scroll", this._viewportResizeHandler);
5618
+ }
5619
+ }
5601
5620
  updated(changedProperties) {
5602
5621
  super.updated(changedProperties);
5603
5622
  if (changedProperties.has("messages")) {
@@ -6417,6 +6436,7 @@ exports.AIChat.styles = lit.css`
6417
6436
  display: flex;
6418
6437
  flex-direction: column;
6419
6438
  height: 100vh;
6439
+ height: var(--viewport-height, 100dvh);
6420
6440
  background: #ffffff;
6421
6441
  }
6422
6442
 
@@ -6578,12 +6598,12 @@ exports.AIChat.styles = lit.css`
6578
6598
  @media (max-width: 480px) and (orientation: portrait) {
6579
6599
  .widget-window {
6580
6600
  position: fixed;
6581
- top: 0;
6601
+ top: var(--viewport-offset-top, 0px);
6582
6602
  left: 0;
6583
6603
  right: 0;
6584
- bottom: 0;
6585
6604
  width: 100vw;
6586
6605
  height: 100vh;
6606
+ height: var(--viewport-height, 100dvh);
6587
6607
  border-radius: 0;
6588
6608
  }
6589
6609
 
@@ -6602,12 +6622,12 @@ exports.AIChat.styles = lit.css`
6602
6622
  @media (max-width: 900px) and (orientation: landscape) {
6603
6623
  .widget-window {
6604
6624
  position: fixed;
6605
- top: 0;
6625
+ top: var(--viewport-offset-top, 0px);
6606
6626
  left: 0;
6607
6627
  right: 0;
6608
- bottom: 0;
6609
6628
  width: 100vw;
6610
6629
  height: 100vh;
6630
+ height: var(--viewport-height, 100dvh);
6611
6631
  border-radius: 0;
6612
6632
  }
6613
6633