dockview-react 4.4.0 → 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.0
3
+ * @version 4.5.0
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -5026,7 +5026,7 @@ class Tab extends CompositeDisposable {
5026
5026
  this._element = document.createElement('div');
5027
5027
  this._element.className = 'dv-tab';
5028
5028
  this._element.tabIndex = 0;
5029
- this._element.draggable = true;
5029
+ this._element.draggable = !this.accessor.options.disableDnd;
5030
5030
  toggleClass(this.element, 'dv-inactive-tab', true);
5031
5031
  const dragHandler = new TabDragHandler(this._element, this.accessor, this.group, this.panel);
5032
5032
  this.dropTarget = new Droptarget(this._element, {
@@ -5074,6 +5074,9 @@ class Tab extends CompositeDisposable {
5074
5074
  this.content = part;
5075
5075
  this._element.appendChild(this.content.element);
5076
5076
  }
5077
+ updateDragAndDropState() {
5078
+ this._element.draggable = !this.accessor.options.disableDnd;
5079
+ }
5077
5080
  dispose() {
5078
5081
  super.dispose();
5079
5082
  }
@@ -5145,7 +5148,7 @@ class VoidContainer extends CompositeDisposable {
5145
5148
  this.onDragStart = this._onDragStart.event;
5146
5149
  this._element = document.createElement('div');
5147
5150
  this._element.className = 'dv-void-container';
5148
- this._element.draggable = true;
5151
+ this._element.draggable = !this.accessor.options.disableDnd;
5149
5152
  this.addDisposables(this._onDrop, this._onDragStart, addDisposableListener(this._element, 'pointerdown', () => {
5150
5153
  this.accessor.doSetGroupActive(this.group);
5151
5154
  }));
@@ -5168,6 +5171,9 @@ class VoidContainer extends CompositeDisposable {
5168
5171
  this._onDrop.fire(event);
5169
5172
  }), this.dropTarget);
5170
5173
  }
5174
+ updateDragAndDropState() {
5175
+ this._element.draggable = !this.accessor.options.disableDnd;
5176
+ }
5171
5177
  }
5172
5178
 
5173
5179
  class Scrollbar extends CompositeDisposable {
@@ -5428,6 +5434,11 @@ class Tabs extends CompositeDisposable {
5428
5434
  .map((x) => x.value.panel.id);
5429
5435
  this._onOverflowTabsChange.fire({ tabs, reset: options.reset });
5430
5436
  }
5437
+ updateDragAndDropState() {
5438
+ for (const tab of this._tabs) {
5439
+ tab.value.updateDragAndDropState();
5440
+ }
5441
+ }
5431
5442
  }
5432
5443
 
5433
5444
  const createSvgElementFromPath = (params) => {
@@ -5700,6 +5711,10 @@ class TabsContainer extends CompositeDisposable {
5700
5711
  });
5701
5712
  }));
5702
5713
  }
5714
+ updateDragAndDropState() {
5715
+ this.tabs.updateDragAndDropState();
5716
+ this.voidContainer.updateDragAndDropState();
5717
+ }
5703
5718
  }
5704
5719
 
5705
5720
  class DockviewUnhandledDragOverEvent extends AcceptableEvent {
@@ -6405,6 +6420,9 @@ class DockviewGroupPanelModel extends CompositeDisposable {
6405
6420
  }));
6406
6421
  }
6407
6422
  }
6423
+ updateDragAndDropState() {
6424
+ this.tabsContainer.updateDragAndDropState();
6425
+ }
6408
6426
  dispose() {
6409
6427
  var _a, _b, _c;
6410
6428
  super.dispose();
@@ -6650,23 +6668,24 @@ class DockviewGroupPanelApiImpl extends GridviewPanelApiImpl {
6650
6668
  : window;
6651
6669
  }
6652
6670
  moveTo(options) {
6653
- var _a, _b, _c;
6671
+ var _a, _b, _c, _d;
6654
6672
  if (!this._group) {
6655
6673
  throw new Error(NOT_INITIALIZED_MESSAGE);
6656
6674
  }
6657
6675
  const group = (_a = options.group) !== null && _a !== void 0 ? _a : this.accessor.addGroup({
6658
6676
  direction: positionToDirection((_b = options.position) !== null && _b !== void 0 ? _b : 'right'),
6659
- skipSetActive: true,
6677
+ skipSetActive: (_c = options.skipSetActive) !== null && _c !== void 0 ? _c : false,
6660
6678
  });
6661
6679
  this.accessor.moveGroupOrPanel({
6662
6680
  from: { groupId: this._group.id },
6663
6681
  to: {
6664
6682
  group,
6665
6683
  position: options.group
6666
- ? (_c = options.position) !== null && _c !== void 0 ? _c : 'center'
6684
+ ? (_d = options.position) !== null && _d !== void 0 ? _d : 'center'
6667
6685
  : 'center',
6668
6686
  index: options.index,
6669
6687
  },
6688
+ skipSetActive: options.skipSetActive,
6670
6689
  });
6671
6690
  }
6672
6691
  maximize() {
@@ -6898,6 +6917,7 @@ class DockviewPanelApiImpl extends GridviewPanelApiImpl {
6898
6917
  : 'center',
6899
6918
  index: options.index,
6900
6919
  },
6920
+ skipSetActive: options.skipSetActive,
6901
6921
  });
6902
6922
  }
6903
6923
  setTitle(title) {
@@ -8854,7 +8874,12 @@ class DockviewComponent extends BaseGrid {
8854
8874
  }
8855
8875
  }
8856
8876
  this.updateDropTargetModel(options);
8877
+ const oldDisableDnd = this.options.disableDnd;
8857
8878
  this._options = Object.assign(Object.assign({}, this.options), options);
8879
+ const newDisableDnd = this.options.disableDnd;
8880
+ if (oldDisableDnd !== newDisableDnd) {
8881
+ this.updateDragAndDropState();
8882
+ }
8858
8883
  if ('theme' in options) {
8859
8884
  this.updateTheme();
8860
8885
  }
@@ -8869,6 +8894,12 @@ class DockviewComponent extends BaseGrid {
8869
8894
  }
8870
8895
  }
8871
8896
  }
8897
+ updateDragAndDropState() {
8898
+ // Update draggable state for all tabs and void containers
8899
+ for (const group of this.groups) {
8900
+ group.model.updateDragAndDropState();
8901
+ }
8902
+ }
8872
8903
  focus() {
8873
8904
  var _a;
8874
8905
  (_a = this.activeGroup) === null || _a === void 0 ? void 0 : _a.focus();
@@ -9456,6 +9487,7 @@ class DockviewComponent extends BaseGrid {
9456
9487
  group: destinationGroup,
9457
9488
  position: destinationTarget,
9458
9489
  },
9490
+ skipSetActive: options.skipSetActive,
9459
9491
  });
9460
9492
  return;
9461
9493
  }
@@ -9474,11 +9506,17 @@ class DockviewComponent extends BaseGrid {
9474
9506
  // remove the group and do not set a new group as active
9475
9507
  this.doRemoveGroup(sourceGroup, { skipActive: true });
9476
9508
  }
9477
- this.movingLock(() => destinationGroup.model.openPanel(removedPanel, {
9478
- index: destinationIndex,
9479
- skipSetGroupActive: true,
9480
- }));
9481
- 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
+ }
9482
9520
  this._onDidMovePanel.fire({
9483
9521
  panel: removedPanel,
9484
9522
  from: sourceGroup,
@@ -9581,6 +9619,7 @@ class DockviewComponent extends BaseGrid {
9581
9619
  const target = options.to.position;
9582
9620
  if (target === 'center') {
9583
9621
  const activePanel = from.activePanel;
9622
+ const targetActivePanel = to.activePanel;
9584
9623
  const panels = this.movingLock(() => [...from.panels].map((p) => from.model.removePanel(p.id, {
9585
9624
  skipSetActive: true,
9586
9625
  })));
@@ -9590,12 +9629,23 @@ class DockviewComponent extends BaseGrid {
9590
9629
  this.movingLock(() => {
9591
9630
  for (const panel of panels) {
9592
9631
  to.model.openPanel(panel, {
9593
- skipSetActive: panel !== activePanel,
9632
+ skipSetActive: true, // Always skip setting panels active during move
9594
9633
  skipSetGroupActive: true,
9595
9634
  });
9596
9635
  }
9597
9636
  });
9598
- 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
+ }
9599
9649
  }
9600
9650
  else {
9601
9651
  switch (from.api.location.type) {
@@ -9615,12 +9665,39 @@ class DockviewComponent extends BaseGrid {
9615
9665
  if (!selectedPopoutGroup) {
9616
9666
  throw new Error('failed to find popout group');
9617
9667
  }
9618
- 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;
9619
9694
  }
9620
9695
  }
9621
- if (from.api.location.type !== 'popout') {
9696
+ // For moves to grid locations
9697
+ if (to.api.location.type === 'grid') {
9622
9698
  const referenceLocation = getGridLocation(to.element);
9623
9699
  const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, target);
9700
+ // Add to grid for all moves targeting grid location
9624
9701
  let size;
9625
9702
  switch (this.gridview.orientation) {
9626
9703
  case exports.Orientation.VERTICAL:
@@ -9638,10 +9715,49 @@ class DockviewComponent extends BaseGrid {
9638
9715
  }
9639
9716
  this.gridview.addView(from, size, dropLocation);
9640
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
+ }
9641
9754
  }
9642
9755
  from.panels.forEach((panel) => {
9643
9756
  this._onDidMovePanel.fire({ panel, from });
9644
9757
  });
9758
+ if (!options.skipSetActive) {
9759
+ this.doSetGroupAndPanelActive(from);
9760
+ }
9645
9761
  }
9646
9762
  doSetGroupActive(group) {
9647
9763
  super.doSetGroupActive(group);