dockview 1.9.1 → 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 +1287 -537
  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 +1287 -537
  40. package/dist/dockview.amd.noStyle.js.map +1 -1
  41. package/dist/dockview.cjs.js +1287 -537
  42. package/dist/dockview.cjs.js.map +1 -1
  43. package/dist/dockview.esm.js +1284 -537
  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 +1287 -537
  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 +1287 -537
  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.1
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,12 +3629,13 @@ class ContentContainer extends CompositeDisposable {
3513
3629
  // noop
3514
3630
  }
3515
3631
  closePanel() {
3632
+ var _a;
3516
3633
  if (this.panel) {
3517
- if (this.accessor.options.defaultRenderer === 'onlyWhenVisibile') {
3518
- this._element.removeChild(this.panel.view.content.element);
3634
+ if (this.panel.api.renderer === 'onlyWhenVisibile') {
3635
+ (_a = this.panel.view.content.element.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(this.panel.view.content.element);
3519
3636
  }
3520
- this.panel = undefined;
3521
3637
  }
3638
+ this.panel = undefined;
3522
3639
  }
3523
3640
  dispose() {
3524
3641
  this.disposable.dispose();
@@ -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,34 +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
- }
4483
+ this.contentContainer.renderPanel(panel, { asActive: true });
4272
4484
  return;
4273
4485
  }
4274
- this.doAddPanel(panel, options.index, skipSetPanelActive);
4275
- if (!skipSetPanelActive) {
4486
+ if (!skipSetActive) {
4276
4487
  this.doSetActivePanel(panel);
4277
4488
  }
4278
- if (!skipSetGroupActive) {
4279
- 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();
4280
4494
  }
4281
- this.updateContainer();
4282
4495
  }
4283
- removePanel(groupItemOrId) {
4496
+ removePanel(groupItemOrId, options = {
4497
+ skipSetActive: false,
4498
+ }) {
4284
4499
  const id = typeof groupItemOrId === 'string'
4285
4500
  ? groupItemOrId
4286
4501
  : groupItemOrId.id;
@@ -4288,7 +4503,7 @@ class DockviewGroupPanelModel extends CompositeDisposable {
4288
4503
  if (!panelToRemove) {
4289
4504
  throw new Error('invalid operation');
4290
4505
  }
4291
- return this._removePanel(panelToRemove);
4506
+ return this._removePanel(panelToRemove, options);
4292
4507
  }
4293
4508
  closeAllPanels() {
4294
4509
  if (this.panels.length > 0) {
@@ -4314,12 +4529,8 @@ class DockviewGroupPanelModel extends CompositeDisposable {
4314
4529
  updateActions(element) {
4315
4530
  this.tabsContainer.setRightActionsElement(element);
4316
4531
  }
4317
- setActive(isGroupActive, skipFocus = false, force = false) {
4318
- var _a, _b, _c, _d;
4532
+ setActive(isGroupActive, force = false) {
4319
4533
  if (!force && this.isActive === isGroupActive) {
4320
- if (!skipFocus) {
4321
- (_b = (_a = this._activePanel) === null || _a === void 0 ? void 0 : _a.focus) === null || _b === void 0 ? void 0 : _b.call(_a);
4322
- }
4323
4534
  return;
4324
4535
  }
4325
4536
  this._isGroupActive = isGroupActive;
@@ -4330,11 +4541,6 @@ class DockviewGroupPanelModel extends CompositeDisposable {
4330
4541
  this.doSetActivePanel(this.panels[0]);
4331
4542
  }
4332
4543
  this.updateContainer();
4333
- if (isGroupActive) {
4334
- if (!skipFocus) {
4335
- (_d = (_c = this._activePanel) === null || _c === void 0 ? void 0 : _c.focus) === null || _d === void 0 ? void 0 : _d.call(_c);
4336
- }
4337
- }
4338
4544
  }
4339
4545
  layout(width, height) {
4340
4546
  var _a;
@@ -4345,17 +4551,22 @@ class DockviewGroupPanelModel extends CompositeDisposable {
4345
4551
  this._activePanel.layout(this._width, this._height);
4346
4552
  }
4347
4553
  }
4348
- _removePanel(panel) {
4554
+ _removePanel(panel, options) {
4349
4555
  const isActivePanel = this._activePanel === panel;
4350
4556
  this.doRemovePanel(panel);
4351
4557
  if (isActivePanel && this.panels.length > 0) {
4352
4558
  const nextPanel = this.mostRecentlyUsed[0];
4353
- this.openPanel(nextPanel);
4559
+ this.openPanel(nextPanel, {
4560
+ skipSetActive: options.skipSetActive,
4561
+ skipSetGroupActive: options.skipSetActiveGroup,
4562
+ });
4354
4563
  }
4355
4564
  if (this._activePanel && this.panels.length === 0) {
4356
4565
  this.doSetActivePanel(undefined);
4357
4566
  }
4358
- this.updateContainer();
4567
+ if (!options.skipSetActive) {
4568
+ this.updateContainer();
4569
+ }
4359
4570
  return panel;
4360
4571
  }
4361
4572
  doRemovePanel(panel) {
@@ -4370,13 +4581,13 @@ class DockviewGroupPanelModel extends CompositeDisposable {
4370
4581
  }
4371
4582
  this._onDidRemovePanel.fire({ panel });
4372
4583
  }
4373
- doAddPanel(panel, index = this.panels.length, skipSetActive = false) {
4584
+ doAddPanel(panel, index = this.panels.length, options = { skipSetActive: false }) {
4374
4585
  const existingPanel = this._panels.indexOf(panel);
4375
4586
  const hasExistingPanel = existingPanel > -1;
4376
4587
  this.tabsContainer.show();
4377
4588
  this.contentContainer.show();
4378
4589
  this.tabsContainer.openPanel(panel, index);
4379
- if (!skipSetActive) {
4590
+ if (!options.skipSetActive) {
4380
4591
  this.contentContainer.openPanel(panel);
4381
4592
  }
4382
4593
  if (hasExistingPanel) {
@@ -4388,12 +4599,17 @@ class DockviewGroupPanelModel extends CompositeDisposable {
4388
4599
  this._onDidAddPanel.fire({ panel });
4389
4600
  }
4390
4601
  doSetActivePanel(panel) {
4602
+ if (this._activePanel === panel) {
4603
+ return;
4604
+ }
4391
4605
  this._activePanel = panel;
4392
4606
  if (panel) {
4393
4607
  this.tabsContainer.setActivePanel(panel);
4394
4608
  panel.layout(this._width, this._height);
4395
4609
  this.updateMru(panel);
4396
- this._onDidActivePanelChange.fire({ panel });
4610
+ this._onDidActivePanelChange.fire({
4611
+ panel,
4612
+ });
4397
4613
  }
4398
4614
  }
4399
4615
  updateMru(panel) {
@@ -4405,11 +4621,11 @@ class DockviewGroupPanelModel extends CompositeDisposable {
4405
4621
  updateContainer() {
4406
4622
  var _a, _b;
4407
4623
  toggleClass(this.container, 'empty', this.isEmpty);
4408
- this.panels.forEach((panel) => panel.updateParentGroup(this.groupPanel, this.isActive));
4624
+ this.panels.forEach((panel) => panel.runEvents());
4409
4625
  if (this.isEmpty && !this.watermark) {
4410
4626
  const watermark = this.accessor.createWatermarkComponent();
4411
4627
  watermark.init({
4412
- containerApi: new DockviewApi(this.accessor),
4628
+ containerApi: this._api,
4413
4629
  group: this.groupPanel,
4414
4630
  });
4415
4631
  this.watermark = watermark;
@@ -4442,10 +4658,32 @@ class DockviewGroupPanelModel extends CompositeDisposable {
4442
4658
  }
4443
4659
  return false;
4444
4660
  }
4445
- handleDropEvent(event, position, index) {
4661
+ handleDropEvent(type, event, position, index) {
4446
4662
  if (this.locked === 'no-drop-target') {
4447
4663
  return;
4448
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
+ }
4449
4687
  const data = getPanelData();
4450
4688
  if (data && data.viewId === this.accessor.id) {
4451
4689
  if (data.panelId === null) {
@@ -4478,12 +4716,14 @@ class DockviewGroupPanelModel extends CompositeDisposable {
4478
4716
  });
4479
4717
  }
4480
4718
  else {
4481
- this._onDidDrop.fire({
4719
+ this._onDidDrop.fire(new DockviewDidDropEvent({
4482
4720
  nativeEvent: event,
4483
4721
  position,
4484
- index,
4722
+ panel,
4485
4723
  getData: () => getPanelData(),
4486
- });
4724
+ group: this.groupPanel,
4725
+ api: this._api,
4726
+ }));
4487
4727
  }
4488
4728
  }
4489
4729
  dispose() {
@@ -4491,6 +4731,7 @@ class DockviewGroupPanelModel extends CompositeDisposable {
4491
4731
  super.dispose();
4492
4732
  (_a = this.watermark) === null || _a === void 0 ? void 0 : _a.element.remove();
4493
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;
4494
4735
  for (const panel of this.panels) {
4495
4736
  panel.dispose();
4496
4737
  }
@@ -4512,15 +4753,7 @@ class Resizable extends CompositeDisposable {
4512
4753
  constructor(parentElement, disableResizing = false) {
4513
4754
  super();
4514
4755
  this._disableResizing = disableResizing;
4515
- if (parentElement) {
4516
- this._element = parentElement;
4517
- }
4518
- else {
4519
- this._element = document.createElement('div');
4520
- this._element.style.height = '100%';
4521
- this._element.style.width = '100%';
4522
- this._element.className = 'dv-resizable-container';
4523
- }
4756
+ this._element = parentElement;
4524
4757
  this.addDisposables(watchElementResize(this._element, (entry) => {
4525
4758
  if (this.isDisposed) {
4526
4759
  /**
@@ -4608,25 +4841,38 @@ class BaseGrid extends Resizable {
4608
4841
  get activeGroup() {
4609
4842
  return this._activeGroup;
4610
4843
  }
4844
+ get locked() {
4845
+ return this.gridview.locked;
4846
+ }
4847
+ set locked(value) {
4848
+ this.gridview.locked = value;
4849
+ }
4611
4850
  constructor(options) {
4612
- super(options.parentElement, options.disableAutoResizing);
4851
+ super(document.createElement('div'), options.disableAutoResizing);
4613
4852
  this._id = nextLayoutId$1.next();
4614
4853
  this._groups = new Map();
4615
4854
  this._onDidLayoutChange = new Emitter();
4616
4855
  this.onDidLayoutChange = this._onDidLayoutChange.event;
4617
- this._onDidRemoveGroup = new Emitter();
4618
- this.onDidRemoveGroup = this._onDidRemoveGroup.event;
4619
- this._onDidAddGroup = new Emitter();
4620
- this.onDidAddGroup = this._onDidAddGroup.event;
4621
- this._onDidActiveGroupChange = new Emitter();
4622
- 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;
4623
4862
  this._bufferOnDidLayoutChange = new TickDelayedEvent();
4863
+ this.element.style.height = '100%';
4864
+ this.element.style.width = '100%';
4865
+ options.parentElement.appendChild(this.element);
4624
4866
  this.gridview = new Gridview(!!options.proportionalLayout, options.styles, options.orientation);
4867
+ this.gridview.locked = !!options.locked;
4625
4868
  this.element.appendChild(this.gridview.element);
4626
4869
  this.layout(0, 0, true); // set some elements height/widths
4627
- 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(() => {
4628
4874
  this._bufferOnDidLayoutChange.fire();
4629
- }), exports.DockviewEvent.any(this.onDidAddGroup, this.onDidRemoveGroup, this.onDidActiveGroupChange)(() => {
4875
+ }), exports.DockviewEvent.any(this.onDidAdd, this.onDidRemove, this.onDidActiveChange)(() => {
4630
4876
  this._bufferOnDidLayoutChange.fire();
4631
4877
  }), this._bufferOnDidLayoutChange.onEvent(() => {
4632
4878
  this._onDidLayoutChange.fire();
@@ -4641,6 +4887,7 @@ class BaseGrid extends Resizable {
4641
4887
  }
4642
4888
  maximizeGroup(panel) {
4643
4889
  this.gridview.maximizeView(panel);
4890
+ this.doSetGroupActive(panel);
4644
4891
  }
4645
4892
  isMaximizedGroup(panel) {
4646
4893
  return this.gridview.maximizedView() === panel;
@@ -4651,13 +4898,12 @@ class BaseGrid extends Resizable {
4651
4898
  hasMaximizedGroup() {
4652
4899
  return this.gridview.hasMaximizedView();
4653
4900
  }
4654
- get onDidMaxmizedGroupChange() {
4655
- return this.gridview.onDidMaxmizedNodeChange;
4901
+ get onDidMaximizedGroupChange() {
4902
+ return this.gridview.onDidMaximizedNodeChange;
4656
4903
  }
4657
4904
  doAddGroup(group, location = [0], size) {
4658
4905
  this.gridview.addView(group, size !== null && size !== void 0 ? size : exports.Sizing.Distribute, location);
4659
- this._onDidAddGroup.fire(group);
4660
- this.doSetGroupActive(group);
4906
+ this._onDidAdd.fire(group);
4661
4907
  }
4662
4908
  doRemoveGroup(group, options) {
4663
4909
  if (!this._groups.has(group.id)) {
@@ -4669,8 +4915,8 @@ class BaseGrid extends Resizable {
4669
4915
  item.disposable.dispose();
4670
4916
  item.value.dispose();
4671
4917
  this._groups.delete(group.id);
4918
+ this._onDidRemove.fire(group);
4672
4919
  }
4673
- this._onDidRemoveGroup.fire(group);
4674
4920
  if (!(options === null || options === void 0 ? void 0 : options.skipActive) && this._activeGroup === group) {
4675
4921
  const groups = Array.from(this._groups.values());
4676
4922
  this.doSetGroupActive(groups.length > 0 ? groups[0].value : undefined);
@@ -4681,25 +4927,18 @@ class BaseGrid extends Resizable {
4681
4927
  var _a;
4682
4928
  return (_a = this._groups.get(id)) === null || _a === void 0 ? void 0 : _a.value;
4683
4929
  }
4684
- doSetGroupActive(group, skipFocus) {
4685
- var _a, _b, _c;
4930
+ doSetGroupActive(group) {
4686
4931
  if (this._activeGroup === group) {
4687
4932
  return;
4688
4933
  }
4689
4934
  if (this._activeGroup) {
4690
4935
  this._activeGroup.setActive(false);
4691
- if (!skipFocus) {
4692
- (_b = (_a = this._activeGroup).focus) === null || _b === void 0 ? void 0 : _b.call(_a);
4693
- }
4694
4936
  }
4695
4937
  if (group) {
4696
4938
  group.setActive(true);
4697
- if (!skipFocus) {
4698
- (_c = group.focus) === null || _c === void 0 ? void 0 : _c.call(group);
4699
- }
4700
4939
  }
4701
4940
  this._activeGroup = group;
4702
- this._onDidActiveGroupChange.fire(group);
4941
+ this._onDidActiveChange.fire(group);
4703
4942
  }
4704
4943
  removeGroup(group) {
4705
4944
  this.doRemoveGroup(group);
@@ -4744,9 +4983,9 @@ class BaseGrid extends Resizable {
4744
4983
  this.gridview.layout(width, height);
4745
4984
  }
4746
4985
  dispose() {
4747
- this._onDidActiveGroupChange.dispose();
4748
- this._onDidAddGroup.dispose();
4749
- this._onDidRemoveGroup.dispose();
4986
+ this._onDidActiveChange.dispose();
4987
+ this._onDidAdd.dispose();
4988
+ this._onDidRemove.dispose();
4750
4989
  this._onDidLayoutChange.dispose();
4751
4990
  for (const group of this.groups) {
4752
4991
  group.dispose();
@@ -4756,11 +4995,15 @@ class BaseGrid extends Resizable {
4756
4995
  }
4757
4996
  }
4758
4997
 
4998
+ class WillFocusEvent extends DockviewEvent {
4999
+ constructor() {
5000
+ super();
5001
+ }
5002
+ }
4759
5003
  /**
4760
5004
  * A core api implementation that should be used across all panel-like objects
4761
5005
  */
4762
5006
  class PanelApiImpl extends CompositeDisposable {
4763
- //
4764
5007
  get isFocused() {
4765
5008
  return this._isFocused;
4766
5009
  }
@@ -4770,6 +5013,9 @@ class PanelApiImpl extends CompositeDisposable {
4770
5013
  get isVisible() {
4771
5014
  return this._isVisible;
4772
5015
  }
5016
+ get isHidden() {
5017
+ return this._isHidden;
5018
+ }
4773
5019
  get width() {
4774
5020
  return this._width;
4775
5021
  }
@@ -4782,38 +5028,26 @@ class PanelApiImpl extends CompositeDisposable {
4782
5028
  this._isFocused = false;
4783
5029
  this._isActive = false;
4784
5030
  this._isVisible = true;
5031
+ this._isHidden = false;
4785
5032
  this._width = 0;
4786
5033
  this._height = 0;
4787
5034
  this.panelUpdatesDisposable = new MutableDisposable();
4788
- this._onDidDimensionChange = new Emitter({
4789
- replay: true,
4790
- });
5035
+ this._onDidDimensionChange = new Emitter();
4791
5036
  this.onDidDimensionsChange = this._onDidDimensionChange.event;
4792
- //
4793
- this._onDidChangeFocus = new Emitter({
4794
- replay: true,
4795
- });
5037
+ this._onDidChangeFocus = new Emitter();
4796
5038
  this.onDidFocusChange = this._onDidChangeFocus.event;
4797
5039
  //
4798
- this._onFocusEvent = new Emitter();
4799
- this.onFocusEvent = this._onFocusEvent.event;
5040
+ this._onWillFocus = new Emitter();
5041
+ this.onWillFocus = this._onWillFocus.event;
4800
5042
  //
4801
- this._onDidVisibilityChange = new Emitter({
4802
- replay: true,
4803
- });
5043
+ this._onDidVisibilityChange = new Emitter();
4804
5044
  this.onDidVisibilityChange = this._onDidVisibilityChange.event;
4805
- //
4806
- this._onVisibilityChange = new Emitter();
4807
- this.onVisibilityChange = this._onVisibilityChange.event;
4808
- //
4809
- this._onDidActiveChange = new Emitter({
4810
- replay: true,
4811
- });
5045
+ this._onDidHiddenChange = new Emitter();
5046
+ this.onDidHiddenChange = this._onDidHiddenChange.event;
5047
+ this._onDidActiveChange = new Emitter();
4812
5048
  this.onDidActiveChange = this._onDidActiveChange.event;
4813
- //
4814
5049
  this._onActiveChange = new Emitter();
4815
5050
  this.onActiveChange = this._onActiveChange.event;
4816
- //
4817
5051
  this._onUpdateParameters = new Emitter();
4818
5052
  this.onUpdateParameters = this._onUpdateParameters.event;
4819
5053
  this.addDisposables(this.onDidFocusChange((event) => {
@@ -4822,10 +5056,12 @@ class PanelApiImpl extends CompositeDisposable {
4822
5056
  this._isActive = event.isActive;
4823
5057
  }), this.onDidVisibilityChange((event) => {
4824
5058
  this._isVisible = event.isVisible;
5059
+ }), this.onDidHiddenChange((event) => {
5060
+ this._isHidden = event.isHidden;
4825
5061
  }), this.onDidDimensionsChange((event) => {
4826
5062
  this._width = event.width;
4827
5063
  this._height = event.height;
4828
- }), 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);
4829
5065
  }
4830
5066
  initialize(panel) {
4831
5067
  this.panelUpdatesDisposable.value = this._onUpdateParameters.event((parameters) => {
@@ -4834,8 +5070,8 @@ class PanelApiImpl extends CompositeDisposable {
4834
5070
  });
4835
5071
  });
4836
5072
  }
4837
- setVisible(isVisible) {
4838
- this._onVisibilityChange.fire({ isVisible });
5073
+ setHidden(isHidden) {
5074
+ this._onDidHiddenChange.fire({ isHidden });
4839
5075
  }
4840
5076
  setActive() {
4841
5077
  this._onActiveChange.fire();
@@ -4843,9 +5079,6 @@ class PanelApiImpl extends CompositeDisposable {
4843
5079
  updateParameters(parameters) {
4844
5080
  this._onUpdateParameters.fire(parameters);
4845
5081
  }
4846
- dispose() {
4847
- super.dispose();
4848
- }
4849
5082
  }
4850
5083
 
4851
5084
  class SplitviewPanelApiImpl extends PanelApiImpl {
@@ -4933,7 +5166,12 @@ class BasePanelView extends CompositeDisposable {
4933
5166
  }), focusTracker);
4934
5167
  }
4935
5168
  focus() {
4936
- 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();
4937
5175
  }
4938
5176
  layout(width, height) {
4939
5177
  this._width = width;
@@ -5262,9 +5500,7 @@ class GridviewPanelApiImpl extends PanelApiImpl {
5262
5500
  super(id);
5263
5501
  this._onDidConstraintsChangeInternal = new Emitter();
5264
5502
  this.onDidConstraintsChangeInternal = this._onDidConstraintsChangeInternal.event;
5265
- this._onDidConstraintsChange = new Emitter({
5266
- replay: true,
5267
- });
5503
+ this._onDidConstraintsChange = new Emitter();
5268
5504
  this.onDidConstraintsChange = this._onDidConstraintsChange.event;
5269
5505
  this._onDidSizeChange = new Emitter();
5270
5506
  this.onDidSizeChange = this._onDidSizeChange.event;
@@ -5357,13 +5593,13 @@ class GridviewPanel extends BasePanelView {
5357
5593
  this._maximumHeight = options.maximumHeight;
5358
5594
  }
5359
5595
  this.api.initialize(this); // TODO: required to by-pass 'super before this' requirement
5360
- this.addDisposables(this.api.onVisibilityChange((event) => {
5361
- const { isVisible } = event;
5596
+ this.addDisposables(this.api.onDidHiddenChange((event) => {
5597
+ const { isHidden } = event;
5362
5598
  const { accessor } = this._params;
5363
- accessor.setVisible(this, isVisible);
5599
+ accessor.setVisible(this, !isHidden);
5364
5600
  }), this.api.onActiveChange(() => {
5365
5601
  const { accessor } = this._params;
5366
- accessor.setActive(this);
5602
+ accessor.doSetGroupActive(this);
5367
5603
  }), this.api.onDidConstraintsChangeInternal((event) => {
5368
5604
  if (typeof event.minimumWidth === 'number' ||
5369
5605
  typeof event.minimumWidth === 'function') {
@@ -5446,6 +5682,17 @@ class DockviewGroupPanelApiImpl extends GridviewPanelApiImpl {
5446
5682
  this.onDidLocationChange = this._onDidLocationChange.event;
5447
5683
  this.addDisposables(this._onDidLocationChange);
5448
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
+ }
5449
5696
  moveTo(options) {
5450
5697
  var _a, _b, _c;
5451
5698
  if (!this._group) {
@@ -5453,14 +5700,23 @@ class DockviewGroupPanelApiImpl extends GridviewPanelApiImpl {
5453
5700
  }
5454
5701
  const group = (_a = options.group) !== null && _a !== void 0 ? _a : this.accessor.addGroup({
5455
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
+ },
5456
5713
  });
5457
- this.accessor.moveGroupOrPanel(group, this._group.id, undefined, options.group ? (_c = options.position) !== null && _c !== void 0 ? _c : 'center' : 'center');
5458
5714
  }
5459
5715
  maximize() {
5460
5716
  if (!this._group) {
5461
5717
  throw new Error(NOT_INITIALIZED_MESSAGE);
5462
5718
  }
5463
- if (this.location !== 'grid') {
5719
+ if (this.location.type !== 'grid') {
5464
5720
  // only grid groups can be maximized
5465
5721
  return;
5466
5722
  }
@@ -5517,6 +5773,12 @@ class DockviewGroupPanel extends GridviewPanel {
5517
5773
  this.api.initialize(this); // cannot use 'this' after after 'super' call
5518
5774
  this._model = new DockviewGroupPanelModel(this.element, accessor, id, options, this);
5519
5775
  }
5776
+ focus() {
5777
+ if (!this.api.isActive) {
5778
+ this.api.setActive();
5779
+ }
5780
+ super.focus();
5781
+ }
5520
5782
  initialize() {
5521
5783
  this._model.initialize();
5522
5784
  }
@@ -5562,6 +5824,9 @@ function isGroupOptionsWithGroup(data) {
5562
5824
  }
5563
5825
 
5564
5826
  class DockviewPanelApiImpl extends GridviewPanelApiImpl {
5827
+ get location() {
5828
+ return this.group.api.location;
5829
+ }
5565
5830
  get title() {
5566
5831
  return this.panel.title;
5567
5832
  }
@@ -5573,15 +5838,34 @@ class DockviewPanelApiImpl extends GridviewPanelApiImpl {
5573
5838
  }
5574
5839
  set group(value) {
5575
5840
  const isOldGroupActive = this.isGroupActive;
5576
- this._group = value;
5577
- this._onDidGroupChange.fire();
5578
- if (this._group) {
5579
- this.disposable.value = this._group.api.onDidActiveChange(() => {
5580
- 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,
5581
5868
  });
5582
- if (this.isGroupActive !== isOldGroupActive) {
5583
- this._onDidActiveGroupChange.fire();
5584
- }
5585
5869
  }
5586
5870
  }
5587
5871
  get group() {
@@ -5599,14 +5883,26 @@ class DockviewPanelApiImpl extends GridviewPanelApiImpl {
5599
5883
  this.onDidGroupChange = this._onDidGroupChange.event;
5600
5884
  this._onDidRendererChange = new Emitter();
5601
5885
  this.onDidRendererChange = this._onDidRendererChange.event;
5602
- this.disposable = new MutableDisposable();
5886
+ this._onDidLocationChange = new Emitter();
5887
+ this.onDidLocationChange = this._onDidLocationChange.event;
5888
+ this.groupEventsDisposable = new MutableDisposable();
5603
5889
  this.initialize(panel);
5604
5890
  this._group = group;
5605
- 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();
5606
5895
  }
5607
5896
  moveTo(options) {
5608
5897
  var _a;
5609
- 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
+ });
5610
5906
  }
5611
5907
  setTitle(title) {
5612
5908
  this.panel.setTitle(title);
@@ -5667,7 +5963,14 @@ class DockviewPanel extends CompositeDisposable {
5667
5963
  this.setTitle(params.title);
5668
5964
  }
5669
5965
  focus() {
5670
- 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
+ }
5671
5974
  }
5672
5975
  toJSON() {
5673
5976
  return {
@@ -5724,20 +6027,40 @@ class DockviewPanel extends CompositeDisposable {
5724
6027
  },
5725
6028
  });
5726
6029
  }
5727
- updateParentGroup(group, isGroupActive) {
6030
+ updateParentGroup(group, options) {
5728
6031
  this._group = group;
5729
- this.api.group = group;
6032
+ this.api.group = this._group;
5730
6033
  const isPanelVisible = this._group.model.isPanelActive(this);
5731
- this.api._onDidActiveChange.fire({
5732
- isActive: isGroupActive && isPanelVisible,
5733
- });
5734
- this.api._onDidVisibilityChange.fire({
5735
- isVisible: isPanelVisible,
5736
- });
5737
- 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
+ }
5738
6061
  }
5739
6062
  layout(width, height) {
5740
- // 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?
5741
6064
  this.api._onDidDimensionChange.fire({
5742
6065
  width,
5743
6066
  height: height,
@@ -5859,8 +6182,6 @@ class DockviewPanelModel {
5859
6182
  this.id = id;
5860
6183
  this.contentComponent = contentComponent;
5861
6184
  this.tabComponent = tabComponent;
5862
- this._group = null;
5863
- this._isPanelVisible = null;
5864
6185
  this._content = this.createContentComponent(this.id, contentComponent);
5865
6186
  this._tab = this.createTabComponent(this.id, tabComponent);
5866
6187
  }
@@ -5868,25 +6189,8 @@ class DockviewPanelModel {
5868
6189
  this.content.init(Object.assign(Object.assign({}, params), { tab: this.tab }));
5869
6190
  this.tab.init(params);
5870
6191
  }
5871
- updateParentGroup(group, isPanelVisible) {
5872
- if (group !== this._group) {
5873
- this._group = group;
5874
- if (this._content.onGroupChange) {
5875
- this._content.onGroupChange(group);
5876
- }
5877
- if (this._tab.onGroupChange) {
5878
- this._tab.onGroupChange(group);
5879
- }
5880
- }
5881
- if (isPanelVisible !== this._isPanelVisible) {
5882
- this._isPanelVisible = isPanelVisible;
5883
- if (this._content.onPanelVisibleChange) {
5884
- this._content.onPanelVisibleChange(isPanelVisible);
5885
- }
5886
- if (this._tab.onPanelVisibleChange) {
5887
- this._tab.onPanelVisibleChange(isPanelVisible);
5888
- }
5889
- }
6192
+ updateParentGroup(_group, _isPanelVisible) {
6193
+ // noop
5890
6194
  }
5891
6195
  layout(width, height) {
5892
6196
  var _a, _b;
@@ -6319,117 +6623,6 @@ class DockviewFloatingGroupPanel extends CompositeDisposable {
6319
6623
  }
6320
6624
  }
6321
6625
 
6322
- class PopoutWindow extends CompositeDisposable {
6323
- constructor(id, className, options) {
6324
- super();
6325
- this.id = id;
6326
- this.className = className;
6327
- this.options = options;
6328
- this._onDidClose = new Emitter();
6329
- this.onDidClose = this._onDidClose.event;
6330
- this._window = null;
6331
- this.addDisposables(this._onDidClose, {
6332
- dispose: () => {
6333
- this.close();
6334
- },
6335
- });
6336
- }
6337
- dimensions() {
6338
- if (!this._window) {
6339
- return null;
6340
- }
6341
- const left = this._window.value.screenX;
6342
- const top = this._window.value.screenY;
6343
- const width = this._window.value.innerWidth;
6344
- const height = this._window.value.innerHeight;
6345
- return { top, left, width, height };
6346
- }
6347
- close() {
6348
- if (this._window) {
6349
- this._window.disposable.dispose();
6350
- this._window.value.close();
6351
- this._window = null;
6352
- }
6353
- }
6354
- open(content) {
6355
- if (this._window) {
6356
- throw new Error('instance of popout window is already open');
6357
- }
6358
- const url = `${this.options.url}`;
6359
- const features = Object.entries({
6360
- top: this.options.top,
6361
- left: this.options.left,
6362
- width: this.options.width,
6363
- height: this.options.height,
6364
- })
6365
- .map(([key, value]) => `${key}=${value}`)
6366
- .join(',');
6367
- // https://developer.mozilla.org/en-US/docs/Web/API/Window/open
6368
- const externalWindow = window.open(url, this.id, features);
6369
- if (!externalWindow) {
6370
- return;
6371
- }
6372
- const disposable = new CompositeDisposable();
6373
- this._window = { value: externalWindow, disposable };
6374
- const cleanUp = () => {
6375
- this._onDidClose.fire();
6376
- this._window = null;
6377
- };
6378
- // prevent any default content from loading
6379
- // externalWindow.document.body.replaceWith(document.createElement('div'));
6380
- disposable.addDisposables(addDisposableWindowListener(window, 'beforeunload', () => {
6381
- cleanUp();
6382
- this.close();
6383
- }));
6384
- externalWindow.addEventListener('load', () => {
6385
- const externalDocument = externalWindow.document;
6386
- externalDocument.title = document.title;
6387
- const div = document.createElement('div');
6388
- div.classList.add('dv-popout-window');
6389
- div.style.position = 'absolute';
6390
- div.style.width = '100%';
6391
- div.style.height = '100%';
6392
- div.style.top = '0px';
6393
- div.style.left = '0px';
6394
- div.classList.add(this.className);
6395
- div.appendChild(content);
6396
- externalDocument.body.replaceChildren(div);
6397
- externalDocument.body.classList.add(this.className);
6398
- addStyles(externalDocument, window.document.styleSheets);
6399
- externalWindow.addEventListener('beforeunload', () => {
6400
- // TODO: indicate external window is closing
6401
- cleanUp();
6402
- });
6403
- });
6404
- }
6405
- }
6406
-
6407
- class DockviewPopoutGroupPanel extends CompositeDisposable {
6408
- constructor(id, group, options) {
6409
- var _a;
6410
- super();
6411
- this.id = id;
6412
- this.group = group;
6413
- this.options = options;
6414
- this.window = new PopoutWindow(id, (_a = options.className) !== null && _a !== void 0 ? _a : '', {
6415
- url: this.options.popoutUrl,
6416
- left: this.options.box.left,
6417
- top: this.options.box.top,
6418
- width: this.options.box.width,
6419
- height: this.options.box.height,
6420
- });
6421
- group.model.location = 'popout';
6422
- this.addDisposables(this.window, {
6423
- dispose: () => {
6424
- group.model.location = 'grid';
6425
- },
6426
- }, this.window.onDidClose(() => {
6427
- this.dispose();
6428
- }));
6429
- this.window.open(group.element);
6430
- }
6431
- }
6432
-
6433
6626
  const DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE = 100;
6434
6627
  const DEFAULT_FLOATING_GROUP_POSITION = { left: 100, top: 100 };
6435
6628
 
@@ -6443,11 +6636,13 @@ class OverlayRenderContainer extends CompositeDisposable {
6443
6636
  super();
6444
6637
  this.element = element;
6445
6638
  this.map = {};
6639
+ this._disposed = false;
6446
6640
  this.addDisposables(Disposable.from(() => {
6447
6641
  for (const value of Object.values(this.map)) {
6448
6642
  value.disposable.dispose();
6449
6643
  value.destroy.dispose();
6450
6644
  }
6645
+ this._disposed = true;
6451
6646
  }));
6452
6647
  }
6453
6648
  detatch(panel) {
@@ -6487,7 +6682,7 @@ class OverlayRenderContainer extends CompositeDisposable {
6487
6682
  focusContainer.style.top = `${box.top - box2.top}px`;
6488
6683
  focusContainer.style.width = `${box.width}px`;
6489
6684
  focusContainer.style.height = `${box.height}px`;
6490
- toggleClass(focusContainer, 'dv-render-overlay-float', panel.group.api.location === 'floating');
6685
+ toggleClass(focusContainer, 'dv-render-overlay-float', panel.group.api.location.type === 'floating');
6491
6686
  };
6492
6687
  const visibilityChanged = () => {
6493
6688
  if (panel.api.isVisible) {
@@ -6533,8 +6728,11 @@ class OverlayRenderContainer extends CompositeDisposable {
6533
6728
  resize();
6534
6729
  }));
6535
6730
  this.map[panel.api.id].destroy = Disposable.from(() => {
6536
- focusContainer.removeChild(panel.view.content.element);
6537
- 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);
6538
6736
  });
6539
6737
  queueMicrotask(() => {
6540
6738
  if (this.isDisposed) {
@@ -6555,11 +6753,164 @@ class OverlayRenderContainer extends CompositeDisposable {
6555
6753
  }
6556
6754
  }
6557
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
+
6558
6895
  const DEFAULT_ROOT_OVERLAY_MODEL = {
6559
6896
  activationSize: { type: 'pixels', value: 10 },
6560
6897
  size: { type: 'pixels', value: 20 },
6561
6898
  };
6562
- 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) {
6563
6914
  function toClassList(element) {
6564
6915
  const list = [];
6565
6916
  for (let i = 0; i < element.classList.length; i++) {
@@ -6610,6 +6961,7 @@ class DockviewComponent extends BaseGrid {
6610
6961
  styles: options.styles,
6611
6962
  parentElement: options.parentElement,
6612
6963
  disableAutoResizing: options.disableAutoResizing,
6964
+ locked: options.locked,
6613
6965
  });
6614
6966
  this.nextGroupId = sequentialNumberGenerator();
6615
6967
  this._deserializer = new DefaultDockviewDeserialzier(this);
@@ -6620,6 +6972,10 @@ class DockviewComponent extends BaseGrid {
6620
6972
  this.onWillDragGroup = this._onWillDragGroup.event;
6621
6973
  this._onDidDrop = new Emitter();
6622
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;
6623
6979
  this._onDidRemovePanel = new Emitter();
6624
6980
  this.onDidRemovePanel = this._onDidRemovePanel.event;
6625
6981
  this._onDidAddPanel = new Emitter();
@@ -6628,15 +6984,36 @@ class DockviewComponent extends BaseGrid {
6628
6984
  this.onDidLayoutFromJSON = this._onDidLayoutFromJSON.event;
6629
6985
  this._onDidActivePanelChange = new Emitter();
6630
6986
  this.onDidActivePanelChange = this._onDidActivePanelChange.event;
6987
+ this._onDidMovePanel = new Emitter();
6631
6988
  this._floatingGroups = [];
6632
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;
6633
6998
  const gready = document.createElement('div');
6634
6999
  gready.className = 'dv-overlay-render-container';
6635
7000
  this.gridview.element.appendChild(gready);
6636
7001
  this.overlayRenderContainer = new OverlayRenderContainer(gready);
6637
7002
  toggleClass(this.gridview.element, 'dv-dockview', true);
6638
7003
  toggleClass(this.element, 'dv-debug', !!options.debug);
6639
- 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)(() => {
6640
7017
  this.updateWatermark();
6641
7018
  }), exports.DockviewEvent.any(this.onDidAddPanel, this.onDidRemovePanel, this.onDidActivePanelChange)(() => {
6642
7019
  this._bufferOnDidLayoutChange.fire();
@@ -6647,7 +7024,7 @@ class DockviewComponent extends BaseGrid {
6647
7024
  }
6648
7025
  // iterate over a copy of the array since .dispose() mutates the original array
6649
7026
  for (const group of [...this._popoutGroups]) {
6650
- group.dispose();
7027
+ group.disposable.dispose();
6651
7028
  }
6652
7029
  }));
6653
7030
  this._options = options;
@@ -6693,7 +7070,7 @@ class DockviewComponent extends BaseGrid {
6693
7070
  return this.options.showDndOverlay({
6694
7071
  nativeEvent: event,
6695
7072
  position: position,
6696
- target: exports.DockviewDropTargets.Edge,
7073
+ target: 'edge',
6697
7074
  getData: getPanelData,
6698
7075
  });
6699
7076
  }
@@ -6704,86 +7081,249 @@ class DockviewComponent extends BaseGrid {
6704
7081
  });
6705
7082
  this.addDisposables(this._rootDropTarget.onDrop((event) => {
6706
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
+ }
6707
7097
  const data = getPanelData();
6708
7098
  if (data) {
6709
- 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
+ });
6710
7109
  }
6711
7110
  else {
6712
- 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
+ }));
6713
7119
  }
6714
7120
  }), this._rootDropTarget);
6715
7121
  this._api = new DockviewApi(this);
6716
7122
  this.updateWatermark();
6717
7123
  }
6718
- addPopoutGroup(item, options) {
6719
- var _a;
6720
- let group;
6721
- let box = options === null || options === void 0 ? void 0 : options.position;
6722
- if (item instanceof DockviewPanel) {
6723
- group = this.createGroup();
6724
- this.removePanel(item, {
6725
- removeEmptyGroup: true,
6726
- skipDispose: true,
6727
- });
6728
- group.model.openPanel(item);
6729
- if (!box) {
6730
- 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;
6731
7168
  }
6732
- }
6733
- else {
6734
- group = item;
6735
- if (!box) {
6736
- box = group.element.getBoundingClientRect();
7169
+ if (popoutContainer === null) {
7170
+ popoutWindowDisposable.dispose();
7171
+ return;
6737
7172
  }
6738
- const skip = typeof (options === null || options === void 0 ? void 0 : options.skipRemoveGroup) === 'boolean' &&
6739
- options.skipRemoveGroup;
6740
- if (!skip) {
6741
- this.doRemoveGroup(item, { skipDispose: true });
6742
- }
6743
- }
6744
- const theme = getTheme(this.gridview.element);
6745
- const popoutWindow = new DockviewPopoutGroupPanel(`${this.id}-${group.id}`, // globally unique within dockview
6746
- group, {
6747
- className: theme !== null && theme !== void 0 ? theme : '',
6748
- popoutUrl: (_a = options === null || options === void 0 ? void 0 : options.popoutUrl) !== null && _a !== void 0 ? _a : '/popout.html',
6749
- box: {
6750
- left: window.screenX + box.left,
6751
- top: window.screenY + box.top,
6752
- width: box.width,
6753
- height: box.height,
6754
- },
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);
6755
7279
  });
6756
- popoutWindow.addDisposables({
6757
- dispose: () => {
6758
- remove(this._popoutGroups, popoutWindow);
6759
- this.updateWatermark();
6760
- },
6761
- }, popoutWindow.window.onDidClose(() => {
6762
- this.doAddGroup(group, [0]);
6763
- }));
6764
- this._popoutGroups.push(popoutWindow);
6765
- this.updateWatermark();
6766
7280
  }
6767
7281
  addFloatingGroup(item, coord, options) {
6768
- var _a, _b, _c, _d, _e, _f;
7282
+ var _a, _b, _c, _d, _e, _f, _g;
6769
7283
  let group;
6770
7284
  if (item instanceof DockviewPanel) {
6771
7285
  group = this.createGroup();
6772
- this.removePanel(item, {
7286
+ this._onDidAddGroup.fire(group);
7287
+ this.movingLock(() => this.removePanel(item, {
6773
7288
  removeEmptyGroup: true,
6774
7289
  skipDispose: true,
6775
- });
6776
- group.model.openPanel(item);
7290
+ skipSetActiveGroup: true,
7291
+ }));
7292
+ group.model.openPanel(item, { skipSetGroupActive: true });
6777
7293
  }
6778
7294
  else {
6779
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;
6780
7300
  const skip = typeof (options === null || options === void 0 ? void 0 : options.skipRemoveGroup) === 'boolean' &&
6781
7301
  options.skipRemoveGroup;
6782
7302
  if (!skip) {
6783
- 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
+ }
6784
7324
  }
6785
7325
  }
6786
- group.model.location = 'floating';
7326
+ group.model.location = { type: 'floating' };
6787
7327
  const overlayLeft = typeof (coord === null || coord === void 0 ? void 0 : coord.x) === 'number'
6788
7328
  ? Math.max(coord.x, 0)
6789
7329
  : DEFAULT_FLOATING_GROUP_POSITION.left;
@@ -6793,16 +7333,16 @@ class DockviewComponent extends BaseGrid {
6793
7333
  const overlay = new Overlay({
6794
7334
  container: this.gridview.element,
6795
7335
  content: group.element,
6796
- height: (_a = coord === null || coord === void 0 ? void 0 : coord.height) !== null && _a !== void 0 ? _a : 300,
6797
- 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,
6798
7338
  left: overlayLeft,
6799
7339
  top: overlayTop,
6800
7340
  minimumInViewportWidth: this.options.floatingGroupBounds === 'boundedWithinViewport'
6801
7341
  ? undefined
6802
- : (_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,
6803
7343
  minimumInViewportHeight: this.options.floatingGroupBounds === 'boundedWithinViewport'
6804
7344
  ? undefined
6805
- : (_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,
6806
7346
  });
6807
7347
  const el = group.element.querySelector('.void-container');
6808
7348
  if (!el) {
@@ -6833,12 +7373,15 @@ class DockviewComponent extends BaseGrid {
6833
7373
  }), {
6834
7374
  dispose: () => {
6835
7375
  disposable.dispose();
6836
- group.model.location = 'grid';
7376
+ group.model.location = { type: 'grid' };
6837
7377
  remove(this._floatingGroups, floatingGroupPanel);
6838
7378
  this.updateWatermark();
6839
7379
  },
6840
7380
  });
6841
7381
  this._floatingGroups.push(floatingGroupPanel);
7382
+ if (!(options === null || options === void 0 ? void 0 : options.skipActiveGroup)) {
7383
+ this.doSetGroupAndPanelActive(group);
7384
+ }
6842
7385
  this.updateWatermark();
6843
7386
  }
6844
7387
  orthogonalize(position) {
@@ -6928,8 +7471,8 @@ class DockviewComponent extends BaseGrid {
6928
7471
  return this.panels.find((panel) => panel.id === id);
6929
7472
  }
6930
7473
  setActivePanel(panel) {
6931
- this.doSetGroupActive(panel.group);
6932
7474
  panel.group.model.openPanel(panel);
7475
+ this.doSetGroupAndPanelActive(panel.group);
6933
7476
  }
6934
7477
  moveToNext(options = {}) {
6935
7478
  var _a;
@@ -6990,7 +7533,8 @@ class DockviewComponent extends BaseGrid {
6990
7533
  });
6991
7534
  const popoutGroups = this._popoutGroups.map((group) => {
6992
7535
  return {
6993
- data: group.group.toJSON(),
7536
+ data: group.popoutGroup.toJSON(),
7537
+ gridReferenceGroup: group.referenceGroup,
6994
7538
  position: group.window.dimensions(),
6995
7539
  };
6996
7540
  });
@@ -7008,7 +7552,7 @@ class DockviewComponent extends BaseGrid {
7008
7552
  return result;
7009
7553
  }
7010
7554
  fromJSON(data) {
7011
- var _a, _b;
7555
+ var _a, _b, _c;
7012
7556
  this.clear();
7013
7557
  if (typeof data !== 'object' || data === null) {
7014
7558
  throw new Error('serialized layout must be a non-null object');
@@ -7047,7 +7591,7 @@ class DockviewComponent extends BaseGrid {
7047
7591
  const isActive = typeof activeView === 'string' &&
7048
7592
  activeView === panel.id;
7049
7593
  group.model.openPanel(panel, {
7050
- skipSetPanelActive: !isActive,
7594
+ skipSetActive: !isActive,
7051
7595
  skipSetGroupActive: true,
7052
7596
  });
7053
7597
  }
@@ -7077,11 +7621,16 @@ class DockviewComponent extends BaseGrid {
7077
7621
  }
7078
7622
  const serializedPopoutGroups = (_b = data.popoutGroups) !== null && _b !== void 0 ? _b : [];
7079
7623
  for (const serializedPopoutGroup of serializedPopoutGroups) {
7080
- const { data, position } = serializedPopoutGroup;
7624
+ const { data, position, gridReferenceGroup } = serializedPopoutGroup;
7081
7625
  const group = createGroupFromSerializedState(data);
7082
- this.addPopoutGroup(group, {
7626
+ this.addPopoutGroup((_c = (gridReferenceGroup
7627
+ ? this.getPanel(gridReferenceGroup)
7628
+ : undefined)) !== null && _c !== void 0 ? _c : group, {
7083
7629
  skipRemoveGroup: true,
7084
7630
  position: position !== null && position !== void 0 ? position : undefined,
7631
+ overridePopoutGroup: gridReferenceGroup
7632
+ ? group
7633
+ : undefined,
7085
7634
  });
7086
7635
  }
7087
7636
  for (const floatingGroup of this._floatingGroups) {
@@ -7128,12 +7677,13 @@ class DockviewComponent extends BaseGrid {
7128
7677
  */
7129
7678
  throw err;
7130
7679
  }
7680
+ this.updateWatermark();
7131
7681
  this._onDidLayoutFromJSON.fire();
7132
7682
  }
7133
7683
  clear() {
7134
7684
  const groups = Array.from(this._groups.values()).map((_) => _.value);
7135
7685
  const hasActiveGroup = !!this.activeGroup;
7136
- const hasActivePanel = !!this.activePanel;
7686
+ !!this.activePanel;
7137
7687
  for (const group of groups) {
7138
7688
  // remove the group will automatically remove the panels
7139
7689
  this.removeGroup(group, { skipActive: true });
@@ -7141,9 +7691,6 @@ class DockviewComponent extends BaseGrid {
7141
7691
  if (hasActiveGroup) {
7142
7692
  this.doSetGroupAndPanelActive(undefined);
7143
7693
  }
7144
- if (hasActivePanel) {
7145
- this._onDidActivePanelChange.fire(undefined);
7146
- }
7147
7694
  this.gridview.clear();
7148
7695
  }
7149
7696
  closeAllGroups() {
@@ -7184,6 +7731,7 @@ class DockviewComponent extends BaseGrid {
7184
7731
  const group = this.orthogonalize(directionToPosition(options.position.direction));
7185
7732
  const panel = this.createPanel(options, group);
7186
7733
  group.model.openPanel(panel);
7734
+ this.doSetGroupAndPanelActive(group);
7187
7735
  return panel;
7188
7736
  }
7189
7737
  }
@@ -7195,6 +7743,7 @@ class DockviewComponent extends BaseGrid {
7195
7743
  const target = toTarget(((_b = options.position) === null || _b === void 0 ? void 0 : _b.direction) || 'within');
7196
7744
  if (options.floating) {
7197
7745
  const group = this.createGroup();
7746
+ this._onDidAddGroup.fire(group);
7198
7747
  const o = typeof options.floating === 'object' &&
7199
7748
  options.floating !== null
7200
7749
  ? options.floating
@@ -7202,16 +7751,16 @@ class DockviewComponent extends BaseGrid {
7202
7751
  this.addFloatingGroup(group, o, {
7203
7752
  inDragMode: false,
7204
7753
  skipRemoveGroup: true,
7754
+ skipActiveGroup: true,
7205
7755
  });
7206
- this._onDidAddGroup.fire(group);
7207
7756
  panel = this.createPanel(options, group);
7208
7757
  group.model.openPanel(panel);
7209
- this.doSetGroupAndPanelActive(group);
7210
7758
  }
7211
- else if (referenceGroup.api.location === 'floating' ||
7759
+ else if (referenceGroup.api.location.type === 'floating' ||
7212
7760
  target === 'center') {
7213
7761
  panel = this.createPanel(options, referenceGroup);
7214
7762
  referenceGroup.model.openPanel(panel);
7763
+ this.doSetGroupAndPanelActive(referenceGroup);
7215
7764
  }
7216
7765
  else {
7217
7766
  const location = getGridLocation(referenceGroup.element);
@@ -7219,10 +7768,12 @@ class DockviewComponent extends BaseGrid {
7219
7768
  const group = this.createGroupAtLocation(relativeLocation);
7220
7769
  panel = this.createPanel(options, group);
7221
7770
  group.model.openPanel(panel);
7771
+ this.doSetGroupAndPanelActive(group);
7222
7772
  }
7223
7773
  }
7224
7774
  else if (options.floating) {
7225
7775
  const group = this.createGroup();
7776
+ this._onDidAddGroup.fire(group);
7226
7777
  const o = typeof options.floating === 'object' &&
7227
7778
  options.floating !== null
7228
7779
  ? options.floating
@@ -7230,16 +7781,16 @@ class DockviewComponent extends BaseGrid {
7230
7781
  this.addFloatingGroup(group, o, {
7231
7782
  inDragMode: false,
7232
7783
  skipRemoveGroup: true,
7784
+ skipActiveGroup: true,
7233
7785
  });
7234
- this._onDidAddGroup.fire(group);
7235
7786
  panel = this.createPanel(options, group);
7236
7787
  group.model.openPanel(panel);
7237
- this.doSetGroupAndPanelActive(group);
7238
7788
  }
7239
7789
  else {
7240
7790
  const group = this.createGroupAtLocation();
7241
7791
  panel = this.createPanel(options, group);
7242
7792
  group.model.openPanel(panel);
7793
+ this.doSetGroupAndPanelActive(group);
7243
7794
  }
7244
7795
  return panel;
7245
7796
  }
@@ -7251,13 +7802,15 @@ class DockviewComponent extends BaseGrid {
7251
7802
  if (!group) {
7252
7803
  throw new Error(`cannot remove panel ${panel.id}. it's missing a group.`);
7253
7804
  }
7254
- group.model.removePanel(panel);
7805
+ group.model.removePanel(panel, {
7806
+ skipSetActiveGroup: options.skipSetActiveGroup,
7807
+ });
7255
7808
  if (!options.skipDispose) {
7256
- this.overlayRenderContainer.detatch(panel);
7809
+ panel.group.model.renderContainer.detatch(panel);
7257
7810
  panel.dispose();
7258
7811
  }
7259
7812
  if (group.size === 0 && options.removeEmptyGroup) {
7260
- this.removeGroup(group);
7813
+ this.removeGroup(group, { skipActive: options.skipSetActiveGroup });
7261
7814
  }
7262
7815
  }
7263
7816
  createWatermarkComponent() {
@@ -7270,7 +7823,7 @@ class DockviewComponent extends BaseGrid {
7270
7823
  }
7271
7824
  updateWatermark() {
7272
7825
  var _a, _b;
7273
- 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) {
7274
7827
  if (!this.watermark) {
7275
7828
  this.watermark = this.createWatermarkComponent();
7276
7829
  this.watermark.init({
@@ -7290,7 +7843,7 @@ class DockviewComponent extends BaseGrid {
7290
7843
  }
7291
7844
  addGroup(options) {
7292
7845
  var _a;
7293
- const group = this.createGroup();
7846
+ const group = this.createGroup(options);
7294
7847
  if (options) {
7295
7848
  let referenceGroup;
7296
7849
  if (isGroupOptionsWithPanel(options)) {
@@ -7316,36 +7869,42 @@ class DockviewComponent extends BaseGrid {
7316
7869
  }
7317
7870
  else {
7318
7871
  const group = this.orthogonalize(directionToPosition(options.direction));
7872
+ if (!options.skipSetActive) {
7873
+ this.doSetGroupAndPanelActive(group);
7874
+ }
7319
7875
  return group;
7320
7876
  }
7321
7877
  const target = toTarget(options.direction || 'within');
7322
7878
  const location = getGridLocation(referenceGroup.element);
7323
7879
  const relativeLocation = getRelativeLocation(this.gridview.orientation, location, target);
7324
7880
  this.doAddGroup(group, relativeLocation);
7881
+ if (!options.skipSetActive) {
7882
+ this.doSetGroupAndPanelActive(group);
7883
+ }
7325
7884
  return group;
7326
7885
  }
7327
7886
  else {
7328
7887
  this.doAddGroup(group);
7888
+ this.doSetGroupAndPanelActive(group);
7329
7889
  return group;
7330
7890
  }
7331
7891
  }
7332
7892
  removeGroup(group, options) {
7893
+ this.doRemoveGroup(group, options);
7894
+ }
7895
+ doRemoveGroup(group, options) {
7333
7896
  var _a;
7334
7897
  const panels = [...group.panels]; // reassign since group panels will mutate
7335
- for (const panel of panels) {
7336
- this.removePanel(panel, {
7337
- removeEmptyGroup: false,
7338
- skipDispose: (_a = options === null || options === void 0 ? void 0 : options.skipDispose) !== null && _a !== void 0 ? _a : false,
7339
- });
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
+ }
7340
7905
  }
7341
7906
  const activePanel = this.activePanel;
7342
- this.doRemoveGroup(group, options);
7343
- if (this.activePanel !== activePanel) {
7344
- this._onDidActivePanelChange.fire(this.activePanel);
7345
- }
7346
- }
7347
- doRemoveGroup(group, options) {
7348
- if (group.api.location === 'floating') {
7907
+ if (group.api.location.type === 'floating') {
7349
7908
  const floatingGroup = this._floatingGroups.find((_) => _.group === group);
7350
7909
  if (floatingGroup) {
7351
7910
  if (!(options === null || options === void 0 ? void 0 : options.skipDispose)) {
@@ -7357,60 +7916,124 @@ class DockviewComponent extends BaseGrid {
7357
7916
  floatingGroup.dispose();
7358
7917
  if (!(options === null || options === void 0 ? void 0 : options.skipActive) && this._activeGroup === group) {
7359
7918
  const groups = Array.from(this._groups.values());
7360
- this.doSetGroupActive(groups.length > 0 ? groups[0].value : undefined);
7919
+ this.doSetGroupAndPanelActive(groups.length > 0 ? groups[0].value : undefined);
7361
7920
  }
7362
7921
  return floatingGroup.group;
7363
7922
  }
7364
7923
  throw new Error('failed to find floating group');
7365
7924
  }
7366
- if (group.api.location === 'popout') {
7367
- const selectedGroup = this._popoutGroups.find((_) => _.group === group);
7925
+ if (group.api.location.type === 'popout') {
7926
+ const selectedGroup = this._popoutGroups.find((_) => _.popoutGroup === group);
7368
7927
  if (selectedGroup) {
7369
7928
  if (!(options === null || options === void 0 ? void 0 : options.skipDispose)) {
7370
- 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();
7371
7938
  this._groups.delete(group.id);
7372
7939
  this._onDidRemoveGroup.fire(group);
7373
7940
  }
7374
- 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
+ }
7375
7946
  if (!(options === null || options === void 0 ? void 0 : options.skipActive) && this._activeGroup === group) {
7376
7947
  const groups = Array.from(this._groups.values());
7377
- this.doSetGroupActive(groups.length > 0 ? groups[0].value : undefined);
7948
+ this.doSetGroupAndPanelActive(groups.length > 0 ? groups[0].value : undefined);
7378
7949
  }
7379
- return selectedGroup.group;
7950
+ this.updateWatermark();
7951
+ return selectedGroup.popoutGroup;
7380
7952
  }
7381
7953
  throw new Error('failed to find popout group');
7382
7954
  }
7383
- 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;
7384
7962
  }
7385
- moveGroupOrPanel(destinationGroup, sourceGroupId, sourceItemId, destinationTarget, destinationIndex) {
7386
- 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;
7387
7980
  const sourceGroup = sourceGroupId
7388
7981
  ? (_a = this._groups.get(sourceGroupId)) === null || _a === void 0 ? void 0 : _a.value
7389
7982
  : undefined;
7983
+ if (!sourceGroup) {
7984
+ throw new Error(`Failed to find group id ${sourceGroupId}`);
7985
+ }
7390
7986
  if (sourceItemId === undefined) {
7391
- if (sourceGroup) {
7392
- this.moveGroup(sourceGroup, destinationGroup, destinationTarget);
7393
- }
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
+ });
7394
7997
  return;
7395
7998
  }
7396
7999
  if (!destinationTarget || destinationTarget === 'center') {
7397
- 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);
7398
- 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) {
7399
8008
  throw new Error(`No panel with id ${sourceItemId}`);
7400
8009
  }
7401
- if ((sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.size) === 0) {
7402
- 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 });
7403
8013
  }
7404
- destinationGroup.model.openPanel(groupItem, {
8014
+ this.movingLock(() => destinationGroup.model.openPanel(removedPanel, {
7405
8015
  index: destinationIndex,
8016
+ skipSetGroupActive: true,
8017
+ }));
8018
+ this.doSetGroupAndPanelActive(destinationGroup);
8019
+ this._onDidMovePanel.fire({
8020
+ panel: removedPanel,
7406
8021
  });
7407
8022
  }
7408
8023
  else {
8024
+ /**
8025
+ * Dropping a panel to the extremities of a group which will place that panel
8026
+ * into an adjacent group
8027
+ */
7409
8028
  const referenceLocation = getGridLocation(destinationGroup.element);
7410
8029
  const targetLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, destinationTarget);
7411
- 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
+ */
7412
8035
  const [targetParentLocation, to] = tail(targetLocation);
7413
- if (sourceGroup.api.location === 'grid') {
8036
+ if (sourceGroup.api.location.type === 'grid') {
7414
8037
  const sourceLocation = getGridLocation(sourceGroup.element);
7415
8038
  const [sourceParentLocation, from] = tail(sourceLocation);
7416
8039
  if (sequenceEquals(sourceParentLocation, targetParentLocation)) {
@@ -7418,78 +8041,123 @@ class DockviewComponent extends BaseGrid {
7418
8041
  // if a group has one tab - we are essentially moving the 'group'
7419
8042
  // which is equivalent to swapping two views in this case
7420
8043
  this.gridview.moveView(sourceParentLocation, from, to);
8044
+ return;
7421
8045
  }
7422
8046
  }
7423
8047
  // source group will become empty so delete the group
7424
- const targetGroup = this.doRemoveGroup(sourceGroup, {
8048
+ const targetGroup = this.movingLock(() => this.doRemoveGroup(sourceGroup, {
7425
8049
  skipActive: true,
7426
8050
  skipDispose: true,
7427
- });
8051
+ }));
7428
8052
  // after deleting the group we need to re-evaulate the ref location
7429
8053
  const updatedReferenceLocation = getGridLocation(destinationGroup.element);
7430
8054
  const location = getRelativeLocation(this.gridview.orientation, updatedReferenceLocation, destinationTarget);
7431
- this.doAddGroup(targetGroup, location);
8055
+ this.movingLock(() => this.doAddGroup(targetGroup, location));
8056
+ this.doSetGroupAndPanelActive(targetGroup);
7432
8057
  }
7433
8058
  else {
7434
- 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);
7435
- 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) {
7436
8068
  throw new Error(`No panel with id ${sourceItemId}`);
7437
8069
  }
7438
8070
  const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, destinationTarget);
7439
8071
  const group = this.createGroupAtLocation(dropLocation);
7440
- group.model.openPanel(groupItem);
8072
+ this.movingLock(() => group.model.openPanel(removedPanel, {
8073
+ skipSetGroupActive: true,
8074
+ }));
8075
+ this.doSetGroupAndPanelActive(group);
7441
8076
  }
7442
8077
  }
7443
8078
  }
7444
- moveGroup(sourceGroup, referenceGroup, target) {
7445
- if (sourceGroup) {
7446
- if (!target || target === 'center') {
7447
- const activePanel = sourceGroup.activePanel;
7448
- const panels = [...sourceGroup.panels].map((p) => sourceGroup.model.removePanel(p.id));
7449
- if ((sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.size) === 0) {
7450
- this.doRemoveGroup(sourceGroup);
7451
- }
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(() => {
7452
8092
  for (const panel of panels) {
7453
- referenceGroup.model.openPanel(panel, {
7454
- skipSetPanelActive: panel !== activePanel,
8093
+ to.model.openPanel(panel, {
8094
+ skipSetActive: panel !== activePanel,
8095
+ skipSetGroupActive: true,
7455
8096
  });
7456
8097
  }
7457
- }
7458
- else {
7459
- switch (sourceGroup.api.location) {
7460
- case 'grid':
7461
- this.gridview.removeView(getGridLocation(sourceGroup.element));
7462
- break;
7463
- case 'floating': {
7464
- const selectedFloatingGroup = this._floatingGroups.find((x) => x.group === sourceGroup);
7465
- if (!selectedFloatingGroup) {
7466
- throw new Error('failed to find floating group');
7467
- }
7468
- selectedFloatingGroup.dispose();
7469
- 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');
7470
8113
  }
7471
- case 'popout': {
7472
- const selectedPopoutGroup = this._popoutGroups.find((x) => x.group === sourceGroup);
7473
- if (!selectedPopoutGroup) {
7474
- throw new Error('failed to find popout group');
7475
- }
7476
- 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');
7477
8121
  }
8122
+ selectedPopoutGroup.disposable.dispose();
7478
8123
  }
7479
- const referenceLocation = getGridLocation(referenceGroup.element);
7480
- const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, target);
7481
- this.gridview.addView(sourceGroup, exports.Sizing.Distribute, dropLocation);
7482
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
+ });
7483
8131
  }
7484
8132
  }
7485
- doSetGroupAndPanelActive(group, skipFocus) {
7486
- 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);
7487
8143
  const activePanel = this.activePanel;
7488
- super.doSetGroupActive(group, skipFocus);
7489
- if (((_a = this._activeGroup) === null || _a === void 0 ? void 0 : _a.activePanel) !== activePanel) {
7490
- 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);
7491
8152
  }
7492
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
+ }
7493
8161
  createGroup(options) {
7494
8162
  if (!options) {
7495
8163
  options = {};
@@ -7506,7 +8174,7 @@ class DockviewComponent extends BaseGrid {
7506
8174
  }
7507
8175
  }
7508
8176
  const view = new DockviewGroupPanel(this, id, options);
7509
- view.init({ params: {}, accessor: null }); // required to initialized .part and allow for correct disposal of group
8177
+ view.init({ params: {}, accessor: this });
7510
8178
  if (!this._groups.has(view.id)) {
7511
8179
  const disposable = new CompositeDisposable(view.model.onTabDragStart((event) => {
7512
8180
  this._onWillDragPanel.fire(event);
@@ -7514,20 +8182,48 @@ class DockviewComponent extends BaseGrid {
7514
8182
  this._onWillDragGroup.fire(event);
7515
8183
  }), view.model.onMove((event) => {
7516
8184
  const { groupId, itemId, target, index } = event;
7517
- 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
+ });
7518
8193
  }), view.model.onDidDrop((event) => {
7519
- 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);
7520
8203
  }), view.model.onDidAddPanel((event) => {
8204
+ if (this._moving) {
8205
+ return;
8206
+ }
7521
8207
  this._onDidAddPanel.fire(event.panel);
7522
8208
  }), view.model.onDidRemovePanel((event) => {
8209
+ if (this._moving) {
8210
+ return;
8211
+ }
7523
8212
  this._onDidRemovePanel.fire(event.panel);
7524
8213
  }), view.model.onDidActivePanelChange((event) => {
7525
- 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
+ }
7526
8223
  }));
7527
8224
  this._groups.set(view.id, { value: view, disposable });
7528
8225
  }
7529
- // TODO: must be called after the above listeners have been setup,
7530
- // not an ideal pattern
8226
+ // TODO: must be called after the above listeners have been setup, not an ideal pattern
7531
8227
  view.initialize();
7532
8228
  return view;
7533
8229
  }
@@ -7580,7 +8276,20 @@ class GridviewComponent extends BaseGrid {
7580
8276
  });
7581
8277
  this._onDidLayoutfromJSON = new Emitter();
7582
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;
7583
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
+ }));
7584
8293
  if (!this.options.components) {
7585
8294
  this.options.components = {};
7586
8295
  }
@@ -7755,6 +8464,7 @@ class GridviewComponent extends BaseGrid {
7755
8464
  });
7756
8465
  this.registerPanel(view);
7757
8466
  this.doAddGroup(view, relativeLocation, options.size);
8467
+ this.doSetGroupActive(view);
7758
8468
  return view;
7759
8469
  }
7760
8470
  registerPanel(panel) {
@@ -8440,10 +9150,10 @@ class SplitviewPanel extends BasePanelView {
8440
9150
  this._onDidChange = new Emitter();
8441
9151
  this.onDidChange = this._onDidChange.event;
8442
9152
  this.api.initialize(this);
8443
- this.addDisposables(this._onDidChange, this.api.onVisibilityChange((event) => {
8444
- const { isVisible } = event;
9153
+ this.addDisposables(this._onDidChange, this.api.onDidHiddenChange((event) => {
9154
+ const { isHidden } = event;
8445
9155
  const { accessor } = this._params;
8446
- accessor.setVisible(this, isVisible);
9156
+ accessor.setVisible(this, !isHidden);
8447
9157
  }), this.api.onActiveChange(() => {
8448
9158
  const { accessor } = this._params;
8449
9159
  accessor.setActive(this);
@@ -8565,13 +9275,13 @@ class ReactPart {
8565
9275
  if (this.disposed) {
8566
9276
  throw new Error('invalid operation: resource is already disposed');
8567
9277
  }
8568
- if (typeof this.component !== 'function') {
9278
+ if (!isReactComponent(this.component)) {
8569
9279
  /**
8570
9280
  * we know this isn't a React.FunctionComponent so throw an error here.
8571
- * if we do not intercept this the React library will throw a very obsure error
8572
- * 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.
8573
9283
  */
8574
- 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');
8575
9285
  }
8576
9286
  const bridgeComponent = React__namespace.createElement(React__namespace.forwardRef(ReactComponentBridge), {
8577
9287
  component: this
@@ -8623,9 +9333,13 @@ const usePortalsLifecycle = () => {
8623
9333
  }, []);
8624
9334
  return [portals, addPortal];
8625
9335
  };
8626
- // it does the job...
8627
- function isReactElement(element) {
8628
- 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 */);
8629
9343
  }
8630
9344
 
8631
9345
  class ReactPanelContentPart {
@@ -8885,6 +9599,8 @@ const DockviewReact = React__namespace.forwardRef((props, ref) => {
8885
9599
  defaultRenderer: props.defaultRenderer,
8886
9600
  debug: props.debug,
8887
9601
  rootOverlayModel: props.rootOverlayModel,
9602
+ locked: props.locked,
9603
+ disableDnd: props.disableDnd,
8888
9604
  });
8889
9605
  const { clientWidth, clientHeight } = domRef.current;
8890
9606
  dockview.layout(clientWidth, clientHeight);
@@ -8896,6 +9612,20 @@ const DockviewReact = React__namespace.forwardRef((props, ref) => {
8896
9612
  dockview.dispose();
8897
9613
  };
8898
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]);
8899
9629
  React__namespace.useEffect(() => {
8900
9630
  if (!dockviewRef.current) {
8901
9631
  return () => {
@@ -8911,6 +9641,21 @@ const DockviewReact = React__namespace.forwardRef((props, ref) => {
8911
9641
  disposable.dispose();
8912
9642
  };
8913
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]);
8914
9659
  React__namespace.useEffect(() => {
8915
9660
  if (!dockviewRef.current) {
8916
9661
  return;
@@ -9153,7 +9898,9 @@ class ReactGridPanelView extends GridviewPanel {
9153
9898
  return new ReactPart(this.element, this.reactPortalStore, this.reactComponent, {
9154
9899
  params: (_b = (_a = this._params) === null || _a === void 0 ? void 0 : _a.params) !== null && _b !== void 0 ? _b : {},
9155
9900
  api: this.api,
9156
- containerApi: new GridviewApi(this._params.accessor),
9901
+ // TODO: fix casting hack
9902
+ containerApi: new GridviewApi(this._params
9903
+ .accessor),
9157
9904
  });
9158
9905
  }
9159
9906
  }
@@ -9336,12 +10083,14 @@ exports.DockviewApi = DockviewApi;
9336
10083
  exports.DockviewComponent = DockviewComponent;
9337
10084
  exports.DockviewCompositeDisposable = CompositeDisposable;
9338
10085
  exports.DockviewDefaultTab = DockviewDefaultTab;
10086
+ exports.DockviewDidDropEvent = DockviewDidDropEvent;
9339
10087
  exports.DockviewEmitter = Emitter;
9340
10088
  exports.DockviewGroupPanel = DockviewGroupPanel;
9341
10089
  exports.DockviewGroupPanelModel = DockviewGroupPanelModel;
9342
10090
  exports.DockviewMutableDisposable = MutableDisposable;
9343
10091
  exports.DockviewPanel = DockviewPanel;
9344
10092
  exports.DockviewReact = DockviewReact;
10093
+ exports.DockviewWillDropEvent = DockviewWillDropEvent;
9345
10094
  exports.DraggablePaneviewPanel = DraggablePaneviewPanel;
9346
10095
  exports.Gridview = Gridview;
9347
10096
  exports.GridviewApi = GridviewApi;
@@ -9365,6 +10114,7 @@ exports.SplitviewComponent = SplitviewComponent;
9365
10114
  exports.SplitviewPanel = SplitviewPanel;
9366
10115
  exports.SplitviewReact = SplitviewReact;
9367
10116
  exports.Tab = Tab;
10117
+ exports.WillShowOverlayLocationEvent = WillShowOverlayLocationEvent;
9368
10118
  exports.createComponent = createComponent;
9369
10119
  exports.directionToPosition = directionToPosition;
9370
10120
  exports.getDirectionOrientation = getDirectionOrientation;
@@ -9379,7 +10129,7 @@ exports.isGroupOptionsWithGroup = isGroupOptionsWithGroup;
9379
10129
  exports.isGroupOptionsWithPanel = isGroupOptionsWithPanel;
9380
10130
  exports.isPanelOptionsWithGroup = isPanelOptionsWithGroup;
9381
10131
  exports.isPanelOptionsWithPanel = isPanelOptionsWithPanel;
9382
- exports.isReactElement = isReactElement;
10132
+ exports.isReactComponent = isReactComponent;
9383
10133
  exports.orthogonal = orthogonal;
9384
10134
  exports.positionToDirection = positionToDirection;
9385
10135
  exports.toTarget = toTarget;