@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/react.js CHANGED
@@ -564,7 +564,7 @@ class IframeManager {
564
564
  container.setAttribute('data-state', 'closed');
565
565
  // Apply different styles for mobile vs desktop
566
566
  if (this.deviceInfo.isMobile) {
567
- // Mobile: full-screen
567
+ // Mobile: full-screen with dynamic viewport height to handle URL bar
568
568
  container.style.cssText = `
569
569
  position: fixed;
570
570
  top: 0;
@@ -572,6 +572,7 @@ class IframeManager {
572
572
  right: 0;
573
573
  bottom: 0;
574
574
  width: 100vw;
575
+ height: 100dvh;
575
576
  height: 100vh;
576
577
  z-index: 2147483001;
577
578
  pointer-events: none;
@@ -580,6 +581,10 @@ class IframeManager {
580
581
  overflow: hidden;
581
582
  background: transparent;
582
583
  `;
584
+ // Use visualViewport API for accurate height on mobile browsers
585
+ if (window.visualViewport) {
586
+ container.style.height = `${window.visualViewport.height}px`;
587
+ }
583
588
  }
584
589
  else {
585
590
  // Desktop: positioned widget
@@ -695,6 +700,11 @@ class IframeManager {
695
700
  window.addEventListener('resize', this.handleResize.bind(this));
696
701
  // Orientation change
697
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
+ }
698
708
  this.logger.debug('Event listeners setup');
699
709
  }
700
710
  /**
@@ -711,6 +721,21 @@ class IframeManager {
711
721
  this.deviceInfo = detectDevice();
712
722
  this.logger.debug('Orientation changed', { orientation: this.deviceInfo.orientation });
713
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(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
+ }
714
739
  /**
715
740
  * Get iframe by type
716
741
  */
@@ -768,6 +793,18 @@ class IframeManager {
768
793
  if (this.deviceInfo.isMobile && type === IframeType.WIDGET && this.config.mobile.scrollLock) {
769
794
  document.body.classList.add('weld-mobile-open');
770
795
  }
796
+ // Hide launcher on mobile when widget is open (full-screen mode)
797
+ if (this.deviceInfo.isMobile && type === IframeType.WIDGET) {
798
+ const launcher = this.iframes.get(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
+ }
771
808
  console.log(`[Weld SDK] Iframe ${type} shown`, { newDisplay: iframe.container.style.display });
772
809
  }
773
810
  /**
@@ -788,6 +825,13 @@ class IframeManager {
788
825
  if (this.deviceInfo.isMobile && type === IframeType.WIDGET) {
789
826
  document.body.classList.remove('weld-mobile-open');
790
827
  }
828
+ // Show launcher again on mobile when widget is closed
829
+ if (this.deviceInfo.isMobile && type === IframeType.WIDGET) {
830
+ const launcher = this.iframes.get(IframeType.LAUNCHER);
831
+ if (launcher) {
832
+ launcher.container.style.display = 'block';
833
+ }
834
+ }
791
835
  console.log(`[Weld SDK] Iframe ${type} hidden`, { newDisplay: iframe.container.style.display });
792
836
  }
793
837
  /**
@@ -1975,7 +2019,7 @@ class StateCoordinator {
1975
2019
  }
1976
2020
  }
1977
2021
 
1978
- var version = "1.0.3";
2022
+ var version = "1.0.4";
1979
2023
  var packageJson = {
1980
2024
  version: version};
1981
2025