dockview-react 4.2.3 → 4.2.5

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.
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * dockview-react
3
- * @version 4.2.3
3
+ * @version 4.2.5
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -642,6 +642,42 @@
642
642
  }));
643
643
  return disposable;
644
644
  }
645
+ function shiftAbsoluteElementIntoView(element, root, options = { buffer: 10 }) {
646
+ const buffer = options.buffer;
647
+ const rect = element.getBoundingClientRect();
648
+ const rootRect = root.getBoundingClientRect();
649
+ let translateX = 0;
650
+ let translateY = 0;
651
+ const left = rect.left - rootRect.left;
652
+ const top = rect.top - rootRect.top;
653
+ const bottom = rect.bottom - rootRect.bottom;
654
+ const right = rect.right - rootRect.right;
655
+ // Check horizontal overflow
656
+ if (left < buffer) {
657
+ translateX = buffer - left;
658
+ }
659
+ else if (right > buffer) {
660
+ translateX = -buffer - right;
661
+ }
662
+ // Check vertical overflow
663
+ if (top < buffer) {
664
+ translateY = buffer - top;
665
+ }
666
+ else if (bottom > buffer) {
667
+ translateY = -bottom - buffer;
668
+ }
669
+ // Apply the translation if needed
670
+ if (translateX !== 0 || translateY !== 0) {
671
+ element.style.transform = `translate(${translateX}px, ${translateY}px)`;
672
+ }
673
+ }
674
+ function findRelativeZIndexParent(el) {
675
+ let tmp = el;
676
+ while (tmp && (tmp.style.zIndex === 'auto' || tmp.style.zIndex === '')) {
677
+ tmp = tmp.parentElement;
678
+ }
679
+ return tmp;
680
+ }
645
681
 
646
682
  function tail(arr) {
647
683
  if (arr.length === 0) {
@@ -4909,6 +4945,8 @@
4909
4945
  var _a, _b;
4910
4946
  // class dockview provides to force ghost image to be drawn on a different layer and prevent weird rendering issues
4911
4947
  addClasses(ghostElement, 'dv-dragged');
4948
+ // move the element off-screen initially otherwise it may in some cases be rendered at (0,0) momentarily
4949
+ ghostElement.style.top = '-9999px';
4912
4950
  document.body.appendChild(ghostElement);
4913
4951
  dataTransfer.setDragImage(ghostElement, (_a = options === null || options === void 0 ? void 0 : options.x) !== null && _a !== void 0 ? _a : 0, (_b = options === null || options === void 0 ? void 0 : options.y) !== null && _b !== void 0 ? _b : 0);
4914
4952
  setTimeout(() => {
@@ -5609,7 +5647,7 @@
5609
5647
  toggleClass(wrapper, 'dv-tab', true);
5610
5648
  toggleClass(wrapper, 'dv-active-tab', panelObject.api.isActive);
5611
5649
  toggleClass(wrapper, 'dv-inactive-tab', !panelObject.api.isActive);
5612
- wrapper.addEventListener('mousedown', () => {
5650
+ wrapper.addEventListener('pointerdown', () => {
5613
5651
  this.accessor.popupService.close();
5614
5652
  tab.element.scrollIntoView();
5615
5653
  tab.panel.api.setActive();
@@ -5617,9 +5655,13 @@
5617
5655
  wrapper.appendChild(child);
5618
5656
  el.appendChild(wrapper);
5619
5657
  }
5658
+ const relativeParent = findRelativeZIndexParent(root);
5620
5659
  this.accessor.popupService.openPopover(el, {
5621
5660
  x: event.clientX,
5622
5661
  y: event.clientY,
5662
+ zIndex: (relativeParent === null || relativeParent === void 0 ? void 0 : relativeParent.style.zIndex)
5663
+ ? `calc(${relativeParent.style.zIndex} * 2)`
5664
+ : undefined,
5623
5665
  });
5624
5666
  }));
5625
5667
  }
@@ -7961,10 +8003,11 @@
7961
8003
  }), this._activeDisposable);
7962
8004
  }
7963
8005
  openPopover(element, position) {
8006
+ var _a;
7964
8007
  this.close();
7965
8008
  const wrapper = document.createElement('div');
7966
8009
  wrapper.style.position = 'absolute';
7967
- wrapper.style.zIndex = '99';
8010
+ wrapper.style.zIndex = (_a = position.zIndex) !== null && _a !== void 0 ? _a : 'var(--dv-overlay-z-index)';
7968
8011
  wrapper.appendChild(element);
7969
8012
  const anchorBox = this._element.getBoundingClientRect();
7970
8013
  const offsetX = anchorBox.left;
@@ -7988,6 +8031,9 @@
7988
8031
  }
7989
8032
  this.close();
7990
8033
  }));
8034
+ requestAnimationFrame(() => {
8035
+ shiftAbsoluteElementIntoView(wrapper, this.root);
8036
+ });
7991
8037
  }
7992
8038
  close() {
7993
8039
  if (this._active) {
@@ -9521,24 +9567,26 @@
9521
9567
  selectedPopoutGroup.disposable.dispose();
9522
9568
  }
9523
9569
  }
9524
- const referenceLocation = getGridLocation(to.element);
9525
- const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, target);
9526
- let size;
9527
- switch (this.gridview.orientation) {
9528
- case exports.Orientation.VERTICAL:
9529
- size =
9530
- referenceLocation.length % 2 == 0
9531
- ? from.api.width
9532
- : from.api.height;
9533
- break;
9534
- case exports.Orientation.HORIZONTAL:
9535
- size =
9536
- referenceLocation.length % 2 == 0
9537
- ? from.api.height
9538
- : from.api.width;
9539
- break;
9570
+ if (from.api.location.type !== 'popout') {
9571
+ const referenceLocation = getGridLocation(to.element);
9572
+ const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, target);
9573
+ let size;
9574
+ switch (this.gridview.orientation) {
9575
+ case exports.Orientation.VERTICAL:
9576
+ size =
9577
+ referenceLocation.length % 2 == 0
9578
+ ? from.api.width
9579
+ : from.api.height;
9580
+ break;
9581
+ case exports.Orientation.HORIZONTAL:
9582
+ size =
9583
+ referenceLocation.length % 2 == 0
9584
+ ? from.api.height
9585
+ : from.api.width;
9586
+ break;
9587
+ }
9588
+ this.gridview.addView(from, size, dropLocation);
9540
9589
  }
9541
- this.gridview.addView(from, size, dropLocation);
9542
9590
  }
9543
9591
  from.panels.forEach((panel) => {
9544
9592
  this._onDidMovePanel.fire({ panel, from });