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