dockview-core 1.8.2 → 1.8.4

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 (187) hide show
  1. package/dist/cjs/api/component.api.d.ts +8 -4
  2. package/dist/cjs/api/component.api.d.ts.map +1 -1
  3. package/dist/cjs/api/component.api.js +14 -0
  4. package/dist/cjs/api/component.api.js.map +1 -1
  5. package/dist/cjs/dnd/abstractDragHandler.d.ts +2 -2
  6. package/dist/cjs/dnd/abstractDragHandler.d.ts.map +1 -1
  7. package/dist/cjs/dnd/abstractDragHandler.js +16 -12
  8. package/dist/cjs/dnd/abstractDragHandler.js.map +1 -1
  9. package/dist/cjs/dnd/groupDragHandler.d.ts +4 -3
  10. package/dist/cjs/dnd/groupDragHandler.d.ts.map +1 -1
  11. package/dist/cjs/dnd/groupDragHandler.js +5 -4
  12. package/dist/cjs/dnd/groupDragHandler.js.map +1 -1
  13. package/dist/cjs/dnd/overlay.d.ts +6 -2
  14. package/dist/cjs/dnd/overlay.d.ts.map +1 -1
  15. package/dist/cjs/dnd/overlay.js +54 -23
  16. package/dist/cjs/dnd/overlay.js.map +1 -1
  17. package/dist/cjs/dockview/components/tab/tab.d.ts +7 -4
  18. package/dist/cjs/dockview/components/tab/tab.d.ts.map +1 -1
  19. package/dist/cjs/dockview/components/tab/tab.js +36 -28
  20. package/dist/cjs/dockview/components/tab/tab.js.map +1 -1
  21. package/dist/cjs/dockview/components/titlebar/tabsContainer.d.ts +19 -1
  22. package/dist/cjs/dockview/components/titlebar/tabsContainer.d.ts.map +1 -1
  23. package/dist/cjs/dockview/components/titlebar/tabsContainer.js +42 -15
  24. package/dist/cjs/dockview/components/titlebar/tabsContainer.js.map +1 -1
  25. package/dist/cjs/dockview/components/titlebar/voidContainer.d.ts +2 -0
  26. package/dist/cjs/dockview/components/titlebar/voidContainer.d.ts.map +1 -1
  27. package/dist/cjs/dockview/components/titlebar/voidContainer.js +7 -3
  28. package/dist/cjs/dockview/components/titlebar/voidContainer.js.map +1 -1
  29. package/dist/cjs/dockview/dockviewComponent.d.ts +11 -4
  30. package/dist/cjs/dockview/dockviewComponent.d.ts.map +1 -1
  31. package/dist/cjs/dockview/dockviewComponent.js +288 -92
  32. package/dist/cjs/dockview/dockviewComponent.js.map +1 -1
  33. package/dist/cjs/dockview/dockviewGroupPanel.d.ts +4 -4
  34. package/dist/cjs/dockview/dockviewGroupPanel.d.ts.map +1 -1
  35. package/dist/cjs/dockview/dockviewGroupPanel.js.map +1 -1
  36. package/dist/cjs/dockview/dockviewGroupPanelModel.d.ts +11 -4
  37. package/dist/cjs/dockview/dockviewGroupPanelModel.d.ts.map +1 -1
  38. package/dist/cjs/dockview/dockviewGroupPanelModel.js +28 -6
  39. package/dist/cjs/dockview/dockviewGroupPanelModel.js.map +1 -1
  40. package/dist/cjs/dockview/dockviewPanel.d.ts +1 -1
  41. package/dist/cjs/dockview/dockviewPanel.d.ts.map +1 -1
  42. package/dist/cjs/dockview/options.d.ts +9 -5
  43. package/dist/cjs/dockview/options.d.ts.map +1 -1
  44. package/dist/cjs/dockview/options.js.map +1 -1
  45. package/dist/cjs/gridview/baseComponentGridview.d.ts +1 -1
  46. package/dist/cjs/gridview/baseComponentGridview.d.ts.map +1 -1
  47. package/dist/cjs/gridview/baseComponentGridview.js.map +1 -1
  48. package/dist/cjs/gridview/basePanelView.d.ts +4 -4
  49. package/dist/cjs/gridview/basePanelView.d.ts.map +1 -1
  50. package/dist/cjs/gridview/basePanelView.js.map +1 -1
  51. package/dist/cjs/gridview/branchNode.d.ts.map +1 -1
  52. package/dist/cjs/gridview/branchNode.js +1 -0
  53. package/dist/cjs/gridview/branchNode.js.map +1 -1
  54. package/dist/cjs/gridview/gridview.d.ts.map +1 -1
  55. package/dist/cjs/gridview/gridview.js +8 -0
  56. package/dist/cjs/gridview/gridview.js.map +1 -1
  57. package/dist/cjs/gridview/gridviewComponent.d.ts +4 -4
  58. package/dist/cjs/gridview/gridviewComponent.d.ts.map +1 -1
  59. package/dist/cjs/gridview/gridviewComponent.js +71 -39
  60. package/dist/cjs/gridview/gridviewComponent.js.map +1 -1
  61. package/dist/cjs/index.d.ts +1 -0
  62. package/dist/cjs/index.d.ts.map +1 -1
  63. package/dist/cjs/index.js.map +1 -1
  64. package/dist/cjs/lifecycle.d.ts +0 -1
  65. package/dist/cjs/lifecycle.d.ts.map +1 -1
  66. package/dist/cjs/lifecycle.js +0 -32
  67. package/dist/cjs/lifecycle.js.map +1 -1
  68. package/dist/cjs/panel/types.d.ts +2 -2
  69. package/dist/cjs/panel/types.d.ts.map +1 -1
  70. package/dist/cjs/paneview/paneviewComponent.d.ts +5 -6
  71. package/dist/cjs/paneview/paneviewComponent.d.ts.map +1 -1
  72. package/dist/cjs/paneview/paneviewComponent.js.map +1 -1
  73. package/dist/cjs/resizable.d.ts.map +1 -1
  74. package/dist/cjs/resizable.js +8 -0
  75. package/dist/cjs/resizable.js.map +1 -1
  76. package/dist/cjs/splitview/splitview.d.ts.map +1 -1
  77. package/dist/cjs/splitview/splitview.js +11 -1
  78. package/dist/cjs/splitview/splitview.js.map +1 -1
  79. package/dist/cjs/splitview/splitviewComponent.d.ts +4 -4
  80. package/dist/cjs/splitview/splitviewComponent.d.ts.map +1 -1
  81. package/dist/cjs/splitview/splitviewComponent.js.map +1 -1
  82. package/dist/cjs/splitview/splitviewPanel.d.ts +1 -1
  83. package/dist/dockview-core.amd.js +411 -186
  84. package/dist/dockview-core.amd.js.map +1 -1
  85. package/dist/dockview-core.amd.min.js +2 -2
  86. package/dist/dockview-core.amd.min.js.map +1 -1
  87. package/dist/dockview-core.amd.min.noStyle.js +2 -2
  88. package/dist/dockview-core.amd.min.noStyle.js.map +1 -1
  89. package/dist/dockview-core.amd.noStyle.js +411 -186
  90. package/dist/dockview-core.amd.noStyle.js.map +1 -1
  91. package/dist/dockview-core.cjs.js +411 -186
  92. package/dist/dockview-core.cjs.js.map +1 -1
  93. package/dist/dockview-core.esm.js +411 -186
  94. package/dist/dockview-core.esm.js.map +1 -1
  95. package/dist/dockview-core.esm.min.js +2 -2
  96. package/dist/dockview-core.esm.min.js.map +1 -1
  97. package/dist/dockview-core.js +411 -186
  98. package/dist/dockview-core.js.map +1 -1
  99. package/dist/dockview-core.min.js +2 -2
  100. package/dist/dockview-core.min.js.map +1 -1
  101. package/dist/dockview-core.min.noStyle.js +2 -2
  102. package/dist/dockview-core.min.noStyle.js.map +1 -1
  103. package/dist/dockview-core.noStyle.js +411 -186
  104. package/dist/dockview-core.noStyle.js.map +1 -1
  105. package/dist/esm/api/component.api.d.ts +8 -4
  106. package/dist/esm/api/component.api.d.ts.map +1 -1
  107. package/dist/esm/api/component.api.js +6 -0
  108. package/dist/esm/api/component.api.js.map +1 -1
  109. package/dist/esm/dnd/abstractDragHandler.d.ts +2 -2
  110. package/dist/esm/dnd/abstractDragHandler.d.ts.map +1 -1
  111. package/dist/esm/dnd/abstractDragHandler.js +16 -12
  112. package/dist/esm/dnd/abstractDragHandler.js.map +1 -1
  113. package/dist/esm/dnd/groupDragHandler.d.ts +4 -3
  114. package/dist/esm/dnd/groupDragHandler.d.ts.map +1 -1
  115. package/dist/esm/dnd/groupDragHandler.js +5 -4
  116. package/dist/esm/dnd/groupDragHandler.js.map +1 -1
  117. package/dist/esm/dnd/overlay.d.ts +6 -2
  118. package/dist/esm/dnd/overlay.d.ts.map +1 -1
  119. package/dist/esm/dnd/overlay.js +46 -23
  120. package/dist/esm/dnd/overlay.js.map +1 -1
  121. package/dist/esm/dockview/components/tab/tab.d.ts +7 -4
  122. package/dist/esm/dockview/components/tab/tab.d.ts.map +1 -1
  123. package/dist/esm/dockview/components/tab/tab.js +32 -24
  124. package/dist/esm/dockview/components/tab/tab.js.map +1 -1
  125. package/dist/esm/dockview/components/titlebar/tabsContainer.d.ts +19 -1
  126. package/dist/esm/dockview/components/titlebar/tabsContainer.d.ts.map +1 -1
  127. package/dist/esm/dockview/components/titlebar/tabsContainer.js +42 -15
  128. package/dist/esm/dockview/components/titlebar/tabsContainer.js.map +1 -1
  129. package/dist/esm/dockview/components/titlebar/voidContainer.d.ts +2 -0
  130. package/dist/esm/dockview/components/titlebar/voidContainer.d.ts.map +1 -1
  131. package/dist/esm/dockview/components/titlebar/voidContainer.js +7 -3
  132. package/dist/esm/dockview/components/titlebar/voidContainer.js.map +1 -1
  133. package/dist/esm/dockview/dockviewComponent.d.ts +11 -4
  134. package/dist/esm/dockview/dockviewComponent.d.ts.map +1 -1
  135. package/dist/esm/dockview/dockviewComponent.js +204 -59
  136. package/dist/esm/dockview/dockviewComponent.js.map +1 -1
  137. package/dist/esm/dockview/dockviewGroupPanel.d.ts +4 -4
  138. package/dist/esm/dockview/dockviewGroupPanel.d.ts.map +1 -1
  139. package/dist/esm/dockview/dockviewGroupPanel.js.map +1 -1
  140. package/dist/esm/dockview/dockviewGroupPanelModel.d.ts +11 -4
  141. package/dist/esm/dockview/dockviewGroupPanelModel.d.ts.map +1 -1
  142. package/dist/esm/dockview/dockviewGroupPanelModel.js +28 -6
  143. package/dist/esm/dockview/dockviewGroupPanelModel.js.map +1 -1
  144. package/dist/esm/dockview/dockviewPanel.d.ts +1 -1
  145. package/dist/esm/dockview/dockviewPanel.d.ts.map +1 -1
  146. package/dist/esm/dockview/options.d.ts +9 -5
  147. package/dist/esm/dockview/options.d.ts.map +1 -1
  148. package/dist/esm/dockview/options.js.map +1 -1
  149. package/dist/esm/gridview/baseComponentGridview.d.ts +1 -1
  150. package/dist/esm/gridview/baseComponentGridview.d.ts.map +1 -1
  151. package/dist/esm/gridview/baseComponentGridview.js.map +1 -1
  152. package/dist/esm/gridview/basePanelView.d.ts +4 -4
  153. package/dist/esm/gridview/basePanelView.d.ts.map +1 -1
  154. package/dist/esm/gridview/basePanelView.js.map +1 -1
  155. package/dist/esm/gridview/branchNode.d.ts.map +1 -1
  156. package/dist/esm/gridview/branchNode.js +1 -0
  157. package/dist/esm/gridview/branchNode.js.map +1 -1
  158. package/dist/esm/gridview/gridview.d.ts.map +1 -1
  159. package/dist/esm/gridview/gridview.js +8 -0
  160. package/dist/esm/gridview/gridview.js.map +1 -1
  161. package/dist/esm/gridview/gridviewComponent.d.ts +4 -4
  162. package/dist/esm/gridview/gridviewComponent.d.ts.map +1 -1
  163. package/dist/esm/gridview/gridviewComponent.js +56 -35
  164. package/dist/esm/gridview/gridviewComponent.js.map +1 -1
  165. package/dist/esm/index.d.ts +1 -0
  166. package/dist/esm/index.d.ts.map +1 -1
  167. package/dist/esm/index.js.map +1 -1
  168. package/dist/esm/lifecycle.d.ts +0 -1
  169. package/dist/esm/lifecycle.d.ts.map +1 -1
  170. package/dist/esm/lifecycle.js +0 -3
  171. package/dist/esm/lifecycle.js.map +1 -1
  172. package/dist/esm/panel/types.d.ts +2 -2
  173. package/dist/esm/panel/types.d.ts.map +1 -1
  174. package/dist/esm/paneview/paneviewComponent.d.ts +5 -6
  175. package/dist/esm/paneview/paneviewComponent.d.ts.map +1 -1
  176. package/dist/esm/paneview/paneviewComponent.js.map +1 -1
  177. package/dist/esm/resizable.d.ts.map +1 -1
  178. package/dist/esm/resizable.js +8 -0
  179. package/dist/esm/resizable.js.map +1 -1
  180. package/dist/esm/splitview/splitview.d.ts.map +1 -1
  181. package/dist/esm/splitview/splitview.js +11 -1
  182. package/dist/esm/splitview/splitview.js.map +1 -1
  183. package/dist/esm/splitview/splitviewComponent.d.ts +4 -4
  184. package/dist/esm/splitview/splitviewComponent.d.ts.map +1 -1
  185. package/dist/esm/splitview/splitviewComponent.js.map +1 -1
  186. package/dist/esm/splitview/splitviewPanel.d.ts +1 -1
  187. package/package.json +3 -4
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * dockview-core
3
- * @version 1.8.2
3
+ * @version 1.8.4
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -268,9 +268,6 @@ class CompositeDisposable {
268
268
  get isDisposed() {
269
269
  return this._isDisposed;
270
270
  }
271
- static from(...args) {
272
- return new CompositeDisposable(...args);
273
- }
274
271
  constructor(...args) {
275
272
  this._isDisposed = false;
276
273
  this._disposables = args;
@@ -899,7 +896,17 @@ class Splitview {
899
896
  size = typeof size === 'number' ? size : item.size;
900
897
  size = clamp(size, item.minimumSize, item.maximumSize);
901
898
  item.size = size;
902
- this.relayout([index]);
899
+ const indexes = range(this.viewItems.length).filter((i) => i !== index);
900
+ const lowPriorityIndexes = [
901
+ ...indexes.filter((i) => this.viewItems[i].priority === LayoutPriority.Low),
902
+ index,
903
+ ];
904
+ const highPriorityIndexes = indexes.filter((i) => this.viewItems[i].priority === LayoutPriority.High);
905
+ /**
906
+ * add this view we are changing to the low-index list since we have determined the size
907
+ * here and don't want it changed
908
+ */
909
+ this.relayout([...lowPriorityIndexes, index], highPriorityIndexes);
903
910
  }
904
911
  addView(view, size = { type: 'distribute' }, index = this.viewItems.length, skipLayout) {
905
912
  const container = document.createElement('div');
@@ -1656,6 +1663,7 @@ class BranchNode extends CompositeDisposable {
1656
1663
  orientation: this.orientation,
1657
1664
  descriptor,
1658
1665
  proportionalLayout,
1666
+ styles,
1659
1667
  });
1660
1668
  }
1661
1669
  this.addDisposables(this._onDidChange, this.splitview.onDidSashEnd(() => {
@@ -2167,6 +2175,14 @@ class Gridview {
2167
2175
  const child = sibling.children[i];
2168
2176
  grandParent.addChild(child, child.size, parentIndex + i);
2169
2177
  }
2178
+ /**
2179
+ * clean down the branch node since we need to dipose of it and
2180
+ * when .dispose() it called on a branch it will dispose of any
2181
+ * views it is holding onto.
2182
+ */
2183
+ while (sibling.children.length > 0) {
2184
+ sibling.removeChild(0);
2185
+ }
2170
2186
  }
2171
2187
  else {
2172
2188
  // otherwise create a new leaf node and add that to the grandparent
@@ -2474,6 +2490,12 @@ class DockviewApi {
2474
2490
  get onDidDrop() {
2475
2491
  return this.component.onDidDrop;
2476
2492
  }
2493
+ get onWillDragGroup() {
2494
+ return this.component.onWillDragGroup;
2495
+ }
2496
+ get onWillDragPanel() {
2497
+ return this.component.onWillDragPanel;
2498
+ }
2477
2499
  get panels() {
2478
2500
  return this.component.panels;
2479
2501
  }
@@ -2936,7 +2958,7 @@ class DragHandler extends CompositeDisposable {
2936
2958
  }
2937
2959
  configure() {
2938
2960
  this.addDisposables(this._onDragStart, addDisposableListener(this.el, 'dragstart', (event) => {
2939
- if (this.isCancelled(event)) {
2961
+ if (event.defaultPrevented || this.isCancelled(event)) {
2940
2962
  event.preventDefault();
2941
2963
  return;
2942
2964
  }
@@ -2956,19 +2978,23 @@ class DragHandler extends CompositeDisposable {
2956
2978
  }
2957
2979
  this.el.classList.add('dv-dragged');
2958
2980
  setTimeout(() => this.el.classList.remove('dv-dragged'), 0);
2959
- this.dataDisposable.value = this.getData(event.dataTransfer);
2981
+ this.dataDisposable.value = this.getData(event);
2982
+ this._onDragStart.fire(event);
2960
2983
  if (event.dataTransfer) {
2961
2984
  event.dataTransfer.effectAllowed = 'move';
2962
- /**
2963
- * Although this is not used by dockview many third party dnd libraries will check
2964
- * dataTransfer.types to determine valid drag events.
2965
- *
2966
- * For example: in react-dnd if dataTransfer.types is not set then the dragStart event will be cancelled
2967
- * through .preventDefault(). Since this is applied globally to all drag events this would break dockviews
2968
- * dnd logic. You can see the code at
2969
- * https://github.com/react-dnd/react-dnd/blob/main/packages/backend-html5/src/HTML5BackendImpl.ts#L542
2970
- */
2971
- event.dataTransfer.setData('text/plain', '__dockview_internal_drag_event__');
2985
+ const hasData = event.dataTransfer.items.length > 0;
2986
+ if (!hasData) {
2987
+ /**
2988
+ * Although this is not used by dockview many third party dnd libraries will check
2989
+ * dataTransfer.types to determine valid drag events.
2990
+ *
2991
+ * For example: in react-dnd if dataTransfer.types is not set then the dragStart event will be cancelled
2992
+ * through .preventDefault(). Since this is applied globally to all drag events this would break dockviews
2993
+ * dnd logic. You can see the code at
2994
+ * https://github.com/react-dnd/react-dnd/blob/main/packages/backend-html5/src/HTML5BackendImpl.ts#L542
2995
+ */
2996
+ event.dataTransfer.setData('text/plain', '__dockview_internal_drag_event__');
2997
+ }
2972
2998
  }
2973
2999
  }), addDisposableListener(this.el, 'dragend', () => {
2974
3000
  this.pointerEventsDisposable.dispose();
@@ -2977,44 +3003,45 @@ class DragHandler extends CompositeDisposable {
2977
3003
  }
2978
3004
  }
2979
3005
 
3006
+ class TabDragHandler extends DragHandler {
3007
+ constructor(element, accessor, group, panel) {
3008
+ super(element);
3009
+ this.accessor = accessor;
3010
+ this.group = group;
3011
+ this.panel = panel;
3012
+ this.panelTransfer = LocalSelectionTransfer.getInstance();
3013
+ }
3014
+ getData(event) {
3015
+ this.panelTransfer.setData([new PanelTransfer(this.accessor.id, this.group.id, this.panel.id)], PanelTransfer.prototype);
3016
+ return {
3017
+ dispose: () => {
3018
+ this.panelTransfer.clearData(PanelTransfer.prototype);
3019
+ },
3020
+ };
3021
+ }
3022
+ }
2980
3023
  class Tab extends CompositeDisposable {
2981
3024
  get element() {
2982
3025
  return this._element;
2983
3026
  }
2984
- constructor(panelId, accessor, group) {
3027
+ constructor(panel, accessor, group) {
2985
3028
  super();
2986
- this.panelId = panelId;
3029
+ this.panel = panel;
2987
3030
  this.accessor = accessor;
2988
3031
  this.group = group;
3032
+ this.content = undefined;
2989
3033
  this._onChanged = new Emitter();
2990
3034
  this.onChanged = this._onChanged.event;
2991
3035
  this._onDropped = new Emitter();
2992
3036
  this.onDrop = this._onDropped.event;
3037
+ this._onDragStart = new Emitter();
3038
+ this.onDragStart = this._onDragStart.event;
2993
3039
  this._element = document.createElement('div');
2994
3040
  this._element.className = 'tab';
2995
3041
  this._element.tabIndex = 0;
2996
3042
  this._element.draggable = true;
2997
3043
  toggleClass(this.element, 'inactive-tab', true);
2998
- this.addDisposables(this._onChanged, this._onDropped, new (class Handler extends DragHandler {
2999
- constructor() {
3000
- super(...arguments);
3001
- this.panelTransfer = LocalSelectionTransfer.getInstance();
3002
- }
3003
- getData() {
3004
- this.panelTransfer.setData([new PanelTransfer(accessor.id, group.id, panelId)], PanelTransfer.prototype);
3005
- return {
3006
- dispose: () => {
3007
- this.panelTransfer.clearData(PanelTransfer.prototype);
3008
- },
3009
- };
3010
- }
3011
- })(this._element));
3012
- this.addDisposables(addDisposableListener(this._element, 'mousedown', (event) => {
3013
- if (event.defaultPrevented) {
3014
- return;
3015
- }
3016
- this._onChanged.fire(event);
3017
- }));
3044
+ const dragHandler = new TabDragHandler(this._element, this.accessor, this.group, this.panel);
3018
3045
  this.droptarget = new Droptarget(this._element, {
3019
3046
  acceptedTargetZones: ['center'],
3020
3047
  canDisplayOverlay: (event, position) => {
@@ -3028,12 +3055,19 @@ class Tab extends CompositeDisposable {
3028
3055
  // don't allow group move to drop on self
3029
3056
  return false;
3030
3057
  }
3031
- return this.panelId !== data.panelId;
3058
+ return this.panel.id !== data.panelId;
3032
3059
  }
3033
3060
  return this.group.model.canDisplayOverlay(event, position, DockviewDropTargets.Tab);
3034
3061
  },
3035
3062
  });
3036
- this.addDisposables(this.droptarget.onDrop((event) => {
3063
+ this.addDisposables(this._onChanged, this._onDropped, this._onDragStart, dragHandler.onDragStart((event) => {
3064
+ this._onDragStart.fire(event);
3065
+ }), dragHandler, addDisposableListener(this._element, 'mousedown', (event) => {
3066
+ if (event.defaultPrevented) {
3067
+ return;
3068
+ }
3069
+ this._onChanged.fire(event);
3070
+ }), this.droptarget.onDrop((event) => {
3037
3071
  this._onDropped.fire(event);
3038
3072
  }), this.droptarget);
3039
3073
  }
@@ -3065,9 +3099,9 @@ function addGhostImage(dataTransfer, ghostElement) {
3065
3099
  }
3066
3100
 
3067
3101
  class GroupDragHandler extends DragHandler {
3068
- constructor(element, accessorId, group) {
3102
+ constructor(element, accessor, group) {
3069
3103
  super(element);
3070
- this.accessorId = accessorId;
3104
+ this.accessor = accessor;
3071
3105
  this.group = group;
3072
3106
  this.panelTransfer = LocalSelectionTransfer.getInstance();
3073
3107
  this.addDisposables(addDisposableListener(element, 'mousedown', (e) => {
@@ -3087,8 +3121,9 @@ class GroupDragHandler extends DragHandler {
3087
3121
  }
3088
3122
  return false;
3089
3123
  }
3090
- getData(dataTransfer) {
3091
- this.panelTransfer.setData([new PanelTransfer(this.accessorId, this.group.id, null)], PanelTransfer.prototype);
3124
+ getData(dragEvent) {
3125
+ const dataTransfer = dragEvent.dataTransfer;
3126
+ this.panelTransfer.setData([new PanelTransfer(this.accessor.id, this.group.id, null)], PanelTransfer.prototype);
3092
3127
  const style = window.getComputedStyle(this.el);
3093
3128
  const bgColor = style.getPropertyValue('--dv-activegroup-visiblepanel-tab-background-color');
3094
3129
  const color = style.getPropertyValue('--dv-activegroup-visiblepanel-tab-color');
@@ -3123,14 +3158,16 @@ class VoidContainer extends CompositeDisposable {
3123
3158
  this.group = group;
3124
3159
  this._onDrop = new Emitter();
3125
3160
  this.onDrop = this._onDrop.event;
3161
+ this._onDragStart = new Emitter();
3162
+ this.onDragStart = this._onDragStart.event;
3126
3163
  this._element = document.createElement('div');
3127
3164
  this._element.className = 'void-container';
3128
3165
  this._element.tabIndex = 0;
3129
3166
  this._element.draggable = true;
3130
- this.addDisposables(this._onDrop, addDisposableListener(this._element, 'click', () => {
3167
+ this.addDisposables(this._onDrop, this._onDragStart, addDisposableListener(this._element, 'click', () => {
3131
3168
  this.accessor.doSetGroupActive(this.group);
3132
3169
  }));
3133
- const handler = new GroupDragHandler(this._element, accessor.id, group);
3170
+ const handler = new GroupDragHandler(this._element, accessor, group);
3134
3171
  this.voidDropTarget = new Droptarget(this._element, {
3135
3172
  acceptedTargetZones: ['center'],
3136
3173
  canDisplayOverlay: (event, position) => {
@@ -3148,7 +3185,9 @@ class VoidContainer extends CompositeDisposable {
3148
3185
  return group.model.canDisplayOverlay(event, position, DockviewDropTargets.Panel);
3149
3186
  },
3150
3187
  });
3151
- this.addDisposables(handler, this.voidDropTarget.onDrop((event) => {
3188
+ this.addDisposables(handler, handler.onDragStart((event) => {
3189
+ this._onDragStart.fire(event);
3190
+ }), this.voidDropTarget.onDrop((event) => {
3152
3191
  this._onDrop.fire(event);
3153
3192
  }), this.voidDropTarget);
3154
3193
  }
@@ -3156,7 +3195,7 @@ class VoidContainer extends CompositeDisposable {
3156
3195
 
3157
3196
  class TabsContainer extends CompositeDisposable {
3158
3197
  get panels() {
3159
- return this.tabs.map((_) => _.value.panelId);
3198
+ return this.tabs.map((_) => _.value.panel.id);
3160
3199
  }
3161
3200
  get size() {
3162
3201
  return this.tabs.length;
@@ -3202,6 +3241,19 @@ class TabsContainer extends CompositeDisposable {
3202
3241
  this.leftActions = element;
3203
3242
  }
3204
3243
  }
3244
+ setPrefixActionsElement(element) {
3245
+ if (this.preActions === element) {
3246
+ return;
3247
+ }
3248
+ if (this.preActions) {
3249
+ this.preActions.remove();
3250
+ this.preActions = undefined;
3251
+ }
3252
+ if (element) {
3253
+ this.preActionsContainer.appendChild(element);
3254
+ this.preActions = element;
3255
+ }
3256
+ }
3205
3257
  get element() {
3206
3258
  return this._element;
3207
3259
  }
@@ -3210,7 +3262,7 @@ class TabsContainer extends CompositeDisposable {
3210
3262
  this.tabs[this.selectedIndex].value === tab);
3211
3263
  }
3212
3264
  indexOf(id) {
3213
- return this.tabs.findIndex((tab) => tab.value.panelId === id);
3265
+ return this.tabs.findIndex((tab) => tab.value.panel.id === id);
3214
3266
  }
3215
3267
  constructor(accessor, group) {
3216
3268
  super();
@@ -3221,7 +3273,11 @@ class TabsContainer extends CompositeDisposable {
3221
3273
  this._hidden = false;
3222
3274
  this._onDrop = new Emitter();
3223
3275
  this.onDrop = this._onDrop.event;
3224
- this.addDisposables(this._onDrop);
3276
+ this._onTabDragStart = new Emitter();
3277
+ this.onTabDragStart = this._onTabDragStart.event;
3278
+ this._onGroupDragStart = new Emitter();
3279
+ this.onGroupDragStart = this._onGroupDragStart.event;
3280
+ this.addDisposables(this._onDrop, this._onTabDragStart, this._onGroupDragStart);
3225
3281
  this._element = document.createElement('div');
3226
3282
  this._element.className = 'tabs-and-actions-container';
3227
3283
  toggleClass(this._element, 'dv-full-width-single-tab', this.accessor.options.singleTabMode === 'fullwidth');
@@ -3238,14 +3294,22 @@ class TabsContainer extends CompositeDisposable {
3238
3294
  this.rightActionsContainer.className = 'right-actions-container';
3239
3295
  this.leftActionsContainer = document.createElement('div');
3240
3296
  this.leftActionsContainer.className = 'left-actions-container';
3297
+ this.preActionsContainer = document.createElement('div');
3298
+ this.preActionsContainer.className = 'pre-actions-container';
3241
3299
  this.tabContainer = document.createElement('div');
3242
3300
  this.tabContainer.className = 'tabs-container';
3243
3301
  this.voidContainer = new VoidContainer(this.accessor, this.group);
3302
+ this._element.appendChild(this.preActionsContainer);
3244
3303
  this._element.appendChild(this.tabContainer);
3245
3304
  this._element.appendChild(this.leftActionsContainer);
3246
3305
  this._element.appendChild(this.voidContainer.element);
3247
3306
  this._element.appendChild(this.rightActionsContainer);
3248
- this.addDisposables(this.voidContainer, this.voidContainer.onDrop((event) => {
3307
+ this.addDisposables(this.voidContainer, this.voidContainer.onDragStart((event) => {
3308
+ this._onGroupDragStart.fire({
3309
+ nativeEvent: event,
3310
+ group: this.group,
3311
+ });
3312
+ }), this.voidContainer.onDrop((event) => {
3249
3313
  this._onDrop.fire({
3250
3314
  event: event.nativeEvent,
3251
3315
  index: this.tabs.length,
@@ -3291,7 +3355,7 @@ class TabsContainer extends CompositeDisposable {
3291
3355
  }
3292
3356
  }
3293
3357
  delete(id) {
3294
- const index = this.tabs.findIndex((tab) => tab.value.panelId === id);
3358
+ const index = this.tabs.findIndex((tab) => tab.value.panel.id === id);
3295
3359
  const tabToRemove = this.tabs.splice(index, 1)[0];
3296
3360
  const { value, disposable } = tabToRemove;
3297
3361
  disposable.dispose();
@@ -3300,21 +3364,23 @@ class TabsContainer extends CompositeDisposable {
3300
3364
  }
3301
3365
  setActivePanel(panel) {
3302
3366
  this.tabs.forEach((tab) => {
3303
- const isActivePanel = panel.id === tab.value.panelId;
3367
+ const isActivePanel = panel.id === tab.value.panel.id;
3304
3368
  tab.value.setActive(isActivePanel);
3305
3369
  });
3306
3370
  }
3307
3371
  openPanel(panel, index = this.tabs.length) {
3308
3372
  var _a;
3309
- if (this.tabs.find((tab) => tab.value.panelId === panel.id)) {
3373
+ if (this.tabs.find((tab) => tab.value.panel.id === panel.id)) {
3310
3374
  return;
3311
3375
  }
3312
- const tabToAdd = new Tab(panel.id, this.accessor, this.group);
3376
+ const tab = new Tab(panel, this.accessor, this.group);
3313
3377
  if (!((_a = panel.view) === null || _a === void 0 ? void 0 : _a.tab)) {
3314
3378
  throw new Error('invalid header component');
3315
3379
  }
3316
- tabToAdd.setContent(panel.view.tab);
3317
- const disposable = CompositeDisposable.from(tabToAdd.onChanged((event) => {
3380
+ tab.setContent(panel.view.tab);
3381
+ const disposable = new CompositeDisposable(tab.onDragStart((event) => {
3382
+ this._onTabDragStart.fire({ nativeEvent: event, panel });
3383
+ }), tab.onChanged((event) => {
3318
3384
  var _a;
3319
3385
  const isFloatingGroupsEnabled = !this.accessor.options.disableFloatingGroups;
3320
3386
  const isFloatingWithOnePanel = this.group.api.isFloating && this.size === 1;
@@ -3322,8 +3388,8 @@ class TabsContainer extends CompositeDisposable {
3322
3388
  !isFloatingWithOnePanel &&
3323
3389
  event.shiftKey) {
3324
3390
  event.preventDefault();
3325
- const panel = this.accessor.getGroupPanel(tabToAdd.panelId);
3326
- const { top, left } = tabToAdd.element.getBoundingClientRect();
3391
+ const panel = this.accessor.getGroupPanel(tab.panel.id);
3392
+ const { top, left } = tab.element.getBoundingClientRect();
3327
3393
  const { top: rootTop, left: rootLeft } = this.accessor.element.getBoundingClientRect();
3328
3394
  this.accessor.addFloatingGroup(panel, {
3329
3395
  x: left - rootLeft,
@@ -3340,13 +3406,13 @@ class TabsContainer extends CompositeDisposable {
3340
3406
  this.group.model.openPanel(panel, {
3341
3407
  skipFocus: alreadyFocused,
3342
3408
  });
3343
- }), tabToAdd.onDrop((event) => {
3409
+ }), tab.onDrop((event) => {
3344
3410
  this._onDrop.fire({
3345
3411
  event: event.nativeEvent,
3346
- index: this.tabs.findIndex((x) => x.value === tabToAdd),
3412
+ index: this.tabs.findIndex((x) => x.value === tab),
3347
3413
  });
3348
3414
  }));
3349
- const value = { value: tabToAdd, disposable };
3415
+ const value = { value: tab, disposable };
3350
3416
  this.addTab(value, index);
3351
3417
  }
3352
3418
  closePanel(panel) {
@@ -3374,7 +3440,7 @@ class DockviewGroupPanelModel extends CompositeDisposable {
3374
3440
  }
3375
3441
  set locked(value) {
3376
3442
  this._locked = value;
3377
- toggleClass(this.container, 'locked-groupview', value);
3443
+ toggleClass(this.container, 'locked-groupview', value === 'no-drop-target' || value);
3378
3444
  }
3379
3445
  get isActive() {
3380
3446
  return this._isGroupActive;
@@ -3431,6 +3497,10 @@ class DockviewGroupPanelModel extends CompositeDisposable {
3431
3497
  this.onMove = this._onMove.event;
3432
3498
  this._onDidDrop = new Emitter();
3433
3499
  this.onDidDrop = this._onDidDrop.event;
3500
+ this._onTabDragStart = new Emitter();
3501
+ this.onTabDragStart = this._onTabDragStart.event;
3502
+ this._onGroupDragStart = new Emitter();
3503
+ this.onGroupDragStart = this._onGroupDragStart.event;
3434
3504
  this._onDidAddPanel = new Emitter();
3435
3505
  this.onDidAddPanel = this._onDidAddPanel.event;
3436
3506
  this._onDidRemovePanel = new Emitter();
@@ -3443,7 +3513,8 @@ class DockviewGroupPanelModel extends CompositeDisposable {
3443
3513
  this.dropTarget = new Droptarget(this.contentContainer.element, {
3444
3514
  acceptedTargetZones: ['top', 'bottom', 'left', 'right', 'center'],
3445
3515
  canDisplayOverlay: (event, position) => {
3446
- if (this.locked && position === 'center') {
3516
+ if (this.locked === 'no-drop-target' ||
3517
+ (this.locked && position === 'center')) {
3447
3518
  return false;
3448
3519
  }
3449
3520
  const data = getPanelData();
@@ -3469,8 +3540,12 @@ class DockviewGroupPanelModel extends CompositeDisposable {
3469
3540
  });
3470
3541
  container.append(this.tabsContainer.element, this.contentContainer.element);
3471
3542
  this.header.hidden = !!options.hideHeader;
3472
- this.locked = !!options.locked;
3473
- this.addDisposables(this.tabsContainer.onDrop((event) => {
3543
+ this.locked = options.locked || false;
3544
+ this.addDisposables(this._onTabDragStart, this._onGroupDragStart, this.tabsContainer.onTabDragStart((event) => {
3545
+ this._onTabDragStart.fire(event);
3546
+ }), this.tabsContainer.onGroupDragStart((event) => {
3547
+ this._onGroupDragStart.fire(event);
3548
+ }), this.tabsContainer.onDrop((event) => {
3474
3549
  this.handleDropEvent(event.event, 'center', event.index);
3475
3550
  }), this.contentContainer.onDidFocus(() => {
3476
3551
  this.accessor.doSetGroupActive(this.groupPanel, true);
@@ -3514,6 +3589,16 @@ class DockviewGroupPanelModel extends CompositeDisposable {
3514
3589
  });
3515
3590
  this.tabsContainer.setLeftActionsElement(this._leftHeaderActions.element);
3516
3591
  }
3592
+ if (this.accessor.options.createPrefixHeaderActionsElement) {
3593
+ this._prefixHeaderActions =
3594
+ this.accessor.options.createPrefixHeaderActionsElement(this.groupPanel);
3595
+ this.addDisposables(this._prefixHeaderActions);
3596
+ this._prefixHeaderActions.init({
3597
+ containerApi: new DockviewApi(this.accessor),
3598
+ api: this.groupPanel.api,
3599
+ });
3600
+ this.tabsContainer.setPrefixActionsElement(this._prefixHeaderActions.element);
3601
+ }
3517
3602
  }
3518
3603
  indexOf(panel) {
3519
3604
  return this.tabsContainer.indexOf(panel.id);
@@ -3525,8 +3610,8 @@ class DockviewGroupPanelModel extends CompositeDisposable {
3525
3610
  activeView: (_a = this._activePanel) === null || _a === void 0 ? void 0 : _a.id,
3526
3611
  id: this.id,
3527
3612
  };
3528
- if (this.locked) {
3529
- result.locked = true;
3613
+ if (this.locked !== false) {
3614
+ result.locked = this.locked;
3530
3615
  }
3531
3616
  if (this.header.hidden) {
3532
3617
  result.hideHeader = true;
@@ -3776,6 +3861,9 @@ class DockviewGroupPanelModel extends CompositeDisposable {
3776
3861
  return false;
3777
3862
  }
3778
3863
  handleDropEvent(event, position, index) {
3864
+ if (this.locked === 'no-drop-target') {
3865
+ return;
3866
+ }
3779
3867
  const data = getPanelData();
3780
3868
  if (data && data.viewId === this.accessor.id) {
3781
3869
  if (data.panelId === null) {
@@ -3853,6 +3941,14 @@ class Resizable extends CompositeDisposable {
3853
3941
  */
3854
3942
  return;
3855
3943
  }
3944
+ if (!document.body.contains(this._element)) {
3945
+ /**
3946
+ * since the event is dispatched through requestAnimationFrame there is a small chance
3947
+ * the component is no longer attached to the DOM, if that is the case the dimensions
3948
+ * are mostly likely all zero and meaningless. we should skip this case.
3949
+ */
3950
+ return;
3951
+ }
3856
3952
  const { width, height } = entry.contentRect;
3857
3953
  this.layout(width, height);
3858
3954
  }));
@@ -5233,6 +5329,12 @@ const bringElementToFront = (() => {
5233
5329
  return pushToTop;
5234
5330
  })();
5235
5331
  class Overlay extends CompositeDisposable {
5332
+ set minimumInViewportWidth(value) {
5333
+ this.options.minimumInViewportWidth = value;
5334
+ }
5335
+ set minimumInViewportHeight(value) {
5336
+ this.options.minimumInViewportHeight = value;
5337
+ }
5236
5338
  constructor(options) {
5237
5339
  super();
5238
5340
  this.options = options;
@@ -5278,9 +5380,11 @@ class Overlay extends CompositeDisposable {
5278
5380
  const overlayRect = this._element.getBoundingClientRect();
5279
5381
  // region: ensure bounds within allowable limits
5280
5382
  // a minimum width of minimumViewportWidth must be inside the viewport
5281
- const xOffset = Math.max(0, overlayRect.width - this.options.minimumInViewportWidth);
5383
+ const xOffset = Math.max(0, this.getMinimumWidth(overlayRect.width));
5282
5384
  // a minimum height of minimumViewportHeight must be inside the viewport
5283
- const yOffset = Math.max(0, overlayRect.height - this.options.minimumInViewportHeight);
5385
+ const yOffset = typeof this.options.minimumInViewportHeight === 'number'
5386
+ ? Math.max(0, this.getMinimumHeight(overlayRect.height))
5387
+ : 0;
5284
5388
  const left = clamp(overlayRect.left - containerRect.left, -xOffset, Math.max(0, containerRect.width - overlayRect.width + xOffset));
5285
5389
  const top = clamp(overlayRect.top - containerRect.top, -yOffset, Math.max(0, containerRect.height - overlayRect.height + yOffset));
5286
5390
  this._element.style.left = `${left}px`;
@@ -5326,9 +5430,10 @@ class Overlay extends CompositeDisposable {
5326
5430
  y: e.clientY - overlayRect.top,
5327
5431
  };
5328
5432
  }
5329
- const xOffset = Math.max(0, overlayRect.width - this.options.minimumInViewportWidth);
5330
- const yOffset = Math.max(0, overlayRect.height -
5331
- this.options.minimumInViewportHeight);
5433
+ const xOffset = Math.max(0, this.getMinimumWidth(overlayRect.width));
5434
+ const yOffset = Math.max(0, this.options.minimumInViewportHeight
5435
+ ? this.getMinimumHeight(overlayRect.height)
5436
+ : 0);
5332
5437
  const left = clamp(x - offset.x, -xOffset, Math.max(0, containerRect.width - overlayRect.width + xOffset));
5333
5438
  const top = clamp(y - offset.y, -yOffset, Math.max(0, containerRect.height - overlayRect.height + yOffset));
5334
5439
  this.setBounds({ top, left });
@@ -5402,14 +5507,11 @@ class Overlay extends CompositeDisposable {
5402
5507
  let height = undefined;
5403
5508
  let left = undefined;
5404
5509
  let width = undefined;
5405
- const minimumInViewportHeight = this.options.minimumInViewportHeight;
5406
- const minimumInViewportWidth = this.options.minimumInViewportWidth;
5407
- function moveTop() {
5510
+ const moveTop = () => {
5408
5511
  top = clamp(y, -Number.MAX_VALUE, startPosition.originalY +
5409
5512
  startPosition.originalHeight >
5410
5513
  containerRect.height
5411
- ? containerRect.height -
5412
- minimumInViewportHeight
5514
+ ? this.getMinimumHeight(containerRect.height)
5413
5515
  : Math.max(0, startPosition.originalY +
5414
5516
  startPosition.originalHeight -
5415
5517
  Overlay.MINIMUM_HEIGHT));
@@ -5417,21 +5519,23 @@ class Overlay extends CompositeDisposable {
5417
5519
  startPosition.originalY +
5418
5520
  startPosition.originalHeight -
5419
5521
  top;
5420
- }
5421
- function moveBottom() {
5522
+ };
5523
+ const moveBottom = () => {
5422
5524
  top =
5423
5525
  startPosition.originalY -
5424
5526
  startPosition.originalHeight;
5425
- height = clamp(y - top, top < 0
5426
- ? -top + minimumInViewportHeight
5527
+ height = clamp(y - top, top < 0 &&
5528
+ typeof this.options
5529
+ .minimumInViewportHeight === 'number'
5530
+ ? -top +
5531
+ this.options.minimumInViewportHeight
5427
5532
  : Overlay.MINIMUM_HEIGHT, Number.MAX_VALUE);
5428
- }
5429
- function moveLeft() {
5533
+ };
5534
+ const moveLeft = () => {
5430
5535
  left = clamp(x, -Number.MAX_VALUE, startPosition.originalX +
5431
5536
  startPosition.originalWidth >
5432
5537
  containerRect.width
5433
- ? containerRect.width -
5434
- minimumInViewportWidth
5538
+ ? this.getMinimumWidth(containerRect.width)
5435
5539
  : Math.max(0, startPosition.originalX +
5436
5540
  startPosition.originalWidth -
5437
5541
  Overlay.MINIMUM_WIDTH));
@@ -5439,15 +5543,18 @@ class Overlay extends CompositeDisposable {
5439
5543
  startPosition.originalX +
5440
5544
  startPosition.originalWidth -
5441
5545
  left;
5442
- }
5443
- function moveRight() {
5546
+ };
5547
+ const moveRight = () => {
5444
5548
  left =
5445
5549
  startPosition.originalX -
5446
5550
  startPosition.originalWidth;
5447
- width = clamp(x - left, left < 0
5448
- ? -left + minimumInViewportWidth
5551
+ width = clamp(x - left, left < 0 &&
5552
+ typeof this.options
5553
+ .minimumInViewportWidth === 'number'
5554
+ ? -left +
5555
+ this.options.minimumInViewportWidth
5449
5556
  : Overlay.MINIMUM_WIDTH, Number.MAX_VALUE);
5450
- }
5557
+ };
5451
5558
  switch (direction) {
5452
5559
  case 'top':
5453
5560
  moveTop();
@@ -5491,6 +5598,18 @@ class Overlay extends CompositeDisposable {
5491
5598
  }));
5492
5599
  }));
5493
5600
  }
5601
+ getMinimumWidth(width) {
5602
+ if (typeof this.options.minimumInViewportWidth === 'number') {
5603
+ return width - this.options.minimumInViewportWidth;
5604
+ }
5605
+ return 0;
5606
+ }
5607
+ getMinimumHeight(height) {
5608
+ if (typeof this.options.minimumInViewportHeight === 'number') {
5609
+ return height - this.options.minimumInViewportHeight;
5610
+ }
5611
+ return height;
5612
+ }
5494
5613
  dispose() {
5495
5614
  this._element.remove();
5496
5615
  super.dispose();
@@ -5511,6 +5630,7 @@ class DockviewFloatingGroupPanel extends CompositeDisposable {
5511
5630
  }
5512
5631
  }
5513
5632
 
5633
+ const DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE = 100;
5514
5634
  class DockviewComponent extends BaseGrid {
5515
5635
  get orientation() {
5516
5636
  return this.gridview.orientation;
@@ -5541,6 +5661,10 @@ class DockviewComponent extends BaseGrid {
5541
5661
  this.nextGroupId = sequentialNumberGenerator();
5542
5662
  this._deserializer = new DefaultDockviewDeserialzier(this);
5543
5663
  this.watermark = null;
5664
+ this._onWillDragPanel = new Emitter();
5665
+ this.onWillDragPanel = this._onWillDragPanel.event;
5666
+ this._onWillDragGroup = new Emitter();
5667
+ this.onWillDragGroup = this._onWillDragGroup.event;
5544
5668
  this._onDidDrop = new Emitter();
5545
5669
  this.onDidDrop = this._onDidDrop.event;
5546
5670
  this._onDidRemovePanel = new Emitter();
@@ -5553,7 +5677,7 @@ class DockviewComponent extends BaseGrid {
5553
5677
  this.onDidActivePanelChange = this._onDidActivePanelChange.event;
5554
5678
  this.floatingGroups = [];
5555
5679
  toggleClass(this.gridview.element, 'dv-dockview', true);
5556
- this.addDisposables(this._onDidDrop, Event.any(this.onDidAddGroup, this.onDidRemoveGroup)(() => {
5680
+ this.addDisposables(this._onWillDragPanel, this._onWillDragGroup, this._onDidActivePanelChange, this._onDidAddPanel, this._onDidRemovePanel, this._onDidLayoutFromJSON, this._onDidDrop, Event.any(this.onDidAddGroup, this.onDidRemoveGroup)(() => {
5557
5681
  this.updateWatermark();
5558
5682
  }), Event.any(this.onDidAddPanel, this.onDidRemovePanel, this.onDidActivePanelChange)(() => {
5559
5683
  this._bufferOnDidLayoutChange.fire();
@@ -5626,7 +5750,7 @@ class DockviewComponent extends BaseGrid {
5626
5750
  this.updateWatermark();
5627
5751
  }
5628
5752
  addFloatingGroup(item, coord, options) {
5629
- var _a, _b;
5753
+ var _a, _b, _c, _d, _e, _f;
5630
5754
  let group;
5631
5755
  if (item instanceof DockviewPanel) {
5632
5756
  group = this.createGroup();
@@ -5654,8 +5778,12 @@ class DockviewComponent extends BaseGrid {
5654
5778
  width: (_b = coord === null || coord === void 0 ? void 0 : coord.width) !== null && _b !== void 0 ? _b : 300,
5655
5779
  left: overlayLeft,
5656
5780
  top: overlayTop,
5657
- minimumInViewportWidth: 100,
5658
- minimumInViewportHeight: 100,
5781
+ minimumInViewportWidth: this.options.floatingGroupBounds === 'boundedWithinViewport'
5782
+ ? undefined
5783
+ : (_d = (_c = this.options.floatingGroupBounds) === null || _c === void 0 ? void 0 : _c.minimumWidthWithinViewport) !== null && _d !== void 0 ? _d : DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE,
5784
+ minimumInViewportHeight: this.options.floatingGroupBounds === 'boundedWithinViewport'
5785
+ ? undefined
5786
+ : (_f = (_e = this.options.floatingGroupBounds) === null || _e === void 0 ? void 0 : _e.minimumHeightWithinViewport) !== null && _f !== void 0 ? _f : DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE,
5659
5787
  });
5660
5788
  const el = group.element.querySelector('.void-container');
5661
5789
  if (!el) {
@@ -5726,12 +5854,37 @@ class DockviewComponent extends BaseGrid {
5726
5854
  }
5727
5855
  }
5728
5856
  updateOptions(options) {
5857
+ var _a, _b;
5729
5858
  const hasOrientationChanged = typeof options.orientation === 'string' &&
5730
5859
  this.gridview.orientation !== options.orientation;
5860
+ const hasFloatingGroupOptionsChanged = options.floatingGroupBounds !== undefined &&
5861
+ options.floatingGroupBounds !== this.options.floatingGroupBounds;
5731
5862
  this._options = Object.assign(Object.assign({}, this.options), options);
5732
5863
  if (hasOrientationChanged) {
5733
5864
  this.gridview.orientation = options.orientation;
5734
5865
  }
5866
+ if (hasFloatingGroupOptionsChanged) {
5867
+ for (const group of this.floatingGroups) {
5868
+ switch (this.options.floatingGroupBounds) {
5869
+ case 'boundedWithinViewport':
5870
+ group.overlay.minimumInViewportHeight = undefined;
5871
+ group.overlay.minimumInViewportWidth = undefined;
5872
+ break;
5873
+ case undefined:
5874
+ group.overlay.minimumInViewportHeight =
5875
+ DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE;
5876
+ group.overlay.minimumInViewportWidth =
5877
+ DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE;
5878
+ break;
5879
+ default:
5880
+ group.overlay.minimumInViewportHeight =
5881
+ (_a = this.options.floatingGroupBounds) === null || _a === void 0 ? void 0 : _a.minimumHeightWithinViewport;
5882
+ group.overlay.minimumInViewportWidth =
5883
+ (_b = this.options.floatingGroupBounds) === null || _b === void 0 ? void 0 : _b.minimumWidthWithinViewport;
5884
+ }
5885
+ group.overlay.setBounds({});
5886
+ }
5887
+ }
5735
5888
  this.layout(this.gridview.width, this.gridview.height, true);
5736
5889
  }
5737
5890
  layout(width, height, forceResize) {
@@ -5824,61 +5977,114 @@ class DockviewComponent extends BaseGrid {
5824
5977
  fromJSON(data) {
5825
5978
  var _a;
5826
5979
  this.clear();
5980
+ if (typeof data !== 'object' || data === null) {
5981
+ throw new Error('serialized layout must be a non-null object');
5982
+ }
5827
5983
  const { grid, panels, activeGroup } = data;
5828
5984
  if (grid.root.type !== 'branch' || !Array.isArray(grid.root.data)) {
5829
5985
  throw new Error('root must be of type branch');
5830
5986
  }
5831
- // take note of the existing dimensions
5832
- const width = this.width;
5833
- const height = this.height;
5834
- const createGroupFromSerializedState = (data) => {
5835
- const { id, locked, hideHeader, views, activeView } = data;
5836
- const group = this.createGroup({
5837
- id,
5838
- locked: !!locked,
5839
- hideHeader: !!hideHeader,
5840
- });
5841
- this._onDidAddGroup.fire(group);
5842
- for (const child of views) {
5843
- const panel = this._deserializer.fromJSON(panels[child], group);
5844
- const isActive = typeof activeView === 'string' && activeView === panel.id;
5845
- group.model.openPanel(panel, {
5846
- skipSetPanelActive: !isActive,
5847
- skipSetGroupActive: true,
5987
+ try {
5988
+ // take note of the existing dimensions
5989
+ const width = this.width;
5990
+ const height = this.height;
5991
+ const createGroupFromSerializedState = (data) => {
5992
+ const { id, locked, hideHeader, views, activeView } = data;
5993
+ if (typeof id !== 'string') {
5994
+ throw new Error('group id must be of type string');
5995
+ }
5996
+ const group = this.createGroup({
5997
+ id,
5998
+ locked: !!locked,
5999
+ hideHeader: !!hideHeader,
5848
6000
  });
6001
+ const createdPanels = [];
6002
+ for (const child of views) {
6003
+ /**
6004
+ * Run the deserializer step seperately since this may fail to due corrupted external state.
6005
+ * In running this section first we avoid firing lots of 'add' events in the event of a failure
6006
+ * due to a corruption of input data.
6007
+ */
6008
+ const panel = this._deserializer.fromJSON(panels[child], group);
6009
+ createdPanels.push(panel);
6010
+ }
6011
+ this._onDidAddGroup.fire(group);
6012
+ for (let i = 0; i < views.length; i++) {
6013
+ const panel = createdPanels[i];
6014
+ const isActive = typeof activeView === 'string' &&
6015
+ activeView === panel.id;
6016
+ group.model.openPanel(panel, {
6017
+ skipSetPanelActive: !isActive,
6018
+ skipSetGroupActive: true,
6019
+ });
6020
+ }
6021
+ if (!group.activePanel && group.panels.length > 0) {
6022
+ group.model.openPanel(group.panels[group.panels.length - 1], {
6023
+ skipSetGroupActive: true,
6024
+ });
6025
+ }
6026
+ return group;
6027
+ };
6028
+ this.gridview.deserialize(grid, {
6029
+ fromJSON: (node) => {
6030
+ return createGroupFromSerializedState(node.data);
6031
+ },
6032
+ });
6033
+ this.layout(width, height, true);
6034
+ const serializedFloatingGroups = (_a = data.floatingGroups) !== null && _a !== void 0 ? _a : [];
6035
+ for (const serializedFloatingGroup of serializedFloatingGroups) {
6036
+ const { data, position } = serializedFloatingGroup;
6037
+ const group = createGroupFromSerializedState(data);
6038
+ this.addFloatingGroup(group, {
6039
+ x: position.left,
6040
+ y: position.top,
6041
+ height: position.height,
6042
+ width: position.width,
6043
+ }, { skipRemoveGroup: true, inDragMode: false });
6044
+ }
6045
+ for (const floatingGroup of this.floatingGroups) {
6046
+ floatingGroup.overlay.setBounds();
6047
+ }
6048
+ if (typeof activeGroup === 'string') {
6049
+ const panel = this.getPanel(activeGroup);
6050
+ if (panel) {
6051
+ this.doSetGroupActive(panel);
6052
+ }
5849
6053
  }
5850
- if (!group.activePanel && group.panels.length > 0) {
5851
- group.model.openPanel(group.panels[group.panels.length - 1], {
5852
- skipSetGroupActive: true,
5853
- });
6054
+ }
6055
+ catch (err) {
6056
+ /**
6057
+ * Takes all the successfully created groups and remove all of their panels.
6058
+ */
6059
+ for (const group of this.groups) {
6060
+ for (const panel of group.panels) {
6061
+ this.removePanel(panel, {
6062
+ removeEmptyGroup: false,
6063
+ skipDispose: false,
6064
+ });
6065
+ }
5854
6066
  }
5855
- return group;
5856
- };
5857
- this.gridview.deserialize(grid, {
5858
- fromJSON: (node) => {
5859
- return createGroupFromSerializedState(node.data);
5860
- },
5861
- });
5862
- this.layout(width, height, true);
5863
- const serializedFloatingGroups = (_a = data.floatingGroups) !== null && _a !== void 0 ? _a : [];
5864
- for (const serializedFloatingGroup of serializedFloatingGroups) {
5865
- const { data, position } = serializedFloatingGroup;
5866
- const group = createGroupFromSerializedState(data);
5867
- this.addFloatingGroup(group, {
5868
- x: position.left,
5869
- y: position.top,
5870
- height: position.height,
5871
- width: position.width,
5872
- }, { skipRemoveGroup: true, inDragMode: false });
5873
- }
5874
- for (const floatingGroup of this.floatingGroups) {
5875
- floatingGroup.overlay.setBounds();
5876
- }
5877
- if (typeof activeGroup === 'string') {
5878
- const panel = this.getPanel(activeGroup);
5879
- if (panel) {
5880
- this.doSetGroupActive(panel);
6067
+ /**
6068
+ * To remove a group we cannot call this.removeGroup(...) since this makes assumptions about
6069
+ * the underlying HTMLElement existing in the Gridview.
6070
+ */
6071
+ for (const group of this.groups) {
6072
+ group.dispose();
6073
+ this._groups.delete(group.id);
6074
+ this._onDidRemoveGroup.fire(group);
5881
6075
  }
6076
+ // iterate over a reassigned array since original array will be modified
6077
+ for (const floatingGroup of [...this.floatingGroups]) {
6078
+ floatingGroup.dispose();
6079
+ }
6080
+ // fires clean-up events and clears the underlying HTML gridview.
6081
+ this.clear();
6082
+ /**
6083
+ * even though we have cleaned-up we still want to inform the caller of their error
6084
+ * and we'll do this through re-throwing the original error since afterall you would
6085
+ * expect trying to load a corrupted layout to result in an error and not silently fail...
6086
+ */
6087
+ throw err;
5882
6088
  }
5883
6089
  this._onDidLayoutFromJSON.fire();
5884
6090
  }
@@ -6092,6 +6298,7 @@ class DockviewComponent extends BaseGrid {
6092
6298
  if (!(options === null || options === void 0 ? void 0 : options.skipDispose)) {
6093
6299
  floatingGroup.group.dispose();
6094
6300
  this._groups.delete(group.id);
6301
+ // TODO: fire group removed event?
6095
6302
  }
6096
6303
  floatingGroup.dispose();
6097
6304
  return floatingGroup.group;
@@ -6214,7 +6421,11 @@ class DockviewComponent extends BaseGrid {
6214
6421
  const view = new DockviewGroupPanel(this, id, options);
6215
6422
  view.init({ params: {}, accessor: null }); // required to initialized .part and allow for correct disposal of group
6216
6423
  if (!this._groups.has(view.id)) {
6217
- const disposable = new CompositeDisposable(view.model.onMove((event) => {
6424
+ const disposable = new CompositeDisposable(view.model.onTabDragStart((event) => {
6425
+ this._onWillDragPanel.fire(event);
6426
+ }), view.model.onGroupDragStart((event) => {
6427
+ this._onWillDragGroup.fire(event);
6428
+ }), view.model.onMove((event) => {
6218
6429
  const { groupId, itemId, target, index } = event;
6219
6430
  this.moveGroupOrPanel(view, groupId, itemId, target, index);
6220
6431
  }), view.model.onDidDrop((event) => {
@@ -6253,13 +6464,6 @@ class DockviewComponent extends BaseGrid {
6253
6464
  var _a;
6254
6465
  return (_a = Array.from(this._groups.values()).find((group) => group.value.model.containsPanel(panel))) === null || _a === void 0 ? void 0 : _a.value;
6255
6466
  }
6256
- dispose() {
6257
- this._onDidActivePanelChange.dispose();
6258
- this._onDidAddPanel.dispose();
6259
- this._onDidRemovePanel.dispose();
6260
- this._onDidLayoutFromJSON.dispose();
6261
- super.dispose();
6262
- }
6263
6467
  }
6264
6468
 
6265
6469
  class GridviewComponent extends BaseGrid {
@@ -6335,43 +6539,64 @@ class GridviewComponent extends BaseGrid {
6335
6539
  fromJSON(serializedGridview) {
6336
6540
  this.clear();
6337
6541
  const { grid, activePanel } = serializedGridview;
6338
- const queue = [];
6339
- // take note of the existing dimensions
6340
- const width = this.width;
6341
- const height = this.height;
6342
- this.gridview.deserialize(grid, {
6343
- fromJSON: (node) => {
6344
- const { data } = node;
6345
- const view = createComponent(data.id, data.component, this.options.components || {}, this.options.frameworkComponents || {}, this.options.frameworkComponentFactory
6346
- ? {
6347
- createComponent: this.options.frameworkComponentFactory
6348
- .createComponent,
6349
- }
6350
- : undefined);
6351
- queue.push(() => view.init({
6352
- params: data.params,
6353
- minimumWidth: data.minimumWidth,
6354
- maximumWidth: data.maximumWidth,
6355
- minimumHeight: data.minimumHeight,
6356
- maximumHeight: data.maximumHeight,
6357
- priority: data.priority,
6358
- snap: !!data.snap,
6359
- accessor: this,
6360
- isVisible: node.visible,
6361
- }));
6362
- this._onDidAddGroup.fire(view);
6363
- this.registerPanel(view);
6364
- return view;
6365
- },
6366
- });
6367
- this.layout(width, height, true);
6368
- queue.forEach((f) => f());
6369
- if (typeof activePanel === 'string') {
6370
- const panel = this.getPanel(activePanel);
6371
- if (panel) {
6372
- this.doSetGroupActive(panel);
6542
+ try {
6543
+ const queue = [];
6544
+ // take note of the existing dimensions
6545
+ const width = this.width;
6546
+ const height = this.height;
6547
+ this.gridview.deserialize(grid, {
6548
+ fromJSON: (node) => {
6549
+ const { data } = node;
6550
+ const view = createComponent(data.id, data.component, this.options.components || {}, this.options.frameworkComponents || {}, this.options.frameworkComponentFactory
6551
+ ? {
6552
+ createComponent: this.options.frameworkComponentFactory
6553
+ .createComponent,
6554
+ }
6555
+ : undefined);
6556
+ queue.push(() => view.init({
6557
+ params: data.params,
6558
+ minimumWidth: data.minimumWidth,
6559
+ maximumWidth: data.maximumWidth,
6560
+ minimumHeight: data.minimumHeight,
6561
+ maximumHeight: data.maximumHeight,
6562
+ priority: data.priority,
6563
+ snap: !!data.snap,
6564
+ accessor: this,
6565
+ isVisible: node.visible,
6566
+ }));
6567
+ this._onDidAddGroup.fire(view);
6568
+ this.registerPanel(view);
6569
+ return view;
6570
+ },
6571
+ });
6572
+ this.layout(width, height, true);
6573
+ queue.forEach((f) => f());
6574
+ if (typeof activePanel === 'string') {
6575
+ const panel = this.getPanel(activePanel);
6576
+ if (panel) {
6577
+ this.doSetGroupActive(panel);
6578
+ }
6373
6579
  }
6374
6580
  }
6581
+ catch (err) {
6582
+ /**
6583
+ * To remove a group we cannot call this.removeGroup(...) since this makes assumptions about
6584
+ * the underlying HTMLElement existing in the Gridview.
6585
+ */
6586
+ for (const group of this.groups) {
6587
+ group.dispose();
6588
+ this._groups.delete(group.id);
6589
+ this._onDidRemoveGroup.fire(group);
6590
+ }
6591
+ // fires clean-up events and clears the underlying HTML gridview.
6592
+ this.clear();
6593
+ /**
6594
+ * even though we have cleaned-up we still want to inform the caller of their error
6595
+ * and we'll do this through re-throwing the original error since afterall you would
6596
+ * expect trying to load a corrupted layout to result in an error and not silently fail...
6597
+ */
6598
+ throw err;
6599
+ }
6375
6600
  this._onDidLayoutfromJSON.fire();
6376
6601
  }
6377
6602
  clear() {