dockview-core 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.
Files changed (41) hide show
  1. package/dist/cjs/dnd/abstractDragHandler.d.ts +3 -1
  2. package/dist/cjs/dnd/abstractDragHandler.js +6 -2
  3. package/dist/cjs/dnd/groupDragHandler.d.ts +1 -1
  4. package/dist/cjs/dnd/groupDragHandler.js +2 -2
  5. package/dist/cjs/dockview/components/tab/tab.d.ts +1 -0
  6. package/dist/cjs/dockview/components/tab/tab.js +6 -5
  7. package/dist/cjs/dockview/components/titlebar/voidContainer.d.ts +1 -0
  8. package/dist/cjs/dockview/components/titlebar/voidContainer.js +3 -2
  9. package/dist/cjs/dockview/dockviewComponent.js +3 -1
  10. package/dist/dockview-core.amd.js +21 -13
  11. package/dist/dockview-core.amd.js.map +1 -1
  12. package/dist/dockview-core.amd.min.js +2 -2
  13. package/dist/dockview-core.amd.min.js.map +1 -1
  14. package/dist/dockview-core.amd.min.noStyle.js +2 -2
  15. package/dist/dockview-core.amd.min.noStyle.js.map +1 -1
  16. package/dist/dockview-core.amd.noStyle.js +21 -13
  17. package/dist/dockview-core.amd.noStyle.js.map +1 -1
  18. package/dist/dockview-core.cjs.js +21 -13
  19. package/dist/dockview-core.cjs.js.map +1 -1
  20. package/dist/dockview-core.esm.js +21 -13
  21. package/dist/dockview-core.esm.js.map +1 -1
  22. package/dist/dockview-core.esm.min.js +2 -2
  23. package/dist/dockview-core.esm.min.js.map +1 -1
  24. package/dist/dockview-core.js +21 -13
  25. package/dist/dockview-core.js.map +1 -1
  26. package/dist/dockview-core.min.js +2 -2
  27. package/dist/dockview-core.min.js.map +1 -1
  28. package/dist/dockview-core.min.noStyle.js +2 -2
  29. package/dist/dockview-core.min.noStyle.js.map +1 -1
  30. package/dist/dockview-core.noStyle.js +21 -13
  31. package/dist/dockview-core.noStyle.js.map +1 -1
  32. package/dist/esm/dnd/abstractDragHandler.d.ts +3 -1
  33. package/dist/esm/dnd/abstractDragHandler.js +6 -2
  34. package/dist/esm/dnd/groupDragHandler.d.ts +1 -1
  35. package/dist/esm/dnd/groupDragHandler.js +2 -2
  36. package/dist/esm/dockview/components/tab/tab.d.ts +1 -0
  37. package/dist/esm/dockview/components/tab/tab.js +6 -5
  38. package/dist/esm/dockview/components/titlebar/voidContainer.d.ts +1 -0
  39. package/dist/esm/dockview/components/titlebar/voidContainer.js +3 -2
  40. package/dist/esm/dockview/dockviewComponent.js +3 -1
  41. package/package.json +1 -1
@@ -1,11 +1,13 @@
1
1
  import { CompositeDisposable, IDisposable } from '../lifecycle';
2
2
  export declare abstract class DragHandler extends CompositeDisposable {
3
3
  protected readonly el: HTMLElement;
4
+ private disabled?;
4
5
  private readonly dataDisposable;
5
6
  private readonly pointerEventsDisposable;
6
7
  private readonly _onDragStart;
7
8
  readonly onDragStart: import("../events").Event<DragEvent>;
8
- constructor(el: HTMLElement);
9
+ constructor(el: HTMLElement, disabled?: boolean | undefined);
10
+ setDisabled(disabled: boolean): void;
9
11
  abstract getData(event: DragEvent): IDisposable;
10
12
  protected isCancelled(_event: DragEvent): boolean;
11
13
  private configure;
@@ -21,9 +21,10 @@ var events_1 = require("../events");
21
21
  var lifecycle_1 = require("../lifecycle");
22
22
  var DragHandler = /** @class */ (function (_super) {
23
23
  __extends(DragHandler, _super);
24
- function DragHandler(el) {
24
+ function DragHandler(el, disabled) {
25
25
  var _this = _super.call(this) || this;
26
26
  _this.el = el;
27
+ _this.disabled = disabled;
27
28
  _this.dataDisposable = new lifecycle_1.MutableDisposable();
28
29
  _this.pointerEventsDisposable = new lifecycle_1.MutableDisposable();
29
30
  _this._onDragStart = new events_1.Emitter();
@@ -32,13 +33,16 @@ var DragHandler = /** @class */ (function (_super) {
32
33
  _this.configure();
33
34
  return _this;
34
35
  }
36
+ DragHandler.prototype.setDisabled = function (disabled) {
37
+ this.disabled = disabled;
38
+ };
35
39
  DragHandler.prototype.isCancelled = function (_event) {
36
40
  return false;
37
41
  };
38
42
  DragHandler.prototype.configure = function () {
39
43
  var _this = this;
40
44
  this.addDisposables(this._onDragStart, (0, events_1.addDisposableListener)(this.el, 'dragstart', function (event) {
41
- if (event.defaultPrevented || _this.isCancelled(event)) {
45
+ if (event.defaultPrevented || _this.isCancelled(event) || _this.disabled) {
42
46
  event.preventDefault();
43
47
  return;
44
48
  }
@@ -6,7 +6,7 @@ export declare class GroupDragHandler extends DragHandler {
6
6
  private readonly accessor;
7
7
  private readonly group;
8
8
  private readonly panelTransfer;
9
- constructor(element: HTMLElement, accessor: DockviewComponent, group: DockviewGroupPanel);
9
+ constructor(element: HTMLElement, accessor: DockviewComponent, group: DockviewGroupPanel, disabled?: boolean);
10
10
  isCancelled(_event: DragEvent): boolean;
11
11
  getData(dragEvent: DragEvent): IDisposable;
12
12
  }
@@ -23,8 +23,8 @@ var dataTransfer_1 = require("./dataTransfer");
23
23
  var ghost_1 = require("./ghost");
24
24
  var GroupDragHandler = /** @class */ (function (_super) {
25
25
  __extends(GroupDragHandler, _super);
26
- function GroupDragHandler(element, accessor, group) {
27
- var _this = _super.call(this, element) || this;
26
+ function GroupDragHandler(element, accessor, group, disabled) {
27
+ var _this = _super.call(this, element, disabled) || this;
28
28
  _this.accessor = accessor;
29
29
  _this.group = group;
30
30
  _this.panelTransfer = dataTransfer_1.LocalSelectionTransfer.getInstance();
@@ -12,6 +12,7 @@ export declare class Tab extends CompositeDisposable {
12
12
  private readonly _element;
13
13
  private readonly dropTarget;
14
14
  private content;
15
+ private readonly dragHandler;
15
16
  private readonly _onPointDown;
16
17
  readonly onPointerDown: Event<MouseEvent>;
17
18
  private readonly _onDropped;
@@ -25,8 +25,8 @@ var abstractDragHandler_1 = require("../../../dnd/abstractDragHandler");
25
25
  var ghost_1 = require("../../../dnd/ghost");
26
26
  var TabDragHandler = /** @class */ (function (_super) {
27
27
  __extends(TabDragHandler, _super);
28
- function TabDragHandler(element, accessor, group, panel) {
29
- var _this = _super.call(this, element) || this;
28
+ function TabDragHandler(element, accessor, group, panel, disabled) {
29
+ var _this = _super.call(this, element, disabled) || this;
30
30
  _this.accessor = accessor;
31
31
  _this.group = group;
32
32
  _this.panel = panel;
@@ -63,7 +63,7 @@ var Tab = /** @class */ (function (_super) {
63
63
  _this._element.tabIndex = 0;
64
64
  _this._element.draggable = !_this.accessor.options.disableDnd;
65
65
  (0, dom_1.toggleClass)(_this.element, 'dv-inactive-tab', true);
66
- var dragHandler = new TabDragHandler(_this._element, _this.accessor, _this.group, _this.panel);
66
+ _this.dragHandler = new TabDragHandler(_this._element, _this.accessor, _this.group, _this.panel, !!_this.accessor.options.disableDnd);
67
67
  _this.dropTarget = new droptarget_1.Droptarget(_this._element, {
68
68
  acceptedTargetZones: ['left', 'right'],
69
69
  overlayModel: { activationSize: { value: 50, type: 'percentage' } },
@@ -80,7 +80,7 @@ var Tab = /** @class */ (function (_super) {
80
80
  getOverrideTarget: function () { var _a; return (_a = group.model.dropTargetContainer) === null || _a === void 0 ? void 0 : _a.model; },
81
81
  });
82
82
  _this.onWillShowOverlay = _this.dropTarget.onWillShowOverlay;
83
- _this.addDisposables(_this._onPointDown, _this._onDropped, _this._onDragStart, dragHandler.onDragStart(function (event) {
83
+ _this.addDisposables(_this._onPointDown, _this._onDropped, _this._onDragStart, _this.dragHandler.onDragStart(function (event) {
84
84
  if (event.dataTransfer) {
85
85
  var style_1 = getComputedStyle(_this.element);
86
86
  var newNode_1 = _this.element.cloneNode(true);
@@ -94,7 +94,7 @@ var Tab = /** @class */ (function (_super) {
94
94
  });
95
95
  }
96
96
  _this._onDragStart.fire(event);
97
- }), dragHandler, (0, events_1.addDisposableListener)(_this._element, 'pointerdown', function (event) {
97
+ }), _this.dragHandler, (0, events_1.addDisposableListener)(_this._element, 'pointerdown', function (event) {
98
98
  _this._onPointDown.fire(event);
99
99
  }), _this.dropTarget.onDrop(function (event) {
100
100
  _this._onDropped.fire(event);
@@ -121,6 +121,7 @@ var Tab = /** @class */ (function (_super) {
121
121
  };
122
122
  Tab.prototype.updateDragAndDropState = function () {
123
123
  this._element.draggable = !this.accessor.options.disableDnd;
124
+ this.dragHandler.setDisabled(!!this.accessor.options.disableDnd);
124
125
  };
125
126
  Tab.prototype.dispose = function () {
126
127
  _super.prototype.dispose.call(this);
@@ -8,6 +8,7 @@ export declare class VoidContainer extends CompositeDisposable {
8
8
  private readonly group;
9
9
  private readonly _element;
10
10
  private readonly dropTarget;
11
+ private readonly handler;
11
12
  private readonly _onDrop;
12
13
  readonly onDrop: Event<DroptargetEvent>;
13
14
  private readonly _onDragStart;
@@ -39,7 +39,7 @@ var VoidContainer = /** @class */ (function (_super) {
39
39
  _this.addDisposables(_this._onDrop, _this._onDragStart, (0, events_1.addDisposableListener)(_this._element, 'pointerdown', function () {
40
40
  _this.accessor.doSetGroupActive(_this.group);
41
41
  }));
42
- var handler = new groupDragHandler_1.GroupDragHandler(_this._element, accessor, group);
42
+ _this.handler = new groupDragHandler_1.GroupDragHandler(_this._element, accessor, group, !!_this.accessor.options.disableDnd);
43
43
  _this.dropTarget = new droptarget_1.Droptarget(_this._element, {
44
44
  acceptedTargetZones: ['center'],
45
45
  canDisplayOverlay: function (event, position) {
@@ -52,7 +52,7 @@ var VoidContainer = /** @class */ (function (_super) {
52
52
  getOverrideTarget: function () { var _a; return (_a = group.model.dropTargetContainer) === null || _a === void 0 ? void 0 : _a.model; },
53
53
  });
54
54
  _this.onWillShowOverlay = _this.dropTarget.onWillShowOverlay;
55
- _this.addDisposables(handler, handler.onDragStart(function (event) {
55
+ _this.addDisposables(_this.handler, _this.handler.onDragStart(function (event) {
56
56
  _this._onDragStart.fire(event);
57
57
  }), _this.dropTarget.onDrop(function (event) {
58
58
  _this._onDrop.fire(event);
@@ -69,6 +69,7 @@ var VoidContainer = /** @class */ (function (_super) {
69
69
  VoidContainer.prototype.updateDragAndDropState = function () {
70
70
  this._element.draggable = !this.accessor.options.disableDnd;
71
71
  (0, dom_1.toggleClass)(this._element, 'dv-draggable', !this.accessor.options.disableDnd);
72
+ this.handler.setDisabled(!!this.accessor.options.disableDnd);
72
73
  };
73
74
  return VoidContainer;
74
75
  }(lifecycle_1.CompositeDisposable));
@@ -1671,11 +1671,13 @@ var DockviewComponent = /** @class */ (function (_super) {
1671
1671
  // remove the group and do not set a new group as active
1672
1672
  this.doRemoveGroup(sourceGroup, { skipActive: true });
1673
1673
  }
1674
+ // Check if destination group is empty - if so, force render the component
1675
+ var isDestinationGroupEmpty_1 = destinationGroup.model.size === 0;
1674
1676
  this.movingLock(function () {
1675
1677
  var _a;
1676
1678
  return destinationGroup.model.openPanel(removedPanel_1, {
1677
1679
  index: destinationIndex,
1678
- skipSetActive: (_a = options.skipSetActive) !== null && _a !== void 0 ? _a : false,
1680
+ skipSetActive: ((_a = options.skipSetActive) !== null && _a !== void 0 ? _a : false) && !isDestinationGroupEmpty_1,
1679
1681
  skipSetGroupActive: true,
1680
1682
  });
1681
1683
  });
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * dockview-core
3
- * @version 4.7.0
3
+ * @version 4.7.1
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -3838,9 +3838,10 @@ define(['exports'], (function (exports) { 'use strict';
3838
3838
  }
3839
3839
 
3840
3840
  class DragHandler extends CompositeDisposable {
3841
- constructor(el) {
3841
+ constructor(el, disabled) {
3842
3842
  super();
3843
3843
  this.el = el;
3844
+ this.disabled = disabled;
3844
3845
  this.dataDisposable = new MutableDisposable();
3845
3846
  this.pointerEventsDisposable = new MutableDisposable();
3846
3847
  this._onDragStart = new Emitter();
@@ -3848,12 +3849,15 @@ define(['exports'], (function (exports) { 'use strict';
3848
3849
  this.addDisposables(this._onDragStart, this.dataDisposable, this.pointerEventsDisposable);
3849
3850
  this.configure();
3850
3851
  }
3852
+ setDisabled(disabled) {
3853
+ this.disabled = disabled;
3854
+ }
3851
3855
  isCancelled(_event) {
3852
3856
  return false;
3853
3857
  }
3854
3858
  configure() {
3855
3859
  this.addDisposables(this._onDragStart, addDisposableListener(this.el, 'dragstart', (event) => {
3856
- if (event.defaultPrevented || this.isCancelled(event)) {
3860
+ if (event.defaultPrevented || this.isCancelled(event) || this.disabled) {
3857
3861
  event.preventDefault();
3858
3862
  return;
3859
3863
  }
@@ -5053,8 +5057,8 @@ define(['exports'], (function (exports) { 'use strict';
5053
5057
  }
5054
5058
 
5055
5059
  class TabDragHandler extends DragHandler {
5056
- constructor(element, accessor, group, panel) {
5057
- super(element);
5060
+ constructor(element, accessor, group, panel, disabled) {
5061
+ super(element, disabled);
5058
5062
  this.accessor = accessor;
5059
5063
  this.group = group;
5060
5064
  this.panel = panel;
@@ -5090,7 +5094,7 @@ define(['exports'], (function (exports) { 'use strict';
5090
5094
  this._element.tabIndex = 0;
5091
5095
  this._element.draggable = !this.accessor.options.disableDnd;
5092
5096
  toggleClass(this.element, 'dv-inactive-tab', true);
5093
- const dragHandler = new TabDragHandler(this._element, this.accessor, this.group, this.panel);
5097
+ this.dragHandler = new TabDragHandler(this._element, this.accessor, this.group, this.panel, !!this.accessor.options.disableDnd);
5094
5098
  this.dropTarget = new Droptarget(this._element, {
5095
5099
  acceptedTargetZones: ['left', 'right'],
5096
5100
  overlayModel: { activationSize: { value: 50, type: 'percentage' } },
@@ -5107,7 +5111,7 @@ define(['exports'], (function (exports) { 'use strict';
5107
5111
  getOverrideTarget: () => { var _a; return (_a = group.model.dropTargetContainer) === null || _a === void 0 ? void 0 : _a.model; },
5108
5112
  });
5109
5113
  this.onWillShowOverlay = this.dropTarget.onWillShowOverlay;
5110
- this.addDisposables(this._onPointDown, this._onDropped, this._onDragStart, dragHandler.onDragStart((event) => {
5114
+ this.addDisposables(this._onPointDown, this._onDropped, this._onDragStart, this.dragHandler.onDragStart((event) => {
5111
5115
  if (event.dataTransfer) {
5112
5116
  const style = getComputedStyle(this.element);
5113
5117
  const newNode = this.element.cloneNode(true);
@@ -5119,7 +5123,7 @@ define(['exports'], (function (exports) { 'use strict';
5119
5123
  });
5120
5124
  }
5121
5125
  this._onDragStart.fire(event);
5122
- }), dragHandler, addDisposableListener(this._element, 'pointerdown', (event) => {
5126
+ }), this.dragHandler, addDisposableListener(this._element, 'pointerdown', (event) => {
5123
5127
  this._onPointDown.fire(event);
5124
5128
  }), this.dropTarget.onDrop((event) => {
5125
5129
  this._onDropped.fire(event);
@@ -5138,6 +5142,7 @@ define(['exports'], (function (exports) { 'use strict';
5138
5142
  }
5139
5143
  updateDragAndDropState() {
5140
5144
  this._element.draggable = !this.accessor.options.disableDnd;
5145
+ this.dragHandler.setDisabled(!!this.accessor.options.disableDnd);
5141
5146
  }
5142
5147
  dispose() {
5143
5148
  super.dispose();
@@ -5179,8 +5184,8 @@ define(['exports'], (function (exports) { 'use strict';
5179
5184
  }
5180
5185
 
5181
5186
  class GroupDragHandler extends DragHandler {
5182
- constructor(element, accessor, group) {
5183
- super(element);
5187
+ constructor(element, accessor, group, disabled) {
5188
+ super(element, disabled);
5184
5189
  this.accessor = accessor;
5185
5190
  this.group = group;
5186
5191
  this.panelTransfer = LocalSelectionTransfer.getInstance();
@@ -5249,7 +5254,7 @@ define(['exports'], (function (exports) { 'use strict';
5249
5254
  this.addDisposables(this._onDrop, this._onDragStart, addDisposableListener(this._element, 'pointerdown', () => {
5250
5255
  this.accessor.doSetGroupActive(this.group);
5251
5256
  }));
5252
- const handler = new GroupDragHandler(this._element, accessor, group);
5257
+ this.handler = new GroupDragHandler(this._element, accessor, group, !!this.accessor.options.disableDnd);
5253
5258
  this.dropTarget = new Droptarget(this._element, {
5254
5259
  acceptedTargetZones: ['center'],
5255
5260
  canDisplayOverlay: (event, position) => {
@@ -5262,7 +5267,7 @@ define(['exports'], (function (exports) { 'use strict';
5262
5267
  getOverrideTarget: () => { var _a; return (_a = group.model.dropTargetContainer) === null || _a === void 0 ? void 0 : _a.model; },
5263
5268
  });
5264
5269
  this.onWillShowOverlay = this.dropTarget.onWillShowOverlay;
5265
- this.addDisposables(handler, handler.onDragStart((event) => {
5270
+ this.addDisposables(this.handler, this.handler.onDragStart((event) => {
5266
5271
  this._onDragStart.fire(event);
5267
5272
  }), this.dropTarget.onDrop((event) => {
5268
5273
  this._onDrop.fire(event);
@@ -5271,6 +5276,7 @@ define(['exports'], (function (exports) { 'use strict';
5271
5276
  updateDragAndDropState() {
5272
5277
  this._element.draggable = !this.accessor.options.disableDnd;
5273
5278
  toggleClass(this._element, 'dv-draggable', !this.accessor.options.disableDnd);
5279
+ this.handler.setDisabled(!!this.accessor.options.disableDnd);
5274
5280
  }
5275
5281
  }
5276
5282
 
@@ -9684,11 +9690,13 @@ define(['exports'], (function (exports) { 'use strict';
9684
9690
  // remove the group and do not set a new group as active
9685
9691
  this.doRemoveGroup(sourceGroup, { skipActive: true });
9686
9692
  }
9693
+ // Check if destination group is empty - if so, force render the component
9694
+ const isDestinationGroupEmpty = destinationGroup.model.size === 0;
9687
9695
  this.movingLock(() => {
9688
9696
  var _a;
9689
9697
  return destinationGroup.model.openPanel(removedPanel, {
9690
9698
  index: destinationIndex,
9691
- skipSetActive: (_a = options.skipSetActive) !== null && _a !== void 0 ? _a : false,
9699
+ skipSetActive: ((_a = options.skipSetActive) !== null && _a !== void 0 ? _a : false) && !isDestinationGroupEmpty,
9692
9700
  skipSetGroupActive: true,
9693
9701
  });
9694
9702
  });