dockview 1.9.2 → 1.10.0

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