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