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
  */
@@ -6639,23 +6639,24 @@
6639
6639
  : window;
6640
6640
  }
6641
6641
  moveTo(options) {
6642
- var _a, _b, _c;
6642
+ var _a, _b, _c, _d;
6643
6643
  if (!this._group) {
6644
6644
  throw new Error(NOT_INITIALIZED_MESSAGE);
6645
6645
  }
6646
6646
  const group = (_a = options.group) !== null && _a !== void 0 ? _a : this.accessor.addGroup({
6647
6647
  direction: positionToDirection((_b = options.position) !== null && _b !== void 0 ? _b : 'right'),
6648
- skipSetActive: true,
6648
+ skipSetActive: (_c = options.skipSetActive) !== null && _c !== void 0 ? _c : false,
6649
6649
  });
6650
6650
  this.accessor.moveGroupOrPanel({
6651
6651
  from: { groupId: this._group.id },
6652
6652
  to: {
6653
6653
  group,
6654
6654
  position: options.group
6655
- ? (_c = options.position) !== null && _c !== void 0 ? _c : 'center'
6655
+ ? (_d = options.position) !== null && _d !== void 0 ? _d : 'center'
6656
6656
  : 'center',
6657
6657
  index: options.index,
6658
6658
  },
6659
+ skipSetActive: options.skipSetActive,
6659
6660
  });
6660
6661
  }
6661
6662
  maximize() {
@@ -6887,6 +6888,7 @@
6887
6888
  : 'center',
6888
6889
  index: options.index,
6889
6890
  },
6891
+ skipSetActive: options.skipSetActive,
6890
6892
  });
6891
6893
  }
6892
6894
  setTitle(title) {
@@ -9456,6 +9458,7 @@
9456
9458
  group: destinationGroup,
9457
9459
  position: destinationTarget,
9458
9460
  },
9461
+ skipSetActive: options.skipSetActive,
9459
9462
  });
9460
9463
  return;
9461
9464
  }
@@ -9474,11 +9477,17 @@
9474
9477
  // remove the group and do not set a new group as active
9475
9478
  this.doRemoveGroup(sourceGroup, { skipActive: true });
9476
9479
  }
9477
- this.movingLock(() => destinationGroup.model.openPanel(removedPanel, {
9478
- index: destinationIndex,
9479
- skipSetGroupActive: true,
9480
- }));
9481
- this.doSetGroupAndPanelActive(destinationGroup);
9480
+ this.movingLock(() => {
9481
+ var _a;
9482
+ return destinationGroup.model.openPanel(removedPanel, {
9483
+ index: destinationIndex,
9484
+ skipSetActive: (_a = options.skipSetActive) !== null && _a !== void 0 ? _a : false,
9485
+ skipSetGroupActive: true,
9486
+ });
9487
+ });
9488
+ if (!options.skipSetActive) {
9489
+ this.doSetGroupAndPanelActive(destinationGroup);
9490
+ }
9482
9491
  this._onDidMovePanel.fire({
9483
9492
  panel: removedPanel,
9484
9493
  from: sourceGroup,
@@ -9581,6 +9590,7 @@
9581
9590
  const target = options.to.position;
9582
9591
  if (target === 'center') {
9583
9592
  const activePanel = from.activePanel;
9593
+ const targetActivePanel = to.activePanel;
9584
9594
  const panels = this.movingLock(() => [...from.panels].map((p) => from.model.removePanel(p.id, {
9585
9595
  skipSetActive: true,
9586
9596
  })));
@@ -9590,12 +9600,23 @@
9590
9600
  this.movingLock(() => {
9591
9601
  for (const panel of panels) {
9592
9602
  to.model.openPanel(panel, {
9593
- skipSetActive: panel !== activePanel,
9603
+ skipSetActive: true, // Always skip setting panels active during move
9594
9604
  skipSetGroupActive: true,
9595
9605
  });
9596
9606
  }
9597
9607
  });
9598
- this.doSetGroupAndPanelActive(to);
9608
+ if (!options.skipSetActive) {
9609
+ // Make the moved panel (from the source group) active
9610
+ if (activePanel) {
9611
+ this.doSetGroupAndPanelActive(to);
9612
+ }
9613
+ }
9614
+ else if (targetActivePanel) {
9615
+ // Ensure the target group's original active panel remains active
9616
+ to.model.openPanel(targetActivePanel, {
9617
+ skipSetGroupActive: true
9618
+ });
9619
+ }
9599
9620
  }
9600
9621
  else {
9601
9622
  switch (from.api.location.type) {
@@ -9615,12 +9636,39 @@
9615
9636
  if (!selectedPopoutGroup) {
9616
9637
  throw new Error('failed to find popout group');
9617
9638
  }
9618
- selectedPopoutGroup.disposable.dispose();
9639
+ // Remove from popout groups list to prevent automatic restoration
9640
+ const index = this._popoutGroups.indexOf(selectedPopoutGroup);
9641
+ if (index >= 0) {
9642
+ this._popoutGroups.splice(index, 1);
9643
+ }
9644
+ // Clean up the reference group (ghost) if it exists and is hidden
9645
+ if (selectedPopoutGroup.referenceGroup) {
9646
+ const referenceGroup = this.getPanel(selectedPopoutGroup.referenceGroup);
9647
+ if (referenceGroup && !referenceGroup.api.isVisible) {
9648
+ this.doRemoveGroup(referenceGroup, { skipActive: true });
9649
+ }
9650
+ }
9651
+ // Manually dispose the window without triggering restoration
9652
+ selectedPopoutGroup.window.dispose();
9653
+ // Update group's location and containers for target
9654
+ if (to.api.location.type === 'grid') {
9655
+ from.model.renderContainer = this.overlayRenderContainer;
9656
+ from.model.dropTargetContainer = this.rootDropTargetContainer;
9657
+ from.model.location = { type: 'grid' };
9658
+ }
9659
+ else if (to.api.location.type === 'floating') {
9660
+ from.model.renderContainer = this.overlayRenderContainer;
9661
+ from.model.dropTargetContainer = this.rootDropTargetContainer;
9662
+ from.model.location = { type: 'floating' };
9663
+ }
9664
+ break;
9619
9665
  }
9620
9666
  }
9621
- if (from.api.location.type !== 'popout') {
9667
+ // For moves to grid locations
9668
+ if (to.api.location.type === 'grid') {
9622
9669
  const referenceLocation = getGridLocation(to.element);
9623
9670
  const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, target);
9671
+ // Add to grid for all moves targeting grid location
9624
9672
  let size;
9625
9673
  switch (this.gridview.orientation) {
9626
9674
  case exports.Orientation.VERTICAL:
@@ -9638,10 +9686,49 @@
9638
9686
  }
9639
9687
  this.gridview.addView(from, size, dropLocation);
9640
9688
  }
9689
+ else if (to.api.location.type === 'floating') {
9690
+ // For moves to floating locations, add as floating group
9691
+ // Get the position/size from the target floating group
9692
+ const targetFloatingGroup = this._floatingGroups.find((x) => x.group === to);
9693
+ if (targetFloatingGroup) {
9694
+ const box = targetFloatingGroup.overlay.toJSON();
9695
+ // Calculate position based on available properties
9696
+ let left, top;
9697
+ if ('left' in box) {
9698
+ left = box.left + 50;
9699
+ }
9700
+ else if ('right' in box) {
9701
+ left = Math.max(0, box.right - box.width - 50);
9702
+ }
9703
+ else {
9704
+ left = 50; // Default fallback
9705
+ }
9706
+ if ('top' in box) {
9707
+ top = box.top + 50;
9708
+ }
9709
+ else if ('bottom' in box) {
9710
+ top = Math.max(0, box.bottom - box.height - 50);
9711
+ }
9712
+ else {
9713
+ top = 50; // Default fallback
9714
+ }
9715
+ this.addFloatingGroup(from, {
9716
+ height: box.height,
9717
+ width: box.width,
9718
+ position: {
9719
+ left,
9720
+ top,
9721
+ },
9722
+ });
9723
+ }
9724
+ }
9641
9725
  }
9642
9726
  from.panels.forEach((panel) => {
9643
9727
  this._onDidMovePanel.fire({ panel, from });
9644
9728
  });
9729
+ if (!options.skipSetActive) {
9730
+ this.doSetGroupAndPanelActive(from);
9731
+ }
9645
9732
  }
9646
9733
  doSetGroupActive(group) {
9647
9734
  super.doSetGroupActive(group);