dockview-core 1.7.6 → 1.8.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 (214) hide show
  1. package/README.md +2 -1
  2. package/dist/cjs/api/component.api.d.ts +6 -1
  3. package/dist/cjs/api/component.api.d.ts.map +1 -1
  4. package/dist/cjs/api/component.api.js +6 -0
  5. package/dist/cjs/api/component.api.js.map +1 -1
  6. package/dist/cjs/api/dockviewGroupPanelApi.d.ts +30 -0
  7. package/dist/cjs/api/dockviewGroupPanelApi.d.ts.map +1 -0
  8. package/dist/cjs/api/dockviewGroupPanelApi.js +54 -0
  9. package/dist/cjs/api/dockviewGroupPanelApi.js.map +1 -0
  10. package/dist/cjs/api/dockviewPanelApi.d.ts +14 -1
  11. package/dist/cjs/api/dockviewPanelApi.d.ts.map +1 -1
  12. package/dist/cjs/api/dockviewPanelApi.js +6 -1
  13. package/dist/cjs/api/dockviewPanelApi.js.map +1 -1
  14. package/dist/cjs/array.d.ts +1 -0
  15. package/dist/cjs/array.d.ts.map +1 -1
  16. package/dist/cjs/array.js +10 -1
  17. package/dist/cjs/array.js.map +1 -1
  18. package/dist/cjs/dnd/abstractDragHandler.d.ts +1 -0
  19. package/dist/cjs/dnd/abstractDragHandler.d.ts.map +1 -1
  20. package/dist/cjs/dnd/abstractDragHandler.js +7 -0
  21. package/dist/cjs/dnd/abstractDragHandler.js.map +1 -1
  22. package/dist/cjs/dnd/droptarget.d.ts +11 -0
  23. package/dist/cjs/dnd/droptarget.d.ts.map +1 -1
  24. package/dist/cjs/dnd/droptarget.js +32 -9
  25. package/dist/cjs/dnd/droptarget.js.map +1 -1
  26. package/dist/cjs/dnd/groupDragHandler.d.ts +1 -0
  27. package/dist/cjs/dnd/groupDragHandler.d.ts.map +1 -1
  28. package/dist/cjs/dnd/groupDragHandler.js +18 -0
  29. package/dist/cjs/dnd/groupDragHandler.js.map +1 -1
  30. package/dist/cjs/dnd/overlay.d.ts +40 -0
  31. package/dist/cjs/dnd/overlay.d.ts.map +1 -0
  32. package/dist/cjs/dnd/overlay.js +382 -0
  33. package/dist/cjs/dnd/overlay.js.map +1 -0
  34. package/dist/cjs/dockview/components/tab/tab.d.ts +2 -2
  35. package/dist/cjs/dockview/components/tab/tab.d.ts.map +1 -1
  36. package/dist/cjs/dockview/components/tab/tab.js +0 -7
  37. package/dist/cjs/dockview/components/tab/tab.js.map +1 -1
  38. package/dist/cjs/dockview/components/titlebar/tabsContainer.d.ts +8 -4
  39. package/dist/cjs/dockview/components/titlebar/tabsContainer.d.ts.map +1 -1
  40. package/dist/cjs/dockview/components/titlebar/tabsContainer.js +54 -10
  41. package/dist/cjs/dockview/components/titlebar/tabsContainer.js.map +1 -1
  42. package/dist/cjs/dockview/deserializer.d.ts +2 -2
  43. package/dist/cjs/dockview/deserializer.d.ts.map +1 -1
  44. package/dist/cjs/dockview/deserializer.js.map +1 -1
  45. package/dist/cjs/dockview/dockviewComponent.d.ts +41 -9
  46. package/dist/cjs/dockview/dockviewComponent.d.ts.map +1 -1
  47. package/dist/cjs/dockview/dockviewComponent.js +285 -76
  48. package/dist/cjs/dockview/dockviewComponent.js.map +1 -1
  49. package/dist/cjs/dockview/dockviewFloatingGroupPanel.d.ts +24 -0
  50. package/dist/cjs/dockview/dockviewFloatingGroupPanel.d.ts.map +1 -0
  51. package/dist/cjs/dockview/dockviewFloatingGroupPanel.js +35 -0
  52. package/dist/cjs/dockview/dockviewFloatingGroupPanel.js.map +1 -0
  53. package/dist/cjs/dockview/dockviewGroupPanel.d.ts +5 -6
  54. package/dist/cjs/dockview/dockviewGroupPanel.d.ts.map +1 -1
  55. package/dist/cjs/dockview/dockviewGroupPanel.js +3 -2
  56. package/dist/cjs/dockview/dockviewGroupPanel.js.map +1 -1
  57. package/dist/cjs/dockview/dockviewGroupPanelModel.d.ts +5 -1
  58. package/dist/cjs/dockview/dockviewGroupPanelModel.d.ts.map +1 -1
  59. package/dist/cjs/dockview/dockviewGroupPanelModel.js +43 -12
  60. package/dist/cjs/dockview/dockviewGroupPanelModel.js.map +1 -1
  61. package/dist/cjs/dockview/dockviewPanel.d.ts +2 -2
  62. package/dist/cjs/dockview/dockviewPanel.d.ts.map +1 -1
  63. package/dist/cjs/dockview/dockviewPanel.js +1 -1
  64. package/dist/cjs/dockview/dockviewPanel.js.map +1 -1
  65. package/dist/cjs/dockview/options.d.ts +22 -6
  66. package/dist/cjs/dockview/options.d.ts.map +1 -1
  67. package/dist/cjs/dockview/options.js.map +1 -1
  68. package/dist/cjs/dom.d.ts +5 -3
  69. package/dist/cjs/dom.d.ts.map +1 -1
  70. package/dist/cjs/dom.js +13 -1
  71. package/dist/cjs/dom.js.map +1 -1
  72. package/dist/cjs/events.d.ts.map +1 -1
  73. package/dist/cjs/gridview/branchNode.js +2 -2
  74. package/dist/cjs/gridview/branchNode.js.map +1 -1
  75. package/dist/cjs/gridview/gridview.d.ts.map +1 -1
  76. package/dist/cjs/gridview/gridview.js +9 -7
  77. package/dist/cjs/gridview/gridview.js.map +1 -1
  78. package/dist/cjs/gridview/gridviewComponent.d.ts.map +1 -1
  79. package/dist/cjs/gridview/gridviewComponent.js +4 -1
  80. package/dist/cjs/gridview/gridviewComponent.js.map +1 -1
  81. package/dist/cjs/gridview/gridviewPanel.d.ts +3 -3
  82. package/dist/cjs/gridview/gridviewPanel.d.ts.map +1 -1
  83. package/dist/cjs/gridview/gridviewPanel.js +2 -2
  84. package/dist/cjs/gridview/gridviewPanel.js.map +1 -1
  85. package/dist/cjs/index.d.ts +1 -1
  86. package/dist/cjs/index.d.ts.map +1 -1
  87. package/dist/cjs/index.js +1 -3
  88. package/dist/cjs/index.js.map +1 -1
  89. package/dist/cjs/math.d.ts.map +1 -1
  90. package/dist/cjs/paneview/paneviewComponent.d.ts.map +1 -1
  91. package/dist/cjs/paneview/paneviewComponent.js +4 -1
  92. package/dist/cjs/paneview/paneviewComponent.js.map +1 -1
  93. package/dist/cjs/splitview/splitviewComponent.d.ts.map +1 -1
  94. package/dist/cjs/splitview/splitviewComponent.js +4 -1
  95. package/dist/cjs/splitview/splitviewComponent.js.map +1 -1
  96. package/dist/dockview-core.amd.js +772 -133
  97. package/dist/dockview-core.amd.js.map +1 -0
  98. package/dist/dockview-core.amd.min.js +3 -2
  99. package/dist/dockview-core.amd.min.js.map +1 -0
  100. package/dist/dockview-core.amd.min.noStyle.js +3 -2
  101. package/dist/dockview-core.amd.min.noStyle.js.map +1 -0
  102. package/dist/dockview-core.amd.noStyle.js +771 -132
  103. package/dist/dockview-core.amd.noStyle.js.map +1 -0
  104. package/dist/dockview-core.cjs.js +772 -133
  105. package/dist/dockview-core.cjs.js.map +1 -0
  106. package/dist/dockview-core.esm.js +773 -133
  107. package/dist/dockview-core.esm.js.map +1 -0
  108. package/dist/dockview-core.esm.min.js +3 -2
  109. package/dist/dockview-core.esm.min.js.map +1 -0
  110. package/dist/dockview-core.js +772 -133
  111. package/dist/dockview-core.js.map +1 -0
  112. package/dist/dockview-core.min.js +3 -2
  113. package/dist/dockview-core.min.js.map +1 -0
  114. package/dist/dockview-core.min.noStyle.js +3 -2
  115. package/dist/dockview-core.min.noStyle.js.map +1 -0
  116. package/dist/dockview-core.noStyle.js +771 -132
  117. package/dist/dockview-core.noStyle.js.map +1 -0
  118. package/dist/esm/api/component.api.d.ts +6 -1
  119. package/dist/esm/api/component.api.d.ts.map +1 -1
  120. package/dist/esm/api/component.api.js +6 -0
  121. package/dist/esm/api/component.api.js.map +1 -1
  122. package/dist/esm/api/dockviewGroupPanelApi.d.ts +30 -0
  123. package/dist/esm/api/dockviewGroupPanelApi.d.ts.map +1 -0
  124. package/dist/esm/api/dockviewGroupPanelApi.js +28 -0
  125. package/dist/esm/api/dockviewGroupPanelApi.js.map +1 -0
  126. package/dist/esm/api/dockviewPanelApi.d.ts +14 -1
  127. package/dist/esm/api/dockviewPanelApi.d.ts.map +1 -1
  128. package/dist/esm/api/dockviewPanelApi.js +6 -1
  129. package/dist/esm/api/dockviewPanelApi.js.map +1 -1
  130. package/dist/esm/array.d.ts +1 -0
  131. package/dist/esm/array.d.ts.map +1 -1
  132. package/dist/esm/array.js +8 -0
  133. package/dist/esm/array.js.map +1 -1
  134. package/dist/esm/dnd/abstractDragHandler.d.ts +1 -0
  135. package/dist/esm/dnd/abstractDragHandler.d.ts.map +1 -1
  136. package/dist/esm/dnd/abstractDragHandler.js +7 -0
  137. package/dist/esm/dnd/abstractDragHandler.js.map +1 -1
  138. package/dist/esm/dnd/droptarget.d.ts +11 -0
  139. package/dist/esm/dnd/droptarget.d.ts.map +1 -1
  140. package/dist/esm/dnd/droptarget.js +32 -9
  141. package/dist/esm/dnd/droptarget.js.map +1 -1
  142. package/dist/esm/dnd/groupDragHandler.d.ts +1 -0
  143. package/dist/esm/dnd/groupDragHandler.d.ts.map +1 -1
  144. package/dist/esm/dnd/groupDragHandler.js +18 -0
  145. package/dist/esm/dnd/groupDragHandler.js.map +1 -1
  146. package/dist/esm/dnd/overlay.d.ts +40 -0
  147. package/dist/esm/dnd/overlay.d.ts.map +1 -0
  148. package/dist/esm/dnd/overlay.js +282 -0
  149. package/dist/esm/dnd/overlay.js.map +1 -0
  150. package/dist/esm/dockview/components/tab/tab.d.ts +2 -2
  151. package/dist/esm/dockview/components/tab/tab.d.ts.map +1 -1
  152. package/dist/esm/dockview/components/tab/tab.js +0 -7
  153. package/dist/esm/dockview/components/tab/tab.js.map +1 -1
  154. package/dist/esm/dockview/components/titlebar/tabsContainer.d.ts +8 -4
  155. package/dist/esm/dockview/components/titlebar/tabsContainer.d.ts.map +1 -1
  156. package/dist/esm/dockview/components/titlebar/tabsContainer.js +54 -10
  157. package/dist/esm/dockview/components/titlebar/tabsContainer.js.map +1 -1
  158. package/dist/esm/dockview/deserializer.d.ts +2 -2
  159. package/dist/esm/dockview/deserializer.d.ts.map +1 -1
  160. package/dist/esm/dockview/deserializer.js.map +1 -1
  161. package/dist/esm/dockview/dockviewComponent.d.ts +41 -9
  162. package/dist/esm/dockview/dockviewComponent.d.ts.map +1 -1
  163. package/dist/esm/dockview/dockviewComponent.js +231 -54
  164. package/dist/esm/dockview/dockviewComponent.js.map +1 -1
  165. package/dist/esm/dockview/dockviewFloatingGroupPanel.d.ts +24 -0
  166. package/dist/esm/dockview/dockviewFloatingGroupPanel.d.ts.map +1 -0
  167. package/dist/esm/dockview/dockviewFloatingGroupPanel.js +13 -0
  168. package/dist/esm/dockview/dockviewFloatingGroupPanel.js.map +1 -0
  169. package/dist/esm/dockview/dockviewGroupPanel.d.ts +5 -6
  170. package/dist/esm/dockview/dockviewGroupPanel.d.ts.map +1 -1
  171. package/dist/esm/dockview/dockviewGroupPanel.js +3 -2
  172. package/dist/esm/dockview/dockviewGroupPanel.js.map +1 -1
  173. package/dist/esm/dockview/dockviewGroupPanelModel.d.ts +5 -1
  174. package/dist/esm/dockview/dockviewGroupPanelModel.d.ts.map +1 -1
  175. package/dist/esm/dockview/dockviewGroupPanelModel.js +36 -9
  176. package/dist/esm/dockview/dockviewGroupPanelModel.js.map +1 -1
  177. package/dist/esm/dockview/dockviewPanel.d.ts +2 -2
  178. package/dist/esm/dockview/dockviewPanel.d.ts.map +1 -1
  179. package/dist/esm/dockview/dockviewPanel.js +1 -1
  180. package/dist/esm/dockview/dockviewPanel.js.map +1 -1
  181. package/dist/esm/dockview/options.d.ts +22 -6
  182. package/dist/esm/dockview/options.d.ts.map +1 -1
  183. package/dist/esm/dockview/options.js.map +1 -1
  184. package/dist/esm/dom.d.ts +5 -3
  185. package/dist/esm/dom.d.ts.map +1 -1
  186. package/dist/esm/dom.js +10 -0
  187. package/dist/esm/dom.js.map +1 -1
  188. package/dist/esm/events.d.ts.map +1 -1
  189. package/dist/esm/gridview/branchNode.js +2 -2
  190. package/dist/esm/gridview/branchNode.js.map +1 -1
  191. package/dist/esm/gridview/gridview.d.ts.map +1 -1
  192. package/dist/esm/gridview/gridview.js +9 -6
  193. package/dist/esm/gridview/gridview.js.map +1 -1
  194. package/dist/esm/gridview/gridviewComponent.d.ts.map +1 -1
  195. package/dist/esm/gridview/gridviewComponent.js +4 -1
  196. package/dist/esm/gridview/gridviewComponent.js.map +1 -1
  197. package/dist/esm/gridview/gridviewPanel.d.ts +3 -3
  198. package/dist/esm/gridview/gridviewPanel.d.ts.map +1 -1
  199. package/dist/esm/gridview/gridviewPanel.js +2 -2
  200. package/dist/esm/gridview/gridviewPanel.js.map +1 -1
  201. package/dist/esm/index.d.ts +1 -1
  202. package/dist/esm/index.d.ts.map +1 -1
  203. package/dist/esm/index.js +0 -1
  204. package/dist/esm/index.js.map +1 -1
  205. package/dist/esm/math.d.ts.map +1 -1
  206. package/dist/esm/math.js.map +1 -1
  207. package/dist/esm/paneview/paneviewComponent.d.ts.map +1 -1
  208. package/dist/esm/paneview/paneviewComponent.js +4 -1
  209. package/dist/esm/paneview/paneviewComponent.js.map +1 -1
  210. package/dist/esm/splitview/splitviewComponent.d.ts.map +1 -1
  211. package/dist/esm/splitview/splitviewComponent.js +4 -1
  212. package/dist/esm/splitview/splitviewComponent.js.map +1 -1
  213. package/dist/styles/dockview.css +216 -1
  214. package/package.json +5 -5
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * dockview-core
3
- * @version 1.7.6
3
+ * @version 1.8.1
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -277,6 +277,31 @@
277
277
  }
278
278
  }
279
279
 
280
+ function createComponent(id, componentName, components = {}, frameworkComponents = {}, createFrameworkComponent, fallback) {
281
+ const Component = typeof componentName === 'string'
282
+ ? components[componentName]
283
+ : undefined;
284
+ const FrameworkComponent = typeof componentName === 'string'
285
+ ? frameworkComponents[componentName]
286
+ : undefined;
287
+ if (Component && FrameworkComponent) {
288
+ throw new Error(`Cannot create '${id}'. component '${componentName}' registered as both a component and frameworkComponent`);
289
+ }
290
+ if (FrameworkComponent) {
291
+ if (!createFrameworkComponent) {
292
+ throw new Error(`Cannot create '${id}' for framework component '${componentName}'. you must register a frameworkPanelWrapper to use framework components`);
293
+ }
294
+ return createFrameworkComponent.createComponent(id, componentName, FrameworkComponent);
295
+ }
296
+ if (!Component) {
297
+ if (fallback) {
298
+ return fallback();
299
+ }
300
+ throw new Error(`Cannot create '${id}', no component '${componentName}' provided`);
301
+ }
302
+ return new Component(id, componentName);
303
+ }
304
+
280
305
  function watchElementResize(element, cb) {
281
306
  const observer = new ResizeObserver((entires) => {
282
307
  /**
@@ -390,31 +415,16 @@
390
415
  refreshState() {
391
416
  this._refreshStateHandler();
392
417
  }
393
- }
394
-
395
- function createComponent(id, componentName, components = {}, frameworkComponents = {}, createFrameworkComponent, fallback) {
396
- const Component = typeof componentName === 'string'
397
- ? components[componentName]
398
- : undefined;
399
- const FrameworkComponent = typeof componentName === 'string'
400
- ? frameworkComponents[componentName]
401
- : undefined;
402
- if (Component && FrameworkComponent) {
403
- throw new Error(`Cannot create '${id}'. component '${componentName}' registered as both a component and frameworkComponent`);
404
- }
405
- if (FrameworkComponent) {
406
- if (!createFrameworkComponent) {
407
- throw new Error(`Cannot create '${id}' for framework component '${componentName}'. you must register a frameworkPanelWrapper to use framework components`);
408
- }
409
- return createFrameworkComponent.createComponent(id, componentName, FrameworkComponent);
410
- }
411
- if (!Component) {
412
- if (fallback) {
413
- return fallback();
414
- }
415
- throw new Error(`Cannot create '${id}', no component '${componentName}' provided`);
416
- }
417
- return new Component(id, componentName);
418
+ }
419
+ // quasi: apparently, but not really; seemingly
420
+ const QUASI_PREVENT_DEFAULT_KEY = 'dv-quasiPreventDefault';
421
+ // mark an event directly for other listeners to check
422
+ function quasiPreventDefault(event) {
423
+ event[QUASI_PREVENT_DEFAULT_KEY] = true;
424
+ }
425
+ // check if this event has been marked
426
+ function quasiDefaultPrevented(event) {
427
+ return event[QUASI_PREVENT_DEFAULT_KEY];
418
428
  }
419
429
 
420
430
  function tail(arr) {
@@ -465,6 +475,14 @@
465
475
  }
466
476
  }
467
477
  return -1;
478
+ }
479
+ function remove(array, value) {
480
+ const index = array.findIndex((t) => t === value);
481
+ if (index > -1) {
482
+ array.splice(index, 1);
483
+ return true;
484
+ }
485
+ return false;
468
486
  }
469
487
 
470
488
  const clamp = (value, min, max) => {
@@ -1607,7 +1625,7 @@
1607
1625
  : true,
1608
1626
  };
1609
1627
  }),
1610
- size: this.size,
1628
+ size: this.orthogonalSize,
1611
1629
  };
1612
1630
  this.children = childDescriptors.map((c) => c.node);
1613
1631
  this.splitview = new Splitview(this.element, {
@@ -1670,7 +1688,7 @@
1670
1688
  layout(size, orthogonalSize) {
1671
1689
  this._size = orthogonalSize;
1672
1690
  this._orthogonalSize = size;
1673
- this.splitview.layout(this.size, this.orthogonalSize);
1691
+ this.splitview.layout(orthogonalSize, size);
1674
1692
  }
1675
1693
  addChild(node, size, index, skipLayout) {
1676
1694
  if (index < 0 || index > this.children.length) {
@@ -1895,9 +1913,9 @@
1895
1913
  this._deserialize(json.root, orientation, deserializer, height);
1896
1914
  }
1897
1915
  _deserialize(root, orientation, deserializer, orthogonalSize) {
1898
- this.root = this._deserializeNode(root, orientation, deserializer, orthogonalSize, true);
1916
+ this.root = this._deserializeNode(root, orientation, deserializer, orthogonalSize);
1899
1917
  }
1900
- _deserializeNode(node, orientation, deserializer, orthogonalSize, isRoot = false) {
1918
+ _deserializeNode(node, orientation, deserializer, orthogonalSize) {
1901
1919
  let result;
1902
1920
  if (node.type === 'branch') {
1903
1921
  const serializedChildren = node.data;
@@ -1907,9 +1925,9 @@
1907
1925
  visible: serializedChild.visible,
1908
1926
  };
1909
1927
  });
1910
- // HORIZONTAL => height=orthogonalsize width=size
1911
- // VERTICAL => height=size width=orthogonalsize
1912
- result = new BranchNode(orientation, this.proportionalLayout, this.styles, isRoot ? orthogonalSize : node.size, isRoot ? node.size : orthogonalSize, children);
1928
+ result = new BranchNode(orientation, this.proportionalLayout, this.styles, node.size, // <- orthogonal size - flips at each depth
1929
+ orthogonalSize, // <- size - flips at each depth
1930
+ children);
1913
1931
  }
1914
1932
  else {
1915
1933
  result = new LeafNode(deserializer.fromJSON(node), orientation, orthogonalSize, node.size);
@@ -1942,7 +1960,8 @@
1942
1960
  const oldRoot = this.root;
1943
1961
  oldRoot.element.remove();
1944
1962
  this._root = new BranchNode(orthogonal(oldRoot.orientation), this.proportionalLayout, this.styles, this.root.orthogonalSize, this.root.size);
1945
- if (oldRoot.children.length === 1) {
1963
+ if (oldRoot.children.length === 0) ;
1964
+ else if (oldRoot.children.length === 1) {
1946
1965
  // can remove one level of redundant branching if there is only a single child
1947
1966
  const childReference = oldRoot.children[0];
1948
1967
  const child = oldRoot.removeChild(0); // remove to prevent disposal when disposing of unwanted root
@@ -2458,6 +2477,9 @@
2458
2477
  addPanel(options) {
2459
2478
  return this.component.addPanel(options);
2460
2479
  }
2480
+ removePanel(panel) {
2481
+ this.component.removePanel(panel);
2482
+ }
2461
2483
  addGroup(options) {
2462
2484
  return this.component.addGroup(options);
2463
2485
  }
@@ -2476,6 +2498,9 @@
2476
2498
  getGroup(id) {
2477
2499
  return this.component.getPanel(id);
2478
2500
  }
2501
+ addFloatingGroup(item, coord) {
2502
+ return this.component.addFloatingGroup(item, coord);
2503
+ }
2479
2504
  fromJSON(data) {
2480
2505
  this.component.fromJSON(data);
2481
2506
  }
@@ -2568,10 +2593,14 @@
2568
2593
  this._onDrop = new Emitter();
2569
2594
  this.onDrop = this._onDrop.event;
2570
2595
  // use a set to take advantage of #<set>.has
2571
- const acceptedTargetZonesSet = new Set(this.options.acceptedTargetZones);
2596
+ this._acceptedTargetZonesSet = new Set(this.options.acceptedTargetZones);
2572
2597
  this.addDisposables(this._onDrop, new DragAndDropObserver(this.element, {
2573
2598
  onDragEnter: () => undefined,
2574
2599
  onDragOver: (e) => {
2600
+ if (this._acceptedTargetZonesSet.size === 0) {
2601
+ this.removeDropTarget();
2602
+ return;
2603
+ }
2575
2604
  const width = this.element.clientWidth;
2576
2605
  const height = this.element.clientHeight;
2577
2606
  if (width === 0 || height === 0) {
@@ -2580,20 +2609,28 @@
2580
2609
  const rect = e.currentTarget.getBoundingClientRect();
2581
2610
  const x = e.clientX - rect.left;
2582
2611
  const y = e.clientY - rect.top;
2583
- const quadrant = this.calculateQuadrant(acceptedTargetZonesSet, x, y, width, height);
2584
- if (quadrant === null) {
2612
+ const quadrant = this.calculateQuadrant(this._acceptedTargetZonesSet, x, y, width, height);
2613
+ /**
2614
+ * If the event has already been used by another DropTarget instance
2615
+ * then don't show a second drop target, only one target should be
2616
+ * active at any one time
2617
+ */
2618
+ if (this.isAlreadyUsed(e) || quadrant === null) {
2585
2619
  // no drop target should be displayed
2586
2620
  this.removeDropTarget();
2587
2621
  return;
2588
2622
  }
2589
2623
  if (typeof this.options.canDisplayOverlay === 'boolean') {
2590
2624
  if (!this.options.canDisplayOverlay) {
2625
+ this.removeDropTarget();
2591
2626
  return;
2592
2627
  }
2593
2628
  }
2594
2629
  else if (!this.options.canDisplayOverlay(e, quadrant)) {
2630
+ this.removeDropTarget();
2595
2631
  return;
2596
2632
  }
2633
+ this.markAsUsed(e);
2597
2634
  if (!this.targetElement) {
2598
2635
  this.targetElement = document.createElement('div');
2599
2636
  this.targetElement.className = 'drop-target-dropzone';
@@ -2604,12 +2641,6 @@
2604
2641
  this.element.classList.add('drop-target');
2605
2642
  this.element.append(this.targetElement);
2606
2643
  }
2607
- if (this.options.acceptedTargetZones.length === 0) {
2608
- return;
2609
- }
2610
- if (!this.targetElement || !this.overlayElement) {
2611
- return;
2612
- }
2613
2644
  this.toggleClasses(quadrant, width, height);
2614
2645
  this.setState(quadrant);
2615
2646
  },
@@ -2632,10 +2663,26 @@
2632
2663
  },
2633
2664
  }));
2634
2665
  }
2666
+ setTargetZones(acceptedTargetZones) {
2667
+ this._acceptedTargetZonesSet = new Set(acceptedTargetZones);
2668
+ }
2635
2669
  dispose() {
2636
2670
  this.removeDropTarget();
2637
2671
  super.dispose();
2638
2672
  }
2673
+ /**
2674
+ * Add a property to the event object for other potential listeners to check
2675
+ */
2676
+ markAsUsed(event) {
2677
+ event[Droptarget.USED_EVENT_ID] = true;
2678
+ }
2679
+ /**
2680
+ * Check is the event has already been used by another instance od DropTarget
2681
+ */
2682
+ isAlreadyUsed(event) {
2683
+ const value = event[Droptarget.USED_EVENT_ID];
2684
+ return typeof value === 'boolean' && value;
2685
+ }
2639
2686
  toggleClasses(quadrant, width, height) {
2640
2687
  var _a, _b, _c, _d;
2641
2688
  if (!this.overlayElement) {
@@ -2730,6 +2777,7 @@
2730
2777
  }
2731
2778
  }
2732
2779
  }
2780
+ Droptarget.USED_EVENT_ID = '__dockview_droptarget_event_is_used__';
2733
2781
  function calculateQuadrantAsPercentage(overlayType, x, y, width, height, threshold) {
2734
2782
  const xp = (100 * x) / width;
2735
2783
  const yp = (100 * y) / height;
@@ -2859,8 +2907,15 @@
2859
2907
  this.addDisposables(this._onDragStart, this.dataDisposable, this.pointerEventsDisposable);
2860
2908
  this.configure();
2861
2909
  }
2910
+ isCancelled(_event) {
2911
+ return false;
2912
+ }
2862
2913
  configure() {
2863
2914
  this.addDisposables(this._onDragStart, addDisposableListener(this.el, 'dragstart', (event) => {
2915
+ if (this.isCancelled(event)) {
2916
+ event.preventDefault();
2917
+ return;
2918
+ }
2864
2919
  const iframes = [
2865
2920
  ...getElementsByTagName('iframe'),
2866
2921
  ...getElementsByTagName('webview'),
@@ -2934,13 +2989,6 @@
2934
2989
  if (event.defaultPrevented) {
2935
2990
  return;
2936
2991
  }
2937
- /**
2938
- * TODO: alternative to stopPropagation
2939
- *
2940
- * I need to stop the event propagation here since otherwise it'll be intercepted by event handlers
2941
- * on the tabs-container. I cannot use event.preventDefault() since I need the on DragStart event to occur
2942
- */
2943
- event.stopPropagation();
2944
2992
  this._onChanged.fire(event);
2945
2993
  }));
2946
2994
  this.droptarget = new Droptarget(this._element, {
@@ -2998,6 +3046,22 @@
2998
3046
  this.accessorId = accessorId;
2999
3047
  this.group = group;
3000
3048
  this.panelTransfer = LocalSelectionTransfer.getInstance();
3049
+ this.addDisposables(addDisposableListener(element, 'mousedown', (e) => {
3050
+ if (e.shiftKey) {
3051
+ /**
3052
+ * You cannot call e.preventDefault() because that will prevent drag events from firing
3053
+ * but we also need to stop any group overlay drag events from occuring
3054
+ * Use a custom event marker that can be checked by the overlay drag events
3055
+ */
3056
+ quasiPreventDefault(e);
3057
+ }
3058
+ }, true));
3059
+ }
3060
+ isCancelled(_event) {
3061
+ if (this.group.api.isFloating && !_event.shiftKey) {
3062
+ return true;
3063
+ }
3064
+ return false;
3001
3065
  }
3002
3066
  getData(dataTransfer) {
3003
3067
  this.panelTransfer.setData([new PanelTransfer(this.accessorId, this.group.id, null)], PanelTransfer.prototype);
@@ -3088,17 +3152,30 @@
3088
3152
  hide() {
3089
3153
  this._element.style.display = 'none';
3090
3154
  }
3091
- setActionElement(element) {
3092
- if (this.actions === element) {
3155
+ setRightActionsElement(element) {
3156
+ if (this.rightActions === element) {
3093
3157
  return;
3094
3158
  }
3095
- if (this.actions) {
3096
- this.actions.remove();
3097
- this.actions = undefined;
3159
+ if (this.rightActions) {
3160
+ this.rightActions.remove();
3161
+ this.rightActions = undefined;
3098
3162
  }
3099
3163
  if (element) {
3100
- this.actionContainer.appendChild(element);
3101
- this.actions = element;
3164
+ this.rightActionsContainer.appendChild(element);
3165
+ this.rightActions = element;
3166
+ }
3167
+ }
3168
+ setLeftActionsElement(element) {
3169
+ if (this.leftActions === element) {
3170
+ return;
3171
+ }
3172
+ if (this.leftActions) {
3173
+ this.leftActions.remove();
3174
+ this.leftActions = undefined;
3175
+ }
3176
+ if (element) {
3177
+ this.leftActionsContainer.appendChild(element);
3178
+ this.leftActions = element;
3102
3179
  }
3103
3180
  }
3104
3181
  get element() {
@@ -3133,19 +3210,35 @@
3133
3210
  toggleClass(this._element, 'dv-single-tab', this.size === 1);
3134
3211
  }
3135
3212
  }));
3136
- this.actionContainer = document.createElement('div');
3137
- this.actionContainer.className = 'action-container';
3213
+ this.rightActionsContainer = document.createElement('div');
3214
+ this.rightActionsContainer.className = 'right-actions-container';
3215
+ this.leftActionsContainer = document.createElement('div');
3216
+ this.leftActionsContainer.className = 'left-actions-container';
3138
3217
  this.tabContainer = document.createElement('div');
3139
3218
  this.tabContainer.className = 'tabs-container';
3140
3219
  this.voidContainer = new VoidContainer(this.accessor, this.group);
3141
3220
  this._element.appendChild(this.tabContainer);
3221
+ this._element.appendChild(this.leftActionsContainer);
3142
3222
  this._element.appendChild(this.voidContainer.element);
3143
- this._element.appendChild(this.actionContainer);
3223
+ this._element.appendChild(this.rightActionsContainer);
3144
3224
  this.addDisposables(this.voidContainer, this.voidContainer.onDrop((event) => {
3145
3225
  this._onDrop.fire({
3146
3226
  event: event.nativeEvent,
3147
3227
  index: this.tabs.length,
3148
3228
  });
3229
+ }), addDisposableListener(this.voidContainer.element, 'mousedown', (event) => {
3230
+ const isFloatingGroupsEnabled = !this.accessor.options.disableFloatingGroups;
3231
+ if (isFloatingGroupsEnabled &&
3232
+ event.shiftKey &&
3233
+ !this.group.api.isFloating) {
3234
+ event.preventDefault();
3235
+ const { top, left } = this.element.getBoundingClientRect();
3236
+ const { top: rootTop, left: rootLeft } = this.accessor.element.getBoundingClientRect();
3237
+ this.accessor.addFloatingGroup(this.group, {
3238
+ x: left - rootLeft + 20,
3239
+ y: top - rootTop + 20,
3240
+ }, { inDragMode: true });
3241
+ }
3149
3242
  }), addDisposableListener(this.tabContainer, 'mousedown', (event) => {
3150
3243
  if (event.defaultPrevented) {
3151
3244
  return;
@@ -3199,6 +3292,21 @@
3199
3292
  tabToAdd.setContent(panel.view.tab);
3200
3293
  const disposable = CompositeDisposable.from(tabToAdd.onChanged((event) => {
3201
3294
  var _a;
3295
+ const isFloatingGroupsEnabled = !this.accessor.options.disableFloatingGroups;
3296
+ const isFloatingWithOnePanel = this.group.api.isFloating && this.size === 1;
3297
+ if (isFloatingGroupsEnabled &&
3298
+ !isFloatingWithOnePanel &&
3299
+ event.shiftKey) {
3300
+ event.preventDefault();
3301
+ const panel = this.accessor.getGroupPanel(tabToAdd.panelId);
3302
+ const { top, left } = tabToAdd.element.getBoundingClientRect();
3303
+ const { top: rootTop, left: rootLeft } = this.accessor.element.getBoundingClientRect();
3304
+ this.accessor.addFloatingGroup(panel, {
3305
+ x: left - rootLeft,
3306
+ y: top - rootTop,
3307
+ }, { inDragMode: true });
3308
+ return;
3309
+ }
3202
3310
  const alreadyFocused = panel.id === ((_a = this.group.model.activePanel) === null || _a === void 0 ? void 0 : _a.id) &&
3203
3311
  this.group.model.isContentFocused;
3204
3312
  const isLeftClick = event.button === 0;
@@ -3268,6 +3376,17 @@
3268
3376
  }
3269
3377
  return isAncestor(document.activeElement, this.contentContainer.element);
3270
3378
  }
3379
+ get isFloating() {
3380
+ return this._isFloating;
3381
+ }
3382
+ set isFloating(value) {
3383
+ this._isFloating = value;
3384
+ this.dropTarget.setTargetZones(value ? ['center'] : ['top', 'bottom', 'left', 'right', 'center']);
3385
+ toggleClass(this.container, 'dv-groupview-floating', value);
3386
+ this.groupPanel.api._onDidFloatingStateChange.fire({
3387
+ isFloating: this.isFloating,
3388
+ });
3389
+ }
3271
3390
  constructor(container, accessor, id, options, groupPanel) {
3272
3391
  super();
3273
3392
  this.container = container;
@@ -3277,6 +3396,7 @@
3277
3396
  this.groupPanel = groupPanel;
3278
3397
  this._isGroupActive = false;
3279
3398
  this._locked = false;
3399
+ this._isFloating = false;
3280
3400
  this.mostRecentlyUsed = [];
3281
3401
  this._onDidChange = new Emitter();
3282
3402
  this.onDidChange = this._onDidChange.event;
@@ -3293,7 +3413,7 @@
3293
3413
  this.onDidRemovePanel = this._onDidRemovePanel.event;
3294
3414
  this._onDidActivePanelChange = new Emitter();
3295
3415
  this.onDidActivePanelChange = this._onDidActivePanelChange.event;
3296
- this.container.classList.add('groupview');
3416
+ toggleClass(this.container, 'groupview', true);
3297
3417
  this.tabsContainer = new TabsContainer(this.accessor, this.groupPanel);
3298
3418
  this.contentContainer = new ContentContainer();
3299
3419
  this.dropTarget = new Droptarget(this.contentContainer.element, {
@@ -3303,6 +3423,9 @@
3303
3423
  return false;
3304
3424
  }
3305
3425
  const data = getPanelData();
3426
+ if (!data && event.shiftKey && !this.isFloating) {
3427
+ return false;
3428
+ }
3306
3429
  if (data && data.viewId === this.accessor.id) {
3307
3430
  if (data.groupId === this.id) {
3308
3431
  if (position === 'center') {
@@ -3347,14 +3470,25 @@
3347
3470
  // correctly initialized
3348
3471
  this.setActive(this.isActive, true, true);
3349
3472
  this.updateContainer();
3350
- if (this.accessor.options.createGroupControlElement) {
3351
- this._control = this.accessor.options.createGroupControlElement(this.groupPanel);
3352
- this.addDisposables(this._control);
3353
- this._control.init({
3473
+ if (this.accessor.options.createRightHeaderActionsElement) {
3474
+ this._rightHeaderActions =
3475
+ this.accessor.options.createRightHeaderActionsElement(this.groupPanel);
3476
+ this.addDisposables(this._rightHeaderActions);
3477
+ this._rightHeaderActions.init({
3478
+ containerApi: new DockviewApi(this.accessor),
3479
+ api: this.groupPanel.api,
3480
+ });
3481
+ this.tabsContainer.setRightActionsElement(this._rightHeaderActions.element);
3482
+ }
3483
+ if (this.accessor.options.createLeftHeaderActionsElement) {
3484
+ this._leftHeaderActions =
3485
+ this.accessor.options.createLeftHeaderActionsElement(this.groupPanel);
3486
+ this.addDisposables(this._leftHeaderActions);
3487
+ this._leftHeaderActions.init({
3354
3488
  containerApi: new DockviewApi(this.accessor),
3355
3489
  api: this.groupPanel.api,
3356
3490
  });
3357
- this.tabsContainer.setActionElement(this._control.element);
3491
+ this.tabsContainer.setLeftActionsElement(this._leftHeaderActions.element);
3358
3492
  }
3359
3493
  }
3360
3494
  indexOf(panel) {
@@ -3487,7 +3621,7 @@
3487
3621
  return this._activePanel === panel;
3488
3622
  }
3489
3623
  updateActions(element) {
3490
- this.tabsContainer.setActionElement(element);
3624
+ this.tabsContainer.setRightActionsElement(element);
3491
3625
  }
3492
3626
  setActive(isGroupActive, skipFocus = false, force = false) {
3493
3627
  var _a, _b, _c, _d;
@@ -3659,9 +3793,10 @@
3659
3793
  }
3660
3794
  }
3661
3795
  dispose() {
3662
- var _a, _b;
3796
+ var _a, _b, _c;
3663
3797
  super.dispose();
3664
- (_b = (_a = this.watermark) === null || _a === void 0 ? void 0 : _a.dispose) === null || _b === void 0 ? void 0 : _b.call(_a);
3798
+ (_a = this.watermark) === null || _a === void 0 ? void 0 : _a.element.remove();
3799
+ (_c = (_b = this.watermark) === null || _b === void 0 ? void 0 : _b.dispose) === null || _c === void 0 ? void 0 : _c.call(_b);
3665
3800
  for (const panel of this.panels) {
3666
3801
  panel.dispose();
3667
3802
  }
@@ -4455,8 +4590,8 @@
4455
4590
  get isActive() {
4456
4591
  return this.api.isActive;
4457
4592
  }
4458
- constructor(id, component, options) {
4459
- super(id, component, new GridviewPanelApiImpl(id));
4593
+ constructor(id, component, options, api) {
4594
+ super(id, component, api !== null && api !== void 0 ? api : new GridviewPanelApiImpl(id));
4460
4595
  this._evaluatedMinimumWidth = 0;
4461
4596
  this._evaluatedMaximumWidth = Number.MAX_SAFE_INTEGER;
4462
4597
  this._evaluatedMinimumHeight = 0;
@@ -4554,6 +4689,32 @@
4554
4689
  }
4555
4690
  }
4556
4691
 
4692
+ class DockviewGroupPanelApiImpl extends GridviewPanelApiImpl {
4693
+ get isFloating() {
4694
+ if (!this._group) {
4695
+ throw new Error(`DockviewGroupPanelApiImpl not initialized`);
4696
+ }
4697
+ return this._group.model.isFloating;
4698
+ }
4699
+ constructor(id, accessor) {
4700
+ super(id);
4701
+ this.accessor = accessor;
4702
+ this._onDidFloatingStateChange = new Emitter();
4703
+ this.onDidFloatingStateChange = this._onDidFloatingStateChange.event;
4704
+ this.addDisposables(this._onDidFloatingStateChange);
4705
+ }
4706
+ moveTo(options) {
4707
+ var _a;
4708
+ if (!this._group) {
4709
+ throw new Error(`DockviewGroupPanelApiImpl not initialized`);
4710
+ }
4711
+ this.accessor.moveGroupOrPanel(options.group, this._group.id, undefined, (_a = options.position) !== null && _a !== void 0 ? _a : 'center');
4712
+ }
4713
+ initialize(group) {
4714
+ this._group = group;
4715
+ }
4716
+ }
4717
+
4557
4718
  class DockviewGroupPanel extends GridviewPanel {
4558
4719
  get panels() {
4559
4720
  return this._model.panels;
@@ -4580,7 +4741,8 @@
4580
4741
  super(id, 'groupview_default', {
4581
4742
  minimumHeight: 100,
4582
4743
  minimumWidth: 100,
4583
- });
4744
+ }, new DockviewGroupPanelApiImpl(id, accessor));
4745
+ this.api.initialize(this); // cannot use 'this' after after 'super' call
4584
4746
  this._model = new DockviewGroupPanelModel(this.element, accessor, id, options, this);
4585
4747
  }
4586
4748
  initialize() {
@@ -4598,7 +4760,6 @@
4598
4760
  return this._model;
4599
4761
  }
4600
4762
  toJSON() {
4601
- // TODO fix typing
4602
4763
  return this.model.toJSON();
4603
4764
  }
4604
4765
  }
@@ -4652,9 +4813,10 @@
4652
4813
  get group() {
4653
4814
  return this._group;
4654
4815
  }
4655
- constructor(panel, group) {
4816
+ constructor(panel, group, accessor) {
4656
4817
  super(panel.id);
4657
4818
  this.panel = panel;
4819
+ this.accessor = accessor;
4658
4820
  this._onDidTitleChange = new Emitter();
4659
4821
  this.onDidTitleChange = this._onDidTitleChange.event;
4660
4822
  this._onDidActiveGroupChange = new Emitter();
@@ -4666,6 +4828,10 @@
4666
4828
  this._group = group;
4667
4829
  this.addDisposables(this.disposable, this._onDidTitleChange, this._onDidGroupChange, this._onDidActiveGroupChange);
4668
4830
  }
4831
+ moveTo(options) {
4832
+ var _a;
4833
+ this.accessor.moveGroupOrPanel(options.group, this._group.id, this.panel.id, (_a = options.position) !== null && _a !== void 0 ? _a : 'center', options.index);
4834
+ }
4669
4835
  setTitle(title) {
4670
4836
  this.panel.setTitle(title);
4671
4837
  }
@@ -4690,7 +4856,7 @@
4690
4856
  this.containerApi = containerApi;
4691
4857
  this.view = view;
4692
4858
  this._group = group;
4693
- this.api = new DockviewPanelApiImpl(this, this._group);
4859
+ this.api = new DockviewPanelApiImpl(this, this._group, accessor);
4694
4860
  this.addDisposables(this.api.onActiveChange(() => {
4695
4861
  accessor.setActivePanel(this);
4696
4862
  }), this.api.onDidSizeChange((event) => {
@@ -5031,6 +5197,296 @@
5031
5197
  }
5032
5198
  }
5033
5199
 
5200
+ const bringElementToFront = (() => {
5201
+ let previous = null;
5202
+ function pushToTop(element) {
5203
+ if (previous !== element && previous !== null) {
5204
+ toggleClass(previous, 'dv-bring-to-front', false);
5205
+ }
5206
+ toggleClass(element, 'dv-bring-to-front', true);
5207
+ previous = element;
5208
+ }
5209
+ return pushToTop;
5210
+ })();
5211
+ class Overlay extends CompositeDisposable {
5212
+ constructor(options) {
5213
+ super();
5214
+ this.options = options;
5215
+ this._element = document.createElement('div');
5216
+ this._onDidChange = new Emitter();
5217
+ this.onDidChange = this._onDidChange.event;
5218
+ this._onDidChangeEnd = new Emitter();
5219
+ this.onDidChangeEnd = this._onDidChangeEnd.event;
5220
+ this.addDisposables(this._onDidChange, this._onDidChangeEnd);
5221
+ this._element.className = 'dv-resize-container';
5222
+ this.setupResize('top');
5223
+ this.setupResize('bottom');
5224
+ this.setupResize('left');
5225
+ this.setupResize('right');
5226
+ this.setupResize('topleft');
5227
+ this.setupResize('topright');
5228
+ this.setupResize('bottomleft');
5229
+ this.setupResize('bottomright');
5230
+ this._element.appendChild(this.options.content);
5231
+ this.options.container.appendChild(this._element);
5232
+ // if input bad resize within acceptable boundaries
5233
+ this.setBounds({
5234
+ height: this.options.height,
5235
+ width: this.options.width,
5236
+ top: this.options.top,
5237
+ left: this.options.left,
5238
+ });
5239
+ }
5240
+ setBounds(bounds = {}) {
5241
+ if (typeof bounds.height === 'number') {
5242
+ this._element.style.height = `${bounds.height}px`;
5243
+ }
5244
+ if (typeof bounds.width === 'number') {
5245
+ this._element.style.width = `${bounds.width}px`;
5246
+ }
5247
+ if (typeof bounds.top === 'number') {
5248
+ this._element.style.top = `${bounds.top}px`;
5249
+ }
5250
+ if (typeof bounds.left === 'number') {
5251
+ this._element.style.left = `${bounds.left}px`;
5252
+ }
5253
+ const containerRect = this.options.container.getBoundingClientRect();
5254
+ const overlayRect = this._element.getBoundingClientRect();
5255
+ // region: ensure bounds within allowable limits
5256
+ // a minimum width of minimumViewportWidth must be inside the viewport
5257
+ const xOffset = Math.max(0, overlayRect.width - this.options.minimumInViewportWidth);
5258
+ // a minimum height of minimumViewportHeight must be inside the viewport
5259
+ const yOffset = Math.max(0, overlayRect.height - this.options.minimumInViewportHeight);
5260
+ const left = clamp(overlayRect.left - containerRect.left, -xOffset, Math.max(0, containerRect.width - overlayRect.width + xOffset));
5261
+ const top = clamp(overlayRect.top - containerRect.top, -yOffset, Math.max(0, containerRect.height - overlayRect.height + yOffset));
5262
+ this._element.style.left = `${left}px`;
5263
+ this._element.style.top = `${top}px`;
5264
+ this._onDidChange.fire();
5265
+ }
5266
+ toJSON() {
5267
+ const container = this.options.container.getBoundingClientRect();
5268
+ const element = this._element.getBoundingClientRect();
5269
+ return {
5270
+ top: element.top - container.top,
5271
+ left: element.left - container.left,
5272
+ width: element.width,
5273
+ height: element.height,
5274
+ };
5275
+ }
5276
+ setupDrag(dragTarget, options = { inDragMode: false }) {
5277
+ const move = new MutableDisposable();
5278
+ const track = () => {
5279
+ let offset = null;
5280
+ const iframes = [
5281
+ ...getElementsByTagName('iframe'),
5282
+ ...getElementsByTagName('webview'),
5283
+ ];
5284
+ for (const iframe of iframes) {
5285
+ iframe.style.pointerEvents = 'none';
5286
+ }
5287
+ move.value = new CompositeDisposable({
5288
+ dispose: () => {
5289
+ for (const iframe of iframes) {
5290
+ iframe.style.pointerEvents = 'auto';
5291
+ }
5292
+ },
5293
+ }, addDisposableWindowListener(window, 'mousemove', (e) => {
5294
+ const containerRect = this.options.container.getBoundingClientRect();
5295
+ const x = e.clientX - containerRect.left;
5296
+ const y = e.clientY - containerRect.top;
5297
+ toggleClass(this._element, 'dv-resize-container-dragging', true);
5298
+ const overlayRect = this._element.getBoundingClientRect();
5299
+ if (offset === null) {
5300
+ offset = {
5301
+ x: e.clientX - overlayRect.left,
5302
+ y: e.clientY - overlayRect.top,
5303
+ };
5304
+ }
5305
+ const xOffset = Math.max(0, overlayRect.width - this.options.minimumInViewportWidth);
5306
+ const yOffset = Math.max(0, overlayRect.height -
5307
+ this.options.minimumInViewportHeight);
5308
+ const left = clamp(x - offset.x, -xOffset, Math.max(0, containerRect.width - overlayRect.width + xOffset));
5309
+ const top = clamp(y - offset.y, -yOffset, Math.max(0, containerRect.height - overlayRect.height + yOffset));
5310
+ this.setBounds({ top, left });
5311
+ }), addDisposableWindowListener(window, 'mouseup', () => {
5312
+ toggleClass(this._element, 'dv-resize-container-dragging', false);
5313
+ move.dispose();
5314
+ this._onDidChangeEnd.fire();
5315
+ }));
5316
+ };
5317
+ this.addDisposables(move, addDisposableListener(dragTarget, 'mousedown', (event) => {
5318
+ if (event.defaultPrevented) {
5319
+ event.preventDefault();
5320
+ return;
5321
+ }
5322
+ // if somebody has marked this event then treat as a defaultPrevented
5323
+ // without actually calling event.preventDefault()
5324
+ if (quasiDefaultPrevented(event)) {
5325
+ return;
5326
+ }
5327
+ track();
5328
+ }), addDisposableListener(this.options.content, 'mousedown', (event) => {
5329
+ if (event.defaultPrevented) {
5330
+ return;
5331
+ }
5332
+ // if somebody has marked this event then treat as a defaultPrevented
5333
+ // without actually calling event.preventDefault()
5334
+ if (quasiDefaultPrevented(event)) {
5335
+ return;
5336
+ }
5337
+ if (event.shiftKey) {
5338
+ track();
5339
+ }
5340
+ }), addDisposableListener(this.options.content, 'mousedown', () => {
5341
+ bringElementToFront(this._element);
5342
+ }, true));
5343
+ bringElementToFront(this._element);
5344
+ if (options.inDragMode) {
5345
+ track();
5346
+ }
5347
+ }
5348
+ setupResize(direction) {
5349
+ const resizeHandleElement = document.createElement('div');
5350
+ resizeHandleElement.className = `dv-resize-handle-${direction}`;
5351
+ this._element.appendChild(resizeHandleElement);
5352
+ const move = new MutableDisposable();
5353
+ this.addDisposables(move, addDisposableListener(resizeHandleElement, 'mousedown', (e) => {
5354
+ e.preventDefault();
5355
+ let startPosition = null;
5356
+ const iframes = [
5357
+ ...getElementsByTagName('iframe'),
5358
+ ...getElementsByTagName('webview'),
5359
+ ];
5360
+ for (const iframe of iframes) {
5361
+ iframe.style.pointerEvents = 'none';
5362
+ }
5363
+ move.value = new CompositeDisposable(addDisposableWindowListener(window, 'mousemove', (e) => {
5364
+ const containerRect = this.options.container.getBoundingClientRect();
5365
+ const overlayRect = this._element.getBoundingClientRect();
5366
+ const y = e.clientY - containerRect.top;
5367
+ const x = e.clientX - containerRect.left;
5368
+ if (startPosition === null) {
5369
+ // record the initial dimensions since as all subsequence moves are relative to this
5370
+ startPosition = {
5371
+ originalY: y,
5372
+ originalHeight: overlayRect.height,
5373
+ originalX: x,
5374
+ originalWidth: overlayRect.width,
5375
+ };
5376
+ }
5377
+ let top = undefined;
5378
+ let height = undefined;
5379
+ let left = undefined;
5380
+ let width = undefined;
5381
+ const minimumInViewportHeight = this.options.minimumInViewportHeight;
5382
+ const minimumInViewportWidth = this.options.minimumInViewportWidth;
5383
+ function moveTop() {
5384
+ top = clamp(y, -Number.MAX_VALUE, startPosition.originalY +
5385
+ startPosition.originalHeight >
5386
+ containerRect.height
5387
+ ? containerRect.height -
5388
+ minimumInViewportHeight
5389
+ : Math.max(0, startPosition.originalY +
5390
+ startPosition.originalHeight -
5391
+ Overlay.MINIMUM_HEIGHT));
5392
+ height =
5393
+ startPosition.originalY +
5394
+ startPosition.originalHeight -
5395
+ top;
5396
+ }
5397
+ function moveBottom() {
5398
+ top =
5399
+ startPosition.originalY -
5400
+ startPosition.originalHeight;
5401
+ height = clamp(y - top, top < 0
5402
+ ? -top + minimumInViewportHeight
5403
+ : Overlay.MINIMUM_HEIGHT, Number.MAX_VALUE);
5404
+ }
5405
+ function moveLeft() {
5406
+ left = clamp(x, -Number.MAX_VALUE, startPosition.originalX +
5407
+ startPosition.originalWidth >
5408
+ containerRect.width
5409
+ ? containerRect.width -
5410
+ minimumInViewportWidth
5411
+ : Math.max(0, startPosition.originalX +
5412
+ startPosition.originalWidth -
5413
+ Overlay.MINIMUM_WIDTH));
5414
+ width =
5415
+ startPosition.originalX +
5416
+ startPosition.originalWidth -
5417
+ left;
5418
+ }
5419
+ function moveRight() {
5420
+ left =
5421
+ startPosition.originalX -
5422
+ startPosition.originalWidth;
5423
+ width = clamp(x - left, left < 0
5424
+ ? -left + minimumInViewportWidth
5425
+ : Overlay.MINIMUM_WIDTH, Number.MAX_VALUE);
5426
+ }
5427
+ switch (direction) {
5428
+ case 'top':
5429
+ moveTop();
5430
+ break;
5431
+ case 'bottom':
5432
+ moveBottom();
5433
+ break;
5434
+ case 'left':
5435
+ moveLeft();
5436
+ break;
5437
+ case 'right':
5438
+ moveRight();
5439
+ break;
5440
+ case 'topleft':
5441
+ moveTop();
5442
+ moveLeft();
5443
+ break;
5444
+ case 'topright':
5445
+ moveTop();
5446
+ moveRight();
5447
+ break;
5448
+ case 'bottomleft':
5449
+ moveBottom();
5450
+ moveLeft();
5451
+ break;
5452
+ case 'bottomright':
5453
+ moveBottom();
5454
+ moveRight();
5455
+ break;
5456
+ }
5457
+ this.setBounds({ height, width, top, left });
5458
+ }), {
5459
+ dispose: () => {
5460
+ for (const iframe of iframes) {
5461
+ iframe.style.pointerEvents = 'auto';
5462
+ }
5463
+ },
5464
+ }, addDisposableWindowListener(window, 'mouseup', () => {
5465
+ move.dispose();
5466
+ this._onDidChangeEnd.fire();
5467
+ }));
5468
+ }));
5469
+ }
5470
+ dispose() {
5471
+ this._element.remove();
5472
+ super.dispose();
5473
+ }
5474
+ }
5475
+ Overlay.MINIMUM_HEIGHT = 20;
5476
+ Overlay.MINIMUM_WIDTH = 20;
5477
+
5478
+ class DockviewFloatingGroupPanel extends CompositeDisposable {
5479
+ constructor(group, overlay) {
5480
+ super();
5481
+ this.group = group;
5482
+ this.overlay = overlay;
5483
+ this.addDisposables(overlay);
5484
+ }
5485
+ position(bounds) {
5486
+ this.overlay.setBounds(bounds);
5487
+ }
5488
+ }
5489
+
5034
5490
  class DockviewComponent extends BaseGrid {
5035
5491
  get orientation() {
5036
5492
  return this.gridview.orientation;
@@ -5071,7 +5527,8 @@
5071
5527
  this.onDidLayoutFromJSON = this._onDidLayoutFromJSON.event;
5072
5528
  this._onDidActivePanelChange = new Emitter();
5073
5529
  this.onDidActivePanelChange = this._onDidActivePanelChange.event;
5074
- this.element.classList.add('dv-dockview');
5530
+ this.floatingGroups = [];
5531
+ toggleClass(this.gridview.element, 'dv-dockview', true);
5075
5532
  this.addDisposables(this._onDidDrop, exports.DockviewEvent.any(this.onDidAddGroup, this.onDidRemoveGroup)(() => {
5076
5533
  this.updateWatermark();
5077
5534
  }), exports.DockviewEvent.any(this.onDidAddPanel, this.onDidRemovePanel, this.onDidActivePanelChange)(() => {
@@ -5101,9 +5558,22 @@
5101
5558
  if (data.viewId !== this.id) {
5102
5559
  return false;
5103
5560
  }
5561
+ if (position === 'center') {
5562
+ // center drop target is only allowed if there are no panels in the grid
5563
+ // floating panels are allowed
5564
+ return this.gridview.length === 0;
5565
+ }
5104
5566
  return true;
5105
5567
  }
5106
5568
  if (this.options.showDndOverlay) {
5569
+ if (position === 'center') {
5570
+ /**
5571
+ * for external events only show the four-corner drag overlays, disable
5572
+ * the center position so that external drag events can fall through to the group
5573
+ * and panel drop target handlers
5574
+ */
5575
+ return false;
5576
+ }
5107
5577
  return this.options.showDndOverlay({
5108
5578
  nativeEvent: event,
5109
5579
  position: position,
@@ -5113,7 +5583,7 @@
5113
5583
  }
5114
5584
  return false;
5115
5585
  },
5116
- acceptedTargetZones: ['top', 'bottom', 'left', 'right'],
5586
+ acceptedTargetZones: ['top', 'bottom', 'left', 'right', 'center'],
5117
5587
  overlayModel: {
5118
5588
  activationSize: { type: 'pixels', value: 10 },
5119
5589
  size: { type: 'pixels', value: 20 },
@@ -5131,6 +5601,75 @@
5131
5601
  this._api = new DockviewApi(this);
5132
5602
  this.updateWatermark();
5133
5603
  }
5604
+ addFloatingGroup(item, coord, options) {
5605
+ var _a, _b;
5606
+ let group;
5607
+ if (item instanceof DockviewPanel) {
5608
+ group = this.createGroup();
5609
+ this.removePanel(item, {
5610
+ removeEmptyGroup: true,
5611
+ skipDispose: true,
5612
+ });
5613
+ group.model.openPanel(item);
5614
+ }
5615
+ else {
5616
+ group = item;
5617
+ const skip = typeof (options === null || options === void 0 ? void 0 : options.skipRemoveGroup) === 'boolean' &&
5618
+ options.skipRemoveGroup;
5619
+ if (!skip) {
5620
+ this.doRemoveGroup(item, { skipDispose: true });
5621
+ }
5622
+ }
5623
+ group.model.isFloating = true;
5624
+ const overlayLeft = typeof (coord === null || coord === void 0 ? void 0 : coord.x) === 'number' ? Math.max(coord.x, 0) : 100;
5625
+ const overlayTop = typeof (coord === null || coord === void 0 ? void 0 : coord.y) === 'number' ? Math.max(coord.y, 0) : 100;
5626
+ const overlay = new Overlay({
5627
+ container: this.gridview.element,
5628
+ content: group.element,
5629
+ height: (_a = coord === null || coord === void 0 ? void 0 : coord.height) !== null && _a !== void 0 ? _a : 300,
5630
+ width: (_b = coord === null || coord === void 0 ? void 0 : coord.width) !== null && _b !== void 0 ? _b : 300,
5631
+ left: overlayLeft,
5632
+ top: overlayTop,
5633
+ minimumInViewportWidth: 100,
5634
+ minimumInViewportHeight: 100,
5635
+ });
5636
+ const el = group.element.querySelector('.void-container');
5637
+ if (!el) {
5638
+ throw new Error('failed to find drag handle');
5639
+ }
5640
+ overlay.setupDrag(el, {
5641
+ inDragMode: typeof (options === null || options === void 0 ? void 0 : options.inDragMode) === 'boolean'
5642
+ ? options.inDragMode
5643
+ : false,
5644
+ });
5645
+ const floatingGroupPanel = new DockviewFloatingGroupPanel(group, overlay);
5646
+ const disposable = watchElementResize(group.element, (entry) => {
5647
+ const { width, height } = entry.contentRect;
5648
+ group.layout(width, height); // let the group know it's size is changing so it can fire events to the panel
5649
+ });
5650
+ floatingGroupPanel.addDisposables(overlay.onDidChange(() => {
5651
+ // this is either a resize or a move
5652
+ // to inform the panels .layout(...) the group with it's current size
5653
+ // don't care about resize since the above watcher handles that
5654
+ group.layout(group.height, group.width);
5655
+ }), overlay.onDidChangeEnd(() => {
5656
+ this._bufferOnDidLayoutChange.fire();
5657
+ }), group.onDidChange((event) => {
5658
+ overlay.setBounds({
5659
+ height: event === null || event === void 0 ? void 0 : event.height,
5660
+ width: event === null || event === void 0 ? void 0 : event.width,
5661
+ });
5662
+ }), {
5663
+ dispose: () => {
5664
+ disposable.dispose();
5665
+ group.model.isFloating = false;
5666
+ remove(this.floatingGroups, floatingGroupPanel);
5667
+ this.updateWatermark();
5668
+ },
5669
+ });
5670
+ this.floatingGroups.push(floatingGroupPanel);
5671
+ this.updateWatermark();
5672
+ }
5134
5673
  orthogonalize(position) {
5135
5674
  switch (position) {
5136
5675
  case 'top':
@@ -5153,6 +5692,7 @@
5153
5692
  switch (position) {
5154
5693
  case 'top':
5155
5694
  case 'left':
5695
+ case 'center':
5156
5696
  return this.createGroupAtLocation([0]); // insert into first position
5157
5697
  case 'bottom':
5158
5698
  case 'right':
@@ -5170,6 +5710,15 @@
5170
5710
  }
5171
5711
  this.layout(this.gridview.width, this.gridview.height, true);
5172
5712
  }
5713
+ layout(width, height, forceResize) {
5714
+ super.layout(width, height, forceResize);
5715
+ if (this.floatingGroups) {
5716
+ for (const floating of this.floatingGroups) {
5717
+ // ensure floting groups stay within visible boundaries
5718
+ floating.overlay.setBounds();
5719
+ }
5720
+ }
5721
+ }
5173
5722
  focus() {
5174
5723
  var _a;
5175
5724
  (_a = this.activeGroup) === null || _a === void 0 ? void 0 : _a.focus();
@@ -5232,51 +5781,81 @@
5232
5781
  collection[panel.id] = panel.toJSON();
5233
5782
  return collection;
5234
5783
  }, {});
5235
- return {
5784
+ const floats = this.floatingGroups.map((floatingGroup) => {
5785
+ return {
5786
+ data: floatingGroup.group.toJSON(),
5787
+ position: floatingGroup.overlay.toJSON(),
5788
+ };
5789
+ });
5790
+ const result = {
5236
5791
  grid: data,
5237
5792
  panels,
5238
5793
  activeGroup: (_a = this.activeGroup) === null || _a === void 0 ? void 0 : _a.id,
5239
5794
  };
5795
+ if (floats.length > 0) {
5796
+ result.floatingGroups = floats;
5797
+ }
5798
+ return result;
5240
5799
  }
5241
5800
  fromJSON(data) {
5801
+ var _a;
5242
5802
  this.clear();
5243
5803
  const { grid, panels, activeGroup } = data;
5244
5804
  if (grid.root.type !== 'branch' || !Array.isArray(grid.root.data)) {
5245
5805
  throw new Error('root must be of type branch');
5246
5806
  }
5807
+ // take note of the existing dimensions
5808
+ const width = this.width;
5809
+ const height = this.height;
5810
+ const createGroupFromSerializedState = (data) => {
5811
+ const { id, locked, hideHeader, views, activeView } = data;
5812
+ const group = this.createGroup({
5813
+ id,
5814
+ locked: !!locked,
5815
+ hideHeader: !!hideHeader,
5816
+ });
5817
+ this._onDidAddGroup.fire(group);
5818
+ for (const child of views) {
5819
+ const panel = this._deserializer.fromJSON(panels[child], group);
5820
+ const isActive = typeof activeView === 'string' && activeView === panel.id;
5821
+ group.model.openPanel(panel, {
5822
+ skipSetPanelActive: !isActive,
5823
+ skipSetGroupActive: true,
5824
+ });
5825
+ }
5826
+ if (!group.activePanel && group.panels.length > 0) {
5827
+ group.model.openPanel(group.panels[group.panels.length - 1], {
5828
+ skipSetGroupActive: true,
5829
+ });
5830
+ }
5831
+ return group;
5832
+ };
5247
5833
  this.gridview.deserialize(grid, {
5248
5834
  fromJSON: (node) => {
5249
- const { id, locked, hideHeader, views, activeView } = node.data;
5250
- const group = this.createGroup({
5251
- id,
5252
- locked: !!locked,
5253
- hideHeader: !!hideHeader,
5254
- });
5255
- this._onDidAddGroup.fire(group);
5256
- for (const child of views) {
5257
- const panel = this._deserializer.fromJSON(panels[child], group);
5258
- const isActive = typeof activeView === 'string' &&
5259
- activeView === panel.id;
5260
- group.model.openPanel(panel, {
5261
- skipSetPanelActive: !isActive,
5262
- skipSetGroupActive: true,
5263
- });
5264
- }
5265
- if (!group.activePanel && group.panels.length > 0) {
5266
- group.model.openPanel(group.panels[group.panels.length - 1], {
5267
- skipSetGroupActive: true,
5268
- });
5269
- }
5270
- return group;
5835
+ return createGroupFromSerializedState(node.data);
5271
5836
  },
5272
5837
  });
5838
+ this.layout(width, height, true);
5839
+ const serializedFloatingGroups = (_a = data.floatingGroups) !== null && _a !== void 0 ? _a : [];
5840
+ for (const serializedFloatingGroup of serializedFloatingGroups) {
5841
+ const { data, position } = serializedFloatingGroup;
5842
+ const group = createGroupFromSerializedState(data);
5843
+ this.addFloatingGroup(group, {
5844
+ x: position.left,
5845
+ y: position.top,
5846
+ height: position.height,
5847
+ width: position.width,
5848
+ }, { skipRemoveGroup: true, inDragMode: false });
5849
+ }
5850
+ for (const floatingGroup of this.floatingGroups) {
5851
+ floatingGroup.overlay.setBounds();
5852
+ }
5273
5853
  if (typeof activeGroup === 'string') {
5274
5854
  const panel = this.getPanel(activeGroup);
5275
5855
  if (panel) {
5276
5856
  this.doSetGroupActive(panel);
5277
5857
  }
5278
5858
  }
5279
- this.gridview.layout(this.width, this.height);
5280
5859
  this._onDidLayoutFromJSON.fire();
5281
5860
  }
5282
5861
  clear() {
@@ -5285,7 +5864,7 @@
5285
5864
  const hasActivePanel = !!this.activePanel;
5286
5865
  for (const group of groups) {
5287
5866
  // remove the group will automatically remove the panels
5288
- this.removeGroup(group, true);
5867
+ this.removeGroup(group, { skipActive: true });
5289
5868
  }
5290
5869
  if (hasActiveGroup) {
5291
5870
  this.doSetGroupActive(undefined);
@@ -5307,6 +5886,9 @@
5307
5886
  throw new Error(`panel with id ${options.id} already exists`);
5308
5887
  }
5309
5888
  let referenceGroup;
5889
+ if (options.position && options.floating) {
5890
+ throw new Error('you can only provide one of: position, floating as arguments to .addPanel(...)');
5891
+ }
5310
5892
  if (options.position) {
5311
5893
  if (isPanelOptionsWithPanel(options.position)) {
5312
5894
  const referencePanel = typeof options.position.referencePanel === 'string'
@@ -5339,7 +5921,20 @@
5339
5921
  let panel;
5340
5922
  if (referenceGroup) {
5341
5923
  const target = toTarget(((_b = options.position) === null || _b === void 0 ? void 0 : _b.direction) || 'within');
5342
- if (target === 'center') {
5924
+ if (options.floating) {
5925
+ const group = this.createGroup();
5926
+ panel = this.createPanel(options, group);
5927
+ group.model.openPanel(panel);
5928
+ const o = typeof options.floating === 'object' &&
5929
+ options.floating !== null
5930
+ ? options.floating
5931
+ : {};
5932
+ this.addFloatingGroup(group, o, {
5933
+ inDragMode: false,
5934
+ skipRemoveGroup: true,
5935
+ });
5936
+ }
5937
+ else if (referenceGroup.api.isFloating || target === 'center') {
5343
5938
  panel = this.createPanel(options, referenceGroup);
5344
5939
  referenceGroup.model.openPanel(panel);
5345
5940
  }
@@ -5351,6 +5946,19 @@
5351
5946
  group.model.openPanel(panel);
5352
5947
  }
5353
5948
  }
5949
+ else if (options.floating) {
5950
+ const group = this.createGroup();
5951
+ panel = this.createPanel(options, group);
5952
+ group.model.openPanel(panel);
5953
+ const o = typeof options.floating === 'object' &&
5954
+ options.floating !== null
5955
+ ? options.floating
5956
+ : {};
5957
+ this.addFloatingGroup(group, o, {
5958
+ inDragMode: false,
5959
+ skipRemoveGroup: true,
5960
+ });
5961
+ }
5354
5962
  else {
5355
5963
  const group = this.createGroupAtLocation();
5356
5964
  panel = this.createPanel(options, group);
@@ -5367,7 +5975,9 @@
5367
5975
  throw new Error(`cannot remove panel ${panel.id}. it's missing a group.`);
5368
5976
  }
5369
5977
  group.model.removePanel(panel);
5370
- panel.dispose();
5978
+ if (!options.skipDispose) {
5979
+ panel.dispose();
5980
+ }
5371
5981
  if (group.size === 0 && options.removeEmptyGroup) {
5372
5982
  this.removeGroup(group);
5373
5983
  }
@@ -5382,7 +5992,7 @@
5382
5992
  }
5383
5993
  updateWatermark() {
5384
5994
  var _a, _b;
5385
- if (this.groups.length === 0) {
5995
+ if (this.groups.filter((x) => !x.api.isFloating).length === 0) {
5386
5996
  if (!this.watermark) {
5387
5997
  this.watermark = this.createWatermarkComponent();
5388
5998
  this.watermark.init({
@@ -5391,7 +6001,7 @@
5391
6001
  const watermarkContainer = document.createElement('div');
5392
6002
  watermarkContainer.className = 'dv-watermark-container';
5393
6003
  watermarkContainer.appendChild(this.watermark.element);
5394
- this.element.appendChild(watermarkContainer);
6004
+ this.gridview.element.appendChild(watermarkContainer);
5395
6005
  }
5396
6006
  }
5397
6007
  else if (this.watermark) {
@@ -5441,15 +6051,28 @@
5441
6051
  return group;
5442
6052
  }
5443
6053
  }
5444
- removeGroup(group, skipActive = false) {
6054
+ removeGroup(group, options) {
6055
+ var _a;
5445
6056
  const panels = [...group.panels]; // reassign since group panels will mutate
5446
6057
  for (const panel of panels) {
5447
6058
  this.removePanel(panel, {
5448
6059
  removeEmptyGroup: false,
5449
- skipDispose: false,
6060
+ skipDispose: (_a = options === null || options === void 0 ? void 0 : options.skipDispose) !== null && _a !== void 0 ? _a : false,
5450
6061
  });
5451
6062
  }
5452
- super.doRemoveGroup(group, { skipActive });
6063
+ this.doRemoveGroup(group, options);
6064
+ }
6065
+ doRemoveGroup(group, options) {
6066
+ const floatingGroup = this.floatingGroups.find((_) => _.group === group);
6067
+ if (floatingGroup) {
6068
+ if (!(options === null || options === void 0 ? void 0 : options.skipDispose)) {
6069
+ floatingGroup.group.dispose();
6070
+ this._groups.delete(group.id);
6071
+ }
6072
+ floatingGroup.dispose();
6073
+ return floatingGroup.group;
6074
+ }
6075
+ return super.doRemoveGroup(group, options);
5453
6076
  }
5454
6077
  moveGroupOrPanel(destinationGroup, sourceGroupId, sourceItemId, destinationTarget, destinationIndex) {
5455
6078
  var _a;
@@ -5480,25 +6103,26 @@
5480
6103
  const targetLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, destinationTarget);
5481
6104
  if (sourceGroup && sourceGroup.size < 2) {
5482
6105
  const [targetParentLocation, to] = tail(targetLocation);
5483
- const sourceLocation = getGridLocation(sourceGroup.element);
5484
- const [sourceParentLocation, from] = tail(sourceLocation);
5485
- if (sequenceEquals(sourceParentLocation, targetParentLocation)) {
5486
- // special case when 'swapping' two views within same grid location
5487
- // if a group has one tab - we are essentially moving the 'group'
5488
- // which is equivalent to swapping two views in this case
5489
- this.gridview.moveView(sourceParentLocation, from, to);
5490
- }
5491
- else {
5492
- // source group will become empty so delete the group
5493
- const targetGroup = this.doRemoveGroup(sourceGroup, {
5494
- skipActive: true,
5495
- skipDispose: true,
5496
- });
5497
- // after deleting the group we need to re-evaulate the ref location
5498
- const updatedReferenceLocation = getGridLocation(destinationGroup.element);
5499
- const location = getRelativeLocation(this.gridview.orientation, updatedReferenceLocation, destinationTarget);
5500
- this.doAddGroup(targetGroup, location);
6106
+ const isFloating = this.floatingGroups.find((x) => x.group === sourceGroup);
6107
+ if (!isFloating) {
6108
+ const sourceLocation = getGridLocation(sourceGroup.element);
6109
+ const [sourceParentLocation, from] = tail(sourceLocation);
6110
+ if (sequenceEquals(sourceParentLocation, targetParentLocation)) {
6111
+ // special case when 'swapping' two views within same grid location
6112
+ // if a group has one tab - we are essentially moving the 'group'
6113
+ // which is equivalent to swapping two views in this case
6114
+ this.gridview.moveView(sourceParentLocation, from, to);
6115
+ }
5501
6116
  }
6117
+ // source group will become empty so delete the group
6118
+ const targetGroup = this.doRemoveGroup(sourceGroup, {
6119
+ skipActive: true,
6120
+ skipDispose: true,
6121
+ });
6122
+ // after deleting the group we need to re-evaulate the ref location
6123
+ const updatedReferenceLocation = getGridLocation(destinationGroup.element);
6124
+ const location = getRelativeLocation(this.gridview.orientation, updatedReferenceLocation, destinationTarget);
6125
+ this.doAddGroup(targetGroup, location);
5502
6126
  }
5503
6127
  else {
5504
6128
  const groupItem = (sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(sourceItemId)) ||
@@ -5527,7 +6151,13 @@
5527
6151
  }
5528
6152
  }
5529
6153
  else {
5530
- this.gridview.removeView(getGridLocation(sourceGroup.element));
6154
+ const floatingGroup = this.floatingGroups.find((x) => x.group === sourceGroup);
6155
+ if (floatingGroup) {
6156
+ floatingGroup.dispose();
6157
+ }
6158
+ else {
6159
+ this.gridview.removeView(getGridLocation(sourceGroup.element));
6160
+ }
5531
6161
  const referenceLocation = getGridLocation(referenceGroup.element);
5532
6162
  const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, target);
5533
6163
  this.gridview.addView(sourceGroup, exports.Sizing.Distribute, dropLocation);
@@ -5682,6 +6312,9 @@
5682
6312
  this.clear();
5683
6313
  const { grid, activePanel } = serializedGridview;
5684
6314
  const queue = [];
6315
+ // take note of the existing dimensions
6316
+ const width = this.width;
6317
+ const height = this.height;
5685
6318
  this.gridview.deserialize(grid, {
5686
6319
  fromJSON: (node) => {
5687
6320
  const { data } = node;
@@ -5707,7 +6340,7 @@
5707
6340
  return view;
5708
6341
  },
5709
6342
  });
5710
- this.layout(this.width, this.height, true);
6343
+ this.layout(width, height, true);
5711
6344
  queue.forEach((f) => f());
5712
6345
  if (typeof activePanel === 'string') {
5713
6346
  const panel = this.getPanel(activePanel);
@@ -6021,6 +6654,9 @@
6021
6654
  this.clear();
6022
6655
  const { views, orientation, size, activeView } = serializedSplitview;
6023
6656
  const queue = [];
6657
+ // take note of the existing dimensions
6658
+ const width = this.width;
6659
+ const height = this.height;
6024
6660
  this.splitview = new Splitview(this.element, {
6025
6661
  orientation,
6026
6662
  proportionalLayout: this.options.proportionalLayout,
@@ -6057,7 +6693,7 @@
6057
6693
  }),
6058
6694
  },
6059
6695
  });
6060
- this.layout(this.width, this.height);
6696
+ this.layout(width, height);
6061
6697
  queue.forEach((f) => f());
6062
6698
  if (typeof activeView === 'string') {
6063
6699
  const panel = this.getPanel(activeView);
@@ -6324,6 +6960,9 @@
6324
6960
  this.clear();
6325
6961
  const { views, size } = serializedPaneview;
6326
6962
  const queue = [];
6963
+ // take note of the existing dimensions
6964
+ const width = this.width;
6965
+ const height = this.height;
6327
6966
  this.paneview = new Paneview(this.element, {
6328
6967
  orientation: exports.Orientation.VERTICAL,
6329
6968
  descriptor: {
@@ -6379,7 +7018,7 @@
6379
7018
  }),
6380
7019
  },
6381
7020
  });
6382
- this.layout(this.width, this.height);
7021
+ this.layout(width, height);
6383
7022
  queue.forEach((f) => f());
6384
7023
  this._onDidLayoutfromJSON.fire();
6385
7024
  }
@@ -6565,6 +7204,6 @@
6565
7204
  exports.orthogonal = orthogonal;
6566
7205
  exports.positionToDirection = positionToDirection;
6567
7206
  exports.toTarget = toTarget;
6568
- exports.watchElementResize = watchElementResize;
6569
7207
 
6570
7208
  }));
7209
+ //# sourceMappingURL=dockview-core.noStyle.js.map