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