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