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
  */
@@ -638,6 +638,42 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
638
638
  }));
639
639
  return disposable;
640
640
  }
641
+ function shiftAbsoluteElementIntoView(element, root, options = { buffer: 10 }) {
642
+ const buffer = options.buffer;
643
+ const rect = element.getBoundingClientRect();
644
+ const rootRect = root.getBoundingClientRect();
645
+ let translateX = 0;
646
+ let translateY = 0;
647
+ const left = rect.left - rootRect.left;
648
+ const top = rect.top - rootRect.top;
649
+ const bottom = rect.bottom - rootRect.bottom;
650
+ const right = rect.right - rootRect.right;
651
+ // Check horizontal overflow
652
+ if (left < buffer) {
653
+ translateX = buffer - left;
654
+ }
655
+ else if (right > buffer) {
656
+ translateX = -buffer - right;
657
+ }
658
+ // Check vertical overflow
659
+ if (top < buffer) {
660
+ translateY = buffer - top;
661
+ }
662
+ else if (bottom > buffer) {
663
+ translateY = -bottom - buffer;
664
+ }
665
+ // Apply the translation if needed
666
+ if (translateX !== 0 || translateY !== 0) {
667
+ element.style.transform = `translate(${translateX}px, ${translateY}px)`;
668
+ }
669
+ }
670
+ function findRelativeZIndexParent(el) {
671
+ let tmp = el;
672
+ while (tmp && (tmp.style.zIndex === 'auto' || tmp.style.zIndex === '')) {
673
+ tmp = tmp.parentElement;
674
+ }
675
+ return tmp;
676
+ }
641
677
 
642
678
  function tail(arr) {
643
679
  if (arr.length === 0) {
@@ -4905,6 +4941,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4905
4941
  var _a, _b;
4906
4942
  // class dockview provides to force ghost image to be drawn on a different layer and prevent weird rendering issues
4907
4943
  addClasses(ghostElement, 'dv-dragged');
4944
+ // move the element off-screen initially otherwise it may in some cases be rendered at (0,0) momentarily
4945
+ ghostElement.style.top = '-9999px';
4908
4946
  document.body.appendChild(ghostElement);
4909
4947
  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);
4910
4948
  setTimeout(() => {
@@ -5605,7 +5643,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5605
5643
  toggleClass(wrapper, 'dv-tab', true);
5606
5644
  toggleClass(wrapper, 'dv-active-tab', panelObject.api.isActive);
5607
5645
  toggleClass(wrapper, 'dv-inactive-tab', !panelObject.api.isActive);
5608
- wrapper.addEventListener('mousedown', () => {
5646
+ wrapper.addEventListener('pointerdown', () => {
5609
5647
  this.accessor.popupService.close();
5610
5648
  tab.element.scrollIntoView();
5611
5649
  tab.panel.api.setActive();
@@ -5613,9 +5651,13 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5613
5651
  wrapper.appendChild(child);
5614
5652
  el.appendChild(wrapper);
5615
5653
  }
5654
+ const relativeParent = findRelativeZIndexParent(root);
5616
5655
  this.accessor.popupService.openPopover(el, {
5617
5656
  x: event.clientX,
5618
5657
  y: event.clientY,
5658
+ zIndex: (relativeParent === null || relativeParent === void 0 ? void 0 : relativeParent.style.zIndex)
5659
+ ? `calc(${relativeParent.style.zIndex} * 2)`
5660
+ : undefined,
5619
5661
  });
5620
5662
  }));
5621
5663
  }
@@ -7957,10 +7999,11 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7957
7999
  }), this._activeDisposable);
7958
8000
  }
7959
8001
  openPopover(element, position) {
8002
+ var _a;
7960
8003
  this.close();
7961
8004
  const wrapper = document.createElement('div');
7962
8005
  wrapper.style.position = 'absolute';
7963
- wrapper.style.zIndex = '99';
8006
+ wrapper.style.zIndex = (_a = position.zIndex) !== null && _a !== void 0 ? _a : 'var(--dv-overlay-z-index)';
7964
8007
  wrapper.appendChild(element);
7965
8008
  const anchorBox = this._element.getBoundingClientRect();
7966
8009
  const offsetX = anchorBox.left;
@@ -7984,6 +8027,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7984
8027
  }
7985
8028
  this.close();
7986
8029
  }));
8030
+ requestAnimationFrame(() => {
8031
+ shiftAbsoluteElementIntoView(wrapper, this.root);
8032
+ });
7987
8033
  }
7988
8034
  close() {
7989
8035
  if (this._active) {
@@ -9517,24 +9563,26 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
9517
9563
  selectedPopoutGroup.disposable.dispose();
9518
9564
  }
9519
9565
  }
9520
- const referenceLocation = getGridLocation(to.element);
9521
- const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, target);
9522
- let size;
9523
- switch (this.gridview.orientation) {
9524
- case exports.Orientation.VERTICAL:
9525
- size =
9526
- referenceLocation.length % 2 == 0
9527
- ? from.api.width
9528
- : from.api.height;
9529
- break;
9530
- case exports.Orientation.HORIZONTAL:
9531
- size =
9532
- referenceLocation.length % 2 == 0
9533
- ? from.api.height
9534
- : from.api.width;
9535
- break;
9566
+ if (from.api.location.type !== 'popout') {
9567
+ const referenceLocation = getGridLocation(to.element);
9568
+ const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, target);
9569
+ let size;
9570
+ switch (this.gridview.orientation) {
9571
+ case exports.Orientation.VERTICAL:
9572
+ size =
9573
+ referenceLocation.length % 2 == 0
9574
+ ? from.api.width
9575
+ : from.api.height;
9576
+ break;
9577
+ case exports.Orientation.HORIZONTAL:
9578
+ size =
9579
+ referenceLocation.length % 2 == 0
9580
+ ? from.api.height
9581
+ : from.api.width;
9582
+ break;
9583
+ }
9584
+ this.gridview.addView(from, size, dropLocation);
9536
9585
  }
9537
- this.gridview.addView(from, size, dropLocation);
9538
9586
  }
9539
9587
  from.panels.forEach((panel) => {
9540
9588
  this._onDidMovePanel.fire({ panel, from });