dockview 1.9.1 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/dist/cjs/dockview/defaultTab.d.ts +0 -1
  2. package/dist/cjs/dockview/defaultTab.js +0 -1
  3. package/dist/cjs/dockview/dockview.d.ts +5 -3
  4. package/dist/cjs/dockview/dockview.js +31 -1
  5. package/dist/cjs/dockview/headerActionsRenderer.d.ts +0 -1
  6. package/dist/cjs/dockview/headerActionsRenderer.js +0 -1
  7. package/dist/cjs/dockview/reactContentPart.d.ts +0 -1
  8. package/dist/cjs/dockview/reactContentPart.js +0 -1
  9. package/dist/cjs/dockview/reactHeaderPart.d.ts +0 -1
  10. package/dist/cjs/dockview/reactHeaderPart.js +0 -1
  11. package/dist/cjs/dockview/reactWatermarkPart.d.ts +0 -1
  12. package/dist/cjs/dockview/reactWatermarkPart.js +0 -1
  13. package/dist/cjs/gridview/gridview.d.ts +0 -1
  14. package/dist/cjs/gridview/gridview.js +0 -1
  15. package/dist/cjs/gridview/view.d.ts +0 -1
  16. package/dist/cjs/gridview/view.js +3 -2
  17. package/dist/cjs/index.d.ts +0 -1
  18. package/dist/cjs/index.js +0 -1
  19. package/dist/cjs/paneview/paneview.d.ts +0 -1
  20. package/dist/cjs/paneview/paneview.js +0 -1
  21. package/dist/cjs/paneview/view.d.ts +0 -1
  22. package/dist/cjs/paneview/view.js +0 -1
  23. package/dist/cjs/react.d.ts +1 -2
  24. package/dist/cjs/react.js +13 -10
  25. package/dist/cjs/splitview/splitview.d.ts +0 -1
  26. package/dist/cjs/splitview/splitview.js +0 -1
  27. package/dist/cjs/splitview/view.d.ts +0 -1
  28. package/dist/cjs/splitview/view.js +0 -1
  29. package/dist/cjs/svg.d.ts +0 -1
  30. package/dist/cjs/svg.js +0 -1
  31. package/dist/cjs/types.d.ts +0 -1
  32. package/dist/cjs/types.js +0 -1
  33. package/dist/dockview.amd.js +1287 -537
  34. package/dist/dockview.amd.js.map +1 -1
  35. package/dist/dockview.amd.min.js +2 -2
  36. package/dist/dockview.amd.min.js.map +1 -1
  37. package/dist/dockview.amd.min.noStyle.js +2 -2
  38. package/dist/dockview.amd.min.noStyle.js.map +1 -1
  39. package/dist/dockview.amd.noStyle.js +1287 -537
  40. package/dist/dockview.amd.noStyle.js.map +1 -1
  41. package/dist/dockview.cjs.js +1287 -537
  42. package/dist/dockview.cjs.js.map +1 -1
  43. package/dist/dockview.esm.js +1284 -537
  44. package/dist/dockview.esm.js.map +1 -1
  45. package/dist/dockview.esm.min.js +2 -2
  46. package/dist/dockview.esm.min.js.map +1 -1
  47. package/dist/dockview.js +1287 -537
  48. package/dist/dockview.js.map +1 -1
  49. package/dist/dockview.min.js +2 -2
  50. package/dist/dockview.min.js.map +1 -1
  51. package/dist/dockview.min.noStyle.js +2 -2
  52. package/dist/dockview.min.noStyle.js.map +1 -1
  53. package/dist/dockview.noStyle.js +1287 -537
  54. package/dist/dockview.noStyle.js.map +1 -1
  55. package/dist/esm/dockview/defaultTab.d.ts +0 -1
  56. package/dist/esm/dockview/defaultTab.js +0 -1
  57. package/dist/esm/dockview/dockview.d.ts +5 -3
  58. package/dist/esm/dockview/dockview.js +31 -1
  59. package/dist/esm/dockview/headerActionsRenderer.d.ts +0 -1
  60. package/dist/esm/dockview/headerActionsRenderer.js +0 -1
  61. package/dist/esm/dockview/reactContentPart.d.ts +0 -1
  62. package/dist/esm/dockview/reactContentPart.js +0 -1
  63. package/dist/esm/dockview/reactHeaderPart.d.ts +0 -1
  64. package/dist/esm/dockview/reactHeaderPart.js +0 -1
  65. package/dist/esm/dockview/reactWatermarkPart.d.ts +0 -1
  66. package/dist/esm/dockview/reactWatermarkPart.js +0 -1
  67. package/dist/esm/gridview/gridview.d.ts +0 -1
  68. package/dist/esm/gridview/gridview.js +0 -1
  69. package/dist/esm/gridview/view.d.ts +0 -1
  70. package/dist/esm/gridview/view.js +3 -2
  71. package/dist/esm/index.d.ts +0 -1
  72. package/dist/esm/index.js +0 -1
  73. package/dist/esm/paneview/paneview.d.ts +0 -1
  74. package/dist/esm/paneview/paneview.js +0 -1
  75. package/dist/esm/paneview/view.d.ts +0 -1
  76. package/dist/esm/paneview/view.js +0 -1
  77. package/dist/esm/react.d.ts +1 -2
  78. package/dist/esm/react.js +11 -8
  79. package/dist/esm/splitview/splitview.d.ts +0 -1
  80. package/dist/esm/splitview/splitview.js +0 -1
  81. package/dist/esm/splitview/view.d.ts +0 -1
  82. package/dist/esm/splitview/view.js +0 -1
  83. package/dist/esm/svg.d.ts +0 -1
  84. package/dist/esm/svg.js +0 -1
  85. package/dist/esm/types.d.ts +0 -1
  86. package/dist/esm/types.js +0 -1
  87. package/package.json +4 -4
  88. package/dist/cjs/dockview/defaultTab.d.ts.map +0 -1
  89. package/dist/cjs/dockview/defaultTab.js.map +0 -1
  90. package/dist/cjs/dockview/dockview.d.ts.map +0 -1
  91. package/dist/cjs/dockview/dockview.js.map +0 -1
  92. package/dist/cjs/dockview/headerActionsRenderer.d.ts.map +0 -1
  93. package/dist/cjs/dockview/headerActionsRenderer.js.map +0 -1
  94. package/dist/cjs/dockview/reactContentPart.d.ts.map +0 -1
  95. package/dist/cjs/dockview/reactContentPart.js.map +0 -1
  96. package/dist/cjs/dockview/reactHeaderPart.d.ts.map +0 -1
  97. package/dist/cjs/dockview/reactHeaderPart.js.map +0 -1
  98. package/dist/cjs/dockview/reactWatermarkPart.d.ts.map +0 -1
  99. package/dist/cjs/dockview/reactWatermarkPart.js.map +0 -1
  100. package/dist/cjs/gridview/gridview.d.ts.map +0 -1
  101. package/dist/cjs/gridview/gridview.js.map +0 -1
  102. package/dist/cjs/gridview/view.d.ts.map +0 -1
  103. package/dist/cjs/gridview/view.js.map +0 -1
  104. package/dist/cjs/index.d.ts.map +0 -1
  105. package/dist/cjs/index.js.map +0 -1
  106. package/dist/cjs/paneview/paneview.d.ts.map +0 -1
  107. package/dist/cjs/paneview/paneview.js.map +0 -1
  108. package/dist/cjs/paneview/view.d.ts.map +0 -1
  109. package/dist/cjs/paneview/view.js.map +0 -1
  110. package/dist/cjs/react.d.ts.map +0 -1
  111. package/dist/cjs/react.js.map +0 -1
  112. package/dist/cjs/splitview/splitview.d.ts.map +0 -1
  113. package/dist/cjs/splitview/splitview.js.map +0 -1
  114. package/dist/cjs/splitview/view.d.ts.map +0 -1
  115. package/dist/cjs/splitview/view.js.map +0 -1
  116. package/dist/cjs/svg.d.ts.map +0 -1
  117. package/dist/cjs/svg.js.map +0 -1
  118. package/dist/cjs/types.d.ts.map +0 -1
  119. package/dist/cjs/types.js.map +0 -1
  120. package/dist/esm/dockview/defaultTab.d.ts.map +0 -1
  121. package/dist/esm/dockview/defaultTab.js.map +0 -1
  122. package/dist/esm/dockview/dockview.d.ts.map +0 -1
  123. package/dist/esm/dockview/dockview.js.map +0 -1
  124. package/dist/esm/dockview/headerActionsRenderer.d.ts.map +0 -1
  125. package/dist/esm/dockview/headerActionsRenderer.js.map +0 -1
  126. package/dist/esm/dockview/reactContentPart.d.ts.map +0 -1
  127. package/dist/esm/dockview/reactContentPart.js.map +0 -1
  128. package/dist/esm/dockview/reactHeaderPart.d.ts.map +0 -1
  129. package/dist/esm/dockview/reactHeaderPart.js.map +0 -1
  130. package/dist/esm/dockview/reactWatermarkPart.d.ts.map +0 -1
  131. package/dist/esm/dockview/reactWatermarkPart.js.map +0 -1
  132. package/dist/esm/gridview/gridview.d.ts.map +0 -1
  133. package/dist/esm/gridview/gridview.js.map +0 -1
  134. package/dist/esm/gridview/view.d.ts.map +0 -1
  135. package/dist/esm/gridview/view.js.map +0 -1
  136. package/dist/esm/index.d.ts.map +0 -1
  137. package/dist/esm/index.js.map +0 -1
  138. package/dist/esm/paneview/paneview.d.ts.map +0 -1
  139. package/dist/esm/paneview/paneview.js.map +0 -1
  140. package/dist/esm/paneview/view.d.ts.map +0 -1
  141. package/dist/esm/paneview/view.js.map +0 -1
  142. package/dist/esm/react.d.ts.map +0 -1
  143. package/dist/esm/react.js.map +0 -1
  144. package/dist/esm/splitview/splitview.d.ts.map +0 -1
  145. package/dist/esm/splitview/splitview.js.map +0 -1
  146. package/dist/esm/splitview/view.d.ts.map +0 -1
  147. package/dist/esm/splitview/view.js.map +0 -1
  148. package/dist/esm/svg.d.ts.map +0 -1
  149. package/dist/esm/svg.js.map +0 -1
  150. package/dist/esm/types.d.ts.map +0 -1
  151. package/dist/esm/types.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * dockview
3
- * @version 1.9.1
3
+ * @version 1.10.0
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -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,12 +3626,13 @@ 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
- if (this.accessor.options.defaultRenderer === 'onlyWhenVisibile') {
3515
- this._element.removeChild(this.panel.view.content.element);
3631
+ if (this.panel.api.renderer === 'onlyWhenVisibile') {
3632
+ (_a = this.panel.view.content.element.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(this.panel.view.content.element);
3516
3633
  }
3517
- this.panel = undefined;
3518
3634
  }
3635
+ this.panel = undefined;
3519
3636
  }
3520
3637
  dispose() {
3521
3638
  this.disposable.dispose();
@@ -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,34 +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
- }
4480
+ this.contentContainer.renderPanel(panel, { asActive: true });
4269
4481
  return;
4270
4482
  }
4271
- this.doAddPanel(panel, options.index, skipSetPanelActive);
4272
- if (!skipSetPanelActive) {
4483
+ if (!skipSetActive) {
4273
4484
  this.doSetActivePanel(panel);
4274
4485
  }
4275
- if (!skipSetGroupActive) {
4276
- 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();
4277
4491
  }
4278
- this.updateContainer();
4279
4492
  }
4280
- removePanel(groupItemOrId) {
4493
+ removePanel(groupItemOrId, options = {
4494
+ skipSetActive: false,
4495
+ }) {
4281
4496
  const id = typeof groupItemOrId === 'string'
4282
4497
  ? groupItemOrId
4283
4498
  : groupItemOrId.id;
@@ -4285,7 +4500,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4285
4500
  if (!panelToRemove) {
4286
4501
  throw new Error('invalid operation');
4287
4502
  }
4288
- return this._removePanel(panelToRemove);
4503
+ return this._removePanel(panelToRemove, options);
4289
4504
  }
4290
4505
  closeAllPanels() {
4291
4506
  if (this.panels.length > 0) {
@@ -4311,12 +4526,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4311
4526
  updateActions(element) {
4312
4527
  this.tabsContainer.setRightActionsElement(element);
4313
4528
  }
4314
- setActive(isGroupActive, skipFocus = false, force = false) {
4315
- var _a, _b, _c, _d;
4529
+ setActive(isGroupActive, force = false) {
4316
4530
  if (!force && this.isActive === isGroupActive) {
4317
- if (!skipFocus) {
4318
- (_b = (_a = this._activePanel) === null || _a === void 0 ? void 0 : _a.focus) === null || _b === void 0 ? void 0 : _b.call(_a);
4319
- }
4320
4531
  return;
4321
4532
  }
4322
4533
  this._isGroupActive = isGroupActive;
@@ -4327,11 +4538,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4327
4538
  this.doSetActivePanel(this.panels[0]);
4328
4539
  }
4329
4540
  this.updateContainer();
4330
- if (isGroupActive) {
4331
- if (!skipFocus) {
4332
- (_d = (_c = this._activePanel) === null || _c === void 0 ? void 0 : _c.focus) === null || _d === void 0 ? void 0 : _d.call(_c);
4333
- }
4334
- }
4335
4541
  }
4336
4542
  layout(width, height) {
4337
4543
  var _a;
@@ -4342,17 +4548,22 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4342
4548
  this._activePanel.layout(this._width, this._height);
4343
4549
  }
4344
4550
  }
4345
- _removePanel(panel) {
4551
+ _removePanel(panel, options) {
4346
4552
  const isActivePanel = this._activePanel === panel;
4347
4553
  this.doRemovePanel(panel);
4348
4554
  if (isActivePanel && this.panels.length > 0) {
4349
4555
  const nextPanel = this.mostRecentlyUsed[0];
4350
- this.openPanel(nextPanel);
4556
+ this.openPanel(nextPanel, {
4557
+ skipSetActive: options.skipSetActive,
4558
+ skipSetGroupActive: options.skipSetActiveGroup,
4559
+ });
4351
4560
  }
4352
4561
  if (this._activePanel && this.panels.length === 0) {
4353
4562
  this.doSetActivePanel(undefined);
4354
4563
  }
4355
- this.updateContainer();
4564
+ if (!options.skipSetActive) {
4565
+ this.updateContainer();
4566
+ }
4356
4567
  return panel;
4357
4568
  }
4358
4569
  doRemovePanel(panel) {
@@ -4367,13 +4578,13 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4367
4578
  }
4368
4579
  this._onDidRemovePanel.fire({ panel });
4369
4580
  }
4370
- doAddPanel(panel, index = this.panels.length, skipSetActive = false) {
4581
+ doAddPanel(panel, index = this.panels.length, options = { skipSetActive: false }) {
4371
4582
  const existingPanel = this._panels.indexOf(panel);
4372
4583
  const hasExistingPanel = existingPanel > -1;
4373
4584
  this.tabsContainer.show();
4374
4585
  this.contentContainer.show();
4375
4586
  this.tabsContainer.openPanel(panel, index);
4376
- if (!skipSetActive) {
4587
+ if (!options.skipSetActive) {
4377
4588
  this.contentContainer.openPanel(panel);
4378
4589
  }
4379
4590
  if (hasExistingPanel) {
@@ -4385,12 +4596,17 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4385
4596
  this._onDidAddPanel.fire({ panel });
4386
4597
  }
4387
4598
  doSetActivePanel(panel) {
4599
+ if (this._activePanel === panel) {
4600
+ return;
4601
+ }
4388
4602
  this._activePanel = panel;
4389
4603
  if (panel) {
4390
4604
  this.tabsContainer.setActivePanel(panel);
4391
4605
  panel.layout(this._width, this._height);
4392
4606
  this.updateMru(panel);
4393
- this._onDidActivePanelChange.fire({ panel });
4607
+ this._onDidActivePanelChange.fire({
4608
+ panel,
4609
+ });
4394
4610
  }
4395
4611
  }
4396
4612
  updateMru(panel) {
@@ -4402,11 +4618,11 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4402
4618
  updateContainer() {
4403
4619
  var _a, _b;
4404
4620
  toggleClass(this.container, 'empty', this.isEmpty);
4405
- this.panels.forEach((panel) => panel.updateParentGroup(this.groupPanel, this.isActive));
4621
+ this.panels.forEach((panel) => panel.runEvents());
4406
4622
  if (this.isEmpty && !this.watermark) {
4407
4623
  const watermark = this.accessor.createWatermarkComponent();
4408
4624
  watermark.init({
4409
- containerApi: new DockviewApi(this.accessor),
4625
+ containerApi: this._api,
4410
4626
  group: this.groupPanel,
4411
4627
  });
4412
4628
  this.watermark = watermark;
@@ -4439,10 +4655,32 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4439
4655
  }
4440
4656
  return false;
4441
4657
  }
4442
- handleDropEvent(event, position, index) {
4658
+ handleDropEvent(type, event, position, index) {
4443
4659
  if (this.locked === 'no-drop-target') {
4444
4660
  return;
4445
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
+ }
4446
4684
  const data = getPanelData();
4447
4685
  if (data && data.viewId === this.accessor.id) {
4448
4686
  if (data.panelId === null) {
@@ -4475,12 +4713,14 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4475
4713
  });
4476
4714
  }
4477
4715
  else {
4478
- this._onDidDrop.fire({
4716
+ this._onDidDrop.fire(new DockviewDidDropEvent({
4479
4717
  nativeEvent: event,
4480
4718
  position,
4481
- index,
4719
+ panel,
4482
4720
  getData: () => getPanelData(),
4483
- });
4721
+ group: this.groupPanel,
4722
+ api: this._api,
4723
+ }));
4484
4724
  }
4485
4725
  }
4486
4726
  dispose() {
@@ -4488,6 +4728,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4488
4728
  super.dispose();
4489
4729
  (_a = this.watermark) === null || _a === void 0 ? void 0 : _a.element.remove();
4490
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;
4491
4732
  for (const panel of this.panels) {
4492
4733
  panel.dispose();
4493
4734
  }
@@ -4509,15 +4750,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4509
4750
  constructor(parentElement, disableResizing = false) {
4510
4751
  super();
4511
4752
  this._disableResizing = disableResizing;
4512
- if (parentElement) {
4513
- this._element = parentElement;
4514
- }
4515
- else {
4516
- this._element = document.createElement('div');
4517
- this._element.style.height = '100%';
4518
- this._element.style.width = '100%';
4519
- this._element.className = 'dv-resizable-container';
4520
- }
4753
+ this._element = parentElement;
4521
4754
  this.addDisposables(watchElementResize(this._element, (entry) => {
4522
4755
  if (this.isDisposed) {
4523
4756
  /**
@@ -4605,25 +4838,38 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4605
4838
  get activeGroup() {
4606
4839
  return this._activeGroup;
4607
4840
  }
4841
+ get locked() {
4842
+ return this.gridview.locked;
4843
+ }
4844
+ set locked(value) {
4845
+ this.gridview.locked = value;
4846
+ }
4608
4847
  constructor(options) {
4609
- super(options.parentElement, options.disableAutoResizing);
4848
+ super(document.createElement('div'), options.disableAutoResizing);
4610
4849
  this._id = nextLayoutId$1.next();
4611
4850
  this._groups = new Map();
4612
4851
  this._onDidLayoutChange = new Emitter();
4613
4852
  this.onDidLayoutChange = this._onDidLayoutChange.event;
4614
- this._onDidRemoveGroup = new Emitter();
4615
- this.onDidRemoveGroup = this._onDidRemoveGroup.event;
4616
- this._onDidAddGroup = new Emitter();
4617
- this.onDidAddGroup = this._onDidAddGroup.event;
4618
- this._onDidActiveGroupChange = new Emitter();
4619
- 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;
4620
4859
  this._bufferOnDidLayoutChange = new TickDelayedEvent();
4860
+ this.element.style.height = '100%';
4861
+ this.element.style.width = '100%';
4862
+ options.parentElement.appendChild(this.element);
4621
4863
  this.gridview = new Gridview(!!options.proportionalLayout, options.styles, options.orientation);
4864
+ this.gridview.locked = !!options.locked;
4622
4865
  this.element.appendChild(this.gridview.element);
4623
4866
  this.layout(0, 0, true); // set some elements height/widths
4624
- 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(() => {
4625
4871
  this._bufferOnDidLayoutChange.fire();
4626
- }), exports.DockviewEvent.any(this.onDidAddGroup, this.onDidRemoveGroup, this.onDidActiveGroupChange)(() => {
4872
+ }), exports.DockviewEvent.any(this.onDidAdd, this.onDidRemove, this.onDidActiveChange)(() => {
4627
4873
  this._bufferOnDidLayoutChange.fire();
4628
4874
  }), this._bufferOnDidLayoutChange.onEvent(() => {
4629
4875
  this._onDidLayoutChange.fire();
@@ -4638,6 +4884,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4638
4884
  }
4639
4885
  maximizeGroup(panel) {
4640
4886
  this.gridview.maximizeView(panel);
4887
+ this.doSetGroupActive(panel);
4641
4888
  }
4642
4889
  isMaximizedGroup(panel) {
4643
4890
  return this.gridview.maximizedView() === panel;
@@ -4648,13 +4895,12 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4648
4895
  hasMaximizedGroup() {
4649
4896
  return this.gridview.hasMaximizedView();
4650
4897
  }
4651
- get onDidMaxmizedGroupChange() {
4652
- return this.gridview.onDidMaxmizedNodeChange;
4898
+ get onDidMaximizedGroupChange() {
4899
+ return this.gridview.onDidMaximizedNodeChange;
4653
4900
  }
4654
4901
  doAddGroup(group, location = [0], size) {
4655
4902
  this.gridview.addView(group, size !== null && size !== void 0 ? size : exports.Sizing.Distribute, location);
4656
- this._onDidAddGroup.fire(group);
4657
- this.doSetGroupActive(group);
4903
+ this._onDidAdd.fire(group);
4658
4904
  }
4659
4905
  doRemoveGroup(group, options) {
4660
4906
  if (!this._groups.has(group.id)) {
@@ -4666,8 +4912,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4666
4912
  item.disposable.dispose();
4667
4913
  item.value.dispose();
4668
4914
  this._groups.delete(group.id);
4915
+ this._onDidRemove.fire(group);
4669
4916
  }
4670
- this._onDidRemoveGroup.fire(group);
4671
4917
  if (!(options === null || options === void 0 ? void 0 : options.skipActive) && this._activeGroup === group) {
4672
4918
  const groups = Array.from(this._groups.values());
4673
4919
  this.doSetGroupActive(groups.length > 0 ? groups[0].value : undefined);
@@ -4678,25 +4924,18 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4678
4924
  var _a;
4679
4925
  return (_a = this._groups.get(id)) === null || _a === void 0 ? void 0 : _a.value;
4680
4926
  }
4681
- doSetGroupActive(group, skipFocus) {
4682
- var _a, _b, _c;
4927
+ doSetGroupActive(group) {
4683
4928
  if (this._activeGroup === group) {
4684
4929
  return;
4685
4930
  }
4686
4931
  if (this._activeGroup) {
4687
4932
  this._activeGroup.setActive(false);
4688
- if (!skipFocus) {
4689
- (_b = (_a = this._activeGroup).focus) === null || _b === void 0 ? void 0 : _b.call(_a);
4690
- }
4691
4933
  }
4692
4934
  if (group) {
4693
4935
  group.setActive(true);
4694
- if (!skipFocus) {
4695
- (_c = group.focus) === null || _c === void 0 ? void 0 : _c.call(group);
4696
- }
4697
4936
  }
4698
4937
  this._activeGroup = group;
4699
- this._onDidActiveGroupChange.fire(group);
4938
+ this._onDidActiveChange.fire(group);
4700
4939
  }
4701
4940
  removeGroup(group) {
4702
4941
  this.doRemoveGroup(group);
@@ -4741,9 +4980,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4741
4980
  this.gridview.layout(width, height);
4742
4981
  }
4743
4982
  dispose() {
4744
- this._onDidActiveGroupChange.dispose();
4745
- this._onDidAddGroup.dispose();
4746
- this._onDidRemoveGroup.dispose();
4983
+ this._onDidActiveChange.dispose();
4984
+ this._onDidAdd.dispose();
4985
+ this._onDidRemove.dispose();
4747
4986
  this._onDidLayoutChange.dispose();
4748
4987
  for (const group of this.groups) {
4749
4988
  group.dispose();
@@ -4753,11 +4992,15 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4753
4992
  }
4754
4993
  }
4755
4994
 
4995
+ class WillFocusEvent extends DockviewEvent {
4996
+ constructor() {
4997
+ super();
4998
+ }
4999
+ }
4756
5000
  /**
4757
5001
  * A core api implementation that should be used across all panel-like objects
4758
5002
  */
4759
5003
  class PanelApiImpl extends CompositeDisposable {
4760
- //
4761
5004
  get isFocused() {
4762
5005
  return this._isFocused;
4763
5006
  }
@@ -4767,6 +5010,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4767
5010
  get isVisible() {
4768
5011
  return this._isVisible;
4769
5012
  }
5013
+ get isHidden() {
5014
+ return this._isHidden;
5015
+ }
4770
5016
  get width() {
4771
5017
  return this._width;
4772
5018
  }
@@ -4779,38 +5025,26 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4779
5025
  this._isFocused = false;
4780
5026
  this._isActive = false;
4781
5027
  this._isVisible = true;
5028
+ this._isHidden = false;
4782
5029
  this._width = 0;
4783
5030
  this._height = 0;
4784
5031
  this.panelUpdatesDisposable = new MutableDisposable();
4785
- this._onDidDimensionChange = new Emitter({
4786
- replay: true,
4787
- });
5032
+ this._onDidDimensionChange = new Emitter();
4788
5033
  this.onDidDimensionsChange = this._onDidDimensionChange.event;
4789
- //
4790
- this._onDidChangeFocus = new Emitter({
4791
- replay: true,
4792
- });
5034
+ this._onDidChangeFocus = new Emitter();
4793
5035
  this.onDidFocusChange = this._onDidChangeFocus.event;
4794
5036
  //
4795
- this._onFocusEvent = new Emitter();
4796
- this.onFocusEvent = this._onFocusEvent.event;
5037
+ this._onWillFocus = new Emitter();
5038
+ this.onWillFocus = this._onWillFocus.event;
4797
5039
  //
4798
- this._onDidVisibilityChange = new Emitter({
4799
- replay: true,
4800
- });
5040
+ this._onDidVisibilityChange = new Emitter();
4801
5041
  this.onDidVisibilityChange = this._onDidVisibilityChange.event;
4802
- //
4803
- this._onVisibilityChange = new Emitter();
4804
- this.onVisibilityChange = this._onVisibilityChange.event;
4805
- //
4806
- this._onDidActiveChange = new Emitter({
4807
- replay: true,
4808
- });
5042
+ this._onDidHiddenChange = new Emitter();
5043
+ this.onDidHiddenChange = this._onDidHiddenChange.event;
5044
+ this._onDidActiveChange = new Emitter();
4809
5045
  this.onDidActiveChange = this._onDidActiveChange.event;
4810
- //
4811
5046
  this._onActiveChange = new Emitter();
4812
5047
  this.onActiveChange = this._onActiveChange.event;
4813
- //
4814
5048
  this._onUpdateParameters = new Emitter();
4815
5049
  this.onUpdateParameters = this._onUpdateParameters.event;
4816
5050
  this.addDisposables(this.onDidFocusChange((event) => {
@@ -4819,10 +5053,12 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4819
5053
  this._isActive = event.isActive;
4820
5054
  }), this.onDidVisibilityChange((event) => {
4821
5055
  this._isVisible = event.isVisible;
5056
+ }), this.onDidHiddenChange((event) => {
5057
+ this._isHidden = event.isHidden;
4822
5058
  }), this.onDidDimensionsChange((event) => {
4823
5059
  this._width = event.width;
4824
5060
  this._height = event.height;
4825
- }), 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);
4826
5062
  }
4827
5063
  initialize(panel) {
4828
5064
  this.panelUpdatesDisposable.value = this._onUpdateParameters.event((parameters) => {
@@ -4831,8 +5067,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4831
5067
  });
4832
5068
  });
4833
5069
  }
4834
- setVisible(isVisible) {
4835
- this._onVisibilityChange.fire({ isVisible });
5070
+ setHidden(isHidden) {
5071
+ this._onDidHiddenChange.fire({ isHidden });
4836
5072
  }
4837
5073
  setActive() {
4838
5074
  this._onActiveChange.fire();
@@ -4840,9 +5076,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4840
5076
  updateParameters(parameters) {
4841
5077
  this._onUpdateParameters.fire(parameters);
4842
5078
  }
4843
- dispose() {
4844
- super.dispose();
4845
- }
4846
5079
  }
4847
5080
 
4848
5081
  class SplitviewPanelApiImpl extends PanelApiImpl {
@@ -4930,7 +5163,12 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4930
5163
  }), focusTracker);
4931
5164
  }
4932
5165
  focus() {
4933
- 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();
4934
5172
  }
4935
5173
  layout(width, height) {
4936
5174
  this._width = width;
@@ -5259,9 +5497,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5259
5497
  super(id);
5260
5498
  this._onDidConstraintsChangeInternal = new Emitter();
5261
5499
  this.onDidConstraintsChangeInternal = this._onDidConstraintsChangeInternal.event;
5262
- this._onDidConstraintsChange = new Emitter({
5263
- replay: true,
5264
- });
5500
+ this._onDidConstraintsChange = new Emitter();
5265
5501
  this.onDidConstraintsChange = this._onDidConstraintsChange.event;
5266
5502
  this._onDidSizeChange = new Emitter();
5267
5503
  this.onDidSizeChange = this._onDidSizeChange.event;
@@ -5354,13 +5590,13 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5354
5590
  this._maximumHeight = options.maximumHeight;
5355
5591
  }
5356
5592
  this.api.initialize(this); // TODO: required to by-pass 'super before this' requirement
5357
- this.addDisposables(this.api.onVisibilityChange((event) => {
5358
- const { isVisible } = event;
5593
+ this.addDisposables(this.api.onDidHiddenChange((event) => {
5594
+ const { isHidden } = event;
5359
5595
  const { accessor } = this._params;
5360
- accessor.setVisible(this, isVisible);
5596
+ accessor.setVisible(this, !isHidden);
5361
5597
  }), this.api.onActiveChange(() => {
5362
5598
  const { accessor } = this._params;
5363
- accessor.setActive(this);
5599
+ accessor.doSetGroupActive(this);
5364
5600
  }), this.api.onDidConstraintsChangeInternal((event) => {
5365
5601
  if (typeof event.minimumWidth === 'number' ||
5366
5602
  typeof event.minimumWidth === 'function') {
@@ -5443,6 +5679,17 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5443
5679
  this.onDidLocationChange = this._onDidLocationChange.event;
5444
5680
  this.addDisposables(this._onDidLocationChange);
5445
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
+ }
5446
5693
  moveTo(options) {
5447
5694
  var _a, _b, _c;
5448
5695
  if (!this._group) {
@@ -5450,14 +5697,23 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5450
5697
  }
5451
5698
  const group = (_a = options.group) !== null && _a !== void 0 ? _a : this.accessor.addGroup({
5452
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
+ },
5453
5710
  });
5454
- this.accessor.moveGroupOrPanel(group, this._group.id, undefined, options.group ? (_c = options.position) !== null && _c !== void 0 ? _c : 'center' : 'center');
5455
5711
  }
5456
5712
  maximize() {
5457
5713
  if (!this._group) {
5458
5714
  throw new Error(NOT_INITIALIZED_MESSAGE);
5459
5715
  }
5460
- if (this.location !== 'grid') {
5716
+ if (this.location.type !== 'grid') {
5461
5717
  // only grid groups can be maximized
5462
5718
  return;
5463
5719
  }
@@ -5514,6 +5770,12 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5514
5770
  this.api.initialize(this); // cannot use 'this' after after 'super' call
5515
5771
  this._model = new DockviewGroupPanelModel(this.element, accessor, id, options, this);
5516
5772
  }
5773
+ focus() {
5774
+ if (!this.api.isActive) {
5775
+ this.api.setActive();
5776
+ }
5777
+ super.focus();
5778
+ }
5517
5779
  initialize() {
5518
5780
  this._model.initialize();
5519
5781
  }
@@ -5559,6 +5821,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5559
5821
  }
5560
5822
 
5561
5823
  class DockviewPanelApiImpl extends GridviewPanelApiImpl {
5824
+ get location() {
5825
+ return this.group.api.location;
5826
+ }
5562
5827
  get title() {
5563
5828
  return this.panel.title;
5564
5829
  }
@@ -5570,15 +5835,34 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5570
5835
  }
5571
5836
  set group(value) {
5572
5837
  const isOldGroupActive = this.isGroupActive;
5573
- this._group = value;
5574
- this._onDidGroupChange.fire();
5575
- if (this._group) {
5576
- this.disposable.value = this._group.api.onDidActiveChange(() => {
5577
- 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,
5578
5865
  });
5579
- if (this.isGroupActive !== isOldGroupActive) {
5580
- this._onDidActiveGroupChange.fire();
5581
- }
5582
5866
  }
5583
5867
  }
5584
5868
  get group() {
@@ -5596,14 +5880,26 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5596
5880
  this.onDidGroupChange = this._onDidGroupChange.event;
5597
5881
  this._onDidRendererChange = new Emitter();
5598
5882
  this.onDidRendererChange = this._onDidRendererChange.event;
5599
- this.disposable = new MutableDisposable();
5883
+ this._onDidLocationChange = new Emitter();
5884
+ this.onDidLocationChange = this._onDidLocationChange.event;
5885
+ this.groupEventsDisposable = new MutableDisposable();
5600
5886
  this.initialize(panel);
5601
5887
  this._group = group;
5602
- 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();
5603
5892
  }
5604
5893
  moveTo(options) {
5605
5894
  var _a;
5606
- 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
+ });
5607
5903
  }
5608
5904
  setTitle(title) {
5609
5905
  this.panel.setTitle(title);
@@ -5664,7 +5960,14 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5664
5960
  this.setTitle(params.title);
5665
5961
  }
5666
5962
  focus() {
5667
- 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
+ }
5668
5971
  }
5669
5972
  toJSON() {
5670
5973
  return {
@@ -5721,20 +6024,40 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5721
6024
  },
5722
6025
  });
5723
6026
  }
5724
- updateParentGroup(group, isGroupActive) {
6027
+ updateParentGroup(group, options) {
5725
6028
  this._group = group;
5726
- this.api.group = group;
6029
+ this.api.group = this._group;
5727
6030
  const isPanelVisible = this._group.model.isPanelActive(this);
5728
- this.api._onDidActiveChange.fire({
5729
- isActive: isGroupActive && isPanelVisible,
5730
- });
5731
- this.api._onDidVisibilityChange.fire({
5732
- isVisible: isPanelVisible,
5733
- });
5734
- 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
+ }
5735
6058
  }
5736
6059
  layout(width, height) {
5737
- // 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?
5738
6061
  this.api._onDidDimensionChange.fire({
5739
6062
  width,
5740
6063
  height: height,
@@ -5856,8 +6179,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5856
6179
  this.id = id;
5857
6180
  this.contentComponent = contentComponent;
5858
6181
  this.tabComponent = tabComponent;
5859
- this._group = null;
5860
- this._isPanelVisible = null;
5861
6182
  this._content = this.createContentComponent(this.id, contentComponent);
5862
6183
  this._tab = this.createTabComponent(this.id, tabComponent);
5863
6184
  }
@@ -5865,25 +6186,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5865
6186
  this.content.init(Object.assign(Object.assign({}, params), { tab: this.tab }));
5866
6187
  this.tab.init(params);
5867
6188
  }
5868
- updateParentGroup(group, isPanelVisible) {
5869
- if (group !== this._group) {
5870
- this._group = group;
5871
- if (this._content.onGroupChange) {
5872
- this._content.onGroupChange(group);
5873
- }
5874
- if (this._tab.onGroupChange) {
5875
- this._tab.onGroupChange(group);
5876
- }
5877
- }
5878
- if (isPanelVisible !== this._isPanelVisible) {
5879
- this._isPanelVisible = isPanelVisible;
5880
- if (this._content.onPanelVisibleChange) {
5881
- this._content.onPanelVisibleChange(isPanelVisible);
5882
- }
5883
- if (this._tab.onPanelVisibleChange) {
5884
- this._tab.onPanelVisibleChange(isPanelVisible);
5885
- }
5886
- }
6189
+ updateParentGroup(_group, _isPanelVisible) {
6190
+ // noop
5887
6191
  }
5888
6192
  layout(width, height) {
5889
6193
  var _a, _b;
@@ -6316,117 +6620,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6316
6620
  }
6317
6621
  }
6318
6622
 
6319
- class PopoutWindow extends CompositeDisposable {
6320
- constructor(id, className, options) {
6321
- super();
6322
- this.id = id;
6323
- this.className = className;
6324
- this.options = options;
6325
- this._onDidClose = new Emitter();
6326
- this.onDidClose = this._onDidClose.event;
6327
- this._window = null;
6328
- this.addDisposables(this._onDidClose, {
6329
- dispose: () => {
6330
- this.close();
6331
- },
6332
- });
6333
- }
6334
- dimensions() {
6335
- if (!this._window) {
6336
- return null;
6337
- }
6338
- const left = this._window.value.screenX;
6339
- const top = this._window.value.screenY;
6340
- const width = this._window.value.innerWidth;
6341
- const height = this._window.value.innerHeight;
6342
- return { top, left, width, height };
6343
- }
6344
- close() {
6345
- if (this._window) {
6346
- this._window.disposable.dispose();
6347
- this._window.value.close();
6348
- this._window = null;
6349
- }
6350
- }
6351
- open(content) {
6352
- if (this._window) {
6353
- throw new Error('instance of popout window is already open');
6354
- }
6355
- const url = `${this.options.url}`;
6356
- const features = Object.entries({
6357
- top: this.options.top,
6358
- left: this.options.left,
6359
- width: this.options.width,
6360
- height: this.options.height,
6361
- })
6362
- .map(([key, value]) => `${key}=${value}`)
6363
- .join(',');
6364
- // https://developer.mozilla.org/en-US/docs/Web/API/Window/open
6365
- const externalWindow = window.open(url, this.id, features);
6366
- if (!externalWindow) {
6367
- return;
6368
- }
6369
- const disposable = new CompositeDisposable();
6370
- this._window = { value: externalWindow, disposable };
6371
- const cleanUp = () => {
6372
- this._onDidClose.fire();
6373
- this._window = null;
6374
- };
6375
- // prevent any default content from loading
6376
- // externalWindow.document.body.replaceWith(document.createElement('div'));
6377
- disposable.addDisposables(addDisposableWindowListener(window, 'beforeunload', () => {
6378
- cleanUp();
6379
- this.close();
6380
- }));
6381
- externalWindow.addEventListener('load', () => {
6382
- const externalDocument = externalWindow.document;
6383
- externalDocument.title = document.title;
6384
- const div = document.createElement('div');
6385
- div.classList.add('dv-popout-window');
6386
- div.style.position = 'absolute';
6387
- div.style.width = '100%';
6388
- div.style.height = '100%';
6389
- div.style.top = '0px';
6390
- div.style.left = '0px';
6391
- div.classList.add(this.className);
6392
- div.appendChild(content);
6393
- externalDocument.body.replaceChildren(div);
6394
- externalDocument.body.classList.add(this.className);
6395
- addStyles(externalDocument, window.document.styleSheets);
6396
- externalWindow.addEventListener('beforeunload', () => {
6397
- // TODO: indicate external window is closing
6398
- cleanUp();
6399
- });
6400
- });
6401
- }
6402
- }
6403
-
6404
- class DockviewPopoutGroupPanel extends CompositeDisposable {
6405
- constructor(id, group, options) {
6406
- var _a;
6407
- super();
6408
- this.id = id;
6409
- this.group = group;
6410
- this.options = options;
6411
- this.window = new PopoutWindow(id, (_a = options.className) !== null && _a !== void 0 ? _a : '', {
6412
- url: this.options.popoutUrl,
6413
- left: this.options.box.left,
6414
- top: this.options.box.top,
6415
- width: this.options.box.width,
6416
- height: this.options.box.height,
6417
- });
6418
- group.model.location = 'popout';
6419
- this.addDisposables(this.window, {
6420
- dispose: () => {
6421
- group.model.location = 'grid';
6422
- },
6423
- }, this.window.onDidClose(() => {
6424
- this.dispose();
6425
- }));
6426
- this.window.open(group.element);
6427
- }
6428
- }
6429
-
6430
6623
  const DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE = 100;
6431
6624
  const DEFAULT_FLOATING_GROUP_POSITION = { left: 100, top: 100 };
6432
6625
 
@@ -6440,11 +6633,13 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6440
6633
  super();
6441
6634
  this.element = element;
6442
6635
  this.map = {};
6636
+ this._disposed = false;
6443
6637
  this.addDisposables(Disposable.from(() => {
6444
6638
  for (const value of Object.values(this.map)) {
6445
6639
  value.disposable.dispose();
6446
6640
  value.destroy.dispose();
6447
6641
  }
6642
+ this._disposed = true;
6448
6643
  }));
6449
6644
  }
6450
6645
  detatch(panel) {
@@ -6484,7 +6679,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6484
6679
  focusContainer.style.top = `${box.top - box2.top}px`;
6485
6680
  focusContainer.style.width = `${box.width}px`;
6486
6681
  focusContainer.style.height = `${box.height}px`;
6487
- toggleClass(focusContainer, 'dv-render-overlay-float', panel.group.api.location === 'floating');
6682
+ toggleClass(focusContainer, 'dv-render-overlay-float', panel.group.api.location.type === 'floating');
6488
6683
  };
6489
6684
  const visibilityChanged = () => {
6490
6685
  if (panel.api.isVisible) {
@@ -6530,8 +6725,11 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6530
6725
  resize();
6531
6726
  }));
6532
6727
  this.map[panel.api.id].destroy = Disposable.from(() => {
6533
- focusContainer.removeChild(panel.view.content.element);
6534
- 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);
6535
6733
  });
6536
6734
  queueMicrotask(() => {
6537
6735
  if (this.isDisposed) {
@@ -6552,11 +6750,164 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6552
6750
  }
6553
6751
  }
6554
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
+
6555
6892
  const DEFAULT_ROOT_OVERLAY_MODEL = {
6556
6893
  activationSize: { type: 'pixels', value: 10 },
6557
6894
  size: { type: 'pixels', value: 20 },
6558
6895
  };
6559
- 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) {
6560
6911
  function toClassList(element) {
6561
6912
  const list = [];
6562
6913
  for (let i = 0; i < element.classList.length; i++) {
@@ -6607,6 +6958,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6607
6958
  styles: options.styles,
6608
6959
  parentElement: options.parentElement,
6609
6960
  disableAutoResizing: options.disableAutoResizing,
6961
+ locked: options.locked,
6610
6962
  });
6611
6963
  this.nextGroupId = sequentialNumberGenerator();
6612
6964
  this._deserializer = new DefaultDockviewDeserialzier(this);
@@ -6617,6 +6969,10 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6617
6969
  this.onWillDragGroup = this._onWillDragGroup.event;
6618
6970
  this._onDidDrop = new Emitter();
6619
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;
6620
6976
  this._onDidRemovePanel = new Emitter();
6621
6977
  this.onDidRemovePanel = this._onDidRemovePanel.event;
6622
6978
  this._onDidAddPanel = new Emitter();
@@ -6625,15 +6981,36 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6625
6981
  this.onDidLayoutFromJSON = this._onDidLayoutFromJSON.event;
6626
6982
  this._onDidActivePanelChange = new Emitter();
6627
6983
  this.onDidActivePanelChange = this._onDidActivePanelChange.event;
6984
+ this._onDidMovePanel = new Emitter();
6628
6985
  this._floatingGroups = [];
6629
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;
6630
6995
  const gready = document.createElement('div');
6631
6996
  gready.className = 'dv-overlay-render-container';
6632
6997
  this.gridview.element.appendChild(gready);
6633
6998
  this.overlayRenderContainer = new OverlayRenderContainer(gready);
6634
6999
  toggleClass(this.gridview.element, 'dv-dockview', true);
6635
7000
  toggleClass(this.element, 'dv-debug', !!options.debug);
6636
- 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)(() => {
6637
7014
  this.updateWatermark();
6638
7015
  }), exports.DockviewEvent.any(this.onDidAddPanel, this.onDidRemovePanel, this.onDidActivePanelChange)(() => {
6639
7016
  this._bufferOnDidLayoutChange.fire();
@@ -6644,7 +7021,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6644
7021
  }
6645
7022
  // iterate over a copy of the array since .dispose() mutates the original array
6646
7023
  for (const group of [...this._popoutGroups]) {
6647
- group.dispose();
7024
+ group.disposable.dispose();
6648
7025
  }
6649
7026
  }));
6650
7027
  this._options = options;
@@ -6690,7 +7067,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6690
7067
  return this.options.showDndOverlay({
6691
7068
  nativeEvent: event,
6692
7069
  position: position,
6693
- target: exports.DockviewDropTargets.Edge,
7070
+ target: 'edge',
6694
7071
  getData: getPanelData,
6695
7072
  });
6696
7073
  }
@@ -6701,86 +7078,249 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6701
7078
  });
6702
7079
  this.addDisposables(this._rootDropTarget.onDrop((event) => {
6703
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
+ }
6704
7094
  const data = getPanelData();
6705
7095
  if (data) {
6706
- 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
+ });
6707
7106
  }
6708
7107
  else {
6709
- 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
+ }));
6710
7116
  }
6711
7117
  }), this._rootDropTarget);
6712
7118
  this._api = new DockviewApi(this);
6713
7119
  this.updateWatermark();
6714
7120
  }
6715
- addPopoutGroup(item, options) {
6716
- var _a;
6717
- let group;
6718
- let box = options === null || options === void 0 ? void 0 : options.position;
6719
- if (item instanceof DockviewPanel) {
6720
- group = this.createGroup();
6721
- this.removePanel(item, {
6722
- removeEmptyGroup: true,
6723
- skipDispose: true,
6724
- });
6725
- group.model.openPanel(item);
6726
- if (!box) {
6727
- 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;
6728
7165
  }
6729
- }
6730
- else {
6731
- group = item;
6732
- if (!box) {
6733
- box = group.element.getBoundingClientRect();
7166
+ if (popoutContainer === null) {
7167
+ popoutWindowDisposable.dispose();
7168
+ return;
6734
7169
  }
6735
- const skip = typeof (options === null || options === void 0 ? void 0 : options.skipRemoveGroup) === 'boolean' &&
6736
- options.skipRemoveGroup;
6737
- if (!skip) {
6738
- this.doRemoveGroup(item, { skipDispose: true });
6739
- }
6740
- }
6741
- const theme = getTheme(this.gridview.element);
6742
- const popoutWindow = new DockviewPopoutGroupPanel(`${this.id}-${group.id}`, // globally unique within dockview
6743
- group, {
6744
- className: theme !== null && theme !== void 0 ? theme : '',
6745
- popoutUrl: (_a = options === null || options === void 0 ? void 0 : options.popoutUrl) !== null && _a !== void 0 ? _a : '/popout.html',
6746
- box: {
6747
- left: window.screenX + box.left,
6748
- top: window.screenY + box.top,
6749
- width: box.width,
6750
- height: box.height,
6751
- },
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);
6752
7276
  });
6753
- popoutWindow.addDisposables({
6754
- dispose: () => {
6755
- remove(this._popoutGroups, popoutWindow);
6756
- this.updateWatermark();
6757
- },
6758
- }, popoutWindow.window.onDidClose(() => {
6759
- this.doAddGroup(group, [0]);
6760
- }));
6761
- this._popoutGroups.push(popoutWindow);
6762
- this.updateWatermark();
6763
7277
  }
6764
7278
  addFloatingGroup(item, coord, options) {
6765
- var _a, _b, _c, _d, _e, _f;
7279
+ var _a, _b, _c, _d, _e, _f, _g;
6766
7280
  let group;
6767
7281
  if (item instanceof DockviewPanel) {
6768
7282
  group = this.createGroup();
6769
- this.removePanel(item, {
7283
+ this._onDidAddGroup.fire(group);
7284
+ this.movingLock(() => this.removePanel(item, {
6770
7285
  removeEmptyGroup: true,
6771
7286
  skipDispose: true,
6772
- });
6773
- group.model.openPanel(item);
7287
+ skipSetActiveGroup: true,
7288
+ }));
7289
+ group.model.openPanel(item, { skipSetGroupActive: true });
6774
7290
  }
6775
7291
  else {
6776
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;
6777
7297
  const skip = typeof (options === null || options === void 0 ? void 0 : options.skipRemoveGroup) === 'boolean' &&
6778
7298
  options.skipRemoveGroup;
6779
7299
  if (!skip) {
6780
- 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
+ }
6781
7321
  }
6782
7322
  }
6783
- group.model.location = 'floating';
7323
+ group.model.location = { type: 'floating' };
6784
7324
  const overlayLeft = typeof (coord === null || coord === void 0 ? void 0 : coord.x) === 'number'
6785
7325
  ? Math.max(coord.x, 0)
6786
7326
  : DEFAULT_FLOATING_GROUP_POSITION.left;
@@ -6790,16 +7330,16 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6790
7330
  const overlay = new Overlay({
6791
7331
  container: this.gridview.element,
6792
7332
  content: group.element,
6793
- height: (_a = coord === null || coord === void 0 ? void 0 : coord.height) !== null && _a !== void 0 ? _a : 300,
6794
- 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,
6795
7335
  left: overlayLeft,
6796
7336
  top: overlayTop,
6797
7337
  minimumInViewportWidth: this.options.floatingGroupBounds === 'boundedWithinViewport'
6798
7338
  ? undefined
6799
- : (_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,
6800
7340
  minimumInViewportHeight: this.options.floatingGroupBounds === 'boundedWithinViewport'
6801
7341
  ? undefined
6802
- : (_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,
6803
7343
  });
6804
7344
  const el = group.element.querySelector('.void-container');
6805
7345
  if (!el) {
@@ -6830,12 +7370,15 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6830
7370
  }), {
6831
7371
  dispose: () => {
6832
7372
  disposable.dispose();
6833
- group.model.location = 'grid';
7373
+ group.model.location = { type: 'grid' };
6834
7374
  remove(this._floatingGroups, floatingGroupPanel);
6835
7375
  this.updateWatermark();
6836
7376
  },
6837
7377
  });
6838
7378
  this._floatingGroups.push(floatingGroupPanel);
7379
+ if (!(options === null || options === void 0 ? void 0 : options.skipActiveGroup)) {
7380
+ this.doSetGroupAndPanelActive(group);
7381
+ }
6839
7382
  this.updateWatermark();
6840
7383
  }
6841
7384
  orthogonalize(position) {
@@ -6925,8 +7468,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6925
7468
  return this.panels.find((panel) => panel.id === id);
6926
7469
  }
6927
7470
  setActivePanel(panel) {
6928
- this.doSetGroupActive(panel.group);
6929
7471
  panel.group.model.openPanel(panel);
7472
+ this.doSetGroupAndPanelActive(panel.group);
6930
7473
  }
6931
7474
  moveToNext(options = {}) {
6932
7475
  var _a;
@@ -6987,7 +7530,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6987
7530
  });
6988
7531
  const popoutGroups = this._popoutGroups.map((group) => {
6989
7532
  return {
6990
- data: group.group.toJSON(),
7533
+ data: group.popoutGroup.toJSON(),
7534
+ gridReferenceGroup: group.referenceGroup,
6991
7535
  position: group.window.dimensions(),
6992
7536
  };
6993
7537
  });
@@ -7005,7 +7549,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7005
7549
  return result;
7006
7550
  }
7007
7551
  fromJSON(data) {
7008
- var _a, _b;
7552
+ var _a, _b, _c;
7009
7553
  this.clear();
7010
7554
  if (typeof data !== 'object' || data === null) {
7011
7555
  throw new Error('serialized layout must be a non-null object');
@@ -7044,7 +7588,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7044
7588
  const isActive = typeof activeView === 'string' &&
7045
7589
  activeView === panel.id;
7046
7590
  group.model.openPanel(panel, {
7047
- skipSetPanelActive: !isActive,
7591
+ skipSetActive: !isActive,
7048
7592
  skipSetGroupActive: true,
7049
7593
  });
7050
7594
  }
@@ -7074,11 +7618,16 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7074
7618
  }
7075
7619
  const serializedPopoutGroups = (_b = data.popoutGroups) !== null && _b !== void 0 ? _b : [];
7076
7620
  for (const serializedPopoutGroup of serializedPopoutGroups) {
7077
- const { data, position } = serializedPopoutGroup;
7621
+ const { data, position, gridReferenceGroup } = serializedPopoutGroup;
7078
7622
  const group = createGroupFromSerializedState(data);
7079
- this.addPopoutGroup(group, {
7623
+ this.addPopoutGroup((_c = (gridReferenceGroup
7624
+ ? this.getPanel(gridReferenceGroup)
7625
+ : undefined)) !== null && _c !== void 0 ? _c : group, {
7080
7626
  skipRemoveGroup: true,
7081
7627
  position: position !== null && position !== void 0 ? position : undefined,
7628
+ overridePopoutGroup: gridReferenceGroup
7629
+ ? group
7630
+ : undefined,
7082
7631
  });
7083
7632
  }
7084
7633
  for (const floatingGroup of this._floatingGroups) {
@@ -7125,12 +7674,13 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7125
7674
  */
7126
7675
  throw err;
7127
7676
  }
7677
+ this.updateWatermark();
7128
7678
  this._onDidLayoutFromJSON.fire();
7129
7679
  }
7130
7680
  clear() {
7131
7681
  const groups = Array.from(this._groups.values()).map((_) => _.value);
7132
7682
  const hasActiveGroup = !!this.activeGroup;
7133
- const hasActivePanel = !!this.activePanel;
7683
+ !!this.activePanel;
7134
7684
  for (const group of groups) {
7135
7685
  // remove the group will automatically remove the panels
7136
7686
  this.removeGroup(group, { skipActive: true });
@@ -7138,9 +7688,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7138
7688
  if (hasActiveGroup) {
7139
7689
  this.doSetGroupAndPanelActive(undefined);
7140
7690
  }
7141
- if (hasActivePanel) {
7142
- this._onDidActivePanelChange.fire(undefined);
7143
- }
7144
7691
  this.gridview.clear();
7145
7692
  }
7146
7693
  closeAllGroups() {
@@ -7181,6 +7728,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7181
7728
  const group = this.orthogonalize(directionToPosition(options.position.direction));
7182
7729
  const panel = this.createPanel(options, group);
7183
7730
  group.model.openPanel(panel);
7731
+ this.doSetGroupAndPanelActive(group);
7184
7732
  return panel;
7185
7733
  }
7186
7734
  }
@@ -7192,6 +7740,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7192
7740
  const target = toTarget(((_b = options.position) === null || _b === void 0 ? void 0 : _b.direction) || 'within');
7193
7741
  if (options.floating) {
7194
7742
  const group = this.createGroup();
7743
+ this._onDidAddGroup.fire(group);
7195
7744
  const o = typeof options.floating === 'object' &&
7196
7745
  options.floating !== null
7197
7746
  ? options.floating
@@ -7199,16 +7748,16 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7199
7748
  this.addFloatingGroup(group, o, {
7200
7749
  inDragMode: false,
7201
7750
  skipRemoveGroup: true,
7751
+ skipActiveGroup: true,
7202
7752
  });
7203
- this._onDidAddGroup.fire(group);
7204
7753
  panel = this.createPanel(options, group);
7205
7754
  group.model.openPanel(panel);
7206
- this.doSetGroupAndPanelActive(group);
7207
7755
  }
7208
- else if (referenceGroup.api.location === 'floating' ||
7756
+ else if (referenceGroup.api.location.type === 'floating' ||
7209
7757
  target === 'center') {
7210
7758
  panel = this.createPanel(options, referenceGroup);
7211
7759
  referenceGroup.model.openPanel(panel);
7760
+ this.doSetGroupAndPanelActive(referenceGroup);
7212
7761
  }
7213
7762
  else {
7214
7763
  const location = getGridLocation(referenceGroup.element);
@@ -7216,10 +7765,12 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7216
7765
  const group = this.createGroupAtLocation(relativeLocation);
7217
7766
  panel = this.createPanel(options, group);
7218
7767
  group.model.openPanel(panel);
7768
+ this.doSetGroupAndPanelActive(group);
7219
7769
  }
7220
7770
  }
7221
7771
  else if (options.floating) {
7222
7772
  const group = this.createGroup();
7773
+ this._onDidAddGroup.fire(group);
7223
7774
  const o = typeof options.floating === 'object' &&
7224
7775
  options.floating !== null
7225
7776
  ? options.floating
@@ -7227,16 +7778,16 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7227
7778
  this.addFloatingGroup(group, o, {
7228
7779
  inDragMode: false,
7229
7780
  skipRemoveGroup: true,
7781
+ skipActiveGroup: true,
7230
7782
  });
7231
- this._onDidAddGroup.fire(group);
7232
7783
  panel = this.createPanel(options, group);
7233
7784
  group.model.openPanel(panel);
7234
- this.doSetGroupAndPanelActive(group);
7235
7785
  }
7236
7786
  else {
7237
7787
  const group = this.createGroupAtLocation();
7238
7788
  panel = this.createPanel(options, group);
7239
7789
  group.model.openPanel(panel);
7790
+ this.doSetGroupAndPanelActive(group);
7240
7791
  }
7241
7792
  return panel;
7242
7793
  }
@@ -7248,13 +7799,15 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7248
7799
  if (!group) {
7249
7800
  throw new Error(`cannot remove panel ${panel.id}. it's missing a group.`);
7250
7801
  }
7251
- group.model.removePanel(panel);
7802
+ group.model.removePanel(panel, {
7803
+ skipSetActiveGroup: options.skipSetActiveGroup,
7804
+ });
7252
7805
  if (!options.skipDispose) {
7253
- this.overlayRenderContainer.detatch(panel);
7806
+ panel.group.model.renderContainer.detatch(panel);
7254
7807
  panel.dispose();
7255
7808
  }
7256
7809
  if (group.size === 0 && options.removeEmptyGroup) {
7257
- this.removeGroup(group);
7810
+ this.removeGroup(group, { skipActive: options.skipSetActiveGroup });
7258
7811
  }
7259
7812
  }
7260
7813
  createWatermarkComponent() {
@@ -7267,7 +7820,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7267
7820
  }
7268
7821
  updateWatermark() {
7269
7822
  var _a, _b;
7270
- 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) {
7271
7824
  if (!this.watermark) {
7272
7825
  this.watermark = this.createWatermarkComponent();
7273
7826
  this.watermark.init({
@@ -7287,7 +7840,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7287
7840
  }
7288
7841
  addGroup(options) {
7289
7842
  var _a;
7290
- const group = this.createGroup();
7843
+ const group = this.createGroup(options);
7291
7844
  if (options) {
7292
7845
  let referenceGroup;
7293
7846
  if (isGroupOptionsWithPanel(options)) {
@@ -7313,36 +7866,42 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7313
7866
  }
7314
7867
  else {
7315
7868
  const group = this.orthogonalize(directionToPosition(options.direction));
7869
+ if (!options.skipSetActive) {
7870
+ this.doSetGroupAndPanelActive(group);
7871
+ }
7316
7872
  return group;
7317
7873
  }
7318
7874
  const target = toTarget(options.direction || 'within');
7319
7875
  const location = getGridLocation(referenceGroup.element);
7320
7876
  const relativeLocation = getRelativeLocation(this.gridview.orientation, location, target);
7321
7877
  this.doAddGroup(group, relativeLocation);
7878
+ if (!options.skipSetActive) {
7879
+ this.doSetGroupAndPanelActive(group);
7880
+ }
7322
7881
  return group;
7323
7882
  }
7324
7883
  else {
7325
7884
  this.doAddGroup(group);
7885
+ this.doSetGroupAndPanelActive(group);
7326
7886
  return group;
7327
7887
  }
7328
7888
  }
7329
7889
  removeGroup(group, options) {
7890
+ this.doRemoveGroup(group, options);
7891
+ }
7892
+ doRemoveGroup(group, options) {
7330
7893
  var _a;
7331
7894
  const panels = [...group.panels]; // reassign since group panels will mutate
7332
- for (const panel of panels) {
7333
- this.removePanel(panel, {
7334
- removeEmptyGroup: false,
7335
- skipDispose: (_a = options === null || options === void 0 ? void 0 : options.skipDispose) !== null && _a !== void 0 ? _a : false,
7336
- });
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
+ }
7337
7902
  }
7338
7903
  const activePanel = this.activePanel;
7339
- this.doRemoveGroup(group, options);
7340
- if (this.activePanel !== activePanel) {
7341
- this._onDidActivePanelChange.fire(this.activePanel);
7342
- }
7343
- }
7344
- doRemoveGroup(group, options) {
7345
- if (group.api.location === 'floating') {
7904
+ if (group.api.location.type === 'floating') {
7346
7905
  const floatingGroup = this._floatingGroups.find((_) => _.group === group);
7347
7906
  if (floatingGroup) {
7348
7907
  if (!(options === null || options === void 0 ? void 0 : options.skipDispose)) {
@@ -7354,60 +7913,124 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7354
7913
  floatingGroup.dispose();
7355
7914
  if (!(options === null || options === void 0 ? void 0 : options.skipActive) && this._activeGroup === group) {
7356
7915
  const groups = Array.from(this._groups.values());
7357
- this.doSetGroupActive(groups.length > 0 ? groups[0].value : undefined);
7916
+ this.doSetGroupAndPanelActive(groups.length > 0 ? groups[0].value : undefined);
7358
7917
  }
7359
7918
  return floatingGroup.group;
7360
7919
  }
7361
7920
  throw new Error('failed to find floating group');
7362
7921
  }
7363
- if (group.api.location === 'popout') {
7364
- const selectedGroup = this._popoutGroups.find((_) => _.group === group);
7922
+ if (group.api.location.type === 'popout') {
7923
+ const selectedGroup = this._popoutGroups.find((_) => _.popoutGroup === group);
7365
7924
  if (selectedGroup) {
7366
7925
  if (!(options === null || options === void 0 ? void 0 : options.skipDispose)) {
7367
- 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();
7368
7935
  this._groups.delete(group.id);
7369
7936
  this._onDidRemoveGroup.fire(group);
7370
7937
  }
7371
- 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
+ }
7372
7943
  if (!(options === null || options === void 0 ? void 0 : options.skipActive) && this._activeGroup === group) {
7373
7944
  const groups = Array.from(this._groups.values());
7374
- this.doSetGroupActive(groups.length > 0 ? groups[0].value : undefined);
7945
+ this.doSetGroupAndPanelActive(groups.length > 0 ? groups[0].value : undefined);
7375
7946
  }
7376
- return selectedGroup.group;
7947
+ this.updateWatermark();
7948
+ return selectedGroup.popoutGroup;
7377
7949
  }
7378
7950
  throw new Error('failed to find popout group');
7379
7951
  }
7380
- 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;
7381
7959
  }
7382
- moveGroupOrPanel(destinationGroup, sourceGroupId, sourceItemId, destinationTarget, destinationIndex) {
7383
- 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;
7384
7977
  const sourceGroup = sourceGroupId
7385
7978
  ? (_a = this._groups.get(sourceGroupId)) === null || _a === void 0 ? void 0 : _a.value
7386
7979
  : undefined;
7980
+ if (!sourceGroup) {
7981
+ throw new Error(`Failed to find group id ${sourceGroupId}`);
7982
+ }
7387
7983
  if (sourceItemId === undefined) {
7388
- if (sourceGroup) {
7389
- this.moveGroup(sourceGroup, destinationGroup, destinationTarget);
7390
- }
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
+ });
7391
7994
  return;
7392
7995
  }
7393
7996
  if (!destinationTarget || destinationTarget === 'center') {
7394
- 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);
7395
- 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) {
7396
8005
  throw new Error(`No panel with id ${sourceItemId}`);
7397
8006
  }
7398
- if ((sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.size) === 0) {
7399
- 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 });
7400
8010
  }
7401
- destinationGroup.model.openPanel(groupItem, {
8011
+ this.movingLock(() => destinationGroup.model.openPanel(removedPanel, {
7402
8012
  index: destinationIndex,
8013
+ skipSetGroupActive: true,
8014
+ }));
8015
+ this.doSetGroupAndPanelActive(destinationGroup);
8016
+ this._onDidMovePanel.fire({
8017
+ panel: removedPanel,
7403
8018
  });
7404
8019
  }
7405
8020
  else {
8021
+ /**
8022
+ * Dropping a panel to the extremities of a group which will place that panel
8023
+ * into an adjacent group
8024
+ */
7406
8025
  const referenceLocation = getGridLocation(destinationGroup.element);
7407
8026
  const targetLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, destinationTarget);
7408
- 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
+ */
7409
8032
  const [targetParentLocation, to] = tail(targetLocation);
7410
- if (sourceGroup.api.location === 'grid') {
8033
+ if (sourceGroup.api.location.type === 'grid') {
7411
8034
  const sourceLocation = getGridLocation(sourceGroup.element);
7412
8035
  const [sourceParentLocation, from] = tail(sourceLocation);
7413
8036
  if (sequenceEquals(sourceParentLocation, targetParentLocation)) {
@@ -7415,78 +8038,123 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7415
8038
  // if a group has one tab - we are essentially moving the 'group'
7416
8039
  // which is equivalent to swapping two views in this case
7417
8040
  this.gridview.moveView(sourceParentLocation, from, to);
8041
+ return;
7418
8042
  }
7419
8043
  }
7420
8044
  // source group will become empty so delete the group
7421
- const targetGroup = this.doRemoveGroup(sourceGroup, {
8045
+ const targetGroup = this.movingLock(() => this.doRemoveGroup(sourceGroup, {
7422
8046
  skipActive: true,
7423
8047
  skipDispose: true,
7424
- });
8048
+ }));
7425
8049
  // after deleting the group we need to re-evaulate the ref location
7426
8050
  const updatedReferenceLocation = getGridLocation(destinationGroup.element);
7427
8051
  const location = getRelativeLocation(this.gridview.orientation, updatedReferenceLocation, destinationTarget);
7428
- this.doAddGroup(targetGroup, location);
8052
+ this.movingLock(() => this.doAddGroup(targetGroup, location));
8053
+ this.doSetGroupAndPanelActive(targetGroup);
7429
8054
  }
7430
8055
  else {
7431
- 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);
7432
- 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) {
7433
8065
  throw new Error(`No panel with id ${sourceItemId}`);
7434
8066
  }
7435
8067
  const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, destinationTarget);
7436
8068
  const group = this.createGroupAtLocation(dropLocation);
7437
- group.model.openPanel(groupItem);
8069
+ this.movingLock(() => group.model.openPanel(removedPanel, {
8070
+ skipSetGroupActive: true,
8071
+ }));
8072
+ this.doSetGroupAndPanelActive(group);
7438
8073
  }
7439
8074
  }
7440
8075
  }
7441
- moveGroup(sourceGroup, referenceGroup, target) {
7442
- if (sourceGroup) {
7443
- if (!target || target === 'center') {
7444
- const activePanel = sourceGroup.activePanel;
7445
- const panels = [...sourceGroup.panels].map((p) => sourceGroup.model.removePanel(p.id));
7446
- if ((sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.size) === 0) {
7447
- this.doRemoveGroup(sourceGroup);
7448
- }
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(() => {
7449
8089
  for (const panel of panels) {
7450
- referenceGroup.model.openPanel(panel, {
7451
- skipSetPanelActive: panel !== activePanel,
8090
+ to.model.openPanel(panel, {
8091
+ skipSetActive: panel !== activePanel,
8092
+ skipSetGroupActive: true,
7452
8093
  });
7453
8094
  }
7454
- }
7455
- else {
7456
- switch (sourceGroup.api.location) {
7457
- case 'grid':
7458
- this.gridview.removeView(getGridLocation(sourceGroup.element));
7459
- break;
7460
- case 'floating': {
7461
- const selectedFloatingGroup = this._floatingGroups.find((x) => x.group === sourceGroup);
7462
- if (!selectedFloatingGroup) {
7463
- throw new Error('failed to find floating group');
7464
- }
7465
- selectedFloatingGroup.dispose();
7466
- 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');
7467
8110
  }
7468
- case 'popout': {
7469
- const selectedPopoutGroup = this._popoutGroups.find((x) => x.group === sourceGroup);
7470
- if (!selectedPopoutGroup) {
7471
- throw new Error('failed to find popout group');
7472
- }
7473
- 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');
7474
8118
  }
8119
+ selectedPopoutGroup.disposable.dispose();
7475
8120
  }
7476
- const referenceLocation = getGridLocation(referenceGroup.element);
7477
- const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, target);
7478
- this.gridview.addView(sourceGroup, exports.Sizing.Distribute, dropLocation);
7479
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
+ });
7480
8128
  }
7481
8129
  }
7482
- doSetGroupAndPanelActive(group, skipFocus) {
7483
- 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);
7484
8140
  const activePanel = this.activePanel;
7485
- super.doSetGroupActive(group, skipFocus);
7486
- if (((_a = this._activeGroup) === null || _a === void 0 ? void 0 : _a.activePanel) !== activePanel) {
7487
- 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);
7488
8149
  }
7489
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
+ }
7490
8158
  createGroup(options) {
7491
8159
  if (!options) {
7492
8160
  options = {};
@@ -7503,7 +8171,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7503
8171
  }
7504
8172
  }
7505
8173
  const view = new DockviewGroupPanel(this, id, options);
7506
- view.init({ params: {}, accessor: null }); // required to initialized .part and allow for correct disposal of group
8174
+ view.init({ params: {}, accessor: this });
7507
8175
  if (!this._groups.has(view.id)) {
7508
8176
  const disposable = new CompositeDisposable(view.model.onTabDragStart((event) => {
7509
8177
  this._onWillDragPanel.fire(event);
@@ -7511,20 +8179,48 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7511
8179
  this._onWillDragGroup.fire(event);
7512
8180
  }), view.model.onMove((event) => {
7513
8181
  const { groupId, itemId, target, index } = event;
7514
- 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
+ });
7515
8190
  }), view.model.onDidDrop((event) => {
7516
- 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);
7517
8200
  }), view.model.onDidAddPanel((event) => {
8201
+ if (this._moving) {
8202
+ return;
8203
+ }
7518
8204
  this._onDidAddPanel.fire(event.panel);
7519
8205
  }), view.model.onDidRemovePanel((event) => {
8206
+ if (this._moving) {
8207
+ return;
8208
+ }
7520
8209
  this._onDidRemovePanel.fire(event.panel);
7521
8210
  }), view.model.onDidActivePanelChange((event) => {
7522
- 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
+ }
7523
8220
  }));
7524
8221
  this._groups.set(view.id, { value: view, disposable });
7525
8222
  }
7526
- // TODO: must be called after the above listeners have been setup,
7527
- // not an ideal pattern
8223
+ // TODO: must be called after the above listeners have been setup, not an ideal pattern
7528
8224
  view.initialize();
7529
8225
  return view;
7530
8226
  }
@@ -7577,7 +8273,20 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7577
8273
  });
7578
8274
  this._onDidLayoutfromJSON = new Emitter();
7579
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;
7580
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
+ }));
7581
8290
  if (!this.options.components) {
7582
8291
  this.options.components = {};
7583
8292
  }
@@ -7752,6 +8461,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7752
8461
  });
7753
8462
  this.registerPanel(view);
7754
8463
  this.doAddGroup(view, relativeLocation, options.size);
8464
+ this.doSetGroupActive(view);
7755
8465
  return view;
7756
8466
  }
7757
8467
  registerPanel(panel) {
@@ -8437,10 +9147,10 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
8437
9147
  this._onDidChange = new Emitter();
8438
9148
  this.onDidChange = this._onDidChange.event;
8439
9149
  this.api.initialize(this);
8440
- this.addDisposables(this._onDidChange, this.api.onVisibilityChange((event) => {
8441
- const { isVisible } = event;
9150
+ this.addDisposables(this._onDidChange, this.api.onDidHiddenChange((event) => {
9151
+ const { isHidden } = event;
8442
9152
  const { accessor } = this._params;
8443
- accessor.setVisible(this, isVisible);
9153
+ accessor.setVisible(this, !isHidden);
8444
9154
  }), this.api.onActiveChange(() => {
8445
9155
  const { accessor } = this._params;
8446
9156
  accessor.setActive(this);
@@ -8562,13 +9272,13 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
8562
9272
  if (this.disposed) {
8563
9273
  throw new Error('invalid operation: resource is already disposed');
8564
9274
  }
8565
- if (typeof this.component !== 'function') {
9275
+ if (!isReactComponent(this.component)) {
8566
9276
  /**
8567
9277
  * we know this isn't a React.FunctionComponent so throw an error here.
8568
- * if we do not intercept this the React library will throw a very obsure error
8569
- * 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.
8570
9280
  */
8571
- 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');
8572
9282
  }
8573
9283
  const bridgeComponent = React__namespace.createElement(React__namespace.forwardRef(ReactComponentBridge), {
8574
9284
  component: this
@@ -8620,9 +9330,13 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
8620
9330
  }, []);
8621
9331
  return [portals, addPortal];
8622
9332
  };
8623
- // it does the job...
8624
- function isReactElement(element) {
8625
- 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 */);
8626
9340
  }
8627
9341
 
8628
9342
  class ReactPanelContentPart {
@@ -8882,6 +9596,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
8882
9596
  defaultRenderer: props.defaultRenderer,
8883
9597
  debug: props.debug,
8884
9598
  rootOverlayModel: props.rootOverlayModel,
9599
+ locked: props.locked,
9600
+ disableDnd: props.disableDnd,
8885
9601
  });
8886
9602
  const { clientWidth, clientHeight } = domRef.current;
8887
9603
  dockview.layout(clientWidth, clientHeight);
@@ -8893,6 +9609,20 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
8893
9609
  dockview.dispose();
8894
9610
  };
8895
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]);
8896
9626
  React__namespace.useEffect(() => {
8897
9627
  if (!dockviewRef.current) {
8898
9628
  return () => {
@@ -8908,6 +9638,21 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
8908
9638
  disposable.dispose();
8909
9639
  };
8910
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]);
8911
9656
  React__namespace.useEffect(() => {
8912
9657
  if (!dockviewRef.current) {
8913
9658
  return;
@@ -9150,7 +9895,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
9150
9895
  return new ReactPart(this.element, this.reactPortalStore, this.reactComponent, {
9151
9896
  params: (_b = (_a = this._params) === null || _a === void 0 ? void 0 : _a.params) !== null && _b !== void 0 ? _b : {},
9152
9897
  api: this.api,
9153
- containerApi: new GridviewApi(this._params.accessor),
9898
+ // TODO: fix casting hack
9899
+ containerApi: new GridviewApi(this._params
9900
+ .accessor),
9154
9901
  });
9155
9902
  }
9156
9903
  }
@@ -9333,12 +10080,14 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
9333
10080
  exports.DockviewComponent = DockviewComponent;
9334
10081
  exports.DockviewCompositeDisposable = CompositeDisposable;
9335
10082
  exports.DockviewDefaultTab = DockviewDefaultTab;
10083
+ exports.DockviewDidDropEvent = DockviewDidDropEvent;
9336
10084
  exports.DockviewEmitter = Emitter;
9337
10085
  exports.DockviewGroupPanel = DockviewGroupPanel;
9338
10086
  exports.DockviewGroupPanelModel = DockviewGroupPanelModel;
9339
10087
  exports.DockviewMutableDisposable = MutableDisposable;
9340
10088
  exports.DockviewPanel = DockviewPanel;
9341
10089
  exports.DockviewReact = DockviewReact;
10090
+ exports.DockviewWillDropEvent = DockviewWillDropEvent;
9342
10091
  exports.DraggablePaneviewPanel = DraggablePaneviewPanel;
9343
10092
  exports.Gridview = Gridview;
9344
10093
  exports.GridviewApi = GridviewApi;
@@ -9362,6 +10111,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
9362
10111
  exports.SplitviewPanel = SplitviewPanel;
9363
10112
  exports.SplitviewReact = SplitviewReact;
9364
10113
  exports.Tab = Tab;
10114
+ exports.WillShowOverlayLocationEvent = WillShowOverlayLocationEvent;
9365
10115
  exports.createComponent = createComponent;
9366
10116
  exports.directionToPosition = directionToPosition;
9367
10117
  exports.getDirectionOrientation = getDirectionOrientation;
@@ -9376,7 +10126,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
9376
10126
  exports.isGroupOptionsWithPanel = isGroupOptionsWithPanel;
9377
10127
  exports.isPanelOptionsWithGroup = isPanelOptionsWithGroup;
9378
10128
  exports.isPanelOptionsWithPanel = isPanelOptionsWithPanel;
9379
- exports.isReactElement = isReactElement;
10129
+ exports.isReactComponent = isReactComponent;
9380
10130
  exports.orthogonal = orthogonal;
9381
10131
  exports.positionToDirection = positionToDirection;
9382
10132
  exports.toTarget = toTarget;