dockview 1.9.2 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/dist/cjs/dockview/defaultTab.d.ts +0 -1
  2. package/dist/cjs/dockview/defaultTab.js +0 -1
  3. package/dist/cjs/dockview/dockview.d.ts +5 -3
  4. package/dist/cjs/dockview/dockview.js +31 -1
  5. package/dist/cjs/dockview/headerActionsRenderer.d.ts +0 -1
  6. package/dist/cjs/dockview/headerActionsRenderer.js +0 -1
  7. package/dist/cjs/dockview/reactContentPart.d.ts +0 -1
  8. package/dist/cjs/dockview/reactContentPart.js +0 -1
  9. package/dist/cjs/dockview/reactHeaderPart.d.ts +0 -1
  10. package/dist/cjs/dockview/reactHeaderPart.js +0 -1
  11. package/dist/cjs/dockview/reactWatermarkPart.d.ts +0 -1
  12. package/dist/cjs/dockview/reactWatermarkPart.js +0 -1
  13. package/dist/cjs/gridview/gridview.d.ts +0 -1
  14. package/dist/cjs/gridview/gridview.js +0 -1
  15. package/dist/cjs/gridview/view.d.ts +0 -1
  16. package/dist/cjs/gridview/view.js +3 -2
  17. package/dist/cjs/index.d.ts +0 -1
  18. package/dist/cjs/index.js +0 -1
  19. package/dist/cjs/paneview/paneview.d.ts +0 -1
  20. package/dist/cjs/paneview/paneview.js +0 -1
  21. package/dist/cjs/paneview/view.d.ts +0 -1
  22. package/dist/cjs/paneview/view.js +0 -1
  23. package/dist/cjs/react.d.ts +1 -2
  24. package/dist/cjs/react.js +13 -10
  25. package/dist/cjs/splitview/splitview.d.ts +0 -1
  26. package/dist/cjs/splitview/splitview.js +0 -1
  27. package/dist/cjs/splitview/view.d.ts +0 -1
  28. package/dist/cjs/splitview/view.js +0 -1
  29. package/dist/cjs/svg.d.ts +0 -1
  30. package/dist/cjs/svg.js +0 -1
  31. package/dist/cjs/types.d.ts +0 -1
  32. package/dist/cjs/types.js +0 -1
  33. package/dist/dockview.amd.js +1283 -534
  34. package/dist/dockview.amd.js.map +1 -1
  35. package/dist/dockview.amd.min.js +2 -2
  36. package/dist/dockview.amd.min.js.map +1 -1
  37. package/dist/dockview.amd.min.noStyle.js +2 -2
  38. package/dist/dockview.amd.min.noStyle.js.map +1 -1
  39. package/dist/dockview.amd.noStyle.js +1283 -534
  40. package/dist/dockview.amd.noStyle.js.map +1 -1
  41. package/dist/dockview.cjs.js +1283 -534
  42. package/dist/dockview.cjs.js.map +1 -1
  43. package/dist/dockview.esm.js +1280 -534
  44. package/dist/dockview.esm.js.map +1 -1
  45. package/dist/dockview.esm.min.js +2 -2
  46. package/dist/dockview.esm.min.js.map +1 -1
  47. package/dist/dockview.js +1283 -534
  48. package/dist/dockview.js.map +1 -1
  49. package/dist/dockview.min.js +2 -2
  50. package/dist/dockview.min.js.map +1 -1
  51. package/dist/dockview.min.noStyle.js +2 -2
  52. package/dist/dockview.min.noStyle.js.map +1 -1
  53. package/dist/dockview.noStyle.js +1283 -534
  54. package/dist/dockview.noStyle.js.map +1 -1
  55. package/dist/esm/dockview/defaultTab.d.ts +0 -1
  56. package/dist/esm/dockview/defaultTab.js +0 -1
  57. package/dist/esm/dockview/dockview.d.ts +5 -3
  58. package/dist/esm/dockview/dockview.js +31 -1
  59. package/dist/esm/dockview/headerActionsRenderer.d.ts +0 -1
  60. package/dist/esm/dockview/headerActionsRenderer.js +0 -1
  61. package/dist/esm/dockview/reactContentPart.d.ts +0 -1
  62. package/dist/esm/dockview/reactContentPart.js +0 -1
  63. package/dist/esm/dockview/reactHeaderPart.d.ts +0 -1
  64. package/dist/esm/dockview/reactHeaderPart.js +0 -1
  65. package/dist/esm/dockview/reactWatermarkPart.d.ts +0 -1
  66. package/dist/esm/dockview/reactWatermarkPart.js +0 -1
  67. package/dist/esm/gridview/gridview.d.ts +0 -1
  68. package/dist/esm/gridview/gridview.js +0 -1
  69. package/dist/esm/gridview/view.d.ts +0 -1
  70. package/dist/esm/gridview/view.js +3 -2
  71. package/dist/esm/index.d.ts +0 -1
  72. package/dist/esm/index.js +0 -1
  73. package/dist/esm/paneview/paneview.d.ts +0 -1
  74. package/dist/esm/paneview/paneview.js +0 -1
  75. package/dist/esm/paneview/view.d.ts +0 -1
  76. package/dist/esm/paneview/view.js +0 -1
  77. package/dist/esm/react.d.ts +1 -2
  78. package/dist/esm/react.js +11 -8
  79. package/dist/esm/splitview/splitview.d.ts +0 -1
  80. package/dist/esm/splitview/splitview.js +0 -1
  81. package/dist/esm/splitview/view.d.ts +0 -1
  82. package/dist/esm/splitview/view.js +0 -1
  83. package/dist/esm/svg.d.ts +0 -1
  84. package/dist/esm/svg.js +0 -1
  85. package/dist/esm/types.d.ts +0 -1
  86. package/dist/esm/types.js +0 -1
  87. package/package.json +4 -4
  88. package/dist/cjs/dockview/defaultTab.d.ts.map +0 -1
  89. package/dist/cjs/dockview/defaultTab.js.map +0 -1
  90. package/dist/cjs/dockview/dockview.d.ts.map +0 -1
  91. package/dist/cjs/dockview/dockview.js.map +0 -1
  92. package/dist/cjs/dockview/headerActionsRenderer.d.ts.map +0 -1
  93. package/dist/cjs/dockview/headerActionsRenderer.js.map +0 -1
  94. package/dist/cjs/dockview/reactContentPart.d.ts.map +0 -1
  95. package/dist/cjs/dockview/reactContentPart.js.map +0 -1
  96. package/dist/cjs/dockview/reactHeaderPart.d.ts.map +0 -1
  97. package/dist/cjs/dockview/reactHeaderPart.js.map +0 -1
  98. package/dist/cjs/dockview/reactWatermarkPart.d.ts.map +0 -1
  99. package/dist/cjs/dockview/reactWatermarkPart.js.map +0 -1
  100. package/dist/cjs/gridview/gridview.d.ts.map +0 -1
  101. package/dist/cjs/gridview/gridview.js.map +0 -1
  102. package/dist/cjs/gridview/view.d.ts.map +0 -1
  103. package/dist/cjs/gridview/view.js.map +0 -1
  104. package/dist/cjs/index.d.ts.map +0 -1
  105. package/dist/cjs/index.js.map +0 -1
  106. package/dist/cjs/paneview/paneview.d.ts.map +0 -1
  107. package/dist/cjs/paneview/paneview.js.map +0 -1
  108. package/dist/cjs/paneview/view.d.ts.map +0 -1
  109. package/dist/cjs/paneview/view.js.map +0 -1
  110. package/dist/cjs/react.d.ts.map +0 -1
  111. package/dist/cjs/react.js.map +0 -1
  112. package/dist/cjs/splitview/splitview.d.ts.map +0 -1
  113. package/dist/cjs/splitview/splitview.js.map +0 -1
  114. package/dist/cjs/splitview/view.d.ts.map +0 -1
  115. package/dist/cjs/splitview/view.js.map +0 -1
  116. package/dist/cjs/svg.d.ts.map +0 -1
  117. package/dist/cjs/svg.js.map +0 -1
  118. package/dist/cjs/types.d.ts.map +0 -1
  119. package/dist/cjs/types.js.map +0 -1
  120. package/dist/esm/dockview/defaultTab.d.ts.map +0 -1
  121. package/dist/esm/dockview/defaultTab.js.map +0 -1
  122. package/dist/esm/dockview/dockview.d.ts.map +0 -1
  123. package/dist/esm/dockview/dockview.js.map +0 -1
  124. package/dist/esm/dockview/headerActionsRenderer.d.ts.map +0 -1
  125. package/dist/esm/dockview/headerActionsRenderer.js.map +0 -1
  126. package/dist/esm/dockview/reactContentPart.d.ts.map +0 -1
  127. package/dist/esm/dockview/reactContentPart.js.map +0 -1
  128. package/dist/esm/dockview/reactHeaderPart.d.ts.map +0 -1
  129. package/dist/esm/dockview/reactHeaderPart.js.map +0 -1
  130. package/dist/esm/dockview/reactWatermarkPart.d.ts.map +0 -1
  131. package/dist/esm/dockview/reactWatermarkPart.js.map +0 -1
  132. package/dist/esm/gridview/gridview.d.ts.map +0 -1
  133. package/dist/esm/gridview/gridview.js.map +0 -1
  134. package/dist/esm/gridview/view.d.ts.map +0 -1
  135. package/dist/esm/gridview/view.js.map +0 -1
  136. package/dist/esm/index.d.ts.map +0 -1
  137. package/dist/esm/index.js.map +0 -1
  138. package/dist/esm/paneview/paneview.d.ts.map +0 -1
  139. package/dist/esm/paneview/paneview.js.map +0 -1
  140. package/dist/esm/paneview/view.d.ts.map +0 -1
  141. package/dist/esm/paneview/view.js.map +0 -1
  142. package/dist/esm/react.d.ts.map +0 -1
  143. package/dist/esm/react.js.map +0 -1
  144. package/dist/esm/splitview/splitview.d.ts.map +0 -1
  145. package/dist/esm/splitview/splitview.js.map +0 -1
  146. package/dist/esm/splitview/view.d.ts.map +0 -1
  147. package/dist/esm/splitview/view.js.map +0 -1
  148. package/dist/esm/svg.d.ts.map +0 -1
  149. package/dist/esm/svg.js.map +0 -1
  150. package/dist/esm/types.d.ts.map +0 -1
  151. package/dist/esm/types.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * dockview
3
- * @version 1.9.2
3
+ * @version 1.10.0
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -108,6 +108,17 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
108
108
  };
109
109
  };
110
110
  })(exports.DockviewEvent || (exports.DockviewEvent = {}));
111
+ class DockviewEvent {
112
+ constructor() {
113
+ this._defaultPrevented = false;
114
+ }
115
+ get defaultPrevented() {
116
+ return this._defaultPrevented;
117
+ }
118
+ preventDefault() {
119
+ this._defaultPrevented = true;
120
+ }
121
+ }
111
122
  class LeakageMonitor {
112
123
  constructor() {
113
124
  this.events = new Map();
@@ -151,6 +162,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
151
162
  }
152
163
  Emitter.ENABLE_TRACKING = isEnabled;
153
164
  }
165
+ get value() {
166
+ return this._last;
167
+ }
154
168
  constructor(options) {
155
169
  this.options = options;
156
170
  this._listeners = [];
@@ -273,8 +287,12 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
273
287
  args.forEach((arg) => this._disposables.push(arg));
274
288
  }
275
289
  dispose() {
276
- this._disposables.forEach((arg) => arg.dispose());
290
+ if (this._isDisposed) {
291
+ return;
292
+ }
277
293
  this._isDisposed = true;
294
+ this._disposables.forEach((arg) => arg.dispose());
295
+ this._disposables = [];
278
296
  }
279
297
  }
280
298
  class MutableDisposable {
@@ -758,6 +776,13 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
758
776
  this._endSnappingEnabled = endSnappingEnabled;
759
777
  this.updateSashEnablement();
760
778
  }
779
+ get disabled() {
780
+ return this._disabled;
781
+ }
782
+ set disabled(value) {
783
+ this._disabled = value;
784
+ toggleClass(this.element, 'dv-splitview-disabled', value);
785
+ }
761
786
  constructor(container, options) {
762
787
  this.container = container;
763
788
  this.viewItems = [];
@@ -768,6 +793,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
768
793
  this._proportions = undefined;
769
794
  this._startSnappingEnabled = true;
770
795
  this._endSnappingEnabled = true;
796
+ this._disabled = false;
771
797
  this._onDidSashEnd = new Emitter();
772
798
  this.onDidSashEnd = this._onDidSashEnd.event;
773
799
  this._onDidAddView = new Emitter();
@@ -1695,7 +1721,13 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1695
1721
  }
1696
1722
  return exports.LayoutPriority.Normal;
1697
1723
  }
1698
- constructor(orientation, proportionalLayout, styles, size, orthogonalSize, childDescriptors) {
1724
+ get disabled() {
1725
+ return this.splitview.disabled;
1726
+ }
1727
+ set disabled(value) {
1728
+ this.splitview.disabled = value;
1729
+ }
1730
+ constructor(orientation, proportionalLayout, styles, size, orthogonalSize, disabled, childDescriptors) {
1699
1731
  super();
1700
1732
  this.orientation = orientation;
1701
1733
  this.proportionalLayout = proportionalLayout;
@@ -1740,6 +1772,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1740
1772
  styles,
1741
1773
  });
1742
1774
  }
1775
+ this.disabled = disabled;
1743
1776
  this.addDisposables(this._onDidChange, this._onDidVisibilityChange, this.splitview.onDidSashEnd(() => {
1744
1777
  this._onDidChange.fire({});
1745
1778
  }));
@@ -1873,7 +1906,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
1873
1906
  }
1874
1907
  function flipNode(node, size, orthogonalSize) {
1875
1908
  if (node instanceof BranchNode) {
1876
- const result = new BranchNode(orthogonal(node.orientation), node.proportionalLayout, node.styles, size, orthogonalSize);
1909
+ const result = new BranchNode(orthogonal(node.orientation), node.proportionalLayout, node.styles, size, orthogonalSize, node.disabled);
1877
1910
  let totalSize = 0;
1878
1911
  for (let i = node.children.length - 1; i >= 0; i--) {
1879
1912
  const child = node.children[i];
@@ -2009,31 +2042,57 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2009
2042
  get maximumHeight() {
2010
2043
  return this.root.maximumHeight;
2011
2044
  }
2045
+ get locked() {
2046
+ return this._locked;
2047
+ }
2048
+ set locked(value) {
2049
+ this._locked = value;
2050
+ const branch = [this.root];
2051
+ /**
2052
+ * simple depth-first-search to cover all nodes
2053
+ *
2054
+ * @see https://en.wikipedia.org/wiki/Depth-first_search
2055
+ */
2056
+ while (branch.length > 0) {
2057
+ const node = branch.pop();
2058
+ if (node instanceof BranchNode) {
2059
+ node.disabled = value;
2060
+ branch.push(...node.children);
2061
+ }
2062
+ }
2063
+ }
2012
2064
  maximizedView() {
2013
2065
  var _a;
2014
- return (_a = this._maximizedNode) === null || _a === void 0 ? void 0 : _a.view;
2066
+ return (_a = this._maximizedNode) === null || _a === void 0 ? void 0 : _a.leaf.view;
2015
2067
  }
2016
2068
  hasMaximizedView() {
2017
2069
  return this._maximizedNode !== undefined;
2018
2070
  }
2019
2071
  maximizeView(view) {
2072
+ var _a;
2020
2073
  const location = getGridLocation(view.element);
2021
2074
  const [_, node] = this.getNode(location);
2022
2075
  if (!(node instanceof LeafNode)) {
2023
2076
  return;
2024
2077
  }
2025
- if (this._maximizedNode === node) {
2078
+ if (((_a = this._maximizedNode) === null || _a === void 0 ? void 0 : _a.leaf) === node) {
2026
2079
  return;
2027
2080
  }
2028
2081
  if (this.hasMaximizedView()) {
2029
2082
  this.exitMaximizedView();
2030
2083
  }
2084
+ const hiddenOnMaximize = [];
2031
2085
  function hideAllViewsBut(parent, exclude) {
2032
2086
  for (let i = 0; i < parent.children.length; i++) {
2033
2087
  const child = parent.children[i];
2034
2088
  if (child instanceof LeafNode) {
2035
2089
  if (child !== exclude) {
2036
- parent.setChildVisible(i, false);
2090
+ if (parent.isChildVisible(i)) {
2091
+ parent.setChildVisible(i, false);
2092
+ }
2093
+ else {
2094
+ hiddenOnMaximize.push(child);
2095
+ }
2037
2096
  }
2038
2097
  }
2039
2098
  else {
@@ -2042,18 +2101,21 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2042
2101
  }
2043
2102
  }
2044
2103
  hideAllViewsBut(this.root, node);
2045
- this._maximizedNode = node;
2046
- this._onDidMaxmizedNodeChange.fire();
2104
+ this._maximizedNode = { leaf: node, hiddenOnMaximize };
2105
+ this._onDidMaximizedNodeChange.fire();
2047
2106
  }
2048
2107
  exitMaximizedView() {
2049
2108
  if (!this._maximizedNode) {
2050
2109
  return;
2051
2110
  }
2111
+ const hiddenOnMaximize = this._maximizedNode.hiddenOnMaximize;
2052
2112
  function showViewsInReverseOrder(parent) {
2053
2113
  for (let index = parent.children.length - 1; index >= 0; index--) {
2054
2114
  const child = parent.children[index];
2055
2115
  if (child instanceof LeafNode) {
2056
- parent.setChildVisible(index, true);
2116
+ if (!hiddenOnMaximize.includes(child)) {
2117
+ parent.setChildVisible(index, true);
2118
+ }
2057
2119
  }
2058
2120
  else {
2059
2121
  showViewsInReverseOrder(child);
@@ -2062,13 +2124,13 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2062
2124
  }
2063
2125
  showViewsInReverseOrder(this.root);
2064
2126
  this._maximizedNode = undefined;
2065
- this._onDidMaxmizedNodeChange.fire();
2127
+ this._onDidMaximizedNodeChange.fire();
2066
2128
  }
2067
2129
  serialize() {
2068
2130
  if (this.hasMaximizedView()) {
2069
2131
  /**
2070
- * do not persist maximized view state but we must first exit any maximized views
2071
- * before serialization to ensure the correct dimensions are persisted
2132
+ * do not persist maximized view state
2133
+ * firstly exit any maximized views to ensure the correct dimensions are persisted
2072
2134
  */
2073
2135
  this.exitMaximizedView();
2074
2136
  }
@@ -2083,14 +2145,14 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2083
2145
  dispose() {
2084
2146
  this.disposable.dispose();
2085
2147
  this._onDidChange.dispose();
2086
- this._onDidMaxmizedNodeChange.dispose();
2148
+ this._onDidMaximizedNodeChange.dispose();
2087
2149
  this.root.dispose();
2088
2150
  this._maximizedNode = undefined;
2089
2151
  this.element.remove();
2090
2152
  }
2091
2153
  clear() {
2092
2154
  const orientation = this.root.orientation;
2093
- this.root = new BranchNode(orientation, this.proportionalLayout, this.styles, this.root.size, this.root.orthogonalSize);
2155
+ this.root = new BranchNode(orientation, this.proportionalLayout, this.styles, this.root.size, this.root.orthogonalSize, this._locked);
2094
2156
  }
2095
2157
  deserialize(json, deserializer) {
2096
2158
  const orientation = json.orientation;
@@ -2111,8 +2173,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2111
2173
  };
2112
2174
  });
2113
2175
  result = new BranchNode(orientation, this.proportionalLayout, this.styles, node.size, // <- orthogonal size - flips at each depth
2114
- orthogonalSize, // <- size - flips at each depth
2115
- children);
2176
+ orthogonalSize, // <- size - flips at each depth,
2177
+ this._locked, children);
2116
2178
  }
2117
2179
  else {
2118
2180
  result = new LeafNode(deserializer.fromJSON(node), orientation, orthogonalSize, node.size);
@@ -2145,7 +2207,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2145
2207
  }
2146
2208
  const oldRoot = this.root;
2147
2209
  oldRoot.element.remove();
2148
- this._root = new BranchNode(orthogonal(oldRoot.orientation), this.proportionalLayout, this.styles, this.root.orthogonalSize, this.root.size);
2210
+ this._root = new BranchNode(orthogonal(oldRoot.orientation), this.proportionalLayout, this.styles, this.root.orthogonalSize, this.root.size, this._locked);
2149
2211
  if (oldRoot.children.length === 0) ;
2150
2212
  else if (oldRoot.children.length === 1) {
2151
2213
  // can remove one level of redundant branching if there is only a single child
@@ -2213,15 +2275,16 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2213
2275
  constructor(proportionalLayout, styles, orientation) {
2214
2276
  this.proportionalLayout = proportionalLayout;
2215
2277
  this.styles = styles;
2278
+ this._locked = false;
2216
2279
  this._maximizedNode = undefined;
2217
2280
  this.disposable = new MutableDisposable();
2218
2281
  this._onDidChange = new Emitter();
2219
2282
  this.onDidChange = this._onDidChange.event;
2220
- this._onDidMaxmizedNodeChange = new Emitter();
2221
- this.onDidMaxmizedNodeChange = this._onDidMaxmizedNodeChange.event;
2283
+ this._onDidMaximizedNodeChange = new Emitter();
2284
+ this.onDidMaximizedNodeChange = this._onDidMaximizedNodeChange.event;
2222
2285
  this.element = document.createElement('div');
2223
2286
  this.element.className = 'grid-view';
2224
- this.root = new BranchNode(orientation, proportionalLayout, styles, 0, 0);
2287
+ this.root = new BranchNode(orientation, proportionalLayout, styles, 0, 0, this._locked);
2225
2288
  }
2226
2289
  isViewVisible(location) {
2227
2290
  const [rest, index] = tail(location);
@@ -2272,7 +2335,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2272
2335
  }
2273
2336
  const child = grandParent.removeChild(parentIndex);
2274
2337
  child.dispose();
2275
- const newParent = new BranchNode(parent.orientation, this.proportionalLayout, this.styles, parent.size, parent.orthogonalSize);
2338
+ const newParent = new BranchNode(parent.orientation, this.proportionalLayout, this.styles, parent.size, parent.orthogonalSize, this._locked);
2276
2339
  grandParent.addChild(newParent, parent.size, parentIndex);
2277
2340
  const newSibling = new LeafNode(parent.view, grandParent.orientation, parent.size);
2278
2341
  newParent.addChild(newSibling, newSiblingSize, 0);
@@ -2899,6 +2962,21 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
2899
2962
  get onDidDrop() {
2900
2963
  return this.component.onDidDrop;
2901
2964
  }
2965
+ /**
2966
+ * Invoked when a Drag'n'Drop event occurs but before dockview handles it giving the user an opportunity to intecept and
2967
+ * prevent the event from occuring using the standard `preventDefault()` syntax.
2968
+ *
2969
+ * Preventing certain events may causes unexpected behaviours, use carefully.
2970
+ */
2971
+ get onWillDrop() {
2972
+ return this.component.onWillDrop;
2973
+ }
2974
+ /**
2975
+ *
2976
+ */
2977
+ get onWillShowOverlay() {
2978
+ return this.component.onWillShowOverlay;
2979
+ }
2902
2980
  /**
2903
2981
  * Invoked before a group is dragged. Exposed for custom Drag'n'Drop functionality.
2904
2982
  */
@@ -3034,17 +3112,17 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3034
3112
  hasMaximizedGroup() {
3035
3113
  return this.component.hasMaximizedGroup();
3036
3114
  }
3037
- exitMaxmizedGroup() {
3115
+ exitMaximizedGroup() {
3038
3116
  this.component.exitMaximizedGroup();
3039
3117
  }
3040
- get onDidMaxmizedGroupChange() {
3041
- return this.component.onDidMaxmizedGroupChange;
3118
+ get onDidMaximizedGroupChange() {
3119
+ return this.component.onDidMaximizedGroupChange;
3042
3120
  }
3043
3121
  /**
3044
3122
  * Add a popout group in a new Window
3045
3123
  */
3046
3124
  addPopoutGroup(item, options) {
3047
- this.component.addPopoutGroup(item, options);
3125
+ return this.component.addPopoutGroup(item, options);
3048
3126
  }
3049
3127
  }
3050
3128
 
@@ -3098,6 +3176,18 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3098
3176
  }
3099
3177
  }
3100
3178
 
3179
+ class WillShowOverlayEvent extends DockviewEvent {
3180
+ get nativeEvent() {
3181
+ return this.options.nativeEvent;
3182
+ }
3183
+ get position() {
3184
+ return this.options.position;
3185
+ }
3186
+ constructor(options) {
3187
+ super();
3188
+ this.options = options;
3189
+ }
3190
+ }
3101
3191
  function directionToPosition(direction) {
3102
3192
  switch (direction) {
3103
3193
  case 'above':
@@ -3150,6 +3240,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3150
3240
  this.options = options;
3151
3241
  this._onDrop = new Emitter();
3152
3242
  this.onDrop = this._onDrop.event;
3243
+ this._onWillShowOverlay = new Emitter();
3244
+ this.onWillShowOverlay = this._onWillShowOverlay.event;
3153
3245
  // use a set to take advantage of #<set>.has
3154
3246
  this._acceptedTargetZonesSet = new Set(this.options.acceptedTargetZones);
3155
3247
  this.dnd = new DragAndDropObserver(this.element, {
@@ -3178,6 +3270,19 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3178
3270
  this.removeDropTarget();
3179
3271
  return;
3180
3272
  }
3273
+ const willShowOverlayEvent = new WillShowOverlayEvent({
3274
+ nativeEvent: e,
3275
+ position: quadrant,
3276
+ });
3277
+ /**
3278
+ * Provide an opportunity to prevent the overlay appearing and in turn
3279
+ * any dnd behaviours
3280
+ */
3281
+ this._onWillShowOverlay.fire(willShowOverlayEvent);
3282
+ if (willShowOverlayEvent.defaultPrevented) {
3283
+ this.removeDropTarget();
3284
+ return;
3285
+ }
3181
3286
  if (typeof this.options.canDisplayOverlay === 'boolean') {
3182
3287
  if (!this.options.canDisplayOverlay) {
3183
3288
  this.removeDropTarget();
@@ -3220,7 +3325,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3220
3325
  }
3221
3326
  },
3222
3327
  });
3223
- this.addDisposables(this._onDrop, this.dnd);
3328
+ this.addDisposables(this._onDrop, this._onWillShowOverlay, this.dnd);
3224
3329
  }
3225
3330
  setTargetZones(acceptedTargetZones) {
3226
3331
  this._acceptedTargetZonesSet = new Set(acceptedTargetZones);
@@ -3273,25 +3378,44 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3273
3378
  size = clamp(0, sizeOptions.value, height) / height;
3274
3379
  }
3275
3380
  }
3276
- const translate = (1 - size) / 2;
3277
- const scale = size;
3278
- let transform;
3381
+ const box = { top: '0px', left: '0px', width: '100%', height: '100%' };
3382
+ /**
3383
+ * You can also achieve the overlay placement using the transform CSS property
3384
+ * to translate and scale the element however this has the undesired effect of
3385
+ * 'skewing' the element. Comment left here for anybody that ever revisits this.
3386
+ *
3387
+ * @see https://developer.mozilla.org/en-US/docs/Web/CSS/transform
3388
+ *
3389
+ * right
3390
+ * translateX(${100 * (1 - size) / 2}%) scaleX(${scale})
3391
+ *
3392
+ * left
3393
+ * translateX(-${100 * (1 - size) / 2}%) scaleX(${scale})
3394
+ *
3395
+ * top
3396
+ * translateY(-${100 * (1 - size) / 2}%) scaleY(${scale})
3397
+ *
3398
+ * bottom
3399
+ * translateY(${100 * (1 - size) / 2}%) scaleY(${scale})
3400
+ */
3279
3401
  if (rightClass) {
3280
- transform = `translateX(${100 * translate}%) scaleX(${scale})`;
3402
+ box.left = `${100 * (1 - size)}%`;
3403
+ box.width = `${100 * size}%`;
3281
3404
  }
3282
3405
  else if (leftClass) {
3283
- transform = `translateX(-${100 * translate}%) scaleX(${scale})`;
3406
+ box.width = `${100 * size}%`;
3284
3407
  }
3285
3408
  else if (topClass) {
3286
- transform = `translateY(-${100 * translate}%) scaleY(${scale})`;
3409
+ box.height = `${100 * size}%`;
3287
3410
  }
3288
3411
  else if (bottomClass) {
3289
- transform = `translateY(${100 * translate}%) scaleY(${scale})`;
3290
- }
3291
- else {
3292
- transform = '';
3412
+ box.top = `${100 * (1 - size)}%`;
3413
+ box.height = `${100 * size}%`;
3293
3414
  }
3294
- this.overlayElement.style.transform = transform;
3415
+ this.overlayElement.style.top = box.top;
3416
+ this.overlayElement.style.left = box.left;
3417
+ this.overlayElement.style.width = box.width;
3418
+ this.overlayElement.style.height = box.height;
3295
3419
  toggleClass(this.overlayElement, 'dv-drop-target-small-vertical', isSmallY);
3296
3420
  toggleClass(this.overlayElement, 'dv-drop-target-small-horizontal', isSmallX);
3297
3421
  toggleClass(this.overlayElement, 'dv-drop-target-left', isLeft);
@@ -3359,14 +3483,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3359
3483
  return 'center';
3360
3484
  }
3361
3485
 
3362
- exports.DockviewDropTargets = void 0;
3363
- (function (DockviewDropTargets) {
3364
- DockviewDropTargets[DockviewDropTargets["Tab"] = 0] = "Tab";
3365
- DockviewDropTargets[DockviewDropTargets["Panel"] = 1] = "Panel";
3366
- DockviewDropTargets[DockviewDropTargets["TabContainer"] = 2] = "TabContainer";
3367
- DockviewDropTargets[DockviewDropTargets["Edge"] = 3] = "Edge";
3368
- })(exports.DockviewDropTargets || (exports.DockviewDropTargets = {}));
3369
-
3370
3486
  class ContentContainer extends CompositeDisposable {
3371
3487
  get element() {
3372
3488
  return this._element;
@@ -3394,7 +3510,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3394
3510
  const data = getPanelData();
3395
3511
  if (!data &&
3396
3512
  event.shiftKey &&
3397
- this.group.location !== 'floating') {
3513
+ this.group.location.type !== 'floating') {
3398
3514
  return false;
3399
3515
  }
3400
3516
  if (data && data.viewId === this.accessor.id) {
@@ -3412,7 +3528,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3412
3528
  data.groupId === this.group.id;
3413
3529
  return !groupHasOnePanelAndIsActiveDragElement;
3414
3530
  }
3415
- return this.group.canDisplayOverlay(event, position, exports.DockviewDropTargets.Panel);
3531
+ return this.group.canDisplayOverlay(event, position, 'panel');
3416
3532
  },
3417
3533
  });
3418
3534
  this.addDisposables(this.dropTarget);
@@ -3437,7 +3553,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3437
3553
  let container;
3438
3554
  switch (panel.api.renderer) {
3439
3555
  case 'onlyWhenVisibile':
3440
- this.accessor.overlayRenderContainer.detatch(panel);
3556
+ this.group.renderContainer.detatch(panel);
3441
3557
  if (this.panel) {
3442
3558
  if (doRender) {
3443
3559
  this._element.appendChild(this.panel.view.content.element);
@@ -3449,7 +3565,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3449
3565
  if (panel.view.content.element.parentElement === this._element) {
3450
3566
  this._element.removeChild(panel.view.content.element);
3451
3567
  }
3452
- container = this.accessor.overlayRenderContainer.attach({
3568
+ container = this.group.renderContainer.attach({
3453
3569
  panel,
3454
3570
  referenceContainer: this,
3455
3571
  });
@@ -3480,9 +3596,10 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3480
3596
  // noop
3481
3597
  }
3482
3598
  closePanel() {
3599
+ var _a;
3483
3600
  if (this.panel) {
3484
3601
  if (this.panel.api.renderer === 'onlyWhenVisibile') {
3485
- this._element.removeChild(this.panel.view.content.element);
3602
+ (_a = this.panel.view.content.element.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(this.panel.view.content.element);
3486
3603
  }
3487
3604
  }
3488
3605
  this.panel = undefined;
@@ -3593,7 +3710,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3593
3710
  this._element.draggable = true;
3594
3711
  toggleClass(this.element, 'inactive-tab', true);
3595
3712
  const dragHandler = new TabDragHandler(this._element, this.accessor, this.group, this.panel);
3596
- this.droptarget = new Droptarget(this._element, {
3713
+ this.dropTarget = new Droptarget(this._element, {
3597
3714
  acceptedTargetZones: ['center'],
3598
3715
  canDisplayOverlay: (event, position) => {
3599
3716
  if (this.group.locked) {
@@ -3608,9 +3725,10 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3608
3725
  }
3609
3726
  return this.panel.id !== data.panelId;
3610
3727
  }
3611
- return this.group.model.canDisplayOverlay(event, position, exports.DockviewDropTargets.Tab);
3728
+ return this.group.model.canDisplayOverlay(event, position, 'tab');
3612
3729
  },
3613
3730
  });
3731
+ this.onWillShowOverlay = this.dropTarget.onWillShowOverlay;
3614
3732
  this.addDisposables(this._onChanged, this._onDropped, this._onDragStart, dragHandler.onDragStart((event) => {
3615
3733
  this._onDragStart.fire(event);
3616
3734
  }), dragHandler, addDisposableListener(this._element, 'mousedown', (event) => {
@@ -3618,9 +3736,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3618
3736
  return;
3619
3737
  }
3620
3738
  this._onChanged.fire(event);
3621
- }), this.droptarget.onDrop((event) => {
3739
+ }), this.dropTarget.onDrop((event) => {
3622
3740
  this._onDropped.fire(event);
3623
- }), this.droptarget);
3741
+ }), this.dropTarget);
3624
3742
  }
3625
3743
  setActive(isActive) {
3626
3744
  toggleClass(this.element, 'active-tab', isActive);
@@ -3667,7 +3785,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3667
3785
  }, true));
3668
3786
  }
3669
3787
  isCancelled(_event) {
3670
- if (this.group.api.location === 'floating' && !_event.shiftKey) {
3788
+ if (this.group.api.location.type === 'floating' && !_event.shiftKey) {
3671
3789
  return true;
3672
3790
  }
3673
3791
  return false;
@@ -3719,7 +3837,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3719
3837
  this.accessor.doSetGroupActive(this.group);
3720
3838
  }));
3721
3839
  const handler = new GroupDragHandler(this._element, accessor, group);
3722
- this.voidDropTarget = new Droptarget(this._element, {
3840
+ this.dropTraget = new Droptarget(this._element, {
3723
3841
  acceptedTargetZones: ['center'],
3724
3842
  canDisplayOverlay: (event, position) => {
3725
3843
  var _a;
@@ -3733,14 +3851,15 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3733
3851
  // don't show the overlay if the tab being dragged is the last panel of this group
3734
3852
  return ((_a = last(this.group.panels)) === null || _a === void 0 ? void 0 : _a.id) !== data.panelId;
3735
3853
  }
3736
- return group.model.canDisplayOverlay(event, position, exports.DockviewDropTargets.Panel);
3854
+ return group.model.canDisplayOverlay(event, position, 'panel');
3737
3855
  },
3738
3856
  });
3857
+ this.onWillShowOverlay = this.dropTraget.onWillShowOverlay;
3739
3858
  this.addDisposables(handler, handler.onDragStart((event) => {
3740
3859
  this._onDragStart.fire(event);
3741
- }), this.voidDropTarget.onDrop((event) => {
3860
+ }), this.dropTraget.onDrop((event) => {
3742
3861
  this._onDrop.fire(event);
3743
- }), this.voidDropTarget);
3862
+ }), this.dropTraget);
3744
3863
  }
3745
3864
  }
3746
3865
 
@@ -3828,19 +3947,11 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3828
3947
  this.onTabDragStart = this._onTabDragStart.event;
3829
3948
  this._onGroupDragStart = new Emitter();
3830
3949
  this.onGroupDragStart = this._onGroupDragStart.event;
3831
- this.addDisposables(this._onDrop, this._onTabDragStart, this._onGroupDragStart);
3950
+ this._onWillShowOverlay = new Emitter();
3951
+ this.onWillShowOverlay = this._onWillShowOverlay.event;
3832
3952
  this._element = document.createElement('div');
3833
3953
  this._element.className = 'tabs-and-actions-container';
3834
3954
  toggleClass(this._element, 'dv-full-width-single-tab', this.accessor.options.singleTabMode === 'fullwidth');
3835
- this.addDisposables(this.accessor.onDidAddPanel((e) => {
3836
- if (e.api.group === this.group) {
3837
- toggleClass(this._element, 'dv-single-tab', this.size === 1);
3838
- }
3839
- }), this.accessor.onDidRemovePanel((e) => {
3840
- if (e.api.group === this.group) {
3841
- toggleClass(this._element, 'dv-single-tab', this.size === 1);
3842
- }
3843
- }));
3844
3955
  this.rightActionsContainer = document.createElement('div');
3845
3956
  this.rightActionsContainer.className = 'right-actions-container';
3846
3957
  this.leftActionsContainer = document.createElement('div');
@@ -3855,7 +3966,15 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3855
3966
  this._element.appendChild(this.leftActionsContainer);
3856
3967
  this._element.appendChild(this.voidContainer.element);
3857
3968
  this._element.appendChild(this.rightActionsContainer);
3858
- this.addDisposables(this.voidContainer, this.voidContainer.onDragStart((event) => {
3969
+ this.addDisposables(this.accessor.onDidAddPanel((e) => {
3970
+ if (e.api.group === this.group) {
3971
+ toggleClass(this._element, 'dv-single-tab', this.size === 1);
3972
+ }
3973
+ }), this.accessor.onDidRemovePanel((e) => {
3974
+ if (e.api.group === this.group) {
3975
+ toggleClass(this._element, 'dv-single-tab', this.size === 1);
3976
+ }
3977
+ }), this._onWillShowOverlay, this._onDrop, this._onTabDragStart, this._onGroupDragStart, this.voidContainer, this.voidContainer.onDragStart((event) => {
3859
3978
  this._onGroupDragStart.fire({
3860
3979
  nativeEvent: event,
3861
3980
  group: this.group,
@@ -3865,11 +3984,15 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3865
3984
  event: event.nativeEvent,
3866
3985
  index: this.tabs.length,
3867
3986
  });
3987
+ }), this.voidContainer.onWillShowOverlay((event) => {
3988
+ this._onWillShowOverlay.fire(new WillShowOverlayLocationEvent(event, {
3989
+ kind: 'header_space',
3990
+ }));
3868
3991
  }), addDisposableListener(this.voidContainer.element, 'mousedown', (event) => {
3869
3992
  const isFloatingGroupsEnabled = !this.accessor.options.disableFloatingGroups;
3870
3993
  if (isFloatingGroupsEnabled &&
3871
3994
  event.shiftKey &&
3872
- this.group.api.location !== 'floating') {
3995
+ this.group.api.location.type !== 'floating') {
3873
3996
  event.preventDefault();
3874
3997
  const { top, left } = this.element.getBoundingClientRect();
3875
3998
  const { top: rootTop, left: rootLeft } = this.accessor.element.getBoundingClientRect();
@@ -3932,9 +4055,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3932
4055
  const disposable = new CompositeDisposable(tab.onDragStart((event) => {
3933
4056
  this._onTabDragStart.fire({ nativeEvent: event, panel });
3934
4057
  }), tab.onChanged((event) => {
3935
- var _a;
3936
4058
  const isFloatingGroupsEnabled = !this.accessor.options.disableFloatingGroups;
3937
- const isFloatingWithOnePanel = this.group.api.location === 'floating' && this.size === 1;
4059
+ const isFloatingWithOnePanel = this.group.api.location.type === 'floating' &&
4060
+ this.size === 1;
3938
4061
  if (isFloatingGroupsEnabled &&
3939
4062
  !isFloatingWithOnePanel &&
3940
4063
  event.shiftKey) {
@@ -3948,20 +4071,20 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3948
4071
  }, { inDragMode: true });
3949
4072
  return;
3950
4073
  }
3951
- const alreadyFocused = panel.id === ((_a = this.group.model.activePanel) === null || _a === void 0 ? void 0 : _a.id) &&
3952
- this.group.model.isContentFocused;
3953
4074
  const isLeftClick = event.button === 0;
3954
4075
  if (!isLeftClick || event.defaultPrevented) {
3955
4076
  return;
3956
4077
  }
3957
- this.group.model.openPanel(panel, {
3958
- skipFocus: alreadyFocused,
3959
- });
4078
+ if (this.group.activePanel !== panel) {
4079
+ this.group.model.openPanel(panel);
4080
+ }
3960
4081
  }), tab.onDrop((event) => {
3961
4082
  this._onDrop.fire({
3962
4083
  event: event.nativeEvent,
3963
4084
  index: this.tabs.findIndex((x) => x.value === tab),
3964
4085
  });
4086
+ }), tab.onWillShowOverlay((event) => {
4087
+ this._onWillShowOverlay.fire(new WillShowOverlayLocationEvent(event, { kind: 'tab' }));
3965
4088
  }));
3966
4089
  const value = { value: tab, disposable };
3967
4090
  this.addTab(value, index);
@@ -3979,6 +4102,60 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
3979
4102
  }
3980
4103
  }
3981
4104
 
4105
+ class DockviewDidDropEvent extends DockviewEvent {
4106
+ get nativeEvent() {
4107
+ return this.options.nativeEvent;
4108
+ }
4109
+ get position() {
4110
+ return this.options.position;
4111
+ }
4112
+ get panel() {
4113
+ return this.options.panel;
4114
+ }
4115
+ get group() {
4116
+ return this.options.group;
4117
+ }
4118
+ get api() {
4119
+ return this.options.api;
4120
+ }
4121
+ constructor(options) {
4122
+ super();
4123
+ this.options = options;
4124
+ }
4125
+ getData() {
4126
+ return this.options.getData();
4127
+ }
4128
+ }
4129
+ class DockviewWillDropEvent extends DockviewDidDropEvent {
4130
+ get kind() {
4131
+ return this._kind;
4132
+ }
4133
+ constructor(options) {
4134
+ super(options);
4135
+ this._kind = options.kind;
4136
+ }
4137
+ }
4138
+ class WillShowOverlayLocationEvent {
4139
+ get kind() {
4140
+ return this._kind;
4141
+ }
4142
+ get nativeEvent() {
4143
+ return this.event.nativeEvent;
4144
+ }
4145
+ get position() {
4146
+ return this.event.position;
4147
+ }
4148
+ get defaultPrevented() {
4149
+ return this.event.defaultPrevented;
4150
+ }
4151
+ preventDefault() {
4152
+ this.event.preventDefault();
4153
+ }
4154
+ constructor(event, options) {
4155
+ this.event = event;
4156
+ this._kind = options.kind;
4157
+ }
4158
+ }
3982
4159
  class DockviewGroupPanelModel extends CompositeDisposable {
3983
4160
  get element() {
3984
4161
  throw new Error('not supported');
@@ -4024,7 +4201,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4024
4201
  this._location = value;
4025
4202
  toggleClass(this.container, 'dv-groupview-floating', false);
4026
4203
  toggleClass(this.container, 'dv-groupview-popout', false);
4027
- switch (value) {
4204
+ switch (value.type) {
4028
4205
  case 'grid':
4029
4206
  this.contentContainer.dropTarget.setTargetZones([
4030
4207
  'top',
@@ -4060,7 +4237,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4060
4237
  this.groupPanel = groupPanel;
4061
4238
  this._isGroupActive = false;
4062
4239
  this._locked = false;
4063
- this._location = 'grid';
4240
+ this._location = { type: 'grid' };
4064
4241
  this.mostRecentlyUsed = [];
4065
4242
  this._onDidChange = new Emitter();
4066
4243
  this.onDidChange = this._onDidChange.event;
@@ -4071,6 +4248,10 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4071
4248
  this.onMove = this._onMove.event;
4072
4249
  this._onDidDrop = new Emitter();
4073
4250
  this.onDidDrop = this._onDidDrop.event;
4251
+ this._onWillDrop = new Emitter();
4252
+ this.onWillDrop = this._onWillDrop.event;
4253
+ this._onWillShowOverlay = new Emitter();
4254
+ this.onWillShowOverlay = this._onWillShowOverlay.event;
4074
4255
  this._onTabDragStart = new Emitter();
4075
4256
  this.onTabDragStart = this._onTabDragStart.event;
4076
4257
  this._onGroupDragStart = new Emitter();
@@ -4081,46 +4262,69 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4081
4262
  this.onDidRemovePanel = this._onDidRemovePanel.event;
4082
4263
  this._onDidActivePanelChange = new Emitter();
4083
4264
  this.onDidActivePanelChange = this._onDidActivePanelChange.event;
4265
+ this._overwriteRenderContainer = null;
4084
4266
  toggleClass(this.container, 'groupview', true);
4267
+ this._api = new DockviewApi(this.accessor);
4085
4268
  this.tabsContainer = new TabsContainer(this.accessor, this.groupPanel);
4086
4269
  this.contentContainer = new ContentContainer(this.accessor, this);
4087
4270
  container.append(this.tabsContainer.element, this.contentContainer.element);
4088
4271
  this.header.hidden = !!options.hideHeader;
4089
4272
  this.locked = (_a = options.locked) !== null && _a !== void 0 ? _a : false;
4090
- this.addDisposables(this._onTabDragStart, this._onGroupDragStart, this.tabsContainer.onTabDragStart((event) => {
4273
+ this.addDisposables(this._onTabDragStart, this._onGroupDragStart, this._onWillShowOverlay, this.tabsContainer.onTabDragStart((event) => {
4091
4274
  this._onTabDragStart.fire(event);
4092
4275
  }), this.tabsContainer.onGroupDragStart((event) => {
4093
4276
  this._onGroupDragStart.fire(event);
4094
4277
  }), this.tabsContainer.onDrop((event) => {
4095
- this.handleDropEvent(event.event, 'center', event.index);
4278
+ this.handleDropEvent('header', event.event, 'center', event.index);
4096
4279
  }), this.contentContainer.onDidFocus(() => {
4097
- this.accessor.doSetGroupActive(this.groupPanel, true);
4280
+ this.accessor.doSetGroupActive(this.groupPanel);
4098
4281
  }), this.contentContainer.onDidBlur(() => {
4099
4282
  // noop
4100
4283
  }), this.contentContainer.dropTarget.onDrop((event) => {
4101
- this.handleDropEvent(event.nativeEvent, event.position);
4102
- }), this._onMove, this._onDidChange, this._onDidDrop, this._onDidAddPanel, this._onDidRemovePanel, this._onDidActivePanelChange);
4284
+ this.handleDropEvent('content', event.nativeEvent, event.position);
4285
+ }), this.tabsContainer.onWillShowOverlay((event) => {
4286
+ this._onWillShowOverlay.fire(event);
4287
+ }), this.contentContainer.dropTarget.onWillShowOverlay((event) => {
4288
+ this._onWillShowOverlay.fire(new WillShowOverlayLocationEvent(event, {
4289
+ kind: 'content',
4290
+ }));
4291
+ }), this._onMove, this._onDidChange, this._onDidDrop, this._onWillDrop, this._onDidAddPanel, this._onDidRemovePanel, this._onDidActivePanelChange);
4292
+ }
4293
+ focusContent() {
4294
+ this.contentContainer.element.focus();
4295
+ }
4296
+ set renderContainer(value) {
4297
+ this.panels.forEach((panel) => {
4298
+ this.renderContainer.detatch(panel);
4299
+ });
4300
+ this._overwriteRenderContainer = value;
4301
+ this.panels.forEach((panel) => {
4302
+ this.rerender(panel);
4303
+ });
4304
+ }
4305
+ get renderContainer() {
4306
+ var _a;
4307
+ return ((_a = this._overwriteRenderContainer) !== null && _a !== void 0 ? _a : this.accessor.overlayRenderContainer);
4103
4308
  }
4104
4309
  initialize() {
4105
- var _a, _b;
4106
- if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.panels) {
4310
+ if (this.options.panels) {
4107
4311
  this.options.panels.forEach((panel) => {
4108
4312
  this.doAddPanel(panel);
4109
4313
  });
4110
4314
  }
4111
- if ((_b = this.options) === null || _b === void 0 ? void 0 : _b.activePanel) {
4315
+ if (this.options.activePanel) {
4112
4316
  this.openPanel(this.options.activePanel);
4113
4317
  }
4114
4318
  // must be run after the constructor otherwise this.parent may not be
4115
4319
  // correctly initialized
4116
- this.setActive(this.isActive, true, true);
4320
+ this.setActive(this.isActive, true);
4117
4321
  this.updateContainer();
4118
4322
  if (this.accessor.options.createRightHeaderActionsElement) {
4119
4323
  this._rightHeaderActions =
4120
4324
  this.accessor.options.createRightHeaderActionsElement(this.groupPanel);
4121
4325
  this.addDisposables(this._rightHeaderActions);
4122
4326
  this._rightHeaderActions.init({
4123
- containerApi: new DockviewApi(this.accessor),
4327
+ containerApi: this._api,
4124
4328
  api: this.groupPanel.api,
4125
4329
  });
4126
4330
  this.tabsContainer.setRightActionsElement(this._rightHeaderActions.element);
@@ -4130,7 +4334,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4130
4334
  this.accessor.options.createLeftHeaderActionsElement(this.groupPanel);
4131
4335
  this.addDisposables(this._leftHeaderActions);
4132
4336
  this._leftHeaderActions.init({
4133
- containerApi: new DockviewApi(this.accessor),
4337
+ containerApi: this._api,
4134
4338
  api: this.groupPanel.api,
4135
4339
  });
4136
4340
  this.tabsContainer.setLeftActionsElement(this._leftHeaderActions.element);
@@ -4140,7 +4344,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4140
4344
  this.accessor.options.createPrefixHeaderActionsElement(this.groupPanel);
4141
4345
  this.addDisposables(this._prefixHeaderActions);
4142
4346
  this._prefixHeaderActions.init({
4143
- containerApi: new DockviewApi(this.accessor),
4347
+ containerApi: this._api,
4144
4348
  api: this.groupPanel.api,
4145
4349
  });
4146
4350
  this.tabsContainer.setPrefixActionsElement(this._prefixHeaderActions.element);
@@ -4220,35 +4424,45 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4220
4424
  //noop
4221
4425
  }
4222
4426
  focus() {
4223
- var _a, _b;
4224
- (_b = (_a = this._activePanel) === null || _a === void 0 ? void 0 : _a.focus) === null || _b === void 0 ? void 0 : _b.call(_a);
4427
+ var _a;
4428
+ (_a = this._activePanel) === null || _a === void 0 ? void 0 : _a.focus();
4225
4429
  }
4226
4430
  openPanel(panel, options = {}) {
4431
+ /**
4432
+ * set the panel group
4433
+ * add the panel
4434
+ * check if group active
4435
+ * check if panel active
4436
+ */
4227
4437
  if (typeof options.index !== 'number' ||
4228
4438
  options.index > this.panels.length) {
4229
4439
  options.index = this.panels.length;
4230
4440
  }
4231
- const skipSetPanelActive = !!options.skipSetPanelActive;
4232
- const skipSetGroupActive = !!options.skipSetGroupActive;
4441
+ const skipSetActive = !!options.skipSetActive;
4233
4442
  // ensure the group is updated before we fire any events
4234
- panel.updateParentGroup(this.groupPanel, true);
4443
+ panel.updateParentGroup(this.groupPanel, {
4444
+ skipSetActive: options.skipSetActive,
4445
+ });
4446
+ this.doAddPanel(panel, options.index, {
4447
+ skipSetActive: skipSetActive,
4448
+ });
4235
4449
  if (this._activePanel === panel) {
4236
- if (!skipSetGroupActive) {
4237
- this.accessor.doSetGroupActive(this.groupPanel);
4238
- }
4239
4450
  this.contentContainer.renderPanel(panel, { asActive: true });
4240
4451
  return;
4241
4452
  }
4242
- this.doAddPanel(panel, options.index, skipSetPanelActive);
4243
- if (!skipSetPanelActive) {
4453
+ if (!skipSetActive) {
4244
4454
  this.doSetActivePanel(panel);
4245
4455
  }
4246
- if (!skipSetGroupActive) {
4247
- this.accessor.doSetGroupActive(this.groupPanel, !!options.skipFocus);
4456
+ if (!options.skipSetGroupActive) {
4457
+ this.accessor.doSetGroupActive(this.groupPanel);
4458
+ }
4459
+ if (!options.skipSetActive) {
4460
+ this.updateContainer();
4248
4461
  }
4249
- this.updateContainer();
4250
4462
  }
4251
- removePanel(groupItemOrId) {
4463
+ removePanel(groupItemOrId, options = {
4464
+ skipSetActive: false,
4465
+ }) {
4252
4466
  const id = typeof groupItemOrId === 'string'
4253
4467
  ? groupItemOrId
4254
4468
  : groupItemOrId.id;
@@ -4256,7 +4470,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4256
4470
  if (!panelToRemove) {
4257
4471
  throw new Error('invalid operation');
4258
4472
  }
4259
- return this._removePanel(panelToRemove);
4473
+ return this._removePanel(panelToRemove, options);
4260
4474
  }
4261
4475
  closeAllPanels() {
4262
4476
  if (this.panels.length > 0) {
@@ -4282,12 +4496,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4282
4496
  updateActions(element) {
4283
4497
  this.tabsContainer.setRightActionsElement(element);
4284
4498
  }
4285
- setActive(isGroupActive, skipFocus = false, force = false) {
4286
- var _a, _b, _c, _d;
4499
+ setActive(isGroupActive, force = false) {
4287
4500
  if (!force && this.isActive === isGroupActive) {
4288
- if (!skipFocus) {
4289
- (_b = (_a = this._activePanel) === null || _a === void 0 ? void 0 : _a.focus) === null || _b === void 0 ? void 0 : _b.call(_a);
4290
- }
4291
4501
  return;
4292
4502
  }
4293
4503
  this._isGroupActive = isGroupActive;
@@ -4298,11 +4508,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4298
4508
  this.doSetActivePanel(this.panels[0]);
4299
4509
  }
4300
4510
  this.updateContainer();
4301
- if (isGroupActive) {
4302
- if (!skipFocus) {
4303
- (_d = (_c = this._activePanel) === null || _c === void 0 ? void 0 : _c.focus) === null || _d === void 0 ? void 0 : _d.call(_c);
4304
- }
4305
- }
4306
4511
  }
4307
4512
  layout(width, height) {
4308
4513
  var _a;
@@ -4313,17 +4518,22 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4313
4518
  this._activePanel.layout(this._width, this._height);
4314
4519
  }
4315
4520
  }
4316
- _removePanel(panel) {
4521
+ _removePanel(panel, options) {
4317
4522
  const isActivePanel = this._activePanel === panel;
4318
4523
  this.doRemovePanel(panel);
4319
4524
  if (isActivePanel && this.panels.length > 0) {
4320
4525
  const nextPanel = this.mostRecentlyUsed[0];
4321
- this.openPanel(nextPanel);
4526
+ this.openPanel(nextPanel, {
4527
+ skipSetActive: options.skipSetActive,
4528
+ skipSetGroupActive: options.skipSetActiveGroup,
4529
+ });
4322
4530
  }
4323
4531
  if (this._activePanel && this.panels.length === 0) {
4324
4532
  this.doSetActivePanel(undefined);
4325
4533
  }
4326
- this.updateContainer();
4534
+ if (!options.skipSetActive) {
4535
+ this.updateContainer();
4536
+ }
4327
4537
  return panel;
4328
4538
  }
4329
4539
  doRemovePanel(panel) {
@@ -4338,13 +4548,13 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4338
4548
  }
4339
4549
  this._onDidRemovePanel.fire({ panel });
4340
4550
  }
4341
- doAddPanel(panel, index = this.panels.length, skipSetActive = false) {
4551
+ doAddPanel(panel, index = this.panels.length, options = { skipSetActive: false }) {
4342
4552
  const existingPanel = this._panels.indexOf(panel);
4343
4553
  const hasExistingPanel = existingPanel > -1;
4344
4554
  this.tabsContainer.show();
4345
4555
  this.contentContainer.show();
4346
4556
  this.tabsContainer.openPanel(panel, index);
4347
- if (!skipSetActive) {
4557
+ if (!options.skipSetActive) {
4348
4558
  this.contentContainer.openPanel(panel);
4349
4559
  }
4350
4560
  if (hasExistingPanel) {
@@ -4356,12 +4566,17 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4356
4566
  this._onDidAddPanel.fire({ panel });
4357
4567
  }
4358
4568
  doSetActivePanel(panel) {
4569
+ if (this._activePanel === panel) {
4570
+ return;
4571
+ }
4359
4572
  this._activePanel = panel;
4360
4573
  if (panel) {
4361
4574
  this.tabsContainer.setActivePanel(panel);
4362
4575
  panel.layout(this._width, this._height);
4363
4576
  this.updateMru(panel);
4364
- this._onDidActivePanelChange.fire({ panel });
4577
+ this._onDidActivePanelChange.fire({
4578
+ panel,
4579
+ });
4365
4580
  }
4366
4581
  }
4367
4582
  updateMru(panel) {
@@ -4373,11 +4588,11 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4373
4588
  updateContainer() {
4374
4589
  var _a, _b;
4375
4590
  toggleClass(this.container, 'empty', this.isEmpty);
4376
- this.panels.forEach((panel) => panel.updateParentGroup(this.groupPanel, this.isActive));
4591
+ this.panels.forEach((panel) => panel.runEvents());
4377
4592
  if (this.isEmpty && !this.watermark) {
4378
4593
  const watermark = this.accessor.createWatermarkComponent();
4379
4594
  watermark.init({
4380
- containerApi: new DockviewApi(this.accessor),
4595
+ containerApi: this._api,
4381
4596
  group: this.groupPanel,
4382
4597
  });
4383
4598
  this.watermark = watermark;
@@ -4410,10 +4625,32 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4410
4625
  }
4411
4626
  return false;
4412
4627
  }
4413
- handleDropEvent(event, position, index) {
4628
+ handleDropEvent(type, event, position, index) {
4414
4629
  if (this.locked === 'no-drop-target') {
4415
4630
  return;
4416
4631
  }
4632
+ function getKind() {
4633
+ switch (type) {
4634
+ case 'header':
4635
+ return typeof index === 'number' ? 'tab' : 'header_space';
4636
+ case 'content':
4637
+ return 'content';
4638
+ }
4639
+ }
4640
+ const panel = typeof index === 'number' ? this.panels[index] : undefined;
4641
+ const willDropEvent = new DockviewWillDropEvent({
4642
+ nativeEvent: event,
4643
+ position,
4644
+ panel,
4645
+ getData: () => getPanelData(),
4646
+ kind: getKind(),
4647
+ group: this.groupPanel,
4648
+ api: this._api,
4649
+ });
4650
+ this._onWillDrop.fire(willDropEvent);
4651
+ if (willDropEvent.defaultPrevented) {
4652
+ return;
4653
+ }
4417
4654
  const data = getPanelData();
4418
4655
  if (data && data.viewId === this.accessor.id) {
4419
4656
  if (data.panelId === null) {
@@ -4446,12 +4683,14 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4446
4683
  });
4447
4684
  }
4448
4685
  else {
4449
- this._onDidDrop.fire({
4686
+ this._onDidDrop.fire(new DockviewDidDropEvent({
4450
4687
  nativeEvent: event,
4451
4688
  position,
4452
- index,
4689
+ panel,
4453
4690
  getData: () => getPanelData(),
4454
- });
4691
+ group: this.groupPanel,
4692
+ api: this._api,
4693
+ }));
4455
4694
  }
4456
4695
  }
4457
4696
  dispose() {
@@ -4459,6 +4698,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4459
4698
  super.dispose();
4460
4699
  (_a = this.watermark) === null || _a === void 0 ? void 0 : _a.element.remove();
4461
4700
  (_c = (_b = this.watermark) === null || _b === void 0 ? void 0 : _b.dispose) === null || _c === void 0 ? void 0 : _c.call(_b);
4701
+ this.watermark = undefined;
4462
4702
  for (const panel of this.panels) {
4463
4703
  panel.dispose();
4464
4704
  }
@@ -4480,15 +4720,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4480
4720
  constructor(parentElement, disableResizing = false) {
4481
4721
  super();
4482
4722
  this._disableResizing = disableResizing;
4483
- if (parentElement) {
4484
- this._element = parentElement;
4485
- }
4486
- else {
4487
- this._element = document.createElement('div');
4488
- this._element.style.height = '100%';
4489
- this._element.style.width = '100%';
4490
- this._element.className = 'dv-resizable-container';
4491
- }
4723
+ this._element = parentElement;
4492
4724
  this.addDisposables(watchElementResize(this._element, (entry) => {
4493
4725
  if (this.isDisposed) {
4494
4726
  /**
@@ -4576,25 +4808,38 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4576
4808
  get activeGroup() {
4577
4809
  return this._activeGroup;
4578
4810
  }
4811
+ get locked() {
4812
+ return this.gridview.locked;
4813
+ }
4814
+ set locked(value) {
4815
+ this.gridview.locked = value;
4816
+ }
4579
4817
  constructor(options) {
4580
- super(options.parentElement, options.disableAutoResizing);
4818
+ super(document.createElement('div'), options.disableAutoResizing);
4581
4819
  this._id = nextLayoutId$1.next();
4582
4820
  this._groups = new Map();
4583
4821
  this._onDidLayoutChange = new Emitter();
4584
4822
  this.onDidLayoutChange = this._onDidLayoutChange.event;
4585
- this._onDidRemoveGroup = new Emitter();
4586
- this.onDidRemoveGroup = this._onDidRemoveGroup.event;
4587
- this._onDidAddGroup = new Emitter();
4588
- this.onDidAddGroup = this._onDidAddGroup.event;
4589
- this._onDidActiveGroupChange = new Emitter();
4590
- this.onDidActiveGroupChange = this._onDidActiveGroupChange.event;
4823
+ this._onDidRemove = new Emitter();
4824
+ this.onDidRemove = this._onDidRemove.event;
4825
+ this._onDidAdd = new Emitter();
4826
+ this.onDidAdd = this._onDidAdd.event;
4827
+ this._onDidActiveChange = new Emitter();
4828
+ this.onDidActiveChange = this._onDidActiveChange.event;
4591
4829
  this._bufferOnDidLayoutChange = new TickDelayedEvent();
4830
+ this.element.style.height = '100%';
4831
+ this.element.style.width = '100%';
4832
+ options.parentElement.appendChild(this.element);
4592
4833
  this.gridview = new Gridview(!!options.proportionalLayout, options.styles, options.orientation);
4834
+ this.gridview.locked = !!options.locked;
4593
4835
  this.element.appendChild(this.gridview.element);
4594
4836
  this.layout(0, 0, true); // set some elements height/widths
4595
- this.addDisposables(this.gridview.onDidChange(() => {
4837
+ this.addDisposables(Disposable.from(() => {
4838
+ var _a;
4839
+ (_a = this.element.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(this.element);
4840
+ }), this.gridview.onDidChange(() => {
4596
4841
  this._bufferOnDidLayoutChange.fire();
4597
- }), exports.DockviewEvent.any(this.onDidAddGroup, this.onDidRemoveGroup, this.onDidActiveGroupChange)(() => {
4842
+ }), exports.DockviewEvent.any(this.onDidAdd, this.onDidRemove, this.onDidActiveChange)(() => {
4598
4843
  this._bufferOnDidLayoutChange.fire();
4599
4844
  }), this._bufferOnDidLayoutChange.onEvent(() => {
4600
4845
  this._onDidLayoutChange.fire();
@@ -4609,6 +4854,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4609
4854
  }
4610
4855
  maximizeGroup(panel) {
4611
4856
  this.gridview.maximizeView(panel);
4857
+ this.doSetGroupActive(panel);
4612
4858
  }
4613
4859
  isMaximizedGroup(panel) {
4614
4860
  return this.gridview.maximizedView() === panel;
@@ -4619,13 +4865,12 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4619
4865
  hasMaximizedGroup() {
4620
4866
  return this.gridview.hasMaximizedView();
4621
4867
  }
4622
- get onDidMaxmizedGroupChange() {
4623
- return this.gridview.onDidMaxmizedNodeChange;
4868
+ get onDidMaximizedGroupChange() {
4869
+ return this.gridview.onDidMaximizedNodeChange;
4624
4870
  }
4625
4871
  doAddGroup(group, location = [0], size) {
4626
4872
  this.gridview.addView(group, size !== null && size !== void 0 ? size : exports.Sizing.Distribute, location);
4627
- this._onDidAddGroup.fire(group);
4628
- this.doSetGroupActive(group);
4873
+ this._onDidAdd.fire(group);
4629
4874
  }
4630
4875
  doRemoveGroup(group, options) {
4631
4876
  if (!this._groups.has(group.id)) {
@@ -4637,8 +4882,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4637
4882
  item.disposable.dispose();
4638
4883
  item.value.dispose();
4639
4884
  this._groups.delete(group.id);
4885
+ this._onDidRemove.fire(group);
4640
4886
  }
4641
- this._onDidRemoveGroup.fire(group);
4642
4887
  if (!(options === null || options === void 0 ? void 0 : options.skipActive) && this._activeGroup === group) {
4643
4888
  const groups = Array.from(this._groups.values());
4644
4889
  this.doSetGroupActive(groups.length > 0 ? groups[0].value : undefined);
@@ -4649,25 +4894,18 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4649
4894
  var _a;
4650
4895
  return (_a = this._groups.get(id)) === null || _a === void 0 ? void 0 : _a.value;
4651
4896
  }
4652
- doSetGroupActive(group, skipFocus) {
4653
- var _a, _b, _c;
4897
+ doSetGroupActive(group) {
4654
4898
  if (this._activeGroup === group) {
4655
4899
  return;
4656
4900
  }
4657
4901
  if (this._activeGroup) {
4658
4902
  this._activeGroup.setActive(false);
4659
- if (!skipFocus) {
4660
- (_b = (_a = this._activeGroup).focus) === null || _b === void 0 ? void 0 : _b.call(_a);
4661
- }
4662
4903
  }
4663
4904
  if (group) {
4664
4905
  group.setActive(true);
4665
- if (!skipFocus) {
4666
- (_c = group.focus) === null || _c === void 0 ? void 0 : _c.call(group);
4667
- }
4668
4906
  }
4669
4907
  this._activeGroup = group;
4670
- this._onDidActiveGroupChange.fire(group);
4908
+ this._onDidActiveChange.fire(group);
4671
4909
  }
4672
4910
  removeGroup(group) {
4673
4911
  this.doRemoveGroup(group);
@@ -4712,9 +4950,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4712
4950
  this.gridview.layout(width, height);
4713
4951
  }
4714
4952
  dispose() {
4715
- this._onDidActiveGroupChange.dispose();
4716
- this._onDidAddGroup.dispose();
4717
- this._onDidRemoveGroup.dispose();
4953
+ this._onDidActiveChange.dispose();
4954
+ this._onDidAdd.dispose();
4955
+ this._onDidRemove.dispose();
4718
4956
  this._onDidLayoutChange.dispose();
4719
4957
  for (const group of this.groups) {
4720
4958
  group.dispose();
@@ -4724,11 +4962,15 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4724
4962
  }
4725
4963
  }
4726
4964
 
4965
+ class WillFocusEvent extends DockviewEvent {
4966
+ constructor() {
4967
+ super();
4968
+ }
4969
+ }
4727
4970
  /**
4728
4971
  * A core api implementation that should be used across all panel-like objects
4729
4972
  */
4730
4973
  class PanelApiImpl extends CompositeDisposable {
4731
- //
4732
4974
  get isFocused() {
4733
4975
  return this._isFocused;
4734
4976
  }
@@ -4738,6 +4980,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4738
4980
  get isVisible() {
4739
4981
  return this._isVisible;
4740
4982
  }
4983
+ get isHidden() {
4984
+ return this._isHidden;
4985
+ }
4741
4986
  get width() {
4742
4987
  return this._width;
4743
4988
  }
@@ -4750,38 +4995,26 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4750
4995
  this._isFocused = false;
4751
4996
  this._isActive = false;
4752
4997
  this._isVisible = true;
4998
+ this._isHidden = false;
4753
4999
  this._width = 0;
4754
5000
  this._height = 0;
4755
5001
  this.panelUpdatesDisposable = new MutableDisposable();
4756
- this._onDidDimensionChange = new Emitter({
4757
- replay: true,
4758
- });
5002
+ this._onDidDimensionChange = new Emitter();
4759
5003
  this.onDidDimensionsChange = this._onDidDimensionChange.event;
4760
- //
4761
- this._onDidChangeFocus = new Emitter({
4762
- replay: true,
4763
- });
5004
+ this._onDidChangeFocus = new Emitter();
4764
5005
  this.onDidFocusChange = this._onDidChangeFocus.event;
4765
5006
  //
4766
- this._onFocusEvent = new Emitter();
4767
- this.onFocusEvent = this._onFocusEvent.event;
5007
+ this._onWillFocus = new Emitter();
5008
+ this.onWillFocus = this._onWillFocus.event;
4768
5009
  //
4769
- this._onDidVisibilityChange = new Emitter({
4770
- replay: true,
4771
- });
5010
+ this._onDidVisibilityChange = new Emitter();
4772
5011
  this.onDidVisibilityChange = this._onDidVisibilityChange.event;
4773
- //
4774
- this._onVisibilityChange = new Emitter();
4775
- this.onVisibilityChange = this._onVisibilityChange.event;
4776
- //
4777
- this._onDidActiveChange = new Emitter({
4778
- replay: true,
4779
- });
5012
+ this._onDidHiddenChange = new Emitter();
5013
+ this.onDidHiddenChange = this._onDidHiddenChange.event;
5014
+ this._onDidActiveChange = new Emitter();
4780
5015
  this.onDidActiveChange = this._onDidActiveChange.event;
4781
- //
4782
5016
  this._onActiveChange = new Emitter();
4783
5017
  this.onActiveChange = this._onActiveChange.event;
4784
- //
4785
5018
  this._onUpdateParameters = new Emitter();
4786
5019
  this.onUpdateParameters = this._onUpdateParameters.event;
4787
5020
  this.addDisposables(this.onDidFocusChange((event) => {
@@ -4790,10 +5023,12 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4790
5023
  this._isActive = event.isActive;
4791
5024
  }), this.onDidVisibilityChange((event) => {
4792
5025
  this._isVisible = event.isVisible;
5026
+ }), this.onDidHiddenChange((event) => {
5027
+ this._isHidden = event.isHidden;
4793
5028
  }), this.onDidDimensionsChange((event) => {
4794
5029
  this._width = event.width;
4795
5030
  this._height = event.height;
4796
- }), this.panelUpdatesDisposable, this._onDidDimensionChange, this._onDidChangeFocus, this._onDidVisibilityChange, this._onDidActiveChange, this._onFocusEvent, this._onActiveChange, this._onVisibilityChange, this._onUpdateParameters);
5031
+ }), this.panelUpdatesDisposable, this._onDidDimensionChange, this._onDidChangeFocus, this._onDidVisibilityChange, this._onDidActiveChange, this._onWillFocus, this._onActiveChange, this._onUpdateParameters, this._onWillFocus, this._onDidHiddenChange, this._onUpdateParameters);
4797
5032
  }
4798
5033
  initialize(panel) {
4799
5034
  this.panelUpdatesDisposable.value = this._onUpdateParameters.event((parameters) => {
@@ -4802,8 +5037,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4802
5037
  });
4803
5038
  });
4804
5039
  }
4805
- setVisible(isVisible) {
4806
- this._onVisibilityChange.fire({ isVisible });
5040
+ setHidden(isHidden) {
5041
+ this._onDidHiddenChange.fire({ isHidden });
4807
5042
  }
4808
5043
  setActive() {
4809
5044
  this._onActiveChange.fire();
@@ -4811,9 +5046,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4811
5046
  updateParameters(parameters) {
4812
5047
  this._onUpdateParameters.fire(parameters);
4813
5048
  }
4814
- dispose() {
4815
- super.dispose();
4816
- }
4817
5049
  }
4818
5050
 
4819
5051
  class SplitviewPanelApiImpl extends PanelApiImpl {
@@ -4901,7 +5133,12 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4901
5133
  }), focusTracker);
4902
5134
  }
4903
5135
  focus() {
4904
- this.api._onFocusEvent.fire();
5136
+ const event = new WillFocusEvent();
5137
+ this.api._onWillFocus.fire(event);
5138
+ if (event.defaultPrevented) {
5139
+ return;
5140
+ }
5141
+ this._element.focus();
4905
5142
  }
4906
5143
  layout(width, height) {
4907
5144
  this._width = width;
@@ -5230,9 +5467,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5230
5467
  super(id);
5231
5468
  this._onDidConstraintsChangeInternal = new Emitter();
5232
5469
  this.onDidConstraintsChangeInternal = this._onDidConstraintsChangeInternal.event;
5233
- this._onDidConstraintsChange = new Emitter({
5234
- replay: true,
5235
- });
5470
+ this._onDidConstraintsChange = new Emitter();
5236
5471
  this.onDidConstraintsChange = this._onDidConstraintsChange.event;
5237
5472
  this._onDidSizeChange = new Emitter();
5238
5473
  this.onDidSizeChange = this._onDidSizeChange.event;
@@ -5325,13 +5560,13 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5325
5560
  this._maximumHeight = options.maximumHeight;
5326
5561
  }
5327
5562
  this.api.initialize(this); // TODO: required to by-pass 'super before this' requirement
5328
- this.addDisposables(this.api.onVisibilityChange((event) => {
5329
- const { isVisible } = event;
5563
+ this.addDisposables(this.api.onDidHiddenChange((event) => {
5564
+ const { isHidden } = event;
5330
5565
  const { accessor } = this._params;
5331
- accessor.setVisible(this, isVisible);
5566
+ accessor.setVisible(this, !isHidden);
5332
5567
  }), this.api.onActiveChange(() => {
5333
5568
  const { accessor } = this._params;
5334
- accessor.setActive(this);
5569
+ accessor.doSetGroupActive(this);
5335
5570
  }), this.api.onDidConstraintsChangeInternal((event) => {
5336
5571
  if (typeof event.minimumWidth === 'number' ||
5337
5572
  typeof event.minimumWidth === 'function') {
@@ -5414,6 +5649,17 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5414
5649
  this.onDidLocationChange = this._onDidLocationChange.event;
5415
5650
  this.addDisposables(this._onDidLocationChange);
5416
5651
  }
5652
+ close() {
5653
+ if (!this._group) {
5654
+ return;
5655
+ }
5656
+ return this.accessor.removeGroup(this._group);
5657
+ }
5658
+ getWindow() {
5659
+ return this.location.type === 'popout'
5660
+ ? this.location.getWindow()
5661
+ : window;
5662
+ }
5417
5663
  moveTo(options) {
5418
5664
  var _a, _b, _c;
5419
5665
  if (!this._group) {
@@ -5421,14 +5667,23 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5421
5667
  }
5422
5668
  const group = (_a = options.group) !== null && _a !== void 0 ? _a : this.accessor.addGroup({
5423
5669
  direction: positionToDirection((_b = options.position) !== null && _b !== void 0 ? _b : 'right'),
5670
+ skipSetActive: true,
5671
+ });
5672
+ this.accessor.moveGroupOrPanel({
5673
+ from: { groupId: this._group.id },
5674
+ to: {
5675
+ group,
5676
+ position: options.group
5677
+ ? (_c = options.position) !== null && _c !== void 0 ? _c : 'center'
5678
+ : 'center',
5679
+ },
5424
5680
  });
5425
- this.accessor.moveGroupOrPanel(group, this._group.id, undefined, options.group ? (_c = options.position) !== null && _c !== void 0 ? _c : 'center' : 'center');
5426
5681
  }
5427
5682
  maximize() {
5428
5683
  if (!this._group) {
5429
5684
  throw new Error(NOT_INITIALIZED_MESSAGE);
5430
5685
  }
5431
- if (this.location !== 'grid') {
5686
+ if (this.location.type !== 'grid') {
5432
5687
  // only grid groups can be maximized
5433
5688
  return;
5434
5689
  }
@@ -5485,6 +5740,12 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5485
5740
  this.api.initialize(this); // cannot use 'this' after after 'super' call
5486
5741
  this._model = new DockviewGroupPanelModel(this.element, accessor, id, options, this);
5487
5742
  }
5743
+ focus() {
5744
+ if (!this.api.isActive) {
5745
+ this.api.setActive();
5746
+ }
5747
+ super.focus();
5748
+ }
5488
5749
  initialize() {
5489
5750
  this._model.initialize();
5490
5751
  }
@@ -5530,6 +5791,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5530
5791
  }
5531
5792
 
5532
5793
  class DockviewPanelApiImpl extends GridviewPanelApiImpl {
5794
+ get location() {
5795
+ return this.group.api.location;
5796
+ }
5533
5797
  get title() {
5534
5798
  return this.panel.title;
5535
5799
  }
@@ -5541,15 +5805,34 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5541
5805
  }
5542
5806
  set group(value) {
5543
5807
  const isOldGroupActive = this.isGroupActive;
5544
- this._group = value;
5545
- this._onDidGroupChange.fire();
5546
- if (this._group) {
5547
- this.disposable.value = this._group.api.onDidActiveChange(() => {
5548
- this._onDidActiveGroupChange.fire();
5808
+ if (this._group !== value) {
5809
+ this._group = value;
5810
+ this._onDidGroupChange.fire({});
5811
+ let _trackGroupActive = isOldGroupActive; // prevent duplicate events with same state
5812
+ this.groupEventsDisposable.value = new CompositeDisposable(this.group.api.onDidLocationChange((event) => {
5813
+ if (this.group !== this.panel.group) {
5814
+ return;
5815
+ }
5816
+ this._onDidLocationChange.fire(event);
5817
+ }), this.group.api.onDidActiveChange(() => {
5818
+ if (this.group !== this.panel.group) {
5819
+ return;
5820
+ }
5821
+ if (_trackGroupActive !== this.isGroupActive) {
5822
+ _trackGroupActive = this.isGroupActive;
5823
+ this._onDidActiveGroupChange.fire({
5824
+ isActive: this.isGroupActive,
5825
+ });
5826
+ }
5827
+ }));
5828
+ // if (this.isGroupActive !== isOldGroupActive) {
5829
+ // this._onDidActiveGroupChange.fire({
5830
+ // isActive: this.isGroupActive,
5831
+ // });
5832
+ // }
5833
+ this._onDidLocationChange.fire({
5834
+ location: this.group.api.location,
5549
5835
  });
5550
- if (this.isGroupActive !== isOldGroupActive) {
5551
- this._onDidActiveGroupChange.fire();
5552
- }
5553
5836
  }
5554
5837
  }
5555
5838
  get group() {
@@ -5567,14 +5850,26 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5567
5850
  this.onDidGroupChange = this._onDidGroupChange.event;
5568
5851
  this._onDidRendererChange = new Emitter();
5569
5852
  this.onDidRendererChange = this._onDidRendererChange.event;
5570
- this.disposable = new MutableDisposable();
5853
+ this._onDidLocationChange = new Emitter();
5854
+ this.onDidLocationChange = this._onDidLocationChange.event;
5855
+ this.groupEventsDisposable = new MutableDisposable();
5571
5856
  this.initialize(panel);
5572
5857
  this._group = group;
5573
- this.addDisposables(this.disposable, this._onDidRendererChange, this._onDidTitleChange, this._onDidGroupChange, this._onDidActiveGroupChange);
5858
+ this.addDisposables(this.groupEventsDisposable, this._onDidRendererChange, this._onDidTitleChange, this._onDidGroupChange, this._onDidActiveGroupChange, this._onDidLocationChange);
5859
+ }
5860
+ getWindow() {
5861
+ return this.group.api.getWindow();
5574
5862
  }
5575
5863
  moveTo(options) {
5576
5864
  var _a;
5577
- this.accessor.moveGroupOrPanel(options.group, this._group.id, this.panel.id, (_a = options.position) !== null && _a !== void 0 ? _a : 'center', options.index);
5865
+ this.accessor.moveGroupOrPanel({
5866
+ from: { groupId: this._group.id, panelId: this.panel.id },
5867
+ to: {
5868
+ group: options.group,
5869
+ position: (_a = options.position) !== null && _a !== void 0 ? _a : 'center',
5870
+ index: options.index,
5871
+ },
5872
+ });
5578
5873
  }
5579
5874
  setTitle(title) {
5580
5875
  this.panel.setTitle(title);
@@ -5635,7 +5930,14 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5635
5930
  this.setTitle(params.title);
5636
5931
  }
5637
5932
  focus() {
5638
- this.api._onFocusEvent.fire();
5933
+ const event = new WillFocusEvent();
5934
+ this.api._onWillFocus.fire(event);
5935
+ if (event.defaultPrevented) {
5936
+ return;
5937
+ }
5938
+ if (!this.api.isActive) {
5939
+ this.api.setActive();
5940
+ }
5639
5941
  }
5640
5942
  toJSON() {
5641
5943
  return {
@@ -5692,20 +5994,40 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5692
5994
  },
5693
5995
  });
5694
5996
  }
5695
- updateParentGroup(group, isGroupActive) {
5997
+ updateParentGroup(group, options) {
5696
5998
  this._group = group;
5697
- this.api.group = group;
5999
+ this.api.group = this._group;
5698
6000
  const isPanelVisible = this._group.model.isPanelActive(this);
5699
- this.api._onDidActiveChange.fire({
5700
- isActive: isGroupActive && isPanelVisible,
5701
- });
5702
- this.api._onDidVisibilityChange.fire({
5703
- isVisible: isPanelVisible,
5704
- });
5705
- this.view.updateParentGroup(this._group, this._group.model.isPanelActive(this));
6001
+ const isActive = this.group.api.isActive && isPanelVisible;
6002
+ if (!(options === null || options === void 0 ? void 0 : options.skipSetActive)) {
6003
+ if (this.api.isActive !== isActive) {
6004
+ this.api._onDidActiveChange.fire({
6005
+ isActive: this.group.api.isActive && isPanelVisible,
6006
+ });
6007
+ }
6008
+ }
6009
+ if (this.api.isVisible !== isPanelVisible) {
6010
+ this.api._onDidVisibilityChange.fire({
6011
+ isVisible: isPanelVisible,
6012
+ });
6013
+ }
6014
+ }
6015
+ runEvents() {
6016
+ const isPanelVisible = this._group.model.isPanelActive(this);
6017
+ const isActive = this.group.api.isActive && isPanelVisible;
6018
+ if (this.api.isActive !== isActive) {
6019
+ this.api._onDidActiveChange.fire({
6020
+ isActive: this.group.api.isActive && isPanelVisible,
6021
+ });
6022
+ }
6023
+ if (this.api.isVisible !== isPanelVisible) {
6024
+ this.api._onDidVisibilityChange.fire({
6025
+ isVisible: isPanelVisible,
6026
+ });
6027
+ }
5706
6028
  }
5707
6029
  layout(width, height) {
5708
- // the obtain the correct dimensions of the content panel we must deduct the tab height
6030
+ // TODO: Can we somehow do height without header height or indicate what the header height is?
5709
6031
  this.api._onDidDimensionChange.fire({
5710
6032
  width,
5711
6033
  height: height,
@@ -5827,8 +6149,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5827
6149
  this.id = id;
5828
6150
  this.contentComponent = contentComponent;
5829
6151
  this.tabComponent = tabComponent;
5830
- this._group = null;
5831
- this._isPanelVisible = null;
5832
6152
  this._content = this.createContentComponent(this.id, contentComponent);
5833
6153
  this._tab = this.createTabComponent(this.id, tabComponent);
5834
6154
  }
@@ -5836,25 +6156,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5836
6156
  this.content.init(Object.assign(Object.assign({}, params), { tab: this.tab }));
5837
6157
  this.tab.init(params);
5838
6158
  }
5839
- updateParentGroup(group, isPanelVisible) {
5840
- if (group !== this._group) {
5841
- this._group = group;
5842
- if (this._content.onGroupChange) {
5843
- this._content.onGroupChange(group);
5844
- }
5845
- if (this._tab.onGroupChange) {
5846
- this._tab.onGroupChange(group);
5847
- }
5848
- }
5849
- if (isPanelVisible !== this._isPanelVisible) {
5850
- this._isPanelVisible = isPanelVisible;
5851
- if (this._content.onPanelVisibleChange) {
5852
- this._content.onPanelVisibleChange(isPanelVisible);
5853
- }
5854
- if (this._tab.onPanelVisibleChange) {
5855
- this._tab.onPanelVisibleChange(isPanelVisible);
5856
- }
5857
- }
6159
+ updateParentGroup(_group, _isPanelVisible) {
6160
+ // noop
5858
6161
  }
5859
6162
  layout(width, height) {
5860
6163
  var _a, _b;
@@ -6287,117 +6590,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6287
6590
  }
6288
6591
  }
6289
6592
 
6290
- class PopoutWindow extends CompositeDisposable {
6291
- constructor(id, className, options) {
6292
- super();
6293
- this.id = id;
6294
- this.className = className;
6295
- this.options = options;
6296
- this._onDidClose = new Emitter();
6297
- this.onDidClose = this._onDidClose.event;
6298
- this._window = null;
6299
- this.addDisposables(this._onDidClose, {
6300
- dispose: () => {
6301
- this.close();
6302
- },
6303
- });
6304
- }
6305
- dimensions() {
6306
- if (!this._window) {
6307
- return null;
6308
- }
6309
- const left = this._window.value.screenX;
6310
- const top = this._window.value.screenY;
6311
- const width = this._window.value.innerWidth;
6312
- const height = this._window.value.innerHeight;
6313
- return { top, left, width, height };
6314
- }
6315
- close() {
6316
- if (this._window) {
6317
- this._window.disposable.dispose();
6318
- this._window.value.close();
6319
- this._window = null;
6320
- }
6321
- }
6322
- open(content) {
6323
- if (this._window) {
6324
- throw new Error('instance of popout window is already open');
6325
- }
6326
- const url = `${this.options.url}`;
6327
- const features = Object.entries({
6328
- top: this.options.top,
6329
- left: this.options.left,
6330
- width: this.options.width,
6331
- height: this.options.height,
6332
- })
6333
- .map(([key, value]) => `${key}=${value}`)
6334
- .join(',');
6335
- // https://developer.mozilla.org/en-US/docs/Web/API/Window/open
6336
- const externalWindow = window.open(url, this.id, features);
6337
- if (!externalWindow) {
6338
- return;
6339
- }
6340
- const disposable = new CompositeDisposable();
6341
- this._window = { value: externalWindow, disposable };
6342
- const cleanUp = () => {
6343
- this._onDidClose.fire();
6344
- this._window = null;
6345
- };
6346
- // prevent any default content from loading
6347
- // externalWindow.document.body.replaceWith(document.createElement('div'));
6348
- disposable.addDisposables(addDisposableWindowListener(window, 'beforeunload', () => {
6349
- cleanUp();
6350
- this.close();
6351
- }));
6352
- externalWindow.addEventListener('load', () => {
6353
- const externalDocument = externalWindow.document;
6354
- externalDocument.title = document.title;
6355
- const div = document.createElement('div');
6356
- div.classList.add('dv-popout-window');
6357
- div.style.position = 'absolute';
6358
- div.style.width = '100%';
6359
- div.style.height = '100%';
6360
- div.style.top = '0px';
6361
- div.style.left = '0px';
6362
- div.classList.add(this.className);
6363
- div.appendChild(content);
6364
- externalDocument.body.replaceChildren(div);
6365
- externalDocument.body.classList.add(this.className);
6366
- addStyles(externalDocument, window.document.styleSheets);
6367
- externalWindow.addEventListener('beforeunload', () => {
6368
- // TODO: indicate external window is closing
6369
- cleanUp();
6370
- });
6371
- });
6372
- }
6373
- }
6374
-
6375
- class DockviewPopoutGroupPanel extends CompositeDisposable {
6376
- constructor(id, group, options) {
6377
- var _a;
6378
- super();
6379
- this.id = id;
6380
- this.group = group;
6381
- this.options = options;
6382
- this.window = new PopoutWindow(id, (_a = options.className) !== null && _a !== void 0 ? _a : '', {
6383
- url: this.options.popoutUrl,
6384
- left: this.options.box.left,
6385
- top: this.options.box.top,
6386
- width: this.options.box.width,
6387
- height: this.options.box.height,
6388
- });
6389
- group.model.location = 'popout';
6390
- this.addDisposables(this.window, {
6391
- dispose: () => {
6392
- group.model.location = 'grid';
6393
- },
6394
- }, this.window.onDidClose(() => {
6395
- this.dispose();
6396
- }));
6397
- this.window.open(group.element);
6398
- }
6399
- }
6400
-
6401
6593
  const DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE = 100;
6402
6594
  const DEFAULT_FLOATING_GROUP_POSITION = { left: 100, top: 100 };
6403
6595
 
@@ -6411,11 +6603,13 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6411
6603
  super();
6412
6604
  this.element = element;
6413
6605
  this.map = {};
6606
+ this._disposed = false;
6414
6607
  this.addDisposables(Disposable.from(() => {
6415
6608
  for (const value of Object.values(this.map)) {
6416
6609
  value.disposable.dispose();
6417
6610
  value.destroy.dispose();
6418
6611
  }
6612
+ this._disposed = true;
6419
6613
  }));
6420
6614
  }
6421
6615
  detatch(panel) {
@@ -6455,7 +6649,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6455
6649
  focusContainer.style.top = `${box.top - box2.top}px`;
6456
6650
  focusContainer.style.width = `${box.width}px`;
6457
6651
  focusContainer.style.height = `${box.height}px`;
6458
- toggleClass(focusContainer, 'dv-render-overlay-float', panel.group.api.location === 'floating');
6652
+ toggleClass(focusContainer, 'dv-render-overlay-float', panel.group.api.location.type === 'floating');
6459
6653
  };
6460
6654
  const visibilityChanged = () => {
6461
6655
  if (panel.api.isVisible) {
@@ -6501,8 +6695,11 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6501
6695
  resize();
6502
6696
  }));
6503
6697
  this.map[panel.api.id].destroy = Disposable.from(() => {
6504
- focusContainer.removeChild(panel.view.content.element);
6505
- this.element.removeChild(focusContainer);
6698
+ var _a;
6699
+ if (panel.view.content.element.parentElement === focusContainer) {
6700
+ focusContainer.removeChild(panel.view.content.element);
6701
+ }
6702
+ (_a = focusContainer.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(focusContainer);
6506
6703
  });
6507
6704
  queueMicrotask(() => {
6508
6705
  if (this.isDisposed) {
@@ -6523,11 +6720,164 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6523
6720
  }
6524
6721
  }
6525
6722
 
6723
+ var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
6724
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
6725
+ return new (P || (P = Promise))(function (resolve, reject) {
6726
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6727
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6728
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
6729
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
6730
+ });
6731
+ };
6732
+ class PopoutWindow extends CompositeDisposable {
6733
+ get window() {
6734
+ var _a, _b;
6735
+ return (_b = (_a = this._window) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : null;
6736
+ }
6737
+ constructor(target, className, options) {
6738
+ super();
6739
+ this.target = target;
6740
+ this.className = className;
6741
+ this.options = options;
6742
+ this._onWillClose = new Emitter();
6743
+ this.onWillClose = this._onWillClose.event;
6744
+ this._onDidClose = new Emitter();
6745
+ this.onDidClose = this._onDidClose.event;
6746
+ this._window = null;
6747
+ this.addDisposables(this._onWillClose, this._onDidClose, {
6748
+ dispose: () => {
6749
+ this.close();
6750
+ },
6751
+ });
6752
+ }
6753
+ dimensions() {
6754
+ if (!this._window) {
6755
+ return null;
6756
+ }
6757
+ const left = this._window.value.screenX;
6758
+ const top = this._window.value.screenY;
6759
+ const width = this._window.value.innerWidth;
6760
+ const height = this._window.value.innerHeight;
6761
+ return { top, left, width, height };
6762
+ }
6763
+ close() {
6764
+ var _a, _b;
6765
+ if (this._window) {
6766
+ this._onWillClose.fire();
6767
+ (_b = (_a = this.options).onWillClose) === null || _b === void 0 ? void 0 : _b.call(_a, {
6768
+ id: this.target,
6769
+ window: this._window.value,
6770
+ });
6771
+ this._window.disposable.dispose();
6772
+ this._window.value.close();
6773
+ this._window = null;
6774
+ this._onDidClose.fire();
6775
+ }
6776
+ }
6777
+ open() {
6778
+ var _a, _b;
6779
+ return __awaiter(this, void 0, void 0, function* () {
6780
+ if (this._window) {
6781
+ throw new Error('instance of popout window is already open');
6782
+ }
6783
+ const url = `${this.options.url}`;
6784
+ const features = Object.entries({
6785
+ top: this.options.top,
6786
+ left: this.options.left,
6787
+ width: this.options.width,
6788
+ height: this.options.height,
6789
+ })
6790
+ .map(([key, value]) => `${key}=${value}`)
6791
+ .join(',');
6792
+ /**
6793
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/open
6794
+ */
6795
+ const externalWindow = window.open(url, this.target, features);
6796
+ if (!externalWindow) {
6797
+ /**
6798
+ * Popup blocked
6799
+ */
6800
+ return null;
6801
+ }
6802
+ const disposable = new CompositeDisposable();
6803
+ this._window = { value: externalWindow, disposable };
6804
+ disposable.addDisposables(addDisposableWindowListener(window, 'beforeunload', () => {
6805
+ /**
6806
+ * before the main window closes we should close this popup too
6807
+ * to be good citizens
6808
+ *
6809
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event
6810
+ */
6811
+ this.close();
6812
+ }));
6813
+ const container = this.createPopoutWindowContainer();
6814
+ if (this.className) {
6815
+ container.classList.add(this.className);
6816
+ }
6817
+ (_b = (_a = this.options).onDidOpen) === null || _b === void 0 ? void 0 : _b.call(_a, {
6818
+ id: this.target,
6819
+ window: externalWindow,
6820
+ });
6821
+ return new Promise((resolve) => {
6822
+ externalWindow.addEventListener('unload', (e) => {
6823
+ // if page fails to load before unloading
6824
+ // this.close();
6825
+ });
6826
+ externalWindow.addEventListener('load', () => {
6827
+ /**
6828
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event
6829
+ */
6830
+ const externalDocument = externalWindow.document;
6831
+ externalDocument.title = document.title;
6832
+ externalDocument.body.appendChild(container);
6833
+ addStyles(externalDocument, window.document.styleSheets);
6834
+ /**
6835
+ * beforeunload must be registered after load for reasons I could not determine
6836
+ * otherwise the beforeunload event will not fire when the window is closed
6837
+ */
6838
+ addDisposableWindowListener(externalWindow, 'beforeunload', () => {
6839
+ /**
6840
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event
6841
+ */
6842
+ this.close();
6843
+ });
6844
+ resolve(container);
6845
+ });
6846
+ });
6847
+ });
6848
+ }
6849
+ createPopoutWindowContainer() {
6850
+ const el = document.createElement('div');
6851
+ el.classList.add('dv-popout-window');
6852
+ el.id = 'dv-popout-window';
6853
+ el.style.position = 'absolute';
6854
+ el.style.width = '100%';
6855
+ el.style.height = '100%';
6856
+ el.style.top = '0px';
6857
+ el.style.left = '0px';
6858
+ return el;
6859
+ }
6860
+ }
6861
+
6526
6862
  const DEFAULT_ROOT_OVERLAY_MODEL = {
6527
6863
  activationSize: { type: 'pixels', value: 10 },
6528
6864
  size: { type: 'pixels', value: 20 },
6529
6865
  };
6530
- function getTheme(element) {
6866
+ function moveGroupWithoutDestroying(options) {
6867
+ const activePanel = options.from.activePanel;
6868
+ const panels = [...options.from.panels].map((panel) => {
6869
+ const removedPanel = options.from.model.removePanel(panel);
6870
+ options.from.model.renderContainer.detatch(panel);
6871
+ return removedPanel;
6872
+ });
6873
+ panels.forEach((panel) => {
6874
+ options.to.model.openPanel(panel, {
6875
+ skipSetActive: activePanel !== panel,
6876
+ skipSetGroupActive: true,
6877
+ });
6878
+ });
6879
+ }
6880
+ function getDockviewTheme(element) {
6531
6881
  function toClassList(element) {
6532
6882
  const list = [];
6533
6883
  for (let i = 0; i < element.classList.length; i++) {
@@ -6578,6 +6928,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6578
6928
  styles: options.styles,
6579
6929
  parentElement: options.parentElement,
6580
6930
  disableAutoResizing: options.disableAutoResizing,
6931
+ locked: options.locked,
6581
6932
  });
6582
6933
  this.nextGroupId = sequentialNumberGenerator();
6583
6934
  this._deserializer = new DefaultDockviewDeserialzier(this);
@@ -6588,6 +6939,10 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6588
6939
  this.onWillDragGroup = this._onWillDragGroup.event;
6589
6940
  this._onDidDrop = new Emitter();
6590
6941
  this.onDidDrop = this._onDidDrop.event;
6942
+ this._onWillDrop = new Emitter();
6943
+ this.onWillDrop = this._onWillDrop.event;
6944
+ this._onWillShowOverlay = new Emitter();
6945
+ this.onWillShowOverlay = this._onWillShowOverlay.event;
6591
6946
  this._onDidRemovePanel = new Emitter();
6592
6947
  this.onDidRemovePanel = this._onDidRemovePanel.event;
6593
6948
  this._onDidAddPanel = new Emitter();
@@ -6596,15 +6951,36 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6596
6951
  this.onDidLayoutFromJSON = this._onDidLayoutFromJSON.event;
6597
6952
  this._onDidActivePanelChange = new Emitter();
6598
6953
  this.onDidActivePanelChange = this._onDidActivePanelChange.event;
6954
+ this._onDidMovePanel = new Emitter();
6599
6955
  this._floatingGroups = [];
6600
6956
  this._popoutGroups = [];
6957
+ this._ignoreEvents = 0;
6958
+ this._onDidRemoveGroup = new Emitter();
6959
+ this.onDidRemoveGroup = this._onDidRemoveGroup.event;
6960
+ this._onDidAddGroup = new Emitter();
6961
+ this.onDidAddGroup = this._onDidAddGroup.event;
6962
+ this._onDidActiveGroupChange = new Emitter();
6963
+ this.onDidActiveGroupChange = this._onDidActiveGroupChange.event;
6964
+ this._moving = false;
6601
6965
  const gready = document.createElement('div');
6602
6966
  gready.className = 'dv-overlay-render-container';
6603
6967
  this.gridview.element.appendChild(gready);
6604
6968
  this.overlayRenderContainer = new OverlayRenderContainer(gready);
6605
6969
  toggleClass(this.gridview.element, 'dv-dockview', true);
6606
6970
  toggleClass(this.element, 'dv-debug', !!options.debug);
6607
- 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)(() => {
6971
+ 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) => {
6972
+ if (!this._moving) {
6973
+ this._onDidAddGroup.fire(event);
6974
+ }
6975
+ }), this.onDidRemove((event) => {
6976
+ if (!this._moving) {
6977
+ this._onDidRemoveGroup.fire(event);
6978
+ }
6979
+ }), this.onDidActiveChange((event) => {
6980
+ if (!this._moving) {
6981
+ this._onDidActiveGroupChange.fire(event);
6982
+ }
6983
+ }), exports.DockviewEvent.any(this.onDidAdd, this.onDidRemove)(() => {
6608
6984
  this.updateWatermark();
6609
6985
  }), exports.DockviewEvent.any(this.onDidAddPanel, this.onDidRemovePanel, this.onDidActivePanelChange)(() => {
6610
6986
  this._bufferOnDidLayoutChange.fire();
@@ -6615,7 +6991,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6615
6991
  }
6616
6992
  // iterate over a copy of the array since .dispose() mutates the original array
6617
6993
  for (const group of [...this._popoutGroups]) {
6618
- group.dispose();
6994
+ group.disposable.dispose();
6619
6995
  }
6620
6996
  }));
6621
6997
  this._options = options;
@@ -6661,7 +7037,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6661
7037
  return this.options.showDndOverlay({
6662
7038
  nativeEvent: event,
6663
7039
  position: position,
6664
- target: exports.DockviewDropTargets.Edge,
7040
+ target: 'edge',
6665
7041
  getData: getPanelData,
6666
7042
  });
6667
7043
  }
@@ -6672,86 +7048,249 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6672
7048
  });
6673
7049
  this.addDisposables(this._rootDropTarget.onDrop((event) => {
6674
7050
  var _a;
7051
+ const willDropEvent = new DockviewWillDropEvent({
7052
+ nativeEvent: event.nativeEvent,
7053
+ position: event.position,
7054
+ panel: undefined,
7055
+ api: this._api,
7056
+ group: undefined,
7057
+ getData: getPanelData,
7058
+ kind: 'content',
7059
+ });
7060
+ this._onWillDrop.fire(willDropEvent);
7061
+ if (willDropEvent.defaultPrevented) {
7062
+ return;
7063
+ }
6675
7064
  const data = getPanelData();
6676
7065
  if (data) {
6677
- this.moveGroupOrPanel(this.orthogonalize(event.position), data.groupId, (_a = data.panelId) !== null && _a !== void 0 ? _a : undefined, 'center');
7066
+ this.moveGroupOrPanel({
7067
+ from: {
7068
+ groupId: data.groupId,
7069
+ panelId: (_a = data.panelId) !== null && _a !== void 0 ? _a : undefined,
7070
+ },
7071
+ to: {
7072
+ group: this.orthogonalize(event.position),
7073
+ position: 'center',
7074
+ },
7075
+ });
6678
7076
  }
6679
7077
  else {
6680
- this._onDidDrop.fire(Object.assign(Object.assign({}, event), { api: this._api, group: null, getData: getPanelData }));
7078
+ this._onDidDrop.fire(new DockviewDidDropEvent({
7079
+ nativeEvent: event.nativeEvent,
7080
+ position: event.position,
7081
+ panel: undefined,
7082
+ api: this._api,
7083
+ group: undefined,
7084
+ getData: getPanelData,
7085
+ }));
6681
7086
  }
6682
7087
  }), this._rootDropTarget);
6683
7088
  this._api = new DockviewApi(this);
6684
7089
  this.updateWatermark();
6685
7090
  }
6686
- addPopoutGroup(item, options) {
6687
- var _a;
6688
- let group;
6689
- let box = options === null || options === void 0 ? void 0 : options.position;
6690
- if (item instanceof DockviewPanel) {
6691
- group = this.createGroup();
6692
- this.removePanel(item, {
6693
- removeEmptyGroup: true,
6694
- skipDispose: true,
6695
- });
6696
- group.model.openPanel(item);
6697
- if (!box) {
6698
- box = this.element.getBoundingClientRect();
7091
+ addPopoutGroup(itemToPopout, options) {
7092
+ var _a, _b, _c;
7093
+ if (itemToPopout instanceof DockviewPanel &&
7094
+ itemToPopout.group.size === 1) {
7095
+ return this.addPopoutGroup(itemToPopout.group);
7096
+ }
7097
+ const theme = getDockviewTheme(this.gridview.element);
7098
+ const element = this.element;
7099
+ function getBox() {
7100
+ if (options === null || options === void 0 ? void 0 : options.position) {
7101
+ return options.position;
7102
+ }
7103
+ if (itemToPopout instanceof DockviewGroupPanel) {
7104
+ return itemToPopout.element.getBoundingClientRect();
7105
+ }
7106
+ if (itemToPopout.group) {
7107
+ return itemToPopout.group.element.getBoundingClientRect();
7108
+ }
7109
+ return element.getBoundingClientRect();
7110
+ }
7111
+ const box = getBox();
7112
+ 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;
7113
+ if (itemToPopout.api.location.type === 'grid') {
7114
+ itemToPopout.api.setHidden(true);
7115
+ }
7116
+ const _window = new PopoutWindow(`${this.id}-${groupId}`, // unique id
7117
+ theme !== null && theme !== void 0 ? theme : '', {
7118
+ url: (_c = options === null || options === void 0 ? void 0 : options.popoutUrl) !== null && _c !== void 0 ? _c : '/popout.html',
7119
+ left: window.screenX + box.left,
7120
+ top: window.screenY + box.top,
7121
+ width: box.width,
7122
+ height: box.height,
7123
+ onDidOpen: options === null || options === void 0 ? void 0 : options.onDidOpen,
7124
+ onWillClose: options === null || options === void 0 ? void 0 : options.onWillClose,
7125
+ });
7126
+ const popoutWindowDisposable = new CompositeDisposable(_window, _window.onDidClose(() => {
7127
+ popoutWindowDisposable.dispose();
7128
+ }));
7129
+ return _window
7130
+ .open()
7131
+ .then((popoutContainer) => {
7132
+ var _a;
7133
+ if (_window.isDisposed) {
7134
+ return;
6699
7135
  }
6700
- }
6701
- else {
6702
- group = item;
6703
- if (!box) {
6704
- box = group.element.getBoundingClientRect();
7136
+ if (popoutContainer === null) {
7137
+ popoutWindowDisposable.dispose();
7138
+ return;
6705
7139
  }
6706
- const skip = typeof (options === null || options === void 0 ? void 0 : options.skipRemoveGroup) === 'boolean' &&
6707
- options.skipRemoveGroup;
6708
- if (!skip) {
6709
- this.doRemoveGroup(item, { skipDispose: true });
6710
- }
6711
- }
6712
- const theme = getTheme(this.gridview.element);
6713
- const popoutWindow = new DockviewPopoutGroupPanel(`${this.id}-${group.id}`, // globally unique within dockview
6714
- group, {
6715
- className: theme !== null && theme !== void 0 ? theme : '',
6716
- popoutUrl: (_a = options === null || options === void 0 ? void 0 : options.popoutUrl) !== null && _a !== void 0 ? _a : '/popout.html',
6717
- box: {
6718
- left: window.screenX + box.left,
6719
- top: window.screenY + box.top,
6720
- width: box.width,
6721
- height: box.height,
6722
- },
7140
+ const gready = document.createElement('div');
7141
+ gready.className = 'dv-overlay-render-container';
7142
+ const overlayRenderContainer = new OverlayRenderContainer(gready);
7143
+ const referenceGroup = itemToPopout instanceof DockviewPanel
7144
+ ? itemToPopout.group
7145
+ : itemToPopout;
7146
+ const referenceLocation = itemToPopout.api.location.type;
7147
+ const group = (_a = options === null || options === void 0 ? void 0 : options.overridePopoutGroup) !== null && _a !== void 0 ? _a : this.createGroup({ id: groupId });
7148
+ group.model.renderContainer = overlayRenderContainer;
7149
+ if (!(options === null || options === void 0 ? void 0 : options.overridePopoutGroup)) {
7150
+ this._onDidAddGroup.fire(group);
7151
+ }
7152
+ if (itemToPopout instanceof DockviewPanel) {
7153
+ this.movingLock(() => {
7154
+ const panel = referenceGroup.model.removePanel(itemToPopout);
7155
+ group.model.openPanel(panel);
7156
+ });
7157
+ }
7158
+ else {
7159
+ this.movingLock(() => moveGroupWithoutDestroying({
7160
+ from: referenceGroup,
7161
+ to: group,
7162
+ }));
7163
+ switch (referenceLocation) {
7164
+ case 'grid':
7165
+ referenceGroup.api.setHidden(true);
7166
+ break;
7167
+ case 'floating':
7168
+ case 'popout':
7169
+ this.removeGroup(referenceGroup);
7170
+ break;
7171
+ }
7172
+ }
7173
+ popoutContainer.classList.add('dv-dockview');
7174
+ popoutContainer.style.overflow = 'hidden';
7175
+ popoutContainer.appendChild(gready);
7176
+ popoutContainer.appendChild(group.element);
7177
+ group.model.location = {
7178
+ type: 'popout',
7179
+ getWindow: () => _window.window,
7180
+ };
7181
+ this.doSetGroupAndPanelActive(group);
7182
+ popoutWindowDisposable.addDisposables(group.api.onDidActiveChange((event) => {
7183
+ var _a;
7184
+ if (event.isActive) {
7185
+ (_a = _window.window) === null || _a === void 0 ? void 0 : _a.focus();
7186
+ }
7187
+ }), group.api.onWillFocus(() => {
7188
+ var _a;
7189
+ (_a = _window.window) === null || _a === void 0 ? void 0 : _a.focus();
7190
+ }));
7191
+ let returnedGroup;
7192
+ const value = {
7193
+ window: _window,
7194
+ popoutGroup: group,
7195
+ referenceGroup: this.getPanel(referenceGroup.id)
7196
+ ? referenceGroup.id
7197
+ : undefined,
7198
+ disposable: {
7199
+ dispose: () => {
7200
+ popoutWindowDisposable.dispose();
7201
+ return returnedGroup;
7202
+ },
7203
+ },
7204
+ };
7205
+ popoutWindowDisposable.addDisposables(
7206
+ /**
7207
+ * ResizeObserver seems slow here, I do not know why but we don't need it
7208
+ * since we can reply on the window resize event as we will occupy the full
7209
+ * window dimensions
7210
+ */
7211
+ addDisposableWindowListener(_window.window, 'resize', () => {
7212
+ group.layout(window.innerWidth, window.innerHeight);
7213
+ }), overlayRenderContainer, Disposable.from(() => {
7214
+ if (this.getPanel(referenceGroup.id)) {
7215
+ this.movingLock(() => moveGroupWithoutDestroying({
7216
+ from: group,
7217
+ to: referenceGroup,
7218
+ }));
7219
+ if (referenceGroup.api.isHidden) {
7220
+ referenceGroup.api.setHidden(false);
7221
+ }
7222
+ if (this.getPanel(group.id)) {
7223
+ this.doRemoveGroup(group, {
7224
+ skipPopoutAssociated: true,
7225
+ });
7226
+ }
7227
+ }
7228
+ else {
7229
+ if (this.getPanel(group.id)) {
7230
+ const removedGroup = this.doRemoveGroup(group, {
7231
+ skipDispose: true,
7232
+ skipActive: true,
7233
+ });
7234
+ removedGroup.model.renderContainer =
7235
+ this.overlayRenderContainer;
7236
+ removedGroup.model.location = { type: 'grid' };
7237
+ returnedGroup = removedGroup;
7238
+ }
7239
+ }
7240
+ }));
7241
+ this._popoutGroups.push(value);
7242
+ this.updateWatermark();
7243
+ })
7244
+ .catch((err) => {
7245
+ console.error(err);
6723
7246
  });
6724
- popoutWindow.addDisposables({
6725
- dispose: () => {
6726
- remove(this._popoutGroups, popoutWindow);
6727
- this.updateWatermark();
6728
- },
6729
- }, popoutWindow.window.onDidClose(() => {
6730
- this.doAddGroup(group, [0]);
6731
- }));
6732
- this._popoutGroups.push(popoutWindow);
6733
- this.updateWatermark();
6734
7247
  }
6735
7248
  addFloatingGroup(item, coord, options) {
6736
- var _a, _b, _c, _d, _e, _f;
7249
+ var _a, _b, _c, _d, _e, _f, _g;
6737
7250
  let group;
6738
7251
  if (item instanceof DockviewPanel) {
6739
7252
  group = this.createGroup();
6740
- this.removePanel(item, {
7253
+ this._onDidAddGroup.fire(group);
7254
+ this.movingLock(() => this.removePanel(item, {
6741
7255
  removeEmptyGroup: true,
6742
7256
  skipDispose: true,
6743
- });
6744
- group.model.openPanel(item);
7257
+ skipSetActiveGroup: true,
7258
+ }));
7259
+ group.model.openPanel(item, { skipSetGroupActive: true });
6745
7260
  }
6746
7261
  else {
6747
7262
  group = item;
7263
+ const popoutReferenceGroupId = (_a = this._popoutGroups.find((_) => _.popoutGroup === group)) === null || _a === void 0 ? void 0 : _a.referenceGroup;
7264
+ const popoutReferenceGroup = popoutReferenceGroupId
7265
+ ? this.getPanel(popoutReferenceGroupId)
7266
+ : undefined;
6748
7267
  const skip = typeof (options === null || options === void 0 ? void 0 : options.skipRemoveGroup) === 'boolean' &&
6749
7268
  options.skipRemoveGroup;
6750
7269
  if (!skip) {
6751
- this.doRemoveGroup(item, { skipDispose: true });
7270
+ if (popoutReferenceGroup) {
7271
+ this.movingLock(() => moveGroupWithoutDestroying({
7272
+ from: item,
7273
+ to: popoutReferenceGroup,
7274
+ }));
7275
+ this.doRemoveGroup(item, {
7276
+ skipPopoutReturn: true,
7277
+ skipPopoutAssociated: true,
7278
+ });
7279
+ this.doRemoveGroup(popoutReferenceGroup, {
7280
+ skipDispose: true,
7281
+ });
7282
+ group = popoutReferenceGroup;
7283
+ }
7284
+ else {
7285
+ this.doRemoveGroup(item, {
7286
+ skipDispose: true,
7287
+ skipPopoutReturn: true,
7288
+ skipPopoutAssociated: !!popoutReferenceGroup,
7289
+ });
7290
+ }
6752
7291
  }
6753
7292
  }
6754
- group.model.location = 'floating';
7293
+ group.model.location = { type: 'floating' };
6755
7294
  const overlayLeft = typeof (coord === null || coord === void 0 ? void 0 : coord.x) === 'number'
6756
7295
  ? Math.max(coord.x, 0)
6757
7296
  : DEFAULT_FLOATING_GROUP_POSITION.left;
@@ -6761,16 +7300,16 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6761
7300
  const overlay = new Overlay({
6762
7301
  container: this.gridview.element,
6763
7302
  content: group.element,
6764
- height: (_a = coord === null || coord === void 0 ? void 0 : coord.height) !== null && _a !== void 0 ? _a : 300,
6765
- width: (_b = coord === null || coord === void 0 ? void 0 : coord.width) !== null && _b !== void 0 ? _b : 300,
7303
+ height: (_b = coord === null || coord === void 0 ? void 0 : coord.height) !== null && _b !== void 0 ? _b : 300,
7304
+ width: (_c = coord === null || coord === void 0 ? void 0 : coord.width) !== null && _c !== void 0 ? _c : 300,
6766
7305
  left: overlayLeft,
6767
7306
  top: overlayTop,
6768
7307
  minimumInViewportWidth: this.options.floatingGroupBounds === 'boundedWithinViewport'
6769
7308
  ? undefined
6770
- : (_d = (_c = this.options.floatingGroupBounds) === null || _c === void 0 ? void 0 : _c.minimumWidthWithinViewport) !== null && _d !== void 0 ? _d : DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE,
7309
+ : (_e = (_d = this.options.floatingGroupBounds) === null || _d === void 0 ? void 0 : _d.minimumWidthWithinViewport) !== null && _e !== void 0 ? _e : DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE,
6771
7310
  minimumInViewportHeight: this.options.floatingGroupBounds === 'boundedWithinViewport'
6772
7311
  ? undefined
6773
- : (_f = (_e = this.options.floatingGroupBounds) === null || _e === void 0 ? void 0 : _e.minimumHeightWithinViewport) !== null && _f !== void 0 ? _f : DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE,
7312
+ : (_g = (_f = this.options.floatingGroupBounds) === null || _f === void 0 ? void 0 : _f.minimumHeightWithinViewport) !== null && _g !== void 0 ? _g : DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE,
6774
7313
  });
6775
7314
  const el = group.element.querySelector('.void-container');
6776
7315
  if (!el) {
@@ -6801,12 +7340,15 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6801
7340
  }), {
6802
7341
  dispose: () => {
6803
7342
  disposable.dispose();
6804
- group.model.location = 'grid';
7343
+ group.model.location = { type: 'grid' };
6805
7344
  remove(this._floatingGroups, floatingGroupPanel);
6806
7345
  this.updateWatermark();
6807
7346
  },
6808
7347
  });
6809
7348
  this._floatingGroups.push(floatingGroupPanel);
7349
+ if (!(options === null || options === void 0 ? void 0 : options.skipActiveGroup)) {
7350
+ this.doSetGroupAndPanelActive(group);
7351
+ }
6810
7352
  this.updateWatermark();
6811
7353
  }
6812
7354
  orthogonalize(position) {
@@ -6896,8 +7438,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6896
7438
  return this.panels.find((panel) => panel.id === id);
6897
7439
  }
6898
7440
  setActivePanel(panel) {
6899
- this.doSetGroupActive(panel.group);
6900
7441
  panel.group.model.openPanel(panel);
7442
+ this.doSetGroupAndPanelActive(panel.group);
6901
7443
  }
6902
7444
  moveToNext(options = {}) {
6903
7445
  var _a;
@@ -6958,7 +7500,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6958
7500
  });
6959
7501
  const popoutGroups = this._popoutGroups.map((group) => {
6960
7502
  return {
6961
- data: group.group.toJSON(),
7503
+ data: group.popoutGroup.toJSON(),
7504
+ gridReferenceGroup: group.referenceGroup,
6962
7505
  position: group.window.dimensions(),
6963
7506
  };
6964
7507
  });
@@ -6976,7 +7519,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6976
7519
  return result;
6977
7520
  }
6978
7521
  fromJSON(data) {
6979
- var _a, _b;
7522
+ var _a, _b, _c;
6980
7523
  this.clear();
6981
7524
  if (typeof data !== 'object' || data === null) {
6982
7525
  throw new Error('serialized layout must be a non-null object');
@@ -7015,7 +7558,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7015
7558
  const isActive = typeof activeView === 'string' &&
7016
7559
  activeView === panel.id;
7017
7560
  group.model.openPanel(panel, {
7018
- skipSetPanelActive: !isActive,
7561
+ skipSetActive: !isActive,
7019
7562
  skipSetGroupActive: true,
7020
7563
  });
7021
7564
  }
@@ -7045,11 +7588,16 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7045
7588
  }
7046
7589
  const serializedPopoutGroups = (_b = data.popoutGroups) !== null && _b !== void 0 ? _b : [];
7047
7590
  for (const serializedPopoutGroup of serializedPopoutGroups) {
7048
- const { data, position } = serializedPopoutGroup;
7591
+ const { data, position, gridReferenceGroup } = serializedPopoutGroup;
7049
7592
  const group = createGroupFromSerializedState(data);
7050
- this.addPopoutGroup(group, {
7593
+ this.addPopoutGroup((_c = (gridReferenceGroup
7594
+ ? this.getPanel(gridReferenceGroup)
7595
+ : undefined)) !== null && _c !== void 0 ? _c : group, {
7051
7596
  skipRemoveGroup: true,
7052
7597
  position: position !== null && position !== void 0 ? position : undefined,
7598
+ overridePopoutGroup: gridReferenceGroup
7599
+ ? group
7600
+ : undefined,
7053
7601
  });
7054
7602
  }
7055
7603
  for (const floatingGroup of this._floatingGroups) {
@@ -7096,12 +7644,13 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7096
7644
  */
7097
7645
  throw err;
7098
7646
  }
7647
+ this.updateWatermark();
7099
7648
  this._onDidLayoutFromJSON.fire();
7100
7649
  }
7101
7650
  clear() {
7102
7651
  const groups = Array.from(this._groups.values()).map((_) => _.value);
7103
7652
  const hasActiveGroup = !!this.activeGroup;
7104
- const hasActivePanel = !!this.activePanel;
7653
+ !!this.activePanel;
7105
7654
  for (const group of groups) {
7106
7655
  // remove the group will automatically remove the panels
7107
7656
  this.removeGroup(group, { skipActive: true });
@@ -7109,9 +7658,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7109
7658
  if (hasActiveGroup) {
7110
7659
  this.doSetGroupAndPanelActive(undefined);
7111
7660
  }
7112
- if (hasActivePanel) {
7113
- this._onDidActivePanelChange.fire(undefined);
7114
- }
7115
7661
  this.gridview.clear();
7116
7662
  }
7117
7663
  closeAllGroups() {
@@ -7152,6 +7698,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7152
7698
  const group = this.orthogonalize(directionToPosition(options.position.direction));
7153
7699
  const panel = this.createPanel(options, group);
7154
7700
  group.model.openPanel(panel);
7701
+ this.doSetGroupAndPanelActive(group);
7155
7702
  return panel;
7156
7703
  }
7157
7704
  }
@@ -7163,6 +7710,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7163
7710
  const target = toTarget(((_b = options.position) === null || _b === void 0 ? void 0 : _b.direction) || 'within');
7164
7711
  if (options.floating) {
7165
7712
  const group = this.createGroup();
7713
+ this._onDidAddGroup.fire(group);
7166
7714
  const o = typeof options.floating === 'object' &&
7167
7715
  options.floating !== null
7168
7716
  ? options.floating
@@ -7170,16 +7718,16 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7170
7718
  this.addFloatingGroup(group, o, {
7171
7719
  inDragMode: false,
7172
7720
  skipRemoveGroup: true,
7721
+ skipActiveGroup: true,
7173
7722
  });
7174
- this._onDidAddGroup.fire(group);
7175
7723
  panel = this.createPanel(options, group);
7176
7724
  group.model.openPanel(panel);
7177
- this.doSetGroupAndPanelActive(group);
7178
7725
  }
7179
- else if (referenceGroup.api.location === 'floating' ||
7726
+ else if (referenceGroup.api.location.type === 'floating' ||
7180
7727
  target === 'center') {
7181
7728
  panel = this.createPanel(options, referenceGroup);
7182
7729
  referenceGroup.model.openPanel(panel);
7730
+ this.doSetGroupAndPanelActive(referenceGroup);
7183
7731
  }
7184
7732
  else {
7185
7733
  const location = getGridLocation(referenceGroup.element);
@@ -7187,10 +7735,12 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7187
7735
  const group = this.createGroupAtLocation(relativeLocation);
7188
7736
  panel = this.createPanel(options, group);
7189
7737
  group.model.openPanel(panel);
7738
+ this.doSetGroupAndPanelActive(group);
7190
7739
  }
7191
7740
  }
7192
7741
  else if (options.floating) {
7193
7742
  const group = this.createGroup();
7743
+ this._onDidAddGroup.fire(group);
7194
7744
  const o = typeof options.floating === 'object' &&
7195
7745
  options.floating !== null
7196
7746
  ? options.floating
@@ -7198,16 +7748,16 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7198
7748
  this.addFloatingGroup(group, o, {
7199
7749
  inDragMode: false,
7200
7750
  skipRemoveGroup: true,
7751
+ skipActiveGroup: true,
7201
7752
  });
7202
- this._onDidAddGroup.fire(group);
7203
7753
  panel = this.createPanel(options, group);
7204
7754
  group.model.openPanel(panel);
7205
- this.doSetGroupAndPanelActive(group);
7206
7755
  }
7207
7756
  else {
7208
7757
  const group = this.createGroupAtLocation();
7209
7758
  panel = this.createPanel(options, group);
7210
7759
  group.model.openPanel(panel);
7760
+ this.doSetGroupAndPanelActive(group);
7211
7761
  }
7212
7762
  return panel;
7213
7763
  }
@@ -7219,13 +7769,15 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7219
7769
  if (!group) {
7220
7770
  throw new Error(`cannot remove panel ${panel.id}. it's missing a group.`);
7221
7771
  }
7222
- group.model.removePanel(panel);
7772
+ group.model.removePanel(panel, {
7773
+ skipSetActiveGroup: options.skipSetActiveGroup,
7774
+ });
7223
7775
  if (!options.skipDispose) {
7224
- this.overlayRenderContainer.detatch(panel);
7776
+ panel.group.model.renderContainer.detatch(panel);
7225
7777
  panel.dispose();
7226
7778
  }
7227
7779
  if (group.size === 0 && options.removeEmptyGroup) {
7228
- this.removeGroup(group);
7780
+ this.removeGroup(group, { skipActive: options.skipSetActiveGroup });
7229
7781
  }
7230
7782
  }
7231
7783
  createWatermarkComponent() {
@@ -7238,7 +7790,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7238
7790
  }
7239
7791
  updateWatermark() {
7240
7792
  var _a, _b;
7241
- if (this.groups.filter((x) => x.api.location === 'grid').length === 0) {
7793
+ if (this.groups.filter((x) => x.api.location.type === 'grid' && !x.api.isHidden).length === 0) {
7242
7794
  if (!this.watermark) {
7243
7795
  this.watermark = this.createWatermarkComponent();
7244
7796
  this.watermark.init({
@@ -7284,36 +7836,42 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7284
7836
  }
7285
7837
  else {
7286
7838
  const group = this.orthogonalize(directionToPosition(options.direction));
7839
+ if (!options.skipSetActive) {
7840
+ this.doSetGroupAndPanelActive(group);
7841
+ }
7287
7842
  return group;
7288
7843
  }
7289
7844
  const target = toTarget(options.direction || 'within');
7290
7845
  const location = getGridLocation(referenceGroup.element);
7291
7846
  const relativeLocation = getRelativeLocation(this.gridview.orientation, location, target);
7292
7847
  this.doAddGroup(group, relativeLocation);
7848
+ if (!options.skipSetActive) {
7849
+ this.doSetGroupAndPanelActive(group);
7850
+ }
7293
7851
  return group;
7294
7852
  }
7295
7853
  else {
7296
7854
  this.doAddGroup(group);
7855
+ this.doSetGroupAndPanelActive(group);
7297
7856
  return group;
7298
7857
  }
7299
7858
  }
7300
7859
  removeGroup(group, options) {
7860
+ this.doRemoveGroup(group, options);
7861
+ }
7862
+ doRemoveGroup(group, options) {
7301
7863
  var _a;
7302
7864
  const panels = [...group.panels]; // reassign since group panels will mutate
7303
- for (const panel of panels) {
7304
- this.removePanel(panel, {
7305
- removeEmptyGroup: false,
7306
- skipDispose: (_a = options === null || options === void 0 ? void 0 : options.skipDispose) !== null && _a !== void 0 ? _a : false,
7307
- });
7865
+ if (!(options === null || options === void 0 ? void 0 : options.skipDispose)) {
7866
+ for (const panel of panels) {
7867
+ this.removePanel(panel, {
7868
+ removeEmptyGroup: false,
7869
+ skipDispose: (_a = options === null || options === void 0 ? void 0 : options.skipDispose) !== null && _a !== void 0 ? _a : false,
7870
+ });
7871
+ }
7308
7872
  }
7309
7873
  const activePanel = this.activePanel;
7310
- this.doRemoveGroup(group, options);
7311
- if (this.activePanel !== activePanel) {
7312
- this._onDidActivePanelChange.fire(this.activePanel);
7313
- }
7314
- }
7315
- doRemoveGroup(group, options) {
7316
- if (group.api.location === 'floating') {
7874
+ if (group.api.location.type === 'floating') {
7317
7875
  const floatingGroup = this._floatingGroups.find((_) => _.group === group);
7318
7876
  if (floatingGroup) {
7319
7877
  if (!(options === null || options === void 0 ? void 0 : options.skipDispose)) {
@@ -7325,60 +7883,124 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7325
7883
  floatingGroup.dispose();
7326
7884
  if (!(options === null || options === void 0 ? void 0 : options.skipActive) && this._activeGroup === group) {
7327
7885
  const groups = Array.from(this._groups.values());
7328
- this.doSetGroupActive(groups.length > 0 ? groups[0].value : undefined);
7886
+ this.doSetGroupAndPanelActive(groups.length > 0 ? groups[0].value : undefined);
7329
7887
  }
7330
7888
  return floatingGroup.group;
7331
7889
  }
7332
7890
  throw new Error('failed to find floating group');
7333
7891
  }
7334
- if (group.api.location === 'popout') {
7335
- const selectedGroup = this._popoutGroups.find((_) => _.group === group);
7892
+ if (group.api.location.type === 'popout') {
7893
+ const selectedGroup = this._popoutGroups.find((_) => _.popoutGroup === group);
7336
7894
  if (selectedGroup) {
7337
7895
  if (!(options === null || options === void 0 ? void 0 : options.skipDispose)) {
7338
- selectedGroup.group.dispose();
7896
+ if (!(options === null || options === void 0 ? void 0 : options.skipPopoutAssociated)) {
7897
+ const refGroup = selectedGroup.referenceGroup
7898
+ ? this.getPanel(selectedGroup.referenceGroup)
7899
+ : undefined;
7900
+ if (refGroup) {
7901
+ this.removeGroup(refGroup);
7902
+ }
7903
+ }
7904
+ selectedGroup.popoutGroup.dispose();
7339
7905
  this._groups.delete(group.id);
7340
7906
  this._onDidRemoveGroup.fire(group);
7341
7907
  }
7342
- selectedGroup.dispose();
7908
+ const removedGroup = selectedGroup.disposable.dispose();
7909
+ if (!(options === null || options === void 0 ? void 0 : options.skipPopoutReturn) && removedGroup) {
7910
+ this.doAddGroup(removedGroup, [0]);
7911
+ this.doSetGroupAndPanelActive(removedGroup);
7912
+ }
7343
7913
  if (!(options === null || options === void 0 ? void 0 : options.skipActive) && this._activeGroup === group) {
7344
7914
  const groups = Array.from(this._groups.values());
7345
- this.doSetGroupActive(groups.length > 0 ? groups[0].value : undefined);
7915
+ this.doSetGroupAndPanelActive(groups.length > 0 ? groups[0].value : undefined);
7346
7916
  }
7347
- return selectedGroup.group;
7917
+ this.updateWatermark();
7918
+ return selectedGroup.popoutGroup;
7348
7919
  }
7349
7920
  throw new Error('failed to find popout group');
7350
7921
  }
7351
- return super.doRemoveGroup(group, options);
7922
+ const re = super.doRemoveGroup(group, options);
7923
+ if (!(options === null || options === void 0 ? void 0 : options.skipActive)) {
7924
+ if (this.activePanel !== activePanel) {
7925
+ this._onDidActivePanelChange.fire(this.activePanel);
7926
+ }
7927
+ }
7928
+ return re;
7352
7929
  }
7353
- moveGroupOrPanel(destinationGroup, sourceGroupId, sourceItemId, destinationTarget, destinationIndex) {
7354
- var _a, _b, _c;
7930
+ movingLock(func) {
7931
+ const isMoving = this._moving;
7932
+ try {
7933
+ this._moving = true;
7934
+ return func();
7935
+ }
7936
+ finally {
7937
+ this._moving = isMoving;
7938
+ }
7939
+ }
7940
+ moveGroupOrPanel(options) {
7941
+ var _a;
7942
+ const destinationGroup = options.to.group;
7943
+ const sourceGroupId = options.from.groupId;
7944
+ const sourceItemId = options.from.panelId;
7945
+ const destinationTarget = options.to.position;
7946
+ const destinationIndex = options.to.index;
7355
7947
  const sourceGroup = sourceGroupId
7356
7948
  ? (_a = this._groups.get(sourceGroupId)) === null || _a === void 0 ? void 0 : _a.value
7357
7949
  : undefined;
7950
+ if (!sourceGroup) {
7951
+ throw new Error(`Failed to find group id ${sourceGroupId}`);
7952
+ }
7358
7953
  if (sourceItemId === undefined) {
7359
- if (sourceGroup) {
7360
- this.moveGroup(sourceGroup, destinationGroup, destinationTarget);
7361
- }
7954
+ /**
7955
+ * Moving an entire group into another group
7956
+ */
7957
+ this.moveGroup({
7958
+ from: { group: sourceGroup },
7959
+ to: {
7960
+ group: destinationGroup,
7961
+ position: destinationTarget,
7962
+ },
7963
+ });
7362
7964
  return;
7363
7965
  }
7364
7966
  if (!destinationTarget || destinationTarget === 'center') {
7365
- 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);
7366
- if (!groupItem) {
7967
+ /**
7968
+ * Dropping a panel within another group
7969
+ */
7970
+ const removedPanel = this.movingLock(() => sourceGroup.model.removePanel(sourceItemId, {
7971
+ skipSetActive: false,
7972
+ skipSetActiveGroup: true,
7973
+ }));
7974
+ if (!removedPanel) {
7367
7975
  throw new Error(`No panel with id ${sourceItemId}`);
7368
7976
  }
7369
- if ((sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.size) === 0) {
7370
- this.doRemoveGroup(sourceGroup);
7977
+ if (sourceGroup.model.size === 0) {
7978
+ // remove the group and do not set a new group as active
7979
+ this.doRemoveGroup(sourceGroup, { skipActive: true });
7371
7980
  }
7372
- destinationGroup.model.openPanel(groupItem, {
7981
+ this.movingLock(() => destinationGroup.model.openPanel(removedPanel, {
7373
7982
  index: destinationIndex,
7983
+ skipSetGroupActive: true,
7984
+ }));
7985
+ this.doSetGroupAndPanelActive(destinationGroup);
7986
+ this._onDidMovePanel.fire({
7987
+ panel: removedPanel,
7374
7988
  });
7375
7989
  }
7376
7990
  else {
7991
+ /**
7992
+ * Dropping a panel to the extremities of a group which will place that panel
7993
+ * into an adjacent group
7994
+ */
7377
7995
  const referenceLocation = getGridLocation(destinationGroup.element);
7378
7996
  const targetLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, destinationTarget);
7379
- if (sourceGroup && sourceGroup.size < 2) {
7997
+ if (sourceGroup.size < 2) {
7998
+ /**
7999
+ * If we are moving from a group which only has one panel left we will consider
8000
+ * moving the group itself rather than moving the panel into a newly created group
8001
+ */
7380
8002
  const [targetParentLocation, to] = tail(targetLocation);
7381
- if (sourceGroup.api.location === 'grid') {
8003
+ if (sourceGroup.api.location.type === 'grid') {
7382
8004
  const sourceLocation = getGridLocation(sourceGroup.element);
7383
8005
  const [sourceParentLocation, from] = tail(sourceLocation);
7384
8006
  if (sequenceEquals(sourceParentLocation, targetParentLocation)) {
@@ -7386,78 +8008,123 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7386
8008
  // if a group has one tab - we are essentially moving the 'group'
7387
8009
  // which is equivalent to swapping two views in this case
7388
8010
  this.gridview.moveView(sourceParentLocation, from, to);
8011
+ return;
7389
8012
  }
7390
8013
  }
7391
8014
  // source group will become empty so delete the group
7392
- const targetGroup = this.doRemoveGroup(sourceGroup, {
8015
+ const targetGroup = this.movingLock(() => this.doRemoveGroup(sourceGroup, {
7393
8016
  skipActive: true,
7394
8017
  skipDispose: true,
7395
- });
8018
+ }));
7396
8019
  // after deleting the group we need to re-evaulate the ref location
7397
8020
  const updatedReferenceLocation = getGridLocation(destinationGroup.element);
7398
8021
  const location = getRelativeLocation(this.gridview.orientation, updatedReferenceLocation, destinationTarget);
7399
- this.doAddGroup(targetGroup, location);
8022
+ this.movingLock(() => this.doAddGroup(targetGroup, location));
8023
+ this.doSetGroupAndPanelActive(targetGroup);
7400
8024
  }
7401
8025
  else {
7402
- 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);
7403
- if (!groupItem) {
8026
+ /**
8027
+ * The group we are removing from has many panels, we need to remove the panels we are moving,
8028
+ * create a new group, add the panels to that new group and add the new group in an appropiate position
8029
+ */
8030
+ const removedPanel = this.movingLock(() => sourceGroup.model.removePanel(sourceItemId, {
8031
+ skipSetActive: false,
8032
+ skipSetActiveGroup: true,
8033
+ }));
8034
+ if (!removedPanel) {
7404
8035
  throw new Error(`No panel with id ${sourceItemId}`);
7405
8036
  }
7406
8037
  const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, destinationTarget);
7407
8038
  const group = this.createGroupAtLocation(dropLocation);
7408
- group.model.openPanel(groupItem);
8039
+ this.movingLock(() => group.model.openPanel(removedPanel, {
8040
+ skipSetGroupActive: true,
8041
+ }));
8042
+ this.doSetGroupAndPanelActive(group);
7409
8043
  }
7410
8044
  }
7411
8045
  }
7412
- moveGroup(sourceGroup, referenceGroup, target) {
7413
- if (sourceGroup) {
7414
- if (!target || target === 'center') {
7415
- const activePanel = sourceGroup.activePanel;
7416
- const panels = [...sourceGroup.panels].map((p) => sourceGroup.model.removePanel(p.id));
7417
- if ((sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.size) === 0) {
7418
- this.doRemoveGroup(sourceGroup);
7419
- }
8046
+ moveGroup(options) {
8047
+ const from = options.from.group;
8048
+ const to = options.to.group;
8049
+ const target = options.to.position;
8050
+ if (target === 'center') {
8051
+ const activePanel = from.activePanel;
8052
+ const panels = this.movingLock(() => [...from.panels].map((p) => from.model.removePanel(p.id, {
8053
+ skipSetActive: true,
8054
+ })));
8055
+ if ((from === null || from === void 0 ? void 0 : from.model.size) === 0) {
8056
+ this.doRemoveGroup(from, { skipActive: true });
8057
+ }
8058
+ this.movingLock(() => {
7420
8059
  for (const panel of panels) {
7421
- referenceGroup.model.openPanel(panel, {
7422
- skipSetPanelActive: panel !== activePanel,
8060
+ to.model.openPanel(panel, {
8061
+ skipSetActive: panel !== activePanel,
8062
+ skipSetGroupActive: true,
7423
8063
  });
7424
8064
  }
7425
- }
7426
- else {
7427
- switch (sourceGroup.api.location) {
7428
- case 'grid':
7429
- this.gridview.removeView(getGridLocation(sourceGroup.element));
7430
- break;
7431
- case 'floating': {
7432
- const selectedFloatingGroup = this._floatingGroups.find((x) => x.group === sourceGroup);
7433
- if (!selectedFloatingGroup) {
7434
- throw new Error('failed to find floating group');
7435
- }
7436
- selectedFloatingGroup.dispose();
7437
- break;
8065
+ });
8066
+ this.doSetGroupAndPanelActive(to);
8067
+ panels.forEach((panel) => {
8068
+ this._onDidMovePanel.fire({ panel });
8069
+ });
8070
+ }
8071
+ else {
8072
+ switch (from.api.location.type) {
8073
+ case 'grid':
8074
+ this.gridview.removeView(getGridLocation(from.element));
8075
+ break;
8076
+ case 'floating': {
8077
+ const selectedFloatingGroup = this._floatingGroups.find((x) => x.group === from);
8078
+ if (!selectedFloatingGroup) {
8079
+ throw new Error('failed to find floating group');
7438
8080
  }
7439
- case 'popout': {
7440
- const selectedPopoutGroup = this._popoutGroups.find((x) => x.group === sourceGroup);
7441
- if (!selectedPopoutGroup) {
7442
- throw new Error('failed to find popout group');
7443
- }
7444
- selectedPopoutGroup.dispose();
8081
+ selectedFloatingGroup.dispose();
8082
+ break;
8083
+ }
8084
+ case 'popout': {
8085
+ const selectedPopoutGroup = this._popoutGroups.find((x) => x.popoutGroup === from);
8086
+ if (!selectedPopoutGroup) {
8087
+ throw new Error('failed to find popout group');
7445
8088
  }
8089
+ selectedPopoutGroup.disposable.dispose();
7446
8090
  }
7447
- const referenceLocation = getGridLocation(referenceGroup.element);
7448
- const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, target);
7449
- this.gridview.addView(sourceGroup, exports.Sizing.Distribute, dropLocation);
7450
8091
  }
8092
+ const referenceLocation = getGridLocation(to.element);
8093
+ const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, target);
8094
+ this.gridview.addView(from, exports.Sizing.Distribute, dropLocation);
8095
+ from.panels.forEach((panel) => {
8096
+ this._onDidMovePanel.fire({ panel });
8097
+ });
7451
8098
  }
7452
8099
  }
7453
- doSetGroupAndPanelActive(group, skipFocus) {
7454
- var _a, _b;
8100
+ doSetGroupActive(group) {
8101
+ super.doSetGroupActive(group);
8102
+ const activePanel = this.activePanel;
8103
+ if (!this._moving &&
8104
+ activePanel !== this._onDidActivePanelChange.value) {
8105
+ this._onDidActivePanelChange.fire(activePanel);
8106
+ }
8107
+ }
8108
+ doSetGroupAndPanelActive(group) {
8109
+ super.doSetGroupActive(group);
7455
8110
  const activePanel = this.activePanel;
7456
- super.doSetGroupActive(group, skipFocus);
7457
- if (((_a = this._activeGroup) === null || _a === void 0 ? void 0 : _a.activePanel) !== activePanel) {
7458
- this._onDidActivePanelChange.fire((_b = this._activeGroup) === null || _b === void 0 ? void 0 : _b.activePanel);
8111
+ if (group &&
8112
+ this.hasMaximizedGroup() &&
8113
+ !this.isMaximizedGroup(group)) {
8114
+ this.exitMaximizedGroup();
8115
+ }
8116
+ if (!this._moving &&
8117
+ activePanel !== this._onDidActivePanelChange.value) {
8118
+ this._onDidActivePanelChange.fire(activePanel);
7459
8119
  }
7460
8120
  }
8121
+ getNextGroupId() {
8122
+ let id = this.nextGroupId.next();
8123
+ while (this._groups.has(id)) {
8124
+ id = this.nextGroupId.next();
8125
+ }
8126
+ return id;
8127
+ }
7461
8128
  createGroup(options) {
7462
8129
  if (!options) {
7463
8130
  options = {};
@@ -7474,7 +8141,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7474
8141
  }
7475
8142
  }
7476
8143
  const view = new DockviewGroupPanel(this, id, options);
7477
- view.init({ params: {}, accessor: null }); // required to initialized .part and allow for correct disposal of group
8144
+ view.init({ params: {}, accessor: this });
7478
8145
  if (!this._groups.has(view.id)) {
7479
8146
  const disposable = new CompositeDisposable(view.model.onTabDragStart((event) => {
7480
8147
  this._onWillDragPanel.fire(event);
@@ -7482,20 +8149,48 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7482
8149
  this._onWillDragGroup.fire(event);
7483
8150
  }), view.model.onMove((event) => {
7484
8151
  const { groupId, itemId, target, index } = event;
7485
- this.moveGroupOrPanel(view, groupId, itemId, target, index);
8152
+ this.moveGroupOrPanel({
8153
+ from: { groupId: groupId, panelId: itemId },
8154
+ to: {
8155
+ group: view,
8156
+ position: target,
8157
+ index,
8158
+ },
8159
+ });
7486
8160
  }), view.model.onDidDrop((event) => {
7487
- this._onDidDrop.fire(Object.assign(Object.assign({}, event), { api: this._api, group: view }));
8161
+ this._onDidDrop.fire(event);
8162
+ }), view.model.onWillDrop((event) => {
8163
+ this._onWillDrop.fire(event);
8164
+ }), view.model.onWillShowOverlay((event) => {
8165
+ if (this.options.disableDnd) {
8166
+ event.preventDefault();
8167
+ return;
8168
+ }
8169
+ this._onWillShowOverlay.fire(event);
7488
8170
  }), view.model.onDidAddPanel((event) => {
8171
+ if (this._moving) {
8172
+ return;
8173
+ }
7489
8174
  this._onDidAddPanel.fire(event.panel);
7490
8175
  }), view.model.onDidRemovePanel((event) => {
8176
+ if (this._moving) {
8177
+ return;
8178
+ }
7491
8179
  this._onDidRemovePanel.fire(event.panel);
7492
8180
  }), view.model.onDidActivePanelChange((event) => {
7493
- this._onDidActivePanelChange.fire(event.panel);
8181
+ if (this._moving) {
8182
+ return;
8183
+ }
8184
+ if (event.panel !== this.activePanel) {
8185
+ return;
8186
+ }
8187
+ if (this._onDidActivePanelChange.value !== event.panel) {
8188
+ this._onDidActivePanelChange.fire(event.panel);
8189
+ }
7494
8190
  }));
7495
8191
  this._groups.set(view.id, { value: view, disposable });
7496
8192
  }
7497
- // TODO: must be called after the above listeners have been setup,
7498
- // not an ideal pattern
8193
+ // TODO: must be called after the above listeners have been setup, not an ideal pattern
7499
8194
  view.initialize();
7500
8195
  return view;
7501
8196
  }
@@ -7548,7 +8243,20 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7548
8243
  });
7549
8244
  this._onDidLayoutfromJSON = new Emitter();
7550
8245
  this.onDidLayoutFromJSON = this._onDidLayoutfromJSON.event;
8246
+ this._onDidRemoveGroup = new Emitter();
8247
+ this.onDidRemoveGroup = this._onDidRemoveGroup.event;
8248
+ this._onDidAddGroup = new Emitter();
8249
+ this.onDidAddGroup = this._onDidAddGroup.event;
8250
+ this._onDidActiveGroupChange = new Emitter();
8251
+ this.onDidActiveGroupChange = this._onDidActiveGroupChange.event;
7551
8252
  this._options = options;
8253
+ this.addDisposables(this._onDidAddGroup, this._onDidRemoveGroup, this._onDidActiveGroupChange, this.onDidAdd((event) => {
8254
+ this._onDidAddGroup.fire(event);
8255
+ }), this.onDidRemove((event) => {
8256
+ this._onDidRemoveGroup.fire(event);
8257
+ }), this.onDidActiveChange((event) => {
8258
+ this._onDidActiveGroupChange.fire(event);
8259
+ }));
7552
8260
  if (!this.options.components) {
7553
8261
  this.options.components = {};
7554
8262
  }
@@ -7723,6 +8431,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7723
8431
  });
7724
8432
  this.registerPanel(view);
7725
8433
  this.doAddGroup(view, relativeLocation, options.size);
8434
+ this.doSetGroupActive(view);
7726
8435
  return view;
7727
8436
  }
7728
8437
  registerPanel(panel) {
@@ -8408,10 +9117,10 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
8408
9117
  this._onDidChange = new Emitter();
8409
9118
  this.onDidChange = this._onDidChange.event;
8410
9119
  this.api.initialize(this);
8411
- this.addDisposables(this._onDidChange, this.api.onVisibilityChange((event) => {
8412
- const { isVisible } = event;
9120
+ this.addDisposables(this._onDidChange, this.api.onDidHiddenChange((event) => {
9121
+ const { isHidden } = event;
8413
9122
  const { accessor } = this._params;
8414
- accessor.setVisible(this, isVisible);
9123
+ accessor.setVisible(this, !isHidden);
8415
9124
  }), this.api.onActiveChange(() => {
8416
9125
  const { accessor } = this._params;
8417
9126
  accessor.setActive(this);
@@ -8533,13 +9242,13 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
8533
9242
  if (this.disposed) {
8534
9243
  throw new Error('invalid operation: resource is already disposed');
8535
9244
  }
8536
- if (typeof this.component !== 'function') {
9245
+ if (!isReactComponent(this.component)) {
8537
9246
  /**
8538
9247
  * we know this isn't a React.FunctionComponent so throw an error here.
8539
- * if we do not intercept this the React library will throw a very obsure error
8540
- * for the same reason, at least at this point we will emit a sensible stacktrace.
9248
+ * if we do not intercept then React library will throw a very obsure error
9249
+ * for the same reason... at least at this point we will emit a sensible stacktrace.
8541
9250
  */
8542
- throw new Error('Invalid Operation. dockview only supports React Functional Components.');
9251
+ throw new Error('Dockview: Only React.memo(...), React.ForwardRef(...) and functional components are accepted as components');
8543
9252
  }
8544
9253
  const bridgeComponent = React__namespace.createElement(React__namespace.forwardRef(ReactComponentBridge), {
8545
9254
  component: this
@@ -8591,9 +9300,13 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
8591
9300
  }, []);
8592
9301
  return [portals, addPortal];
8593
9302
  };
8594
- // it does the job...
8595
- function isReactElement(element) {
8596
- return !!(element === null || element === void 0 ? void 0 : element.type);
9303
+ function isReactComponent(component) {
9304
+ /**
9305
+ * Yes, we could use "react-is" but that would introduce an unwanted peer dependency
9306
+ * so for now we will check in a rather crude fashion...
9307
+ */
9308
+ return (typeof component === 'function' /** Functional Componnts */ ||
9309
+ !!(component === null || component === void 0 ? void 0 : component.$$typeof) /** React.memo(...) Components */);
8597
9310
  }
8598
9311
 
8599
9312
  class ReactPanelContentPart {
@@ -8853,6 +9566,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
8853
9566
  defaultRenderer: props.defaultRenderer,
8854
9567
  debug: props.debug,
8855
9568
  rootOverlayModel: props.rootOverlayModel,
9569
+ locked: props.locked,
9570
+ disableDnd: props.disableDnd,
8856
9571
  });
8857
9572
  const { clientWidth, clientHeight } = domRef.current;
8858
9573
  dockview.layout(clientWidth, clientHeight);
@@ -8864,6 +9579,20 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
8864
9579
  dockview.dispose();
8865
9580
  };
8866
9581
  }, []);
9582
+ React__namespace.useEffect(() => {
9583
+ if (!dockviewRef.current) {
9584
+ return;
9585
+ }
9586
+ dockviewRef.current.locked = !!props.locked;
9587
+ }, [props.locked]);
9588
+ React__namespace.useEffect(() => {
9589
+ if (!dockviewRef.current) {
9590
+ return;
9591
+ }
9592
+ dockviewRef.current.updateOptions({
9593
+ disableDnd: props.disableDnd,
9594
+ });
9595
+ }, [props.disableDnd]);
8867
9596
  React__namespace.useEffect(() => {
8868
9597
  if (!dockviewRef.current) {
8869
9598
  return () => {
@@ -8879,6 +9608,21 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
8879
9608
  disposable.dispose();
8880
9609
  };
8881
9610
  }, [props.onDidDrop]);
9611
+ React__namespace.useEffect(() => {
9612
+ if (!dockviewRef.current) {
9613
+ return () => {
9614
+ // noop
9615
+ };
9616
+ }
9617
+ const disposable = dockviewRef.current.onWillDrop((event) => {
9618
+ if (props.onWillDrop) {
9619
+ props.onWillDrop(event);
9620
+ }
9621
+ });
9622
+ return () => {
9623
+ disposable.dispose();
9624
+ };
9625
+ }, [props.onWillDrop]);
8882
9626
  React__namespace.useEffect(() => {
8883
9627
  if (!dockviewRef.current) {
8884
9628
  return;
@@ -9121,7 +9865,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
9121
9865
  return new ReactPart(this.element, this.reactPortalStore, this.reactComponent, {
9122
9866
  params: (_b = (_a = this._params) === null || _a === void 0 ? void 0 : _a.params) !== null && _b !== void 0 ? _b : {},
9123
9867
  api: this.api,
9124
- containerApi: new GridviewApi(this._params.accessor),
9868
+ // TODO: fix casting hack
9869
+ containerApi: new GridviewApi(this._params
9870
+ .accessor),
9125
9871
  });
9126
9872
  }
9127
9873
  }
@@ -9304,12 +10050,14 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
9304
10050
  exports.DockviewComponent = DockviewComponent;
9305
10051
  exports.DockviewCompositeDisposable = CompositeDisposable;
9306
10052
  exports.DockviewDefaultTab = DockviewDefaultTab;
10053
+ exports.DockviewDidDropEvent = DockviewDidDropEvent;
9307
10054
  exports.DockviewEmitter = Emitter;
9308
10055
  exports.DockviewGroupPanel = DockviewGroupPanel;
9309
10056
  exports.DockviewGroupPanelModel = DockviewGroupPanelModel;
9310
10057
  exports.DockviewMutableDisposable = MutableDisposable;
9311
10058
  exports.DockviewPanel = DockviewPanel;
9312
10059
  exports.DockviewReact = DockviewReact;
10060
+ exports.DockviewWillDropEvent = DockviewWillDropEvent;
9313
10061
  exports.DraggablePaneviewPanel = DraggablePaneviewPanel;
9314
10062
  exports.Gridview = Gridview;
9315
10063
  exports.GridviewApi = GridviewApi;
@@ -9333,6 +10081,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
9333
10081
  exports.SplitviewPanel = SplitviewPanel;
9334
10082
  exports.SplitviewReact = SplitviewReact;
9335
10083
  exports.Tab = Tab;
10084
+ exports.WillShowOverlayLocationEvent = WillShowOverlayLocationEvent;
9336
10085
  exports.createComponent = createComponent;
9337
10086
  exports.directionToPosition = directionToPosition;
9338
10087
  exports.getDirectionOrientation = getDirectionOrientation;
@@ -9347,7 +10096,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
9347
10096
  exports.isGroupOptionsWithPanel = isGroupOptionsWithPanel;
9348
10097
  exports.isPanelOptionsWithGroup = isPanelOptionsWithGroup;
9349
10098
  exports.isPanelOptionsWithPanel = isPanelOptionsWithPanel;
9350
- exports.isReactElement = isReactElement;
10099
+ exports.isReactComponent = isReactComponent;
9351
10100
  exports.orthogonal = orthogonal;
9352
10101
  exports.positionToDirection = positionToDirection;
9353
10102
  exports.toTarget = toTarget;