dockview 1.9.2 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/dist/cjs/dockview/defaultTab.d.ts +0 -1
  2. package/dist/cjs/dockview/defaultTab.js +0 -1
  3. package/dist/cjs/dockview/dockview.d.ts +5 -3
  4. package/dist/cjs/dockview/dockview.js +31 -1
  5. package/dist/cjs/dockview/headerActionsRenderer.d.ts +0 -1
  6. package/dist/cjs/dockview/headerActionsRenderer.js +0 -1
  7. package/dist/cjs/dockview/reactContentPart.d.ts +0 -1
  8. package/dist/cjs/dockview/reactContentPart.js +0 -1
  9. package/dist/cjs/dockview/reactHeaderPart.d.ts +0 -1
  10. package/dist/cjs/dockview/reactHeaderPart.js +0 -1
  11. package/dist/cjs/dockview/reactWatermarkPart.d.ts +0 -1
  12. package/dist/cjs/dockview/reactWatermarkPart.js +0 -1
  13. package/dist/cjs/gridview/gridview.d.ts +0 -1
  14. package/dist/cjs/gridview/gridview.js +0 -1
  15. package/dist/cjs/gridview/view.d.ts +0 -1
  16. package/dist/cjs/gridview/view.js +3 -2
  17. package/dist/cjs/index.d.ts +0 -1
  18. package/dist/cjs/index.js +0 -1
  19. package/dist/cjs/paneview/paneview.d.ts +0 -1
  20. package/dist/cjs/paneview/paneview.js +0 -1
  21. package/dist/cjs/paneview/view.d.ts +0 -1
  22. package/dist/cjs/paneview/view.js +0 -1
  23. package/dist/cjs/react.d.ts +1 -2
  24. package/dist/cjs/react.js +13 -10
  25. package/dist/cjs/splitview/splitview.d.ts +0 -1
  26. package/dist/cjs/splitview/splitview.js +0 -1
  27. package/dist/cjs/splitview/view.d.ts +0 -1
  28. package/dist/cjs/splitview/view.js +0 -1
  29. package/dist/cjs/svg.d.ts +0 -1
  30. package/dist/cjs/svg.js +0 -1
  31. package/dist/cjs/types.d.ts +0 -1
  32. package/dist/cjs/types.js +0 -1
  33. package/dist/dockview.amd.js +1283 -534
  34. package/dist/dockview.amd.js.map +1 -1
  35. package/dist/dockview.amd.min.js +2 -2
  36. package/dist/dockview.amd.min.js.map +1 -1
  37. package/dist/dockview.amd.min.noStyle.js +2 -2
  38. package/dist/dockview.amd.min.noStyle.js.map +1 -1
  39. package/dist/dockview.amd.noStyle.js +1283 -534
  40. package/dist/dockview.amd.noStyle.js.map +1 -1
  41. package/dist/dockview.cjs.js +1283 -534
  42. package/dist/dockview.cjs.js.map +1 -1
  43. package/dist/dockview.esm.js +1280 -534
  44. package/dist/dockview.esm.js.map +1 -1
  45. package/dist/dockview.esm.min.js +2 -2
  46. package/dist/dockview.esm.min.js.map +1 -1
  47. package/dist/dockview.js +1283 -534
  48. package/dist/dockview.js.map +1 -1
  49. package/dist/dockview.min.js +2 -2
  50. package/dist/dockview.min.js.map +1 -1
  51. package/dist/dockview.min.noStyle.js +2 -2
  52. package/dist/dockview.min.noStyle.js.map +1 -1
  53. package/dist/dockview.noStyle.js +1283 -534
  54. package/dist/dockview.noStyle.js.map +1 -1
  55. package/dist/esm/dockview/defaultTab.d.ts +0 -1
  56. package/dist/esm/dockview/defaultTab.js +0 -1
  57. package/dist/esm/dockview/dockview.d.ts +5 -3
  58. package/dist/esm/dockview/dockview.js +31 -1
  59. package/dist/esm/dockview/headerActionsRenderer.d.ts +0 -1
  60. package/dist/esm/dockview/headerActionsRenderer.js +0 -1
  61. package/dist/esm/dockview/reactContentPart.d.ts +0 -1
  62. package/dist/esm/dockview/reactContentPart.js +0 -1
  63. package/dist/esm/dockview/reactHeaderPart.d.ts +0 -1
  64. package/dist/esm/dockview/reactHeaderPart.js +0 -1
  65. package/dist/esm/dockview/reactWatermarkPart.d.ts +0 -1
  66. package/dist/esm/dockview/reactWatermarkPart.js +0 -1
  67. package/dist/esm/gridview/gridview.d.ts +0 -1
  68. package/dist/esm/gridview/gridview.js +0 -1
  69. package/dist/esm/gridview/view.d.ts +0 -1
  70. package/dist/esm/gridview/view.js +3 -2
  71. package/dist/esm/index.d.ts +0 -1
  72. package/dist/esm/index.js +0 -1
  73. package/dist/esm/paneview/paneview.d.ts +0 -1
  74. package/dist/esm/paneview/paneview.js +0 -1
  75. package/dist/esm/paneview/view.d.ts +0 -1
  76. package/dist/esm/paneview/view.js +0 -1
  77. package/dist/esm/react.d.ts +1 -2
  78. package/dist/esm/react.js +11 -8
  79. package/dist/esm/splitview/splitview.d.ts +0 -1
  80. package/dist/esm/splitview/splitview.js +0 -1
  81. package/dist/esm/splitview/view.d.ts +0 -1
  82. package/dist/esm/splitview/view.js +0 -1
  83. package/dist/esm/svg.d.ts +0 -1
  84. package/dist/esm/svg.js +0 -1
  85. package/dist/esm/types.d.ts +0 -1
  86. package/dist/esm/types.js +0 -1
  87. package/package.json +4 -4
  88. package/dist/cjs/dockview/defaultTab.d.ts.map +0 -1
  89. package/dist/cjs/dockview/defaultTab.js.map +0 -1
  90. package/dist/cjs/dockview/dockview.d.ts.map +0 -1
  91. package/dist/cjs/dockview/dockview.js.map +0 -1
  92. package/dist/cjs/dockview/headerActionsRenderer.d.ts.map +0 -1
  93. package/dist/cjs/dockview/headerActionsRenderer.js.map +0 -1
  94. package/dist/cjs/dockview/reactContentPart.d.ts.map +0 -1
  95. package/dist/cjs/dockview/reactContentPart.js.map +0 -1
  96. package/dist/cjs/dockview/reactHeaderPart.d.ts.map +0 -1
  97. package/dist/cjs/dockview/reactHeaderPart.js.map +0 -1
  98. package/dist/cjs/dockview/reactWatermarkPart.d.ts.map +0 -1
  99. package/dist/cjs/dockview/reactWatermarkPart.js.map +0 -1
  100. package/dist/cjs/gridview/gridview.d.ts.map +0 -1
  101. package/dist/cjs/gridview/gridview.js.map +0 -1
  102. package/dist/cjs/gridview/view.d.ts.map +0 -1
  103. package/dist/cjs/gridview/view.js.map +0 -1
  104. package/dist/cjs/index.d.ts.map +0 -1
  105. package/dist/cjs/index.js.map +0 -1
  106. package/dist/cjs/paneview/paneview.d.ts.map +0 -1
  107. package/dist/cjs/paneview/paneview.js.map +0 -1
  108. package/dist/cjs/paneview/view.d.ts.map +0 -1
  109. package/dist/cjs/paneview/view.js.map +0 -1
  110. package/dist/cjs/react.d.ts.map +0 -1
  111. package/dist/cjs/react.js.map +0 -1
  112. package/dist/cjs/splitview/splitview.d.ts.map +0 -1
  113. package/dist/cjs/splitview/splitview.js.map +0 -1
  114. package/dist/cjs/splitview/view.d.ts.map +0 -1
  115. package/dist/cjs/splitview/view.js.map +0 -1
  116. package/dist/cjs/svg.d.ts.map +0 -1
  117. package/dist/cjs/svg.js.map +0 -1
  118. package/dist/cjs/types.d.ts.map +0 -1
  119. package/dist/cjs/types.js.map +0 -1
  120. package/dist/esm/dockview/defaultTab.d.ts.map +0 -1
  121. package/dist/esm/dockview/defaultTab.js.map +0 -1
  122. package/dist/esm/dockview/dockview.d.ts.map +0 -1
  123. package/dist/esm/dockview/dockview.js.map +0 -1
  124. package/dist/esm/dockview/headerActionsRenderer.d.ts.map +0 -1
  125. package/dist/esm/dockview/headerActionsRenderer.js.map +0 -1
  126. package/dist/esm/dockview/reactContentPart.d.ts.map +0 -1
  127. package/dist/esm/dockview/reactContentPart.js.map +0 -1
  128. package/dist/esm/dockview/reactHeaderPart.d.ts.map +0 -1
  129. package/dist/esm/dockview/reactHeaderPart.js.map +0 -1
  130. package/dist/esm/dockview/reactWatermarkPart.d.ts.map +0 -1
  131. package/dist/esm/dockview/reactWatermarkPart.js.map +0 -1
  132. package/dist/esm/gridview/gridview.d.ts.map +0 -1
  133. package/dist/esm/gridview/gridview.js.map +0 -1
  134. package/dist/esm/gridview/view.d.ts.map +0 -1
  135. package/dist/esm/gridview/view.js.map +0 -1
  136. package/dist/esm/index.d.ts.map +0 -1
  137. package/dist/esm/index.js.map +0 -1
  138. package/dist/esm/paneview/paneview.d.ts.map +0 -1
  139. package/dist/esm/paneview/paneview.js.map +0 -1
  140. package/dist/esm/paneview/view.d.ts.map +0 -1
  141. package/dist/esm/paneview/view.js.map +0 -1
  142. package/dist/esm/react.d.ts.map +0 -1
  143. package/dist/esm/react.js.map +0 -1
  144. package/dist/esm/splitview/splitview.d.ts.map +0 -1
  145. package/dist/esm/splitview/splitview.js.map +0 -1
  146. package/dist/esm/splitview/view.d.ts.map +0 -1
  147. package/dist/esm/splitview/view.js.map +0 -1
  148. package/dist/esm/svg.d.ts.map +0 -1
  149. package/dist/esm/svg.js.map +0 -1
  150. package/dist/esm/types.d.ts.map +0 -1
  151. package/dist/esm/types.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * dockview
3
- * @version 1.9.2
3
+ * @version 1.10.0
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -141,6 +141,17 @@ exports.DockviewEvent = void 0;
141
141
  };
142
142
  };
143
143
  })(exports.DockviewEvent || (exports.DockviewEvent = {}));
144
+ class DockviewEvent {
145
+ constructor() {
146
+ this._defaultPrevented = false;
147
+ }
148
+ get defaultPrevented() {
149
+ return this._defaultPrevented;
150
+ }
151
+ preventDefault() {
152
+ this._defaultPrevented = true;
153
+ }
154
+ }
144
155
  class LeakageMonitor {
145
156
  constructor() {
146
157
  this.events = new Map();
@@ -184,6 +195,9 @@ class Emitter {
184
195
  }
185
196
  Emitter.ENABLE_TRACKING = isEnabled;
186
197
  }
198
+ get value() {
199
+ return this._last;
200
+ }
187
201
  constructor(options) {
188
202
  this.options = options;
189
203
  this._listeners = [];
@@ -306,8 +320,12 @@ class CompositeDisposable {
306
320
  args.forEach((arg) => this._disposables.push(arg));
307
321
  }
308
322
  dispose() {
309
- this._disposables.forEach((arg) => arg.dispose());
323
+ if (this._isDisposed) {
324
+ return;
325
+ }
310
326
  this._isDisposed = true;
327
+ this._disposables.forEach((arg) => arg.dispose());
328
+ this._disposables = [];
311
329
  }
312
330
  }
313
331
  class MutableDisposable {
@@ -791,6 +809,13 @@ class Splitview {
791
809
  this._endSnappingEnabled = endSnappingEnabled;
792
810
  this.updateSashEnablement();
793
811
  }
812
+ get disabled() {
813
+ return this._disabled;
814
+ }
815
+ set disabled(value) {
816
+ this._disabled = value;
817
+ toggleClass(this.element, 'dv-splitview-disabled', value);
818
+ }
794
819
  constructor(container, options) {
795
820
  this.container = container;
796
821
  this.viewItems = [];
@@ -801,6 +826,7 @@ class Splitview {
801
826
  this._proportions = undefined;
802
827
  this._startSnappingEnabled = true;
803
828
  this._endSnappingEnabled = true;
829
+ this._disabled = false;
804
830
  this._onDidSashEnd = new Emitter();
805
831
  this.onDidSashEnd = this._onDidSashEnd.event;
806
832
  this._onDidAddView = new Emitter();
@@ -1728,7 +1754,13 @@ class BranchNode extends CompositeDisposable {
1728
1754
  }
1729
1755
  return exports.LayoutPriority.Normal;
1730
1756
  }
1731
- constructor(orientation, proportionalLayout, styles, size, orthogonalSize, childDescriptors) {
1757
+ get disabled() {
1758
+ return this.splitview.disabled;
1759
+ }
1760
+ set disabled(value) {
1761
+ this.splitview.disabled = value;
1762
+ }
1763
+ constructor(orientation, proportionalLayout, styles, size, orthogonalSize, disabled, childDescriptors) {
1732
1764
  super();
1733
1765
  this.orientation = orientation;
1734
1766
  this.proportionalLayout = proportionalLayout;
@@ -1773,6 +1805,7 @@ class BranchNode extends CompositeDisposable {
1773
1805
  styles,
1774
1806
  });
1775
1807
  }
1808
+ this.disabled = disabled;
1776
1809
  this.addDisposables(this._onDidChange, this._onDidVisibilityChange, this.splitview.onDidSashEnd(() => {
1777
1810
  this._onDidChange.fire({});
1778
1811
  }));
@@ -1906,7 +1939,7 @@ function findLeaf(candiateNode, last) {
1906
1939
  }
1907
1940
  function flipNode(node, size, orthogonalSize) {
1908
1941
  if (node instanceof BranchNode) {
1909
- const result = new BranchNode(orthogonal(node.orientation), node.proportionalLayout, node.styles, size, orthogonalSize);
1942
+ const result = new BranchNode(orthogonal(node.orientation), node.proportionalLayout, node.styles, size, orthogonalSize, node.disabled);
1910
1943
  let totalSize = 0;
1911
1944
  for (let i = node.children.length - 1; i >= 0; i--) {
1912
1945
  const child = node.children[i];
@@ -2042,31 +2075,57 @@ class Gridview {
2042
2075
  get maximumHeight() {
2043
2076
  return this.root.maximumHeight;
2044
2077
  }
2078
+ get locked() {
2079
+ return this._locked;
2080
+ }
2081
+ set locked(value) {
2082
+ this._locked = value;
2083
+ const branch = [this.root];
2084
+ /**
2085
+ * simple depth-first-search to cover all nodes
2086
+ *
2087
+ * @see https://en.wikipedia.org/wiki/Depth-first_search
2088
+ */
2089
+ while (branch.length > 0) {
2090
+ const node = branch.pop();
2091
+ if (node instanceof BranchNode) {
2092
+ node.disabled = value;
2093
+ branch.push(...node.children);
2094
+ }
2095
+ }
2096
+ }
2045
2097
  maximizedView() {
2046
2098
  var _a;
2047
- return (_a = this._maximizedNode) === null || _a === void 0 ? void 0 : _a.view;
2099
+ return (_a = this._maximizedNode) === null || _a === void 0 ? void 0 : _a.leaf.view;
2048
2100
  }
2049
2101
  hasMaximizedView() {
2050
2102
  return this._maximizedNode !== undefined;
2051
2103
  }
2052
2104
  maximizeView(view) {
2105
+ var _a;
2053
2106
  const location = getGridLocation(view.element);
2054
2107
  const [_, node] = this.getNode(location);
2055
2108
  if (!(node instanceof LeafNode)) {
2056
2109
  return;
2057
2110
  }
2058
- if (this._maximizedNode === node) {
2111
+ if (((_a = this._maximizedNode) === null || _a === void 0 ? void 0 : _a.leaf) === node) {
2059
2112
  return;
2060
2113
  }
2061
2114
  if (this.hasMaximizedView()) {
2062
2115
  this.exitMaximizedView();
2063
2116
  }
2117
+ const hiddenOnMaximize = [];
2064
2118
  function hideAllViewsBut(parent, exclude) {
2065
2119
  for (let i = 0; i < parent.children.length; i++) {
2066
2120
  const child = parent.children[i];
2067
2121
  if (child instanceof LeafNode) {
2068
2122
  if (child !== exclude) {
2069
- parent.setChildVisible(i, false);
2123
+ if (parent.isChildVisible(i)) {
2124
+ parent.setChildVisible(i, false);
2125
+ }
2126
+ else {
2127
+ hiddenOnMaximize.push(child);
2128
+ }
2070
2129
  }
2071
2130
  }
2072
2131
  else {
@@ -2075,18 +2134,21 @@ class Gridview {
2075
2134
  }
2076
2135
  }
2077
2136
  hideAllViewsBut(this.root, node);
2078
- this._maximizedNode = node;
2079
- this._onDidMaxmizedNodeChange.fire();
2137
+ this._maximizedNode = { leaf: node, hiddenOnMaximize };
2138
+ this._onDidMaximizedNodeChange.fire();
2080
2139
  }
2081
2140
  exitMaximizedView() {
2082
2141
  if (!this._maximizedNode) {
2083
2142
  return;
2084
2143
  }
2144
+ const hiddenOnMaximize = this._maximizedNode.hiddenOnMaximize;
2085
2145
  function showViewsInReverseOrder(parent) {
2086
2146
  for (let index = parent.children.length - 1; index >= 0; index--) {
2087
2147
  const child = parent.children[index];
2088
2148
  if (child instanceof LeafNode) {
2089
- parent.setChildVisible(index, true);
2149
+ if (!hiddenOnMaximize.includes(child)) {
2150
+ parent.setChildVisible(index, true);
2151
+ }
2090
2152
  }
2091
2153
  else {
2092
2154
  showViewsInReverseOrder(child);
@@ -2095,13 +2157,13 @@ class Gridview {
2095
2157
  }
2096
2158
  showViewsInReverseOrder(this.root);
2097
2159
  this._maximizedNode = undefined;
2098
- this._onDidMaxmizedNodeChange.fire();
2160
+ this._onDidMaximizedNodeChange.fire();
2099
2161
  }
2100
2162
  serialize() {
2101
2163
  if (this.hasMaximizedView()) {
2102
2164
  /**
2103
- * do not persist maximized view state but we must first exit any maximized views
2104
- * before serialization to ensure the correct dimensions are persisted
2165
+ * do not persist maximized view state
2166
+ * firstly exit any maximized views to ensure the correct dimensions are persisted
2105
2167
  */
2106
2168
  this.exitMaximizedView();
2107
2169
  }
@@ -2116,14 +2178,14 @@ class Gridview {
2116
2178
  dispose() {
2117
2179
  this.disposable.dispose();
2118
2180
  this._onDidChange.dispose();
2119
- this._onDidMaxmizedNodeChange.dispose();
2181
+ this._onDidMaximizedNodeChange.dispose();
2120
2182
  this.root.dispose();
2121
2183
  this._maximizedNode = undefined;
2122
2184
  this.element.remove();
2123
2185
  }
2124
2186
  clear() {
2125
2187
  const orientation = this.root.orientation;
2126
- this.root = new BranchNode(orientation, this.proportionalLayout, this.styles, this.root.size, this.root.orthogonalSize);
2188
+ this.root = new BranchNode(orientation, this.proportionalLayout, this.styles, this.root.size, this.root.orthogonalSize, this._locked);
2127
2189
  }
2128
2190
  deserialize(json, deserializer) {
2129
2191
  const orientation = json.orientation;
@@ -2144,8 +2206,8 @@ class Gridview {
2144
2206
  };
2145
2207
  });
2146
2208
  result = new BranchNode(orientation, this.proportionalLayout, this.styles, node.size, // <- orthogonal size - flips at each depth
2147
- orthogonalSize, // <- size - flips at each depth
2148
- children);
2209
+ orthogonalSize, // <- size - flips at each depth,
2210
+ this._locked, children);
2149
2211
  }
2150
2212
  else {
2151
2213
  result = new LeafNode(deserializer.fromJSON(node), orientation, orthogonalSize, node.size);
@@ -2178,7 +2240,7 @@ class Gridview {
2178
2240
  }
2179
2241
  const oldRoot = this.root;
2180
2242
  oldRoot.element.remove();
2181
- this._root = new BranchNode(orthogonal(oldRoot.orientation), this.proportionalLayout, this.styles, this.root.orthogonalSize, this.root.size);
2243
+ this._root = new BranchNode(orthogonal(oldRoot.orientation), this.proportionalLayout, this.styles, this.root.orthogonalSize, this.root.size, this._locked);
2182
2244
  if (oldRoot.children.length === 0) ;
2183
2245
  else if (oldRoot.children.length === 1) {
2184
2246
  // can remove one level of redundant branching if there is only a single child
@@ -2246,15 +2308,16 @@ class Gridview {
2246
2308
  constructor(proportionalLayout, styles, orientation) {
2247
2309
  this.proportionalLayout = proportionalLayout;
2248
2310
  this.styles = styles;
2311
+ this._locked = false;
2249
2312
  this._maximizedNode = undefined;
2250
2313
  this.disposable = new MutableDisposable();
2251
2314
  this._onDidChange = new Emitter();
2252
2315
  this.onDidChange = this._onDidChange.event;
2253
- this._onDidMaxmizedNodeChange = new Emitter();
2254
- this.onDidMaxmizedNodeChange = this._onDidMaxmizedNodeChange.event;
2316
+ this._onDidMaximizedNodeChange = new Emitter();
2317
+ this.onDidMaximizedNodeChange = this._onDidMaximizedNodeChange.event;
2255
2318
  this.element = document.createElement('div');
2256
2319
  this.element.className = 'grid-view';
2257
- this.root = new BranchNode(orientation, proportionalLayout, styles, 0, 0);
2320
+ this.root = new BranchNode(orientation, proportionalLayout, styles, 0, 0, this._locked);
2258
2321
  }
2259
2322
  isViewVisible(location) {
2260
2323
  const [rest, index] = tail(location);
@@ -2305,7 +2368,7 @@ class Gridview {
2305
2368
  }
2306
2369
  const child = grandParent.removeChild(parentIndex);
2307
2370
  child.dispose();
2308
- const newParent = new BranchNode(parent.orientation, this.proportionalLayout, this.styles, parent.size, parent.orthogonalSize);
2371
+ const newParent = new BranchNode(parent.orientation, this.proportionalLayout, this.styles, parent.size, parent.orthogonalSize, this._locked);
2309
2372
  grandParent.addChild(newParent, parent.size, parentIndex);
2310
2373
  const newSibling = new LeafNode(parent.view, grandParent.orientation, parent.size);
2311
2374
  newParent.addChild(newSibling, newSiblingSize, 0);
@@ -2932,6 +2995,21 @@ class DockviewApi {
2932
2995
  get onDidDrop() {
2933
2996
  return this.component.onDidDrop;
2934
2997
  }
2998
+ /**
2999
+ * Invoked when a Drag'n'Drop event occurs but before dockview handles it giving the user an opportunity to intecept and
3000
+ * prevent the event from occuring using the standard `preventDefault()` syntax.
3001
+ *
3002
+ * Preventing certain events may causes unexpected behaviours, use carefully.
3003
+ */
3004
+ get onWillDrop() {
3005
+ return this.component.onWillDrop;
3006
+ }
3007
+ /**
3008
+ *
3009
+ */
3010
+ get onWillShowOverlay() {
3011
+ return this.component.onWillShowOverlay;
3012
+ }
2935
3013
  /**
2936
3014
  * Invoked before a group is dragged. Exposed for custom Drag'n'Drop functionality.
2937
3015
  */
@@ -3067,17 +3145,17 @@ class DockviewApi {
3067
3145
  hasMaximizedGroup() {
3068
3146
  return this.component.hasMaximizedGroup();
3069
3147
  }
3070
- exitMaxmizedGroup() {
3148
+ exitMaximizedGroup() {
3071
3149
  this.component.exitMaximizedGroup();
3072
3150
  }
3073
- get onDidMaxmizedGroupChange() {
3074
- return this.component.onDidMaxmizedGroupChange;
3151
+ get onDidMaximizedGroupChange() {
3152
+ return this.component.onDidMaximizedGroupChange;
3075
3153
  }
3076
3154
  /**
3077
3155
  * Add a popout group in a new Window
3078
3156
  */
3079
3157
  addPopoutGroup(item, options) {
3080
- this.component.addPopoutGroup(item, options);
3158
+ return this.component.addPopoutGroup(item, options);
3081
3159
  }
3082
3160
  }
3083
3161
 
@@ -3131,6 +3209,18 @@ class DragAndDropObserver extends CompositeDisposable {
3131
3209
  }
3132
3210
  }
3133
3211
 
3212
+ class WillShowOverlayEvent extends DockviewEvent {
3213
+ get nativeEvent() {
3214
+ return this.options.nativeEvent;
3215
+ }
3216
+ get position() {
3217
+ return this.options.position;
3218
+ }
3219
+ constructor(options) {
3220
+ super();
3221
+ this.options = options;
3222
+ }
3223
+ }
3134
3224
  function directionToPosition(direction) {
3135
3225
  switch (direction) {
3136
3226
  case 'above':
@@ -3183,6 +3273,8 @@ class Droptarget extends CompositeDisposable {
3183
3273
  this.options = options;
3184
3274
  this._onDrop = new Emitter();
3185
3275
  this.onDrop = this._onDrop.event;
3276
+ this._onWillShowOverlay = new Emitter();
3277
+ this.onWillShowOverlay = this._onWillShowOverlay.event;
3186
3278
  // use a set to take advantage of #<set>.has
3187
3279
  this._acceptedTargetZonesSet = new Set(this.options.acceptedTargetZones);
3188
3280
  this.dnd = new DragAndDropObserver(this.element, {
@@ -3211,6 +3303,19 @@ class Droptarget extends CompositeDisposable {
3211
3303
  this.removeDropTarget();
3212
3304
  return;
3213
3305
  }
3306
+ const willShowOverlayEvent = new WillShowOverlayEvent({
3307
+ nativeEvent: e,
3308
+ position: quadrant,
3309
+ });
3310
+ /**
3311
+ * Provide an opportunity to prevent the overlay appearing and in turn
3312
+ * any dnd behaviours
3313
+ */
3314
+ this._onWillShowOverlay.fire(willShowOverlayEvent);
3315
+ if (willShowOverlayEvent.defaultPrevented) {
3316
+ this.removeDropTarget();
3317
+ return;
3318
+ }
3214
3319
  if (typeof this.options.canDisplayOverlay === 'boolean') {
3215
3320
  if (!this.options.canDisplayOverlay) {
3216
3321
  this.removeDropTarget();
@@ -3253,7 +3358,7 @@ class Droptarget extends CompositeDisposable {
3253
3358
  }
3254
3359
  },
3255
3360
  });
3256
- this.addDisposables(this._onDrop, this.dnd);
3361
+ this.addDisposables(this._onDrop, this._onWillShowOverlay, this.dnd);
3257
3362
  }
3258
3363
  setTargetZones(acceptedTargetZones) {
3259
3364
  this._acceptedTargetZonesSet = new Set(acceptedTargetZones);
@@ -3306,25 +3411,44 @@ class Droptarget extends CompositeDisposable {
3306
3411
  size = clamp(0, sizeOptions.value, height) / height;
3307
3412
  }
3308
3413
  }
3309
- const translate = (1 - size) / 2;
3310
- const scale = size;
3311
- let transform;
3414
+ const box = { top: '0px', left: '0px', width: '100%', height: '100%' };
3415
+ /**
3416
+ * You can also achieve the overlay placement using the transform CSS property
3417
+ * to translate and scale the element however this has the undesired effect of
3418
+ * 'skewing' the element. Comment left here for anybody that ever revisits this.
3419
+ *
3420
+ * @see https://developer.mozilla.org/en-US/docs/Web/CSS/transform
3421
+ *
3422
+ * right
3423
+ * translateX(${100 * (1 - size) / 2}%) scaleX(${scale})
3424
+ *
3425
+ * left
3426
+ * translateX(-${100 * (1 - size) / 2}%) scaleX(${scale})
3427
+ *
3428
+ * top
3429
+ * translateY(-${100 * (1 - size) / 2}%) scaleY(${scale})
3430
+ *
3431
+ * bottom
3432
+ * translateY(${100 * (1 - size) / 2}%) scaleY(${scale})
3433
+ */
3312
3434
  if (rightClass) {
3313
- transform = `translateX(${100 * translate}%) scaleX(${scale})`;
3435
+ box.left = `${100 * (1 - size)}%`;
3436
+ box.width = `${100 * size}%`;
3314
3437
  }
3315
3438
  else if (leftClass) {
3316
- transform = `translateX(-${100 * translate}%) scaleX(${scale})`;
3439
+ box.width = `${100 * size}%`;
3317
3440
  }
3318
3441
  else if (topClass) {
3319
- transform = `translateY(-${100 * translate}%) scaleY(${scale})`;
3442
+ box.height = `${100 * size}%`;
3320
3443
  }
3321
3444
  else if (bottomClass) {
3322
- transform = `translateY(${100 * translate}%) scaleY(${scale})`;
3323
- }
3324
- else {
3325
- transform = '';
3445
+ box.top = `${100 * (1 - size)}%`;
3446
+ box.height = `${100 * size}%`;
3326
3447
  }
3327
- this.overlayElement.style.transform = transform;
3448
+ this.overlayElement.style.top = box.top;
3449
+ this.overlayElement.style.left = box.left;
3450
+ this.overlayElement.style.width = box.width;
3451
+ this.overlayElement.style.height = box.height;
3328
3452
  toggleClass(this.overlayElement, 'dv-drop-target-small-vertical', isSmallY);
3329
3453
  toggleClass(this.overlayElement, 'dv-drop-target-small-horizontal', isSmallX);
3330
3454
  toggleClass(this.overlayElement, 'dv-drop-target-left', isLeft);
@@ -3392,14 +3516,6 @@ function calculateQuadrantAsPixels(overlayType, x, y, width, height, threshold)
3392
3516
  return 'center';
3393
3517
  }
3394
3518
 
3395
- exports.DockviewDropTargets = void 0;
3396
- (function (DockviewDropTargets) {
3397
- DockviewDropTargets[DockviewDropTargets["Tab"] = 0] = "Tab";
3398
- DockviewDropTargets[DockviewDropTargets["Panel"] = 1] = "Panel";
3399
- DockviewDropTargets[DockviewDropTargets["TabContainer"] = 2] = "TabContainer";
3400
- DockviewDropTargets[DockviewDropTargets["Edge"] = 3] = "Edge";
3401
- })(exports.DockviewDropTargets || (exports.DockviewDropTargets = {}));
3402
-
3403
3519
  class ContentContainer extends CompositeDisposable {
3404
3520
  get element() {
3405
3521
  return this._element;
@@ -3427,7 +3543,7 @@ class ContentContainer extends CompositeDisposable {
3427
3543
  const data = getPanelData();
3428
3544
  if (!data &&
3429
3545
  event.shiftKey &&
3430
- this.group.location !== 'floating') {
3546
+ this.group.location.type !== 'floating') {
3431
3547
  return false;
3432
3548
  }
3433
3549
  if (data && data.viewId === this.accessor.id) {
@@ -3445,7 +3561,7 @@ class ContentContainer extends CompositeDisposable {
3445
3561
  data.groupId === this.group.id;
3446
3562
  return !groupHasOnePanelAndIsActiveDragElement;
3447
3563
  }
3448
- return this.group.canDisplayOverlay(event, position, exports.DockviewDropTargets.Panel);
3564
+ return this.group.canDisplayOverlay(event, position, 'panel');
3449
3565
  },
3450
3566
  });
3451
3567
  this.addDisposables(this.dropTarget);
@@ -3470,7 +3586,7 @@ class ContentContainer extends CompositeDisposable {
3470
3586
  let container;
3471
3587
  switch (panel.api.renderer) {
3472
3588
  case 'onlyWhenVisibile':
3473
- this.accessor.overlayRenderContainer.detatch(panel);
3589
+ this.group.renderContainer.detatch(panel);
3474
3590
  if (this.panel) {
3475
3591
  if (doRender) {
3476
3592
  this._element.appendChild(this.panel.view.content.element);
@@ -3482,7 +3598,7 @@ class ContentContainer extends CompositeDisposable {
3482
3598
  if (panel.view.content.element.parentElement === this._element) {
3483
3599
  this._element.removeChild(panel.view.content.element);
3484
3600
  }
3485
- container = this.accessor.overlayRenderContainer.attach({
3601
+ container = this.group.renderContainer.attach({
3486
3602
  panel,
3487
3603
  referenceContainer: this,
3488
3604
  });
@@ -3513,9 +3629,10 @@ class ContentContainer extends CompositeDisposable {
3513
3629
  // noop
3514
3630
  }
3515
3631
  closePanel() {
3632
+ var _a;
3516
3633
  if (this.panel) {
3517
3634
  if (this.panel.api.renderer === 'onlyWhenVisibile') {
3518
- this._element.removeChild(this.panel.view.content.element);
3635
+ (_a = this.panel.view.content.element.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(this.panel.view.content.element);
3519
3636
  }
3520
3637
  }
3521
3638
  this.panel = undefined;
@@ -3626,7 +3743,7 @@ class Tab extends CompositeDisposable {
3626
3743
  this._element.draggable = true;
3627
3744
  toggleClass(this.element, 'inactive-tab', true);
3628
3745
  const dragHandler = new TabDragHandler(this._element, this.accessor, this.group, this.panel);
3629
- this.droptarget = new Droptarget(this._element, {
3746
+ this.dropTarget = new Droptarget(this._element, {
3630
3747
  acceptedTargetZones: ['center'],
3631
3748
  canDisplayOverlay: (event, position) => {
3632
3749
  if (this.group.locked) {
@@ -3641,9 +3758,10 @@ class Tab extends CompositeDisposable {
3641
3758
  }
3642
3759
  return this.panel.id !== data.panelId;
3643
3760
  }
3644
- return this.group.model.canDisplayOverlay(event, position, exports.DockviewDropTargets.Tab);
3761
+ return this.group.model.canDisplayOverlay(event, position, 'tab');
3645
3762
  },
3646
3763
  });
3764
+ this.onWillShowOverlay = this.dropTarget.onWillShowOverlay;
3647
3765
  this.addDisposables(this._onChanged, this._onDropped, this._onDragStart, dragHandler.onDragStart((event) => {
3648
3766
  this._onDragStart.fire(event);
3649
3767
  }), dragHandler, addDisposableListener(this._element, 'mousedown', (event) => {
@@ -3651,9 +3769,9 @@ class Tab extends CompositeDisposable {
3651
3769
  return;
3652
3770
  }
3653
3771
  this._onChanged.fire(event);
3654
- }), this.droptarget.onDrop((event) => {
3772
+ }), this.dropTarget.onDrop((event) => {
3655
3773
  this._onDropped.fire(event);
3656
- }), this.droptarget);
3774
+ }), this.dropTarget);
3657
3775
  }
3658
3776
  setActive(isActive) {
3659
3777
  toggleClass(this.element, 'active-tab', isActive);
@@ -3700,7 +3818,7 @@ class GroupDragHandler extends DragHandler {
3700
3818
  }, true));
3701
3819
  }
3702
3820
  isCancelled(_event) {
3703
- if (this.group.api.location === 'floating' && !_event.shiftKey) {
3821
+ if (this.group.api.location.type === 'floating' && !_event.shiftKey) {
3704
3822
  return true;
3705
3823
  }
3706
3824
  return false;
@@ -3752,7 +3870,7 @@ class VoidContainer extends CompositeDisposable {
3752
3870
  this.accessor.doSetGroupActive(this.group);
3753
3871
  }));
3754
3872
  const handler = new GroupDragHandler(this._element, accessor, group);
3755
- this.voidDropTarget = new Droptarget(this._element, {
3873
+ this.dropTraget = new Droptarget(this._element, {
3756
3874
  acceptedTargetZones: ['center'],
3757
3875
  canDisplayOverlay: (event, position) => {
3758
3876
  var _a;
@@ -3766,14 +3884,15 @@ class VoidContainer extends CompositeDisposable {
3766
3884
  // don't show the overlay if the tab being dragged is the last panel of this group
3767
3885
  return ((_a = last(this.group.panels)) === null || _a === void 0 ? void 0 : _a.id) !== data.panelId;
3768
3886
  }
3769
- return group.model.canDisplayOverlay(event, position, exports.DockviewDropTargets.Panel);
3887
+ return group.model.canDisplayOverlay(event, position, 'panel');
3770
3888
  },
3771
3889
  });
3890
+ this.onWillShowOverlay = this.dropTraget.onWillShowOverlay;
3772
3891
  this.addDisposables(handler, handler.onDragStart((event) => {
3773
3892
  this._onDragStart.fire(event);
3774
- }), this.voidDropTarget.onDrop((event) => {
3893
+ }), this.dropTraget.onDrop((event) => {
3775
3894
  this._onDrop.fire(event);
3776
- }), this.voidDropTarget);
3895
+ }), this.dropTraget);
3777
3896
  }
3778
3897
  }
3779
3898
 
@@ -3861,19 +3980,11 @@ class TabsContainer extends CompositeDisposable {
3861
3980
  this.onTabDragStart = this._onTabDragStart.event;
3862
3981
  this._onGroupDragStart = new Emitter();
3863
3982
  this.onGroupDragStart = this._onGroupDragStart.event;
3864
- this.addDisposables(this._onDrop, this._onTabDragStart, this._onGroupDragStart);
3983
+ this._onWillShowOverlay = new Emitter();
3984
+ this.onWillShowOverlay = this._onWillShowOverlay.event;
3865
3985
  this._element = document.createElement('div');
3866
3986
  this._element.className = 'tabs-and-actions-container';
3867
3987
  toggleClass(this._element, 'dv-full-width-single-tab', this.accessor.options.singleTabMode === 'fullwidth');
3868
- this.addDisposables(this.accessor.onDidAddPanel((e) => {
3869
- if (e.api.group === this.group) {
3870
- toggleClass(this._element, 'dv-single-tab', this.size === 1);
3871
- }
3872
- }), this.accessor.onDidRemovePanel((e) => {
3873
- if (e.api.group === this.group) {
3874
- toggleClass(this._element, 'dv-single-tab', this.size === 1);
3875
- }
3876
- }));
3877
3988
  this.rightActionsContainer = document.createElement('div');
3878
3989
  this.rightActionsContainer.className = 'right-actions-container';
3879
3990
  this.leftActionsContainer = document.createElement('div');
@@ -3888,7 +3999,15 @@ class TabsContainer extends CompositeDisposable {
3888
3999
  this._element.appendChild(this.leftActionsContainer);
3889
4000
  this._element.appendChild(this.voidContainer.element);
3890
4001
  this._element.appendChild(this.rightActionsContainer);
3891
- this.addDisposables(this.voidContainer, this.voidContainer.onDragStart((event) => {
4002
+ this.addDisposables(this.accessor.onDidAddPanel((e) => {
4003
+ if (e.api.group === this.group) {
4004
+ toggleClass(this._element, 'dv-single-tab', this.size === 1);
4005
+ }
4006
+ }), this.accessor.onDidRemovePanel((e) => {
4007
+ if (e.api.group === this.group) {
4008
+ toggleClass(this._element, 'dv-single-tab', this.size === 1);
4009
+ }
4010
+ }), this._onWillShowOverlay, this._onDrop, this._onTabDragStart, this._onGroupDragStart, this.voidContainer, this.voidContainer.onDragStart((event) => {
3892
4011
  this._onGroupDragStart.fire({
3893
4012
  nativeEvent: event,
3894
4013
  group: this.group,
@@ -3898,11 +4017,15 @@ class TabsContainer extends CompositeDisposable {
3898
4017
  event: event.nativeEvent,
3899
4018
  index: this.tabs.length,
3900
4019
  });
4020
+ }), this.voidContainer.onWillShowOverlay((event) => {
4021
+ this._onWillShowOverlay.fire(new WillShowOverlayLocationEvent(event, {
4022
+ kind: 'header_space',
4023
+ }));
3901
4024
  }), addDisposableListener(this.voidContainer.element, 'mousedown', (event) => {
3902
4025
  const isFloatingGroupsEnabled = !this.accessor.options.disableFloatingGroups;
3903
4026
  if (isFloatingGroupsEnabled &&
3904
4027
  event.shiftKey &&
3905
- this.group.api.location !== 'floating') {
4028
+ this.group.api.location.type !== 'floating') {
3906
4029
  event.preventDefault();
3907
4030
  const { top, left } = this.element.getBoundingClientRect();
3908
4031
  const { top: rootTop, left: rootLeft } = this.accessor.element.getBoundingClientRect();
@@ -3965,9 +4088,9 @@ class TabsContainer extends CompositeDisposable {
3965
4088
  const disposable = new CompositeDisposable(tab.onDragStart((event) => {
3966
4089
  this._onTabDragStart.fire({ nativeEvent: event, panel });
3967
4090
  }), tab.onChanged((event) => {
3968
- var _a;
3969
4091
  const isFloatingGroupsEnabled = !this.accessor.options.disableFloatingGroups;
3970
- const isFloatingWithOnePanel = this.group.api.location === 'floating' && this.size === 1;
4092
+ const isFloatingWithOnePanel = this.group.api.location.type === 'floating' &&
4093
+ this.size === 1;
3971
4094
  if (isFloatingGroupsEnabled &&
3972
4095
  !isFloatingWithOnePanel &&
3973
4096
  event.shiftKey) {
@@ -3981,20 +4104,20 @@ class TabsContainer extends CompositeDisposable {
3981
4104
  }, { inDragMode: true });
3982
4105
  return;
3983
4106
  }
3984
- const alreadyFocused = panel.id === ((_a = this.group.model.activePanel) === null || _a === void 0 ? void 0 : _a.id) &&
3985
- this.group.model.isContentFocused;
3986
4107
  const isLeftClick = event.button === 0;
3987
4108
  if (!isLeftClick || event.defaultPrevented) {
3988
4109
  return;
3989
4110
  }
3990
- this.group.model.openPanel(panel, {
3991
- skipFocus: alreadyFocused,
3992
- });
4111
+ if (this.group.activePanel !== panel) {
4112
+ this.group.model.openPanel(panel);
4113
+ }
3993
4114
  }), tab.onDrop((event) => {
3994
4115
  this._onDrop.fire({
3995
4116
  event: event.nativeEvent,
3996
4117
  index: this.tabs.findIndex((x) => x.value === tab),
3997
4118
  });
4119
+ }), tab.onWillShowOverlay((event) => {
4120
+ this._onWillShowOverlay.fire(new WillShowOverlayLocationEvent(event, { kind: 'tab' }));
3998
4121
  }));
3999
4122
  const value = { value: tab, disposable };
4000
4123
  this.addTab(value, index);
@@ -4012,6 +4135,60 @@ class TabsContainer extends CompositeDisposable {
4012
4135
  }
4013
4136
  }
4014
4137
 
4138
+ class DockviewDidDropEvent extends DockviewEvent {
4139
+ get nativeEvent() {
4140
+ return this.options.nativeEvent;
4141
+ }
4142
+ get position() {
4143
+ return this.options.position;
4144
+ }
4145
+ get panel() {
4146
+ return this.options.panel;
4147
+ }
4148
+ get group() {
4149
+ return this.options.group;
4150
+ }
4151
+ get api() {
4152
+ return this.options.api;
4153
+ }
4154
+ constructor(options) {
4155
+ super();
4156
+ this.options = options;
4157
+ }
4158
+ getData() {
4159
+ return this.options.getData();
4160
+ }
4161
+ }
4162
+ class DockviewWillDropEvent extends DockviewDidDropEvent {
4163
+ get kind() {
4164
+ return this._kind;
4165
+ }
4166
+ constructor(options) {
4167
+ super(options);
4168
+ this._kind = options.kind;
4169
+ }
4170
+ }
4171
+ class WillShowOverlayLocationEvent {
4172
+ get kind() {
4173
+ return this._kind;
4174
+ }
4175
+ get nativeEvent() {
4176
+ return this.event.nativeEvent;
4177
+ }
4178
+ get position() {
4179
+ return this.event.position;
4180
+ }
4181
+ get defaultPrevented() {
4182
+ return this.event.defaultPrevented;
4183
+ }
4184
+ preventDefault() {
4185
+ this.event.preventDefault();
4186
+ }
4187
+ constructor(event, options) {
4188
+ this.event = event;
4189
+ this._kind = options.kind;
4190
+ }
4191
+ }
4015
4192
  class DockviewGroupPanelModel extends CompositeDisposable {
4016
4193
  get element() {
4017
4194
  throw new Error('not supported');
@@ -4057,7 +4234,7 @@ class DockviewGroupPanelModel extends CompositeDisposable {
4057
4234
  this._location = value;
4058
4235
  toggleClass(this.container, 'dv-groupview-floating', false);
4059
4236
  toggleClass(this.container, 'dv-groupview-popout', false);
4060
- switch (value) {
4237
+ switch (value.type) {
4061
4238
  case 'grid':
4062
4239
  this.contentContainer.dropTarget.setTargetZones([
4063
4240
  'top',
@@ -4093,7 +4270,7 @@ class DockviewGroupPanelModel extends CompositeDisposable {
4093
4270
  this.groupPanel = groupPanel;
4094
4271
  this._isGroupActive = false;
4095
4272
  this._locked = false;
4096
- this._location = 'grid';
4273
+ this._location = { type: 'grid' };
4097
4274
  this.mostRecentlyUsed = [];
4098
4275
  this._onDidChange = new Emitter();
4099
4276
  this.onDidChange = this._onDidChange.event;
@@ -4104,6 +4281,10 @@ class DockviewGroupPanelModel extends CompositeDisposable {
4104
4281
  this.onMove = this._onMove.event;
4105
4282
  this._onDidDrop = new Emitter();
4106
4283
  this.onDidDrop = this._onDidDrop.event;
4284
+ this._onWillDrop = new Emitter();
4285
+ this.onWillDrop = this._onWillDrop.event;
4286
+ this._onWillShowOverlay = new Emitter();
4287
+ this.onWillShowOverlay = this._onWillShowOverlay.event;
4107
4288
  this._onTabDragStart = new Emitter();
4108
4289
  this.onTabDragStart = this._onTabDragStart.event;
4109
4290
  this._onGroupDragStart = new Emitter();
@@ -4114,46 +4295,69 @@ class DockviewGroupPanelModel extends CompositeDisposable {
4114
4295
  this.onDidRemovePanel = this._onDidRemovePanel.event;
4115
4296
  this._onDidActivePanelChange = new Emitter();
4116
4297
  this.onDidActivePanelChange = this._onDidActivePanelChange.event;
4298
+ this._overwriteRenderContainer = null;
4117
4299
  toggleClass(this.container, 'groupview', true);
4300
+ this._api = new DockviewApi(this.accessor);
4118
4301
  this.tabsContainer = new TabsContainer(this.accessor, this.groupPanel);
4119
4302
  this.contentContainer = new ContentContainer(this.accessor, this);
4120
4303
  container.append(this.tabsContainer.element, this.contentContainer.element);
4121
4304
  this.header.hidden = !!options.hideHeader;
4122
4305
  this.locked = (_a = options.locked) !== null && _a !== void 0 ? _a : false;
4123
- this.addDisposables(this._onTabDragStart, this._onGroupDragStart, this.tabsContainer.onTabDragStart((event) => {
4306
+ this.addDisposables(this._onTabDragStart, this._onGroupDragStart, this._onWillShowOverlay, this.tabsContainer.onTabDragStart((event) => {
4124
4307
  this._onTabDragStart.fire(event);
4125
4308
  }), this.tabsContainer.onGroupDragStart((event) => {
4126
4309
  this._onGroupDragStart.fire(event);
4127
4310
  }), this.tabsContainer.onDrop((event) => {
4128
- this.handleDropEvent(event.event, 'center', event.index);
4311
+ this.handleDropEvent('header', event.event, 'center', event.index);
4129
4312
  }), this.contentContainer.onDidFocus(() => {
4130
- this.accessor.doSetGroupActive(this.groupPanel, true);
4313
+ this.accessor.doSetGroupActive(this.groupPanel);
4131
4314
  }), this.contentContainer.onDidBlur(() => {
4132
4315
  // noop
4133
4316
  }), this.contentContainer.dropTarget.onDrop((event) => {
4134
- this.handleDropEvent(event.nativeEvent, event.position);
4135
- }), this._onMove, this._onDidChange, this._onDidDrop, this._onDidAddPanel, this._onDidRemovePanel, this._onDidActivePanelChange);
4317
+ this.handleDropEvent('content', event.nativeEvent, event.position);
4318
+ }), this.tabsContainer.onWillShowOverlay((event) => {
4319
+ this._onWillShowOverlay.fire(event);
4320
+ }), this.contentContainer.dropTarget.onWillShowOverlay((event) => {
4321
+ this._onWillShowOverlay.fire(new WillShowOverlayLocationEvent(event, {
4322
+ kind: 'content',
4323
+ }));
4324
+ }), this._onMove, this._onDidChange, this._onDidDrop, this._onWillDrop, this._onDidAddPanel, this._onDidRemovePanel, this._onDidActivePanelChange);
4325
+ }
4326
+ focusContent() {
4327
+ this.contentContainer.element.focus();
4328
+ }
4329
+ set renderContainer(value) {
4330
+ this.panels.forEach((panel) => {
4331
+ this.renderContainer.detatch(panel);
4332
+ });
4333
+ this._overwriteRenderContainer = value;
4334
+ this.panels.forEach((panel) => {
4335
+ this.rerender(panel);
4336
+ });
4337
+ }
4338
+ get renderContainer() {
4339
+ var _a;
4340
+ return ((_a = this._overwriteRenderContainer) !== null && _a !== void 0 ? _a : this.accessor.overlayRenderContainer);
4136
4341
  }
4137
4342
  initialize() {
4138
- var _a, _b;
4139
- if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.panels) {
4343
+ if (this.options.panels) {
4140
4344
  this.options.panels.forEach((panel) => {
4141
4345
  this.doAddPanel(panel);
4142
4346
  });
4143
4347
  }
4144
- if ((_b = this.options) === null || _b === void 0 ? void 0 : _b.activePanel) {
4348
+ if (this.options.activePanel) {
4145
4349
  this.openPanel(this.options.activePanel);
4146
4350
  }
4147
4351
  // must be run after the constructor otherwise this.parent may not be
4148
4352
  // correctly initialized
4149
- this.setActive(this.isActive, true, true);
4353
+ this.setActive(this.isActive, true);
4150
4354
  this.updateContainer();
4151
4355
  if (this.accessor.options.createRightHeaderActionsElement) {
4152
4356
  this._rightHeaderActions =
4153
4357
  this.accessor.options.createRightHeaderActionsElement(this.groupPanel);
4154
4358
  this.addDisposables(this._rightHeaderActions);
4155
4359
  this._rightHeaderActions.init({
4156
- containerApi: new DockviewApi(this.accessor),
4360
+ containerApi: this._api,
4157
4361
  api: this.groupPanel.api,
4158
4362
  });
4159
4363
  this.tabsContainer.setRightActionsElement(this._rightHeaderActions.element);
@@ -4163,7 +4367,7 @@ class DockviewGroupPanelModel extends CompositeDisposable {
4163
4367
  this.accessor.options.createLeftHeaderActionsElement(this.groupPanel);
4164
4368
  this.addDisposables(this._leftHeaderActions);
4165
4369
  this._leftHeaderActions.init({
4166
- containerApi: new DockviewApi(this.accessor),
4370
+ containerApi: this._api,
4167
4371
  api: this.groupPanel.api,
4168
4372
  });
4169
4373
  this.tabsContainer.setLeftActionsElement(this._leftHeaderActions.element);
@@ -4173,7 +4377,7 @@ class DockviewGroupPanelModel extends CompositeDisposable {
4173
4377
  this.accessor.options.createPrefixHeaderActionsElement(this.groupPanel);
4174
4378
  this.addDisposables(this._prefixHeaderActions);
4175
4379
  this._prefixHeaderActions.init({
4176
- containerApi: new DockviewApi(this.accessor),
4380
+ containerApi: this._api,
4177
4381
  api: this.groupPanel.api,
4178
4382
  });
4179
4383
  this.tabsContainer.setPrefixActionsElement(this._prefixHeaderActions.element);
@@ -4253,35 +4457,45 @@ class DockviewGroupPanelModel extends CompositeDisposable {
4253
4457
  //noop
4254
4458
  }
4255
4459
  focus() {
4256
- var _a, _b;
4257
- (_b = (_a = this._activePanel) === null || _a === void 0 ? void 0 : _a.focus) === null || _b === void 0 ? void 0 : _b.call(_a);
4460
+ var _a;
4461
+ (_a = this._activePanel) === null || _a === void 0 ? void 0 : _a.focus();
4258
4462
  }
4259
4463
  openPanel(panel, options = {}) {
4464
+ /**
4465
+ * set the panel group
4466
+ * add the panel
4467
+ * check if group active
4468
+ * check if panel active
4469
+ */
4260
4470
  if (typeof options.index !== 'number' ||
4261
4471
  options.index > this.panels.length) {
4262
4472
  options.index = this.panels.length;
4263
4473
  }
4264
- const skipSetPanelActive = !!options.skipSetPanelActive;
4265
- const skipSetGroupActive = !!options.skipSetGroupActive;
4474
+ const skipSetActive = !!options.skipSetActive;
4266
4475
  // ensure the group is updated before we fire any events
4267
- panel.updateParentGroup(this.groupPanel, true);
4476
+ panel.updateParentGroup(this.groupPanel, {
4477
+ skipSetActive: options.skipSetActive,
4478
+ });
4479
+ this.doAddPanel(panel, options.index, {
4480
+ skipSetActive: skipSetActive,
4481
+ });
4268
4482
  if (this._activePanel === panel) {
4269
- if (!skipSetGroupActive) {
4270
- this.accessor.doSetGroupActive(this.groupPanel);
4271
- }
4272
4483
  this.contentContainer.renderPanel(panel, { asActive: true });
4273
4484
  return;
4274
4485
  }
4275
- this.doAddPanel(panel, options.index, skipSetPanelActive);
4276
- if (!skipSetPanelActive) {
4486
+ if (!skipSetActive) {
4277
4487
  this.doSetActivePanel(panel);
4278
4488
  }
4279
- if (!skipSetGroupActive) {
4280
- this.accessor.doSetGroupActive(this.groupPanel, !!options.skipFocus);
4489
+ if (!options.skipSetGroupActive) {
4490
+ this.accessor.doSetGroupActive(this.groupPanel);
4491
+ }
4492
+ if (!options.skipSetActive) {
4493
+ this.updateContainer();
4281
4494
  }
4282
- this.updateContainer();
4283
4495
  }
4284
- removePanel(groupItemOrId) {
4496
+ removePanel(groupItemOrId, options = {
4497
+ skipSetActive: false,
4498
+ }) {
4285
4499
  const id = typeof groupItemOrId === 'string'
4286
4500
  ? groupItemOrId
4287
4501
  : groupItemOrId.id;
@@ -4289,7 +4503,7 @@ class DockviewGroupPanelModel extends CompositeDisposable {
4289
4503
  if (!panelToRemove) {
4290
4504
  throw new Error('invalid operation');
4291
4505
  }
4292
- return this._removePanel(panelToRemove);
4506
+ return this._removePanel(panelToRemove, options);
4293
4507
  }
4294
4508
  closeAllPanels() {
4295
4509
  if (this.panels.length > 0) {
@@ -4315,12 +4529,8 @@ class DockviewGroupPanelModel extends CompositeDisposable {
4315
4529
  updateActions(element) {
4316
4530
  this.tabsContainer.setRightActionsElement(element);
4317
4531
  }
4318
- setActive(isGroupActive, skipFocus = false, force = false) {
4319
- var _a, _b, _c, _d;
4532
+ setActive(isGroupActive, force = false) {
4320
4533
  if (!force && this.isActive === isGroupActive) {
4321
- if (!skipFocus) {
4322
- (_b = (_a = this._activePanel) === null || _a === void 0 ? void 0 : _a.focus) === null || _b === void 0 ? void 0 : _b.call(_a);
4323
- }
4324
4534
  return;
4325
4535
  }
4326
4536
  this._isGroupActive = isGroupActive;
@@ -4331,11 +4541,6 @@ class DockviewGroupPanelModel extends CompositeDisposable {
4331
4541
  this.doSetActivePanel(this.panels[0]);
4332
4542
  }
4333
4543
  this.updateContainer();
4334
- if (isGroupActive) {
4335
- if (!skipFocus) {
4336
- (_d = (_c = this._activePanel) === null || _c === void 0 ? void 0 : _c.focus) === null || _d === void 0 ? void 0 : _d.call(_c);
4337
- }
4338
- }
4339
4544
  }
4340
4545
  layout(width, height) {
4341
4546
  var _a;
@@ -4346,17 +4551,22 @@ class DockviewGroupPanelModel extends CompositeDisposable {
4346
4551
  this._activePanel.layout(this._width, this._height);
4347
4552
  }
4348
4553
  }
4349
- _removePanel(panel) {
4554
+ _removePanel(panel, options) {
4350
4555
  const isActivePanel = this._activePanel === panel;
4351
4556
  this.doRemovePanel(panel);
4352
4557
  if (isActivePanel && this.panels.length > 0) {
4353
4558
  const nextPanel = this.mostRecentlyUsed[0];
4354
- this.openPanel(nextPanel);
4559
+ this.openPanel(nextPanel, {
4560
+ skipSetActive: options.skipSetActive,
4561
+ skipSetGroupActive: options.skipSetActiveGroup,
4562
+ });
4355
4563
  }
4356
4564
  if (this._activePanel && this.panels.length === 0) {
4357
4565
  this.doSetActivePanel(undefined);
4358
4566
  }
4359
- this.updateContainer();
4567
+ if (!options.skipSetActive) {
4568
+ this.updateContainer();
4569
+ }
4360
4570
  return panel;
4361
4571
  }
4362
4572
  doRemovePanel(panel) {
@@ -4371,13 +4581,13 @@ class DockviewGroupPanelModel extends CompositeDisposable {
4371
4581
  }
4372
4582
  this._onDidRemovePanel.fire({ panel });
4373
4583
  }
4374
- doAddPanel(panel, index = this.panels.length, skipSetActive = false) {
4584
+ doAddPanel(panel, index = this.panels.length, options = { skipSetActive: false }) {
4375
4585
  const existingPanel = this._panels.indexOf(panel);
4376
4586
  const hasExistingPanel = existingPanel > -1;
4377
4587
  this.tabsContainer.show();
4378
4588
  this.contentContainer.show();
4379
4589
  this.tabsContainer.openPanel(panel, index);
4380
- if (!skipSetActive) {
4590
+ if (!options.skipSetActive) {
4381
4591
  this.contentContainer.openPanel(panel);
4382
4592
  }
4383
4593
  if (hasExistingPanel) {
@@ -4389,12 +4599,17 @@ class DockviewGroupPanelModel extends CompositeDisposable {
4389
4599
  this._onDidAddPanel.fire({ panel });
4390
4600
  }
4391
4601
  doSetActivePanel(panel) {
4602
+ if (this._activePanel === panel) {
4603
+ return;
4604
+ }
4392
4605
  this._activePanel = panel;
4393
4606
  if (panel) {
4394
4607
  this.tabsContainer.setActivePanel(panel);
4395
4608
  panel.layout(this._width, this._height);
4396
4609
  this.updateMru(panel);
4397
- this._onDidActivePanelChange.fire({ panel });
4610
+ this._onDidActivePanelChange.fire({
4611
+ panel,
4612
+ });
4398
4613
  }
4399
4614
  }
4400
4615
  updateMru(panel) {
@@ -4406,11 +4621,11 @@ class DockviewGroupPanelModel extends CompositeDisposable {
4406
4621
  updateContainer() {
4407
4622
  var _a, _b;
4408
4623
  toggleClass(this.container, 'empty', this.isEmpty);
4409
- this.panels.forEach((panel) => panel.updateParentGroup(this.groupPanel, this.isActive));
4624
+ this.panels.forEach((panel) => panel.runEvents());
4410
4625
  if (this.isEmpty && !this.watermark) {
4411
4626
  const watermark = this.accessor.createWatermarkComponent();
4412
4627
  watermark.init({
4413
- containerApi: new DockviewApi(this.accessor),
4628
+ containerApi: this._api,
4414
4629
  group: this.groupPanel,
4415
4630
  });
4416
4631
  this.watermark = watermark;
@@ -4443,10 +4658,32 @@ class DockviewGroupPanelModel extends CompositeDisposable {
4443
4658
  }
4444
4659
  return false;
4445
4660
  }
4446
- handleDropEvent(event, position, index) {
4661
+ handleDropEvent(type, event, position, index) {
4447
4662
  if (this.locked === 'no-drop-target') {
4448
4663
  return;
4449
4664
  }
4665
+ function getKind() {
4666
+ switch (type) {
4667
+ case 'header':
4668
+ return typeof index === 'number' ? 'tab' : 'header_space';
4669
+ case 'content':
4670
+ return 'content';
4671
+ }
4672
+ }
4673
+ const panel = typeof index === 'number' ? this.panels[index] : undefined;
4674
+ const willDropEvent = new DockviewWillDropEvent({
4675
+ nativeEvent: event,
4676
+ position,
4677
+ panel,
4678
+ getData: () => getPanelData(),
4679
+ kind: getKind(),
4680
+ group: this.groupPanel,
4681
+ api: this._api,
4682
+ });
4683
+ this._onWillDrop.fire(willDropEvent);
4684
+ if (willDropEvent.defaultPrevented) {
4685
+ return;
4686
+ }
4450
4687
  const data = getPanelData();
4451
4688
  if (data && data.viewId === this.accessor.id) {
4452
4689
  if (data.panelId === null) {
@@ -4479,12 +4716,14 @@ class DockviewGroupPanelModel extends CompositeDisposable {
4479
4716
  });
4480
4717
  }
4481
4718
  else {
4482
- this._onDidDrop.fire({
4719
+ this._onDidDrop.fire(new DockviewDidDropEvent({
4483
4720
  nativeEvent: event,
4484
4721
  position,
4485
- index,
4722
+ panel,
4486
4723
  getData: () => getPanelData(),
4487
- });
4724
+ group: this.groupPanel,
4725
+ api: this._api,
4726
+ }));
4488
4727
  }
4489
4728
  }
4490
4729
  dispose() {
@@ -4492,6 +4731,7 @@ class DockviewGroupPanelModel extends CompositeDisposable {
4492
4731
  super.dispose();
4493
4732
  (_a = this.watermark) === null || _a === void 0 ? void 0 : _a.element.remove();
4494
4733
  (_c = (_b = this.watermark) === null || _b === void 0 ? void 0 : _b.dispose) === null || _c === void 0 ? void 0 : _c.call(_b);
4734
+ this.watermark = undefined;
4495
4735
  for (const panel of this.panels) {
4496
4736
  panel.dispose();
4497
4737
  }
@@ -4513,15 +4753,7 @@ class Resizable extends CompositeDisposable {
4513
4753
  constructor(parentElement, disableResizing = false) {
4514
4754
  super();
4515
4755
  this._disableResizing = disableResizing;
4516
- if (parentElement) {
4517
- this._element = parentElement;
4518
- }
4519
- else {
4520
- this._element = document.createElement('div');
4521
- this._element.style.height = '100%';
4522
- this._element.style.width = '100%';
4523
- this._element.className = 'dv-resizable-container';
4524
- }
4756
+ this._element = parentElement;
4525
4757
  this.addDisposables(watchElementResize(this._element, (entry) => {
4526
4758
  if (this.isDisposed) {
4527
4759
  /**
@@ -4609,25 +4841,38 @@ class BaseGrid extends Resizable {
4609
4841
  get activeGroup() {
4610
4842
  return this._activeGroup;
4611
4843
  }
4844
+ get locked() {
4845
+ return this.gridview.locked;
4846
+ }
4847
+ set locked(value) {
4848
+ this.gridview.locked = value;
4849
+ }
4612
4850
  constructor(options) {
4613
- super(options.parentElement, options.disableAutoResizing);
4851
+ super(document.createElement('div'), options.disableAutoResizing);
4614
4852
  this._id = nextLayoutId$1.next();
4615
4853
  this._groups = new Map();
4616
4854
  this._onDidLayoutChange = new Emitter();
4617
4855
  this.onDidLayoutChange = this._onDidLayoutChange.event;
4618
- this._onDidRemoveGroup = new Emitter();
4619
- this.onDidRemoveGroup = this._onDidRemoveGroup.event;
4620
- this._onDidAddGroup = new Emitter();
4621
- this.onDidAddGroup = this._onDidAddGroup.event;
4622
- this._onDidActiveGroupChange = new Emitter();
4623
- this.onDidActiveGroupChange = this._onDidActiveGroupChange.event;
4856
+ this._onDidRemove = new Emitter();
4857
+ this.onDidRemove = this._onDidRemove.event;
4858
+ this._onDidAdd = new Emitter();
4859
+ this.onDidAdd = this._onDidAdd.event;
4860
+ this._onDidActiveChange = new Emitter();
4861
+ this.onDidActiveChange = this._onDidActiveChange.event;
4624
4862
  this._bufferOnDidLayoutChange = new TickDelayedEvent();
4863
+ this.element.style.height = '100%';
4864
+ this.element.style.width = '100%';
4865
+ options.parentElement.appendChild(this.element);
4625
4866
  this.gridview = new Gridview(!!options.proportionalLayout, options.styles, options.orientation);
4867
+ this.gridview.locked = !!options.locked;
4626
4868
  this.element.appendChild(this.gridview.element);
4627
4869
  this.layout(0, 0, true); // set some elements height/widths
4628
- this.addDisposables(this.gridview.onDidChange(() => {
4870
+ this.addDisposables(Disposable.from(() => {
4871
+ var _a;
4872
+ (_a = this.element.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(this.element);
4873
+ }), this.gridview.onDidChange(() => {
4629
4874
  this._bufferOnDidLayoutChange.fire();
4630
- }), exports.DockviewEvent.any(this.onDidAddGroup, this.onDidRemoveGroup, this.onDidActiveGroupChange)(() => {
4875
+ }), exports.DockviewEvent.any(this.onDidAdd, this.onDidRemove, this.onDidActiveChange)(() => {
4631
4876
  this._bufferOnDidLayoutChange.fire();
4632
4877
  }), this._bufferOnDidLayoutChange.onEvent(() => {
4633
4878
  this._onDidLayoutChange.fire();
@@ -4642,6 +4887,7 @@ class BaseGrid extends Resizable {
4642
4887
  }
4643
4888
  maximizeGroup(panel) {
4644
4889
  this.gridview.maximizeView(panel);
4890
+ this.doSetGroupActive(panel);
4645
4891
  }
4646
4892
  isMaximizedGroup(panel) {
4647
4893
  return this.gridview.maximizedView() === panel;
@@ -4652,13 +4898,12 @@ class BaseGrid extends Resizable {
4652
4898
  hasMaximizedGroup() {
4653
4899
  return this.gridview.hasMaximizedView();
4654
4900
  }
4655
- get onDidMaxmizedGroupChange() {
4656
- return this.gridview.onDidMaxmizedNodeChange;
4901
+ get onDidMaximizedGroupChange() {
4902
+ return this.gridview.onDidMaximizedNodeChange;
4657
4903
  }
4658
4904
  doAddGroup(group, location = [0], size) {
4659
4905
  this.gridview.addView(group, size !== null && size !== void 0 ? size : exports.Sizing.Distribute, location);
4660
- this._onDidAddGroup.fire(group);
4661
- this.doSetGroupActive(group);
4906
+ this._onDidAdd.fire(group);
4662
4907
  }
4663
4908
  doRemoveGroup(group, options) {
4664
4909
  if (!this._groups.has(group.id)) {
@@ -4670,8 +4915,8 @@ class BaseGrid extends Resizable {
4670
4915
  item.disposable.dispose();
4671
4916
  item.value.dispose();
4672
4917
  this._groups.delete(group.id);
4918
+ this._onDidRemove.fire(group);
4673
4919
  }
4674
- this._onDidRemoveGroup.fire(group);
4675
4920
  if (!(options === null || options === void 0 ? void 0 : options.skipActive) && this._activeGroup === group) {
4676
4921
  const groups = Array.from(this._groups.values());
4677
4922
  this.doSetGroupActive(groups.length > 0 ? groups[0].value : undefined);
@@ -4682,25 +4927,18 @@ class BaseGrid extends Resizable {
4682
4927
  var _a;
4683
4928
  return (_a = this._groups.get(id)) === null || _a === void 0 ? void 0 : _a.value;
4684
4929
  }
4685
- doSetGroupActive(group, skipFocus) {
4686
- var _a, _b, _c;
4930
+ doSetGroupActive(group) {
4687
4931
  if (this._activeGroup === group) {
4688
4932
  return;
4689
4933
  }
4690
4934
  if (this._activeGroup) {
4691
4935
  this._activeGroup.setActive(false);
4692
- if (!skipFocus) {
4693
- (_b = (_a = this._activeGroup).focus) === null || _b === void 0 ? void 0 : _b.call(_a);
4694
- }
4695
4936
  }
4696
4937
  if (group) {
4697
4938
  group.setActive(true);
4698
- if (!skipFocus) {
4699
- (_c = group.focus) === null || _c === void 0 ? void 0 : _c.call(group);
4700
- }
4701
4939
  }
4702
4940
  this._activeGroup = group;
4703
- this._onDidActiveGroupChange.fire(group);
4941
+ this._onDidActiveChange.fire(group);
4704
4942
  }
4705
4943
  removeGroup(group) {
4706
4944
  this.doRemoveGroup(group);
@@ -4745,9 +4983,9 @@ class BaseGrid extends Resizable {
4745
4983
  this.gridview.layout(width, height);
4746
4984
  }
4747
4985
  dispose() {
4748
- this._onDidActiveGroupChange.dispose();
4749
- this._onDidAddGroup.dispose();
4750
- this._onDidRemoveGroup.dispose();
4986
+ this._onDidActiveChange.dispose();
4987
+ this._onDidAdd.dispose();
4988
+ this._onDidRemove.dispose();
4751
4989
  this._onDidLayoutChange.dispose();
4752
4990
  for (const group of this.groups) {
4753
4991
  group.dispose();
@@ -4757,11 +4995,15 @@ class BaseGrid extends Resizable {
4757
4995
  }
4758
4996
  }
4759
4997
 
4998
+ class WillFocusEvent extends DockviewEvent {
4999
+ constructor() {
5000
+ super();
5001
+ }
5002
+ }
4760
5003
  /**
4761
5004
  * A core api implementation that should be used across all panel-like objects
4762
5005
  */
4763
5006
  class PanelApiImpl extends CompositeDisposable {
4764
- //
4765
5007
  get isFocused() {
4766
5008
  return this._isFocused;
4767
5009
  }
@@ -4771,6 +5013,9 @@ class PanelApiImpl extends CompositeDisposable {
4771
5013
  get isVisible() {
4772
5014
  return this._isVisible;
4773
5015
  }
5016
+ get isHidden() {
5017
+ return this._isHidden;
5018
+ }
4774
5019
  get width() {
4775
5020
  return this._width;
4776
5021
  }
@@ -4783,38 +5028,26 @@ class PanelApiImpl extends CompositeDisposable {
4783
5028
  this._isFocused = false;
4784
5029
  this._isActive = false;
4785
5030
  this._isVisible = true;
5031
+ this._isHidden = false;
4786
5032
  this._width = 0;
4787
5033
  this._height = 0;
4788
5034
  this.panelUpdatesDisposable = new MutableDisposable();
4789
- this._onDidDimensionChange = new Emitter({
4790
- replay: true,
4791
- });
5035
+ this._onDidDimensionChange = new Emitter();
4792
5036
  this.onDidDimensionsChange = this._onDidDimensionChange.event;
4793
- //
4794
- this._onDidChangeFocus = new Emitter({
4795
- replay: true,
4796
- });
5037
+ this._onDidChangeFocus = new Emitter();
4797
5038
  this.onDidFocusChange = this._onDidChangeFocus.event;
4798
5039
  //
4799
- this._onFocusEvent = new Emitter();
4800
- this.onFocusEvent = this._onFocusEvent.event;
5040
+ this._onWillFocus = new Emitter();
5041
+ this.onWillFocus = this._onWillFocus.event;
4801
5042
  //
4802
- this._onDidVisibilityChange = new Emitter({
4803
- replay: true,
4804
- });
5043
+ this._onDidVisibilityChange = new Emitter();
4805
5044
  this.onDidVisibilityChange = this._onDidVisibilityChange.event;
4806
- //
4807
- this._onVisibilityChange = new Emitter();
4808
- this.onVisibilityChange = this._onVisibilityChange.event;
4809
- //
4810
- this._onDidActiveChange = new Emitter({
4811
- replay: true,
4812
- });
5045
+ this._onDidHiddenChange = new Emitter();
5046
+ this.onDidHiddenChange = this._onDidHiddenChange.event;
5047
+ this._onDidActiveChange = new Emitter();
4813
5048
  this.onDidActiveChange = this._onDidActiveChange.event;
4814
- //
4815
5049
  this._onActiveChange = new Emitter();
4816
5050
  this.onActiveChange = this._onActiveChange.event;
4817
- //
4818
5051
  this._onUpdateParameters = new Emitter();
4819
5052
  this.onUpdateParameters = this._onUpdateParameters.event;
4820
5053
  this.addDisposables(this.onDidFocusChange((event) => {
@@ -4823,10 +5056,12 @@ class PanelApiImpl extends CompositeDisposable {
4823
5056
  this._isActive = event.isActive;
4824
5057
  }), this.onDidVisibilityChange((event) => {
4825
5058
  this._isVisible = event.isVisible;
5059
+ }), this.onDidHiddenChange((event) => {
5060
+ this._isHidden = event.isHidden;
4826
5061
  }), this.onDidDimensionsChange((event) => {
4827
5062
  this._width = event.width;
4828
5063
  this._height = event.height;
4829
- }), this.panelUpdatesDisposable, this._onDidDimensionChange, this._onDidChangeFocus, this._onDidVisibilityChange, this._onDidActiveChange, this._onFocusEvent, this._onActiveChange, this._onVisibilityChange, this._onUpdateParameters);
5064
+ }), this.panelUpdatesDisposable, this._onDidDimensionChange, this._onDidChangeFocus, this._onDidVisibilityChange, this._onDidActiveChange, this._onWillFocus, this._onActiveChange, this._onUpdateParameters, this._onWillFocus, this._onDidHiddenChange, this._onUpdateParameters);
4830
5065
  }
4831
5066
  initialize(panel) {
4832
5067
  this.panelUpdatesDisposable.value = this._onUpdateParameters.event((parameters) => {
@@ -4835,8 +5070,8 @@ class PanelApiImpl extends CompositeDisposable {
4835
5070
  });
4836
5071
  });
4837
5072
  }
4838
- setVisible(isVisible) {
4839
- this._onVisibilityChange.fire({ isVisible });
5073
+ setHidden(isHidden) {
5074
+ this._onDidHiddenChange.fire({ isHidden });
4840
5075
  }
4841
5076
  setActive() {
4842
5077
  this._onActiveChange.fire();
@@ -4844,9 +5079,6 @@ class PanelApiImpl extends CompositeDisposable {
4844
5079
  updateParameters(parameters) {
4845
5080
  this._onUpdateParameters.fire(parameters);
4846
5081
  }
4847
- dispose() {
4848
- super.dispose();
4849
- }
4850
5082
  }
4851
5083
 
4852
5084
  class SplitviewPanelApiImpl extends PanelApiImpl {
@@ -4934,7 +5166,12 @@ class BasePanelView extends CompositeDisposable {
4934
5166
  }), focusTracker);
4935
5167
  }
4936
5168
  focus() {
4937
- this.api._onFocusEvent.fire();
5169
+ const event = new WillFocusEvent();
5170
+ this.api._onWillFocus.fire(event);
5171
+ if (event.defaultPrevented) {
5172
+ return;
5173
+ }
5174
+ this._element.focus();
4938
5175
  }
4939
5176
  layout(width, height) {
4940
5177
  this._width = width;
@@ -5263,9 +5500,7 @@ class GridviewPanelApiImpl extends PanelApiImpl {
5263
5500
  super(id);
5264
5501
  this._onDidConstraintsChangeInternal = new Emitter();
5265
5502
  this.onDidConstraintsChangeInternal = this._onDidConstraintsChangeInternal.event;
5266
- this._onDidConstraintsChange = new Emitter({
5267
- replay: true,
5268
- });
5503
+ this._onDidConstraintsChange = new Emitter();
5269
5504
  this.onDidConstraintsChange = this._onDidConstraintsChange.event;
5270
5505
  this._onDidSizeChange = new Emitter();
5271
5506
  this.onDidSizeChange = this._onDidSizeChange.event;
@@ -5358,13 +5593,13 @@ class GridviewPanel extends BasePanelView {
5358
5593
  this._maximumHeight = options.maximumHeight;
5359
5594
  }
5360
5595
  this.api.initialize(this); // TODO: required to by-pass 'super before this' requirement
5361
- this.addDisposables(this.api.onVisibilityChange((event) => {
5362
- const { isVisible } = event;
5596
+ this.addDisposables(this.api.onDidHiddenChange((event) => {
5597
+ const { isHidden } = event;
5363
5598
  const { accessor } = this._params;
5364
- accessor.setVisible(this, isVisible);
5599
+ accessor.setVisible(this, !isHidden);
5365
5600
  }), this.api.onActiveChange(() => {
5366
5601
  const { accessor } = this._params;
5367
- accessor.setActive(this);
5602
+ accessor.doSetGroupActive(this);
5368
5603
  }), this.api.onDidConstraintsChangeInternal((event) => {
5369
5604
  if (typeof event.minimumWidth === 'number' ||
5370
5605
  typeof event.minimumWidth === 'function') {
@@ -5447,6 +5682,17 @@ class DockviewGroupPanelApiImpl extends GridviewPanelApiImpl {
5447
5682
  this.onDidLocationChange = this._onDidLocationChange.event;
5448
5683
  this.addDisposables(this._onDidLocationChange);
5449
5684
  }
5685
+ close() {
5686
+ if (!this._group) {
5687
+ return;
5688
+ }
5689
+ return this.accessor.removeGroup(this._group);
5690
+ }
5691
+ getWindow() {
5692
+ return this.location.type === 'popout'
5693
+ ? this.location.getWindow()
5694
+ : window;
5695
+ }
5450
5696
  moveTo(options) {
5451
5697
  var _a, _b, _c;
5452
5698
  if (!this._group) {
@@ -5454,14 +5700,23 @@ class DockviewGroupPanelApiImpl extends GridviewPanelApiImpl {
5454
5700
  }
5455
5701
  const group = (_a = options.group) !== null && _a !== void 0 ? _a : this.accessor.addGroup({
5456
5702
  direction: positionToDirection((_b = options.position) !== null && _b !== void 0 ? _b : 'right'),
5703
+ skipSetActive: true,
5704
+ });
5705
+ this.accessor.moveGroupOrPanel({
5706
+ from: { groupId: this._group.id },
5707
+ to: {
5708
+ group,
5709
+ position: options.group
5710
+ ? (_c = options.position) !== null && _c !== void 0 ? _c : 'center'
5711
+ : 'center',
5712
+ },
5457
5713
  });
5458
- this.accessor.moveGroupOrPanel(group, this._group.id, undefined, options.group ? (_c = options.position) !== null && _c !== void 0 ? _c : 'center' : 'center');
5459
5714
  }
5460
5715
  maximize() {
5461
5716
  if (!this._group) {
5462
5717
  throw new Error(NOT_INITIALIZED_MESSAGE);
5463
5718
  }
5464
- if (this.location !== 'grid') {
5719
+ if (this.location.type !== 'grid') {
5465
5720
  // only grid groups can be maximized
5466
5721
  return;
5467
5722
  }
@@ -5518,6 +5773,12 @@ class DockviewGroupPanel extends GridviewPanel {
5518
5773
  this.api.initialize(this); // cannot use 'this' after after 'super' call
5519
5774
  this._model = new DockviewGroupPanelModel(this.element, accessor, id, options, this);
5520
5775
  }
5776
+ focus() {
5777
+ if (!this.api.isActive) {
5778
+ this.api.setActive();
5779
+ }
5780
+ super.focus();
5781
+ }
5521
5782
  initialize() {
5522
5783
  this._model.initialize();
5523
5784
  }
@@ -5563,6 +5824,9 @@ function isGroupOptionsWithGroup(data) {
5563
5824
  }
5564
5825
 
5565
5826
  class DockviewPanelApiImpl extends GridviewPanelApiImpl {
5827
+ get location() {
5828
+ return this.group.api.location;
5829
+ }
5566
5830
  get title() {
5567
5831
  return this.panel.title;
5568
5832
  }
@@ -5574,15 +5838,34 @@ class DockviewPanelApiImpl extends GridviewPanelApiImpl {
5574
5838
  }
5575
5839
  set group(value) {
5576
5840
  const isOldGroupActive = this.isGroupActive;
5577
- this._group = value;
5578
- this._onDidGroupChange.fire();
5579
- if (this._group) {
5580
- this.disposable.value = this._group.api.onDidActiveChange(() => {
5581
- this._onDidActiveGroupChange.fire();
5841
+ if (this._group !== value) {
5842
+ this._group = value;
5843
+ this._onDidGroupChange.fire({});
5844
+ let _trackGroupActive = isOldGroupActive; // prevent duplicate events with same state
5845
+ this.groupEventsDisposable.value = new CompositeDisposable(this.group.api.onDidLocationChange((event) => {
5846
+ if (this.group !== this.panel.group) {
5847
+ return;
5848
+ }
5849
+ this._onDidLocationChange.fire(event);
5850
+ }), this.group.api.onDidActiveChange(() => {
5851
+ if (this.group !== this.panel.group) {
5852
+ return;
5853
+ }
5854
+ if (_trackGroupActive !== this.isGroupActive) {
5855
+ _trackGroupActive = this.isGroupActive;
5856
+ this._onDidActiveGroupChange.fire({
5857
+ isActive: this.isGroupActive,
5858
+ });
5859
+ }
5860
+ }));
5861
+ // if (this.isGroupActive !== isOldGroupActive) {
5862
+ // this._onDidActiveGroupChange.fire({
5863
+ // isActive: this.isGroupActive,
5864
+ // });
5865
+ // }
5866
+ this._onDidLocationChange.fire({
5867
+ location: this.group.api.location,
5582
5868
  });
5583
- if (this.isGroupActive !== isOldGroupActive) {
5584
- this._onDidActiveGroupChange.fire();
5585
- }
5586
5869
  }
5587
5870
  }
5588
5871
  get group() {
@@ -5600,14 +5883,26 @@ class DockviewPanelApiImpl extends GridviewPanelApiImpl {
5600
5883
  this.onDidGroupChange = this._onDidGroupChange.event;
5601
5884
  this._onDidRendererChange = new Emitter();
5602
5885
  this.onDidRendererChange = this._onDidRendererChange.event;
5603
- this.disposable = new MutableDisposable();
5886
+ this._onDidLocationChange = new Emitter();
5887
+ this.onDidLocationChange = this._onDidLocationChange.event;
5888
+ this.groupEventsDisposable = new MutableDisposable();
5604
5889
  this.initialize(panel);
5605
5890
  this._group = group;
5606
- this.addDisposables(this.disposable, this._onDidRendererChange, this._onDidTitleChange, this._onDidGroupChange, this._onDidActiveGroupChange);
5891
+ this.addDisposables(this.groupEventsDisposable, this._onDidRendererChange, this._onDidTitleChange, this._onDidGroupChange, this._onDidActiveGroupChange, this._onDidLocationChange);
5892
+ }
5893
+ getWindow() {
5894
+ return this.group.api.getWindow();
5607
5895
  }
5608
5896
  moveTo(options) {
5609
5897
  var _a;
5610
- this.accessor.moveGroupOrPanel(options.group, this._group.id, this.panel.id, (_a = options.position) !== null && _a !== void 0 ? _a : 'center', options.index);
5898
+ this.accessor.moveGroupOrPanel({
5899
+ from: { groupId: this._group.id, panelId: this.panel.id },
5900
+ to: {
5901
+ group: options.group,
5902
+ position: (_a = options.position) !== null && _a !== void 0 ? _a : 'center',
5903
+ index: options.index,
5904
+ },
5905
+ });
5611
5906
  }
5612
5907
  setTitle(title) {
5613
5908
  this.panel.setTitle(title);
@@ -5668,7 +5963,14 @@ class DockviewPanel extends CompositeDisposable {
5668
5963
  this.setTitle(params.title);
5669
5964
  }
5670
5965
  focus() {
5671
- this.api._onFocusEvent.fire();
5966
+ const event = new WillFocusEvent();
5967
+ this.api._onWillFocus.fire(event);
5968
+ if (event.defaultPrevented) {
5969
+ return;
5970
+ }
5971
+ if (!this.api.isActive) {
5972
+ this.api.setActive();
5973
+ }
5672
5974
  }
5673
5975
  toJSON() {
5674
5976
  return {
@@ -5725,20 +6027,40 @@ class DockviewPanel extends CompositeDisposable {
5725
6027
  },
5726
6028
  });
5727
6029
  }
5728
- updateParentGroup(group, isGroupActive) {
6030
+ updateParentGroup(group, options) {
5729
6031
  this._group = group;
5730
- this.api.group = group;
6032
+ this.api.group = this._group;
5731
6033
  const isPanelVisible = this._group.model.isPanelActive(this);
5732
- this.api._onDidActiveChange.fire({
5733
- isActive: isGroupActive && isPanelVisible,
5734
- });
5735
- this.api._onDidVisibilityChange.fire({
5736
- isVisible: isPanelVisible,
5737
- });
5738
- this.view.updateParentGroup(this._group, this._group.model.isPanelActive(this));
6034
+ const isActive = this.group.api.isActive && isPanelVisible;
6035
+ if (!(options === null || options === void 0 ? void 0 : options.skipSetActive)) {
6036
+ if (this.api.isActive !== isActive) {
6037
+ this.api._onDidActiveChange.fire({
6038
+ isActive: this.group.api.isActive && isPanelVisible,
6039
+ });
6040
+ }
6041
+ }
6042
+ if (this.api.isVisible !== isPanelVisible) {
6043
+ this.api._onDidVisibilityChange.fire({
6044
+ isVisible: isPanelVisible,
6045
+ });
6046
+ }
6047
+ }
6048
+ runEvents() {
6049
+ const isPanelVisible = this._group.model.isPanelActive(this);
6050
+ const isActive = this.group.api.isActive && isPanelVisible;
6051
+ if (this.api.isActive !== isActive) {
6052
+ this.api._onDidActiveChange.fire({
6053
+ isActive: this.group.api.isActive && isPanelVisible,
6054
+ });
6055
+ }
6056
+ if (this.api.isVisible !== isPanelVisible) {
6057
+ this.api._onDidVisibilityChange.fire({
6058
+ isVisible: isPanelVisible,
6059
+ });
6060
+ }
5739
6061
  }
5740
6062
  layout(width, height) {
5741
- // the obtain the correct dimensions of the content panel we must deduct the tab height
6063
+ // TODO: Can we somehow do height without header height or indicate what the header height is?
5742
6064
  this.api._onDidDimensionChange.fire({
5743
6065
  width,
5744
6066
  height: height,
@@ -5860,8 +6182,6 @@ class DockviewPanelModel {
5860
6182
  this.id = id;
5861
6183
  this.contentComponent = contentComponent;
5862
6184
  this.tabComponent = tabComponent;
5863
- this._group = null;
5864
- this._isPanelVisible = null;
5865
6185
  this._content = this.createContentComponent(this.id, contentComponent);
5866
6186
  this._tab = this.createTabComponent(this.id, tabComponent);
5867
6187
  }
@@ -5869,25 +6189,8 @@ class DockviewPanelModel {
5869
6189
  this.content.init(Object.assign(Object.assign({}, params), { tab: this.tab }));
5870
6190
  this.tab.init(params);
5871
6191
  }
5872
- updateParentGroup(group, isPanelVisible) {
5873
- if (group !== this._group) {
5874
- this._group = group;
5875
- if (this._content.onGroupChange) {
5876
- this._content.onGroupChange(group);
5877
- }
5878
- if (this._tab.onGroupChange) {
5879
- this._tab.onGroupChange(group);
5880
- }
5881
- }
5882
- if (isPanelVisible !== this._isPanelVisible) {
5883
- this._isPanelVisible = isPanelVisible;
5884
- if (this._content.onPanelVisibleChange) {
5885
- this._content.onPanelVisibleChange(isPanelVisible);
5886
- }
5887
- if (this._tab.onPanelVisibleChange) {
5888
- this._tab.onPanelVisibleChange(isPanelVisible);
5889
- }
5890
- }
6192
+ updateParentGroup(_group, _isPanelVisible) {
6193
+ // noop
5891
6194
  }
5892
6195
  layout(width, height) {
5893
6196
  var _a, _b;
@@ -6320,117 +6623,6 @@ class DockviewFloatingGroupPanel extends CompositeDisposable {
6320
6623
  }
6321
6624
  }
6322
6625
 
6323
- class PopoutWindow extends CompositeDisposable {
6324
- constructor(id, className, options) {
6325
- super();
6326
- this.id = id;
6327
- this.className = className;
6328
- this.options = options;
6329
- this._onDidClose = new Emitter();
6330
- this.onDidClose = this._onDidClose.event;
6331
- this._window = null;
6332
- this.addDisposables(this._onDidClose, {
6333
- dispose: () => {
6334
- this.close();
6335
- },
6336
- });
6337
- }
6338
- dimensions() {
6339
- if (!this._window) {
6340
- return null;
6341
- }
6342
- const left = this._window.value.screenX;
6343
- const top = this._window.value.screenY;
6344
- const width = this._window.value.innerWidth;
6345
- const height = this._window.value.innerHeight;
6346
- return { top, left, width, height };
6347
- }
6348
- close() {
6349
- if (this._window) {
6350
- this._window.disposable.dispose();
6351
- this._window.value.close();
6352
- this._window = null;
6353
- }
6354
- }
6355
- open(content) {
6356
- if (this._window) {
6357
- throw new Error('instance of popout window is already open');
6358
- }
6359
- const url = `${this.options.url}`;
6360
- const features = Object.entries({
6361
- top: this.options.top,
6362
- left: this.options.left,
6363
- width: this.options.width,
6364
- height: this.options.height,
6365
- })
6366
- .map(([key, value]) => `${key}=${value}`)
6367
- .join(',');
6368
- // https://developer.mozilla.org/en-US/docs/Web/API/Window/open
6369
- const externalWindow = window.open(url, this.id, features);
6370
- if (!externalWindow) {
6371
- return;
6372
- }
6373
- const disposable = new CompositeDisposable();
6374
- this._window = { value: externalWindow, disposable };
6375
- const cleanUp = () => {
6376
- this._onDidClose.fire();
6377
- this._window = null;
6378
- };
6379
- // prevent any default content from loading
6380
- // externalWindow.document.body.replaceWith(document.createElement('div'));
6381
- disposable.addDisposables(addDisposableWindowListener(window, 'beforeunload', () => {
6382
- cleanUp();
6383
- this.close();
6384
- }));
6385
- externalWindow.addEventListener('load', () => {
6386
- const externalDocument = externalWindow.document;
6387
- externalDocument.title = document.title;
6388
- const div = document.createElement('div');
6389
- div.classList.add('dv-popout-window');
6390
- div.style.position = 'absolute';
6391
- div.style.width = '100%';
6392
- div.style.height = '100%';
6393
- div.style.top = '0px';
6394
- div.style.left = '0px';
6395
- div.classList.add(this.className);
6396
- div.appendChild(content);
6397
- externalDocument.body.replaceChildren(div);
6398
- externalDocument.body.classList.add(this.className);
6399
- addStyles(externalDocument, window.document.styleSheets);
6400
- externalWindow.addEventListener('beforeunload', () => {
6401
- // TODO: indicate external window is closing
6402
- cleanUp();
6403
- });
6404
- });
6405
- }
6406
- }
6407
-
6408
- class DockviewPopoutGroupPanel extends CompositeDisposable {
6409
- constructor(id, group, options) {
6410
- var _a;
6411
- super();
6412
- this.id = id;
6413
- this.group = group;
6414
- this.options = options;
6415
- this.window = new PopoutWindow(id, (_a = options.className) !== null && _a !== void 0 ? _a : '', {
6416
- url: this.options.popoutUrl,
6417
- left: this.options.box.left,
6418
- top: this.options.box.top,
6419
- width: this.options.box.width,
6420
- height: this.options.box.height,
6421
- });
6422
- group.model.location = 'popout';
6423
- this.addDisposables(this.window, {
6424
- dispose: () => {
6425
- group.model.location = 'grid';
6426
- },
6427
- }, this.window.onDidClose(() => {
6428
- this.dispose();
6429
- }));
6430
- this.window.open(group.element);
6431
- }
6432
- }
6433
-
6434
6626
  const DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE = 100;
6435
6627
  const DEFAULT_FLOATING_GROUP_POSITION = { left: 100, top: 100 };
6436
6628
 
@@ -6444,11 +6636,13 @@ class OverlayRenderContainer extends CompositeDisposable {
6444
6636
  super();
6445
6637
  this.element = element;
6446
6638
  this.map = {};
6639
+ this._disposed = false;
6447
6640
  this.addDisposables(Disposable.from(() => {
6448
6641
  for (const value of Object.values(this.map)) {
6449
6642
  value.disposable.dispose();
6450
6643
  value.destroy.dispose();
6451
6644
  }
6645
+ this._disposed = true;
6452
6646
  }));
6453
6647
  }
6454
6648
  detatch(panel) {
@@ -6488,7 +6682,7 @@ class OverlayRenderContainer extends CompositeDisposable {
6488
6682
  focusContainer.style.top = `${box.top - box2.top}px`;
6489
6683
  focusContainer.style.width = `${box.width}px`;
6490
6684
  focusContainer.style.height = `${box.height}px`;
6491
- toggleClass(focusContainer, 'dv-render-overlay-float', panel.group.api.location === 'floating');
6685
+ toggleClass(focusContainer, 'dv-render-overlay-float', panel.group.api.location.type === 'floating');
6492
6686
  };
6493
6687
  const visibilityChanged = () => {
6494
6688
  if (panel.api.isVisible) {
@@ -6534,8 +6728,11 @@ class OverlayRenderContainer extends CompositeDisposable {
6534
6728
  resize();
6535
6729
  }));
6536
6730
  this.map[panel.api.id].destroy = Disposable.from(() => {
6537
- focusContainer.removeChild(panel.view.content.element);
6538
- this.element.removeChild(focusContainer);
6731
+ var _a;
6732
+ if (panel.view.content.element.parentElement === focusContainer) {
6733
+ focusContainer.removeChild(panel.view.content.element);
6734
+ }
6735
+ (_a = focusContainer.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(focusContainer);
6539
6736
  });
6540
6737
  queueMicrotask(() => {
6541
6738
  if (this.isDisposed) {
@@ -6556,11 +6753,164 @@ class OverlayRenderContainer extends CompositeDisposable {
6556
6753
  }
6557
6754
  }
6558
6755
 
6756
+ var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
6757
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
6758
+ return new (P || (P = Promise))(function (resolve, reject) {
6759
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6760
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6761
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
6762
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
6763
+ });
6764
+ };
6765
+ class PopoutWindow extends CompositeDisposable {
6766
+ get window() {
6767
+ var _a, _b;
6768
+ return (_b = (_a = this._window) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : null;
6769
+ }
6770
+ constructor(target, className, options) {
6771
+ super();
6772
+ this.target = target;
6773
+ this.className = className;
6774
+ this.options = options;
6775
+ this._onWillClose = new Emitter();
6776
+ this.onWillClose = this._onWillClose.event;
6777
+ this._onDidClose = new Emitter();
6778
+ this.onDidClose = this._onDidClose.event;
6779
+ this._window = null;
6780
+ this.addDisposables(this._onWillClose, this._onDidClose, {
6781
+ dispose: () => {
6782
+ this.close();
6783
+ },
6784
+ });
6785
+ }
6786
+ dimensions() {
6787
+ if (!this._window) {
6788
+ return null;
6789
+ }
6790
+ const left = this._window.value.screenX;
6791
+ const top = this._window.value.screenY;
6792
+ const width = this._window.value.innerWidth;
6793
+ const height = this._window.value.innerHeight;
6794
+ return { top, left, width, height };
6795
+ }
6796
+ close() {
6797
+ var _a, _b;
6798
+ if (this._window) {
6799
+ this._onWillClose.fire();
6800
+ (_b = (_a = this.options).onWillClose) === null || _b === void 0 ? void 0 : _b.call(_a, {
6801
+ id: this.target,
6802
+ window: this._window.value,
6803
+ });
6804
+ this._window.disposable.dispose();
6805
+ this._window.value.close();
6806
+ this._window = null;
6807
+ this._onDidClose.fire();
6808
+ }
6809
+ }
6810
+ open() {
6811
+ var _a, _b;
6812
+ return __awaiter(this, void 0, void 0, function* () {
6813
+ if (this._window) {
6814
+ throw new Error('instance of popout window is already open');
6815
+ }
6816
+ const url = `${this.options.url}`;
6817
+ const features = Object.entries({
6818
+ top: this.options.top,
6819
+ left: this.options.left,
6820
+ width: this.options.width,
6821
+ height: this.options.height,
6822
+ })
6823
+ .map(([key, value]) => `${key}=${value}`)
6824
+ .join(',');
6825
+ /**
6826
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/open
6827
+ */
6828
+ const externalWindow = window.open(url, this.target, features);
6829
+ if (!externalWindow) {
6830
+ /**
6831
+ * Popup blocked
6832
+ */
6833
+ return null;
6834
+ }
6835
+ const disposable = new CompositeDisposable();
6836
+ this._window = { value: externalWindow, disposable };
6837
+ disposable.addDisposables(addDisposableWindowListener(window, 'beforeunload', () => {
6838
+ /**
6839
+ * before the main window closes we should close this popup too
6840
+ * to be good citizens
6841
+ *
6842
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event
6843
+ */
6844
+ this.close();
6845
+ }));
6846
+ const container = this.createPopoutWindowContainer();
6847
+ if (this.className) {
6848
+ container.classList.add(this.className);
6849
+ }
6850
+ (_b = (_a = this.options).onDidOpen) === null || _b === void 0 ? void 0 : _b.call(_a, {
6851
+ id: this.target,
6852
+ window: externalWindow,
6853
+ });
6854
+ return new Promise((resolve) => {
6855
+ externalWindow.addEventListener('unload', (e) => {
6856
+ // if page fails to load before unloading
6857
+ // this.close();
6858
+ });
6859
+ externalWindow.addEventListener('load', () => {
6860
+ /**
6861
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event
6862
+ */
6863
+ const externalDocument = externalWindow.document;
6864
+ externalDocument.title = document.title;
6865
+ externalDocument.body.appendChild(container);
6866
+ addStyles(externalDocument, window.document.styleSheets);
6867
+ /**
6868
+ * beforeunload must be registered after load for reasons I could not determine
6869
+ * otherwise the beforeunload event will not fire when the window is closed
6870
+ */
6871
+ addDisposableWindowListener(externalWindow, 'beforeunload', () => {
6872
+ /**
6873
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event
6874
+ */
6875
+ this.close();
6876
+ });
6877
+ resolve(container);
6878
+ });
6879
+ });
6880
+ });
6881
+ }
6882
+ createPopoutWindowContainer() {
6883
+ const el = document.createElement('div');
6884
+ el.classList.add('dv-popout-window');
6885
+ el.id = 'dv-popout-window';
6886
+ el.style.position = 'absolute';
6887
+ el.style.width = '100%';
6888
+ el.style.height = '100%';
6889
+ el.style.top = '0px';
6890
+ el.style.left = '0px';
6891
+ return el;
6892
+ }
6893
+ }
6894
+
6559
6895
  const DEFAULT_ROOT_OVERLAY_MODEL = {
6560
6896
  activationSize: { type: 'pixels', value: 10 },
6561
6897
  size: { type: 'pixels', value: 20 },
6562
6898
  };
6563
- function getTheme(element) {
6899
+ function moveGroupWithoutDestroying(options) {
6900
+ const activePanel = options.from.activePanel;
6901
+ const panels = [...options.from.panels].map((panel) => {
6902
+ const removedPanel = options.from.model.removePanel(panel);
6903
+ options.from.model.renderContainer.detatch(panel);
6904
+ return removedPanel;
6905
+ });
6906
+ panels.forEach((panel) => {
6907
+ options.to.model.openPanel(panel, {
6908
+ skipSetActive: activePanel !== panel,
6909
+ skipSetGroupActive: true,
6910
+ });
6911
+ });
6912
+ }
6913
+ function getDockviewTheme(element) {
6564
6914
  function toClassList(element) {
6565
6915
  const list = [];
6566
6916
  for (let i = 0; i < element.classList.length; i++) {
@@ -6611,6 +6961,7 @@ class DockviewComponent extends BaseGrid {
6611
6961
  styles: options.styles,
6612
6962
  parentElement: options.parentElement,
6613
6963
  disableAutoResizing: options.disableAutoResizing,
6964
+ locked: options.locked,
6614
6965
  });
6615
6966
  this.nextGroupId = sequentialNumberGenerator();
6616
6967
  this._deserializer = new DefaultDockviewDeserialzier(this);
@@ -6621,6 +6972,10 @@ class DockviewComponent extends BaseGrid {
6621
6972
  this.onWillDragGroup = this._onWillDragGroup.event;
6622
6973
  this._onDidDrop = new Emitter();
6623
6974
  this.onDidDrop = this._onDidDrop.event;
6975
+ this._onWillDrop = new Emitter();
6976
+ this.onWillDrop = this._onWillDrop.event;
6977
+ this._onWillShowOverlay = new Emitter();
6978
+ this.onWillShowOverlay = this._onWillShowOverlay.event;
6624
6979
  this._onDidRemovePanel = new Emitter();
6625
6980
  this.onDidRemovePanel = this._onDidRemovePanel.event;
6626
6981
  this._onDidAddPanel = new Emitter();
@@ -6629,15 +6984,36 @@ class DockviewComponent extends BaseGrid {
6629
6984
  this.onDidLayoutFromJSON = this._onDidLayoutFromJSON.event;
6630
6985
  this._onDidActivePanelChange = new Emitter();
6631
6986
  this.onDidActivePanelChange = this._onDidActivePanelChange.event;
6987
+ this._onDidMovePanel = new Emitter();
6632
6988
  this._floatingGroups = [];
6633
6989
  this._popoutGroups = [];
6990
+ this._ignoreEvents = 0;
6991
+ this._onDidRemoveGroup = new Emitter();
6992
+ this.onDidRemoveGroup = this._onDidRemoveGroup.event;
6993
+ this._onDidAddGroup = new Emitter();
6994
+ this.onDidAddGroup = this._onDidAddGroup.event;
6995
+ this._onDidActiveGroupChange = new Emitter();
6996
+ this.onDidActiveGroupChange = this._onDidActiveGroupChange.event;
6997
+ this._moving = false;
6634
6998
  const gready = document.createElement('div');
6635
6999
  gready.className = 'dv-overlay-render-container';
6636
7000
  this.gridview.element.appendChild(gready);
6637
7001
  this.overlayRenderContainer = new OverlayRenderContainer(gready);
6638
7002
  toggleClass(this.gridview.element, 'dv-dockview', true);
6639
7003
  toggleClass(this.element, 'dv-debug', !!options.debug);
6640
- this.addDisposables(this.overlayRenderContainer, this._onWillDragPanel, this._onWillDragGroup, this._onDidActivePanelChange, this._onDidAddPanel, this._onDidRemovePanel, this._onDidLayoutFromJSON, this._onDidDrop, exports.DockviewEvent.any(this.onDidAddGroup, this.onDidRemoveGroup)(() => {
7004
+ this.addDisposables(this.overlayRenderContainer, this._onWillDragPanel, this._onWillDragGroup, this._onWillShowOverlay, this._onDidActivePanelChange, this._onDidAddPanel, this._onDidRemovePanel, this._onDidLayoutFromJSON, this._onDidDrop, this._onWillDrop, this._onDidMovePanel, this._onDidAddGroup, this._onDidRemoveGroup, this._onDidActiveGroupChange, this.onDidAdd((event) => {
7005
+ if (!this._moving) {
7006
+ this._onDidAddGroup.fire(event);
7007
+ }
7008
+ }), this.onDidRemove((event) => {
7009
+ if (!this._moving) {
7010
+ this._onDidRemoveGroup.fire(event);
7011
+ }
7012
+ }), this.onDidActiveChange((event) => {
7013
+ if (!this._moving) {
7014
+ this._onDidActiveGroupChange.fire(event);
7015
+ }
7016
+ }), exports.DockviewEvent.any(this.onDidAdd, this.onDidRemove)(() => {
6641
7017
  this.updateWatermark();
6642
7018
  }), exports.DockviewEvent.any(this.onDidAddPanel, this.onDidRemovePanel, this.onDidActivePanelChange)(() => {
6643
7019
  this._bufferOnDidLayoutChange.fire();
@@ -6648,7 +7024,7 @@ class DockviewComponent extends BaseGrid {
6648
7024
  }
6649
7025
  // iterate over a copy of the array since .dispose() mutates the original array
6650
7026
  for (const group of [...this._popoutGroups]) {
6651
- group.dispose();
7027
+ group.disposable.dispose();
6652
7028
  }
6653
7029
  }));
6654
7030
  this._options = options;
@@ -6694,7 +7070,7 @@ class DockviewComponent extends BaseGrid {
6694
7070
  return this.options.showDndOverlay({
6695
7071
  nativeEvent: event,
6696
7072
  position: position,
6697
- target: exports.DockviewDropTargets.Edge,
7073
+ target: 'edge',
6698
7074
  getData: getPanelData,
6699
7075
  });
6700
7076
  }
@@ -6705,86 +7081,249 @@ class DockviewComponent extends BaseGrid {
6705
7081
  });
6706
7082
  this.addDisposables(this._rootDropTarget.onDrop((event) => {
6707
7083
  var _a;
7084
+ const willDropEvent = new DockviewWillDropEvent({
7085
+ nativeEvent: event.nativeEvent,
7086
+ position: event.position,
7087
+ panel: undefined,
7088
+ api: this._api,
7089
+ group: undefined,
7090
+ getData: getPanelData,
7091
+ kind: 'content',
7092
+ });
7093
+ this._onWillDrop.fire(willDropEvent);
7094
+ if (willDropEvent.defaultPrevented) {
7095
+ return;
7096
+ }
6708
7097
  const data = getPanelData();
6709
7098
  if (data) {
6710
- this.moveGroupOrPanel(this.orthogonalize(event.position), data.groupId, (_a = data.panelId) !== null && _a !== void 0 ? _a : undefined, 'center');
7099
+ this.moveGroupOrPanel({
7100
+ from: {
7101
+ groupId: data.groupId,
7102
+ panelId: (_a = data.panelId) !== null && _a !== void 0 ? _a : undefined,
7103
+ },
7104
+ to: {
7105
+ group: this.orthogonalize(event.position),
7106
+ position: 'center',
7107
+ },
7108
+ });
6711
7109
  }
6712
7110
  else {
6713
- this._onDidDrop.fire(Object.assign(Object.assign({}, event), { api: this._api, group: null, getData: getPanelData }));
7111
+ this._onDidDrop.fire(new DockviewDidDropEvent({
7112
+ nativeEvent: event.nativeEvent,
7113
+ position: event.position,
7114
+ panel: undefined,
7115
+ api: this._api,
7116
+ group: undefined,
7117
+ getData: getPanelData,
7118
+ }));
6714
7119
  }
6715
7120
  }), this._rootDropTarget);
6716
7121
  this._api = new DockviewApi(this);
6717
7122
  this.updateWatermark();
6718
7123
  }
6719
- addPopoutGroup(item, options) {
6720
- var _a;
6721
- let group;
6722
- let box = options === null || options === void 0 ? void 0 : options.position;
6723
- if (item instanceof DockviewPanel) {
6724
- group = this.createGroup();
6725
- this.removePanel(item, {
6726
- removeEmptyGroup: true,
6727
- skipDispose: true,
6728
- });
6729
- group.model.openPanel(item);
6730
- if (!box) {
6731
- box = this.element.getBoundingClientRect();
7124
+ addPopoutGroup(itemToPopout, options) {
7125
+ var _a, _b, _c;
7126
+ if (itemToPopout instanceof DockviewPanel &&
7127
+ itemToPopout.group.size === 1) {
7128
+ return this.addPopoutGroup(itemToPopout.group);
7129
+ }
7130
+ const theme = getDockviewTheme(this.gridview.element);
7131
+ const element = this.element;
7132
+ function getBox() {
7133
+ if (options === null || options === void 0 ? void 0 : options.position) {
7134
+ return options.position;
7135
+ }
7136
+ if (itemToPopout instanceof DockviewGroupPanel) {
7137
+ return itemToPopout.element.getBoundingClientRect();
7138
+ }
7139
+ if (itemToPopout.group) {
7140
+ return itemToPopout.group.element.getBoundingClientRect();
7141
+ }
7142
+ return element.getBoundingClientRect();
7143
+ }
7144
+ const box = getBox();
7145
+ const groupId = (_b = (_a = options === null || options === void 0 ? void 0 : options.overridePopoutGroup) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : this.getNextGroupId(); //item.id;
7146
+ if (itemToPopout.api.location.type === 'grid') {
7147
+ itemToPopout.api.setHidden(true);
7148
+ }
7149
+ const _window = new PopoutWindow(`${this.id}-${groupId}`, // unique id
7150
+ theme !== null && theme !== void 0 ? theme : '', {
7151
+ url: (_c = options === null || options === void 0 ? void 0 : options.popoutUrl) !== null && _c !== void 0 ? _c : '/popout.html',
7152
+ left: window.screenX + box.left,
7153
+ top: window.screenY + box.top,
7154
+ width: box.width,
7155
+ height: box.height,
7156
+ onDidOpen: options === null || options === void 0 ? void 0 : options.onDidOpen,
7157
+ onWillClose: options === null || options === void 0 ? void 0 : options.onWillClose,
7158
+ });
7159
+ const popoutWindowDisposable = new CompositeDisposable(_window, _window.onDidClose(() => {
7160
+ popoutWindowDisposable.dispose();
7161
+ }));
7162
+ return _window
7163
+ .open()
7164
+ .then((popoutContainer) => {
7165
+ var _a;
7166
+ if (_window.isDisposed) {
7167
+ return;
6732
7168
  }
6733
- }
6734
- else {
6735
- group = item;
6736
- if (!box) {
6737
- box = group.element.getBoundingClientRect();
7169
+ if (popoutContainer === null) {
7170
+ popoutWindowDisposable.dispose();
7171
+ return;
6738
7172
  }
6739
- const skip = typeof (options === null || options === void 0 ? void 0 : options.skipRemoveGroup) === 'boolean' &&
6740
- options.skipRemoveGroup;
6741
- if (!skip) {
6742
- this.doRemoveGroup(item, { skipDispose: true });
6743
- }
6744
- }
6745
- const theme = getTheme(this.gridview.element);
6746
- const popoutWindow = new DockviewPopoutGroupPanel(`${this.id}-${group.id}`, // globally unique within dockview
6747
- group, {
6748
- className: theme !== null && theme !== void 0 ? theme : '',
6749
- popoutUrl: (_a = options === null || options === void 0 ? void 0 : options.popoutUrl) !== null && _a !== void 0 ? _a : '/popout.html',
6750
- box: {
6751
- left: window.screenX + box.left,
6752
- top: window.screenY + box.top,
6753
- width: box.width,
6754
- height: box.height,
6755
- },
7173
+ const gready = document.createElement('div');
7174
+ gready.className = 'dv-overlay-render-container';
7175
+ const overlayRenderContainer = new OverlayRenderContainer(gready);
7176
+ const referenceGroup = itemToPopout instanceof DockviewPanel
7177
+ ? itemToPopout.group
7178
+ : itemToPopout;
7179
+ const referenceLocation = itemToPopout.api.location.type;
7180
+ const group = (_a = options === null || options === void 0 ? void 0 : options.overridePopoutGroup) !== null && _a !== void 0 ? _a : this.createGroup({ id: groupId });
7181
+ group.model.renderContainer = overlayRenderContainer;
7182
+ if (!(options === null || options === void 0 ? void 0 : options.overridePopoutGroup)) {
7183
+ this._onDidAddGroup.fire(group);
7184
+ }
7185
+ if (itemToPopout instanceof DockviewPanel) {
7186
+ this.movingLock(() => {
7187
+ const panel = referenceGroup.model.removePanel(itemToPopout);
7188
+ group.model.openPanel(panel);
7189
+ });
7190
+ }
7191
+ else {
7192
+ this.movingLock(() => moveGroupWithoutDestroying({
7193
+ from: referenceGroup,
7194
+ to: group,
7195
+ }));
7196
+ switch (referenceLocation) {
7197
+ case 'grid':
7198
+ referenceGroup.api.setHidden(true);
7199
+ break;
7200
+ case 'floating':
7201
+ case 'popout':
7202
+ this.removeGroup(referenceGroup);
7203
+ break;
7204
+ }
7205
+ }
7206
+ popoutContainer.classList.add('dv-dockview');
7207
+ popoutContainer.style.overflow = 'hidden';
7208
+ popoutContainer.appendChild(gready);
7209
+ popoutContainer.appendChild(group.element);
7210
+ group.model.location = {
7211
+ type: 'popout',
7212
+ getWindow: () => _window.window,
7213
+ };
7214
+ this.doSetGroupAndPanelActive(group);
7215
+ popoutWindowDisposable.addDisposables(group.api.onDidActiveChange((event) => {
7216
+ var _a;
7217
+ if (event.isActive) {
7218
+ (_a = _window.window) === null || _a === void 0 ? void 0 : _a.focus();
7219
+ }
7220
+ }), group.api.onWillFocus(() => {
7221
+ var _a;
7222
+ (_a = _window.window) === null || _a === void 0 ? void 0 : _a.focus();
7223
+ }));
7224
+ let returnedGroup;
7225
+ const value = {
7226
+ window: _window,
7227
+ popoutGroup: group,
7228
+ referenceGroup: this.getPanel(referenceGroup.id)
7229
+ ? referenceGroup.id
7230
+ : undefined,
7231
+ disposable: {
7232
+ dispose: () => {
7233
+ popoutWindowDisposable.dispose();
7234
+ return returnedGroup;
7235
+ },
7236
+ },
7237
+ };
7238
+ popoutWindowDisposable.addDisposables(
7239
+ /**
7240
+ * ResizeObserver seems slow here, I do not know why but we don't need it
7241
+ * since we can reply on the window resize event as we will occupy the full
7242
+ * window dimensions
7243
+ */
7244
+ addDisposableWindowListener(_window.window, 'resize', () => {
7245
+ group.layout(window.innerWidth, window.innerHeight);
7246
+ }), overlayRenderContainer, Disposable.from(() => {
7247
+ if (this.getPanel(referenceGroup.id)) {
7248
+ this.movingLock(() => moveGroupWithoutDestroying({
7249
+ from: group,
7250
+ to: referenceGroup,
7251
+ }));
7252
+ if (referenceGroup.api.isHidden) {
7253
+ referenceGroup.api.setHidden(false);
7254
+ }
7255
+ if (this.getPanel(group.id)) {
7256
+ this.doRemoveGroup(group, {
7257
+ skipPopoutAssociated: true,
7258
+ });
7259
+ }
7260
+ }
7261
+ else {
7262
+ if (this.getPanel(group.id)) {
7263
+ const removedGroup = this.doRemoveGroup(group, {
7264
+ skipDispose: true,
7265
+ skipActive: true,
7266
+ });
7267
+ removedGroup.model.renderContainer =
7268
+ this.overlayRenderContainer;
7269
+ removedGroup.model.location = { type: 'grid' };
7270
+ returnedGroup = removedGroup;
7271
+ }
7272
+ }
7273
+ }));
7274
+ this._popoutGroups.push(value);
7275
+ this.updateWatermark();
7276
+ })
7277
+ .catch((err) => {
7278
+ console.error(err);
6756
7279
  });
6757
- popoutWindow.addDisposables({
6758
- dispose: () => {
6759
- remove(this._popoutGroups, popoutWindow);
6760
- this.updateWatermark();
6761
- },
6762
- }, popoutWindow.window.onDidClose(() => {
6763
- this.doAddGroup(group, [0]);
6764
- }));
6765
- this._popoutGroups.push(popoutWindow);
6766
- this.updateWatermark();
6767
7280
  }
6768
7281
  addFloatingGroup(item, coord, options) {
6769
- var _a, _b, _c, _d, _e, _f;
7282
+ var _a, _b, _c, _d, _e, _f, _g;
6770
7283
  let group;
6771
7284
  if (item instanceof DockviewPanel) {
6772
7285
  group = this.createGroup();
6773
- this.removePanel(item, {
7286
+ this._onDidAddGroup.fire(group);
7287
+ this.movingLock(() => this.removePanel(item, {
6774
7288
  removeEmptyGroup: true,
6775
7289
  skipDispose: true,
6776
- });
6777
- group.model.openPanel(item);
7290
+ skipSetActiveGroup: true,
7291
+ }));
7292
+ group.model.openPanel(item, { skipSetGroupActive: true });
6778
7293
  }
6779
7294
  else {
6780
7295
  group = item;
7296
+ const popoutReferenceGroupId = (_a = this._popoutGroups.find((_) => _.popoutGroup === group)) === null || _a === void 0 ? void 0 : _a.referenceGroup;
7297
+ const popoutReferenceGroup = popoutReferenceGroupId
7298
+ ? this.getPanel(popoutReferenceGroupId)
7299
+ : undefined;
6781
7300
  const skip = typeof (options === null || options === void 0 ? void 0 : options.skipRemoveGroup) === 'boolean' &&
6782
7301
  options.skipRemoveGroup;
6783
7302
  if (!skip) {
6784
- this.doRemoveGroup(item, { skipDispose: true });
7303
+ if (popoutReferenceGroup) {
7304
+ this.movingLock(() => moveGroupWithoutDestroying({
7305
+ from: item,
7306
+ to: popoutReferenceGroup,
7307
+ }));
7308
+ this.doRemoveGroup(item, {
7309
+ skipPopoutReturn: true,
7310
+ skipPopoutAssociated: true,
7311
+ });
7312
+ this.doRemoveGroup(popoutReferenceGroup, {
7313
+ skipDispose: true,
7314
+ });
7315
+ group = popoutReferenceGroup;
7316
+ }
7317
+ else {
7318
+ this.doRemoveGroup(item, {
7319
+ skipDispose: true,
7320
+ skipPopoutReturn: true,
7321
+ skipPopoutAssociated: !!popoutReferenceGroup,
7322
+ });
7323
+ }
6785
7324
  }
6786
7325
  }
6787
- group.model.location = 'floating';
7326
+ group.model.location = { type: 'floating' };
6788
7327
  const overlayLeft = typeof (coord === null || coord === void 0 ? void 0 : coord.x) === 'number'
6789
7328
  ? Math.max(coord.x, 0)
6790
7329
  : DEFAULT_FLOATING_GROUP_POSITION.left;
@@ -6794,16 +7333,16 @@ class DockviewComponent extends BaseGrid {
6794
7333
  const overlay = new Overlay({
6795
7334
  container: this.gridview.element,
6796
7335
  content: group.element,
6797
- height: (_a = coord === null || coord === void 0 ? void 0 : coord.height) !== null && _a !== void 0 ? _a : 300,
6798
- width: (_b = coord === null || coord === void 0 ? void 0 : coord.width) !== null && _b !== void 0 ? _b : 300,
7336
+ height: (_b = coord === null || coord === void 0 ? void 0 : coord.height) !== null && _b !== void 0 ? _b : 300,
7337
+ width: (_c = coord === null || coord === void 0 ? void 0 : coord.width) !== null && _c !== void 0 ? _c : 300,
6799
7338
  left: overlayLeft,
6800
7339
  top: overlayTop,
6801
7340
  minimumInViewportWidth: this.options.floatingGroupBounds === 'boundedWithinViewport'
6802
7341
  ? undefined
6803
- : (_d = (_c = this.options.floatingGroupBounds) === null || _c === void 0 ? void 0 : _c.minimumWidthWithinViewport) !== null && _d !== void 0 ? _d : DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE,
7342
+ : (_e = (_d = this.options.floatingGroupBounds) === null || _d === void 0 ? void 0 : _d.minimumWidthWithinViewport) !== null && _e !== void 0 ? _e : DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE,
6804
7343
  minimumInViewportHeight: this.options.floatingGroupBounds === 'boundedWithinViewport'
6805
7344
  ? undefined
6806
- : (_f = (_e = this.options.floatingGroupBounds) === null || _e === void 0 ? void 0 : _e.minimumHeightWithinViewport) !== null && _f !== void 0 ? _f : DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE,
7345
+ : (_g = (_f = this.options.floatingGroupBounds) === null || _f === void 0 ? void 0 : _f.minimumHeightWithinViewport) !== null && _g !== void 0 ? _g : DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE,
6807
7346
  });
6808
7347
  const el = group.element.querySelector('.void-container');
6809
7348
  if (!el) {
@@ -6834,12 +7373,15 @@ class DockviewComponent extends BaseGrid {
6834
7373
  }), {
6835
7374
  dispose: () => {
6836
7375
  disposable.dispose();
6837
- group.model.location = 'grid';
7376
+ group.model.location = { type: 'grid' };
6838
7377
  remove(this._floatingGroups, floatingGroupPanel);
6839
7378
  this.updateWatermark();
6840
7379
  },
6841
7380
  });
6842
7381
  this._floatingGroups.push(floatingGroupPanel);
7382
+ if (!(options === null || options === void 0 ? void 0 : options.skipActiveGroup)) {
7383
+ this.doSetGroupAndPanelActive(group);
7384
+ }
6843
7385
  this.updateWatermark();
6844
7386
  }
6845
7387
  orthogonalize(position) {
@@ -6929,8 +7471,8 @@ class DockviewComponent extends BaseGrid {
6929
7471
  return this.panels.find((panel) => panel.id === id);
6930
7472
  }
6931
7473
  setActivePanel(panel) {
6932
- this.doSetGroupActive(panel.group);
6933
7474
  panel.group.model.openPanel(panel);
7475
+ this.doSetGroupAndPanelActive(panel.group);
6934
7476
  }
6935
7477
  moveToNext(options = {}) {
6936
7478
  var _a;
@@ -6991,7 +7533,8 @@ class DockviewComponent extends BaseGrid {
6991
7533
  });
6992
7534
  const popoutGroups = this._popoutGroups.map((group) => {
6993
7535
  return {
6994
- data: group.group.toJSON(),
7536
+ data: group.popoutGroup.toJSON(),
7537
+ gridReferenceGroup: group.referenceGroup,
6995
7538
  position: group.window.dimensions(),
6996
7539
  };
6997
7540
  });
@@ -7009,7 +7552,7 @@ class DockviewComponent extends BaseGrid {
7009
7552
  return result;
7010
7553
  }
7011
7554
  fromJSON(data) {
7012
- var _a, _b;
7555
+ var _a, _b, _c;
7013
7556
  this.clear();
7014
7557
  if (typeof data !== 'object' || data === null) {
7015
7558
  throw new Error('serialized layout must be a non-null object');
@@ -7048,7 +7591,7 @@ class DockviewComponent extends BaseGrid {
7048
7591
  const isActive = typeof activeView === 'string' &&
7049
7592
  activeView === panel.id;
7050
7593
  group.model.openPanel(panel, {
7051
- skipSetPanelActive: !isActive,
7594
+ skipSetActive: !isActive,
7052
7595
  skipSetGroupActive: true,
7053
7596
  });
7054
7597
  }
@@ -7078,11 +7621,16 @@ class DockviewComponent extends BaseGrid {
7078
7621
  }
7079
7622
  const serializedPopoutGroups = (_b = data.popoutGroups) !== null && _b !== void 0 ? _b : [];
7080
7623
  for (const serializedPopoutGroup of serializedPopoutGroups) {
7081
- const { data, position } = serializedPopoutGroup;
7624
+ const { data, position, gridReferenceGroup } = serializedPopoutGroup;
7082
7625
  const group = createGroupFromSerializedState(data);
7083
- this.addPopoutGroup(group, {
7626
+ this.addPopoutGroup((_c = (gridReferenceGroup
7627
+ ? this.getPanel(gridReferenceGroup)
7628
+ : undefined)) !== null && _c !== void 0 ? _c : group, {
7084
7629
  skipRemoveGroup: true,
7085
7630
  position: position !== null && position !== void 0 ? position : undefined,
7631
+ overridePopoutGroup: gridReferenceGroup
7632
+ ? group
7633
+ : undefined,
7086
7634
  });
7087
7635
  }
7088
7636
  for (const floatingGroup of this._floatingGroups) {
@@ -7129,12 +7677,13 @@ class DockviewComponent extends BaseGrid {
7129
7677
  */
7130
7678
  throw err;
7131
7679
  }
7680
+ this.updateWatermark();
7132
7681
  this._onDidLayoutFromJSON.fire();
7133
7682
  }
7134
7683
  clear() {
7135
7684
  const groups = Array.from(this._groups.values()).map((_) => _.value);
7136
7685
  const hasActiveGroup = !!this.activeGroup;
7137
- const hasActivePanel = !!this.activePanel;
7686
+ !!this.activePanel;
7138
7687
  for (const group of groups) {
7139
7688
  // remove the group will automatically remove the panels
7140
7689
  this.removeGroup(group, { skipActive: true });
@@ -7142,9 +7691,6 @@ class DockviewComponent extends BaseGrid {
7142
7691
  if (hasActiveGroup) {
7143
7692
  this.doSetGroupAndPanelActive(undefined);
7144
7693
  }
7145
- if (hasActivePanel) {
7146
- this._onDidActivePanelChange.fire(undefined);
7147
- }
7148
7694
  this.gridview.clear();
7149
7695
  }
7150
7696
  closeAllGroups() {
@@ -7185,6 +7731,7 @@ class DockviewComponent extends BaseGrid {
7185
7731
  const group = this.orthogonalize(directionToPosition(options.position.direction));
7186
7732
  const panel = this.createPanel(options, group);
7187
7733
  group.model.openPanel(panel);
7734
+ this.doSetGroupAndPanelActive(group);
7188
7735
  return panel;
7189
7736
  }
7190
7737
  }
@@ -7196,6 +7743,7 @@ class DockviewComponent extends BaseGrid {
7196
7743
  const target = toTarget(((_b = options.position) === null || _b === void 0 ? void 0 : _b.direction) || 'within');
7197
7744
  if (options.floating) {
7198
7745
  const group = this.createGroup();
7746
+ this._onDidAddGroup.fire(group);
7199
7747
  const o = typeof options.floating === 'object' &&
7200
7748
  options.floating !== null
7201
7749
  ? options.floating
@@ -7203,16 +7751,16 @@ class DockviewComponent extends BaseGrid {
7203
7751
  this.addFloatingGroup(group, o, {
7204
7752
  inDragMode: false,
7205
7753
  skipRemoveGroup: true,
7754
+ skipActiveGroup: true,
7206
7755
  });
7207
- this._onDidAddGroup.fire(group);
7208
7756
  panel = this.createPanel(options, group);
7209
7757
  group.model.openPanel(panel);
7210
- this.doSetGroupAndPanelActive(group);
7211
7758
  }
7212
- else if (referenceGroup.api.location === 'floating' ||
7759
+ else if (referenceGroup.api.location.type === 'floating' ||
7213
7760
  target === 'center') {
7214
7761
  panel = this.createPanel(options, referenceGroup);
7215
7762
  referenceGroup.model.openPanel(panel);
7763
+ this.doSetGroupAndPanelActive(referenceGroup);
7216
7764
  }
7217
7765
  else {
7218
7766
  const location = getGridLocation(referenceGroup.element);
@@ -7220,10 +7768,12 @@ class DockviewComponent extends BaseGrid {
7220
7768
  const group = this.createGroupAtLocation(relativeLocation);
7221
7769
  panel = this.createPanel(options, group);
7222
7770
  group.model.openPanel(panel);
7771
+ this.doSetGroupAndPanelActive(group);
7223
7772
  }
7224
7773
  }
7225
7774
  else if (options.floating) {
7226
7775
  const group = this.createGroup();
7776
+ this._onDidAddGroup.fire(group);
7227
7777
  const o = typeof options.floating === 'object' &&
7228
7778
  options.floating !== null
7229
7779
  ? options.floating
@@ -7231,16 +7781,16 @@ class DockviewComponent extends BaseGrid {
7231
7781
  this.addFloatingGroup(group, o, {
7232
7782
  inDragMode: false,
7233
7783
  skipRemoveGroup: true,
7784
+ skipActiveGroup: true,
7234
7785
  });
7235
- this._onDidAddGroup.fire(group);
7236
7786
  panel = this.createPanel(options, group);
7237
7787
  group.model.openPanel(panel);
7238
- this.doSetGroupAndPanelActive(group);
7239
7788
  }
7240
7789
  else {
7241
7790
  const group = this.createGroupAtLocation();
7242
7791
  panel = this.createPanel(options, group);
7243
7792
  group.model.openPanel(panel);
7793
+ this.doSetGroupAndPanelActive(group);
7244
7794
  }
7245
7795
  return panel;
7246
7796
  }
@@ -7252,13 +7802,15 @@ class DockviewComponent extends BaseGrid {
7252
7802
  if (!group) {
7253
7803
  throw new Error(`cannot remove panel ${panel.id}. it's missing a group.`);
7254
7804
  }
7255
- group.model.removePanel(panel);
7805
+ group.model.removePanel(panel, {
7806
+ skipSetActiveGroup: options.skipSetActiveGroup,
7807
+ });
7256
7808
  if (!options.skipDispose) {
7257
- this.overlayRenderContainer.detatch(panel);
7809
+ panel.group.model.renderContainer.detatch(panel);
7258
7810
  panel.dispose();
7259
7811
  }
7260
7812
  if (group.size === 0 && options.removeEmptyGroup) {
7261
- this.removeGroup(group);
7813
+ this.removeGroup(group, { skipActive: options.skipSetActiveGroup });
7262
7814
  }
7263
7815
  }
7264
7816
  createWatermarkComponent() {
@@ -7271,7 +7823,7 @@ class DockviewComponent extends BaseGrid {
7271
7823
  }
7272
7824
  updateWatermark() {
7273
7825
  var _a, _b;
7274
- if (this.groups.filter((x) => x.api.location === 'grid').length === 0) {
7826
+ if (this.groups.filter((x) => x.api.location.type === 'grid' && !x.api.isHidden).length === 0) {
7275
7827
  if (!this.watermark) {
7276
7828
  this.watermark = this.createWatermarkComponent();
7277
7829
  this.watermark.init({
@@ -7317,36 +7869,42 @@ class DockviewComponent extends BaseGrid {
7317
7869
  }
7318
7870
  else {
7319
7871
  const group = this.orthogonalize(directionToPosition(options.direction));
7872
+ if (!options.skipSetActive) {
7873
+ this.doSetGroupAndPanelActive(group);
7874
+ }
7320
7875
  return group;
7321
7876
  }
7322
7877
  const target = toTarget(options.direction || 'within');
7323
7878
  const location = getGridLocation(referenceGroup.element);
7324
7879
  const relativeLocation = getRelativeLocation(this.gridview.orientation, location, target);
7325
7880
  this.doAddGroup(group, relativeLocation);
7881
+ if (!options.skipSetActive) {
7882
+ this.doSetGroupAndPanelActive(group);
7883
+ }
7326
7884
  return group;
7327
7885
  }
7328
7886
  else {
7329
7887
  this.doAddGroup(group);
7888
+ this.doSetGroupAndPanelActive(group);
7330
7889
  return group;
7331
7890
  }
7332
7891
  }
7333
7892
  removeGroup(group, options) {
7893
+ this.doRemoveGroup(group, options);
7894
+ }
7895
+ doRemoveGroup(group, options) {
7334
7896
  var _a;
7335
7897
  const panels = [...group.panels]; // reassign since group panels will mutate
7336
- for (const panel of panels) {
7337
- this.removePanel(panel, {
7338
- removeEmptyGroup: false,
7339
- skipDispose: (_a = options === null || options === void 0 ? void 0 : options.skipDispose) !== null && _a !== void 0 ? _a : false,
7340
- });
7898
+ if (!(options === null || options === void 0 ? void 0 : options.skipDispose)) {
7899
+ for (const panel of panels) {
7900
+ this.removePanel(panel, {
7901
+ removeEmptyGroup: false,
7902
+ skipDispose: (_a = options === null || options === void 0 ? void 0 : options.skipDispose) !== null && _a !== void 0 ? _a : false,
7903
+ });
7904
+ }
7341
7905
  }
7342
7906
  const activePanel = this.activePanel;
7343
- this.doRemoveGroup(group, options);
7344
- if (this.activePanel !== activePanel) {
7345
- this._onDidActivePanelChange.fire(this.activePanel);
7346
- }
7347
- }
7348
- doRemoveGroup(group, options) {
7349
- if (group.api.location === 'floating') {
7907
+ if (group.api.location.type === 'floating') {
7350
7908
  const floatingGroup = this._floatingGroups.find((_) => _.group === group);
7351
7909
  if (floatingGroup) {
7352
7910
  if (!(options === null || options === void 0 ? void 0 : options.skipDispose)) {
@@ -7358,60 +7916,124 @@ class DockviewComponent extends BaseGrid {
7358
7916
  floatingGroup.dispose();
7359
7917
  if (!(options === null || options === void 0 ? void 0 : options.skipActive) && this._activeGroup === group) {
7360
7918
  const groups = Array.from(this._groups.values());
7361
- this.doSetGroupActive(groups.length > 0 ? groups[0].value : undefined);
7919
+ this.doSetGroupAndPanelActive(groups.length > 0 ? groups[0].value : undefined);
7362
7920
  }
7363
7921
  return floatingGroup.group;
7364
7922
  }
7365
7923
  throw new Error('failed to find floating group');
7366
7924
  }
7367
- if (group.api.location === 'popout') {
7368
- const selectedGroup = this._popoutGroups.find((_) => _.group === group);
7925
+ if (group.api.location.type === 'popout') {
7926
+ const selectedGroup = this._popoutGroups.find((_) => _.popoutGroup === group);
7369
7927
  if (selectedGroup) {
7370
7928
  if (!(options === null || options === void 0 ? void 0 : options.skipDispose)) {
7371
- selectedGroup.group.dispose();
7929
+ if (!(options === null || options === void 0 ? void 0 : options.skipPopoutAssociated)) {
7930
+ const refGroup = selectedGroup.referenceGroup
7931
+ ? this.getPanel(selectedGroup.referenceGroup)
7932
+ : undefined;
7933
+ if (refGroup) {
7934
+ this.removeGroup(refGroup);
7935
+ }
7936
+ }
7937
+ selectedGroup.popoutGroup.dispose();
7372
7938
  this._groups.delete(group.id);
7373
7939
  this._onDidRemoveGroup.fire(group);
7374
7940
  }
7375
- selectedGroup.dispose();
7941
+ const removedGroup = selectedGroup.disposable.dispose();
7942
+ if (!(options === null || options === void 0 ? void 0 : options.skipPopoutReturn) && removedGroup) {
7943
+ this.doAddGroup(removedGroup, [0]);
7944
+ this.doSetGroupAndPanelActive(removedGroup);
7945
+ }
7376
7946
  if (!(options === null || options === void 0 ? void 0 : options.skipActive) && this._activeGroup === group) {
7377
7947
  const groups = Array.from(this._groups.values());
7378
- this.doSetGroupActive(groups.length > 0 ? groups[0].value : undefined);
7948
+ this.doSetGroupAndPanelActive(groups.length > 0 ? groups[0].value : undefined);
7379
7949
  }
7380
- return selectedGroup.group;
7950
+ this.updateWatermark();
7951
+ return selectedGroup.popoutGroup;
7381
7952
  }
7382
7953
  throw new Error('failed to find popout group');
7383
7954
  }
7384
- return super.doRemoveGroup(group, options);
7955
+ const re = super.doRemoveGroup(group, options);
7956
+ if (!(options === null || options === void 0 ? void 0 : options.skipActive)) {
7957
+ if (this.activePanel !== activePanel) {
7958
+ this._onDidActivePanelChange.fire(this.activePanel);
7959
+ }
7960
+ }
7961
+ return re;
7385
7962
  }
7386
- moveGroupOrPanel(destinationGroup, sourceGroupId, sourceItemId, destinationTarget, destinationIndex) {
7387
- var _a, _b, _c;
7963
+ movingLock(func) {
7964
+ const isMoving = this._moving;
7965
+ try {
7966
+ this._moving = true;
7967
+ return func();
7968
+ }
7969
+ finally {
7970
+ this._moving = isMoving;
7971
+ }
7972
+ }
7973
+ moveGroupOrPanel(options) {
7974
+ var _a;
7975
+ const destinationGroup = options.to.group;
7976
+ const sourceGroupId = options.from.groupId;
7977
+ const sourceItemId = options.from.panelId;
7978
+ const destinationTarget = options.to.position;
7979
+ const destinationIndex = options.to.index;
7388
7980
  const sourceGroup = sourceGroupId
7389
7981
  ? (_a = this._groups.get(sourceGroupId)) === null || _a === void 0 ? void 0 : _a.value
7390
7982
  : undefined;
7983
+ if (!sourceGroup) {
7984
+ throw new Error(`Failed to find group id ${sourceGroupId}`);
7985
+ }
7391
7986
  if (sourceItemId === undefined) {
7392
- if (sourceGroup) {
7393
- this.moveGroup(sourceGroup, destinationGroup, destinationTarget);
7394
- }
7987
+ /**
7988
+ * Moving an entire group into another group
7989
+ */
7990
+ this.moveGroup({
7991
+ from: { group: sourceGroup },
7992
+ to: {
7993
+ group: destinationGroup,
7994
+ position: destinationTarget,
7995
+ },
7996
+ });
7395
7997
  return;
7396
7998
  }
7397
7999
  if (!destinationTarget || destinationTarget === 'center') {
7398
- const groupItem = (_b = sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(sourceItemId)) !== null && _b !== void 0 ? _b : this.panels.find((panel) => panel.id === sourceItemId);
7399
- if (!groupItem) {
8000
+ /**
8001
+ * Dropping a panel within another group
8002
+ */
8003
+ const removedPanel = this.movingLock(() => sourceGroup.model.removePanel(sourceItemId, {
8004
+ skipSetActive: false,
8005
+ skipSetActiveGroup: true,
8006
+ }));
8007
+ if (!removedPanel) {
7400
8008
  throw new Error(`No panel with id ${sourceItemId}`);
7401
8009
  }
7402
- if ((sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.size) === 0) {
7403
- this.doRemoveGroup(sourceGroup);
8010
+ if (sourceGroup.model.size === 0) {
8011
+ // remove the group and do not set a new group as active
8012
+ this.doRemoveGroup(sourceGroup, { skipActive: true });
7404
8013
  }
7405
- destinationGroup.model.openPanel(groupItem, {
8014
+ this.movingLock(() => destinationGroup.model.openPanel(removedPanel, {
7406
8015
  index: destinationIndex,
8016
+ skipSetGroupActive: true,
8017
+ }));
8018
+ this.doSetGroupAndPanelActive(destinationGroup);
8019
+ this._onDidMovePanel.fire({
8020
+ panel: removedPanel,
7407
8021
  });
7408
8022
  }
7409
8023
  else {
8024
+ /**
8025
+ * Dropping a panel to the extremities of a group which will place that panel
8026
+ * into an adjacent group
8027
+ */
7410
8028
  const referenceLocation = getGridLocation(destinationGroup.element);
7411
8029
  const targetLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, destinationTarget);
7412
- if (sourceGroup && sourceGroup.size < 2) {
8030
+ if (sourceGroup.size < 2) {
8031
+ /**
8032
+ * If we are moving from a group which only has one panel left we will consider
8033
+ * moving the group itself rather than moving the panel into a newly created group
8034
+ */
7413
8035
  const [targetParentLocation, to] = tail(targetLocation);
7414
- if (sourceGroup.api.location === 'grid') {
8036
+ if (sourceGroup.api.location.type === 'grid') {
7415
8037
  const sourceLocation = getGridLocation(sourceGroup.element);
7416
8038
  const [sourceParentLocation, from] = tail(sourceLocation);
7417
8039
  if (sequenceEquals(sourceParentLocation, targetParentLocation)) {
@@ -7419,78 +8041,123 @@ class DockviewComponent extends BaseGrid {
7419
8041
  // if a group has one tab - we are essentially moving the 'group'
7420
8042
  // which is equivalent to swapping two views in this case
7421
8043
  this.gridview.moveView(sourceParentLocation, from, to);
8044
+ return;
7422
8045
  }
7423
8046
  }
7424
8047
  // source group will become empty so delete the group
7425
- const targetGroup = this.doRemoveGroup(sourceGroup, {
8048
+ const targetGroup = this.movingLock(() => this.doRemoveGroup(sourceGroup, {
7426
8049
  skipActive: true,
7427
8050
  skipDispose: true,
7428
- });
8051
+ }));
7429
8052
  // after deleting the group we need to re-evaulate the ref location
7430
8053
  const updatedReferenceLocation = getGridLocation(destinationGroup.element);
7431
8054
  const location = getRelativeLocation(this.gridview.orientation, updatedReferenceLocation, destinationTarget);
7432
- this.doAddGroup(targetGroup, location);
8055
+ this.movingLock(() => this.doAddGroup(targetGroup, location));
8056
+ this.doSetGroupAndPanelActive(targetGroup);
7433
8057
  }
7434
8058
  else {
7435
- const groupItem = (_c = sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.removePanel(sourceItemId)) !== null && _c !== void 0 ? _c : this.panels.find((panel) => panel.id === sourceItemId);
7436
- if (!groupItem) {
8059
+ /**
8060
+ * The group we are removing from has many panels, we need to remove the panels we are moving,
8061
+ * create a new group, add the panels to that new group and add the new group in an appropiate position
8062
+ */
8063
+ const removedPanel = this.movingLock(() => sourceGroup.model.removePanel(sourceItemId, {
8064
+ skipSetActive: false,
8065
+ skipSetActiveGroup: true,
8066
+ }));
8067
+ if (!removedPanel) {
7437
8068
  throw new Error(`No panel with id ${sourceItemId}`);
7438
8069
  }
7439
8070
  const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, destinationTarget);
7440
8071
  const group = this.createGroupAtLocation(dropLocation);
7441
- group.model.openPanel(groupItem);
8072
+ this.movingLock(() => group.model.openPanel(removedPanel, {
8073
+ skipSetGroupActive: true,
8074
+ }));
8075
+ this.doSetGroupAndPanelActive(group);
7442
8076
  }
7443
8077
  }
7444
8078
  }
7445
- moveGroup(sourceGroup, referenceGroup, target) {
7446
- if (sourceGroup) {
7447
- if (!target || target === 'center') {
7448
- const activePanel = sourceGroup.activePanel;
7449
- const panels = [...sourceGroup.panels].map((p) => sourceGroup.model.removePanel(p.id));
7450
- if ((sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.size) === 0) {
7451
- this.doRemoveGroup(sourceGroup);
7452
- }
8079
+ moveGroup(options) {
8080
+ const from = options.from.group;
8081
+ const to = options.to.group;
8082
+ const target = options.to.position;
8083
+ if (target === 'center') {
8084
+ const activePanel = from.activePanel;
8085
+ const panels = this.movingLock(() => [...from.panels].map((p) => from.model.removePanel(p.id, {
8086
+ skipSetActive: true,
8087
+ })));
8088
+ if ((from === null || from === void 0 ? void 0 : from.model.size) === 0) {
8089
+ this.doRemoveGroup(from, { skipActive: true });
8090
+ }
8091
+ this.movingLock(() => {
7453
8092
  for (const panel of panels) {
7454
- referenceGroup.model.openPanel(panel, {
7455
- skipSetPanelActive: panel !== activePanel,
8093
+ to.model.openPanel(panel, {
8094
+ skipSetActive: panel !== activePanel,
8095
+ skipSetGroupActive: true,
7456
8096
  });
7457
8097
  }
7458
- }
7459
- else {
7460
- switch (sourceGroup.api.location) {
7461
- case 'grid':
7462
- this.gridview.removeView(getGridLocation(sourceGroup.element));
7463
- break;
7464
- case 'floating': {
7465
- const selectedFloatingGroup = this._floatingGroups.find((x) => x.group === sourceGroup);
7466
- if (!selectedFloatingGroup) {
7467
- throw new Error('failed to find floating group');
7468
- }
7469
- selectedFloatingGroup.dispose();
7470
- break;
8098
+ });
8099
+ this.doSetGroupAndPanelActive(to);
8100
+ panels.forEach((panel) => {
8101
+ this._onDidMovePanel.fire({ panel });
8102
+ });
8103
+ }
8104
+ else {
8105
+ switch (from.api.location.type) {
8106
+ case 'grid':
8107
+ this.gridview.removeView(getGridLocation(from.element));
8108
+ break;
8109
+ case 'floating': {
8110
+ const selectedFloatingGroup = this._floatingGroups.find((x) => x.group === from);
8111
+ if (!selectedFloatingGroup) {
8112
+ throw new Error('failed to find floating group');
7471
8113
  }
7472
- case 'popout': {
7473
- const selectedPopoutGroup = this._popoutGroups.find((x) => x.group === sourceGroup);
7474
- if (!selectedPopoutGroup) {
7475
- throw new Error('failed to find popout group');
7476
- }
7477
- selectedPopoutGroup.dispose();
8114
+ selectedFloatingGroup.dispose();
8115
+ break;
8116
+ }
8117
+ case 'popout': {
8118
+ const selectedPopoutGroup = this._popoutGroups.find((x) => x.popoutGroup === from);
8119
+ if (!selectedPopoutGroup) {
8120
+ throw new Error('failed to find popout group');
7478
8121
  }
8122
+ selectedPopoutGroup.disposable.dispose();
7479
8123
  }
7480
- const referenceLocation = getGridLocation(referenceGroup.element);
7481
- const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, target);
7482
- this.gridview.addView(sourceGroup, exports.Sizing.Distribute, dropLocation);
7483
8124
  }
8125
+ const referenceLocation = getGridLocation(to.element);
8126
+ const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, target);
8127
+ this.gridview.addView(from, exports.Sizing.Distribute, dropLocation);
8128
+ from.panels.forEach((panel) => {
8129
+ this._onDidMovePanel.fire({ panel });
8130
+ });
7484
8131
  }
7485
8132
  }
7486
- doSetGroupAndPanelActive(group, skipFocus) {
7487
- var _a, _b;
8133
+ doSetGroupActive(group) {
8134
+ super.doSetGroupActive(group);
8135
+ const activePanel = this.activePanel;
8136
+ if (!this._moving &&
8137
+ activePanel !== this._onDidActivePanelChange.value) {
8138
+ this._onDidActivePanelChange.fire(activePanel);
8139
+ }
8140
+ }
8141
+ doSetGroupAndPanelActive(group) {
8142
+ super.doSetGroupActive(group);
7488
8143
  const activePanel = this.activePanel;
7489
- super.doSetGroupActive(group, skipFocus);
7490
- if (((_a = this._activeGroup) === null || _a === void 0 ? void 0 : _a.activePanel) !== activePanel) {
7491
- this._onDidActivePanelChange.fire((_b = this._activeGroup) === null || _b === void 0 ? void 0 : _b.activePanel);
8144
+ if (group &&
8145
+ this.hasMaximizedGroup() &&
8146
+ !this.isMaximizedGroup(group)) {
8147
+ this.exitMaximizedGroup();
8148
+ }
8149
+ if (!this._moving &&
8150
+ activePanel !== this._onDidActivePanelChange.value) {
8151
+ this._onDidActivePanelChange.fire(activePanel);
7492
8152
  }
7493
8153
  }
8154
+ getNextGroupId() {
8155
+ let id = this.nextGroupId.next();
8156
+ while (this._groups.has(id)) {
8157
+ id = this.nextGroupId.next();
8158
+ }
8159
+ return id;
8160
+ }
7494
8161
  createGroup(options) {
7495
8162
  if (!options) {
7496
8163
  options = {};
@@ -7507,7 +8174,7 @@ class DockviewComponent extends BaseGrid {
7507
8174
  }
7508
8175
  }
7509
8176
  const view = new DockviewGroupPanel(this, id, options);
7510
- view.init({ params: {}, accessor: null }); // required to initialized .part and allow for correct disposal of group
8177
+ view.init({ params: {}, accessor: this });
7511
8178
  if (!this._groups.has(view.id)) {
7512
8179
  const disposable = new CompositeDisposable(view.model.onTabDragStart((event) => {
7513
8180
  this._onWillDragPanel.fire(event);
@@ -7515,20 +8182,48 @@ class DockviewComponent extends BaseGrid {
7515
8182
  this._onWillDragGroup.fire(event);
7516
8183
  }), view.model.onMove((event) => {
7517
8184
  const { groupId, itemId, target, index } = event;
7518
- this.moveGroupOrPanel(view, groupId, itemId, target, index);
8185
+ this.moveGroupOrPanel({
8186
+ from: { groupId: groupId, panelId: itemId },
8187
+ to: {
8188
+ group: view,
8189
+ position: target,
8190
+ index,
8191
+ },
8192
+ });
7519
8193
  }), view.model.onDidDrop((event) => {
7520
- this._onDidDrop.fire(Object.assign(Object.assign({}, event), { api: this._api, group: view }));
8194
+ this._onDidDrop.fire(event);
8195
+ }), view.model.onWillDrop((event) => {
8196
+ this._onWillDrop.fire(event);
8197
+ }), view.model.onWillShowOverlay((event) => {
8198
+ if (this.options.disableDnd) {
8199
+ event.preventDefault();
8200
+ return;
8201
+ }
8202
+ this._onWillShowOverlay.fire(event);
7521
8203
  }), view.model.onDidAddPanel((event) => {
8204
+ if (this._moving) {
8205
+ return;
8206
+ }
7522
8207
  this._onDidAddPanel.fire(event.panel);
7523
8208
  }), view.model.onDidRemovePanel((event) => {
8209
+ if (this._moving) {
8210
+ return;
8211
+ }
7524
8212
  this._onDidRemovePanel.fire(event.panel);
7525
8213
  }), view.model.onDidActivePanelChange((event) => {
7526
- this._onDidActivePanelChange.fire(event.panel);
8214
+ if (this._moving) {
8215
+ return;
8216
+ }
8217
+ if (event.panel !== this.activePanel) {
8218
+ return;
8219
+ }
8220
+ if (this._onDidActivePanelChange.value !== event.panel) {
8221
+ this._onDidActivePanelChange.fire(event.panel);
8222
+ }
7527
8223
  }));
7528
8224
  this._groups.set(view.id, { value: view, disposable });
7529
8225
  }
7530
- // TODO: must be called after the above listeners have been setup,
7531
- // not an ideal pattern
8226
+ // TODO: must be called after the above listeners have been setup, not an ideal pattern
7532
8227
  view.initialize();
7533
8228
  return view;
7534
8229
  }
@@ -7581,7 +8276,20 @@ class GridviewComponent extends BaseGrid {
7581
8276
  });
7582
8277
  this._onDidLayoutfromJSON = new Emitter();
7583
8278
  this.onDidLayoutFromJSON = this._onDidLayoutfromJSON.event;
8279
+ this._onDidRemoveGroup = new Emitter();
8280
+ this.onDidRemoveGroup = this._onDidRemoveGroup.event;
8281
+ this._onDidAddGroup = new Emitter();
8282
+ this.onDidAddGroup = this._onDidAddGroup.event;
8283
+ this._onDidActiveGroupChange = new Emitter();
8284
+ this.onDidActiveGroupChange = this._onDidActiveGroupChange.event;
7584
8285
  this._options = options;
8286
+ this.addDisposables(this._onDidAddGroup, this._onDidRemoveGroup, this._onDidActiveGroupChange, this.onDidAdd((event) => {
8287
+ this._onDidAddGroup.fire(event);
8288
+ }), this.onDidRemove((event) => {
8289
+ this._onDidRemoveGroup.fire(event);
8290
+ }), this.onDidActiveChange((event) => {
8291
+ this._onDidActiveGroupChange.fire(event);
8292
+ }));
7585
8293
  if (!this.options.components) {
7586
8294
  this.options.components = {};
7587
8295
  }
@@ -7756,6 +8464,7 @@ class GridviewComponent extends BaseGrid {
7756
8464
  });
7757
8465
  this.registerPanel(view);
7758
8466
  this.doAddGroup(view, relativeLocation, options.size);
8467
+ this.doSetGroupActive(view);
7759
8468
  return view;
7760
8469
  }
7761
8470
  registerPanel(panel) {
@@ -8441,10 +9150,10 @@ class SplitviewPanel extends BasePanelView {
8441
9150
  this._onDidChange = new Emitter();
8442
9151
  this.onDidChange = this._onDidChange.event;
8443
9152
  this.api.initialize(this);
8444
- this.addDisposables(this._onDidChange, this.api.onVisibilityChange((event) => {
8445
- const { isVisible } = event;
9153
+ this.addDisposables(this._onDidChange, this.api.onDidHiddenChange((event) => {
9154
+ const { isHidden } = event;
8446
9155
  const { accessor } = this._params;
8447
- accessor.setVisible(this, isVisible);
9156
+ accessor.setVisible(this, !isHidden);
8448
9157
  }), this.api.onActiveChange(() => {
8449
9158
  const { accessor } = this._params;
8450
9159
  accessor.setActive(this);
@@ -8566,13 +9275,13 @@ class ReactPart {
8566
9275
  if (this.disposed) {
8567
9276
  throw new Error('invalid operation: resource is already disposed');
8568
9277
  }
8569
- if (typeof this.component !== 'function') {
9278
+ if (!isReactComponent(this.component)) {
8570
9279
  /**
8571
9280
  * we know this isn't a React.FunctionComponent so throw an error here.
8572
- * if we do not intercept this the React library will throw a very obsure error
8573
- * for the same reason, at least at this point we will emit a sensible stacktrace.
9281
+ * if we do not intercept then React library will throw a very obsure error
9282
+ * for the same reason... at least at this point we will emit a sensible stacktrace.
8574
9283
  */
8575
- throw new Error('Invalid Operation. dockview only supports React Functional Components.');
9284
+ throw new Error('Dockview: Only React.memo(...), React.ForwardRef(...) and functional components are accepted as components');
8576
9285
  }
8577
9286
  const bridgeComponent = React__namespace.createElement(React__namespace.forwardRef(ReactComponentBridge), {
8578
9287
  component: this
@@ -8624,9 +9333,13 @@ const usePortalsLifecycle = () => {
8624
9333
  }, []);
8625
9334
  return [portals, addPortal];
8626
9335
  };
8627
- // it does the job...
8628
- function isReactElement(element) {
8629
- return !!(element === null || element === void 0 ? void 0 : element.type);
9336
+ function isReactComponent(component) {
9337
+ /**
9338
+ * Yes, we could use "react-is" but that would introduce an unwanted peer dependency
9339
+ * so for now we will check in a rather crude fashion...
9340
+ */
9341
+ return (typeof component === 'function' /** Functional Componnts */ ||
9342
+ !!(component === null || component === void 0 ? void 0 : component.$$typeof) /** React.memo(...) Components */);
8630
9343
  }
8631
9344
 
8632
9345
  class ReactPanelContentPart {
@@ -8886,6 +9599,8 @@ const DockviewReact = React__namespace.forwardRef((props, ref) => {
8886
9599
  defaultRenderer: props.defaultRenderer,
8887
9600
  debug: props.debug,
8888
9601
  rootOverlayModel: props.rootOverlayModel,
9602
+ locked: props.locked,
9603
+ disableDnd: props.disableDnd,
8889
9604
  });
8890
9605
  const { clientWidth, clientHeight } = domRef.current;
8891
9606
  dockview.layout(clientWidth, clientHeight);
@@ -8897,6 +9612,20 @@ const DockviewReact = React__namespace.forwardRef((props, ref) => {
8897
9612
  dockview.dispose();
8898
9613
  };
8899
9614
  }, []);
9615
+ React__namespace.useEffect(() => {
9616
+ if (!dockviewRef.current) {
9617
+ return;
9618
+ }
9619
+ dockviewRef.current.locked = !!props.locked;
9620
+ }, [props.locked]);
9621
+ React__namespace.useEffect(() => {
9622
+ if (!dockviewRef.current) {
9623
+ return;
9624
+ }
9625
+ dockviewRef.current.updateOptions({
9626
+ disableDnd: props.disableDnd,
9627
+ });
9628
+ }, [props.disableDnd]);
8900
9629
  React__namespace.useEffect(() => {
8901
9630
  if (!dockviewRef.current) {
8902
9631
  return () => {
@@ -8912,6 +9641,21 @@ const DockviewReact = React__namespace.forwardRef((props, ref) => {
8912
9641
  disposable.dispose();
8913
9642
  };
8914
9643
  }, [props.onDidDrop]);
9644
+ React__namespace.useEffect(() => {
9645
+ if (!dockviewRef.current) {
9646
+ return () => {
9647
+ // noop
9648
+ };
9649
+ }
9650
+ const disposable = dockviewRef.current.onWillDrop((event) => {
9651
+ if (props.onWillDrop) {
9652
+ props.onWillDrop(event);
9653
+ }
9654
+ });
9655
+ return () => {
9656
+ disposable.dispose();
9657
+ };
9658
+ }, [props.onWillDrop]);
8915
9659
  React__namespace.useEffect(() => {
8916
9660
  if (!dockviewRef.current) {
8917
9661
  return;
@@ -9154,7 +9898,9 @@ class ReactGridPanelView extends GridviewPanel {
9154
9898
  return new ReactPart(this.element, this.reactPortalStore, this.reactComponent, {
9155
9899
  params: (_b = (_a = this._params) === null || _a === void 0 ? void 0 : _a.params) !== null && _b !== void 0 ? _b : {},
9156
9900
  api: this.api,
9157
- containerApi: new GridviewApi(this._params.accessor),
9901
+ // TODO: fix casting hack
9902
+ containerApi: new GridviewApi(this._params
9903
+ .accessor),
9158
9904
  });
9159
9905
  }
9160
9906
  }
@@ -9337,12 +10083,14 @@ exports.DockviewApi = DockviewApi;
9337
10083
  exports.DockviewComponent = DockviewComponent;
9338
10084
  exports.DockviewCompositeDisposable = CompositeDisposable;
9339
10085
  exports.DockviewDefaultTab = DockviewDefaultTab;
10086
+ exports.DockviewDidDropEvent = DockviewDidDropEvent;
9340
10087
  exports.DockviewEmitter = Emitter;
9341
10088
  exports.DockviewGroupPanel = DockviewGroupPanel;
9342
10089
  exports.DockviewGroupPanelModel = DockviewGroupPanelModel;
9343
10090
  exports.DockviewMutableDisposable = MutableDisposable;
9344
10091
  exports.DockviewPanel = DockviewPanel;
9345
10092
  exports.DockviewReact = DockviewReact;
10093
+ exports.DockviewWillDropEvent = DockviewWillDropEvent;
9346
10094
  exports.DraggablePaneviewPanel = DraggablePaneviewPanel;
9347
10095
  exports.Gridview = Gridview;
9348
10096
  exports.GridviewApi = GridviewApi;
@@ -9366,6 +10114,7 @@ exports.SplitviewComponent = SplitviewComponent;
9366
10114
  exports.SplitviewPanel = SplitviewPanel;
9367
10115
  exports.SplitviewReact = SplitviewReact;
9368
10116
  exports.Tab = Tab;
10117
+ exports.WillShowOverlayLocationEvent = WillShowOverlayLocationEvent;
9369
10118
  exports.createComponent = createComponent;
9370
10119
  exports.directionToPosition = directionToPosition;
9371
10120
  exports.getDirectionOrientation = getDirectionOrientation;
@@ -9380,7 +10129,7 @@ exports.isGroupOptionsWithGroup = isGroupOptionsWithGroup;
9380
10129
  exports.isGroupOptionsWithPanel = isGroupOptionsWithPanel;
9381
10130
  exports.isPanelOptionsWithGroup = isPanelOptionsWithGroup;
9382
10131
  exports.isPanelOptionsWithPanel = isPanelOptionsWithPanel;
9383
- exports.isReactElement = isReactElement;
10132
+ exports.isReactComponent = isReactComponent;
9384
10133
  exports.orthogonal = orthogonal;
9385
10134
  exports.positionToDirection = positionToDirection;
9386
10135
  exports.toTarget = toTarget;