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