@weldsuite/helpdesk-widget-sdk 1.0.2 → 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.
@@ -618,20 +618,47 @@ class IframeManager {
618
618
  const container = document.createElement('div');
619
619
  container.className = 'weld-widget-frame';
620
620
  container.setAttribute('data-state', 'closed');
621
- container.style.cssText = `
622
- position: fixed;
623
- bottom: ${widget.position.bottom};
624
- right: ${widget.position.right};
625
- width: ${widget.width};
626
- height: ${widget.height};
627
- max-width: 100vw;
628
- z-index: 2147483001;
629
- pointer-events: none;
630
- display: none;
631
- border-radius: 16px;
632
- overflow: hidden;
633
- background: transparent;
634
- `;
621
+ // Apply different styles for mobile vs desktop
622
+ if (this.deviceInfo.isMobile) {
623
+ // Mobile: full-screen with dynamic viewport height to handle URL bar
624
+ container.style.cssText = `
625
+ position: fixed;
626
+ top: 0;
627
+ left: 0;
628
+ right: 0;
629
+ bottom: 0;
630
+ width: 100vw;
631
+ height: 100dvh;
632
+ height: 100vh;
633
+ z-index: 2147483001;
634
+ pointer-events: none;
635
+ display: none;
636
+ border-radius: 0;
637
+ overflow: hidden;
638
+ background: transparent;
639
+ `;
640
+ // Use visualViewport API for accurate height on mobile browsers
641
+ if (window.visualViewport) {
642
+ container.style.height = `${window.visualViewport.height}px`;
643
+ }
644
+ }
645
+ else {
646
+ // Desktop: positioned widget
647
+ container.style.cssText = `
648
+ position: fixed;
649
+ bottom: ${widget.position.bottom};
650
+ right: ${widget.position.right};
651
+ width: ${widget.width};
652
+ height: ${widget.height};
653
+ max-width: 100vw;
654
+ z-index: 2147483001;
655
+ pointer-events: none;
656
+ display: none;
657
+ border-radius: 16px;
658
+ overflow: hidden;
659
+ background: transparent;
660
+ `;
661
+ }
635
662
  // Create iframe
636
663
  const iframe = document.createElement('iframe');
637
664
  iframe.name = widget.name;
@@ -643,7 +670,7 @@ class IframeManager {
643
670
  border: none;
644
671
  background: transparent;
645
672
  display: block;
646
- border-radius: 16px;
673
+ border-radius: ${this.deviceInfo.isMobile ? '0' : '16px'};
647
674
  `;
648
675
  iframe.setAttribute('allow', 'clipboard-write; camera; microphone');
649
676
  iframe.setAttribute('sandbox', 'allow-scripts allow-same-origin allow-forms allow-popups allow-downloads');
@@ -729,6 +756,11 @@ class IframeManager {
729
756
  window.addEventListener('resize', this.handleResize.bind(this));
730
757
  // Orientation change
731
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
+ }
732
764
  this.logger.debug('Event listeners setup');
733
765
  }
734
766
  /**
@@ -745,6 +777,21 @@ class IframeManager {
745
777
  this.deviceInfo = detectDevice();
746
778
  this.logger.debug('Orientation changed', { orientation: this.deviceInfo.orientation });
747
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
+ }
748
795
  /**
749
796
  * Get iframe by type
750
797
  */
@@ -802,6 +849,18 @@ class IframeManager {
802
849
  if (this.deviceInfo.isMobile && type === IframeType.WIDGET && this.config.mobile.scrollLock) {
803
850
  document.body.classList.add('weld-mobile-open');
804
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
+ }
805
864
  console.log(`[Weld SDK] Iframe ${type} shown`, { newDisplay: iframe.container.style.display });
806
865
  }
807
866
  /**
@@ -822,6 +881,13 @@ class IframeManager {
822
881
  if (this.deviceInfo.isMobile && type === IframeType.WIDGET) {
823
882
  document.body.classList.remove('weld-mobile-open');
824
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
+ }
825
891
  console.log(`[Weld SDK] Iframe ${type} hidden`, { newDisplay: iframe.container.style.display });
826
892
  }
827
893
  /**
@@ -2009,7 +2075,7 @@ class StateCoordinator {
2009
2075
  }
2010
2076
  }
2011
2077
 
2012
- var version = "1.0.2";
2078
+ var version = "1.0.4";
2013
2079
  var packageJson = {
2014
2080
  version: version};
2015
2081