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