@buni.ai/chatbot-angular 1.0.27 → 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 +29 -65
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +29 -65
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
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
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
const
|
|
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:
|
|
548
|
-
|
|
549
|
-
|
|
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(
|
|
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.
|
|
561
|
-
this.
|
|
562
|
-
this.
|
|
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)
|
|
@@ -700,7 +685,7 @@ class BuniChatWidget {
|
|
|
700
685
|
setupPostMessageAPI(iframe) {
|
|
701
686
|
// Listen for messages from the iframe
|
|
702
687
|
window.addEventListener("message", (event) => {
|
|
703
|
-
var _a
|
|
688
|
+
var _a;
|
|
704
689
|
if (event.source !== iframe.contentWindow) {
|
|
705
690
|
return;
|
|
706
691
|
}
|
|
@@ -749,28 +734,7 @@ class BuniChatWidget {
|
|
|
749
734
|
this.state.displayMode = "minimal";
|
|
750
735
|
this.state.isOpen = true;
|
|
751
736
|
this.state.isMinimized = false;
|
|
752
|
-
|
|
753
|
-
if (this.widgetElement && this.chatIframe && this.triggerIframe) {
|
|
754
|
-
const position = ((_a = this.options.config) === null || _a === void 0 ? void 0 : _a.position) || "bottom-right";
|
|
755
|
-
this.widgetElement.style.cssText = `
|
|
756
|
-
position: fixed;
|
|
757
|
-
pointer-events: none;
|
|
758
|
-
z-index: 999999;
|
|
759
|
-
width: min(calc(100vw - 1.5rem), 390px);
|
|
760
|
-
max-width: min(calc(100vw - 1.5rem), 390px);
|
|
761
|
-
height: auto;
|
|
762
|
-
transition: width 0.3s ease, height 0.3s ease, border-radius 0.3s ease;
|
|
763
|
-
${this.getPositionStyles(position, true)}
|
|
764
|
-
display: block;
|
|
765
|
-
overflow: visible;
|
|
766
|
-
box-sizing: border-box;
|
|
767
|
-
`;
|
|
768
|
-
this.triggerIframe.style.display = "none";
|
|
769
|
-
this.chatIframe.style.display = "block";
|
|
770
|
-
this.chatIframe.style.visibility = "visible";
|
|
771
|
-
this.chatIframe.style.width = "100%";
|
|
772
|
-
this.chatIframe.style.height = "min(calc(100vh - 1.5rem), 520px)";
|
|
773
|
-
}
|
|
737
|
+
this.applyMinimalContainerFrame();
|
|
774
738
|
}
|
|
775
739
|
else {
|
|
776
740
|
// Backward-compatible behavior.
|
|
@@ -780,7 +744,7 @@ class BuniChatWidget {
|
|
|
780
744
|
case "new_unread_message":
|
|
781
745
|
// Update unread count in trigger
|
|
782
746
|
this.state.unreadCount++;
|
|
783
|
-
if ((
|
|
747
|
+
if ((_a = this.triggerIframe) === null || _a === void 0 ? void 0 : _a.contentWindow) {
|
|
784
748
|
this.triggerIframe.contentWindow.postMessage({ type: "updateUnreadCount", count: this.state.unreadCount }, window.location.origin);
|
|
785
749
|
}
|
|
786
750
|
break;
|