@buni.ai/chatbot-angular 1.0.26 → 1.0.28

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
@@ -356,12 +356,12 @@ class BuniChatWidget {
356
356
  if (event.source === ((_j = this.chatIframe) === null || _j === void 0 ? void 0 : _j.contentWindow) &&
357
357
  event.origin === this.getBaseUrl()) {
358
358
  if (this.isMinimalModeEnabled()) {
359
- if (!this.state.isOpen) {
360
- void this.openChat();
361
- }
362
359
  this.postMessageToWidget("minimize");
360
+ this.applyMinimalContainerFrame();
363
361
  this.displayMode = "minimal";
364
362
  this.state.displayMode = "minimal";
363
+ this.state.isOpen = true;
364
+ this.state.isMinimized = false;
365
365
  }
366
366
  else {
367
367
  this.closeChat();
@@ -514,56 +514,41 @@ class BuniChatWidget {
514
514
  async openChatInMinimalMode() {
515
515
  if (!this.chatIframe || !this.widgetElement || !this.triggerIframe)
516
516
  return;
517
- const config = this.options.config || {};
518
- const isMobile = window.innerWidth <= 768;
519
- const isTablet = window.innerWidth > 768 && window.innerWidth <= 1024;
520
- const ensureUnits = (value, defaultValue) => {
521
- if (!value)
522
- return defaultValue;
523
- const str = String(value);
524
- if (str.match(/^[\d.]+\s*(px|em|rem|%|vh|vw)$/))
525
- return str;
526
- if (str.match(/^[\d.]+$/))
527
- return `${str}px`;
528
- return str;
529
- };
530
- const widthValue = ensureUnits(config.width, "350px");
531
- const heightValue = ensureUnits(config.height, "650px");
532
- const chatWidth = isMobile
533
- ? "100vw"
534
- : isTablet
535
- ? "min(calc(100vw - 3rem), 370px)"
536
- : widthValue;
537
- const chatHeight = isMobile
538
- ? "100vh"
539
- : isTablet
540
- ? "min(calc(100vh - 3rem), 620px)"
541
- : heightValue;
542
- // Size container to full chat dimensions initially (iframe needs space to render)
517
+ this.applyMinimalContainerFrame();
518
+ this.state.isMinimized = false;
519
+ this.state.isOpen = true;
520
+ this.displayMode = "minimal";
521
+ this.state.displayMode = "minimal";
522
+ // Ask the iframe to enter minimal mode; it will reply with "minimized" when ready
523
+ this.postMessageToWidget("minimize");
524
+ this.emit("minimized", { timestamp: Date.now() });
525
+ }
526
+ applyMinimalContainerFrame() {
527
+ var _a;
528
+ if (!this.widgetElement || !this.chatIframe || !this.triggerIframe)
529
+ return;
530
+ const position = ((_a = this.options.config) === null || _a === void 0 ? void 0 : _a.position) || "bottom-right";
543
531
  this.widgetElement.style.cssText = `
544
532
  position: fixed;
545
533
  pointer-events: none;
546
534
  z-index: 999999;
547
- width: ${chatWidth};
548
- height: ${chatHeight};
549
- ${isMobile ? "max-width: 100vw; max-height: 100vh;" : ""}
535
+ width: min(calc(100vw - 1.5rem), 390px);
536
+ max-width: min(calc(100vw - 1.5rem), 390px);
537
+ height: auto;
538
+ max-height: none;
539
+ min-height: 0;
550
540
  transition: width 0.3s ease, height 0.3s ease, border-radius 0.3s ease;
551
- ${this.getPositionStyles(config.position || "bottom-right", false)}
541
+ ${this.getPositionStyles(position, true)}
552
542
  display: block;
553
543
  overflow: visible;
554
544
  box-sizing: border-box;
555
545
  `;
556
- // Hide trigger, show chat iframe
557
546
  this.triggerIframe.style.display = "none";
558
547
  this.chatIframe.style.display = "block";
559
548
  this.chatIframe.style.visibility = "visible";
560
- this.state.isMinimized = false;
561
- this.state.isOpen = true;
562
- this.displayMode = "minimal";
563
- this.state.displayMode = "minimal";
564
- // Ask the iframe to enter minimal mode; it will reply with "minimized" when ready
565
- this.postMessageToWidget("minimize");
566
- this.emit("minimized", { timestamp: Date.now() });
549
+ this.chatIframe.style.width = "100%";
550
+ this.chatIframe.style.height = "min(calc(100vh - 1.5rem), 520px)";
551
+ this.chatIframe.style.maxHeight = "min(calc(100vh - 1.5rem), 520px)";
567
552
  }
568
553
  async openChat() {
569
554
  if (!this.chatIframe || !this.widgetElement || !this.triggerIframe)
@@ -745,23 +730,11 @@ class BuniChatWidget {
745
730
  case "minimized":
746
731
  this.syncServerBehaviorFromData(data);
747
732
  if (this.isMinimalModeEnabled()) {
748
- if (!this.state.isOpen) {
749
- void this.openChat();
750
- }
751
733
  this.displayMode = "minimal";
752
734
  this.state.displayMode = "minimal";
753
- // Shrink container to actual minimal card size
754
- if (this.widgetElement && this.chatIframe) {
755
- const isMobile = window.innerWidth <= 768;
756
- if (!isMobile) {
757
- this.widgetElement.style.width =
758
- "min(calc(100vw - 1.5rem), 390px)";
759
- this.widgetElement.style.height = "auto";
760
- this.widgetElement.style.overflow = "visible";
761
- this.chatIframe.style.height = "520px";
762
- this.chatIframe.style.width = "100%";
763
- }
764
- }
735
+ this.state.isOpen = true;
736
+ this.state.isMinimized = false;
737
+ this.applyMinimalContainerFrame();
765
738
  }
766
739
  else {
767
740
  // Backward-compatible behavior.