dockview-react 4.2.1 → 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.1
3
+ * @version 4.2.4
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -642,6 +642,44 @@
642
642
  }));
643
643
  return disposable;
644
644
  }
645
+ function shiftAbsoluteElementIntoView(element, root, options = { buffer: 10 }) {
646
+ const buffer = options.buffer;
647
+ const rect = element.getBoundingClientRect();
648
+ const rootRect = element.getBoundingClientRect();
649
+ const viewportWidth = root.clientWidth;
650
+ const viewportHeight = root.clientHeight;
651
+ let translateX = 0;
652
+ let translateY = 0;
653
+ const left = rect.left - rootRect.left;
654
+ const top = rect.top - rootRect.top;
655
+ const bottom = rect.bottom - rootRect.bottom;
656
+ const right = rect.right - rootRect.right;
657
+ // Check horizontal overflow
658
+ if (left < buffer) {
659
+ translateX = buffer - left;
660
+ }
661
+ else if (right > viewportWidth - buffer) {
662
+ translateX = viewportWidth - right - buffer;
663
+ }
664
+ // Check vertical overflow
665
+ if (top < buffer) {
666
+ translateY = buffer - top;
667
+ }
668
+ else if (bottom > viewportHeight - buffer) {
669
+ translateY = viewportHeight - bottom - buffer;
670
+ }
671
+ // Apply the translation if needed
672
+ if (translateX !== 0 || translateY !== 0) {
673
+ element.style.transform = `translate(${translateX}px, ${translateY}px)`;
674
+ }
675
+ }
676
+ function findRelativeZIndexParent(el) {
677
+ let tmp = el;
678
+ while (tmp && (tmp.style.zIndex === 'auto' || tmp.style.zIndex === '')) {
679
+ tmp = tmp.parentElement;
680
+ }
681
+ return tmp;
682
+ }
645
683
 
646
684
  function tail(arr) {
647
685
  if (arr.length === 0) {
@@ -5609,7 +5647,7 @@
5609
5647
  toggleClass(wrapper, 'dv-tab', true);
5610
5648
  toggleClass(wrapper, 'dv-active-tab', panelObject.api.isActive);
5611
5649
  toggleClass(wrapper, 'dv-inactive-tab', !panelObject.api.isActive);
5612
- wrapper.addEventListener('mousedown', () => {
5650
+ wrapper.addEventListener('pointerdown', () => {
5613
5651
  this.accessor.popupService.close();
5614
5652
  tab.element.scrollIntoView();
5615
5653
  tab.panel.api.setActive();
@@ -5617,9 +5655,13 @@
5617
5655
  wrapper.appendChild(child);
5618
5656
  el.appendChild(wrapper);
5619
5657
  }
5658
+ const relativeParent = findRelativeZIndexParent(root);
5620
5659
  this.accessor.popupService.openPopover(el, {
5621
5660
  x: event.clientX,
5622
5661
  y: event.clientY,
5662
+ zIndex: (relativeParent === null || relativeParent === void 0 ? void 0 : relativeParent.style.zIndex)
5663
+ ? `calc(${relativeParent.style.zIndex} * 2)`
5664
+ : undefined,
5623
5665
  });
5624
5666
  }));
5625
5667
  }
@@ -7961,10 +8003,11 @@
7961
8003
  }), this._activeDisposable);
7962
8004
  }
7963
8005
  openPopover(element, position) {
8006
+ var _a;
7964
8007
  this.close();
7965
8008
  const wrapper = document.createElement('div');
7966
8009
  wrapper.style.position = 'absolute';
7967
- wrapper.style.zIndex = '99';
8010
+ wrapper.style.zIndex = (_a = position.zIndex) !== null && _a !== void 0 ? _a : 'var(--dv-overlay-z-index)';
7968
8011
  wrapper.appendChild(element);
7969
8012
  const anchorBox = this._element.getBoundingClientRect();
7970
8013
  const offsetX = anchorBox.left;
@@ -7988,6 +8031,9 @@
7988
8031
  }
7989
8032
  this.close();
7990
8033
  }));
8034
+ requestAnimationFrame(() => {
8035
+ shiftAbsoluteElementIntoView(wrapper, this.root);
8036
+ });
7991
8037
  }
7992
8038
  close() {
7993
8039
  if (this._active) {
@@ -9521,24 +9567,26 @@
9521
9567
  selectedPopoutGroup.disposable.dispose();
9522
9568
  }
9523
9569
  }
9524
- const referenceLocation = getGridLocation(to.element);
9525
- const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, target);
9526
- let size;
9527
- switch (this.gridview.orientation) {
9528
- case exports.Orientation.VERTICAL:
9529
- size =
9530
- referenceLocation.length % 2 == 0
9531
- ? from.api.width
9532
- : from.api.height;
9533
- break;
9534
- case exports.Orientation.HORIZONTAL:
9535
- size =
9536
- referenceLocation.length % 2 == 0
9537
- ? from.api.height
9538
- : from.api.width;
9539
- break;
9570
+ if (from.api.location.type !== 'popout') {
9571
+ const referenceLocation = getGridLocation(to.element);
9572
+ const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, target);
9573
+ let size;
9574
+ switch (this.gridview.orientation) {
9575
+ case exports.Orientation.VERTICAL:
9576
+ size =
9577
+ referenceLocation.length % 2 == 0
9578
+ ? from.api.width
9579
+ : from.api.height;
9580
+ break;
9581
+ case exports.Orientation.HORIZONTAL:
9582
+ size =
9583
+ referenceLocation.length % 2 == 0
9584
+ ? from.api.height
9585
+ : from.api.width;
9586
+ break;
9587
+ }
9588
+ this.gridview.addView(from, size, dropLocation);
9540
9589
  }
9541
- this.gridview.addView(from, size, dropLocation);
9542
9590
  }
9543
9591
  from.panels.forEach((panel) => {
9544
9592
  this._onDidMovePanel.fire({ panel, from });
@@ -11115,6 +11163,7 @@
11115
11163
  }
11116
11164
  dockviewRef.current = api;
11117
11165
  return () => {
11166
+ dockviewRef.current = undefined;
11118
11167
  api.dispose();
11119
11168
  };
11120
11169
  }, []);
@@ -11350,6 +11399,7 @@
11350
11399
  }
11351
11400
  splitviewRef.current = api;
11352
11401
  return () => {
11402
+ splitviewRef.current = undefined;
11353
11403
  api.dispose();
11354
11404
  };
11355
11405
  }, []);
@@ -11433,6 +11483,7 @@
11433
11483
  }
11434
11484
  gridviewRef.current = api;
11435
11485
  return () => {
11486
+ gridviewRef.current = undefined;
11436
11487
  api.dispose();
11437
11488
  };
11438
11489
  }, []);
@@ -11538,6 +11589,7 @@
11538
11589
  }
11539
11590
  paneviewRef.current = api;
11540
11591
  return () => {
11592
+ paneviewRef.current = undefined;
11541
11593
  api.dispose();
11542
11594
  };
11543
11595
  }, []);