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