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