dockview-react 4.12.0 → 4.13.1

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.12.0
3
+ * @version 4.13.1
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -1297,11 +1297,13 @@ class Splitview {
1297
1297
  document.removeEventListener('pointermove', onPointerMove);
1298
1298
  document.removeEventListener('pointerup', end);
1299
1299
  document.removeEventListener('pointercancel', end);
1300
+ document.removeEventListener('contextmenu', end);
1300
1301
  this._onDidSashEnd.fire(undefined);
1301
1302
  };
1302
1303
  document.addEventListener('pointermove', onPointerMove);
1303
1304
  document.addEventListener('pointerup', end);
1304
1305
  document.addEventListener('pointercancel', end);
1306
+ document.addEventListener('contextmenu', end);
1305
1307
  };
1306
1308
  sash.addEventListener('pointerdown', onPointerStart);
1307
1309
  const sashItem = {
@@ -5163,7 +5165,7 @@ class Tab extends CompositeDisposable {
5163
5165
  }
5164
5166
  }
5165
5167
 
5166
- class WillShowOverlayLocationEvent {
5168
+ class DockviewWillShowOverlayLocationEvent {
5167
5169
  get kind() {
5168
5170
  return this.options.kind;
5169
5171
  }
@@ -5511,7 +5513,7 @@ class Tabs extends CompositeDisposable {
5511
5513
  index: this._tabs.findIndex((x) => x.value === tab),
5512
5514
  });
5513
5515
  }), tab.onWillShowOverlay((event) => {
5514
- this._onWillShowOverlay.fire(new WillShowOverlayLocationEvent(event, {
5516
+ this._onWillShowOverlay.fire(new DockviewWillShowOverlayLocationEvent(event, {
5515
5517
  kind: 'tab',
5516
5518
  panel: this.group.activePanel,
5517
5519
  api: this.accessor.api,
@@ -5675,7 +5677,7 @@ class TabsContainer extends CompositeDisposable {
5675
5677
  index: this.tabs.size,
5676
5678
  });
5677
5679
  }), this.voidContainer.onWillShowOverlay((event) => {
5678
- this._onWillShowOverlay.fire(new WillShowOverlayLocationEvent(event, {
5680
+ this._onWillShowOverlay.fire(new DockviewWillShowOverlayLocationEvent(event, {
5679
5681
  kind: 'header_space',
5680
5682
  panel: this.group.activePanel,
5681
5683
  api: this.accessor.api,
@@ -6069,7 +6071,7 @@ class DockviewGroupPanelModel extends CompositeDisposable {
6069
6071
  }), this.tabsContainer.onWillShowOverlay((event) => {
6070
6072
  this._onWillShowOverlay.fire(event);
6071
6073
  }), this.contentContainer.dropTarget.onWillShowOverlay((event) => {
6072
- this._onWillShowOverlay.fire(new WillShowOverlayLocationEvent(event, {
6074
+ this._onWillShowOverlay.fire(new DockviewWillShowOverlayLocationEvent(event, {
6073
6075
  kind: 'content',
6074
6076
  panel: this.activePanel,
6075
6077
  api: this._api,
@@ -6745,7 +6747,19 @@ class DockviewGroupPanelApiImpl extends GridviewPanelApiImpl {
6745
6747
  this.onDidLocationChange = this._onDidLocationChange.event;
6746
6748
  this._onDidActivePanelChange = new Emitter();
6747
6749
  this.onDidActivePanelChange = this._onDidActivePanelChange.event;
6748
- this.addDisposables(this._onDidLocationChange, this._onDidActivePanelChange);
6750
+ this.addDisposables(this._onDidLocationChange, this._onDidActivePanelChange, this._onDidVisibilityChange.event((event) => {
6751
+ // When becoming visible, apply any pending size change
6752
+ if (event.isVisible && this._pendingSize) {
6753
+ super.setSize(this._pendingSize);
6754
+ this._pendingSize = undefined;
6755
+ }
6756
+ }));
6757
+ }
6758
+ setSize(event) {
6759
+ // Always store the requested size
6760
+ this._pendingSize = Object.assign({}, event);
6761
+ // Apply the size change immediately
6762
+ super.setSize(event);
6749
6763
  }
6750
6764
  close() {
6751
6765
  if (!this._group) {
@@ -7697,13 +7711,16 @@ class Overlay extends CompositeDisposable {
7697
7711
  let right = undefined;
7698
7712
  let width = undefined;
7699
7713
  const moveTop = () => {
7700
- top = clamp(y, -Number.MAX_VALUE, startPosition.originalY +
7714
+ // When dragging top handle, constrain top position to prevent oversizing
7715
+ const maxTop = startPosition.originalY +
7701
7716
  startPosition.originalHeight >
7702
7717
  containerRect.height
7703
- ? this.getMinimumHeight(containerRect.height)
7718
+ ? Math.max(0, containerRect.height -
7719
+ Overlay.MINIMUM_HEIGHT)
7704
7720
  : Math.max(0, startPosition.originalY +
7705
7721
  startPosition.originalHeight -
7706
- Overlay.MINIMUM_HEIGHT));
7722
+ Overlay.MINIMUM_HEIGHT);
7723
+ top = clamp(y, 0, maxTop);
7707
7724
  height =
7708
7725
  startPosition.originalY +
7709
7726
  startPosition.originalHeight -
@@ -7714,22 +7731,27 @@ class Overlay extends CompositeDisposable {
7714
7731
  top =
7715
7732
  startPosition.originalY -
7716
7733
  startPosition.originalHeight;
7717
- height = clamp(y - top, top < 0 &&
7718
- typeof this.options
7719
- .minimumInViewportHeight === 'number'
7734
+ // When dragging bottom handle, constrain height to container height
7735
+ const minHeight = top < 0 &&
7736
+ typeof this.options.minimumInViewportHeight ===
7737
+ 'number'
7720
7738
  ? -top +
7721
7739
  this.options.minimumInViewportHeight
7722
- : Overlay.MINIMUM_HEIGHT, Number.MAX_VALUE);
7740
+ : Overlay.MINIMUM_HEIGHT;
7741
+ const maxHeight = containerRect.height - Math.max(0, top);
7742
+ height = clamp(y - top, minHeight, maxHeight);
7723
7743
  bottom = containerRect.height - top - height;
7724
7744
  };
7725
7745
  const moveLeft = () => {
7726
- left = clamp(x, -Number.MAX_VALUE, startPosition.originalX +
7746
+ const maxLeft = startPosition.originalX +
7727
7747
  startPosition.originalWidth >
7728
7748
  containerRect.width
7729
- ? this.getMinimumWidth(containerRect.width)
7749
+ ? Math.max(0, containerRect.width -
7750
+ Overlay.MINIMUM_WIDTH) // Prevent extending beyong right edge
7730
7751
  : Math.max(0, startPosition.originalX +
7731
7752
  startPosition.originalWidth -
7732
- Overlay.MINIMUM_WIDTH));
7753
+ Overlay.MINIMUM_WIDTH);
7754
+ left = clamp(x, 0, maxLeft); // min is 0 (Not -Infinity) to prevent dragging beyond left edge
7733
7755
  width =
7734
7756
  startPosition.originalX +
7735
7757
  startPosition.originalWidth -
@@ -7740,12 +7762,15 @@ class Overlay extends CompositeDisposable {
7740
7762
  left =
7741
7763
  startPosition.originalX -
7742
7764
  startPosition.originalWidth;
7743
- width = clamp(x - left, left < 0 &&
7744
- typeof this.options
7745
- .minimumInViewportWidth === 'number'
7765
+ // When dragging right handle, constrain width to container width
7766
+ const minWidth = left < 0 &&
7767
+ typeof this.options.minimumInViewportWidth ===
7768
+ 'number'
7746
7769
  ? -left +
7747
7770
  this.options.minimumInViewportWidth
7748
- : Overlay.MINIMUM_WIDTH, Number.MAX_VALUE);
7771
+ : Overlay.MINIMUM_WIDTH;
7772
+ const maxWidth = containerRect.width - Math.max(0, left);
7773
+ width = clamp(x - left, minWidth, maxWidth);
7749
7774
  right = containerRect.width - left - width;
7750
7775
  };
7751
7776
  switch (direction) {
@@ -8538,7 +8563,14 @@ class DockviewComponent extends BaseGrid {
8538
8563
  if (options.debug) {
8539
8564
  this.addDisposables(new StrictEventsSequencing(this));
8540
8565
  }
8541
- this.addDisposables(this.rootDropTargetContainer, this.overlayRenderContainer, this._onWillDragPanel, this._onWillDragGroup, this._onWillShowOverlay, this._onDidActivePanelChange, this._onDidAddPanel, this._onDidRemovePanel, this._onDidLayoutFromJSON, this._onDidDrop, this._onWillDrop, this._onDidMovePanel, this._onDidAddGroup, this._onDidRemoveGroup, this._onDidActiveGroupChange, this._onUnhandledDragOverEvent, this._onDidMaximizedGroupChange, this._onDidOptionsChange, this._onDidPopoutGroupSizeChange, this._onDidPopoutGroupPositionChange, this._onDidOpenPopoutWindowFail, this.onDidViewVisibilityChangeMicroTaskQueue(() => {
8566
+ this.addDisposables(this.rootDropTargetContainer, this.overlayRenderContainer, this._onWillDragPanel, this._onWillDragGroup, this._onWillShowOverlay, this._onDidActivePanelChange, this._onDidAddPanel, this._onDidRemovePanel, this._onDidLayoutFromJSON, this._onDidDrop, this._onWillDrop, this._onDidMovePanel, this._onDidMovePanel.event(() => {
8567
+ /**
8568
+ * Update overlay positions after DOM layout completes to prevent 0×0 dimensions.
8569
+ * With defaultRenderer="always" this results in panel content not showing after move operations.
8570
+ * Debounced to avoid multiple calls when moving groups with multiple panels.
8571
+ */
8572
+ this.debouncedUpdateAllPositions();
8573
+ }), this._onDidAddGroup, this._onDidRemoveGroup, this._onDidActiveGroupChange, this._onUnhandledDragOverEvent, this._onDidMaximizedGroupChange, this._onDidOptionsChange, this._onDidPopoutGroupSizeChange, this._onDidPopoutGroupPositionChange, this._onDidOpenPopoutWindowFail, this.onDidViewVisibilityChangeMicroTaskQueue(() => {
8542
8574
  this.updateWatermark();
8543
8575
  }), this.onDidAdd((event) => {
8544
8576
  if (!this._moving) {
@@ -8575,7 +8607,7 @@ class DockviewComponent extends BaseGrid {
8575
8607
  // option only available when no panels in primary grid
8576
8608
  return;
8577
8609
  }
8578
- this._onWillShowOverlay.fire(new WillShowOverlayLocationEvent(event, {
8610
+ this._onWillShowOverlay.fire(new DockviewWillShowOverlayLocationEvent(event, {
8579
8611
  kind: 'edge',
8580
8612
  panel: undefined,
8581
8613
  api: this._api,
@@ -9404,9 +9436,7 @@ class DockviewComponent extends BaseGrid {
9404
9436
  }
9405
9437
  this.updateWatermark();
9406
9438
  // Force position updates for always visible panels after DOM layout is complete
9407
- requestAnimationFrame(() => {
9408
- this.overlayRenderContainer.updateAllPositions();
9409
- });
9439
+ this.debouncedUpdateAllPositions();
9410
9440
  this._onDidLayoutFromJSON.fire();
9411
9441
  }
9412
9442
  clear() {
@@ -9742,6 +9772,15 @@ class DockviewComponent extends BaseGrid {
9742
9772
  }
9743
9773
  return re;
9744
9774
  }
9775
+ debouncedUpdateAllPositions() {
9776
+ if (this._updatePositionsFrameId !== undefined) {
9777
+ cancelAnimationFrame(this._updatePositionsFrameId);
9778
+ }
9779
+ this._updatePositionsFrameId = requestAnimationFrame(() => {
9780
+ this._updatePositionsFrameId = undefined;
9781
+ this.overlayRenderContainer.updateAllPositions();
9782
+ });
9783
+ }
9745
9784
  movingLock(func) {
9746
9785
  const isMoving = this._moving;
9747
9786
  try {
@@ -10052,6 +10091,7 @@ class DockviewComponent extends BaseGrid {
10052
10091
  from.panels.forEach((panel) => {
10053
10092
  this._onDidMovePanel.fire({ panel, from });
10054
10093
  });
10094
+ this.debouncedUpdateAllPositions();
10055
10095
  // Ensure group becomes active after move
10056
10096
  if (options.skipSetActive === false) {
10057
10097
  // Only activate when explicitly requested (skipSetActive: false)
@@ -12123,6 +12163,7 @@ exports.DockviewPanel = DockviewPanel;
12123
12163
  exports.DockviewReact = DockviewReact;
12124
12164
  exports.DockviewUnhandledDragOverEvent = DockviewUnhandledDragOverEvent;
12125
12165
  exports.DockviewWillDropEvent = DockviewWillDropEvent;
12166
+ exports.DockviewWillShowOverlayLocationEvent = DockviewWillShowOverlayLocationEvent;
12126
12167
  exports.DraggablePaneviewPanel = DraggablePaneviewPanel;
12127
12168
  exports.Gridview = Gridview;
12128
12169
  exports.GridviewApi = GridviewApi;