@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.
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
@@ -556,20 +556,47 @@ class IframeManager {
556
556
  const container = document.createElement('div');
557
557
  container.className = 'weld-widget-frame';
558
558
  container.setAttribute('data-state', 'closed');
559
- container.style.cssText = `
560
- position: fixed;
561
- bottom: ${widget.position.bottom};
562
- right: ${widget.position.right};
563
- width: ${widget.width};
564
- height: ${widget.height};
565
- max-width: 100vw;
566
- z-index: 2147483001;
567
- pointer-events: none;
568
- display: none;
569
- border-radius: 16px;
570
- overflow: hidden;
571
- background: transparent;
572
- `;
559
+ // Apply different styles for mobile vs desktop
560
+ if (this.deviceInfo.isMobile) {
561
+ // Mobile: full-screen with dynamic viewport height to handle URL bar
562
+ container.style.cssText = `
563
+ position: fixed;
564
+ top: 0;
565
+ left: 0;
566
+ right: 0;
567
+ bottom: 0;
568
+ width: 100vw;
569
+ height: 100dvh;
570
+ height: 100vh;
571
+ z-index: 2147483001;
572
+ pointer-events: none;
573
+ display: none;
574
+ border-radius: 0;
575
+ overflow: hidden;
576
+ background: transparent;
577
+ `;
578
+ // Use visualViewport API for accurate height on mobile browsers
579
+ if (window.visualViewport) {
580
+ container.style.height = `${window.visualViewport.height}px`;
581
+ }
582
+ }
583
+ else {
584
+ // Desktop: positioned widget
585
+ container.style.cssText = `
586
+ position: fixed;
587
+ bottom: ${widget.position.bottom};
588
+ right: ${widget.position.right};
589
+ width: ${widget.width};
590
+ height: ${widget.height};
591
+ max-width: 100vw;
592
+ z-index: 2147483001;
593
+ pointer-events: none;
594
+ display: none;
595
+ border-radius: 16px;
596
+ overflow: hidden;
597
+ background: transparent;
598
+ `;
599
+ }
573
600
  // Create iframe
574
601
  const iframe = document.createElement('iframe');
575
602
  iframe.name = widget.name;
@@ -581,7 +608,7 @@ class IframeManager {
581
608
  border: none;
582
609
  background: transparent;
583
610
  display: block;
584
- border-radius: 16px;
611
+ border-radius: ${this.deviceInfo.isMobile ? '0' : '16px'};
585
612
  `;
586
613
  iframe.setAttribute('allow', 'clipboard-write; camera; microphone');
587
614
  iframe.setAttribute('sandbox', 'allow-scripts allow-same-origin allow-forms allow-popups allow-downloads');
@@ -667,6 +694,11 @@ class IframeManager {
667
694
  window.addEventListener('resize', this.handleResize.bind(this));
668
695
  // Orientation change
669
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
+ }
670
702
  this.logger.debug('Event listeners setup');
671
703
  }
672
704
  /**
@@ -683,6 +715,21 @@ class IframeManager {
683
715
  this.deviceInfo = detectDevice();
684
716
  this.logger.debug('Orientation changed', { orientation: this.deviceInfo.orientation });
685
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
+ }
686
733
  /**
687
734
  * Get iframe by type
688
735
  */
@@ -740,6 +787,18 @@ class IframeManager {
740
787
  if (this.deviceInfo.isMobile && type === IframeType.WIDGET && this.config.mobile.scrollLock) {
741
788
  document.body.classList.add('weld-mobile-open');
742
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
+ }
743
802
  console.log(`[Weld SDK] Iframe ${type} shown`, { newDisplay: iframe.container.style.display });
744
803
  }
745
804
  /**
@@ -760,6 +819,13 @@ class IframeManager {
760
819
  if (this.deviceInfo.isMobile && type === IframeType.WIDGET) {
761
820
  document.body.classList.remove('weld-mobile-open');
762
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
+ }
763
829
  console.log(`[Weld SDK] Iframe ${type} hidden`, { newDisplay: iframe.container.style.display });
764
830
  }
765
831
  /**
@@ -2156,7 +2222,7 @@ class StateCoordinator {
2156
2222
  }
2157
2223
  }
2158
2224
 
2159
- var version = "1.0.2";
2225
+ var version = "1.0.4";
2160
2226
  var packageJson = {
2161
2227
  version: version};
2162
2228