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