@weldsuite/helpdesk-widget-sdk 1.0.2 → 1.0.4

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.umd.js CHANGED
@@ -562,20 +562,47 @@
562
562
  const container = document.createElement('div');
563
563
  container.className = 'weld-widget-frame';
564
564
  container.setAttribute('data-state', 'closed');
565
- container.style.cssText = `
566
- position: fixed;
567
- bottom: ${widget.position.bottom};
568
- right: ${widget.position.right};
569
- width: ${widget.width};
570
- height: ${widget.height};
571
- max-width: 100vw;
572
- z-index: 2147483001;
573
- pointer-events: none;
574
- display: none;
575
- border-radius: 16px;
576
- overflow: hidden;
577
- background: transparent;
578
- `;
565
+ // Apply different styles for mobile vs desktop
566
+ if (this.deviceInfo.isMobile) {
567
+ // Mobile: full-screen with dynamic viewport height to handle URL bar
568
+ container.style.cssText = `
569
+ position: fixed;
570
+ top: 0;
571
+ left: 0;
572
+ right: 0;
573
+ bottom: 0;
574
+ width: 100vw;
575
+ height: 100dvh;
576
+ height: 100vh;
577
+ z-index: 2147483001;
578
+ pointer-events: none;
579
+ display: none;
580
+ border-radius: 0;
581
+ overflow: hidden;
582
+ background: transparent;
583
+ `;
584
+ // Use visualViewport API for accurate height on mobile browsers
585
+ if (window.visualViewport) {
586
+ container.style.height = `${window.visualViewport.height}px`;
587
+ }
588
+ }
589
+ else {
590
+ // Desktop: positioned widget
591
+ container.style.cssText = `
592
+ position: fixed;
593
+ bottom: ${widget.position.bottom};
594
+ right: ${widget.position.right};
595
+ width: ${widget.width};
596
+ height: ${widget.height};
597
+ max-width: 100vw;
598
+ z-index: 2147483001;
599
+ pointer-events: none;
600
+ display: none;
601
+ border-radius: 16px;
602
+ overflow: hidden;
603
+ background: transparent;
604
+ `;
605
+ }
579
606
  // Create iframe
580
607
  const iframe = document.createElement('iframe');
581
608
  iframe.name = widget.name;
@@ -587,7 +614,7 @@
587
614
  border: none;
588
615
  background: transparent;
589
616
  display: block;
590
- border-radius: 16px;
617
+ border-radius: ${this.deviceInfo.isMobile ? '0' : '16px'};
591
618
  `;
592
619
  iframe.setAttribute('allow', 'clipboard-write; camera; microphone');
593
620
  iframe.setAttribute('sandbox', 'allow-scripts allow-same-origin allow-forms allow-popups allow-downloads');
@@ -673,6 +700,11 @@
673
700
  window.addEventListener('resize', this.handleResize.bind(this));
674
701
  // Orientation change
675
702
  window.addEventListener('orientationchange', this.handleOrientationChange.bind(this));
703
+ // Visual viewport resize (handles mobile URL bar and keyboard)
704
+ if (window.visualViewport) {
705
+ window.visualViewport.addEventListener('resize', this.handleVisualViewportResize.bind(this));
706
+ window.visualViewport.addEventListener('scroll', this.handleVisualViewportResize.bind(this));
707
+ }
676
708
  this.logger.debug('Event listeners setup');
677
709
  }
678
710
  /**
@@ -689,6 +721,21 @@
689
721
  this.deviceInfo = detectDevice();
690
722
  this.logger.debug('Orientation changed', { orientation: this.deviceInfo.orientation });
691
723
  }
724
+ /**
725
+ * Handle visual viewport resize (mobile URL bar, keyboard)
726
+ */
727
+ handleVisualViewportResize() {
728
+ if (!this.deviceInfo.isMobile || !window.visualViewport)
729
+ return;
730
+ const widget = this.iframes.get(exports.IframeType.WIDGET);
731
+ if (widget && widget.visible) {
732
+ const vh = window.visualViewport.height;
733
+ const offsetTop = window.visualViewport.offsetTop;
734
+ widget.container.style.height = `${vh}px`;
735
+ widget.container.style.top = `${offsetTop}px`;
736
+ this.logger.debug('Visual viewport resized', { height: vh, offsetTop });
737
+ }
738
+ }
692
739
  /**
693
740
  * Get iframe by type
694
741
  */
@@ -746,6 +793,18 @@
746
793
  if (this.deviceInfo.isMobile && type === exports.IframeType.WIDGET && this.config.mobile.scrollLock) {
747
794
  document.body.classList.add('weld-mobile-open');
748
795
  }
796
+ // Hide launcher on mobile when widget is open (full-screen mode)
797
+ if (this.deviceInfo.isMobile && type === exports.IframeType.WIDGET) {
798
+ const launcher = this.iframes.get(exports.IframeType.LAUNCHER);
799
+ if (launcher) {
800
+ launcher.container.style.display = 'none';
801
+ }
802
+ // Apply accurate viewport height using visualViewport API
803
+ if (window.visualViewport) {
804
+ iframe.container.style.height = `${window.visualViewport.height}px`;
805
+ iframe.container.style.top = `${window.visualViewport.offsetTop}px`;
806
+ }
807
+ }
749
808
  console.log(`[Weld SDK] Iframe ${type} shown`, { newDisplay: iframe.container.style.display });
750
809
  }
751
810
  /**
@@ -766,6 +825,13 @@
766
825
  if (this.deviceInfo.isMobile && type === exports.IframeType.WIDGET) {
767
826
  document.body.classList.remove('weld-mobile-open');
768
827
  }
828
+ // Show launcher again on mobile when widget is closed
829
+ if (this.deviceInfo.isMobile && type === exports.IframeType.WIDGET) {
830
+ const launcher = this.iframes.get(exports.IframeType.LAUNCHER);
831
+ if (launcher) {
832
+ launcher.container.style.display = 'block';
833
+ }
834
+ }
769
835
  console.log(`[Weld SDK] Iframe ${type} hidden`, { newDisplay: iframe.container.style.display });
770
836
  }
771
837
  /**
@@ -2162,7 +2228,7 @@
2162
2228
  }
2163
2229
  }
2164
2230
 
2165
- var version = "1.0.2";
2231
+ var version = "1.0.4";
2166
2232
  var packageJson = {
2167
2233
  version: version};
2168
2234