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