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