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
  */
@@ -669,6 +669,42 @@ function onDidWindowResizeEnd(element, cb) {
669
669
  }));
670
670
  return disposable;
671
671
  }
672
+ function shiftAbsoluteElementIntoView(element, root, options = { buffer: 10 }) {
673
+ const buffer = options.buffer;
674
+ const rect = element.getBoundingClientRect();
675
+ const rootRect = root.getBoundingClientRect();
676
+ let translateX = 0;
677
+ let translateY = 0;
678
+ const left = rect.left - rootRect.left;
679
+ const top = rect.top - rootRect.top;
680
+ const bottom = rect.bottom - rootRect.bottom;
681
+ const right = rect.right - rootRect.right;
682
+ // Check horizontal overflow
683
+ if (left < buffer) {
684
+ translateX = buffer - left;
685
+ }
686
+ else if (right > buffer) {
687
+ translateX = -buffer - right;
688
+ }
689
+ // Check vertical overflow
690
+ if (top < buffer) {
691
+ translateY = buffer - top;
692
+ }
693
+ else if (bottom > buffer) {
694
+ translateY = -bottom - buffer;
695
+ }
696
+ // Apply the translation if needed
697
+ if (translateX !== 0 || translateY !== 0) {
698
+ element.style.transform = `translate(${translateX}px, ${translateY}px)`;
699
+ }
700
+ }
701
+ function findRelativeZIndexParent(el) {
702
+ let tmp = el;
703
+ while (tmp && (tmp.style.zIndex === 'auto' || tmp.style.zIndex === '')) {
704
+ tmp = tmp.parentElement;
705
+ }
706
+ return tmp;
707
+ }
672
708
 
673
709
  function tail(arr) {
674
710
  if (arr.length === 0) {
@@ -4936,6 +4972,8 @@ function addGhostImage(dataTransfer, ghostElement, options) {
4936
4972
  var _a, _b;
4937
4973
  // class dockview provides to force ghost image to be drawn on a different layer and prevent weird rendering issues
4938
4974
  addClasses(ghostElement, 'dv-dragged');
4975
+ // move the element off-screen initially otherwise it may in some cases be rendered at (0,0) momentarily
4976
+ ghostElement.style.top = '-9999px';
4939
4977
  document.body.appendChild(ghostElement);
4940
4978
  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);
4941
4979
  setTimeout(() => {
@@ -5636,7 +5674,7 @@ class TabsContainer extends CompositeDisposable {
5636
5674
  toggleClass(wrapper, 'dv-tab', true);
5637
5675
  toggleClass(wrapper, 'dv-active-tab', panelObject.api.isActive);
5638
5676
  toggleClass(wrapper, 'dv-inactive-tab', !panelObject.api.isActive);
5639
- wrapper.addEventListener('mousedown', () => {
5677
+ wrapper.addEventListener('pointerdown', () => {
5640
5678
  this.accessor.popupService.close();
5641
5679
  tab.element.scrollIntoView();
5642
5680
  tab.panel.api.setActive();
@@ -5644,9 +5682,13 @@ class TabsContainer extends CompositeDisposable {
5644
5682
  wrapper.appendChild(child);
5645
5683
  el.appendChild(wrapper);
5646
5684
  }
5685
+ const relativeParent = findRelativeZIndexParent(root);
5647
5686
  this.accessor.popupService.openPopover(el, {
5648
5687
  x: event.clientX,
5649
5688
  y: event.clientY,
5689
+ zIndex: (relativeParent === null || relativeParent === void 0 ? void 0 : relativeParent.style.zIndex)
5690
+ ? `calc(${relativeParent.style.zIndex} * 2)`
5691
+ : undefined,
5650
5692
  });
5651
5693
  }));
5652
5694
  }
@@ -7988,10 +8030,11 @@ class PopupService extends CompositeDisposable {
7988
8030
  }), this._activeDisposable);
7989
8031
  }
7990
8032
  openPopover(element, position) {
8033
+ var _a;
7991
8034
  this.close();
7992
8035
  const wrapper = document.createElement('div');
7993
8036
  wrapper.style.position = 'absolute';
7994
- wrapper.style.zIndex = '99';
8037
+ wrapper.style.zIndex = (_a = position.zIndex) !== null && _a !== void 0 ? _a : 'var(--dv-overlay-z-index)';
7995
8038
  wrapper.appendChild(element);
7996
8039
  const anchorBox = this._element.getBoundingClientRect();
7997
8040
  const offsetX = anchorBox.left;
@@ -8015,6 +8058,9 @@ class PopupService extends CompositeDisposable {
8015
8058
  }
8016
8059
  this.close();
8017
8060
  }));
8061
+ requestAnimationFrame(() => {
8062
+ shiftAbsoluteElementIntoView(wrapper, this.root);
8063
+ });
8018
8064
  }
8019
8065
  close() {
8020
8066
  if (this._active) {
@@ -9548,24 +9594,26 @@ class DockviewComponent extends BaseGrid {
9548
9594
  selectedPopoutGroup.disposable.dispose();
9549
9595
  }
9550
9596
  }
9551
- const referenceLocation = getGridLocation(to.element);
9552
- const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, target);
9553
- let size;
9554
- switch (this.gridview.orientation) {
9555
- case Orientation.VERTICAL:
9556
- size =
9557
- referenceLocation.length % 2 == 0
9558
- ? from.api.width
9559
- : from.api.height;
9560
- break;
9561
- case Orientation.HORIZONTAL:
9562
- size =
9563
- referenceLocation.length % 2 == 0
9564
- ? from.api.height
9565
- : from.api.width;
9566
- break;
9597
+ if (from.api.location.type !== 'popout') {
9598
+ const referenceLocation = getGridLocation(to.element);
9599
+ const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, target);
9600
+ let size;
9601
+ switch (this.gridview.orientation) {
9602
+ case Orientation.VERTICAL:
9603
+ size =
9604
+ referenceLocation.length % 2 == 0
9605
+ ? from.api.width
9606
+ : from.api.height;
9607
+ break;
9608
+ case Orientation.HORIZONTAL:
9609
+ size =
9610
+ referenceLocation.length % 2 == 0
9611
+ ? from.api.height
9612
+ : from.api.width;
9613
+ break;
9614
+ }
9615
+ this.gridview.addView(from, size, dropLocation);
9567
9616
  }
9568
- this.gridview.addView(from, size, dropLocation);
9569
9617
  }
9570
9618
  from.panels.forEach((panel) => {
9571
9619
  this._onDidMovePanel.fire({ panel, from });