@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.
package/dist/index.mjs CHANGED
@@ -5371,7 +5371,7 @@ MarkdownIt.prototype.renderInline = function(src, env) {
5371
5371
  var lib_default = MarkdownIt;
5372
5372
 
5373
5373
  // src/components/ai-chat.ts
5374
- console.log("Chatbot Ver = 0.2.25-beta.5");
5374
+ console.log("Chatbot Ver = 0.2.27-beta.1");
5375
5375
  var md = new lib_default({
5376
5376
  html: false,
5377
5377
  // Disable HTML tags in source for security
@@ -5383,6 +5383,13 @@ var md = new lib_default({
5383
5383
  var AIChat = class extends LitElement {
5384
5384
  constructor() {
5385
5385
  super();
5386
+ this._viewportResizeHandler = () => {
5387
+ const vv = window.visualViewport;
5388
+ if (vv) {
5389
+ this.style.setProperty("--viewport-height", `${vv.height}px`);
5390
+ this.style.setProperty("--viewport-offset-top", `${vv.offsetTop}px`);
5391
+ }
5392
+ };
5386
5393
  this.apiUrl = "";
5387
5394
  this.sessionId = "default-session";
5388
5395
  this.chatTitle = "My AI Agent";
@@ -5526,6 +5533,11 @@ ${this.welcomeSubtitle}` : this.welcomeMessage;
5526
5533
  }
5527
5534
  async connectedCallback() {
5528
5535
  super.connectedCallback();
5536
+ if (window.visualViewport) {
5537
+ window.visualViewport.addEventListener("resize", this._viewportResizeHandler);
5538
+ window.visualViewport.addEventListener("scroll", this._viewportResizeHandler);
5539
+ this._viewportResizeHandler();
5540
+ }
5529
5541
  const savedMessages = this.loadMessagesFromStorage();
5530
5542
  if (this.initialMessages && this.initialMessages.length > 0) {
5531
5543
  this.messages = [...this.initialMessages];
@@ -5596,6 +5608,13 @@ ${this.welcomeSubtitle}` : this.welcomeMessage;
5596
5608
  }, 500);
5597
5609
  }
5598
5610
  }
5611
+ disconnectedCallback() {
5612
+ super.disconnectedCallback();
5613
+ if (window.visualViewport) {
5614
+ window.visualViewport.removeEventListener("resize", this._viewportResizeHandler);
5615
+ window.visualViewport.removeEventListener("scroll", this._viewportResizeHandler);
5616
+ }
5617
+ }
5599
5618
  updated(changedProperties) {
5600
5619
  super.updated(changedProperties);
5601
5620
  if (changedProperties.has("messages")) {
@@ -6415,6 +6434,7 @@ AIChat.styles = css`
6415
6434
  display: flex;
6416
6435
  flex-direction: column;
6417
6436
  height: 100vh;
6437
+ height: var(--viewport-height, 100dvh);
6418
6438
  background: #ffffff;
6419
6439
  }
6420
6440
 
@@ -6576,12 +6596,12 @@ AIChat.styles = css`
6576
6596
  @media (max-width: 480px) and (orientation: portrait) {
6577
6597
  .widget-window {
6578
6598
  position: fixed;
6579
- top: 0;
6599
+ top: var(--viewport-offset-top, 0px);
6580
6600
  left: 0;
6581
6601
  right: 0;
6582
- bottom: 0;
6583
6602
  width: 100vw;
6584
6603
  height: 100vh;
6604
+ height: var(--viewport-height, 100dvh);
6585
6605
  border-radius: 0;
6586
6606
  }
6587
6607
 
@@ -6600,12 +6620,12 @@ AIChat.styles = css`
6600
6620
  @media (max-width: 900px) and (orientation: landscape) {
6601
6621
  .widget-window {
6602
6622
  position: fixed;
6603
- top: 0;
6623
+ top: var(--viewport-offset-top, 0px);
6604
6624
  left: 0;
6605
6625
  right: 0;
6606
- bottom: 0;
6607
6626
  width: 100vw;
6608
6627
  height: 100vh;
6628
+ height: var(--viewport-height, 100dvh);
6609
6629
  border-radius: 0;
6610
6630
  }
6611
6631