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
  */
@@ -5024,7 +5024,7 @@ class Tab extends CompositeDisposable {
5024
5024
  this._element = document.createElement('div');
5025
5025
  this._element.className = 'dv-tab';
5026
5026
  this._element.tabIndex = 0;
5027
- this._element.draggable = true;
5027
+ this._element.draggable = !this.accessor.options.disableDnd;
5028
5028
  toggleClass(this.element, 'dv-inactive-tab', true);
5029
5029
  const dragHandler = new TabDragHandler(this._element, this.accessor, this.group, this.panel);
5030
5030
  this.dropTarget = new Droptarget(this._element, {
@@ -5072,6 +5072,9 @@ class Tab extends CompositeDisposable {
5072
5072
  this.content = part;
5073
5073
  this._element.appendChild(this.content.element);
5074
5074
  }
5075
+ updateDragAndDropState() {
5076
+ this._element.draggable = !this.accessor.options.disableDnd;
5077
+ }
5075
5078
  dispose() {
5076
5079
  super.dispose();
5077
5080
  }
@@ -5143,7 +5146,7 @@ class VoidContainer extends CompositeDisposable {
5143
5146
  this.onDragStart = this._onDragStart.event;
5144
5147
  this._element = document.createElement('div');
5145
5148
  this._element.className = 'dv-void-container';
5146
- this._element.draggable = true;
5149
+ this._element.draggable = !this.accessor.options.disableDnd;
5147
5150
  this.addDisposables(this._onDrop, this._onDragStart, addDisposableListener(this._element, 'pointerdown', () => {
5148
5151
  this.accessor.doSetGroupActive(this.group);
5149
5152
  }));
@@ -5166,6 +5169,9 @@ class VoidContainer extends CompositeDisposable {
5166
5169
  this._onDrop.fire(event);
5167
5170
  }), this.dropTarget);
5168
5171
  }
5172
+ updateDragAndDropState() {
5173
+ this._element.draggable = !this.accessor.options.disableDnd;
5174
+ }
5169
5175
  }
5170
5176
 
5171
5177
  class Scrollbar extends CompositeDisposable {
@@ -5426,6 +5432,11 @@ class Tabs extends CompositeDisposable {
5426
5432
  .map((x) => x.value.panel.id);
5427
5433
  this._onOverflowTabsChange.fire({ tabs, reset: options.reset });
5428
5434
  }
5435
+ updateDragAndDropState() {
5436
+ for (const tab of this._tabs) {
5437
+ tab.value.updateDragAndDropState();
5438
+ }
5439
+ }
5429
5440
  }
5430
5441
 
5431
5442
  const createSvgElementFromPath = (params) => {
@@ -5698,6 +5709,10 @@ class TabsContainer extends CompositeDisposable {
5698
5709
  });
5699
5710
  }));
5700
5711
  }
5712
+ updateDragAndDropState() {
5713
+ this.tabs.updateDragAndDropState();
5714
+ this.voidContainer.updateDragAndDropState();
5715
+ }
5701
5716
  }
5702
5717
 
5703
5718
  class DockviewUnhandledDragOverEvent extends AcceptableEvent {
@@ -6403,6 +6418,9 @@ class DockviewGroupPanelModel extends CompositeDisposable {
6403
6418
  }));
6404
6419
  }
6405
6420
  }
6421
+ updateDragAndDropState() {
6422
+ this.tabsContainer.updateDragAndDropState();
6423
+ }
6406
6424
  dispose() {
6407
6425
  var _a, _b, _c;
6408
6426
  super.dispose();
@@ -6648,23 +6666,24 @@ class DockviewGroupPanelApiImpl extends GridviewPanelApiImpl {
6648
6666
  : window;
6649
6667
  }
6650
6668
  moveTo(options) {
6651
- var _a, _b, _c;
6669
+ var _a, _b, _c, _d;
6652
6670
  if (!this._group) {
6653
6671
  throw new Error(NOT_INITIALIZED_MESSAGE);
6654
6672
  }
6655
6673
  const group = (_a = options.group) !== null && _a !== void 0 ? _a : this.accessor.addGroup({
6656
6674
  direction: positionToDirection((_b = options.position) !== null && _b !== void 0 ? _b : 'right'),
6657
- skipSetActive: true,
6675
+ skipSetActive: (_c = options.skipSetActive) !== null && _c !== void 0 ? _c : false,
6658
6676
  });
6659
6677
  this.accessor.moveGroupOrPanel({
6660
6678
  from: { groupId: this._group.id },
6661
6679
  to: {
6662
6680
  group,
6663
6681
  position: options.group
6664
- ? (_c = options.position) !== null && _c !== void 0 ? _c : 'center'
6682
+ ? (_d = options.position) !== null && _d !== void 0 ? _d : 'center'
6665
6683
  : 'center',
6666
6684
  index: options.index,
6667
6685
  },
6686
+ skipSetActive: options.skipSetActive,
6668
6687
  });
6669
6688
  }
6670
6689
  maximize() {
@@ -6896,6 +6915,7 @@ class DockviewPanelApiImpl extends GridviewPanelApiImpl {
6896
6915
  : 'center',
6897
6916
  index: options.index,
6898
6917
  },
6918
+ skipSetActive: options.skipSetActive,
6899
6919
  });
6900
6920
  }
6901
6921
  setTitle(title) {
@@ -8852,7 +8872,12 @@ class DockviewComponent extends BaseGrid {
8852
8872
  }
8853
8873
  }
8854
8874
  this.updateDropTargetModel(options);
8875
+ const oldDisableDnd = this.options.disableDnd;
8855
8876
  this._options = Object.assign(Object.assign({}, this.options), options);
8877
+ const newDisableDnd = this.options.disableDnd;
8878
+ if (oldDisableDnd !== newDisableDnd) {
8879
+ this.updateDragAndDropState();
8880
+ }
8856
8881
  if ('theme' in options) {
8857
8882
  this.updateTheme();
8858
8883
  }
@@ -8867,6 +8892,12 @@ class DockviewComponent extends BaseGrid {
8867
8892
  }
8868
8893
  }
8869
8894
  }
8895
+ updateDragAndDropState() {
8896
+ // Update draggable state for all tabs and void containers
8897
+ for (const group of this.groups) {
8898
+ group.model.updateDragAndDropState();
8899
+ }
8900
+ }
8870
8901
  focus() {
8871
8902
  var _a;
8872
8903
  (_a = this.activeGroup) === null || _a === void 0 ? void 0 : _a.focus();
@@ -9454,6 +9485,7 @@ class DockviewComponent extends BaseGrid {
9454
9485
  group: destinationGroup,
9455
9486
  position: destinationTarget,
9456
9487
  },
9488
+ skipSetActive: options.skipSetActive,
9457
9489
  });
9458
9490
  return;
9459
9491
  }
@@ -9472,11 +9504,17 @@ class DockviewComponent extends BaseGrid {
9472
9504
  // remove the group and do not set a new group as active
9473
9505
  this.doRemoveGroup(sourceGroup, { skipActive: true });
9474
9506
  }
9475
- this.movingLock(() => destinationGroup.model.openPanel(removedPanel, {
9476
- index: destinationIndex,
9477
- skipSetGroupActive: true,
9478
- }));
9479
- this.doSetGroupAndPanelActive(destinationGroup);
9507
+ this.movingLock(() => {
9508
+ var _a;
9509
+ return destinationGroup.model.openPanel(removedPanel, {
9510
+ index: destinationIndex,
9511
+ skipSetActive: (_a = options.skipSetActive) !== null && _a !== void 0 ? _a : false,
9512
+ skipSetGroupActive: true,
9513
+ });
9514
+ });
9515
+ if (!options.skipSetActive) {
9516
+ this.doSetGroupAndPanelActive(destinationGroup);
9517
+ }
9480
9518
  this._onDidMovePanel.fire({
9481
9519
  panel: removedPanel,
9482
9520
  from: sourceGroup,
@@ -9579,6 +9617,7 @@ class DockviewComponent extends BaseGrid {
9579
9617
  const target = options.to.position;
9580
9618
  if (target === 'center') {
9581
9619
  const activePanel = from.activePanel;
9620
+ const targetActivePanel = to.activePanel;
9582
9621
  const panels = this.movingLock(() => [...from.panels].map((p) => from.model.removePanel(p.id, {
9583
9622
  skipSetActive: true,
9584
9623
  })));
@@ -9588,12 +9627,23 @@ class DockviewComponent extends BaseGrid {
9588
9627
  this.movingLock(() => {
9589
9628
  for (const panel of panels) {
9590
9629
  to.model.openPanel(panel, {
9591
- skipSetActive: panel !== activePanel,
9630
+ skipSetActive: true, // Always skip setting panels active during move
9592
9631
  skipSetGroupActive: true,
9593
9632
  });
9594
9633
  }
9595
9634
  });
9596
- this.doSetGroupAndPanelActive(to);
9635
+ if (!options.skipSetActive) {
9636
+ // Make the moved panel (from the source group) active
9637
+ if (activePanel) {
9638
+ this.doSetGroupAndPanelActive(to);
9639
+ }
9640
+ }
9641
+ else if (targetActivePanel) {
9642
+ // Ensure the target group's original active panel remains active
9643
+ to.model.openPanel(targetActivePanel, {
9644
+ skipSetGroupActive: true
9645
+ });
9646
+ }
9597
9647
  }
9598
9648
  else {
9599
9649
  switch (from.api.location.type) {
@@ -9613,12 +9663,39 @@ class DockviewComponent extends BaseGrid {
9613
9663
  if (!selectedPopoutGroup) {
9614
9664
  throw new Error('failed to find popout group');
9615
9665
  }
9616
- selectedPopoutGroup.disposable.dispose();
9666
+ // Remove from popout groups list to prevent automatic restoration
9667
+ const index = this._popoutGroups.indexOf(selectedPopoutGroup);
9668
+ if (index >= 0) {
9669
+ this._popoutGroups.splice(index, 1);
9670
+ }
9671
+ // Clean up the reference group (ghost) if it exists and is hidden
9672
+ if (selectedPopoutGroup.referenceGroup) {
9673
+ const referenceGroup = this.getPanel(selectedPopoutGroup.referenceGroup);
9674
+ if (referenceGroup && !referenceGroup.api.isVisible) {
9675
+ this.doRemoveGroup(referenceGroup, { skipActive: true });
9676
+ }
9677
+ }
9678
+ // Manually dispose the window without triggering restoration
9679
+ selectedPopoutGroup.window.dispose();
9680
+ // Update group's location and containers for target
9681
+ if (to.api.location.type === 'grid') {
9682
+ from.model.renderContainer = this.overlayRenderContainer;
9683
+ from.model.dropTargetContainer = this.rootDropTargetContainer;
9684
+ from.model.location = { type: 'grid' };
9685
+ }
9686
+ else if (to.api.location.type === 'floating') {
9687
+ from.model.renderContainer = this.overlayRenderContainer;
9688
+ from.model.dropTargetContainer = this.rootDropTargetContainer;
9689
+ from.model.location = { type: 'floating' };
9690
+ }
9691
+ break;
9617
9692
  }
9618
9693
  }
9619
- if (from.api.location.type !== 'popout') {
9694
+ // For moves to grid locations
9695
+ if (to.api.location.type === 'grid') {
9620
9696
  const referenceLocation = getGridLocation(to.element);
9621
9697
  const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, target);
9698
+ // Add to grid for all moves targeting grid location
9622
9699
  let size;
9623
9700
  switch (this.gridview.orientation) {
9624
9701
  case Orientation.VERTICAL:
@@ -9636,10 +9713,49 @@ class DockviewComponent extends BaseGrid {
9636
9713
  }
9637
9714
  this.gridview.addView(from, size, dropLocation);
9638
9715
  }
9716
+ else if (to.api.location.type === 'floating') {
9717
+ // For moves to floating locations, add as floating group
9718
+ // Get the position/size from the target floating group
9719
+ const targetFloatingGroup = this._floatingGroups.find((x) => x.group === to);
9720
+ if (targetFloatingGroup) {
9721
+ const box = targetFloatingGroup.overlay.toJSON();
9722
+ // Calculate position based on available properties
9723
+ let left, top;
9724
+ if ('left' in box) {
9725
+ left = box.left + 50;
9726
+ }
9727
+ else if ('right' in box) {
9728
+ left = Math.max(0, box.right - box.width - 50);
9729
+ }
9730
+ else {
9731
+ left = 50; // Default fallback
9732
+ }
9733
+ if ('top' in box) {
9734
+ top = box.top + 50;
9735
+ }
9736
+ else if ('bottom' in box) {
9737
+ top = Math.max(0, box.bottom - box.height - 50);
9738
+ }
9739
+ else {
9740
+ top = 50; // Default fallback
9741
+ }
9742
+ this.addFloatingGroup(from, {
9743
+ height: box.height,
9744
+ width: box.width,
9745
+ position: {
9746
+ left,
9747
+ top,
9748
+ },
9749
+ });
9750
+ }
9751
+ }
9639
9752
  }
9640
9753
  from.panels.forEach((panel) => {
9641
9754
  this._onDidMovePanel.fire({ panel, from });
9642
9755
  });
9756
+ if (!options.skipSetActive) {
9757
+ this.doSetGroupAndPanelActive(from);
9758
+ }
9643
9759
  }
9644
9760
  doSetGroupActive(group) {
9645
9761
  super.doSetGroupActive(group);