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