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