dockview-react 4.4.1 → 4.5.0

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.4.1
3
+ * @version 4.5.0
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -6666,23 +6666,24 @@ class DockviewGroupPanelApiImpl extends GridviewPanelApiImpl {
6666
6666
  : window;
6667
6667
  }
6668
6668
  moveTo(options) {
6669
- var _a, _b, _c;
6669
+ var _a, _b, _c, _d;
6670
6670
  if (!this._group) {
6671
6671
  throw new Error(NOT_INITIALIZED_MESSAGE);
6672
6672
  }
6673
6673
  const group = (_a = options.group) !== null && _a !== void 0 ? _a : this.accessor.addGroup({
6674
6674
  direction: positionToDirection((_b = options.position) !== null && _b !== void 0 ? _b : 'right'),
6675
- skipSetActive: true,
6675
+ skipSetActive: (_c = options.skipSetActive) !== null && _c !== void 0 ? _c : false,
6676
6676
  });
6677
6677
  this.accessor.moveGroupOrPanel({
6678
6678
  from: { groupId: this._group.id },
6679
6679
  to: {
6680
6680
  group,
6681
6681
  position: options.group
6682
- ? (_c = options.position) !== null && _c !== void 0 ? _c : 'center'
6682
+ ? (_d = options.position) !== null && _d !== void 0 ? _d : 'center'
6683
6683
  : 'center',
6684
6684
  index: options.index,
6685
6685
  },
6686
+ skipSetActive: options.skipSetActive,
6686
6687
  });
6687
6688
  }
6688
6689
  maximize() {
@@ -6914,6 +6915,7 @@ class DockviewPanelApiImpl extends GridviewPanelApiImpl {
6914
6915
  : 'center',
6915
6916
  index: options.index,
6916
6917
  },
6918
+ skipSetActive: options.skipSetActive,
6917
6919
  });
6918
6920
  }
6919
6921
  setTitle(title) {
@@ -9483,6 +9485,7 @@ class DockviewComponent extends BaseGrid {
9483
9485
  group: destinationGroup,
9484
9486
  position: destinationTarget,
9485
9487
  },
9488
+ skipSetActive: options.skipSetActive,
9486
9489
  });
9487
9490
  return;
9488
9491
  }
@@ -9501,11 +9504,17 @@ class DockviewComponent extends BaseGrid {
9501
9504
  // remove the group and do not set a new group as active
9502
9505
  this.doRemoveGroup(sourceGroup, { skipActive: true });
9503
9506
  }
9504
- this.movingLock(() => destinationGroup.model.openPanel(removedPanel, {
9505
- index: destinationIndex,
9506
- skipSetGroupActive: true,
9507
- }));
9508
- this.doSetGroupAndPanelActive(destinationGroup);
9507
+ this.movingLock(() => {
9508
+ var _a;
9509
+ return destinationGroup.model.openPanel(removedPanel, {
9510
+ index: destinationIndex,
9511
+ skipSetActive: (_a = options.skipSetActive) !== null && _a !== void 0 ? _a : false,
9512
+ skipSetGroupActive: true,
9513
+ });
9514
+ });
9515
+ if (!options.skipSetActive) {
9516
+ this.doSetGroupAndPanelActive(destinationGroup);
9517
+ }
9509
9518
  this._onDidMovePanel.fire({
9510
9519
  panel: removedPanel,
9511
9520
  from: sourceGroup,
@@ -9608,6 +9617,7 @@ class DockviewComponent extends BaseGrid {
9608
9617
  const target = options.to.position;
9609
9618
  if (target === 'center') {
9610
9619
  const activePanel = from.activePanel;
9620
+ const targetActivePanel = to.activePanel;
9611
9621
  const panels = this.movingLock(() => [...from.panels].map((p) => from.model.removePanel(p.id, {
9612
9622
  skipSetActive: true,
9613
9623
  })));
@@ -9617,12 +9627,23 @@ class DockviewComponent extends BaseGrid {
9617
9627
  this.movingLock(() => {
9618
9628
  for (const panel of panels) {
9619
9629
  to.model.openPanel(panel, {
9620
- skipSetActive: panel !== activePanel,
9630
+ skipSetActive: true, // Always skip setting panels active during move
9621
9631
  skipSetGroupActive: true,
9622
9632
  });
9623
9633
  }
9624
9634
  });
9625
- this.doSetGroupAndPanelActive(to);
9635
+ if (!options.skipSetActive) {
9636
+ // Make the moved panel (from the source group) active
9637
+ if (activePanel) {
9638
+ this.doSetGroupAndPanelActive(to);
9639
+ }
9640
+ }
9641
+ else if (targetActivePanel) {
9642
+ // Ensure the target group's original active panel remains active
9643
+ to.model.openPanel(targetActivePanel, {
9644
+ skipSetGroupActive: true
9645
+ });
9646
+ }
9626
9647
  }
9627
9648
  else {
9628
9649
  switch (from.api.location.type) {
@@ -9642,12 +9663,39 @@ class DockviewComponent extends BaseGrid {
9642
9663
  if (!selectedPopoutGroup) {
9643
9664
  throw new Error('failed to find popout group');
9644
9665
  }
9645
- selectedPopoutGroup.disposable.dispose();
9666
+ // Remove from popout groups list to prevent automatic restoration
9667
+ const index = this._popoutGroups.indexOf(selectedPopoutGroup);
9668
+ if (index >= 0) {
9669
+ this._popoutGroups.splice(index, 1);
9670
+ }
9671
+ // Clean up the reference group (ghost) if it exists and is hidden
9672
+ if (selectedPopoutGroup.referenceGroup) {
9673
+ const referenceGroup = this.getPanel(selectedPopoutGroup.referenceGroup);
9674
+ if (referenceGroup && !referenceGroup.api.isVisible) {
9675
+ this.doRemoveGroup(referenceGroup, { skipActive: true });
9676
+ }
9677
+ }
9678
+ // Manually dispose the window without triggering restoration
9679
+ selectedPopoutGroup.window.dispose();
9680
+ // Update group's location and containers for target
9681
+ if (to.api.location.type === 'grid') {
9682
+ from.model.renderContainer = this.overlayRenderContainer;
9683
+ from.model.dropTargetContainer = this.rootDropTargetContainer;
9684
+ from.model.location = { type: 'grid' };
9685
+ }
9686
+ else if (to.api.location.type === 'floating') {
9687
+ from.model.renderContainer = this.overlayRenderContainer;
9688
+ from.model.dropTargetContainer = this.rootDropTargetContainer;
9689
+ from.model.location = { type: 'floating' };
9690
+ }
9691
+ break;
9646
9692
  }
9647
9693
  }
9648
- if (from.api.location.type !== 'popout') {
9694
+ // For moves to grid locations
9695
+ if (to.api.location.type === 'grid') {
9649
9696
  const referenceLocation = getGridLocation(to.element);
9650
9697
  const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, target);
9698
+ // Add to grid for all moves targeting grid location
9651
9699
  let size;
9652
9700
  switch (this.gridview.orientation) {
9653
9701
  case Orientation.VERTICAL:
@@ -9665,10 +9713,49 @@ class DockviewComponent extends BaseGrid {
9665
9713
  }
9666
9714
  this.gridview.addView(from, size, dropLocation);
9667
9715
  }
9716
+ else if (to.api.location.type === 'floating') {
9717
+ // For moves to floating locations, add as floating group
9718
+ // Get the position/size from the target floating group
9719
+ const targetFloatingGroup = this._floatingGroups.find((x) => x.group === to);
9720
+ if (targetFloatingGroup) {
9721
+ const box = targetFloatingGroup.overlay.toJSON();
9722
+ // Calculate position based on available properties
9723
+ let left, top;
9724
+ if ('left' in box) {
9725
+ left = box.left + 50;
9726
+ }
9727
+ else if ('right' in box) {
9728
+ left = Math.max(0, box.right - box.width - 50);
9729
+ }
9730
+ else {
9731
+ left = 50; // Default fallback
9732
+ }
9733
+ if ('top' in box) {
9734
+ top = box.top + 50;
9735
+ }
9736
+ else if ('bottom' in box) {
9737
+ top = Math.max(0, box.bottom - box.height - 50);
9738
+ }
9739
+ else {
9740
+ top = 50; // Default fallback
9741
+ }
9742
+ this.addFloatingGroup(from, {
9743
+ height: box.height,
9744
+ width: box.width,
9745
+ position: {
9746
+ left,
9747
+ top,
9748
+ },
9749
+ });
9750
+ }
9751
+ }
9668
9752
  }
9669
9753
  from.panels.forEach((panel) => {
9670
9754
  this._onDidMovePanel.fire({ panel, from });
9671
9755
  });
9756
+ if (!options.skipSetActive) {
9757
+ this.doSetGroupAndPanelActive(from);
9758
+ }
9672
9759
  }
9673
9760
  doSetGroupActive(group) {
9674
9761
  super.doSetGroupActive(group);