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
  */
@@ -112,6 +112,17 @@
112
112
  };
113
113
  };
114
114
  })(exports.DockviewEvent || (exports.DockviewEvent = {}));
115
+ class DockviewEvent {
116
+ constructor() {
117
+ this._defaultPrevented = false;
118
+ }
119
+ get defaultPrevented() {
120
+ return this._defaultPrevented;
121
+ }
122
+ preventDefault() {
123
+ this._defaultPrevented = true;
124
+ }
125
+ }
115
126
  class LeakageMonitor {
116
127
  constructor() {
117
128
  this.events = new Map();
@@ -155,6 +166,9 @@
155
166
  }
156
167
  Emitter.ENABLE_TRACKING = isEnabled;
157
168
  }
169
+ get value() {
170
+ return this._last;
171
+ }
158
172
  constructor(options) {
159
173
  this.options = options;
160
174
  this._listeners = [];
@@ -277,8 +291,12 @@
277
291
  args.forEach((arg) => this._disposables.push(arg));
278
292
  }
279
293
  dispose() {
280
- this._disposables.forEach((arg) => arg.dispose());
294
+ if (this._isDisposed) {
295
+ return;
296
+ }
281
297
  this._isDisposed = true;
298
+ this._disposables.forEach((arg) => arg.dispose());
299
+ this._disposables = [];
282
300
  }
283
301
  }
284
302
  class MutableDisposable {
@@ -762,6 +780,13 @@
762
780
  this._endSnappingEnabled = endSnappingEnabled;
763
781
  this.updateSashEnablement();
764
782
  }
783
+ get disabled() {
784
+ return this._disabled;
785
+ }
786
+ set disabled(value) {
787
+ this._disabled = value;
788
+ toggleClass(this.element, 'dv-splitview-disabled', value);
789
+ }
765
790
  constructor(container, options) {
766
791
  this.container = container;
767
792
  this.viewItems = [];
@@ -772,6 +797,7 @@
772
797
  this._proportions = undefined;
773
798
  this._startSnappingEnabled = true;
774
799
  this._endSnappingEnabled = true;
800
+ this._disabled = false;
775
801
  this._onDidSashEnd = new Emitter();
776
802
  this.onDidSashEnd = this._onDidSashEnd.event;
777
803
  this._onDidAddView = new Emitter();
@@ -1699,7 +1725,13 @@
1699
1725
  }
1700
1726
  return exports.LayoutPriority.Normal;
1701
1727
  }
1702
- constructor(orientation, proportionalLayout, styles, size, orthogonalSize, childDescriptors) {
1728
+ get disabled() {
1729
+ return this.splitview.disabled;
1730
+ }
1731
+ set disabled(value) {
1732
+ this.splitview.disabled = value;
1733
+ }
1734
+ constructor(orientation, proportionalLayout, styles, size, orthogonalSize, disabled, childDescriptors) {
1703
1735
  super();
1704
1736
  this.orientation = orientation;
1705
1737
  this.proportionalLayout = proportionalLayout;
@@ -1744,6 +1776,7 @@
1744
1776
  styles,
1745
1777
  });
1746
1778
  }
1779
+ this.disabled = disabled;
1747
1780
  this.addDisposables(this._onDidChange, this._onDidVisibilityChange, this.splitview.onDidSashEnd(() => {
1748
1781
  this._onDidChange.fire({});
1749
1782
  }));
@@ -1877,7 +1910,7 @@
1877
1910
  }
1878
1911
  function flipNode(node, size, orthogonalSize) {
1879
1912
  if (node instanceof BranchNode) {
1880
- const result = new BranchNode(orthogonal(node.orientation), node.proportionalLayout, node.styles, size, orthogonalSize);
1913
+ const result = new BranchNode(orthogonal(node.orientation), node.proportionalLayout, node.styles, size, orthogonalSize, node.disabled);
1881
1914
  let totalSize = 0;
1882
1915
  for (let i = node.children.length - 1; i >= 0; i--) {
1883
1916
  const child = node.children[i];
@@ -2013,31 +2046,57 @@
2013
2046
  get maximumHeight() {
2014
2047
  return this.root.maximumHeight;
2015
2048
  }
2049
+ get locked() {
2050
+ return this._locked;
2051
+ }
2052
+ set locked(value) {
2053
+ this._locked = value;
2054
+ const branch = [this.root];
2055
+ /**
2056
+ * simple depth-first-search to cover all nodes
2057
+ *
2058
+ * @see https://en.wikipedia.org/wiki/Depth-first_search
2059
+ */
2060
+ while (branch.length > 0) {
2061
+ const node = branch.pop();
2062
+ if (node instanceof BranchNode) {
2063
+ node.disabled = value;
2064
+ branch.push(...node.children);
2065
+ }
2066
+ }
2067
+ }
2016
2068
  maximizedView() {
2017
2069
  var _a;
2018
- return (_a = this._maximizedNode) === null || _a === void 0 ? void 0 : _a.view;
2070
+ return (_a = this._maximizedNode) === null || _a === void 0 ? void 0 : _a.leaf.view;
2019
2071
  }
2020
2072
  hasMaximizedView() {
2021
2073
  return this._maximizedNode !== undefined;
2022
2074
  }
2023
2075
  maximizeView(view) {
2076
+ var _a;
2024
2077
  const location = getGridLocation(view.element);
2025
2078
  const [_, node] = this.getNode(location);
2026
2079
  if (!(node instanceof LeafNode)) {
2027
2080
  return;
2028
2081
  }
2029
- if (this._maximizedNode === node) {
2082
+ if (((_a = this._maximizedNode) === null || _a === void 0 ? void 0 : _a.leaf) === node) {
2030
2083
  return;
2031
2084
  }
2032
2085
  if (this.hasMaximizedView()) {
2033
2086
  this.exitMaximizedView();
2034
2087
  }
2088
+ const hiddenOnMaximize = [];
2035
2089
  function hideAllViewsBut(parent, exclude) {
2036
2090
  for (let i = 0; i < parent.children.length; i++) {
2037
2091
  const child = parent.children[i];
2038
2092
  if (child instanceof LeafNode) {
2039
2093
  if (child !== exclude) {
2040
- parent.setChildVisible(i, false);
2094
+ if (parent.isChildVisible(i)) {
2095
+ parent.setChildVisible(i, false);
2096
+ }
2097
+ else {
2098
+ hiddenOnMaximize.push(child);
2099
+ }
2041
2100
  }
2042
2101
  }
2043
2102
  else {
@@ -2046,18 +2105,21 @@
2046
2105
  }
2047
2106
  }
2048
2107
  hideAllViewsBut(this.root, node);
2049
- this._maximizedNode = node;
2050
- this._onDidMaxmizedNodeChange.fire();
2108
+ this._maximizedNode = { leaf: node, hiddenOnMaximize };
2109
+ this._onDidMaximizedNodeChange.fire();
2051
2110
  }
2052
2111
  exitMaximizedView() {
2053
2112
  if (!this._maximizedNode) {
2054
2113
  return;
2055
2114
  }
2115
+ const hiddenOnMaximize = this._maximizedNode.hiddenOnMaximize;
2056
2116
  function showViewsInReverseOrder(parent) {
2057
2117
  for (let index = parent.children.length - 1; index >= 0; index--) {
2058
2118
  const child = parent.children[index];
2059
2119
  if (child instanceof LeafNode) {
2060
- parent.setChildVisible(index, true);
2120
+ if (!hiddenOnMaximize.includes(child)) {
2121
+ parent.setChildVisible(index, true);
2122
+ }
2061
2123
  }
2062
2124
  else {
2063
2125
  showViewsInReverseOrder(child);
@@ -2066,13 +2128,13 @@
2066
2128
  }
2067
2129
  showViewsInReverseOrder(this.root);
2068
2130
  this._maximizedNode = undefined;
2069
- this._onDidMaxmizedNodeChange.fire();
2131
+ this._onDidMaximizedNodeChange.fire();
2070
2132
  }
2071
2133
  serialize() {
2072
2134
  if (this.hasMaximizedView()) {
2073
2135
  /**
2074
- * do not persist maximized view state but we must first exit any maximized views
2075
- * before serialization to ensure the correct dimensions are persisted
2136
+ * do not persist maximized view state
2137
+ * firstly exit any maximized views to ensure the correct dimensions are persisted
2076
2138
  */
2077
2139
  this.exitMaximizedView();
2078
2140
  }
@@ -2087,14 +2149,14 @@
2087
2149
  dispose() {
2088
2150
  this.disposable.dispose();
2089
2151
  this._onDidChange.dispose();
2090
- this._onDidMaxmizedNodeChange.dispose();
2152
+ this._onDidMaximizedNodeChange.dispose();
2091
2153
  this.root.dispose();
2092
2154
  this._maximizedNode = undefined;
2093
2155
  this.element.remove();
2094
2156
  }
2095
2157
  clear() {
2096
2158
  const orientation = this.root.orientation;
2097
- this.root = new BranchNode(orientation, this.proportionalLayout, this.styles, this.root.size, this.root.orthogonalSize);
2159
+ this.root = new BranchNode(orientation, this.proportionalLayout, this.styles, this.root.size, this.root.orthogonalSize, this._locked);
2098
2160
  }
2099
2161
  deserialize(json, deserializer) {
2100
2162
  const orientation = json.orientation;
@@ -2115,8 +2177,8 @@
2115
2177
  };
2116
2178
  });
2117
2179
  result = new BranchNode(orientation, this.proportionalLayout, this.styles, node.size, // <- orthogonal size - flips at each depth
2118
- orthogonalSize, // <- size - flips at each depth
2119
- children);
2180
+ orthogonalSize, // <- size - flips at each depth,
2181
+ this._locked, children);
2120
2182
  }
2121
2183
  else {
2122
2184
  result = new LeafNode(deserializer.fromJSON(node), orientation, orthogonalSize, node.size);
@@ -2149,7 +2211,7 @@
2149
2211
  }
2150
2212
  const oldRoot = this.root;
2151
2213
  oldRoot.element.remove();
2152
- this._root = new BranchNode(orthogonal(oldRoot.orientation), this.proportionalLayout, this.styles, this.root.orthogonalSize, this.root.size);
2214
+ this._root = new BranchNode(orthogonal(oldRoot.orientation), this.proportionalLayout, this.styles, this.root.orthogonalSize, this.root.size, this._locked);
2153
2215
  if (oldRoot.children.length === 0) ;
2154
2216
  else if (oldRoot.children.length === 1) {
2155
2217
  // can remove one level of redundant branching if there is only a single child
@@ -2217,15 +2279,16 @@
2217
2279
  constructor(proportionalLayout, styles, orientation) {
2218
2280
  this.proportionalLayout = proportionalLayout;
2219
2281
  this.styles = styles;
2282
+ this._locked = false;
2220
2283
  this._maximizedNode = undefined;
2221
2284
  this.disposable = new MutableDisposable();
2222
2285
  this._onDidChange = new Emitter();
2223
2286
  this.onDidChange = this._onDidChange.event;
2224
- this._onDidMaxmizedNodeChange = new Emitter();
2225
- this.onDidMaxmizedNodeChange = this._onDidMaxmizedNodeChange.event;
2287
+ this._onDidMaximizedNodeChange = new Emitter();
2288
+ this.onDidMaximizedNodeChange = this._onDidMaximizedNodeChange.event;
2226
2289
  this.element = document.createElement('div');
2227
2290
  this.element.className = 'grid-view';
2228
- this.root = new BranchNode(orientation, proportionalLayout, styles, 0, 0);
2291
+ this.root = new BranchNode(orientation, proportionalLayout, styles, 0, 0, this._locked);
2229
2292
  }
2230
2293
  isViewVisible(location) {
2231
2294
  const [rest, index] = tail(location);
@@ -2276,7 +2339,7 @@
2276
2339
  }
2277
2340
  const child = grandParent.removeChild(parentIndex);
2278
2341
  child.dispose();
2279
- const newParent = new BranchNode(parent.orientation, this.proportionalLayout, this.styles, parent.size, parent.orthogonalSize);
2342
+ const newParent = new BranchNode(parent.orientation, this.proportionalLayout, this.styles, parent.size, parent.orthogonalSize, this._locked);
2280
2343
  grandParent.addChild(newParent, parent.size, parentIndex);
2281
2344
  const newSibling = new LeafNode(parent.view, grandParent.orientation, parent.size);
2282
2345
  newParent.addChild(newSibling, newSiblingSize, 0);
@@ -2903,6 +2966,21 @@
2903
2966
  get onDidDrop() {
2904
2967
  return this.component.onDidDrop;
2905
2968
  }
2969
+ /**
2970
+ * Invoked when a Drag'n'Drop event occurs but before dockview handles it giving the user an opportunity to intecept and
2971
+ * prevent the event from occuring using the standard `preventDefault()` syntax.
2972
+ *
2973
+ * Preventing certain events may causes unexpected behaviours, use carefully.
2974
+ */
2975
+ get onWillDrop() {
2976
+ return this.component.onWillDrop;
2977
+ }
2978
+ /**
2979
+ *
2980
+ */
2981
+ get onWillShowOverlay() {
2982
+ return this.component.onWillShowOverlay;
2983
+ }
2906
2984
  /**
2907
2985
  * Invoked before a group is dragged. Exposed for custom Drag'n'Drop functionality.
2908
2986
  */
@@ -3038,17 +3116,17 @@
3038
3116
  hasMaximizedGroup() {
3039
3117
  return this.component.hasMaximizedGroup();
3040
3118
  }
3041
- exitMaxmizedGroup() {
3119
+ exitMaximizedGroup() {
3042
3120
  this.component.exitMaximizedGroup();
3043
3121
  }
3044
- get onDidMaxmizedGroupChange() {
3045
- return this.component.onDidMaxmizedGroupChange;
3122
+ get onDidMaximizedGroupChange() {
3123
+ return this.component.onDidMaximizedGroupChange;
3046
3124
  }
3047
3125
  /**
3048
3126
  * Add a popout group in a new Window
3049
3127
  */
3050
3128
  addPopoutGroup(item, options) {
3051
- this.component.addPopoutGroup(item, options);
3129
+ return this.component.addPopoutGroup(item, options);
3052
3130
  }
3053
3131
  }
3054
3132
 
@@ -3102,6 +3180,18 @@
3102
3180
  }
3103
3181
  }
3104
3182
 
3183
+ class WillShowOverlayEvent extends DockviewEvent {
3184
+ get nativeEvent() {
3185
+ return this.options.nativeEvent;
3186
+ }
3187
+ get position() {
3188
+ return this.options.position;
3189
+ }
3190
+ constructor(options) {
3191
+ super();
3192
+ this.options = options;
3193
+ }
3194
+ }
3105
3195
  function directionToPosition(direction) {
3106
3196
  switch (direction) {
3107
3197
  case 'above':
@@ -3154,6 +3244,8 @@
3154
3244
  this.options = options;
3155
3245
  this._onDrop = new Emitter();
3156
3246
  this.onDrop = this._onDrop.event;
3247
+ this._onWillShowOverlay = new Emitter();
3248
+ this.onWillShowOverlay = this._onWillShowOverlay.event;
3157
3249
  // use a set to take advantage of #<set>.has
3158
3250
  this._acceptedTargetZonesSet = new Set(this.options.acceptedTargetZones);
3159
3251
  this.dnd = new DragAndDropObserver(this.element, {
@@ -3182,6 +3274,19 @@
3182
3274
  this.removeDropTarget();
3183
3275
  return;
3184
3276
  }
3277
+ const willShowOverlayEvent = new WillShowOverlayEvent({
3278
+ nativeEvent: e,
3279
+ position: quadrant,
3280
+ });
3281
+ /**
3282
+ * Provide an opportunity to prevent the overlay appearing and in turn
3283
+ * any dnd behaviours
3284
+ */
3285
+ this._onWillShowOverlay.fire(willShowOverlayEvent);
3286
+ if (willShowOverlayEvent.defaultPrevented) {
3287
+ this.removeDropTarget();
3288
+ return;
3289
+ }
3185
3290
  if (typeof this.options.canDisplayOverlay === 'boolean') {
3186
3291
  if (!this.options.canDisplayOverlay) {
3187
3292
  this.removeDropTarget();
@@ -3224,7 +3329,7 @@
3224
3329
  }
3225
3330
  },
3226
3331
  });
3227
- this.addDisposables(this._onDrop, this.dnd);
3332
+ this.addDisposables(this._onDrop, this._onWillShowOverlay, this.dnd);
3228
3333
  }
3229
3334
  setTargetZones(acceptedTargetZones) {
3230
3335
  this._acceptedTargetZonesSet = new Set(acceptedTargetZones);
@@ -3277,25 +3382,44 @@
3277
3382
  size = clamp(0, sizeOptions.value, height) / height;
3278
3383
  }
3279
3384
  }
3280
- const translate = (1 - size) / 2;
3281
- const scale = size;
3282
- let transform;
3385
+ const box = { top: '0px', left: '0px', width: '100%', height: '100%' };
3386
+ /**
3387
+ * You can also achieve the overlay placement using the transform CSS property
3388
+ * to translate and scale the element however this has the undesired effect of
3389
+ * 'skewing' the element. Comment left here for anybody that ever revisits this.
3390
+ *
3391
+ * @see https://developer.mozilla.org/en-US/docs/Web/CSS/transform
3392
+ *
3393
+ * right
3394
+ * translateX(${100 * (1 - size) / 2}%) scaleX(${scale})
3395
+ *
3396
+ * left
3397
+ * translateX(-${100 * (1 - size) / 2}%) scaleX(${scale})
3398
+ *
3399
+ * top
3400
+ * translateY(-${100 * (1 - size) / 2}%) scaleY(${scale})
3401
+ *
3402
+ * bottom
3403
+ * translateY(${100 * (1 - size) / 2}%) scaleY(${scale})
3404
+ */
3283
3405
  if (rightClass) {
3284
- transform = `translateX(${100 * translate}%) scaleX(${scale})`;
3406
+ box.left = `${100 * (1 - size)}%`;
3407
+ box.width = `${100 * size}%`;
3285
3408
  }
3286
3409
  else if (leftClass) {
3287
- transform = `translateX(-${100 * translate}%) scaleX(${scale})`;
3410
+ box.width = `${100 * size}%`;
3288
3411
  }
3289
3412
  else if (topClass) {
3290
- transform = `translateY(-${100 * translate}%) scaleY(${scale})`;
3413
+ box.height = `${100 * size}%`;
3291
3414
  }
3292
3415
  else if (bottomClass) {
3293
- transform = `translateY(${100 * translate}%) scaleY(${scale})`;
3294
- }
3295
- else {
3296
- transform = '';
3416
+ box.top = `${100 * (1 - size)}%`;
3417
+ box.height = `${100 * size}%`;
3297
3418
  }
3298
- this.overlayElement.style.transform = transform;
3419
+ this.overlayElement.style.top = box.top;
3420
+ this.overlayElement.style.left = box.left;
3421
+ this.overlayElement.style.width = box.width;
3422
+ this.overlayElement.style.height = box.height;
3299
3423
  toggleClass(this.overlayElement, 'dv-drop-target-small-vertical', isSmallY);
3300
3424
  toggleClass(this.overlayElement, 'dv-drop-target-small-horizontal', isSmallX);
3301
3425
  toggleClass(this.overlayElement, 'dv-drop-target-left', isLeft);
@@ -3363,14 +3487,6 @@
3363
3487
  return 'center';
3364
3488
  }
3365
3489
 
3366
- exports.DockviewDropTargets = void 0;
3367
- (function (DockviewDropTargets) {
3368
- DockviewDropTargets[DockviewDropTargets["Tab"] = 0] = "Tab";
3369
- DockviewDropTargets[DockviewDropTargets["Panel"] = 1] = "Panel";
3370
- DockviewDropTargets[DockviewDropTargets["TabContainer"] = 2] = "TabContainer";
3371
- DockviewDropTargets[DockviewDropTargets["Edge"] = 3] = "Edge";
3372
- })(exports.DockviewDropTargets || (exports.DockviewDropTargets = {}));
3373
-
3374
3490
  class ContentContainer extends CompositeDisposable {
3375
3491
  get element() {
3376
3492
  return this._element;
@@ -3398,7 +3514,7 @@
3398
3514
  const data = getPanelData();
3399
3515
  if (!data &&
3400
3516
  event.shiftKey &&
3401
- this.group.location !== 'floating') {
3517
+ this.group.location.type !== 'floating') {
3402
3518
  return false;
3403
3519
  }
3404
3520
  if (data && data.viewId === this.accessor.id) {
@@ -3416,7 +3532,7 @@
3416
3532
  data.groupId === this.group.id;
3417
3533
  return !groupHasOnePanelAndIsActiveDragElement;
3418
3534
  }
3419
- return this.group.canDisplayOverlay(event, position, exports.DockviewDropTargets.Panel);
3535
+ return this.group.canDisplayOverlay(event, position, 'panel');
3420
3536
  },
3421
3537
  });
3422
3538
  this.addDisposables(this.dropTarget);
@@ -3441,7 +3557,7 @@
3441
3557
  let container;
3442
3558
  switch (panel.api.renderer) {
3443
3559
  case 'onlyWhenVisibile':
3444
- this.accessor.overlayRenderContainer.detatch(panel);
3560
+ this.group.renderContainer.detatch(panel);
3445
3561
  if (this.panel) {
3446
3562
  if (doRender) {
3447
3563
  this._element.appendChild(this.panel.view.content.element);
@@ -3453,7 +3569,7 @@
3453
3569
  if (panel.view.content.element.parentElement === this._element) {
3454
3570
  this._element.removeChild(panel.view.content.element);
3455
3571
  }
3456
- container = this.accessor.overlayRenderContainer.attach({
3572
+ container = this.group.renderContainer.attach({
3457
3573
  panel,
3458
3574
  referenceContainer: this,
3459
3575
  });
@@ -3484,12 +3600,13 @@
3484
3600
  // noop
3485
3601
  }
3486
3602
  closePanel() {
3603
+ var _a;
3487
3604
  if (this.panel) {
3488
- if (this.accessor.options.defaultRenderer === 'onlyWhenVisibile') {
3489
- this._element.removeChild(this.panel.view.content.element);
3605
+ if (this.panel.api.renderer === 'onlyWhenVisibile') {
3606
+ (_a = this.panel.view.content.element.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(this.panel.view.content.element);
3490
3607
  }
3491
- this.panel = undefined;
3492
3608
  }
3609
+ this.panel = undefined;
3493
3610
  }
3494
3611
  dispose() {
3495
3612
  this.disposable.dispose();
@@ -3597,7 +3714,7 @@
3597
3714
  this._element.draggable = true;
3598
3715
  toggleClass(this.element, 'inactive-tab', true);
3599
3716
  const dragHandler = new TabDragHandler(this._element, this.accessor, this.group, this.panel);
3600
- this.droptarget = new Droptarget(this._element, {
3717
+ this.dropTarget = new Droptarget(this._element, {
3601
3718
  acceptedTargetZones: ['center'],
3602
3719
  canDisplayOverlay: (event, position) => {
3603
3720
  if (this.group.locked) {
@@ -3612,9 +3729,10 @@
3612
3729
  }
3613
3730
  return this.panel.id !== data.panelId;
3614
3731
  }
3615
- return this.group.model.canDisplayOverlay(event, position, exports.DockviewDropTargets.Tab);
3732
+ return this.group.model.canDisplayOverlay(event, position, 'tab');
3616
3733
  },
3617
3734
  });
3735
+ this.onWillShowOverlay = this.dropTarget.onWillShowOverlay;
3618
3736
  this.addDisposables(this._onChanged, this._onDropped, this._onDragStart, dragHandler.onDragStart((event) => {
3619
3737
  this._onDragStart.fire(event);
3620
3738
  }), dragHandler, addDisposableListener(this._element, 'mousedown', (event) => {
@@ -3622,9 +3740,9 @@
3622
3740
  return;
3623
3741
  }
3624
3742
  this._onChanged.fire(event);
3625
- }), this.droptarget.onDrop((event) => {
3743
+ }), this.dropTarget.onDrop((event) => {
3626
3744
  this._onDropped.fire(event);
3627
- }), this.droptarget);
3745
+ }), this.dropTarget);
3628
3746
  }
3629
3747
  setActive(isActive) {
3630
3748
  toggleClass(this.element, 'active-tab', isActive);
@@ -3671,7 +3789,7 @@
3671
3789
  }, true));
3672
3790
  }
3673
3791
  isCancelled(_event) {
3674
- if (this.group.api.location === 'floating' && !_event.shiftKey) {
3792
+ if (this.group.api.location.type === 'floating' && !_event.shiftKey) {
3675
3793
  return true;
3676
3794
  }
3677
3795
  return false;
@@ -3723,7 +3841,7 @@
3723
3841
  this.accessor.doSetGroupActive(this.group);
3724
3842
  }));
3725
3843
  const handler = new GroupDragHandler(this._element, accessor, group);
3726
- this.voidDropTarget = new Droptarget(this._element, {
3844
+ this.dropTraget = new Droptarget(this._element, {
3727
3845
  acceptedTargetZones: ['center'],
3728
3846
  canDisplayOverlay: (event, position) => {
3729
3847
  var _a;
@@ -3737,14 +3855,15 @@
3737
3855
  // don't show the overlay if the tab being dragged is the last panel of this group
3738
3856
  return ((_a = last(this.group.panels)) === null || _a === void 0 ? void 0 : _a.id) !== data.panelId;
3739
3857
  }
3740
- return group.model.canDisplayOverlay(event, position, exports.DockviewDropTargets.Panel);
3858
+ return group.model.canDisplayOverlay(event, position, 'panel');
3741
3859
  },
3742
3860
  });
3861
+ this.onWillShowOverlay = this.dropTraget.onWillShowOverlay;
3743
3862
  this.addDisposables(handler, handler.onDragStart((event) => {
3744
3863
  this._onDragStart.fire(event);
3745
- }), this.voidDropTarget.onDrop((event) => {
3864
+ }), this.dropTraget.onDrop((event) => {
3746
3865
  this._onDrop.fire(event);
3747
- }), this.voidDropTarget);
3866
+ }), this.dropTraget);
3748
3867
  }
3749
3868
  }
3750
3869
 
@@ -3832,19 +3951,11 @@
3832
3951
  this.onTabDragStart = this._onTabDragStart.event;
3833
3952
  this._onGroupDragStart = new Emitter();
3834
3953
  this.onGroupDragStart = this._onGroupDragStart.event;
3835
- this.addDisposables(this._onDrop, this._onTabDragStart, this._onGroupDragStart);
3954
+ this._onWillShowOverlay = new Emitter();
3955
+ this.onWillShowOverlay = this._onWillShowOverlay.event;
3836
3956
  this._element = document.createElement('div');
3837
3957
  this._element.className = 'tabs-and-actions-container';
3838
3958
  toggleClass(this._element, 'dv-full-width-single-tab', this.accessor.options.singleTabMode === 'fullwidth');
3839
- this.addDisposables(this.accessor.onDidAddPanel((e) => {
3840
- if (e.api.group === this.group) {
3841
- toggleClass(this._element, 'dv-single-tab', this.size === 1);
3842
- }
3843
- }), this.accessor.onDidRemovePanel((e) => {
3844
- if (e.api.group === this.group) {
3845
- toggleClass(this._element, 'dv-single-tab', this.size === 1);
3846
- }
3847
- }));
3848
3959
  this.rightActionsContainer = document.createElement('div');
3849
3960
  this.rightActionsContainer.className = 'right-actions-container';
3850
3961
  this.leftActionsContainer = document.createElement('div');
@@ -3859,7 +3970,15 @@
3859
3970
  this._element.appendChild(this.leftActionsContainer);
3860
3971
  this._element.appendChild(this.voidContainer.element);
3861
3972
  this._element.appendChild(this.rightActionsContainer);
3862
- this.addDisposables(this.voidContainer, this.voidContainer.onDragStart((event) => {
3973
+ this.addDisposables(this.accessor.onDidAddPanel((e) => {
3974
+ if (e.api.group === this.group) {
3975
+ toggleClass(this._element, 'dv-single-tab', this.size === 1);
3976
+ }
3977
+ }), this.accessor.onDidRemovePanel((e) => {
3978
+ if (e.api.group === this.group) {
3979
+ toggleClass(this._element, 'dv-single-tab', this.size === 1);
3980
+ }
3981
+ }), this._onWillShowOverlay, this._onDrop, this._onTabDragStart, this._onGroupDragStart, this.voidContainer, this.voidContainer.onDragStart((event) => {
3863
3982
  this._onGroupDragStart.fire({
3864
3983
  nativeEvent: event,
3865
3984
  group: this.group,
@@ -3869,11 +3988,15 @@
3869
3988
  event: event.nativeEvent,
3870
3989
  index: this.tabs.length,
3871
3990
  });
3991
+ }), this.voidContainer.onWillShowOverlay((event) => {
3992
+ this._onWillShowOverlay.fire(new WillShowOverlayLocationEvent(event, {
3993
+ kind: 'header_space',
3994
+ }));
3872
3995
  }), addDisposableListener(this.voidContainer.element, 'mousedown', (event) => {
3873
3996
  const isFloatingGroupsEnabled = !this.accessor.options.disableFloatingGroups;
3874
3997
  if (isFloatingGroupsEnabled &&
3875
3998
  event.shiftKey &&
3876
- this.group.api.location !== 'floating') {
3999
+ this.group.api.location.type !== 'floating') {
3877
4000
  event.preventDefault();
3878
4001
  const { top, left } = this.element.getBoundingClientRect();
3879
4002
  const { top: rootTop, left: rootLeft } = this.accessor.element.getBoundingClientRect();
@@ -3936,9 +4059,9 @@
3936
4059
  const disposable = new CompositeDisposable(tab.onDragStart((event) => {
3937
4060
  this._onTabDragStart.fire({ nativeEvent: event, panel });
3938
4061
  }), tab.onChanged((event) => {
3939
- var _a;
3940
4062
  const isFloatingGroupsEnabled = !this.accessor.options.disableFloatingGroups;
3941
- const isFloatingWithOnePanel = this.group.api.location === 'floating' && this.size === 1;
4063
+ const isFloatingWithOnePanel = this.group.api.location.type === 'floating' &&
4064
+ this.size === 1;
3942
4065
  if (isFloatingGroupsEnabled &&
3943
4066
  !isFloatingWithOnePanel &&
3944
4067
  event.shiftKey) {
@@ -3952,20 +4075,20 @@
3952
4075
  }, { inDragMode: true });
3953
4076
  return;
3954
4077
  }
3955
- const alreadyFocused = panel.id === ((_a = this.group.model.activePanel) === null || _a === void 0 ? void 0 : _a.id) &&
3956
- this.group.model.isContentFocused;
3957
4078
  const isLeftClick = event.button === 0;
3958
4079
  if (!isLeftClick || event.defaultPrevented) {
3959
4080
  return;
3960
4081
  }
3961
- this.group.model.openPanel(panel, {
3962
- skipFocus: alreadyFocused,
3963
- });
4082
+ if (this.group.activePanel !== panel) {
4083
+ this.group.model.openPanel(panel);
4084
+ }
3964
4085
  }), tab.onDrop((event) => {
3965
4086
  this._onDrop.fire({
3966
4087
  event: event.nativeEvent,
3967
4088
  index: this.tabs.findIndex((x) => x.value === tab),
3968
4089
  });
4090
+ }), tab.onWillShowOverlay((event) => {
4091
+ this._onWillShowOverlay.fire(new WillShowOverlayLocationEvent(event, { kind: 'tab' }));
3969
4092
  }));
3970
4093
  const value = { value: tab, disposable };
3971
4094
  this.addTab(value, index);
@@ -3983,6 +4106,60 @@
3983
4106
  }
3984
4107
  }
3985
4108
 
4109
+ class DockviewDidDropEvent extends DockviewEvent {
4110
+ get nativeEvent() {
4111
+ return this.options.nativeEvent;
4112
+ }
4113
+ get position() {
4114
+ return this.options.position;
4115
+ }
4116
+ get panel() {
4117
+ return this.options.panel;
4118
+ }
4119
+ get group() {
4120
+ return this.options.group;
4121
+ }
4122
+ get api() {
4123
+ return this.options.api;
4124
+ }
4125
+ constructor(options) {
4126
+ super();
4127
+ this.options = options;
4128
+ }
4129
+ getData() {
4130
+ return this.options.getData();
4131
+ }
4132
+ }
4133
+ class DockviewWillDropEvent extends DockviewDidDropEvent {
4134
+ get kind() {
4135
+ return this._kind;
4136
+ }
4137
+ constructor(options) {
4138
+ super(options);
4139
+ this._kind = options.kind;
4140
+ }
4141
+ }
4142
+ class WillShowOverlayLocationEvent {
4143
+ get kind() {
4144
+ return this._kind;
4145
+ }
4146
+ get nativeEvent() {
4147
+ return this.event.nativeEvent;
4148
+ }
4149
+ get position() {
4150
+ return this.event.position;
4151
+ }
4152
+ get defaultPrevented() {
4153
+ return this.event.defaultPrevented;
4154
+ }
4155
+ preventDefault() {
4156
+ this.event.preventDefault();
4157
+ }
4158
+ constructor(event, options) {
4159
+ this.event = event;
4160
+ this._kind = options.kind;
4161
+ }
4162
+ }
3986
4163
  class DockviewGroupPanelModel extends CompositeDisposable {
3987
4164
  get element() {
3988
4165
  throw new Error('not supported');
@@ -4028,7 +4205,7 @@
4028
4205
  this._location = value;
4029
4206
  toggleClass(this.container, 'dv-groupview-floating', false);
4030
4207
  toggleClass(this.container, 'dv-groupview-popout', false);
4031
- switch (value) {
4208
+ switch (value.type) {
4032
4209
  case 'grid':
4033
4210
  this.contentContainer.dropTarget.setTargetZones([
4034
4211
  'top',
@@ -4064,7 +4241,7 @@
4064
4241
  this.groupPanel = groupPanel;
4065
4242
  this._isGroupActive = false;
4066
4243
  this._locked = false;
4067
- this._location = 'grid';
4244
+ this._location = { type: 'grid' };
4068
4245
  this.mostRecentlyUsed = [];
4069
4246
  this._onDidChange = new Emitter();
4070
4247
  this.onDidChange = this._onDidChange.event;
@@ -4075,6 +4252,10 @@
4075
4252
  this.onMove = this._onMove.event;
4076
4253
  this._onDidDrop = new Emitter();
4077
4254
  this.onDidDrop = this._onDidDrop.event;
4255
+ this._onWillDrop = new Emitter();
4256
+ this.onWillDrop = this._onWillDrop.event;
4257
+ this._onWillShowOverlay = new Emitter();
4258
+ this.onWillShowOverlay = this._onWillShowOverlay.event;
4078
4259
  this._onTabDragStart = new Emitter();
4079
4260
  this.onTabDragStart = this._onTabDragStart.event;
4080
4261
  this._onGroupDragStart = new Emitter();
@@ -4085,46 +4266,69 @@
4085
4266
  this.onDidRemovePanel = this._onDidRemovePanel.event;
4086
4267
  this._onDidActivePanelChange = new Emitter();
4087
4268
  this.onDidActivePanelChange = this._onDidActivePanelChange.event;
4269
+ this._overwriteRenderContainer = null;
4088
4270
  toggleClass(this.container, 'groupview', true);
4271
+ this._api = new DockviewApi(this.accessor);
4089
4272
  this.tabsContainer = new TabsContainer(this.accessor, this.groupPanel);
4090
4273
  this.contentContainer = new ContentContainer(this.accessor, this);
4091
4274
  container.append(this.tabsContainer.element, this.contentContainer.element);
4092
4275
  this.header.hidden = !!options.hideHeader;
4093
4276
  this.locked = (_a = options.locked) !== null && _a !== void 0 ? _a : false;
4094
- this.addDisposables(this._onTabDragStart, this._onGroupDragStart, this.tabsContainer.onTabDragStart((event) => {
4277
+ this.addDisposables(this._onTabDragStart, this._onGroupDragStart, this._onWillShowOverlay, this.tabsContainer.onTabDragStart((event) => {
4095
4278
  this._onTabDragStart.fire(event);
4096
4279
  }), this.tabsContainer.onGroupDragStart((event) => {
4097
4280
  this._onGroupDragStart.fire(event);
4098
4281
  }), this.tabsContainer.onDrop((event) => {
4099
- this.handleDropEvent(event.event, 'center', event.index);
4282
+ this.handleDropEvent('header', event.event, 'center', event.index);
4100
4283
  }), this.contentContainer.onDidFocus(() => {
4101
- this.accessor.doSetGroupActive(this.groupPanel, true);
4284
+ this.accessor.doSetGroupActive(this.groupPanel);
4102
4285
  }), this.contentContainer.onDidBlur(() => {
4103
4286
  // noop
4104
4287
  }), this.contentContainer.dropTarget.onDrop((event) => {
4105
- this.handleDropEvent(event.nativeEvent, event.position);
4106
- }), this._onMove, this._onDidChange, this._onDidDrop, this._onDidAddPanel, this._onDidRemovePanel, this._onDidActivePanelChange);
4288
+ this.handleDropEvent('content', event.nativeEvent, event.position);
4289
+ }), this.tabsContainer.onWillShowOverlay((event) => {
4290
+ this._onWillShowOverlay.fire(event);
4291
+ }), this.contentContainer.dropTarget.onWillShowOverlay((event) => {
4292
+ this._onWillShowOverlay.fire(new WillShowOverlayLocationEvent(event, {
4293
+ kind: 'content',
4294
+ }));
4295
+ }), this._onMove, this._onDidChange, this._onDidDrop, this._onWillDrop, this._onDidAddPanel, this._onDidRemovePanel, this._onDidActivePanelChange);
4296
+ }
4297
+ focusContent() {
4298
+ this.contentContainer.element.focus();
4299
+ }
4300
+ set renderContainer(value) {
4301
+ this.panels.forEach((panel) => {
4302
+ this.renderContainer.detatch(panel);
4303
+ });
4304
+ this._overwriteRenderContainer = value;
4305
+ this.panels.forEach((panel) => {
4306
+ this.rerender(panel);
4307
+ });
4308
+ }
4309
+ get renderContainer() {
4310
+ var _a;
4311
+ return ((_a = this._overwriteRenderContainer) !== null && _a !== void 0 ? _a : this.accessor.overlayRenderContainer);
4107
4312
  }
4108
4313
  initialize() {
4109
- var _a, _b;
4110
- if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.panels) {
4314
+ if (this.options.panels) {
4111
4315
  this.options.panels.forEach((panel) => {
4112
4316
  this.doAddPanel(panel);
4113
4317
  });
4114
4318
  }
4115
- if ((_b = this.options) === null || _b === void 0 ? void 0 : _b.activePanel) {
4319
+ if (this.options.activePanel) {
4116
4320
  this.openPanel(this.options.activePanel);
4117
4321
  }
4118
4322
  // must be run after the constructor otherwise this.parent may not be
4119
4323
  // correctly initialized
4120
- this.setActive(this.isActive, true, true);
4324
+ this.setActive(this.isActive, true);
4121
4325
  this.updateContainer();
4122
4326
  if (this.accessor.options.createRightHeaderActionsElement) {
4123
4327
  this._rightHeaderActions =
4124
4328
  this.accessor.options.createRightHeaderActionsElement(this.groupPanel);
4125
4329
  this.addDisposables(this._rightHeaderActions);
4126
4330
  this._rightHeaderActions.init({
4127
- containerApi: new DockviewApi(this.accessor),
4331
+ containerApi: this._api,
4128
4332
  api: this.groupPanel.api,
4129
4333
  });
4130
4334
  this.tabsContainer.setRightActionsElement(this._rightHeaderActions.element);
@@ -4134,7 +4338,7 @@
4134
4338
  this.accessor.options.createLeftHeaderActionsElement(this.groupPanel);
4135
4339
  this.addDisposables(this._leftHeaderActions);
4136
4340
  this._leftHeaderActions.init({
4137
- containerApi: new DockviewApi(this.accessor),
4341
+ containerApi: this._api,
4138
4342
  api: this.groupPanel.api,
4139
4343
  });
4140
4344
  this.tabsContainer.setLeftActionsElement(this._leftHeaderActions.element);
@@ -4144,7 +4348,7 @@
4144
4348
  this.accessor.options.createPrefixHeaderActionsElement(this.groupPanel);
4145
4349
  this.addDisposables(this._prefixHeaderActions);
4146
4350
  this._prefixHeaderActions.init({
4147
- containerApi: new DockviewApi(this.accessor),
4351
+ containerApi: this._api,
4148
4352
  api: this.groupPanel.api,
4149
4353
  });
4150
4354
  this.tabsContainer.setPrefixActionsElement(this._prefixHeaderActions.element);
@@ -4224,34 +4428,45 @@
4224
4428
  //noop
4225
4429
  }
4226
4430
  focus() {
4227
- var _a, _b;
4228
- (_b = (_a = this._activePanel) === null || _a === void 0 ? void 0 : _a.focus) === null || _b === void 0 ? void 0 : _b.call(_a);
4431
+ var _a;
4432
+ (_a = this._activePanel) === null || _a === void 0 ? void 0 : _a.focus();
4229
4433
  }
4230
4434
  openPanel(panel, options = {}) {
4435
+ /**
4436
+ * set the panel group
4437
+ * add the panel
4438
+ * check if group active
4439
+ * check if panel active
4440
+ */
4231
4441
  if (typeof options.index !== 'number' ||
4232
4442
  options.index > this.panels.length) {
4233
4443
  options.index = this.panels.length;
4234
4444
  }
4235
- const skipSetPanelActive = !!options.skipSetPanelActive;
4236
- const skipSetGroupActive = !!options.skipSetGroupActive;
4445
+ const skipSetActive = !!options.skipSetActive;
4237
4446
  // ensure the group is updated before we fire any events
4238
- panel.updateParentGroup(this.groupPanel, true);
4447
+ panel.updateParentGroup(this.groupPanel, {
4448
+ skipSetActive: options.skipSetActive,
4449
+ });
4450
+ this.doAddPanel(panel, options.index, {
4451
+ skipSetActive: skipSetActive,
4452
+ });
4239
4453
  if (this._activePanel === panel) {
4240
- if (!skipSetGroupActive) {
4241
- this.accessor.doSetGroupActive(this.groupPanel);
4242
- }
4454
+ this.contentContainer.renderPanel(panel, { asActive: true });
4243
4455
  return;
4244
4456
  }
4245
- this.doAddPanel(panel, options.index, skipSetPanelActive);
4246
- if (!skipSetPanelActive) {
4457
+ if (!skipSetActive) {
4247
4458
  this.doSetActivePanel(panel);
4248
4459
  }
4249
- if (!skipSetGroupActive) {
4250
- this.accessor.doSetGroupActive(this.groupPanel, !!options.skipFocus);
4460
+ if (!options.skipSetGroupActive) {
4461
+ this.accessor.doSetGroupActive(this.groupPanel);
4462
+ }
4463
+ if (!options.skipSetActive) {
4464
+ this.updateContainer();
4251
4465
  }
4252
- this.updateContainer();
4253
4466
  }
4254
- removePanel(groupItemOrId) {
4467
+ removePanel(groupItemOrId, options = {
4468
+ skipSetActive: false,
4469
+ }) {
4255
4470
  const id = typeof groupItemOrId === 'string'
4256
4471
  ? groupItemOrId
4257
4472
  : groupItemOrId.id;
@@ -4259,7 +4474,7 @@
4259
4474
  if (!panelToRemove) {
4260
4475
  throw new Error('invalid operation');
4261
4476
  }
4262
- return this._removePanel(panelToRemove);
4477
+ return this._removePanel(panelToRemove, options);
4263
4478
  }
4264
4479
  closeAllPanels() {
4265
4480
  if (this.panels.length > 0) {
@@ -4285,12 +4500,8 @@
4285
4500
  updateActions(element) {
4286
4501
  this.tabsContainer.setRightActionsElement(element);
4287
4502
  }
4288
- setActive(isGroupActive, skipFocus = false, force = false) {
4289
- var _a, _b, _c, _d;
4503
+ setActive(isGroupActive, force = false) {
4290
4504
  if (!force && this.isActive === isGroupActive) {
4291
- if (!skipFocus) {
4292
- (_b = (_a = this._activePanel) === null || _a === void 0 ? void 0 : _a.focus) === null || _b === void 0 ? void 0 : _b.call(_a);
4293
- }
4294
4505
  return;
4295
4506
  }
4296
4507
  this._isGroupActive = isGroupActive;
@@ -4301,11 +4512,6 @@
4301
4512
  this.doSetActivePanel(this.panels[0]);
4302
4513
  }
4303
4514
  this.updateContainer();
4304
- if (isGroupActive) {
4305
- if (!skipFocus) {
4306
- (_d = (_c = this._activePanel) === null || _c === void 0 ? void 0 : _c.focus) === null || _d === void 0 ? void 0 : _d.call(_c);
4307
- }
4308
- }
4309
4515
  }
4310
4516
  layout(width, height) {
4311
4517
  var _a;
@@ -4316,17 +4522,22 @@
4316
4522
  this._activePanel.layout(this._width, this._height);
4317
4523
  }
4318
4524
  }
4319
- _removePanel(panel) {
4525
+ _removePanel(panel, options) {
4320
4526
  const isActivePanel = this._activePanel === panel;
4321
4527
  this.doRemovePanel(panel);
4322
4528
  if (isActivePanel && this.panels.length > 0) {
4323
4529
  const nextPanel = this.mostRecentlyUsed[0];
4324
- this.openPanel(nextPanel);
4530
+ this.openPanel(nextPanel, {
4531
+ skipSetActive: options.skipSetActive,
4532
+ skipSetGroupActive: options.skipSetActiveGroup,
4533
+ });
4325
4534
  }
4326
4535
  if (this._activePanel && this.panels.length === 0) {
4327
4536
  this.doSetActivePanel(undefined);
4328
4537
  }
4329
- this.updateContainer();
4538
+ if (!options.skipSetActive) {
4539
+ this.updateContainer();
4540
+ }
4330
4541
  return panel;
4331
4542
  }
4332
4543
  doRemovePanel(panel) {
@@ -4341,13 +4552,13 @@
4341
4552
  }
4342
4553
  this._onDidRemovePanel.fire({ panel });
4343
4554
  }
4344
- doAddPanel(panel, index = this.panels.length, skipSetActive = false) {
4555
+ doAddPanel(panel, index = this.panels.length, options = { skipSetActive: false }) {
4345
4556
  const existingPanel = this._panels.indexOf(panel);
4346
4557
  const hasExistingPanel = existingPanel > -1;
4347
4558
  this.tabsContainer.show();
4348
4559
  this.contentContainer.show();
4349
4560
  this.tabsContainer.openPanel(panel, index);
4350
- if (!skipSetActive) {
4561
+ if (!options.skipSetActive) {
4351
4562
  this.contentContainer.openPanel(panel);
4352
4563
  }
4353
4564
  if (hasExistingPanel) {
@@ -4359,12 +4570,17 @@
4359
4570
  this._onDidAddPanel.fire({ panel });
4360
4571
  }
4361
4572
  doSetActivePanel(panel) {
4573
+ if (this._activePanel === panel) {
4574
+ return;
4575
+ }
4362
4576
  this._activePanel = panel;
4363
4577
  if (panel) {
4364
4578
  this.tabsContainer.setActivePanel(panel);
4365
4579
  panel.layout(this._width, this._height);
4366
4580
  this.updateMru(panel);
4367
- this._onDidActivePanelChange.fire({ panel });
4581
+ this._onDidActivePanelChange.fire({
4582
+ panel,
4583
+ });
4368
4584
  }
4369
4585
  }
4370
4586
  updateMru(panel) {
@@ -4376,11 +4592,11 @@
4376
4592
  updateContainer() {
4377
4593
  var _a, _b;
4378
4594
  toggleClass(this.container, 'empty', this.isEmpty);
4379
- this.panels.forEach((panel) => panel.updateParentGroup(this.groupPanel, this.isActive));
4595
+ this.panels.forEach((panel) => panel.runEvents());
4380
4596
  if (this.isEmpty && !this.watermark) {
4381
4597
  const watermark = this.accessor.createWatermarkComponent();
4382
4598
  watermark.init({
4383
- containerApi: new DockviewApi(this.accessor),
4599
+ containerApi: this._api,
4384
4600
  group: this.groupPanel,
4385
4601
  });
4386
4602
  this.watermark = watermark;
@@ -4413,10 +4629,32 @@
4413
4629
  }
4414
4630
  return false;
4415
4631
  }
4416
- handleDropEvent(event, position, index) {
4632
+ handleDropEvent(type, event, position, index) {
4417
4633
  if (this.locked === 'no-drop-target') {
4418
4634
  return;
4419
4635
  }
4636
+ function getKind() {
4637
+ switch (type) {
4638
+ case 'header':
4639
+ return typeof index === 'number' ? 'tab' : 'header_space';
4640
+ case 'content':
4641
+ return 'content';
4642
+ }
4643
+ }
4644
+ const panel = typeof index === 'number' ? this.panels[index] : undefined;
4645
+ const willDropEvent = new DockviewWillDropEvent({
4646
+ nativeEvent: event,
4647
+ position,
4648
+ panel,
4649
+ getData: () => getPanelData(),
4650
+ kind: getKind(),
4651
+ group: this.groupPanel,
4652
+ api: this._api,
4653
+ });
4654
+ this._onWillDrop.fire(willDropEvent);
4655
+ if (willDropEvent.defaultPrevented) {
4656
+ return;
4657
+ }
4420
4658
  const data = getPanelData();
4421
4659
  if (data && data.viewId === this.accessor.id) {
4422
4660
  if (data.panelId === null) {
@@ -4449,12 +4687,14 @@
4449
4687
  });
4450
4688
  }
4451
4689
  else {
4452
- this._onDidDrop.fire({
4690
+ this._onDidDrop.fire(new DockviewDidDropEvent({
4453
4691
  nativeEvent: event,
4454
4692
  position,
4455
- index,
4693
+ panel,
4456
4694
  getData: () => getPanelData(),
4457
- });
4695
+ group: this.groupPanel,
4696
+ api: this._api,
4697
+ }));
4458
4698
  }
4459
4699
  }
4460
4700
  dispose() {
@@ -4462,6 +4702,7 @@
4462
4702
  super.dispose();
4463
4703
  (_a = this.watermark) === null || _a === void 0 ? void 0 : _a.element.remove();
4464
4704
  (_c = (_b = this.watermark) === null || _b === void 0 ? void 0 : _b.dispose) === null || _c === void 0 ? void 0 : _c.call(_b);
4705
+ this.watermark = undefined;
4465
4706
  for (const panel of this.panels) {
4466
4707
  panel.dispose();
4467
4708
  }
@@ -4483,15 +4724,7 @@
4483
4724
  constructor(parentElement, disableResizing = false) {
4484
4725
  super();
4485
4726
  this._disableResizing = disableResizing;
4486
- if (parentElement) {
4487
- this._element = parentElement;
4488
- }
4489
- else {
4490
- this._element = document.createElement('div');
4491
- this._element.style.height = '100%';
4492
- this._element.style.width = '100%';
4493
- this._element.className = 'dv-resizable-container';
4494
- }
4727
+ this._element = parentElement;
4495
4728
  this.addDisposables(watchElementResize(this._element, (entry) => {
4496
4729
  if (this.isDisposed) {
4497
4730
  /**
@@ -4579,25 +4812,38 @@
4579
4812
  get activeGroup() {
4580
4813
  return this._activeGroup;
4581
4814
  }
4815
+ get locked() {
4816
+ return this.gridview.locked;
4817
+ }
4818
+ set locked(value) {
4819
+ this.gridview.locked = value;
4820
+ }
4582
4821
  constructor(options) {
4583
- super(options.parentElement, options.disableAutoResizing);
4822
+ super(document.createElement('div'), options.disableAutoResizing);
4584
4823
  this._id = nextLayoutId$1.next();
4585
4824
  this._groups = new Map();
4586
4825
  this._onDidLayoutChange = new Emitter();
4587
4826
  this.onDidLayoutChange = this._onDidLayoutChange.event;
4588
- this._onDidRemoveGroup = new Emitter();
4589
- this.onDidRemoveGroup = this._onDidRemoveGroup.event;
4590
- this._onDidAddGroup = new Emitter();
4591
- this.onDidAddGroup = this._onDidAddGroup.event;
4592
- this._onDidActiveGroupChange = new Emitter();
4593
- this.onDidActiveGroupChange = this._onDidActiveGroupChange.event;
4827
+ this._onDidRemove = new Emitter();
4828
+ this.onDidRemove = this._onDidRemove.event;
4829
+ this._onDidAdd = new Emitter();
4830
+ this.onDidAdd = this._onDidAdd.event;
4831
+ this._onDidActiveChange = new Emitter();
4832
+ this.onDidActiveChange = this._onDidActiveChange.event;
4594
4833
  this._bufferOnDidLayoutChange = new TickDelayedEvent();
4834
+ this.element.style.height = '100%';
4835
+ this.element.style.width = '100%';
4836
+ options.parentElement.appendChild(this.element);
4595
4837
  this.gridview = new Gridview(!!options.proportionalLayout, options.styles, options.orientation);
4838
+ this.gridview.locked = !!options.locked;
4596
4839
  this.element.appendChild(this.gridview.element);
4597
4840
  this.layout(0, 0, true); // set some elements height/widths
4598
- this.addDisposables(this.gridview.onDidChange(() => {
4841
+ this.addDisposables(Disposable.from(() => {
4842
+ var _a;
4843
+ (_a = this.element.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(this.element);
4844
+ }), this.gridview.onDidChange(() => {
4599
4845
  this._bufferOnDidLayoutChange.fire();
4600
- }), exports.DockviewEvent.any(this.onDidAddGroup, this.onDidRemoveGroup, this.onDidActiveGroupChange)(() => {
4846
+ }), exports.DockviewEvent.any(this.onDidAdd, this.onDidRemove, this.onDidActiveChange)(() => {
4601
4847
  this._bufferOnDidLayoutChange.fire();
4602
4848
  }), this._bufferOnDidLayoutChange.onEvent(() => {
4603
4849
  this._onDidLayoutChange.fire();
@@ -4612,6 +4858,7 @@
4612
4858
  }
4613
4859
  maximizeGroup(panel) {
4614
4860
  this.gridview.maximizeView(panel);
4861
+ this.doSetGroupActive(panel);
4615
4862
  }
4616
4863
  isMaximizedGroup(panel) {
4617
4864
  return this.gridview.maximizedView() === panel;
@@ -4622,13 +4869,12 @@
4622
4869
  hasMaximizedGroup() {
4623
4870
  return this.gridview.hasMaximizedView();
4624
4871
  }
4625
- get onDidMaxmizedGroupChange() {
4626
- return this.gridview.onDidMaxmizedNodeChange;
4872
+ get onDidMaximizedGroupChange() {
4873
+ return this.gridview.onDidMaximizedNodeChange;
4627
4874
  }
4628
4875
  doAddGroup(group, location = [0], size) {
4629
4876
  this.gridview.addView(group, size !== null && size !== void 0 ? size : exports.Sizing.Distribute, location);
4630
- this._onDidAddGroup.fire(group);
4631
- this.doSetGroupActive(group);
4877
+ this._onDidAdd.fire(group);
4632
4878
  }
4633
4879
  doRemoveGroup(group, options) {
4634
4880
  if (!this._groups.has(group.id)) {
@@ -4640,8 +4886,8 @@
4640
4886
  item.disposable.dispose();
4641
4887
  item.value.dispose();
4642
4888
  this._groups.delete(group.id);
4889
+ this._onDidRemove.fire(group);
4643
4890
  }
4644
- this._onDidRemoveGroup.fire(group);
4645
4891
  if (!(options === null || options === void 0 ? void 0 : options.skipActive) && this._activeGroup === group) {
4646
4892
  const groups = Array.from(this._groups.values());
4647
4893
  this.doSetGroupActive(groups.length > 0 ? groups[0].value : undefined);
@@ -4652,25 +4898,18 @@
4652
4898
  var _a;
4653
4899
  return (_a = this._groups.get(id)) === null || _a === void 0 ? void 0 : _a.value;
4654
4900
  }
4655
- doSetGroupActive(group, skipFocus) {
4656
- var _a, _b, _c;
4901
+ doSetGroupActive(group) {
4657
4902
  if (this._activeGroup === group) {
4658
4903
  return;
4659
4904
  }
4660
4905
  if (this._activeGroup) {
4661
4906
  this._activeGroup.setActive(false);
4662
- if (!skipFocus) {
4663
- (_b = (_a = this._activeGroup).focus) === null || _b === void 0 ? void 0 : _b.call(_a);
4664
- }
4665
4907
  }
4666
4908
  if (group) {
4667
4909
  group.setActive(true);
4668
- if (!skipFocus) {
4669
- (_c = group.focus) === null || _c === void 0 ? void 0 : _c.call(group);
4670
- }
4671
4910
  }
4672
4911
  this._activeGroup = group;
4673
- this._onDidActiveGroupChange.fire(group);
4912
+ this._onDidActiveChange.fire(group);
4674
4913
  }
4675
4914
  removeGroup(group) {
4676
4915
  this.doRemoveGroup(group);
@@ -4715,9 +4954,9 @@
4715
4954
  this.gridview.layout(width, height);
4716
4955
  }
4717
4956
  dispose() {
4718
- this._onDidActiveGroupChange.dispose();
4719
- this._onDidAddGroup.dispose();
4720
- this._onDidRemoveGroup.dispose();
4957
+ this._onDidActiveChange.dispose();
4958
+ this._onDidAdd.dispose();
4959
+ this._onDidRemove.dispose();
4721
4960
  this._onDidLayoutChange.dispose();
4722
4961
  for (const group of this.groups) {
4723
4962
  group.dispose();
@@ -4727,11 +4966,15 @@
4727
4966
  }
4728
4967
  }
4729
4968
 
4969
+ class WillFocusEvent extends DockviewEvent {
4970
+ constructor() {
4971
+ super();
4972
+ }
4973
+ }
4730
4974
  /**
4731
4975
  * A core api implementation that should be used across all panel-like objects
4732
4976
  */
4733
4977
  class PanelApiImpl extends CompositeDisposable {
4734
- //
4735
4978
  get isFocused() {
4736
4979
  return this._isFocused;
4737
4980
  }
@@ -4741,6 +4984,9 @@
4741
4984
  get isVisible() {
4742
4985
  return this._isVisible;
4743
4986
  }
4987
+ get isHidden() {
4988
+ return this._isHidden;
4989
+ }
4744
4990
  get width() {
4745
4991
  return this._width;
4746
4992
  }
@@ -4753,38 +4999,26 @@
4753
4999
  this._isFocused = false;
4754
5000
  this._isActive = false;
4755
5001
  this._isVisible = true;
5002
+ this._isHidden = false;
4756
5003
  this._width = 0;
4757
5004
  this._height = 0;
4758
5005
  this.panelUpdatesDisposable = new MutableDisposable();
4759
- this._onDidDimensionChange = new Emitter({
4760
- replay: true,
4761
- });
5006
+ this._onDidDimensionChange = new Emitter();
4762
5007
  this.onDidDimensionsChange = this._onDidDimensionChange.event;
4763
- //
4764
- this._onDidChangeFocus = new Emitter({
4765
- replay: true,
4766
- });
5008
+ this._onDidChangeFocus = new Emitter();
4767
5009
  this.onDidFocusChange = this._onDidChangeFocus.event;
4768
5010
  //
4769
- this._onFocusEvent = new Emitter();
4770
- this.onFocusEvent = this._onFocusEvent.event;
5011
+ this._onWillFocus = new Emitter();
5012
+ this.onWillFocus = this._onWillFocus.event;
4771
5013
  //
4772
- this._onDidVisibilityChange = new Emitter({
4773
- replay: true,
4774
- });
5014
+ this._onDidVisibilityChange = new Emitter();
4775
5015
  this.onDidVisibilityChange = this._onDidVisibilityChange.event;
4776
- //
4777
- this._onVisibilityChange = new Emitter();
4778
- this.onVisibilityChange = this._onVisibilityChange.event;
4779
- //
4780
- this._onDidActiveChange = new Emitter({
4781
- replay: true,
4782
- });
5016
+ this._onDidHiddenChange = new Emitter();
5017
+ this.onDidHiddenChange = this._onDidHiddenChange.event;
5018
+ this._onDidActiveChange = new Emitter();
4783
5019
  this.onDidActiveChange = this._onDidActiveChange.event;
4784
- //
4785
5020
  this._onActiveChange = new Emitter();
4786
5021
  this.onActiveChange = this._onActiveChange.event;
4787
- //
4788
5022
  this._onUpdateParameters = new Emitter();
4789
5023
  this.onUpdateParameters = this._onUpdateParameters.event;
4790
5024
  this.addDisposables(this.onDidFocusChange((event) => {
@@ -4793,10 +5027,12 @@
4793
5027
  this._isActive = event.isActive;
4794
5028
  }), this.onDidVisibilityChange((event) => {
4795
5029
  this._isVisible = event.isVisible;
5030
+ }), this.onDidHiddenChange((event) => {
5031
+ this._isHidden = event.isHidden;
4796
5032
  }), this.onDidDimensionsChange((event) => {
4797
5033
  this._width = event.width;
4798
5034
  this._height = event.height;
4799
- }), this.panelUpdatesDisposable, this._onDidDimensionChange, this._onDidChangeFocus, this._onDidVisibilityChange, this._onDidActiveChange, this._onFocusEvent, this._onActiveChange, this._onVisibilityChange, this._onUpdateParameters);
5035
+ }), this.panelUpdatesDisposable, this._onDidDimensionChange, this._onDidChangeFocus, this._onDidVisibilityChange, this._onDidActiveChange, this._onWillFocus, this._onActiveChange, this._onUpdateParameters, this._onWillFocus, this._onDidHiddenChange, this._onUpdateParameters);
4800
5036
  }
4801
5037
  initialize(panel) {
4802
5038
  this.panelUpdatesDisposable.value = this._onUpdateParameters.event((parameters) => {
@@ -4805,8 +5041,8 @@
4805
5041
  });
4806
5042
  });
4807
5043
  }
4808
- setVisible(isVisible) {
4809
- this._onVisibilityChange.fire({ isVisible });
5044
+ setHidden(isHidden) {
5045
+ this._onDidHiddenChange.fire({ isHidden });
4810
5046
  }
4811
5047
  setActive() {
4812
5048
  this._onActiveChange.fire();
@@ -4814,9 +5050,6 @@
4814
5050
  updateParameters(parameters) {
4815
5051
  this._onUpdateParameters.fire(parameters);
4816
5052
  }
4817
- dispose() {
4818
- super.dispose();
4819
- }
4820
5053
  }
4821
5054
 
4822
5055
  class SplitviewPanelApiImpl extends PanelApiImpl {
@@ -4904,7 +5137,12 @@
4904
5137
  }), focusTracker);
4905
5138
  }
4906
5139
  focus() {
4907
- this.api._onFocusEvent.fire();
5140
+ const event = new WillFocusEvent();
5141
+ this.api._onWillFocus.fire(event);
5142
+ if (event.defaultPrevented) {
5143
+ return;
5144
+ }
5145
+ this._element.focus();
4908
5146
  }
4909
5147
  layout(width, height) {
4910
5148
  this._width = width;
@@ -5233,9 +5471,7 @@
5233
5471
  super(id);
5234
5472
  this._onDidConstraintsChangeInternal = new Emitter();
5235
5473
  this.onDidConstraintsChangeInternal = this._onDidConstraintsChangeInternal.event;
5236
- this._onDidConstraintsChange = new Emitter({
5237
- replay: true,
5238
- });
5474
+ this._onDidConstraintsChange = new Emitter();
5239
5475
  this.onDidConstraintsChange = this._onDidConstraintsChange.event;
5240
5476
  this._onDidSizeChange = new Emitter();
5241
5477
  this.onDidSizeChange = this._onDidSizeChange.event;
@@ -5328,13 +5564,13 @@
5328
5564
  this._maximumHeight = options.maximumHeight;
5329
5565
  }
5330
5566
  this.api.initialize(this); // TODO: required to by-pass 'super before this' requirement
5331
- this.addDisposables(this.api.onVisibilityChange((event) => {
5332
- const { isVisible } = event;
5567
+ this.addDisposables(this.api.onDidHiddenChange((event) => {
5568
+ const { isHidden } = event;
5333
5569
  const { accessor } = this._params;
5334
- accessor.setVisible(this, isVisible);
5570
+ accessor.setVisible(this, !isHidden);
5335
5571
  }), this.api.onActiveChange(() => {
5336
5572
  const { accessor } = this._params;
5337
- accessor.setActive(this);
5573
+ accessor.doSetGroupActive(this);
5338
5574
  }), this.api.onDidConstraintsChangeInternal((event) => {
5339
5575
  if (typeof event.minimumWidth === 'number' ||
5340
5576
  typeof event.minimumWidth === 'function') {
@@ -5417,6 +5653,17 @@
5417
5653
  this.onDidLocationChange = this._onDidLocationChange.event;
5418
5654
  this.addDisposables(this._onDidLocationChange);
5419
5655
  }
5656
+ close() {
5657
+ if (!this._group) {
5658
+ return;
5659
+ }
5660
+ return this.accessor.removeGroup(this._group);
5661
+ }
5662
+ getWindow() {
5663
+ return this.location.type === 'popout'
5664
+ ? this.location.getWindow()
5665
+ : window;
5666
+ }
5420
5667
  moveTo(options) {
5421
5668
  var _a, _b, _c;
5422
5669
  if (!this._group) {
@@ -5424,14 +5671,23 @@
5424
5671
  }
5425
5672
  const group = (_a = options.group) !== null && _a !== void 0 ? _a : this.accessor.addGroup({
5426
5673
  direction: positionToDirection((_b = options.position) !== null && _b !== void 0 ? _b : 'right'),
5674
+ skipSetActive: true,
5675
+ });
5676
+ this.accessor.moveGroupOrPanel({
5677
+ from: { groupId: this._group.id },
5678
+ to: {
5679
+ group,
5680
+ position: options.group
5681
+ ? (_c = options.position) !== null && _c !== void 0 ? _c : 'center'
5682
+ : 'center',
5683
+ },
5427
5684
  });
5428
- this.accessor.moveGroupOrPanel(group, this._group.id, undefined, options.group ? (_c = options.position) !== null && _c !== void 0 ? _c : 'center' : 'center');
5429
5685
  }
5430
5686
  maximize() {
5431
5687
  if (!this._group) {
5432
5688
  throw new Error(NOT_INITIALIZED_MESSAGE);
5433
5689
  }
5434
- if (this.location !== 'grid') {
5690
+ if (this.location.type !== 'grid') {
5435
5691
  // only grid groups can be maximized
5436
5692
  return;
5437
5693
  }
@@ -5488,6 +5744,12 @@
5488
5744
  this.api.initialize(this); // cannot use 'this' after after 'super' call
5489
5745
  this._model = new DockviewGroupPanelModel(this.element, accessor, id, options, this);
5490
5746
  }
5747
+ focus() {
5748
+ if (!this.api.isActive) {
5749
+ this.api.setActive();
5750
+ }
5751
+ super.focus();
5752
+ }
5491
5753
  initialize() {
5492
5754
  this._model.initialize();
5493
5755
  }
@@ -5533,6 +5795,9 @@
5533
5795
  }
5534
5796
 
5535
5797
  class DockviewPanelApiImpl extends GridviewPanelApiImpl {
5798
+ get location() {
5799
+ return this.group.api.location;
5800
+ }
5536
5801
  get title() {
5537
5802
  return this.panel.title;
5538
5803
  }
@@ -5544,15 +5809,34 @@
5544
5809
  }
5545
5810
  set group(value) {
5546
5811
  const isOldGroupActive = this.isGroupActive;
5547
- this._group = value;
5548
- this._onDidGroupChange.fire();
5549
- if (this._group) {
5550
- this.disposable.value = this._group.api.onDidActiveChange(() => {
5551
- this._onDidActiveGroupChange.fire();
5812
+ if (this._group !== value) {
5813
+ this._group = value;
5814
+ this._onDidGroupChange.fire({});
5815
+ let _trackGroupActive = isOldGroupActive; // prevent duplicate events with same state
5816
+ this.groupEventsDisposable.value = new CompositeDisposable(this.group.api.onDidLocationChange((event) => {
5817
+ if (this.group !== this.panel.group) {
5818
+ return;
5819
+ }
5820
+ this._onDidLocationChange.fire(event);
5821
+ }), this.group.api.onDidActiveChange(() => {
5822
+ if (this.group !== this.panel.group) {
5823
+ return;
5824
+ }
5825
+ if (_trackGroupActive !== this.isGroupActive) {
5826
+ _trackGroupActive = this.isGroupActive;
5827
+ this._onDidActiveGroupChange.fire({
5828
+ isActive: this.isGroupActive,
5829
+ });
5830
+ }
5831
+ }));
5832
+ // if (this.isGroupActive !== isOldGroupActive) {
5833
+ // this._onDidActiveGroupChange.fire({
5834
+ // isActive: this.isGroupActive,
5835
+ // });
5836
+ // }
5837
+ this._onDidLocationChange.fire({
5838
+ location: this.group.api.location,
5552
5839
  });
5553
- if (this.isGroupActive !== isOldGroupActive) {
5554
- this._onDidActiveGroupChange.fire();
5555
- }
5556
5840
  }
5557
5841
  }
5558
5842
  get group() {
@@ -5570,14 +5854,26 @@
5570
5854
  this.onDidGroupChange = this._onDidGroupChange.event;
5571
5855
  this._onDidRendererChange = new Emitter();
5572
5856
  this.onDidRendererChange = this._onDidRendererChange.event;
5573
- this.disposable = new MutableDisposable();
5857
+ this._onDidLocationChange = new Emitter();
5858
+ this.onDidLocationChange = this._onDidLocationChange.event;
5859
+ this.groupEventsDisposable = new MutableDisposable();
5574
5860
  this.initialize(panel);
5575
5861
  this._group = group;
5576
- this.addDisposables(this.disposable, this._onDidRendererChange, this._onDidTitleChange, this._onDidGroupChange, this._onDidActiveGroupChange);
5862
+ this.addDisposables(this.groupEventsDisposable, this._onDidRendererChange, this._onDidTitleChange, this._onDidGroupChange, this._onDidActiveGroupChange, this._onDidLocationChange);
5863
+ }
5864
+ getWindow() {
5865
+ return this.group.api.getWindow();
5577
5866
  }
5578
5867
  moveTo(options) {
5579
5868
  var _a;
5580
- this.accessor.moveGroupOrPanel(options.group, this._group.id, this.panel.id, (_a = options.position) !== null && _a !== void 0 ? _a : 'center', options.index);
5869
+ this.accessor.moveGroupOrPanel({
5870
+ from: { groupId: this._group.id, panelId: this.panel.id },
5871
+ to: {
5872
+ group: options.group,
5873
+ position: (_a = options.position) !== null && _a !== void 0 ? _a : 'center',
5874
+ index: options.index,
5875
+ },
5876
+ });
5581
5877
  }
5582
5878
  setTitle(title) {
5583
5879
  this.panel.setTitle(title);
@@ -5638,7 +5934,14 @@
5638
5934
  this.setTitle(params.title);
5639
5935
  }
5640
5936
  focus() {
5641
- this.api._onFocusEvent.fire();
5937
+ const event = new WillFocusEvent();
5938
+ this.api._onWillFocus.fire(event);
5939
+ if (event.defaultPrevented) {
5940
+ return;
5941
+ }
5942
+ if (!this.api.isActive) {
5943
+ this.api.setActive();
5944
+ }
5642
5945
  }
5643
5946
  toJSON() {
5644
5947
  return {
@@ -5695,20 +5998,40 @@
5695
5998
  },
5696
5999
  });
5697
6000
  }
5698
- updateParentGroup(group, isGroupActive) {
6001
+ updateParentGroup(group, options) {
5699
6002
  this._group = group;
5700
- this.api.group = group;
6003
+ this.api.group = this._group;
5701
6004
  const isPanelVisible = this._group.model.isPanelActive(this);
5702
- this.api._onDidActiveChange.fire({
5703
- isActive: isGroupActive && isPanelVisible,
5704
- });
5705
- this.api._onDidVisibilityChange.fire({
5706
- isVisible: isPanelVisible,
5707
- });
5708
- this.view.updateParentGroup(this._group, this._group.model.isPanelActive(this));
6005
+ const isActive = this.group.api.isActive && isPanelVisible;
6006
+ if (!(options === null || options === void 0 ? void 0 : options.skipSetActive)) {
6007
+ if (this.api.isActive !== isActive) {
6008
+ this.api._onDidActiveChange.fire({
6009
+ isActive: this.group.api.isActive && isPanelVisible,
6010
+ });
6011
+ }
6012
+ }
6013
+ if (this.api.isVisible !== isPanelVisible) {
6014
+ this.api._onDidVisibilityChange.fire({
6015
+ isVisible: isPanelVisible,
6016
+ });
6017
+ }
6018
+ }
6019
+ runEvents() {
6020
+ const isPanelVisible = this._group.model.isPanelActive(this);
6021
+ const isActive = this.group.api.isActive && isPanelVisible;
6022
+ if (this.api.isActive !== isActive) {
6023
+ this.api._onDidActiveChange.fire({
6024
+ isActive: this.group.api.isActive && isPanelVisible,
6025
+ });
6026
+ }
6027
+ if (this.api.isVisible !== isPanelVisible) {
6028
+ this.api._onDidVisibilityChange.fire({
6029
+ isVisible: isPanelVisible,
6030
+ });
6031
+ }
5709
6032
  }
5710
6033
  layout(width, height) {
5711
- // the obtain the correct dimensions of the content panel we must deduct the tab height
6034
+ // TODO: Can we somehow do height without header height or indicate what the header height is?
5712
6035
  this.api._onDidDimensionChange.fire({
5713
6036
  width,
5714
6037
  height: height,
@@ -5830,8 +6153,6 @@
5830
6153
  this.id = id;
5831
6154
  this.contentComponent = contentComponent;
5832
6155
  this.tabComponent = tabComponent;
5833
- this._group = null;
5834
- this._isPanelVisible = null;
5835
6156
  this._content = this.createContentComponent(this.id, contentComponent);
5836
6157
  this._tab = this.createTabComponent(this.id, tabComponent);
5837
6158
  }
@@ -5839,25 +6160,8 @@
5839
6160
  this.content.init(Object.assign(Object.assign({}, params), { tab: this.tab }));
5840
6161
  this.tab.init(params);
5841
6162
  }
5842
- updateParentGroup(group, isPanelVisible) {
5843
- if (group !== this._group) {
5844
- this._group = group;
5845
- if (this._content.onGroupChange) {
5846
- this._content.onGroupChange(group);
5847
- }
5848
- if (this._tab.onGroupChange) {
5849
- this._tab.onGroupChange(group);
5850
- }
5851
- }
5852
- if (isPanelVisible !== this._isPanelVisible) {
5853
- this._isPanelVisible = isPanelVisible;
5854
- if (this._content.onPanelVisibleChange) {
5855
- this._content.onPanelVisibleChange(isPanelVisible);
5856
- }
5857
- if (this._tab.onPanelVisibleChange) {
5858
- this._tab.onPanelVisibleChange(isPanelVisible);
5859
- }
5860
- }
6163
+ updateParentGroup(_group, _isPanelVisible) {
6164
+ // noop
5861
6165
  }
5862
6166
  layout(width, height) {
5863
6167
  var _a, _b;
@@ -6290,117 +6594,6 @@
6290
6594
  }
6291
6595
  }
6292
6596
 
6293
- class PopoutWindow extends CompositeDisposable {
6294
- constructor(id, className, options) {
6295
- super();
6296
- this.id = id;
6297
- this.className = className;
6298
- this.options = options;
6299
- this._onDidClose = new Emitter();
6300
- this.onDidClose = this._onDidClose.event;
6301
- this._window = null;
6302
- this.addDisposables(this._onDidClose, {
6303
- dispose: () => {
6304
- this.close();
6305
- },
6306
- });
6307
- }
6308
- dimensions() {
6309
- if (!this._window) {
6310
- return null;
6311
- }
6312
- const left = this._window.value.screenX;
6313
- const top = this._window.value.screenY;
6314
- const width = this._window.value.innerWidth;
6315
- const height = this._window.value.innerHeight;
6316
- return { top, left, width, height };
6317
- }
6318
- close() {
6319
- if (this._window) {
6320
- this._window.disposable.dispose();
6321
- this._window.value.close();
6322
- this._window = null;
6323
- }
6324
- }
6325
- open(content) {
6326
- if (this._window) {
6327
- throw new Error('instance of popout window is already open');
6328
- }
6329
- const url = `${this.options.url}`;
6330
- const features = Object.entries({
6331
- top: this.options.top,
6332
- left: this.options.left,
6333
- width: this.options.width,
6334
- height: this.options.height,
6335
- })
6336
- .map(([key, value]) => `${key}=${value}`)
6337
- .join(',');
6338
- // https://developer.mozilla.org/en-US/docs/Web/API/Window/open
6339
- const externalWindow = window.open(url, this.id, features);
6340
- if (!externalWindow) {
6341
- return;
6342
- }
6343
- const disposable = new CompositeDisposable();
6344
- this._window = { value: externalWindow, disposable };
6345
- const cleanUp = () => {
6346
- this._onDidClose.fire();
6347
- this._window = null;
6348
- };
6349
- // prevent any default content from loading
6350
- // externalWindow.document.body.replaceWith(document.createElement('div'));
6351
- disposable.addDisposables(addDisposableWindowListener(window, 'beforeunload', () => {
6352
- cleanUp();
6353
- this.close();
6354
- }));
6355
- externalWindow.addEventListener('load', () => {
6356
- const externalDocument = externalWindow.document;
6357
- externalDocument.title = document.title;
6358
- const div = document.createElement('div');
6359
- div.classList.add('dv-popout-window');
6360
- div.style.position = 'absolute';
6361
- div.style.width = '100%';
6362
- div.style.height = '100%';
6363
- div.style.top = '0px';
6364
- div.style.left = '0px';
6365
- div.classList.add(this.className);
6366
- div.appendChild(content);
6367
- externalDocument.body.replaceChildren(div);
6368
- externalDocument.body.classList.add(this.className);
6369
- addStyles(externalDocument, window.document.styleSheets);
6370
- externalWindow.addEventListener('beforeunload', () => {
6371
- // TODO: indicate external window is closing
6372
- cleanUp();
6373
- });
6374
- });
6375
- }
6376
- }
6377
-
6378
- class DockviewPopoutGroupPanel extends CompositeDisposable {
6379
- constructor(id, group, options) {
6380
- var _a;
6381
- super();
6382
- this.id = id;
6383
- this.group = group;
6384
- this.options = options;
6385
- this.window = new PopoutWindow(id, (_a = options.className) !== null && _a !== void 0 ? _a : '', {
6386
- url: this.options.popoutUrl,
6387
- left: this.options.box.left,
6388
- top: this.options.box.top,
6389
- width: this.options.box.width,
6390
- height: this.options.box.height,
6391
- });
6392
- group.model.location = 'popout';
6393
- this.addDisposables(this.window, {
6394
- dispose: () => {
6395
- group.model.location = 'grid';
6396
- },
6397
- }, this.window.onDidClose(() => {
6398
- this.dispose();
6399
- }));
6400
- this.window.open(group.element);
6401
- }
6402
- }
6403
-
6404
6597
  const DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE = 100;
6405
6598
  const DEFAULT_FLOATING_GROUP_POSITION = { left: 100, top: 100 };
6406
6599
 
@@ -6414,11 +6607,13 @@
6414
6607
  super();
6415
6608
  this.element = element;
6416
6609
  this.map = {};
6610
+ this._disposed = false;
6417
6611
  this.addDisposables(Disposable.from(() => {
6418
6612
  for (const value of Object.values(this.map)) {
6419
6613
  value.disposable.dispose();
6420
6614
  value.destroy.dispose();
6421
6615
  }
6616
+ this._disposed = true;
6422
6617
  }));
6423
6618
  }
6424
6619
  detatch(panel) {
@@ -6458,7 +6653,7 @@
6458
6653
  focusContainer.style.top = `${box.top - box2.top}px`;
6459
6654
  focusContainer.style.width = `${box.width}px`;
6460
6655
  focusContainer.style.height = `${box.height}px`;
6461
- toggleClass(focusContainer, 'dv-render-overlay-float', panel.group.api.location === 'floating');
6656
+ toggleClass(focusContainer, 'dv-render-overlay-float', panel.group.api.location.type === 'floating');
6462
6657
  };
6463
6658
  const visibilityChanged = () => {
6464
6659
  if (panel.api.isVisible) {
@@ -6504,8 +6699,11 @@
6504
6699
  resize();
6505
6700
  }));
6506
6701
  this.map[panel.api.id].destroy = Disposable.from(() => {
6507
- focusContainer.removeChild(panel.view.content.element);
6508
- this.element.removeChild(focusContainer);
6702
+ var _a;
6703
+ if (panel.view.content.element.parentElement === focusContainer) {
6704
+ focusContainer.removeChild(panel.view.content.element);
6705
+ }
6706
+ (_a = focusContainer.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(focusContainer);
6509
6707
  });
6510
6708
  queueMicrotask(() => {
6511
6709
  if (this.isDisposed) {
@@ -6526,11 +6724,164 @@
6526
6724
  }
6527
6725
  }
6528
6726
 
6727
+ var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
6728
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
6729
+ return new (P || (P = Promise))(function (resolve, reject) {
6730
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6731
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6732
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
6733
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
6734
+ });
6735
+ };
6736
+ class PopoutWindow extends CompositeDisposable {
6737
+ get window() {
6738
+ var _a, _b;
6739
+ return (_b = (_a = this._window) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : null;
6740
+ }
6741
+ constructor(target, className, options) {
6742
+ super();
6743
+ this.target = target;
6744
+ this.className = className;
6745
+ this.options = options;
6746
+ this._onWillClose = new Emitter();
6747
+ this.onWillClose = this._onWillClose.event;
6748
+ this._onDidClose = new Emitter();
6749
+ this.onDidClose = this._onDidClose.event;
6750
+ this._window = null;
6751
+ this.addDisposables(this._onWillClose, this._onDidClose, {
6752
+ dispose: () => {
6753
+ this.close();
6754
+ },
6755
+ });
6756
+ }
6757
+ dimensions() {
6758
+ if (!this._window) {
6759
+ return null;
6760
+ }
6761
+ const left = this._window.value.screenX;
6762
+ const top = this._window.value.screenY;
6763
+ const width = this._window.value.innerWidth;
6764
+ const height = this._window.value.innerHeight;
6765
+ return { top, left, width, height };
6766
+ }
6767
+ close() {
6768
+ var _a, _b;
6769
+ if (this._window) {
6770
+ this._onWillClose.fire();
6771
+ (_b = (_a = this.options).onWillClose) === null || _b === void 0 ? void 0 : _b.call(_a, {
6772
+ id: this.target,
6773
+ window: this._window.value,
6774
+ });
6775
+ this._window.disposable.dispose();
6776
+ this._window.value.close();
6777
+ this._window = null;
6778
+ this._onDidClose.fire();
6779
+ }
6780
+ }
6781
+ open() {
6782
+ var _a, _b;
6783
+ return __awaiter(this, void 0, void 0, function* () {
6784
+ if (this._window) {
6785
+ throw new Error('instance of popout window is already open');
6786
+ }
6787
+ const url = `${this.options.url}`;
6788
+ const features = Object.entries({
6789
+ top: this.options.top,
6790
+ left: this.options.left,
6791
+ width: this.options.width,
6792
+ height: this.options.height,
6793
+ })
6794
+ .map(([key, value]) => `${key}=${value}`)
6795
+ .join(',');
6796
+ /**
6797
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/open
6798
+ */
6799
+ const externalWindow = window.open(url, this.target, features);
6800
+ if (!externalWindow) {
6801
+ /**
6802
+ * Popup blocked
6803
+ */
6804
+ return null;
6805
+ }
6806
+ const disposable = new CompositeDisposable();
6807
+ this._window = { value: externalWindow, disposable };
6808
+ disposable.addDisposables(addDisposableWindowListener(window, 'beforeunload', () => {
6809
+ /**
6810
+ * before the main window closes we should close this popup too
6811
+ * to be good citizens
6812
+ *
6813
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event
6814
+ */
6815
+ this.close();
6816
+ }));
6817
+ const container = this.createPopoutWindowContainer();
6818
+ if (this.className) {
6819
+ container.classList.add(this.className);
6820
+ }
6821
+ (_b = (_a = this.options).onDidOpen) === null || _b === void 0 ? void 0 : _b.call(_a, {
6822
+ id: this.target,
6823
+ window: externalWindow,
6824
+ });
6825
+ return new Promise((resolve) => {
6826
+ externalWindow.addEventListener('unload', (e) => {
6827
+ // if page fails to load before unloading
6828
+ // this.close();
6829
+ });
6830
+ externalWindow.addEventListener('load', () => {
6831
+ /**
6832
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event
6833
+ */
6834
+ const externalDocument = externalWindow.document;
6835
+ externalDocument.title = document.title;
6836
+ externalDocument.body.appendChild(container);
6837
+ addStyles(externalDocument, window.document.styleSheets);
6838
+ /**
6839
+ * beforeunload must be registered after load for reasons I could not determine
6840
+ * otherwise the beforeunload event will not fire when the window is closed
6841
+ */
6842
+ addDisposableWindowListener(externalWindow, 'beforeunload', () => {
6843
+ /**
6844
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/beforeunload_event
6845
+ */
6846
+ this.close();
6847
+ });
6848
+ resolve(container);
6849
+ });
6850
+ });
6851
+ });
6852
+ }
6853
+ createPopoutWindowContainer() {
6854
+ const el = document.createElement('div');
6855
+ el.classList.add('dv-popout-window');
6856
+ el.id = 'dv-popout-window';
6857
+ el.style.position = 'absolute';
6858
+ el.style.width = '100%';
6859
+ el.style.height = '100%';
6860
+ el.style.top = '0px';
6861
+ el.style.left = '0px';
6862
+ return el;
6863
+ }
6864
+ }
6865
+
6529
6866
  const DEFAULT_ROOT_OVERLAY_MODEL = {
6530
6867
  activationSize: { type: 'pixels', value: 10 },
6531
6868
  size: { type: 'pixels', value: 20 },
6532
6869
  };
6533
- function getTheme(element) {
6870
+ function moveGroupWithoutDestroying(options) {
6871
+ const activePanel = options.from.activePanel;
6872
+ const panels = [...options.from.panels].map((panel) => {
6873
+ const removedPanel = options.from.model.removePanel(panel);
6874
+ options.from.model.renderContainer.detatch(panel);
6875
+ return removedPanel;
6876
+ });
6877
+ panels.forEach((panel) => {
6878
+ options.to.model.openPanel(panel, {
6879
+ skipSetActive: activePanel !== panel,
6880
+ skipSetGroupActive: true,
6881
+ });
6882
+ });
6883
+ }
6884
+ function getDockviewTheme(element) {
6534
6885
  function toClassList(element) {
6535
6886
  const list = [];
6536
6887
  for (let i = 0; i < element.classList.length; i++) {
@@ -6581,6 +6932,7 @@
6581
6932
  styles: options.styles,
6582
6933
  parentElement: options.parentElement,
6583
6934
  disableAutoResizing: options.disableAutoResizing,
6935
+ locked: options.locked,
6584
6936
  });
6585
6937
  this.nextGroupId = sequentialNumberGenerator();
6586
6938
  this._deserializer = new DefaultDockviewDeserialzier(this);
@@ -6591,6 +6943,10 @@
6591
6943
  this.onWillDragGroup = this._onWillDragGroup.event;
6592
6944
  this._onDidDrop = new Emitter();
6593
6945
  this.onDidDrop = this._onDidDrop.event;
6946
+ this._onWillDrop = new Emitter();
6947
+ this.onWillDrop = this._onWillDrop.event;
6948
+ this._onWillShowOverlay = new Emitter();
6949
+ this.onWillShowOverlay = this._onWillShowOverlay.event;
6594
6950
  this._onDidRemovePanel = new Emitter();
6595
6951
  this.onDidRemovePanel = this._onDidRemovePanel.event;
6596
6952
  this._onDidAddPanel = new Emitter();
@@ -6599,15 +6955,36 @@
6599
6955
  this.onDidLayoutFromJSON = this._onDidLayoutFromJSON.event;
6600
6956
  this._onDidActivePanelChange = new Emitter();
6601
6957
  this.onDidActivePanelChange = this._onDidActivePanelChange.event;
6958
+ this._onDidMovePanel = new Emitter();
6602
6959
  this._floatingGroups = [];
6603
6960
  this._popoutGroups = [];
6961
+ this._ignoreEvents = 0;
6962
+ this._onDidRemoveGroup = new Emitter();
6963
+ this.onDidRemoveGroup = this._onDidRemoveGroup.event;
6964
+ this._onDidAddGroup = new Emitter();
6965
+ this.onDidAddGroup = this._onDidAddGroup.event;
6966
+ this._onDidActiveGroupChange = new Emitter();
6967
+ this.onDidActiveGroupChange = this._onDidActiveGroupChange.event;
6968
+ this._moving = false;
6604
6969
  const gready = document.createElement('div');
6605
6970
  gready.className = 'dv-overlay-render-container';
6606
6971
  this.gridview.element.appendChild(gready);
6607
6972
  this.overlayRenderContainer = new OverlayRenderContainer(gready);
6608
6973
  toggleClass(this.gridview.element, 'dv-dockview', true);
6609
6974
  toggleClass(this.element, 'dv-debug', !!options.debug);
6610
- 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)(() => {
6975
+ 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) => {
6976
+ if (!this._moving) {
6977
+ this._onDidAddGroup.fire(event);
6978
+ }
6979
+ }), this.onDidRemove((event) => {
6980
+ if (!this._moving) {
6981
+ this._onDidRemoveGroup.fire(event);
6982
+ }
6983
+ }), this.onDidActiveChange((event) => {
6984
+ if (!this._moving) {
6985
+ this._onDidActiveGroupChange.fire(event);
6986
+ }
6987
+ }), exports.DockviewEvent.any(this.onDidAdd, this.onDidRemove)(() => {
6611
6988
  this.updateWatermark();
6612
6989
  }), exports.DockviewEvent.any(this.onDidAddPanel, this.onDidRemovePanel, this.onDidActivePanelChange)(() => {
6613
6990
  this._bufferOnDidLayoutChange.fire();
@@ -6618,7 +6995,7 @@
6618
6995
  }
6619
6996
  // iterate over a copy of the array since .dispose() mutates the original array
6620
6997
  for (const group of [...this._popoutGroups]) {
6621
- group.dispose();
6998
+ group.disposable.dispose();
6622
6999
  }
6623
7000
  }));
6624
7001
  this._options = options;
@@ -6664,7 +7041,7 @@
6664
7041
  return this.options.showDndOverlay({
6665
7042
  nativeEvent: event,
6666
7043
  position: position,
6667
- target: exports.DockviewDropTargets.Edge,
7044
+ target: 'edge',
6668
7045
  getData: getPanelData,
6669
7046
  });
6670
7047
  }
@@ -6675,86 +7052,249 @@
6675
7052
  });
6676
7053
  this.addDisposables(this._rootDropTarget.onDrop((event) => {
6677
7054
  var _a;
7055
+ const willDropEvent = new DockviewWillDropEvent({
7056
+ nativeEvent: event.nativeEvent,
7057
+ position: event.position,
7058
+ panel: undefined,
7059
+ api: this._api,
7060
+ group: undefined,
7061
+ getData: getPanelData,
7062
+ kind: 'content',
7063
+ });
7064
+ this._onWillDrop.fire(willDropEvent);
7065
+ if (willDropEvent.defaultPrevented) {
7066
+ return;
7067
+ }
6678
7068
  const data = getPanelData();
6679
7069
  if (data) {
6680
- this.moveGroupOrPanel(this.orthogonalize(event.position), data.groupId, (_a = data.panelId) !== null && _a !== void 0 ? _a : undefined, 'center');
7070
+ this.moveGroupOrPanel({
7071
+ from: {
7072
+ groupId: data.groupId,
7073
+ panelId: (_a = data.panelId) !== null && _a !== void 0 ? _a : undefined,
7074
+ },
7075
+ to: {
7076
+ group: this.orthogonalize(event.position),
7077
+ position: 'center',
7078
+ },
7079
+ });
6681
7080
  }
6682
7081
  else {
6683
- this._onDidDrop.fire(Object.assign(Object.assign({}, event), { api: this._api, group: null, getData: getPanelData }));
7082
+ this._onDidDrop.fire(new DockviewDidDropEvent({
7083
+ nativeEvent: event.nativeEvent,
7084
+ position: event.position,
7085
+ panel: undefined,
7086
+ api: this._api,
7087
+ group: undefined,
7088
+ getData: getPanelData,
7089
+ }));
6684
7090
  }
6685
7091
  }), this._rootDropTarget);
6686
7092
  this._api = new DockviewApi(this);
6687
7093
  this.updateWatermark();
6688
7094
  }
6689
- addPopoutGroup(item, options) {
6690
- var _a;
6691
- let group;
6692
- let box = options === null || options === void 0 ? void 0 : options.position;
6693
- if (item instanceof DockviewPanel) {
6694
- group = this.createGroup();
6695
- this.removePanel(item, {
6696
- removeEmptyGroup: true,
6697
- skipDispose: true,
6698
- });
6699
- group.model.openPanel(item);
6700
- if (!box) {
6701
- box = this.element.getBoundingClientRect();
7095
+ addPopoutGroup(itemToPopout, options) {
7096
+ var _a, _b, _c;
7097
+ if (itemToPopout instanceof DockviewPanel &&
7098
+ itemToPopout.group.size === 1) {
7099
+ return this.addPopoutGroup(itemToPopout.group);
7100
+ }
7101
+ const theme = getDockviewTheme(this.gridview.element);
7102
+ const element = this.element;
7103
+ function getBox() {
7104
+ if (options === null || options === void 0 ? void 0 : options.position) {
7105
+ return options.position;
7106
+ }
7107
+ if (itemToPopout instanceof DockviewGroupPanel) {
7108
+ return itemToPopout.element.getBoundingClientRect();
7109
+ }
7110
+ if (itemToPopout.group) {
7111
+ return itemToPopout.group.element.getBoundingClientRect();
7112
+ }
7113
+ return element.getBoundingClientRect();
7114
+ }
7115
+ const box = getBox();
7116
+ 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;
7117
+ if (itemToPopout.api.location.type === 'grid') {
7118
+ itemToPopout.api.setHidden(true);
7119
+ }
7120
+ const _window = new PopoutWindow(`${this.id}-${groupId}`, // unique id
7121
+ theme !== null && theme !== void 0 ? theme : '', {
7122
+ url: (_c = options === null || options === void 0 ? void 0 : options.popoutUrl) !== null && _c !== void 0 ? _c : '/popout.html',
7123
+ left: window.screenX + box.left,
7124
+ top: window.screenY + box.top,
7125
+ width: box.width,
7126
+ height: box.height,
7127
+ onDidOpen: options === null || options === void 0 ? void 0 : options.onDidOpen,
7128
+ onWillClose: options === null || options === void 0 ? void 0 : options.onWillClose,
7129
+ });
7130
+ const popoutWindowDisposable = new CompositeDisposable(_window, _window.onDidClose(() => {
7131
+ popoutWindowDisposable.dispose();
7132
+ }));
7133
+ return _window
7134
+ .open()
7135
+ .then((popoutContainer) => {
7136
+ var _a;
7137
+ if (_window.isDisposed) {
7138
+ return;
6702
7139
  }
6703
- }
6704
- else {
6705
- group = item;
6706
- if (!box) {
6707
- box = group.element.getBoundingClientRect();
7140
+ if (popoutContainer === null) {
7141
+ popoutWindowDisposable.dispose();
7142
+ return;
6708
7143
  }
6709
- const skip = typeof (options === null || options === void 0 ? void 0 : options.skipRemoveGroup) === 'boolean' &&
6710
- options.skipRemoveGroup;
6711
- if (!skip) {
6712
- this.doRemoveGroup(item, { skipDispose: true });
6713
- }
6714
- }
6715
- const theme = getTheme(this.gridview.element);
6716
- const popoutWindow = new DockviewPopoutGroupPanel(`${this.id}-${group.id}`, // globally unique within dockview
6717
- group, {
6718
- className: theme !== null && theme !== void 0 ? theme : '',
6719
- popoutUrl: (_a = options === null || options === void 0 ? void 0 : options.popoutUrl) !== null && _a !== void 0 ? _a : '/popout.html',
6720
- box: {
6721
- left: window.screenX + box.left,
6722
- top: window.screenY + box.top,
6723
- width: box.width,
6724
- height: box.height,
6725
- },
7144
+ const gready = document.createElement('div');
7145
+ gready.className = 'dv-overlay-render-container';
7146
+ const overlayRenderContainer = new OverlayRenderContainer(gready);
7147
+ const referenceGroup = itemToPopout instanceof DockviewPanel
7148
+ ? itemToPopout.group
7149
+ : itemToPopout;
7150
+ const referenceLocation = itemToPopout.api.location.type;
7151
+ const group = (_a = options === null || options === void 0 ? void 0 : options.overridePopoutGroup) !== null && _a !== void 0 ? _a : this.createGroup({ id: groupId });
7152
+ group.model.renderContainer = overlayRenderContainer;
7153
+ if (!(options === null || options === void 0 ? void 0 : options.overridePopoutGroup)) {
7154
+ this._onDidAddGroup.fire(group);
7155
+ }
7156
+ if (itemToPopout instanceof DockviewPanel) {
7157
+ this.movingLock(() => {
7158
+ const panel = referenceGroup.model.removePanel(itemToPopout);
7159
+ group.model.openPanel(panel);
7160
+ });
7161
+ }
7162
+ else {
7163
+ this.movingLock(() => moveGroupWithoutDestroying({
7164
+ from: referenceGroup,
7165
+ to: group,
7166
+ }));
7167
+ switch (referenceLocation) {
7168
+ case 'grid':
7169
+ referenceGroup.api.setHidden(true);
7170
+ break;
7171
+ case 'floating':
7172
+ case 'popout':
7173
+ this.removeGroup(referenceGroup);
7174
+ break;
7175
+ }
7176
+ }
7177
+ popoutContainer.classList.add('dv-dockview');
7178
+ popoutContainer.style.overflow = 'hidden';
7179
+ popoutContainer.appendChild(gready);
7180
+ popoutContainer.appendChild(group.element);
7181
+ group.model.location = {
7182
+ type: 'popout',
7183
+ getWindow: () => _window.window,
7184
+ };
7185
+ this.doSetGroupAndPanelActive(group);
7186
+ popoutWindowDisposable.addDisposables(group.api.onDidActiveChange((event) => {
7187
+ var _a;
7188
+ if (event.isActive) {
7189
+ (_a = _window.window) === null || _a === void 0 ? void 0 : _a.focus();
7190
+ }
7191
+ }), group.api.onWillFocus(() => {
7192
+ var _a;
7193
+ (_a = _window.window) === null || _a === void 0 ? void 0 : _a.focus();
7194
+ }));
7195
+ let returnedGroup;
7196
+ const value = {
7197
+ window: _window,
7198
+ popoutGroup: group,
7199
+ referenceGroup: this.getPanel(referenceGroup.id)
7200
+ ? referenceGroup.id
7201
+ : undefined,
7202
+ disposable: {
7203
+ dispose: () => {
7204
+ popoutWindowDisposable.dispose();
7205
+ return returnedGroup;
7206
+ },
7207
+ },
7208
+ };
7209
+ popoutWindowDisposable.addDisposables(
7210
+ /**
7211
+ * ResizeObserver seems slow here, I do not know why but we don't need it
7212
+ * since we can reply on the window resize event as we will occupy the full
7213
+ * window dimensions
7214
+ */
7215
+ addDisposableWindowListener(_window.window, 'resize', () => {
7216
+ group.layout(window.innerWidth, window.innerHeight);
7217
+ }), overlayRenderContainer, Disposable.from(() => {
7218
+ if (this.getPanel(referenceGroup.id)) {
7219
+ this.movingLock(() => moveGroupWithoutDestroying({
7220
+ from: group,
7221
+ to: referenceGroup,
7222
+ }));
7223
+ if (referenceGroup.api.isHidden) {
7224
+ referenceGroup.api.setHidden(false);
7225
+ }
7226
+ if (this.getPanel(group.id)) {
7227
+ this.doRemoveGroup(group, {
7228
+ skipPopoutAssociated: true,
7229
+ });
7230
+ }
7231
+ }
7232
+ else {
7233
+ if (this.getPanel(group.id)) {
7234
+ const removedGroup = this.doRemoveGroup(group, {
7235
+ skipDispose: true,
7236
+ skipActive: true,
7237
+ });
7238
+ removedGroup.model.renderContainer =
7239
+ this.overlayRenderContainer;
7240
+ removedGroup.model.location = { type: 'grid' };
7241
+ returnedGroup = removedGroup;
7242
+ }
7243
+ }
7244
+ }));
7245
+ this._popoutGroups.push(value);
7246
+ this.updateWatermark();
7247
+ })
7248
+ .catch((err) => {
7249
+ console.error(err);
6726
7250
  });
6727
- popoutWindow.addDisposables({
6728
- dispose: () => {
6729
- remove(this._popoutGroups, popoutWindow);
6730
- this.updateWatermark();
6731
- },
6732
- }, popoutWindow.window.onDidClose(() => {
6733
- this.doAddGroup(group, [0]);
6734
- }));
6735
- this._popoutGroups.push(popoutWindow);
6736
- this.updateWatermark();
6737
7251
  }
6738
7252
  addFloatingGroup(item, coord, options) {
6739
- var _a, _b, _c, _d, _e, _f;
7253
+ var _a, _b, _c, _d, _e, _f, _g;
6740
7254
  let group;
6741
7255
  if (item instanceof DockviewPanel) {
6742
7256
  group = this.createGroup();
6743
- this.removePanel(item, {
7257
+ this._onDidAddGroup.fire(group);
7258
+ this.movingLock(() => this.removePanel(item, {
6744
7259
  removeEmptyGroup: true,
6745
7260
  skipDispose: true,
6746
- });
6747
- group.model.openPanel(item);
7261
+ skipSetActiveGroup: true,
7262
+ }));
7263
+ group.model.openPanel(item, { skipSetGroupActive: true });
6748
7264
  }
6749
7265
  else {
6750
7266
  group = item;
7267
+ const popoutReferenceGroupId = (_a = this._popoutGroups.find((_) => _.popoutGroup === group)) === null || _a === void 0 ? void 0 : _a.referenceGroup;
7268
+ const popoutReferenceGroup = popoutReferenceGroupId
7269
+ ? this.getPanel(popoutReferenceGroupId)
7270
+ : undefined;
6751
7271
  const skip = typeof (options === null || options === void 0 ? void 0 : options.skipRemoveGroup) === 'boolean' &&
6752
7272
  options.skipRemoveGroup;
6753
7273
  if (!skip) {
6754
- this.doRemoveGroup(item, { skipDispose: true });
7274
+ if (popoutReferenceGroup) {
7275
+ this.movingLock(() => moveGroupWithoutDestroying({
7276
+ from: item,
7277
+ to: popoutReferenceGroup,
7278
+ }));
7279
+ this.doRemoveGroup(item, {
7280
+ skipPopoutReturn: true,
7281
+ skipPopoutAssociated: true,
7282
+ });
7283
+ this.doRemoveGroup(popoutReferenceGroup, {
7284
+ skipDispose: true,
7285
+ });
7286
+ group = popoutReferenceGroup;
7287
+ }
7288
+ else {
7289
+ this.doRemoveGroup(item, {
7290
+ skipDispose: true,
7291
+ skipPopoutReturn: true,
7292
+ skipPopoutAssociated: !!popoutReferenceGroup,
7293
+ });
7294
+ }
6755
7295
  }
6756
7296
  }
6757
- group.model.location = 'floating';
7297
+ group.model.location = { type: 'floating' };
6758
7298
  const overlayLeft = typeof (coord === null || coord === void 0 ? void 0 : coord.x) === 'number'
6759
7299
  ? Math.max(coord.x, 0)
6760
7300
  : DEFAULT_FLOATING_GROUP_POSITION.left;
@@ -6764,16 +7304,16 @@
6764
7304
  const overlay = new Overlay({
6765
7305
  container: this.gridview.element,
6766
7306
  content: group.element,
6767
- height: (_a = coord === null || coord === void 0 ? void 0 : coord.height) !== null && _a !== void 0 ? _a : 300,
6768
- width: (_b = coord === null || coord === void 0 ? void 0 : coord.width) !== null && _b !== void 0 ? _b : 300,
7307
+ height: (_b = coord === null || coord === void 0 ? void 0 : coord.height) !== null && _b !== void 0 ? _b : 300,
7308
+ width: (_c = coord === null || coord === void 0 ? void 0 : coord.width) !== null && _c !== void 0 ? _c : 300,
6769
7309
  left: overlayLeft,
6770
7310
  top: overlayTop,
6771
7311
  minimumInViewportWidth: this.options.floatingGroupBounds === 'boundedWithinViewport'
6772
7312
  ? undefined
6773
- : (_d = (_c = this.options.floatingGroupBounds) === null || _c === void 0 ? void 0 : _c.minimumWidthWithinViewport) !== null && _d !== void 0 ? _d : DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE,
7313
+ : (_e = (_d = this.options.floatingGroupBounds) === null || _d === void 0 ? void 0 : _d.minimumWidthWithinViewport) !== null && _e !== void 0 ? _e : DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE,
6774
7314
  minimumInViewportHeight: this.options.floatingGroupBounds === 'boundedWithinViewport'
6775
7315
  ? undefined
6776
- : (_f = (_e = this.options.floatingGroupBounds) === null || _e === void 0 ? void 0 : _e.minimumHeightWithinViewport) !== null && _f !== void 0 ? _f : DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE,
7316
+ : (_g = (_f = this.options.floatingGroupBounds) === null || _f === void 0 ? void 0 : _f.minimumHeightWithinViewport) !== null && _g !== void 0 ? _g : DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE,
6777
7317
  });
6778
7318
  const el = group.element.querySelector('.void-container');
6779
7319
  if (!el) {
@@ -6804,12 +7344,15 @@
6804
7344
  }), {
6805
7345
  dispose: () => {
6806
7346
  disposable.dispose();
6807
- group.model.location = 'grid';
7347
+ group.model.location = { type: 'grid' };
6808
7348
  remove(this._floatingGroups, floatingGroupPanel);
6809
7349
  this.updateWatermark();
6810
7350
  },
6811
7351
  });
6812
7352
  this._floatingGroups.push(floatingGroupPanel);
7353
+ if (!(options === null || options === void 0 ? void 0 : options.skipActiveGroup)) {
7354
+ this.doSetGroupAndPanelActive(group);
7355
+ }
6813
7356
  this.updateWatermark();
6814
7357
  }
6815
7358
  orthogonalize(position) {
@@ -6899,8 +7442,8 @@
6899
7442
  return this.panels.find((panel) => panel.id === id);
6900
7443
  }
6901
7444
  setActivePanel(panel) {
6902
- this.doSetGroupActive(panel.group);
6903
7445
  panel.group.model.openPanel(panel);
7446
+ this.doSetGroupAndPanelActive(panel.group);
6904
7447
  }
6905
7448
  moveToNext(options = {}) {
6906
7449
  var _a;
@@ -6961,7 +7504,8 @@
6961
7504
  });
6962
7505
  const popoutGroups = this._popoutGroups.map((group) => {
6963
7506
  return {
6964
- data: group.group.toJSON(),
7507
+ data: group.popoutGroup.toJSON(),
7508
+ gridReferenceGroup: group.referenceGroup,
6965
7509
  position: group.window.dimensions(),
6966
7510
  };
6967
7511
  });
@@ -6979,7 +7523,7 @@
6979
7523
  return result;
6980
7524
  }
6981
7525
  fromJSON(data) {
6982
- var _a, _b;
7526
+ var _a, _b, _c;
6983
7527
  this.clear();
6984
7528
  if (typeof data !== 'object' || data === null) {
6985
7529
  throw new Error('serialized layout must be a non-null object');
@@ -7018,7 +7562,7 @@
7018
7562
  const isActive = typeof activeView === 'string' &&
7019
7563
  activeView === panel.id;
7020
7564
  group.model.openPanel(panel, {
7021
- skipSetPanelActive: !isActive,
7565
+ skipSetActive: !isActive,
7022
7566
  skipSetGroupActive: true,
7023
7567
  });
7024
7568
  }
@@ -7048,11 +7592,16 @@
7048
7592
  }
7049
7593
  const serializedPopoutGroups = (_b = data.popoutGroups) !== null && _b !== void 0 ? _b : [];
7050
7594
  for (const serializedPopoutGroup of serializedPopoutGroups) {
7051
- const { data, position } = serializedPopoutGroup;
7595
+ const { data, position, gridReferenceGroup } = serializedPopoutGroup;
7052
7596
  const group = createGroupFromSerializedState(data);
7053
- this.addPopoutGroup(group, {
7597
+ this.addPopoutGroup((_c = (gridReferenceGroup
7598
+ ? this.getPanel(gridReferenceGroup)
7599
+ : undefined)) !== null && _c !== void 0 ? _c : group, {
7054
7600
  skipRemoveGroup: true,
7055
7601
  position: position !== null && position !== void 0 ? position : undefined,
7602
+ overridePopoutGroup: gridReferenceGroup
7603
+ ? group
7604
+ : undefined,
7056
7605
  });
7057
7606
  }
7058
7607
  for (const floatingGroup of this._floatingGroups) {
@@ -7099,12 +7648,13 @@
7099
7648
  */
7100
7649
  throw err;
7101
7650
  }
7651
+ this.updateWatermark();
7102
7652
  this._onDidLayoutFromJSON.fire();
7103
7653
  }
7104
7654
  clear() {
7105
7655
  const groups = Array.from(this._groups.values()).map((_) => _.value);
7106
7656
  const hasActiveGroup = !!this.activeGroup;
7107
- const hasActivePanel = !!this.activePanel;
7657
+ !!this.activePanel;
7108
7658
  for (const group of groups) {
7109
7659
  // remove the group will automatically remove the panels
7110
7660
  this.removeGroup(group, { skipActive: true });
@@ -7112,9 +7662,6 @@
7112
7662
  if (hasActiveGroup) {
7113
7663
  this.doSetGroupAndPanelActive(undefined);
7114
7664
  }
7115
- if (hasActivePanel) {
7116
- this._onDidActivePanelChange.fire(undefined);
7117
- }
7118
7665
  this.gridview.clear();
7119
7666
  }
7120
7667
  closeAllGroups() {
@@ -7155,6 +7702,7 @@
7155
7702
  const group = this.orthogonalize(directionToPosition(options.position.direction));
7156
7703
  const panel = this.createPanel(options, group);
7157
7704
  group.model.openPanel(panel);
7705
+ this.doSetGroupAndPanelActive(group);
7158
7706
  return panel;
7159
7707
  }
7160
7708
  }
@@ -7166,6 +7714,7 @@
7166
7714
  const target = toTarget(((_b = options.position) === null || _b === void 0 ? void 0 : _b.direction) || 'within');
7167
7715
  if (options.floating) {
7168
7716
  const group = this.createGroup();
7717
+ this._onDidAddGroup.fire(group);
7169
7718
  const o = typeof options.floating === 'object' &&
7170
7719
  options.floating !== null
7171
7720
  ? options.floating
@@ -7173,16 +7722,16 @@
7173
7722
  this.addFloatingGroup(group, o, {
7174
7723
  inDragMode: false,
7175
7724
  skipRemoveGroup: true,
7725
+ skipActiveGroup: true,
7176
7726
  });
7177
- this._onDidAddGroup.fire(group);
7178
7727
  panel = this.createPanel(options, group);
7179
7728
  group.model.openPanel(panel);
7180
- this.doSetGroupAndPanelActive(group);
7181
7729
  }
7182
- else if (referenceGroup.api.location === 'floating' ||
7730
+ else if (referenceGroup.api.location.type === 'floating' ||
7183
7731
  target === 'center') {
7184
7732
  panel = this.createPanel(options, referenceGroup);
7185
7733
  referenceGroup.model.openPanel(panel);
7734
+ this.doSetGroupAndPanelActive(referenceGroup);
7186
7735
  }
7187
7736
  else {
7188
7737
  const location = getGridLocation(referenceGroup.element);
@@ -7190,10 +7739,12 @@
7190
7739
  const group = this.createGroupAtLocation(relativeLocation);
7191
7740
  panel = this.createPanel(options, group);
7192
7741
  group.model.openPanel(panel);
7742
+ this.doSetGroupAndPanelActive(group);
7193
7743
  }
7194
7744
  }
7195
7745
  else if (options.floating) {
7196
7746
  const group = this.createGroup();
7747
+ this._onDidAddGroup.fire(group);
7197
7748
  const o = typeof options.floating === 'object' &&
7198
7749
  options.floating !== null
7199
7750
  ? options.floating
@@ -7201,16 +7752,16 @@
7201
7752
  this.addFloatingGroup(group, o, {
7202
7753
  inDragMode: false,
7203
7754
  skipRemoveGroup: true,
7755
+ skipActiveGroup: true,
7204
7756
  });
7205
- this._onDidAddGroup.fire(group);
7206
7757
  panel = this.createPanel(options, group);
7207
7758
  group.model.openPanel(panel);
7208
- this.doSetGroupAndPanelActive(group);
7209
7759
  }
7210
7760
  else {
7211
7761
  const group = this.createGroupAtLocation();
7212
7762
  panel = this.createPanel(options, group);
7213
7763
  group.model.openPanel(panel);
7764
+ this.doSetGroupAndPanelActive(group);
7214
7765
  }
7215
7766
  return panel;
7216
7767
  }
@@ -7222,13 +7773,15 @@
7222
7773
  if (!group) {
7223
7774
  throw new Error(`cannot remove panel ${panel.id}. it's missing a group.`);
7224
7775
  }
7225
- group.model.removePanel(panel);
7776
+ group.model.removePanel(panel, {
7777
+ skipSetActiveGroup: options.skipSetActiveGroup,
7778
+ });
7226
7779
  if (!options.skipDispose) {
7227
- this.overlayRenderContainer.detatch(panel);
7780
+ panel.group.model.renderContainer.detatch(panel);
7228
7781
  panel.dispose();
7229
7782
  }
7230
7783
  if (group.size === 0 && options.removeEmptyGroup) {
7231
- this.removeGroup(group);
7784
+ this.removeGroup(group, { skipActive: options.skipSetActiveGroup });
7232
7785
  }
7233
7786
  }
7234
7787
  createWatermarkComponent() {
@@ -7241,7 +7794,7 @@
7241
7794
  }
7242
7795
  updateWatermark() {
7243
7796
  var _a, _b;
7244
- if (this.groups.filter((x) => x.api.location === 'grid').length === 0) {
7797
+ if (this.groups.filter((x) => x.api.location.type === 'grid' && !x.api.isHidden).length === 0) {
7245
7798
  if (!this.watermark) {
7246
7799
  this.watermark = this.createWatermarkComponent();
7247
7800
  this.watermark.init({
@@ -7261,7 +7814,7 @@
7261
7814
  }
7262
7815
  addGroup(options) {
7263
7816
  var _a;
7264
- const group = this.createGroup();
7817
+ const group = this.createGroup(options);
7265
7818
  if (options) {
7266
7819
  let referenceGroup;
7267
7820
  if (isGroupOptionsWithPanel(options)) {
@@ -7287,36 +7840,42 @@
7287
7840
  }
7288
7841
  else {
7289
7842
  const group = this.orthogonalize(directionToPosition(options.direction));
7843
+ if (!options.skipSetActive) {
7844
+ this.doSetGroupAndPanelActive(group);
7845
+ }
7290
7846
  return group;
7291
7847
  }
7292
7848
  const target = toTarget(options.direction || 'within');
7293
7849
  const location = getGridLocation(referenceGroup.element);
7294
7850
  const relativeLocation = getRelativeLocation(this.gridview.orientation, location, target);
7295
7851
  this.doAddGroup(group, relativeLocation);
7852
+ if (!options.skipSetActive) {
7853
+ this.doSetGroupAndPanelActive(group);
7854
+ }
7296
7855
  return group;
7297
7856
  }
7298
7857
  else {
7299
7858
  this.doAddGroup(group);
7859
+ this.doSetGroupAndPanelActive(group);
7300
7860
  return group;
7301
7861
  }
7302
7862
  }
7303
7863
  removeGroup(group, options) {
7864
+ this.doRemoveGroup(group, options);
7865
+ }
7866
+ doRemoveGroup(group, options) {
7304
7867
  var _a;
7305
7868
  const panels = [...group.panels]; // reassign since group panels will mutate
7306
- for (const panel of panels) {
7307
- this.removePanel(panel, {
7308
- removeEmptyGroup: false,
7309
- skipDispose: (_a = options === null || options === void 0 ? void 0 : options.skipDispose) !== null && _a !== void 0 ? _a : false,
7310
- });
7869
+ if (!(options === null || options === void 0 ? void 0 : options.skipDispose)) {
7870
+ for (const panel of panels) {
7871
+ this.removePanel(panel, {
7872
+ removeEmptyGroup: false,
7873
+ skipDispose: (_a = options === null || options === void 0 ? void 0 : options.skipDispose) !== null && _a !== void 0 ? _a : false,
7874
+ });
7875
+ }
7311
7876
  }
7312
7877
  const activePanel = this.activePanel;
7313
- this.doRemoveGroup(group, options);
7314
- if (this.activePanel !== activePanel) {
7315
- this._onDidActivePanelChange.fire(this.activePanel);
7316
- }
7317
- }
7318
- doRemoveGroup(group, options) {
7319
- if (group.api.location === 'floating') {
7878
+ if (group.api.location.type === 'floating') {
7320
7879
  const floatingGroup = this._floatingGroups.find((_) => _.group === group);
7321
7880
  if (floatingGroup) {
7322
7881
  if (!(options === null || options === void 0 ? void 0 : options.skipDispose)) {
@@ -7328,60 +7887,124 @@
7328
7887
  floatingGroup.dispose();
7329
7888
  if (!(options === null || options === void 0 ? void 0 : options.skipActive) && this._activeGroup === group) {
7330
7889
  const groups = Array.from(this._groups.values());
7331
- this.doSetGroupActive(groups.length > 0 ? groups[0].value : undefined);
7890
+ this.doSetGroupAndPanelActive(groups.length > 0 ? groups[0].value : undefined);
7332
7891
  }
7333
7892
  return floatingGroup.group;
7334
7893
  }
7335
7894
  throw new Error('failed to find floating group');
7336
7895
  }
7337
- if (group.api.location === 'popout') {
7338
- const selectedGroup = this._popoutGroups.find((_) => _.group === group);
7896
+ if (group.api.location.type === 'popout') {
7897
+ const selectedGroup = this._popoutGroups.find((_) => _.popoutGroup === group);
7339
7898
  if (selectedGroup) {
7340
7899
  if (!(options === null || options === void 0 ? void 0 : options.skipDispose)) {
7341
- selectedGroup.group.dispose();
7900
+ if (!(options === null || options === void 0 ? void 0 : options.skipPopoutAssociated)) {
7901
+ const refGroup = selectedGroup.referenceGroup
7902
+ ? this.getPanel(selectedGroup.referenceGroup)
7903
+ : undefined;
7904
+ if (refGroup) {
7905
+ this.removeGroup(refGroup);
7906
+ }
7907
+ }
7908
+ selectedGroup.popoutGroup.dispose();
7342
7909
  this._groups.delete(group.id);
7343
7910
  this._onDidRemoveGroup.fire(group);
7344
7911
  }
7345
- selectedGroup.dispose();
7912
+ const removedGroup = selectedGroup.disposable.dispose();
7913
+ if (!(options === null || options === void 0 ? void 0 : options.skipPopoutReturn) && removedGroup) {
7914
+ this.doAddGroup(removedGroup, [0]);
7915
+ this.doSetGroupAndPanelActive(removedGroup);
7916
+ }
7346
7917
  if (!(options === null || options === void 0 ? void 0 : options.skipActive) && this._activeGroup === group) {
7347
7918
  const groups = Array.from(this._groups.values());
7348
- this.doSetGroupActive(groups.length > 0 ? groups[0].value : undefined);
7919
+ this.doSetGroupAndPanelActive(groups.length > 0 ? groups[0].value : undefined);
7349
7920
  }
7350
- return selectedGroup.group;
7921
+ this.updateWatermark();
7922
+ return selectedGroup.popoutGroup;
7351
7923
  }
7352
7924
  throw new Error('failed to find popout group');
7353
7925
  }
7354
- return super.doRemoveGroup(group, options);
7926
+ const re = super.doRemoveGroup(group, options);
7927
+ if (!(options === null || options === void 0 ? void 0 : options.skipActive)) {
7928
+ if (this.activePanel !== activePanel) {
7929
+ this._onDidActivePanelChange.fire(this.activePanel);
7930
+ }
7931
+ }
7932
+ return re;
7355
7933
  }
7356
- moveGroupOrPanel(destinationGroup, sourceGroupId, sourceItemId, destinationTarget, destinationIndex) {
7357
- var _a, _b, _c;
7934
+ movingLock(func) {
7935
+ const isMoving = this._moving;
7936
+ try {
7937
+ this._moving = true;
7938
+ return func();
7939
+ }
7940
+ finally {
7941
+ this._moving = isMoving;
7942
+ }
7943
+ }
7944
+ moveGroupOrPanel(options) {
7945
+ var _a;
7946
+ const destinationGroup = options.to.group;
7947
+ const sourceGroupId = options.from.groupId;
7948
+ const sourceItemId = options.from.panelId;
7949
+ const destinationTarget = options.to.position;
7950
+ const destinationIndex = options.to.index;
7358
7951
  const sourceGroup = sourceGroupId
7359
7952
  ? (_a = this._groups.get(sourceGroupId)) === null || _a === void 0 ? void 0 : _a.value
7360
7953
  : undefined;
7954
+ if (!sourceGroup) {
7955
+ throw new Error(`Failed to find group id ${sourceGroupId}`);
7956
+ }
7361
7957
  if (sourceItemId === undefined) {
7362
- if (sourceGroup) {
7363
- this.moveGroup(sourceGroup, destinationGroup, destinationTarget);
7364
- }
7958
+ /**
7959
+ * Moving an entire group into another group
7960
+ */
7961
+ this.moveGroup({
7962
+ from: { group: sourceGroup },
7963
+ to: {
7964
+ group: destinationGroup,
7965
+ position: destinationTarget,
7966
+ },
7967
+ });
7365
7968
  return;
7366
7969
  }
7367
7970
  if (!destinationTarget || destinationTarget === 'center') {
7368
- 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);
7369
- if (!groupItem) {
7971
+ /**
7972
+ * Dropping a panel within another group
7973
+ */
7974
+ const removedPanel = this.movingLock(() => sourceGroup.model.removePanel(sourceItemId, {
7975
+ skipSetActive: false,
7976
+ skipSetActiveGroup: true,
7977
+ }));
7978
+ if (!removedPanel) {
7370
7979
  throw new Error(`No panel with id ${sourceItemId}`);
7371
7980
  }
7372
- if ((sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.size) === 0) {
7373
- this.doRemoveGroup(sourceGroup);
7981
+ if (sourceGroup.model.size === 0) {
7982
+ // remove the group and do not set a new group as active
7983
+ this.doRemoveGroup(sourceGroup, { skipActive: true });
7374
7984
  }
7375
- destinationGroup.model.openPanel(groupItem, {
7985
+ this.movingLock(() => destinationGroup.model.openPanel(removedPanel, {
7376
7986
  index: destinationIndex,
7987
+ skipSetGroupActive: true,
7988
+ }));
7989
+ this.doSetGroupAndPanelActive(destinationGroup);
7990
+ this._onDidMovePanel.fire({
7991
+ panel: removedPanel,
7377
7992
  });
7378
7993
  }
7379
7994
  else {
7995
+ /**
7996
+ * Dropping a panel to the extremities of a group which will place that panel
7997
+ * into an adjacent group
7998
+ */
7380
7999
  const referenceLocation = getGridLocation(destinationGroup.element);
7381
8000
  const targetLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, destinationTarget);
7382
- if (sourceGroup && sourceGroup.size < 2) {
8001
+ if (sourceGroup.size < 2) {
8002
+ /**
8003
+ * If we are moving from a group which only has one panel left we will consider
8004
+ * moving the group itself rather than moving the panel into a newly created group
8005
+ */
7383
8006
  const [targetParentLocation, to] = tail(targetLocation);
7384
- if (sourceGroup.api.location === 'grid') {
8007
+ if (sourceGroup.api.location.type === 'grid') {
7385
8008
  const sourceLocation = getGridLocation(sourceGroup.element);
7386
8009
  const [sourceParentLocation, from] = tail(sourceLocation);
7387
8010
  if (sequenceEquals(sourceParentLocation, targetParentLocation)) {
@@ -7389,78 +8012,123 @@
7389
8012
  // if a group has one tab - we are essentially moving the 'group'
7390
8013
  // which is equivalent to swapping two views in this case
7391
8014
  this.gridview.moveView(sourceParentLocation, from, to);
8015
+ return;
7392
8016
  }
7393
8017
  }
7394
8018
  // source group will become empty so delete the group
7395
- const targetGroup = this.doRemoveGroup(sourceGroup, {
8019
+ const targetGroup = this.movingLock(() => this.doRemoveGroup(sourceGroup, {
7396
8020
  skipActive: true,
7397
8021
  skipDispose: true,
7398
- });
8022
+ }));
7399
8023
  // after deleting the group we need to re-evaulate the ref location
7400
8024
  const updatedReferenceLocation = getGridLocation(destinationGroup.element);
7401
8025
  const location = getRelativeLocation(this.gridview.orientation, updatedReferenceLocation, destinationTarget);
7402
- this.doAddGroup(targetGroup, location);
8026
+ this.movingLock(() => this.doAddGroup(targetGroup, location));
8027
+ this.doSetGroupAndPanelActive(targetGroup);
7403
8028
  }
7404
8029
  else {
7405
- 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);
7406
- if (!groupItem) {
8030
+ /**
8031
+ * The group we are removing from has many panels, we need to remove the panels we are moving,
8032
+ * create a new group, add the panels to that new group and add the new group in an appropiate position
8033
+ */
8034
+ const removedPanel = this.movingLock(() => sourceGroup.model.removePanel(sourceItemId, {
8035
+ skipSetActive: false,
8036
+ skipSetActiveGroup: true,
8037
+ }));
8038
+ if (!removedPanel) {
7407
8039
  throw new Error(`No panel with id ${sourceItemId}`);
7408
8040
  }
7409
8041
  const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, destinationTarget);
7410
8042
  const group = this.createGroupAtLocation(dropLocation);
7411
- group.model.openPanel(groupItem);
8043
+ this.movingLock(() => group.model.openPanel(removedPanel, {
8044
+ skipSetGroupActive: true,
8045
+ }));
8046
+ this.doSetGroupAndPanelActive(group);
7412
8047
  }
7413
8048
  }
7414
8049
  }
7415
- moveGroup(sourceGroup, referenceGroup, target) {
7416
- if (sourceGroup) {
7417
- if (!target || target === 'center') {
7418
- const activePanel = sourceGroup.activePanel;
7419
- const panels = [...sourceGroup.panels].map((p) => sourceGroup.model.removePanel(p.id));
7420
- if ((sourceGroup === null || sourceGroup === void 0 ? void 0 : sourceGroup.model.size) === 0) {
7421
- this.doRemoveGroup(sourceGroup);
7422
- }
8050
+ moveGroup(options) {
8051
+ const from = options.from.group;
8052
+ const to = options.to.group;
8053
+ const target = options.to.position;
8054
+ if (target === 'center') {
8055
+ const activePanel = from.activePanel;
8056
+ const panels = this.movingLock(() => [...from.panels].map((p) => from.model.removePanel(p.id, {
8057
+ skipSetActive: true,
8058
+ })));
8059
+ if ((from === null || from === void 0 ? void 0 : from.model.size) === 0) {
8060
+ this.doRemoveGroup(from, { skipActive: true });
8061
+ }
8062
+ this.movingLock(() => {
7423
8063
  for (const panel of panels) {
7424
- referenceGroup.model.openPanel(panel, {
7425
- skipSetPanelActive: panel !== activePanel,
8064
+ to.model.openPanel(panel, {
8065
+ skipSetActive: panel !== activePanel,
8066
+ skipSetGroupActive: true,
7426
8067
  });
7427
8068
  }
7428
- }
7429
- else {
7430
- switch (sourceGroup.api.location) {
7431
- case 'grid':
7432
- this.gridview.removeView(getGridLocation(sourceGroup.element));
7433
- break;
7434
- case 'floating': {
7435
- const selectedFloatingGroup = this._floatingGroups.find((x) => x.group === sourceGroup);
7436
- if (!selectedFloatingGroup) {
7437
- throw new Error('failed to find floating group');
7438
- }
7439
- selectedFloatingGroup.dispose();
7440
- break;
8069
+ });
8070
+ this.doSetGroupAndPanelActive(to);
8071
+ panels.forEach((panel) => {
8072
+ this._onDidMovePanel.fire({ panel });
8073
+ });
8074
+ }
8075
+ else {
8076
+ switch (from.api.location.type) {
8077
+ case 'grid':
8078
+ this.gridview.removeView(getGridLocation(from.element));
8079
+ break;
8080
+ case 'floating': {
8081
+ const selectedFloatingGroup = this._floatingGroups.find((x) => x.group === from);
8082
+ if (!selectedFloatingGroup) {
8083
+ throw new Error('failed to find floating group');
7441
8084
  }
7442
- case 'popout': {
7443
- const selectedPopoutGroup = this._popoutGroups.find((x) => x.group === sourceGroup);
7444
- if (!selectedPopoutGroup) {
7445
- throw new Error('failed to find popout group');
7446
- }
7447
- selectedPopoutGroup.dispose();
8085
+ selectedFloatingGroup.dispose();
8086
+ break;
8087
+ }
8088
+ case 'popout': {
8089
+ const selectedPopoutGroup = this._popoutGroups.find((x) => x.popoutGroup === from);
8090
+ if (!selectedPopoutGroup) {
8091
+ throw new Error('failed to find popout group');
7448
8092
  }
8093
+ selectedPopoutGroup.disposable.dispose();
7449
8094
  }
7450
- const referenceLocation = getGridLocation(referenceGroup.element);
7451
- const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, target);
7452
- this.gridview.addView(sourceGroup, exports.Sizing.Distribute, dropLocation);
7453
8095
  }
8096
+ const referenceLocation = getGridLocation(to.element);
8097
+ const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, target);
8098
+ this.gridview.addView(from, exports.Sizing.Distribute, dropLocation);
8099
+ from.panels.forEach((panel) => {
8100
+ this._onDidMovePanel.fire({ panel });
8101
+ });
7454
8102
  }
7455
8103
  }
7456
- doSetGroupAndPanelActive(group, skipFocus) {
7457
- var _a, _b;
8104
+ doSetGroupActive(group) {
8105
+ super.doSetGroupActive(group);
8106
+ const activePanel = this.activePanel;
8107
+ if (!this._moving &&
8108
+ activePanel !== this._onDidActivePanelChange.value) {
8109
+ this._onDidActivePanelChange.fire(activePanel);
8110
+ }
8111
+ }
8112
+ doSetGroupAndPanelActive(group) {
8113
+ super.doSetGroupActive(group);
7458
8114
  const activePanel = this.activePanel;
7459
- super.doSetGroupActive(group, skipFocus);
7460
- if (((_a = this._activeGroup) === null || _a === void 0 ? void 0 : _a.activePanel) !== activePanel) {
7461
- this._onDidActivePanelChange.fire((_b = this._activeGroup) === null || _b === void 0 ? void 0 : _b.activePanel);
8115
+ if (group &&
8116
+ this.hasMaximizedGroup() &&
8117
+ !this.isMaximizedGroup(group)) {
8118
+ this.exitMaximizedGroup();
8119
+ }
8120
+ if (!this._moving &&
8121
+ activePanel !== this._onDidActivePanelChange.value) {
8122
+ this._onDidActivePanelChange.fire(activePanel);
7462
8123
  }
7463
8124
  }
8125
+ getNextGroupId() {
8126
+ let id = this.nextGroupId.next();
8127
+ while (this._groups.has(id)) {
8128
+ id = this.nextGroupId.next();
8129
+ }
8130
+ return id;
8131
+ }
7464
8132
  createGroup(options) {
7465
8133
  if (!options) {
7466
8134
  options = {};
@@ -7477,7 +8145,7 @@
7477
8145
  }
7478
8146
  }
7479
8147
  const view = new DockviewGroupPanel(this, id, options);
7480
- view.init({ params: {}, accessor: null }); // required to initialized .part and allow for correct disposal of group
8148
+ view.init({ params: {}, accessor: this });
7481
8149
  if (!this._groups.has(view.id)) {
7482
8150
  const disposable = new CompositeDisposable(view.model.onTabDragStart((event) => {
7483
8151
  this._onWillDragPanel.fire(event);
@@ -7485,20 +8153,48 @@
7485
8153
  this._onWillDragGroup.fire(event);
7486
8154
  }), view.model.onMove((event) => {
7487
8155
  const { groupId, itemId, target, index } = event;
7488
- this.moveGroupOrPanel(view, groupId, itemId, target, index);
8156
+ this.moveGroupOrPanel({
8157
+ from: { groupId: groupId, panelId: itemId },
8158
+ to: {
8159
+ group: view,
8160
+ position: target,
8161
+ index,
8162
+ },
8163
+ });
7489
8164
  }), view.model.onDidDrop((event) => {
7490
- this._onDidDrop.fire(Object.assign(Object.assign({}, event), { api: this._api, group: view }));
8165
+ this._onDidDrop.fire(event);
8166
+ }), view.model.onWillDrop((event) => {
8167
+ this._onWillDrop.fire(event);
8168
+ }), view.model.onWillShowOverlay((event) => {
8169
+ if (this.options.disableDnd) {
8170
+ event.preventDefault();
8171
+ return;
8172
+ }
8173
+ this._onWillShowOverlay.fire(event);
7491
8174
  }), view.model.onDidAddPanel((event) => {
8175
+ if (this._moving) {
8176
+ return;
8177
+ }
7492
8178
  this._onDidAddPanel.fire(event.panel);
7493
8179
  }), view.model.onDidRemovePanel((event) => {
8180
+ if (this._moving) {
8181
+ return;
8182
+ }
7494
8183
  this._onDidRemovePanel.fire(event.panel);
7495
8184
  }), view.model.onDidActivePanelChange((event) => {
7496
- this._onDidActivePanelChange.fire(event.panel);
8185
+ if (this._moving) {
8186
+ return;
8187
+ }
8188
+ if (event.panel !== this.activePanel) {
8189
+ return;
8190
+ }
8191
+ if (this._onDidActivePanelChange.value !== event.panel) {
8192
+ this._onDidActivePanelChange.fire(event.panel);
8193
+ }
7497
8194
  }));
7498
8195
  this._groups.set(view.id, { value: view, disposable });
7499
8196
  }
7500
- // TODO: must be called after the above listeners have been setup,
7501
- // not an ideal pattern
8197
+ // TODO: must be called after the above listeners have been setup, not an ideal pattern
7502
8198
  view.initialize();
7503
8199
  return view;
7504
8200
  }
@@ -7551,7 +8247,20 @@
7551
8247
  });
7552
8248
  this._onDidLayoutfromJSON = new Emitter();
7553
8249
  this.onDidLayoutFromJSON = this._onDidLayoutfromJSON.event;
8250
+ this._onDidRemoveGroup = new Emitter();
8251
+ this.onDidRemoveGroup = this._onDidRemoveGroup.event;
8252
+ this._onDidAddGroup = new Emitter();
8253
+ this.onDidAddGroup = this._onDidAddGroup.event;
8254
+ this._onDidActiveGroupChange = new Emitter();
8255
+ this.onDidActiveGroupChange = this._onDidActiveGroupChange.event;
7554
8256
  this._options = options;
8257
+ this.addDisposables(this._onDidAddGroup, this._onDidRemoveGroup, this._onDidActiveGroupChange, this.onDidAdd((event) => {
8258
+ this._onDidAddGroup.fire(event);
8259
+ }), this.onDidRemove((event) => {
8260
+ this._onDidRemoveGroup.fire(event);
8261
+ }), this.onDidActiveChange((event) => {
8262
+ this._onDidActiveGroupChange.fire(event);
8263
+ }));
7555
8264
  if (!this.options.components) {
7556
8265
  this.options.components = {};
7557
8266
  }
@@ -7726,6 +8435,7 @@
7726
8435
  });
7727
8436
  this.registerPanel(view);
7728
8437
  this.doAddGroup(view, relativeLocation, options.size);
8438
+ this.doSetGroupActive(view);
7729
8439
  return view;
7730
8440
  }
7731
8441
  registerPanel(panel) {
@@ -8411,10 +9121,10 @@
8411
9121
  this._onDidChange = new Emitter();
8412
9122
  this.onDidChange = this._onDidChange.event;
8413
9123
  this.api.initialize(this);
8414
- this.addDisposables(this._onDidChange, this.api.onVisibilityChange((event) => {
8415
- const { isVisible } = event;
9124
+ this.addDisposables(this._onDidChange, this.api.onDidHiddenChange((event) => {
9125
+ const { isHidden } = event;
8416
9126
  const { accessor } = this._params;
8417
- accessor.setVisible(this, isVisible);
9127
+ accessor.setVisible(this, !isHidden);
8418
9128
  }), this.api.onActiveChange(() => {
8419
9129
  const { accessor } = this._params;
8420
9130
  accessor.setActive(this);
@@ -8536,13 +9246,13 @@
8536
9246
  if (this.disposed) {
8537
9247
  throw new Error('invalid operation: resource is already disposed');
8538
9248
  }
8539
- if (typeof this.component !== 'function') {
9249
+ if (!isReactComponent(this.component)) {
8540
9250
  /**
8541
9251
  * we know this isn't a React.FunctionComponent so throw an error here.
8542
- * if we do not intercept this the React library will throw a very obsure error
8543
- * for the same reason, at least at this point we will emit a sensible stacktrace.
9252
+ * if we do not intercept then React library will throw a very obsure error
9253
+ * for the same reason... at least at this point we will emit a sensible stacktrace.
8544
9254
  */
8545
- throw new Error('Invalid Operation. dockview only supports React Functional Components.');
9255
+ throw new Error('Dockview: Only React.memo(...), React.ForwardRef(...) and functional components are accepted as components');
8546
9256
  }
8547
9257
  const bridgeComponent = React__namespace.createElement(React__namespace.forwardRef(ReactComponentBridge), {
8548
9258
  component: this
@@ -8594,9 +9304,13 @@
8594
9304
  }, []);
8595
9305
  return [portals, addPortal];
8596
9306
  };
8597
- // it does the job...
8598
- function isReactElement(element) {
8599
- return !!(element === null || element === void 0 ? void 0 : element.type);
9307
+ function isReactComponent(component) {
9308
+ /**
9309
+ * Yes, we could use "react-is" but that would introduce an unwanted peer dependency
9310
+ * so for now we will check in a rather crude fashion...
9311
+ */
9312
+ return (typeof component === 'function' /** Functional Componnts */ ||
9313
+ !!(component === null || component === void 0 ? void 0 : component.$$typeof) /** React.memo(...) Components */);
8600
9314
  }
8601
9315
 
8602
9316
  class ReactPanelContentPart {
@@ -8856,6 +9570,8 @@
8856
9570
  defaultRenderer: props.defaultRenderer,
8857
9571
  debug: props.debug,
8858
9572
  rootOverlayModel: props.rootOverlayModel,
9573
+ locked: props.locked,
9574
+ disableDnd: props.disableDnd,
8859
9575
  });
8860
9576
  const { clientWidth, clientHeight } = domRef.current;
8861
9577
  dockview.layout(clientWidth, clientHeight);
@@ -8867,6 +9583,20 @@
8867
9583
  dockview.dispose();
8868
9584
  };
8869
9585
  }, []);
9586
+ React__namespace.useEffect(() => {
9587
+ if (!dockviewRef.current) {
9588
+ return;
9589
+ }
9590
+ dockviewRef.current.locked = !!props.locked;
9591
+ }, [props.locked]);
9592
+ React__namespace.useEffect(() => {
9593
+ if (!dockviewRef.current) {
9594
+ return;
9595
+ }
9596
+ dockviewRef.current.updateOptions({
9597
+ disableDnd: props.disableDnd,
9598
+ });
9599
+ }, [props.disableDnd]);
8870
9600
  React__namespace.useEffect(() => {
8871
9601
  if (!dockviewRef.current) {
8872
9602
  return () => {
@@ -8882,6 +9612,21 @@
8882
9612
  disposable.dispose();
8883
9613
  };
8884
9614
  }, [props.onDidDrop]);
9615
+ React__namespace.useEffect(() => {
9616
+ if (!dockviewRef.current) {
9617
+ return () => {
9618
+ // noop
9619
+ };
9620
+ }
9621
+ const disposable = dockviewRef.current.onWillDrop((event) => {
9622
+ if (props.onWillDrop) {
9623
+ props.onWillDrop(event);
9624
+ }
9625
+ });
9626
+ return () => {
9627
+ disposable.dispose();
9628
+ };
9629
+ }, [props.onWillDrop]);
8885
9630
  React__namespace.useEffect(() => {
8886
9631
  if (!dockviewRef.current) {
8887
9632
  return;
@@ -9124,7 +9869,9 @@
9124
9869
  return new ReactPart(this.element, this.reactPortalStore, this.reactComponent, {
9125
9870
  params: (_b = (_a = this._params) === null || _a === void 0 ? void 0 : _a.params) !== null && _b !== void 0 ? _b : {},
9126
9871
  api: this.api,
9127
- containerApi: new GridviewApi(this._params.accessor),
9872
+ // TODO: fix casting hack
9873
+ containerApi: new GridviewApi(this._params
9874
+ .accessor),
9128
9875
  });
9129
9876
  }
9130
9877
  }
@@ -9307,12 +10054,14 @@
9307
10054
  exports.DockviewComponent = DockviewComponent;
9308
10055
  exports.DockviewCompositeDisposable = CompositeDisposable;
9309
10056
  exports.DockviewDefaultTab = DockviewDefaultTab;
10057
+ exports.DockviewDidDropEvent = DockviewDidDropEvent;
9310
10058
  exports.DockviewEmitter = Emitter;
9311
10059
  exports.DockviewGroupPanel = DockviewGroupPanel;
9312
10060
  exports.DockviewGroupPanelModel = DockviewGroupPanelModel;
9313
10061
  exports.DockviewMutableDisposable = MutableDisposable;
9314
10062
  exports.DockviewPanel = DockviewPanel;
9315
10063
  exports.DockviewReact = DockviewReact;
10064
+ exports.DockviewWillDropEvent = DockviewWillDropEvent;
9316
10065
  exports.DraggablePaneviewPanel = DraggablePaneviewPanel;
9317
10066
  exports.Gridview = Gridview;
9318
10067
  exports.GridviewApi = GridviewApi;
@@ -9336,6 +10085,7 @@
9336
10085
  exports.SplitviewPanel = SplitviewPanel;
9337
10086
  exports.SplitviewReact = SplitviewReact;
9338
10087
  exports.Tab = Tab;
10088
+ exports.WillShowOverlayLocationEvent = WillShowOverlayLocationEvent;
9339
10089
  exports.createComponent = createComponent;
9340
10090
  exports.directionToPosition = directionToPosition;
9341
10091
  exports.getDirectionOrientation = getDirectionOrientation;
@@ -9350,7 +10100,7 @@
9350
10100
  exports.isGroupOptionsWithPanel = isGroupOptionsWithPanel;
9351
10101
  exports.isPanelOptionsWithGroup = isPanelOptionsWithGroup;
9352
10102
  exports.isPanelOptionsWithPanel = isPanelOptionsWithPanel;
9353
- exports.isReactElement = isReactElement;
10103
+ exports.isReactComponent = isReactComponent;
9354
10104
  exports.orthogonal = orthogonal;
9355
10105
  exports.positionToDirection = positionToDirection;
9356
10106
  exports.toTarget = toTarget;