dockview-react 4.7.0 → 4.7.1

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.7.0
3
+ * @version 4.7.1
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -3839,9 +3839,10 @@ class DockviewApi {
3839
3839
  }
3840
3840
 
3841
3841
  class DragHandler extends CompositeDisposable {
3842
- constructor(el) {
3842
+ constructor(el, disabled) {
3843
3843
  super();
3844
3844
  this.el = el;
3845
+ this.disabled = disabled;
3845
3846
  this.dataDisposable = new MutableDisposable();
3846
3847
  this.pointerEventsDisposable = new MutableDisposable();
3847
3848
  this._onDragStart = new Emitter();
@@ -3849,12 +3850,15 @@ class DragHandler extends CompositeDisposable {
3849
3850
  this.addDisposables(this._onDragStart, this.dataDisposable, this.pointerEventsDisposable);
3850
3851
  this.configure();
3851
3852
  }
3853
+ setDisabled(disabled) {
3854
+ this.disabled = disabled;
3855
+ }
3852
3856
  isCancelled(_event) {
3853
3857
  return false;
3854
3858
  }
3855
3859
  configure() {
3856
3860
  this.addDisposables(this._onDragStart, addDisposableListener(this.el, 'dragstart', (event) => {
3857
- if (event.defaultPrevented || this.isCancelled(event)) {
3861
+ if (event.defaultPrevented || this.isCancelled(event) || this.disabled) {
3858
3862
  event.preventDefault();
3859
3863
  return;
3860
3864
  }
@@ -5054,8 +5058,8 @@ function addGhostImage(dataTransfer, ghostElement, options) {
5054
5058
  }
5055
5059
 
5056
5060
  class TabDragHandler extends DragHandler {
5057
- constructor(element, accessor, group, panel) {
5058
- super(element);
5061
+ constructor(element, accessor, group, panel, disabled) {
5062
+ super(element, disabled);
5059
5063
  this.accessor = accessor;
5060
5064
  this.group = group;
5061
5065
  this.panel = panel;
@@ -5091,7 +5095,7 @@ class Tab extends CompositeDisposable {
5091
5095
  this._element.tabIndex = 0;
5092
5096
  this._element.draggable = !this.accessor.options.disableDnd;
5093
5097
  toggleClass(this.element, 'dv-inactive-tab', true);
5094
- const dragHandler = new TabDragHandler(this._element, this.accessor, this.group, this.panel);
5098
+ this.dragHandler = new TabDragHandler(this._element, this.accessor, this.group, this.panel, !!this.accessor.options.disableDnd);
5095
5099
  this.dropTarget = new Droptarget(this._element, {
5096
5100
  acceptedTargetZones: ['left', 'right'],
5097
5101
  overlayModel: { activationSize: { value: 50, type: 'percentage' } },
@@ -5108,7 +5112,7 @@ class Tab extends CompositeDisposable {
5108
5112
  getOverrideTarget: () => { var _a; return (_a = group.model.dropTargetContainer) === null || _a === void 0 ? void 0 : _a.model; },
5109
5113
  });
5110
5114
  this.onWillShowOverlay = this.dropTarget.onWillShowOverlay;
5111
- this.addDisposables(this._onPointDown, this._onDropped, this._onDragStart, dragHandler.onDragStart((event) => {
5115
+ this.addDisposables(this._onPointDown, this._onDropped, this._onDragStart, this.dragHandler.onDragStart((event) => {
5112
5116
  if (event.dataTransfer) {
5113
5117
  const style = getComputedStyle(this.element);
5114
5118
  const newNode = this.element.cloneNode(true);
@@ -5120,7 +5124,7 @@ class Tab extends CompositeDisposable {
5120
5124
  });
5121
5125
  }
5122
5126
  this._onDragStart.fire(event);
5123
- }), dragHandler, addDisposableListener(this._element, 'pointerdown', (event) => {
5127
+ }), this.dragHandler, addDisposableListener(this._element, 'pointerdown', (event) => {
5124
5128
  this._onPointDown.fire(event);
5125
5129
  }), this.dropTarget.onDrop((event) => {
5126
5130
  this._onDropped.fire(event);
@@ -5139,6 +5143,7 @@ class Tab extends CompositeDisposable {
5139
5143
  }
5140
5144
  updateDragAndDropState() {
5141
5145
  this._element.draggable = !this.accessor.options.disableDnd;
5146
+ this.dragHandler.setDisabled(!!this.accessor.options.disableDnd);
5142
5147
  }
5143
5148
  dispose() {
5144
5149
  super.dispose();
@@ -5180,8 +5185,8 @@ class WillShowOverlayLocationEvent {
5180
5185
  }
5181
5186
 
5182
5187
  class GroupDragHandler extends DragHandler {
5183
- constructor(element, accessor, group) {
5184
- super(element);
5188
+ constructor(element, accessor, group, disabled) {
5189
+ super(element, disabled);
5185
5190
  this.accessor = accessor;
5186
5191
  this.group = group;
5187
5192
  this.panelTransfer = LocalSelectionTransfer.getInstance();
@@ -5250,7 +5255,7 @@ class VoidContainer extends CompositeDisposable {
5250
5255
  this.addDisposables(this._onDrop, this._onDragStart, addDisposableListener(this._element, 'pointerdown', () => {
5251
5256
  this.accessor.doSetGroupActive(this.group);
5252
5257
  }));
5253
- const handler = new GroupDragHandler(this._element, accessor, group);
5258
+ this.handler = new GroupDragHandler(this._element, accessor, group, !!this.accessor.options.disableDnd);
5254
5259
  this.dropTarget = new Droptarget(this._element, {
5255
5260
  acceptedTargetZones: ['center'],
5256
5261
  canDisplayOverlay: (event, position) => {
@@ -5263,7 +5268,7 @@ class VoidContainer extends CompositeDisposable {
5263
5268
  getOverrideTarget: () => { var _a; return (_a = group.model.dropTargetContainer) === null || _a === void 0 ? void 0 : _a.model; },
5264
5269
  });
5265
5270
  this.onWillShowOverlay = this.dropTarget.onWillShowOverlay;
5266
- this.addDisposables(handler, handler.onDragStart((event) => {
5271
+ this.addDisposables(this.handler, this.handler.onDragStart((event) => {
5267
5272
  this._onDragStart.fire(event);
5268
5273
  }), this.dropTarget.onDrop((event) => {
5269
5274
  this._onDrop.fire(event);
@@ -5272,6 +5277,7 @@ class VoidContainer extends CompositeDisposable {
5272
5277
  updateDragAndDropState() {
5273
5278
  this._element.draggable = !this.accessor.options.disableDnd;
5274
5279
  toggleClass(this._element, 'dv-draggable', !this.accessor.options.disableDnd);
5280
+ this.handler.setDisabled(!!this.accessor.options.disableDnd);
5275
5281
  }
5276
5282
  }
5277
5283
 
@@ -9662,11 +9668,13 @@ class DockviewComponent extends BaseGrid {
9662
9668
  // remove the group and do not set a new group as active
9663
9669
  this.doRemoveGroup(sourceGroup, { skipActive: true });
9664
9670
  }
9671
+ // Check if destination group is empty - if so, force render the component
9672
+ const isDestinationGroupEmpty = destinationGroup.model.size === 0;
9665
9673
  this.movingLock(() => {
9666
9674
  var _a;
9667
9675
  return destinationGroup.model.openPanel(removedPanel, {
9668
9676
  index: destinationIndex,
9669
- skipSetActive: (_a = options.skipSetActive) !== null && _a !== void 0 ? _a : false,
9677
+ skipSetActive: ((_a = options.skipSetActive) !== null && _a !== void 0 ? _a : false) && !isDestinationGroupEmpty,
9670
9678
  skipSetGroupActive: true,
9671
9679
  });
9672
9680
  });