dockview 1.8.5 → 1.9.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 (46) hide show
  1. package/README.md +15 -10
  2. package/dist/cjs/dockview/defaultTab.js.map +1 -1
  3. package/dist/cjs/dockview/dockview.d.ts +3 -1
  4. package/dist/cjs/dockview/dockview.d.ts.map +1 -1
  5. package/dist/cjs/dockview/dockview.js +2 -0
  6. package/dist/cjs/dockview/dockview.js.map +1 -1
  7. package/dist/cjs/dockview/reactWatermarkPart.js.map +1 -1
  8. package/dist/cjs/gridview/gridview.js.map +1 -1
  9. package/dist/cjs/gridview/view.js.map +1 -1
  10. package/dist/cjs/paneview/paneview.js.map +1 -1
  11. package/dist/cjs/react.js.map +1 -1
  12. package/dist/cjs/splitview/splitview.js.map +1 -1
  13. package/dist/cjs/splitview/view.js.map +1 -1
  14. package/dist/dockview.amd.js +897 -169
  15. package/dist/dockview.amd.js.map +1 -1
  16. package/dist/dockview.amd.min.js +2 -2
  17. package/dist/dockview.amd.min.js.map +1 -1
  18. package/dist/dockview.amd.min.noStyle.js +2 -2
  19. package/dist/dockview.amd.min.noStyle.js.map +1 -1
  20. package/dist/dockview.amd.noStyle.js +897 -169
  21. package/dist/dockview.amd.noStyle.js.map +1 -1
  22. package/dist/dockview.cjs.js +897 -169
  23. package/dist/dockview.cjs.js.map +1 -1
  24. package/dist/dockview.esm.js +897 -169
  25. package/dist/dockview.esm.js.map +1 -1
  26. package/dist/dockview.esm.min.js +2 -2
  27. package/dist/dockview.esm.min.js.map +1 -1
  28. package/dist/dockview.js +897 -169
  29. package/dist/dockview.js.map +1 -1
  30. package/dist/dockview.min.js +2 -2
  31. package/dist/dockview.min.js.map +1 -1
  32. package/dist/dockview.min.noStyle.js +2 -2
  33. package/dist/dockview.min.noStyle.js.map +1 -1
  34. package/dist/dockview.noStyle.js +897 -169
  35. package/dist/dockview.noStyle.js.map +1 -1
  36. package/dist/esm/dockview/defaultTab.js.map +1 -1
  37. package/dist/esm/dockview/dockview.d.ts +3 -1
  38. package/dist/esm/dockview/dockview.d.ts.map +1 -1
  39. package/dist/esm/dockview/dockview.js +2 -0
  40. package/dist/esm/dockview/dockview.js.map +1 -1
  41. package/dist/esm/dockview/reactWatermarkPart.js.map +1 -1
  42. package/dist/esm/gridview/gridview.js.map +1 -1
  43. package/dist/esm/paneview/paneview.js.map +1 -1
  44. package/dist/esm/react.js.map +1 -1
  45. package/dist/esm/splitview/splitview.js.map +1 -1
  46. package/package.json +2 -2
package/dist/dockview.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * dockview
3
- * @version 1.8.5
3
+ * @version 1.9.0
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -286,6 +286,14 @@
286
286
  // noop
287
287
  },
288
288
  };
289
+ function from(func) {
290
+ return {
291
+ dispose: () => {
292
+ func();
293
+ },
294
+ };
295
+ }
296
+ Disposable.from = from;
289
297
  })(Disposable || (Disposable = {}));
290
298
  class CompositeDisposable {
291
299
  get isDisposed() {
@@ -470,6 +478,61 @@
470
478
  function quasiDefaultPrevented(event) {
471
479
  return event[QUASI_PREVENT_DEFAULT_KEY];
472
480
  }
481
+ function addStyles(document, styleSheetList) {
482
+ const styleSheets = Array.from(styleSheetList);
483
+ for (const styleSheet of styleSheets) {
484
+ if (styleSheet.href) {
485
+ const link = document.createElement('link');
486
+ link.href = styleSheet.href;
487
+ link.type = styleSheet.type;
488
+ link.rel = 'stylesheet';
489
+ document.head.appendChild(link);
490
+ }
491
+ let cssTexts = [];
492
+ try {
493
+ if (styleSheet.cssRules) {
494
+ cssTexts = Array.from(styleSheet.cssRules).map((rule) => rule.cssText);
495
+ }
496
+ }
497
+ catch (err) {
498
+ // security errors (lack of permissions), ignore
499
+ }
500
+ for (const rule of cssTexts) {
501
+ const style = document.createElement('style');
502
+ style.appendChild(document.createTextNode(rule));
503
+ document.head.appendChild(style);
504
+ }
505
+ }
506
+ }
507
+ function getDomNodePagePosition(domNode) {
508
+ const { left, top, width, height } = domNode.getBoundingClientRect();
509
+ return {
510
+ left: left + window.scrollX,
511
+ top: top + window.scrollY,
512
+ width: width,
513
+ height: height,
514
+ };
515
+ }
516
+ /**
517
+ * Check whether an element is in the DOM (including the Shadow DOM)
518
+ * @see https://terodox.tech/how-to-tell-if-an-element-is-in-the-dom-including-the-shadow-dom/
519
+ */
520
+ function isInDocument(element) {
521
+ let currentElement = element;
522
+ while (currentElement === null || currentElement === void 0 ? void 0 : currentElement.parentNode) {
523
+ if (currentElement.parentNode === document) {
524
+ return true;
525
+ }
526
+ else if (currentElement.parentNode instanceof DocumentFragment) {
527
+ // handle shadow DOMs
528
+ currentElement = currentElement.parentNode.host;
529
+ }
530
+ else {
531
+ currentElement = currentElement.parentNode;
532
+ }
533
+ }
534
+ return false;
535
+ }
473
536
 
474
537
  function tail(arr) {
475
538
  if (arr.length === 0) {
@@ -667,6 +730,9 @@
667
730
  Sizing.Invisible = Invisible;
668
731
  })(exports.Sizing || (exports.Sizing = {}));
669
732
  class Splitview {
733
+ get contentSize() {
734
+ return this._contentSize;
735
+ }
670
736
  get size() {
671
737
  return this._size;
672
738
  }
@@ -732,7 +798,7 @@
732
798
  this.sashes = [];
733
799
  this._size = 0;
734
800
  this._orthogonalSize = 0;
735
- this.contentSize = 0;
801
+ this._contentSize = 0;
736
802
  this._proportions = undefined;
737
803
  this._startSnappingEnabled = true;
738
804
  this._endSnappingEnabled = true;
@@ -851,7 +917,7 @@
851
917
  );
852
918
  });
853
919
  // Initialize content size and proportions for first layout
854
- this.contentSize = this.viewItems.reduce((r, i) => r + i.size, 0);
920
+ this._contentSize = this.viewItems.reduce((r, i) => r + i.size, 0);
855
921
  this.saveProportions();
856
922
  }
857
923
  }
@@ -1125,7 +1191,7 @@
1125
1191
  this.addView(view, sizing, to);
1126
1192
  }
1127
1193
  layout(size, orthogonalSize) {
1128
- const previousSize = Math.max(this.size, this.contentSize);
1194
+ const previousSize = Math.max(this.size, this._contentSize);
1129
1195
  this.size = size;
1130
1196
  this.orthogonalSize = orthogonalSize;
1131
1197
  if (!this.proportions) {
@@ -1135,9 +1201,23 @@
1135
1201
  this.resize(this.viewItems.length - 1, size - previousSize, undefined, lowPriorityIndexes, highPriorityIndexes);
1136
1202
  }
1137
1203
  else {
1204
+ let total = 0;
1205
+ for (let i = 0; i < this.viewItems.length; i++) {
1206
+ const item = this.viewItems[i];
1207
+ const proportion = this.proportions[i];
1208
+ if (typeof proportion === 'number') {
1209
+ total += proportion;
1210
+ }
1211
+ else {
1212
+ size -= item.size;
1213
+ }
1214
+ }
1138
1215
  for (let i = 0; i < this.viewItems.length; i++) {
1139
1216
  const item = this.viewItems[i];
1140
- item.size = clamp(Math.round(this.proportions[i] * size), item.minimumSize, item.maximumSize);
1217
+ const proportion = this.proportions[i];
1218
+ if (typeof proportion === 'number' && total > 0) {
1219
+ item.size = clamp(Math.round((proportion * size) / total), item.minimumSize, item.maximumSize);
1220
+ }
1141
1221
  }
1142
1222
  }
1143
1223
  this.distributeEmptySpace();
@@ -1174,12 +1254,12 @@
1174
1254
  }
1175
1255
  }
1176
1256
  saveProportions() {
1177
- if (this.proportionalLayout && this.contentSize > 0) {
1178
- this._proportions = this.viewItems.map((i) => i.size / this.contentSize);
1257
+ if (this.proportionalLayout && this._contentSize > 0) {
1258
+ this._proportions = this.viewItems.map((i) => i.visible ? i.size / this._contentSize : undefined);
1179
1259
  }
1180
1260
  }
1181
1261
  layoutViews() {
1182
- this.contentSize = this.viewItems.reduce((r, i) => r + i.size, 0);
1262
+ this._contentSize = this.viewItems.reduce((r, i) => r + i.size, 0);
1183
1263
  let sum = 0;
1184
1264
  const x = [];
1185
1265
  this.updateSashEnablement();
@@ -1273,7 +1353,7 @@
1273
1353
  }
1274
1354
  else if (snappedAfter &&
1275
1355
  collapsesDown[index] &&
1276
- (position < this.contentSize || this.endSnappingEnabled)) {
1356
+ (position < this._contentSize || this.endSnappingEnabled)) {
1277
1357
  this.updateSash(sash, exports.SashState.MAXIMUM);
1278
1358
  }
1279
1359
  else {
@@ -1562,7 +1642,6 @@
1562
1642
  setVisible(visible) {
1563
1643
  if (this.view.setVisible) {
1564
1644
  this.view.setVisible(visible);
1565
- this._onDidChange.fire({});
1566
1645
  }
1567
1646
  }
1568
1647
  layout(size, orthogonalSize) {
@@ -1594,10 +1673,14 @@
1594
1673
  get minimumSize() {
1595
1674
  return this.children.length === 0
1596
1675
  ? 0
1597
- : Math.max(...this.children.map((c) => c.minimumOrthogonalSize));
1676
+ : Math.max(...this.children.map((c, index) => this.splitview.isViewVisible(index)
1677
+ ? c.minimumOrthogonalSize
1678
+ : 0));
1598
1679
  }
1599
1680
  get maximumSize() {
1600
- return Math.min(...this.children.map((c) => c.maximumOrthogonalSize));
1681
+ return Math.min(...this.children.map((c, index) => this.splitview.isViewVisible(index)
1682
+ ? c.maximumOrthogonalSize
1683
+ : Number.POSITIVE_INFINITY));
1601
1684
  }
1602
1685
  get minimumOrthogonalSize() {
1603
1686
  return this.splitview.minimumSize;
@@ -1655,6 +1738,8 @@
1655
1738
  this.children = [];
1656
1739
  this._onDidChange = new Emitter();
1657
1740
  this.onDidChange = this._onDidChange.event;
1741
+ this._onDidVisibilityChange = new Emitter();
1742
+ this.onDidVisibilityChange = this._onDidVisibilityChange.event;
1658
1743
  this._orthogonalSize = orthogonalSize;
1659
1744
  this._size = size;
1660
1745
  this.element = document.createElement('div');
@@ -1689,7 +1774,7 @@
1689
1774
  styles,
1690
1775
  });
1691
1776
  }
1692
- this.addDisposables(this._onDidChange, this.splitview.onDidSashEnd(() => {
1777
+ this.addDisposables(this._onDidChange, this._onDidVisibilityChange, this.splitview.onDidSashEnd(() => {
1693
1778
  this._onDidChange.fire({});
1694
1779
  }));
1695
1780
  this.setupChildrenEvents();
@@ -1712,7 +1797,15 @@
1712
1797
  if (this.splitview.isViewVisible(index) === visible) {
1713
1798
  return;
1714
1799
  }
1800
+ const wereAllChildrenHidden = this.splitview.contentSize === 0;
1715
1801
  this.splitview.setViewVisible(index, visible);
1802
+ const areAllChildrenHidden = this.splitview.contentSize === 0;
1803
+ // If all children are hidden then the parent should hide the entire splitview
1804
+ // If the entire splitview is hidden then the parent should show the splitview when a child is shown
1805
+ if ((visible && wereAllChildrenHidden) ||
1806
+ (!visible && areAllChildrenHidden)) {
1807
+ this._onDidVisibilityChange.fire(visible);
1808
+ }
1716
1809
  }
1717
1810
  moveChild(from, to) {
1718
1811
  if (from === to) {
@@ -1776,13 +1869,20 @@
1776
1869
  }
1777
1870
  setupChildrenEvents() {
1778
1871
  this._childrenDisposable.dispose();
1779
- this._childrenDisposable = exports.DockviewEvent.any(...this.children.map((c) => c.onDidChange))((e) => {
1872
+ this._childrenDisposable = new CompositeDisposable(exports.DockviewEvent.any(...this.children.map((c) => c.onDidChange))((e) => {
1780
1873
  /**
1781
1874
  * indicate a change has occured to allows any re-rendering but don't bubble
1782
1875
  * event because that was specific to this branch
1783
1876
  */
1784
1877
  this._onDidChange.fire({ size: e.orthogonalSize });
1785
- });
1878
+ }), ...this.children.map((c, i) => {
1879
+ if (c instanceof BranchNode) {
1880
+ return c.onDidVisibilityChange((visible) => {
1881
+ this.setChildVisible(i, visible);
1882
+ });
1883
+ }
1884
+ return Disposable.NONE;
1885
+ }));
1786
1886
  }
1787
1887
  dispose() {
1788
1888
  this._childrenDisposable.dispose();
@@ -1943,7 +2043,69 @@
1943
2043
  get maximumHeight() {
1944
2044
  return this.root.maximumHeight;
1945
2045
  }
2046
+ maximizedView() {
2047
+ var _a;
2048
+ return (_a = this._maximizedNode) === null || _a === void 0 ? void 0 : _a.view;
2049
+ }
2050
+ hasMaximizedView() {
2051
+ return this._maximizedNode !== undefined;
2052
+ }
2053
+ maximizeView(view) {
2054
+ const location = getGridLocation(view.element);
2055
+ const [_, node] = this.getNode(location);
2056
+ if (!(node instanceof LeafNode)) {
2057
+ return;
2058
+ }
2059
+ if (this._maximizedNode === node) {
2060
+ return;
2061
+ }
2062
+ if (this.hasMaximizedView()) {
2063
+ this.exitMaximizedView();
2064
+ }
2065
+ function hideAllViewsBut(parent, exclude) {
2066
+ for (let i = 0; i < parent.children.length; i++) {
2067
+ const child = parent.children[i];
2068
+ if (child instanceof LeafNode) {
2069
+ if (child !== exclude) {
2070
+ parent.setChildVisible(i, false);
2071
+ }
2072
+ }
2073
+ else {
2074
+ hideAllViewsBut(child, exclude);
2075
+ }
2076
+ }
2077
+ }
2078
+ hideAllViewsBut(this.root, node);
2079
+ this._maximizedNode = node;
2080
+ this._onDidMaxmizedNodeChange.fire();
2081
+ }
2082
+ exitMaximizedView() {
2083
+ if (!this._maximizedNode) {
2084
+ return;
2085
+ }
2086
+ function showViewsInReverseOrder(parent) {
2087
+ for (let index = parent.children.length - 1; index >= 0; index--) {
2088
+ const child = parent.children[index];
2089
+ if (child instanceof LeafNode) {
2090
+ parent.setChildVisible(index, true);
2091
+ }
2092
+ else {
2093
+ showViewsInReverseOrder(child);
2094
+ }
2095
+ }
2096
+ }
2097
+ showViewsInReverseOrder(this.root);
2098
+ this._maximizedNode = undefined;
2099
+ this._onDidMaxmizedNodeChange.fire();
2100
+ }
1946
2101
  serialize() {
2102
+ if (this.hasMaximizedView()) {
2103
+ /**
2104
+ * do not persist maximized view state but we must first exit any maximized views
2105
+ * before serialization to ensure the correct dimensions are persisted
2106
+ */
2107
+ this.exitMaximizedView();
2108
+ }
1947
2109
  const root = serializeBranchNode(this.getView(), this.orientation);
1948
2110
  return {
1949
2111
  root,
@@ -1955,7 +2117,9 @@
1955
2117
  dispose() {
1956
2118
  this.disposable.dispose();
1957
2119
  this._onDidChange.dispose();
2120
+ this._onDidMaxmizedNodeChange.dispose();
1958
2121
  this.root.dispose();
2122
+ this._maximizedNode = undefined;
1959
2123
  this.element.remove();
1960
2124
  }
1961
2125
  clear() {
@@ -1996,6 +2160,7 @@
1996
2160
  const oldRoot = this._root;
1997
2161
  if (oldRoot) {
1998
2162
  oldRoot.dispose();
2163
+ this._maximizedNode = undefined;
1999
2164
  this.element.removeChild(oldRoot.element);
2000
2165
  }
2001
2166
  this._root = root;
@@ -2082,9 +2247,12 @@
2082
2247
  constructor(proportionalLayout, styles, orientation) {
2083
2248
  this.proportionalLayout = proportionalLayout;
2084
2249
  this.styles = styles;
2250
+ this._maximizedNode = undefined;
2085
2251
  this.disposable = new MutableDisposable();
2086
2252
  this._onDidChange = new Emitter();
2087
2253
  this.onDidChange = this._onDidChange.event;
2254
+ this._onDidMaxmizedNodeChange = new Emitter();
2255
+ this.onDidMaxmizedNodeChange = this._onDidMaxmizedNodeChange.event;
2088
2256
  this.element = document.createElement('div');
2089
2257
  this.element.className = 'grid-view';
2090
2258
  this.root = new BranchNode(orientation, proportionalLayout, styles, 0, 0);
@@ -2098,6 +2266,9 @@
2098
2266
  return parent.isChildVisible(index);
2099
2267
  }
2100
2268
  setViewVisible(location, visible) {
2269
+ if (this.hasMaximizedView()) {
2270
+ this.exitMaximizedView();
2271
+ }
2101
2272
  const [rest, index] = tail(location);
2102
2273
  const [, parent] = this.getNode(rest);
2103
2274
  if (!(parent instanceof BranchNode)) {
@@ -2106,6 +2277,9 @@
2106
2277
  parent.setChildVisible(index, visible);
2107
2278
  }
2108
2279
  moveView(parentLocation, from, to) {
2280
+ if (this.hasMaximizedView()) {
2281
+ this.exitMaximizedView();
2282
+ }
2109
2283
  const [, parent] = this.getNode(parentLocation);
2110
2284
  if (!(parent instanceof BranchNode)) {
2111
2285
  throw new Error('Invalid location');
@@ -2113,6 +2287,9 @@
2113
2287
  parent.moveChild(from, to);
2114
2288
  }
2115
2289
  addView(view, size, location) {
2290
+ if (this.hasMaximizedView()) {
2291
+ this.exitMaximizedView();
2292
+ }
2116
2293
  const [rest, index] = tail(location);
2117
2294
  const [pathToParent, parent] = this.getNode(rest);
2118
2295
  if (parent instanceof BranchNode) {
@@ -2145,6 +2322,9 @@
2145
2322
  return this.removeView(location, sizing);
2146
2323
  }
2147
2324
  removeView(location, sizing) {
2325
+ if (this.hasMaximizedView()) {
2326
+ this.exitMaximizedView();
2327
+ }
2148
2328
  const [rest, index] = tail(location);
2149
2329
  const [pathToParent, parent] = this.getNode(rest);
2150
2330
  if (!(parent instanceof BranchNode)) {
@@ -2882,6 +3062,24 @@
2882
3062
  moveToPrevious(options) {
2883
3063
  this.component.moveToPrevious(options);
2884
3064
  }
3065
+ maximizeGroup(panel) {
3066
+ this.component.maximizeGroup(panel.group);
3067
+ }
3068
+ hasMaximizedGroup() {
3069
+ return this.component.hasMaximizedGroup();
3070
+ }
3071
+ exitMaxmizedGroup() {
3072
+ this.component.exitMaximizedGroup();
3073
+ }
3074
+ get onDidMaxmizedGroupChange() {
3075
+ return this.component.onDidMaxmizedGroupChange;
3076
+ }
3077
+ /**
3078
+ * Add a popout group in a new Window
3079
+ */
3080
+ addPopoutGroup(item, options) {
3081
+ this.component.addPopoutGroup(item, options);
3082
+ }
2885
3083
  }
2886
3084
 
2887
3085
  class DragAndDropObserver extends CompositeDisposable {
@@ -2892,29 +3090,44 @@
2892
3090
  this.target = null;
2893
3091
  this.registerListeners();
2894
3092
  }
3093
+ onDragEnter(e) {
3094
+ this.target = e.target;
3095
+ this.callbacks.onDragEnter(e);
3096
+ }
3097
+ onDragOver(e) {
3098
+ e.preventDefault(); // needed so that the drop event fires (https://stackoverflow.com/questions/21339924/drop-event-not-firing-in-chrome)
3099
+ if (this.callbacks.onDragOver) {
3100
+ this.callbacks.onDragOver(e);
3101
+ }
3102
+ }
3103
+ onDragLeave(e) {
3104
+ if (this.target === e.target) {
3105
+ this.target = null;
3106
+ this.callbacks.onDragLeave(e);
3107
+ }
3108
+ }
3109
+ onDragEnd(e) {
3110
+ this.target = null;
3111
+ this.callbacks.onDragEnd(e);
3112
+ }
3113
+ onDrop(e) {
3114
+ this.callbacks.onDrop(e);
3115
+ }
2895
3116
  registerListeners() {
2896
3117
  this.addDisposables(addDisposableListener(this.element, 'dragenter', (e) => {
2897
- this.target = e.target;
2898
- this.callbacks.onDragEnter(e);
3118
+ this.onDragEnter(e);
2899
3119
  }, true));
2900
3120
  this.addDisposables(addDisposableListener(this.element, 'dragover', (e) => {
2901
- e.preventDefault(); // needed so that the drop event fires (https://stackoverflow.com/questions/21339924/drop-event-not-firing-in-chrome)
2902
- if (this.callbacks.onDragOver) {
2903
- this.callbacks.onDragOver(e);
2904
- }
3121
+ this.onDragOver(e);
2905
3122
  }, true));
2906
3123
  this.addDisposables(addDisposableListener(this.element, 'dragleave', (e) => {
2907
- if (this.target === e.target) {
2908
- this.target = null;
2909
- this.callbacks.onDragLeave(e);
2910
- }
3124
+ this.onDragLeave(e);
2911
3125
  }));
2912
3126
  this.addDisposables(addDisposableListener(this.element, 'dragend', (e) => {
2913
- this.target = null;
2914
- this.callbacks.onDragEnd(e);
3127
+ this.onDragEnd(e);
2915
3128
  }));
2916
3129
  this.addDisposables(addDisposableListener(this.element, 'drop', (e) => {
2917
- this.callbacks.onDrop(e);
3130
+ this.onDrop(e);
2918
3131
  }));
2919
3132
  }
2920
3133
  }
@@ -2966,7 +3179,7 @@
2966
3179
  this.onDrop = this._onDrop.event;
2967
3180
  // use a set to take advantage of #<set>.has
2968
3181
  this._acceptedTargetZonesSet = new Set(this.options.acceptedTargetZones);
2969
- this.addDisposables(this._onDrop, new DragAndDropObserver(this.element, {
3182
+ this.dnd = new DragAndDropObserver(this.element, {
2970
3183
  onDragEnter: () => undefined,
2971
3184
  onDragOver: (e) => {
2972
3185
  if (this._acceptedTargetZonesSet.size === 0) {
@@ -3033,7 +3246,8 @@
3033
3246
  this._onDrop.fire({ position: state, nativeEvent: e });
3034
3247
  }
3035
3248
  },
3036
- }));
3249
+ });
3250
+ this.addDisposables(this._onDrop, this.dnd);
3037
3251
  }
3038
3252
  setTargetZones(acceptedTargetZones) {
3039
3253
  this._acceptedTargetZonesSet = new Set(acceptedTargetZones);
@@ -3189,12 +3403,22 @@
3189
3403
  return 'center';
3190
3404
  }
3191
3405
 
3406
+ exports.DockviewDropTargets = void 0;
3407
+ (function (DockviewDropTargets) {
3408
+ DockviewDropTargets[DockviewDropTargets["Tab"] = 0] = "Tab";
3409
+ DockviewDropTargets[DockviewDropTargets["Panel"] = 1] = "Panel";
3410
+ DockviewDropTargets[DockviewDropTargets["TabContainer"] = 2] = "TabContainer";
3411
+ DockviewDropTargets[DockviewDropTargets["Edge"] = 3] = "Edge";
3412
+ })(exports.DockviewDropTargets || (exports.DockviewDropTargets = {}));
3413
+
3192
3414
  class ContentContainer extends CompositeDisposable {
3193
3415
  get element() {
3194
3416
  return this._element;
3195
3417
  }
3196
- constructor() {
3418
+ constructor(accessor, group) {
3197
3419
  super();
3420
+ this.accessor = accessor;
3421
+ this.group = group;
3198
3422
  this.disposable = new MutableDisposable();
3199
3423
  this._onDidFocus = new Emitter();
3200
3424
  this.onDidFocus = this._onDidFocus.event;
@@ -3204,11 +3428,38 @@
3204
3428
  this._element.className = 'content-container';
3205
3429
  this._element.tabIndex = -1;
3206
3430
  this.addDisposables(this._onDidFocus, this._onDidBlur);
3207
- // for hosted containers
3208
- // 1) register a drop target on the host
3209
- // 2) register window dragStart events to disable pointer events
3210
- // 3) register dragEnd events
3211
- // 4) register mouseMove events (if no buttons are present we take this as a dragEnd event)
3431
+ this.dropTarget = new Droptarget(this.element, {
3432
+ acceptedTargetZones: ['top', 'bottom', 'left', 'right', 'center'],
3433
+ canDisplayOverlay: (event, position) => {
3434
+ if (this.group.locked === 'no-drop-target' ||
3435
+ (this.group.locked && position === 'center')) {
3436
+ return false;
3437
+ }
3438
+ const data = getPanelData();
3439
+ if (!data &&
3440
+ event.shiftKey &&
3441
+ this.group.location !== 'floating') {
3442
+ return false;
3443
+ }
3444
+ if (data && data.viewId === this.accessor.id) {
3445
+ if (data.groupId === this.group.id) {
3446
+ if (position === 'center') {
3447
+ // don't allow to drop on self for center position
3448
+ return false;
3449
+ }
3450
+ if (data.panelId === null) {
3451
+ // don't allow group move to drop anywhere on self
3452
+ return false;
3453
+ }
3454
+ }
3455
+ const groupHasOnePanelAndIsActiveDragElement = this.group.panels.length === 1 &&
3456
+ data.groupId === this.group.id;
3457
+ return !groupHasOnePanelAndIsActiveDragElement;
3458
+ }
3459
+ return this.group.canDisplayOverlay(event, position, exports.DockviewDropTargets.Panel);
3460
+ },
3461
+ });
3462
+ this.addDisposables(this.dropTarget);
3212
3463
  }
3213
3464
  show() {
3214
3465
  this.element.style.display = '';
@@ -3216,23 +3467,43 @@
3216
3467
  hide() {
3217
3468
  this.element.style.display = 'none';
3218
3469
  }
3219
- openPanel(panel) {
3220
- var _a;
3221
- if (this.panel === panel) {
3222
- return;
3223
- }
3224
- if (this.panel) {
3225
- if ((_a = this.panel.view) === null || _a === void 0 ? void 0 : _a.content) {
3226
- this._element.removeChild(this.panel.view.content.element);
3227
- }
3228
- this.panel = undefined;
3470
+ renderPanel(panel, options = { asActive: true }) {
3471
+ const doRender = options.asActive ||
3472
+ (this.panel && this.group.isPanelActive(this.panel));
3473
+ if (this.panel &&
3474
+ this.panel.view.content.element.parentElement === this._element) {
3475
+ /**
3476
+ * If the currently attached panel is mounted directly to the content then remove it
3477
+ */
3478
+ this._element.removeChild(this.panel.view.content.element);
3229
3479
  }
3230
3480
  this.panel = panel;
3231
- const disposable = new CompositeDisposable();
3232
- if (this.panel.view) {
3233
- const _onDidFocus = this.panel.view.content.onDidFocus;
3234
- const _onDidBlur = this.panel.view.content.onDidBlur;
3235
- const focusTracker = trackFocus(this._element);
3481
+ let container;
3482
+ switch (panel.api.renderer) {
3483
+ case 'onlyWhenVisibile':
3484
+ this.accessor.overlayRenderContainer.detatch(panel);
3485
+ if (this.panel) {
3486
+ if (doRender) {
3487
+ this._element.appendChild(this.panel.view.content.element);
3488
+ }
3489
+ }
3490
+ container = this._element;
3491
+ break;
3492
+ case 'always':
3493
+ if (panel.view.content.element.parentElement === this._element) {
3494
+ this._element.removeChild(panel.view.content.element);
3495
+ }
3496
+ container = this.accessor.overlayRenderContainer.attach({
3497
+ panel,
3498
+ referenceContainer: this,
3499
+ });
3500
+ break;
3501
+ }
3502
+ if (doRender) {
3503
+ const _onDidFocus = panel.view.content.onDidFocus;
3504
+ const _onDidBlur = panel.view.content.onDidBlur;
3505
+ const focusTracker = trackFocus(container);
3506
+ const disposable = new CompositeDisposable();
3236
3507
  disposable.addDisposables(focusTracker, focusTracker.onDidFocus(() => this._onDidFocus.fire()), focusTracker.onDidBlur(() => this._onDidBlur.fire()));
3237
3508
  if (_onDidFocus) {
3238
3509
  disposable.addDisposables(_onDidFocus(() => this._onDidFocus.fire()));
@@ -3240,17 +3511,23 @@
3240
3511
  if (_onDidBlur) {
3241
3512
  disposable.addDisposables(_onDidBlur(() => this._onDidBlur.fire()));
3242
3513
  }
3243
- this._element.appendChild(this.panel.view.content.element);
3514
+ this.disposable.value = disposable;
3244
3515
  }
3245
- this.disposable.value = disposable;
3516
+ }
3517
+ openPanel(panel) {
3518
+ if (this.panel === panel) {
3519
+ return;
3520
+ }
3521
+ this.renderPanel(panel);
3246
3522
  }
3247
3523
  layout(_width, _height) {
3248
3524
  // noop
3249
3525
  }
3250
3526
  closePanel() {
3251
- var _a, _b, _c;
3252
- if ((_c = (_b = (_a = this.panel) === null || _a === void 0 ? void 0 : _a.view) === null || _b === void 0 ? void 0 : _b.content) === null || _c === void 0 ? void 0 : _c.element) {
3253
- this._element.removeChild(this.panel.view.content.element);
3527
+ if (this.panel) {
3528
+ if (this.accessor.options.defaultRenderer === 'onlyWhenVisibile') {
3529
+ this._element.removeChild(this.panel.view.content.element);
3530
+ }
3254
3531
  this.panel = undefined;
3255
3532
  }
3256
3533
  }
@@ -3260,14 +3537,6 @@
3260
3537
  }
3261
3538
  }
3262
3539
 
3263
- exports.DockviewDropTargets = void 0;
3264
- (function (DockviewDropTargets) {
3265
- DockviewDropTargets[DockviewDropTargets["Tab"] = 0] = "Tab";
3266
- DockviewDropTargets[DockviewDropTargets["Panel"] = 1] = "Panel";
3267
- DockviewDropTargets[DockviewDropTargets["TabContainer"] = 2] = "TabContainer";
3268
- DockviewDropTargets[DockviewDropTargets["Edge"] = 3] = "Edge";
3269
- })(exports.DockviewDropTargets || (exports.DockviewDropTargets = {}));
3270
-
3271
3540
  class DragHandler extends CompositeDisposable {
3272
3541
  constructor(el) {
3273
3542
  super();
@@ -3442,7 +3711,7 @@
3442
3711
  }, true));
3443
3712
  }
3444
3713
  isCancelled(_event) {
3445
- if (this.group.api.isFloating && !_event.shiftKey) {
3714
+ if (this.group.api.location === 'floating' && !_event.shiftKey) {
3446
3715
  return true;
3447
3716
  }
3448
3717
  return false;
@@ -3644,7 +3913,7 @@
3644
3913
  const isFloatingGroupsEnabled = !this.accessor.options.disableFloatingGroups;
3645
3914
  if (isFloatingGroupsEnabled &&
3646
3915
  event.shiftKey &&
3647
- !this.group.api.isFloating) {
3916
+ this.group.api.location !== 'floating') {
3648
3917
  event.preventDefault();
3649
3918
  const { top, left } = this.element.getBoundingClientRect();
3650
3919
  const { top: rootTop, left: rootLeft } = this.accessor.element.getBoundingClientRect();
@@ -3709,7 +3978,7 @@
3709
3978
  }), tab.onChanged((event) => {
3710
3979
  var _a;
3711
3980
  const isFloatingGroupsEnabled = !this.accessor.options.disableFloatingGroups;
3712
- const isFloatingWithOnePanel = this.group.api.isFloating && this.size === 1;
3981
+ const isFloatingWithOnePanel = this.group.api.location === 'floating' && this.size === 1;
3713
3982
  if (isFloatingGroupsEnabled &&
3714
3983
  !isFloatingWithOnePanel &&
3715
3984
  event.shiftKey) {
@@ -3792,15 +4061,37 @@
3792
4061
  }
3793
4062
  return isAncestor(document.activeElement, this.contentContainer.element);
3794
4063
  }
3795
- get isFloating() {
3796
- return this._isFloating;
3797
- }
3798
- set isFloating(value) {
3799
- this._isFloating = value;
3800
- this.dropTarget.setTargetZones(value ? ['center'] : ['top', 'bottom', 'left', 'right', 'center']);
3801
- toggleClass(this.container, 'dv-groupview-floating', value);
3802
- this.groupPanel.api._onDidFloatingStateChange.fire({
3803
- isFloating: this.isFloating,
4064
+ get location() {
4065
+ return this._location;
4066
+ }
4067
+ set location(value) {
4068
+ this._location = value;
4069
+ toggleClass(this.container, 'dv-groupview-floating', false);
4070
+ toggleClass(this.container, 'dv-groupview-popout', false);
4071
+ switch (value) {
4072
+ case 'grid':
4073
+ this.contentContainer.dropTarget.setTargetZones([
4074
+ 'top',
4075
+ 'bottom',
4076
+ 'left',
4077
+ 'right',
4078
+ 'center',
4079
+ ]);
4080
+ break;
4081
+ case 'floating':
4082
+ this.contentContainer.dropTarget.setTargetZones(['center']);
4083
+ this.contentContainer.dropTarget.setTargetZones(value
4084
+ ? ['center']
4085
+ : ['top', 'bottom', 'left', 'right', 'center']);
4086
+ toggleClass(this.container, 'dv-groupview-floating', true);
4087
+ break;
4088
+ case 'popout':
4089
+ this.contentContainer.dropTarget.setTargetZones(['center']);
4090
+ toggleClass(this.container, 'dv-groupview-popout', true);
4091
+ break;
4092
+ }
4093
+ this.groupPanel.api._onDidLocationChange.fire({
4094
+ location: this.location,
3804
4095
  });
3805
4096
  }
3806
4097
  constructor(container, accessor, id, options, groupPanel) {
@@ -3813,7 +4104,7 @@
3813
4104
  this.groupPanel = groupPanel;
3814
4105
  this._isGroupActive = false;
3815
4106
  this._locked = false;
3816
- this._isFloating = false;
4107
+ this._location = 'grid';
3817
4108
  this.mostRecentlyUsed = [];
3818
4109
  this._onDidChange = new Emitter();
3819
4110
  this.onDidChange = this._onDidChange.event;
@@ -3836,35 +4127,7 @@
3836
4127
  this.onDidActivePanelChange = this._onDidActivePanelChange.event;
3837
4128
  toggleClass(this.container, 'groupview', true);
3838
4129
  this.tabsContainer = new TabsContainer(this.accessor, this.groupPanel);
3839
- this.contentContainer = new ContentContainer();
3840
- this.dropTarget = new Droptarget(this.contentContainer.element, {
3841
- acceptedTargetZones: ['top', 'bottom', 'left', 'right', 'center'],
3842
- canDisplayOverlay: (event, position) => {
3843
- if (this.locked === 'no-drop-target' ||
3844
- (this.locked && position === 'center')) {
3845
- return false;
3846
- }
3847
- const data = getPanelData();
3848
- if (!data && event.shiftKey && !this.isFloating) {
3849
- return false;
3850
- }
3851
- if (data && data.viewId === this.accessor.id) {
3852
- if (data.groupId === this.id) {
3853
- if (position === 'center') {
3854
- // don't allow to drop on self for center position
3855
- return false;
3856
- }
3857
- if (data.panelId === null) {
3858
- // don't allow group move to drop anywhere on self
3859
- return false;
3860
- }
3861
- }
3862
- const groupHasOnePanelAndIsActiveDragElement = this._panels.length === 1 && data.groupId === this.id;
3863
- return !groupHasOnePanelAndIsActiveDragElement;
3864
- }
3865
- return this.canDisplayOverlay(event, position, exports.DockviewDropTargets.Panel);
3866
- },
3867
- });
4130
+ this.contentContainer = new ContentContainer(this.accessor, this);
3868
4131
  container.append(this.tabsContainer.element, this.contentContainer.element);
3869
4132
  this.header.hidden = !!options.hideHeader;
3870
4133
  this.locked = (_a = options.locked) !== null && _a !== void 0 ? _a : false;
@@ -3878,7 +4141,7 @@
3878
4141
  this.accessor.doSetGroupActive(this.groupPanel, true);
3879
4142
  }), this.contentContainer.onDidBlur(() => {
3880
4143
  // noop
3881
- }), this.dropTarget.onDrop((event) => {
4144
+ }), this.contentContainer.dropTarget.onDrop((event) => {
3882
4145
  this.handleDropEvent(event.nativeEvent, event.position);
3883
4146
  }), this._onMove, this._onDidChange, this._onDidDrop, this._onDidAddPanel, this._onDidRemovePanel, this._onDidActivePanelChange);
3884
4147
  }
@@ -3927,6 +4190,9 @@
3927
4190
  this.tabsContainer.setPrefixActionsElement(this._prefixHeaderActions.element);
3928
4191
  }
3929
4192
  }
4193
+ rerender(panel) {
4194
+ this.contentContainer.renderPanel(panel, { asActive: false });
4195
+ }
3930
4196
  indexOf(panel) {
3931
4197
  return this.tabsContainer.indexOf(panel.id);
3932
4198
  }
@@ -4118,12 +4384,12 @@
4118
4384
  doAddPanel(panel, index = this.panels.length, skipSetActive = false) {
4119
4385
  const existingPanel = this._panels.indexOf(panel);
4120
4386
  const hasExistingPanel = existingPanel > -1;
4387
+ this.tabsContainer.show();
4388
+ this.contentContainer.show();
4121
4389
  this.tabsContainer.openPanel(panel, index);
4122
4390
  if (!skipSetActive) {
4123
4391
  this.contentContainer.openPanel(panel);
4124
4392
  }
4125
- this.tabsContainer.show();
4126
- this.contentContainer.show();
4127
4393
  if (hasExistingPanel) {
4128
4394
  // TODO - need to ensure ordering hasn't changed and if it has need to re-order this.panels
4129
4395
  return;
@@ -4239,7 +4505,6 @@
4239
4505
  for (const panel of this.panels) {
4240
4506
  panel.dispose();
4241
4507
  }
4242
- this.dropTarget.dispose();
4243
4508
  this.tabsContainer.dispose();
4244
4509
  this.contentContainer.dispose();
4245
4510
  }
@@ -4278,7 +4543,7 @@
4278
4543
  if (this.disableResizing) {
4279
4544
  return;
4280
4545
  }
4281
- if (!document.body.contains(this._element)) {
4546
+ if (!isInDocument(this._element)) {
4282
4547
  /**
4283
4548
  * since the event is dispatched through requestAnimationFrame there is a small chance
4284
4549
  * the component is no longer attached to the DOM, if that is the case the dimensions
@@ -4370,6 +4635,21 @@
4370
4635
  isVisible(panel) {
4371
4636
  return this.gridview.isViewVisible(getGridLocation(panel.element));
4372
4637
  }
4638
+ maximizeGroup(panel) {
4639
+ this.gridview.maximizeView(panel);
4640
+ }
4641
+ isMaximizedGroup(panel) {
4642
+ return this.gridview.maximizedView() === panel;
4643
+ }
4644
+ exitMaximizedGroup() {
4645
+ this.gridview.exitMaximizedView();
4646
+ }
4647
+ hasMaximizedGroup() {
4648
+ return this.gridview.hasMaximizedView();
4649
+ }
4650
+ get onDidMaxmizedGroupChange() {
4651
+ return this.gridview.onDidMaxmizedNodeChange;
4652
+ }
4373
4653
  doAddGroup(group, location = [0], size) {
4374
4654
  this.gridview.addView(group, size !== null && size !== void 0 ? size : exports.Sizing.Distribute, location);
4375
4655
  this._onDidAddGroup.fire(group);
@@ -5146,32 +5426,63 @@
5146
5426
  }
5147
5427
  }
5148
5428
 
5429
+ // TODO find a better way to initialize and avoid needing null checks
5430
+ const NOT_INITIALIZED_MESSAGE = 'DockviewGroupPanelApiImpl not initialized';
5149
5431
  class DockviewGroupPanelApiImpl extends GridviewPanelApiImpl {
5150
- get isFloating() {
5432
+ get location() {
5151
5433
  if (!this._group) {
5152
- throw new Error(`DockviewGroupPanelApiImpl not initialized`);
5434
+ throw new Error(NOT_INITIALIZED_MESSAGE);
5153
5435
  }
5154
- return this._group.model.isFloating;
5436
+ return this._group.model.location;
5155
5437
  }
5156
5438
  constructor(id, accessor) {
5157
5439
  super(id);
5158
5440
  this.accessor = accessor;
5159
- this._onDidFloatingStateChange = new Emitter();
5160
- this.onDidFloatingStateChange = this._onDidFloatingStateChange.event;
5161
- this.addDisposables(this._onDidFloatingStateChange);
5441
+ this._onDidLocationChange = new Emitter();
5442
+ this.onDidLocationChange = this._onDidLocationChange.event;
5443
+ this.addDisposables(this._onDidLocationChange);
5162
5444
  }
5163
5445
  moveTo(options) {
5164
- var _a;
5446
+ var _a, _b, _c;
5447
+ if (!this._group) {
5448
+ throw new Error(NOT_INITIALIZED_MESSAGE);
5449
+ }
5450
+ const group = (_a = options.group) !== null && _a !== void 0 ? _a : this.accessor.addGroup({
5451
+ direction: positionToDirection((_b = options.position) !== null && _b !== void 0 ? _b : 'right'),
5452
+ });
5453
+ this.accessor.moveGroupOrPanel(group, this._group.id, undefined, options.group ? (_c = options.position) !== null && _c !== void 0 ? _c : 'center' : 'center');
5454
+ }
5455
+ maximize() {
5456
+ if (!this._group) {
5457
+ throw new Error(NOT_INITIALIZED_MESSAGE);
5458
+ }
5459
+ if (this.location !== 'grid') {
5460
+ // only grid groups can be maximized
5461
+ return;
5462
+ }
5463
+ this.accessor.maximizeGroup(this._group);
5464
+ }
5465
+ isMaximized() {
5165
5466
  if (!this._group) {
5166
- throw new Error(`DockviewGroupPanelApiImpl not initialized`);
5467
+ throw new Error(NOT_INITIALIZED_MESSAGE);
5468
+ }
5469
+ return this.accessor.isMaximizedGroup(this._group);
5470
+ }
5471
+ exitMaximized() {
5472
+ if (!this._group) {
5473
+ throw new Error(NOT_INITIALIZED_MESSAGE);
5474
+ }
5475
+ if (this.isMaximized()) {
5476
+ this.accessor.exitMaximizedGroup();
5167
5477
  }
5168
- this.accessor.moveGroupOrPanel(options.group, this._group.id, undefined, (_a = options.position) !== null && _a !== void 0 ? _a : 'center');
5169
5478
  }
5170
5479
  initialize(group) {
5171
5480
  this._group = group;
5172
5481
  }
5173
5482
  }
5174
5483
 
5484
+ const MINIMUM_DOCKVIEW_GROUP_PANEL_WIDTH = 100;
5485
+ const MINIMUM_DOCKVIEW_GROUP_PANEL_HEIGHT = 100;
5175
5486
  class DockviewGroupPanel extends GridviewPanel {
5176
5487
  get panels() {
5177
5488
  return this._model.panels;
@@ -5196,8 +5507,8 @@
5196
5507
  }
5197
5508
  constructor(accessor, id, options) {
5198
5509
  super(id, 'groupview_default', {
5199
- minimumHeight: 100,
5200
- minimumWidth: 100,
5510
+ minimumHeight: MINIMUM_DOCKVIEW_GROUP_PANEL_HEIGHT,
5511
+ minimumWidth: MINIMUM_DOCKVIEW_GROUP_PANEL_WIDTH,
5201
5512
  }, new DockviewGroupPanelApiImpl(id, accessor));
5202
5513
  this.api.initialize(this); // cannot use 'this' after after 'super' call
5203
5514
  this._model = new DockviewGroupPanelModel(this.element, accessor, id, options, this);
@@ -5251,8 +5562,10 @@
5251
5562
  return this.panel.title;
5252
5563
  }
5253
5564
  get isGroupActive() {
5254
- var _a;
5255
- return !!((_a = this.group) === null || _a === void 0 ? void 0 : _a.isActive);
5565
+ return this.group.isActive;
5566
+ }
5567
+ get renderer() {
5568
+ return this.panel.renderer;
5256
5569
  }
5257
5570
  set group(value) {
5258
5571
  const isOldGroupActive = this.isGroupActive;
@@ -5280,10 +5593,12 @@
5280
5593
  this.onDidActiveGroupChange = this._onDidActiveGroupChange.event;
5281
5594
  this._onDidGroupChange = new Emitter();
5282
5595
  this.onDidGroupChange = this._onDidGroupChange.event;
5596
+ this._onDidRendererChange = new Emitter();
5597
+ this.onDidRendererChange = this._onDidRendererChange.event;
5283
5598
  this.disposable = new MutableDisposable();
5284
5599
  this.initialize(panel);
5285
5600
  this._group = group;
5286
- this.addDisposables(this.disposable, this._onDidTitleChange, this._onDidGroupChange, this._onDidActiveGroupChange);
5601
+ this.addDisposables(this.disposable, this._onDidRendererChange, this._onDidTitleChange, this._onDidGroupChange, this._onDidActiveGroupChange);
5287
5602
  }
5288
5603
  moveTo(options) {
5289
5604
  var _a;
@@ -5292,9 +5607,21 @@
5292
5607
  setTitle(title) {
5293
5608
  this.panel.setTitle(title);
5294
5609
  }
5610
+ setRenderer(renderer) {
5611
+ this.panel.setRenderer(renderer);
5612
+ }
5295
5613
  close() {
5296
5614
  this.group.model.closePanel(this.panel);
5297
5615
  }
5616
+ maximize() {
5617
+ this.group.api.maximize();
5618
+ }
5619
+ isMaximized() {
5620
+ return this.group.api.isMaximized();
5621
+ }
5622
+ exitMaximized() {
5623
+ this.group.api.exitMaximized();
5624
+ }
5298
5625
  }
5299
5626
 
5300
5627
  class DockviewPanel extends CompositeDisposable {
@@ -5307,11 +5634,17 @@
5307
5634
  get group() {
5308
5635
  return this._group;
5309
5636
  }
5310
- constructor(id, accessor, containerApi, group, view) {
5637
+ get renderer() {
5638
+ var _a;
5639
+ return (_a = this._renderer) !== null && _a !== void 0 ? _a : this.accessor.renderer;
5640
+ }
5641
+ constructor(id, accessor, containerApi, group, view, options) {
5311
5642
  super();
5312
5643
  this.id = id;
5644
+ this.accessor = accessor;
5313
5645
  this.containerApi = containerApi;
5314
5646
  this.view = view;
5647
+ this._renderer = options.renderer;
5315
5648
  this._group = group;
5316
5649
  this.api = new DockviewPanelApiImpl(this, this._group, accessor);
5317
5650
  this.addDisposables(this.api.onActiveChange(() => {
@@ -5320,6 +5653,8 @@
5320
5653
  // forward the resize event to the group since if you want to resize a panel
5321
5654
  // you are actually just resizing the panels parent which is the group
5322
5655
  this.group.api.setSize(event);
5656
+ }), this.api.onDidRendererChange((event) => {
5657
+ this.group.model.rerender(this);
5323
5658
  }));
5324
5659
  }
5325
5660
  init(params) {
@@ -5339,6 +5674,7 @@
5339
5674
  ? this._params
5340
5675
  : undefined,
5341
5676
  title: this.title,
5677
+ renderer: this._renderer,
5342
5678
  };
5343
5679
  }
5344
5680
  setTitle(title) {
@@ -5354,6 +5690,15 @@
5354
5690
  this.api._onDidTitleChange.fire({ title });
5355
5691
  }
5356
5692
  }
5693
+ setRenderer(renderer) {
5694
+ const didChange = renderer !== this.renderer;
5695
+ if (didChange) {
5696
+ this._renderer = renderer;
5697
+ this.api._onDidRendererChange.fire({
5698
+ renderer: renderer,
5699
+ });
5700
+ }
5701
+ }
5357
5702
  update(event) {
5358
5703
  var _a;
5359
5704
  // merge the new parameters with the existing parameters
@@ -5572,8 +5917,8 @@
5572
5917
  }
5573
5918
 
5574
5919
  class DefaultDockviewDeserialzier {
5575
- constructor(layout) {
5576
- this.layout = layout;
5920
+ constructor(accessor) {
5921
+ this.accessor = accessor;
5577
5922
  }
5578
5923
  fromJSON(panelData, group) {
5579
5924
  var _a, _b;
@@ -5587,8 +5932,10 @@
5587
5932
  const tabComponent = viewData
5588
5933
  ? (_b = viewData.tab) === null || _b === void 0 ? void 0 : _b.id
5589
5934
  : panelData.tabComponent;
5590
- const view = new DockviewPanelModel(this.layout, panelId, contentComponent, tabComponent);
5591
- const panel = new DockviewPanel(panelId, this.layout, new DockviewApi(this.layout), group, view);
5935
+ const view = new DockviewPanelModel(this.accessor, panelId, contentComponent, tabComponent);
5936
+ const panel = new DockviewPanel(panelId, this.accessor, new DockviewApi(this.accessor), group, view, {
5937
+ renderer: panelData.renderer,
5938
+ });
5592
5939
  panel.init({
5593
5940
  title: title !== null && title !== void 0 ? title : panelId,
5594
5941
  params: params !== null && params !== void 0 ? params : {},
@@ -5968,7 +6315,261 @@
5968
6315
  }
5969
6316
  }
5970
6317
 
6318
+ class PopoutWindow extends CompositeDisposable {
6319
+ constructor(id, className, options) {
6320
+ super();
6321
+ this.id = id;
6322
+ this.className = className;
6323
+ this.options = options;
6324
+ this._onDidClose = new Emitter();
6325
+ this.onDidClose = this._onDidClose.event;
6326
+ this._window = null;
6327
+ this.addDisposables(this._onDidClose, {
6328
+ dispose: () => {
6329
+ this.close();
6330
+ },
6331
+ });
6332
+ }
6333
+ dimensions() {
6334
+ if (!this._window) {
6335
+ return null;
6336
+ }
6337
+ const left = this._window.value.screenX;
6338
+ const top = this._window.value.screenY;
6339
+ const width = this._window.value.innerWidth;
6340
+ const height = this._window.value.innerHeight;
6341
+ return { top, left, width, height };
6342
+ }
6343
+ close() {
6344
+ if (this._window) {
6345
+ this._window.disposable.dispose();
6346
+ this._window.value.close();
6347
+ this._window = null;
6348
+ }
6349
+ }
6350
+ open(content) {
6351
+ if (this._window) {
6352
+ throw new Error('instance of popout window is already open');
6353
+ }
6354
+ const url = `${this.options.url}`;
6355
+ const features = Object.entries({
6356
+ top: this.options.top,
6357
+ left: this.options.left,
6358
+ width: this.options.width,
6359
+ height: this.options.height,
6360
+ })
6361
+ .map(([key, value]) => `${key}=${value}`)
6362
+ .join(',');
6363
+ // https://developer.mozilla.org/en-US/docs/Web/API/Window/open
6364
+ const externalWindow = window.open(url, this.id, features);
6365
+ if (!externalWindow) {
6366
+ return;
6367
+ }
6368
+ const disposable = new CompositeDisposable();
6369
+ this._window = { value: externalWindow, disposable };
6370
+ const cleanUp = () => {
6371
+ this._onDidClose.fire();
6372
+ this._window = null;
6373
+ };
6374
+ // prevent any default content from loading
6375
+ // externalWindow.document.body.replaceWith(document.createElement('div'));
6376
+ disposable.addDisposables(addDisposableWindowListener(window, 'beforeunload', () => {
6377
+ cleanUp();
6378
+ this.close();
6379
+ }));
6380
+ externalWindow.addEventListener('load', () => {
6381
+ const externalDocument = externalWindow.document;
6382
+ externalDocument.title = document.title;
6383
+ const div = document.createElement('div');
6384
+ div.classList.add('dv-popout-window');
6385
+ div.style.position = 'absolute';
6386
+ div.style.width = '100%';
6387
+ div.style.height = '100%';
6388
+ div.style.top = '0px';
6389
+ div.style.left = '0px';
6390
+ div.classList.add(this.className);
6391
+ div.appendChild(content);
6392
+ externalDocument.body.replaceChildren(div);
6393
+ externalDocument.body.classList.add(this.className);
6394
+ addStyles(externalDocument, window.document.styleSheets);
6395
+ externalWindow.addEventListener('beforeunload', () => {
6396
+ // TODO: indicate external window is closing
6397
+ cleanUp();
6398
+ });
6399
+ });
6400
+ }
6401
+ }
6402
+
6403
+ class DockviewPopoutGroupPanel extends CompositeDisposable {
6404
+ constructor(id, group, options) {
6405
+ var _a;
6406
+ super();
6407
+ this.id = id;
6408
+ this.group = group;
6409
+ this.options = options;
6410
+ this.window = new PopoutWindow(id, (_a = options.className) !== null && _a !== void 0 ? _a : '', {
6411
+ url: this.options.popoutUrl,
6412
+ left: this.options.box.left,
6413
+ top: this.options.box.top,
6414
+ width: this.options.box.width,
6415
+ height: this.options.box.height,
6416
+ });
6417
+ group.model.location = 'popout';
6418
+ this.addDisposables(this.window, {
6419
+ dispose: () => {
6420
+ group.model.location = 'grid';
6421
+ },
6422
+ }, this.window.onDidClose(() => {
6423
+ this.dispose();
6424
+ }));
6425
+ this.window.open(group.element);
6426
+ }
6427
+ }
6428
+
5971
6429
  const DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE = 100;
6430
+ const DEFAULT_FLOATING_GROUP_POSITION = { left: 100, top: 100 };
6431
+
6432
+ function createFocusableElement() {
6433
+ const element = document.createElement('div');
6434
+ element.tabIndex = -1;
6435
+ return element;
6436
+ }
6437
+ class OverlayRenderContainer extends CompositeDisposable {
6438
+ constructor(element) {
6439
+ super();
6440
+ this.element = element;
6441
+ this.map = {};
6442
+ this.addDisposables(Disposable.from(() => {
6443
+ for (const value of Object.values(this.map)) {
6444
+ value.disposable.dispose();
6445
+ value.destroy.dispose();
6446
+ }
6447
+ }));
6448
+ }
6449
+ detatch(panel) {
6450
+ if (this.map[panel.api.id]) {
6451
+ const { disposable, destroy } = this.map[panel.api.id];
6452
+ disposable.dispose();
6453
+ destroy.dispose();
6454
+ delete this.map[panel.api.id];
6455
+ return true;
6456
+ }
6457
+ return false;
6458
+ }
6459
+ attach(options) {
6460
+ const { panel, referenceContainer } = options;
6461
+ if (!this.map[panel.api.id]) {
6462
+ const element = createFocusableElement();
6463
+ element.className = 'dv-render-overlay';
6464
+ this.map[panel.api.id] = {
6465
+ panel,
6466
+ disposable: Disposable.NONE,
6467
+ destroy: Disposable.NONE,
6468
+ element,
6469
+ };
6470
+ }
6471
+ const focusContainer = this.map[panel.api.id].element;
6472
+ if (panel.view.content.element.parentElement !== focusContainer) {
6473
+ focusContainer.appendChild(panel.view.content.element);
6474
+ }
6475
+ if (focusContainer.parentElement !== this.element) {
6476
+ this.element.appendChild(focusContainer);
6477
+ }
6478
+ const resize = () => {
6479
+ // TODO propagate position to avoid getDomNodePagePosition calls, possible performance bottleneck?
6480
+ const box = getDomNodePagePosition(referenceContainer.element);
6481
+ const box2 = getDomNodePagePosition(this.element);
6482
+ focusContainer.style.left = `${box.left - box2.left}px`;
6483
+ focusContainer.style.top = `${box.top - box2.top}px`;
6484
+ focusContainer.style.width = `${box.width}px`;
6485
+ focusContainer.style.height = `${box.height}px`;
6486
+ toggleClass(focusContainer, 'dv-render-overlay-float', panel.group.api.location === 'floating');
6487
+ };
6488
+ const visibilityChanged = () => {
6489
+ if (panel.api.isVisible) {
6490
+ resize();
6491
+ }
6492
+ focusContainer.style.display = panel.api.isVisible ? '' : 'none';
6493
+ };
6494
+ const disposable = new CompositeDisposable(
6495
+ /**
6496
+ * since container is positioned absoutely we must explicitly forward
6497
+ * the dnd events for the expect behaviours to continue to occur in terms of dnd
6498
+ *
6499
+ * the dnd observer does not need to be conditional on whether the panel is visible since
6500
+ * non-visible panels are 'display: none' and in such case the dnd observer will not fire.
6501
+ */
6502
+ new DragAndDropObserver(focusContainer, {
6503
+ onDragEnd: (e) => {
6504
+ referenceContainer.dropTarget.dnd.onDragEnd(e);
6505
+ },
6506
+ onDragEnter: (e) => {
6507
+ referenceContainer.dropTarget.dnd.onDragEnter(e);
6508
+ },
6509
+ onDragLeave: (e) => {
6510
+ referenceContainer.dropTarget.dnd.onDragLeave(e);
6511
+ },
6512
+ onDrop: (e) => {
6513
+ referenceContainer.dropTarget.dnd.onDrop(e);
6514
+ },
6515
+ onDragOver: (e) => {
6516
+ referenceContainer.dropTarget.dnd.onDragOver(e);
6517
+ },
6518
+ }), panel.api.onDidVisibilityChange((event) => {
6519
+ /**
6520
+ * Control the visibility of the content, however even when not visible (display: none)
6521
+ * the content is still maintained within the DOM hence DOM specific attributes
6522
+ * such as scroll position are maintained when next made visible.
6523
+ */
6524
+ visibilityChanged();
6525
+ }), panel.api.onDidDimensionsChange(() => {
6526
+ if (!panel.api.isVisible) {
6527
+ return;
6528
+ }
6529
+ resize();
6530
+ }));
6531
+ this.map[panel.api.id].destroy = Disposable.from(() => {
6532
+ focusContainer.removeChild(panel.view.content.element);
6533
+ this.element.removeChild(focusContainer);
6534
+ });
6535
+ queueMicrotask(() => {
6536
+ if (this.isDisposed) {
6537
+ return;
6538
+ }
6539
+ /**
6540
+ * wait until everything has finished in the current stack-frame call before
6541
+ * calling the first resize as other size-altering events may still occur before
6542
+ * the end of the stack-frame.
6543
+ */
6544
+ visibilityChanged();
6545
+ });
6546
+ // dispose of logic asoccciated with previous reference-container
6547
+ this.map[panel.api.id].disposable.dispose();
6548
+ // and reset the disposable to the active reference-container
6549
+ this.map[panel.api.id].disposable = disposable;
6550
+ return focusContainer;
6551
+ }
6552
+ }
6553
+
6554
+ function getTheme(element) {
6555
+ function toClassList(element) {
6556
+ const list = [];
6557
+ for (let i = 0; i < element.classList.length; i++) {
6558
+ list.push(element.classList.item(i));
6559
+ }
6560
+ return list;
6561
+ }
6562
+ let theme = undefined;
6563
+ let parent = element;
6564
+ while (parent !== null) {
6565
+ theme = toClassList(parent).find((cls) => cls.startsWith('dockview-theme-'));
6566
+ if (typeof theme === 'string') {
6567
+ break;
6568
+ }
6569
+ parent = parent.parentElement;
6570
+ }
6571
+ return theme;
6572
+ }
5972
6573
  class DockviewComponent extends BaseGrid {
5973
6574
  get orientation() {
5974
6575
  return this.gridview.orientation;
@@ -5989,6 +6590,10 @@
5989
6590
  }
5990
6591
  return activeGroup.activePanel;
5991
6592
  }
6593
+ get renderer() {
6594
+ var _a;
6595
+ return (_a = this.options.defaultRenderer) !== null && _a !== void 0 ? _a : 'onlyWhenVisibile';
6596
+ }
5992
6597
  constructor(options) {
5993
6598
  var _a;
5994
6599
  super({
@@ -6015,12 +6620,27 @@
6015
6620
  this.onDidLayoutFromJSON = this._onDidLayoutFromJSON.event;
6016
6621
  this._onDidActivePanelChange = new Emitter();
6017
6622
  this.onDidActivePanelChange = this._onDidActivePanelChange.event;
6018
- this.floatingGroups = [];
6623
+ this._floatingGroups = [];
6624
+ this._popoutGroups = [];
6625
+ const gready = document.createElement('div');
6626
+ gready.className = 'dv-overlay-render-container';
6627
+ this.gridview.element.appendChild(gready);
6628
+ this.overlayRenderContainer = new OverlayRenderContainer(gready);
6019
6629
  toggleClass(this.gridview.element, 'dv-dockview', true);
6020
- this.addDisposables(this._onWillDragPanel, this._onWillDragGroup, this._onDidActivePanelChange, this._onDidAddPanel, this._onDidRemovePanel, this._onDidLayoutFromJSON, this._onDidDrop, exports.DockviewEvent.any(this.onDidAddGroup, this.onDidRemoveGroup)(() => {
6630
+ toggleClass(this.element, 'dv-debug', !!options.debug);
6631
+ 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)(() => {
6021
6632
  this.updateWatermark();
6022
6633
  }), exports.DockviewEvent.any(this.onDidAddPanel, this.onDidRemovePanel, this.onDidActivePanelChange)(() => {
6023
6634
  this._bufferOnDidLayoutChange.fire();
6635
+ }), Disposable.from(() => {
6636
+ // iterate over a copy of the array since .dispose() mutates the original array
6637
+ for (const group of [...this._floatingGroups]) {
6638
+ group.dispose();
6639
+ }
6640
+ // iterate over a copy of the array since .dispose() mutates the original array
6641
+ for (const group of [...this._popoutGroups]) {
6642
+ group.dispose();
6643
+ }
6024
6644
  }));
6025
6645
  this._options = options;
6026
6646
  if (!this.options.components) {
@@ -6090,6 +6710,55 @@
6090
6710
  this._api = new DockviewApi(this);
6091
6711
  this.updateWatermark();
6092
6712
  }
6713
+ addPopoutGroup(item, options) {
6714
+ var _a;
6715
+ let group;
6716
+ let box = options === null || options === void 0 ? void 0 : options.position;
6717
+ if (item instanceof DockviewPanel) {
6718
+ group = this.createGroup();
6719
+ this.removePanel(item, {
6720
+ removeEmptyGroup: true,
6721
+ skipDispose: true,
6722
+ });
6723
+ group.model.openPanel(item);
6724
+ if (!box) {
6725
+ box = this.element.getBoundingClientRect();
6726
+ }
6727
+ }
6728
+ else {
6729
+ group = item;
6730
+ if (!box) {
6731
+ box = group.element.getBoundingClientRect();
6732
+ }
6733
+ const skip = typeof (options === null || options === void 0 ? void 0 : options.skipRemoveGroup) === 'boolean' &&
6734
+ options.skipRemoveGroup;
6735
+ if (!skip) {
6736
+ this.doRemoveGroup(item, { skipDispose: true });
6737
+ }
6738
+ }
6739
+ const theme = getTheme(this.gridview.element);
6740
+ const popoutWindow = new DockviewPopoutGroupPanel(`${this.id}-${group.id}`, // globally unique within dockview
6741
+ group, {
6742
+ className: theme !== null && theme !== void 0 ? theme : '',
6743
+ popoutUrl: (_a = options === null || options === void 0 ? void 0 : options.popoutUrl) !== null && _a !== void 0 ? _a : '/popout.html',
6744
+ box: {
6745
+ left: window.screenX + box.left,
6746
+ top: window.screenY + box.top,
6747
+ width: box.width,
6748
+ height: box.height,
6749
+ },
6750
+ });
6751
+ popoutWindow.addDisposables({
6752
+ dispose: () => {
6753
+ remove(this._popoutGroups, popoutWindow);
6754
+ this.updateWatermark();
6755
+ },
6756
+ }, popoutWindow.window.onDidClose(() => {
6757
+ this.doAddGroup(group, [0]);
6758
+ }));
6759
+ this._popoutGroups.push(popoutWindow);
6760
+ this.updateWatermark();
6761
+ }
6093
6762
  addFloatingGroup(item, coord, options) {
6094
6763
  var _a, _b, _c, _d, _e, _f;
6095
6764
  let group;
@@ -6109,9 +6778,13 @@
6109
6778
  this.doRemoveGroup(item, { skipDispose: true });
6110
6779
  }
6111
6780
  }
6112
- group.model.isFloating = true;
6113
- const overlayLeft = typeof (coord === null || coord === void 0 ? void 0 : coord.x) === 'number' ? Math.max(coord.x, 0) : 100;
6114
- const overlayTop = typeof (coord === null || coord === void 0 ? void 0 : coord.y) === 'number' ? Math.max(coord.y, 0) : 100;
6781
+ group.model.location = 'floating';
6782
+ const overlayLeft = typeof (coord === null || coord === void 0 ? void 0 : coord.x) === 'number'
6783
+ ? Math.max(coord.x, 0)
6784
+ : DEFAULT_FLOATING_GROUP_POSITION.left;
6785
+ const overlayTop = typeof (coord === null || coord === void 0 ? void 0 : coord.y) === 'number'
6786
+ ? Math.max(coord.y, 0)
6787
+ : DEFAULT_FLOATING_GROUP_POSITION.top;
6115
6788
  const overlay = new Overlay({
6116
6789
  container: this.gridview.element,
6117
6790
  content: group.element,
@@ -6155,12 +6828,12 @@
6155
6828
  }), {
6156
6829
  dispose: () => {
6157
6830
  disposable.dispose();
6158
- group.model.isFloating = false;
6159
- remove(this.floatingGroups, floatingGroupPanel);
6831
+ group.model.location = 'grid';
6832
+ remove(this._floatingGroups, floatingGroupPanel);
6160
6833
  this.updateWatermark();
6161
6834
  },
6162
6835
  });
6163
- this.floatingGroups.push(floatingGroupPanel);
6836
+ this._floatingGroups.push(floatingGroupPanel);
6164
6837
  this.updateWatermark();
6165
6838
  }
6166
6839
  orthogonalize(position) {
@@ -6205,7 +6878,7 @@
6205
6878
  this.gridview.orientation = options.orientation;
6206
6879
  }
6207
6880
  if (hasFloatingGroupOptionsChanged) {
6208
- for (const group of this.floatingGroups) {
6881
+ for (const group of this._floatingGroups) {
6209
6882
  switch (this.options.floatingGroupBounds) {
6210
6883
  case 'boundedWithinViewport':
6211
6884
  group.overlay.minimumInViewportHeight = undefined;
@@ -6230,8 +6903,8 @@
6230
6903
  }
6231
6904
  layout(width, height, forceResize) {
6232
6905
  super.layout(width, height, forceResize);
6233
- if (this.floatingGroups) {
6234
- for (const floating of this.floatingGroups) {
6906
+ if (this._floatingGroups) {
6907
+ for (const floating of this._floatingGroups) {
6235
6908
  // ensure floting groups stay within visible boundaries
6236
6909
  floating.overlay.setBounds();
6237
6910
  }
@@ -6299,10 +6972,16 @@
6299
6972
  collection[panel.id] = panel.toJSON();
6300
6973
  return collection;
6301
6974
  }, {});
6302
- const floats = this.floatingGroups.map((floatingGroup) => {
6975
+ const floats = this._floatingGroups.map((group) => {
6976
+ return {
6977
+ data: group.group.toJSON(),
6978
+ position: group.overlay.toJSON(),
6979
+ };
6980
+ });
6981
+ const popoutGroups = this._popoutGroups.map((group) => {
6303
6982
  return {
6304
- data: floatingGroup.group.toJSON(),
6305
- position: floatingGroup.overlay.toJSON(),
6983
+ data: group.group.toJSON(),
6984
+ position: group.window.dimensions(),
6306
6985
  };
6307
6986
  });
6308
6987
  const result = {
@@ -6313,10 +6992,13 @@
6313
6992
  if (floats.length > 0) {
6314
6993
  result.floatingGroups = floats;
6315
6994
  }
6995
+ if (popoutGroups.length > 0) {
6996
+ result.popoutGroups = popoutGroups;
6997
+ }
6316
6998
  return result;
6317
6999
  }
6318
7000
  fromJSON(data) {
6319
- var _a;
7001
+ var _a, _b;
6320
7002
  this.clear();
6321
7003
  if (typeof data !== 'object' || data === null) {
6322
7004
  throw new Error('serialized layout must be a non-null object');
@@ -6383,7 +7065,16 @@
6383
7065
  width: position.width,
6384
7066
  }, { skipRemoveGroup: true, inDragMode: false });
6385
7067
  }
6386
- for (const floatingGroup of this.floatingGroups) {
7068
+ const serializedPopoutGroups = (_b = data.popoutGroups) !== null && _b !== void 0 ? _b : [];
7069
+ for (const serializedPopoutGroup of serializedPopoutGroups) {
7070
+ const { data, position } = serializedPopoutGroup;
7071
+ const group = createGroupFromSerializedState(data);
7072
+ this.addPopoutGroup(group, {
7073
+ skipRemoveGroup: true,
7074
+ position: position !== null && position !== void 0 ? position : undefined,
7075
+ });
7076
+ }
7077
+ for (const floatingGroup of this._floatingGroups) {
6387
7078
  floatingGroup.overlay.setBounds();
6388
7079
  }
6389
7080
  if (typeof activeGroup === 'string') {
@@ -6415,7 +7106,7 @@
6415
7106
  this._onDidRemoveGroup.fire(group);
6416
7107
  }
6417
7108
  // iterate over a reassigned array since original array will be modified
6418
- for (const floatingGroup of [...this.floatingGroups]) {
7109
+ for (const floatingGroup of [...this._floatingGroups]) {
6419
7110
  floatingGroup.dispose();
6420
7111
  }
6421
7112
  // fires clean-up events and clears the underlying HTML gridview.
@@ -6507,7 +7198,8 @@
6507
7198
  group.model.openPanel(panel);
6508
7199
  this.doSetGroupAndPanelActive(group);
6509
7200
  }
6510
- else if (referenceGroup.api.isFloating || target === 'center') {
7201
+ else if (referenceGroup.api.location === 'floating' ||
7202
+ target === 'center') {
6511
7203
  panel = this.createPanel(options, referenceGroup);
6512
7204
  referenceGroup.model.openPanel(panel);
6513
7205
  }
@@ -6551,6 +7243,7 @@
6551
7243
  }
6552
7244
  group.model.removePanel(panel);
6553
7245
  if (!options.skipDispose) {
7246
+ this.overlayRenderContainer.detatch(panel);
6554
7247
  panel.dispose();
6555
7248
  }
6556
7249
  if (group.size === 0 && options.removeEmptyGroup) {
@@ -6567,7 +7260,7 @@
6567
7260
  }
6568
7261
  updateWatermark() {
6569
7262
  var _a, _b;
6570
- if (this.groups.filter((x) => !x.api.isFloating).length === 0) {
7263
+ if (this.groups.filter((x) => x.api.location === 'grid').length === 0) {
6571
7264
  if (!this.watermark) {
6572
7265
  this.watermark = this.createWatermarkComponent();
6573
7266
  this.watermark.init({
@@ -6642,19 +7335,40 @@
6642
7335
  }
6643
7336
  }
6644
7337
  doRemoveGroup(group, options) {
6645
- const floatingGroup = this.floatingGroups.find((_) => _.group === group);
6646
- if (floatingGroup) {
6647
- if (!(options === null || options === void 0 ? void 0 : options.skipDispose)) {
6648
- floatingGroup.group.dispose();
6649
- this._groups.delete(group.id);
6650
- this._onDidRemoveGroup.fire(group);
7338
+ if (group.api.location === 'floating') {
7339
+ const floatingGroup = this._floatingGroups.find((_) => _.group === group);
7340
+ if (floatingGroup) {
7341
+ if (!(options === null || options === void 0 ? void 0 : options.skipDispose)) {
7342
+ floatingGroup.group.dispose();
7343
+ this._groups.delete(group.id);
7344
+ this._onDidRemoveGroup.fire(group);
7345
+ }
7346
+ remove(this._floatingGroups, floatingGroup);
7347
+ floatingGroup.dispose();
7348
+ if (!(options === null || options === void 0 ? void 0 : options.skipActive) && this._activeGroup === group) {
7349
+ const groups = Array.from(this._groups.values());
7350
+ this.doSetGroupActive(groups.length > 0 ? groups[0].value : undefined);
7351
+ }
7352
+ return floatingGroup.group;
6651
7353
  }
6652
- floatingGroup.dispose();
6653
- if (!(options === null || options === void 0 ? void 0 : options.skipActive) && this._activeGroup === group) {
6654
- const groups = Array.from(this._groups.values());
6655
- this.doSetGroupActive(groups.length > 0 ? groups[0].value : undefined);
7354
+ throw new Error('failed to find floating group');
7355
+ }
7356
+ if (group.api.location === 'popout') {
7357
+ const selectedGroup = this._popoutGroups.find((_) => _.group === group);
7358
+ if (selectedGroup) {
7359
+ if (!(options === null || options === void 0 ? void 0 : options.skipDispose)) {
7360
+ selectedGroup.group.dispose();
7361
+ this._groups.delete(group.id);
7362
+ this._onDidRemoveGroup.fire(group);
7363
+ }
7364
+ selectedGroup.dispose();
7365
+ if (!(options === null || options === void 0 ? void 0 : options.skipActive) && this._activeGroup === group) {
7366
+ const groups = Array.from(this._groups.values());
7367
+ this.doSetGroupActive(groups.length > 0 ? groups[0].value : undefined);
7368
+ }
7369
+ return selectedGroup.group;
6656
7370
  }
6657
- return floatingGroup.group;
7371
+ throw new Error('failed to find popout group');
6658
7372
  }
6659
7373
  return super.doRemoveGroup(group, options);
6660
7374
  }
@@ -6686,8 +7400,7 @@
6686
7400
  const targetLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, destinationTarget);
6687
7401
  if (sourceGroup && sourceGroup.size < 2) {
6688
7402
  const [targetParentLocation, to] = tail(targetLocation);
6689
- const isFloating = this.floatingGroups.find((x) => x.group === sourceGroup);
6690
- if (!isFloating) {
7403
+ if (sourceGroup.api.location === 'grid') {
6691
7404
  const sourceLocation = getGridLocation(sourceGroup.element);
6692
7405
  const [sourceParentLocation, from] = tail(sourceLocation);
6693
7406
  if (sequenceEquals(sourceParentLocation, targetParentLocation)) {
@@ -6733,12 +7446,25 @@
6733
7446
  }
6734
7447
  }
6735
7448
  else {
6736
- const floatingGroup = this.floatingGroups.find((x) => x.group === sourceGroup);
6737
- if (floatingGroup) {
6738
- floatingGroup.dispose();
6739
- }
6740
- else {
6741
- this.gridview.removeView(getGridLocation(sourceGroup.element));
7449
+ switch (sourceGroup.api.location) {
7450
+ case 'grid':
7451
+ this.gridview.removeView(getGridLocation(sourceGroup.element));
7452
+ break;
7453
+ case 'floating': {
7454
+ const selectedFloatingGroup = this._floatingGroups.find((x) => x.group === sourceGroup);
7455
+ if (!selectedFloatingGroup) {
7456
+ throw new Error('failed to find floating group');
7457
+ }
7458
+ selectedFloatingGroup.dispose();
7459
+ break;
7460
+ }
7461
+ case 'popout': {
7462
+ const selectedPopoutGroup = this._popoutGroups.find((x) => x.group === sourceGroup);
7463
+ if (!selectedPopoutGroup) {
7464
+ throw new Error('failed to find popout group');
7465
+ }
7466
+ selectedPopoutGroup.dispose();
7467
+ }
6742
7468
  }
6743
7469
  const referenceLocation = getGridLocation(referenceGroup.element);
6744
7470
  const dropLocation = getRelativeLocation(this.gridview.orientation, referenceLocation, target);
@@ -6800,7 +7526,7 @@
6800
7526
  const contentComponent = options.component;
6801
7527
  const tabComponent = (_a = options.tabComponent) !== null && _a !== void 0 ? _a : this.options.defaultTabComponent;
6802
7528
  const view = new DockviewPanelModel(this, options.id, contentComponent, tabComponent);
6803
- const panel = new DockviewPanel(options.id, this, this._api, group, view);
7529
+ const panel = new DockviewPanel(options.id, this, this._api, group, view, { renderer: options.renderer });
6804
7530
  panel.init({
6805
7531
  title: (_b = options.title) !== null && _b !== void 0 ? _b : options.id,
6806
7532
  params: (_c = options === null || options === void 0 ? void 0 : options.params) !== null && _c !== void 0 ? _c : {},
@@ -8146,6 +8872,8 @@
8146
8872
  singleTabMode: props.singleTabMode,
8147
8873
  disableFloatingGroups: props.disableFloatingGroups,
8148
8874
  floatingGroupBounds: props.floatingGroupBounds,
8875
+ defaultRenderer: props.defaultRenderer,
8876
+ debug: props.debug,
8149
8877
  });
8150
8878
  const { clientWidth, clientHeight } = domRef.current;
8151
8879
  dockview.layout(clientWidth, clientHeight);