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
  */
@@ -638,6 +638,44 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
638
638
  }));
639
639
  return disposable;
640
640
  }
641
+ function shiftAbsoluteElementIntoView(element, root, options = { buffer: 10 }) {
642
+ const buffer = options.buffer;
643
+ const rect = element.getBoundingClientRect();
644
+ const rootRect = element.getBoundingClientRect();
645
+ const viewportWidth = root.clientWidth;
646
+ const viewportHeight = root.clientHeight;
647
+ let translateX = 0;
648
+ let translateY = 0;
649
+ const left = rect.left - rootRect.left;
650
+ const top = rect.top - rootRect.top;
651
+ const bottom = rect.bottom - rootRect.bottom;
652
+ const right = rect.right - rootRect.right;
653
+ // Check horizontal overflow
654
+ if (left < buffer) {
655
+ translateX = buffer - left;
656
+ }
657
+ else if (right > viewportWidth - buffer) {
658
+ translateX = viewportWidth - right - buffer;
659
+ }
660
+ // Check vertical overflow
661
+ if (top < buffer) {
662
+ translateY = buffer - top;
663
+ }
664
+ else if (bottom > viewportHeight - buffer) {
665
+ translateY = viewportHeight - bottom - buffer;
666
+ }
667
+ // Apply the translation if needed
668
+ if (translateX !== 0 || translateY !== 0) {
669
+ element.style.transform = `translate(${translateX}px, ${translateY}px)`;
670
+ }
671
+ }
672
+ function findRelativeZIndexParent(el) {
673
+ let tmp = el;
674
+ while (tmp && (tmp.style.zIndex === 'auto' || tmp.style.zIndex === '')) {
675
+ tmp = tmp.parentElement;
676
+ }
677
+ return tmp;
678
+ }
641
679
 
642
680
  function tail(arr) {
643
681
  if (arr.length === 0) {
@@ -5605,7 +5643,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5605
5643
  toggleClass(wrapper, 'dv-tab', true);
5606
5644
  toggleClass(wrapper, 'dv-active-tab', panelObject.api.isActive);
5607
5645
  toggleClass(wrapper, 'dv-inactive-tab', !panelObject.api.isActive);
5608
- wrapper.addEventListener('mousedown', () => {
5646
+ wrapper.addEventListener('pointerdown', () => {
5609
5647
  this.accessor.popupService.close();
5610
5648
  tab.element.scrollIntoView();
5611
5649
  tab.panel.api.setActive();
@@ -5613,9 +5651,13 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5613
5651
  wrapper.appendChild(child);
5614
5652
  el.appendChild(wrapper);
5615
5653
  }
5654
+ const relativeParent = findRelativeZIndexParent(root);
5616
5655
  this.accessor.popupService.openPopover(el, {
5617
5656
  x: event.clientX,
5618
5657
  y: event.clientY,
5658
+ zIndex: (relativeParent === null || relativeParent === void 0 ? void 0 : relativeParent.style.zIndex)
5659
+ ? `calc(${relativeParent.style.zIndex} * 2)`
5660
+ : undefined,
5619
5661
  });
5620
5662
  }));
5621
5663
  }
@@ -7957,10 +7999,11 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7957
7999
  }), this._activeDisposable);
7958
8000
  }
7959
8001
  openPopover(element, position) {
8002
+ var _a;
7960
8003
  this.close();
7961
8004
  const wrapper = document.createElement('div');
7962
8005
  wrapper.style.position = 'absolute';
7963
- wrapper.style.zIndex = '99';
8006
+ wrapper.style.zIndex = (_a = position.zIndex) !== null && _a !== void 0 ? _a : 'var(--dv-overlay-z-index)';
7964
8007
  wrapper.appendChild(element);
7965
8008
  const anchorBox = this._element.getBoundingClientRect();
7966
8009
  const offsetX = anchorBox.left;
@@ -7984,6 +8027,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7984
8027
  }
7985
8028
  this.close();
7986
8029
  }));
8030
+ requestAnimationFrame(() => {
8031
+ shiftAbsoluteElementIntoView(wrapper, this.root);
8032
+ });
7987
8033
  }
7988
8034
  close() {
7989
8035
  if (this._active) {
@@ -9517,24 +9563,26 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
9517
9563
  selectedPopoutGroup.disposable.dispose();
9518
9564
  }
9519
9565
  }
9520
- const referenceLocation = getGridLocation(to.element);
9521
- const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, target);
9522
- let size;
9523
- switch (this.gridview.orientation) {
9524
- case exports.Orientation.VERTICAL:
9525
- size =
9526
- referenceLocation.length % 2 == 0
9527
- ? from.api.width
9528
- : from.api.height;
9529
- break;
9530
- case exports.Orientation.HORIZONTAL:
9531
- size =
9532
- referenceLocation.length % 2 == 0
9533
- ? from.api.height
9534
- : from.api.width;
9535
- break;
9566
+ if (from.api.location.type !== 'popout') {
9567
+ const referenceLocation = getGridLocation(to.element);
9568
+ const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, target);
9569
+ let size;
9570
+ switch (this.gridview.orientation) {
9571
+ case exports.Orientation.VERTICAL:
9572
+ size =
9573
+ referenceLocation.length % 2 == 0
9574
+ ? from.api.width
9575
+ : from.api.height;
9576
+ break;
9577
+ case exports.Orientation.HORIZONTAL:
9578
+ size =
9579
+ referenceLocation.length % 2 == 0
9580
+ ? from.api.height
9581
+ : from.api.width;
9582
+ break;
9583
+ }
9584
+ this.gridview.addView(from, size, dropLocation);
9536
9585
  }
9537
- this.gridview.addView(from, size, dropLocation);
9538
9586
  }
9539
9587
  from.panels.forEach((panel) => {
9540
9588
  this._onDidMovePanel.fire({ panel, from });
@@ -11111,6 +11159,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
11111
11159
  }
11112
11160
  dockviewRef.current = api;
11113
11161
  return () => {
11162
+ dockviewRef.current = undefined;
11114
11163
  api.dispose();
11115
11164
  };
11116
11165
  }, []);
@@ -11346,6 +11395,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
11346
11395
  }
11347
11396
  splitviewRef.current = api;
11348
11397
  return () => {
11398
+ splitviewRef.current = undefined;
11349
11399
  api.dispose();
11350
11400
  };
11351
11401
  }, []);
@@ -11429,6 +11479,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
11429
11479
  }
11430
11480
  gridviewRef.current = api;
11431
11481
  return () => {
11482
+ gridviewRef.current = undefined;
11432
11483
  api.dispose();
11433
11484
  };
11434
11485
  }, []);
@@ -11534,6 +11585,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
11534
11585
  }
11535
11586
  paneviewRef.current = api;
11536
11587
  return () => {
11588
+ paneviewRef.current = undefined;
11537
11589
  api.dispose();
11538
11590
  };
11539
11591
  }, []);