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
  */
@@ -4993,7 +4993,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4993
4993
  this._element = document.createElement('div');
4994
4994
  this._element.className = 'dv-tab';
4995
4995
  this._element.tabIndex = 0;
4996
- this._element.draggable = true;
4996
+ this._element.draggable = !this.accessor.options.disableDnd;
4997
4997
  toggleClass(this.element, 'dv-inactive-tab', true);
4998
4998
  const dragHandler = new TabDragHandler(this._element, this.accessor, this.group, this.panel);
4999
4999
  this.dropTarget = new Droptarget(this._element, {
@@ -5041,6 +5041,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5041
5041
  this.content = part;
5042
5042
  this._element.appendChild(this.content.element);
5043
5043
  }
5044
+ updateDragAndDropState() {
5045
+ this._element.draggable = !this.accessor.options.disableDnd;
5046
+ }
5044
5047
  dispose() {
5045
5048
  super.dispose();
5046
5049
  }
@@ -5112,7 +5115,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5112
5115
  this.onDragStart = this._onDragStart.event;
5113
5116
  this._element = document.createElement('div');
5114
5117
  this._element.className = 'dv-void-container';
5115
- this._element.draggable = true;
5118
+ this._element.draggable = !this.accessor.options.disableDnd;
5116
5119
  this.addDisposables(this._onDrop, this._onDragStart, addDisposableListener(this._element, 'pointerdown', () => {
5117
5120
  this.accessor.doSetGroupActive(this.group);
5118
5121
  }));
@@ -5135,6 +5138,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5135
5138
  this._onDrop.fire(event);
5136
5139
  }), this.dropTarget);
5137
5140
  }
5141
+ updateDragAndDropState() {
5142
+ this._element.draggable = !this.accessor.options.disableDnd;
5143
+ }
5138
5144
  }
5139
5145
 
5140
5146
  class Scrollbar extends CompositeDisposable {
@@ -5395,6 +5401,11 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5395
5401
  .map((x) => x.value.panel.id);
5396
5402
  this._onOverflowTabsChange.fire({ tabs, reset: options.reset });
5397
5403
  }
5404
+ updateDragAndDropState() {
5405
+ for (const tab of this._tabs) {
5406
+ tab.value.updateDragAndDropState();
5407
+ }
5408
+ }
5398
5409
  }
5399
5410
 
5400
5411
  const createSvgElementFromPath = (params) => {
@@ -5667,6 +5678,10 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5667
5678
  });
5668
5679
  }));
5669
5680
  }
5681
+ updateDragAndDropState() {
5682
+ this.tabs.updateDragAndDropState();
5683
+ this.voidContainer.updateDragAndDropState();
5684
+ }
5670
5685
  }
5671
5686
 
5672
5687
  class DockviewUnhandledDragOverEvent extends AcceptableEvent {
@@ -6372,6 +6387,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6372
6387
  }));
6373
6388
  }
6374
6389
  }
6390
+ updateDragAndDropState() {
6391
+ this.tabsContainer.updateDragAndDropState();
6392
+ }
6375
6393
  dispose() {
6376
6394
  var _a, _b, _c;
6377
6395
  super.dispose();
@@ -6617,23 +6635,24 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6617
6635
  : window;
6618
6636
  }
6619
6637
  moveTo(options) {
6620
- var _a, _b, _c;
6638
+ var _a, _b, _c, _d;
6621
6639
  if (!this._group) {
6622
6640
  throw new Error(NOT_INITIALIZED_MESSAGE);
6623
6641
  }
6624
6642
  const group = (_a = options.group) !== null && _a !== void 0 ? _a : this.accessor.addGroup({
6625
6643
  direction: positionToDirection((_b = options.position) !== null && _b !== void 0 ? _b : 'right'),
6626
- skipSetActive: true,
6644
+ skipSetActive: (_c = options.skipSetActive) !== null && _c !== void 0 ? _c : false,
6627
6645
  });
6628
6646
  this.accessor.moveGroupOrPanel({
6629
6647
  from: { groupId: this._group.id },
6630
6648
  to: {
6631
6649
  group,
6632
6650
  position: options.group
6633
- ? (_c = options.position) !== null && _c !== void 0 ? _c : 'center'
6651
+ ? (_d = options.position) !== null && _d !== void 0 ? _d : 'center'
6634
6652
  : 'center',
6635
6653
  index: options.index,
6636
6654
  },
6655
+ skipSetActive: options.skipSetActive,
6637
6656
  });
6638
6657
  }
6639
6658
  maximize() {
@@ -6865,6 +6884,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6865
6884
  : 'center',
6866
6885
  index: options.index,
6867
6886
  },
6887
+ skipSetActive: options.skipSetActive,
6868
6888
  });
6869
6889
  }
6870
6890
  setTitle(title) {
@@ -8821,7 +8841,12 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
8821
8841
  }
8822
8842
  }
8823
8843
  this.updateDropTargetModel(options);
8844
+ const oldDisableDnd = this.options.disableDnd;
8824
8845
  this._options = Object.assign(Object.assign({}, this.options), options);
8846
+ const newDisableDnd = this.options.disableDnd;
8847
+ if (oldDisableDnd !== newDisableDnd) {
8848
+ this.updateDragAndDropState();
8849
+ }
8825
8850
  if ('theme' in options) {
8826
8851
  this.updateTheme();
8827
8852
  }
@@ -8836,6 +8861,12 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
8836
8861
  }
8837
8862
  }
8838
8863
  }
8864
+ updateDragAndDropState() {
8865
+ // Update draggable state for all tabs and void containers
8866
+ for (const group of this.groups) {
8867
+ group.model.updateDragAndDropState();
8868
+ }
8869
+ }
8839
8870
  focus() {
8840
8871
  var _a;
8841
8872
  (_a = this.activeGroup) === null || _a === void 0 ? void 0 : _a.focus();
@@ -9423,6 +9454,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
9423
9454
  group: destinationGroup,
9424
9455
  position: destinationTarget,
9425
9456
  },
9457
+ skipSetActive: options.skipSetActive,
9426
9458
  });
9427
9459
  return;
9428
9460
  }
@@ -9441,11 +9473,17 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
9441
9473
  // remove the group and do not set a new group as active
9442
9474
  this.doRemoveGroup(sourceGroup, { skipActive: true });
9443
9475
  }
9444
- this.movingLock(() => destinationGroup.model.openPanel(removedPanel, {
9445
- index: destinationIndex,
9446
- skipSetGroupActive: true,
9447
- }));
9448
- 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
+ }
9449
9487
  this._onDidMovePanel.fire({
9450
9488
  panel: removedPanel,
9451
9489
  from: sourceGroup,
@@ -9548,6 +9586,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
9548
9586
  const target = options.to.position;
9549
9587
  if (target === 'center') {
9550
9588
  const activePanel = from.activePanel;
9589
+ const targetActivePanel = to.activePanel;
9551
9590
  const panels = this.movingLock(() => [...from.panels].map((p) => from.model.removePanel(p.id, {
9552
9591
  skipSetActive: true,
9553
9592
  })));
@@ -9557,12 +9596,23 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
9557
9596
  this.movingLock(() => {
9558
9597
  for (const panel of panels) {
9559
9598
  to.model.openPanel(panel, {
9560
- skipSetActive: panel !== activePanel,
9599
+ skipSetActive: true, // Always skip setting panels active during move
9561
9600
  skipSetGroupActive: true,
9562
9601
  });
9563
9602
  }
9564
9603
  });
9565
- 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
+ }
9566
9616
  }
9567
9617
  else {
9568
9618
  switch (from.api.location.type) {
@@ -9582,12 +9632,39 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
9582
9632
  if (!selectedPopoutGroup) {
9583
9633
  throw new Error('failed to find popout group');
9584
9634
  }
9585
- 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;
9586
9661
  }
9587
9662
  }
9588
- if (from.api.location.type !== 'popout') {
9663
+ // For moves to grid locations
9664
+ if (to.api.location.type === 'grid') {
9589
9665
  const referenceLocation = getGridLocation(to.element);
9590
9666
  const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, target);
9667
+ // Add to grid for all moves targeting grid location
9591
9668
  let size;
9592
9669
  switch (this.gridview.orientation) {
9593
9670
  case exports.Orientation.VERTICAL:
@@ -9605,10 +9682,49 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
9605
9682
  }
9606
9683
  this.gridview.addView(from, size, dropLocation);
9607
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
+ }
9608
9721
  }
9609
9722
  from.panels.forEach((panel) => {
9610
9723
  this._onDidMovePanel.fire({ panel, from });
9611
9724
  });
9725
+ if (!options.skipSetActive) {
9726
+ this.doSetGroupAndPanelActive(from);
9727
+ }
9612
9728
  }
9613
9729
  doSetGroupActive(group) {
9614
9730
  super.doSetGroupActive(group);