@weldsuite/helpdesk-widget-sdk 1.0.3 → 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.js CHANGED
@@ -562,7 +562,7 @@ class IframeManager {
562
562
  container.setAttribute('data-state', 'closed');
563
563
  // Apply different styles for mobile vs desktop
564
564
  if (this.deviceInfo.isMobile) {
565
- // Mobile: full-screen
565
+ // Mobile: full-screen with dynamic viewport height to handle URL bar
566
566
  container.style.cssText = `
567
567
  position: fixed;
568
568
  top: 0;
@@ -570,6 +570,7 @@ class IframeManager {
570
570
  right: 0;
571
571
  bottom: 0;
572
572
  width: 100vw;
573
+ height: 100dvh;
573
574
  height: 100vh;
574
575
  z-index: 2147483001;
575
576
  pointer-events: none;
@@ -578,6 +579,10 @@ class IframeManager {
578
579
  overflow: hidden;
579
580
  background: transparent;
580
581
  `;
582
+ // Use visualViewport API for accurate height on mobile browsers
583
+ if (window.visualViewport) {
584
+ container.style.height = `${window.visualViewport.height}px`;
585
+ }
581
586
  }
582
587
  else {
583
588
  // Desktop: positioned widget
@@ -693,6 +698,11 @@ class IframeManager {
693
698
  window.addEventListener('resize', this.handleResize.bind(this));
694
699
  // Orientation change
695
700
  window.addEventListener('orientationchange', this.handleOrientationChange.bind(this));
701
+ // Visual viewport resize (handles mobile URL bar and keyboard)
702
+ if (window.visualViewport) {
703
+ window.visualViewport.addEventListener('resize', this.handleVisualViewportResize.bind(this));
704
+ window.visualViewport.addEventListener('scroll', this.handleVisualViewportResize.bind(this));
705
+ }
696
706
  this.logger.debug('Event listeners setup');
697
707
  }
698
708
  /**
@@ -709,6 +719,21 @@ class IframeManager {
709
719
  this.deviceInfo = detectDevice();
710
720
  this.logger.debug('Orientation changed', { orientation: this.deviceInfo.orientation });
711
721
  }
722
+ /**
723
+ * Handle visual viewport resize (mobile URL bar, keyboard)
724
+ */
725
+ handleVisualViewportResize() {
726
+ if (!this.deviceInfo.isMobile || !window.visualViewport)
727
+ return;
728
+ const widget = this.iframes.get(exports.IframeType.WIDGET);
729
+ if (widget && widget.visible) {
730
+ const vh = window.visualViewport.height;
731
+ const offsetTop = window.visualViewport.offsetTop;
732
+ widget.container.style.height = `${vh}px`;
733
+ widget.container.style.top = `${offsetTop}px`;
734
+ this.logger.debug('Visual viewport resized', { height: vh, offsetTop });
735
+ }
736
+ }
712
737
  /**
713
738
  * Get iframe by type
714
739
  */
@@ -766,6 +791,18 @@ class IframeManager {
766
791
  if (this.deviceInfo.isMobile && type === exports.IframeType.WIDGET && this.config.mobile.scrollLock) {
767
792
  document.body.classList.add('weld-mobile-open');
768
793
  }
794
+ // Hide launcher on mobile when widget is open (full-screen mode)
795
+ if (this.deviceInfo.isMobile && type === exports.IframeType.WIDGET) {
796
+ const launcher = this.iframes.get(exports.IframeType.LAUNCHER);
797
+ if (launcher) {
798
+ launcher.container.style.display = 'none';
799
+ }
800
+ // Apply accurate viewport height using visualViewport API
801
+ if (window.visualViewport) {
802
+ iframe.container.style.height = `${window.visualViewport.height}px`;
803
+ iframe.container.style.top = `${window.visualViewport.offsetTop}px`;
804
+ }
805
+ }
769
806
  console.log(`[Weld SDK] Iframe ${type} shown`, { newDisplay: iframe.container.style.display });
770
807
  }
771
808
  /**
@@ -786,6 +823,13 @@ class IframeManager {
786
823
  if (this.deviceInfo.isMobile && type === exports.IframeType.WIDGET) {
787
824
  document.body.classList.remove('weld-mobile-open');
788
825
  }
826
+ // Show launcher again on mobile when widget is closed
827
+ if (this.deviceInfo.isMobile && type === exports.IframeType.WIDGET) {
828
+ const launcher = this.iframes.get(exports.IframeType.LAUNCHER);
829
+ if (launcher) {
830
+ launcher.container.style.display = 'block';
831
+ }
832
+ }
789
833
  console.log(`[Weld SDK] Iframe ${type} hidden`, { newDisplay: iframe.container.style.display });
790
834
  }
791
835
  /**
@@ -2182,7 +2226,7 @@ class StateCoordinator {
2182
2226
  }
2183
2227
  }
2184
2228
 
2185
- var version = "1.0.3";
2229
+ var version = "1.0.4";
2186
2230
  var packageJson = {
2187
2231
  version: version};
2188
2232