@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.
@@ -620,7 +620,7 @@ class IframeManager {
620
620
  container.setAttribute('data-state', 'closed');
621
621
  // Apply different styles for mobile vs desktop
622
622
  if (this.deviceInfo.isMobile) {
623
- // Mobile: full-screen
623
+ // Mobile: full-screen with dynamic viewport height to handle URL bar
624
624
  container.style.cssText = `
625
625
  position: fixed;
626
626
  top: 0;
@@ -628,6 +628,7 @@ class IframeManager {
628
628
  right: 0;
629
629
  bottom: 0;
630
630
  width: 100vw;
631
+ height: 100dvh;
631
632
  height: 100vh;
632
633
  z-index: 2147483001;
633
634
  pointer-events: none;
@@ -636,6 +637,10 @@ class IframeManager {
636
637
  overflow: hidden;
637
638
  background: transparent;
638
639
  `;
640
+ // Use visualViewport API for accurate height on mobile browsers
641
+ if (window.visualViewport) {
642
+ container.style.height = `${window.visualViewport.height}px`;
643
+ }
639
644
  }
640
645
  else {
641
646
  // Desktop: positioned widget
@@ -751,6 +756,11 @@ class IframeManager {
751
756
  window.addEventListener('resize', this.handleResize.bind(this));
752
757
  // Orientation change
753
758
  window.addEventListener('orientationchange', this.handleOrientationChange.bind(this));
759
+ // Visual viewport resize (handles mobile URL bar and keyboard)
760
+ if (window.visualViewport) {
761
+ window.visualViewport.addEventListener('resize', this.handleVisualViewportResize.bind(this));
762
+ window.visualViewport.addEventListener('scroll', this.handleVisualViewportResize.bind(this));
763
+ }
754
764
  this.logger.debug('Event listeners setup');
755
765
  }
756
766
  /**
@@ -767,6 +777,21 @@ class IframeManager {
767
777
  this.deviceInfo = detectDevice();
768
778
  this.logger.debug('Orientation changed', { orientation: this.deviceInfo.orientation });
769
779
  }
780
+ /**
781
+ * Handle visual viewport resize (mobile URL bar, keyboard)
782
+ */
783
+ handleVisualViewportResize() {
784
+ if (!this.deviceInfo.isMobile || !window.visualViewport)
785
+ return;
786
+ const widget = this.iframes.get(IframeType.WIDGET);
787
+ if (widget && widget.visible) {
788
+ const vh = window.visualViewport.height;
789
+ const offsetTop = window.visualViewport.offsetTop;
790
+ widget.container.style.height = `${vh}px`;
791
+ widget.container.style.top = `${offsetTop}px`;
792
+ this.logger.debug('Visual viewport resized', { height: vh, offsetTop });
793
+ }
794
+ }
770
795
  /**
771
796
  * Get iframe by type
772
797
  */
@@ -824,6 +849,18 @@ class IframeManager {
824
849
  if (this.deviceInfo.isMobile && type === IframeType.WIDGET && this.config.mobile.scrollLock) {
825
850
  document.body.classList.add('weld-mobile-open');
826
851
  }
852
+ // Hide launcher on mobile when widget is open (full-screen mode)
853
+ if (this.deviceInfo.isMobile && type === IframeType.WIDGET) {
854
+ const launcher = this.iframes.get(IframeType.LAUNCHER);
855
+ if (launcher) {
856
+ launcher.container.style.display = 'none';
857
+ }
858
+ // Apply accurate viewport height using visualViewport API
859
+ if (window.visualViewport) {
860
+ iframe.container.style.height = `${window.visualViewport.height}px`;
861
+ iframe.container.style.top = `${window.visualViewport.offsetTop}px`;
862
+ }
863
+ }
827
864
  console.log(`[Weld SDK] Iframe ${type} shown`, { newDisplay: iframe.container.style.display });
828
865
  }
829
866
  /**
@@ -844,6 +881,13 @@ class IframeManager {
844
881
  if (this.deviceInfo.isMobile && type === IframeType.WIDGET) {
845
882
  document.body.classList.remove('weld-mobile-open');
846
883
  }
884
+ // Show launcher again on mobile when widget is closed
885
+ if (this.deviceInfo.isMobile && type === IframeType.WIDGET) {
886
+ const launcher = this.iframes.get(IframeType.LAUNCHER);
887
+ if (launcher) {
888
+ launcher.container.style.display = 'block';
889
+ }
890
+ }
847
891
  console.log(`[Weld SDK] Iframe ${type} hidden`, { newDisplay: iframe.container.style.display });
848
892
  }
849
893
  /**
@@ -2031,7 +2075,7 @@ class StateCoordinator {
2031
2075
  }
2032
2076
  }
2033
2077
 
2034
- var version = "1.0.3";
2078
+ var version = "1.0.4";
2035
2079
  var packageJson = {
2036
2080
  version: version};
2037
2081