dockview 1.9.1 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/dist/cjs/dockview/defaultTab.d.ts +0 -1
  2. package/dist/cjs/dockview/defaultTab.js +0 -1
  3. package/dist/cjs/dockview/dockview.d.ts +5 -3
  4. package/dist/cjs/dockview/dockview.js +31 -1
  5. package/dist/cjs/dockview/headerActionsRenderer.d.ts +0 -1
  6. package/dist/cjs/dockview/headerActionsRenderer.js +0 -1
  7. package/dist/cjs/dockview/reactContentPart.d.ts +0 -1
  8. package/dist/cjs/dockview/reactContentPart.js +0 -1
  9. package/dist/cjs/dockview/reactHeaderPart.d.ts +0 -1
  10. package/dist/cjs/dockview/reactHeaderPart.js +0 -1
  11. package/dist/cjs/dockview/reactWatermarkPart.d.ts +0 -1
  12. package/dist/cjs/dockview/reactWatermarkPart.js +0 -1
  13. package/dist/cjs/gridview/gridview.d.ts +0 -1
  14. package/dist/cjs/gridview/gridview.js +0 -1
  15. package/dist/cjs/gridview/view.d.ts +0 -1
  16. package/dist/cjs/gridview/view.js +3 -2
  17. package/dist/cjs/index.d.ts +0 -1
  18. package/dist/cjs/index.js +0 -1
  19. package/dist/cjs/paneview/paneview.d.ts +0 -1
  20. package/dist/cjs/paneview/paneview.js +0 -1
  21. package/dist/cjs/paneview/view.d.ts +0 -1
  22. package/dist/cjs/paneview/view.js +0 -1
  23. package/dist/cjs/react.d.ts +1 -2
  24. package/dist/cjs/react.js +13 -10
  25. package/dist/cjs/splitview/splitview.d.ts +0 -1
  26. package/dist/cjs/splitview/splitview.js +0 -1
  27. package/dist/cjs/splitview/view.d.ts +0 -1
  28. package/dist/cjs/splitview/view.js +0 -1
  29. package/dist/cjs/svg.d.ts +0 -1
  30. package/dist/cjs/svg.js +0 -1
  31. package/dist/cjs/types.d.ts +0 -1
  32. package/dist/cjs/types.js +0 -1
  33. package/dist/dockview.amd.js +1287 -537
  34. package/dist/dockview.amd.js.map +1 -1
  35. package/dist/dockview.amd.min.js +2 -2
  36. package/dist/dockview.amd.min.js.map +1 -1
  37. package/dist/dockview.amd.min.noStyle.js +2 -2
  38. package/dist/dockview.amd.min.noStyle.js.map +1 -1
  39. package/dist/dockview.amd.noStyle.js +1287 -537
  40. package/dist/dockview.amd.noStyle.js.map +1 -1
  41. package/dist/dockview.cjs.js +1287 -537
  42. package/dist/dockview.cjs.js.map +1 -1
  43. package/dist/dockview.esm.js +1284 -537
  44. package/dist/dockview.esm.js.map +1 -1
  45. package/dist/dockview.esm.min.js +2 -2
  46. package/dist/dockview.esm.min.js.map +1 -1
  47. package/dist/dockview.js +1287 -537
  48. package/dist/dockview.js.map +1 -1
  49. package/dist/dockview.min.js +2 -2
  50. package/dist/dockview.min.js.map +1 -1
  51. package/dist/dockview.min.noStyle.js +2 -2
  52. package/dist/dockview.min.noStyle.js.map +1 -1
  53. package/dist/dockview.noStyle.js +1287 -537
  54. package/dist/dockview.noStyle.js.map +1 -1
  55. package/dist/esm/dockview/defaultTab.d.ts +0 -1
  56. package/dist/esm/dockview/defaultTab.js +0 -1
  57. package/dist/esm/dockview/dockview.d.ts +5 -3
  58. package/dist/esm/dockview/dockview.js +31 -1
  59. package/dist/esm/dockview/headerActionsRenderer.d.ts +0 -1
  60. package/dist/esm/dockview/headerActionsRenderer.js +0 -1
  61. package/dist/esm/dockview/reactContentPart.d.ts +0 -1
  62. package/dist/esm/dockview/reactContentPart.js +0 -1
  63. package/dist/esm/dockview/reactHeaderPart.d.ts +0 -1
  64. package/dist/esm/dockview/reactHeaderPart.js +0 -1
  65. package/dist/esm/dockview/reactWatermarkPart.d.ts +0 -1
  66. package/dist/esm/dockview/reactWatermarkPart.js +0 -1
  67. package/dist/esm/gridview/gridview.d.ts +0 -1
  68. package/dist/esm/gridview/gridview.js +0 -1
  69. package/dist/esm/gridview/view.d.ts +0 -1
  70. package/dist/esm/gridview/view.js +3 -2
  71. package/dist/esm/index.d.ts +0 -1
  72. package/dist/esm/index.js +0 -1
  73. package/dist/esm/paneview/paneview.d.ts +0 -1
  74. package/dist/esm/paneview/paneview.js +0 -1
  75. package/dist/esm/paneview/view.d.ts +0 -1
  76. package/dist/esm/paneview/view.js +0 -1
  77. package/dist/esm/react.d.ts +1 -2
  78. package/dist/esm/react.js +11 -8
  79. package/dist/esm/splitview/splitview.d.ts +0 -1
  80. package/dist/esm/splitview/splitview.js +0 -1
  81. package/dist/esm/splitview/view.d.ts +0 -1
  82. package/dist/esm/splitview/view.js +0 -1
  83. package/dist/esm/svg.d.ts +0 -1
  84. package/dist/esm/svg.js +0 -1
  85. package/dist/esm/types.d.ts +0 -1
  86. package/dist/esm/types.js +0 -1
  87. package/package.json +4 -4
  88. package/dist/cjs/dockview/defaultTab.d.ts.map +0 -1
  89. package/dist/cjs/dockview/defaultTab.js.map +0 -1
  90. package/dist/cjs/dockview/dockview.d.ts.map +0 -1
  91. package/dist/cjs/dockview/dockview.js.map +0 -1
  92. package/dist/cjs/dockview/headerActionsRenderer.d.ts.map +0 -1
  93. package/dist/cjs/dockview/headerActionsRenderer.js.map +0 -1
  94. package/dist/cjs/dockview/reactContentPart.d.ts.map +0 -1
  95. package/dist/cjs/dockview/reactContentPart.js.map +0 -1
  96. package/dist/cjs/dockview/reactHeaderPart.d.ts.map +0 -1
  97. package/dist/cjs/dockview/reactHeaderPart.js.map +0 -1
  98. package/dist/cjs/dockview/reactWatermarkPart.d.ts.map +0 -1
  99. package/dist/cjs/dockview/reactWatermarkPart.js.map +0 -1
  100. package/dist/cjs/gridview/gridview.d.ts.map +0 -1
  101. package/dist/cjs/gridview/gridview.js.map +0 -1
  102. package/dist/cjs/gridview/view.d.ts.map +0 -1
  103. package/dist/cjs/gridview/view.js.map +0 -1
  104. package/dist/cjs/index.d.ts.map +0 -1
  105. package/dist/cjs/index.js.map +0 -1
  106. package/dist/cjs/paneview/paneview.d.ts.map +0 -1
  107. package/dist/cjs/paneview/paneview.js.map +0 -1
  108. package/dist/cjs/paneview/view.d.ts.map +0 -1
  109. package/dist/cjs/paneview/view.js.map +0 -1
  110. package/dist/cjs/react.d.ts.map +0 -1
  111. package/dist/cjs/react.js.map +0 -1
  112. package/dist/cjs/splitview/splitview.d.ts.map +0 -1
  113. package/dist/cjs/splitview/splitview.js.map +0 -1
  114. package/dist/cjs/splitview/view.d.ts.map +0 -1
  115. package/dist/cjs/splitview/view.js.map +0 -1
  116. package/dist/cjs/svg.d.ts.map +0 -1
  117. package/dist/cjs/svg.js.map +0 -1
  118. package/dist/cjs/types.d.ts.map +0 -1
  119. package/dist/cjs/types.js.map +0 -1
  120. package/dist/esm/dockview/defaultTab.d.ts.map +0 -1
  121. package/dist/esm/dockview/defaultTab.js.map +0 -1
  122. package/dist/esm/dockview/dockview.d.ts.map +0 -1
  123. package/dist/esm/dockview/dockview.js.map +0 -1
  124. package/dist/esm/dockview/headerActionsRenderer.d.ts.map +0 -1
  125. package/dist/esm/dockview/headerActionsRenderer.js.map +0 -1
  126. package/dist/esm/dockview/reactContentPart.d.ts.map +0 -1
  127. package/dist/esm/dockview/reactContentPart.js.map +0 -1
  128. package/dist/esm/dockview/reactHeaderPart.d.ts.map +0 -1
  129. package/dist/esm/dockview/reactHeaderPart.js.map +0 -1
  130. package/dist/esm/dockview/reactWatermarkPart.d.ts.map +0 -1
  131. package/dist/esm/dockview/reactWatermarkPart.js.map +0 -1
  132. package/dist/esm/gridview/gridview.d.ts.map +0 -1
  133. package/dist/esm/gridview/gridview.js.map +0 -1
  134. package/dist/esm/gridview/view.d.ts.map +0 -1
  135. package/dist/esm/gridview/view.js.map +0 -1
  136. package/dist/esm/index.d.ts.map +0 -1
  137. package/dist/esm/index.js.map +0 -1
  138. package/dist/esm/paneview/paneview.d.ts.map +0 -1
  139. package/dist/esm/paneview/paneview.js.map +0 -1
  140. package/dist/esm/paneview/view.d.ts.map +0 -1
  141. package/dist/esm/paneview/view.js.map +0 -1
  142. package/dist/esm/react.d.ts.map +0 -1
  143. package/dist/esm/react.js.map +0 -1
  144. package/dist/esm/splitview/splitview.d.ts.map +0 -1
  145. package/dist/esm/splitview/splitview.js.map +0 -1
  146. package/dist/esm/splitview/view.d.ts.map +0 -1
  147. package/dist/esm/splitview/view.js.map +0 -1
  148. package/dist/esm/svg.d.ts.map +0 -1
  149. package/dist/esm/svg.js.map +0 -1
  150. package/dist/esm/types.d.ts.map +0 -1
  151. package/dist/esm/types.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * dockview
3
- * @version 1.9.1
3
+ * @version 1.10.0
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -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,12 +3596,13 @@ 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
- if (this.accessor.options.defaultRenderer === 'onlyWhenVisibile') {
3485
- this._element.removeChild(this.panel.view.content.element);
3601
+ if (this.panel.api.renderer === 'onlyWhenVisibile') {
3602
+ (_a = this.panel.view.content.element.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(this.panel.view.content.element);
3486
3603
  }
3487
- this.panel = undefined;
3488
3604
  }
3605
+ this.panel = undefined;
3489
3606
  }
3490
3607
  dispose() {
3491
3608
  this.disposable.dispose();
@@ -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,34 +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
- }
4450
+ this.contentContainer.renderPanel(panel, { asActive: true });
4239
4451
  return;
4240
4452
  }
4241
- this.doAddPanel(panel, options.index, skipSetPanelActive);
4242
- if (!skipSetPanelActive) {
4453
+ if (!skipSetActive) {
4243
4454
  this.doSetActivePanel(panel);
4244
4455
  }
4245
- if (!skipSetGroupActive) {
4246
- 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();
4247
4461
  }
4248
- this.updateContainer();
4249
4462
  }
4250
- removePanel(groupItemOrId) {
4463
+ removePanel(groupItemOrId, options = {
4464
+ skipSetActive: false,
4465
+ }) {
4251
4466
  const id = typeof groupItemOrId === 'string'
4252
4467
  ? groupItemOrId
4253
4468
  : groupItemOrId.id;
@@ -4255,7 +4470,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4255
4470
  if (!panelToRemove) {
4256
4471
  throw new Error('invalid operation');
4257
4472
  }
4258
- return this._removePanel(panelToRemove);
4473
+ return this._removePanel(panelToRemove, options);
4259
4474
  }
4260
4475
  closeAllPanels() {
4261
4476
  if (this.panels.length > 0) {
@@ -4281,12 +4496,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4281
4496
  updateActions(element) {
4282
4497
  this.tabsContainer.setRightActionsElement(element);
4283
4498
  }
4284
- setActive(isGroupActive, skipFocus = false, force = false) {
4285
- var _a, _b, _c, _d;
4499
+ setActive(isGroupActive, force = false) {
4286
4500
  if (!force && this.isActive === isGroupActive) {
4287
- if (!skipFocus) {
4288
- (_b = (_a = this._activePanel) === null || _a === void 0 ? void 0 : _a.focus) === null || _b === void 0 ? void 0 : _b.call(_a);
4289
- }
4290
4501
  return;
4291
4502
  }
4292
4503
  this._isGroupActive = isGroupActive;
@@ -4297,11 +4508,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4297
4508
  this.doSetActivePanel(this.panels[0]);
4298
4509
  }
4299
4510
  this.updateContainer();
4300
- if (isGroupActive) {
4301
- if (!skipFocus) {
4302
- (_d = (_c = this._activePanel) === null || _c === void 0 ? void 0 : _c.focus) === null || _d === void 0 ? void 0 : _d.call(_c);
4303
- }
4304
- }
4305
4511
  }
4306
4512
  layout(width, height) {
4307
4513
  var _a;
@@ -4312,17 +4518,22 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4312
4518
  this._activePanel.layout(this._width, this._height);
4313
4519
  }
4314
4520
  }
4315
- _removePanel(panel) {
4521
+ _removePanel(panel, options) {
4316
4522
  const isActivePanel = this._activePanel === panel;
4317
4523
  this.doRemovePanel(panel);
4318
4524
  if (isActivePanel && this.panels.length > 0) {
4319
4525
  const nextPanel = this.mostRecentlyUsed[0];
4320
- this.openPanel(nextPanel);
4526
+ this.openPanel(nextPanel, {
4527
+ skipSetActive: options.skipSetActive,
4528
+ skipSetGroupActive: options.skipSetActiveGroup,
4529
+ });
4321
4530
  }
4322
4531
  if (this._activePanel && this.panels.length === 0) {
4323
4532
  this.doSetActivePanel(undefined);
4324
4533
  }
4325
- this.updateContainer();
4534
+ if (!options.skipSetActive) {
4535
+ this.updateContainer();
4536
+ }
4326
4537
  return panel;
4327
4538
  }
4328
4539
  doRemovePanel(panel) {
@@ -4337,13 +4548,13 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4337
4548
  }
4338
4549
  this._onDidRemovePanel.fire({ panel });
4339
4550
  }
4340
- doAddPanel(panel, index = this.panels.length, skipSetActive = false) {
4551
+ doAddPanel(panel, index = this.panels.length, options = { skipSetActive: false }) {
4341
4552
  const existingPanel = this._panels.indexOf(panel);
4342
4553
  const hasExistingPanel = existingPanel > -1;
4343
4554
  this.tabsContainer.show();
4344
4555
  this.contentContainer.show();
4345
4556
  this.tabsContainer.openPanel(panel, index);
4346
- if (!skipSetActive) {
4557
+ if (!options.skipSetActive) {
4347
4558
  this.contentContainer.openPanel(panel);
4348
4559
  }
4349
4560
  if (hasExistingPanel) {
@@ -4355,12 +4566,17 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4355
4566
  this._onDidAddPanel.fire({ panel });
4356
4567
  }
4357
4568
  doSetActivePanel(panel) {
4569
+ if (this._activePanel === panel) {
4570
+ return;
4571
+ }
4358
4572
  this._activePanel = panel;
4359
4573
  if (panel) {
4360
4574
  this.tabsContainer.setActivePanel(panel);
4361
4575
  panel.layout(this._width, this._height);
4362
4576
  this.updateMru(panel);
4363
- this._onDidActivePanelChange.fire({ panel });
4577
+ this._onDidActivePanelChange.fire({
4578
+ panel,
4579
+ });
4364
4580
  }
4365
4581
  }
4366
4582
  updateMru(panel) {
@@ -4372,11 +4588,11 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4372
4588
  updateContainer() {
4373
4589
  var _a, _b;
4374
4590
  toggleClass(this.container, 'empty', this.isEmpty);
4375
- this.panels.forEach((panel) => panel.updateParentGroup(this.groupPanel, this.isActive));
4591
+ this.panels.forEach((panel) => panel.runEvents());
4376
4592
  if (this.isEmpty && !this.watermark) {
4377
4593
  const watermark = this.accessor.createWatermarkComponent();
4378
4594
  watermark.init({
4379
- containerApi: new DockviewApi(this.accessor),
4595
+ containerApi: this._api,
4380
4596
  group: this.groupPanel,
4381
4597
  });
4382
4598
  this.watermark = watermark;
@@ -4409,10 +4625,32 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4409
4625
  }
4410
4626
  return false;
4411
4627
  }
4412
- handleDropEvent(event, position, index) {
4628
+ handleDropEvent(type, event, position, index) {
4413
4629
  if (this.locked === 'no-drop-target') {
4414
4630
  return;
4415
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
+ }
4416
4654
  const data = getPanelData();
4417
4655
  if (data && data.viewId === this.accessor.id) {
4418
4656
  if (data.panelId === null) {
@@ -4445,12 +4683,14 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4445
4683
  });
4446
4684
  }
4447
4685
  else {
4448
- this._onDidDrop.fire({
4686
+ this._onDidDrop.fire(new DockviewDidDropEvent({
4449
4687
  nativeEvent: event,
4450
4688
  position,
4451
- index,
4689
+ panel,
4452
4690
  getData: () => getPanelData(),
4453
- });
4691
+ group: this.groupPanel,
4692
+ api: this._api,
4693
+ }));
4454
4694
  }
4455
4695
  }
4456
4696
  dispose() {
@@ -4458,6 +4698,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4458
4698
  super.dispose();
4459
4699
  (_a = this.watermark) === null || _a === void 0 ? void 0 : _a.element.remove();
4460
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;
4461
4702
  for (const panel of this.panels) {
4462
4703
  panel.dispose();
4463
4704
  }
@@ -4479,15 +4720,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4479
4720
  constructor(parentElement, disableResizing = false) {
4480
4721
  super();
4481
4722
  this._disableResizing = disableResizing;
4482
- if (parentElement) {
4483
- this._element = parentElement;
4484
- }
4485
- else {
4486
- this._element = document.createElement('div');
4487
- this._element.style.height = '100%';
4488
- this._element.style.width = '100%';
4489
- this._element.className = 'dv-resizable-container';
4490
- }
4723
+ this._element = parentElement;
4491
4724
  this.addDisposables(watchElementResize(this._element, (entry) => {
4492
4725
  if (this.isDisposed) {
4493
4726
  /**
@@ -4575,25 +4808,38 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4575
4808
  get activeGroup() {
4576
4809
  return this._activeGroup;
4577
4810
  }
4811
+ get locked() {
4812
+ return this.gridview.locked;
4813
+ }
4814
+ set locked(value) {
4815
+ this.gridview.locked = value;
4816
+ }
4578
4817
  constructor(options) {
4579
- super(options.parentElement, options.disableAutoResizing);
4818
+ super(document.createElement('div'), options.disableAutoResizing);
4580
4819
  this._id = nextLayoutId$1.next();
4581
4820
  this._groups = new Map();
4582
4821
  this._onDidLayoutChange = new Emitter();
4583
4822
  this.onDidLayoutChange = this._onDidLayoutChange.event;
4584
- this._onDidRemoveGroup = new Emitter();
4585
- this.onDidRemoveGroup = this._onDidRemoveGroup.event;
4586
- this._onDidAddGroup = new Emitter();
4587
- this.onDidAddGroup = this._onDidAddGroup.event;
4588
- this._onDidActiveGroupChange = new Emitter();
4589
- 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;
4590
4829
  this._bufferOnDidLayoutChange = new TickDelayedEvent();
4830
+ this.element.style.height = '100%';
4831
+ this.element.style.width = '100%';
4832
+ options.parentElement.appendChild(this.element);
4591
4833
  this.gridview = new Gridview(!!options.proportionalLayout, options.styles, options.orientation);
4834
+ this.gridview.locked = !!options.locked;
4592
4835
  this.element.appendChild(this.gridview.element);
4593
4836
  this.layout(0, 0, true); // set some elements height/widths
4594
- 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(() => {
4595
4841
  this._bufferOnDidLayoutChange.fire();
4596
- }), exports.DockviewEvent.any(this.onDidAddGroup, this.onDidRemoveGroup, this.onDidActiveGroupChange)(() => {
4842
+ }), exports.DockviewEvent.any(this.onDidAdd, this.onDidRemove, this.onDidActiveChange)(() => {
4597
4843
  this._bufferOnDidLayoutChange.fire();
4598
4844
  }), this._bufferOnDidLayoutChange.onEvent(() => {
4599
4845
  this._onDidLayoutChange.fire();
@@ -4608,6 +4854,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4608
4854
  }
4609
4855
  maximizeGroup(panel) {
4610
4856
  this.gridview.maximizeView(panel);
4857
+ this.doSetGroupActive(panel);
4611
4858
  }
4612
4859
  isMaximizedGroup(panel) {
4613
4860
  return this.gridview.maximizedView() === panel;
@@ -4618,13 +4865,12 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4618
4865
  hasMaximizedGroup() {
4619
4866
  return this.gridview.hasMaximizedView();
4620
4867
  }
4621
- get onDidMaxmizedGroupChange() {
4622
- return this.gridview.onDidMaxmizedNodeChange;
4868
+ get onDidMaximizedGroupChange() {
4869
+ return this.gridview.onDidMaximizedNodeChange;
4623
4870
  }
4624
4871
  doAddGroup(group, location = [0], size) {
4625
4872
  this.gridview.addView(group, size !== null && size !== void 0 ? size : exports.Sizing.Distribute, location);
4626
- this._onDidAddGroup.fire(group);
4627
- this.doSetGroupActive(group);
4873
+ this._onDidAdd.fire(group);
4628
4874
  }
4629
4875
  doRemoveGroup(group, options) {
4630
4876
  if (!this._groups.has(group.id)) {
@@ -4636,8 +4882,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4636
4882
  item.disposable.dispose();
4637
4883
  item.value.dispose();
4638
4884
  this._groups.delete(group.id);
4885
+ this._onDidRemove.fire(group);
4639
4886
  }
4640
- this._onDidRemoveGroup.fire(group);
4641
4887
  if (!(options === null || options === void 0 ? void 0 : options.skipActive) && this._activeGroup === group) {
4642
4888
  const groups = Array.from(this._groups.values());
4643
4889
  this.doSetGroupActive(groups.length > 0 ? groups[0].value : undefined);
@@ -4648,25 +4894,18 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4648
4894
  var _a;
4649
4895
  return (_a = this._groups.get(id)) === null || _a === void 0 ? void 0 : _a.value;
4650
4896
  }
4651
- doSetGroupActive(group, skipFocus) {
4652
- var _a, _b, _c;
4897
+ doSetGroupActive(group) {
4653
4898
  if (this._activeGroup === group) {
4654
4899
  return;
4655
4900
  }
4656
4901
  if (this._activeGroup) {
4657
4902
  this._activeGroup.setActive(false);
4658
- if (!skipFocus) {
4659
- (_b = (_a = this._activeGroup).focus) === null || _b === void 0 ? void 0 : _b.call(_a);
4660
- }
4661
4903
  }
4662
4904
  if (group) {
4663
4905
  group.setActive(true);
4664
- if (!skipFocus) {
4665
- (_c = group.focus) === null || _c === void 0 ? void 0 : _c.call(group);
4666
- }
4667
4906
  }
4668
4907
  this._activeGroup = group;
4669
- this._onDidActiveGroupChange.fire(group);
4908
+ this._onDidActiveChange.fire(group);
4670
4909
  }
4671
4910
  removeGroup(group) {
4672
4911
  this.doRemoveGroup(group);
@@ -4711,9 +4950,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4711
4950
  this.gridview.layout(width, height);
4712
4951
  }
4713
4952
  dispose() {
4714
- this._onDidActiveGroupChange.dispose();
4715
- this._onDidAddGroup.dispose();
4716
- this._onDidRemoveGroup.dispose();
4953
+ this._onDidActiveChange.dispose();
4954
+ this._onDidAdd.dispose();
4955
+ this._onDidRemove.dispose();
4717
4956
  this._onDidLayoutChange.dispose();
4718
4957
  for (const group of this.groups) {
4719
4958
  group.dispose();
@@ -4723,11 +4962,15 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4723
4962
  }
4724
4963
  }
4725
4964
 
4965
+ class WillFocusEvent extends DockviewEvent {
4966
+ constructor() {
4967
+ super();
4968
+ }
4969
+ }
4726
4970
  /**
4727
4971
  * A core api implementation that should be used across all panel-like objects
4728
4972
  */
4729
4973
  class PanelApiImpl extends CompositeDisposable {
4730
- //
4731
4974
  get isFocused() {
4732
4975
  return this._isFocused;
4733
4976
  }
@@ -4737,6 +4980,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4737
4980
  get isVisible() {
4738
4981
  return this._isVisible;
4739
4982
  }
4983
+ get isHidden() {
4984
+ return this._isHidden;
4985
+ }
4740
4986
  get width() {
4741
4987
  return this._width;
4742
4988
  }
@@ -4749,38 +4995,26 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4749
4995
  this._isFocused = false;
4750
4996
  this._isActive = false;
4751
4997
  this._isVisible = true;
4998
+ this._isHidden = false;
4752
4999
  this._width = 0;
4753
5000
  this._height = 0;
4754
5001
  this.panelUpdatesDisposable = new MutableDisposable();
4755
- this._onDidDimensionChange = new Emitter({
4756
- replay: true,
4757
- });
5002
+ this._onDidDimensionChange = new Emitter();
4758
5003
  this.onDidDimensionsChange = this._onDidDimensionChange.event;
4759
- //
4760
- this._onDidChangeFocus = new Emitter({
4761
- replay: true,
4762
- });
5004
+ this._onDidChangeFocus = new Emitter();
4763
5005
  this.onDidFocusChange = this._onDidChangeFocus.event;
4764
5006
  //
4765
- this._onFocusEvent = new Emitter();
4766
- this.onFocusEvent = this._onFocusEvent.event;
5007
+ this._onWillFocus = new Emitter();
5008
+ this.onWillFocus = this._onWillFocus.event;
4767
5009
  //
4768
- this._onDidVisibilityChange = new Emitter({
4769
- replay: true,
4770
- });
5010
+ this._onDidVisibilityChange = new Emitter();
4771
5011
  this.onDidVisibilityChange = this._onDidVisibilityChange.event;
4772
- //
4773
- this._onVisibilityChange = new Emitter();
4774
- this.onVisibilityChange = this._onVisibilityChange.event;
4775
- //
4776
- this._onDidActiveChange = new Emitter({
4777
- replay: true,
4778
- });
5012
+ this._onDidHiddenChange = new Emitter();
5013
+ this.onDidHiddenChange = this._onDidHiddenChange.event;
5014
+ this._onDidActiveChange = new Emitter();
4779
5015
  this.onDidActiveChange = this._onDidActiveChange.event;
4780
- //
4781
5016
  this._onActiveChange = new Emitter();
4782
5017
  this.onActiveChange = this._onActiveChange.event;
4783
- //
4784
5018
  this._onUpdateParameters = new Emitter();
4785
5019
  this.onUpdateParameters = this._onUpdateParameters.event;
4786
5020
  this.addDisposables(this.onDidFocusChange((event) => {
@@ -4789,10 +5023,12 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4789
5023
  this._isActive = event.isActive;
4790
5024
  }), this.onDidVisibilityChange((event) => {
4791
5025
  this._isVisible = event.isVisible;
5026
+ }), this.onDidHiddenChange((event) => {
5027
+ this._isHidden = event.isHidden;
4792
5028
  }), this.onDidDimensionsChange((event) => {
4793
5029
  this._width = event.width;
4794
5030
  this._height = event.height;
4795
- }), 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);
4796
5032
  }
4797
5033
  initialize(panel) {
4798
5034
  this.panelUpdatesDisposable.value = this._onUpdateParameters.event((parameters) => {
@@ -4801,8 +5037,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4801
5037
  });
4802
5038
  });
4803
5039
  }
4804
- setVisible(isVisible) {
4805
- this._onVisibilityChange.fire({ isVisible });
5040
+ setHidden(isHidden) {
5041
+ this._onDidHiddenChange.fire({ isHidden });
4806
5042
  }
4807
5043
  setActive() {
4808
5044
  this._onActiveChange.fire();
@@ -4810,9 +5046,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4810
5046
  updateParameters(parameters) {
4811
5047
  this._onUpdateParameters.fire(parameters);
4812
5048
  }
4813
- dispose() {
4814
- super.dispose();
4815
- }
4816
5049
  }
4817
5050
 
4818
5051
  class SplitviewPanelApiImpl extends PanelApiImpl {
@@ -4900,7 +5133,12 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
4900
5133
  }), focusTracker);
4901
5134
  }
4902
5135
  focus() {
4903
- 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();
4904
5142
  }
4905
5143
  layout(width, height) {
4906
5144
  this._width = width;
@@ -5229,9 +5467,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5229
5467
  super(id);
5230
5468
  this._onDidConstraintsChangeInternal = new Emitter();
5231
5469
  this.onDidConstraintsChangeInternal = this._onDidConstraintsChangeInternal.event;
5232
- this._onDidConstraintsChange = new Emitter({
5233
- replay: true,
5234
- });
5470
+ this._onDidConstraintsChange = new Emitter();
5235
5471
  this.onDidConstraintsChange = this._onDidConstraintsChange.event;
5236
5472
  this._onDidSizeChange = new Emitter();
5237
5473
  this.onDidSizeChange = this._onDidSizeChange.event;
@@ -5324,13 +5560,13 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5324
5560
  this._maximumHeight = options.maximumHeight;
5325
5561
  }
5326
5562
  this.api.initialize(this); // TODO: required to by-pass 'super before this' requirement
5327
- this.addDisposables(this.api.onVisibilityChange((event) => {
5328
- const { isVisible } = event;
5563
+ this.addDisposables(this.api.onDidHiddenChange((event) => {
5564
+ const { isHidden } = event;
5329
5565
  const { accessor } = this._params;
5330
- accessor.setVisible(this, isVisible);
5566
+ accessor.setVisible(this, !isHidden);
5331
5567
  }), this.api.onActiveChange(() => {
5332
5568
  const { accessor } = this._params;
5333
- accessor.setActive(this);
5569
+ accessor.doSetGroupActive(this);
5334
5570
  }), this.api.onDidConstraintsChangeInternal((event) => {
5335
5571
  if (typeof event.minimumWidth === 'number' ||
5336
5572
  typeof event.minimumWidth === 'function') {
@@ -5413,6 +5649,17 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5413
5649
  this.onDidLocationChange = this._onDidLocationChange.event;
5414
5650
  this.addDisposables(this._onDidLocationChange);
5415
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
+ }
5416
5663
  moveTo(options) {
5417
5664
  var _a, _b, _c;
5418
5665
  if (!this._group) {
@@ -5420,14 +5667,23 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5420
5667
  }
5421
5668
  const group = (_a = options.group) !== null && _a !== void 0 ? _a : this.accessor.addGroup({
5422
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
+ },
5423
5680
  });
5424
- this.accessor.moveGroupOrPanel(group, this._group.id, undefined, options.group ? (_c = options.position) !== null && _c !== void 0 ? _c : 'center' : 'center');
5425
5681
  }
5426
5682
  maximize() {
5427
5683
  if (!this._group) {
5428
5684
  throw new Error(NOT_INITIALIZED_MESSAGE);
5429
5685
  }
5430
- if (this.location !== 'grid') {
5686
+ if (this.location.type !== 'grid') {
5431
5687
  // only grid groups can be maximized
5432
5688
  return;
5433
5689
  }
@@ -5484,6 +5740,12 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5484
5740
  this.api.initialize(this); // cannot use 'this' after after 'super' call
5485
5741
  this._model = new DockviewGroupPanelModel(this.element, accessor, id, options, this);
5486
5742
  }
5743
+ focus() {
5744
+ if (!this.api.isActive) {
5745
+ this.api.setActive();
5746
+ }
5747
+ super.focus();
5748
+ }
5487
5749
  initialize() {
5488
5750
  this._model.initialize();
5489
5751
  }
@@ -5529,6 +5791,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5529
5791
  }
5530
5792
 
5531
5793
  class DockviewPanelApiImpl extends GridviewPanelApiImpl {
5794
+ get location() {
5795
+ return this.group.api.location;
5796
+ }
5532
5797
  get title() {
5533
5798
  return this.panel.title;
5534
5799
  }
@@ -5540,15 +5805,34 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5540
5805
  }
5541
5806
  set group(value) {
5542
5807
  const isOldGroupActive = this.isGroupActive;
5543
- this._group = value;
5544
- this._onDidGroupChange.fire();
5545
- if (this._group) {
5546
- this.disposable.value = this._group.api.onDidActiveChange(() => {
5547
- 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,
5548
5835
  });
5549
- if (this.isGroupActive !== isOldGroupActive) {
5550
- this._onDidActiveGroupChange.fire();
5551
- }
5552
5836
  }
5553
5837
  }
5554
5838
  get group() {
@@ -5566,14 +5850,26 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5566
5850
  this.onDidGroupChange = this._onDidGroupChange.event;
5567
5851
  this._onDidRendererChange = new Emitter();
5568
5852
  this.onDidRendererChange = this._onDidRendererChange.event;
5569
- this.disposable = new MutableDisposable();
5853
+ this._onDidLocationChange = new Emitter();
5854
+ this.onDidLocationChange = this._onDidLocationChange.event;
5855
+ this.groupEventsDisposable = new MutableDisposable();
5570
5856
  this.initialize(panel);
5571
5857
  this._group = group;
5572
- 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();
5573
5862
  }
5574
5863
  moveTo(options) {
5575
5864
  var _a;
5576
- 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
+ });
5577
5873
  }
5578
5874
  setTitle(title) {
5579
5875
  this.panel.setTitle(title);
@@ -5634,7 +5930,14 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5634
5930
  this.setTitle(params.title);
5635
5931
  }
5636
5932
  focus() {
5637
- 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
+ }
5638
5941
  }
5639
5942
  toJSON() {
5640
5943
  return {
@@ -5691,20 +5994,40 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5691
5994
  },
5692
5995
  });
5693
5996
  }
5694
- updateParentGroup(group, isGroupActive) {
5997
+ updateParentGroup(group, options) {
5695
5998
  this._group = group;
5696
- this.api.group = group;
5999
+ this.api.group = this._group;
5697
6000
  const isPanelVisible = this._group.model.isPanelActive(this);
5698
- this.api._onDidActiveChange.fire({
5699
- isActive: isGroupActive && isPanelVisible,
5700
- });
5701
- this.api._onDidVisibilityChange.fire({
5702
- isVisible: isPanelVisible,
5703
- });
5704
- 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
+ }
5705
6028
  }
5706
6029
  layout(width, height) {
5707
- // 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?
5708
6031
  this.api._onDidDimensionChange.fire({
5709
6032
  width,
5710
6033
  height: height,
@@ -5826,8 +6149,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5826
6149
  this.id = id;
5827
6150
  this.contentComponent = contentComponent;
5828
6151
  this.tabComponent = tabComponent;
5829
- this._group = null;
5830
- this._isPanelVisible = null;
5831
6152
  this._content = this.createContentComponent(this.id, contentComponent);
5832
6153
  this._tab = this.createTabComponent(this.id, tabComponent);
5833
6154
  }
@@ -5835,25 +6156,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
5835
6156
  this.content.init(Object.assign(Object.assign({}, params), { tab: this.tab }));
5836
6157
  this.tab.init(params);
5837
6158
  }
5838
- updateParentGroup(group, isPanelVisible) {
5839
- if (group !== this._group) {
5840
- this._group = group;
5841
- if (this._content.onGroupChange) {
5842
- this._content.onGroupChange(group);
5843
- }
5844
- if (this._tab.onGroupChange) {
5845
- this._tab.onGroupChange(group);
5846
- }
5847
- }
5848
- if (isPanelVisible !== this._isPanelVisible) {
5849
- this._isPanelVisible = isPanelVisible;
5850
- if (this._content.onPanelVisibleChange) {
5851
- this._content.onPanelVisibleChange(isPanelVisible);
5852
- }
5853
- if (this._tab.onPanelVisibleChange) {
5854
- this._tab.onPanelVisibleChange(isPanelVisible);
5855
- }
5856
- }
6159
+ updateParentGroup(_group, _isPanelVisible) {
6160
+ // noop
5857
6161
  }
5858
6162
  layout(width, height) {
5859
6163
  var _a, _b;
@@ -6286,117 +6590,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6286
6590
  }
6287
6591
  }
6288
6592
 
6289
- class PopoutWindow extends CompositeDisposable {
6290
- constructor(id, className, options) {
6291
- super();
6292
- this.id = id;
6293
- this.className = className;
6294
- this.options = options;
6295
- this._onDidClose = new Emitter();
6296
- this.onDidClose = this._onDidClose.event;
6297
- this._window = null;
6298
- this.addDisposables(this._onDidClose, {
6299
- dispose: () => {
6300
- this.close();
6301
- },
6302
- });
6303
- }
6304
- dimensions() {
6305
- if (!this._window) {
6306
- return null;
6307
- }
6308
- const left = this._window.value.screenX;
6309
- const top = this._window.value.screenY;
6310
- const width = this._window.value.innerWidth;
6311
- const height = this._window.value.innerHeight;
6312
- return { top, left, width, height };
6313
- }
6314
- close() {
6315
- if (this._window) {
6316
- this._window.disposable.dispose();
6317
- this._window.value.close();
6318
- this._window = null;
6319
- }
6320
- }
6321
- open(content) {
6322
- if (this._window) {
6323
- throw new Error('instance of popout window is already open');
6324
- }
6325
- const url = `${this.options.url}`;
6326
- const features = Object.entries({
6327
- top: this.options.top,
6328
- left: this.options.left,
6329
- width: this.options.width,
6330
- height: this.options.height,
6331
- })
6332
- .map(([key, value]) => `${key}=${value}`)
6333
- .join(',');
6334
- // https://developer.mozilla.org/en-US/docs/Web/API/Window/open
6335
- const externalWindow = window.open(url, this.id, features);
6336
- if (!externalWindow) {
6337
- return;
6338
- }
6339
- const disposable = new CompositeDisposable();
6340
- this._window = { value: externalWindow, disposable };
6341
- const cleanUp = () => {
6342
- this._onDidClose.fire();
6343
- this._window = null;
6344
- };
6345
- // prevent any default content from loading
6346
- // externalWindow.document.body.replaceWith(document.createElement('div'));
6347
- disposable.addDisposables(addDisposableWindowListener(window, 'beforeunload', () => {
6348
- cleanUp();
6349
- this.close();
6350
- }));
6351
- externalWindow.addEventListener('load', () => {
6352
- const externalDocument = externalWindow.document;
6353
- externalDocument.title = document.title;
6354
- const div = document.createElement('div');
6355
- div.classList.add('dv-popout-window');
6356
- div.style.position = 'absolute';
6357
- div.style.width = '100%';
6358
- div.style.height = '100%';
6359
- div.style.top = '0px';
6360
- div.style.left = '0px';
6361
- div.classList.add(this.className);
6362
- div.appendChild(content);
6363
- externalDocument.body.replaceChildren(div);
6364
- externalDocument.body.classList.add(this.className);
6365
- addStyles(externalDocument, window.document.styleSheets);
6366
- externalWindow.addEventListener('beforeunload', () => {
6367
- // TODO: indicate external window is closing
6368
- cleanUp();
6369
- });
6370
- });
6371
- }
6372
- }
6373
-
6374
- class DockviewPopoutGroupPanel extends CompositeDisposable {
6375
- constructor(id, group, options) {
6376
- var _a;
6377
- super();
6378
- this.id = id;
6379
- this.group = group;
6380
- this.options = options;
6381
- this.window = new PopoutWindow(id, (_a = options.className) !== null && _a !== void 0 ? _a : '', {
6382
- url: this.options.popoutUrl,
6383
- left: this.options.box.left,
6384
- top: this.options.box.top,
6385
- width: this.options.box.width,
6386
- height: this.options.box.height,
6387
- });
6388
- group.model.location = 'popout';
6389
- this.addDisposables(this.window, {
6390
- dispose: () => {
6391
- group.model.location = 'grid';
6392
- },
6393
- }, this.window.onDidClose(() => {
6394
- this.dispose();
6395
- }));
6396
- this.window.open(group.element);
6397
- }
6398
- }
6399
-
6400
6593
  const DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE = 100;
6401
6594
  const DEFAULT_FLOATING_GROUP_POSITION = { left: 100, top: 100 };
6402
6595
 
@@ -6410,11 +6603,13 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6410
6603
  super();
6411
6604
  this.element = element;
6412
6605
  this.map = {};
6606
+ this._disposed = false;
6413
6607
  this.addDisposables(Disposable.from(() => {
6414
6608
  for (const value of Object.values(this.map)) {
6415
6609
  value.disposable.dispose();
6416
6610
  value.destroy.dispose();
6417
6611
  }
6612
+ this._disposed = true;
6418
6613
  }));
6419
6614
  }
6420
6615
  detatch(panel) {
@@ -6454,7 +6649,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6454
6649
  focusContainer.style.top = `${box.top - box2.top}px`;
6455
6650
  focusContainer.style.width = `${box.width}px`;
6456
6651
  focusContainer.style.height = `${box.height}px`;
6457
- toggleClass(focusContainer, 'dv-render-overlay-float', panel.group.api.location === 'floating');
6652
+ toggleClass(focusContainer, 'dv-render-overlay-float', panel.group.api.location.type === 'floating');
6458
6653
  };
6459
6654
  const visibilityChanged = () => {
6460
6655
  if (panel.api.isVisible) {
@@ -6500,8 +6695,11 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6500
6695
  resize();
6501
6696
  }));
6502
6697
  this.map[panel.api.id].destroy = Disposable.from(() => {
6503
- focusContainer.removeChild(panel.view.content.element);
6504
- 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);
6505
6703
  });
6506
6704
  queueMicrotask(() => {
6507
6705
  if (this.isDisposed) {
@@ -6522,11 +6720,164 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6522
6720
  }
6523
6721
  }
6524
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
+
6525
6862
  const DEFAULT_ROOT_OVERLAY_MODEL = {
6526
6863
  activationSize: { type: 'pixels', value: 10 },
6527
6864
  size: { type: 'pixels', value: 20 },
6528
6865
  };
6529
- 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) {
6530
6881
  function toClassList(element) {
6531
6882
  const list = [];
6532
6883
  for (let i = 0; i < element.classList.length; i++) {
@@ -6577,6 +6928,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6577
6928
  styles: options.styles,
6578
6929
  parentElement: options.parentElement,
6579
6930
  disableAutoResizing: options.disableAutoResizing,
6931
+ locked: options.locked,
6580
6932
  });
6581
6933
  this.nextGroupId = sequentialNumberGenerator();
6582
6934
  this._deserializer = new DefaultDockviewDeserialzier(this);
@@ -6587,6 +6939,10 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6587
6939
  this.onWillDragGroup = this._onWillDragGroup.event;
6588
6940
  this._onDidDrop = new Emitter();
6589
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;
6590
6946
  this._onDidRemovePanel = new Emitter();
6591
6947
  this.onDidRemovePanel = this._onDidRemovePanel.event;
6592
6948
  this._onDidAddPanel = new Emitter();
@@ -6595,15 +6951,36 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6595
6951
  this.onDidLayoutFromJSON = this._onDidLayoutFromJSON.event;
6596
6952
  this._onDidActivePanelChange = new Emitter();
6597
6953
  this.onDidActivePanelChange = this._onDidActivePanelChange.event;
6954
+ this._onDidMovePanel = new Emitter();
6598
6955
  this._floatingGroups = [];
6599
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;
6600
6965
  const gready = document.createElement('div');
6601
6966
  gready.className = 'dv-overlay-render-container';
6602
6967
  this.gridview.element.appendChild(gready);
6603
6968
  this.overlayRenderContainer = new OverlayRenderContainer(gready);
6604
6969
  toggleClass(this.gridview.element, 'dv-dockview', true);
6605
6970
  toggleClass(this.element, 'dv-debug', !!options.debug);
6606
- 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)(() => {
6607
6984
  this.updateWatermark();
6608
6985
  }), exports.DockviewEvent.any(this.onDidAddPanel, this.onDidRemovePanel, this.onDidActivePanelChange)(() => {
6609
6986
  this._bufferOnDidLayoutChange.fire();
@@ -6614,7 +6991,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6614
6991
  }
6615
6992
  // iterate over a copy of the array since .dispose() mutates the original array
6616
6993
  for (const group of [...this._popoutGroups]) {
6617
- group.dispose();
6994
+ group.disposable.dispose();
6618
6995
  }
6619
6996
  }));
6620
6997
  this._options = options;
@@ -6660,7 +7037,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6660
7037
  return this.options.showDndOverlay({
6661
7038
  nativeEvent: event,
6662
7039
  position: position,
6663
- target: exports.DockviewDropTargets.Edge,
7040
+ target: 'edge',
6664
7041
  getData: getPanelData,
6665
7042
  });
6666
7043
  }
@@ -6671,86 +7048,249 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6671
7048
  });
6672
7049
  this.addDisposables(this._rootDropTarget.onDrop((event) => {
6673
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
+ }
6674
7064
  const data = getPanelData();
6675
7065
  if (data) {
6676
- 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
+ });
6677
7076
  }
6678
7077
  else {
6679
- 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
+ }));
6680
7086
  }
6681
7087
  }), this._rootDropTarget);
6682
7088
  this._api = new DockviewApi(this);
6683
7089
  this.updateWatermark();
6684
7090
  }
6685
- addPopoutGroup(item, options) {
6686
- var _a;
6687
- let group;
6688
- let box = options === null || options === void 0 ? void 0 : options.position;
6689
- if (item instanceof DockviewPanel) {
6690
- group = this.createGroup();
6691
- this.removePanel(item, {
6692
- removeEmptyGroup: true,
6693
- skipDispose: true,
6694
- });
6695
- group.model.openPanel(item);
6696
- if (!box) {
6697
- 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;
6698
7135
  }
6699
- }
6700
- else {
6701
- group = item;
6702
- if (!box) {
6703
- box = group.element.getBoundingClientRect();
7136
+ if (popoutContainer === null) {
7137
+ popoutWindowDisposable.dispose();
7138
+ return;
6704
7139
  }
6705
- const skip = typeof (options === null || options === void 0 ? void 0 : options.skipRemoveGroup) === 'boolean' &&
6706
- options.skipRemoveGroup;
6707
- if (!skip) {
6708
- this.doRemoveGroup(item, { skipDispose: true });
6709
- }
6710
- }
6711
- const theme = getTheme(this.gridview.element);
6712
- const popoutWindow = new DockviewPopoutGroupPanel(`${this.id}-${group.id}`, // globally unique within dockview
6713
- group, {
6714
- className: theme !== null && theme !== void 0 ? theme : '',
6715
- popoutUrl: (_a = options === null || options === void 0 ? void 0 : options.popoutUrl) !== null && _a !== void 0 ? _a : '/popout.html',
6716
- box: {
6717
- left: window.screenX + box.left,
6718
- top: window.screenY + box.top,
6719
- width: box.width,
6720
- height: box.height,
6721
- },
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);
6722
7246
  });
6723
- popoutWindow.addDisposables({
6724
- dispose: () => {
6725
- remove(this._popoutGroups, popoutWindow);
6726
- this.updateWatermark();
6727
- },
6728
- }, popoutWindow.window.onDidClose(() => {
6729
- this.doAddGroup(group, [0]);
6730
- }));
6731
- this._popoutGroups.push(popoutWindow);
6732
- this.updateWatermark();
6733
7247
  }
6734
7248
  addFloatingGroup(item, coord, options) {
6735
- var _a, _b, _c, _d, _e, _f;
7249
+ var _a, _b, _c, _d, _e, _f, _g;
6736
7250
  let group;
6737
7251
  if (item instanceof DockviewPanel) {
6738
7252
  group = this.createGroup();
6739
- this.removePanel(item, {
7253
+ this._onDidAddGroup.fire(group);
7254
+ this.movingLock(() => this.removePanel(item, {
6740
7255
  removeEmptyGroup: true,
6741
7256
  skipDispose: true,
6742
- });
6743
- group.model.openPanel(item);
7257
+ skipSetActiveGroup: true,
7258
+ }));
7259
+ group.model.openPanel(item, { skipSetGroupActive: true });
6744
7260
  }
6745
7261
  else {
6746
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;
6747
7267
  const skip = typeof (options === null || options === void 0 ? void 0 : options.skipRemoveGroup) === 'boolean' &&
6748
7268
  options.skipRemoveGroup;
6749
7269
  if (!skip) {
6750
- 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
+ }
6751
7291
  }
6752
7292
  }
6753
- group.model.location = 'floating';
7293
+ group.model.location = { type: 'floating' };
6754
7294
  const overlayLeft = typeof (coord === null || coord === void 0 ? void 0 : coord.x) === 'number'
6755
7295
  ? Math.max(coord.x, 0)
6756
7296
  : DEFAULT_FLOATING_GROUP_POSITION.left;
@@ -6760,16 +7300,16 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6760
7300
  const overlay = new Overlay({
6761
7301
  container: this.gridview.element,
6762
7302
  content: group.element,
6763
- height: (_a = coord === null || coord === void 0 ? void 0 : coord.height) !== null && _a !== void 0 ? _a : 300,
6764
- 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,
6765
7305
  left: overlayLeft,
6766
7306
  top: overlayTop,
6767
7307
  minimumInViewportWidth: this.options.floatingGroupBounds === 'boundedWithinViewport'
6768
7308
  ? undefined
6769
- : (_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,
6770
7310
  minimumInViewportHeight: this.options.floatingGroupBounds === 'boundedWithinViewport'
6771
7311
  ? undefined
6772
- : (_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,
6773
7313
  });
6774
7314
  const el = group.element.querySelector('.void-container');
6775
7315
  if (!el) {
@@ -6800,12 +7340,15 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6800
7340
  }), {
6801
7341
  dispose: () => {
6802
7342
  disposable.dispose();
6803
- group.model.location = 'grid';
7343
+ group.model.location = { type: 'grid' };
6804
7344
  remove(this._floatingGroups, floatingGroupPanel);
6805
7345
  this.updateWatermark();
6806
7346
  },
6807
7347
  });
6808
7348
  this._floatingGroups.push(floatingGroupPanel);
7349
+ if (!(options === null || options === void 0 ? void 0 : options.skipActiveGroup)) {
7350
+ this.doSetGroupAndPanelActive(group);
7351
+ }
6809
7352
  this.updateWatermark();
6810
7353
  }
6811
7354
  orthogonalize(position) {
@@ -6895,8 +7438,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6895
7438
  return this.panels.find((panel) => panel.id === id);
6896
7439
  }
6897
7440
  setActivePanel(panel) {
6898
- this.doSetGroupActive(panel.group);
6899
7441
  panel.group.model.openPanel(panel);
7442
+ this.doSetGroupAndPanelActive(panel.group);
6900
7443
  }
6901
7444
  moveToNext(options = {}) {
6902
7445
  var _a;
@@ -6957,7 +7500,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6957
7500
  });
6958
7501
  const popoutGroups = this._popoutGroups.map((group) => {
6959
7502
  return {
6960
- data: group.group.toJSON(),
7503
+ data: group.popoutGroup.toJSON(),
7504
+ gridReferenceGroup: group.referenceGroup,
6961
7505
  position: group.window.dimensions(),
6962
7506
  };
6963
7507
  });
@@ -6975,7 +7519,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
6975
7519
  return result;
6976
7520
  }
6977
7521
  fromJSON(data) {
6978
- var _a, _b;
7522
+ var _a, _b, _c;
6979
7523
  this.clear();
6980
7524
  if (typeof data !== 'object' || data === null) {
6981
7525
  throw new Error('serialized layout must be a non-null object');
@@ -7014,7 +7558,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7014
7558
  const isActive = typeof activeView === 'string' &&
7015
7559
  activeView === panel.id;
7016
7560
  group.model.openPanel(panel, {
7017
- skipSetPanelActive: !isActive,
7561
+ skipSetActive: !isActive,
7018
7562
  skipSetGroupActive: true,
7019
7563
  });
7020
7564
  }
@@ -7044,11 +7588,16 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7044
7588
  }
7045
7589
  const serializedPopoutGroups = (_b = data.popoutGroups) !== null && _b !== void 0 ? _b : [];
7046
7590
  for (const serializedPopoutGroup of serializedPopoutGroups) {
7047
- const { data, position } = serializedPopoutGroup;
7591
+ const { data, position, gridReferenceGroup } = serializedPopoutGroup;
7048
7592
  const group = createGroupFromSerializedState(data);
7049
- this.addPopoutGroup(group, {
7593
+ this.addPopoutGroup((_c = (gridReferenceGroup
7594
+ ? this.getPanel(gridReferenceGroup)
7595
+ : undefined)) !== null && _c !== void 0 ? _c : group, {
7050
7596
  skipRemoveGroup: true,
7051
7597
  position: position !== null && position !== void 0 ? position : undefined,
7598
+ overridePopoutGroup: gridReferenceGroup
7599
+ ? group
7600
+ : undefined,
7052
7601
  });
7053
7602
  }
7054
7603
  for (const floatingGroup of this._floatingGroups) {
@@ -7095,12 +7644,13 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7095
7644
  */
7096
7645
  throw err;
7097
7646
  }
7647
+ this.updateWatermark();
7098
7648
  this._onDidLayoutFromJSON.fire();
7099
7649
  }
7100
7650
  clear() {
7101
7651
  const groups = Array.from(this._groups.values()).map((_) => _.value);
7102
7652
  const hasActiveGroup = !!this.activeGroup;
7103
- const hasActivePanel = !!this.activePanel;
7653
+ !!this.activePanel;
7104
7654
  for (const group of groups) {
7105
7655
  // remove the group will automatically remove the panels
7106
7656
  this.removeGroup(group, { skipActive: true });
@@ -7108,9 +7658,6 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7108
7658
  if (hasActiveGroup) {
7109
7659
  this.doSetGroupAndPanelActive(undefined);
7110
7660
  }
7111
- if (hasActivePanel) {
7112
- this._onDidActivePanelChange.fire(undefined);
7113
- }
7114
7661
  this.gridview.clear();
7115
7662
  }
7116
7663
  closeAllGroups() {
@@ -7151,6 +7698,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7151
7698
  const group = this.orthogonalize(directionToPosition(options.position.direction));
7152
7699
  const panel = this.createPanel(options, group);
7153
7700
  group.model.openPanel(panel);
7701
+ this.doSetGroupAndPanelActive(group);
7154
7702
  return panel;
7155
7703
  }
7156
7704
  }
@@ -7162,6 +7710,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7162
7710
  const target = toTarget(((_b = options.position) === null || _b === void 0 ? void 0 : _b.direction) || 'within');
7163
7711
  if (options.floating) {
7164
7712
  const group = this.createGroup();
7713
+ this._onDidAddGroup.fire(group);
7165
7714
  const o = typeof options.floating === 'object' &&
7166
7715
  options.floating !== null
7167
7716
  ? options.floating
@@ -7169,16 +7718,16 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7169
7718
  this.addFloatingGroup(group, o, {
7170
7719
  inDragMode: false,
7171
7720
  skipRemoveGroup: true,
7721
+ skipActiveGroup: true,
7172
7722
  });
7173
- this._onDidAddGroup.fire(group);
7174
7723
  panel = this.createPanel(options, group);
7175
7724
  group.model.openPanel(panel);
7176
- this.doSetGroupAndPanelActive(group);
7177
7725
  }
7178
- else if (referenceGroup.api.location === 'floating' ||
7726
+ else if (referenceGroup.api.location.type === 'floating' ||
7179
7727
  target === 'center') {
7180
7728
  panel = this.createPanel(options, referenceGroup);
7181
7729
  referenceGroup.model.openPanel(panel);
7730
+ this.doSetGroupAndPanelActive(referenceGroup);
7182
7731
  }
7183
7732
  else {
7184
7733
  const location = getGridLocation(referenceGroup.element);
@@ -7186,10 +7735,12 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7186
7735
  const group = this.createGroupAtLocation(relativeLocation);
7187
7736
  panel = this.createPanel(options, group);
7188
7737
  group.model.openPanel(panel);
7738
+ this.doSetGroupAndPanelActive(group);
7189
7739
  }
7190
7740
  }
7191
7741
  else if (options.floating) {
7192
7742
  const group = this.createGroup();
7743
+ this._onDidAddGroup.fire(group);
7193
7744
  const o = typeof options.floating === 'object' &&
7194
7745
  options.floating !== null
7195
7746
  ? options.floating
@@ -7197,16 +7748,16 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7197
7748
  this.addFloatingGroup(group, o, {
7198
7749
  inDragMode: false,
7199
7750
  skipRemoveGroup: true,
7751
+ skipActiveGroup: true,
7200
7752
  });
7201
- this._onDidAddGroup.fire(group);
7202
7753
  panel = this.createPanel(options, group);
7203
7754
  group.model.openPanel(panel);
7204
- this.doSetGroupAndPanelActive(group);
7205
7755
  }
7206
7756
  else {
7207
7757
  const group = this.createGroupAtLocation();
7208
7758
  panel = this.createPanel(options, group);
7209
7759
  group.model.openPanel(panel);
7760
+ this.doSetGroupAndPanelActive(group);
7210
7761
  }
7211
7762
  return panel;
7212
7763
  }
@@ -7218,13 +7769,15 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7218
7769
  if (!group) {
7219
7770
  throw new Error(`cannot remove panel ${panel.id}. it's missing a group.`);
7220
7771
  }
7221
- group.model.removePanel(panel);
7772
+ group.model.removePanel(panel, {
7773
+ skipSetActiveGroup: options.skipSetActiveGroup,
7774
+ });
7222
7775
  if (!options.skipDispose) {
7223
- this.overlayRenderContainer.detatch(panel);
7776
+ panel.group.model.renderContainer.detatch(panel);
7224
7777
  panel.dispose();
7225
7778
  }
7226
7779
  if (group.size === 0 && options.removeEmptyGroup) {
7227
- this.removeGroup(group);
7780
+ this.removeGroup(group, { skipActive: options.skipSetActiveGroup });
7228
7781
  }
7229
7782
  }
7230
7783
  createWatermarkComponent() {
@@ -7237,7 +7790,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7237
7790
  }
7238
7791
  updateWatermark() {
7239
7792
  var _a, _b;
7240
- 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) {
7241
7794
  if (!this.watermark) {
7242
7795
  this.watermark = this.createWatermarkComponent();
7243
7796
  this.watermark.init({
@@ -7257,7 +7810,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7257
7810
  }
7258
7811
  addGroup(options) {
7259
7812
  var _a;
7260
- const group = this.createGroup();
7813
+ const group = this.createGroup(options);
7261
7814
  if (options) {
7262
7815
  let referenceGroup;
7263
7816
  if (isGroupOptionsWithPanel(options)) {
@@ -7283,36 +7836,42 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7283
7836
  }
7284
7837
  else {
7285
7838
  const group = this.orthogonalize(directionToPosition(options.direction));
7839
+ if (!options.skipSetActive) {
7840
+ this.doSetGroupAndPanelActive(group);
7841
+ }
7286
7842
  return group;
7287
7843
  }
7288
7844
  const target = toTarget(options.direction || 'within');
7289
7845
  const location = getGridLocation(referenceGroup.element);
7290
7846
  const relativeLocation = getRelativeLocation(this.gridview.orientation, location, target);
7291
7847
  this.doAddGroup(group, relativeLocation);
7848
+ if (!options.skipSetActive) {
7849
+ this.doSetGroupAndPanelActive(group);
7850
+ }
7292
7851
  return group;
7293
7852
  }
7294
7853
  else {
7295
7854
  this.doAddGroup(group);
7855
+ this.doSetGroupAndPanelActive(group);
7296
7856
  return group;
7297
7857
  }
7298
7858
  }
7299
7859
  removeGroup(group, options) {
7860
+ this.doRemoveGroup(group, options);
7861
+ }
7862
+ doRemoveGroup(group, options) {
7300
7863
  var _a;
7301
7864
  const panels = [...group.panels]; // reassign since group panels will mutate
7302
- for (const panel of panels) {
7303
- this.removePanel(panel, {
7304
- removeEmptyGroup: false,
7305
- skipDispose: (_a = options === null || options === void 0 ? void 0 : options.skipDispose) !== null && _a !== void 0 ? _a : false,
7306
- });
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
+ }
7307
7872
  }
7308
7873
  const activePanel = this.activePanel;
7309
- this.doRemoveGroup(group, options);
7310
- if (this.activePanel !== activePanel) {
7311
- this._onDidActivePanelChange.fire(this.activePanel);
7312
- }
7313
- }
7314
- doRemoveGroup(group, options) {
7315
- if (group.api.location === 'floating') {
7874
+ if (group.api.location.type === 'floating') {
7316
7875
  const floatingGroup = this._floatingGroups.find((_) => _.group === group);
7317
7876
  if (floatingGroup) {
7318
7877
  if (!(options === null || options === void 0 ? void 0 : options.skipDispose)) {
@@ -7324,60 +7883,124 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7324
7883
  floatingGroup.dispose();
7325
7884
  if (!(options === null || options === void 0 ? void 0 : options.skipActive) && this._activeGroup === group) {
7326
7885
  const groups = Array.from(this._groups.values());
7327
- this.doSetGroupActive(groups.length > 0 ? groups[0].value : undefined);
7886
+ this.doSetGroupAndPanelActive(groups.length > 0 ? groups[0].value : undefined);
7328
7887
  }
7329
7888
  return floatingGroup.group;
7330
7889
  }
7331
7890
  throw new Error('failed to find floating group');
7332
7891
  }
7333
- if (group.api.location === 'popout') {
7334
- const selectedGroup = this._popoutGroups.find((_) => _.group === group);
7892
+ if (group.api.location.type === 'popout') {
7893
+ const selectedGroup = this._popoutGroups.find((_) => _.popoutGroup === group);
7335
7894
  if (selectedGroup) {
7336
7895
  if (!(options === null || options === void 0 ? void 0 : options.skipDispose)) {
7337
- 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();
7338
7905
  this._groups.delete(group.id);
7339
7906
  this._onDidRemoveGroup.fire(group);
7340
7907
  }
7341
- 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
+ }
7342
7913
  if (!(options === null || options === void 0 ? void 0 : options.skipActive) && this._activeGroup === group) {
7343
7914
  const groups = Array.from(this._groups.values());
7344
- this.doSetGroupActive(groups.length > 0 ? groups[0].value : undefined);
7915
+ this.doSetGroupAndPanelActive(groups.length > 0 ? groups[0].value : undefined);
7345
7916
  }
7346
- return selectedGroup.group;
7917
+ this.updateWatermark();
7918
+ return selectedGroup.popoutGroup;
7347
7919
  }
7348
7920
  throw new Error('failed to find popout group');
7349
7921
  }
7350
- 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;
7351
7929
  }
7352
- moveGroupOrPanel(destinationGroup, sourceGroupId, sourceItemId, destinationTarget, destinationIndex) {
7353
- 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;
7354
7947
  const sourceGroup = sourceGroupId
7355
7948
  ? (_a = this._groups.get(sourceGroupId)) === null || _a === void 0 ? void 0 : _a.value
7356
7949
  : undefined;
7950
+ if (!sourceGroup) {
7951
+ throw new Error(`Failed to find group id ${sourceGroupId}`);
7952
+ }
7357
7953
  if (sourceItemId === undefined) {
7358
- if (sourceGroup) {
7359
- this.moveGroup(sourceGroup, destinationGroup, destinationTarget);
7360
- }
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
+ });
7361
7964
  return;
7362
7965
  }
7363
7966
  if (!destinationTarget || destinationTarget === 'center') {
7364
- 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);
7365
- 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) {
7366
7975
  throw new Error(`No panel with id ${sourceItemId}`);
7367
7976
  }
7368
- if ((sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.size) === 0) {
7369
- 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 });
7370
7980
  }
7371
- destinationGroup.model.openPanel(groupItem, {
7981
+ this.movingLock(() => destinationGroup.model.openPanel(removedPanel, {
7372
7982
  index: destinationIndex,
7983
+ skipSetGroupActive: true,
7984
+ }));
7985
+ this.doSetGroupAndPanelActive(destinationGroup);
7986
+ this._onDidMovePanel.fire({
7987
+ panel: removedPanel,
7373
7988
  });
7374
7989
  }
7375
7990
  else {
7991
+ /**
7992
+ * Dropping a panel to the extremities of a group which will place that panel
7993
+ * into an adjacent group
7994
+ */
7376
7995
  const referenceLocation = getGridLocation(destinationGroup.element);
7377
7996
  const targetLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, destinationTarget);
7378
- 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
+ */
7379
8002
  const [targetParentLocation, to] = tail(targetLocation);
7380
- if (sourceGroup.api.location === 'grid') {
8003
+ if (sourceGroup.api.location.type === 'grid') {
7381
8004
  const sourceLocation = getGridLocation(sourceGroup.element);
7382
8005
  const [sourceParentLocation, from] = tail(sourceLocation);
7383
8006
  if (sequenceEquals(sourceParentLocation, targetParentLocation)) {
@@ -7385,78 +8008,123 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7385
8008
  // if a group has one tab - we are essentially moving the 'group'
7386
8009
  // which is equivalent to swapping two views in this case
7387
8010
  this.gridview.moveView(sourceParentLocation, from, to);
8011
+ return;
7388
8012
  }
7389
8013
  }
7390
8014
  // source group will become empty so delete the group
7391
- const targetGroup = this.doRemoveGroup(sourceGroup, {
8015
+ const targetGroup = this.movingLock(() => this.doRemoveGroup(sourceGroup, {
7392
8016
  skipActive: true,
7393
8017
  skipDispose: true,
7394
- });
8018
+ }));
7395
8019
  // after deleting the group we need to re-evaulate the ref location
7396
8020
  const updatedReferenceLocation = getGridLocation(destinationGroup.element);
7397
8021
  const location = getRelativeLocation(this.gridview.orientation, updatedReferenceLocation, destinationTarget);
7398
- this.doAddGroup(targetGroup, location);
8022
+ this.movingLock(() => this.doAddGroup(targetGroup, location));
8023
+ this.doSetGroupAndPanelActive(targetGroup);
7399
8024
  }
7400
8025
  else {
7401
- 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);
7402
- 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) {
7403
8035
  throw new Error(`No panel with id ${sourceItemId}`);
7404
8036
  }
7405
8037
  const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, destinationTarget);
7406
8038
  const group = this.createGroupAtLocation(dropLocation);
7407
- group.model.openPanel(groupItem);
8039
+ this.movingLock(() => group.model.openPanel(removedPanel, {
8040
+ skipSetGroupActive: true,
8041
+ }));
8042
+ this.doSetGroupAndPanelActive(group);
7408
8043
  }
7409
8044
  }
7410
8045
  }
7411
- moveGroup(sourceGroup, referenceGroup, target) {
7412
- if (sourceGroup) {
7413
- if (!target || target === 'center') {
7414
- const activePanel = sourceGroup.activePanel;
7415
- const panels = [...sourceGroup.panels].map((p) => sourceGroup.model.removePanel(p.id));
7416
- if ((sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.size) === 0) {
7417
- this.doRemoveGroup(sourceGroup);
7418
- }
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(() => {
7419
8059
  for (const panel of panels) {
7420
- referenceGroup.model.openPanel(panel, {
7421
- skipSetPanelActive: panel !== activePanel,
8060
+ to.model.openPanel(panel, {
8061
+ skipSetActive: panel !== activePanel,
8062
+ skipSetGroupActive: true,
7422
8063
  });
7423
8064
  }
7424
- }
7425
- else {
7426
- switch (sourceGroup.api.location) {
7427
- case 'grid':
7428
- this.gridview.removeView(getGridLocation(sourceGroup.element));
7429
- break;
7430
- case 'floating': {
7431
- const selectedFloatingGroup = this._floatingGroups.find((x) => x.group === sourceGroup);
7432
- if (!selectedFloatingGroup) {
7433
- throw new Error('failed to find floating group');
7434
- }
7435
- selectedFloatingGroup.dispose();
7436
- 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');
7437
8080
  }
7438
- case 'popout': {
7439
- const selectedPopoutGroup = this._popoutGroups.find((x) => x.group === sourceGroup);
7440
- if (!selectedPopoutGroup) {
7441
- throw new Error('failed to find popout group');
7442
- }
7443
- 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');
7444
8088
  }
8089
+ selectedPopoutGroup.disposable.dispose();
7445
8090
  }
7446
- const referenceLocation = getGridLocation(referenceGroup.element);
7447
- const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, target);
7448
- this.gridview.addView(sourceGroup, exports.Sizing.Distribute, dropLocation);
7449
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
+ });
7450
8098
  }
7451
8099
  }
7452
- doSetGroupAndPanelActive(group, skipFocus) {
7453
- 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);
7454
8110
  const activePanel = this.activePanel;
7455
- super.doSetGroupActive(group, skipFocus);
7456
- if (((_a = this._activeGroup) === null || _a === void 0 ? void 0 : _a.activePanel) !== activePanel) {
7457
- 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);
7458
8119
  }
7459
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
+ }
7460
8128
  createGroup(options) {
7461
8129
  if (!options) {
7462
8130
  options = {};
@@ -7473,7 +8141,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7473
8141
  }
7474
8142
  }
7475
8143
  const view = new DockviewGroupPanel(this, id, options);
7476
- view.init({ params: {}, accessor: null }); // required to initialized .part and allow for correct disposal of group
8144
+ view.init({ params: {}, accessor: this });
7477
8145
  if (!this._groups.has(view.id)) {
7478
8146
  const disposable = new CompositeDisposable(view.model.onTabDragStart((event) => {
7479
8147
  this._onWillDragPanel.fire(event);
@@ -7481,20 +8149,48 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7481
8149
  this._onWillDragGroup.fire(event);
7482
8150
  }), view.model.onMove((event) => {
7483
8151
  const { groupId, itemId, target, index } = event;
7484
- 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
+ });
7485
8160
  }), view.model.onDidDrop((event) => {
7486
- 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);
7487
8170
  }), view.model.onDidAddPanel((event) => {
8171
+ if (this._moving) {
8172
+ return;
8173
+ }
7488
8174
  this._onDidAddPanel.fire(event.panel);
7489
8175
  }), view.model.onDidRemovePanel((event) => {
8176
+ if (this._moving) {
8177
+ return;
8178
+ }
7490
8179
  this._onDidRemovePanel.fire(event.panel);
7491
8180
  }), view.model.onDidActivePanelChange((event) => {
7492
- 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
+ }
7493
8190
  }));
7494
8191
  this._groups.set(view.id, { value: view, disposable });
7495
8192
  }
7496
- // TODO: must be called after the above listeners have been setup,
7497
- // not an ideal pattern
8193
+ // TODO: must be called after the above listeners have been setup, not an ideal pattern
7498
8194
  view.initialize();
7499
8195
  return view;
7500
8196
  }
@@ -7547,7 +8243,20 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7547
8243
  });
7548
8244
  this._onDidLayoutfromJSON = new Emitter();
7549
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;
7550
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
+ }));
7551
8260
  if (!this.options.components) {
7552
8261
  this.options.components = {};
7553
8262
  }
@@ -7722,6 +8431,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
7722
8431
  });
7723
8432
  this.registerPanel(view);
7724
8433
  this.doAddGroup(view, relativeLocation, options.size);
8434
+ this.doSetGroupActive(view);
7725
8435
  return view;
7726
8436
  }
7727
8437
  registerPanel(panel) {
@@ -8407,10 +9117,10 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
8407
9117
  this._onDidChange = new Emitter();
8408
9118
  this.onDidChange = this._onDidChange.event;
8409
9119
  this.api.initialize(this);
8410
- this.addDisposables(this._onDidChange, this.api.onVisibilityChange((event) => {
8411
- const { isVisible } = event;
9120
+ this.addDisposables(this._onDidChange, this.api.onDidHiddenChange((event) => {
9121
+ const { isHidden } = event;
8412
9122
  const { accessor } = this._params;
8413
- accessor.setVisible(this, isVisible);
9123
+ accessor.setVisible(this, !isHidden);
8414
9124
  }), this.api.onActiveChange(() => {
8415
9125
  const { accessor } = this._params;
8416
9126
  accessor.setActive(this);
@@ -8532,13 +9242,13 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
8532
9242
  if (this.disposed) {
8533
9243
  throw new Error('invalid operation: resource is already disposed');
8534
9244
  }
8535
- if (typeof this.component !== 'function') {
9245
+ if (!isReactComponent(this.component)) {
8536
9246
  /**
8537
9247
  * we know this isn't a React.FunctionComponent so throw an error here.
8538
- * if we do not intercept this the React library will throw a very obsure error
8539
- * 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.
8540
9250
  */
8541
- 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');
8542
9252
  }
8543
9253
  const bridgeComponent = React__namespace.createElement(React__namespace.forwardRef(ReactComponentBridge), {
8544
9254
  component: this
@@ -8590,9 +9300,13 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
8590
9300
  }, []);
8591
9301
  return [portals, addPortal];
8592
9302
  };
8593
- // it does the job...
8594
- function isReactElement(element) {
8595
- 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 */);
8596
9310
  }
8597
9311
 
8598
9312
  class ReactPanelContentPart {
@@ -8852,6 +9566,8 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
8852
9566
  defaultRenderer: props.defaultRenderer,
8853
9567
  debug: props.debug,
8854
9568
  rootOverlayModel: props.rootOverlayModel,
9569
+ locked: props.locked,
9570
+ disableDnd: props.disableDnd,
8855
9571
  });
8856
9572
  const { clientWidth, clientHeight } = domRef.current;
8857
9573
  dockview.layout(clientWidth, clientHeight);
@@ -8863,6 +9579,20 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
8863
9579
  dockview.dispose();
8864
9580
  };
8865
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]);
8866
9596
  React__namespace.useEffect(() => {
8867
9597
  if (!dockviewRef.current) {
8868
9598
  return () => {
@@ -8878,6 +9608,21 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
8878
9608
  disposable.dispose();
8879
9609
  };
8880
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]);
8881
9626
  React__namespace.useEffect(() => {
8882
9627
  if (!dockviewRef.current) {
8883
9628
  return;
@@ -9120,7 +9865,9 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
9120
9865
  return new ReactPart(this.element, this.reactPortalStore, this.reactComponent, {
9121
9866
  params: (_b = (_a = this._params) === null || _a === void 0 ? void 0 : _a.params) !== null && _b !== void 0 ? _b : {},
9122
9867
  api: this.api,
9123
- containerApi: new GridviewApi(this._params.accessor),
9868
+ // TODO: fix casting hack
9869
+ containerApi: new GridviewApi(this._params
9870
+ .accessor),
9124
9871
  });
9125
9872
  }
9126
9873
  }
@@ -9303,12 +10050,14 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
9303
10050
  exports.DockviewComponent = DockviewComponent;
9304
10051
  exports.DockviewCompositeDisposable = CompositeDisposable;
9305
10052
  exports.DockviewDefaultTab = DockviewDefaultTab;
10053
+ exports.DockviewDidDropEvent = DockviewDidDropEvent;
9306
10054
  exports.DockviewEmitter = Emitter;
9307
10055
  exports.DockviewGroupPanel = DockviewGroupPanel;
9308
10056
  exports.DockviewGroupPanelModel = DockviewGroupPanelModel;
9309
10057
  exports.DockviewMutableDisposable = MutableDisposable;
9310
10058
  exports.DockviewPanel = DockviewPanel;
9311
10059
  exports.DockviewReact = DockviewReact;
10060
+ exports.DockviewWillDropEvent = DockviewWillDropEvent;
9312
10061
  exports.DraggablePaneviewPanel = DraggablePaneviewPanel;
9313
10062
  exports.Gridview = Gridview;
9314
10063
  exports.GridviewApi = GridviewApi;
@@ -9332,6 +10081,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
9332
10081
  exports.SplitviewPanel = SplitviewPanel;
9333
10082
  exports.SplitviewReact = SplitviewReact;
9334
10083
  exports.Tab = Tab;
10084
+ exports.WillShowOverlayLocationEvent = WillShowOverlayLocationEvent;
9335
10085
  exports.createComponent = createComponent;
9336
10086
  exports.directionToPosition = directionToPosition;
9337
10087
  exports.getDirectionOrientation = getDirectionOrientation;
@@ -9346,7 +10096,7 @@ define(['exports', 'react', 'react-dom'], (function (exports, React, ReactDOM) {
9346
10096
  exports.isGroupOptionsWithPanel = isGroupOptionsWithPanel;
9347
10097
  exports.isPanelOptionsWithGroup = isPanelOptionsWithGroup;
9348
10098
  exports.isPanelOptionsWithPanel = isPanelOptionsWithPanel;
9349
- exports.isReactElement = isReactElement;
10099
+ exports.isReactComponent = isReactComponent;
9350
10100
  exports.orthogonal = orthogonal;
9351
10101
  exports.positionToDirection = positionToDirection;
9352
10102
  exports.toTarget = toTarget;