dockview-react 4.7.0 → 4.9.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.7.0
3
+ * @version 4.9.0
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -3812,9 +3812,10 @@
3812
3812
  }
3813
3813
 
3814
3814
  class DragHandler extends CompositeDisposable {
3815
- constructor(el) {
3815
+ constructor(el, disabled) {
3816
3816
  super();
3817
3817
  this.el = el;
3818
+ this.disabled = disabled;
3818
3819
  this.dataDisposable = new MutableDisposable();
3819
3820
  this.pointerEventsDisposable = new MutableDisposable();
3820
3821
  this._onDragStart = new Emitter();
@@ -3822,12 +3823,15 @@
3822
3823
  this.addDisposables(this._onDragStart, this.dataDisposable, this.pointerEventsDisposable);
3823
3824
  this.configure();
3824
3825
  }
3826
+ setDisabled(disabled) {
3827
+ this.disabled = disabled;
3828
+ }
3825
3829
  isCancelled(_event) {
3826
3830
  return false;
3827
3831
  }
3828
3832
  configure() {
3829
3833
  this.addDisposables(this._onDragStart, addDisposableListener(this.el, 'dragstart', (event) => {
3830
- if (event.defaultPrevented || this.isCancelled(event)) {
3834
+ if (event.defaultPrevented || this.isCancelled(event) || this.disabled) {
3831
3835
  event.preventDefault();
3832
3836
  return;
3833
3837
  }
@@ -5027,8 +5031,8 @@
5027
5031
  }
5028
5032
 
5029
5033
  class TabDragHandler extends DragHandler {
5030
- constructor(element, accessor, group, panel) {
5031
- super(element);
5034
+ constructor(element, accessor, group, panel, disabled) {
5035
+ super(element, disabled);
5032
5036
  this.accessor = accessor;
5033
5037
  this.group = group;
5034
5038
  this.panel = panel;
@@ -5064,7 +5068,7 @@
5064
5068
  this._element.tabIndex = 0;
5065
5069
  this._element.draggable = !this.accessor.options.disableDnd;
5066
5070
  toggleClass(this.element, 'dv-inactive-tab', true);
5067
- const dragHandler = new TabDragHandler(this._element, this.accessor, this.group, this.panel);
5071
+ this.dragHandler = new TabDragHandler(this._element, this.accessor, this.group, this.panel, !!this.accessor.options.disableDnd);
5068
5072
  this.dropTarget = new Droptarget(this._element, {
5069
5073
  acceptedTargetZones: ['left', 'right'],
5070
5074
  overlayModel: { activationSize: { value: 50, type: 'percentage' } },
@@ -5081,7 +5085,7 @@
5081
5085
  getOverrideTarget: () => { var _a; return (_a = group.model.dropTargetContainer) === null || _a === void 0 ? void 0 : _a.model; },
5082
5086
  });
5083
5087
  this.onWillShowOverlay = this.dropTarget.onWillShowOverlay;
5084
- this.addDisposables(this._onPointDown, this._onDropped, this._onDragStart, dragHandler.onDragStart((event) => {
5088
+ this.addDisposables(this._onPointDown, this._onDropped, this._onDragStart, this.dragHandler.onDragStart((event) => {
5085
5089
  if (event.dataTransfer) {
5086
5090
  const style = getComputedStyle(this.element);
5087
5091
  const newNode = this.element.cloneNode(true);
@@ -5093,7 +5097,7 @@
5093
5097
  });
5094
5098
  }
5095
5099
  this._onDragStart.fire(event);
5096
- }), dragHandler, addDisposableListener(this._element, 'pointerdown', (event) => {
5100
+ }), this.dragHandler, addDisposableListener(this._element, 'pointerdown', (event) => {
5097
5101
  this._onPointDown.fire(event);
5098
5102
  }), this.dropTarget.onDrop((event) => {
5099
5103
  this._onDropped.fire(event);
@@ -5112,6 +5116,7 @@
5112
5116
  }
5113
5117
  updateDragAndDropState() {
5114
5118
  this._element.draggable = !this.accessor.options.disableDnd;
5119
+ this.dragHandler.setDisabled(!!this.accessor.options.disableDnd);
5115
5120
  }
5116
5121
  dispose() {
5117
5122
  super.dispose();
@@ -5153,8 +5158,8 @@
5153
5158
  }
5154
5159
 
5155
5160
  class GroupDragHandler extends DragHandler {
5156
- constructor(element, accessor, group) {
5157
- super(element);
5161
+ constructor(element, accessor, group, disabled) {
5162
+ super(element, disabled);
5158
5163
  this.accessor = accessor;
5159
5164
  this.group = group;
5160
5165
  this.panelTransfer = LocalSelectionTransfer.getInstance();
@@ -5223,7 +5228,7 @@
5223
5228
  this.addDisposables(this._onDrop, this._onDragStart, addDisposableListener(this._element, 'pointerdown', () => {
5224
5229
  this.accessor.doSetGroupActive(this.group);
5225
5230
  }));
5226
- const handler = new GroupDragHandler(this._element, accessor, group);
5231
+ this.handler = new GroupDragHandler(this._element, accessor, group, !!this.accessor.options.disableDnd);
5227
5232
  this.dropTarget = new Droptarget(this._element, {
5228
5233
  acceptedTargetZones: ['center'],
5229
5234
  canDisplayOverlay: (event, position) => {
@@ -5236,7 +5241,7 @@
5236
5241
  getOverrideTarget: () => { var _a; return (_a = group.model.dropTargetContainer) === null || _a === void 0 ? void 0 : _a.model; },
5237
5242
  });
5238
5243
  this.onWillShowOverlay = this.dropTarget.onWillShowOverlay;
5239
- this.addDisposables(handler, handler.onDragStart((event) => {
5244
+ this.addDisposables(this.handler, this.handler.onDragStart((event) => {
5240
5245
  this._onDragStart.fire(event);
5241
5246
  }), this.dropTarget.onDrop((event) => {
5242
5247
  this._onDrop.fire(event);
@@ -5245,6 +5250,7 @@
5245
5250
  updateDragAndDropState() {
5246
5251
  this._element.draggable = !this.accessor.options.disableDnd;
5247
5252
  toggleClass(this._element, 'dv-draggable', !this.accessor.options.disableDnd);
5253
+ this.handler.setDisabled(!!this.accessor.options.disableDnd);
5248
5254
  }
5249
5255
  }
5250
5256
 
@@ -9635,11 +9641,13 @@
9635
9641
  // remove the group and do not set a new group as active
9636
9642
  this.doRemoveGroup(sourceGroup, { skipActive: true });
9637
9643
  }
9644
+ // Check if destination group is empty - if so, force render the component
9645
+ const isDestinationGroupEmpty = destinationGroup.model.size === 0;
9638
9646
  this.movingLock(() => {
9639
9647
  var _a;
9640
9648
  return destinationGroup.model.openPanel(removedPanel, {
9641
9649
  index: destinationIndex,
9642
- skipSetActive: (_a = options.skipSetActive) !== null && _a !== void 0 ? _a : false,
9650
+ skipSetActive: ((_a = options.skipSetActive) !== null && _a !== void 0 ? _a : false) && !isDestinationGroupEmpty,
9643
9651
  skipSetGroupActive: true,
9644
9652
  });
9645
9653
  });