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