dockview-react 4.2.3 → 4.2.4

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.4
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -669,6 +669,44 @@ 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 = element.getBoundingClientRect();
676
+ const viewportWidth = root.clientWidth;
677
+ const viewportHeight = root.clientHeight;
678
+ let translateX = 0;
679
+ let translateY = 0;
680
+ const left = rect.left - rootRect.left;
681
+ const top = rect.top - rootRect.top;
682
+ const bottom = rect.bottom - rootRect.bottom;
683
+ const right = rect.right - rootRect.right;
684
+ // Check horizontal overflow
685
+ if (left < buffer) {
686
+ translateX = buffer - left;
687
+ }
688
+ else if (right > viewportWidth - buffer) {
689
+ translateX = viewportWidth - right - buffer;
690
+ }
691
+ // Check vertical overflow
692
+ if (top < buffer) {
693
+ translateY = buffer - top;
694
+ }
695
+ else if (bottom > viewportHeight - buffer) {
696
+ translateY = viewportHeight - bottom - buffer;
697
+ }
698
+ // Apply the translation if needed
699
+ if (translateX !== 0 || translateY !== 0) {
700
+ element.style.transform = `translate(${translateX}px, ${translateY}px)`;
701
+ }
702
+ }
703
+ function findRelativeZIndexParent(el) {
704
+ let tmp = el;
705
+ while (tmp && (tmp.style.zIndex === 'auto' || tmp.style.zIndex === '')) {
706
+ tmp = tmp.parentElement;
707
+ }
708
+ return tmp;
709
+ }
672
710
 
673
711
  function tail(arr) {
674
712
  if (arr.length === 0) {
@@ -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 });